Merge pull request #16177 from atm-gauthier/NEW/add_real_payments_on_salaries
NEW Salary payment request and Salary payment are 2 different steps in workflow on Salary payment recording
This commit is contained in:
commit
7d20df8054
@ -10,6 +10,7 @@
|
||||
* Copyright (C) 2017-2020 Frédéric France <frederic.france@netlogic.fr>
|
||||
* Copyright (C) 2018 Ferran Marcet <fmarcet@2byte.es>
|
||||
* 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
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@ -945,7 +946,7 @@ if (empty($action) || $action == 'view') {
|
||||
$vatstatic = new Tva($db);
|
||||
$donationstatic = new Don($db);
|
||||
$loanstatic = new Loan($db);
|
||||
$salarystatic = new PaymentSalary($db);
|
||||
$salarystatic = new Salary($db);
|
||||
$variousstatic = new PaymentVarious($db);
|
||||
|
||||
llxHeader('', $langs->trans("FinanceJournal"));
|
||||
|
||||
@ -3,6 +3,7 @@
|
||||
* Copyright (C) 2004-2019 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2017 Pierre-Henry Favre <support@atm-consulting.fr>
|
||||
* Copyright (C) 2020 Maxime DEMAREST <maxime@indelog.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
|
||||
@ -206,7 +207,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 .= " WHERE datep between ".$wheretail;
|
||||
$sql .= " AND t.entity IN (".($entity == 1 ? '0,1' : $entity).')';
|
||||
//$sql.=" AND fk_statut <> ".PaymentSalary::STATUS_DRAFT;
|
||||
//$sql.=" AND fk_statut <> ".PaymentSalary::STATUS_DRAFT;
|
||||
}
|
||||
// Social contributions
|
||||
if (GETPOST('selectsocialcontributions')) {
|
||||
|
||||
@ -1420,6 +1420,7 @@ if ($resql) {
|
||||
} elseif ($links[$key]['type'] == 'member') {
|
||||
} elseif ($links[$key]['type'] == 'sc') {
|
||||
} elseif ($links[$key]['type'] == 'vat') {
|
||||
} elseif ($links[$key]['type'] == 'salary') {
|
||||
} else {
|
||||
// Show link with label $links[$key]['label']
|
||||
if (!empty($objp->label) && !empty($links[$key]['label'])) {
|
||||
|
||||
@ -367,6 +367,11 @@ if ($result) {
|
||||
print img_object($langs->trans('VATDeclaration'), 'bill').' ';
|
||||
print $langs->trans("VATDeclaration").($links[$key]['label'] ? ' '.$links[$key]['label'] : '');
|
||||
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') {
|
||||
print '<a href="'.DOL_URL_ROOT.'/compta/payment_sc/card.php?id='.$links[$key]['url_id'].'">';
|
||||
print img_object($langs->trans('Payment'), 'payment').' ';
|
||||
@ -378,7 +383,7 @@ if ($result) {
|
||||
print $langs->trans("VATPayment");
|
||||
print '</a>';
|
||||
} 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 $langs->trans("SalaryPayment");
|
||||
print '</a>';
|
||||
|
||||
@ -6,6 +6,7 @@
|
||||
* Copyright (C) 2011-2014 Juanjo Menent <jmenent@2byte.es>
|
||||
* Copyright (C) 2015 Jean-François Ferry <jfefe@aternatik.fr>
|
||||
* 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
|
||||
* 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/sociales/class/chargesociales.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.'/compta/bank/class/account.class.php';
|
||||
|
||||
@ -84,7 +85,7 @@ if (!$sortorder) {
|
||||
$tva_static = new Tva($db);
|
||||
$socialcontrib = new ChargeSociales($db);
|
||||
$payment_sc_static = new PaymentSocialContribution($db);
|
||||
$sal_static = new PaymentSalary($db);
|
||||
$sal_static = new Salary($db);
|
||||
$accountstatic = new Account($db);
|
||||
|
||||
llxHeader('', $langs->trans("SpecialExpensesArea"));
|
||||
@ -468,7 +469,7 @@ while ($j < $numlt) {
|
||||
/*
|
||||
if (!empty($conf->salaries->enabled) && !empty($user->rights->salaries->read))
|
||||
{
|
||||
$sal = new PaymentSalary($db);
|
||||
$sal = new Salary($db);
|
||||
|
||||
print "<br>";
|
||||
|
||||
|
||||
@ -6,6 +6,7 @@
|
||||
* Copyright (C) 2011-2014 Juanjo Menent <jmenent@2byte.es>
|
||||
* Copyright (C) 2015 Jean-François Ferry <jfefe@aternatik.fr>
|
||||
* 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
|
||||
* 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/sociales/class/chargesociales.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.'/compta/bank/class/account.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formsocialcontrib.class.php';
|
||||
@ -95,7 +96,7 @@ if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x'
|
||||
$tva_static = new Tva($db);
|
||||
$socialcontrib = new ChargeSociales($db);
|
||||
$payment_sc_static = new PaymentSocialContribution($db);
|
||||
$sal_static = new PaymentSalary($db);
|
||||
$sal_static = new Salary($db);
|
||||
$accountstatic = new Account($db);
|
||||
$formsocialcontrib = new FormSocialContrib($db);
|
||||
|
||||
|
||||
@ -2237,6 +2237,9 @@ abstract class CommonObject
|
||||
if (get_class($this) == 'Tva') {
|
||||
$fieldname = 'fk_typepayment';
|
||||
}
|
||||
if (get_class($this) == 'Salary') {
|
||||
$fieldname = 'fk_typepayment';
|
||||
}
|
||||
|
||||
$sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element;
|
||||
$sql .= ' SET '.$fieldname.' = '.(($id > 0 || $id == '0') ? $id : 'NULL');
|
||||
|
||||
@ -1874,7 +1874,7 @@ function dol_banner_tab($object, $paramid, $morehtml = '', $shownav = 1, $fieldi
|
||||
} else {
|
||||
$morehtmlstatus .= '<span class="statusrefbuy">'.$object->getLibStatut(6, 1).'</span>';
|
||||
}
|
||||
} elseif (in_array($object->element, array('facture', 'invoice', 'invoice_supplier', 'chargesociales', 'loan', 'tva'))) {
|
||||
} elseif (in_array($object->element, array('facture', 'invoice', 'invoice_supplier', 'chargesociales', 'loan', 'tva', 'salary'))) {
|
||||
$tmptxt = $object->getLibStatut(6, $object->totalpaye);
|
||||
if (empty($tmptxt) || $tmptxt == $object->getLibStatut(3)) {
|
||||
$tmptxt = $object->getLibStatut(5, $object->totalpaye);
|
||||
|
||||
@ -2,6 +2,7 @@
|
||||
/**
|
||||
* Copyright (C) 2015 Charlie BENKE <charlie@patas-monkey.com>
|
||||
* 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
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@ -33,7 +34,7 @@ function salaries_prepare_head($object)
|
||||
$head = array();
|
||||
|
||||
$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';
|
||||
$h++;
|
||||
|
||||
|
||||
@ -1145,8 +1145,9 @@ function print_left_eldy_menu($db, $menu_array_before, $menu_array_after, &$tabM
|
||||
$langs->load("salaries");
|
||||
$newmenu->add("/salaries/list.php?leftmenu=tax_salary&mainmenu=billing", $langs->trans("Salaries"), 0, $user->rights->salaries->read, '', $mainmenu, 'tax_salary', 0, '', '', '', img_picto('', 'salary', 'class="paddingright pictofixedwidth"'));
|
||||
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/list.php?leftmenu=tax_salary", $langs->trans("Payments"), 1, $user->rights->salaries->read);
|
||||
$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("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);
|
||||
}
|
||||
}
|
||||
|
||||
@ -197,3 +197,37 @@ ALTER TABLE llx_propal CHANGE COLUMN tva total_tva double(24,8) default 0;
|
||||
ALTER TABLE llx_propal CHANGE COLUMN total total_ttc double(24,8) default 0;
|
||||
ALTER TABLE llx_commande_fournisseur CHANGE COLUMN tva total_tva double(24,8) default 0;
|
||||
|
||||
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 1 NOT NULL,
|
||||
fk_account integer,
|
||||
fk_user_author integer, -- user creating
|
||||
fk_user_modif integer -- user making last change
|
||||
)ENGINE=innodb;
|
||||
|
||||
ALTER TABLE llx_payment_salary CHANGE fk_user fk_user integer NULL;
|
||||
ALTER TABLE llx_payment_salary ADD COLUMN fk_salary integer;
|
||||
|
||||
REPLACE INTO llx_salary (rowid, fk_user, amount, fk_projet, fk_account, fk_typepayment, num_payment, label, datesp, dateep, entity, note, fk_bank) SELECT ps.rowid, ps.fk_user, ps.amount, ps.fk_projet, b.fk_account, ps.fk_typepayment, ps.num_payment, ps.label, ps.datesp, ps.dateep, ps.entity, ps.note, ps.fk_bank FROM llx_payment_salary ps LEFT JOIN llx_salary s ON (s.rowid = ps.fk_salary) LEFT JOIN llx_bank b ON (b.rowid = ps.fk_bank) WHERE s.rowid IS NULL;
|
||||
|
||||
UPDATE llx_payment_salary ps INNER JOIN llx_salary s ON (s.rowid = ps.rowid) SET ps.fk_salary = s.rowid WHERE ps.fk_salary IS NULL;
|
||||
|
||||
ALTER TABLE llx_salary CHANGE paye paye smallint default 0 NOT NULL;
|
||||
|
||||
@ -24,4 +24,3 @@ ALTER TABLE llx_payment_salary ADD INDEX idx_payment_salary_datesp (datesp);
|
||||
ALTER TABLE llx_payment_salary ADD INDEX idx_payment_salary_dateep (dateep);
|
||||
|
||||
ALTER TABLE llx_payment_salary ADD CONSTRAINT fk_payment_salary_user FOREIGN KEY (fk_user) REFERENCES llx_user (rowid);
|
||||
|
||||
|
||||
@ -22,7 +22,7 @@ create table llx_payment_salary
|
||||
ref varchar(30) NULL, -- payment reference number (currently NULL because there is no numbering manager yet)
|
||||
tms timestamp DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
|
||||
datec datetime, -- Create date
|
||||
fk_user integer NOT NULL,
|
||||
fk_user integer DEFAULT 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
|
||||
@ -37,5 +37,6 @@ create table llx_payment_salary
|
||||
note text,
|
||||
fk_bank integer,
|
||||
fk_user_author integer, -- user creating
|
||||
fk_user_modif integer -- user making last change
|
||||
fk_user_modif integer, -- user making last change
|
||||
fk_salary integer
|
||||
)ENGINE=innodb;
|
||||
|
||||
44
htdocs/install/mysql/tables/llx_salary.sql
Normal file
44
htdocs/install/mysql/tables/llx_salary.sql
Normal 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;
|
||||
@ -495,6 +495,7 @@ Reported=Delayed
|
||||
DisabledBecausePayments=Not possible since there are some payments
|
||||
CantRemovePaymentWithOneInvoicePaid=Can't remove payment since there is at least one invoice classified paid
|
||||
CantRemovePaymentVATPaid=Can't remove payment since VAT declaration is classified paid
|
||||
CantRemovePaymentSalaryPaid=Can't remove payment since salary is classified paid
|
||||
ExpectedToPay=Expected payment
|
||||
CantRemoveConciliatedPayment=Can't remove reconciled payment
|
||||
PayedByThisPayment=Paid by this payment
|
||||
@ -502,6 +503,7 @@ ClosePaidInvoicesAutomatically=Classify automatically all standard, down payment
|
||||
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.
|
||||
ClosePaidVATAutomatically=Classify automatically VAT declaration 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".
|
||||
ToMakePayment=Pay
|
||||
ToMakePaymentBack=Pay back
|
||||
|
||||
@ -139,12 +139,16 @@ DateChequeReceived=Check reception date
|
||||
NbOfCheques=No. of checks
|
||||
PaySocialContribution=Pay a social/fiscal tax
|
||||
PayVAT=Pay a VAT declaration
|
||||
PaySalary=Pay a salary card
|
||||
ConfirmPaySocialContribution=Are you sure you want to classify this social or fiscal tax as paid ?
|
||||
ConfirmPayVAT=Are you sure you want to classify this VAT declaration as paid ?
|
||||
ConfirmPaySalary=Are you sure you want to classify this salary card as paid?
|
||||
DeleteSocialContribution=Delete a social or fiscal tax payment
|
||||
DeleteVAT=Delete a VAT declaration
|
||||
DeleteSalary=Delete a salary card
|
||||
ConfirmDeleteSocialContribution=Are you sure you want to delete this social/fiscal tax payment ?
|
||||
ConfirmDeleteVAT=Are you sure you want to delete this VAT declaration ?
|
||||
ConfirmDeleteSalary=Are you sure you want to delete this salary?
|
||||
ExportDataset_tax_1=Social and fiscal taxes and payments
|
||||
CalcModeVATDebt=Mode <b>%sVAT on commitment accounting%s</b>.
|
||||
CalcModeVATEngagement=Mode <b>%sVAT on incomes-expenses%s</b>.
|
||||
@ -244,6 +248,7 @@ 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.
|
||||
ConfirmCloneTax=Confirm the clone of a social/fiscal tax
|
||||
ConfirmCloneVAT=Confirm the clone of a VAT declaration
|
||||
ConfirmCloneSalary=Confirm the clone of a salary
|
||||
CloneTaxForNextMonth=Clone it for next month
|
||||
SimpleReport=Simple report
|
||||
AddExtraReport=Extra reports (add foreign and national customer report)
|
||||
|
||||
@ -2,12 +2,14 @@
|
||||
SALARIES_ACCOUNTING_ACCOUNT_PAYMENT=Accounting account used for user third parties
|
||||
SALARIES_ACCOUNTING_ACCOUNT_PAYMENT_Desc=The dedicated accounting account defined on user 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 user accounting account on user is not defined.
|
||||
SALARIES_ACCOUNTING_ACCOUNT_CHARGE=Accounting account by default for wage payments
|
||||
CREATE_NEW_SALARY_WITHOUT_AUTO_PAYMENT=By default, leave empty the option "Automatically create a total payment" when creating a Salary
|
||||
Salary=Salary
|
||||
Salaries=Salaries
|
||||
NewSalaryPayment=New salary payment
|
||||
NewSalaryPayment=New salary card
|
||||
AddSalaryPayment=Add salary payment
|
||||
SalaryPayment=Salary payment
|
||||
SalariesPayments=Salaries payments
|
||||
SalariesPaymentsOf=Salaries payments of %s
|
||||
ShowSalaryPayment=Show salary payment
|
||||
THM=Average hourly rate
|
||||
TJM=Average daily rate
|
||||
|
||||
@ -2,6 +2,7 @@
|
||||
SALARIES_ACCOUNTING_ACCOUNT_PAYMENT=Compte comptable utilisé pour les utilisateurs
|
||||
SALARIES_ACCOUNTING_ACCOUNT_PAYMENT_Desc=Le compte comptable défini sur la fiche utilisateur sera utilisé uniquement pour la comptabilité auxiliaire. Celui-ci sera utilisé pour le grand livre et comme valeur par défaut de la comptabilité auxiliaire si le compte dédié de l'utilisateur n'est pas défini.
|
||||
SALARIES_ACCOUNTING_ACCOUNT_CHARGE=Compte comptable par défaut pour les paiements de salaires
|
||||
CREATE_NEW_SALARY_WITHOUT_AUTO_PAYMENT=Par défaut, laisser vide l’option « Créer automatiquement un règlement total » lors de la création d'un Salaire
|
||||
Salary=Salaire
|
||||
Salaries=Salaires
|
||||
NewSalaryPayment=Nouveau règlement de salaire
|
||||
|
||||
@ -6,6 +6,7 @@
|
||||
* Copyright (C) 2015-2019 Alexandre Spangaro <aspangaro@open-dsi.fr>
|
||||
* Copyright (C) 2015 Marcos García <marcosgdf@gmail.com>
|
||||
* 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
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@ -92,7 +93,7 @@ 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';
|
||||
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';
|
||||
@ -564,7 +565,7 @@ $listofreferent = array(
|
||||
'salaries'=>array(
|
||||
'name'=>"Salaries",
|
||||
'title'=>"ListSalariesAssociatedProject",
|
||||
'class'=>'PaymentSalary',
|
||||
'class'=>'Salary',
|
||||
'table'=>'payment_salary',
|
||||
'datefieldname'=>'datev',
|
||||
'margin'=>'minus',
|
||||
|
||||
@ -68,6 +68,13 @@ if ($action == 'update') {
|
||||
}
|
||||
}
|
||||
|
||||
// Set boolean (on/off) constants
|
||||
elseif (preg_match('/^(set|del)_?([A-Z_]+)$/', $action, $reg)) {
|
||||
if (!dolibarr_set_const($db, $reg[2], ($reg[1] === 'set' ? '1' : '0'), 'chaine', 0, '', $conf->entity) > 0) {
|
||||
dol_print_error($db);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* View
|
||||
*/
|
||||
@ -127,7 +134,21 @@ print "</table>\n";
|
||||
|
||||
print '<div class="center"><input type="submit" class="button" value="'.$langs->trans('Modify').'" name="button"></div>';
|
||||
|
||||
print '</form>';
|
||||
print '</form><br>';
|
||||
|
||||
echo '<div>';
|
||||
echo '<table class="noborder centpercent">';
|
||||
echo '<thead>';
|
||||
echo '<tr class="liste_titre"><th>' . $langs->trans('Parameter') . '</th><th>' . $langs->trans('Value') . '</th></tr>';
|
||||
echo '</thead>';
|
||||
echo '<tbody>';
|
||||
|
||||
$key = 'CREATE_NEW_SALARY_WITHOUT_AUTO_PAYMENT';
|
||||
echo '<tr><td>', $langs->trans($key), '</td><td>', ajax_constantonoff($key), '</td></tr>';
|
||||
|
||||
echo '</tbody>';
|
||||
echo '</table>';
|
||||
echo '</div>';
|
||||
|
||||
// End of page
|
||||
llxFooter();
|
||||
|
||||
655
htdocs/salaries/card.php
Normal file → Executable file
655
htdocs/salaries/card.php
Normal file → Executable file
@ -4,6 +4,7 @@
|
||||
* Copyright (C) 2015 Jean-François Ferry <jfefe@aternatik.fr>
|
||||
* Copyright (C) 2015 Charlie BENKE <charlie@patas-monkey.com>
|
||||
* 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
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@ -24,9 +25,9 @@
|
||||
* \ingroup salaries
|
||||
* \brief Page of salaries payments
|
||||
*/
|
||||
|
||||
require '../main.inc.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.'/compta/bank/class/account.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/salaries.lib.php';
|
||||
@ -37,7 +38,7 @@ if (!empty($conf->projet->enabled)) {
|
||||
}
|
||||
|
||||
// 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");
|
||||
}
|
||||
@ -47,11 +48,18 @@ $action = GETPOST('action', 'aZ09');
|
||||
$cancel = GETPOST('cancel', 'aZ09');
|
||||
$accountid = GETPOST('accountid', 'int') > 0 ? GETPOST('accountid', 'int') : 0;
|
||||
$projectid = (GETPOST('projectid', 'int') ? GETPOST('projectid', 'int') : GETPOST('fk_project', 'int'));
|
||||
$confirm = GETPOST('confirm');
|
||||
if (GETPOSTISSET('auto_create_paiement') || $action === 'add') {
|
||||
$auto_create_paiement = GETPOST("auto_create_paiement", "int");
|
||||
} else {
|
||||
$auto_create_paiement = empty($conf->global->CREATE_NEW_SALARY_WITHOUT_AUTO_PAYMENT);
|
||||
}
|
||||
|
||||
$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'));
|
||||
$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'));
|
||||
$label = GETPOST('label');
|
||||
|
||||
// Security check
|
||||
$socid = GETPOST("socid", "int");
|
||||
@ -60,7 +68,7 @@ if ($user->socid) {
|
||||
}
|
||||
$result = restrictedArea($user, 'salaries', '', '', '');
|
||||
|
||||
$object = new PaymentSalary($db);
|
||||
$object = new Salary($db);
|
||||
$extrafields = new ExtraFields($db);
|
||||
|
||||
// fetch optionals attributes and labels
|
||||
@ -85,20 +93,62 @@ if ($action == 'classin' && $user->rights->banque->modifier) {
|
||||
$object->setProject($projectid);
|
||||
}
|
||||
|
||||
// set label
|
||||
if ($action == 'setlabel' && $user->rights->salaries->write) {
|
||||
$object->fetch($id);
|
||||
$object->label = $label;
|
||||
$object->update($user);
|
||||
}
|
||||
|
||||
// Classify paid
|
||||
if ($action == 'confirm_paid' && $user->rights->salaries->write && $confirm == 'yes') {
|
||||
$object->fetch($id);
|
||||
$result = $object->set_paid($user);
|
||||
}
|
||||
|
||||
// Reopen
|
||||
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)) {
|
||||
$error = 0;
|
||||
|
||||
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->accountid = GETPOST("accountid", 'int') > 0 ? GETPOST("accountid", "int") : 0;
|
||||
$object->fk_user = GETPOST("fk_user", 'int') > 0 ? GETPOST("fk_user", "int") : 0;
|
||||
$object->datev = $datev;
|
||||
$object->datep = $datep;
|
||||
$object->amount = price2num(GETPOST("amount", 'alpha'));
|
||||
$object->amount = $amount = price2num(GETPOST("amount", 'alpha'));
|
||||
$object->label = GETPOST("label", 'alphanohtml');
|
||||
$object->datesp = $datesp;
|
||||
$object->dateep = $dateep;
|
||||
@ -119,7 +169,11 @@ if ($action == 'add' && empty($cancel)) {
|
||||
$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');
|
||||
$error++;
|
||||
}
|
||||
@ -127,7 +181,7 @@ if ($action == 'add' && empty($cancel)) {
|
||||
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Employee")), null, 'errors');
|
||||
$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');
|
||||
$error++;
|
||||
}
|
||||
@ -135,67 +189,163 @@ if ($action == 'add' && empty($cancel)) {
|
||||
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Amount")), null, 'errors');
|
||||
$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');
|
||||
$error++;
|
||||
}
|
||||
|
||||
if (!$error) {
|
||||
$db->begin();
|
||||
|
||||
$ret = $object->create($user);
|
||||
if ($ret > 0) {
|
||||
$db->commit();
|
||||
if ($ret < 0) $error++;
|
||||
if (!empty($auto_create_paiement) && !$error) {
|
||||
$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')) {
|
||||
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;
|
||||
} else {
|
||||
header("Location: list.php");
|
||||
header("Location: " . $_SERVER['PHP_SELF'] . '?id=' . $object->id);
|
||||
exit;
|
||||
}
|
||||
} else {
|
||||
$db->rollback();
|
||||
setEventMessages($object->error, $object->errors, 'errors');
|
||||
$action = "create";
|
||||
}
|
||||
}
|
||||
|
||||
$action = 'create';
|
||||
}
|
||||
|
||||
if ($action == 'delete') {
|
||||
if ($action == 'confirm_delete') {
|
||||
$result = $object->fetch($id);
|
||||
$totalpaye = $object->getSommePaiement();
|
||||
|
||||
if ($object->rappro == 0) {
|
||||
if (empty($totalpaye)) {
|
||||
$db->begin();
|
||||
|
||||
$ret = $object->delete($user);
|
||||
if ($ret > 0) {
|
||||
if ($object->fk_bank) {
|
||||
$accountline = new AccountLine($db);
|
||||
$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 {
|
||||
if ($ret > 0)
|
||||
{
|
||||
$db->commit();
|
||||
header("Location: ".DOL_URL_ROOT.'/salaries/list.php');
|
||||
exit;
|
||||
}
|
||||
else {
|
||||
$db->rollback();
|
||||
setEventMessages($object->error, $object->errors, 'errors');
|
||||
}
|
||||
}
|
||||
else {
|
||||
setEventMessages($langs->trans('DisabledBecausePayments'), null, 'errors');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if ($action == 'update' && !$_POST["cancel"] && $user->rights->salaries->write) {
|
||||
$amount = price2num(GETPOST('amount'));
|
||||
|
||||
if (empty($amount)) {
|
||||
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 {
|
||||
setEventMessages('Error try do delete a line linked to a conciliated bank transaction', null, 'errors');
|
||||
$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);
|
||||
}
|
||||
}
|
||||
|
||||
@ -204,15 +354,13 @@ if ($action == 'delete') {
|
||||
* View
|
||||
*/
|
||||
|
||||
llxHeader("", $langs->trans("SalaryPayment"));
|
||||
llxHeader("", $langs->trans("Salary"));
|
||||
|
||||
$form = new Form($db);
|
||||
if (!empty($conf->projet->enabled)) {
|
||||
$formproject = new FormProjets($db);
|
||||
}
|
||||
if (!empty($conf->projet->enabled)) $formproject = new FormProjets($db);
|
||||
|
||||
if ($id) {
|
||||
$object = new PaymentSalary($db);
|
||||
$object = new Salary($db);
|
||||
$result = $object->fetch($id);
|
||||
if ($result <= 0) {
|
||||
dol_print_error($db);
|
||||
@ -249,22 +397,40 @@ if ($action == 'create') {
|
||||
|
||||
print load_fiche_titre($langs->trans("NewSalaryPayment"), '', 'salary');
|
||||
|
||||
if (!empty($conf->use_javascript_ajax)) {
|
||||
print "\n".'<script type="text/javascript" language="javascript">';
|
||||
print /** @lang JavaScript */'
|
||||
$(document).ready(function () {
|
||||
let onAutoCreatePaiementChange = function () {
|
||||
if($("#auto_create_paiement").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();
|
||||
}
|
||||
};
|
||||
$("#radiopayment").click(function() {
|
||||
$("#label").val($(this).data("label"));
|
||||
});
|
||||
$("#radiorefund").click(function() {
|
||||
$("#label").val($(this).data("label"));
|
||||
});
|
||||
$("#auto_create_paiement").click(function () {
|
||||
onAutoCreatePaiementChange();
|
||||
});
|
||||
onAutoCreatePaiementChange();
|
||||
});
|
||||
';
|
||||
print '</script>'."\n";
|
||||
}
|
||||
|
||||
print dol_get_fiche_head('', '');
|
||||
|
||||
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) ? '' : $datep), "datep", 0, 0, 0, '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>';
|
||||
|
||||
// Employee
|
||||
print '<tr><td>';
|
||||
print $form->editfieldkey('Employee', 'fk_user', '', $object, 0, 'string', '', 1).'</td><td>';
|
||||
@ -296,30 +462,7 @@ if ($action == 'create') {
|
||||
print '<input name="amount" id="amount" class="minwidth100" value="'.GETPOST("amount").'">';
|
||||
print '</td></tr>';
|
||||
|
||||
// Bank
|
||||
if (!empty($conf->banque->enabled)) {
|
||||
print '<tr><td>';
|
||||
print $form->editfieldkey('BankAccount', 'selectaccountid', '', $object, 0, 'string', '', 1).'</td><td>';
|
||||
$form->select_comptes($accountid, "accountid", 0, '', 1); // Affiche liste des comptes courant
|
||||
print '</td></tr>';
|
||||
}
|
||||
|
||||
// Type payment
|
||||
print '<tr><td>';
|
||||
print $form->editfieldkey('PaymentMode', 'selectpaymenttype', '', $object, 0, 'string', '', 1).'</td><td>';
|
||||
$form->select_types_paiements(GETPOST("paymenttype", 'aZ09'), "paymenttype", '', 2);
|
||||
print '</td></tr>';
|
||||
|
||||
// Number
|
||||
if (!empty($conf->banque->enabled)) {
|
||||
// Number
|
||||
print '<tr><td><label for="num_payment">'.$langs->trans('Numero');
|
||||
print ' <em>('.$langs->trans("ChequeOrTransferNumber").')</em>';
|
||||
print '</label></td>';
|
||||
print '<td><input name="num_payment" id="num_payment" type="text" value="'.GETPOST("num_payment").'"></td></tr>'."\n";
|
||||
}
|
||||
|
||||
// Project
|
||||
// Project
|
||||
if (!empty($conf->projet->enabled)) {
|
||||
$formproject = new FormProjets($db);
|
||||
|
||||
@ -328,6 +471,56 @@ if ($action == 'create') {
|
||||
print '</td></tr>';
|
||||
}
|
||||
|
||||
// Bank
|
||||
if (!empty($conf->banque->enabled)) {
|
||||
print '<tr><td id="label_fk_account">';
|
||||
print $form->editfieldkey('BankAccount', 'selectaccountid', '', $object, 0, 'string', '', 1).'</td><td>';
|
||||
$form->select_comptes($accountid, "accountid", 0, '', 1); // Affiche liste des comptes courant
|
||||
print '</td></tr>';
|
||||
}
|
||||
|
||||
// Type payment
|
||||
print '<tr><td id="label_type_payment">';
|
||||
print $form->editfieldkey('PaymentMode', 'selectpaymenttype', '', $object, 0, 'string', '', 1).'</td><td>';
|
||||
$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" ' . (empty($auto_create_paiement) ? '' : 'checked="checked"') . ' value="1"></td></tr>'."\n"; // Date payment
|
||||
|
||||
// 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) ? '' : $datep), "datep", 0, 0, 0, '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>';
|
||||
|
||||
// Number
|
||||
if (!empty($conf->banque->enabled)) {
|
||||
// Number
|
||||
print '<tr class="hide_if_no_auto_create_payment"><td><label for="num_payment">'.$langs->trans('Numero');
|
||||
print ' <em>('.$langs->trans("ChequeOrTransferNumber").')</em>';
|
||||
print '</label></td>';
|
||||
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
|
||||
$parameters = array();
|
||||
$reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
|
||||
@ -361,16 +554,57 @@ if ($action == 'create') {
|
||||
if ($id) {
|
||||
$head = salaries_prepare_head($object);
|
||||
|
||||
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&action=update\" method=\"post\">";
|
||||
print '<input type="hidden" name="token" value="'.newToken().'">';
|
||||
}
|
||||
|
||||
print dol_get_fiche_head($head, 'card', $langs->trans("SalaryPayment"), -1, 'salary');
|
||||
|
||||
$linkback = '<a href="'.DOL_URL_ROOT.'/salaries/list.php?restore_lastsearch_values=1'.(!empty($socid) ? '&socid='.$socid : '').'">'.$langs->trans("BackToList").'</a>';
|
||||
|
||||
$morehtmlref = '<div class="refidno">';
|
||||
|
||||
// Label
|
||||
if ($action != 'editlabel') {
|
||||
$morehtmlref .= $form->editfieldkey("Label", 'label', $object->label, $object, $user->rights->salaries->write, 'string', '', 0, 1);
|
||||
$morehtmlref .= $object->label;
|
||||
} else {
|
||||
$morehtmlref .= '<br>'.$langs->trans('Label').' : ';
|
||||
$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>';
|
||||
}
|
||||
|
||||
// Employee
|
||||
$userstatic = new User($db);
|
||||
$userstatic->fetch($object->fk_user);
|
||||
$morehtmlref .= $langs->trans('Employee').' : '.$userstatic->getNomUrl(1);
|
||||
$morehtmlref .= '<br>' .$langs->trans('Employee').' : '.$userstatic->getNomUrl(1);
|
||||
|
||||
// Project
|
||||
if (!empty($conf->projet->enabled)) {
|
||||
@ -384,7 +618,7 @@ if ($id) {
|
||||
$morehtmlref .= '<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">';
|
||||
$morehtmlref .= '<input type="hidden" name="action" value="classin">';
|
||||
$morehtmlref .= '<input type="hidden" name="token" value="'.newToken().'">';
|
||||
$morehtmlref .= $formproject->select_projects(0, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1);
|
||||
$morehtmlref .= $formproject->select_projects(-1, $object->fk_project, 'projectid', 0, 0, 1, 0, 1, 0, 0, '', 1);
|
||||
$morehtmlref .= '<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">';
|
||||
$morehtmlref .= '</form>';
|
||||
} else {
|
||||
@ -402,50 +636,93 @@ if ($id) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$morehtmlref .= '</div>';
|
||||
|
||||
$totalpaye = $object->getSommePaiement();
|
||||
$object->totalpaye = $totalpaye;
|
||||
|
||||
dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'ref', $morehtmlref, '', 0, '', '');
|
||||
|
||||
print '<div class="fichecenter">';
|
||||
print '<div class="fichehalfleft">';
|
||||
print '<div class="underbanner clearboth"></div>';
|
||||
|
||||
print '<table class="border centpercent tableforfield">';
|
||||
|
||||
// Label
|
||||
print '<tr><td class="titlefield">'.$langs->trans("Label").'</td><td>'.$object->label.'</td></tr>';
|
||||
if ($action == 'edit') {
|
||||
print '<tr><td>'.$langs->trans("DateStartPeriod")."</td><td>";
|
||||
print $form->selectDate($object->datesp, 'datesp', 0, 0, 0, 'datesp', 1);
|
||||
print "</td></tr>";
|
||||
|
||||
print "<tr>";
|
||||
print '<td>'.$langs->trans("DateStartPeriod").'</td><td>';
|
||||
print dol_print_date($object->datesp, 'day');
|
||||
print '</td></tr>';
|
||||
} else {
|
||||
print "<tr>";
|
||||
print '<td>' . $langs->trans("DateStartPeriod") . '</td><td>';
|
||||
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 dol_print_date($object->datep, 'day');
|
||||
print '</td></tr>';
|
||||
|
||||
print '<tr><td>'.$langs->trans("DateValue").'</td><td>';
|
||||
print dol_print_date($object->datev, 'day');
|
||||
print '</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>';
|
||||
} else {
|
||||
print '<tr><td>' . $langs->trans("Amount") . '</td><td>' . price($object->amount, 0, $outputlangs, 1, -1, -1, $conf->currency) . '</td></tr>';
|
||||
}
|
||||
|
||||
// Mode of payment
|
||||
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&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>';
|
||||
|
||||
print '<tr><td>'.$langs->trans("Amount").'</td><td>'.price($object->amount, 0, $outputlangs, 1, -1, -1, $conf->currency).'</td></tr>';
|
||||
|
||||
// Bank Account
|
||||
if (!empty($conf->banque->enabled)) {
|
||||
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>';
|
||||
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&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>';
|
||||
}
|
||||
|
||||
// Other attributes
|
||||
@ -455,20 +732,170 @@ if ($id) {
|
||||
|
||||
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_payment 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_typepayment = 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();
|
||||
|
||||
if ($action == 'edit') {
|
||||
print '<div align="center">';
|
||||
print '<input type="submit" class="button" name="save" value="'.$langs->trans("Save").'">';
|
||||
print ' ';
|
||||
print '<input type="submit" class="button" name="cancel" value="'.$langs->trans("Cancel").'">';
|
||||
print '</div>';
|
||||
print "</form>\n";
|
||||
}
|
||||
|
||||
print dol_get_fiche_end();
|
||||
|
||||
|
||||
// Action buttons
|
||||
|
||||
print '<div class="tabsAction">'."\n";
|
||||
if ($object->rappro == 0) {
|
||||
if (!empty($user->rights->salaries->delete)) {
|
||||
print '<div class="inline-block divButAction"><a class="butActionDelete" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&action=delete&token='.newToken().'">'.$langs->trans("Delete").'</a></div>';
|
||||
} else {
|
||||
print '<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#" title="'.(dol_escape_htmltag($langs->trans("NotAllowed"))).'">'.$langs->trans("Delete").'</a></div>';
|
||||
if ($action != 'edit') {
|
||||
// Reopen
|
||||
if ($object->paye && $user->rights->salaries->write) {
|
||||
print "<div class=\"inline-block divButAction\"><a class=\"butAction\" href=\"".dol_buildpath("/salaries/card.php", 1)."?id=$object->id&action=reopen\">".$langs->trans("ReOpen")."</a></div>";
|
||||
}
|
||||
|
||||
// Edit
|
||||
if ($object->paye == 0 && $user->rights->salaries->write) {
|
||||
print "<div class=\"inline-block divButAction\"><a class=\"butAction\" href=\"".DOL_URL_ROOT."/salaries/card.php?id=$object->id&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&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&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&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>";
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -1,6 +1,7 @@
|
||||
<?php
|
||||
/* Copyright (C) 2018 Alexandre Spangaro <aspangaro@open-dsi.fr>
|
||||
* 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
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@ -83,7 +84,7 @@ class SalariesStats extends Stats
|
||||
$sql = "SELECT YEAR(datep) as dm, count(*)";
|
||||
$sql .= " FROM ".$this->from;
|
||||
$sql .= " GROUP BY dm DESC";
|
||||
$sql .= " WHERE ".$this->where;
|
||||
//$sql .= " WHERE ".$this->where;
|
||||
|
||||
return $this->_getNbByYear($sql);
|
||||
}
|
||||
@ -101,7 +102,7 @@ class SalariesStats extends Stats
|
||||
$sql = "SELECT MONTH(datep) as dm, count(*)";
|
||||
$sql .= " FROM ".$this->from;
|
||||
$sql .= " WHERE YEAR(datep) = ".$year;
|
||||
$sql .= " AND ".$this->where;
|
||||
//$sql .= " AND ".$this->where;
|
||||
$sql .= " GROUP BY dm";
|
||||
$sql .= $this->db->order('dm', 'DESC');
|
||||
|
||||
@ -123,7 +124,7 @@ class SalariesStats extends Stats
|
||||
$sql = "SELECT date_format(datep,'%m') as dm, sum(".$this->field.")";
|
||||
$sql .= " FROM ".$this->from;
|
||||
$sql .= " WHERE date_format(datep,'%Y') = '".$this->db->escape($year)."'";
|
||||
$sql .= " AND ".$this->where;
|
||||
//$sql .= " AND ".$this->where;
|
||||
$sql .= " GROUP BY dm";
|
||||
$sql .= $this->db->order('dm', 'DESC');
|
||||
|
||||
@ -144,7 +145,7 @@ class SalariesStats extends Stats
|
||||
$sql = "SELECT date_format(datep,'%m') as dm, avg(".$this->field.")";
|
||||
$sql .= " FROM ".$this->from;
|
||||
$sql .= " WHERE date_format(datep,'%Y') = '".$this->db->escape($year)."'";
|
||||
$sql .= " AND ".$this->where;
|
||||
//$sql .= " AND ".$this->where;
|
||||
$sql .= " GROUP BY dm";
|
||||
$sql .= $this->db->order('dm', 'DESC');
|
||||
|
||||
@ -160,7 +161,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 .= " FROM ".$this->from;
|
||||
$sql .= " WHERE ".$this->where;
|
||||
//$sql .= " WHERE ".$this->where;
|
||||
$sql .= " GROUP BY year";
|
||||
$sql .= $this->db->order('year', 'DESC');
|
||||
|
||||
|
||||
738
htdocs/salaries/class/salary.class.php
Normal file
738
htdocs/salaries/class/salary.class.php
Normal file
@ -0,0 +1,738 @@
|
||||
<?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 extrafields
|
||||
/*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)
|
||||
{
|
||||
// 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("Salary").'</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
|
||||
* @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 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);
|
||||
}
|
||||
}
|
||||
@ -7,6 +7,7 @@
|
||||
* Copyright (C) 2011-2012 Juanjo Menent <jmenent@2byte.es>
|
||||
* Copyright (C) 2013 Cédric Salvador <csalvador@gpcsolutions.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
|
||||
* 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/class/html.formfile.class.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
|
||||
$langs->loadLangs(array("compta", "bills", "users", "salaries", "hrm"));
|
||||
@ -70,7 +71,7 @@ if (!$sortfield) {
|
||||
}
|
||||
|
||||
|
||||
$object = new PaymentSalary($db);
|
||||
$object = new Salary($db);
|
||||
$object->fetch($id, $ref);
|
||||
|
||||
$upload_dir = $conf->salaries->dir_output.'/'.dol_sanitizeFileName($object->id);
|
||||
|
||||
@ -2,6 +2,7 @@
|
||||
/* Copyright (C) 2005-2015 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2015 Charlie BENKE <charlie@patas-monkey.com>
|
||||
* 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
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@ -24,7 +25,7 @@
|
||||
*/
|
||||
|
||||
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/functions2.lib.php';
|
||||
|
||||
@ -48,7 +49,7 @@ $result = restrictedArea($user, 'salaries', '', '', '');
|
||||
|
||||
llxHeader("", $langs->trans("SalaryPayment"));
|
||||
|
||||
$object = new PaymentSalary($db);
|
||||
$object = new Salary($db);
|
||||
$object->fetch($id);
|
||||
$object->info($id);
|
||||
|
||||
|
||||
@ -2,6 +2,7 @@
|
||||
/* Copyright (C) 2011-2019 Alexandre Spangaro <aspangaro@open-dsi.fr>
|
||||
* Copyright (C) 2015-2016 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* 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
|
||||
@ -82,10 +83,13 @@ if (!$sortorder) {
|
||||
$search_ref = GETPOST('search_ref', 'int');
|
||||
$search_user = GETPOST('search_user', '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_end = dol_mktime(23, 59, 59, GETPOST('search_date_endmonth', 'int'), GETPOST('search_date_endday', 'int'), GETPOST('search_date_endyear', '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_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_account = GETPOST('search_account', 'int');
|
||||
$search_status = GETPOST('search_status', 'int');
|
||||
|
||||
$filtre = GETPOST("filtre", 'restricthtml');
|
||||
|
||||
@ -160,10 +164,14 @@ if (empty($reshook)) {
|
||||
$search_ref = "";
|
||||
$search_user = "";
|
||||
$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_amount = "";
|
||||
$search_account = '';
|
||||
$search_status = '';
|
||||
$search_type_id = "";
|
||||
}
|
||||
if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')
|
||||
@ -190,7 +198,7 @@ if (empty($reshook)) {
|
||||
*/
|
||||
|
||||
$form = new Form($db);
|
||||
$salstatic = new PaymentSalary($db);
|
||||
$salstatic = new Salary($db);
|
||||
$userstatic = new User($db);
|
||||
$accountstatic = new Account($db);
|
||||
|
||||
@ -198,16 +206,18 @@ $now = dol_now();
|
||||
|
||||
//$help_url="EN:Module_BillOfMaterials|FR:Module_BillOfMaterials_FR|ES:Módulo_BillOfMaterials";
|
||||
$help_url = '';
|
||||
$title = $langs->trans('SalariesPayments');
|
||||
$title = $langs->trans('Salaries');
|
||||
|
||||
$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 .= " pst.code as payment_code";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."payment_salary as s";
|
||||
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as pst ON s.fk_typepayment = pst.id";
|
||||
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."bank as b ON s.fk_bank = b.rowid";
|
||||
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."bank_account as ba ON b.fk_account = ba.rowid,";
|
||||
$sql .= " pst.code as payment_code,";
|
||||
$sql .= " SUM(ps.amount) as alreadypayed";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."salary as s";
|
||||
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."payment_salary as ps ON (ps.fk_salary = s.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 .= " WHERE u.rowid = s.fk_user";
|
||||
$sql .= " AND s.entity IN (".getEntity('payment_salaries').")";
|
||||
@ -225,11 +235,11 @@ if ($search_user) {
|
||||
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);
|
||||
@ -237,6 +247,9 @@ if ($search_amount) {
|
||||
if ($search_account > 0) {
|
||||
$sql .= " AND b.fk_account=".((int) $search_account);
|
||||
}
|
||||
if ($search_status != '' && $search_status >= 0) {
|
||||
$sql .= " AND s.paye = ".$db->escape($search_status);
|
||||
}
|
||||
if ($filtre) {
|
||||
$filtre = str_replace(":", "=", $filtre);
|
||||
$sql .= " AND ".$filtre;
|
||||
@ -244,6 +257,7 @@ if ($filtre) {
|
||||
if ($search_type_id) {
|
||||
$sql .= " AND s.fk_typepayment=".$search_type_id;
|
||||
}
|
||||
$sql .= " GROUP BY u.rowid, ba.rowid, s.rowid, s.amount, s.dateep, s.datesp, s.label, s.paye, pst.code";
|
||||
$sql .= $db->order($sortfield, $sortorder);
|
||||
|
||||
// Count total nb of records
|
||||
@ -305,12 +319,22 @@ if ($search_label) {
|
||||
if ($search_account) {
|
||||
$param .= '&search_account='.urlencode($search_account);
|
||||
}
|
||||
if ($search_date_start) {
|
||||
$param .= '&search_date_startday='.urlencode(GETPOST('search_date_startday', 'int')).'&search_date_startmonth='.urlencode(GETPOST('search_date_startmonth', 'int')).'&search_date_startyear='.urlencode(GETPOST('search_date_startyear', 'int'));
|
||||
if ($search_status != '' && $search_status != '-1') {
|
||||
$param .= '&search_status='.urlencode($search_status);
|
||||
}
|
||||
if ($search_date_end) {
|
||||
$param .= '&search_date_endday='.urlencode(GETPOST('search_date_endday', 'int')).'&search_date_endmonth='.urlencode(GETPOST('search_date_endmonth', 'int')).'&search_date_endyear='.urlencode(GETPOST('search_date_endyear', 'int'));
|
||||
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'));
|
||||
}
|
||||
|
||||
// Add $param from extra fields
|
||||
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
|
||||
|
||||
@ -367,18 +391,31 @@ print '<input class="flat" type="text" size="6" name="search_user" value="'.$db-
|
||||
print '</td>';
|
||||
// Label
|
||||
print '<td class="liste_titre"><input type="text" class="flat width150" name="search_label" value="'.$db->escape($search_label).'"></td>';
|
||||
// Date payment
|
||||
|
||||
// Date start
|
||||
print '<td class="liste_titre center">';
|
||||
print '<div class="nowrap">';
|
||||
print $form->selectDate($search_date_start ? $search_date_start : -1, 'search_date_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From'));
|
||||
print $langs->trans('From').' ';
|
||||
print $form->selectDate($search_date_start_from ? $search_date_start_from : -1, 'search_date_start_from', 0, 0, 1);
|
||||
print '</div>';
|
||||
print '<div class="nowrap">';
|
||||
print $form->selectDate($search_date_end ? $search_date_end : -1, 'search_date_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to'));
|
||||
print $langs->trans('to').' ';
|
||||
print $form->selectDate($search_date_start_to ? $search_date_start_to : -1, 'search_date_start_to', 0, 0, 1);
|
||||
print '</div>';
|
||||
print '</td>';
|
||||
// Date value
|
||||
|
||||
// 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
|
||||
print '<td class="liste_titre left">';
|
||||
$form->select_types_paiements($search_type_id, 'search_type_id', '', 0, 1, 1, 16);
|
||||
@ -392,6 +429,11 @@ if (!empty($conf->banque->enabled)) {
|
||||
// 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 maxwidthonsmartphone right">';
|
||||
$liststatus = array('0' => $langs->trans("Unpaid"), '1' => $langs->trans("Paid"));
|
||||
print $form->selectarray('search_status', $liststatus, $search_status, 1);
|
||||
print '</td>';
|
||||
|
||||
// Extra fields
|
||||
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php';
|
||||
|
||||
@ -411,15 +453,16 @@ print '</tr>'."\n";
|
||||
// --------------------------------------------------------------------
|
||||
print '<tr class="liste_titre">';
|
||||
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("DatePayment", $_SERVER["PHP_SELF"], "s.datep,s.rowid", "", $param, '', $sortfield, $sortorder, 'center ');
|
||||
print_liste_field_titre("DateValue", $_SERVER["PHP_SELF"], "s.datev,s.rowid", "", $param, '', $sortfield, $sortorder, 'center ');
|
||||
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);
|
||||
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('Status', $_SERVER["PHP_SELF"], "s.paye", '', $param, 'class="right"', $sortfield, $sortorder);
|
||||
// Extra fields
|
||||
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php';
|
||||
// Hook fields
|
||||
@ -488,14 +531,14 @@ while ($i < ($limit ? min($num, $limit) : $num)) {
|
||||
$totalarray['nbfield']++;
|
||||
}
|
||||
|
||||
// Date payment
|
||||
print '<td class="center">'.dol_print_date($db->jdate($obj->datep), 'day')."</td>\n";
|
||||
// Date Start
|
||||
print '<td class="center">'.dol_print_date($db->jdate($obj->datesp), 'day')."</td>\n";
|
||||
if (!$i) {
|
||||
$totalarray['nbfield']++;
|
||||
}
|
||||
|
||||
// Date value
|
||||
print '<td class="center">'.dol_print_date($db->jdate($obj->datev), 'day')."</td>\n";
|
||||
// Date End
|
||||
print '<td class="center">'.dol_print_date($db->jdate($obj->dateep), 'day')."</td>\n";
|
||||
if (!$i) {
|
||||
$totalarray['nbfield']++;
|
||||
}
|
||||
@ -509,7 +552,7 @@ while ($i < ($limit ? min($num, $limit) : $num)) {
|
||||
// Account
|
||||
if (!empty($conf->banque->enabled)) {
|
||||
print '<td>';
|
||||
if ($obj->fk_bank > 0) {
|
||||
if ($obj->fk_account > 0) {
|
||||
//$accountstatic->fetch($obj->fk_bank);
|
||||
$accountstatic->id = $obj->bid;
|
||||
$accountstatic->ref = $obj->bref;
|
||||
@ -523,7 +566,7 @@ while ($i < ($limit ? min($num, $limit) : $num)) {
|
||||
|
||||
$accountstatic->accountancy_journal = $accountingjournal->getNomUrl(0, 1, 1, '', 1);
|
||||
}
|
||||
$accountstatic->label = $obj->blabel;
|
||||
//$accountstatic->label = $obj->blabel;
|
||||
print $accountstatic->getNomUrl(1);
|
||||
} else {
|
||||
print ' ';
|
||||
@ -534,6 +577,8 @@ while ($i < ($limit ? min($num, $limit) : $num)) {
|
||||
}
|
||||
}
|
||||
|
||||
// if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 'totalttcfield';
|
||||
|
||||
// Amount
|
||||
print '<td class="nowrap right">'.price($obj->amount).'</td>';
|
||||
if (!$i) {
|
||||
@ -544,6 +589,9 @@ while ($i < ($limit ? min($num, $limit) : $num)) {
|
||||
}
|
||||
$totalarray['val']['totalttcfield'] += $obj->amount;
|
||||
|
||||
print '<td class="nowrap right">'.$salstatic->LibStatut($obj->paye, 5, $obj->alreadypayed).'</td>';
|
||||
if (!$i) $totalarray['nbfield']++;
|
||||
|
||||
// Extra fields
|
||||
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php';
|
||||
// Fields from hook
|
||||
|
||||
344
htdocs/salaries/paiement_salary.php
Normal file
344
htdocs/salaries/paiement_salary.php
Normal file
@ -0,0 +1,344 @@
|
||||
<?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"> </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 ' ';
|
||||
print '<input type="submit" class="button" name="cancel" value="'.$langs->trans("Cancel").'">';
|
||||
print '</div>';
|
||||
|
||||
print "</form>\n";
|
||||
}
|
||||
|
||||
llxFooter();
|
||||
$db->close();
|
||||
288
htdocs/salaries/payment_salary/card.php
Normal file
288
htdocs/salaries/payment_salary/card.php
Normal file
@ -0,0 +1,288 @@
|
||||
<?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', 'salaries'));
|
||||
|
||||
// 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.'&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_payment.'</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'].'&facid='.$objp->facid.'&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'].'&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();
|
||||
228
htdocs/salaries/payments.php
Normal file
228
htdocs/salaries/payments.php
Normal file
@ -0,0 +1,228 @@
|
||||
<?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.'/user/class/user.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
|
||||
|
||||
// Load translation files required by the page
|
||||
$langs->loadLangs(array('compta', 'bills', 'salaries'));
|
||||
|
||||
// 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()); }
|
||||
$search_user = GETPOST("search_user", 'int');
|
||||
|
||||
$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 (!empty($search_user)) {
|
||||
$u = new user($db);
|
||||
$u->fetch($search_user);
|
||||
$title = $langs->trans("SalariesPaymentsOf", '{s1}');
|
||||
$title = $title = str_replace('{s1}', $u->getNomUrl(), $title);
|
||||
}
|
||||
|
||||
$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_typepayment = pct.id";
|
||||
$sql .= " WHERE s.entity IN (".getEntity('user').")";
|
||||
if (!empty($search_user)) $sql .= " AND u.rowid = ".$search_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"], "ps.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"> </td>';
|
||||
print '<td align="center"> </td>';
|
||||
print '<td align="center"> </td>';
|
||||
print '<td align="center"> </td>';
|
||||
print '<td align="center"> </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();
|
||||
@ -1,6 +1,7 @@
|
||||
<?php
|
||||
/* Copyright (C) 2018 Alexandre Spangaro <aspangaro@open-dsi.fr>
|
||||
* 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
|
||||
* 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';
|
||||
|
||||
// Load translation files required by the page
|
||||
$langs->loadLangs(array("salaries", "companies"));
|
||||
$langs->loadLangs(array("salaries", "companies", "bills"));
|
||||
|
||||
$WIDTH = DolGraph::getDefaultGraphSizeForStats('width');
|
||||
$HEIGHT = DolGraph::getDefaultGraphSizeForStats('height');
|
||||
|
||||
@ -6,6 +6,7 @@
|
||||
* Copyright (C) 2013 Peter Fontaine <contact@peterfontaine.fr>
|
||||
* Copyright (C) 2015-2016 Marcos García <marcosgdf@gmail.com>
|
||||
* 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
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@ -357,11 +358,12 @@ if ($action != 'edit' && $action != 'create') { // If not bank account yet, $ac
|
||||
) {
|
||||
$salary = new PaymentSalary($db);
|
||||
|
||||
$sql = "SELECT ps.rowid, ps.datesp, ps.dateep, ps.amount";
|
||||
$sql = "SELECT ps.rowid, s.datesp, s.dateep, ps.amount";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."payment_salary as ps";
|
||||
$sql .= " WHERE ps.fk_user = ".$object->id;
|
||||
$sql .= " INNER JOIN ".MAIN_DB_PREFIX."salary as s ON (s.rowid = ps.fk_salary)";
|
||||
$sql .= " WHERE s.fk_user = ".$object->id;
|
||||
$sql .= " AND ps.entity = ".$conf->entity;
|
||||
$sql .= " ORDER BY ps.datesp DESC";
|
||||
$sql .= " ORDER BY ps.rowid DESC";
|
||||
|
||||
$resql = $db->query($sql);
|
||||
if ($resql) {
|
||||
@ -370,7 +372,7 @@ if ($action != 'edit' && $action != 'create') { // If not bank account yet, $ac
|
||||
print '<table class="noborder centpercent">';
|
||||
|
||||
print '<tr class="liste_titre">';
|
||||
print '<td colspan="4"><table width="100%" class="nobordernopadding"><tr><td>'.$langs->trans("LastSalaries", ($num <= $MAXLIST ? "" : $MAXLIST)).'</td><td class="right"><a class="notasortlink" href="'.DOL_URL_ROOT.'/salaries/list.php?search_user='.$object->login.'">'.$langs->trans("AllSalaries").'<span class="badge marginleftonlyshort">'.$num.'</span></a></td>';
|
||||
print '<td colspan="4"><table width="100%" class="nobordernopadding"><tr><td>'.$langs->trans("LastSalaries", ($num <= $MAXLIST ? "" : $MAXLIST)).'</td><td class="right"><a class="notasortlink" href="'.DOL_URL_ROOT.'/salaries/payments.php?search_user='.$object->id.'">'.$langs->trans("AllSalaries").'<span class="badge marginleftonlyshort">'.$num.'</span></a></td>';
|
||||
print '</tr></table></td>';
|
||||
print '</tr>';
|
||||
|
||||
@ -380,9 +382,9 @@ if ($action != 'edit' && $action != 'create') { // If not bank account yet, $ac
|
||||
|
||||
print '<tr class="oddeven">';
|
||||
print '<td class="nowraponall">';
|
||||
$salary->id = $objp->rowid;
|
||||
$salary->ref = $objp->rowid;
|
||||
print $salary->getNomUrl(1);
|
||||
$payment_salary->id = $objp->rowid;
|
||||
$payment_salary->ref = $objp->rowid;
|
||||
print $payment_salary->getNomUrl(1);
|
||||
print '</td>';
|
||||
|
||||
print '<td class="right" width="80px">'.dol_print_date($db->jdate($objp->datesp), 'day')."</td>\n";
|
||||
|
||||
Loading…
Reference in New Issue
Block a user