* Copyright (C) 2005 Simon TOSSER * Copyright (C) 2013-2015 Alexandre Spangaro * Copyright (C) 2013-2014 Olivier Geffroy * Copyright (C) 2013-2014 Florian Henry * Copyright (C) 2014 Juanjo Menent * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . * */ /** * \file htdocs/accountancy/supplier/card.php * \ingroup Accountancy * \brief Card supplier ventilation */ require '../../main.inc.php'; // Class require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php'; require_once DOL_DOCUMENT_ROOT.'/accountancy/class/html.formventilation.class.php'; // Langs $langs->load("compta"); $langs->load("bills"); $langs->load("other"); $langs->load("main"); $langs->load("accountancy"); $action = GETPOST('action'); $id = GETPOST('id', 'int'); $codeventil = GETPOST('codeventil'); // Security check if ($user->societe_id > 0) accessforbidden(); if ($action == 'ventil' && $user->rights->accounting->ventilation->dispatch) { $sql = " UPDATE " . MAIN_DB_PREFIX . "facture_fourn_det"; $sql .= " SET fk_code_ventilation = " . $codeventil; $sql .= " WHERE rowid = " . $id; dol_syslog('accountancy/journal/sellsjournal.php:: $sql=' . $sql); $resql = $db->query($sql); if (! $resql) { setEventMessage($db->lasterror(), 'errors'); } } /* * View */ llxHeader("", "", "FicheVentilation"); if ($cancel == $langs->trans("Cancel")) { $action = ''; } /* * Create */ $form = new Form($db); $facturefournisseur_static = new FactureFournisseur($db); $formventilation = new FormVentilation($db); if ($_GET["id"]) { $sql = "SELECT f.ref as facnumber, f.rowid as facid, l.fk_product, l.description, l.rowid, l.fk_code_ventilation, "; $sql .= " p.rowid as product_id, p.ref as product_ref, p.label as product_label"; $sql .= ", aa.account_number, aa.label"; $sql .= " FROM " . MAIN_DB_PREFIX . "facture_fourn_det as l"; $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "product as p ON p.rowid = l.fk_product"; $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accountingaccount as aa ON l.fk_code_ventilation = aa.rowid"; $sql .= " INNER JOIN " . MAIN_DB_PREFIX . "facture_fourn as f ON f.rowid = l.fk_facture_fourn "; $sql .= " WHERE f.fk_statut > 0"; $sql .= " AND l.rowid = " . $id; if (! empty($conf->multicompany->enabled)) { $sql .= " AND f.entity = '" . $conf->entity . "'"; } $result = $db->query($sql); if ($result) { $num_lines = $db->num_rows($result); $i = 0; if ($num_lines) { $objp = $db->fetch_object($result); print '
' . "\n"; print ''; print ''; print_fiche_titre($langs->trans("SuppliersVentilation")); print ''; // ref invoice print ''; $facturefournisseur_static->ref = $objp->facnumber; $facturefournisseur_static->id = $objp->facid; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print '
' . $langs->trans("BillsSuppliers") . '' . $facturefournisseur_static->getNomUrl(1) . '
Ligne' . stripslashes(nl2br($objp->description)) . '
' . $langs->trans("ProductLabel") . '' . dol_trunc($objp->product_label, 24) . '
' . $langs->trans("Account") . ''; print $objp->account_number . '-' . $objp->label; print '
' . $langs->trans("NewAccount") . ''; print $formventilation->select_account($objp->fk_code_ventilation, 'codeventil', 1); print '
 
'; print '
'; } else { print "Error 1"; } } else { print "Error 2"; } } else { print "Error ID incorrect"; } llxFooter(); $db->close();