order.lib.php 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. <?php
  2. /* Copyright (C) 2006-2012 Laurent Destailleur <eldy@users.sourceforge.net>
  3. * Copyright (C) 2007 Rodolphe Quiedeville <rodolphe@quiedeville.org>
  4. * Copyright (C) 2010-2012 Regis Houssin <regis.houssin@capnetworks.com>
  5. * Copyright (C) 2010 Juanjo Menent <jmenent@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 <http://www.gnu.org/licenses/>.
  19. * or see http://www.gnu.org/
  20. */
  21. /**
  22. * \file htdocs/core/lib/order.lib.php
  23. * \brief Ensemble de fonctions de base pour le module commande
  24. * \ingroup commande
  25. */
  26. /**
  27. * Prepare array with list of tabs
  28. *
  29. * @param Object $object Object related to tabs
  30. * @return array Array of tabs to shoc
  31. */
  32. function commande_prepare_head($object)
  33. {
  34. global $langs, $conf, $user;
  35. if (! empty($conf->expedition->enabled)) $langs->load("sendings");
  36. $langs->load("orders");
  37. $h = 0;
  38. $head = array();
  39. if (! empty($conf->commande->enabled) && $user->rights->commande->lire)
  40. {
  41. $head[$h][0] = DOL_URL_ROOT.'/commande/fiche.php?id='.$object->id;
  42. $head[$h][1] = $langs->trans("OrderCard");
  43. $head[$h][2] = 'order';
  44. $h++;
  45. }
  46. if (($conf->expedition_bon->enabled && $user->rights->expedition->lire)
  47. || ($conf->livraison_bon->enabled && $user->rights->expedition->livraison->lire))
  48. {
  49. $head[$h][0] = DOL_URL_ROOT.'/expedition/shipment.php?id='.$object->id;
  50. if ($conf->expedition_bon->enabled) $text=$langs->trans("Shipment");
  51. if ($conf->expedition_bon->enabled && $conf->livraison_bon->enabled) $text.='/';
  52. if ($conf->livraison_bon->enabled) $text.=$langs->trans("Receivings");
  53. $head[$h][1] = $text;
  54. $head[$h][2] = 'shipping';
  55. $h++;
  56. }
  57. if (! empty($conf->global->MAIN_USE_PREVIEW_TABS))
  58. {
  59. $head[$h][0] = DOL_URL_ROOT.'/commande/apercu.php?id='.$object->id;
  60. $head[$h][1] = $langs->trans("Preview");
  61. $head[$h][2] = 'preview';
  62. $h++;
  63. }
  64. if (empty($conf->global->MAIN_DISABLE_CONTACTS_TAB))
  65. {
  66. $head[$h][0] = DOL_URL_ROOT.'/commande/contact.php?id='.$object->id;
  67. $head[$h][1] = $langs->trans('ContactsAddresses');
  68. $head[$h][2] = 'contact';
  69. $h++;
  70. }
  71. // Show more tabs from modules
  72. // Entries must be declared in modules descriptor with line
  73. // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
  74. // $this->tabs = array('entity:-tabname); to remove a tab
  75. complete_head_from_modules($conf,$langs,$object,$head,$h,'order');
  76. if (empty($conf->global->MAIN_DISABLE_NOTES_TAB))
  77. {
  78. $nbNote = 0;
  79. if(!empty($object->note_private)) $nbNote++;
  80. if(!empty($object->note_public)) $nbNote++;
  81. $head[$h][0] = DOL_URL_ROOT.'/commande/note.php?id='.$object->id;
  82. $head[$h][1] = $langs->trans('Notes');
  83. if($nbNote > 0) $head[$h][1].= ' ('.$nbNote.')';
  84. $head[$h][2] = 'note';
  85. $h++;
  86. }
  87. require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
  88. $upload_dir = $conf->commande->dir_output . "/" . dol_sanitizeFileName($object->ref);
  89. $nbFiles = count(dol_dir_list($upload_dir,'files',0,'','(\.meta|_preview\.png)$'));
  90. $head[$h][0] = DOL_URL_ROOT.'/commande/document.php?id='.$object->id;
  91. $head[$h][1] = $langs->trans('Documents');
  92. if($nbFiles > 0) $head[$h][1].= ' ('.$nbFiles.')';
  93. $head[$h][2] = 'documents';
  94. $h++;
  95. $head[$h][0] = DOL_URL_ROOT.'/commande/info.php?id='.$object->id;
  96. $head[$h][1] = $langs->trans("Info");
  97. $head[$h][2] = 'info';
  98. $h++;
  99. complete_head_from_modules($conf,$langs,$object,$head,$h,'order','remove');
  100. return $head;
  101. }
  102. /**
  103. * Return array head with list of tabs to view object informations.
  104. *
  105. * @param Object $object order
  106. * @return array head array with tabs
  107. */
  108. function order_admin_prepare_head($object)
  109. {
  110. global $langs, $conf, $user;
  111. $h = 0;
  112. $head = array();
  113. $head[$h][0] = DOL_URL_ROOT.'/admin/commande.php';
  114. $head[$h][1] = $langs->trans("Miscellaneous");
  115. $head[$h][2] = 'general';
  116. $h++;
  117. complete_head_from_modules($conf,$langs,$object,$head,$h,'order_admin');
  118. $head[$h][0] = DOL_URL_ROOT.'/admin/order_extrafields.php';
  119. $head[$h][1] = $langs->trans("ExtraFields");
  120. $head[$h][2] = 'attributes';
  121. $h++;
  122. $head[$h][0] = DOL_URL_ROOT.'/admin/orderdet_extrafields.php';
  123. $head[$h][1] = $langs->trans("ExtraFieldsLines");
  124. $head[$h][2] = 'attributeslines';
  125. $h++;
  126. complete_head_from_modules($conf,$langs,$object,$head,$h,'order_admin','remove');
  127. return $head;
  128. }