Better management of social contribution
New: Can edit label and date for period even if payed
This commit is contained in:
parent
3b811c1b72
commit
d9183a681d
@ -29,7 +29,7 @@ require_once(DOL_DOCUMENT_ROOT."/commonobject.class.php");
|
||||
|
||||
/** \class ChargeSociales
|
||||
\brief Classe permettant la gestion des paiements des charges
|
||||
La tva collectée n'est calculée que sur les factures payées.
|
||||
La tva collect<EFBFBD>e n'est calcul<EFBFBD>e que sur les factures pay<EFBFBD>es.
|
||||
*/
|
||||
class ChargeSociales extends CommonObject
|
||||
{
|
||||
@ -37,7 +37,7 @@ class ChargeSociales extends CommonObject
|
||||
var $error;
|
||||
var $element='rowid';
|
||||
var $table_element='chargesociales';
|
||||
|
||||
|
||||
var $id;
|
||||
var $date_ech;
|
||||
var $lib;
|
||||
@ -77,6 +77,7 @@ class ChargeSociales extends CommonObject
|
||||
$obj = $this->db->fetch_object($resql);
|
||||
|
||||
$this->id = $obj->rowid;
|
||||
$this->ref = $obj->rowid;
|
||||
$this->date_ech = $obj->date_ech;
|
||||
$this->lib = $obj->lib;
|
||||
$this->type = $obj->fk_type;
|
||||
@ -102,30 +103,30 @@ class ChargeSociales extends CommonObject
|
||||
|
||||
|
||||
/**
|
||||
* \brief Crée une charge sociale
|
||||
* \param user Utilisateur qui crée
|
||||
* \return int <0 si KO, id charge créée si OK
|
||||
* \brief Create a social contribution in database
|
||||
* \param user User making creation
|
||||
* \return int <0 if KO, id if OK
|
||||
*/
|
||||
function create($user)
|
||||
{
|
||||
// Nettoyage parametres
|
||||
$newamount=price2num($this->amount,'MT');
|
||||
|
||||
|
||||
// Validation parametres
|
||||
if (! $newamount > 0)
|
||||
{
|
||||
$this->error="ErrorBadParameter";
|
||||
return -2;
|
||||
}
|
||||
|
||||
|
||||
$this->db->begin();
|
||||
|
||||
|
||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."chargesociales (fk_type, libelle, date_ech, periode, amount)";
|
||||
$sql.= " VALUES (".$this->type.",'".addslashes($this->lib)."',";
|
||||
$sql.= " '".$this->db->idate($this->date_ech)."','".$this->periode."',";
|
||||
$sql.= " '".$this->db->idate($this->date_ech)."','".$this->db->idate($this->periode)."',";
|
||||
$sql.= " ".price2num($newamount);
|
||||
$sql.= ")";
|
||||
|
||||
|
||||
dol_syslog("ChargesSociales::create sql=".$sql);
|
||||
$resql=$this->db->query($sql);
|
||||
if ($resql)
|
||||
@ -142,12 +143,12 @@ class ChargeSociales extends CommonObject
|
||||
$this->db->rollback();
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* \brief Efface un charge sociale
|
||||
* \param user Utilisateur qui crée le paiement
|
||||
* \param user Utilisateur qui cr<EFBFBD>e le paiement
|
||||
* \return int <0 si erreur, >0 si ok
|
||||
*/
|
||||
function delete($user)
|
||||
@ -166,7 +167,7 @@ class ChargeSociales extends CommonObject
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* \brief Met a jour une charge sociale
|
||||
@ -176,13 +177,13 @@ class ChargeSociales extends CommonObject
|
||||
function update($user)
|
||||
{
|
||||
$this->db->begin();
|
||||
|
||||
|
||||
$sql = "UPDATE ".MAIN_DB_PREFIX."chargesociales";
|
||||
$sql.= " SET libelle='".addslashes($this->lib)."',";
|
||||
$sql.= " date_ech='".$this->db->idate($this->date_ech)."',";
|
||||
$sql.= " periode='".$this->periode."'";
|
||||
$sql.= " periode='".$this->db->idate($this->periode)."'";
|
||||
$sql.= " WHERE rowid=".$this->id;
|
||||
|
||||
|
||||
dol_syslog("ChargesSociales::update sql=".$sql);
|
||||
$resql=$this->db->query($sql);
|
||||
if ($resql)
|
||||
@ -196,9 +197,9 @@ class ChargeSociales extends CommonObject
|
||||
$this->db->rollback();
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
function solde($year = 0)
|
||||
{
|
||||
$sql = "SELECT sum(f.amount) as amount";
|
||||
@ -227,7 +228,7 @@ class ChargeSociales extends CommonObject
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Tag la charge comme payée complètement
|
||||
* \brief Tag la charge comme pay<EFBFBD>e compl<EFBFBD>tement
|
||||
* \param rowid id de la ligne a modifier
|
||||
*/
|
||||
function set_payed($rowid)
|
||||
@ -237,8 +238,8 @@ class ChargeSociales extends CommonObject
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Retourne le libellé du statut d'une charge (impayé, payée)
|
||||
* \param mode 0=libellé long, 1=libellé court, 2=Picto + Libellé court, 3=Picto, 4=Picto + Libellé long
|
||||
* \brief Retourne le libell<EFBFBD> du statut d'une charge (impay<EFBFBD>, pay<EFBFBD>e)
|
||||
* \param mode 0=libell<EFBFBD> long, 1=libell<EFBFBD> court, 2=Picto + Libell<EFBFBD> court, 3=Picto, 4=Picto + Libell<EFBFBD> long
|
||||
* \return string Libelle
|
||||
*/
|
||||
function getLibStatut($mode=0)
|
||||
@ -247,10 +248,10 @@ class ChargeSociales extends CommonObject
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Renvoi le libellé d'un statut donné
|
||||
* \brief Renvoi le libell<EFBFBD> d'un statut donn<EFBFBD>
|
||||
* \param statut Id statut
|
||||
* \param mode 0=libellé long, 1=libellé court, 2=Picto + Libellé court, 3=Picto, 4=Picto + Libellé long, 5=Libellé court + Picto
|
||||
* \return string Libellé du statut
|
||||
* \param mode 0=libell<EFBFBD> long, 1=libell<EFBFBD> court, 2=Picto + Libell<EFBFBD> court, 3=Picto, 4=Picto + Libell<EFBFBD> long, 5=Libell<EFBFBD> court + Picto
|
||||
* \return string Libell<EFBFBD> du statut
|
||||
*/
|
||||
function LibStatut($statut,$mode=0)
|
||||
{
|
||||
@ -301,9 +302,9 @@ class ChargeSociales extends CommonObject
|
||||
function getNomUrl($withpicto=0,$maxlen=0)
|
||||
{
|
||||
global $langs;
|
||||
|
||||
|
||||
$result='';
|
||||
|
||||
|
||||
$lien = '<a href="'.DOL_URL_ROOT.'/compta/sociales/charges.php?id='.$this->id.'">';
|
||||
$lienfin='</a>';
|
||||
|
||||
@ -348,7 +349,7 @@ class ChargeSociales extends CommonObject
|
||||
class PaiementCharge
|
||||
{
|
||||
var $db;
|
||||
|
||||
|
||||
var $id;
|
||||
var $chid;
|
||||
var $paiementtype;
|
||||
@ -357,7 +358,7 @@ class PaiementCharge
|
||||
var $num_paiement;
|
||||
var $note;
|
||||
|
||||
|
||||
|
||||
function PaiementCharge($DB)
|
||||
{
|
||||
$this->db = $DB;
|
||||
@ -366,8 +367,8 @@ class PaiementCharge
|
||||
|
||||
/**
|
||||
* \brief Creation d'un paiement de charge sociale dans la base
|
||||
* \param user Utilisateur qui crée le paiement
|
||||
* \return int <0 si KO, id du paiement crée si OK
|
||||
* \param user Utilisateur qui cr<EFBFBD>e le paiement
|
||||
* \return int <0 si KO, id du paiement cr<EFBFBD>e si OK
|
||||
*/
|
||||
function create($user)
|
||||
{
|
||||
@ -380,9 +381,9 @@ class PaiementCharge
|
||||
$this->error='ErrorBadValueForParameters';
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
$this->db->begin();
|
||||
|
||||
|
||||
$total=0;
|
||||
foreach ($this->amounts as $key => $value)
|
||||
{
|
||||
@ -393,7 +394,7 @@ class PaiementCharge
|
||||
|
||||
if ($total > 0)
|
||||
{
|
||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."paiementcharge (fk_charge, datec, datep, amount,";
|
||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."paiementcharge (fk_charge, datec, datep, amount,";
|
||||
$sql.= " fk_typepaiement, num_paiement, note, fk_user_creat, fk_bank)";
|
||||
$sql.= " VALUES ($this->chid, ".$this->db->idate(mktime()).", ";
|
||||
$sql.= $this->db->idate($this->datepaye).", ";
|
||||
@ -429,18 +430,18 @@ class PaiementCharge
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Mise a jour du lien entre le paiement de charge et la ligne dans llx_bank générée
|
||||
* \brief Mise a jour du lien entre le paiement de charge et la ligne dans llx_bank g<EFBFBD>n<EFBFBD>r<EFBFBD>e
|
||||
* \param id_bank Id de la banque
|
||||
* \return int >0 si OK, <=0 si KO
|
||||
*/
|
||||
function update_fk_bank($id_bank)
|
||||
{
|
||||
$sql = "UPDATE llx_paiementcharge set fk_bank = ".$id_bank." where rowid = ".$this->id;
|
||||
|
||||
|
||||
dol_syslog("PaiementCharge::update_fk_bank sql=".$sql);
|
||||
$result = $this->db->query($sql);
|
||||
if ($result)
|
||||
{
|
||||
if ($result)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
|
||||
@ -27,6 +27,7 @@
|
||||
|
||||
require("./pre.inc.php");
|
||||
require_once(DOL_DOCUMENT_ROOT."/compta/tva/tva.class.php");
|
||||
require_once(DOL_DOCUMENT_ROOT."/chargesociales.class.php");
|
||||
|
||||
$langs->load("compta");
|
||||
|
||||
@ -48,6 +49,7 @@ llxHeader('',$langs->trans("TaxAndDividendsArea"));
|
||||
|
||||
print_fiche_titre($langs->trans("TaxAndDividendsArea"),($year?"<a href='index.php?year=".($year-1)."'>".img_previous()."</a> ".$langs->trans("Year")." $year <a href='index.php?year=".($year+1)."'>".img_next()."</a>":""));
|
||||
|
||||
print $langs->trans("DescTaxAndDividendsArea").'<br>';
|
||||
print "<br>";
|
||||
|
||||
|
||||
@ -56,29 +58,31 @@ print "<br>";
|
||||
print_titre($langs->trans("SocialContributions"));
|
||||
print '<table class="noborder" width="100%">';
|
||||
print "<tr class=\"liste_titre\">";
|
||||
print '<td width="120">'.$langs->trans("PeriodEndDate").'</td>';
|
||||
print '<td>'.$langs->trans("Label").'</td>';
|
||||
print "<td>".$langs->trans("Type")."</td>";
|
||||
print "<td align=\"right\">".$langs->trans("Nb")."</td>";
|
||||
print "<td align=\"right\">".$langs->trans("Amount")."</td>";
|
||||
print "<td align=\"right\">".$langs->trans("NbOfPayments")."</td>";
|
||||
print "<td align=\"right\">".$langs->trans("AlreadyPayed")."</td>";
|
||||
print "</tr>\n";
|
||||
|
||||
$sql = "SELECT c.id, c.libelle as lib, s.fk_type as type,";
|
||||
$sql.=" count(s.rowid) as nb, sum(s.amount) as total, sum(pc.amount) as totalpaye";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."c_chargesociales as c";
|
||||
$sql.= ", ".MAIN_DB_PREFIX."chargesociales as s";
|
||||
$sql = "SELECT c.id, c.libelle as lib, s.rowid, s.libelle, s.fk_type as type, s.periode, s.date_ech,";
|
||||
$sql.= " count(s.rowid) as nb, sum(s.amount) as total, sum(pc.amount) as totalpaye";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."c_chargesociales as c,";
|
||||
$sql.= " ".MAIN_DB_PREFIX."chargesociales as s";
|
||||
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."paiementcharge as pc ON pc.fk_charge = s.rowid";
|
||||
$sql.= " WHERE s.fk_type = c.id";
|
||||
$sql.= " AND s.entity = ".$conf->entity;
|
||||
if ($year > 0)
|
||||
{
|
||||
$sql .= " AND (";
|
||||
// Si period renseigné on l'utilise comme critere de date, sinon on prend date échéance,
|
||||
// ceci afin d'etre compatible avec les cas ou la période n'etait pas obligatoire
|
||||
// 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 .= " (s.periode is not null and date_format(s.periode, '%Y') = $year) ";
|
||||
$sql .= "or (s.periode is null and date_format(s.date_ech, '%Y') = $year)";
|
||||
$sql .= ")";
|
||||
}
|
||||
$sql.= " GROUP BY c.id, c.libelle, s.fk_type";
|
||||
$sql.= " GROUP BY c.id, c.libelle, s.rowid, s.fk_type, s.periode, s.date_ech";
|
||||
$sql.= " ORDER BY c.libelle ASC";
|
||||
|
||||
dol_syslog("compta/charges/index.php: select payment sql=".$sql);
|
||||
@ -88,6 +92,7 @@ if ($resql)
|
||||
$num = $db->num_rows($resql);
|
||||
$i = 0;
|
||||
$total = 0;
|
||||
$totalnb = 0;
|
||||
$totalpaye = 0;
|
||||
$var=true;
|
||||
|
||||
@ -96,17 +101,28 @@ if ($resql)
|
||||
$obj = $db->fetch_object($resql);
|
||||
$var = !$var;
|
||||
print "<tr $bc[$var]>";
|
||||
$date=$obj->periode;
|
||||
if (empty($date)) $date=$obj->date_ech;
|
||||
print '<td>'.dol_print_date($date,'day').'</td>';
|
||||
print '<td align="left">';
|
||||
$socialcontrib=new ChargeSociales($db);
|
||||
$socialcontrib->id=$obj->rowid;
|
||||
$socialcontrib->lib=$obj->libelle;
|
||||
print $socialcontrib->getNomUrl(1,'16');
|
||||
print '</td>';
|
||||
print '<td><a href="../sociales/index.php?filtre=s.fk_type:'.$obj->type.'">'.$obj->lib.'</a></td>';
|
||||
print '<td align="right">'.$obj->nb.'</td>';
|
||||
print '<td align="right">'.price($obj->total).'</td>';
|
||||
print '<td align="right">'.$obj->nb.'</td>';
|
||||
print '<td align="right">'.price($obj->totalpaye).'</td>';
|
||||
print '</tr>';
|
||||
$total = $total + $obj->total;
|
||||
$totalnb = $totalnb + $obj->nb;
|
||||
$totalpaye = $totalpaye + $obj->totalpaye;
|
||||
$i++;
|
||||
}
|
||||
print '<tr class="liste_total"><td align="right" colspan="2">'.$langs->trans("Total").'</td>';
|
||||
print '<tr class="liste_total"><td align="right" colspan="3">'.$langs->trans("Total").'</td>';
|
||||
print '<td align="right"><b>'.price($total)."</b></td>";
|
||||
print '<td align="right"><b>'.$totalnb.'</b></td>';
|
||||
print '<td align="right"><b>'.price($totalpaye)."</b></td>";
|
||||
print "</tr>";
|
||||
}
|
||||
@ -132,8 +148,8 @@ if (empty($_GET["mode"]) || $_GET["mode"] != 'sconly')
|
||||
$sql.= " WHERE f.entity = ".$conf->entity;
|
||||
if ($year > 0)
|
||||
{
|
||||
// Si period renseigné on l'utilise comme critere de date, sinon on prend date échéance,
|
||||
// ceci afin d'etre compatible avec les cas ou la période n'etait pas obligatoire
|
||||
// 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 date_format(f.datev, '%Y') = ".$year;
|
||||
}
|
||||
$sql.= " ORDER BY dm DESC";
|
||||
@ -146,9 +162,11 @@ if (empty($_GET["mode"]) || $_GET["mode"] != 'sconly')
|
||||
$total = 0 ;
|
||||
print '<table class="noborder" width="100%">';
|
||||
print '<tr class="liste_titre">';
|
||||
print '<td nowrap>'.$langs->trans("Date").'</td>';
|
||||
print '<td width="120" nowrap="nowrap">'.$langs->trans("PeriodEndDate").'</td>';
|
||||
print "<td>".$langs->trans("Label")."</td>";
|
||||
print '<td align="right">'.$langs->trans("Amount")."</td>";
|
||||
print '<td align="center">'.$langs->trans("DatePayment")."</td>";
|
||||
print "<td align=\"right\">".$langs->trans("AlreadyPayed")."</td>";
|
||||
print "</tr>\n";
|
||||
$var=1;
|
||||
while ($i < $num)
|
||||
@ -156,17 +174,22 @@ if (empty($_GET["mode"]) || $_GET["mode"] != 'sconly')
|
||||
$obj = $db->fetch_object($result);
|
||||
$var=!$var;
|
||||
print "<tr $bc[$var]>";
|
||||
print '<td align="left">'.dol_print_date($obj->dm,'day')."</td>\n";
|
||||
print '<td align="left">'.dol_print_date($obj->dm,'day').' ? </td>'."\n";
|
||||
print "<td>".$obj->label."</td>\n";
|
||||
$total = $total + $obj->amount;
|
||||
|
||||
print "<td align=\"right\">".price($obj->amount)."</td>";
|
||||
print '<td align="center">'.dol_print_date($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"><b>'.price($total)."</b></td></tr>";
|
||||
print '<td align="right"><b>'.price($total)."</b></td>";
|
||||
print '<td> </td>';
|
||||
print '<td align="right"><b>'.price($total)."</b></td>";
|
||||
print "</tr>";
|
||||
|
||||
print "</table>";
|
||||
$db->free($result);
|
||||
|
||||
@ -50,42 +50,28 @@ $result = restrictedArea($user, 'tax', '', '', 'charges');
|
||||
/*
|
||||
* Classer paye
|
||||
*/
|
||||
if ($_POST["action"] == 'confirm_payed')
|
||||
if ($_REQUEST["action"] == 'confirm_payed' && $_REQUEST["confirm"] == 'yes')
|
||||
{
|
||||
if ($_POST["confirm"] == 'yes')
|
||||
{
|
||||
$chargesociales = new ChargeSociales($db);
|
||||
$result = $chargesociales->set_payed($chid);
|
||||
}
|
||||
else
|
||||
{
|
||||
$_GET["action"]='';
|
||||
}
|
||||
$chargesociales = new ChargeSociales($db);
|
||||
$result = $chargesociales->set_payed($chid);
|
||||
}
|
||||
|
||||
/*
|
||||
* Suppression d'une charge sociale
|
||||
*/
|
||||
if ($_POST["action"] == 'confirm_delete')
|
||||
if ($_REQUEST["action"] == 'confirm_delete' && $_REQUEST["confirm"] == 'yes')
|
||||
{
|
||||
if ($_POST["confirm"] == 'yes')
|
||||
$chargesociales=new ChargeSociales($db);
|
||||
$chargesociales->id=$_GET["id"];
|
||||
$result=$chargesociales->delete($user);
|
||||
if ($result > 0)
|
||||
{
|
||||
$chargesociales=new ChargeSociales($db);
|
||||
$chargesociales->id=$_GET["id"];
|
||||
$result=$chargesociales->delete($user);
|
||||
if ($result > 0)
|
||||
{
|
||||
Header("Location: index.php");
|
||||
exit;
|
||||
}
|
||||
else
|
||||
{
|
||||
$mesg='<div class="error">'.$chargesociales->error.'</div>';
|
||||
}
|
||||
Header("Location: index.php");
|
||||
exit;
|
||||
}
|
||||
else
|
||||
{
|
||||
$_GET['action']='';
|
||||
$mesg='<div class="error">'.$chargesociales->error.'</div>';
|
||||
}
|
||||
}
|
||||
|
||||
@ -97,12 +83,13 @@ if ($_POST["action"] == 'confirm_delete')
|
||||
if ($_POST["action"] == 'add' && $user->rights->tax->charges->creer)
|
||||
{
|
||||
$dateech=@dol_mktime($_POST["echhour"],$_POST["echmin"],$_POST["echsec"],$_POST["echmonth"],$_POST["echday"],$_POST["echyear"]);
|
||||
$dateperiod=@dol_mktime($_POST["periodhour"],$_POST["periodmin"],$_POST["periodsec"],$_POST["periodmonth"],$_POST["periodday"],$_POST["periodyear"]);
|
||||
if (! $dateech)
|
||||
{
|
||||
$mesg='<div class="error">'.$langs->trans("ErrorFieldRequired",$langs->transnoentities("DateDue")).'</div>';
|
||||
$_GET["action"] = 'create';
|
||||
}
|
||||
elseif (! $_POST["period"])
|
||||
elseif (! $dateperiod)
|
||||
{
|
||||
$mesg='<div class="error">'.$langs->trans("ErrorFieldRequired",$langs->transnoentities("Period")).'</div>';
|
||||
$_GET["action"] = 'create';
|
||||
@ -119,7 +106,7 @@ if ($_POST["action"] == 'add' && $user->rights->tax->charges->creer)
|
||||
$chargesociales->type=$_POST["actioncode"];
|
||||
$chargesociales->lib=$_POST["label"];
|
||||
$chargesociales->date_ech=$dateech;
|
||||
$chargesociales->periode=$_POST["period"];
|
||||
$chargesociales->periode=$dateperiod;
|
||||
$chargesociales->amount=$_POST["amount"];
|
||||
|
||||
$chid=$chargesociales->create($user);
|
||||
@ -138,12 +125,13 @@ if ($_POST["action"] == 'add' && $user->rights->tax->charges->creer)
|
||||
if ($_GET["action"] == 'update' && ! $_POST["cancel"] && $user->rights->tax->charges->creer)
|
||||
{
|
||||
$dateech=@dol_mktime($_POST["echhour"],$_POST["echmin"],$_POST["echsec"],$_POST["echmonth"],$_POST["echday"],$_POST["echyear"]);
|
||||
$dateperiod=@dol_mktime($_POST["periodhour"],$_POST["periodmin"],$_POST["periodsec"],$_POST["periodmonth"],$_POST["periodday"],$_POST["periodyear"]);
|
||||
if (! $dateech)
|
||||
{
|
||||
$mesg='<div class="error">'.$langs->trans("ErrorFieldRequired",$langs->transnoentities("DateDue")).'</div>';
|
||||
$_GET["action"] = 'edit';
|
||||
}
|
||||
elseif (! $_POST["period"])
|
||||
elseif (! $dateperiod)
|
||||
{
|
||||
$mesg='<div class="error">'.$langs->trans("ErrorFieldRequired",$langs->transnoentities("Period")).'</div>';
|
||||
$_GET["action"] = 'edit';
|
||||
@ -155,7 +143,7 @@ if ($_GET["action"] == 'update' && ! $_POST["cancel"] && $user->rights->tax->cha
|
||||
|
||||
$chargesociales->lib=$_POST["label"];
|
||||
$chargesociales->date_ech=$dateech;
|
||||
$chargesociales->periode=$_POST["period"];
|
||||
$chargesociales->periode=$dateperiod;
|
||||
|
||||
$result=$chargesociales->update($user);
|
||||
if ($result > 0)
|
||||
@ -169,6 +157,12 @@ if ($_GET["action"] == 'update' && ! $_POST["cancel"] && $user->rights->tax->cha
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* View
|
||||
*/
|
||||
|
||||
llxHeader();
|
||||
|
||||
$html = new Form($db);
|
||||
@ -186,7 +180,7 @@ if ($_GET["action"] == 'create')
|
||||
|
||||
$var=false;
|
||||
|
||||
print '<form name="charge" method="post" action="'.DOL_URL_ROOT.'/compta/sociales/charges.php">';
|
||||
print '<form name="charge" method="post" action="'.$_SERVER["PHP_SELF"].'">';
|
||||
print '<input type="hidden" name="action" value="add">';
|
||||
|
||||
print "<table class=\"noborder\" width=\"100%\">";
|
||||
@ -194,35 +188,43 @@ if ($_GET["action"] == 'create')
|
||||
print '<td>';
|
||||
print ' ';
|
||||
print '</td><td align="left">';
|
||||
print $langs->trans("DateDue");
|
||||
print '</td><td align="left">';
|
||||
print $langs->trans("Period");
|
||||
print $langs->trans("Label");
|
||||
print '</td><td align="left">';
|
||||
print $langs->trans("Type");
|
||||
print '</td><td align="left">';
|
||||
print $langs->trans("Label");
|
||||
print '</td><td align="center">';
|
||||
print $langs->trans("PeriodEndDate");
|
||||
print '</td><td align="right">';
|
||||
print $langs->trans("Amount");
|
||||
print '</td><td align="center">';
|
||||
print $langs->trans("DateDue");
|
||||
print '</td><td align="left">';
|
||||
print ' ';
|
||||
print '</td>';
|
||||
print "</tr>\n";
|
||||
|
||||
print '<tr '.$bc[$var].' valign="top">';
|
||||
|
||||
print '<td> </td>';
|
||||
print '<td>';
|
||||
print $html->select_date('-1', 'ech', 0, 0, 0, 'charge', 1);
|
||||
print '</td>';
|
||||
print '<td><input type="text" size="8" name="period"><br>YYYYMMDD</td>';
|
||||
|
||||
print '<td align="left">';
|
||||
$html->select_type_socialcontrib();
|
||||
print '</td>';
|
||||
|
||||
// Label
|
||||
print '<td align="left"><input type="text" size="34" name="label" class="flat"></td>';
|
||||
|
||||
// Type
|
||||
print '<td align="left">';
|
||||
$html->select_type_socialcontrib(isset($_POST["actioncode"])?$_POST["actioncode"]:'','actioncode',1);
|
||||
print '</td>';
|
||||
|
||||
// Date end period
|
||||
print '<td align="center">';
|
||||
print $html->select_date(! empty($dateperiod)?$dateperiod:'-1', 'period', 0, 0, 0, 'charge', 1);
|
||||
print '</td>';
|
||||
|
||||
print '<td align="right"><input type="text" size="6" name="amount" class="flat"></td>';
|
||||
|
||||
print '<td align="center">';
|
||||
print $html->select_date(! empty($dateech)?$dateech:'-1', 'ech', 0, 0, 0, 'charge', 1);
|
||||
print '</td>';
|
||||
|
||||
print '<td align="center"><input type="submit" class="button" value="'.$langs->trans("Add").'"></td>';
|
||||
print '</tr>';
|
||||
|
||||
@ -277,23 +279,40 @@ if ($chid > 0)
|
||||
|
||||
print '<table class="border" width="100%">';
|
||||
|
||||
print "<tr><td>".$langs->trans("Ref").'</td><td colspan="2">'.$cha->id."</td></tr>";
|
||||
// Ref
|
||||
print "<tr><td>".$langs->trans("Ref").'</td><td colspan="2">';
|
||||
print $html->showrefnav($cha,'id');
|
||||
print "</td></tr>";
|
||||
|
||||
print "<tr><td>".$langs->trans("Type")."</td><td>$cha->type_libelle</td><td>".$langs->trans("Payments")."</td></tr>";
|
||||
|
||||
print "<tr><td>".$langs->trans("Period")."</td>";
|
||||
print "<td>";
|
||||
if ($cha->paye==0 && $_GET['action'] == 'edit')
|
||||
// Label
|
||||
if ($_GET['action'] == 'edit')
|
||||
{
|
||||
print "<input type=\"text\" name=\"period\" value=\"".dol_print_date($cha->periode,"%Y%m%d")."\"> (YYYYMMDD)";
|
||||
print '<tr><td>'.$langs->trans("Label").'</td><td colspan="2">';
|
||||
print '<input type="text" name="label" size="40" value="'.$cha->lib.'">';
|
||||
print '</td></tr>';
|
||||
}
|
||||
else
|
||||
{
|
||||
print dol_print_date($cha->periode,"%Y");
|
||||
print '<tr><td>'.$langs->trans("Label").'</td><td colspan="2">'.$cha->lib.'</td></tr>';
|
||||
}
|
||||
|
||||
// Type
|
||||
print "<tr><td>".$langs->trans("Type")."</td><td>$cha->type_libelle</td><td>".$langs->trans("Payments")."</td></tr>";
|
||||
|
||||
// Period en date
|
||||
print "<tr><td>".$langs->trans("PeriodEndDate")."</td>";
|
||||
print "<td>";
|
||||
if ($_GET['action'] == 'edit')
|
||||
{
|
||||
print $html->select_date($cha->periode, 'period', 0, 0, 0, 'charge', 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
print dol_print_date($cha->periode,"day");
|
||||
}
|
||||
print "</td>";
|
||||
|
||||
print '<td rowspan="5" valign="top">';
|
||||
print '<td rowspan="4" valign="top">';
|
||||
|
||||
/*
|
||||
* Paiements
|
||||
@ -355,17 +374,14 @@ if ($chid > 0)
|
||||
|
||||
print "</tr>";
|
||||
|
||||
if ($cha->paye==0 && $_GET['action'] == 'edit')
|
||||
// Due date
|
||||
if ($_GET['action'] == 'edit')
|
||||
{
|
||||
print '<tr><td>'.$langs->trans("Label").'</td><td>';
|
||||
print '<input type="text" name="label" size="40" value="'.$cha->lib.'">';
|
||||
print '</td></tr>';
|
||||
print '<tr><td>'.$langs->trans("DateDue")."</td><td>";
|
||||
print $html->select_date($cha->date_ech, 'ech', 0, 0, 0, 'charge', 1);
|
||||
print "</td></tr>";
|
||||
}
|
||||
else {
|
||||
print '<tr><td>'.$langs->trans("Label").'</td><td>'.$cha->lib.'</td></tr>';
|
||||
print "<tr><td>".$langs->trans("DateDue")."</td><td>".dol_print_date($cha->date_ech,'day')."</td></tr>";
|
||||
}
|
||||
print '<tr><td>'.$langs->trans("AmountTTC").'</td><td>'.price($cha->amount).'</td></tr>';
|
||||
@ -391,12 +407,12 @@ if ($chid > 0)
|
||||
/*
|
||||
* Boutons actions
|
||||
*/
|
||||
if (! $_GET["action"] || $_GET["action"] == 'update')
|
||||
if ($_GET["action"] != 'edit')
|
||||
{
|
||||
print "<div class=\"tabsAction\">\n";
|
||||
|
||||
// Editer
|
||||
if ($cha->paye == 0 && $user->rights->tax->charges->creer)
|
||||
// Edit
|
||||
if ($user->rights->tax->charges->creer)
|
||||
{
|
||||
print "<a class=\"butAction\" href=\"".DOL_URL_ROOT."/compta/sociales/charges.php?id=$cha->id&action=edit\">".$langs->trans("Modify")."</a>";
|
||||
}
|
||||
@ -407,13 +423,13 @@ if ($chid > 0)
|
||||
print "<a class=\"butAction\" href=\"".DOL_URL_ROOT."/compta/paiement_charge.php?id=$cha->id&action=create\">".$langs->trans("DoPayment")."</a>";
|
||||
}
|
||||
|
||||
// Classer 'payé'
|
||||
// Classify 'payed'
|
||||
if ($cha->paye == 0 && round($resteapayer) <=0 && $user->rights->tax->charges->creer)
|
||||
{
|
||||
print "<a class=\"butAction\" href=\"".DOL_URL_ROOT."/compta/sociales/charges.php?id=$cha->id&action=payed\">".$langs->trans("ClassifyPayed")."</a>";
|
||||
}
|
||||
|
||||
// Supprimer
|
||||
// Delete
|
||||
if ($cha->paye == 0 && $totalpaye <=0 && $user->rights->tax->charges->supprimer)
|
||||
{
|
||||
print "<a class=\"butActionDelete\" href=\"".DOL_URL_ROOT."/compta/sociales/charges.php?id=$cha->id&action=delete\">".$langs->trans("Delete")."</a>";
|
||||
@ -424,7 +440,7 @@ if ($chid > 0)
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Charge non trouvé */
|
||||
/* Charge non trouv<EFBFBD> */
|
||||
dol_print_error('',$cha->error);
|
||||
}
|
||||
}
|
||||
|
||||
@ -147,22 +147,24 @@ if ($resql)
|
||||
|
||||
print "<tr class=\"liste_titre\">";
|
||||
print_liste_field_titre($langs->trans("Ref"),"index.php","id","",$param,"",$sortfield,$sortorder);
|
||||
print_liste_field_titre($langs->trans("DateDue"),"index.php","de","",$param,"",$sortfield,$sortorder);
|
||||
print_liste_field_titre($langs->trans("Period"),"index.php","periode","",$param,'align="center"',$sortfield,$sortorder);
|
||||
print_liste_field_titre($langs->trans("Type"),"index.php","type","",$param,'align="left"',$sortfield,$sortorder);
|
||||
print_liste_field_titre($langs->trans("Label"),"index.php","s.libelle","",$param,'align="left"',$sortfield,$sortorder);
|
||||
print_liste_field_titre($langs->trans("Type"),"index.php","type","",$param,'align="left"',$sortfield,$sortorder);
|
||||
print_liste_field_titre($langs->trans("PeriodEndDate"),"index.php","periode","",$param,'align="center"',$sortfield,$sortorder);
|
||||
print_liste_field_titre($langs->trans("Amount"),"index.php","s.amount","",$param,'align="right"',$sortfield,$sortorder);
|
||||
print_liste_field_titre($langs->trans("DateDue"),"index.php","de","",$param,'align="center"',$sortfield,$sortorder);
|
||||
print_liste_field_titre($langs->trans("Status"),"index.php","s.paye","",$param,'align="right"',$sortfield,$sortorder);
|
||||
print "</tr>\n";
|
||||
|
||||
print "<tr class=\"liste_titre\">";
|
||||
print '<td> </td>';
|
||||
print '<td> </td>';
|
||||
print '<td> </td>';
|
||||
// Type
|
||||
print '<td align="left">';
|
||||
$html->select_type_socialcontrib($typeid,'typeid',1,16,0);
|
||||
print '</td>';
|
||||
// Period end date
|
||||
print '<td> </td>';
|
||||
print '<td> </td>';
|
||||
print '<td> </td>';
|
||||
print '<td align="right">';
|
||||
print '<input type="image" class="liste_titre" src="'.DOL_URL_ROOT.'/theme/'.$conf->theme.'/img/search.png" name="button_search" alt="'.$langs->trans("Search").'">';
|
||||
@ -176,16 +178,22 @@ if ($resql)
|
||||
$var = !$var;
|
||||
print "<tr $bc[$var]>";
|
||||
|
||||
// Ref
|
||||
print '<td width="60">';
|
||||
print '<a href="charges.php?id='.$obj->id.'">'.img_file().' '.$obj->id.'</a>';
|
||||
print '</td>';
|
||||
|
||||
print '<td width="110">'.dol_print_date($obj->de, 'day').'</td>';
|
||||
// Label
|
||||
print '<td>'.dol_trunc($obj->libelle,42).'</td>';
|
||||
|
||||
// Type
|
||||
print '<td>'.dol_trunc($obj->type_lib,16).'</td>';
|
||||
|
||||
// Date end period
|
||||
print '<td align="center">';
|
||||
if ($obj->periode)
|
||||
{
|
||||
print '<a href="index.php?year='.strftime("%Y",$obj->periode).'">'.strftime("%Y",$obj->periode).'</a>';
|
||||
print '<a href="index.php?year='.strftime("%Y",$obj->periode).'">'.dol_print_date($obj->periode,'day').'</a>';
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -193,12 +201,11 @@ if ($resql)
|
||||
}
|
||||
print '</td>';
|
||||
|
||||
print '<td>'.dol_trunc($obj->type_lib,16).'</td>';
|
||||
|
||||
print '<td>'.dol_trunc($obj->libelle,42).'</td>';
|
||||
|
||||
print '<td align="right" width="100">'.price($obj->amount).'</td>';
|
||||
|
||||
// Due date
|
||||
print '<td width="110" align="center">'.dol_print_date($obj->de, 'day').'</td>';
|
||||
|
||||
print '<td align="right" nowrap="nowrap">'.$chargesociale_static->LibStatut($obj->paye,5).'</a></td>';
|
||||
|
||||
print '</tr>';
|
||||
|
||||
@ -266,6 +266,8 @@ WatermarkOnDraftBill=Watermark on draft invoices (nothing if empty)
|
||||
CloneInvoice=Clone invoice
|
||||
ConfirmCloneInvoice=Are you sure you want to clone this invoice <b>%s</b> ?
|
||||
DisabledBecauseReplacedInvoice=Action disabled because invoice has been replaced
|
||||
DescTaxAndDividendsArea=This area presents a summary of all payments made for tax or social contributions. Only records with payment during the fixed year are included here.
|
||||
NbOfPayments=Nb of payments
|
||||
|
||||
# PaymentConditions
|
||||
PaymentConditionShortRECEP=Immediate
|
||||
|
||||
@ -78,6 +78,7 @@ Always=Always
|
||||
Never=Never
|
||||
Under=under
|
||||
Period=Period
|
||||
PeriodEndDate=End date for period
|
||||
Activate=Activate
|
||||
Activated=Activated
|
||||
Closed=Closed
|
||||
|
||||
@ -266,6 +266,8 @@ InvoiceNotChecked=Aucune facture n'a été sélectionnée
|
||||
CloneInvoice=Cloner facture
|
||||
ConfirmCloneInvoice=Etes-vous sur de vouloir cloner cette facture <b>%s</b> ?
|
||||
DisabledBecauseReplacedInvoice=Action désactivée car facture remplacée
|
||||
DescTaxAndDividendsArea=Cet écran résumé la liste de toutes les taxes et charges sociales sociales exigées pour une année donnée. La date prise en compte est la période d'exigibilité.
|
||||
NbOfPayments=Nb de payements
|
||||
|
||||
# PaymentConditions
|
||||
PaymentConditionShortRECEP=A réception
|
||||
|
||||
@ -77,6 +77,7 @@ Always=Toujours
|
||||
Never=Jamais
|
||||
Under=sous
|
||||
Period=Période
|
||||
PeriodEndDate=Date fin période
|
||||
Activate=Activer
|
||||
Activated=Activé
|
||||
Closed=Clôturé
|
||||
|
||||
Loading…
Reference in New Issue
Block a user