fourn.lib.php 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231
  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 show
  31. */
  32. function facturefourn_prepare_head($object)
  33. {
  34. global $db, $langs, $conf;
  35. $h = 0;
  36. $head = array();
  37. $head[$h][0] = DOL_URL_ROOT.'/fourn/facture/card.php?facid='.$object->id;
  38. $head[$h][1] = $langs->trans('Card');
  39. $head[$h][2] = 'card';
  40. $h++;
  41. if (empty($conf->global->MAIN_DISABLE_CONTACTS_TAB))
  42. {
  43. $nbContact = count($object->liste_contact(-1,'internal')) + count($object->liste_contact(-1,'external'));
  44. $head[$h][0] = DOL_URL_ROOT.'/fourn/facture/contact.php?facid='.$object->id;
  45. $head[$h][1] = $langs->trans('ContactsAddresses');
  46. if ($nbContact > 0) $head[$h][1].= ' <span class="badge">'.$nbContact.'</span>';
  47. $head[$h][2] = 'contact';
  48. $h++;
  49. }
  50. // Show more tabs from modules
  51. // Entries must be declared in modules descriptor with line
  52. // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
  53. // $this->tabs = array('entity:-tabname); to remove a tab
  54. complete_head_from_modules($conf,$langs,$object,$head,$h,'supplier_invoice');
  55. if (empty($conf->global->MAIN_DISABLE_NOTES_TAB))
  56. {
  57. $nbNote = 0;
  58. if(!empty($object->note_private)) $nbNote++;
  59. if(!empty($object->note_public)) $nbNote++;
  60. $head[$h][0] = DOL_URL_ROOT.'/fourn/facture/note.php?facid='.$object->id;
  61. $head[$h][1] = $langs->trans('Notes');
  62. if ($nbNote > 0) $head[$h][1].= ' <span class="badge">'.$nbNote.'</span>';
  63. $head[$h][2] = 'note';
  64. $h++;
  65. }
  66. require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
  67. require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php';
  68. $upload_dir = $conf->fournisseur->facture->dir_output.'/'.get_exdir($object->id,2,0,0,$object,'invoice_supplier').$object->ref;
  69. $nbFiles = count(dol_dir_list($upload_dir,'files',0,'','(\.meta|_preview.*\.png)$'));
  70. $nbLinks=Link::count($db, $object->element, $object->id);
  71. $head[$h][0] = DOL_URL_ROOT.'/fourn/facture/document.php?facid='.$object->id;
  72. $head[$h][1] = $langs->trans('Documents');
  73. if (($nbFiles+$nbLinks) > 0) $head[$h][1].= ' <span class="badge">'.($nbFiles+$nbLinks).'</span>';
  74. $head[$h][2] = 'documents';
  75. $h++;
  76. $head[$h][0] = DOL_URL_ROOT.'/fourn/facture/info.php?facid='.$object->id;
  77. $head[$h][1] = $langs->trans('Info');
  78. $head[$h][2] = 'info';
  79. $h++;
  80. complete_head_from_modules($conf,$langs,$object,$head,$h,'supplier_invoice','remove');
  81. return $head;
  82. }
  83. /**
  84. * Prepare array with list of tabs
  85. *
  86. * @param Object $object Object related to tabs
  87. * @return array Array of tabs to show
  88. */
  89. function ordersupplier_prepare_head($object)
  90. {
  91. global $db, $langs, $conf, $user;
  92. $h = 0;
  93. $head = array();
  94. $head[$h][0] = DOL_URL_ROOT.'/fourn/commande/card.php?id='.$object->id;
  95. $head[$h][1] = $langs->trans("OrderCard");
  96. $head[$h][2] = 'card';
  97. $h++;
  98. if (! empty($conf->stock->enabled) && ! empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER))
  99. {
  100. $langs->load("stocks");
  101. $head[$h][0] = DOL_URL_ROOT.'/fourn/commande/dispatch.php?id='.$object->id;
  102. $head[$h][1] = $langs->trans("OrderDispatch");
  103. $head[$h][2] = 'dispatch';
  104. $h++;
  105. }
  106. if (empty($conf->global->MAIN_DISABLE_CONTACTS_TAB))
  107. {
  108. $nbContact = count($object->liste_contact(-1,'internal')) + count($object->liste_contact(-1,'external'));
  109. $head[$h][0] = DOL_URL_ROOT.'/fourn/commande/contact.php?id='.$object->id;
  110. $head[$h][1] = $langs->trans('ContactsAddresses');
  111. if ($nbContact > 0) $head[$h][1].= ' <span class="badge">'.$nbContact.'</span>';
  112. $head[$h][2] = 'contact';
  113. $h++;
  114. }
  115. // Show more tabs from modules
  116. // Entries must be declared in modules descriptor with line
  117. // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
  118. // $this->tabs = array('entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to remove a tab
  119. complete_head_from_modules($conf,$langs,$object,$head,$h,'supplier_order');
  120. if (empty($conf->global->MAIN_DISABLE_NOTES_TAB))
  121. {
  122. $nbNote = 0;
  123. if(!empty($object->note_private)) $nbNote++;
  124. if(!empty($object->note_public)) $nbNote++;
  125. $head[$h][0] = DOL_URL_ROOT.'/fourn/commande/note.php?id='.$object->id;
  126. $head[$h][1] = $langs->trans("Notes");
  127. if ($nbNote > 0) $head[$h][1].= ' <span class="badge">'.$nbNote.'</span>';
  128. $head[$h][2] = 'note';
  129. $h++;
  130. }
  131. require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
  132. require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php';
  133. $upload_dir = $conf->fournisseur->dir_output . "/commande/" . dol_sanitizeFileName($object->ref);
  134. $nbFiles = count(dol_dir_list($upload_dir,'files',0,'','(\.meta|_preview.*\.png)$'));
  135. $nbLinks=Link::count($db, $object->element, $object->id);
  136. $head[$h][0] = DOL_URL_ROOT.'/fourn/commande/document.php?id='.$object->id;
  137. $head[$h][1] = $langs->trans('Documents');
  138. if (($nbFiles+$nbLinks) > 0) $head[$h][1].= ' <span class="badge">'.($nbFiles+$nbLinks).'</span>';
  139. $head[$h][2] = 'documents';
  140. $h++;
  141. $head[$h][0] = DOL_URL_ROOT.'/fourn/commande/info.php?id='.$object->id;
  142. $head[$h][1].= $langs->trans("Events");
  143. if (! empty($conf->agenda->enabled) && (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read) ))
  144. {
  145. $head[$h][1].= '/';
  146. $head[$h][1].= $langs->trans("Agenda");
  147. }
  148. $head[$h][2] = 'info';
  149. $h++;
  150. complete_head_from_modules($conf,$langs,$object,$head,$h,'supplier_order', 'remove');
  151. return $head;
  152. }
  153. /**
  154. * Return array head with list of tabs to view object informations.
  155. *
  156. * @return array head array with tabs
  157. */
  158. function supplierorder_admin_prepare_head()
  159. {
  160. global $langs, $conf, $user;
  161. $h = 0;
  162. $head = array();
  163. $head[$h][0] = DOL_URL_ROOT."/admin/supplier_order.php";
  164. $head[$h][1] = $langs->trans("SupplierOrder");
  165. $head[$h][2] = 'order';
  166. $h++;
  167. $head[$h][0] = DOL_URL_ROOT."/admin/supplier_invoice.php";
  168. $head[$h][1] = $langs->trans("SuppliersInvoice");
  169. $head[$h][2] = 'invoice';
  170. $h++;
  171. $head[$h][0] = DOL_URL_ROOT."/admin/supplier_payment.php";
  172. $head[$h][1] = $langs->trans("SuppliersPayment");
  173. $head[$h][2] = 'supplierpayment';
  174. $h++;
  175. complete_head_from_modules($conf,$langs,null,$head,$h,'supplierorder_admin');
  176. $head[$h][0] = DOL_URL_ROOT.'/admin/supplierorder_extrafields.php';
  177. $head[$h][1] = $langs->trans("ExtraFieldsSupplierOrders");
  178. $head[$h][2] = 'supplierorder';
  179. $h++;
  180. $head[$h][0] = DOL_URL_ROOT.'/admin/supplierorderdet_extrafields.php';
  181. $head[$h][1] = $langs->trans("ExtraFieldsSupplierOrdersLines");
  182. $head[$h][2] = 'supplierorderdet';
  183. $h++;
  184. $head[$h][0] = DOL_URL_ROOT.'/admin/supplierinvoice_extrafields.php';
  185. $head[$h][1] = $langs->trans("ExtraFieldsSupplierInvoices");
  186. $head[$h][2] = 'supplierinvoice';
  187. $h++;
  188. $head[$h][0] = DOL_URL_ROOT.'/admin/supplierinvoicedet_extrafields.php';
  189. $head[$h][1] = $langs->trans("ExtraFieldsSupplierInvoicesLines");
  190. $head[$h][2] = 'supplierinvoicedet';
  191. $h++;
  192. complete_head_from_modules($conf,$langs,null,$head,$h,'supplierorder_admin','remove');
  193. return $head;
  194. }