Tache #6464: Ajout lien dans criture bancaire sur detail de la charge sociale

This commit is contained in:
Laurent Destailleur 2007-02-03 12:44:44 +00:00
parent 14fceb1758
commit 947a0141f1
14 changed files with 144 additions and 116 deletions

View File

@ -38,7 +38,6 @@ class ChargeSociales
var $id;
var $date_ech;
var $date_pai;
var $lib;
var $type;
var $type_libelle;
@ -60,7 +59,7 @@ class ChargeSociales
*/
function fetch($id)
{
$sql = "SELECT cs.rowid,".$this->db->pdate("cs.date_ech")." as date_ech,".$this->db->pdate("cs.date_pai")." as date_pai,";
$sql = "SELECT cs.rowid,".$this->db->pdate("cs.date_ech")." as date_ech,";
$sql.= " cs.libelle as lib, cs.fk_type, cs.amount, cs.paye, ".$this->db->pdate("cs.periode")." as periode,";
$sql.= " c.libelle";
$sql.= " FROM ".MAIN_DB_PREFIX."chargesociales as cs, ".MAIN_DB_PREFIX."c_chargesociales as c";
@ -77,7 +76,6 @@ class ChargeSociales
$this->id = $obj->rowid;
$this->date_ech = $obj->date_ech;
$this->date_pai = $obj->date_pai;
$this->lib = $obj->lib;
$this->type = $obj->fk_type;
$this->type_libelle = $obj->libelle;
@ -241,6 +239,26 @@ class ChargeSociales
return "Error, mode/status not found";
}
/**
* \brief Renvoie nom clicable (avec eventuellement le picto)
* \param withpicto Inclut le picto dans le lien
* \return string Chaine avec URL
*/
function getNomUrl($withpicto=0)
{
global $langs;
$result='';
$lien = '<a href="'.DOL_URL_ROOT.'/compta/sociales/charges.php?id='.$this->id.'">';
$lienfin='</a>';
if ($withpicto) $result.=($lien.img_object($langs->trans("ShowBill"),'bill').$lienfin.' ');
$result.=$lien.$this->lib.$lienfin;
return $result;
}
}

View File

