fourn.lib.php 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  1. <?php
  2. /* Copyright (C) 2005-2009 Laurent Destailleur <eldy@users.sourceforge.net>
  3. * Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com>
  4. * Copyright (C) 2006 Marc Barilley <marc@ocebo.com>
  5. * Copyright (C) 2011-2013 Philippe Grand <philippe.grand@atoo-net.com>
  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/fourn.lib.php
  23. * \brief Functions used by supplier invoice module
  24. * \ingroup supplier
  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 facturefourn_prepare_head($object)
  33. {
  34. global $langs, $conf;
  35. $h = 0;
  36. $head = array();
  37. $head[$h][0] = DOL_URL_ROOT.'/fourn/facture/fiche.php?facid='.$object->id;
  38. $head[$h][1] = $langs->trans('CardBill');
  39. $head[$h][2] = 'card';
  40. $h++;
  41. if (empty($conf->global->MAIN_DISABLE_CONTACTS_TAB))
  42. {
  43. $head[$h][0] = DOL_URL_ROOT.'/fourn/facture/contact.php?facid='.$object->id;
  44. $head[$h][1] = $langs->trans('ContactsAddresses');
  45. $head[$h][2] = 'contact';
  46. $h++;
  47. }
  48. // Show more tabs from modules
  49. // Entries must be declared in modules descriptor with line
  50. // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
  51. // $this->tabs = array('entity:-tabname); to remove a tab
  52. complete_head_from_modules($conf,$langs,$object,$head,$h,'supplier_invoice');
  53. if (empty($conf->global->MAIN_DISABLE_NOTES_TAB))
  54. {
  55. $nbNote = 0;
  56. if(!empty($object->note_private)) $nbNote++;
  57. if(!empty($object->note_public)) $nbNote++;
  58. $head[$h][0] = DOL_URL_ROOT.'/fourn/facture/note.php?facid='.$object->id;
  59. $head[$h][1] = $langs->trans('Notes');
  60. if($nbNote > 0) $head[$h][1].= ' ('.$nbNote.')';
  61. $head[$h][2] = 'note';
  62. $h++;
  63. }
  64. require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
  65. $upload_dir = $conf->fournisseur->facture->dir_output.'/'.get_exdir($object->id,2).$object->ref;
  66. $nbFiles = count(dol_dir_list($upload_dir,'files',0,'','(\.meta|_preview\.png)$'));
  67. $head[$h][0] = DOL_URL_ROOT.'/fourn/facture/document.php?facid='.$object->id;
  68. $head[$h][1] = $langs->trans('Documents');
  69. if($nbFiles > 0) $head[$h][1].= ' ('.$nbFiles.')';
  70. $head[$h][2] = 'documents';
  71. $h++;
  72. $head[$h][0] = DOL_URL_ROOT.'/fourn/facture/info.php?facid='.$object->id;
  73. $head[$h][1] = $langs->trans('Info');
  74. $head[$h][2] = 'info';
  75. $h++;
  76. complete_head_from_modules($conf,$langs,$object,$head,$h,'supplier_invoice','remove');
  77. return $head;
  78. }
  79. /**
  80. * Prepare array with list of tabs
  81. *
  82. * @param Object $object Object related to tabs
  83. * @return array Array of tabs to shoc
  84. */
  85. function ordersupplier_prepare_head($object)
  86. {
  87. global $langs, $conf;
  88. $h = 0;
  89. $head = array();
  90. $head[$h][0] = DOL_URL_ROOT.'/fourn/commande/fiche.php?id='.$object->id;
  91. $head[$h][1] = $langs->trans("OrderCard");
  92. $head[$h][2] = 'card';
  93. $h++;
  94. if (! empty($conf->stock->enabled) && ! empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER))
  95. {
  96. $langs->load("stocks");
  97. $head[$h][0] = DOL_URL_ROOT.'/fourn/commande/dispatch.php?id='.$object->id;
  98. $head[$h][1] = $langs->trans("OrderDispatch");
  99. $head[$h][2] = 'dispatch';
  100. $h++;
  101. }
  102. if (empty($conf->global->MAIN_DISABLE_CONTACTS_TAB))
  103. {
  104. $head[$h][0] = DOL_URL_ROOT.'/fourn/commande/contact.php?id='.$object->id;
  105. $head[$h][1] = $langs->trans('ContactsAddresses');
  106. $head[$h][2] = 'contact';
  107. $h++;
  108. }
  109. // Show more tabs from modules
  110. // Entries must be declared in modules descriptor with line
  111. // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
  112. // $this->tabs = array('entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to remove a tab
  113. complete_head_from_modules($conf,$langs,$object,$head,$h,'supplier_order');
  114. if (empty($conf->global->MAIN_DISABLE_NOTES_TAB))
  115. {
  116. $nbNote = 0;
  117. if(!empty($object->note_private)) $nbNote++;
  118. if(!empty($object->note_public)) $nbNote++;
  119. $head[$h][0] = DOL_URL_ROOT.'/fourn/commande/note.php?id='.$object->id;
  120. $head[$h][1] = $langs->trans("Notes");
  121. if($nbNote > 0) $head[$h][1].= ' ('.$nbNote.')';
  122. $head[$h][2] = 'note';
  123. $h++;
  124. }
  125. require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
  126. $upload_dir = $conf->fournisseur->dir_output . "/commande/" . dol_sanitizeFileName($object->ref);
  127. $nbFiles = count(dol_dir_list($upload_dir,'files',0,'','(\.meta|_preview\.png)$'));
  128. $head[$h][0] = DOL_URL_ROOT.'/fourn/commande/document.php?id='.$object->id;
  129. $head[$h][1] = $langs->trans('Documents');
  130. if($nbFiles > 0) $head[$h][1].= ' ('.$nbFiles.')';
  131. $head[$h][2] = 'documents';
  132. $h++;
  133. $head[$h][0] = DOL_URL_ROOT.'/fourn/commande/history.php?id='.$object->id;
  134. $head[$h][1] = $langs->trans("OrderFollow");
  135. $head[$h][2] = 'info';
  136. $h++;
  137. return $head;
  138. }
  139. /**
  140. * Return array head with list of tabs to view object informations.
  141. *
  142. * @param Object $object order
  143. * @return array head array with tabs
  144. */
  145. function supplierorder_admin_prepare_head($object)
  146. {
  147. global $langs, $conf, $user;
  148. $h = 0;
  149. $head = array();
  150. $head[$h][0] = DOL_URL_ROOT."/admin/supplier_order.php";
  151. $head[$h][1] = $langs->trans("SupplierOrder");
  152. $head[$h][2] = 'order';
  153. $h++;
  154. $head[$h][0] = DOL_URL_ROOT."/admin/supplier_invoice.php";
  155. $head[$h][1] = $langs->trans("SuppliersInvoice");
  156. $head[$h][2] = 'invoice';
  157. $h++;
  158. complete_head_from_modules($conf,$langs,$object,$head,$h,'supplierorder_admin');
  159. $head[$h][0] = DOL_URL_ROOT.'/admin/supplierorder_extrafields.php';
  160. $head[$h][1] = $langs->trans("ExtraFieldsSupplierOrders");
  161. $head[$h][2] = 'supplierorder';
  162. $h++;
  163. $head[$h][0] = DOL_URL_ROOT.'/admin/supplierinvoice_extrafields.php';
  164. $head[$h][1] = $langs->trans("ExtraFieldsSupplierInvoices");
  165. $head[$h][2] = 'supplierinvoice';
  166. $h++;
  167. complete_head_from_modules($conf,$langs,$object,$head,$h,'supplierorder_admin','remove');
  168. return $head;
  169. }