info.php 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242
  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 Info page for Purchase Order / Supplier Order
  24. */
  25. // Load Dolibarr environment
  26. require '../../main.inc.php';
  27. require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
  28. require_once DOL_DOCUMENT_ROOT.'/core/lib/fourn.lib.php';
  29. require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
  30. require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php';
  31. if (isModEnabled('project')) {
  32. require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
  33. }
  34. // Load translation files required by the page
  35. $langs->loadLangs(array("suppliers", "orders", "companies", "stocks"));
  36. // Get Paramters
  37. $id = GETPOST('id', 'int');
  38. $ref = GETPOST('ref', 'alpha');
  39. $action = GETPOST('action', 'aZ09');
  40. $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
  41. $sortfield = GETPOST('sortfield', 'aZ09comma');
  42. $sortorder = GETPOST('sortorder', 'aZ09comma');
  43. $page = GETPOST("page", 'int');
  44. if (empty($page) || $page == -1) {
  45. $page = 0;
  46. } // If $page is not defined, or '' or -1
  47. $offset = $limit * $page;
  48. $pageprev = $page - 1;
  49. $pagenext = $page + 1;
  50. if (!$sortfield) {
  51. $sortfield = 'a.datep,a.id';
  52. }
  53. if (!$sortorder) {
  54. $sortorder = 'DESC,DESC';
  55. }
  56. if (GETPOST('actioncode', 'array')) {
  57. $actioncode = GETPOST('actioncode', 'array', 3);
  58. if (!count($actioncode)) {
  59. $actioncode = '0';
  60. }
  61. } else {
  62. $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));
  63. }
  64. $search_rowid = GETPOST('search_rowid');
  65. $search_agenda_label = GETPOST('search_agenda_label');
  66. // Security check
  67. $socid = 0;
  68. if ($user->socid) {
  69. $socid = $user->socid;
  70. }
  71. $result = restrictedArea($user, 'fournisseur', $id, 'commande_fournisseur', 'commande');
  72. if (empty($user->rights->fournisseur->commande->lire)) {
  73. accessforbidden();
  74. }
  75. // Init Hooks
  76. $hookmanager->initHooks(array('ordersuppliercardinfo'));
  77. $usercancreate = ($user->rights->fournisseur->commande->creer || $user->rights->supplier_order->creer);
  78. $permissiontoadd = $usercancreate; // Used by the include of actions_addupdatedelete.inc.php
  79. /*
  80. * Actions
  81. */
  82. $parameters = array('id'=>$id);
  83. $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
  84. if ($reshook < 0) {
  85. setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
  86. }
  87. // Purge search criteria
  88. 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
  89. $actioncode = '';
  90. $search_agenda_label = '';
  91. }
  92. /*
  93. * View
  94. */
  95. $form = new Form($db);
  96. $object = new CommandeFournisseur($db);
  97. if ($id > 0 || !empty($ref)) {
  98. $object->fetch($id, $ref);
  99. $object->fetch_thirdparty();
  100. $object->info($object->id);
  101. }
  102. $title = $object->ref.' - '.$langs->trans('Info').' - '.$object->ref.' '.$object->name;
  103. if (!empty($conf->global->MAIN_HTML_TITLE) && preg_match('/projectnameonly/', $conf->global->MAIN_HTML_TITLE) && $object->name) {
  104. $title = $object->ref.' '.$object->name.' - '.$langs->trans("Info");
  105. }
  106. $help_url = 'EN:Module_Suppliers_Orders|FR:CommandeFournisseur|ES:Módulo_Pedidos_a_proveedores';
  107. llxHeader('', $title, $help_url);
  108. $now = dol_now();
  109. $head = ordersupplier_prepare_head($object);
  110. print dol_get_fiche_head($head, 'info', $langs->trans("SupplierOrder"), -1, 'order');
  111. // Supplier order card
  112. $linkback = '<a href="'.DOL_URL_ROOT.'/fourn/commande/list.php'.(!empty($socid) ? '?socid='.$socid : '').'">'.$langs->trans("BackToList").'</a>';
  113. $morehtmlref = '<div class="refidno">';
  114. // Ref supplier
  115. $morehtmlref .= $form->editfieldkey("RefSupplier", 'ref_supplier', $object->ref_supplier, $object, 0, 'string', '', 0, 1);
  116. $morehtmlref .= $form->editfieldval("RefSupplier", 'ref_supplier', $object->ref_supplier, $object, 0, 'string', '', null, null, '', 1);
  117. // Thirdparty
  118. $morehtmlref .= '<br>'.$object->thirdparty->getNomUrl(1);
  119. // Project
  120. if (isModEnabled('project')) {
  121. $langs->load("projects");
  122. $morehtmlref .= '<br>';
  123. if (0) {
  124. $morehtmlref .= img_picto($langs->trans("Project"), 'project', 'class="pictofixedwidth"');
  125. if ($action != 'classify' && $caneditproject) {
  126. $morehtmlref .= '<a class="editfielda" href="'.$_SERVER['PHP_SELF'].'?action=classify&token='.newToken().'&id='.$object->id.'">'.img_edit($langs->transnoentitiesnoconv('SetProject')).'</a> ';
  127. }
  128. $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, (empty($conf->global->PROJECT_CAN_ALWAYS_LINK_TO_ALL_SUPPLIERS) ? $object->socid : -1), $object->fk_project, ($action == 'classify' ? 'projectid' : 'none'), 0, 0, 0, 1, '', 'maxwidth300');
  129. } else {
  130. if (!empty($object->fk_project)) {
  131. $proj = new Project($db);
  132. $proj->fetch($object->fk_project);
  133. $morehtmlref .= $proj->getNomUrl(1);
  134. if ($proj->title) {
  135. $morehtmlref .= '<span class="opacitymedium"> - '.dol_escape_htmltag($proj->title).'</span>';
  136. }
  137. }
  138. }
  139. }
  140. $morehtmlref .= '</div>';
  141. dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref);
  142. print '<div class="fichecenter">';
  143. print '<div class="underbanner clearboth"></div>';
  144. dol_print_object_info($object, 1);
  145. print '</div>';
  146. print '<div class="clearboth"></div>';
  147. print dol_get_fiche_end();
  148. // Actions buttons
  149. $out = '';
  150. $permok = $user->rights->agenda->myactions->create;
  151. if ($permok) {
  152. $out .= '&originid='.$object->id.'&origin=order_supplier';
  153. }
  154. print '<div class="tabsAction">';
  155. if (isModEnabled('agenda')) {
  156. if ($user->hasRight('agenda', 'myactions', 'create') || $user->hasRight('agenda', 'allactions', 'create')) {
  157. 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>';
  158. } else {
  159. print '<a class="butActionRefused classfortooltip" href="#">'.$langs->trans("AddAction").'</a>';
  160. }
  161. }
  162. print '</div>';
  163. if (!empty($object->id)) {
  164. $param = '&id='.$object->id;
  165. if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
  166. $param .= '&contextpage='.$contextpage;
  167. }
  168. if ($limit > 0 && $limit != $conf->liste_limit) {
  169. $param .= '&limit='.$limit;
  170. }
  171. print load_fiche_titre($langs->trans("ActionsOnOrder"), '', '');
  172. // List of actions on element
  173. /*include_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php';
  174. $formactions=new FormActions($db);
  175. $somethingshown = $formactions->showactions($object,'project',0);*/
  176. // List of todo actions
  177. //show_actions_todo($conf,$langs,$db,$object,null,0,$actioncode);
  178. // List of done actions
  179. //show_actions_done($conf,$langs,$db,$object,null,0,$actioncode, '', $filters, $sortfield, $sortorder);
  180. // List of all actions
  181. $filters = array();
  182. $filters['search_agenda_label'] = $search_agenda_label;
  183. $filters['search_rowid'] = $search_rowid;
  184. show_actions_done($conf, $langs, $db, $object, null, 0, $actioncode, '', $filters, $sortfield, $sortorder);
  185. }
  186. // End of page
  187. llxFooter();
  188. $db->close();