Merge pull request #1457 from aspangaro/develop-salary
Add salary payment in tax module
This commit is contained in:
commit
6efe28d5c8
@ -5,7 +5,8 @@
|
|||||||
* Copyright (C) 2004 Christophe Combelles <ccomb@free.fr>
|
* Copyright (C) 2004 Christophe Combelles <ccomb@free.fr>
|
||||||
* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com>
|
* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com>
|
||||||
* Copyright (C) 2010-2011 Juanjo Menent <jmenent@@2byte.es>
|
* Copyright (C) 2010-2011 Juanjo Menent <jmenent@@2byte.es>
|
||||||
* Copyright (C) 2012 Marcos García <marcosgdf@gmail.com>
|
* Copyright (C) 2012 Marcos García <marcosgdf@gmail.com>
|
||||||
|
* Copyright (C) 2011-2014 Alexandre Spangaro <alexandre.spangaro@gmail.com>
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
@ -30,10 +31,12 @@
|
|||||||
require('../../main.inc.php');
|
require('../../main.inc.php');
|
||||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/bank.lib.php';
|
require_once DOL_DOCUMENT_ROOT.'/core/lib/bank.lib.php';
|
||||||
require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php';
|
require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php';
|
||||||
|
require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php';
|
||||||
require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php';
|
require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php';
|
||||||
require_once DOL_DOCUMENT_ROOT.'/compta/sociales/class/chargesociales.class.php';
|
require_once DOL_DOCUMENT_ROOT.'/compta/sociales/class/chargesociales.class.php';
|
||||||
require_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php';
|
require_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php';
|
||||||
require_once DOL_DOCUMENT_ROOT.'/compta/tva/class/tva.class.php';
|
require_once DOL_DOCUMENT_ROOT.'/compta/tva/class/tva.class.php';
|
||||||
|
require_once DOL_DOCUMENT_ROOT.'/compta/salaries/class/paymentsalary.class.php';
|
||||||
require_once DOL_DOCUMENT_ROOT.'/fourn/class/paiementfourn.class.php';
|
require_once DOL_DOCUMENT_ROOT.'/fourn/class/paiementfourn.class.php';
|
||||||
require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
|
require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
|
||||||
|
|
||||||
@ -133,11 +136,13 @@ if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->banque->m
|
|||||||
llxHeader();
|
llxHeader();
|
||||||
|
|
||||||
$societestatic=new Societe($db);
|
$societestatic=new Societe($db);
|
||||||
|
$userstatic=new User($db);
|
||||||
$chargestatic=new ChargeSociales($db);
|
$chargestatic=new ChargeSociales($db);
|
||||||
$memberstatic=new Adherent($db);
|
$memberstatic=new Adherent($db);
|
||||||
$paymentstatic=new Paiement($db);
|
$paymentstatic=new Paiement($db);
|
||||||
$paymentsupplierstatic=new PaiementFourn($db);
|
$paymentsupplierstatic=new PaiementFourn($db);
|
||||||
$paymentvatstatic=new TVA($db);
|
$paymentvatstatic=new TVA($db);
|
||||||
|
$paymentsalstatic=new PaymentSalary($db);
|
||||||
$bankstatic=new Account($db);
|
$bankstatic=new Account($db);
|
||||||
$banklinestatic=new AccountLine($db);
|
$banklinestatic=new AccountLine($db);
|
||||||
|
|
||||||
@ -458,8 +463,12 @@ if ($id > 0 || ! empty($ref))
|
|||||||
}
|
}
|
||||||
if ($mode_search && ! empty($conf->tax->enabled))
|
if ($mode_search && ! empty($conf->tax->enabled))
|
||||||
{
|
{
|
||||||
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."bank_url as bu2 ON bu2.fk_bank = b.rowid AND bu2.type='payment_vat'";
|
// VAT
|
||||||
|
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."bank_url as bu2 ON bu2.fk_bank = b.rowid AND bu2.type='payment_vat'";
|
||||||
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."tva as t ON bu2.url_id = t.rowid";
|
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."tva as t ON bu2.url_id = t.rowid";
|
||||||
|
// Salary payment
|
||||||
|
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."bank_url as bu3 ON bu3.fk_bank = b.rowid AND bu3.type='payment_salary'";
|
||||||
|
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."payment_salary as sal ON bu3.url_id = sal.rowid";
|
||||||
}
|
}
|
||||||
if ($mode_search && ! empty($conf->adherent->enabled))
|
if ($mode_search && ! empty($conf->adherent->enabled))
|
||||||
{
|
{
|
||||||
@ -577,6 +586,12 @@ if ($id > 0 || ! empty($ref))
|
|||||||
$paymentvatstatic->ref=$links[$key]['url_id'];
|
$paymentvatstatic->ref=$links[$key]['url_id'];
|
||||||
print ' '.$paymentvatstatic->getNomUrl(2);
|
print ' '.$paymentvatstatic->getNomUrl(2);
|
||||||
}
|
}
|
||||||
|
elseif ($links[$key]['type']=='payment_salary')
|
||||||
|
{
|
||||||
|
$paymentsalstatic->id=$links[$key]['url_id'];
|
||||||
|
$paymentsalstatic->ref=$links[$key]['url_id'];
|
||||||
|
print ' '.$paymentsalstatic->getNomUrl(2);
|
||||||
|
}
|
||||||
elseif ($links[$key]['type']=='banktransfert')
|
elseif ($links[$key]['type']=='banktransfert')
|
||||||
{
|
{
|
||||||
// Do not show link to transfer since there is no transfer card (avoid confusion). Can already be accessed from transaction detail.
|
// Do not show link to transfer since there is no transfer card (avoid confusion). Can already be accessed from transaction detail.
|
||||||
@ -611,6 +626,10 @@ if ($id > 0 || ! empty($ref))
|
|||||||
elseif ($links[$key]['type']=='company')
|
elseif ($links[$key]['type']=='company')
|
||||||
{
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
elseif ($links[$key]['type']=='user')
|
||||||
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
elseif ($links[$key]['type']=='member')
|
elseif ($links[$key]['type']=='member')
|
||||||
{
|
{
|
||||||
@ -650,6 +669,12 @@ if ($id > 0 || ! empty($ref))
|
|||||||
$societestatic->nom=$links[$key]['label'];
|
$societestatic->nom=$links[$key]['label'];
|
||||||
print $societestatic->getNomUrl(1,'',16);
|
print $societestatic->getNomUrl(1,'',16);
|
||||||
}
|
}
|
||||||
|
else if ($links[$key]['type']=='user')
|
||||||
|
{
|
||||||
|
$userstatic->id=$links[$key]['url_id'];
|
||||||
|
$userstatic->lastname=$links[$key]['label'];
|
||||||
|
print $userstatic->getNomUrl(1,'');
|
||||||
|
}
|
||||||
else if ($links[$key]['type']=='sc')
|
else if ($links[$key]['type']=='sc')
|
||||||
{
|
{
|
||||||
// sc=old value
|
// sc=old value
|
||||||
|
|||||||
@ -2,6 +2,7 @@
|
|||||||
/* Copyright (C) 2001-2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
/* Copyright (C) 2001-2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||||
* Copyright (C) 2004-2010 Laurent Destailleur <eldy@users.sourceforge.net>
|
* Copyright (C) 2004-2010 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||||
* Copyright (C) 2005-2010 Regis Houssin <regis.houssin@capnetworks.com>
|
* Copyright (C) 2005-2010 Regis Houssin <regis.houssin@capnetworks.com>
|
||||||
|
* Copyright (C) 2011-2014 Alexandre Spangaro <alexandre.spangaro@gmail.com>
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
@ -20,13 +21,14 @@
|
|||||||
/**
|
/**
|
||||||
* \file htdocs/compta/charges/index.php
|
* \file htdocs/compta/charges/index.php
|
||||||
* \ingroup compta
|
* \ingroup compta
|
||||||
* \brief Page to list payments of social contributions and vat
|
* \brief Page to list payments of social contributions, vat and salaries
|
||||||
*/
|
*/
|
||||||
|
|
||||||
require '../../main.inc.php';
|
require '../../main.inc.php';
|
||||||
require_once DOL_DOCUMENT_ROOT.'/compta/tva/class/tva.class.php';
|
require_once DOL_DOCUMENT_ROOT.'/compta/tva/class/tva.class.php';
|
||||||
require_once DOL_DOCUMENT_ROOT.'/compta/sociales/class/chargesociales.class.php';
|
require_once DOL_DOCUMENT_ROOT.'/compta/sociales/class/chargesociales.class.php';
|
||||||
require_once DOL_DOCUMENT_ROOT.'/compta/sociales/class/paymentsocialcontribution.class.php';
|
require_once DOL_DOCUMENT_ROOT.'/compta/sociales/class/paymentsocialcontribution.class.php';
|
||||||
|
require_once DOL_DOCUMENT_ROOT.'/compta/salaries/class/paymentsalary.class.php';
|
||||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
|
require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
|
||||||
|
|
||||||
$langs->load("compta");
|
$langs->load("compta");
|
||||||
@ -59,6 +61,7 @@ if (! $sortorder) $sortorder="DESC";
|
|||||||
$tva_static = new Tva($db);
|
$tva_static = new Tva($db);
|
||||||
$socialcontrib=new ChargeSociales($db);
|
$socialcontrib=new ChargeSociales($db);
|
||||||
$payment_sc_static=new PaymentSocialContribution($db);
|
$payment_sc_static=new PaymentSocialContribution($db);
|
||||||
|
$sal_static = new PaymentSalary($db);
|
||||||
|
|
||||||
llxHeader('',$langs->trans("TaxAndDividendsArea"));
|
llxHeader('',$langs->trans("TaxAndDividendsArea"));
|
||||||
|
|
||||||
@ -74,12 +77,92 @@ print_fiche_titre($title, ($year?"<a href='index.php?year=".($year-1).$param."'>
|
|||||||
|
|
||||||
if ($year) $param.='&year='.$year;
|
if ($year) $param.='&year='.$year;
|
||||||
|
|
||||||
// Social contributions only
|
|
||||||
if (GETPOST("mode") != 'sconly')
|
if (GETPOST("mode") != 'sconly')
|
||||||
{
|
{
|
||||||
print $langs->trans("DescTaxAndDividendsArea").'<br>';
|
print $langs->trans("DescTaxAndDividendsArea").'<br>';
|
||||||
print "<br>";
|
print "<br>";
|
||||||
|
}
|
||||||
|
|
||||||
|
// Payment Salary
|
||||||
|
if (empty($_GET["mode"]) || $_GET["mode"] != 'sconly')
|
||||||
|
{
|
||||||
|
$sal = new PaymentSalary($db);
|
||||||
|
|
||||||
|
print_fiche_titre($langs->trans("SalariesPayments").($year?' ('.$langs->trans("Year").' '.$year.')':''), '', '');
|
||||||
|
|
||||||
|
$sql = "SELECT s.rowid, s.amount, s.label, s.datev as dm";
|
||||||
|
$sql.= " FROM ".MAIN_DB_PREFIX."payment_salary as s";
|
||||||
|
$sql.= " WHERE s.entity = ".$conf->entity;
|
||||||
|
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))."'";
|
||||||
|
}
|
||||||
|
if (preg_match('/^s/',$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" width="100%">';
|
||||||
|
print '<tr class="liste_titre">';
|
||||||
|
print_liste_field_titre($langs->trans("PeriodEndDate"),$_SERVER["PHP_SELF"],"s.datev","",$param,'width="120"',$sortfield,$sortorder);
|
||||||
|
print_liste_field_titre($langs->trans("Label"),$_SERVER["PHP_SELF"],"s.label","",$param,'',$sortfield,$sortorder);
|
||||||
|
print_liste_field_titre($langs->trans("ExpectedToPay"),$_SERVER["PHP_SELF"],"s.amount","",$param,'align="right"',$sortfield,$sortorder);
|
||||||
|
print_liste_field_titre($langs->trans("RefPayment"),$_SERVER["PHP_SELF"],"s.rowid","",$param,'',$sortfield,$sortorder);
|
||||||
|
print_liste_field_titre($langs->trans("DatePayment"),$_SERVER["PHP_SELF"],"s.datev","",$param,'align="center"',$sortfield,$sortorder);
|
||||||
|
print_liste_field_titre($langs->trans("PayedByThisPayment"),$_SERVER["PHP_SELF"],"s.amount","",$param,'align="right"',$sortfield,$sortorder);
|
||||||
|
print "</tr>\n";
|
||||||
|
$var=1;
|
||||||
|
while ($i < $num)
|
||||||
|
{
|
||||||
|
$obj = $db->fetch_object($result);
|
||||||
|
|
||||||
|
$total = $total + $obj->amount;
|
||||||
|
|
||||||
|
$var=!$var;
|
||||||
|
print "<tr ".$bc[$var].">";
|
||||||
|
print '<td align="left">'.dol_print_date($db->jdate($obj->dm),'day').'</td>'."\n";
|
||||||
|
|
||||||
|
print "<td>".$obj->label."</td>\n";
|
||||||
|
|
||||||
|
print '<td align="right">'.price($obj->amount)."</td>";
|
||||||
|
|
||||||
|
// Ref payment
|
||||||
|
$sal_static->id=$obj->rowid;
|
||||||
|
$sal_static->ref=$obj->rowid;
|
||||||
|
print '<td align="left">'.$sal_static->getNomUrl(1)."</td>\n";
|
||||||
|
|
||||||
|
print '<td align="center">'.dol_print_date($db->jdate($obj->dm),'day')."</td>\n";
|
||||||
|
print '<td align="right">'.price($obj->amount)."</td>";
|
||||||
|
print "</tr>\n";
|
||||||
|
|
||||||
|
$i++;
|
||||||
|
}
|
||||||
|
print '<tr class="liste_total"><td align="right" colspan="2">'.$langs->trans("Total").'</td>';
|
||||||
|
print '<td align="right">'.price($total)."</td>";
|
||||||
|
print '<td align="center"> </td>';
|
||||||
|
print '<td align="center"> </td>';
|
||||||
|
print '<td align="right">'.price($total)."</td>";
|
||||||
|
print "</tr>";
|
||||||
|
|
||||||
|
print "</table>";
|
||||||
|
$db->free($result);
|
||||||
|
|
||||||
|
print "<br>";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
dol_print_error($db);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Social contributions only
|
||||||
|
if (GETPOST("mode") != 'sconly')
|
||||||
|
{
|
||||||
print_fiche_titre($langs->trans("SocialContributionsPayments").($year?' ('.$langs->trans("Year").' '.$year.')':''), '', '');
|
print_fiche_titre($langs->trans("SocialContributionsPayments").($year?' ('.$langs->trans("Year").' '.$year.')':''), '', '');
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -219,7 +302,7 @@ if (empty($_GET["mode"]) || $_GET["mode"] != 'sconly')
|
|||||||
|
|
||||||
$var=!$var;
|
$var=!$var;
|
||||||
print "<tr ".$bc[$var].">";
|
print "<tr ".$bc[$var].">";
|
||||||
print '<td align="left">'.dol_print_date($db->jdate($obj->dm),'day').' ? </td>'."\n";
|
print '<td align="left">'.dol_print_date($db->jdate($obj->dm),'day').'</td>'."\n";
|
||||||
|
|
||||||
print "<td>".$obj->label."</td>\n";
|
print "<td>".$obj->label."</td>\n";
|
||||||
|
|
||||||
|
|||||||
578
htdocs/compta/salaries/class/paymentsalary.class.php
Normal file
578
htdocs/compta/salaries/class/paymentsalary.class.php
Normal file
@ -0,0 +1,578 @@
|
|||||||
|
<?php
|
||||||
|
/* Copyright (C) 2011-2014 Alexandre Spangaro <alexandre.spangaro@gmail.com>
|
||||||
|
*
|
||||||
|
* 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 <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \file htdocs/compta/salaries/class/paymentsalary.class.php
|
||||||
|
* \ingroup tax
|
||||||
|
* \brief Class for tax module salary payment
|
||||||
|
*/
|
||||||
|
|
||||||
|
// Put here all includes required by your class file
|
||||||
|
require_once DOL_DOCUMENT_ROOT .'/core/class/commonobject.class.php';
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Put here description of your class
|
||||||
|
*/
|
||||||
|
class PaymentSalary extends CommonObject
|
||||||
|
{
|
||||||
|
//public $element='payment_salary'; //!< Id that identify managed objects
|
||||||
|
//public $table_element='payment_salary'; //!< Name of table without prefix where object is stored
|
||||||
|
|
||||||
|
var $id;
|
||||||
|
var $ref;
|
||||||
|
|
||||||
|
var $tms;
|
||||||
|
var $fk_user;
|
||||||
|
var $datep;
|
||||||
|
var $datev;
|
||||||
|
var $amount;
|
||||||
|
var $label;
|
||||||
|
var $datesp;
|
||||||
|
var $dateep;
|
||||||
|
var $note;
|
||||||
|
var $fk_bank;
|
||||||
|
var $fk_user_creat;
|
||||||
|
var $fk_user_modif;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor
|
||||||
|
*
|
||||||
|
* @param DoliDB $db Database handler
|
||||||
|
*/
|
||||||
|
function __construct($db)
|
||||||
|
{
|
||||||
|
$this->db = $db;
|
||||||
|
$this->element = 'payment_salary';
|
||||||
|
$this->table_element = 'payment_salary';
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create in database
|
||||||
|
*
|
||||||
|
* @param User $user User that create
|
||||||
|
* @return int <0 if KO, >0 if OK
|
||||||
|
*/
|
||||||
|
function create($user)
|
||||||
|
{
|
||||||
|
global $conf, $langs;
|
||||||
|
|
||||||
|
$error=0;
|
||||||
|
|
||||||
|
// Clean parameters
|
||||||
|
$this->fk_user=trim($this->fk_user);
|
||||||
|
$this->amount=trim($this->amount);
|
||||||
|
$this->label=trim($this->label);
|
||||||
|
$this->note=trim($this->note);
|
||||||
|
$this->fk_bank=trim($this->fk_bank);
|
||||||
|
$this->fk_user_creat=trim($this->fk_user_creat);
|
||||||
|
$this->fk_user_modif=trim($this->fk_user_modif);
|
||||||
|
|
||||||
|
// Check parameters
|
||||||
|
// Put here code to add control on parameters values
|
||||||
|
|
||||||
|
// Insert request
|
||||||
|
$sql = "INSERT INTO ".MAIN_DB_PREFIX."payment_salary(";
|
||||||
|
$sql.= "tms,";
|
||||||
|
$sql.= "fk_user,";
|
||||||
|
$sql.= "datep,";
|
||||||
|
$sql.= "datev,";
|
||||||
|
$sql.= "amount,";
|
||||||
|
$sql.= "label,";
|
||||||
|
$sql.= "datesp,";
|
||||||
|
$sql.= "dateep,";
|
||||||
|
$sql.= "note,";
|
||||||
|
$sql.= "fk_bank,";
|
||||||
|
$sql.= "fk_user_creat,";
|
||||||
|
$sql.= "fk_user_modif";
|
||||||
|
|
||||||
|
$sql.= ") VALUES (";
|
||||||
|
|
||||||
|
$sql.= " ".$this->db->idate($this->tms).",";
|
||||||
|
$sql.= " '".$this->fk_user."',";
|
||||||
|
$sql.= " ".$this->db->idate($this->datep).",";
|
||||||
|
$sql.= " ".$this->db->idate($this->datev).",";
|
||||||
|
$sql.= " '".$this->amount."',";
|
||||||
|
$sql.= " '".$this->label."',";
|
||||||
|
$sql.= " ".$this->db->idate($this->datesp).",";
|
||||||
|
$sql.= " ".$this->db->idate($this->dateep).",";
|
||||||
|
$sql.= " '".$this->note."',";
|
||||||
|
$sql.= " ".($this->fk_bank <= 0 ? "NULL" : "'".$this->fk_bank."'").",";
|
||||||
|
$sql.= " '".$this->fk_user_creat."',";
|
||||||
|
$sql.= " '".$this->fk_user_modif."'";
|
||||||
|
|
||||||
|
$sql.= ")";
|
||||||
|
|
||||||
|
dol_syslog(get_class($this)."::create sql=".$sql, LOG_DEBUG);
|
||||||
|
$resql=$this->db->query($sql);
|
||||||
|
if ($resql)
|
||||||
|
{
|
||||||
|
$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."payment_salary");
|
||||||
|
|
||||||
|
// Appel des triggers
|
||||||
|
include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php';
|
||||||
|
$interface=new Interfaces($this->db);
|
||||||
|
$result=$interface->run_triggers('PAYMENT_SALARY_CREATE',$this,$user,$langs,$conf);
|
||||||
|
if ($result < 0) { $error++; $this->errors=$interface->errors; }
|
||||||
|
// Fin appel triggers
|
||||||
|
|
||||||
|
return $this->id;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$this->error="Error ".$this->db->lasterror();
|
||||||
|
dol_syslog(get_class($this)."::create ".$this->error, LOG_ERR);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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
|
||||||
|
*/
|
||||||
|
function update($user=0, $notrigger=0)
|
||||||
|
{
|
||||||
|
global $conf, $langs;
|
||||||
|
|
||||||
|
$error=0;
|
||||||
|
|
||||||
|
// Clean parameters
|
||||||
|
$this->fk_user=trim($this->fk_user);
|
||||||
|
$this->amount=trim($this->amount);
|
||||||
|
$this->label=trim($this->label);
|
||||||
|
$this->note=trim($this->note);
|
||||||
|
$this->fk_bank=trim($this->fk_bank);
|
||||||
|
$this->fk_user_creat=trim($this->fk_user_creat);
|
||||||
|
$this->fk_user_modif=trim($this->fk_user_modif);
|
||||||
|
|
||||||
|
// Check parameters
|
||||||
|
if (empty($this->fk_user) || $this->fk_user < 0)
|
||||||
|
{
|
||||||
|
$this->error='ErrorBadParameter';
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update request
|
||||||
|
$sql = "UPDATE ".MAIN_DB_PREFIX."payment_salary SET";
|
||||||
|
|
||||||
|
$sql.= " tms=".$this->db->idate($this->tms).",";
|
||||||
|
$sql.= " fk_user='".$this->fk_user."',";
|
||||||
|
$sql.= " datep=".$this->db->idate($this->datep).",";
|
||||||
|
$sql.= " datev=".$this->db->idate($this->datev).",";
|
||||||
|
$sql.= " amount='".$this->amount."',";
|
||||||
|
$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."',";
|
||||||
|
$sql.= " fk_user_creat='".$this->fk_user_creat."',";
|
||||||
|
$sql.= " fk_user_modif='".$this->fk_user_modif."'";
|
||||||
|
|
||||||
|
$sql.= " WHERE rowid=".$this->id;
|
||||||
|
|
||||||
|
dol_syslog(get_class($this)."::update sql=".$sql, LOG_DEBUG);
|
||||||
|
$resql = $this->db->query($sql);
|
||||||
|
if (! $resql)
|
||||||
|
{
|
||||||
|
$this->error="Error ".$this->db->lasterror();
|
||||||
|
dol_syslog(get_class($this)."::update ".$this->error, LOG_ERR);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (! $notrigger)
|
||||||
|
{
|
||||||
|
// Appel des triggers
|
||||||
|
include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php';
|
||||||
|
$interface=new Interfaces($this->db);
|
||||||
|
$result=$interface->run_triggers('PAYMENT_SALARY_MODIFY',$this,$user,$langs,$conf);
|
||||||
|
if ($result < 0) { $error++; $this->errors=$interface->errors; }
|
||||||
|
// Fin appel triggers
|
||||||
|
}
|
||||||
|
|
||||||
|
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
|
||||||
|
*/
|
||||||
|
function fetch($id, $user=0)
|
||||||
|
{
|
||||||
|
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.label,";
|
||||||
|
$sql.= " s.datesp,";
|
||||||
|
$sql.= " s.dateep,";
|
||||||
|
$sql.= " s.note,";
|
||||||
|
$sql.= " s.fk_bank,";
|
||||||
|
$sql.= " s.fk_user_creat,";
|
||||||
|
$sql.= " s.fk_user_modif,";
|
||||||
|
$sql.= " b.fk_account,";
|
||||||
|
$sql.= " b.fk_type,";
|
||||||
|
$sql.= " b.rappro";
|
||||||
|
|
||||||
|
$sql.= " FROM ".MAIN_DB_PREFIX."payment_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 sql=".$sql, 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->label = $obj->label;
|
||||||
|
$this->datesp = $this->db->jdate($obj->datesp);
|
||||||
|
$this->dateep = $this->db->jdate($obj->dateep);
|
||||||
|
$this->note = $obj->note;
|
||||||
|
$this->fk_bank = $obj->fk_bank;
|
||||||
|
$this->fk_user_creat = $obj->fk_user_creat;
|
||||||
|
$this->fk_user_modif = $obj->fk_user_modif;
|
||||||
|
$this->fk_account = $obj->fk_account;
|
||||||
|
$this->fk_type = $obj->fk_type;
|
||||||
|
$this->rappro = $obj->rappro;
|
||||||
|
}
|
||||||
|
$this->db->free($resql);
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$this->error="Error ".$this->db->lasterror();
|
||||||
|
dol_syslog(get_class($this)."::fetch ".$this->error, LOG_ERR);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Delete object in database
|
||||||
|
*
|
||||||
|
* @param User $user User that delete
|
||||||
|
* @return int <0 if KO, >0 if OK
|
||||||
|
*/
|
||||||
|
function delete($user)
|
||||||
|
{
|
||||||
|
global $conf, $langs;
|
||||||
|
|
||||||
|
$error=0;
|
||||||
|
|
||||||
|
$sql = "DELETE FROM ".MAIN_DB_PREFIX."payment_salary";
|
||||||
|
$sql.= " WHERE rowid=".$this->id;
|
||||||
|
|
||||||
|
dol_syslog(get_class($this)."::delete sql=".$sql);
|
||||||
|
$resql = $this->db->query($sql);
|
||||||
|
if (! $resql)
|
||||||
|
{
|
||||||
|
$this->error="Error ".$this->db->lasterror();
|
||||||
|
dol_syslog(get_class($this)."::delete ".$this->error, LOG_ERR);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Appel des triggers
|
||||||
|
include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php';
|
||||||
|
$interface=new Interfaces($this->db);
|
||||||
|
$result=$interface->run_triggers('PAYMENT_SALARY_DELETE',$this,$user,$langs,$conf);
|
||||||
|
if ($result < 0) { $error++; $this->errors=$interface->errors; }
|
||||||
|
// Fin appel triggers
|
||||||
|
|
||||||
|
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
|
||||||
|
*/
|
||||||
|
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_creat='';
|
||||||
|
$this->fk_user_modif='';
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Ajoute un paiement de salaire
|
||||||
|
*
|
||||||
|
* @param User $user Object user that insert
|
||||||
|
* @return int <0 if KO, rowid in tva table if OK
|
||||||
|
*/
|
||||||
|
function addPayment($user)
|
||||||
|
{
|
||||||
|
global $conf,$langs;
|
||||||
|
|
||||||
|
$this->db->begin();
|
||||||
|
|
||||||
|
// Clean parameters
|
||||||
|
$this->amount=price2num(trim($this->amount));
|
||||||
|
|
||||||
|
// 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("Person"));
|
||||||
|
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->paymenttype) || $this->paymenttype <= 0))
|
||||||
|
{
|
||||||
|
$this->error=$langs->trans("ErrorFieldRequired",$langs->transnoentities("PaymentMode"));
|
||||||
|
return -6;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Insertion dans table des paiement salaires
|
||||||
|
$sql = "INSERT INTO ".MAIN_DB_PREFIX."payment_salary (fk_user";
|
||||||
|
$sql.= ", datep";
|
||||||
|
$sql.= ", datev";
|
||||||
|
$sql.= ", amount";
|
||||||
|
if ($this->note) $sql.=", note";
|
||||||
|
if ($this->label) $sql.=", label";
|
||||||
|
$sql.= ", datesp";
|
||||||
|
$sql.= ", dateep";
|
||||||
|
$sql.= ", fk_user_creat";
|
||||||
|
$sql.= ", fk_bank";
|
||||||
|
$sql.= ", entity";
|
||||||
|
$sql.= ") ";
|
||||||
|
$sql.= " VALUES (";
|
||||||
|
$sql.= "'".$this->fk_user."'";
|
||||||
|
$sql.= ", '".$this->db->idate($this->datep)."'";
|
||||||
|
$sql.= ", '".$this->db->idate($this->datev)."'";
|
||||||
|
$sql.= ", ".$this->amount;
|
||||||
|
if ($this->note) $sql.= ", '".$this->db->escape($this->note)."'";
|
||||||
|
if ($this->label) $sql.= ", '".$this->db->escape($this->label)."'";
|
||||||
|
$sql.= ", '".$this->db->idate($this->datesp)."'";
|
||||||
|
$sql.= ", '".$this->db->idate($this->dateep)."'";
|
||||||
|
$sql.= ", '".$user->id."'";
|
||||||
|
$sql.= ", NULL";
|
||||||
|
$sql.= ", ".$conf->entity;
|
||||||
|
$sql.= ")";
|
||||||
|
|
||||||
|
dol_syslog(get_class($this)."::addPayment sql=".$sql);
|
||||||
|
$result = $this->db->query($sql);
|
||||||
|
if ($result)
|
||||||
|
{
|
||||||
|
$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."payment_salary"); // TODO devrait s'appeler payment_salary
|
||||||
|
|
||||||
|
// Appel des triggers
|
||||||
|
include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php';
|
||||||
|
$interface=new Interfaces($this->db);
|
||||||
|
$result=$interface->run_triggers('PAYMENT_SALARY_ADDPAYMENT',$this,$user,$langs,$conf);
|
||||||
|
if ($result < 0) { $error++; $this->errors=$interface->errors; }
|
||||||
|
// Fin appel triggers
|
||||||
|
|
||||||
|
if ($this->id > 0)
|
||||||
|
{
|
||||||
|
$ok=1;
|
||||||
|
if (! empty($conf->banque->enabled) && ! empty($this->amount))
|
||||||
|
{
|
||||||
|
// Insertion dans llx_bank
|
||||||
|
require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
|
||||||
|
|
||||||
|
$acc = new Account($this->db);
|
||||||
|
$result=$acc->fetch($this->accountid);
|
||||||
|
if ($result <= 0) dol_print_error($this->db);
|
||||||
|
|
||||||
|
// Insert payment into llx_bank
|
||||||
|
// Add link 'payment_salary' in bank_url between payment and bank transaction
|
||||||
|
$bank_line_id = $acc->addline(
|
||||||
|
$this->datep,
|
||||||
|
$this->paymenttype,
|
||||||
|
$this->label,
|
||||||
|
-abs($this->amount),
|
||||||
|
'',
|
||||||
|
'',
|
||||||
|
$user
|
||||||
|
);
|
||||||
|
|
||||||
|
// Mise a jour fk_bank dans llx_paiement.
|
||||||
|
// On connait ainsi le paiement qui a genere l'ecriture bancaire
|
||||||
|
if ($bank_line_id > 0)
|
||||||
|
{
|
||||||
|
$this->update_fk_bank($bank_line_id);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$this->error=$acc->error;
|
||||||
|
$ok=0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add link 'payment_salary' in bank_url between payment and bank transaction
|
||||||
|
$url=DOL_URL_ROOT.'/compta/salaries/fiche.php?id=';
|
||||||
|
|
||||||
|
$result=$acc->add_url_line($bank_line_id, $this->id, $url, "(SalaryPayment)", "payment_salary");
|
||||||
|
if ($result <= 0)
|
||||||
|
{
|
||||||
|
$this->error=$acc->error;
|
||||||
|
$ok=0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add link 'user' in bank_url between operation and bank transaction
|
||||||
|
$linkaddedforthirdparty=array();
|
||||||
|
foreach ($this->amounts as $key => $value)
|
||||||
|
{
|
||||||
|
$sal = new PaymentSalary($this->db);
|
||||||
|
|
||||||
|
$sal->fetch($key);
|
||||||
|
$sal->fetch_user($this->fk_user);
|
||||||
|
|
||||||
|
if (! in_array($sal->user->id,$linkaddedforthirdparty)) // Not yet done for this thirdparty
|
||||||
|
{
|
||||||
|
$result=$acc->add_url_line(
|
||||||
|
$bank_line_id,
|
||||||
|
$sal->user->id,
|
||||||
|
DOL_URL_ROOT.'/user/fiche.php?id=',
|
||||||
|
$sal->user->lastname,
|
||||||
|
'user'
|
||||||
|
);
|
||||||
|
|
||||||
|
if ($result <= 0) dol_print_error($this->db);
|
||||||
|
$linkaddedforthirdparty[$sal->user->id]=$sal->user->id; // Mark as done for this thirdparty
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($ok)
|
||||||
|
{
|
||||||
|
$this->db->commit();
|
||||||
|
return $this->id;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$this->db->rollback();
|
||||||
|
return -3;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$this->error=$this->db->error();
|
||||||
|
$this->db->rollback();
|
||||||
|
return -2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$this->error=$this->db->error();
|
||||||
|
$this->db->rollback();
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Mise a jour du lien entre le paiement salaire et la ligne générée dans llx_bank
|
||||||
|
*
|
||||||
|
* @param int $id_bank Id compte bancaire
|
||||||
|
* @return int <0 if KO, >0 if OK
|
||||||
|
*/
|
||||||
|
function update_fk_bank($id_bank)
|
||||||
|
{
|
||||||
|
$sql = 'UPDATE '.MAIN_DB_PREFIX.'payment_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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Renvoie nom clicable (avec eventuellement le picto)
|
||||||
|
*
|
||||||
|
* @param int $withpicto 0=Pas de picto, 1=Inclut le picto dans le lien, 2=Picto seul
|
||||||
|
* @param string $option Sur quoi pointe le lien
|
||||||
|
* @return string Chaine avec URL
|
||||||
|
*/
|
||||||
|
function getNomUrl($withpicto=0,$option='')
|
||||||
|
{
|
||||||
|
global $langs;
|
||||||
|
|
||||||
|
$result='';
|
||||||
|
|
||||||
|
$lien = '<a href="'.DOL_URL_ROOT.'/compta/salaries/fiche.php?id='.$this->id.'">';
|
||||||
|
$lienfin='</a>';
|
||||||
|
|
||||||
|
$picto='payment';
|
||||||
|
$label=$langs->trans("ShowSalaryPayment").': '.$this->ref;
|
||||||
|
|
||||||
|
if ($withpicto) $result.=($lien.img_object($label,$picto).$lienfin);
|
||||||
|
if ($withpicto && $withpicto != 2) $result.=' ';
|
||||||
|
if ($withpicto != 2) $result.=$lien.$this->ref.$lienfin;
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
?>
|
||||||
345
htdocs/compta/salaries/fiche.php
Normal file
345
htdocs/compta/salaries/fiche.php
Normal file
@ -0,0 +1,345 @@
|
|||||||
|
<?php
|
||||||
|
/* Copyright (C) 2011-2014 Alexandre Spangaro <alexandre.spangaro@gmail.com>
|
||||||
|
*
|
||||||
|
* 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 <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \file htdocs/compta/salaries/fiche.php
|
||||||
|
* \ingroup tax
|
||||||
|
* \brief Page of salaries payments
|
||||||
|
*/
|
||||||
|
|
||||||
|
require '../../main.inc.php';
|
||||||
|
require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
|
||||||
|
require_once DOL_DOCUMENT_ROOT.'/compta/salaries/class/paymentsalary.class.php';
|
||||||
|
require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
|
||||||
|
|
||||||
|
$langs->load("compta");
|
||||||
|
$langs->load("banks");
|
||||||
|
$langs->load("bills");
|
||||||
|
|
||||||
|
$id=GETPOST("id",'int');
|
||||||
|
$action=GETPOST('action');
|
||||||
|
|
||||||
|
// Security check
|
||||||
|
$socid = isset($_GET["socid"])?$_GET["socid"]:'';
|
||||||
|
if ($user->societe_id) $socid=$user->societe_id;
|
||||||
|
$result = restrictedArea($user, 'tax', '', '', 'charges');
|
||||||
|
|
||||||
|
$sal = new PaymentSalary($db);
|
||||||
|
|
||||||
|
// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array
|
||||||
|
$hookmanager->initHooks(array('taxsalarycard'));
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Actions
|
||||||
|
*/
|
||||||
|
|
||||||
|
if ($_POST["cancel"] == $langs->trans("Cancel"))
|
||||||
|
{
|
||||||
|
header("Location: index.php");
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($action == 'add' && $_POST["cancel"] <> $langs->trans("Cancel"))
|
||||||
|
{
|
||||||
|
$db->begin();
|
||||||
|
|
||||||
|
$datev=dol_mktime(12,0,0, $_POST["datevmonth"], $_POST["datevday"], $_POST["datevyear"]);
|
||||||
|
$datep=dol_mktime(12,0,0, $_POST["datepmonth"], $_POST["datepday"], $_POST["datepyear"]);
|
||||||
|
$datesp=dol_mktime(12,0,0, $_POST["datespmonth"], $_POST["datespday"], $_POST["datespyear"]);
|
||||||
|
$dateep=dol_mktime(12,0,0, $_POST["dateepmonth"], $_POST["dateepday"], $_POST["dateepyear"]);
|
||||||
|
|
||||||
|
|
||||||
|
$sal->accountid=$_POST["accountid"];
|
||||||
|
$sal->paymenttype=$_POST["paiementtype"];
|
||||||
|
$sal->fk_user=$_POST["fk_user"];
|
||||||
|
$sal->datev=$datev;
|
||||||
|
$sal->datep=$datep;
|
||||||
|
$sal->amount=$_POST["amount"];
|
||||||
|
$sal->label=$_POST["label"];
|
||||||
|
$sal->datesp=$datesp;
|
||||||
|
$sal->dateep=$dateep;
|
||||||
|
|
||||||
|
$ret=$sal->addPayment($user);
|
||||||
|
if ($ret > 0)
|
||||||
|
{
|
||||||
|
$db->commit();
|
||||||
|
header("Location: index.php");
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$db->rollback();
|
||||||
|
setEventMessage($sal->error, 'errors');
|
||||||
|
$action="create";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($action == 'delete')
|
||||||
|
{
|
||||||
|
$result=$sal->fetch($id);
|
||||||
|
|
||||||
|
if ($sal->rappro == 0)
|
||||||
|
{
|
||||||
|
$db->begin();
|
||||||
|
|
||||||
|
$ret=$sal->delete($user);
|
||||||
|
if ($ret > 0)
|
||||||
|
{
|
||||||
|
if ($sal->fk_bank)
|
||||||
|
{
|
||||||
|
$accountline=new AccountLine($db);
|
||||||
|
$result=$accountline->fetch($sal->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.'/compta/salaries/index.php');
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$sal->error=$accountline->error;
|
||||||
|
$db->rollback();
|
||||||
|
setEventMessage($sal->error,'errors');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$db->rollback();
|
||||||
|
setEventMessage($sal->error,'errors');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
setEventMessage('Error try do delete a line linked to a conciliated bank transaction','errors');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* View
|
||||||
|
*/
|
||||||
|
|
||||||
|
llxHeader();
|
||||||
|
|
||||||
|
$form = new Form($db);
|
||||||
|
|
||||||
|
if ($id)
|
||||||
|
{
|
||||||
|
$salpayment = new PaymentSalary($db);
|
||||||
|
$result = $salpayment->fetch($id);
|
||||||
|
if ($result <= 0)
|
||||||
|
{
|
||||||
|
dol_print_error($db);
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Formulaire saisie salaire
|
||||||
|
if ($action == 'create')
|
||||||
|
{
|
||||||
|
$year_current = strftime("%Y",dol_now());
|
||||||
|
$pastmonth = strftime("%m",dol_now()) - 1;
|
||||||
|
$pastmonthyear = $year_current;
|
||||||
|
if ($pastmonth == 0)
|
||||||
|
{
|
||||||
|
$pastmonth = 12;
|
||||||
|
$pastmonthyear--;
|
||||||
|
}
|
||||||
|
|
||||||
|
$datesp=dol_mktime(0, 0, 0, $datespmonth, $datespday, $datespyear);
|
||||||
|
$dateep=dol_mktime(23, 59, 59, $dateepmonth, $dateepday, $dateepyear);
|
||||||
|
|
||||||
|
if (empty($datesp) || empty($dateep)) // We define date_start and date_end
|
||||||
|
{
|
||||||
|
$datesp=dol_get_first_day($pastmonthyear,$pastmonth,false); $dateep=dol_get_last_day($pastmonthyear,$pastmonth,false);
|
||||||
|
}
|
||||||
|
|
||||||
|
print "<form name='add' action=\"fiche.php\" method=\"post\">\n";
|
||||||
|
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
||||||
|
print '<input type="hidden" name="action" value="add">';
|
||||||
|
|
||||||
|
print_fiche_titre($langs->trans("NewSalaryPayment"));
|
||||||
|
|
||||||
|
print '<table class="border" width="100%">';
|
||||||
|
|
||||||
|
print "<tr>";
|
||||||
|
print '<td class="fieldrequired">'.$langs->trans("DatePayment").'</td><td>';
|
||||||
|
print $form->select_date($datep,"datep",'','','','add');
|
||||||
|
print '</td></tr>';
|
||||||
|
|
||||||
|
print '<tr><td class="fieldrequired">'.$langs->trans("DateValue").'</td><td>';
|
||||||
|
print $form->select_date($datev,"datev",'','','','add');
|
||||||
|
print '</td></tr>';
|
||||||
|
|
||||||
|
print "<tr>";
|
||||||
|
print '<td class="fieldrequired">'.$langs->trans("Person").'</td><td>';
|
||||||
|
print $form->select_dolusers(GETPOST('fk_user','int'),'fk_user',1);
|
||||||
|
print '</td></tr>';
|
||||||
|
|
||||||
|
// Label
|
||||||
|
print '<tr><td class="fieldrequired">'.$langs->trans("Label").'</td><td><input name="label" size="40" value="'.($_POST["label"]?$_POST["label"]:$langs->trans("SalaryPayment")).'"></td></tr>';
|
||||||
|
|
||||||
|
print "<tr>";
|
||||||
|
print '<td class="fieldrequired">'.$langs->trans("DateStartPeriod").'</td><td>';
|
||||||
|
print $form->select_date($datesp,"datesp",'','','','add');
|
||||||
|
print '</td></tr>';
|
||||||
|
|
||||||
|
print '<tr><td class="fieldrequired">'.$langs->trans("DateEndPeriod").'</td><td>';
|
||||||
|
print $form->select_date($dateep,"dateep",'','','','add');
|
||||||
|
print '</td></tr>';
|
||||||
|
|
||||||
|
// Amount
|
||||||
|
print '<tr><td class="fieldrequired">'.$langs->trans("Amount").'</td><td><input name="amount" size="10" value="'.$_POST["amount"].'"></td></tr>';
|
||||||
|
|
||||||
|
// Bank
|
||||||
|
if (! empty($conf->banque->enabled))
|
||||||
|
{
|
||||||
|
print '<tr><td class="fieldrequired">'.$langs->trans("Account").'</td><td>';
|
||||||
|
$form->select_comptes($_POST["accountid"],"accountid",0,"courant=1",1); // Affiche liste des comptes courant
|
||||||
|
print '</td></tr>';
|
||||||
|
|
||||||
|
print '<tr><td class="fieldrequired">'.$langs->trans("PaymentMode").'</td><td>';
|
||||||
|
$form->select_types_paiements($_POST["paiementtype"], "paiementtype");
|
||||||
|
print "</td>\n";
|
||||||
|
print "</tr>";
|
||||||
|
}
|
||||||
|
|
||||||
|
// Other attributes
|
||||||
|
$parameters=array('colspan' => ' colspan="1"');
|
||||||
|
$reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook
|
||||||
|
|
||||||
|
print '</table>';
|
||||||
|
|
||||||
|
print "<br>";
|
||||||
|
|
||||||
|
print '<center><input type="submit" class="button" value="'.$langs->trans("Save").'"> ';
|
||||||
|
print '<input type="submit" class="button" name="cancel" value="'.$langs->trans("Cancel").'"></center>';
|
||||||
|
|
||||||
|
print '</form>';
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* ************************************************************************** */
|
||||||
|
/* */
|
||||||
|
/* Barre d'action */
|
||||||
|
/* */
|
||||||
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
if ($id)
|
||||||
|
{
|
||||||
|
$h = 0;
|
||||||
|
$head[$h][0] = DOL_URL_ROOT.'/compta/salaries/fiche.php?id='.$salpayment->id;
|
||||||
|
$head[$h][1] = $langs->trans('Card');
|
||||||
|
$head[$h][2] = 'card';
|
||||||
|
$h++;
|
||||||
|
|
||||||
|
dol_fiche_head($head, 'card', $langs->trans("SalaryPayment"), 0, 'payment');
|
||||||
|
|
||||||
|
|
||||||
|
print '<table class="border" width="100%">';
|
||||||
|
|
||||||
|
print "<tr>";
|
||||||
|
print '<td width="25%">'.$langs->trans("Ref").'</td><td colspan="3">';
|
||||||
|
print $salpayment->ref;
|
||||||
|
print '</td></tr>';
|
||||||
|
|
||||||
|
// Person
|
||||||
|
print '<tr><td>'.$langs->trans("Person").'</td><td>';
|
||||||
|
$usersal=new User($db);
|
||||||
|
$usersal->fetch($salpayment->fk_user);
|
||||||
|
print $usersal->getNomUrl(1);
|
||||||
|
print '</td></tr>';
|
||||||
|
|
||||||
|
// Label
|
||||||
|
print '<tr><td>'.$langs->trans("Label").'</td><td>'.$salpayment->label.'</td></tr>';
|
||||||
|
|
||||||
|
print "<tr>";
|
||||||
|
print '<td>'.$langs->trans("DateStartPeriod").'</td><td colspan="3">';
|
||||||
|
print dol_print_date($salpayment->datesp,'day');
|
||||||
|
print '</td></tr>';
|
||||||
|
|
||||||
|
print '<tr><td>'.$langs->trans("DateEndPeriod").'</td><td colspan="3">';
|
||||||
|
print dol_print_date($salpayment->dateep,'day');
|
||||||
|
print '</td></tr>';
|
||||||
|
|
||||||
|
print "<tr>";
|
||||||
|
print '<td>'.$langs->trans("DatePayment").'</td><td colspan="3">';
|
||||||
|
print dol_print_date($salpayment->datep,'day');
|
||||||
|
print '</td></tr>';
|
||||||
|
|
||||||
|
print '<tr><td>'.$langs->trans("DateValue").'</td><td colspan="3">';
|
||||||
|
print dol_print_date($salpayment->datev,'day');
|
||||||
|
print '</td></tr>';
|
||||||
|
|
||||||
|
print '<tr><td>'.$langs->trans("Amount").'</td><td colspan="3">'.price($salpayment->amount).'</td></tr>';
|
||||||
|
|
||||||
|
if (! empty($conf->banque->enabled))
|
||||||
|
{
|
||||||
|
if ($salpayment->fk_account > 0)
|
||||||
|
{
|
||||||
|
$bankline=new AccountLine($db);
|
||||||
|
$bankline->fetch($salpayment->fk_bank);
|
||||||
|
|
||||||
|
print '<tr>';
|
||||||
|
print '<td>'.$langs->trans('BankTransactionLine').'</td>';
|
||||||
|
print '<td colspan="3">';
|
||||||
|
print $bankline->getNomUrl(1,0,'showall');
|
||||||
|
print '</td>';
|
||||||
|
print '</tr>';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 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
|
||||||
|
|
||||||
|
print '</table>';
|
||||||
|
|
||||||
|
print '</div>';
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Boutons d'actions
|
||||||
|
*/
|
||||||
|
print "<div class=\"tabsAction\">\n";
|
||||||
|
if ($salpayment->rappro == 0)
|
||||||
|
{
|
||||||
|
if (! empty($user->rights->tax->charges->supprimer))
|
||||||
|
{
|
||||||
|
print '<a class="butActionDelete" href="fiche.php?id='.$salpayment->id.'&action=delete">'.$langs->trans("Delete").'</a>';
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
print '<a class="butActionRefused" href="#" title="'.(dol_escape_htmltag($langs->trans("NotAllowed"))).'">'.$langs->trans("Delete").'</a>';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
print '<a class="butActionRefused" href="#" title="'.$langs->trans("LinkedToAConcialitedTransaction").'">'.$langs->trans("Delete").'</a>';
|
||||||
|
}
|
||||||
|
print "</div>";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
$db->close();
|
||||||
|
|
||||||
|
llxFooter();
|
||||||
|
?>
|
||||||
107
htdocs/compta/salaries/index.php
Normal file
107
htdocs/compta/salaries/index.php
Normal file
@ -0,0 +1,107 @@
|
|||||||
|
<?php
|
||||||
|
/* Copyright (C) 2011-2014 Alexandre Spangaro <alexandre.spangaro@gmail.com>
|
||||||
|
*
|
||||||
|
* 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 <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \file htdocs/compta/salaries/index.php
|
||||||
|
* \ingroup tax
|
||||||
|
* \brief List of salaries payments
|
||||||
|
*/
|
||||||
|
|
||||||
|
require '../../main.inc.php';
|
||||||
|
require_once DOL_DOCUMENT_ROOT.'/compta/salaries/class/paymentsalary.class.php';
|
||||||
|
|
||||||
|
$langs->load("compta");
|
||||||
|
|
||||||
|
// Security check
|
||||||
|
$socid = isset($_GET["socid"])?$_GET["socid"]:'';
|
||||||
|
if ($user->societe_id) $socid=$user->societe_id;
|
||||||
|
$result = restrictedArea($user, 'tax', '', '', 'charges');
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* View
|
||||||
|
*/
|
||||||
|
|
||||||
|
llxHeader();
|
||||||
|
|
||||||
|
$salstatic = new PaymentSalary($db);
|
||||||
|
$userstatic = new User($db);
|
||||||
|
|
||||||
|
|
||||||
|
print_fiche_titre($langs->trans("SalariesPayments"));
|
||||||
|
|
||||||
|
$sql = "SELECT u.rowid as uid, u.lastname, u.firstname, s.rowid, s.fk_user, s.amount, s.label, s.datev as dm";
|
||||||
|
$sql.= " FROM ".MAIN_DB_PREFIX."payment_salary as s, ".MAIN_DB_PREFIX."user as u";
|
||||||
|
$sql.= " WHERE u.rowid = s.fk_user";
|
||||||
|
$sql.= " AND s.entity = ".$conf->entity;
|
||||||
|
$sql.= " ORDER BY dm DESC";
|
||||||
|
|
||||||
|
$result = $db->query($sql);
|
||||||
|
if ($result)
|
||||||
|
{
|
||||||
|
$num = $db->num_rows($result);
|
||||||
|
$i = 0;
|
||||||
|
$total = 0 ;
|
||||||
|
|
||||||
|
print '<table class="noborder" width="100%">';
|
||||||
|
print '<tr class="liste_titre">';
|
||||||
|
print '<td class="nowrap" align="left">'.$langs->trans("Ref").'</td>';
|
||||||
|
print "<td>".$langs->trans("Person")."</td>";
|
||||||
|
print "<td>".$langs->trans("Label")."</td>";
|
||||||
|
print '<td class="nowrap" align="left">'.$langs->trans("DatePayment").'</td>';
|
||||||
|
print "<td align=\"right\">".$langs->trans("PayedByThisPayment")."</td>";
|
||||||
|
print "</tr>\n";
|
||||||
|
$var=1;
|
||||||
|
while ($i < $num)
|
||||||
|
{
|
||||||
|
$obj = $db->fetch_object($result);
|
||||||
|
$var=!$var;
|
||||||
|
print "<tr ".$bc[$var].">";
|
||||||
|
|
||||||
|
$userstatic->id=$obj->uid;
|
||||||
|
$userstatic->lastname=$obj->lastname;
|
||||||
|
$userstatic->firstname=$obj->firstname;
|
||||||
|
$salstatic->id=$obj->rowid;
|
||||||
|
$salstatic->ref=$obj->rowid;
|
||||||
|
print "<td>".$salstatic->getNomUrl(1)."</td>\n";
|
||||||
|
print "<td>".$userstatic->getNomUrl(1)."</td>\n";
|
||||||
|
print "<td>".dol_trunc($obj->label,40)."</td>\n";
|
||||||
|
print '<td align="left">'.dol_print_date($db->jdate($obj->dm),'day')."</td>\n";
|
||||||
|
$total = $total + $obj->amount;
|
||||||
|
|
||||||
|
print "<td align=\"right\">".price($obj->amount)."</td>";
|
||||||
|
print "</tr>\n";
|
||||||
|
|
||||||
|
$i++;
|
||||||
|
}
|
||||||
|
print '<tr class="liste_total"><td colspan="4">'.$langs->trans("Total").'</td>';
|
||||||
|
print "<td align=\"right\"><b>".price($total)."</b></td></tr>";
|
||||||
|
|
||||||
|
print "</table>";
|
||||||
|
$db->free($result);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
dol_print_error($db);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
$db->close();
|
||||||
|
|
||||||
|
llxFooter();
|
||||||
|
?>
|
||||||
@ -180,9 +180,12 @@ insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, left
|
|||||||
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->deplacement->enabled && $leftmenu=="tripsandexpenses"', __HANDLER__, 'left', 2102__+MAX_llx_menu__, 'accountancy', '', 2100__+MAX_llx_menu__, '/compta/deplacement/list.php?leftmenu=tripsandexpenses', 'List', 1, 'trips', '$user->rights->deplacement->lire', '', 0, 2, __ENTITY__);
|
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->deplacement->enabled && $leftmenu=="tripsandexpenses"', __HANDLER__, 'left', 2102__+MAX_llx_menu__, 'accountancy', '', 2100__+MAX_llx_menu__, '/compta/deplacement/list.php?leftmenu=tripsandexpenses', 'List', 1, 'trips', '$user->rights->deplacement->lire', '', 0, 2, __ENTITY__);
|
||||||
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->deplacement->enabled && $leftmenu=="tripsandexpenses"', __HANDLER__, 'left', 2103__+MAX_llx_menu__, 'accountancy', '', 2100__+MAX_llx_menu__, '/compta/deplacement/stats/index.php?leftmenu=tripsandexpenses', 'Statistics', 1, 'trips', '$user->rights->deplacement->lire', '', 0, 2, __ENTITY__);
|
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->deplacement->enabled && $leftmenu=="tripsandexpenses"', __HANDLER__, 'left', 2103__+MAX_llx_menu__, 'accountancy', '', 2100__+MAX_llx_menu__, '/compta/deplacement/stats/index.php?leftmenu=tripsandexpenses', 'Statistics', 1, 'trips', '$user->rights->deplacement->lire', '', 0, 2, __ENTITY__);
|
||||||
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->tax->enabled', __HANDLER__, 'left', 2200__+MAX_llx_menu__, 'accountancy', 'tax', 6__+MAX_llx_menu__, '/compta/charges/index.php?leftmenu=tax&mainmenu=accountancy', 'MenuTaxAndDividends', 0, 'compta', '$user->rights->tax->charges->lire', '', 0, 6, __ENTITY__);
|
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->tax->enabled', __HANDLER__, 'left', 2200__+MAX_llx_menu__, 'accountancy', 'tax', 6__+MAX_llx_menu__, '/compta/charges/index.php?leftmenu=tax&mainmenu=accountancy', 'MenuTaxAndDividends', 0, 'compta', '$user->rights->tax->charges->lire', '', 0, 6, __ENTITY__);
|
||||||
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->tax->enabled', __HANDLER__, 'left', 2201__+MAX_llx_menu__, 'accountancy', 'tax_social', 2200__+MAX_llx_menu__, '/compta/sociales/index.php?leftmenu=tax_social', 'SocialContributions', 1, '', '$user->rights->tax->charges->lire', '', 0, 1, __ENTITY__);
|
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->tax->enabled', __HANDLER__, 'left', 2201__+MAX_llx_menu__, 'accountancy', 'tax_sal', 2200__+MAX_llx_menu__, '/compta/salaries/index.php?leftmenu=tax_sal&mainmenu=accountancy', 'Salaries', 1, 'companies', '$user->rights->tax->charges->lire', '', 0, 7, __ENTITY__);
|
||||||
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->tax->enabled && $leftmenu=="tax_social"', __HANDLER__, 'left', 2202__+MAX_llx_menu__, 'accountancy', '', 2201__+MAX_llx_menu__, '/compta/sociales/charges.php?leftmenu=tax_social&action=create', 'MenuNewSocialContribution', 2, '', '$user->rights->tax->charges->creer', '', 0, 2, __ENTITY__);
|
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->tax->enabled && $leftmenu=="tax_sal"', __HANDLER__, 'left', 2201__+MAX_llx_menu__, 'accountancy', '', 2201__+MAX_llx_menu__, '/compta/salaries/fiche.php?leftmenu=tax_sal&action=create', 'NewPayment', 2, 'companies', '$user->rights->tax->charges->creer', '', 0, 0, __ENTITY__);
|
||||||
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->tax->enabled && $leftmenu=="tax_social"', __HANDLER__, 'left', 2203__+MAX_llx_menu__, 'accountancy', '', 2201__+MAX_llx_menu__, '/compta/charges/index.php?leftmenu=tax_social&mainmenu=accountancy&mode=sconly', 'Payments', 2, '', '$user->rights->tax->charges->lire', '', 0, 3, __ENTITY__);
|
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->tax->enabled && $leftmenu=="tax_sal"', __HANDLER__, 'left', 2202__+MAX_llx_menu__, 'accountancy', '', 2201__+MAX_llx_menu__, '/compta/salaries/index.php?leftmenu=tax_sal', 'Payments', 2, 'companies', '$user->rights->tax->charges->lire', '', 0, 1, __ENTITY__);
|
||||||
|
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->tax->enabled', __HANDLER__, 'left', 2250__+MAX_llx_menu__, 'accountancy', 'tax_social', 2200__+MAX_llx_menu__, '/compta/sociales/index.php?leftmenu=tax_social', 'SocialContributions', 1, '', '$user->rights->tax->charges->lire', '', 0, 1, __ENTITY__);
|
||||||
|
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->tax->enabled && $leftmenu=="tax_social"', __HANDLER__, 'left', 2251__+MAX_llx_menu__, 'accountancy', '', 2250__+MAX_llx_menu__, '/compta/sociales/charges.php?leftmenu=tax_social&action=create', 'MenuNewSocialContribution', 2, '', '$user->rights->tax->charges->creer', '', 0, 2, __ENTITY__);
|
||||||
|
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->tax->enabled && $leftmenu=="tax_social"', __HANDLER__, 'left', 2252__+MAX_llx_menu__, 'accountancy', '', 2250__+MAX_llx_menu__, '/compta/charges/index.php?leftmenu=tax_social&mainmenu=accountancy&mode=sconly', 'Payments', 2, '', '$user->rights->tax->charges->lire', '', 0, 3, __ENTITY__);
|
||||||
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->tax->enabled && empty($conf->global->TAX_DISABLE_VAT_MENUS)', __HANDLER__, 'left', 2300__+MAX_llx_menu__, 'accountancy', 'tax_vat', 2200__+MAX_llx_menu__, '/compta/tva/index.php?leftmenu=tax_vat&mainmenu=accountancy', 'VAT', 1, 'companies', '$user->rights->tax->charges->lire', '', 0, 7, __ENTITY__);
|
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->tax->enabled && empty($conf->global->TAX_DISABLE_VAT_MENUS)', __HANDLER__, 'left', 2300__+MAX_llx_menu__, 'accountancy', 'tax_vat', 2200__+MAX_llx_menu__, '/compta/tva/index.php?leftmenu=tax_vat&mainmenu=accountancy', 'VAT', 1, 'companies', '$user->rights->tax->charges->lire', '', 0, 7, __ENTITY__);
|
||||||
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->tax->enabled && empty($conf->global->TAX_DISABLE_VAT_MENUS) && $leftmenu=="tax_vat"', __HANDLER__, 'left', 2301__+MAX_llx_menu__, 'accountancy', '', 2300__+MAX_llx_menu__, '/compta/tva/fiche.php?leftmenu=tax_vat&action=create', 'NewPayment', 2, 'companies', '$user->rights->tax->charges->creer', '', 0, 0, __ENTITY__);
|
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->tax->enabled && empty($conf->global->TAX_DISABLE_VAT_MENUS) && $leftmenu=="tax_vat"', __HANDLER__, 'left', 2301__+MAX_llx_menu__, 'accountancy', '', 2300__+MAX_llx_menu__, '/compta/tva/fiche.php?leftmenu=tax_vat&action=create', 'NewPayment', 2, 'companies', '$user->rights->tax->charges->creer', '', 0, 0, __ENTITY__);
|
||||||
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->tax->enabled && empty($conf->global->TAX_DISABLE_VAT_MENUS) && $leftmenu=="tax_vat"', __HANDLER__, 'left', 2302__+MAX_llx_menu__, 'accountancy', '', 2300__+MAX_llx_menu__, '/compta/tva/reglement.php?leftmenu=tax_vat', 'Payments', 2, 'companies', '$user->rights->tax->charges->lire', '', 0, 1, __ENTITY__);
|
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->tax->enabled && empty($conf->global->TAX_DISABLE_VAT_MENUS) && $leftmenu=="tax_vat"', __HANDLER__, 'left', 2302__+MAX_llx_menu__, 'accountancy', '', 2300__+MAX_llx_menu__, '/compta/tva/reglement.php?leftmenu=tax_vat', 'Payments', 2, 'companies', '$user->rights->tax->charges->lire', '', 0, 1, __ENTITY__);
|
||||||
|
|||||||
@ -804,7 +804,13 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after,&$tabMenu
|
|||||||
if (! empty($conf->tax->enabled))
|
if (! empty($conf->tax->enabled))
|
||||||
{
|
{
|
||||||
$newmenu->add("/compta/charges/index.php?leftmenu=tax&mainmenu=accountancy",$langs->trans("MenuTaxAndDividends"), 0, $user->rights->tax->charges->lire, '', $mainmenu, 'tax');
|
$newmenu->add("/compta/charges/index.php?leftmenu=tax&mainmenu=accountancy",$langs->trans("MenuTaxAndDividends"), 0, $user->rights->tax->charges->lire, '', $mainmenu, 'tax');
|
||||||
if (empty($leftmenu) || preg_match('/^tax/i',$leftmenu)) $newmenu->add("/compta/sociales/index.php?leftmenu=tax_social",$langs->trans("MenuSocialContributions"),1,$user->rights->tax->charges->lire);
|
// Salaries
|
||||||
|
if (empty($leftmenu) || preg_match('/^tax/i',$leftmenu)) $newmenu->add("/compta/salaries/index.php?leftmenu=tax_sal&mainmenu=accountancy",$langs->trans("Salaries"),1,$user->rights->tax->charges->lire, '', $mainmenu, 'tax_vat');
|
||||||
|
if (empty($leftmenu) || preg_match('/^tax/i',$leftmenu)) $newmenu->add("/compta/salaries/fiche.php?leftmenu=tax_sal&action=create",$langs->trans("NewPayment"),2,$user->rights->tax->charges->creer);
|
||||||
|
if (empty($leftmenu) || preg_match('/^tax/i',$leftmenu)) $newmenu->add("/compta/salaries/index.php?leftmenu=tax_sal",$langs->trans("Payments"),2,$user->rights->tax->charges->lire);
|
||||||
|
global $mysoc;
|
||||||
|
// Social contributions
|
||||||
|
if (empty($leftmenu) || preg_match('/^tax/i',$leftmenu)) $newmenu->add("/compta/sociales/index.php?leftmenu=tax_social",$langs->trans("MenuSocialContributions"),1,$user->rights->tax->charges->lire);
|
||||||
if (empty($leftmenu) || preg_match('/^tax/i',$leftmenu)) $newmenu->add("/compta/sociales/charges.php?leftmenu=tax_social&action=create",$langs->trans("MenuNewSocialContribution"), 2, $user->rights->tax->charges->creer);
|
if (empty($leftmenu) || preg_match('/^tax/i',$leftmenu)) $newmenu->add("/compta/sociales/charges.php?leftmenu=tax_social&action=create",$langs->trans("MenuNewSocialContribution"), 2, $user->rights->tax->charges->creer);
|
||||||
if (empty($leftmenu) || preg_match('/^tax/i',$leftmenu)) $newmenu->add("/compta/charges/index.php?leftmenu=tax_social&mainmenu=accountancy&mode=sconly",$langs->trans("Payments"), 2, $user->rights->tax->charges->lire);
|
if (empty($leftmenu) || preg_match('/^tax/i',$leftmenu)) $newmenu->add("/compta/charges/index.php?leftmenu=tax_social&mainmenu=accountancy&mode=sconly",$langs->trans("Payments"), 2, $user->rights->tax->charges->lire);
|
||||||
// VAT
|
// VAT
|
||||||
|
|||||||
@ -1036,4 +1036,22 @@ CREATE TABLE IF NOT EXISTS `llx_expeditiondet_batch` (
|
|||||||
`qty` double NOT NULL DEFAULT '0',
|
`qty` double NOT NULL DEFAULT '0',
|
||||||
`fk_origin_stock` int(11) NOT NULL,
|
`fk_origin_stock` int(11) NOT NULL,
|
||||||
KEY `ix_fk_expeditiondet` (`fk_expeditiondet`)
|
KEY `ix_fk_expeditiondet` (`fk_expeditiondet`)
|
||||||
) ENGINE=InnoDB;
|
) ENGINE=InnoDB;
|
||||||
|
|
||||||
|
--Salary payment in tax module
|
||||||
|
CREATE TABLE IF NOT EXISTS `llx_payment_salary` (
|
||||||
|
`rowid` integer AUTO_INCREMENT PRIMARY KEY,
|
||||||
|
`tms` timestamp,
|
||||||
|
`fk_user` integer NOT NULL,
|
||||||
|
`datep` date,
|
||||||
|
`datev` date,
|
||||||
|
`amount` real NOT NULL DEFAULT 0,
|
||||||
|
`label` varchar(255),
|
||||||
|
`datesp` date, -- date de début de la période
|
||||||
|
`dateep` date, -- date de fin de la période
|
||||||
|
`entity` integer DEFAULT 1 NOT NULL, -- multi company id
|
||||||
|
`note` text,
|
||||||
|
`fk_bank` integer,
|
||||||
|
`fk_user_creat` integer,
|
||||||
|
`fk_user_modif` integer
|
||||||
|
)ENGINE=innodb;
|
||||||
35
htdocs/install/mysql/tables/llx_payment_salary.sql
Normal file
35
htdocs/install/mysql/tables/llx_payment_salary.sql
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
-- ===================================================================
|
||||||
|
-- Copyright (C) 2011-2014 Alexandre Spangaro <alexandre.spangaro@gmail.com>
|
||||||
|
--
|
||||||
|
-- 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 <http://www.gnu.org/licenses/>.
|
||||||
|
--
|
||||||
|
-- ===================================================================
|
||||||
|
|
||||||
|
create table llx_payment_salary
|
||||||
|
(
|
||||||
|
rowid integer AUTO_INCREMENT PRIMARY KEY,
|
||||||
|
tms timestamp,
|
||||||
|
fk_user integer NOT NULL,
|
||||||
|
datep date, -- date de paiement
|
||||||
|
datev date, -- date de valeur
|
||||||
|
amount real NOT NULL DEFAULT 0,
|
||||||
|
label varchar(255),
|
||||||
|
datesp date, -- date de début de la période
|
||||||
|
dateep date, -- date de fin de la période
|
||||||
|
entity integer DEFAULT 1 NOT NULL, -- multi company id
|
||||||
|
note text,
|
||||||
|
fk_bank integer,
|
||||||
|
fk_user_creat integer, -- utilisateur qui a cree l'info
|
||||||
|
fk_user_modif integer -- utilisateur qui a modifié l'info
|
||||||
|
)ENGINE=innodb;
|
||||||
@ -41,6 +41,7 @@ VATToCollect=VAT purchases
|
|||||||
VATSummary=VAT Balance
|
VATSummary=VAT Balance
|
||||||
LT2SummaryES=IRPF Balance
|
LT2SummaryES=IRPF Balance
|
||||||
VATPaid=VAT paid
|
VATPaid=VAT paid
|
||||||
|
SalaryPaid=Salary paid
|
||||||
LT2PaidES=IRPF Paid
|
LT2PaidES=IRPF Paid
|
||||||
LT2CustomerES=IRPF sales
|
LT2CustomerES=IRPF sales
|
||||||
LT2SupplierES=IRPF purchases
|
LT2SupplierES=IRPF purchases
|
||||||
@ -51,6 +52,7 @@ TaxAndDividendsArea=Tax, social contributions and dividends area
|
|||||||
SocialContribution=Social contribution
|
SocialContribution=Social contribution
|
||||||
SocialContributions=Social contributions
|
SocialContributions=Social contributions
|
||||||
MenuTaxAndDividends=Taxes and dividends
|
MenuTaxAndDividends=Taxes and dividends
|
||||||
|
MenuSalaries=Salaries
|
||||||
MenuSocialContributions=Social contributions
|
MenuSocialContributions=Social contributions
|
||||||
MenuNewSocialContribution=New contribution
|
MenuNewSocialContribution=New contribution
|
||||||
NewSocialContribution=New social contribution
|
NewSocialContribution=New social contribution
|
||||||
@ -63,19 +65,26 @@ PaymentCustomerInvoice=Customer invoice payment
|
|||||||
PaymentSupplierInvoice=Supplier invoice payment
|
PaymentSupplierInvoice=Supplier invoice payment
|
||||||
PaymentSocialContribution=Social contribution payment
|
PaymentSocialContribution=Social contribution payment
|
||||||
PaymentVat=VAT payment
|
PaymentVat=VAT payment
|
||||||
|
PaymentSalary=Salary payment
|
||||||
ListPayment=List of payments
|
ListPayment=List of payments
|
||||||
ListOfPayments=List of payments
|
ListOfPayments=List of payments
|
||||||
ListOfCustomerPayments=List of customer payments
|
ListOfCustomerPayments=List of customer payments
|
||||||
ListOfSupplierPayments=List of supplier payments
|
ListOfSupplierPayments=List of supplier payments
|
||||||
DatePayment=Payment date
|
DatePayment=Payment date
|
||||||
|
DateStartPeriod=Date start period
|
||||||
|
DateEndPeriod=Date end period
|
||||||
NewVATPayment=New VAT payment
|
NewVATPayment=New VAT payment
|
||||||
|
NewSalaryPayment=New salary payment
|
||||||
newLT2PaymentES=New IRPF payment
|
newLT2PaymentES=New IRPF payment
|
||||||
LT2PaymentES=IRPF Payment
|
LT2PaymentES=IRPF Payment
|
||||||
LT2PaymentsES=IRPF Payments
|
LT2PaymentsES=IRPF Payments
|
||||||
VATPayment=VAT Payment
|
VATPayment=VAT Payment
|
||||||
VATPayments=VAT Payments
|
VATPayments=VAT Payments
|
||||||
|
SalaryPayment=Salary payment
|
||||||
|
SalariesPayments=Salaries payments
|
||||||
SocialContributionsPayments=Social contributions payments
|
SocialContributionsPayments=Social contributions payments
|
||||||
ShowVatPayment=Show VAT payment
|
ShowVatPayment=Show VAT payment
|
||||||
|
ShowSalaryPayment=Show salary payment
|
||||||
TotalToPay=Total to pay
|
TotalToPay=Total to pay
|
||||||
TotalVATReceived=Total VAT received
|
TotalVATReceived=Total VAT received
|
||||||
CustomerAccountancyCode=Customer accountancy code
|
CustomerAccountancyCode=Customer accountancy code
|
||||||
|
|||||||
@ -41,6 +41,7 @@ VATToCollect=TVA achats
|
|||||||
VATSummary=Balance de TVA
|
VATSummary=Balance de TVA
|
||||||
LT2SummaryES=Balance de IRPF
|
LT2SummaryES=Balance de IRPF
|
||||||
VATPaid=TVA payée
|
VATPaid=TVA payée
|
||||||
|
SalaryPaid=Salaire payé
|
||||||
LT2PaidES=IRPF Payée
|
LT2PaidES=IRPF Payée
|
||||||
LT2CustomerES=IRPF ventes
|
LT2CustomerES=IRPF ventes
|
||||||
LT2SupplierES=IRPF achats
|
LT2SupplierES=IRPF achats
|
||||||
@ -51,6 +52,7 @@ TaxAndDividendsArea=Espace taxes, charges sociales et dividendes
|
|||||||
SocialContribution=Charge sociale
|
SocialContribution=Charge sociale
|
||||||
SocialContributions=Charges sociales
|
SocialContributions=Charges sociales
|
||||||
MenuTaxAndDividends=Taxes et charges
|
MenuTaxAndDividends=Taxes et charges
|
||||||
|
MenuSalaries=Salaires
|
||||||
MenuSocialContributions=Charges sociales
|
MenuSocialContributions=Charges sociales
|
||||||
MenuNewSocialContribution=Nouvelle charge
|
MenuNewSocialContribution=Nouvelle charge
|
||||||
NewSocialContribution=Nouvelle charge sociale
|
NewSocialContribution=Nouvelle charge sociale
|
||||||
@ -63,19 +65,26 @@ PaymentCustomerInvoice=Règlement facture client
|
|||||||
PaymentSupplierInvoice=Règlement facture fournisseur
|
PaymentSupplierInvoice=Règlement facture fournisseur
|
||||||
PaymentSocialContribution=Règlement charge sociale
|
PaymentSocialContribution=Règlement charge sociale
|
||||||
PaymentVat=Règlement TVA
|
PaymentVat=Règlement TVA
|
||||||
|
PaymentSalary=Règlement salaire
|
||||||
ListPayment=Liste des règlements
|
ListPayment=Liste des règlements
|
||||||
ListOfPayments=Liste des règlements
|
ListOfPayments=Liste des règlements
|
||||||
ListOfCustomerPayments=Liste des règlements clients
|
ListOfCustomerPayments=Liste des règlements clients
|
||||||
ListOfSupplierPayments=Liste des règlements fournisseurs
|
ListOfSupplierPayments=Liste des règlements fournisseurs
|
||||||
DatePayment=Date de règlement
|
DatePayment=Date de règlement
|
||||||
|
DateStartPeriod=Date de début période
|
||||||
|
DateEndPeriod=Date de fin période
|
||||||
NewVATPayment=Nouveau règlement de TVA
|
NewVATPayment=Nouveau règlement de TVA
|
||||||
|
NewSalaryPayment=Nouveau règlement de salaire
|
||||||
newLT2PaymentES=Nouveau règlement de IRPF
|
newLT2PaymentES=Nouveau règlement de IRPF
|
||||||
LT2PaymentES=Règlement IRPF
|
LT2PaymentES=Règlement IRPF
|
||||||
LT2PaymentsES=Règlements IRPF
|
LT2PaymentsES=Règlements IRPF
|
||||||
VATPayment=Règlement TVA
|
VATPayment=Règlement TVA
|
||||||
VATPayments=Règlements TVA
|
VATPayments=Règlements TVA
|
||||||
|
SalaryPayment=Règlement salaire
|
||||||
|
SalariesPayments=Règlements des salaires
|
||||||
SocialContributionsPayments=Règlements charges sociales
|
SocialContributionsPayments=Règlements charges sociales
|
||||||
ShowVatPayment=Affiche paiement TVA
|
ShowVatPayment=Afficher paiement TVA
|
||||||
|
ShowSalaryPayment=Afficher paiement salaire
|
||||||
TotalToPay=Total à payer
|
TotalToPay=Total à payer
|
||||||
TotalVATReceived=Total TVA perçue
|
TotalVATReceived=Total TVA perçue
|
||||||
CustomerAccountancyCode=Compte comptable client
|
CustomerAccountancyCode=Compte comptable client
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user