NEW : add real payments on salaries objects

This commit is contained in:
Gauthier PC portable 024
2021-02-04 17:21:08 +01:00
parent 62622a2065
commit e188ec6cd7
31 changed files with 2986 additions and 835 deletions

View File

@@ -10,6 +10,7 @@
* Copyright (C) 2017-2018 Frédéric France <frederic.france@netlogic.fr> * Copyright (C) 2017-2018 Frédéric France <frederic.france@netlogic.fr>
* Copyright (C) 2018 Ferran Marcet <fmarcet@2byte.es> * Copyright (C) 2018 Ferran Marcet <fmarcet@2byte.es>
* Copyright (C) 2018 Eric Seigne <eric.seigne@cap-rel.fr> * Copyright (C) 2018 Eric Seigne <eric.seigne@cap-rel.fr>
* Copyright (C) 2021 Gauthier VERDOL <gauthier.verdol@atm-consulting.fr>
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@@ -45,7 +46,7 @@ require_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php';
require_once DOL_DOCUMENT_ROOT.'/don/class/don.class.php'; require_once DOL_DOCUMENT_ROOT.'/don/class/don.class.php';
require_once DOL_DOCUMENT_ROOT.'/don/class/paymentdonation.class.php'; require_once DOL_DOCUMENT_ROOT.'/don/class/paymentdonation.class.php';
require_once DOL_DOCUMENT_ROOT.'/compta/tva/class/tva.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/tva/class/tva.class.php';
require_once DOL_DOCUMENT_ROOT.'/salaries/class/paymentsalary.class.php'; require_once DOL_DOCUMENT_ROOT.'/salaries/class/salary.class.php';
require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
require_once DOL_DOCUMENT_ROOT.'/fourn/class/paiementfourn.class.php'; require_once DOL_DOCUMENT_ROOT.'/fourn/class/paiementfourn.class.php';
require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php'; require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php';
@@ -145,7 +146,7 @@ $bankaccountstatic = new Account($db);
$chargestatic = new ChargeSociales($db); $chargestatic = new ChargeSociales($db);
$paymentdonstatic = new PaymentDonation($db); $paymentdonstatic = new PaymentDonation($db);
$paymentvatstatic = new TVA($db); $paymentvatstatic = new TVA($db);
$paymentsalstatic = new PaymentSalary($db); $paymentsalstatic = new Salary($db);
$paymentexpensereportstatic = new PaymentExpenseReport($db); $paymentexpensereportstatic = new PaymentExpenseReport($db);
$paymentvariousstatic = new PaymentVarious($db); $paymentvariousstatic = new PaymentVarious($db);
$paymentloanstatic = new PaymentLoan($db); $paymentloanstatic = new PaymentLoan($db);
@@ -954,7 +955,7 @@ if (empty($action) || $action == 'view') {
$vatstatic = new Tva($db); $vatstatic = new Tva($db);
$donationstatic = new Don($db); $donationstatic = new Don($db);
$loanstatic = new Loan($db); $loanstatic = new Loan($db);
$salarystatic = new PaymentSalary($db); $salarystatic = new Salary($db);
$variousstatic = new PaymentVarious($db); $variousstatic = new PaymentVarious($db);
llxHeader('', $langs->trans("FinanceJournal")); llxHeader('', $langs->trans("FinanceJournal"));

View File

@@ -33,7 +33,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
require_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php';
require_once DOL_DOCUMENT_ROOT.'/salaries/class/paymentsalary.class.php'; require_once DOL_DOCUMENT_ROOT.'/salaries/class/salary.class.php';
require_once DOL_DOCUMENT_ROOT.'/compta/sociales/class/chargesociales.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/sociales/class/chargesociales.class.php';
require_once DOL_DOCUMENT_ROOT.'/don/class/don.class.php'; require_once DOL_DOCUMENT_ROOT.'/don/class/don.class.php';
require_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport.class.php'; require_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport.class.php';
@@ -189,7 +189,7 @@ if (($action == 'searchfiles' || $action == 'dl')) {
$sql .= " FROM ".MAIN_DB_PREFIX."payment_salary as t LEFT JOIN ".MAIN_DB_PREFIX."user as u ON u.rowid = t.fk_user LEFT JOIN ".MAIN_DB_PREFIX."c_country as c ON c.rowid = u.fk_country"; $sql .= " FROM ".MAIN_DB_PREFIX."payment_salary as t LEFT JOIN ".MAIN_DB_PREFIX."user as u ON u.rowid = t.fk_user LEFT JOIN ".MAIN_DB_PREFIX."c_country as c ON c.rowid = u.fk_country";
$sql .= " WHERE datep between ".$wheretail; $sql .= " WHERE datep between ".$wheretail;
$sql .= " AND t.entity IN (".($entity == 1 ? '0,1' : $entity).')'; $sql .= " AND t.entity IN (".($entity == 1 ? '0,1' : $entity).')';
//$sql.=" AND fk_statut <> ".PaymentSalary::STATUS_DRAFT; //$sql.=" AND fk_statut <> ".Salary::STATUS_DRAFT;
} }
// Social contributions // Social contributions
if (GETPOST('selectsocialcontributions')) { if (GETPOST('selectsocialcontributions')) {
@@ -510,7 +510,7 @@ $invoice = new Facture($db);
$supplier_invoice = new FactureFournisseur($db); $supplier_invoice = new FactureFournisseur($db);
$expensereport = new ExpenseReport($db); $expensereport = new ExpenseReport($db);
$don = new Don($db); $don = new Don($db);
$salary_payment = new PaymentSalary($db); $salary_payment = new Salary($db);
$charge_sociales = new ChargeSociales($db); $charge_sociales = new ChargeSociales($db);
$various_payment = new PaymentVarious($db); $various_payment = new PaymentVarious($db);
$payment_loan = new PaymentLoan($db); $payment_loan = new PaymentLoan($db);

View File

@@ -9,6 +9,7 @@
* Copyright (C) 2017-2019 Alexandre Spangaro <aspangaro@open-dsi.fr> * Copyright (C) 2017-2019 Alexandre Spangaro <aspangaro@open-dsi.fr>
* Copyright (C) 2018 Ferran Marcet <fmarcet@2byte.es> * Copyright (C) 2018 Ferran Marcet <fmarcet@2byte.es>
* Copyright (C) 2018 Frédéric France <frederic.france@netlogic.fr> * Copyright (C) 2018 Frédéric France <frederic.france@netlogic.fr>
* Copyright (C) 2021 Gauthier VERDOL <gauthier.verdol@atm-consulting.fr>
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@@ -43,7 +44,7 @@ require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php';
require_once DOL_DOCUMENT_ROOT.'/compta/sociales/class/chargesociales.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/sociales/class/chargesociales.class.php';
require_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php';
require_once DOL_DOCUMENT_ROOT.'/compta/tva/class/tva.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/tva/class/tva.class.php';
require_once DOL_DOCUMENT_ROOT.'/salaries/class/paymentsalary.class.php'; require_once DOL_DOCUMENT_ROOT.'/salaries/class/salary.class.php';
require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/paymentvarious.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/paymentvarious.class.php';
require_once DOL_DOCUMENT_ROOT.'/compta/prelevement/class/bonprelevement.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/prelevement/class/bonprelevement.class.php';
require_once DOL_DOCUMENT_ROOT.'/don/class/don.class.php'; require_once DOL_DOCUMENT_ROOT.'/don/class/don.class.php';
@@ -383,7 +384,7 @@ $memberstatic = new Adherent($db);
$paymentstatic = new Paiement($db); $paymentstatic = new Paiement($db);
$paymentsupplierstatic = new PaiementFourn($db); $paymentsupplierstatic = new PaiementFourn($db);
$paymentvatstatic = new TVA($db); $paymentvatstatic = new TVA($db);
$paymentsalstatic = new PaymentSalary($db); $paymentsalstatic = new Salary($db);
$paymentvariousstatic = new PaymentVarious($db); $paymentvariousstatic = new PaymentVarious($db);
$donstatic = new Don($db); $donstatic = new Don($db);
$paymentexpensereportstatic = new PaymentExpenseReport($db); $paymentexpensereportstatic = new PaymentExpenseReport($db);

View File

@@ -8,6 +8,7 @@
* Copyright (C) 2015 Jean-François Ferry <jfefe@aternatik.fr> * Copyright (C) 2015 Jean-François Ferry <jfefe@aternatik.fr>
* Copyright (C) 2016 Marcos García <marcosgdf@gmail.com> * Copyright (C) 2016 Marcos García <marcosgdf@gmail.com>
* Copyright (C) 2018 Frédéric France <frederic.france@netlogic.fr> * Copyright (C) 2018 Frédéric France <frederic.france@netlogic.fr>
* Copyright (C) 2021 Gauthier VERDOL <gauthier.verdol@atm-consulting.fr>
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@@ -337,6 +338,7 @@ if ($result)
{ {
print '<tr><td class="tdtop">'.$langs->trans("Links").'</td>'; print '<tr><td class="tdtop">'.$langs->trans("Links").'</td>';
print '<td>'; print '<td>';
foreach ($links as $key=>$val) foreach ($links as $key=>$val)
{ {
if ($key) print '<br>'; if ($key) print '<br>';
@@ -367,26 +369,32 @@ if ($result)
$societe->fetch($links[$key]['url_id']); $societe->fetch($links[$key]['url_id']);
print $societe->getNomUrl(1); print $societe->getNomUrl(1);
} }
elseif ($links[$key]['type'] == 'sc') { elseif ($links[$key]['type'] == 'sc') {
print '<a href="'.DOL_URL_ROOT.'/compta/sociales/card.php?id='.$links[$key]['url_id'].'">'; print '<a href="'.DOL_URL_ROOT.'/compta/sociales/card.php?id='.$links[$key]['url_id'].'">';
print img_object($langs->trans('SocialContribution'), 'bill').' '; print img_object($langs->trans('SocialContribution'), 'bill').' ';
print $langs->trans("SocialContribution").($links[$key]['label'] ? ' - '.$links[$key]['label'] : ''); print $langs->trans("SocialContribution").($links[$key]['label'] ? ' - '.$links[$key]['label'] : '');
print '</a>'; print '</a>';
} }
elseif ($links[$key]['type'] == 'salary') {
print '<a href="'.DOL_URL_ROOT.'/salaries/card.php?id='.$links[$key]['url_id'].'">';
print img_object($langs->trans('Salary'), 'bill').' ';
print $langs->trans("Salary").($links[$key]['label'] ? ' - '.$links[$key]['label'] : '');
print '</a>';
}
elseif ($links[$key]['type'] == 'payment_sc') { elseif ($links[$key]['type'] == 'payment_sc') {
print '<a href="'.DOL_URL_ROOT.'/compta/payment_sc/card.php?id='.$links[$key]['url_id'].'">'; print '<a href="'.DOL_URL_ROOT.'/compta/payment_sc/card.php?id='.$links[$key]['url_id'].'">';
print img_object($langs->trans('Payment'), 'payment').' '; print img_object($langs->trans('Payment'), 'payment').' ';
print $langs->trans("SocialContributionPayment"); print $langs->trans("SocialContributionPayment");
print '</a>'; print '</a>';
} }
elseif ($links[$key]['type'] == 'payment_vat') { elseif ($links[$key]['type'] == 'payment_vat') {
print '<a href="'.DOL_URL_ROOT.'/compta/tva/card.php?id='.$links[$key]['url_id'].'">'; print '<a href="'.DOL_URL_ROOT.'/compta/tva/card.php?id='.$links[$key]['url_id'].'">';
print img_object($langs->trans('VAT'), 'payment').' '; print img_object($langs->trans('VAT'), 'payment').' ';
print $langs->trans("VATPayment"); print $langs->trans("VATPayment");
print '</a>'; print '</a>';
} }
elseif ($links[$key]['type'] == 'payment_salary') { elseif ($links[$key]['type'] == 'payment_salary') {
print '<a href="'.DOL_URL_ROOT.'/salaries/card.php?id='.$links[$key]['url_id'].'">'; print '<a href="'.DOL_URL_ROOT.'/salaries/payment_salary/card.php?id='.$links[$key]['url_id'].'">';
print img_object($langs->trans('PaymentSalary'), 'payment').' '; print img_object($langs->trans('PaymentSalary'), 'payment').' ';
print $langs->trans("SalaryPayment"); print $langs->trans("SalaryPayment");
print '</a>'; print '</a>';

View File

@@ -6,6 +6,7 @@
* Copyright (C) 2011-2014 Juanjo Menent <jmenent@2byte.es> * Copyright (C) 2011-2014 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2015 Jean-François Ferry <jfefe@aternatik.fr> * Copyright (C) 2015 Jean-François Ferry <jfefe@aternatik.fr>
* Copyright (C) 2019 Nicolas ZABOURI <info@inovea-conseil.com> * Copyright (C) 2019 Nicolas ZABOURI <info@inovea-conseil.com>
* Copyright (C) 2021 Gauthier VERDOL <gauthier.verdol@atm-consulting.fr>
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@@ -31,7 +32,7 @@ require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/compta/tva/class/tva.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/tva/class/tva.class.php';
require_once DOL_DOCUMENT_ROOT.'/compta/sociales/class/chargesociales.class.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/sociales/class/paymentsocialcontribution.class.php';
require_once DOL_DOCUMENT_ROOT.'/salaries/class/paymentsalary.class.php'; require_once DOL_DOCUMENT_ROOT.'/salaries/class/salary.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
@@ -74,7 +75,7 @@ if (!$sortorder) $sortorder = "DESC";
$tva_static = new Tva($db); $tva_static = new Tva($db);
$socialcontrib = new ChargeSociales($db); $socialcontrib = new ChargeSociales($db);
$payment_sc_static = new PaymentSocialContribution($db); $payment_sc_static = new PaymentSocialContribution($db);
$sal_static = new PaymentSalary($db); $sal_static = new Salary($db);
$accountstatic = new Account($db); $accountstatic = new Account($db);
llxHeader('', $langs->trans("SpecialExpensesArea")); llxHeader('', $langs->trans("SpecialExpensesArea"));
@@ -470,7 +471,7 @@ if (!empty($conf->salaries->enabled) && !empty($user->rights->salaries->read))
{ {
if (!$mode || $mode != 'sconly') if (!$mode || $mode != 'sconly')
{ {
$sal = new PaymentSalary($db); $sal = new Salary($db);
print "<br>"; print "<br>";

View File

@@ -5,6 +5,7 @@
* Copyright (C) 2011-2016 Alexandre Spangaro <aspangaro@open-dsi.fr> * Copyright (C) 2011-2016 Alexandre Spangaro <aspangaro@open-dsi.fr>
* Copyright (C) 2011-2014 Juanjo Menent <jmenent@2byte.es> * Copyright (C) 2011-2014 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2015 Jean-François Ferry <jfefe@aternatik.fr> * Copyright (C) 2015 Jean-François Ferry <jfefe@aternatik.fr>
* Copyright (C) 2021 Gauthier VERDOL <gauthier.verdol@atm-consulting.fr>
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@@ -30,7 +31,7 @@ require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/compta/tva/class/tva.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/tva/class/tva.class.php';
require_once DOL_DOCUMENT_ROOT.'/compta/sociales/class/chargesociales.class.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/sociales/class/paymentsocialcontribution.class.php';
require_once DOL_DOCUMENT_ROOT.'/salaries/class/paymentsalary.class.php'; require_once DOL_DOCUMENT_ROOT.'/salaries/class/salary.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
// Load translation files required by the page // Load translation files required by the page
@@ -64,7 +65,7 @@ if (!$sortorder) $sortorder = "DESC";
$tva_static = new Tva($db); $tva_static = new Tva($db);
$socialcontrib = new ChargeSociales($db); $socialcontrib = new ChargeSociales($db);
$payment_sc_static = new PaymentSocialContribution($db); $payment_sc_static = new PaymentSocialContribution($db);
$sal_static = new PaymentSalary($db); $sal_static = new Salary($db);
llxHeader('', $langs->trans("SpecialExpensesArea")); llxHeader('', $langs->trans("SpecialExpensesArea"));
@@ -403,7 +404,7 @@ if (!empty($conf->salaries->enabled) && !empty($user->rights->salaries->read))
{ {
if (!$mode || $mode != 'sconly') if (!$mode || $mode != 'sconly')
{ {
$sal = new PaymentSalary($db); $sal = new Salary($db);
print "<br>"; print "<br>";

View File

@@ -14,6 +14,7 @@
* Copyright (C) 2017 Rui Strecht <rui.strecht@aliartalentos.com> * Copyright (C) 2017 Rui Strecht <rui.strecht@aliartalentos.com>
* Copyright (C) 2018-2019 Frédéric France <frederic.france@netlogic.fr> * Copyright (C) 2018-2019 Frédéric France <frederic.france@netlogic.fr>
* Copyright (C) 2018 Josep Lluís Amador <joseplluis@lliuretic.cat> * Copyright (C) 2018 Josep Lluís Amador <joseplluis@lliuretic.cat>
* Copyright (C) 2021 Gauthier VERDOL <gauthier.verdol@atm-consulting.fr>
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@@ -2042,6 +2043,7 @@ abstract class CommonObject
$fieldname = 'fk_mode_reglement'; $fieldname = 'fk_mode_reglement';
if ($this->element == 'societe') $fieldname = 'mode_reglement'; if ($this->element == 'societe') $fieldname = 'mode_reglement';
if (get_class($this) == 'Fournisseur') $fieldname = 'mode_reglement_supplier'; if (get_class($this) == 'Fournisseur') $fieldname = 'mode_reglement_supplier';
if (get_class($this) == 'Salary') $fieldname = 'fk_typepayment';
$sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element; $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element;
$sql .= ' SET '.$fieldname.' = '.(($id > 0 || $id == '0') ? $id : 'NULL'); $sql .= ' SET '.$fieldname.' = '.(($id > 0 || $id == '0') ? $id : 'NULL');

View File

@@ -15,6 +15,7 @@
* Copyright (C) 2015 Jean-François Ferry <jfefe@aternatik.fr> * Copyright (C) 2015 Jean-François Ferry <jfefe@aternatik.fr>
* Copyright (C) 2018-2020 Frédéric France <frederic.france@netlogic.fr> * Copyright (C) 2018-2020 Frédéric France <frederic.france@netlogic.fr>
* Copyright (C) 2019 Thibault Foucart <support@ptibogxiv.net> * Copyright (C) 2019 Thibault Foucart <support@ptibogxiv.net>
* Copyright (C) 2021 Gauthier VERDOL <gauthier.verdol@atm-consulting.fr>
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@@ -1611,7 +1612,7 @@ function dol_banner_tab($object, $paramid, $morehtml = '', $shownav = 1, $fieldi
$morehtmlstatus .= '<span class="statusrefbuy">'.$object->getLibStatut(6, 1).'</span>'; $morehtmlstatus .= '<span class="statusrefbuy">'.$object->getLibStatut(6, 1).'</span>';
} }
} }
elseif (in_array($object->element, array('facture', 'invoice', 'invoice_supplier', 'chargesociales', 'loan'))) elseif (in_array($object->element, array('facture', 'invoice', 'invoice_supplier', 'chargesociales', 'loan', 'salary')))
{ {
$tmptxt = $object->getLibStatut(6, $object->totalpaye); $tmptxt = $object->getLibStatut(6, $object->totalpaye);
if (empty($tmptxt) || $tmptxt == $object->getLibStatut(3)) $tmptxt = $object->getLibStatut(5, $object->totalpaye); if (empty($tmptxt) || $tmptxt == $object->getLibStatut(3)) $tmptxt = $object->getLibStatut(5, $object->totalpaye);

View File

@@ -2,6 +2,7 @@
/** /**
* Copyright (C) 2015 Charlie BENKE <charlie@patas-monkey.com> * Copyright (C) 2015 Charlie BENKE <charlie@patas-monkey.com>
* Copyright (C) 2019 Alexandre Spangaro <aspangaro@open-dsi.fr> * Copyright (C) 2019 Alexandre Spangaro <aspangaro@open-dsi.fr>
* Copyright (C) 2021 Gauthier VERDOL <gauthier.verdol@atm-consulting.fr>
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@@ -34,7 +35,7 @@ function salaries_prepare_head($object)
$head = array(); $head = array();
$head[$h][0] = DOL_URL_ROOT.'/salaries/card.php?id='.$object->id; $head[$h][0] = DOL_URL_ROOT.'/salaries/card.php?id='.$object->id;
$head[$h][1] = $langs->trans("SalaryPayment"); $head[$h][1] = $langs->trans("Salary");
$head[$h][2] = 'card'; $head[$h][2] = 'card';
$h++; $h++;

View File

@@ -6,6 +6,7 @@
* Copyright (C) 2015 Marcos García <marcosgdf@gmail.com> * Copyright (C) 2015 Marcos García <marcosgdf@gmail.com>
* Copyright (C) 2018 Ferran Marcet <fmarcet@2byte.es> * Copyright (C) 2018 Ferran Marcet <fmarcet@2byte.es>
* Copyright (C) 2018-2019 Frédéric France <frederic.france@netlogic.fr> * Copyright (C) 2018-2019 Frédéric France <frederic.france@netlogic.fr>
* Copyright (C) 2021 Gauthier VERDOL <gauthier.verdol@atm-consulting.fr>
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@@ -1155,8 +1156,9 @@ function print_left_eldy_menu($db, $menu_array_before, $menu_array_after, &$tabM
$langs->load("salaries"); $langs->load("salaries");
$newmenu->add("/salaries/list.php?leftmenu=tax_salary&amp;mainmenu=billing", $langs->trans("Salaries"), 0, $user->rights->salaries->read, '', $mainmenu, 'tax_salary'); $newmenu->add("/salaries/list.php?leftmenu=tax_salary&amp;mainmenu=billing", $langs->trans("Salaries"), 0, $user->rights->salaries->read, '', $mainmenu, 'tax_salary');
if ($usemenuhider || empty($leftmenu) || preg_match('/^tax_salary/i', $leftmenu)) { if ($usemenuhider || empty($leftmenu) || preg_match('/^tax_salary/i', $leftmenu)) {
$newmenu->add("/salaries/card.php?leftmenu=tax_salary&action=create", $langs->trans("NewPayment"), 1, $user->rights->salaries->write); $newmenu->add("/salaries/card.php?leftmenu=tax_salary&action=create", $langs->trans("New"), 1, $user->rights->salaries->write);
$newmenu->add("/salaries/list.php?leftmenu=tax_salary", $langs->trans("Payments"), 1, $user->rights->salaries->read); $newmenu->add("/salaries/list.php?leftmenu=tax_salary", $langs->trans("List"), 1, $user->rights->salaries->read);
$newmenu->add("/salaries/payments.php?leftmenu=tax_salary", $langs->trans("Payments"), 1, $user->rights->salaries->read);
$newmenu->add("/salaries/stats/index.php?leftmenu=tax_salary", $langs->trans("Statistics"), 1, $user->rights->salaries->read); $newmenu->add("/salaries/stats/index.php?leftmenu=tax_salary", $langs->trans("Statistics"), 1, $user->rights->salaries->read);
} }
} }

View File

@@ -1,5 +1,6 @@
-- =================================================================== -- ===================================================================
-- Copyright (C) 2011-2018 Alexandre Spangaro <aspangaro@open-dsi.fr> -- Copyright (C) 2004 Laurent Destailleur <eldy@users.sourceforge.net>
-- Copyright (C) 2021 Gauthier VERDOL <gauthier.verdol@atm-consulting.fr>
-- --
-- This program is free software; you can redistribute it and/or modify -- 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 -- it under the terms of the GNU General Public License as published by
@@ -19,23 +20,16 @@
create table llx_payment_salary create table llx_payment_salary
( (
rowid integer AUTO_INCREMENT PRIMARY KEY, rowid integer AUTO_INCREMENT PRIMARY KEY,
ref varchar(30) NULL, -- payment reference number (currently NULL because there is no numbering manager yet) fk_salary integer,
datec datetime, -- date de creation
tms timestamp, tms timestamp,
datec datetime, -- Create date datep datetime, -- payment date
fk_user integer NOT NULL, amount double(24,8) DEFAULT 0,
datep date, -- payment date fk_typepaiement integer NOT NULL,
datev date, -- value date (this field should not be here, only into bank tables) num_paiement varchar(50),
salary double(24,8), -- salary of user when payment was done
amount double(24,8) NOT NULL DEFAULT 0,
fk_projet integer DEFAULT NULL,
fk_typepayment integer NOT NULL,
num_payment varchar(50), -- num cheque or other
label varchar(255),
datesp date, -- date start period
dateep date, -- date end period
entity integer DEFAULT 1 NOT NULL, -- multi company id
note text, note text,
fk_bank integer, fk_bank integer NOT NULL,
fk_user_author integer, -- user creating fk_user_creat integer, -- creation user
fk_user_modif integer -- user making last change fk_user_modif integer -- last modification user
)ENGINE=innodb; )ENGINE=innodb;

View File

@@ -1,5 +1,6 @@
-- ============================================================================ -- ============================================================================
-- Copyright (C) 2015 Laurent Destailleur <eldy@users.sourceforge.net> -- Copyright (C) 2015 Laurent Destailleur <eldy@users.sourceforge.net>
-- Copyright (C) 2021 Gauthier VERDOL <gauthier.verdol@atm-consulting.fr>
-- --
-- This program is free software; you can redistribute it and/or modify -- 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 -- it under the terms of the GNU General Public License as published by
@@ -17,11 +18,11 @@
-- ============================================================================ -- ============================================================================
ALTER TABLE llx_payment_salary ADD INDEX idx_payment_salary_ref (num_payment); ALTER TABLE llx_salary ADD INDEX idx_salary_ref (num_payment);
ALTER TABLE llx_payment_salary ADD INDEX idx_payment_salary_user (fk_user, entity); ALTER TABLE llx_salary ADD INDEX idx_salary_user (fk_user, entity);
ALTER TABLE llx_payment_salary ADD INDEX idx_payment_salary_datep (datep); ALTER TABLE llx_salary ADD INDEX idx_salary_datep (datep);
ALTER TABLE llx_payment_salary ADD INDEX idx_payment_salary_datesp (datesp); ALTER TABLE llx_salary ADD INDEX idx_salary_datesp (datesp);
ALTER TABLE llx_payment_salary ADD INDEX idx_payment_salary_dateep (dateep); ALTER TABLE llx_salary ADD INDEX idx_salary_dateep (dateep);
ALTER TABLE llx_payment_salary ADD CONSTRAINT fk_payment_salary_user FOREIGN KEY (fk_user) REFERENCES llx_user (rowid); ALTER TABLE llx_salary ADD CONSTRAINT fk_salary_user FOREIGN KEY (fk_user) REFERENCES llx_user (rowid);

View File

@@ -0,0 +1,44 @@
-- ===================================================================
-- Copyright (C) 2011-2018 Alexandre Spangaro <aspangaro@open-dsi.fr>
-- Copyright (C) 2021 Gauthier VERDOL <gauthier.verdol@atm-consulting.fr>
--
-- 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 <https://www.gnu.org/licenses/>.
--
-- ===================================================================
create table llx_salary
(
rowid integer AUTO_INCREMENT PRIMARY KEY,
ref varchar(30) NULL, -- payment reference number (currently NULL because there is no numbering manager yet)
tms timestamp,
datec datetime, -- Create date
fk_user integer NOT NULL,
datep date, -- payment date
datev date, -- value date (this field should not be here, only into bank tables)
salary double(24,8), -- salary of user when payment was done
amount double(24,8) NOT NULL DEFAULT 0,
fk_projet integer DEFAULT NULL,
fk_typepayment integer NOT NULL,
num_payment varchar(50), -- num cheque or other
label varchar(255),
datesp date, -- date start period
dateep date, -- date end period
entity integer DEFAULT 1 NOT NULL, -- multi company id
note text,
fk_bank integer,
paye smallint default 0 NOT NULL,
fk_account integer,
fk_user_author integer, -- user creating
fk_user_modif integer -- user making last change
)ENGINE=innodb;

View File

@@ -1,5 +1,6 @@
-- =================================================================== -- ===================================================================
-- Copyright (C) 2019 Alexandre Spangaro <aspangaro@open-dsi.fr> -- Copyright (C) 2019 Alexandre Spangaro <aspangaro@open-dsi.fr>
-- Copyright (C) 2021 Gauthier VERDOL <gauthier.verdol@atm-consulting.fr>
-- --
-- This program is free software; you can redistribute it and/or modify -- 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 -- it under the terms of the GNU General Public License as published by
@@ -17,4 +18,4 @@
-- =================================================================== -- ===================================================================
ALTER TABLE llx_payment_salary_extrafields ADD INDEX idx_payment_salary_extrafields (fk_object); ALTER TABLE llx_salary_extrafields ADD INDEX idx_salary_extrafields (fk_object);

View File

@@ -1,5 +1,6 @@
-- =================================================================== -- ===================================================================
-- Copyright (C) 2019 Alexandre Spangaro <aspangaro@open-dsi.fr> -- Copyright (C) 2019 Alexandre Spangaro <aspangaro@open-dsi.fr>
-- Copyright (C) 2021 Gauthier VERDOL <gauthier.verdol@atm-consulting.fr>
-- --
-- This program is free software; you can redistribute it and/or modify -- 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 -- it under the terms of the GNU General Public License as published by
@@ -16,7 +17,7 @@
-- --
-- =================================================================== -- ===================================================================
create table llx_payment_salary_extrafields create table llx_salary_extrafields
( (
rowid integer AUTO_INCREMENT PRIMARY KEY, rowid integer AUTO_INCREMENT PRIMARY KEY,
tms timestamp, tms timestamp,

View File

@@ -493,12 +493,14 @@ Cash=Cash
Reported=Delayed Reported=Delayed
DisabledBecausePayments=Not possible since there are some payments DisabledBecausePayments=Not possible since there are some payments
CantRemovePaymentWithOneInvoicePaid=Can't remove payment since there is at least one invoice classified paid CantRemovePaymentWithOneInvoicePaid=Can't remove payment since there is at least one invoice classified paid
CantRemovePaymentSalaryPaid=Can't remove payment since salary is classified paid
ExpectedToPay=Expected payment ExpectedToPay=Expected payment
CantRemoveConciliatedPayment=Can't remove reconciled payment CantRemoveConciliatedPayment=Can't remove reconciled payment
PayedByThisPayment=Paid by this payment PayedByThisPayment=Paid by this payment
ClosePaidInvoicesAutomatically=Classify automatically all standard, down payment or replacement invoices as "Paid" when payment is done entirely. ClosePaidInvoicesAutomatically=Classify automatically all standard, down payment or replacement invoices as "Paid" when payment is done entirely.
ClosePaidCreditNotesAutomatically=Classify automatically all credit notes as "Paid" when refund is done entirely. ClosePaidCreditNotesAutomatically=Classify automatically all credit notes as "Paid" when refund is done entirely.
ClosePaidContributionsAutomatically=Classify automatically all social or fiscal contributions as "Paid" when payment is done entirely. ClosePaidContributionsAutomatically=Classify automatically all social or fiscal contributions as "Paid" when payment is done entirely.
ClosePaidSalaryAutomatically=Classify automatically salary as "Paid" when payment is done entirely.
AllCompletelyPayedInvoiceWillBeClosed=All invoices with no remainder to pay will be automatically closed with status "Paid". AllCompletelyPayedInvoiceWillBeClosed=All invoices with no remainder to pay will be automatically closed with status "Paid".
ToMakePayment=Pay ToMakePayment=Pay
ToMakePaymentBack=Pay back ToMakePaymentBack=Pay back

View File

@@ -133,9 +133,13 @@ NoWaitingChecks=No checks awaiting deposit.
DateChequeReceived=Check reception date DateChequeReceived=Check reception date
NbOfCheques=No. of checks NbOfCheques=No. of checks
PaySocialContribution=Pay a social/fiscal tax PaySocialContribution=Pay a social/fiscal tax
ConfirmPaySalary=Pay a salary card
ConfirmPaySocialContribution=Are you sure you want to classify this social or fiscal tax as paid? ConfirmPaySocialContribution=Are you sure you want to classify this social or fiscal tax as paid?
ConfirmPaySalary=Are you sure you want to classify this salary card as paid?
DeleteSocialContribution=Delete a social or fiscal tax payment DeleteSocialContribution=Delete a social or fiscal tax payment
DeleteSalary=Delete a salary card
ConfirmDeleteSocialContribution=Are you sure you want to delete this social/fiscal tax payment? ConfirmDeleteSocialContribution=Are you sure you want to delete this social/fiscal tax payment?
ConfirmDeleteSalary=Are you sure you want to delete this salary?
ExportDataset_tax_1=Social and fiscal taxes and payments ExportDataset_tax_1=Social and fiscal taxes and payments
CalcModeVATDebt=Mode <b>%sVAT on commitment accounting%s</b>. CalcModeVATDebt=Mode <b>%sVAT on commitment accounting%s</b>.
CalcModeVATEngagement=Mode <b>%sVAT on incomes-expenses%s</b>. CalcModeVATEngagement=Mode <b>%sVAT on incomes-expenses%s</b>.
@@ -231,6 +235,7 @@ ACCOUNTING_ACCOUNT_CUSTOMER_Desc=The dedicated accounting account defined on thi
ACCOUNTING_ACCOUNT_SUPPLIER=Accounting account used for vendor third parties ACCOUNTING_ACCOUNT_SUPPLIER=Accounting account used for vendor third parties
ACCOUNTING_ACCOUNT_SUPPLIER_Desc=The dedicated accounting account defined on third party card will be used for Subledger accounting only. This one will be used for General Ledger and as default value of Subledger accounting if dedicated vendor accounting account on third party is not defined. ACCOUNTING_ACCOUNT_SUPPLIER_Desc=The dedicated accounting account defined on third party card will be used for Subledger accounting only. This one will be used for General Ledger and as default value of Subledger accounting if dedicated vendor accounting account on third party is not defined.
ConfirmCloneTax=Confirm the clone of a social/fiscal tax ConfirmCloneTax=Confirm the clone of a social/fiscal tax
ConfirmCloneSalary=Confirm the clone of a salary
CloneTaxForNextMonth=Clone it for next month CloneTaxForNextMonth=Clone it for next month
SimpleReport=Simple report SimpleReport=Simple report
AddExtraReport=Extra reports (add foreign and national customer report) AddExtraReport=Extra reports (add foreign and national customer report)

View File

@@ -4,7 +4,7 @@ SALARIES_ACCOUNTING_ACCOUNT_PAYMENT_Desc=The dedicated accounting account define
SALARIES_ACCOUNTING_ACCOUNT_CHARGE=Accounting account by default for wage payments SALARIES_ACCOUNTING_ACCOUNT_CHARGE=Accounting account by default for wage payments
Salary=Salary Salary=Salary
Salaries=Salaries Salaries=Salaries
NewSalaryPayment=New salary payment NewSalaryPayment=New salary card
AddSalaryPayment=Add salary payment AddSalaryPayment=Add salary payment
SalaryPayment=Salary payment SalaryPayment=Salary payment
SalariesPayments=Salaries payments SalariesPayments=Salaries payments

View File

@@ -6,6 +6,7 @@
* Copyright (C) 2015-2019 Alexandre Spangaro <aspangaro@open-dsi.fr> * Copyright (C) 2015-2019 Alexandre Spangaro <aspangaro@open-dsi.fr>
* Copyright (C) 2015 Marcos García <marcosgdf@gmail.com> * Copyright (C) 2015 Marcos García <marcosgdf@gmail.com>
* Copyright (C) 2016 Josep Lluís Amador <joseplluis@lliuretic.cat> * Copyright (C) 2016 Josep Lluís Amador <joseplluis@lliuretic.cat>
* Copyright (C) 2021 Gauthier VERDOL <gauthier.verdol@atm-consulting.fr>
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@@ -53,7 +54,7 @@ if (!empty($conf->loan->enabled)) require_once DOL_DOCUMENT_ROOT.'/loan/class/
if (!empty($conf->stock->enabled)) require_once DOL_DOCUMENT_ROOT.'/product/stock/class/mouvementstock.class.php'; if (!empty($conf->stock->enabled)) require_once DOL_DOCUMENT_ROOT.'/product/stock/class/mouvementstock.class.php';
if (!empty($conf->tax->enabled)) require_once DOL_DOCUMENT_ROOT.'/compta/sociales/class/chargesociales.class.php'; if (!empty($conf->tax->enabled)) require_once DOL_DOCUMENT_ROOT.'/compta/sociales/class/chargesociales.class.php';
if (!empty($conf->banque->enabled)) require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/paymentvarious.class.php'; if (!empty($conf->banque->enabled)) require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/paymentvarious.class.php';
if (!empty($conf->salaries->enabled)) require_once DOL_DOCUMENT_ROOT.'/salaries/class/paymentsalary.class.php'; if (!empty($conf->salaries->enabled)) require_once DOL_DOCUMENT_ROOT.'/salaries/class/salary.class.php';
if (!empty($conf->categorie->enabled)) require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; if (!empty($conf->categorie->enabled)) require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
if (!empty($conf->mrp->enabled)) require_once DOL_DOCUMENT_ROOT.'/mrp/class/mo.class.php'; if (!empty($conf->mrp->enabled)) require_once DOL_DOCUMENT_ROOT.'/mrp/class/mo.class.php';
@@ -487,7 +488,7 @@ $listofreferent = array(
'salaries'=>array( 'salaries'=>array(
'name'=>"Salaries", 'name'=>"Salaries",
'title'=>"ListSalariesAssociatedProject", 'title'=>"ListSalariesAssociatedProject",
'class'=>'PaymentSalary', 'class'=>'Salary',
'table'=>'payment_salary', 'table'=>'payment_salary',
'datefieldname'=>'datev', 'datefieldname'=>'datev',
'margin'=>'minus', 'margin'=>'minus',

View File

@@ -27,6 +27,7 @@
require '../main.inc.php'; require '../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
require_once DOL_DOCUMENT_ROOT.'/salaries/class/salary.class.php';
require_once DOL_DOCUMENT_ROOT.'/salaries/class/paymentsalary.class.php'; require_once DOL_DOCUMENT_ROOT.'/salaries/class/paymentsalary.class.php';
require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/salaries.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/salaries.lib.php';
@@ -38,7 +39,7 @@ if (!empty($conf->projet->enabled))
} }
// Load translation files required by the page // Load translation files required by the page
$langs->loadLangs(array("compta", "banks", "bills", "users", "salaries", "hrm")); $langs->loadLangs(array("compta", "banks", "bills", "users", "salaries", "hrm", "trips"));
if (!empty($conf->projet->enabled)) $langs->load("projects"); if (!empty($conf->projet->enabled)) $langs->load("projects");
$id = GETPOST("id", 'int'); $id = GETPOST("id", 'int');
@@ -46,18 +47,21 @@ $action = GETPOST('action', 'aZ09');
$cancel = GETPOST('cancel', 'aZ09'); $cancel = GETPOST('cancel', 'aZ09');
$accountid = GETPOST('accountid', 'int') > 0 ? GETPOST('accountid', 'int') : 0; $accountid = GETPOST('accountid', 'int') > 0 ? GETPOST('accountid', 'int') : 0;
$projectid = (GETPOST('projectid', 'int') ? GETPOST('projectid', 'int') : GETPOST('fk_project', 'int')); $projectid = (GETPOST('projectid', 'int') ? GETPOST('projectid', 'int') : GETPOST('fk_project', 'int'));
$confirm = GETPOST('confirm');
$auto_create_paiement = GETPOST("auto_create_paiement", "int");
$datep = dol_mktime(12, 0, 0, GETPOST("datepmonth", 'int'), GETPOST("datepday", 'int'), GETPOST("datepyear", 'int')); $datep = dol_mktime(12, 0, 0, GETPOST("datepmonth", 'int'), GETPOST("datepday", 'int'), GETPOST("datepyear", 'int'));
$datev = dol_mktime(12, 0, 0, GETPOST("datevmonth", 'int'), GETPOST("datevday", 'int'), GETPOST("datevyear", 'int')); $datev = dol_mktime(12, 0, 0, GETPOST("datevmonth", 'int'), GETPOST("datevday", 'int'), GETPOST("datevyear", 'int'));
$datesp = dol_mktime(12, 0, 0, GETPOST("datespmonth", 'int'), GETPOST("datespday", 'int'), GETPOST("datespyear", 'int')); $datesp = dol_mktime(12, 0, 0, GETPOST("datespmonth", 'int'), GETPOST("datespday", 'int'), GETPOST("datespyear", 'int'));
$dateep = dol_mktime(12, 0, 0, GETPOST("dateepmonth", 'int'), GETPOST("dateepday", 'int'), GETPOST("dateepyear", 'int')); $dateep = dol_mktime(12, 0, 0, GETPOST("dateepmonth", 'int'), GETPOST("dateepday", 'int'), GETPOST("dateepyear", 'int'));
$label = GETPOST('label');
// Security check // Security check
$socid = GETPOST("socid", "int"); $socid = GETPOST("socid", "int");
if ($user->socid) $socid = $user->socid; if ($user->socid) $socid = $user->socid;
$result = restrictedArea($user, 'salaries', '', '', ''); $result = restrictedArea($user, 'salaries', '', '', '');
$object = new PaymentSalary($db); $object = new Salary($db);
$extrafields = new ExtraFields($db); $extrafields = new ExtraFields($db);
// fetch optionals attributes and labels // fetch optionals attributes and labels
@@ -77,11 +81,49 @@ if ($cancel)
exit; exit;
} }
// Link to a project if ($action == 'setlabel' && $user->rights->salaries->write) {
if ($action == 'classin' && $user->rights->banque->modifier) $object->fetch($id);
$object->label = $label;
$object->update($user);
}
// Classify paid
if ($action == 'confirm_paid' && $user->rights->salaries->write && $confirm == 'yes')
{ {
$object->fetch($id); $object->fetch($id);
$object->setProject($projectid); $result = $object->set_paid($user);
}
if ($action == 'reopen' && $user->rights->salaries->write) {
$result = $object->fetch($id);
if ($object->paye)
{
$result = $object->set_unpaid($user);
if ($result > 0)
{
header('Location: '.$_SERVER["PHP_SELF"].'?id='.$id);
exit();
} else {
setEventMessages($object->error, $object->errors, 'errors');
}
}
}
// payment mode
if ($action == 'setmode' && $user->rights->salaries->write) {
$object->fetch($id);
$result = $object->setPaymentMethods(GETPOST('mode_reglement_id', 'int'));
if ($result < 0)
setEventMessages($object->error, $object->errors, 'errors');
}
// bank account
if ($action == 'setbankaccount' && $user->rights->salaries->write) {
$object->fetch($id);
$result = $object->setBankAccount(GETPOST('fk_account', 'int'));
if ($result < 0) {
setEventMessages($object->error, $object->errors, 'errors');
}
} }
if ($action == 'add' && empty($cancel)) if ($action == 'add' && empty($cancel))
@@ -90,13 +132,13 @@ if ($action == 'add' && empty($cancel))
if (empty($datev)) $datev = $datep; if (empty($datev)) $datev = $datep;
$type_payment = dol_getIdFromCode($db, GETPOST("paymenttype", 'alpha'), 'c_paiement', 'code', 'id', 1); $type_payment = GETPOST("paymenttype", 'alpha');
$object->amount = $amount = price2num(GETPOST("amount", 'alpha'));
$object->accountid = GETPOST("accountid", 'int') > 0 ? GETPOST("accountid", "int") : 0; $object->accountid = GETPOST("accountid", 'int') > 0 ? GETPOST("accountid", "int") : 0;
$object->fk_user = GETPOST("fk_user", 'int') > 0 ? GETPOST("fk_user", "int") : 0; $object->fk_user = GETPOST("fk_user", 'int') > 0 ? GETPOST("fk_user", "int") : 0;
$object->datev = $datev; $object->datev = $datev;
$object->datep = $datep; $object->datep = $datep;
$object->amount = price2num(GETPOST("amount", 'alpha'));
$object->label = GETPOST("label", 'alphanohtml'); $object->label = GETPOST("label", 'alphanohtml');
$object->datesp = $datesp; $object->datesp = $datesp;
$object->dateep = $dateep; $object->dateep = $dateep;
@@ -115,7 +157,11 @@ if ($action == 'add' && empty($cancel))
$ret = $extrafields->setOptionalsFromPost(null, $object); $ret = $extrafields->setOptionalsFromPost(null, $object);
if ($ret < 0) $error++; if ($ret < 0) $error++;
if (empty($datep) || empty($datev) || empty($datesp) || empty($dateep)) if (!empty($auto_create_paiement) && empty($datep)) {
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("DATE_PAIEMENT")), null, 'errors');
$error++;
}
if (empty($datesp) || empty($dateep))
{ {
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Date")), null, 'errors'); setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Date")), null, 'errors');
$error++; $error++;
@@ -125,7 +171,7 @@ if ($action == 'add' && empty($cancel))
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Employee")), null, 'errors'); setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Employee")), null, 'errors');
$error++; $error++;
} }
if (empty($type_payment) || $type_payment < 0) if (!empty($auto_create_paiement) && (empty($type_payment) || $type_payment < 0))
{ {
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("PaymentMode")), null, 'errors'); setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("PaymentMode")), null, 'errors');
$error++; $error++;
@@ -135,7 +181,7 @@ if ($action == 'add' && empty($cancel))
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Amount")), null, 'errors'); setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Amount")), null, 'errors');
$error++; $error++;
} }
if (!empty($conf->banque->enabled) && !$object->accountid > 0) if (!empty($conf->banque->enabled) && !empty($auto_create_paiement) && !$object->accountid > 0)
{ {
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("BankAccount")), null, 'errors'); setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("BankAccount")), null, 'errors');
$error++; $error++;
@@ -143,73 +189,171 @@ if ($action == 'add' && empty($cancel))
if (!$error) if (!$error)
{ {
$db->begin();
$ret = $object->create($user); $ret = $object->create($user);
if ($ret > 0) if ($ret < 0) $error++;
if (!empty($auto_create_paiement) && !$error)
{ {
$db->commit(); $db->begin();
// Create a line of payments
$paiement = new PaymentSalary($db);
$paiement->chid = $object->id;
$paiement->datepaye = $datep;
$paiement->datev = $datev;
$paiement->amounts = array($object->id=>$amount); // Tableau de montant
$paiement->paiementtype = $type_payment;
$paiement->num_payment = GETPOST("num_payment", 'alphanohtml');
$paiement->note = GETPOST("note", 'none');
if (!$error)
{
$paymentid = $paiement->create($user, (int) GETPOST('closepaidsalary'));
if ($paymentid < 0)
{
$error++;
setEventMessages($paiement->error, null, 'errors');
$action = 'create';
}
}
if (!$error)
{
$result = $paiement->addPaymentToBank($user, 'payment_salary', '(SalaryPayment)', GETPOST('accountid', 'int'), '', '');
if (!($result > 0))
{
$error++;
setEventMessages($paiement->error, null, 'errors');
}
}
if (!$error)
{
$db->commit();
}
else {
$db->rollback();
}
}
if(empty($error)) {
if (GETPOST('saveandnew', 'alpha')) { if (GETPOST('saveandnew', 'alpha')) {
setEventMessages($langs->trans("RecordSaved"), '', 'mesgs'); setEventMessages($langs->trans("RecordSaved"), '', 'mesgs');
header("Location: card.php?action=create&fk_project=".urlencode($projectid)."&accountid=".urlencode($accountid).'&paymenttype='.urlencode(GETPOST('paymenttype', 'az09')).'&datepday='.GETPOST("datepday", 'int').'&datepmonth='.GETPOST("datepmonth", 'int').'&datepyear='.GETPOST("datepyear", 'int')); header("Location: card.php?action=create&fk_project=" . urlencode($projectid) . "&accountid=" . urlencode($accountid) . '&paymenttype=' . urlencode(GETPOST('paymenttype', 'az09')) . '&datepday=' . GETPOST("datepday", 'int') . '&datepmonth=' . GETPOST("datepmonth", 'int') . '&datepyear=' . GETPOST("datepyear", 'int'));
exit; exit;
} else { } else {
header("Location: list.php"); header("Location: " . $_SERVER['PHP_SELF'] . '?id=' . $object->id);
exit; exit;
} }
} }
else
{
$db->rollback();
setEventMessages($object->error, $object->errors, 'errors');
$action = "create";
}
} }
$action = 'create'; $action = 'create';
} }
if ($action == 'delete') if ($action == 'confirm_delete')
{ {
$result = $object->fetch($id); $result = $object->fetch($id);
$totalpaye = $object->getSommePaiement();
if ($object->rappro == 0) if (empty($totalpaye))
{ {
$db->begin(); $db->begin();
$ret = $object->delete($user); $ret = $object->delete($user);
if ($ret > 0) if ($ret > 0)
{ {
if ($object->fk_bank) $db->commit();
{ header("Location: ".DOL_URL_ROOT.'/salaries/list.php');
$accountline = new AccountLine($db); exit;
$result = $accountline->fetch($object->fk_bank);
if ($result > 0) $result = $accountline->delete($user); // $result may be 0 if not found (when bank entry was deleted manually and fk_bank point to nothing)
}
if ($result >= 0)
{
$db->commit();
header("Location: ".DOL_URL_ROOT.'/salaries/list.php');
exit;
}
else
{
$object->error = $accountline->error;
$db->rollback();
setEventMessages($object->error, $object->errors, 'errors');
}
} }
else else {
{
$db->rollback(); $db->rollback();
setEventMessages($object->error, $object->errors, 'errors'); setEventMessages($object->error, $object->errors, 'errors');
} }
} }
else else {
setEventMessages($langs->trans('DisabledBecausePayments'), null, 'errors');
}
}
if ($action == 'update' && !$_POST["cancel"] && $user->rights->salaries->write)
{
$amount = price2num(GETPOST('amount'));
if (empty($amount))
{ {
setEventMessages('Error try do delete a line linked to a conciliated bank transaction', null, 'errors'); setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Amount")), null, 'errors');
$action = 'edit';
}
elseif (!is_numeric($amount))
{
setEventMessages($langs->trans("ErrorFieldMustBeANumeric", $langs->transnoentities("Amount")), null, 'errors');
$action = 'create';
}
else {
$result = $object->fetch($id);
$object->amount = price2num($amount);
$object->datesp = price2num($datesp);
$object->dateep = price2num($dateep);
$result = $object->update($user);
if ($result <= 0) {
setEventMessages($object->error, $object->errors, 'errors');
}
}
}
if ($action == 'confirm_clone' && $confirm != 'yes') { $action = ''; }
if ($action == 'confirm_clone' && $confirm == 'yes' && ($user->rights->salaries->write))
{
$db->begin();
$originalId = $id;
$object->fetch($id);
if ($object->id > 0)
{
$object->paye = 0;
$object->id = $object->ref = null;
if (GETPOST('clone_label', 'alphanohtml')) {
$object->label = GETPOST('clone_label', 'alphanohtml');
}
else {
$object->label = $langs->trans("CopyOf").' '.$object->label;
}
$newdatestart = dol_mktime(0, 0, 0, GETPOST('clone_date_startmonth', 'int'), GETPOST('clone_date_startday', 'int'), GETPOST('clone_date_startyear', 'int'));
$newdateend = dol_mktime(0, 0, 0, GETPOST('clone_date_endmonth', 'int'), GETPOST('clone_date_endday', 'int'), GETPOST('clone_date_endyear', 'int'));
if ($newdatestart) $object->datesp = $newdatestart;
if ($newdateend) $object->dateep = $newdateend;
//if ($object->check()) {
$id = $object->create($user);
if ($id > 0)
{
$db->commit();
$db->close();
header("Location: ".$_SERVER["PHP_SELF"]."?id=".$id);
exit;
}
else {
$id = $originalId;
$db->rollback();
setEventMessages($object->error, $object->errors, 'errors');
}
//}
}
else {
$db->rollback();
dol_print_error($db, $object->error);
} }
} }
@@ -218,14 +362,14 @@ if ($action == 'delete')
* View * View
*/ */
llxHeader("", $langs->trans("SalaryPayment")); llxHeader("", $langs->trans("Salary"));
$form = new Form($db); $form = new Form($db);
if (!empty($conf->projet->enabled)) $formproject = new FormProjets($db); if (!empty($conf->projet->enabled)) $formproject = new FormProjets($db);
if ($id) if ($id)
{ {
$object = new PaymentSalary($db); $object = new Salary($db);
$result = $object->fetch($id); $result = $object->fetch($id);
if ($result <= 0) if ($result <= 0)
{ {
@@ -266,22 +410,48 @@ if ($action == 'create')
print load_fiche_titre($langs->trans("NewSalaryPayment"), '', 'object_payment'); print load_fiche_titre($langs->trans("NewSalaryPayment"), '', 'object_payment');
if (!empty($conf->use_javascript_ajax))
{
print "\n".'<script type="text/javascript" language="javascript">';
print '$(document).ready(function () {
$("#radiopayment").click(function() {
$("#label").val($(this).data("label"));
});
$("#radiorefund").click(function() {
$("#label").val($(this).data("label"));
});
$("#auto_create_paiement").click(function() {
if($(this).is(":checked")) {
$("#label_fk_account").find("span").addClass("fieldrequired");
$("#label_type_payment").find("span").addClass("fieldrequired");
$(".hide_if_no_auto_create_payment").show();
} else {
$("#label_fk_account").find("span").removeClass("fieldrequired");
$("#label_type_payment").find("span").removeClass("fieldrequired");
$(".hide_if_no_auto_create_payment").hide();
}
});';
if ($_REQUEST['action'] === 'add') { // form has been send but there is at least one error
if (empty($auto_create_paiement)) {
print '$("#label_fk_account").find("span").removeClass("fieldrequired");
$("#label_type_payment").find("span").removeClass("fieldrequired");
$(".hide_if_no_auto_create_payment").hide();';
} else {
print '$("#label_fk_account").find("span").addClass("fieldrequired");
$("#label_type_payment").find("span").addClass("fieldrequired");
$(".hide_if_no_auto_create_payment").show();';
}
}
print '});';
print '</script>'."\n";
}
dol_fiche_head('', ''); dol_fiche_head('', '');
print '<table class="border centpercent">'; print '<table class="border centpercent">';
// Date payment
print '<tr><td>';
print $form->editfieldkey('DatePayment', 'datep', '', $object, 0, 'string', '', 1).'</td><td>';
print $form->selectDate((empty($datep) ?-1 : $datep), "datep", '', '', '', 'add', 1, 1);
print '</td></tr>';
// Date value for bank
print '<tr><td>';
print $form->editfieldkey('DateValue', 'datev', '', $object, 0).'</td><td>';
print $form->selectDate((empty($datev) ?-1 : $datev), "datev", '', '', '', 'add', 1, 1);
print '</td></tr>';
// Label // Label
print '<tr><td>'; print '<tr><td>';
print $form->editfieldkey('Label', 'label', '', $object, 0, 'string', '', 1).'</td><td>'; print $form->editfieldkey('Label', 'label', '', $object, 0, 'string', '', 1).'</td><td>';
@@ -326,28 +496,55 @@ if ($action == 'create')
// Bank // Bank
if (!empty($conf->banque->enabled)) if (!empty($conf->banque->enabled))
{ {
print '<tr><td>'; print '<tr><td id="label_fk_account">';
print $form->editfieldkey('BankAccount', 'selectaccountid', '', $object, 0, 'string', '', 1).'</td><td>'; print $form->editfieldkey('BankAccount', 'selectaccountid', '', $object, 0, 'string', '', 1).'</td><td>';
$form->select_comptes($accountid, "accountid", 0, '', 1); // Affiche liste des comptes courant $form->select_comptes($accountid, "accountid", 0, '', 1); // Affiche liste des comptes courant
print '</td></tr>'; print '</td></tr>';
} }
// Type payment // Type payment
print '<tr><td>'; print '<tr><td id="label_type_payment">';
print $form->editfieldkey('PaymentMode', 'selectpaymenttype', '', $object, 0, 'string', '', 1).'</td><td>'; print $form->editfieldkey('PaymentMode', 'selectpaymenttype', '', $object, 0, 'string', '', 1).'</td><td>';
$form->select_types_paiements(GETPOST("paymenttype", 'aZ09'), "paymenttype", '', 2); $form->select_types_paiements(GETPOST("paymenttype", 'aZ09'), "paymenttype", '');
print '</td></tr>';
// Auto create payment
print '<tr><td>'.$langs->trans('AutomaticCreationPayment').'</td>';
print '<td><input id="auto_create_paiement" name="auto_create_paiement" type="checkbox" '.($_REQUEST['action'] === 'add' ? (empty($auto_create_paiement) ? '' : 'checked="checked"') : 'checked="checked"').' value="1"></td></tr>'."\n";
// Date payment
print '<tr class="hide_if_no_auto_create_payment"><td>';
print $form->editfieldkey('DatePayment', 'datep', '', $object, 0, 'string', '', 1).'</td><td>';
print $form->selectDate((empty($datep) ?-1 : $datep), "datep", '', '', '', 'add', 1, 1);
print '</td></tr>';
// Date value for bank
print '<tr class="hide_if_no_auto_create_payment"><td>';
print $form->editfieldkey('DateValue', 'datev', '', $object, 0).'</td><td>';
print $form->selectDate((empty($datev) ?-1 : $datev), "datev", '', '', '', 'add', 1, 1);
print '</td></tr>'; print '</td></tr>';
// Number // Number
if (!empty($conf->banque->enabled)) if (!empty($conf->banque->enabled))
{ {
// Number // Number
print '<tr><td><label for="num_payment">'.$langs->trans('Numero'); print '<tr class="hide_if_no_auto_create_payment"><td><label for="num_payment">'.$langs->trans('Numero');
print ' <em>('.$langs->trans("ChequeOrTransferNumber").')</em>'; print ' <em>('.$langs->trans("ChequeOrTransferNumber").')</em>';
print '</label></td>'; print '</label></td>';
print '<td><input name="num_payment" id="num_payment" type="text" value="'.GETPOST("num_payment").'"></td></tr>'."\n"; print '<td><input name="num_payment" id="num_payment" type="text" value="'.GETPOST("num_payment").'"></td></tr>'."\n";
} }
// Comments
print '<tr class="hide_if_no_auto_create_payment">';
print '<td class="tdtop">'.$langs->trans("Comments").'</td>';
print '<td class="tdtop"><textarea name="note" wrap="soft" cols="60" rows="'.ROWS_3.'"></textarea></td>';
print '</tr>';
// Bouton Save payment
print '<tr class="hide_if_no_auto_create_payment"><td>';
print $langs->trans("ClosePaidSalaryAutomatically");
print '</td><td><input type="checkbox" checked value="1" name="closepaidsalary"></td></tr>';
// Other attributes // Other attributes
$parameters = array(); $parameters = array();
$reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
@@ -383,7 +580,38 @@ if ($id)
{ {
$head = salaries_prepare_head($object); $head = salaries_prepare_head($object);
dol_fiche_head($head, 'card', $langs->trans("SalaryPayment"), -1, 'payment'); if ($action === 'clone')
{
$formquestion = array(
array('type' => 'text', 'name' => 'clone_label', 'label' => $langs->trans("Label"), 'value' => $langs->trans("CopyOf").' '.$object->label),
);
//$formquestion[] = array('type' => 'date', 'name' => 'clone_date_ech', 'label' => $langs->trans("Date"), 'value' => -1);
$formquestion[] = array('type' => 'date', 'name' => 'clone_date_start', 'label' => $langs->trans("DateStart"), 'value' => -1);
$formquestion[] = array('type' => 'date', 'name' => 'clone_date_end', 'label' => $langs->trans("DateEnd"), 'value' => -1);
print $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ToClone'), $langs->trans('ConfirmCloneSalary', $object->ref), 'confirm_clone', $formquestion, 'yes', 1, 240);
}
if ($action == 'paid')
{
$text = $langs->trans('ConfirmPaySalary');
print $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$object->id, $langs->trans('PaySalary'), $text, "confirm_paid", '', '', 2);
}
if ($action == 'delete')
{
$text = $langs->trans('ConfirmDeleteSalary');
print $form->formconfirm($_SERVER['PHP_SELF'].'?id='.$object->id, $langs->trans('DeleteSalary'), $text, 'confirm_delete', '', '', 2);
}
if ($action == 'edit')
{
print "<form name=\"charge\" action=\"".$_SERVER["PHP_SELF"]."?id=$object->id&amp;action=update\" method=\"post\">";
print '<input type="hidden" name="token" value="'.newToken().'">';
}
dol_fiche_head($head, 'card', $langs->trans("Salary"), -1, 'payment');
$linkback = '<a href="'.DOL_URL_ROOT.'/salaries/list.php?restore_lastsearch_values=1'.(!empty($socid) ? '&socid='.$socid : '').'">'.$langs->trans("BackToList").'</a>'; $linkback = '<a href="'.DOL_URL_ROOT.'/salaries/list.php?restore_lastsearch_values=1'.(!empty($socid) ? '&socid='.$socid : '').'">'.$langs->trans("BackToList").'</a>';
@@ -426,82 +654,296 @@ if ($id)
} }
} }
} }
// Label
if ($action != 'editlabel') {
$morehtmlref .= '<br>' . $form->editfieldkey("Label", 'label', $object->label, $object, $user->rights->salaries->write, 'string', '', 0, 1);
$morehtmlref .= $object->label;
} else {
$morehtmlref .= '<br>'.$langs->trans('Label').' :&nbsp;';
$morehtmlref .= '<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">';
$morehtmlref .= '<input type="hidden" name="action" value="setlabel">';
$morehtmlref .= '<input type="hidden" name="token" value="'.newToken().'">';
$morehtmlref .= '<input type="text" name="label" value="'.$object->label.'"/>';
$morehtmlref .= '<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">';
$morehtmlref .= '</form>';
}
$morehtmlref .= '</div>'; $morehtmlref .= '</div>';
$totalpaye = $object->getSommePaiement();
$object->totalpaye = $totalpaye;
dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'ref', $morehtmlref, '', 0, '', ''); dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'ref', $morehtmlref, '', 0, '', '');
print '<div class="fichecenter">'; print '<div class="fichecenter">';
print '<div class="fichehalfleft">';
print '<div class="underbanner clearboth"></div>'; print '<div class="underbanner clearboth"></div>';
print '<table class="border centpercent">'; print '<table class="border centpercent">';
// Label if ($action == 'edit')
print '<tr><td class="titlefield">'.$langs->trans("Label").'</td><td>'.$object->label.'</td></tr>'; {
print '<tr><td>'.$langs->trans("DateStartPeriod")."</td><td>";
print $form->selectDate($object->datesp, 'datesp', 0, 0, 0, 'datesp', 1);
print "</td></tr>";
print "<tr>"; } else {
print '<td>'.$langs->trans("DateStartPeriod").'</td><td>'; print "<tr>";
print dol_print_date($object->datesp, 'day'); print '<td>' . $langs->trans("DateStartPeriod") . '</td><td>';
print '</td></tr>'; print dol_print_date($object->datesp, 'day');
print '</td></tr>';
}
print '<tr><td>'.$langs->trans("DateEndPeriod").'</td><td>';
print dol_print_date($object->dateep, 'day');
print '</td></tr>';
print "<tr>"; if ($action == 'edit')
{
print '<tr><td>'.$langs->trans("DateEndPeriod")."</td><td>";
print $form->selectDate($object->dateep, 'dateep', 0, 0, 0, 'dateep', 1);
print "</td></tr>";
} else {
print "<tr>";
print '<td>' . $langs->trans("DateEndPeriod") . '</td><td>';
print dol_print_date($object->dateep, 'day');
print '</td></tr>';
}
/*print "<tr>";
print '<td>'.$langs->trans("DatePayment").'</td><td>'; print '<td>'.$langs->trans("DatePayment").'</td><td>';
print dol_print_date($object->datep, 'day'); print dol_print_date($object->datep, 'day');
print '</td></tr>'; print '</td></tr>';
print '<tr><td>'.$langs->trans("DateValue").'</td><td>'; print '<tr><td>'.$langs->trans("DateValue").'</td><td>';
print dol_print_date($object->datev, 'day'); print dol_print_date($object->datev, 'day');
print '</td></tr>'; print '</td></tr>';*/
print '<tr><td>'.$langs->trans("Amount").'</td><td>'.price($object->amount, 0, $outputlangs, 1, -1, -1, $conf->currency).'</td></tr>'; if ($action == 'edit') {
print '<tr><td class="fieldrequired">' . $langs->trans("Amount") . '</td><td><input name="amount" size="10" value="' . $object->amount . '"></td></tr>';
if (!empty($conf->banque->enabled)) } else {
{ print '<tr><td>' . $langs->trans("Amount") . '</td><td>' . price($object->amount, 0, $outputlangs, 1, -1, -1, $conf->currency) . '</td></tr>';
if ($object->fk_account > 0)
{
$bankline = new AccountLine($db);
$bankline->fetch($object->fk_bank);
print '<tr>';
print '<td>'.$langs->trans('BankTransactionLine').'</td>';
print '<td>';
print $bankline->getNomUrl(1, 0, 'showall');
print '</td>';
print '</tr>';
}
} }
// Other attributes // Mode of payment
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php'; print '<tr><td>';
print '<table class="nobordernopadding" width="100%"><tr><td>';
print $langs->trans('PaymentMode');
print '</td>';
if ($action != 'editmode')
print '<td class="right"><a class="editfielda" href="'.$_SERVER["PHP_SELF"].'?action=editmode&amp;id='.$object->id.'">'.img_edit($langs->trans('SetMode'), 1).'</a></td>';
print '</tr></table>';
print '</td><td>';
if ($action == 'editmode') {
$form->form_modes_reglement($_SERVER['PHP_SELF'].'?id='.$object->id, $object->type_payment, 'mode_reglement_id');
} else {
$form->form_modes_reglement($_SERVER['PHP_SELF'].'?id='.$object->id, $object->type_payment, 'none');
}
print '</td></tr>';
// Bank Account
if (!empty($conf->banque->enabled))
{
print '<tr><td class="nowrap">';
print '<table width="100%" class="nobordernopadding"><tr><td class="nowrap">';
print $langs->trans('BankAccount');
print '<td>';
if ($action != 'editbankaccount' && $user->rights->salaries->write)
print '<td class="right"><a class="editfielda" href="'.$_SERVER["PHP_SELF"].'?action=editbankaccount&amp;id='.$object->id.'">'.img_edit($langs->trans('SetBankAccount'), 1).'</a></td>';
print '</tr></table>';
print '</td><td>';
if ($action == 'editbankaccount') {
$form->formSelectAccount($_SERVER['PHP_SELF'].'?id='.$object->id, $object->fk_account, 'fk_account', 1);
} else {
$form->formSelectAccount($_SERVER['PHP_SELF'].'?id='.$object->id, $object->fk_account, 'none');
}
print '</td>';
print '</tr>';
}
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php';
print '</table>'; print '</table>';
print '</div>'; print '</div>';
print '<div class="fichehalfright">';
print '<div class="ficheaddleft">';
$nbcols = 3;
if (!empty($conf->banque->enabled)) {
$nbcols++;
}
/*
* Payments
*/
$sql = "SELECT p.rowid, p.num_paiement as num_payment, p.datep as dp, p.amount,";
$sql .= " c.code as type_code,c.libelle as paiement_type,";
$sql .= ' ba.rowid as baid, ba.ref as baref, ba.label, ba.number as banumber, ba.account_number, ba.currency_code as bacurrency_code, ba.fk_accountancy_journal';
$sql .= " FROM ".MAIN_DB_PREFIX."payment_salary as p";
$sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'bank as b ON p.fk_bank = b.rowid';
$sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'bank_account as ba ON b.fk_account = ba.rowid';
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as c ON p.fk_typepaiement = c.id";
$sql .= ", ".MAIN_DB_PREFIX."salary as salaire";
$sql .= " WHERE p.fk_salary = ".$id;
$sql .= " AND p.fk_salary = salaire.rowid";
$sql .= " AND salaire.entity IN (".getEntity('tax').")";
$sql .= " ORDER BY dp DESC";
//print $sql;
$resql = $db->query($sql);
if ($resql)
{
$totalpaye = 0;
$num = $db->num_rows($resql);
$i = 0; $total = 0;
print '<div class="div-table-responsive-no-min">'; // You can use div-table-responsive-no-min if you dont need reserved height for your table
print '<table class="noborder paymenttable">';
print '<tr class="liste_titre">';
print '<td>'.$langs->trans("RefPayment").'</td>';
print '<td>'.$langs->trans("Date").'</td>';
print '<td>'.$langs->trans("Type").'</td>';
if (!empty($conf->banque->enabled)) {
print '<td class="liste_titre right">'.$langs->trans('BankAccount').'</td>';
}
print '<td class="right">'.$langs->trans("Amount").'</td>';
print '</tr>';
if ($num > 0)
{
$bankaccountstatic = new Account($db);
while ($i < $num)
{
$objp = $db->fetch_object($resql);
print '<tr class="oddeven"><td>';
print '<a href="'.DOL_URL_ROOT.'/salaries/payment_salary/card.php?id='.$objp->rowid.'">'.img_object($langs->trans("Payment"), "payment").' '.$objp->rowid.'</a></td>';
print '<td>'.dol_print_date($db->jdate($objp->dp), 'day')."</td>\n";
$labeltype = $langs->trans("PaymentType".$objp->type_code) != ("PaymentType".$objp->type_code) ? $langs->trans("PaymentType".$objp->type_code) : $objp->paiement_type;
print "<td>".$labeltype.' '.$objp->num_payment."</td>\n";
if (!empty($conf->banque->enabled))
{
$bankaccountstatic->id = $objp->baid;
$bankaccountstatic->ref = $objp->baref;
$bankaccountstatic->label = $objp->baref;
$bankaccountstatic->number = $objp->banumber;
$bankaccountstatic->currency_code = $objp->bacurrency_code;
if (!empty($conf->accounting->enabled)) {
$bankaccountstatic->account_number = $objp->account_number;
$accountingjournal = new AccountingJournal($db);
$accountingjournal->fetch($objp->fk_accountancy_journal);
$bankaccountstatic->accountancy_journal = $accountingjournal->getNomUrl(0, 1, 1, '', 1);
}
print '<td class="right">';
if ($bankaccountstatic->id)
print $bankaccountstatic->getNomUrl(1, 'transactions');
print '</td>';
}
print '<td class="right">'.price($objp->amount)."</td>\n";
print "</tr>";
$totalpaye += $objp->amount;
$i++;
}
}
else {
print '<tr class="oddeven"><td><span class="opacitymedium">'.$langs->trans("None").'</span></td>';
print '<td></td><td></td><td></td><td></td>';
print '</tr>';
}
print '<tr><td colspan="'.$nbcols.'" class="right">'.$langs->trans("AlreadyPaid")." :</td><td class=\"right\">".price($totalpaye)."</td></tr>\n";
print '<tr><td colspan="'.$nbcols.'" class="right">'.$langs->trans("AmountExpected")." :</td><td class=\"right\">".price($object->amount)."</td></tr>\n";
$resteapayer = $object->amount - $totalpaye;
$cssforamountpaymentcomplete = 'amountpaymentcomplete';
print '<tr><td colspan="'.$nbcols.'" class="right">'.$langs->trans("RemainderToPay")." :</td>";
print '<td class="right'.($resteapayer ? ' amountremaintopay' : (' '.$cssforamountpaymentcomplete)).'">'.price($resteapayer)."</td></tr>\n";
print "</table>";
print '</div>';
$db->free($resql);
}
else {
dol_print_error($db);
}
print '</div>';
print '</div>';
print '</div>';
print '<div class="clearboth"></div>';
dol_fiche_end(); dol_fiche_end();
if ($action == 'edit')
{
print '<div align="center">';
print '<input type="submit" class="button" name="save" value="'.$langs->trans("Save").'">';
print ' &nbsp; ';
print '<input type="submit" class="button" name="cancel" value="'.$langs->trans("Cancel").'">';
print '</div>';
print "</form>\n";
}
/* /*
* Action buttons * Action buttons
*/ */
print '<div class="tabsAction">'."\n"; print '<div class="tabsAction">'."\n";
if ($object->rappro == 0) if ($action != 'edit')
{ {
if (!empty($user->rights->salaries->delete)) // Reopen
if ($object->paye && $user->rights->salaries->write)
{ {
print '<div class="inline-block divButAction"><a class="butActionDelete" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&action=delete">'.$langs->trans("Delete").'</a></div>'; print "<div class=\"inline-block divButAction\"><a class=\"butAction\" href=\"".dol_buildpath("/salaries/card.php", 1)."?id=$object->id&amp;action=reopen\">".$langs->trans("ReOpen")."</a></div>";
} }
else
// Edit
if ($object->paye == 0 && $user->rights->salaries->write)
{ {
print '<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#" title="'.(dol_escape_htmltag($langs->trans("NotAllowed"))).'">'.$langs->trans("Delete").'</a></div>'; print "<div class=\"inline-block divButAction\"><a class=\"butAction\" href=\"".DOL_URL_ROOT."/salaries/card.php?id=$object->id&amp;action=edit\">".$langs->trans("Modify")."</a></div>";
}
// Emit payment
if ($object->paye == 0 && ((price2num($object->amount) < 0 && price2num($resteapayer, 'MT') < 0) || (price2num($object->amount) > 0 && price2num($resteapayer, 'MT') > 0)) && $user->rights->salaries->write)
{
print "<div class=\"inline-block divButAction\"><a class=\"butAction\" href=\"".DOL_URL_ROOT."/salaries/paiement_salary.php?id=$object->id&amp;action=create\">".$langs->trans("DoPayment")."</a></div>";
}
// Classify 'paid'
if ($object->paye == 0
&& (
(round($resteapayer) <= 0 && $object->amount > 0)
|| (round($resteapayer) >= 0 && $object->amount < 0)
)
&& $user->rights->salaries->write)
{
print "<div class=\"inline-block divButAction\"><a class=\"butAction\" href=\"".DOL_URL_ROOT."/salaries/card.php?id=$object->id&amp;action=paid\">".$langs->trans("ClassifyPaid")."</a></div>";
}
// Clone
if ($user->rights->salaries->write)
{
print "<div class=\"inline-block divButAction\"><a class=\"butAction\" href=\"".dol_buildpath("/salaries/card.php", 1)."?id=$object->id&amp;action=clone\">".$langs->trans("ToClone")."</a></div>";
}
if (!empty($user->rights->salaries->delete) && empty($totalpaye))
{
print '<div class="inline-block divButAction"><a class="butActionDelete" href="card.php?id='.$object->id.'&action=delete">'.$langs->trans("Delete").'</a></div>';
}
else {
print '<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#" title="'.(dol_escape_htmltag($langs->trans("DisabledBecausePayments"))).'">'.$langs->trans("Delete").'</a></div>';
} }
}
else
{
print '<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans("LinkedToAConciliatedTransaction").'">'.$langs->trans("Delete").'</a></div>';
} }
print "</div>"; print "</div>";
} }

File diff suppressed because it is too large Load Diff

View File

@@ -1,6 +1,7 @@
<?php <?php
/* Copyright (C) 2018 Alexandre Spangaro <aspangaro@open-dsi.fr> /* Copyright (C) 2018 Alexandre Spangaro <aspangaro@open-dsi.fr>
* Copyright (c) 2018 Fidesio <contact@fidesio.com> * Copyright (c) 2018 Fidesio <contact@fidesio.com>
* Copyright (C) 2021 Gauthier VERDOL <gauthier.verdol@atm-consulting.fr>
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@@ -80,7 +81,7 @@ class SalariesStats extends Stats
$sql = "SELECT YEAR(datep) as dm, count(*)"; $sql = "SELECT YEAR(datep) as dm, count(*)";
$sql .= " FROM ".$this->from; $sql .= " FROM ".$this->from;
$sql .= " GROUP BY dm DESC"; $sql .= " GROUP BY dm DESC";
$sql .= " WHERE ".$this->where; //$sql .= " WHERE ".$this->where;
return $this->_getNbByYear($sql); return $this->_getNbByYear($sql);
} }
@@ -98,7 +99,7 @@ class SalariesStats extends Stats
$sql = "SELECT MONTH(datep) as dm, count(*)"; $sql = "SELECT MONTH(datep) as dm, count(*)";
$sql .= " FROM ".$this->from; $sql .= " FROM ".$this->from;
$sql .= " WHERE YEAR(datep) = ".$year; $sql .= " WHERE YEAR(datep) = ".$year;
$sql .= " AND ".$this->where; //$sql .= " AND ".$this->where;
$sql .= " GROUP BY dm"; $sql .= " GROUP BY dm";
$sql .= $this->db->order('dm', 'DESC'); $sql .= $this->db->order('dm', 'DESC');
@@ -120,7 +121,7 @@ class SalariesStats extends Stats
$sql = "SELECT date_format(datep,'%m') as dm, sum(".$this->field.")"; $sql = "SELECT date_format(datep,'%m') as dm, sum(".$this->field.")";
$sql .= " FROM ".$this->from; $sql .= " FROM ".$this->from;
$sql .= " WHERE date_format(datep,'%Y') = '".$year."'"; $sql .= " WHERE date_format(datep,'%Y') = '".$year."'";
$sql .= " AND ".$this->where; //$sql .= " AND ".$this->where;
$sql .= " GROUP BY dm"; $sql .= " GROUP BY dm";
$sql .= $this->db->order('dm', 'DESC'); $sql .= $this->db->order('dm', 'DESC');
@@ -141,7 +142,7 @@ class SalariesStats extends Stats
$sql = "SELECT date_format(datep,'%m') as dm, avg(".$this->field.")"; $sql = "SELECT date_format(datep,'%m') as dm, avg(".$this->field.")";
$sql .= " FROM ".$this->from; $sql .= " FROM ".$this->from;
$sql .= " WHERE date_format(datep,'%Y') = '".$year."'"; $sql .= " WHERE date_format(datep,'%Y') = '".$year."'";
$sql .= " AND ".$this->where; //$sql .= " AND ".$this->where;
$sql .= " GROUP BY dm"; $sql .= " GROUP BY dm";
$sql .= $this->db->order('dm', 'DESC'); $sql .= $this->db->order('dm', 'DESC');
@@ -157,7 +158,7 @@ class SalariesStats extends Stats
{ {
$sql = "SELECT date_format(datep,'%Y') as year, count(*) as nb, sum(".$this->field.") as total, avg(".$this->field.") as avg"; $sql = "SELECT date_format(datep,'%Y') as year, count(*) as nb, sum(".$this->field.") as total, avg(".$this->field.") as avg";
$sql .= " FROM ".$this->from; $sql .= " FROM ".$this->from;
$sql .= " WHERE ".$this->where; //$sql .= " WHERE ".$this->where;
$sql .= " GROUP BY year"; $sql .= " GROUP BY year";
$sql .= $this->db->order('year', 'DESC'); $sql .= $this->db->order('year', 'DESC');

View File

@@ -0,0 +1,755 @@
<?php
/* Copyright (C) 2011-2019 Alexandre Spangaro <aspangaro@open-dsi.fr>
* Copyright (C) 2014 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2021 Gauthier VERDOL <gauthier.verdol@atm-consulting.fr>
*
* 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 <https://www.gnu.org/licenses/>.
*/
/**
* \file htdocs/salaries/class/salary.class.php
* \ingroup salaries
* \brief Class for salaries module payment
*/
// Put here all includes required by your class file
require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php';
/**
* Class to manage salary payments
*/
class Salary extends CommonObject
{
/**
* @var string ID to identify managed object
*/
public $element = 'salary';
/**
* @var string Name of table without prefix where object is stored
*/
public $table_element = 'salary';
/**
* @var string String with name of icon for myobject. Must be the part after the 'object_' into object_myobject.png
*/
public $picto = 'payment';
public $tms;
/**
* @var int User ID
*/
public $fk_user;
public $datep;
public $datev;
public $amount;
/**
* @var int ID
*/
public $fk_project;
public $type_payment;
public $num_payment;
/**
* @var string salary payments label
*/
public $label;
public $datesp;
public $dateep;
/**
* @var int ID
*/
public $fk_bank;
/**
* @var int ID
*/
public $fk_user_author;
/**
* @var int ID
*/
public $fk_user_modif;
const STATUS_UNPAID = 0;
const STATUS_PAID = 1;
/**
* Constructor
*
* @param DoliDB $db Database handler
*/
public function __construct($db)
{
$this->db = $db;
$this->element = 'salary';
$this->table_element = 'salary';
}
/**
* Update database
*
* @param User $user User that modify
* @param int $notrigger 0=no, 1=yes (no update trigger)
* @return int <0 if KO, >0 if OK
*/
public function update($user = null, $notrigger = 0)
{
global $conf, $langs;
$error = 0;
// Clean parameters
$this->amount = trim($this->amount);
$this->label = trim($this->label);
$this->note = trim($this->note);
// Check parameters
if (empty($this->fk_user) || $this->fk_user < 0)
{
$this->error = 'ErrorBadParameter';
return -1;
}
$this->db->begin();
// Update request
$sql = "UPDATE ".MAIN_DB_PREFIX."salary SET";
$sql .= " tms='".$this->db->idate(dol_now())."',";
$sql .= " fk_user=".$this->fk_user.",";
/*$sql .= " datep='".$this->db->idate($this->datep)."',";
$sql .= " datev='".$this->db->idate($this->datev)."',";*/
$sql .= " amount=".price2num($this->amount).",";
$sql .= " fk_projet=".((int) $this->fk_project).",";
$sql .= " fk_typepayment=".$this->type_payment.",";
$sql .= " num_payment='".$this->db->escape($this->num_payment)."',";
$sql .= " label='".$this->db->escape($this->label)."',";
$sql .= " datesp='".$this->db->idate($this->datesp)."',";
$sql .= " dateep='".$this->db->idate($this->dateep)."',";
$sql .= " note='".$this->db->escape($this->note)."',";
$sql .= " fk_bank=".($this->fk_bank > 0 ? (int) $this->fk_bank : "null").",";
$sql .= " fk_user_author=".((int) $this->fk_user_author).",";
$sql .= " fk_user_modif=".($this->fk_user_modif > 0 ? (int) $this->fk_user_modif : 'null');
$sql .= " WHERE rowid=".$this->id;
dol_syslog(get_class($this)."::update", LOG_DEBUG);
$resql = $this->db->query($sql);
if (!$resql)
{
$this->error = "Error ".$this->db->lasterror();
return -1;
}
// Update extrafield
if (!$error)
{
if (!$error)
{
$result = $this->insertExtraFields();
if ($result < 0)
{
$error++;
}
}
}
if (!$notrigger)
{
// Call trigger
$result = $this->call_trigger('salary_MODIFY', $user);
if ($result < 0) $error++;
// End call triggers
}
if (!$error)
{
$this->db->commit();
return 1;
}
else
{
$this->db->rollback();
return -1;
}
}
/**
* Load object in memory from database
*
* @param int $id id object
* @param User $user User that load
* @return int <0 if KO, >0 if OK
*/
public function fetch($id, $user = null)
{
global $langs;
$sql = "SELECT";
$sql .= " s.rowid,";
$sql .= " s.tms,";
$sql .= " s.fk_user,";
$sql .= " s.datep,";
$sql .= " s.datev,";
$sql .= " s.amount,";
$sql .= " s.fk_projet as fk_project,";
$sql .= " s.fk_typepayment,";
$sql .= " s.num_payment,";
$sql .= " s.label,";
$sql .= " s.datesp,";
$sql .= " s.dateep,";
$sql .= " s.note,";
$sql .= " s.paye,";
$sql .= " s.fk_bank,";
$sql .= " s.fk_user_author,";
$sql .= " s.fk_user_modif,";
$sql .= " s.fk_account";
/*$sql .= " b.fk_type,";
$sql .= " b.rappro";*/
$sql .= " FROM ".MAIN_DB_PREFIX."salary as s";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."bank as b ON s.fk_bank = b.rowid";
$sql .= " WHERE s.rowid = ".$id;
dol_syslog(get_class($this)."::fetch", LOG_DEBUG);
$resql = $this->db->query($sql);
if ($resql)
{
if ($this->db->num_rows($resql))
{
$obj = $this->db->fetch_object($resql);
$this->id = $obj->rowid;
$this->ref = $obj->rowid;
$this->tms = $this->db->jdate($obj->tms);
$this->fk_user = $obj->fk_user;
$this->datep = $this->db->jdate($obj->datep);
$this->datev = $this->db->jdate($obj->datev);
$this->amount = $obj->amount;
$this->fk_project = $obj->fk_project;
$this->type_payment = $obj->fk_typepayment;
$this->num_payment = $obj->num_payment;
$this->label = $obj->label;
$this->datesp = $this->db->jdate($obj->datesp);
$this->dateep = $this->db->jdate($obj->dateep);
$this->note = $obj->note;
$this->paye = $obj->paye;
$this->fk_bank = $obj->fk_bank;
$this->fk_user_author = $obj->fk_user_author;
$this->fk_user_modif = $obj->fk_user_modif;
$this->fk_account = $this->accountid = $obj->fk_account;
$this->fk_type = $obj->fk_type;
$this->rappro = $obj->rappro;
// Retreive all extrafield
// fetch optionals attributes and labels
$this->fetch_optionals();
}
$this->db->free($resql);
return 1;
}
else
{
$this->error = "Error ".$this->db->lasterror();
return -1;
}
}
/**
* Delete object in database
*
* @param User $user User that delete
* @return int <0 if KO, >0 if OK
*/
public function delete($user)
{
global $conf, $langs;
$error = 0;
// Call trigger
$result = $this->call_trigger('salary_DELETE', $user);
if ($result < 0) return -1;
// End call triggers
// Delete donation
if (!$error)
{
$sql = "DELETE FROM ".MAIN_DB_PREFIX."salary_extrafields";
$sql .= " WHERE fk_object=".$this->id;
$resql = $this->db->query($sql);
if (!$resql)
{
$this->errors[] = $this->db->lasterror();
$error++;
}
}
$sql = "DELETE FROM ".MAIN_DB_PREFIX."salary";
$sql .= " WHERE rowid=".$this->id;
dol_syslog(get_class($this)."::delete", LOG_DEBUG);
$resql = $this->db->query($sql);
if (!$resql)
{
$this->error = "Error ".$this->db->lasterror();
return -1;
}
return 1;
}
/**
* Initialise an instance with random values.
* Used to build previews or test instances.
* id must be 0 if object instance is a specimen.
*
* @return void
*/
public function initAsSpecimen()
{
$this->id = 0;
$this->tms = '';
$this->fk_user = '';
$this->datep = '';
$this->datev = '';
$this->amount = '';
$this->label = '';
$this->datesp = '';
$this->dateep = '';
$this->note = '';
$this->fk_bank = '';
$this->fk_user_author = '';
$this->fk_user_modif = '';
}
/**
* Create in database
*
* @param User $user User that create
* @return int <0 if KO, >0 if OK
*/
public function create($user)
{
global $conf, $langs;
$error = 0;
$now = dol_now();
// Clean parameters
$this->amount = price2num(trim($this->amount));
$this->label = trim($this->label);
$this->note = trim($this->note);
$this->fk_bank = trim($this->fk_bank);
$this->fk_user_author = trim($this->fk_user_author);
$this->fk_user_modif = trim($this->fk_user_modif);
$this->accountid = trim($this->accountid);
$this->paye = trim($this->paye);
// Check parameters
if (!$this->label)
{
$this->error = $langs->trans("ErrorFieldRequired", $langs->transnoentities("Label"));
return -3;
}
if ($this->fk_user < 0 || $this->fk_user == '')
{
$this->error = $langs->trans("ErrorFieldRequired", $langs->transnoentities("Employee"));
return -4;
}
if ($this->amount < 0 || $this->amount == '')
{
$this->error = $langs->trans("ErrorFieldRequired", $langs->transnoentities("Amount"));
return -5;
}
/* if (!empty($conf->banque->enabled) && (empty($this->accountid) || $this->accountid <= 0))
{
$this->error = $langs->trans("ErrorFieldRequired", $langs->transnoentities("Account"));
return -6;
}
if (!empty($conf->banque->enabled) && (empty($this->type_payment) || $this->type_payment <= 0))
{
$this->error = $langs->trans("ErrorFieldRequired", $langs->transnoentities("PaymentMode"));
return -7;
}*/
$this->db->begin();
// Insert into llx_salary
$sql = "INSERT INTO ".MAIN_DB_PREFIX."salary (fk_user";
//$sql .= ", datep";
//$sql .= ", datev";
$sql .= ", amount";
$sql .= ", fk_projet";
$sql .= ", salary";
$sql .= ", fk_typepayment";
$sql .= ", fk_account";
$sql .= ", num_payment";
if ($this->note) $sql .= ", note";
$sql .= ", label";
$sql .= ", datesp";
$sql .= ", dateep";
$sql .= ", fk_user_author";
$sql .= ", datec";
$sql .= ", fk_bank";
$sql .= ", entity";
$sql .= ") ";
$sql .= " VALUES (";
$sql .= "'".$this->db->escape($this->fk_user)."'";
//$sql .= ", '".$this->db->idate($this->datep)."'";
//$sql .= ", '".$this->db->idate($this->datev)."'";
$sql .= ", ".$this->amount;
$sql .= ", ".($this->fk_project > 0 ? $this->fk_project : 0);
$sql .= ", ".($this->salary > 0 ? $this->salary : "null");
$sql .= ", ".($this->type_payment > 0 ? $this->type_payment : 0);
$sql .= ", ".($this->accountid > 0 ? $this->accountid : "null");
$sql .= ", '".$this->db->escape($this->num_payment)."'";
if ($this->note) $sql .= ", '".$this->db->escape($this->note)."'";
$sql .= ", '".$this->db->escape($this->label)."'";
$sql .= ", '".$this->db->idate($this->datesp)."'";
$sql .= ", '".$this->db->idate($this->dateep)."'";
$sql .= ", '".$this->db->escape($user->id)."'";
$sql .= ", '".$this->db->idate($now)."'";
$sql .= ", NULL";
$sql .= ", ".$conf->entity;
$sql .= ")";
dol_syslog(get_class($this)."::create", LOG_DEBUG);
$result = $this->db->query($sql);
if ($result)
{
$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."salary");
if ($this->id > 0)
{
if (!empty($conf->banque->enabled) && !empty($this->amount))
{
// Insert into llx_bank
require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
$acc = new Account($this->db);
$result = $acc->fetch($this->accountid);
if ($result <= 0) dol_print_error($this->db);
// Update extrafield
if (!$error) {
if (!$error)
{
$result = $this->insertExtraFields();
if ($result < 0)
{
$error++;
}
}
}
}
// Call trigger
$result = $this->call_trigger('salary_CREATE', $user);
if ($result < 0) $error++;
// End call triggers
}
else $error++;
if (!$error)
{
$this->db->commit();
return $this->id;
}
else
{
$this->db->rollback();
return -2;
}
}
else
{
$this->error = $this->db->error();
$this->db->rollback();
return -1;
}
}
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/**
* Update link between payment salary and line generate into llx_bank
*
* @param int $id_bank Id bank account
* @return int <0 if KO, >0 if OK
*/
public function update_fk_bank($id_bank)
{
// phpcs:enable
$sql = 'UPDATE '.MAIN_DB_PREFIX.'salary SET fk_bank = '.$id_bank;
$sql .= ' WHERE rowid = '.$this->id;
$result = $this->db->query($sql);
if ($result)
{
return 1;
}
else
{
dol_print_error($this->db);
return -1;
}
}
/**
* Send name clicable (with possibly the picto)
*
* @param int $withpicto 0=No picto, 1=Include picto into link, 2=Only picto
* @param string $option link option
* @param int $notooltip 1=Disable tooltip
* @param string $morecss Add more css on link
* @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking
* @return string Chaine with URL
*/
public function getNomUrl($withpicto = 0, $option = '', $notooltip = 0, $morecss = '', $save_lastsearch_value = -1)
{
global $db, $conf, $langs, $hookmanager;
global $dolibarr_main_authentication, $dolibarr_main_demo;
global $menumanager;
if (!empty($conf->dol_no_mouse_hover)) $notooltip = 1; // Force disable tooltips
$result = '';
$label = '<u>'.$langs->trans("ShowSalaryPayment").'</u>';
$label .= '<br>';
$label .= '<b>'.$langs->trans('Ref').':</b> '.$this->ref;
$url = DOL_URL_ROOT.'/salaries/card.php?id='.$this->id;
if ($option != 'nolink')
{
// Add param to save lastsearch_values or not
$add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0);
if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) $add_save_lastsearch_values = 1;
if ($add_save_lastsearch_values) $url .= '&save_lastsearch_values=1';
}
$linkclose = '';
if (empty($notooltip))
{
if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER))
{
$label = $langs->trans("ShowMyObject");
$linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"';
}
$linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"';
$linkclose .= ' class="classfortooltip'.($morecss ? ' '.$morecss : '').'"';
/*
$hookmanager->initHooks(array('myobjectdao'));
$parameters=array('id'=>$this->id);
$reshook=$hookmanager->executeHooks('getnomurltooltip',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks
if ($reshook > 0) $linkclose = $hookmanager->resPrint;
*/
}
else $linkclose = ($morecss ? ' class="'.$morecss.'"' : '');
$linkstart = '<a href="'.$url.'"';
$linkstart .= $linkclose.'>';
$linkend = '</a>';
$result .= $linkstart;
if ($withpicto) $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1);
if ($withpicto != 2) $result .= $this->ref;
$result .= $linkend;
//if ($withpicto != 2) $result.=(($addlabel && $this->label) ? $sep . dol_trunc($this->label, ($addlabel > 1 ? $addlabel : 0)) : '');
global $action, $hookmanager;
$hookmanager->initHooks(array('salarypayment'));
$parameters = array('id'=>$this->id, 'getnomurl'=>$result);
$reshook = $hookmanager->executeHooks('getNomUrl', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
if ($reshook > 0) $result = $hookmanager->resPrint;
else $result .= $hookmanager->resPrint;
return $result;
}
/**
* Return amount of payments already done
*
* @return int Amount of payment already done, <0 if KO
*/
public function getSommePaiement()
{
$table = 'payment_salary';
$field = 'fk_salary';
$sql = 'SELECT sum(amount) as amount';
$sql .= ' FROM '.MAIN_DB_PREFIX.$table;
$sql .= ' WHERE '.$field.' = '.$this->id;
dol_syslog(get_class($this)."::getSommePaiement", LOG_DEBUG);
$resql = $this->db->query($sql);
if ($resql) {
$amount = 0;
$obj = $this->db->fetch_object($resql);
if ($obj) $amount = $obj->amount ? $obj->amount : 0;
$this->db->free($resql);
return $amount;
}
else
{
return -1;
}
}
/**
* Information on record
*
* @param int $id Id of record
* @return void
*/
public function info($id)
{
$sql = 'SELECT ps.rowid, ps.datec, ps.fk_user_author';
$sql .= ' FROM '.MAIN_DB_PREFIX.'salary as ps';
$sql .= ' WHERE ps.rowid = '.$id;
dol_syslog(get_class($this).'::info', LOG_DEBUG);
$result = $this->db->query($sql);
if ($result)
{
if ($this->db->num_rows($result))
{
$obj = $this->db->fetch_object($result);
$this->id = $obj->rowid;
if ($obj->fk_user_author)
{
$cuser = new User($this->db);
$cuser->fetch($obj->fk_user_author);
$this->user_creation = $cuser;
}
$this->date_creation = $this->db->jdate($obj->datec);
}
$this->db->free($result);
}
else
{
dol_print_error($this->db);
}
}
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/**
* Tag social contribution as payed completely
*
* @param User $user Object user making change
* @return int <0 if KO, >0 if OK
*/
public function set_paid($user)
{
// phpcs:enable
$sql = "UPDATE ".MAIN_DB_PREFIX."salary SET";
$sql .= " paye = 1";
$sql .= " WHERE rowid = ".$this->id;
$return = $this->db->query($sql);
if ($return) return 1;
else return -1;
}
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/**
* Remove tag payed on social contribution
*
* @param User $user Object user making change
* @return int <0 if KO, >0 if OK
*/
public function set_unpaid($user)
{
// phpcs:enable
$sql = "UPDATE ".MAIN_DB_PREFIX."salary SET";
$sql .= " paye = 0";
$sql .= " WHERE rowid = ".$this->id;
$return = $this->db->query($sql);
if ($return) return 1;
else return -1;
}
/**
* Retourne le libelle du statut d'une facture (brouillon, validee, abandonnee, payee)
*
* @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto
* @return string Libelle
*/
public function getLibStatut($mode = 0, $alreadypaid = -1)
{
return $this->LibStatut($this->paye, $mode, $alreadypaid);
}
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/**
* Renvoi le libelle d'un statut donne
*
* @param int $status Id status
* @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=short label + picto, 6=Long label + picto
* @param double $alreadypaid 0=No payment already done, >0=Some payments were already done (we recommand to put here amount payed if you have it, 1 otherwise)
* @return string Label
*/
public function LibStatut($status, $mode = 0, $alreadypaid = -1)
{
// phpcs:enable
global $langs;
// Load translation files required by the page
$langs->loadLangs(array("customers", "bills"));
// We reinit status array to force to redefine them because label may change according to properties values.
$this->labelStatus = array();
$this->labelStatusShort = array();
if (empty($this->labelStatus) || empty($this->labelStatusShort))
{
global $langs;
//$langs->load("mymodule");
$this->labelStatus[self::STATUS_UNPAID] = $langs->trans('BillStatusNotPaid');
$this->labelStatus[self::STATUS_PAID] = $langs->trans('BillStatusPaid');
if ($status == self::STATUS_UNPAID && $alreadypaid <> 0) $this->labelStatus[self::STATUS_UNPAID] = $langs->trans("BillStatusStarted");
$this->labelStatusShort[self::STATUS_UNPAID] = $langs->trans('BillStatusNotPaid');
$this->labelStatusShort[self::STATUS_PAID] = $langs->trans('BillStatusPaid');
if ($status == self::STATUS_UNPAID && $alreadypaid <> 0) $this->labelStatusShort[self::STATUS_UNPAID] = $langs->trans("BillStatusStarted");
}
$statusType = 'status1';
if ($status == 0 && $alreadypaid <> 0) $statusType = 'status3';
if ($status == 1) $statusType = 'status6';
return dolGetStatus($this->labelStatus[$status], $this->labelStatusShort[$status], '', $statusType, $mode);
}
}

View File

@@ -7,6 +7,7 @@
* Copyright (C) 2011-2012 Juanjo Menent <jmenent@2byte.es> * Copyright (C) 2011-2012 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2013 Cédric Salvador <csalvador@gpcsolutions.fr> * Copyright (C) 2013 Cédric Salvador <csalvador@gpcsolutions.fr>
* Copyright (C) 2015-2019 Alexandre Spangaro <aspangaro@open-dsi.fr> * Copyright (C) 2015-2019 Alexandre Spangaro <aspangaro@open-dsi.fr>
* Copyright (C) 2021 Gauthier VERDOL <gauthier.verdol@atm-consulting.fr>
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@@ -33,7 +34,7 @@ require '../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/salaries.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/salaries.lib.php';
require_once DOL_DOCUMENT_ROOT.'/salaries/class/paymentsalary.class.php'; require_once DOL_DOCUMENT_ROOT.'/salaries/class/salary.class.php';
// Load translation files required by the page // Load translation files required by the page
$langs->loadLangs(array("compta", "bills", "users", "salaries", "hrm")); $langs->loadLangs(array("compta", "bills", "users", "salaries", "hrm"));
@@ -62,7 +63,7 @@ if (!$sortorder) $sortorder = "ASC";
if (!$sortfield) $sortfield = "name"; if (!$sortfield) $sortfield = "name";
$object = new PaymentSalary($db); $object = new Salary($db);
$object->fetch($id, $ref); $object->fetch($id, $ref);
$upload_dir = $conf->salaries->dir_output.'/'.dol_sanitizeFileName($object->id); $upload_dir = $conf->salaries->dir_output.'/'.dol_sanitizeFileName($object->id);

View File

@@ -2,6 +2,7 @@
/* Copyright (C) 2005-2015 Laurent Destailleur <eldy@users.sourceforge.net> /* Copyright (C) 2005-2015 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2015 Charlie BENKE <charlie@patas-monkey.com> * Copyright (C) 2015 Charlie BENKE <charlie@patas-monkey.com>
* Copyright (C) 2017-2019 Alexandre Spangaro <aspangaro@open-dsi.fr> * Copyright (C) 2017-2019 Alexandre Spangaro <aspangaro@open-dsi.fr>
* Copyright (C) 2021 Gauthier VERDOL <gauthier.verdol@atm-consulting.fr>
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@@ -24,7 +25,7 @@
*/ */
require '../main.inc.php'; require '../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/salaries/class/paymentsalary.class.php'; require_once DOL_DOCUMENT_ROOT.'/salaries/class/salary.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/salaries.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/salaries.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
@@ -46,7 +47,7 @@ $result = restrictedArea($user, 'salaries', '', '', '');
llxHeader("", $langs->trans("SalaryPayment")); llxHeader("", $langs->trans("SalaryPayment"));
$object = new PaymentSalary($db); $object = new Salary($db);
$object->fetch($id); $object->fetch($id);
$object->info($id); $object->info($id);

View File

@@ -2,6 +2,7 @@
/* Copyright (C) 2011-2019 Alexandre Spangaro <aspangaro@open-dsi.fr> /* Copyright (C) 2011-2019 Alexandre Spangaro <aspangaro@open-dsi.fr>
* Copyright (C) 2015-2016 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2015-2016 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2015 Jean-François Ferry <jfefe@aternatik.fr> * Copyright (C) 2015 Jean-François Ferry <jfefe@aternatik.fr>
* Copyright (C) 2021 Gauthier VERDOL <gauthier.verdol@atm-consulting.fr>
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@@ -24,7 +25,7 @@
*/ */
require '../main.inc.php'; require '../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/salaries/class/paymentsalary.class.php'; require_once DOL_DOCUMENT_ROOT.'/salaries/class/salary.class.php';
require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
if (!empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingjournal.class.php'; if (!empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingjournal.class.php';
@@ -40,10 +41,13 @@ $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
$search_ref = GETPOST('search_ref', 'int'); $search_ref = GETPOST('search_ref', 'int');
$search_user = GETPOST('search_user', 'alpha'); $search_user = GETPOST('search_user', 'alpha');
$search_label = GETPOST('search_label', 'alpha'); $search_label = GETPOST('search_label', 'alpha');
$search_date_start = dol_mktime(0, 0, 0, GETPOST('search_date_startmonth', 'int'), GETPOST('search_date_startday', 'int'), GETPOST('search_date_startyear', 'int')); $search_date_start_from = dol_mktime(0, 0, 0, GETPOST('search_date_start_frommonth', 'int'), GETPOST('search_date_start_fromday', 'int'), GETPOST('search_date_start_fromyear', 'int'));
$search_date_end = dol_mktime(23, 59, 59, GETPOST('search_date_endmonth', 'int'), GETPOST('search_date_endday', 'int'), GETPOST('search_date_endyear', 'int')); $search_date_start_to = dol_mktime(23, 59, 59, GETPOST('search_date_start_tomonth', 'int'), GETPOST('search_date_start_today', 'int'), GETPOST('search_date_start_toyear', 'int'));
$search_date_end_from = dol_mktime(0, 0, 0, GETPOST('search_date_end_frommonth', 'int'), GETPOST('search_date_end_fromday', 'int'), GETPOST('search_date_end_fromyear', 'int'));
$search_date_end_to = dol_mktime(23, 59, 59, GETPOST('search_date_end_tomonth', 'int'), GETPOST('search_date_end_today', 'int'), GETPOST('search_date_end_toyear', 'int'));
$search_amount = GETPOST('search_amount', 'alpha'); $search_amount = GETPOST('search_amount', 'alpha');
$search_account = GETPOST('search_account', 'int'); $search_account = GETPOST('search_account', 'int');
$search_status = GETPOST('search_status', 'int');
$sortfield = GETPOST("sortfield", 'alpha'); $sortfield = GETPOST("sortfield", 'alpha');
$sortorder = GETPOST("sortorder", 'alpha'); $sortorder = GETPOST("sortorder", 'alpha');
@@ -84,10 +88,14 @@ if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x'
$search_ref = ""; $search_ref = "";
$search_user = ""; $search_user = "";
$search_label = ""; $search_label = "";
$search_date_start = ''; $search_date_start_from = '';
$search_date_start_to = '';
$search_date_end_from = '';
$search_date_end_to = '';
$search_date_end = ''; $search_date_end = '';
$search_amount = ""; $search_amount = "";
$search_account = ''; $search_account = '';
$search_status = '';
$typeid = ""; $typeid = "";
} }
@@ -99,18 +107,20 @@ if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x'
llxHeader('', $langs->trans("Salaries")); llxHeader('', $langs->trans("Salaries"));
$form = new Form($db); $form = new Form($db);
$salstatic = new PaymentSalary($db); $salstatic = new Salary($db);
$userstatic = new User($db); $userstatic = new User($db);
$accountstatic = new Account($db); $accountstatic = new Account($db);
$sql = "SELECT u.rowid as uid, u.lastname, u.firstname, u.login, u.email, u.admin, u.salary as current_salary, u.fk_soc as fk_soc, u.statut as status,"; $sql = "SELECT u.rowid as uid, u.lastname, u.firstname, u.login, u.email, u.admin, u.salary as current_salary, u.fk_soc as fk_soc, u.statut as status,";
$sql .= " s.rowid, s.fk_user, s.amount, s.salary, s.label, s.datep as datep, s.datev as datev, s.fk_typepayment as type, s.num_payment, s.fk_bank,"; $sql .= " s.rowid, s.fk_account, s.paye, s.fk_user, s.amount, s.salary, s.label, s.datesp as datesp, s.dateep as dateep, s.fk_typepayment as type, s.num_payment, s.fk_bank,";
$sql .= " ba.rowid as bid, ba.ref as bref, ba.number as bnumber, ba.account_number, ba.fk_accountancy_journal, ba.label as blabel,"; $sql .= " ba.rowid as bid, ba.ref as bref, ba.number as bnumber, ba.account_number, ba.fk_accountancy_journal, ba.label as blabel,";
$sql .= " pst.code as payment_code"; $sql .= " pst.code as payment_code,";
$sql .= " FROM ".MAIN_DB_PREFIX."payment_salary as s"; $sql .= " SUM(ps.amount) as alreadypayed";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as pst ON s.fk_typepayment = pst.id"; $sql .= " FROM ".MAIN_DB_PREFIX."salary as s";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."bank as b ON s.fk_bank = b.rowid"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."payment_salary as ps ON (ps.fk_salary = s.rowid) ";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."bank_account as ba ON b.fk_account = ba.rowid,"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as pst ON (s.fk_typepayment = pst.id) ";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."bank_account ba ON (ba.rowid = s.fk_account), ";
//$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."payment_salary as ps ON ps.fk_salary = s.rowid, ";
$sql .= " ".MAIN_DB_PREFIX."user as u"; $sql .= " ".MAIN_DB_PREFIX."user as u";
$sql .= " WHERE u.rowid = s.fk_user"; $sql .= " WHERE u.rowid = s.fk_user";
$sql .= " AND s.entity = ".$conf->entity; $sql .= " AND s.entity = ".$conf->entity;
@@ -119,10 +129,11 @@ $sql .= " AND s.entity = ".$conf->entity;
if ($search_ref) $sql .= " AND s.rowid=".$search_ref; if ($search_ref) $sql .= " AND s.rowid=".$search_ref;
if ($search_user) $sql .= natural_search(array('u.login', 'u.lastname', 'u.firstname', 'u.email'), $search_user); if ($search_user) $sql .= natural_search(array('u.login', 'u.lastname', 'u.firstname', 'u.email'), $search_user);
if ($search_label) $sql .= natural_search(array('s.label'), $search_label); if ($search_label) $sql .= natural_search(array('s.label'), $search_label);
if ($search_date_start) $sql .= " AND s.datep >= '".$db->idate($search_date_start)."'"; if (!empty($search_date_start_from) && !empty($search_date_start_to)) $sql .= " AND s.datesp BETWEEN '".$db->idate($search_date_start_from)."' AND '".$db->idate($search_date_start_to)."'";
if ($search_date_end) $sql .= " AND s.datep <= '".$db->idate($search_date_end)."'"; if (!empty($search_date_end_from) && !empty($search_date_end_to)) $sql .= " AND s.dateep BETWEEN '".$db->idate($search_date_end_from)."' AND '".$db->idate($search_date_end_to)."'";
if ($search_amount) $sql .= natural_search("s.amount", $search_amount, 1); if ($search_amount) $sql .= natural_search("s.amount", $search_amount, 1);
if ($search_account > 0) $sql .= " AND b.fk_account=".$search_account; if ($search_account > 0) $sql .= " AND s.fk_account=".$search_account;
if ($search_status != '' && $search_status >= 0) $sql .= " AND s.paye = ".$db->escape($search_status);
if ($filtre) { if ($filtre) {
$filtre = str_replace(":", "=", $filtre); $filtre = str_replace(":", "=", $filtre);
$sql .= " AND ".$filtre; $sql .= " AND ".$filtre;
@@ -130,9 +141,9 @@ if ($filtre) {
if ($typeid) { if ($typeid) {
$sql .= " AND s.fk_typepayment=".$typeid; $sql .= " AND s.fk_typepayment=".$typeid;
} }
$sql .= " GROUP BY s.rowid, s.amount, s.dateep, s.datesp, s.label, s.paye, pst.code";
$sql .= $db->order($sortfield, $sortorder); $sql .= $db->order($sortfield, $sortorder);
//$sql.= " GROUP BY u.rowid, u.lastname, u.firstname, s.rowid, s.fk_user, s.amount, s.label, s.datev, s.fk_typepayment, s.num_payment, pst.code";
$totalnboflines = 0; $totalnboflines = 0;
$result = $db->query($sql); $result = $db->query($sql);
if ($result) if ($result)
@@ -155,6 +166,16 @@ if ($result)
if ($typeid) $param .= '&amp;typeid='.$typeid; if ($typeid) $param .= '&amp;typeid='.$typeid;
if ($optioncss != '') $param .= '&amp;optioncss='.$optioncss; if ($optioncss != '') $param .= '&amp;optioncss='.$optioncss;
if ($search_ref) $param .= '&search_ref='.urlencode($search_ref);
if ($search_label) $param .= '&search_label='.urlencode($search_label);
if ($search_amount) $param .= '&search_amount='.urlencode($search_amount);
if ($search_user) $param .= '&search_user='.urlencode($search_user);
if ($search_status != '' && $search_status != '-1') $param .= '&search_status='.urlencode($search_status);
if (!empty($search_date_start_from)) $param .= '&search_date_start_fromday='.urlencode(GETPOST('search_date_start_fromday')).'&search_date_start_frommonth='.urlencode(GETPOST('search_date_start_frommonth')).'&search_date_start_fromyear='.urlencode(GETPOST('search_date_start_fromyear'));
if (!empty($search_date_start_to)) $param .= "&search_date_start_today=".urlencode(GETPOST('search_date_start_today'))."&search_date_start_tomonth=".urlencode(GETPOST('search_date_start_tomonth'))."&search_date_start_toyear=".urlencode(GETPOST('search_date_start_toyear'));
if (!empty($search_date_end_from)) $param .= '&search_date_end_fromday='.urlencode(GETPOST('search_date_end_fromday')).'&search_date_end_frommonth='.urlencode(GETPOST('search_date_end_frommonth')).'&search_date_end_fromyear='.urlencode(GETPOST('search_date_end_fromyear'));
if (!empty($search_date_end_to)) $param .= "&search_date_end_today=".urlencode(GETPOST('search_date_end_today'))."&search_date_end_tomonth=".urlencode(GETPOST('search_date_end_tomonth'))."&search_date_end_toyear=".urlencode(GETPOST('search_date_end_toyear'));
$newcardbutton = ''; $newcardbutton = '';
if (!empty($user->rights->salaries->write)) if (!empty($user->rights->salaries->write))
{ {
@@ -169,7 +190,7 @@ if ($result)
print '<input type="hidden" name="sortfield" value="'.$sortfield.'">'; print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
print '<input type="hidden" name="sortorder" value="'.$sortorder.'">'; print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
print_barre_liste($langs->trans("SalariesPayments"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $totalnboflines, 'object_payment', 0, $newcardbutton, '', $limit, 0, 0, 1); print_barre_liste($langs->trans("Salaries"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $totalnboflines, 'object_payment', 0, $newcardbutton, '', $limit, 0, 0, 1);
print '<div class="div-table-responsive">'; print '<div class="div-table-responsive">';
print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n"; print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n";
@@ -185,17 +206,31 @@ if ($result)
print '</td>'; print '</td>';
// Label // Label
print '<td class="liste_titre"><input type="text" class="flat" size="10" name="search_label" value="'.$db->escape($search_label).'"></td>'; print '<td class="liste_titre"><input type="text" class="flat" size="10" name="search_label" value="'.$db->escape($search_label).'"></td>';
// Date
// Date Start
print '<td class="liste_titre center">'; print '<td class="liste_titre center">';
print '<div class="nowrap">'; print '<div class="nowrap">';
print $langs->trans('From').' '; print $langs->trans('From').' ';
print $form->selectDate($search_date_start ? $search_date_start : -1, 'search_date_start', 0, 0, 1); print $form->selectDate($search_date_start_from ? $search_date_start_from : -1, 'search_date_start_from', 0, 0, 1);
print '</div>'; print '</div>';
print '<div class="nowrap">'; print '<div class="nowrap">';
print $langs->trans('to').' '; print $langs->trans('to').' ';
print $form->selectDate($search_date_end ? $search_date_end : -1, 'search_date_end', 0, 0, 1); print $form->selectDate($search_date_start_to ? $search_date_start_to : -1, 'search_date_start_to', 0, 0, 1);
print '</div>'; print '</div>';
print '</td>'; print '</td>';
// Date End
print '<td class="liste_titre center">';
print '<div class="nowrap">';
print $langs->trans('From').' ';
print $form->selectDate($search_date_end_from ? $search_date_end_from : -1, 'search_date_end_from', 0, 0, 1);
print '</div>';
print '<div class="nowrap">';
print $langs->trans('to').' ';
print $form->selectDate($search_date_end_to ? $search_date_end_to : -1, 'search_date_end_to', 0, 0, 1);
print '</div>';
print '</td>';
// Type // Type
print '<td class="liste_titre left">'; print '<td class="liste_titre left">';
$form->select_types_paiements($typeid, 'typeid', '', 0, 1, 1, 16); $form->select_types_paiements($typeid, 'typeid', '', 0, 1, 1, 16);
@@ -210,6 +245,11 @@ if ($result)
// Amount // Amount
print '<td class="liste_titre right"><input name="search_amount" class="flat" type="text" size="8" value="'.$db->escape($search_amount).'"></td>'; print '<td class="liste_titre right"><input name="search_amount" class="flat" type="text" size="8" value="'.$db->escape($search_amount).'"></td>';
print '<td class="liste_titre maxwidthonsmartphone right">';
$liststatus = array('0' => $langs->trans("Unpaid"), '1' => $langs->trans("Paid"));
print $form->selectarray('search_status', $liststatus, $search_status, 1);
print '</td>';
print '<td class="liste_titre maxwidthsearch">'; print '<td class="liste_titre maxwidthsearch">';
$searchpicto = $form->showFilterAndCheckAddButtons(0); $searchpicto = $form->showFilterAndCheckAddButtons(0);
print $searchpicto; print $searchpicto;
@@ -217,13 +257,15 @@ if ($result)
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
print_liste_field_titre("Ref", $_SERVER["PHP_SELF"], "s.rowid", "", $param, "", $sortfield, $sortorder); print_liste_field_titre("Ref", $_SERVER["PHP_SELF"], "s.rowid", "", $param, "", $sortfield, $sortorder);
print_liste_field_titre("Employee", $_SERVER["PHP_SELF"], "u.rowid", "", $param, "", $sortfield, $sortorder); print_liste_field_titre("Employee", $_SERVER["PHP_SELF"], "u.lastname", "", $param, "", $sortfield, $sortorder);
print_liste_field_titre("Label", $_SERVER["PHP_SELF"], "s.label", "", $param, 'class="left"', $sortfield, $sortorder); print_liste_field_titre("Label", $_SERVER["PHP_SELF"], "s.label", "", $param, 'class="left"', $sortfield, $sortorder);
print_liste_field_titre("DatePayment", $_SERVER["PHP_SELF"], "s.datep,s.rowid", "", $param, 'align="center"', $sortfield, $sortorder); print_liste_field_titre("DateStart", $_SERVER["PHP_SELF"], "s.datesp,s.rowid", "", $param, 'align="center"', $sortfield, $sortorder);
print_liste_field_titre("DateEnd", $_SERVER["PHP_SELF"], "s.dateep,s.rowid", "", $param, 'align="center"', $sortfield, $sortorder);
print_liste_field_titre("PaymentMode", $_SERVER["PHP_SELF"], "type", "", $param, 'class="left"', $sortfield, $sortorder); print_liste_field_titre("PaymentMode", $_SERVER["PHP_SELF"], "type", "", $param, 'class="left"', $sortfield, $sortorder);
if (!empty($conf->banque->enabled)) print_liste_field_titre("BankAccount", $_SERVER["PHP_SELF"], "ba.label", "", $param, "", $sortfield, $sortorder); if (!empty($conf->banque->enabled)) print_liste_field_titre("BankAccount", $_SERVER["PHP_SELF"], "ba.label", "", $param, "", $sortfield, $sortorder);
print_liste_field_titre("PayedByThisPayment", $_SERVER["PHP_SELF"], "s.amount", "", $param, 'class="right"', $sortfield, $sortorder); print_liste_field_titre("Amount", $_SERVER["PHP_SELF"], "s.amount", "", $param, 'class="right"', $sortfield, $sortorder);
print_liste_field_titre('', $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'maxwidthsearch '); print_liste_field_titre('Status', $_SERVER["PHP_SELF"], "s.paye", '', $param, 'class="right"', $sortfield, $sortorder);
print_liste_field_titre('', $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'maxwidthsearch ');
print "</tr>\n"; print "</tr>\n";
print "</tr>\n"; print "</tr>\n";
@@ -258,8 +300,13 @@ if ($result)
print "<td>".dol_trunc($obj->label, 40)."</td>\n"; print "<td>".dol_trunc($obj->label, 40)."</td>\n";
if (!$i) $totalarray['nbfield']++; if (!$i) $totalarray['nbfield']++;
// Date payment // Date Start
print '<td class="center">'.dol_print_date($db->jdate($obj->datep), 'day')."</td>\n"; print '<td class="center">'.dol_print_date($db->jdate($obj->datesp), 'day')."</td>\n";
if (!$i) $totalarray['nbfield']++;
if (!$i) $totalarray['nbfield']++;
// Date End
print '<td class="center">'.dol_print_date($db->jdate($obj->dateep), 'day')."</td>\n";
if (!$i) $totalarray['nbfield']++; if (!$i) $totalarray['nbfield']++;
// Type // Type
@@ -270,14 +317,13 @@ if ($result)
if (!empty($conf->banque->enabled)) if (!empty($conf->banque->enabled))
{ {
print '<td>'; print '<td>';
if ($obj->fk_bank > 0) if ($obj->fk_account > 0)
{ {
//$accountstatic->fetch($obj->fk_bank);
$accountstatic->id = $obj->bid; $accountstatic->id = $obj->bid;
$accountstatic->ref = $obj->bref; $accountstatic->ref = $obj->bref;
$accountstatic->number = $obj->bnumber; $accountstatic->number = $obj->bnumber;
if (!empty($conf->accounting->enabled)) /*if (!empty($conf->accounting->enabled))
{ {
$accountstatic->account_number = $obj->account_number; $accountstatic->account_number = $obj->account_number;
@@ -285,8 +331,8 @@ if ($result)
$accountingjournal->fetch($obj->fk_accountancy_journal); $accountingjournal->fetch($obj->fk_accountancy_journal);
$accountstatic->accountancy_journal = $accountingjournal->getNomUrl(0, 1, 1, '', 1); $accountstatic->accountancy_journal = $accountingjournal->getNomUrl(0, 1, 1, '', 1);
} }*/
$accountstatic->label = $obj->blabel; //$accountstatic->label = $obj->blabel;
print $accountstatic->getNomUrl(1); print $accountstatic->getNomUrl(1);
} }
else print '&nbsp;'; else print '&nbsp;';
@@ -294,15 +340,19 @@ if ($result)
if (!$i) $totalarray['nbfield']++; if (!$i) $totalarray['nbfield']++;
} }
if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 'totalttcfield';
// Amount // Amount
print '<td class="nowrap right">'.price($obj->amount).'</td>'; print '<td class="nowrap right">'.price($obj->amount).'</td>';
if (!$i) $totalarray['nbfield']++; if (!$i) $totalarray['nbfield']++;
if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 'totalttcfield';
$totalarray['val']['totalttcfield'] += $obj->amount; $totalarray['val']['totalttcfield'] += $obj->amount;
print '<td class="nowrap right">'.$salstatic->LibStatut($obj->paye, 5, $obj->alreadypayed).'</td>';
if (!$i) $totalarray['nbfield']++;
print '<td></td>'; print '<td></td>';
if (!$i) $totalarray['nbfield']++; //if (!$i) $totalarray['nbfield']++;
print "</tr>\n"; print "</tr>\n";

View File

@@ -0,0 +1,347 @@
<?php
/* Copyright (C) 2004-2014 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2016-2018 Frédéric France <frederic.france@netlogic.fr>
* Copyright (C) 2021 Gauthier VERDOL <gauthier.verdol@atm-consulting.fr>
*
* 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 <https://www.gnu.org/licenses/>.
*/
/**
* \file htdocs/compta/paiement_charge.php
* \ingroup tax
* \brief Page to add payment of a tax
*/
require '../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/salaries/class/salary.class.php';
require_once DOL_DOCUMENT_ROOT.'/salaries/class/paymentsalary.class.php';
require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
// Load translation files required by the page
$langs->load("bills");
$chid = GETPOST("id", 'int');
$action = GETPOST('action', 'alpha');
$amounts = array();
// Security check
$socid = 0;
if ($user->socid > 0)
{
$socid = $user->socid;
}
/*
* Actions
*/
if ($action == 'add_payment' || ($action == 'confirm_paiement' && $confirm == 'yes'))
{
$error = 0;
if ($_POST["cancel"])
{
$loc = DOL_URL_ROOT.'/salaries/card.php?id='.$chid;
header("Location: ".$loc);
exit;
}
$datepaye = dol_mktime(12, 0, 0, $_POST["remonth"], $_POST["reday"], $_POST["reyear"]);
if (!$_POST["paiementtype"] > 0)
{
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("PaymentMode")), null, 'errors');
$error++;
$action = 'create';
}
if ($datepaye == '')
{
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Date")), null, 'errors');
$error++;
$action = 'create';
}
if (!empty($conf->banque->enabled) && !($_POST["accountid"] > 0))
{
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("AccountToCredit")), null, 'errors');
$error++;
$action = 'create';
}
if (!$error)
{
$paymentid = 0;
// Read possible payments
foreach ($_POST as $key => $value)
{
if (substr($key, 0, 7) == 'amount_')
{
$other_chid = substr($key, 7);
$amounts[$other_chid] = price2num($_POST[$key]);
}
}
if (count($amounts) <= 0)
{
$error++;
setEventMessages($langs->trans("ErrorNoPaymentDefined"), null, 'errors');
$action = 'create';
}
if (!$error)
{
$db->begin();
// Create a line of payments
$paiement = new PaymentSalary($db);
$paiement->chid = $chid;
$paiement->datepaye = $datepaye;
$paiement->amounts = $amounts; // Tableau de montant
$paiement->paiementtype = GETPOST("paiementtype", 'alphanohtml');
$paiement->num_payment = GETPOST("num_payment", 'alphanohtml');
$paiement->note = GETPOST("note", 'none');
$paiement->note_private = GETPOST("note", 'none');
if (!$error)
{
$paymentid = $paiement->create($user, (GETPOST('closepaidsalary') == 'on' ? 1 : 0));
if ($paymentid < 0)
{
$error++;
setEventMessages($paiement->error, null, 'errors');
$action = 'create';
}
}
if (!$error)
{
$result = $paiement->addPaymentToBank($user, 'payment_salary', '(SalaryPayment)', GETPOST('accountid', 'int'), '', '');
if (!($result > 0))
{
$error++;
setEventMessages($paiement->error, null, 'errors');
$action = 'create';
}
}
if (!$error)
{
$db->commit();
$loc = DOL_URL_ROOT.'/salaries/card.php?id='.$chid;
header('Location: '.$loc);
exit;
}
else
{
$db->rollback();
}
}
}
}
/*
* View
*/
llxHeader();
$form = new Form($db);
// Formulaire de creation d'un paiement de charge
if ($action == 'create')
{
$salary = new Salary($db);
$salary->fetch($chid);
$salary->accountid = $salary->fk_account ? $salary->fk_account : $salary->accountid;
$salary->paiementtype = $salary->mode_reglement_id ? $salary->mode_reglement_id : $salary->paiementtype;
$total = $salary->amount;
if (!empty($conf->use_javascript_ajax))
{
print "\n".'<script type="text/javascript" language="javascript">';
//Add js for AutoFill
print ' $(document).ready(function () {';
print ' $(".AutoFillAmount").on(\'click touchstart\', function(){
var amount = $(this).data("value");
document.getElementById($(this).data(\'rowid\')).value = amount ;
});';
print ' });'."\n";
print ' </script>'."\n";
}
print load_fiche_titre($langs->trans("DoPayment"));
print "<br>\n";
if ($mesg)
{
print "<div class=\"error\">$mesg</div>";
}
print '<form name="add_payment" action="'.$_SERVER['PHP_SELF'].'" method="post">';
print '<input type="hidden" name="token" value="'.newToken().'">';
print '<input type="hidden" name="id" value="'.$chid.'">';
print '<input type="hidden" name="chid" value="'.$chid.'">';
print '<input type="hidden" name="action" value="add_payment">';
dol_fiche_head('', '');
print '<table class="border centpercent">';
print '<tr><td class="titlefieldcreate">'.$langs->trans("Ref").'</td><td><a href="'.DOL_URL_ROOT.'/salaries/card.php?id='.$chid.'">'.$chid.'</a></td></tr>';
print '<tr><td>'.$langs->trans("DateStart")."</td><td>".dol_print_date($salary->datesp, 'day')."</td></tr>\n";
print '<tr><td>'.$langs->trans("DateEnd")."</td><td>".dol_print_date($salary->dateep, 'day')."</td></tr>\n";
print '<tr><td>'.$langs->trans("Label").'</td><td>'.$salary->label."</td></tr>\n";
/*print '<tr><td>'.$langs->trans("DateDue")."</td><td>".dol_print_date($salary->date_ech,'day')."</td></tr>\n";
print '<tr><td>'.$langs->trans("Amount")."</td><td>".price($salary->amount,0,$outputlangs,1,-1,-1,$conf->currency).'</td></tr>';*/
$sql = "SELECT sum(p.amount) as total";
$sql .= " FROM ".MAIN_DB_PREFIX."payment_salary as p";
$sql .= " WHERE p.fk_salary = ".$chid;
$resql = $db->query($sql);
if ($resql)
{
$obj = $db->fetch_object($resql);
$sumpaid = $obj->total;
$db->free();
}
/*print '<tr><td>'.$langs->trans("AlreadyPaid").'</td><td>'.price($sumpaid,0,$outputlangs,1,-1,-1,$conf->currency).'</td></tr>';
print '<tr><td class="tdtop">'.$langs->trans("RemainderToPay").'</td><td>'.price($total-$sumpaid,0,$outputlangs,1,-1,-1,$conf->currency).'</td></tr>';*/
print '<tr><td class="fieldrequired">'.$langs->trans("Date").'</td><td>';
$datepaye = dol_mktime(12, 0, 0, $_POST["remonth"], $_POST["reday"], $_POST["reyear"]);
$datepayment = empty($conf->global->MAIN_AUTOFILL_DATE) ? (empty($_POST["remonth"]) ?-1 : $datepaye) : '';
print $form->selectDate($datepayment, '', '', '', '', "add_payment", 1, 1);
print "</td>";
print '</tr>';
print '<tr><td class="fieldrequired">'.$langs->trans("PaymentMode").'</td><td>';
$form->select_types_paiements(isset($_POST["paiementtype"]) ? $_POST["paiementtype"] : $salary->type_payment, "paiementtype");
print "</td>\n";
print '</tr>';
print '<tr>';
print '<td class="fieldrequired">'.$langs->trans('AccountToDebit').'</td>';
print '<td>';
$form->select_comptes(isset($_POST["accountid"]) ? $_POST["accountid"] : $salary->accountid, "accountid", 0, '', 1); // Show opend bank account list
print '</td></tr>';
// Number
print '<tr><td>'.$langs->trans('Numero');
print ' <em>('.$langs->trans("ChequeOrTransferNumber").')</em>';
print '</td>';
print '<td><input name="num_payment" type="text" value="'.GETPOST('num_payment', 'alphanohtml').'"></td></tr>'."\n";
print '<tr>';
print '<td class="tdtop">'.$langs->trans("Comments").'</td>';
print '<td class="tdtop"><textarea name="note" wrap="soft" cols="60" rows="'.ROWS_3.'"></textarea></td>';
print '</tr>';
print '</table>';
dol_fiche_end();
/*
* Autres charges impayees
*/
$num = 1;
$i = 0;
print '<table class="noborder centpercent">';
print '<tr class="liste_titre">';
//print '<td>'.$langs->trans("SocialContribution").'</td>';
print '<td class="left">'.$langs->trans("DateEnd").'</td>';
print '<td class="right">'.$langs->trans("Amount").'</td>';
print '<td class="right">'.$langs->trans("AlreadyPaid").'</td>';
print '<td class="right">'.$langs->trans("RemainderToPay").'</td>';
print '<td class="center">'.$langs->trans("Amount").'</td>';
print "</tr>\n";
$total = 0;
$totalrecu = 0;
while ($i < $num)
{
$objp = $salary;
print '<tr class="oddeven">';
if ($objp->dateep > 0)
{
print '<td class="left">'.dol_print_date($objp->dateep, 'day').'</td>'."\n";
}
else
{
print "<td align=\"center\"><b>!!!</b></td>\n";
}
print '<td class="right">'.price($objp->amount)."</td>";
print '<td class="right">'.price($sumpaid)."</td>";
print '<td class="right">'.price($objp->amount - $sumpaid)."</td>";
print '<td class="center">';
if ($sumpaid < $objp->amount)
{
$namef = "amount_".$objp->id;
$nameRemain = "remain_".$objp->id;
if (!empty($conf->use_javascript_ajax))
print img_picto("Auto fill", 'rightarrow', "class='AutoFillAmount' data-rowid='".$namef."' data-value='".($objp->amount - $sumpaid)."'");
$remaintopay = $objp->amount - $sumpaid;
print '<input type=hidden class="sum_remain" name="'.$nameRemain.'" value="'.$remaintopay.'">';
print '<input type="text" size="8" name="'.$namef.'" id="'.$namef.'">';
}
else
{
print '-';
}
print "</td>";
print "</tr>\n";
$total += $objp->total;
$total_ttc += $objp->total_ttc;
$totalrecu += $objp->am;
$i++;
}
if ($i > 1)
{
// Print total
print '<tr class="oddeven">';
print '<td colspan="2" class="left">'.$langs->trans("Total").':</td>';
print '<td class="right"><b>'.price($total_ttc).'</b></td>';
print '<td class="right"><b>'.price($totalrecu).'</b></td>';
print '<td class="right"><b>'.price($total_ttc - $totalrecu).'</b></td>';
print '<td align="center">&nbsp;</td>';
print "</tr>\n";
}
print "</table>";
// Bouton Save payment
print '<br><div class="center"><input type="checkbox" checked name="closepaidsalary"> '.$langs->trans("ClosePaidSalaryAutomatically");
print '<br><input type="submit" class="button" name="save" value="'.$langs->trans('ToMakePayment').'">';
print '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
print '<input type="submit" class="button" name="cancel" value="'.$langs->trans("Cancel").'">';
print '</div>';
print "</form>\n";
}
llxFooter();
$db->close();

View File

@@ -0,0 +1,291 @@
<?php
/* Copyright (C) 2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2014 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005 Marc Barilley / Ocebo <marc@ocebo.com>
* Copyright (C) 2005-2009 Regis Houssin <regis.houssin@inodbox.com>
* Copyright (C) 2021 Gauthier VERDOL <gauthier.verdol@atm-consulting.fr>
*
* 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 <https://www.gnu.org/licenses/>.
*/
/**
* \file htdocs/compta/payment_sc/card.php
* \ingroup facture
* \brief Onglet payment of a salary
* \remarks Fichier presque identique a fournisseur/paiement/card.php
*/
require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/salaries/class/salary.class.php';
require_once DOL_DOCUMENT_ROOT.'/salaries/class/paymentsalary.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 (!empty($conf->banque->enabled)) 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 = GETPOST("id", 'int');
$action = GETPOST('action', 'aZ09');
$confirm = GETPOST('confirm');
if ($user->socid) $socid = $user->socid;
// TODO ajouter regle pour restreindre acces paiement
//$result = restrictedArea($user, 'facture', $id,'');
$object = new PaymentSalary($db);
if ($id > 0)
{
$result = $object->fetch($id);
if (!$result) dol_print_error($db, 'Failed to get payment id '.$id);
}
/*
* Actions
*/
// Delete payment
if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->salaries->delete)
{
$db->begin();
$result = $object->delete($user);
if ($result > 0)
{
$db->commit();
header("Location: ".DOL_URL_ROOT."/salaries/payments.php");
exit;
}
else
{
setEventMessages($object->error, $object->errors, 'errors');
$db->rollback();
}
}
/*
* View
*/
llxHeader();
$salary = new Salary($db);
$form = new Form($db);
$h = 0;
$head[$h][0] = DOL_URL_ROOT.'/salaries/payment_salary/card.php?id='.$id;
$head[$h][1] = $langs->trans("SalaryPayment");
$hselected = $h;
$h++;
/*$head[$h][0] = DOL_URL_ROOT.'/compta/payment_sc/info.php?id='.$id;
$head[$h][1] = $langs->trans("Info");
$h++;
*/
dol_fiche_head($head, $hselected, $langs->trans("SalaryPayment"), -1, 'payment');
/*
* Deletion confirmation of payment
*/
if ($action == 'delete')
{
print $form->formconfirm('card.php?id='.$object->id, $langs->trans("DeleteSalary"), $langs->trans("ConfirmDeleteSalaryPayment"), 'confirm_delete', '', 0, 2);
}
/*
* Validation confirmation of payment
*/
/*
if ($action == 'valide')
{
$facid = $_GET['facid'];
print $form->formconfirm('card.php?id='.$object->id.'&amp;facid='.$facid, $langs->trans("ValidatePayment"), $langs->trans("ConfirmValidatePayment"), 'confirm_valide','',0,2);
}
*/
$linkback = '<a href="'.DOL_URL_ROOT.'/salaries/payments.php">'.$langs->trans("BackToList").'</a>';
dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'id', '');
print '<div class="fichecenter">';
print '<div class="underbanner clearboth"></div>';
print '<table class="border centpercent">';
// Ref
/*print '<tr><td class="titlefield">'.$langs->trans('Ref').'</td>';
print '<td colspan="3">';
print $form->showrefnav($object,'id','',1,'rowid','id');
print '</td></tr>';*/
// Date
print '<tr><td>'.$langs->trans('Date').'</td><td colspan="3">'.dol_print_date($object->datep, 'day').'</td></tr>';
// Mode
print '<tr><td>'.$langs->trans('Mode').'</td><td colspan="3">'.$langs->trans("PaymentType".$object->type_code).'</td></tr>';
// Numero
print '<tr><td>'.$langs->trans('Numero').'</td><td colspan="3">'.$object->num_paiement.'</td></tr>';
// Montant
print '<tr><td>'.$langs->trans('Amount').'</td><td colspan="3">'.price($object->amount, 0, $outputlangs, 1, -1, -1, $conf->currency).'</td></tr>';
// Note
print '<tr><td>'.$langs->trans('Note').'</td><td colspan="3">'.nl2br($object->note).'</td></tr>';
// Bank account
if (!empty($conf->banque->enabled))
{
if ($object->bank_account)
{
$bankline = new AccountLine($db);
$bankline->fetch($object->bank_line);
print '<tr>';
print '<td>'.$langs->trans('BankTransactionLine').'</td>';
print '<td colspan="3">';
print $bankline->getNomUrl(1, 0, 'showall');
print '</td>';
print '</tr>';
}
}
print '</table>';
print '</div>';
dol_fiche_end();
/*
* List of salaries payed
*/
$disable_delete = 0;
$sql = 'SELECT f.rowid as scid, f.label, f.paye, f.amount as sc_amount, ps.amount';
$sql .= ' FROM '.MAIN_DB_PREFIX.'payment_salary as ps,'.MAIN_DB_PREFIX.'salary as f';
$sql .= ' WHERE ps.fk_salary = f.rowid';
$sql .= ' AND f.entity = '.$conf->entity;
$sql .= ' AND ps.rowid = '.$object->id;
dol_syslog("payment_salary/card.php", LOG_DEBUG);
$resql = $db->query($sql);
if ($resql)
{
$num = $db->num_rows($resql);
$i = 0;
$total = 0;
print '<br><table class="noborder centpercent">';
print '<tr class="liste_titre">';
print '<td>'.$langs->trans('Salary').'</td>';
print '<td>'.$langs->trans('Type').'</td>';
print '<td>'.$langs->trans('Label').'</td>';
print '<td class="right">'.$langs->trans('ExpectedToPay').'</td>';
print '<td class="center">'.$langs->trans('Status').'</td>';
print '<td class="right">'.$langs->trans('PayedByThisPayment').'</td>';
print "</tr>\n";
if ($num > 0)
{
while ($i < $num)
{
$objp = $db->fetch_object($resql);
print '<tr class="oddeven">';
// Ref
print '<td>';
$salary->fetch($objp->scid);
print $salary->getNomUrl(1);
print "</td>\n";
// Type
print '<td>';
print $salary->type_label;
/*print $salary->type;*/
print "</td>\n";
// Label
print '<td>'.$objp->label.'</td>';
// Expected to pay
print '<td class="right">'.price($objp->sc_amount).'</td>';
// Status
print '<td class="center">'.$salary->getLibStatut(4, $objp->amount).'</td>';
// Amount payed
print '<td class="right">'.price($objp->amount).'</td>';
print "</tr>\n";
if ($objp->paye == 1) // If at least one invoice is paid, disable delete
{
$disable_delete = 1;
}
$total = $total + $objp->amount;
$i++;
}
}
print "</table>\n";
$db->free($resql);
}
else
{
dol_print_error($db);
}
/*
* Boutons Actions
*/
print '<div class="tabsAction">';
/*
if (! empty($conf->global->BILL_ADD_PAYMENT_VALIDATION))
{
if ($user->socid == 0 && $object->statut == 0 && $_GET['action'] == '')
{
if ($user->rights->facture->paiement)
{
print '<a class="butAction" href="card.php?id='.$_GET['id'].'&amp;facid='.$objp->facid.'&amp;action=valide">'.$langs->trans('Valid').'</a>';
}
}
}
*/
if ($action == '')
{
if ($user->rights->salaries->delete)
{
if (!$disable_delete)
{
print '<a class="butActionDelete" href="card.php?id='.$_GET['id'].'&amp;action=delete">'.$langs->trans('Delete').'</a>';
}
else
{
print '<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans("CantRemovePaymentSalaryPaid")).'">'.$langs->trans('Delete').'</a>';
}
}
}
print '</div>';
// End of page
llxFooter();
$db->close();

View File

@@ -0,0 +1,222 @@
<?php
/* Copyright (C) 2001-2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2014 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2010 Regis Houssin <regis.houssin@inodbox.com>
* Copyright (C) 2011-2016 Alexandre Spangaro <aspangaro@open-dsi.fr>
* Copyright (C) 2011-2014 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2015 Jean-François Ferry <jfefe@aternatik.fr>
* Copyright (C) 2021 Gauthier VERDOL <gauthier.verdol@atm-consulting.fr>
*
* 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 <https://www.gnu.org/licenses/>.
*/
/**
* \file htdocs/compta/sociales/payments.php
* \ingroup compta
* \brief Page to list payments of special expenses
*/
require '../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/salaries/class/salary.class.php';
require_once DOL_DOCUMENT_ROOT.'/salaries/class/paymentsalary.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
// Load translation files required by the page
$langs->loadLangs(array('compta', 'bills'));
// Security check
if ($user->socid) $socid = $user->socid;
$result = restrictedArea($user, 'tax|salaries', '', '', 'charges|');
$mode = GETPOST("mode", 'alpha');
$year = GETPOST("year", 'int');
$filtre = GETPOST("filtre", 'alpha');
if (!$year && $mode != 'sconly') { $year = date("Y", time()); }
$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
$sortfield = GETPOST("sortfield", 'alpha');
$sortorder = GETPOST("sortorder", 'alpha');
$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
$offset = $limit * $page;
$pageprev = $page - 1;
$pagenext = $page + 1;
if (!$sortfield) $sortfield = "pc.datep";
if (!$sortorder) $sortorder = "DESC";
/*
* View
*/
$payment_salary_static = new PaymentSalary($db);
$sal_static = new Salary($db);
llxHeader('', $langs->trans("SalariesArea"));
$title = $langs->trans("SalariesPayments");
if ($mode == 'sconly') $title = $langs->trans("PaymentsSalaries");
$param = '';
if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.$contextpage;
if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.$limit;
if ($mode == 'sconly') $param = '&mode=sconly';
if ($sortfield) $param .= '&sortfield='.$sortfield;
if ($sortorder) $param .= '&sortorder='.$sortorder;
print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
print '<input type="hidden" name="token" value="'.newToken().'">';
print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
print '<input type="hidden" name="page" value="'.$page.'">';
print '<input type="hidden" name="mode" value="'.$mode.'">';
print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $center, $num, $totalnboflines, 'title_accountancy', 0, '', '', $limit);
if ($year) $param .= '&year='.$year;
// Localtax
if ($mysoc->localtax1_assuj == "1" && $mysoc->localtax2_assuj == "1")
{
$j = 1;
$numlt = 3;
}
elseif ($mysoc->localtax1_assuj == "1")
{
$j = 1;
$numlt = 2;
}
elseif ($mysoc->localtax2_assuj == "1")
{
$j = 2;
$numlt = 3;
}
else
{
$j = 0;
$numlt = 0;
}
// Payment Salary
if (!empty($conf->salaries->enabled) && !empty($user->rights->salaries->read))
{
if (!$mode || $mode != 'sconly')
{
$sal = new Salary($db);
$sql = "SELECT ps.rowid as payment_id, ps.amount, s.rowid as salary_id, s.label, ps.datep as datep, s.datesp, s.dateep, s.amount as salary, u.salary as current_salary, pct.code as payment_code";
$sql .= " FROM ".MAIN_DB_PREFIX."payment_salary as ps";
$sql .= " INNER JOIN ".MAIN_DB_PREFIX."salary as s ON (s.rowid = ps.fk_salary)";
$sql .= " INNER JOIN ".MAIN_DB_PREFIX."user as u ON (u.rowid = s.fk_user)";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as pct ON ps.fk_typepaiement = pct.id";
$sql .= " WHERE s.entity IN (".getEntity('user').")";
/* if ($year > 0)
{
$sql .= " AND (s.datesp between '".$db->idate(dol_get_first_day($year, 1, false))."' AND '".$db->idate(dol_get_last_day($year, 12, false))."'";
$sql .= " OR s.dateep between '".$db->idate(dol_get_first_day($year, 1, false))."' AND '".$db->idate(dol_get_last_day($year, 12, false))."')";
}*/
if (preg_match('/^s\./', $sortfield)
|| preg_match('/^pct\./', $sortfield)
|| preg_match('/^ps\./', $sortfield)) $sql .= $db->order($sortfield, $sortorder);
$result = $db->query($sql);
if ($result)
{
$num = $db->num_rows($result);
$i = 0;
$total = 0;
print '<table class="noborder centpercent">';
print '<tr class="liste_titre">';
print_liste_field_titre("RefPayment", $_SERVER["PHP_SELF"], "s.rowid", "", $param, '', $sortfield, $sortorder);
print_liste_field_titre("DatePayment", $_SERVER["PHP_SELF"], "ps.datep", "", $param, 'align="center"', $sortfield, $sortorder);
print_liste_field_titre("Type", $_SERVER["PHP_SELF"], "pct.code", "", $param, '', $sortfield, $sortorder);
print_liste_field_titre("Salary", $_SERVER["PHP_SELF"], "s.rowid", "", $param, '', $sortfield, $sortorder);
print_liste_field_titre("DateStart", $_SERVER["PHP_SELF"], "s.datesp", "", $param, 'width="140px"', $sortfield, $sortorder);
print_liste_field_titre("PeriodEndDate", $_SERVER["PHP_SELF"], "s.dateep", "", $param, 'width="140px"', $sortfield, $sortorder);
print_liste_field_titre("Label", $_SERVER["PHP_SELF"], "s.label", "", $param, '', $sortfield, $sortorder);
print_liste_field_titre("ExpectedToPay", $_SERVER["PHP_SELF"], "s.amount", "", $param, 'class="right"', $sortfield, $sortorder);
print_liste_field_titre("PayedByThisPayment", $_SERVER["PHP_SELF"], "s.amount", "", $param, 'class="right"', $sortfield, $sortorder);
print "</tr>\n";
while ($i < $num)
{
$obj = $db->fetch_object($result);
$total = $total + $obj->amount;
print '<tr class="oddeven">';
// Ref payment
$payment_salary_static->id = $obj->payment_id;
$payment_salary_static->ref = $obj->payment_id;
print '<td class="left">'.$payment_salary_static->getNomUrl(1)."</td>\n";
print '<td class="center">'.dol_print_date($db->jdate($obj->datep), 'day')."</td>\n";
// Type payment
print '<td>';
if ($obj->payment_code) print $langs->trans("PaymentTypeShort".$obj->payment_code).' ';
print $obj->num_payment.'</td>';
print '<td>';
$sal_static->id = $obj->salary_id;
$sal_static->ref = $obj->salary_id;
$sal_static->label = $obj->label;
print $sal_static->getNomUrl(1, '20');
print '</td>';
// Date début salaire
print '<td class="left">'.dol_print_date($db->jdate($obj->datesp), 'day').'</td>'."\n";
// Date fin salaire
print '<td class="left">'.dol_print_date($db->jdate($obj->dateep), 'day').'</td>'."\n";
print "<td>".$obj->label."</td>\n";
print '<td class="right">'.($obj->salary ?price($obj->salary) : '')."</td>";
print '<td class="right">'.price($obj->amount)."</td>";
print "</tr>\n";
$i++;
}
print '<tr class="liste_total"><td colspan="2">'.$langs->trans("Total").'</td>';
print '<td class="right"></td>'; // A total here has no sense
print '<td align="center">&nbsp;</td>';
print '<td align="center">&nbsp;</td>';
print '<td align="center">&nbsp;</td>';
print '<td align="center">&nbsp;</td>';
print '<td align="center">&nbsp;</td>';
print '<td class="right">'.price($total)."</td>";
print "</tr>";
print "</table>";
$db->free($result);
print "<br>";
}
else
{
dol_print_error($db);
}
}
}
print '</form>';
// End of page
llxFooter();
$db->close();

View File

@@ -1,6 +1,7 @@
<?php <?php
/* Copyright (C) 2018 Alexandre Spangaro <aspangaro@open-dsi.fr> /* Copyright (C) 2018 Alexandre Spangaro <aspangaro@open-dsi.fr>
* Copyright (C) 2018 Fidesio <contact@fidesio.com> * Copyright (C) 2018 Fidesio <contact@fidesio.com>
* Copyright (C) 2021 Gauthier VERDOL <gauthier.verdol@atm-consulting.fr>
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@@ -27,7 +28,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php';
require_once DOL_DOCUMENT_ROOT.'/salaries/class/salariesstats.class.php'; require_once DOL_DOCUMENT_ROOT.'/salaries/class/salariesstats.class.php';
// Load translation files required by the page // Load translation files required by the page
$langs->loadLangs(array("salaries", "companies")); $langs->loadLangs(array("salaries", "companies", "bills"));
$WIDTH = DolGraph::getDefaultGraphSizeForStats('width'); $WIDTH = DolGraph::getDefaultGraphSizeForStats('width');
$HEIGHT = DolGraph::getDefaultGraphSizeForStats('height'); $HEIGHT = DolGraph::getDefaultGraphSizeForStats('height');

View File

@@ -6,6 +6,7 @@
* Copyright (C) 2013 Peter Fontaine <contact@peterfontaine.fr> * Copyright (C) 2013 Peter Fontaine <contact@peterfontaine.fr>
* Copyright (C) 2015-2016 Marcos García <marcosgdf@gmail.com> * Copyright (C) 2015-2016 Marcos García <marcosgdf@gmail.com>
* Copyright (C) 2015 Alexandre Spangaro <aspangaro@open-dsi.fr> * Copyright (C) 2015 Alexandre Spangaro <aspangaro@open-dsi.fr>
* Copyright (C) 2021 Gauthier VERDOL <gauthier.verdol@atm-consulting.fr>
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@@ -34,7 +35,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
require_once DOL_DOCUMENT_ROOT.'/user/class/userbankaccount.class.php'; require_once DOL_DOCUMENT_ROOT.'/user/class/userbankaccount.class.php';
if (!empty($conf->holiday->enabled)) require_once DOL_DOCUMENT_ROOT.'/holiday/class/holiday.class.php'; if (!empty($conf->holiday->enabled)) require_once DOL_DOCUMENT_ROOT.'/holiday/class/holiday.class.php';
if (!empty($conf->expensereport->enabled)) require_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport.class.php'; if (!empty($conf->expensereport->enabled)) require_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport.class.php';
if (!empty($conf->salaries->enabled)) require_once DOL_DOCUMENT_ROOT.'/salaries/class/paymentsalary.class.php'; if (!empty($conf->salaries->enabled)) require_once DOL_DOCUMENT_ROOT.'/salaries/class/salary.class.php';
// Load translation files required by page // Load translation files required by page
$langs->loadLangs(array('companies', 'commercial', 'banks', 'bills', 'trips', 'holiday', 'salaries')); $langs->loadLangs(array('companies', 'commercial', 'banks', 'bills', 'trips', 'holiday', 'salaries'));
@@ -243,7 +244,7 @@ if ($action != 'edit' && $action != 'create') // If not bank account yet, $acco
$user->rights->salaries->read && (in_array($object->id, $childids) || $object->id == $user->id) $user->rights->salaries->read && (in_array($object->id, $childids) || $object->id == $user->id)
) )
{ {
$salary = new PaymentSalary($db); $salary = new Salary($db);
$sql = "SELECT ps.rowid, ps.datesp, ps.dateep, ps.amount"; $sql = "SELECT ps.rowid, ps.datesp, ps.dateep, ps.amount";
$sql .= " FROM ".MAIN_DB_PREFIX."payment_salary as ps"; $sql .= " FROM ".MAIN_DB_PREFIX."payment_salary as ps";