* Copyright (C) 2004-2014 Laurent Destailleur * Copyright (C) 2005 Marc Barilley / Ocebo * Copyright (C) 2005-2009 Regis Houssin * Copyright (C) 2022 Alexandre Spangaro * Copyright (C) 2024 MDW * Copyright (C) 2024 Frédéric France * * 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/compta/payment_sc/card.php * \ingroup tax * \brief Tab with payment of a social contribution * \remarks File similar to fourn/paiement/card.php */ // Load Dolibarr environment require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/compta/sociales/class/chargesociales.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/sociales/class/paymentsocialcontribution.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/modules/facture/modules_facture.php'; if (isModEnabled("bank")) { require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; } // Load translation files required by the page $langs->loadLangs(array('bills', 'banks', 'companies')); // Security check $id = GETPOSTINT("id"); $action = GETPOST('action', 'aZ09'); $confirm = GETPOST('confirm', 'aZ09'); if ($user->socid) { $socid = $user->socid; } $object = new PaymentSocialContribution($db); if ($id > 0) { $result = $object->fetch($id); if (!$result) { dol_print_error($db, 'Failed to get payment id '.$id); } } $result = restrictedArea($user, 'payment_sc', $object, ''); /* * Actions */ // Delete payment if ($action == 'confirm_delete' && $confirm == 'yes' && $user->hasRight('tax', 'charges', 'supprimer')) { $db->begin(); $result = $object->delete($user); if ($result > 0) { $db->commit(); header("Location: ".DOL_URL_ROOT."/compta/sociales/payments.php"); exit; } else { setEventMessages($object->error, $object->errors, 'errors'); $db->rollback(); } } /*if ($action == 'setdatep' && GETPOST('datepday') && $user->hasRight('tax', 'charges', 'creer')) { $datepaye = dol_mktime(GETPOST('datephour', 'int'), GETPOST('datepmin', 'int'), GETPOST('datepsec', 'int'), GETPOST('datepmonth', 'int'), GETPOST('datepday', 'int'), GETPOST('datepyear', 'int')); $res = $object->update_date($datepaye); if ($res === 0) { setEventMessages($langs->trans('PaymentDateUpdateSucceeded'), null, 'mesgs'); } else { setEventMessages($langs->trans('PaymentDateUpdateFailed'), null, 'errors'); } }*/ /* * View */ llxHeader(); $socialcontrib = new ChargeSociales($db); $form = new Form($db); $h = 0; $head = array(); $head[$h][0] = DOL_URL_ROOT.'/compta/payment_sc/card.php?id='.$id; $head[$h][1] = $langs->trans("PaymentSocialContribution"); $hselected = $h; $h++; /*$head[$h][0] = DOL_URL_ROOT.'/compta/payment_sc/info.php?id='.$id; $head[$h][1] = $langs->trans("Info"); $h++; */ print dol_get_fiche_head($head, (string) $hselected, $langs->trans("PaymentSocialContribution"), -1, 'payment'); /* * Deletion confirmation of payment */ if ($action == 'delete') { print $form->formconfirm('card.php?id='.$object->id, $langs->trans("DeletePayment"), $langs->trans("ConfirmDeletePayment"), 'confirm_delete', '', 0, 2); } $linkback = ''.$langs->trans("BackToList").''; dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'id', ''); print '
'; print '
'; print ''; // Date print ''; // Mode print ''; // Numero print ''; // Amount print ''; // Note print ''; // Bank account if (isModEnabled("bank")) { if ($object->bank_account) { $bankline = new AccountLine($db); $bankline->fetch($object->bank_line); print ''; print ''; print ''; print ''; } } print '
'.$langs->trans('Date').''.dol_print_date($object->datep, 'day').'
'.$langs->trans('Mode').''.$langs->trans("PaymentType".$object->type_code).'
'.$langs->trans('Numero').''.dol_escape_htmltag($object->num_payment).'
'.$langs->trans('Amount').''.price($object->amount, 0, $langs, 1, -1, -1, $conf->currency).'
'.$langs->trans('Note').''.dol_string_onlythesehtmltags(dol_htmlcleanlastbr($object->note_private)).'
'.$langs->trans('BankTransactionLine').''; print $bankline->getNomUrl(1, 0, 'showall'); print '
'; print '
'; print dol_get_fiche_end(); /* * List of social contributions paid */ $disable_delete = 0; $sql = 'SELECT f.rowid as scid, f.libelle as label, f.paye, f.amount as sc_amount, pf.amount, pc.libelle as sc_type'; $sql .= ' FROM '.MAIN_DB_PREFIX.'paiementcharge as pf,'.MAIN_DB_PREFIX.'chargesociales as f, '.MAIN_DB_PREFIX.'c_chargesociales as pc'; $sql .= ' WHERE pf.fk_charge = f.rowid AND f.fk_type = pc.id'; $sql .= ' AND f.entity = '.$conf->entity; $sql .= ' AND pf.rowid = '.((int) $object->id); dol_syslog("compta/payment_sc/card.php", LOG_DEBUG); $resql = $db->query($sql); if ($resql) { $num = $db->num_rows($resql); $i = 0; $total = 0; print '
'; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print "\n"; if ($num > 0) { while ($i < $num) { $objp = $db->fetch_object($resql); print ''; // Ref print '\n"; // Type print '\n"; // Label print ''; // Expected to pay print ''; // Status print ''; // Amount paid print ''; print "\n"; if ($objp->paye == 1) { // If at least one invoice is paid, disable delete $disable_delete = 1; } $total += $objp->amount; $i++; } } print "
'.$langs->trans('SocialContribution').''.$langs->trans('Type').''.$langs->trans('Label').''.$langs->trans('ExpectedToPay').''.$langs->trans('Status').''.$langs->trans('PayedByThisPayment').'
'; $socialcontrib->fetch($objp->scid); print $socialcontrib->getNomUrl(1); print "'; print $socialcontrib->type_label; /*print $socialcontrib->type;*/ print "'.$objp->label.''.price($objp->sc_amount).''.$socialcontrib->getLibStatut(4, $objp->amount).''.price($objp->amount).'
\n"; $db->free($resql); } else { dol_print_error($db); } /* * Actions Buttons */ print '
'; /* if (!empty($conf->global->BILL_ADD_PAYMENT_VALIDATION)) { if ($user->socid == 0 && $object->statut == 0 && $action == '') { if ($user->hasRight('facture', 'paiement')){ print ''.$langs->trans('Valid').''; } } } */ if ($action == '') { if ($user->hasRight('tax', 'charges', 'supprimer')) { if (!$disable_delete) { print dolGetButtonAction($langs->trans("Delete"), '', 'delete', $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=delete&token='.newToken(), 'delete', 1); } else { print dolGetButtonAction($langs->trans("CantRemovePaymentWithOneInvoicePaid"), $langs->trans("Delete"), 'delete', $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=delete&token='.newToken(), 'delete', 0); } } } print '
'; // End of page llxFooter(); $db->close();