1<?php 2/* Copyright (C) 2005-2009 Laurent Destailleur <eldy@users.sourceforge.net> 3 * Copyright (C) 2005-2012 Regis Houssin <regis.houssin@inodbox.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 <https://www.gnu.org/licenses/>. 19 * or see https://www.gnu.org/ 20 */ 21 22/** 23 * \file htdocs/core/lib/fourn.lib.php 24 * \brief Functions used by supplier invoice module 25 * \ingroup supplier 26 */ 27 28/** 29 * Prepare array with list of tabs 30 * 31 * @param Object $object Object related to tabs 32 * @return array Array of tabs to show 33 */ 34function facturefourn_prepare_head($object) 35{ 36 global $db, $langs, $conf; 37 38 $h = 0; 39 $head = array(); 40 41 $head[$h][0] = DOL_URL_ROOT.'/fourn/facture/card.php?facid='.$object->id; 42 $head[$h][1] = $langs->trans('SupplierInvoice'); 43 $head[$h][2] = 'card'; 44 $h++; 45 46 if (empty($conf->global->MAIN_DISABLE_CONTACTS_TAB)) { 47 $nbContact = count($object->liste_contact(-1, 'internal')) + count($object->liste_contact(-1, 'external')); 48 $head[$h][0] = DOL_URL_ROOT.'/fourn/facture/contact.php?facid='.$object->id; 49 $head[$h][1] = $langs->trans('ContactsAddresses'); 50 if ($nbContact > 0) { 51 $head[$h][1] .= '<span class="badge marginleftonlyshort">'.$nbContact.'</span>'; 52 } 53 $head[$h][2] = 'contact'; 54 $h++; 55 } 56 57 //if ($fac->mode_reglement_code == 'PRE') 58 if (!empty($conf->paymentbybanktransfer->enabled)) { 59 $nbStandingOrders = 0; 60 $sql = "SELECT COUNT(pfd.rowid) as nb"; 61 $sql .= " FROM ".MAIN_DB_PREFIX."prelevement_facture_demande as pfd"; 62 $sql .= " WHERE pfd.fk_facture_fourn = ".((int) $object->id); 63 $sql .= " AND pfd.ext_payment_id IS NULL"; 64 $resql = $db->query($sql); 65 if ($resql) { 66 $obj = $db->fetch_object($resql); 67 if ($obj) { 68 $nbStandingOrders = $obj->nb; 69 } 70 } else { 71 dol_print_error($db); 72 } 73 $head[$h][0] = DOL_URL_ROOT.'/compta/facture/prelevement.php?facid='.$object->id.'&type=bank-transfer'; 74 $head[$h][1] = $langs->trans('BankTransfer'); 75 if ($nbStandingOrders > 0) { 76 $head[$h][1] .= '<span class="badge marginleftonlyshort">'.$nbStandingOrders.'</span>'; 77 } 78 $head[$h][2] = 'standingorders'; 79 $h++; 80 } 81 82 // Show more tabs from modules 83 // Entries must be declared in modules descriptor with line 84 // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab 85 // $this->tabs = array('entity:-tabname); to remove a tab 86 complete_head_from_modules($conf, $langs, $object, $head, $h, 'supplier_invoice'); 87 88 if (empty($conf->global->MAIN_DISABLE_NOTES_TAB)) { 89 $nbNote = 0; 90 if (!empty($object->note_private)) { 91 $nbNote++; 92 } 93 if (!empty($object->note_public)) { 94 $nbNote++; 95 } 96 $head[$h][0] = DOL_URL_ROOT.'/fourn/facture/note.php?facid='.$object->id; 97 $head[$h][1] = $langs->trans('Notes'); 98 if ($nbNote > 0) { 99 $head[$h][1] .= '<span class="badge marginleftonlyshort">'.$nbNote.'</span>'; 100 } 101 $head[$h][2] = 'note'; 102 $h++; 103 } 104 105 require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; 106 require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php'; 107 $upload_dir = $conf->fournisseur->facture->dir_output.'/'.get_exdir($object->id, 2, 0, 0, $object, 'invoice_supplier').$object->ref; 108 $nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png)$')); 109 $nbLinks = Link::count($db, $object->element, $object->id); 110 $head[$h][0] = DOL_URL_ROOT.'/fourn/facture/document.php?facid='.$object->id; 111 $head[$h][1] = $langs->trans('Documents'); 112 if (($nbFiles + $nbLinks) > 0) { 113 $head[$h][1] .= '<span class="badge marginleftonlyshort">'.($nbFiles + $nbLinks).'</span>'; 114 } 115 $head[$h][2] = 'documents'; 116 $h++; 117 118 $head[$h][0] = DOL_URL_ROOT.'/fourn/facture/info.php?facid='.$object->id; 119 $head[$h][1] = $langs->trans('Info'); 120 $head[$h][2] = 'info'; 121 $h++; 122 123 complete_head_from_modules($conf, $langs, $object, $head, $h, 'supplier_invoice', 'remove'); 124 125 return $head; 126} 127 128 129/** 130 * Prepare array with list of tabs 131 * 132 * @param Object $object Object related to tabs 133 * @return array Array of tabs to show 134 */ 135function ordersupplier_prepare_head($object) 136{ 137 global $db, $langs, $conf, $user; 138 139 $h = 0; 140 $head = array(); 141 142 $head[$h][0] = DOL_URL_ROOT.'/fourn/commande/card.php?id='.$object->id; 143 $head[$h][1] = $langs->trans("SupplierOrder"); 144 $head[$h][2] = 'card'; 145 $h++; 146 147 if (empty($conf->global->MAIN_DISABLE_CONTACTS_TAB)) { 148 $nbContact = count($object->liste_contact(-1, 'internal')) + count($object->liste_contact(-1, 'external')); 149 $head[$h][0] = DOL_URL_ROOT.'/fourn/commande/contact.php?id='.$object->id; 150 $head[$h][1] = $langs->trans('ContactsAddresses'); 151 if ($nbContact > 0) { 152 $head[$h][1] .= '<span class="badge marginleftonlyshort">'.$nbContact.'</span>'; 153 } 154 $head[$h][2] = 'contact'; 155 $h++; 156 } 157 158 if (!empty($conf->stock->enabled) && (!empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER) || !empty($conf->global->STOCK_CALCULATE_ON_RECEPTION) || !empty($conf->global->STOCK_CALCULATE_ON_RECEPTION_CLOSE))) { 159 $langs->load("stocks"); 160 $head[$h][0] = DOL_URL_ROOT.'/fourn/commande/dispatch.php?id='.$object->id; 161 $head[$h][1] = $langs->trans("OrderDispatch"); 162 $head[$h][2] = 'dispatch'; 163 $h++; 164 } 165 166 // Show more tabs from modules 167 // Entries must be declared in modules descriptor with line 168 // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab 169 // $this->tabs = array('entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to remove a tab 170 complete_head_from_modules($conf, $langs, $object, $head, $h, 'supplier_order'); 171 172 if (empty($conf->global->MAIN_DISABLE_NOTES_TAB)) { 173 $nbNote = 0; 174 if (!empty($object->note_private)) { 175 $nbNote++; 176 } 177 if (!empty($object->note_public)) { 178 $nbNote++; 179 } 180 $head[$h][0] = DOL_URL_ROOT.'/fourn/commande/note.php?id='.$object->id; 181 $head[$h][1] = $langs->trans("Notes"); 182 if ($nbNote > 0) { 183 $head[$h][1] .= '<span class="badge marginleftonlyshort">'.$nbNote.'</span>'; 184 } 185 $head[$h][2] = 'note'; 186 $h++; 187 } 188 189 require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; 190 require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php'; 191 $upload_dir = $conf->fournisseur->dir_output."/commande/".dol_sanitizeFileName($object->ref); 192 $nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png)$')); 193 $nbLinks = Link::count($db, $object->element, $object->id); 194 $head[$h][0] = DOL_URL_ROOT.'/fourn/commande/document.php?id='.$object->id; 195 $head[$h][1] = $langs->trans('Documents'); 196 if (($nbFiles + $nbLinks) > 0) { 197 $head[$h][1] .= '<span class="badge marginleftonlyshort">'.($nbFiles + $nbLinks).'</span>'; 198 } 199 $head[$h][2] = 'documents'; 200 $h++; 201 202 $head[$h][0] = DOL_URL_ROOT.'/fourn/commande/info.php?id='.$object->id; 203 $head[$h][1] .= $langs->trans("Events"); 204 if (!empty($conf->agenda->enabled) && (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read))) { 205 $head[$h][1] .= '/'; 206 $head[$h][1] .= $langs->trans("Agenda"); 207 } 208 $head[$h][2] = 'info'; 209 $h++; 210 complete_head_from_modules($conf, $langs, $object, $head, $h, 'supplier_order', 'remove'); 211 return $head; 212} 213 214/** 215 * Return array head with list of tabs to view object informations. 216 * 217 * @return array head array with tabs 218 */ 219function supplierorder_admin_prepare_head() 220{ 221 global $langs, $conf, $user; 222 223 $h = 0; 224 $head = array(); 225 226 $head[$h][0] = DOL_URL_ROOT."/admin/supplier_order.php"; 227 $head[$h][1] = $langs->trans("SupplierOrder"); 228 $head[$h][2] = 'order'; 229 $h++; 230 231 $head[$h][0] = DOL_URL_ROOT."/admin/supplier_invoice.php"; 232 $head[$h][1] = $langs->trans("SuppliersInvoice"); 233 $head[$h][2] = 'invoice'; 234 $h++; 235 236 $head[$h][0] = DOL_URL_ROOT."/admin/supplier_payment.php"; 237 $head[$h][1] = $langs->trans("SuppliersPayment"); 238 $head[$h][2] = 'supplierpayment'; 239 $h++; 240 241 complete_head_from_modules($conf, $langs, null, $head, $h, 'supplierorder_admin'); 242 243 $head[$h][0] = DOL_URL_ROOT.'/admin/supplierorder_extrafields.php'; 244 $head[$h][1] = $langs->trans("ExtraFieldsSupplierOrders"); 245 $head[$h][2] = 'supplierorder'; 246 $h++; 247 248 $head[$h][0] = DOL_URL_ROOT.'/admin/supplierorderdet_extrafields.php'; 249 $head[$h][1] = $langs->trans("ExtraFieldsSupplierOrdersLines"); 250 $head[$h][2] = 'supplierorderdet'; 251 $h++; 252 253 $head[$h][0] = DOL_URL_ROOT.'/admin/supplierinvoice_extrafields.php'; 254 $head[$h][1] = $langs->trans("ExtraFieldsSupplierInvoices"); 255 $head[$h][2] = 'supplierinvoice'; 256 $h++; 257 258 $head[$h][0] = DOL_URL_ROOT.'/admin/supplierinvoicedet_extrafields.php'; 259 $head[$h][1] = $langs->trans("ExtraFieldsSupplierInvoicesLines"); 260 $head[$h][2] = 'supplierinvoicedet'; 261 $h++; 262 263 complete_head_from_modules($conf, $langs, null, $head, $h, 'supplierorder_admin', 'remove'); 264 265 return $head; 266} 267