@ -1,7 +1,7 @@
<?php
/* Copyright (C) 2001-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2003 Jean-Louis Bergamo <jlb@j1b.org>
* Copyright (C) 2004-2005 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2004-2007 Laurent Destailleur <eldy@users.sourceforge.net>
* Copytight (C) 2004 Christophe Combelles <ccomb@free.fr>
*
* This program is free software; you can redistribute it and/or modify
@ -442,7 +442,19 @@ function _print_lines($db,$result,$sql,$acct)
print $links[$key]['label'];
print '</a>';
}
else {
else if ($links[$key]['type']=='sc') {
print '<a href="'.DOL_URL_ROOT.'/compta/sociales/charges.php?id='.$links[$key]['url_id'].'">';
//print img_object($langs->trans('ShowBill'),'bill').' ';
print $langs->trans("SocialContribution");
print '</a>';
}
else if ($links[$key]['type']=='payment_sc') {
print '<a href="'.DOL_URL_ROOT.'/compta/sociales/xxx.php?id='.$links[$key]['url_id'].'">';
//print img_object($langs->trans('ShowPayment'),'payment').' ';
print $langs->trans("SocialContributionPayment");
print '</a>';
}
else {
print '<a href="'.$links[$key]['url'].$links[$key]['url_id'].'">';
print $links[$key]['label'];
print '</a>';

View File

@ -1,7 +1,7 @@
<?php
/* Copyright (C) 2001-2006 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2003 Xavier DUTOIT <doli@sydesy.com>
* Copyright (C) 2004-2006 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2004-2007 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2004 Christophe Combelles <ccomb@free.fr>
*
* This program is free software; you can redistribute it and/or modify
@ -257,36 +257,10 @@ if ($result)
// Account
print "<tr><td>".$langs->trans("Account")."</td>";
/*
if (! $objp->rappro)
{
if ($user->rights->banque->modifier && $acct->type != 2 && $acct->rappro) // Si non compte cash et si rapprochable
{
print '<td colspan="3">';
$html->select_comptes($acct->id,'accountid',0);
print '</td>';
//print '<td align="center">';
//print '<input type="submit" class="button" name="conciliate" value="'.$langs->trans("Conciliate").'">';
//print '</td>';
}
else
{
print '<td colspan="3">';
$html->select_comptes($acct->id,'accountid',0);
print '</td>';
}
print '<td align="center"><input type="submit" class="button" value="'.$langs->trans("Update").'"></td>';
}
else
{
*/
print '<td colspan="4">';
print '<a href="account.php?account='.$acct->id.'">'.img_object($langs->trans("ShowAccount"),'account').' '.$acct->label.'</a>';
print '<input type="hidden" name="accountid" value="'.$acct->id.'">';
print '</td>';
/*
}
*/
print '</tr>';
// Date ope
@ -358,39 +332,52 @@ if ($result)
}
print '</td></tr>';
// Affiche liens
if (sizeof($links)) {
print "<tr><td>".$langs->trans("Links")."</td>";
print '<td colspan="3">';
foreach($links as $key=>$val)
{
if ($key) print '<br>';
if ($links[$key]['type']=='payment') {
print '<a href="'.DOL_URL_ROOT.'/compta/paiement/fiche.php?id='.$links[$key]['url_id'].'">';
print img_object($langs->trans('ShowPayment'),'payment').' ';
print $langs->trans("Payment");
print '</a>';
}
else if ($links[$key]['type']=='payment_supplier') {
print '<a href="'.DOL_URL_ROOT.'/fourn/paiement/fiche.php?id='.$links[$key]['url_id'].'">';
print img_object($langs->trans('ShowPayment'),'payment').' ';
print $langs->trans("Payment");
print '</a>';
}
else if ($links[$key]['type']=='company') {
print '<a href="'.DOL_URL_ROOT.'/compta/fiche.php?socid='.$links[$key]['url_id'].'">';
print img_object($langs->trans('ShowCustomer'),'company').' ';
print $links[$key]['label'];
print '</a>';
}
else {
print '<a href="'.$links[$key]['url'].$links[$key]['url_id'].'">';
print $links[$key]['label'];
print '</a>';
}
}
print '</td><td>&nbsp;</td></tr>';
}
// Affiche liens
if (sizeof($links))
{
print "<tr><td>".$langs->trans("Links")."</td>";
print '<td colspan="3">';
foreach($links as $key=>$val)
{
if ($key) print '<br>';
if ($links[$key]['type']=='payment') {
print '<a href="'.DOL_URL_ROOT.'/compta/paiement/fiche.php?id='.$links[$key]['url_id'].'">';
print img_object($langs->trans('ShowPayment'),'payment').' ';
print $langs->trans("Payment");
print '</a>';
}
else if ($links[$key]['type']=='payment_supplier') {
print '<a href="'.DOL_URL_ROOT.'/fourn/paiement/fiche.php?id='.$links[$key]['url_id'].'">';
print img_object($langs->trans('ShowPayment'),'payment').' ';
print $langs->trans("Payment");
print '</a>';
}
else if ($links[$key]['type']=='company') {
print '<a href="'.DOL_URL_ROOT.'/compta/fiche.php?socid='.$links[$key]['url_id'].'">';
print img_object($langs->trans('ShowCustomer'),'company').' ';
print $links[$key]['label'];
print '</a>';
}
else if ($links[$key]['type']=='sc') {
print '<a href="'.DOL_URL_ROOT.'/compta/sociales/charges.php?id='.$links[$key]['url_id'].'">';
print img_object($langs->trans('ShowBill'),'bill').' ';
print $langs->trans("SocialContribution");
print '</a>';
}
else if ($links[$key]['type']=='payment_sc') {
print '<a href="'.DOL_URL_ROOT.'/compta/sociales/xxx.php?id='.$links[$key]['url_id'].'">';
print img_object($langs->trans('ShowPayment'),'payment').' ';
print $langs->trans("SocialContributionPayment");
print '</a>';
}
else {
print '<a href="'.$links[$key]['url'].$links[$key]['url_id'].'">';
print $links[$key]['label'];
print '</a>';
}
}
print '</td><td>&nbsp;</td></tr>';
}
// Amount
print "<tr><td>".$langs->trans("Amount")."</td>";

View File

