From 947a0141f16594c3383a8ac1ed3bea8df4882b1d Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 3 Feb 2007 12:44:44 +0000 Subject: [PATCH] =?UTF-8?q?Tache=20#6464:=20Ajout=20lien=20dans=20=E9critu?= =?UTF-8?q?re=20bancaire=20sur=20detail=20de=20la=20charge=20sociale?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- htdocs/chargesociales.class.php | 24 ++++++- htdocs/compta/bank/account.php | 16 ++++- htdocs/compta/bank/ligne.php | 107 ++++++++++++---------------- htdocs/compta/index.php | 15 ++-- htdocs/compta/paiement_charge.php | 72 +++++++++---------- htdocs/compta/sociales/charges.php | 2 +- htdocs/compta/sociales/index.php | 8 ++- htdocs/langs/en_US/banks.lang | 2 + htdocs/langs/en_US/bills.lang | 1 + htdocs/langs/fr_FR/banks.lang | 1 + htdocs/langs/fr_FR/bills.lang | 1 + mysql/migration/2.0.0-2.1.0.sql | 7 +- mysql/tables/llx_bank_url.sql | 3 +- mysql/tables/llx_chargesociales.sql | 1 - 14 files changed, 144 insertions(+), 116 deletions(-) diff --git a/htdocs/chargesociales.class.php b/htdocs/chargesociales.class.php index c265a03070d..c05689ecf53 100644 --- a/htdocs/chargesociales.class.php +++ b/htdocs/chargesociales.class.php @@ -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 = ''; + $lienfin=''; + + if ($withpicto) $result.=($lien.img_object($langs->trans("ShowBill"),'bill').$lienfin.' '); + $result.=$lien.$this->lib.$lienfin; + return $result; + } } diff --git a/htdocs/compta/bank/account.php b/htdocs/compta/bank/account.php index 316f5bee1c1..de6b552d31c 100644 --- a/htdocs/compta/bank/account.php +++ b/htdocs/compta/bank/account.php @@ -1,7 +1,7 @@ * Copyright (C) 2003 Jean-Louis Bergamo - * Copyright (C) 2004-2005 Laurent Destailleur + * Copyright (C) 2004-2007 Laurent Destailleur * Copytight (C) 2004 Christophe Combelles * * 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 ''; } - else { + else if ($links[$key]['type']=='sc') { + print ''; + //print img_object($langs->trans('ShowBill'),'bill').' '; + print $langs->trans("SocialContribution"); + print ''; + } + else if ($links[$key]['type']=='payment_sc') { + print ''; + //print img_object($langs->trans('ShowPayment'),'payment').' '; + print $langs->trans("SocialContributionPayment"); + print ''; + } + else { print ''; print $links[$key]['label']; print ''; diff --git a/htdocs/compta/bank/ligne.php b/htdocs/compta/bank/ligne.php index 7eff952c81d..8288483432c 100644 --- a/htdocs/compta/bank/ligne.php +++ b/htdocs/compta/bank/ligne.php @@ -1,7 +1,7 @@ * Copyright (C) 2003 Xavier DUTOIT - * Copyright (C) 2004-2006 Laurent Destailleur + * Copyright (C) 2004-2007 Laurent Destailleur * Copyright (C) 2004 Christophe Combelles * * This program is free software; you can redistribute it and/or modify @@ -257,36 +257,10 @@ if ($result) // Account print "".$langs->trans("Account").""; - /* - if (! $objp->rappro) - { - if ($user->rights->banque->modifier && $acct->type != 2 && $acct->rappro) // Si non compte cash et si rapprochable - { - print ''; - $html->select_comptes($acct->id,'accountid',0); - print ''; - //print ''; - //print ''; - //print ''; - } - else - { - print ''; - $html->select_comptes($acct->id,'accountid',0); - print ''; - } - print ''; - } - else - { - */ print ''; print ''.img_object($langs->trans("ShowAccount"),'account').' '.$acct->label.''; print ''; print ''; - /* - } - */ print ''; // Date ope @@ -358,39 +332,52 @@ if ($result) } print ''; - // Affiche liens - if (sizeof($links)) { - print "".$langs->trans("Links").""; - print ''; - foreach($links as $key=>$val) - { - if ($key) print '
'; - if ($links[$key]['type']=='payment') { - print ''; - print img_object($langs->trans('ShowPayment'),'payment').' '; - print $langs->trans("Payment"); - print ''; - } - else if ($links[$key]['type']=='payment_supplier') { - print ''; - print img_object($langs->trans('ShowPayment'),'payment').' '; - print $langs->trans("Payment"); - print ''; - } - else if ($links[$key]['type']=='company') { - print ''; - print img_object($langs->trans('ShowCustomer'),'company').' '; - print $links[$key]['label']; - print ''; - } - else { - print ''; - print $links[$key]['label']; - print ''; - } - } - print ' '; - } + // Affiche liens + if (sizeof($links)) + { + print "".$langs->trans("Links").""; + print ''; + foreach($links as $key=>$val) + { + if ($key) print '
'; + if ($links[$key]['type']=='payment') { + print ''; + print img_object($langs->trans('ShowPayment'),'payment').' '; + print $langs->trans("Payment"); + print ''; + } + else if ($links[$key]['type']=='payment_supplier') { + print ''; + print img_object($langs->trans('ShowPayment'),'payment').' '; + print $langs->trans("Payment"); + print ''; + } + else if ($links[$key]['type']=='company') { + print ''; + print img_object($langs->trans('ShowCustomer'),'company').' '; + print $links[$key]['label']; + print ''; + } + else if ($links[$key]['type']=='sc') { + print ''; + print img_object($langs->trans('ShowBill'),'bill').' '; + print $langs->trans("SocialContribution"); + print ''; + } + else if ($links[$key]['type']=='payment_sc') { + print ''; + print img_object($langs->trans('ShowPayment'),'payment').' '; + print $langs->trans("SocialContributionPayment"); + print ''; + } + else { + print ''; + print $links[$key]['label']; + print ''; + } + } + print ' '; + } // Amount print "".$langs->trans("Amount").""; diff --git a/htdocs/compta/index.php b/htdocs/compta/index.php index 995007d1671..2e51b09fd7d 100644 --- a/htdocs/compta/index.php +++ b/htdocs/compta/index.php @@ -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 ""; - print ''.img_object($langs->trans("ShowBill"),"bill").' '.$obj->libelle.''; + $chargestatic->id=$obj->rowid; + $chargestatic->lib=$obj->libelle; + print ''.$chargestatic->getNomUrl(1).''; print ''.price($obj->amount).''; print ''; $tot_ttc+=$obj->amount; diff --git a/htdocs/compta/paiement_charge.php b/htdocs/compta/paiement_charge.php index b73b03074ca..e740d1952e8 100755 --- a/htdocs/compta/paiement_charge.php +++ b/htdocs/compta/paiement_charge.php @@ -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 "
$mesg

