order.lib.php 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  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 Commande $object Object related to tabs
  30. * @return array Array of tabs to show
  31. */
  32. function commande_prepare_head(Commande $object)
  33. {
  34. global $db, $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/card.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("Shipments");
  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_DISABLE_CONTACTS_TAB))
  58. {
  59. $nbContact = count($object->liste_contact(-1,'internal')) + count($object->liste_contact(-1,'external'));
  60. $head[$h][0] = DOL_URL_ROOT.'/commande/contact.php?id='.$object->id;
  61. $head[$h][1] = $langs->trans('ContactsAddresses');
  62. if ($nbContact > 0) $head[$h][1].= ' <span class="badge">'.$nbContact.'</span>';
  63. $head[$h][2] = 'contact';
  64. $h++;
  65. }
  66. // Show more tabs from modules
  67. // Entries must be declared in modules descriptor with line
  68. // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
  69. // $this->tabs = array('entity:-tabname); to remove a tab
  70. complete_head_from_modules($conf,$langs,$object,$head,$h,'order');
  71. if (empty($conf->global->MAIN_DISABLE_NOTES_TAB))
  72. {
  73. $nbNote = 0;
  74. if(!empty($object->note_private)) $nbNote++;
  75. if(!empty($object->note_public)) $nbNote++;
  76. $head[$h][0] = DOL_URL_ROOT.'/commande/note.php?id='.$object->id;
  77. $head[$h][1] = $langs->trans('Notes');
  78. if ($nbNote > 0) $head[$h][1].= ' <span class="badge">'.$nbNote.'</span>';
  79. $head[$h][2] = 'note';
  80. $h++;
  81. }
  82. require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
  83. require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php';
  84. $upload_dir = $conf->commande->dir_output . "/" . dol_sanitizeFileName($object->ref);
  85. $nbFiles = count(dol_dir_list($upload_dir,'files',0,'','(\.meta|_preview.*\.png)$'));
  86. $nbLinks=Link::count($db, $object->element, $object->id);
  87. $head[$h][0] = DOL_URL_ROOT.'/commande/document.php?id='.$object->id;
  88. $head[$h][1] = $langs->trans('Documents');
  89. if (($nbFiles+$nbLinks) > 0) $head[$h][1].= ' <span class="badge">'.($nbFiles+$nbLinks).'</span>';
  90. $head[$h][2] = 'documents';
  91. $h++;
  92. $head[$h][0] = DOL_URL_ROOT.'/commande/info.php?id='.$object->id;
  93. $head[$h][1] = $langs->trans("Info");
  94. $head[$h][2] = 'info';
  95. $h++;
  96. complete_head_from_modules($conf,$langs,$object,$head,$h,'order','remove');
  97. return $head;
  98. }
  99. /**
  100. * Return array head with list of tabs to view object informations.
  101. *
  102. * @return array head array with tabs
  103. */
  104. function order_admin_prepare_head()
  105. {
  106. global $langs, $conf, $user;
  107. $h = 0;
  108. $head = array();
  109. $head[$h][0] = DOL_URL_ROOT.'/admin/commande.php';
  110. $head[$h][1] = $langs->trans("Miscellaneous");
  111. $head[$h][2] = 'general';
  112. $h++;
  113. complete_head_from_modules($conf,$langs,null,$head,$h,'order_admin');
  114. $head[$h][0] = DOL_URL_ROOT.'/admin/order_extrafields.php';
  115. $head[$h][1] = $langs->trans("ExtraFields");
  116. $head[$h][2] = 'attributes';
  117. $h++;
  118. $head[$h][0] = DOL_URL_ROOT.'/admin/orderdet_extrafields.php';
  119. $head[$h][1] = $langs->trans("ExtraFieldsLines");
  120. $head[$h][2] = 'attributeslines';
  121. $h++;
  122. complete_head_from_modules($conf,$langs,null,$head,$h,'order_admin','remove');
  123. return $head;
  124. }