@ -32,6 +32,7 @@ require("./pre.inc.php");
require_once(DOL_DOCUMENT_ROOT.'/facture.class.php');
if ($conf->commande->enabled) require_once(DOL_DOCUMENT_ROOT.'/commande/commande.class.php');
if ($conf->facture->enabled) require_once(DOL_DOCUMENT_ROOT.'/fourn/fournisseur.facture.class.php');
if ($conf->tax->enabled) require_once(DOL_DOCUMENT_ROOT.'/chargesociales.class.php');
$user->getrights(); // On a besoin des permissions sur plusieurs modules
@ -179,14 +180,16 @@ if ($conf->facture->enabled && $user->rights->facture->lire)
/**
* Charges a payer
*/
if ($conf->compta->enabled || $conf->comptaexpert->enabled)
if ($conf->tax->enabled)
{
if ($user->societe_id == 0)
{
$chargestatic=new ChargeSociales($db);
$sql = "SELECT c.rowid, c.amount, cc.libelle";
$sql .= " FROM ".MAIN_DB_PREFIX."chargesociales as c, ".MAIN_DB_PREFIX."c_chargesociales as cc";
$sql .= " WHERE c.fk_type = cc.id AND c.paye=0";
$sql = "SELECT c.rowid, c.amount, ".$db->pdate("c.date_ech")." as date_ech,";
$sql.= " cc.libelle";
$sql.= " FROM ".MAIN_DB_PREFIX."chargesociales as c, ".MAIN_DB_PREFIX."c_chargesociales as cc";
$sql.= " WHERE c.fk_type = cc.id AND c.paye=0";
$resql = $db->query($sql);
@ -206,7 +209,9 @@ if ($conf->compta->enabled || $conf->comptaexpert->enabled)
$obj = $db->fetch_object($resql);
$var = !$var;
print "<tr $bc[$var]>";
print '<td><a href="'.DOL_URL_ROOT.'/compta/sociales/charges.php?id='.$obj->rowid.'">'.img_object($langs->trans("ShowBill"),"bill").' '.$obj->libelle.'</td>';
$chargestatic->id=$obj->rowid;
$chargestatic->lib=$obj->libelle;
print '<td>'.$chargestatic->getNomUrl(1).'</td>';
print '<td align="right">'.price($obj->amount).'</td>';
print '</tr>';
$tot_ttc+=$obj->amount;

View File

@ -30,11 +30,11 @@ include_once("./pre.inc.php");
include_once("../chargesociales.class.php");
include_once(DOL_DOCUMENT_ROOT."/compta/bank/account.class.php");
$langs->load("bills");
$chid=isset($_GET["id"])?$_GET["id"]:$_POST["id"];
/*
* Sécurité accés client
*/
// Sécurité accés client
if ($user->societe_id > 0)
{
$action = '';
@ -47,6 +47,13 @@ if ($user->societe_id > 0)
*/
if ($_POST["action"] == 'add_paiement')
{
if ($_POST["cancel"])
{
$loc = DOL_URL_ROOT.'/compta/sociales/charges.php?id='.$chid;
Header("Location: $loc");
exit;
}
if ($_POST["paiementtype"] > 0)
{
@ -93,7 +100,8 @@ if ($_POST["action"] == 'add_paiement')
$total = price2num($total);
// Insertion dans llx_bank
$label = "Règlement charge";
$langs->load("banks");
$label = $langs->trans("SocialContributionPayment");
$acc = new Account($db, $_POST["accountid"]);
$bank_line_id = $acc->addline($paiement->datepaye, $paiement->paiementtype, $label, -abs($total), $paiement->num_paiement, '', $user);
@ -105,7 +113,7 @@ if ($_POST["action"] == 'add_paiement')
// Mise a jour liens (pour chaque charge concernée par le paiement)
foreach ($paiement->amounts as $key => $value)
{
$acc->add_url_line($bank_line_id, $chid, DOL_URL_ROOT.'/compta/sociales/charges.php?id=', $chid);
$acc->add_url_line($bank_line_id, $chid, DOL_URL_ROOT.'/compta/sociales/charges.php?id=', '(socialcontribution)','sc');
}
$db->commit();
@ -127,7 +135,7 @@ if ($_POST["action"] == 'add_paiement')
}
else
{
$mesg = "Vous devez sélectionner un mode de paiement";
$mesg = $langs->trans("ErrorFieldRequired",$langs->transnoentities("PaymentMode"));
}
$_GET["action"]='create';
}
@ -142,12 +150,6 @@ llxHeader();
$html=new Form($db);
if ($mesg)
{
print "<div class=\"error\">$mesg</div><br>";
}
/*
* Formulaire de creation d'un paiement de charge
*/
@ -159,9 +161,14 @@ if ($_GET["action"] == 'create')
$total = $charge->amount;
print_titre("Emettre un paiement d'une charge");
print_titre($langs->trans("DoPayment"));
print "<br>\n";
if ($mesg)
{
print "<div class=\"error\">$mesg</div>";
}
print '<form name="add_paiement" action="paiement_charge.php" method="post">';
print "<input type=\"hidden\" name=\"id\" value=\"$charge->id\">";
print '<input type="hidden" name="action" value="add_paiement">';
@ -216,32 +223,16 @@ if ($_GET["action"] == 'create')
print ' <em>(Numéro chèque ou virement)</em>'; // \todo a traduire
print "<td><input name=\"num_paiement\" type=\"text\"></td></tr>\n";
/*
* Autres charges impayées
*/
// $sql = "SELECT f.rowid as facid,f.facnumber,f.total_ttc,".$db->pdate("f.datef")." as df";
// $sql .= ", sum(pf.amount) as am";
// $sql .= " FROM ".MAIN_DB_PREFIX."facture as f";
// $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."paiement_facture as pf ON pf.fk_facture = f.rowid";
// $sql .= " WHERE f.fk_soc = ".$facture->socid;
// $sql .= " AND f.paye = 0";
// $sql .= " AND f.fk_statut = 1"; // Statut=0 => non validée, Statut=2 => annulée
// $sql .= " GROUP BY f.facnumber";
//
// $result=$db->query($sql);
// if ($result)
// {
// $num = $db->num_rows($result);
//
// if ($num > 0)
// {
/*
* Autres charges impayées
*/
$num = 1;
$i = 0;
print '<tr><td colspan="3">';
print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">';
print '<td>'.$langs->trans("SocialContribution").'</td>';
print '<td align="center">'.$langs->trans("DateDue").'</td>';
//print '<td>'.$langs->trans("SocialContribution").'</td>';
print '<td align="left">'.$langs->trans("DateDue").'</td>';
print '<td align="right">'.$langs->trans("AmountTTC").'</td>';
print '<td align="right">'.$langs->trans("AlreadyPayed").'</td>';
print '<td align="right">'.$langs->trans("RemainderToPay").'</td>';
@ -261,12 +252,11 @@ if ($_GET["action"] == 'create')
print "<tr $bc[$var]>";
print '<td><a href="'.DOL_URL_ROOT.'/compta/sociales/charges.php?id='.$objp->id.'">' . $objp->id;
print "</a></td>\n";
//print '<td>'.$charge->getNomUrl(1)."</td>\n";
if ($objp->date_ech > 0 )
if ($objp->date_ech > 0)
{
print "<td align=\"center\">".dolibarr_print_date($objp->date_ech)."</td>\n";
print "<td align=\"left\">".dolibarr_print_date($objp->date_ech,'day')."</td>\n";
}
else
{
@ -320,7 +310,11 @@ if ($_GET["action"] == 'create')
*
*/
print '<tr><td colspan="3" align="center"><input type="submit" class="button" value="'.$langs->trans("Save").'"></td></tr>';
print '<tr><td colspan="3" align="center">';
print '<input type="submit" class="button" name="save" value="'.$langs->trans("Save").'">';
print '&nbsp; &nbsp;';
print '<input type="submit" class="button" name="cancel" value="'.$langs->trans("Cancel").'">';
print '</td></tr>';
print "</table>";
print "</form>\n";
// }

View File

@ -227,7 +227,7 @@ if ($chid > 0)
}
else {
print '<tr><td>'.$langs->trans("Label").'</td><td>'.$cha->lib.'</td></tr>';
print "<tr><td>".$langs->trans("DateDue")."</td><td>".dolibarr_print_date($cha->date_ech)."</td></tr>";
print "<tr><td>".$langs->trans("DateDue")."</td><td>".dolibarr_print_date($cha->date_ech,'day')."</td></tr>";
}
print '<tr><td>'.$langs->trans("AmountTTC").'</td><td>'.price($cha->amount).'</td></tr>';

View File

@ -187,9 +187,11 @@ print_liste_field_titre($langs->trans("Status"),"index.php","s.paye","","",'alig
print "</tr>\n";
$sql = "SELECT s.rowid as id, s.fk_type as type, c.libelle as type_lib, s.amount,".$db->pdate("s.date_ech")." as de, s.date_pai, s.libelle, s.paye,".$db->pdate("s.periode")." as periode,".$db->pdate("s.date_pai")." as dp";
$sql .= " FROM ".MAIN_DB_PREFIX."c_chargesociales as c, ".MAIN_DB_PREFIX."chargesociales as s";
$sql .= " WHERE s.fk_type = c.id";
$sql = "SELECT s.rowid as id, s.fk_type as type, ";
$sql.= " s.amount,".$db->pdate("s.date_ech")." as de, s.libelle, s.paye,".$db->pdate("s.periode")." as periode,";
$sql.= " c.libelle as type_lib";
$sql.= " FROM ".MAIN_DB_PREFIX."c_chargesociales as c, ".MAIN_DB_PREFIX."chargesociales as s";
$sql.= " WHERE s.fk_type = c.id";
if ($year > 0)
{
$sql .= " AND (";

View File

@ -88,9 +88,11 @@ DateConciliating=Conciliate date
BankLineConciliated=Transaction conciliated
CustomerInvoicePayment=Customer payment
SupplierInvoicePayment=Supplier payment
SocialContributionPayment=Social contribution payment
FinancialAccountJournal=Financial account journal
BankTransfer=Bank transfer
BankTransfers=Bank transfers
TransferDesc=Transfer from one account to another one, Dolibarr will write two records (one for debit in source account and a credit in target account, of same amount. Same label and date will be used for this transaction)
TransferFrom=From
TransferTo=To
CheckTransmitter=Transmitter

View File

@ -138,6 +138,7 @@ AlreadyPayed=Already payed
Abandoned=Abandoned
RemainderToPay=Remainder to pay
RemainderToTake=Remainder to take
AmountExpected=Amount clamed
EscompteOffered=Discount offered (payment before term)
CreateDraft=Create draft
SendBillRef=Send invoice %s

View File

@ -88,6 +88,7 @@ DateConciliating=Date rapprochement
BankLineConciliated=Ecriture rapprochée
CustomerInvoicePayment=Règlement client
SupplierInvoicePayment=Règlement fournisseur
SocialContributionPayment=Règlement charge sociale
FinancialAccountJournal=Journal de trésorerie du compte
BankTransfer=Virement bancaire
BankTransfers=Virements bancaire

View File

@ -139,6 +139,7 @@ AlreadyPayed=D
Abandoned=Abandonné
RemainderToPay=Reste à payer
RemainderToTake=Reste à encaisser
AmountExpected=Montant réclamé
EscompteOffered=Escompte (réglement avant échéance)
CreateDraft=Créer brouillon
SendBillRef=Envoi facture %s

View File

@ -215,7 +215,9 @@ delete from llx_const where name in ('OSC_CATALOG_URL','OSC_LANGUAGE_ID');
alter table llx_paiementfourn add statut smallint(6) NOT NULL DEFAULT 0;
alter table llx_bank_url add column type enum("company","payment","member","donation","charge");
alter table llx_bank_url add column type enum("company","payment","member","subscription","donation","sc","payment_sc");
update llx_bank_url set type=null where type='';
alter table llx_bank_url modify type enum("company","payment","member","subscription","donation","sc","payment_sc");
update llx_bank_url set type = 'payment_supplier' where label = '(paiement)' and type='payment' and url like '%/fourn/%';
@ -889,3 +891,6 @@ alter table llx_product_price add column price_ttc float(12,4) DEFAULT 0 after p
alter table llx_product_price add column price_base_type varchar(3) DEFAULT 'HT' after price_ttc;
ALTER TABLE llx_document_model ADD UNIQUE uk_document_model (nom,type);
ALTER TABLE llx_chargesociales drop column date_pai;

View File

@ -1,5 +1,6 @@
-- ===================================================================
-- Copyright (C) 2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
-- Copyright (C) 2007 Laurent Destailleur <eldy@users.sourceforge.net>
--
-- This program is free software; you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
@ -27,5 +28,5 @@ create table llx_bank_url
url_id integer,
url varchar(255),
label varchar(255),
type enum("company","payment","member","donation","charge")
type enum("company","payment","member","subscription","donation","sc","payment_sc")
)type=innodb;

View File

@ -24,7 +24,6 @@ create table llx_chargesociales
(
rowid integer AUTO_INCREMENT PRIMARY KEY,
date_ech datetime NOT NULL, -- date d'echeance
date_pai datetime, -- date de paiements
libelle varchar(80),
fk_type integer,
amount real default 0 NOT NULL,