PageRenderTime 56ms CodeModel.GetById 28ms RepoModel.GetById 0ms app.codeStats 1ms

/htdocs/fourn/commande/info.php

http://github.com/Dolibarr/dolibarr
PHP | 245 lines | 144 code | 52 blank | 49 comment | 45 complexity | 772ea013d7852d43351096c71448eaff MD5 | raw file
Possible License(s): GPL-2.0, AGPL-3.0, LGPL-2.0, CC-BY-SA-4.0, BSD-3-Clause, MPL-2.0-no-copyleft-exception, LGPL-3.0, GPL-3.0, LGPL-2.1, MIT
  1. <?php
  2. /* Copyright (C) 2003-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
  3. * Copyright (C) 2004-2016 Laurent Destailleur <eldy@users.sourceforge.net>
  4. * Copyright (C) 2005-2012 Regis Houssin <regis.houssin@inodbox.com>
  5. * Copyright (C) 2017 Ferran Marcet <fmarcet@2byte.es>
  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 htdocs/fourn/commande/info.php
  22. * \ingroup commande
  23. * \brief Fiche commande
  24. */
  25. require '../../main.inc.php';
  26. require_once DOL_DOCUMENT_ROOT.'/core/lib/fourn.lib.php';
  27. require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
  28. require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php';
  29. require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
  30. if (!empty($conf->projet->enabled)) {
  31. require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
  32. }
  33. // Load translation files required by the page
  34. $langs->loadLangs(array("suppliers", "orders", "companies", "stocks"));
  35. $id = GETPOST('id', 'int');
  36. $ref = GETPOST('ref', 'alpha');
  37. $action = GETPOST('action', 'aZ09');
  38. $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
  39. $sortfield = GETPOST("sortfield", 'alpha');
  40. $sortorder = GETPOST("sortorder", 'alpha');
  41. $page = GETPOST("page", 'int');
  42. if (empty($page) || $page == -1) {
  43. $page = 0;
  44. } // If $page is not defined, or '' or -1
  45. $offset = $limit * $page;
  46. $pageprev = $page - 1;
  47. $pagenext = $page + 1;
  48. if (!$sortfield) {
  49. $sortfield = 'a.datep,a.id';
  50. }
  51. if (!$sortorder) {
  52. $sortorder = 'DESC,DESC';
  53. }
  54. if (GETPOST('actioncode', 'array')) {
  55. $actioncode = GETPOST('actioncode', 'array', 3);
  56. if (!count($actioncode)) {
  57. $actioncode = '0';
  58. }
  59. } else {
  60. $actioncode = GETPOST("actioncode", "alpha", 3) ?GETPOST("actioncode", "alpha", 3) : (GETPOST("actioncode") == '0' ? '0' : (empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECTS) ? '' : $conf->global->AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECTS));
  61. }
  62. $search_agenda_label = GETPOST('search_agenda_label');
  63. // Security check
  64. $socid = 0;
  65. if ($user->socid) {
  66. $socid = $user->socid;
  67. }
  68. $result = restrictedArea($user, 'fournisseur', $id, 'commande_fournisseur', 'commande');
  69. if (empty($user->rights->fournisseur->commande->lire)) {
  70. accessforbidden();
  71. }
  72. $hookmanager->initHooks(array('ordersuppliercardinfo'));
  73. /*
  74. * Actions
  75. */
  76. $parameters = array('id'=>$id);
  77. $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
  78. if ($reshook < 0) {
  79. setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
  80. }
  81. // Purge search criteria
  82. if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // All test are required to be compatible with all browsers
  83. $actioncode = '';
  84. $search_agenda_label = '';
  85. }
  86. /*
  87. * View
  88. */
  89. $form = new Form($db);
  90. $object = new CommandeFournisseur($db);
  91. if ($id > 0 || !empty($ref)) {
  92. $object->fetch($id, $ref);
  93. $object->fetch_thirdparty();
  94. $object->info($object->id);
  95. }
  96. $title = $langs->trans("SupplierOrder").' - '.$langs->trans('Info').' - '.$object->ref.' '.$object->name;
  97. if (!empty($conf->global->MAIN_HTML_TITLE) && preg_match('/projectnameonly/', $conf->global->MAIN_HTML_TITLE) && $object->name) {
  98. $title = $object->ref.' '.$object->name.' - '.$langs->trans("Info");
  99. }
  100. $help_url = 'EN:Module_Suppliers_Orders|FR:CommandeFournisseur|ES:Módulo_Pedidos_a_proveedores';
  101. llxHeader('', $title, $help_url);
  102. $now = dol_now();
  103. $head = ordersupplier_prepare_head($object);
  104. print dol_get_fiche_head($head, 'info', $langs->trans("SupplierOrder"), -1, 'order');
  105. // Supplier order card
  106. $linkback = '<a href="'.DOL_URL_ROOT.'/fourn/commande/list.php'.(!empty($socid) ? '?socid='.$socid : '').'">'.$langs->trans("BackToList").'</a>';
  107. $morehtmlref = '<div class="refidno">';
  108. // Ref supplier
  109. $morehtmlref .= $form->editfieldkey("RefSupplier", 'ref_supplier', $object->ref_supplier, $object, 0, 'string', '', 0, 1);
  110. $morehtmlref .= $form->editfieldval("RefSupplier", 'ref_supplier', $object->ref_supplier, $object, 0, 'string', '', null, null, '', 1);
  111. // Thirdparty
  112. $morehtmlref .= '<br>'.$langs->trans('ThirdParty').' : '.$object->thirdparty->getNomUrl(1);
  113. // Project
  114. if (!empty($conf->projet->enabled)) {
  115. $langs->load("projects");
  116. $morehtmlref .= '<br>'.$langs->trans('Project').' ';
  117. if ($user->rights->fournisseur->commande->creer || $user->rights->supplier_order->creer) {
  118. if ($action != 'classify') {
  119. //$morehtmlref.='<a class="editfielda" href="' . $_SERVER['PHP_SELF'] . '?action=classify&token='.newToken().'&id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a> : ';
  120. $morehtmlref .= ' : ';
  121. }
  122. if ($action == 'classify') {
  123. //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1);
  124. $morehtmlref .= '<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">';
  125. $morehtmlref .= '<input type="hidden" name="action" value="classin">';
  126. $morehtmlref .= '<input type="hidden" name="token" value="'.newToken().'">';
  127. $morehtmlref .= $formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1);
  128. $morehtmlref .= '<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">';
  129. $morehtmlref .= '</form>';
  130. } else {
  131. $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1);
  132. }
  133. } else {
  134. if (!empty($object->fk_project)) {
  135. $proj = new Project($db);
  136. $proj->fetch($object->fk_project);
  137. $morehtmlref .= ' : '.$proj->getNomUrl(1);
  138. if ($proj->title) {
  139. $morehtmlref .= ' - '.$proj->title;
  140. }
  141. } else {
  142. $morehtmlref .= '';
  143. }
  144. }
  145. }
  146. $morehtmlref .= '</div>';
  147. dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref);
  148. print '<div class="fichecenter">';
  149. print '<div class="underbanner clearboth"></div>';
  150. dol_print_object_info($object, 1);
  151. print '</div>';
  152. print '<div class="clearboth"></div>';
  153. print dol_get_fiche_end();
  154. // Actions buttons
  155. $out = '';
  156. $permok = $user->rights->agenda->myactions->create;
  157. if ($permok) {
  158. $out .= '&originid='.$object->id.'&origin=order_supplier';
  159. }
  160. print '<div class="tabsAction">';
  161. if (!empty($conf->agenda->enabled)) {
  162. if (!empty($user->rights->agenda->myactions->create) || !empty($user->rights->agenda->allactions->create)) {
  163. print '<a class="butAction" href="'.DOL_URL_ROOT.'/comm/action/card.php?action=create'.$out.'&backtopage='.urlencode($_SERVER["PHP_SELF"].'?id='.$object->id).'">'.$langs->trans("AddAction").'</a>';
  164. } else {
  165. print '<a class="butActionRefused classfortooltip" href="#">'.$langs->trans("AddAction").'</a>';
  166. }
  167. }
  168. print '</div>';
  169. if (!empty($object->id)) {
  170. $param = '&id='.$object->id;
  171. if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
  172. $param .= '&contextpage='.$contextpage;
  173. }
  174. if ($limit > 0 && $limit != $conf->liste_limit) {
  175. $param .= '&limit='.$limit;
  176. }
  177. print load_fiche_titre($langs->trans("ActionsOnOrder"), '', '');
  178. // List of actions on element
  179. /*include_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php';
  180. $formactions=new FormActions($db);
  181. $somethingshown = $formactions->showactions($object,'project',0);*/
  182. // List of todo actions
  183. //show_actions_todo($conf,$langs,$db,$object,null,0,$actioncode);
  184. // List of done actions
  185. //show_actions_done($conf,$langs,$db,$object,null,0,$actioncode, '', $filters, $sortfield, $sortorder);
  186. // List of all actions
  187. $filters = array();
  188. $filters['search_agenda_label'] = $search_agenda_label;
  189. show_actions_done($conf, $langs, $db, $object, null, 0, $actioncode, '', $filters, $sortfield, $sortorder);
  190. }
  191. // End of page
  192. llxFooter();
  193. $db->close();