info.php 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. <?php
  2. /* Copyright (C) 2005-2006 Laurent Destailleur <eldy@users.sourceforge.net>
  3. * Copyright (C) 2005-2009 Regis Houssin <regis.houssin@inodbox.com>
  4. * Copyright (C) 2017 Ferran Marcet <fmarcet@2byte.es>
  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 <https://www.gnu.org/licenses/>.
  18. */
  19. /**
  20. * \file htdocs/commande/info.php
  21. * \ingroup commande
  22. * \brief Sale Order info page
  23. */
  24. require '../main.inc.php';
  25. require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
  26. require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php';
  27. require_once DOL_DOCUMENT_ROOT.'/core/lib/order.lib.php';
  28. if (!empty($conf->project->enabled)) {
  29. require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
  30. }
  31. if (!$user->rights->commande->lire) {
  32. accessforbidden();
  33. }
  34. // Load translation files required by the page
  35. $langs->loadLangs(array('orders', 'sendings', 'bills'));
  36. $socid = 0;
  37. $comid = GETPOST("id", 'int');
  38. $id = GETPOST("id", 'int');
  39. $ref = GETPOST('ref', 'alpha');
  40. // Security check
  41. if ($user->socid) {
  42. $socid = $user->socid;
  43. }
  44. $result = restrictedArea($user, 'commande', $comid, '');
  45. $object = new Commande($db);
  46. if (!$object->fetch($id, $ref) > 0) {
  47. dol_print_error($db);
  48. exit;
  49. }
  50. /*
  51. * View
  52. */
  53. $form = new Form($db);
  54. $title = $langs->trans('Order')." - ".$langs->trans('Info');
  55. $help_url = 'EN:Customers_Orders|FR:Commandes_Clients|ES:Pedidos de clientes|DE:Modul_Kundenaufträge';
  56. llxHeader('', $title, $help_url);
  57. $object->fetch_thirdparty();
  58. $object->info($object->id);
  59. $head = commande_prepare_head($object);
  60. print dol_get_fiche_head($head, 'info', $langs->trans("CustomerOrder"), -1, 'order');
  61. // Order card
  62. $linkback = '<a href="'.DOL_URL_ROOT.'/commande/list.php?restore_lastsearch_values=1'.(!empty($socid) ? '&socid='.$socid : '').'">'.$langs->trans("BackToList").'</a>';
  63. $morehtmlref = '<div class="refidno">';
  64. // Ref customer
  65. $morehtmlref .= $form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', 0, 1);
  66. $morehtmlref .= $form->editfieldval("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', null, null, '', 1);
  67. // Thirdparty
  68. $morehtmlref .= '<br>'.$langs->trans('ThirdParty').' : '.$object->thirdparty->getNomUrl(1);
  69. // Project
  70. if (!empty($conf->project->enabled)) {
  71. $langs->load("projects");
  72. $morehtmlref .= '<br>'.$langs->trans('Project').' ';
  73. if ($user->rights->commande->creer) {
  74. if ($action != 'classify') {
  75. //$morehtmlref.='<a class="editfielda" href="' . $_SERVER['PHP_SELF'] . '?action=classify&token='.newToken().'&id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a> : ';
  76. $morehtmlref .= ' : ';
  77. }
  78. if ($action == 'classify') {
  79. //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1);
  80. $morehtmlref .= '<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">';
  81. $morehtmlref .= '<input type="hidden" name="action" value="classin">';
  82. $morehtmlref .= '<input type="hidden" name="token" value="'.newToken().'">';
  83. $morehtmlref .= $formproject->select_projects($object->thirdparty->id, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1);
  84. $morehtmlref .= '<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">';
  85. $morehtmlref .= '</form>';
  86. } else {
  87. $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->thirdparty->id, $object->fk_project, 'none', 0, 0, 0, 1);
  88. }
  89. } else {
  90. if (!empty($object->fk_project)) {
  91. $proj = new Project($db);
  92. $proj->fetch($object->fk_project);
  93. $morehtmlref .= ' : '.$proj->getNomUrl(1);
  94. if ($proj->title) {
  95. $morehtmlref .= ' - '.$proj->title;
  96. }
  97. } else {
  98. $morehtmlref .= '';
  99. }
  100. }
  101. }
  102. $morehtmlref .= '</div>';
  103. dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref);
  104. print '<div class="fichecenter">';
  105. print '<div class="underbanner clearboth"></div>';
  106. print '<br>';
  107. print '<table width="100%"><tr><td>';
  108. dol_print_object_info($object);
  109. print '</td></tr></table>';
  110. print '</div>';
  111. print dol_get_fiche_end();
  112. // End of page
  113. llxFooter();
  114. $db->close();