PageRenderTime 28ms CodeModel.GetById 27ms RepoModel.GetById 0ms app.codeStats 0ms

/htdocs/fourn/commande/history.php

https://github.com/Modulaweb/dolibarr
PHP | 192 lines | 109 code | 41 blank | 42 comment | 9 complexity | f7a90486f9852e3e1756124e77a420d2 MD5 | raw file
Possible License(s): GPL-2.0, LGPL-2.0, LGPL-3.0, GPL-3.0, CC-BY-SA-4.0, LGPL-2.1, MPL-2.0-no-copyleft-exception, BSD-3-Clause
  1. <?php
  2. /* Copyright (C) 2003-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
  3. * Copyright (C) 2004-2009 Laurent Destailleur <eldy@users.sourceforge.net>
  4. * Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com>
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation; either version 3 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  18. */
  19. /**
  20. * \file htdocs/fourn/commande/history.php
  21. * \ingroup commande
  22. * \brief Fiche commande
  23. */
  24. require '../../main.inc.php';
  25. require_once DOL_DOCUMENT_ROOT.'/core/lib/fourn.lib.php';
  26. require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php';
  27. $langs->load("orders");
  28. $langs->load("suppliers");
  29. $langs->load("companies");
  30. $langs->load('stocks');
  31. $id=GETPOST('id','int');
  32. $ref=GETPOST('ref','alpha');
  33. // Security check
  34. $socid='';
  35. if (! empty($user->societe_id)) $socid=$user->societe_id;
  36. $result = restrictedArea($user, 'fournisseur', $id, '', 'commande');
  37. /*
  38. * View
  39. */
  40. $form = new Form($db);
  41. $now=dol_now();
  42. if ($id > 0 || ! empty($ref))
  43. {
  44. $soc = new Societe($db);
  45. $commande = new CommandeFournisseur($db);
  46. $result=$commande->fetch($id,$ref);
  47. if ($result >= 0)
  48. {
  49. $soc->fetch($commande->socid);
  50. $author = new User($db);
  51. $author->fetch($commande->user_author_id);
  52. llxHeader('',$langs->trans("History"),"CommandeFournisseur");
  53. $head = ordersupplier_prepare_head($commande);
  54. $title=$langs->trans("SupplierOrder");
  55. dol_fiche_head($head, 'info', $title, 0, 'order');
  56. /*
  57. * Commande
  58. */
  59. print '<table class="border" width="100%">';
  60. $linkback = '<a href="'.DOL_URL_ROOT.'/fourn/commande/liste.php'.(! empty($socid)?'?socid='.$socid:'').'">'.$langs->trans("BackToList").'</a>';
  61. // Ref
  62. print '<tr><td width="20%">'.$langs->trans("Ref").'</td>';
  63. print '<td colspan="2">';
  64. print $form->showrefnav($commande, 'ref', $linkback, 1, 'ref', 'ref');
  65. print '</td>';
  66. print '</tr>';
  67. // Fournisseur
  68. print '<tr><td>'.$langs->trans("Supplier")."</td>";
  69. print '<td colspan="2">'.$soc->getNomUrl(1,'supplier').'</td>';
  70. print '</tr>';
  71. // Statut
  72. print '<tr>';
  73. print '<td>'.$langs->trans("Status").'</td>';
  74. print '<td colspan="2">';
  75. print $commande->getLibStatut(4);
  76. print "</td></tr>";
  77. // Date
  78. if ($commande->methode_commande_id > 0)
  79. {
  80. print '<tr><td>'.$langs->trans("Date").'</td><td colspan="2">';
  81. if ($commande->date_commande)
  82. {
  83. print dol_print_date($commande->date_commande,"dayhourtext")."\n";
  84. }
  85. print "</td></tr>";
  86. if ($commande->methode_commande)
  87. {
  88. print '<tr><td>'.$langs->trans("Method").'</td><td colspan="2">'.$commande->getInputMethod().'</td></tr>';
  89. }
  90. }
  91. // Auteur
  92. print '<tr><td>'.$langs->trans("AuthorRequest").'</td>';
  93. print '<td colspan="2">'.$author->getNomUrl(1).'</td>';
  94. print '</tr>';
  95. print "</table>\n";
  96. print "<br>";
  97. /*
  98. * Suivi historique
  99. * Date - Statut - Auteur
  100. */
  101. print '<table class="noborder" width="100%">';
  102. print '<tr class="liste_titre"><td class="liste_titre">'.$langs->trans("Date").'</td>';
  103. print '<td class="liste_titre">'.$langs->trans("Status").'</td>';
  104. print '<td class="liste_titre" align="center">'.$langs->trans("Author").'</td>';
  105. print '<td class="liste_titre" align="left">'.$langs->trans("Comment").'</td>';
  106. print '</tr>';
  107. $sql = "SELECT l.fk_statut, l.datelog as dl, l.comment, u.rowid, u.login, u.firstname, u.lastname";
  108. $sql.= " FROM ".MAIN_DB_PREFIX."commande_fournisseur_log as l";
  109. $sql.= " , ".MAIN_DB_PREFIX."user as u ";
  110. $sql.= " WHERE l.fk_commande = ".$commande->id;
  111. $sql.= " AND u.rowid = l.fk_user";
  112. $sql.= " ORDER BY l.rowid DESC";
  113. $resql = $db->query($sql);
  114. if ($resql)
  115. {
  116. $num = $db->num_rows($resql);
  117. $i = 0;
  118. $var=True;
  119. while ($i < $num)
  120. {
  121. $var=!$var;
  122. $obj = $db->fetch_object($resql);
  123. print "<tr ".$bc[$var].">";
  124. print '<td width="20%">'.dol_print_date($db->jdate($obj->dl),"dayhour")."</td>\n";
  125. // Statut
  126. print '<td class="nowrap">'.$commande->LibStatut($obj->fk_statut,4)."</td>\n";
  127. // User
  128. print '<td align="center"><a href="'.DOL_URL_ROOT.'/user/fiche.php?id='.$obj->rowid.'">';
  129. print img_object($langs->trans("ShowUser"),'user').' '.$obj->login.'</a></td>';
  130. // Comment
  131. print '<td class="nowrap" title="'.dol_escape_htmltag($obj->comment).'">'.dol_trunc($obj->comment,48)."</td>\n";
  132. print '</tr>';
  133. $i++;
  134. }
  135. $db->free($resql);
  136. }
  137. else
  138. {
  139. dol_print_error($db);
  140. }
  141. print "</table>";
  142. print '</div>';
  143. }
  144. else
  145. {
  146. /* Commande non trouvee */
  147. print "Commande inexistante ou acces refuse";
  148. }
  149. }
  150. llxFooter();
  151. $db->close();