"; -} - - /* * 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 "
\n"; + if ($mesg) + { + print "
$mesg
"; + } + print '
'; print "id\">"; print ''; @@ -216,32 +223,16 @@ if ($_GET["action"] == 'create') print ' (Numéro chèque ou virement)'; // \todo a traduire print "\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 ''; print ''; print ''; - print ''; - print ''; + //print ''; + print ''; print ''; print ''; print ''; @@ -261,12 +252,11 @@ if ($_GET["action"] == 'create') print ""; - print '\n"; + //print '\n"; - if ($objp->date_ech > 0 ) + if ($objp->date_ech > 0) { - print "\n"; + print "\n"; } else { @@ -320,7 +310,11 @@ if ($_GET["action"] == 'create') * */ - print ''; + print ''; print "
'.$langs->trans("SocialContribution").''.$langs->trans("DateDue").''.$langs->trans("SocialContribution").''.$langs->trans("DateDue").''.$langs->trans("AmountTTC").''.$langs->trans("AlreadyPayed").''.$langs->trans("RemainderToPay").'
' . $objp->id; - print "'.$charge->getNomUrl(1)."".dolibarr_print_date($objp->date_ech)."".dolibarr_print_date($objp->date_ech,'day')."
'; + print ''; + print '   '; + print ''; + print '
"; print "
\n"; // } diff --git a/htdocs/compta/sociales/charges.php b/htdocs/compta/sociales/charges.php index 7c859f1e3ed..d8383a1ae82 100644 --- a/htdocs/compta/sociales/charges.php +++ b/htdocs/compta/sociales/charges.php @@ -227,7 +227,7 @@ if ($chid > 0) } else { print ''.$langs->trans("Label").''.$cha->lib.''; - print "".$langs->trans("DateDue")."".dolibarr_print_date($cha->date_ech).""; + print "".$langs->trans("DateDue")."".dolibarr_print_date($cha->date_ech,'day').""; } print ''.$langs->trans("AmountTTC").''.price($cha->amount).''; diff --git a/htdocs/compta/sociales/index.php b/htdocs/compta/sociales/index.php index 88828fe5c9d..3d12358c3d8 100644 --- a/htdocs/compta/sociales/index.php +++ b/htdocs/compta/sociales/index.php @@ -187,9 +187,11 @@ print_liste_field_titre($langs->trans("Status"),"index.php","s.paye","","",'alig print "\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 ("; diff --git a/htdocs/langs/en_US/banks.lang b/htdocs/langs/en_US/banks.lang index 793e5c9e155..7d0dee4cd43 100644 --- a/htdocs/langs/en_US/banks.lang +++ b/htdocs/langs/en_US/banks.lang @@ -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 diff --git a/htdocs/langs/en_US/bills.lang b/htdocs/langs/en_US/bills.lang index 1e32e87d901..89eb70acf56 100644 --- a/htdocs/langs/en_US/bills.lang +++ b/htdocs/langs/en_US/bills.lang @@ -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 diff --git a/htdocs/langs/fr_FR/banks.lang b/htdocs/langs/fr_FR/banks.lang index a7f0b1ab8f0..1786a9bba54 100644 --- a/htdocs/langs/fr_FR/banks.lang +++ b/htdocs/langs/fr_FR/banks.lang @@ -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 diff --git a/htdocs/langs/fr_FR/bills.lang b/htdocs/langs/fr_FR/bills.lang index 8cf154c6b48..fd8dd3a3a20 100644 --- a/htdocs/langs/fr_FR/bills.lang +++ b/htdocs/langs/fr_FR/bills.lang @@ -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 diff --git a/mysql/migration/2.0.0-2.1.0.sql b/mysql/migration/2.0.0-2.1.0.sql index 0b2b79b3717..5c1f5f748d9 100644 --- a/mysql/migration/2.0.0-2.1.0.sql +++ b/mysql/migration/2.0.0-2.1.0.sql @@ -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; + diff --git a/mysql/tables/llx_bank_url.sql b/mysql/tables/llx_bank_url.sql index 546442b2ccd..a5d38b931ad 100644 --- a/mysql/tables/llx_bank_url.sql +++ b/mysql/tables/llx_bank_url.sql @@ -1,5 +1,6 @@ -- =================================================================== -- Copyright (C) 2003 Rodolphe Quiedeville +-- Copyright (C) 2007 Laurent Destailleur -- -- This program is free software; you can redistribute it and/or modify -- it under the terms of the GNU General Public License as published by @@ -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; diff --git a/mysql/tables/llx_chargesociales.sql b/mysql/tables/llx_chargesociales.sql index 6c1796ed93d..968d35f0924 100644 --- a/mysql/tables/llx_chargesociales.sql +++ b/mysql/tables/llx_chargesociales.sql @@ -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,