diff --git a/htdocs/compta/charges/index.php b/htdocs/compta/charges/index.php
index 519c24792f9..183220d2004 100644
--- a/htdocs/compta/charges/index.php
+++ b/htdocs/compta/charges/index.php
@@ -94,15 +94,14 @@ if ($conf->salaries->enabled)
print_fiche_titre($langs->trans("SalariesPayments").($year?' ('.$langs->trans("Year").' '.$year.')':''), '', '');
- $sql = "SELECT s.rowid, s.amount, s.label, s.datev as dm, s.salary, u.salary as current_salary";
+ $sql = "SELECT s.rowid, s.amount, s.label, s.datep as datep, s.datev as datev, s.datesp, s.dateep, s.salary, u.salary as current_salary";
$sql.= " FROM ".MAIN_DB_PREFIX."payment_salary as s, ".MAIN_DB_PREFIX."user as u";
$sql.= " WHERE s.entity IN (".getEntity('user',1).")";
$sql.= " AND u.rowid = s.fk_user";
if ($year > 0)
{
- // Si period renseignee on l'utilise comme critere de date, sinon on prend date echeance,
- // ceci afin d'etre compatible avec les cas ou la periode n'etait pas obligatoire
- $sql.= " AND s.datev between '".$db->idate(dol_get_first_day($year,1,false))."' AND '".$db->idate(dol_get_last_day($year,12,false))."'";
+ $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)) $sql.= $db->order($sortfield,$sortorder);
@@ -114,11 +113,11 @@ if ($conf->salaries->enabled)
$total = 0 ;
print '
';
if (! empty($conf->banque->enabled))
{
- if ($salpayment->fk_account > 0)
+ if ($object->fk_account > 0)
{
$bankline=new AccountLine($db);
- $bankline->fetch($salpayment->fk_bank);
+ $bankline->fetch($object->fk_bank);
print '
';
print '
'.$langs->trans('BankTransactionLine').'
';
@@ -362,21 +370,22 @@ if ($id)
// Other attributes
$parameters=array('colspan' => ' colspan="3"');
- $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$salpayment,$action); // Note that $action and $object may have been modified by hook
+ $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook
print '
';
// Amount
diff --git a/htdocs/compta/salaries/info.php b/htdocs/compta/salaries/info.php
index 4d060685d54..cbc0c1742ff 100644
--- a/htdocs/compta/salaries/info.php
+++ b/htdocs/compta/salaries/info.php
@@ -1,5 +1,5 @@
+/* Copyright (C) 2005-2015 Laurent Destailleur
* Copyright (C) 2015 Charlie BENKE
*
* This program is free software; you can redistribute it and/or modify
@@ -23,7 +23,7 @@
*/
require '../../main.inc.php';
-require_once DOL_DOCUMENT_ROOT.'/compta/sociales/class/chargesociales.class.php';
+require_once DOL_DOCUMENT_ROOT.'/compta/salaries/class/paymentsalary.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/salaries.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
diff --git a/htdocs/compta/sociales/class/paymentsocialcontribution.class.php b/htdocs/compta/sociales/class/paymentsocialcontribution.class.php
index 08f9380c905..d58e0add8ab 100644
--- a/htdocs/compta/sociales/class/paymentsocialcontribution.class.php
+++ b/htdocs/compta/sociales/class/paymentsocialcontribution.class.php
@@ -25,8 +25,8 @@
require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php';
-/** \class PaymentSocialContribution
- * \brief Class to manage payments of social contributions
+/**
+ * Class to manage payments of social contributions
*/
class PaymentSocialContribution extends CommonObject
{
diff --git a/htdocs/core/lib/salaries.lib.php b/htdocs/core/lib/salaries.lib.php
index cff64bbf31f..8f74066de01 100644
--- a/htdocs/core/lib/salaries.lib.php
+++ b/htdocs/core/lib/salaries.lib.php
@@ -33,7 +33,7 @@ function salaries_prepare_head($object) {
$head[$h][0] = DOL_URL_ROOT.'/compta/salaries/card.php?id='.$object->id;
$head[$h][1] = $langs->trans("Card");
- $head[$h][2] = 'salaries';
+ $head[$h][2] = 'card';
$h++;
// Show more tabs from modules
@@ -42,11 +42,13 @@ function salaries_prepare_head($object) {
// $this->tabs = array('entity:-tabname); to remove a tab
complete_head_from_modules($conf,$langs,$object,$head,$h,'salaries');
+ /*
$head[$h][0] = DOL_URL_ROOT.'/compta/salaries/info.php?id='.$object->id;
$head[$h][1] = $langs->trans("Info");
$head[$h][2] = 'info';
$h++;
-
+ */
+
complete_head_from_modules($conf,$langs,$object,$head,$h,'salaries', 'remove');
return $head;
diff --git a/htdocs/core/modules/modSalaries.class.php b/htdocs/core/modules/modSalaries.class.php
index 2144c95b1b3..038d11f4eba 100644
--- a/htdocs/core/modules/modSalaries.class.php
+++ b/htdocs/core/modules/modSalaries.class.php
@@ -133,6 +133,19 @@ class modSalaries extends DolibarrModules
//--------
$r=0;
+ $r++;
+ $this->export_code[$r]=$this->rights_class.'_'.$r;
+ $this->export_label[$r]='Salaries and payments';
+ $this->export_permission[$r]=array(array("salary","export"));
+ $this->export_fields_array[$r]=array('u.firstname'=>"Firstname",'u.lastname'=>"Lastname",'u.login'=>"Login",'u.salary'=>'CurrentSalary','p.rowid'=>'PaymentId','p.datep'=>'DatePayment','p.datesp'=>'DateStartPeriod','p.dateep'=>'DateEndPeriod','p.amount'=>'AmountPayment','p.num_paiement'=>'Numero','p.label'=>'Label','p.note'=>'Note');
+ $this->export_TypeFields_array[$r]=array('u.firstname'=>"Text",'u.lastname'=>"Text",'u.login'=>'Text','u.salary'=>"Number",'p.datep'=>'Date','p.datesp'=>'Date','p.dateep'=>'Date','p.amount'=>'Number','p.num_paiement'=>'Number','p.label'=>'Text');
+ $this->export_entities_array[$r]=array('u.firstname'=>'user','u.lastname'=>'user','u.login'=>'user','u.salary'=>'user','p.datep'=>'payment','p.datesp'=>'payment','p.dateep'=>'payment','p.amount'=>'payment','p.label'=>'payment','p.note'=>'payment','p.num_paiement'=>'payment');
+
+ $this->export_sql_start[$r]='SELECT DISTINCT ';
+ $this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'user as u';
+ $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'paiementsalary as p ON p.fk_user = u.rowid';
+ $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement as cp ON p.fk_typepaiement = cp.rowid';
+ $this->export_sql_end[$r] .=' AND u.entity IN ('.getEntity('user',1).')';
}
diff --git a/htdocs/install/mysql/migration/3.7.0-3.8.0.sql b/htdocs/install/mysql/migration/3.7.0-3.8.0.sql
index 28f4ab69f71..a2c19c71211 100755
--- a/htdocs/install/mysql/migration/3.7.0-3.8.0.sql
+++ b/htdocs/install/mysql/migration/3.7.0-3.8.0.sql
@@ -78,6 +78,15 @@ ALTER TABLE llx_extrafields ADD COLUMN list integer DEFAULT 0 after perms;
ALTER TABLE llx_payment_salary ADD COLUMN salary real after datev;
+ALTER TABLE llx_payment_salary ADD INDEX idx_payment_salary_ref (num_payment);
+ALTER TABLE llx_payment_salary ADD INDEX idx_payment_salary_user (fk_user, entity);
+ALTER TABLE llx_payment_salary ADD INDEX idx_payment_salary_datep (datep);
+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);
+
+
UPDATE llx_projet_task_time SET task_datehour = task_date where task_datehour IS NULL;
ALTER TABLE llx_projet_task_time ADD COLUMN task_date_withhour integer DEFAULT 0 after task_datehour;
diff --git a/htdocs/install/mysql/tables/llx_payment_salary.key.sql b/htdocs/install/mysql/tables/llx_payment_salary.key.sql
new file mode 100644
index 00000000000..d1df789eebe
--- /dev/null
+++ b/htdocs/install/mysql/tables/llx_payment_salary.key.sql
@@ -0,0 +1,27 @@
+-- ============================================================================
+-- Copyright (C) 2015 Laurent Destailleur
+--
+-- 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 .
+--
+-- ============================================================================
+
+
+ALTER TABLE llx_payment_salary ADD INDEX idx_payment_salary_ref (num_payment);
+ALTER TABLE llx_payment_salary ADD INDEX idx_payment_salary_user (fk_user, entity);
+ALTER TABLE llx_payment_salary ADD INDEX idx_payment_salary_datep (datep);
+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);
+
diff --git a/htdocs/install/mysql/tables/llx_payment_salary.sql b/htdocs/install/mysql/tables/llx_payment_salary.sql
index 2498c771ba6..5bda961c274 100644
--- a/htdocs/install/mysql/tables/llx_payment_salary.sql
+++ b/htdocs/install/mysql/tables/llx_payment_salary.sql
@@ -22,14 +22,14 @@ create table llx_payment_salary
tms timestamp,
fk_user integer NOT NULL,
datep date, -- date de paiement
- datev date, -- date de valeur
+ datev date, -- date de valeur (this field should not be here, only into bank tables)
salary real, -- salary of user when payment was done
amount real NOT NULL DEFAULT 0,
fk_typepayment integer NOT NULL,
- num_payment varchar(50),
+ num_payment varchar(50), -- ref
label varchar(255),
- datesp date, -- date de début de la période
- dateep date, -- date de fin de la période
+ datesp date, -- date start period
+ dateep date, -- date end period
entity integer DEFAULT 1 NOT NULL, -- multi company id
note text,
fk_bank integer,
diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang
index e5604ffdb20..42dbfd9079b 100755
--- a/htdocs/langs/en_US/admin.lang
+++ b/htdocs/langs/en_US/admin.lang
@@ -492,8 +492,8 @@ Module400Name=Projects/Opportunities/Leads
Module400Desc=Management of projects, opportunities or leads. You can then assign any element (invoice, order, proposal, intervention, ...) to a project and get a transversal view from the project view.
Module410Name=Webcalendar
Module410Desc=Webcalendar integration
-Module500Name=Special expenses (tax, social contributions, dividends)
-Module500Desc=Management of special expenses like taxes, social contribution, dividends and salaries
+Module500Name=Special expenses
+Module500Desc=Management of special expenses (taxes, social contribution, dividends)
Module510Name=Salaries
Module510Desc=Management of employees salaries and payments
Module520Name=Loan