From 048b3c01ce8816efef35a780740e269a5445a95a Mon Sep 17 00:00:00 2001 From: aspangaro Date: Thu, 6 Mar 2014 21:21:16 +0100 Subject: [PATCH 1/6] Add salary payment in tax module - Link to user. Necessary for future hrm module. --- htdocs/compta/bank/account.php | 29 +- htdocs/compta/charges/index.php | 89 ++- .../compta/salaries/class/salaries.class.php | 578 ++++++++++++++++++ htdocs/compta/salaries/fiche.php | 327 ++++++++++ htdocs/compta/salaries/index.php | 107 ++++ htdocs/core/menus/init_menu_auguria.sql | 9 +- htdocs/core/menus/standard/eldy.lib.php | 8 +- htdocs/install/mysql/tables/llx_salaries.sql | 35 ++ htdocs/langs/en_US/compta.lang | 6 + htdocs/langs/fr_FR/compta.lang | 5 + 10 files changed, 1184 insertions(+), 9 deletions(-) create mode 100644 htdocs/compta/salaries/class/salaries.class.php create mode 100644 htdocs/compta/salaries/fiche.php create mode 100644 htdocs/compta/salaries/index.php create mode 100644 htdocs/install/mysql/tables/llx_salaries.sql diff --git a/htdocs/compta/bank/account.php b/htdocs/compta/bank/account.php index d85d6ff3b27..90a4e59fe40 100644 --- a/htdocs/compta/bank/account.php +++ b/htdocs/compta/bank/account.php @@ -5,7 +5,8 @@ * Copyright (C) 2004 Christophe Combelles * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2010-2011 Juanjo Menent - * Copyright (C) 2012 Marcos García + * Copyright (C) 2012 Marcos García + * Copyright (C) 2011-2014 Alexandre Spangaro * * 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 @@ -30,10 +31,12 @@ require('../../main.inc.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.'/user/class/user.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/paiement/class/paiement.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/tva/class/tva.class.php'; +require_once DOL_DOCUMENT_ROOT.'/compta/salaries/class/salaries.class.php'; require_once DOL_DOCUMENT_ROOT.'/fourn/class/paiementfourn.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(); $societestatic=new Societe($db); +$userstatic=new User($db); $chargestatic=new ChargeSociales($db); $memberstatic=new Adherent($db); $paymentstatic=new Paiement($db); $paymentsupplierstatic=new PaiementFourn($db); $paymentvatstatic=new TVA($db); +$paymentsalstatic=new Sal($db); $bankstatic=new Account($db); $banklinestatic=new AccountLine($db); @@ -458,8 +463,12 @@ if ($id > 0 || ! empty($ref)) } 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"; + // Salaries + $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."bank_url as bu3 ON bu3.fk_bank = b.rowid AND bu3.type='payment_sal'"; + $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."salaries as sal ON bu3.url_id = sal.rowid"; } if ($mode_search && ! empty($conf->adherent->enabled)) { @@ -577,6 +586,12 @@ if ($id > 0 || ! empty($ref)) $paymentvatstatic->ref=$links[$key]['url_id']; print ' '.$paymentvatstatic->getNomUrl(2); } + elseif ($links[$key]['type']=='payment_sal') + { + $paymentsalstatic->id=$links[$key]['url_id']; + $paymentsalstatic->ref=$links[$key]['url_id']; + print ' '.$paymentsalstatic->getNomUrl(2); + } 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. @@ -611,6 +626,10 @@ if ($id > 0 || ! empty($ref)) elseif ($links[$key]['type']=='company') { + } + elseif ($links[$key]['type']=='user') + { + } elseif ($links[$key]['type']=='member') { @@ -650,6 +669,12 @@ if ($id > 0 || ! empty($ref)) $societestatic->nom=$links[$key]['label']; 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') { // sc=old value diff --git a/htdocs/compta/charges/index.php b/htdocs/compta/charges/index.php index 21d68d42663..1004f765fa8 100644 --- a/htdocs/compta/charges/index.php +++ b/htdocs/compta/charges/index.php @@ -2,6 +2,7 @@ /* Copyright (C) 2001-2003 Rodolphe Quiedeville * Copyright (C) 2004-2010 Laurent Destailleur * Copyright (C) 2005-2010 Regis Houssin + * Copyright (C) 2011-2014 Alexandre Spangaro * * 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 @@ -20,13 +21,14 @@ /** * \file htdocs/compta/charges/index.php * \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_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.'/compta/salaries/class/salaries.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; $langs->load("compta"); @@ -59,6 +61,7 @@ if (! $sortorder) $sortorder="DESC"; $tva_static = new Tva($db); $socialcontrib=new ChargeSociales($db); $payment_sc_static=new PaymentSocialContribution($db); +$sal_static = new Sal($db); llxHeader('',$langs->trans("TaxAndDividendsArea")); @@ -74,12 +77,92 @@ print_fiche_titre($title, ($year?" if ($year) $param.='&year='.$year; -// Social contributions only if (GETPOST("mode") != 'sconly') { print $langs->trans("DescTaxAndDividendsArea").'
'; print "
"; +} +// Salaries +if (empty($_GET["mode"]) || $_GET["mode"] != 'sconly') +{ + $sal = new Sal($db); + + print_fiche_titre($langs->trans("SalPayments").($year?' ('.$langs->trans("Year").' '.$year.')':''), '', ''); + + $sql = "SELECT s.rowid, s.amount, s.label, s.datev as dm"; + $sql.= " FROM ".MAIN_DB_PREFIX."salaries 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 ''; + print ''; + 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 "\n"; + $var=1; + while ($i < $num) + { + $obj = $db->fetch_object($result); + + $total = $total + $obj->amount; + + $var=!$var; + print ""; + print ''."\n"; + + print "\n"; + + print '"; + + // Ref payment + $sal_static->id=$obj->rowid; + $sal_static->ref=$obj->rowid; + print '\n"; + + print '\n"; + print '"; + print "\n"; + + $i++; + } + print ''; + print '"; + print ''; + print ''; + print '"; + print ""; + + print "
'.dol_print_date($db->jdate($obj->dm),'day').'".$obj->label."'.price($obj->amount)."'.$sal_static->getNomUrl(1)."'.dol_print_date($db->jdate($obj->dm),'day')."'.price($obj->amount)."
'.$langs->trans("Total").''.price($total)."  '.price($total)."
"; + $db->free($result); + + print "
"; + } + else + { + dol_print_error($db); + } +} + +// Social contributions only +if (GETPOST("mode") != 'sconly') +{ print_fiche_titre($langs->trans("SocialContributionsPayments").($year?' ('.$langs->trans("Year").' '.$year.')':''), '', ''); } @@ -219,7 +302,7 @@ if (empty($_GET["mode"]) || $_GET["mode"] != 'sconly') $var=!$var; print ""; - print ''.dol_print_date($db->jdate($obj->dm),'day').' ? '."\n"; + print ''.dol_print_date($db->jdate($obj->dm),'day').''."\n"; print "".$obj->label."\n"; diff --git a/htdocs/compta/salaries/class/salaries.class.php b/htdocs/compta/salaries/class/salaries.class.php new file mode 100644 index 00000000000..ccb89a1e4e5 --- /dev/null +++ b/htdocs/compta/salaries/class/salaries.class.php @@ -0,0 +1,578 @@ + + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** + * \file htdocs/compta/salaries/class/salaries.class.php + * \ingroup tax + * \brief Class for tax module salaries + */ + +// 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 Sal extends CommonObject +{ + //public $element='salaries'; //!< Id that identify managed objects + //public $table_element='salaries'; //!< 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 = 'salaries'; + $this->table_element = 'salaries'; + 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."salaries("; + $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."salaries"); + + // Appel des triggers + include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; + $interface=new Interfaces($this->db); + $result=$interface->run_triggers('SAL_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."salaries 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('SAL_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."salaries 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."salaries"; + $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('SAL_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."salaries (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."salaries"); // TODO devrait s'appeler payment_sal + + // Appel des triggers + include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; + $interface=new Interfaces($this->db); + $result=$interface->run_triggers('SAL_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_sal' 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_sal' 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, "(SalPayment)", "payment_sal"); + 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 Sal ($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.'salaries 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 = '
'; + $lienfin=''; + + $picto='payment'; + $label=$langs->trans("ShowSalPayment").': '.$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; + } + +} +?> diff --git a/htdocs/compta/salaries/fiche.php b/htdocs/compta/salaries/fiche.php new file mode 100644 index 00000000000..9ff49c2ad11 --- /dev/null +++ b/htdocs/compta/salaries/fiche.php @@ -0,0 +1,327 @@ + + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** + * \file htdocs/compta/salaries/fiche.php + * \ingroup tax + * \brief Page of salaries payments + */ + +require '../../main.inc.php'; +require_once DOL_DOCUMENT_ROOT.'/compta/salaries/class/salaries.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 Sal($db); + +// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array +$hookmanager->initHooks(array('taxsalcard')); + + + +/** + * 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 Sal($db); + $result = $salpayment->fetch($id); + if ($result <= 0) + { + dol_print_error($db); + exit; + } +} + +// Formulaire saisie salaire +if ($action == 'create') +{ + print "
\n"; + print ''; + print ''; + + print_fiche_titre($langs->trans("NewSalPayment")); + + print ''; + + print ""; + print ''; + + print ''; + + print ""; + print ''; + + // Label + print ''; + + print ""; + print ''; + + print ''; + + // Amount + print ''; + + // Bank + if (! empty($conf->banque->enabled)) + { + print ''; + + print '\n"; + print ""; + } + + // 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 '
'.$langs->trans("DatePayment").''; + print $form->select_date($datep,"datep",'','','','add'); + print '
'.$langs->trans("DateValue").''; + print $form->select_date($datev,"datev",'','','','add'); + print '
'.$langs->trans("Person").''; + print $form->select_dolusers(GETPOST('fk_user','int'),'fk_user',1); + print '
'.$langs->trans("Label").'trans("SalPayment")).'">
'.$langs->trans("DateStartPeriod").''; + print $form->select_date($datesp,"datesp",'','','','add'); + print '
'.$langs->trans("DateEndPeriod").''; + print $form->select_date($dateep,"dateep",'','','','add'); + print '
'.$langs->trans("Amount").'
'.$langs->trans("Account").''; + $form->select_comptes($_POST["accountid"],"accountid",0,"courant=1",1); // Affiche liste des comptes courant + print '
'.$langs->trans("PaymentMode").''; + $form->select_types_paiements($_POST["paiementtype"], "paiementtype"); + print "
'; + + print "
"; + + print '
  '; + print '
'; + + print '
'; +} + + +/* ************************************************************************** */ +/* */ +/* 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("SalPayment"), 0, 'payment'); + + + print ''; + + print ""; + print ''; + + // Person + print ''; + + // Label + print ''; + + print ""; + print ''; + + print ''; + + print ""; + print ''; + + print ''; + + print ''; + + if (! empty($conf->banque->enabled)) + { + if ($salpayment->fk_account > 0) + { + $bankline=new AccountLine($db); + $bankline->fetch($salpayment->fk_bank); + + print ''; + print ''; + print ''; + print ''; + } + } + + // 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 '
'.$langs->trans("Ref").''; + print $salpayment->ref; + print '
'.$langs->trans("Person").''; + $usersal=new User($db); + $usersal->fetch($salpayment->fk_user); + print $usersal->getNomUrl(1); + print '
'.$langs->trans("Label").''.$salpayment->label.'
'.$langs->trans("DateStartPeriod").''; + print dol_print_date($salpayment->datesp,'day'); + print '
'.$langs->trans("DateEndPeriod").''; + print dol_print_date($salpayment->dateep,'day'); + print '
'.$langs->trans("DatePayment").''; + print dol_print_date($salpayment->datep,'day'); + print '
'.$langs->trans("DateValue").''; + print dol_print_date($salpayment->datev,'day'); + print '
'.$langs->trans("Amount").''.price($salpayment->amount).'
'.$langs->trans('BankTransactionLine').''; + print $bankline->getNomUrl(1,0,'showall'); + print '
'; + + print ''; + + /* + * Boutons d'actions + */ + print "
\n"; + if ($salpayment->rappro == 0) + { + if (! empty($user->rights->tax->charges->supprimer)) + { + print ''.$langs->trans("Delete").''; + } + else + { + print ''.$langs->trans("Delete").''; + } + } + else + { + print ''.$langs->trans("Delete").''; + } + print "
"; +} + + +$db->close(); + +llxFooter(); +?> diff --git a/htdocs/compta/salaries/index.php b/htdocs/compta/salaries/index.php new file mode 100644 index 00000000000..a2e166529de --- /dev/null +++ b/htdocs/compta/salaries/index.php @@ -0,0 +1,107 @@ + + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** + * \file htdocs/compta/salaries/index.php + * \ingroup tax + * \brief List of salaries payments + */ + +require '../../main.inc.php'; +require_once DOL_DOCUMENT_ROOT.'/compta/salaries/class/salaries.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 Sal($db); +$userstatic = new User($db); + + +print_fiche_titre($langs->trans("SalPayments")); + +$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."salaries 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 ''; + print ''; + print ''; + print ""; + print ""; + print ''; + print ""; + print "\n"; + $var=1; + while ($i < $num) + { + $obj = $db->fetch_object($result); + $var=!$var; + print ""; + + $userstatic->id=$obj->uid; + $userstatic->lastname=$obj->lastname; + $userstatic->firstname=$obj->firstname; + $salstatic->id=$obj->rowid; + $salstatic->ref=$obj->rowid; + print "\n"; + print "\n"; + print "\n"; + print '\n"; + $total = $total + $obj->amount; + + print ""; + print "\n"; + + $i++; + } + print ''; + print ""; + + print "
'.$langs->trans("Ref").'".$langs->trans("Person")."".$langs->trans("Label")."'.$langs->trans("DatePayment").'".$langs->trans("PayedByThisPayment")."
".$salstatic->getNomUrl(1)."".$userstatic->getNomUrl(1)."".dol_trunc($obj->label,40)."'.dol_print_date($db->jdate($obj->dm),'day')."".price($obj->amount)."
'.$langs->trans("Total").'".price($total)."
"; + $db->free($result); +} +else +{ + dol_print_error($db); +} + + +$db->close(); + +llxFooter(); +?> diff --git a/htdocs/core/menus/init_menu_auguria.sql b/htdocs/core/menus/init_menu_auguria.sql index ea9852253e2..91769af37fb 100644 --- a/htdocs/core/menus/init_menu_auguria.sql +++ b/htdocs/core/menus/init_menu_auguria.sql @@ -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', 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', 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 && $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_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', __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_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_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) && $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__); diff --git a/htdocs/core/menus/standard/eldy.lib.php b/htdocs/core/menus/standard/eldy.lib.php index 6c7e64d118a..d879d8cde7a 100644 --- a/htdocs/core/menus/standard/eldy.lib.php +++ b/htdocs/core/menus/standard/eldy.lib.php @@ -804,7 +804,13 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after,&$tabMenu 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'); - 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/charges/index.php?leftmenu=tax_social&mainmenu=accountancy&mode=sconly",$langs->trans("Payments"), 2, $user->rights->tax->charges->lire); // VAT diff --git a/htdocs/install/mysql/tables/llx_salaries.sql b/htdocs/install/mysql/tables/llx_salaries.sql new file mode 100644 index 00000000000..398086274f1 --- /dev/null +++ b/htdocs/install/mysql/tables/llx_salaries.sql @@ -0,0 +1,35 @@ +-- =================================================================== +-- Copyright (C) 2011-2014 Alexandre Spangaro +-- +-- 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 . +-- +-- =================================================================== + +create table llx_salaries +( + 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; \ No newline at end of file diff --git a/htdocs/langs/en_US/compta.lang b/htdocs/langs/en_US/compta.lang index b505efef8bc..45158337f04 100644 --- a/htdocs/langs/en_US/compta.lang +++ b/htdocs/langs/en_US/compta.lang @@ -41,6 +41,7 @@ VATToCollect=VAT purchases VATSummary=VAT Balance LT2SummaryES=IRPF Balance VATPaid=VAT paid +SalPaid=Salary paid LT2PaidES=IRPF Paid LT2CustomerES=IRPF sales LT2SupplierES=IRPF purchases @@ -63,19 +64,24 @@ PaymentCustomerInvoice=Customer invoice payment PaymentSupplierInvoice=Supplier invoice payment PaymentSocialContribution=Social contribution payment PaymentVat=VAT payment +PaymentSal=Salary payment ListPayment=List of payments ListOfPayments=List of payments ListOfCustomerPayments=List of customer payments ListOfSupplierPayments=List of supplier payments DatePayment=Payment date NewVATPayment=New VAT payment +NewSalPayment=New Salary payment newLT2PaymentES=New IRPF payment LT2PaymentES=IRPF Payment LT2PaymentsES=IRPF Payments VATPayment=VAT Payment VATPayments=VAT Payments +SalPayment=Salary payment +SalPayments=Saalries payments SocialContributionsPayments=Social contributions payments ShowVatPayment=Show VAT payment +ShowSalPayment=Show salary payment TotalToPay=Total to pay TotalVATReceived=Total VAT received CustomerAccountancyCode=Customer accountancy code diff --git a/htdocs/langs/fr_FR/compta.lang b/htdocs/langs/fr_FR/compta.lang index 4630b76f6e6..99cc954ab6d 100644 --- a/htdocs/langs/fr_FR/compta.lang +++ b/htdocs/langs/fr_FR/compta.lang @@ -63,19 +63,24 @@ PaymentCustomerInvoice=Règlement facture client PaymentSupplierInvoice=Règlement facture fournisseur PaymentSocialContribution=Règlement charge sociale PaymentVat=Règlement TVA +PaymentSal=Règlement salaire ListPayment=Liste des règlements ListOfPayments=Liste des règlements ListOfCustomerPayments=Liste des règlements clients ListOfSupplierPayments=Liste des règlements fournisseurs DatePayment=Date de règlement NewVATPayment=Nouveau règlement de TVA +NewSalPayment=Nouveau règlement de salaire newLT2PaymentES=Nouveau règlement de IRPF LT2PaymentES=Règlement IRPF LT2PaymentsES=Règlements IRPF VATPayment=Règlement TVA VATPayments=Règlements TVA +SalPayment=Règlement salaire +SalPayments=Règlements des salaires SocialContributionsPayments=Règlements charges sociales ShowVatPayment=Affiche paiement TVA +ShowSalPayment=Affiche paiement salaire TotalToPay=Total à payer TotalVATReceived=Total TVA perçue CustomerAccountancyCode=Compte comptable client From fca29f431270f4abbd0efdc241f693f0f12e2875 Mon Sep 17 00:00:00 2001 From: aspangaro Date: Thu, 6 Mar 2014 21:29:20 +0100 Subject: [PATCH 2/6] Add table into script migration && key language --- .../install/mysql/migration/3.5.0-3.6.0.sql | 20 ++++++++++++++++++- htdocs/langs/en_US/compta.lang | 2 ++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/htdocs/install/mysql/migration/3.5.0-3.6.0.sql b/htdocs/install/mysql/migration/3.5.0-3.6.0.sql index b10122ee269..584b994470e 100644 --- a/htdocs/install/mysql/migration/3.5.0-3.6.0.sql +++ b/htdocs/install/mysql/migration/3.5.0-3.6.0.sql @@ -1036,4 +1036,22 @@ CREATE TABLE IF NOT EXISTS `llx_expeditiondet_batch` ( `qty` double NOT NULL DEFAULT '0', `fk_origin_stock` int(11) NOT NULL, KEY `ix_fk_expeditiondet` (`fk_expeditiondet`) -) ENGINE=InnoDB; \ No newline at end of file +) ENGINE=InnoDB; + +--Salary payment in tax module +CREATE TABLE IF NOT EXISTS `llx_salaries` ( + `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; \ No newline at end of file diff --git a/htdocs/langs/en_US/compta.lang b/htdocs/langs/en_US/compta.lang index 45158337f04..909a5cb39aa 100644 --- a/htdocs/langs/en_US/compta.lang +++ b/htdocs/langs/en_US/compta.lang @@ -70,6 +70,8 @@ ListOfPayments=List of payments ListOfCustomerPayments=List of customer payments ListOfSupplierPayments=List of supplier payments DatePayment=Payment date +Datesp=Date start period +Dateep=Date end period NewVATPayment=New VAT payment NewSalPayment=New Salary payment newLT2PaymentES=New IRPF payment From 74d3fdae151c80aa336b7f4209781661e6eb9b96 Mon Sep 17 00:00:00 2001 From: aspangaro Date: Fri, 7 Mar 2014 06:42:48 +0100 Subject: [PATCH 3/6] Update langs & fix period for salaries in tax module --- htdocs/compta/salaries/fiche.php | 18 ++++++++++++++++++ htdocs/langs/en_US/compta.lang | 5 +++-- htdocs/langs/fr_FR/compta.lang | 3 +++ 3 files changed, 24 insertions(+), 2 deletions(-) diff --git a/htdocs/compta/salaries/fiche.php b/htdocs/compta/salaries/fiche.php index 9ff49c2ad11..2cdca50a71f 100644 --- a/htdocs/compta/salaries/fiche.php +++ b/htdocs/compta/salaries/fiche.php @@ -22,6 +22,7 @@ */ require '../../main.inc.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; require_once DOL_DOCUMENT_ROOT.'/compta/salaries/class/salaries.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; @@ -155,6 +156,23 @@ if ($id) // 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 "
\n"; print ''; print ''; diff --git a/htdocs/langs/en_US/compta.lang b/htdocs/langs/en_US/compta.lang index 909a5cb39aa..ffa1db78b34 100644 --- a/htdocs/langs/en_US/compta.lang +++ b/htdocs/langs/en_US/compta.lang @@ -52,6 +52,7 @@ TaxAndDividendsArea=Tax, social contributions and dividends area SocialContribution=Social contribution SocialContributions=Social contributions MenuTaxAndDividends=Taxes and dividends +MenuSalaries=Salaries MenuSocialContributions=Social contributions MenuNewSocialContribution=New contribution NewSocialContribution=New social contribution @@ -70,8 +71,8 @@ ListOfPayments=List of payments ListOfCustomerPayments=List of customer payments ListOfSupplierPayments=List of supplier payments DatePayment=Payment date -Datesp=Date start period -Dateep=Date end period +DateStartPeriod=Date start period +DateEndPeriod=Date end period NewVATPayment=New VAT payment NewSalPayment=New Salary payment newLT2PaymentES=New IRPF payment diff --git a/htdocs/langs/fr_FR/compta.lang b/htdocs/langs/fr_FR/compta.lang index 99cc954ab6d..f3d23f5f437 100644 --- a/htdocs/langs/fr_FR/compta.lang +++ b/htdocs/langs/fr_FR/compta.lang @@ -51,6 +51,7 @@ TaxAndDividendsArea=Espace taxes, charges sociales et dividendes SocialContribution=Charge sociale SocialContributions=Charges sociales MenuTaxAndDividends=Taxes et charges +MenuSalaries=Salaires MenuSocialContributions=Charges sociales MenuNewSocialContribution=Nouvelle charge NewSocialContribution=Nouvelle charge sociale @@ -69,6 +70,8 @@ ListOfPayments=Liste des règlements ListOfCustomerPayments=Liste des règlements clients ListOfSupplierPayments=Liste des règlements fournisseurs DatePayment=Date de règlement +DateStartPeriod=Date de début période +DateEndPeriod=Date de fin période NewVATPayment=Nouveau règlement de TVA NewSalPayment=Nouveau règlement de salaire newLT2PaymentES=Nouveau règlement de IRPF From 61a57353000b3110942a00facfd8a60ffe54450e Mon Sep 17 00:00:00 2001 From: aspangaro Date: Mon, 10 Mar 2014 21:17:03 +0100 Subject: [PATCH 4/6] Rename "Sal" class into "Salaries" --- htdocs/compta/bank/account.php | 2 +- htdocs/compta/charges/index.php | 4 ++-- htdocs/compta/salaries/class/salaries.class.php | 12 ++++++------ htdocs/compta/salaries/fiche.php | 4 ++-- htdocs/compta/salaries/index.php | 2 +- 5 files changed, 12 insertions(+), 12 deletions(-) diff --git a/htdocs/compta/bank/account.php b/htdocs/compta/bank/account.php index 90a4e59fe40..1240e8f7655 100644 --- a/htdocs/compta/bank/account.php +++ b/htdocs/compta/bank/account.php @@ -142,7 +142,7 @@ $memberstatic=new Adherent($db); $paymentstatic=new Paiement($db); $paymentsupplierstatic=new PaiementFourn($db); $paymentvatstatic=new TVA($db); -$paymentsalstatic=new Sal($db); +$paymentsalstatic=new Salaries($db); $bankstatic=new Account($db); $banklinestatic=new AccountLine($db); diff --git a/htdocs/compta/charges/index.php b/htdocs/compta/charges/index.php index 1004f765fa8..1a2fa0cf0f6 100644 --- a/htdocs/compta/charges/index.php +++ b/htdocs/compta/charges/index.php @@ -61,7 +61,7 @@ if (! $sortorder) $sortorder="DESC"; $tva_static = new Tva($db); $socialcontrib=new ChargeSociales($db); $payment_sc_static=new PaymentSocialContribution($db); -$sal_static = new Sal($db); +$sal_static = new Salaries($db); llxHeader('',$langs->trans("TaxAndDividendsArea")); @@ -86,7 +86,7 @@ if (GETPOST("mode") != 'sconly') // Salaries if (empty($_GET["mode"]) || $_GET["mode"] != 'sconly') { - $sal = new Sal($db); + $sal = new Salaries($db); print_fiche_titre($langs->trans("SalPayments").($year?' ('.$langs->trans("Year").' '.$year.')':''), '', ''); diff --git a/htdocs/compta/salaries/class/salaries.class.php b/htdocs/compta/salaries/class/salaries.class.php index ccb89a1e4e5..51b2682918a 100644 --- a/htdocs/compta/salaries/class/salaries.class.php +++ b/htdocs/compta/salaries/class/salaries.class.php @@ -28,7 +28,7 @@ require_once DOL_DOCUMENT_ROOT .'/core/class/commonobject.class.php'; /** * Put here description of your class */ -class Sal extends CommonObject +class Salaries extends CommonObject { //public $element='salaries'; //!< Id that identify managed objects //public $table_element='salaries'; //!< Name of table without prefix where object is stored @@ -130,7 +130,7 @@ class Sal extends CommonObject // Appel des triggers include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; $interface=new Interfaces($this->db); - $result=$interface->run_triggers('SAL_CREATE',$this,$user,$langs,$conf); + $result=$interface->run_triggers('SALARIES_CREATE',$this,$user,$langs,$conf); if ($result < 0) { $error++; $this->errors=$interface->errors; } // Fin appel triggers @@ -205,7 +205,7 @@ class Sal extends CommonObject // Appel des triggers include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; $interface=new Interfaces($this->db); - $result=$interface->run_triggers('SAL_MODIFY',$this,$user,$langs,$conf); + $result=$interface->run_triggers('SALARIES_MODIFY',$this,$user,$langs,$conf); if ($result < 0) { $error++; $this->errors=$interface->errors; } // Fin appel triggers } @@ -313,7 +313,7 @@ class Sal extends CommonObject // Appel des triggers include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; $interface=new Interfaces($this->db); - $result=$interface->run_triggers('SAL_DELETE',$this,$user,$langs,$conf); + $result=$interface->run_triggers('SALARIES_DELETE',$this,$user,$langs,$conf); if ($result < 0) { $error++; $this->errors=$interface->errors; } // Fin appel triggers @@ -424,7 +424,7 @@ class Sal extends CommonObject // Appel des triggers include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; $interface=new Interfaces($this->db); - $result=$interface->run_triggers('SAL_ADDPAYMENT',$this,$user,$langs,$conf); + $result=$interface->run_triggers('SALARIES_ADDPAYMENT',$this,$user,$langs,$conf); if ($result < 0) { $error++; $this->errors=$interface->errors; } // Fin appel triggers @@ -478,7 +478,7 @@ class Sal extends CommonObject $linkaddedforthirdparty=array(); foreach ($this->amounts as $key => $value) { - $sal = new Sal ($this->db); + $sal = new Salaries ($this->db); $sal->fetch($key); $sal->fetch_user($this->fk_user); diff --git a/htdocs/compta/salaries/fiche.php b/htdocs/compta/salaries/fiche.php index 2cdca50a71f..04563f9aae6 100644 --- a/htdocs/compta/salaries/fiche.php +++ b/htdocs/compta/salaries/fiche.php @@ -38,7 +38,7 @@ $socid = isset($_GET["socid"])?$_GET["socid"]:''; if ($user->societe_id) $socid=$user->societe_id; $result = restrictedArea($user, 'tax', '', '', 'charges'); -$sal = new Sal($db); +$sal = new Salaries($db); // Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array $hookmanager->initHooks(array('taxsalcard')); @@ -144,7 +144,7 @@ $form = new Form($db); if ($id) { - $salpayment = new Sal($db); + $salpayment = new Salaries($db); $result = $salpayment->fetch($id); if ($result <= 0) { diff --git a/htdocs/compta/salaries/index.php b/htdocs/compta/salaries/index.php index a2e166529de..4d38643ec48 100644 --- a/htdocs/compta/salaries/index.php +++ b/htdocs/compta/salaries/index.php @@ -39,7 +39,7 @@ $result = restrictedArea($user, 'tax', '', '', 'charges'); llxHeader(); -$salstatic = new Sal($db); +$salstatic = new Salaries($db); $userstatic = new User($db); From 12ffb19cec09f9a6b907e9341c490982550206b7 Mon Sep 17 00:00:00 2001 From: aspangaro Date: Tue, 11 Mar 2014 06:26:18 +0100 Subject: [PATCH 5/6] Use more explicit name for class and functions --- htdocs/compta/bank/account.php | 12 ++--- htdocs/compta/charges/index.php | 12 ++--- ...ries.class.php => paymentsalary.class.php} | 48 +++++++++---------- htdocs/compta/salaries/fiche.php | 14 +++--- htdocs/compta/salaries/index.php | 8 ++-- .../install/mysql/migration/3.5.0-3.6.0.sql | 2 +- ...lx_salaries.sql => llx_payment_salary.sql} | 2 +- htdocs/langs/en_US/compta.lang | 12 ++--- htdocs/langs/fr_FR/compta.lang | 13 ++--- 9 files changed, 62 insertions(+), 61 deletions(-) rename htdocs/compta/salaries/class/{salaries.class.php => paymentsalary.class.php} (90%) rename htdocs/install/mysql/tables/{llx_salaries.sql => llx_payment_salary.sql} (98%) diff --git a/htdocs/compta/bank/account.php b/htdocs/compta/bank/account.php index 1240e8f7655..c52ee7a0546 100644 --- a/htdocs/compta/bank/account.php +++ b/htdocs/compta/bank/account.php @@ -36,7 +36,7 @@ require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/sociales/class/chargesociales.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/tva/class/tva.class.php'; -require_once DOL_DOCUMENT_ROOT.'/compta/salaries/class/salaries.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.'/compta/bank/class/account.class.php'; @@ -142,7 +142,7 @@ $memberstatic=new Adherent($db); $paymentstatic=new Paiement($db); $paymentsupplierstatic=new PaiementFourn($db); $paymentvatstatic=new TVA($db); -$paymentsalstatic=new Salaries($db); +$paymentsalstatic=new PaymentSalary($db); $bankstatic=new Account($db); $banklinestatic=new AccountLine($db); @@ -466,9 +466,9 @@ if ($id > 0 || ! empty($ref)) // 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"; - // Salaries - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."bank_url as bu3 ON bu3.fk_bank = b.rowid AND bu3.type='payment_sal'"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."salaries as sal ON bu3.url_id = sal.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)) { @@ -586,7 +586,7 @@ if ($id > 0 || ! empty($ref)) $paymentvatstatic->ref=$links[$key]['url_id']; print ' '.$paymentvatstatic->getNomUrl(2); } - elseif ($links[$key]['type']=='payment_sal') + elseif ($links[$key]['type']=='payment_salary') { $paymentsalstatic->id=$links[$key]['url_id']; $paymentsalstatic->ref=$links[$key]['url_id']; diff --git a/htdocs/compta/charges/index.php b/htdocs/compta/charges/index.php index 1a2fa0cf0f6..aa8d26c32f4 100644 --- a/htdocs/compta/charges/index.php +++ b/htdocs/compta/charges/index.php @@ -28,7 +28,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.'/compta/salaries/class/salaries.class.php'; +require_once DOL_DOCUMENT_ROOT.'/compta/salaries/class/paymentsalary.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; $langs->load("compta"); @@ -61,7 +61,7 @@ if (! $sortorder) $sortorder="DESC"; $tva_static = new Tva($db); $socialcontrib=new ChargeSociales($db); $payment_sc_static=new PaymentSocialContribution($db); -$sal_static = new Salaries($db); +$sal_static = new PaymentSalary($db); llxHeader('',$langs->trans("TaxAndDividendsArea")); @@ -83,15 +83,15 @@ if (GETPOST("mode") != 'sconly') print "
"; } -// Salaries +// Payment Salary if (empty($_GET["mode"]) || $_GET["mode"] != 'sconly') { - $sal = new Salaries($db); + $sal = new PaymentSalary($db); - print_fiche_titre($langs->trans("SalPayments").($year?' ('.$langs->trans("Year").' '.$year.')':''), '', ''); + 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."salaries as s"; + $sql.= " FROM ".MAIN_DB_PREFIX."payment_salary as s"; $sql.= " WHERE s.entity = ".$conf->entity; if ($year > 0) { diff --git a/htdocs/compta/salaries/class/salaries.class.php b/htdocs/compta/salaries/class/paymentsalary.class.php similarity index 90% rename from htdocs/compta/salaries/class/salaries.class.php rename to htdocs/compta/salaries/class/paymentsalary.class.php index 51b2682918a..3e3574d194b 100644 --- a/htdocs/compta/salaries/class/salaries.class.php +++ b/htdocs/compta/salaries/class/paymentsalary.class.php @@ -16,9 +16,9 @@ */ /** - * \file htdocs/compta/salaries/class/salaries.class.php + * \file htdocs/compta/salaries/class/paymentsalary.class.php * \ingroup tax - * \brief Class for tax module salaries + * \brief Class for tax module salary payment */ // Put here all includes required by your class file @@ -28,10 +28,10 @@ require_once DOL_DOCUMENT_ROOT .'/core/class/commonobject.class.php'; /** * Put here description of your class */ -class Salaries extends CommonObject +class PaymentSalary extends CommonObject { - //public $element='salaries'; //!< Id that identify managed objects - //public $table_element='salaries'; //!< Name of table without prefix where object is stored + //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; @@ -59,8 +59,8 @@ class Salaries extends CommonObject function __construct($db) { $this->db = $db; - $this->element = 'salaries'; - $this->table_element = 'salaries'; + $this->element = 'payment_salary'; + $this->table_element = 'payment_salary'; return 1; } @@ -90,7 +90,7 @@ class Salaries extends CommonObject // Put here code to add control on parameters values // Insert request - $sql = "INSERT INTO ".MAIN_DB_PREFIX."salaries("; + $sql = "INSERT INTO ".MAIN_DB_PREFIX."payment_salary("; $sql.= "tms,"; $sql.= "fk_user,"; $sql.= "datep,"; @@ -125,12 +125,12 @@ class Salaries extends CommonObject $resql=$this->db->query($sql); if ($resql) { - $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."salaries"); + $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('SALARIES_CREATE',$this,$user,$langs,$conf); + $result=$interface->run_triggers('PAYMENT_SALARY_CREATE',$this,$user,$langs,$conf); if ($result < 0) { $error++; $this->errors=$interface->errors; } // Fin appel triggers @@ -174,7 +174,7 @@ class Salaries extends CommonObject } // Update request - $sql = "UPDATE ".MAIN_DB_PREFIX."salaries SET"; + $sql = "UPDATE ".MAIN_DB_PREFIX."payment_salary SET"; $sql.= " tms=".$this->db->idate($this->tms).","; $sql.= " fk_user='".$this->fk_user."',"; @@ -205,7 +205,7 @@ class Salaries extends CommonObject // Appel des triggers include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; $interface=new Interfaces($this->db); - $result=$interface->run_triggers('SALARIES_MODIFY',$this,$user,$langs,$conf); + $result=$interface->run_triggers('PAYMENT_SALARY_MODIFY',$this,$user,$langs,$conf); if ($result < 0) { $error++; $this->errors=$interface->errors; } // Fin appel triggers } @@ -243,7 +243,7 @@ class Salaries extends CommonObject $sql.= " b.fk_type,"; $sql.= " b.rappro"; - $sql.= " FROM ".MAIN_DB_PREFIX."salaries as s"; + $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; @@ -298,7 +298,7 @@ class Salaries extends CommonObject $error=0; - $sql = "DELETE FROM ".MAIN_DB_PREFIX."salaries"; + $sql = "DELETE FROM ".MAIN_DB_PREFIX."payment_salary"; $sql.= " WHERE rowid=".$this->id; dol_syslog(get_class($this)."::delete sql=".$sql); @@ -313,7 +313,7 @@ class Salaries extends CommonObject // Appel des triggers include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; $interface=new Interfaces($this->db); - $result=$interface->run_triggers('SALARIES_DELETE',$this,$user,$langs,$conf); + $result=$interface->run_triggers('PAYMENT_SALARY_DELETE',$this,$user,$langs,$conf); if ($result < 0) { $error++; $this->errors=$interface->errors; } // Fin appel triggers @@ -389,7 +389,7 @@ class Salaries extends CommonObject } // Insertion dans table des paiement salaires - $sql = "INSERT INTO ".MAIN_DB_PREFIX."salaries (fk_user"; + $sql = "INSERT INTO ".MAIN_DB_PREFIX."payment_salary (fk_user"; $sql.= ", datep"; $sql.= ", datev"; $sql.= ", amount"; @@ -419,12 +419,12 @@ class Salaries extends CommonObject $result = $this->db->query($sql); if ($result) { - $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."salaries"); // TODO devrait s'appeler payment_sal + $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('SALARIES_ADDPAYMENT',$this,$user,$langs,$conf); + $result=$interface->run_triggers('PAYMENT_SALARY_ADDPAYMENT',$this,$user,$langs,$conf); if ($result < 0) { $error++; $this->errors=$interface->errors; } // Fin appel triggers @@ -441,7 +441,7 @@ class Salaries extends CommonObject if ($result <= 0) dol_print_error($this->db); // Insert payment into llx_bank - // Add link 'payment_sal' in bank_url between payment and bank transaction + // Add link 'payment_salary' in bank_url between payment and bank transaction $bank_line_id = $acc->addline( $this->datep, $this->paymenttype, @@ -464,10 +464,10 @@ class Salaries extends CommonObject $ok=0; } - // Add link 'payment_sal' in bank_url between payment and bank transaction + // 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, "(SalPayment)", "payment_sal"); + $result=$acc->add_url_line($bank_line_id, $this->id, $url, "(SalaryPayment)", "payment_salary"); if ($result <= 0) { $this->error=$acc->error; @@ -478,7 +478,7 @@ class Salaries extends CommonObject $linkaddedforthirdparty=array(); foreach ($this->amounts as $key => $value) { - $sal = new Salaries ($this->db); + $sal = new PaymentSalary ($this->db); $sal->fetch($key); $sal->fetch_user($this->fk_user); @@ -534,7 +534,7 @@ class Salaries extends CommonObject */ function update_fk_bank($id_bank) { - $sql = 'UPDATE '.MAIN_DB_PREFIX.'salaries SET 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) @@ -566,7 +566,7 @@ class Salaries extends CommonObject $lienfin=''; $picto='payment'; - $label=$langs->trans("ShowSalPayment").': '.$this->ref; + $label=$langs->trans("ShowSalaryPayment").': '.$this->ref; if ($withpicto) $result.=($lien.img_object($label,$picto).$lienfin); if ($withpicto && $withpicto != 2) $result.=' '; diff --git a/htdocs/compta/salaries/fiche.php b/htdocs/compta/salaries/fiche.php index 04563f9aae6..636dc8f5002 100644 --- a/htdocs/compta/salaries/fiche.php +++ b/htdocs/compta/salaries/fiche.php @@ -23,7 +23,7 @@ require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; -require_once DOL_DOCUMENT_ROOT.'/compta/salaries/class/salaries.class.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"); @@ -38,10 +38,10 @@ $socid = isset($_GET["socid"])?$_GET["socid"]:''; if ($user->societe_id) $socid=$user->societe_id; $result = restrictedArea($user, 'tax', '', '', 'charges'); -$sal = new Salaries($db); +$sal = new PaymentSalary($db); // Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array -$hookmanager->initHooks(array('taxsalcard')); +$hookmanager->initHooks(array('taxsalarycard')); @@ -144,7 +144,7 @@ $form = new Form($db); if ($id) { - $salpayment = new Salaries($db); + $salpayment = new PaymentSalary($db); $result = $salpayment->fetch($id); if ($result <= 0) { @@ -177,7 +177,7 @@ if ($action == 'create') print ''; print ''; - print_fiche_titre($langs->trans("NewSalPayment")); + print_fiche_titre($langs->trans("NewSalaryPayment")); print ''; @@ -196,7 +196,7 @@ if ($action == 'create') print ''; // Label - print ''; + print ''; print ""; print '
'.$langs->trans("Label").'trans("SalPayment")).'">
'.$langs->trans("Label").'trans("SalaryPayment")).'">
'.$langs->trans("DateStartPeriod").''; @@ -252,7 +252,7 @@ if ($id) $head[$h][2] = 'card'; $h++; - dol_fiche_head($head, 'card', $langs->trans("SalPayment"), 0, 'payment'); + dol_fiche_head($head, 'card', $langs->trans("SalaryPayment"), 0, 'payment'); print ''; diff --git a/htdocs/compta/salaries/index.php b/htdocs/compta/salaries/index.php index 4d38643ec48..a7d1b84987d 100644 --- a/htdocs/compta/salaries/index.php +++ b/htdocs/compta/salaries/index.php @@ -22,7 +22,7 @@ */ require '../../main.inc.php'; -require_once DOL_DOCUMENT_ROOT.'/compta/salaries/class/salaries.class.php'; +require_once DOL_DOCUMENT_ROOT.'/compta/salaries/class/paymentsalary.class.php'; $langs->load("compta"); @@ -39,14 +39,14 @@ $result = restrictedArea($user, 'tax', '', '', 'charges'); llxHeader(); -$salstatic = new Salaries($db); +$salstatic = new PaymentSalary($db); $userstatic = new User($db); -print_fiche_titre($langs->trans("SalPayments")); +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."salaries as s, ".MAIN_DB_PREFIX."user as u"; +$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"; diff --git a/htdocs/install/mysql/migration/3.5.0-3.6.0.sql b/htdocs/install/mysql/migration/3.5.0-3.6.0.sql index 584b994470e..bd37d953875 100644 --- a/htdocs/install/mysql/migration/3.5.0-3.6.0.sql +++ b/htdocs/install/mysql/migration/3.5.0-3.6.0.sql @@ -1039,7 +1039,7 @@ CREATE TABLE IF NOT EXISTS `llx_expeditiondet_batch` ( ) ENGINE=InnoDB; --Salary payment in tax module -CREATE TABLE IF NOT EXISTS `llx_salaries` ( +CREATE TABLE IF NOT EXISTS `llx_payment_salary` ( `rowid` integer AUTO_INCREMENT PRIMARY KEY, `tms` timestamp, `fk_user` integer NOT NULL, diff --git a/htdocs/install/mysql/tables/llx_salaries.sql b/htdocs/install/mysql/tables/llx_payment_salary.sql similarity index 98% rename from htdocs/install/mysql/tables/llx_salaries.sql rename to htdocs/install/mysql/tables/llx_payment_salary.sql index 398086274f1..513eed2b943 100644 --- a/htdocs/install/mysql/tables/llx_salaries.sql +++ b/htdocs/install/mysql/tables/llx_payment_salary.sql @@ -16,7 +16,7 @@ -- -- =================================================================== -create table llx_salaries +create table llx_payment_salary ( rowid integer AUTO_INCREMENT PRIMARY KEY, tms timestamp, diff --git a/htdocs/langs/en_US/compta.lang b/htdocs/langs/en_US/compta.lang index ffa1db78b34..03b3f6cbc39 100644 --- a/htdocs/langs/en_US/compta.lang +++ b/htdocs/langs/en_US/compta.lang @@ -41,7 +41,7 @@ VATToCollect=VAT purchases VATSummary=VAT Balance LT2SummaryES=IRPF Balance VATPaid=VAT paid -SalPaid=Salary paid +SalaryPaid=Salary paid LT2PaidES=IRPF Paid LT2CustomerES=IRPF sales LT2SupplierES=IRPF purchases @@ -65,7 +65,7 @@ PaymentCustomerInvoice=Customer invoice payment PaymentSupplierInvoice=Supplier invoice payment PaymentSocialContribution=Social contribution payment PaymentVat=VAT payment -PaymentSal=Salary payment +PaymentSalary=Salary payment ListPayment=List of payments ListOfPayments=List of payments ListOfCustomerPayments=List of customer payments @@ -74,17 +74,17 @@ DatePayment=Payment date DateStartPeriod=Date start period DateEndPeriod=Date end period NewVATPayment=New VAT payment -NewSalPayment=New Salary payment +NewSalaryPayment=New salary payment newLT2PaymentES=New IRPF payment LT2PaymentES=IRPF Payment LT2PaymentsES=IRPF Payments VATPayment=VAT Payment VATPayments=VAT Payments -SalPayment=Salary payment -SalPayments=Saalries payments +SalaryPayment=Salary payment +SalariesPayments=Salaries payments SocialContributionsPayments=Social contributions payments ShowVatPayment=Show VAT payment -ShowSalPayment=Show salary payment +ShowSalaryPayment=Show salary payment TotalToPay=Total to pay TotalVATReceived=Total VAT received CustomerAccountancyCode=Customer accountancy code diff --git a/htdocs/langs/fr_FR/compta.lang b/htdocs/langs/fr_FR/compta.lang index f3d23f5f437..dbc1d2520c8 100644 --- a/htdocs/langs/fr_FR/compta.lang +++ b/htdocs/langs/fr_FR/compta.lang @@ -41,6 +41,7 @@ VATToCollect=TVA achats VATSummary=Balance de TVA LT2SummaryES=Balance de IRPF VATPaid=TVA payée +SalaryPaid=Salaire payé LT2PaidES=IRPF Payée LT2CustomerES=IRPF ventes LT2SupplierES=IRPF achats @@ -64,7 +65,7 @@ PaymentCustomerInvoice=Règlement facture client PaymentSupplierInvoice=Règlement facture fournisseur PaymentSocialContribution=Règlement charge sociale PaymentVat=Règlement TVA -PaymentSal=Règlement salaire +PaymentSalary=Règlement salaire ListPayment=Liste des règlements ListOfPayments=Liste des règlements ListOfCustomerPayments=Liste des règlements clients @@ -73,17 +74,17 @@ DatePayment=Date de règlement DateStartPeriod=Date de début période DateEndPeriod=Date de fin période NewVATPayment=Nouveau règlement de TVA -NewSalPayment=Nouveau règlement de salaire +NewSalaryPayment=Nouveau règlement de salaire newLT2PaymentES=Nouveau règlement de IRPF LT2PaymentES=Règlement IRPF LT2PaymentsES=Règlements IRPF VATPayment=Règlement TVA VATPayments=Règlements TVA -SalPayment=Règlement salaire -SalPayments=Règlements des salaires +SalaryPayment=Règlement salaire +SalariesPayments=Règlements des salaires SocialContributionsPayments=Règlements charges sociales -ShowVatPayment=Affiche paiement TVA -ShowSalPayment=Affiche paiement salaire +ShowVatPayment=Afficher paiement TVA +ShowSalaryPayment=Afficher paiement salaire TotalToPay=Total à payer TotalVATReceived=Total TVA perçue CustomerAccountancyCode=Compte comptable client From 99b2dfda77721ad57a12cc5b068e911f2c11bb9d Mon Sep 17 00:00:00 2001 From: aspangaro Date: Tue, 11 Mar 2014 10:52:49 +0100 Subject: [PATCH 6/6] Correct Travis Error --- htdocs/compta/salaries/class/paymentsalary.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/compta/salaries/class/paymentsalary.class.php b/htdocs/compta/salaries/class/paymentsalary.class.php index 3e3574d194b..2aff98a2322 100644 --- a/htdocs/compta/salaries/class/paymentsalary.class.php +++ b/htdocs/compta/salaries/class/paymentsalary.class.php @@ -478,7 +478,7 @@ class PaymentSalary extends CommonObject $linkaddedforthirdparty=array(); foreach ($this->amounts as $key => $value) { - $sal = new PaymentSalary ($this->db); + $sal = new PaymentSalary($this->db); $sal->fetch($key); $sal->fetch_user($this->fk_user);