diff --git a/htdocs/chargesociales.class.php b/htdocs/chargesociales.class.php index 58d139aac37..64819fa43ba 100644 --- a/htdocs/chargesociales.class.php +++ b/htdocs/chargesociales.class.php @@ -346,15 +346,16 @@ class ChargeSociales extends CommonObject /** \class PaiementCharge * \brief Classe permettant la gestion des paiements des charges */ -class PaiementCharge +class PaiementCharge extends CommonObject { var $db; //!< To store db handler var $error; //!< To return error code (or message) var $errors=array(); //!< To return several error codes (or messages) - //var $element='paiementcharge'; //!< Id that identify managed objects - //var $table_element='paiementcharge'; //!< Name of table without prefix where object is stored + var $element='paiementcharge'; //!< Id that identify managed objects + var $table_element='paiementcharge'; //!< Name of table without prefix where object is stored var $id; + var $ref; var $fk_charge; var $datec=''; @@ -463,7 +464,6 @@ class PaiementCharge global $langs; $sql = "SELECT"; $sql.= " t.rowid,"; - $sql.= " t.fk_charge,"; $sql.= " t.datec,"; $sql.= " t.tms,"; @@ -475,10 +475,10 @@ class PaiementCharge $sql.= " t.fk_bank,"; $sql.= " t.fk_user_creat,"; $sql.= " t.fk_user_modif,"; - - $sql.= " pt.code as type_code, pt.libelle as type_libelle"; - - $sql.= " FROM ".MAIN_DB_PREFIX."paiementcharge as t, ".MAIN_DB_PREFIX."c_paiement as pt"; + $sql.= " pt.code as type_code, pt.libelle as type_libelle,"; + $sql.= ' b.fk_account'; + $sql.= " FROM (".MAIN_DB_PREFIX."paiementcharge as t, ".MAIN_DB_PREFIX."c_paiement as pt)"; + $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'bank as b ON t.fk_bank = b.rowid'; $sql.= " WHERE t.rowid = ".$id." AND t.fk_typepaiement = pt.id"; dol_syslog(get_class($this)."::fetch sql=".$sql, LOG_DEBUG); @@ -490,6 +490,7 @@ class PaiementCharge $obj = $this->db->fetch_object($resql); $this->id = $obj->rowid; + $this->ref = $obj->rowid; $this->fk_charge = $obj->fk_charge; $this->datec = $this->db->jdate($obj->datec); @@ -505,6 +506,9 @@ class PaiementCharge $this->type_code = $obj->type_code; $this->type_libelle = $obj->type_libelle; + + $this->bank_account = $obj->fk_account; + $this->bank_line = $obj->fk_bank; } $this->db->free($resql); diff --git a/htdocs/compta/bank/account.php b/htdocs/compta/bank/account.php index f236b7204c0..cf41c8fdfd8 100644 --- a/htdocs/compta/bank/account.php +++ b/htdocs/compta/bank/account.php @@ -23,7 +23,7 @@ /** * \file htdocs/compta/bank/account.php * \ingroup banque - * \brief Page de d�tail des transactions bancaires + * \brief List of detail of bank transaction for an account * \version $Id$ */ @@ -500,28 +500,18 @@ if ($account || $_GET["ref"]) $links = $acct->get_url($objp->rowid); - $isbanktransfert=false; - foreach($links as $key=>$val) { if ($val['type']=='banktransfert') $isbanktransfert=true; } - $issocialcontrib=false; - foreach($links as $key=>$val) { if ($val['type']=='sc') $issocialcontrib=true; } - - $showlabel=true; - //if (sizeof($links) == 0) $showlabel=true; - //if ($isbanktransfert || $issocialcontrib) $showlabel=true; - if ($showlabel) + // Sgow generic description + if (preg_match('/^\((.*)\)$/i',$objp->label,$reg)) { - if (preg_match('/^\((.*)\)$/i',$objp->label,$reg)) - { - // Genereic description because between (). We show it after translating. - print $langs->trans($reg[1]); - } - else - { - print dol_trunc($objp->label,60); - } + // Generic description because between (). We show it after translating. + print $langs->trans($reg[1]); + } + else + { + print dol_trunc($objp->label,60); } - // Add links in description field + // Add links after description foreach($links as $key=>$val) { if ($links[$key]['type']=='payment') { @@ -544,12 +534,11 @@ if ($account || $_GET["ref"]) else if ($links[$key]['type']=='payment_sc') { //print ' - '; - /* - print ''; - //print img_object($langs->trans('ShowPayment'),'payment').' '; - print $langs->trans("SocialContributionPayment"); + print ''; + print ' '.img_object($langs->trans('ShowPayment'),'payment').' '; + //print $langs->trans("SocialContributionPayment"); print ''; - */ + } else if ($links[$key]['type']=='payment_vat') { diff --git a/htdocs/compta/bank/ligne.php b/htdocs/compta/bank/ligne.php index 8d470922718..ba5c9c64327 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-2009 Laurent Destailleur + * Copyright (C) 2004-2010 Laurent Destailleur * Copyright (C) 2004 Christophe Combelles * * This program is free software; you can redistribute it and/or modify @@ -373,7 +373,7 @@ if ($result) print ''; } else if ($links[$key]['type']=='payment_sc') { - print ''; + print ''; print img_object($langs->trans('ShowPayment'),'payment').' '; print $langs->trans("SocialContributionPayment"); print ''; diff --git a/htdocs/compta/bank/search.php b/htdocs/compta/bank/search.php index c9ea98d1df8..88ae567f2aa 100644 --- a/htdocs/compta/bank/search.php +++ b/htdocs/compta/bank/search.php @@ -187,7 +187,9 @@ if ($resql) // Date print ''.dol_print_date($db->jdate($objp->do),"day")."   \n"; + // Description print "rowid&account=$objp->fk_account\">"; + //print $objp->label; $reg=array(); preg_match('/\((.+)\)/i',$objp->label,$reg); // Si texte entoure de parenthee on tente recherche de traduction if ($reg[1] && $langs->trans($reg[1])!=$reg[1]) print $langs->trans($reg[1]); diff --git a/htdocs/compta/paiement.php b/htdocs/compta/paiement.php index 416cdb91801..48fd9371653 100644 --- a/htdocs/compta/paiement.php +++ b/htdocs/compta/paiement.php @@ -280,7 +280,7 @@ if ($_GET['action'] == 'create' || $_POST['action'] == 'confirm_paiement' || $_P print ''.$langs->trans('Date').''; $datepayment = dol_mktime(12, 0 , 0, $_POST['remonth'], $_POST['reday'], $_POST['reyear']); $datepayment= ($datepayment == '' ? (empty($conf->global->MAIN_AUTOFILL_DATE)?-1:0) : $datepayment); - $html->select_date($datepayment,'','','',0,"add_paiement"); + $html->select_date($datepayment,'','','',0,"add_paiement",1,1); print ''; print ''.$langs->trans('Comments').''; diff --git a/htdocs/compta/paiement/fiche.php b/htdocs/compta/paiement/fiche.php index 3b80212e792..fc25aa0e0a2 100644 --- a/htdocs/compta/paiement/fiche.php +++ b/htdocs/compta/paiement/fiche.php @@ -226,9 +226,10 @@ if ($resql) print '
'; print ''; print ''; - print ''; print ''; - print ''; + print ''; + print ''; + print ''; print "\n"; if ($num > 0) @@ -242,15 +243,27 @@ if ($resql) $objp = $db->fetch_object($resql); $var=!$var; print ''; + + // Invoice print '\n"; - print ''; + + // Third party print ''; + + // Expected to pay + print ''; + + // Statut + print ''; + + // Amount payed print ''; + print "\n"; if ($objp->paye == 1) // If at least one invoice is paid, disable delete { diff --git a/htdocs/compta/paiement_charge.php b/htdocs/compta/paiement_charge.php index 5b5d29f1d6b..ef822e70572 100755 --- a/htdocs/compta/paiement_charge.php +++ b/htdocs/compta/paiement_charge.php @@ -1,5 +1,5 @@ +/* Copyright (C) 2004-2010 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 @@ -17,11 +17,11 @@ */ /** - \file htdocs/compta/paiement_charge.php - \ingroup compta - \brief Page de creation d'un paiement d'une charge - \version $Id$ -*/ + * \file htdocs/compta/paiement_charge.php + * \ingroup tax + * \brief Page to add payment of a tax + * \version $Id$ + */ include_once("./pre.inc.php"); include_once(DOL_DOCUMENT_ROOT."/chargesociales.class.php"); @@ -34,8 +34,8 @@ $chid=isset($_GET["id"])?$_GET["id"]:$_POST["id"]; // Securite acces client if ($user->societe_id > 0) { - $action = ''; - $socid = $user->societe_id; + $action = ''; + $socid = $user->societe_id; } @@ -46,98 +46,99 @@ if ($_POST["action"] == 'add_paiement') { if ($_POST["cancel"]) { - $loc = DOL_URL_ROOT.'/compta/sociales/charges.php?id='.$chid; - Header("Location: $loc"); + $loc = DOL_URL_ROOT.'/compta/sociales/charges.php?id='.$chid; + Header("Location: $loc"); exit; } - $datepaye = dol_mktime(12, 0 , 0, $_POST["remonth"], $_POST["reday"], $_POST["reyear"]); + $datepaye = dol_mktime(12, 0 , 0, $_POST["remonth"], $_POST["reday"], $_POST["reyear"]); - if (! $_POST["paiementtype"] > 0) - { - $mesg = $langs->trans("ErrorFieldRequired",$langs->transnoentities("PaymentMode")); - $error++; - } + if (! $_POST["paiementtype"] > 0) + { + $mesg = $langs->trans("ErrorFieldRequired",$langs->transnoentities("PaymentMode")); + $error++; + } if ($datepaye == '') - { - $mesg = $langs->trans("ErrorFieldRequired",$langs->transnoentities("Date")); - $error++; - } + { + $mesg = $langs->trans("ErrorFieldRequired",$langs->transnoentities("Date")); + $error++; + } - if (! $error) - { - $paiement_id = 0; + if (! $error) + { + $paiement_id = 0; - // Read possible payments - $amounts = array(); - foreach ($_POST as $key => $value) - { - if (substr($key,0,7) == 'amount_') - { - $other_chid = substr($key,7); + // Read possible payments + $amounts = array(); + foreach ($_POST as $key => $value) + { + if (substr($key,0,7) == 'amount_') + { + $other_chid = substr($key,7); - $amounts[$other_chid] = $_POST[$key]; - } - } + $amounts[$other_chid] = $_POST[$key]; + } + } - $db->begin(); + $db->begin(); - // Creation de la ligne paiement - $paiement = new PaiementCharge($db); - $paiement->chid = $chid; - $paiement->datepaye = $datepaye; - $paiement->amounts = $amounts; // Tableau de montant - $paiement->paiementtype = $_POST["paiementtype"]; - $paiement->num_paiement = $_POST["num_paiement"]; - $paiement->note = $_POST["note"]; - $paiement_id = $paiement->create($user); + // Creation de la ligne paiement + $paiement = new PaiementCharge($db); + $paiement->chid = $chid; + $paiement->datepaye = $datepaye; + $paiement->amounts = $amounts; // Tableau de montant + $paiement->paiementtype = $_POST["paiementtype"]; + $paiement->num_paiement = $_POST["num_paiement"]; + $paiement->note = $_POST["note"]; + $paiement_id = $paiement->create($user); - if ($paiement_id > 0) - { - // On determine le montant total du paiement - $total=0; - foreach ($paiement->amounts as $key => $value) - { - $chid = $key; - $value = trim($value); - $amount = price2num(trim($value), 'MT'); // Un round est ok si nb avec '.' - $total += $amount; - } + if ($paiement_id > 0) + { + // On determine le montant total du paiement + $total=0; + foreach ($paiement->amounts as $key => $value) + { + $chid = $key; + $value = trim($value); + $amount = price2num(trim($value), 'MT'); // Un round est ok si nb avec '.' + $total += $amount; + } - // Insertion dans llx_bank - $langs->load("banks"); + // Insertion dans llx_bank + $langs->load("banks"); $label = $langs->transnoentities("SocialContributionPayment"); - $acc = new Account($db, $_POST["accountid"]); - $bank_line_id = $acc->addline($paiement->datepaye, $paiement->paiementtype, $label, -abs($total), $paiement->num_paiement, '', $user); + $acc = new Account($db, $_POST["accountid"]); + $bank_line_id = $acc->addline($paiement->datepaye, $paiement->paiementtype, $label, -abs($total), $paiement->num_paiement, '', $user); - // Mise a jour fk_bank dans llx_paiementcharge. On connait ainsi le paiement qui a g�n�r� l'�criture bancaire - if ($bank_line_id > 0) - { - $paiement->update_fk_bank($bank_line_id); + // Mise a jour fk_bank dans llx_paiementcharge. On connait ainsi le paiement qui a genere l'ecriture bancaire + if ($bank_line_id > 0) + { + $paiement->update_fk_bank($bank_line_id); - // 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=', '(socialcontribution)','sc'); - } + // Mise a jour liens (pour chaque charge concernee par le paiement) + foreach ($paiement->amounts as $key => $value) + { + //$acc->add_url_line($bank_line_id, $chid, DOL_URL_ROOT.'/compta/charges.php?id=', '(socialcontribution)','payment_sc'); + $acc->add_url_line($bank_line_id, $paymentid, DOL_URL_ROOT.'/compta/payment_sc/fiche.php?id=', '(paiement)','payment_sc'); + } - $db->commit(); + $db->commit(); - $loc = DOL_URL_ROOT.'/compta/sociales/charges.php?id='.$chid; - Header("Location: $loc"); - exit; - } - else { - $db->rollback(); - $mesg = "Echec de la cr�ation entr�e compte: ".$db->error(); - } - } - else - { - $db->rollback(); - $mesg = "Echec de la cr�ation du paiement: paiement_id=$paiement_id ".$db->error(); - } - } + $loc = DOL_URL_ROOT.'/compta/sociales/charges.php?id='.$chid; + Header("Location: $loc"); + exit; + } + else { + $db->rollback(); + $mesg = "Echec de la creation entree compte: ".$db->error(); + } + } + else + { + $db->rollback(); + $mesg = "Failed to create payment: paiement_id=$paiement_id ".$db->error(); + } + } $_GET["action"]='create'; } @@ -158,171 +159,175 @@ $html=new Form($db); if ($_GET["action"] == 'create') { - $charge = new ChargeSociales($db); - $charge->fetch($chid); + $charge = new ChargeSociales($db); + $charge->fetch($chid); - $total = $charge->amount; + $total = $charge->amount; - print_fiche_titre($langs->trans("DoPayment")); - print "
\n"; + print_fiche_titre($langs->trans("DoPayment")); + print "
\n"; if ($mesg) { print "
$mesg
"; } - print '
'; - print ''; - print "id\">"; - print ''; + print ''; + print ''; + print "id\">"; + print ''; - print '
'.$langs->trans('Bill').''.$langs->trans('Status').''.$langs->trans('Company').''.$langs->trans('AmountTTC').''.$langs->trans('ExpectedToPay').''.$langs->trans('Status').''.$langs->trans('PayedByThisPayment').'
'; $facturestatic->id=$objp->facid; $facturestatic->ref=$objp->facnumber; $facturestatic->type=$objp->type; print $facturestatic->getNomUrl(1); print "'.$facturestatic->LibStatut($objp->paye,$objp->fk_statut,2,1).''.img_object($langs->trans('ShowCompany'),'company').' '.$objp->nom.''.price($objp->total_ttc).''.$facturestatic->LibStatut($objp->paye,$objp->fk_statut,2,1).''.price($objp->amount).'
'; + print '
'; - print ""; + print ""; - print ''; - print '\n"; - print '\n"; - print '\n"; - print '\n"; + print ''; + print '\n"; + print '\n"; + print '\n"; + print '\n"; - print ''; + print ''; - $sql = "SELECT sum(p.amount) as total"; - $sql.= " FROM ".MAIN_DB_PREFIX."paiementcharge as p"; - $sql.= " WHERE p.fk_charge = ".$chid; - $resql = $db->query($sql); - if ($resql) - { - $obj=$db->fetch_object($resql); - $sumpaid = $obj->total; - $db->free(); - } - print ''; - print "'; + $sql = "SELECT sum(p.amount) as total"; + $sql.= " FROM ".MAIN_DB_PREFIX."paiementcharge as p"; + $sql.= " WHERE p.fk_charge = ".$chid; + $resql = $db->query($sql); + if ($resql) + { + $obj=$db->fetch_object($resql); + $sumpaid = $obj->total; + $db->free(); + } + print ''; + print "'; - print "'; + print "'; - print ""; + print ""; - print '"; - print ''; + print '"; + print ''; - print '\n"; + print '\n"; - print ''; + print ''; - print ''; - print ''; - print ''; + print ''; + print ''; + print ''; - print '\n"; + print '\n"; - /* - * Autres charges impay�es - */ - $num = 1; - $i = 0; - print '\n"; + // } + // $db->free(); + // } + // else + // { + // print $sql ."
".$db->error(); + // } + /* + * + */ - print ''; - print "
Charge
Charge
'.$langs->trans("Ref").''; - print ''.$chid.'
'.$langs->trans("Type")."".$charge->type_libelle."
'.$langs->trans("Period")."".dol_print_date($charge->periode,'day')."
'.$langs->trans("Label").''.$charge->lib."
'.$langs->trans("DateDue")."".dol_print_date($charge->date_ech,'day')."
'.$langs->trans("Ref").''; + print ''.$chid.'
'.$langs->trans("Type")."".$charge->type_libelle."
'.$langs->trans("Period")."".dol_print_date($charge->periode,'day')."
'.$langs->trans("Label").''.$charge->lib."
'.$langs->trans("DateDue")."".dol_print_date($charge->date_ech,'day')."
'.$langs->trans("AmountTTC")."".price($charge->amount).' '.$langs->trans("Currency".$conf->monnaie).'
'.$langs->trans("AmountTTC")."".price($charge->amount).' '.$langs->trans("Currency".$conf->monnaie).'
'.$langs->trans("AlreadyPaid").''.price($sumpaid).' '.$langs->trans("Currency".$conf->monnaie).'
".$langs->trans("RemainderToPay")."".price($total - $sumpaid).' '.$langs->trans("Currency".$conf->monnaie).'
'.$langs->trans("AlreadyPaid").''.price($sumpaid).' '.$langs->trans("Currency".$conf->monnaie).'
".$langs->trans("RemainderToPay")."".price($total - $sumpaid).' '.$langs->trans("Currency".$conf->monnaie).'
".$langs->trans("Payment").'
".$langs->trans("Payment").'
'.$langs->trans("Date").''; - $datepayment=empty($conf->global->MAIN_AUTOFILL_DATE)?-1:0; - $html->select_date($datepayment,'','','','',"add_paiement"); - print "'.$langs->trans("Comments").'
'.$langs->trans("Date").''; + $datepayment=empty($conf->global->MAIN_AUTOFILL_DATE)?-1:0; + $html->select_date($datepayment,'','','','',"add_paiement",1,1); + print "'.$langs->trans("Comments").'
'.$langs->trans("PaymentMode").''; - $html->select_types_paiements($charge->paiementtype, "paiementtype"); - print "
'.$langs->trans("PaymentMode").''; + $html->select_types_paiements($charge->paiementtype, "paiementtype"); + print "
'.$langs->trans('AccountToCredit').''; - $html->select_comptes($charge->accountid, "accountid", 0, "courant=1"); // Affiche liste des comptes courant - print '
'.$langs->trans('AccountToCredit').''; + $html->select_comptes($charge->accountid, "accountid", 0, "courant=1"); // Affiche liste des comptes courant + print '
'.$langs->trans('Numero'); - print ' ('.$langs->trans("ChequeOrTransferNumber").')'; - print "
'.$langs->trans('Numero'); + print ' ('.$langs->trans("ChequeOrTransferNumber").')'; + print "
'; - print ''; - print ''; - //print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print "\n"; + /* + * Autres charges impayees + */ + $num = 1; + $i = 0; + print '\n"; -// } -// $db->free(); -// } -// else -// { -// print $sql ."
".$db->error(); -// } - /* - * - */ + print "\n"; + $total+=$objp->total; + $total_ttc+=$objp->total_ttc; + $totalrecu+=$objp->am; + $i++; + } + if ($i > 1) + { + // Print total + print ""; + print ''; + print ""; + print ""; + print ""; + print ''; + print "\n"; + } + print "
'.$langs->trans("SocialContribution").''.$langs->trans("DateDue").''.$langs->trans("AmountTTC").''.$langs->trans("AlreadyPaid").''.$langs->trans("RemainderToPay").''.$langs->trans("Amount").'
'; + print ''; + print ''; + //print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print "\n"; - $var=True; - $total=0; - $totalrecu=0; + $var=True; + $total=0; + $totalrecu=0; - while ($i < $num) - { - //$objp = $db->fetch_object($result); - $objp = $charge; + while ($i < $num) + { + //$objp = $db->fetch_object($result); + $objp = $charge; - $var=!$var; + $var=!$var; - print ""; + print ""; - //print '\n"; + //print '\n"; - if ($objp->date_ech > 0) - { - print "\n"; - } - else - { - print "\n"; - } + if ($objp->date_ech > 0) + { + print "\n"; + } + else + { + print "\n"; + } - print '"; + print '"; - print '"; + print '"; - print '"; + print '"; - print '"; + print '"; - print "\n"; - $total+=$objp->total; - $total_ttc+=$objp->total_ttc; - $totalrecu+=$objp->am; - $i++; - } - if ($i > 1) - { - // Print total - print ""; - print ''; - print ""; - print ""; - print ""; - print ''; - print "\n"; - } - print "
'.$langs->trans("SocialContribution").''.$langs->trans("DateDue").''.$langs->trans("AmountTTC").''.$langs->trans("AlreadyPaid").''.$langs->trans("RemainderToPay").''.$langs->trans("Amount").'
'.$charge->getNomUrl(1)."'.$charge->getNomUrl(1)."".dol_print_date($objp->date_ech,'day')."!!!".dol_print_date($objp->date_ech,'day')."!!!'.price($objp->amount)."'.price($objp->amount)."'.price($sumpaid)."'.price($sumpaid)."'.price($objp->amount-$sumpaid)."'.price($objp->amount-$sumpaid)."'; - if ($sumpaid < $objp->amount) - { - $namef = "amount_".$objp->id; - print ''; - } - else - { - print '-'; - } - print "'; + if ($sumpaid < $objp->amount) + { + $namef = "amount_".$objp->id; + print ''; + } + else + { + print '-'; + } + print "
'.$langs->trans("TotalTTC").':".price($total_ttc)."".price($totalrecu)."".price($total_ttc - $totalrecu)." 
'.$langs->trans("TotalTTC").':".price($total_ttc)."".price($totalrecu)."".price($total_ttc - $totalrecu)." 
'; - print ''; - print '   '; - print ''; - print '
"; - print "\n"; -// } + print ""; + + print '
'; + //print ''; + print ''; + print '   '; + print ''; + + print '
'; + //print ''; + print "\n"; + // } } diff --git a/htdocs/compta/payment_sc/fiche.php b/htdocs/compta/payment_sc/fiche.php index 0df2e42338e..001828dc4d8 100644 --- a/htdocs/compta/payment_sc/fiche.php +++ b/htdocs/compta/payment_sc/fiche.php @@ -28,7 +28,6 @@ */ require('./pre.inc.php'); -require_once(DOL_DOCUMENT_ROOT.'/paiement.class.php'); include_once(DOL_DOCUMENT_ROOT."/chargesociales.class.php"); require_once(DOL_DOCUMENT_ROOT.'/facture.class.php'); require_once(DOL_DOCUMENT_ROOT."/includes/modules/facture/modules_facture.php"); @@ -56,7 +55,7 @@ if ($_REQUEST['action'] == 'confirm_delete' && $_REQUEST['confirm'] == 'yes' && { $db->begin(); - $paiement = new Paiement($db); + $paiement = new PaiementCharge($db); $paiement->fetch($_GET['id']); $result = $paiement->delete(); if ($result > 0) @@ -76,7 +75,7 @@ if ($_REQUEST['action'] == 'confirm_valide' && $_REQUEST['confirm'] == 'yes' && { $db->begin(); - $paiement = new Paiement($db); + $paiement = new PaiementCharge($db); $paiement->id = $_GET['id']; if ($paiement->valide() > 0) { @@ -166,7 +165,10 @@ if ($mesg) print $mesg.'
'; print ''; // Ref -print ''; +print ''; +print ''; // Date print ''; @@ -205,11 +207,11 @@ print '
'.$langs->trans('Ref').''.$paiement->id.'
'.$langs->trans('Ref').''; +print $html->showrefnav($paiement,'id','',1,'rowid','id'); +print '
'.$langs->trans('Date').''.dol_print_date($paiement->datep,'day').'
'; /* - * List of invoices + * List of social contributions payed */ $disable_delete = 0; -$sql = 'SELECT f.rowid as scid, f.libelle, f.paye, pf.amount, pc.libelle as sc_type'; +$sql = 'SELECT f.rowid as scid, f.libelle, f.paye, f.amount as sc_amount, pf.amount, pc.libelle as sc_type'; $sql.= ' FROM '.MAIN_DB_PREFIX.'paiementcharge as pf,'.MAIN_DB_PREFIX.'chargesociales as f, '.MAIN_DB_PREFIX.'c_chargesociales as pc'; $sql.= ' WHERE pf.fk_charge = f.rowid AND pf.fk_typepaiement = pc.id'; $sql.= ' AND f.entity = '.$conf->entity; @@ -225,8 +227,9 @@ if ($resql) print ''; print ''.$langs->trans('SocialContribution').''; print ''.$langs->trans('Label').''; + print ''.$langs->trans('ExpectedToPay').''; print ''.$langs->trans('Status').''; - print ''.$langs->trans('AmountTTC').''; + print ''.$langs->trans('PayedByThisPayment').''; print "\n"; if ($num > 0) @@ -247,7 +250,11 @@ if ($resql) print $socialcontribstatic->getNomUrl(1); print "\n"; print ''.$objp->libelle.''; + // Expected to pay + print ''.price($objp->sc_amount).''; + // Status print ''.$socialcontribstatic->LibStatut($objp->fk_statut,2).''; + // Amount payed print ''.price($objp->amount).''; print "\n"; if ($objp->paye == 1) // If at least one invoice is paid, disable delete diff --git a/htdocs/fourn/facture/paiement.php b/htdocs/fourn/facture/paiement.php index 4ea65f243a6..33c66c388fc 100644 --- a/htdocs/fourn/facture/paiement.php +++ b/htdocs/fourn/facture/paiement.php @@ -1,7 +1,7 @@ * Copyright (C) 2004 Eric Seigne - * Copyright (C) 2004-2009 Laurent Destailleur + * Copyright (C) 2004-2010 Laurent Destailleur * Copyright (C) 2004 Christophe Combelles * Copyright (C) 2005 Marc Barilley / Ocebo * @@ -232,11 +232,11 @@ if ($action == 'create' || $action == 'add_paiement') print ''.$langs->trans('Payment').''; print ''.$langs->trans('Company').''.$obj->nom.''; - print ''.$langs->trans('Date').''; - $html->select_date($dateinvoice,'','','','',"addpaiement"); + print ''.$langs->trans('Date').''; + $html->select_date($dateinvoice,'','','','',"addpaiement",1,1); print ''; print ''.$langs->trans('Comments').''; - print ''.$langs->trans('PaymentMode').''; + print ''.$langs->trans('PaymentMode').''; $html->select_types_paiements(empty($_POST['paiementid'])?'':$_POST['paiementid'],'paiementid'); print ''; print ''; @@ -244,7 +244,7 @@ if ($action == 'create' || $action == 'add_paiement') print ''.$langs->trans('Numero').''; if ($conf->banque->enabled) { - print ''.$langs->trans('Account').''; + print ''.$langs->trans('Account').''; $html->select_comptes(empty($_POST['accountid'])?'':$_POST['accountid'],'accountid',0,'',1); print ''; } @@ -252,6 +252,8 @@ if ($action == 'create' || $action == 'add_paiement') { print ' '; } + print ''; + /* * Autres factures impayees */ @@ -270,7 +272,8 @@ if ($action == 'create' || $action == 'add_paiement') if ($num > 0) { $i = 0; - print ''; + print '
'; + print $langs->trans('Invoices').'
'; print ''; print ''; @@ -326,7 +329,7 @@ if ($action == 'create' || $action == 'add_paiement') print ''; print "\n"; } - print "
 
\n"; + print "\n"; } $db->free($resql); } @@ -338,8 +341,10 @@ if ($action == 'create' || $action == 'add_paiement') /* * */ - print ''; - print ''; + + print '
'; + print '
'; + print ''; } } diff --git a/htdocs/fourn/paiement/fiche.php b/htdocs/fourn/paiement/fiche.php index 33576f22590..7459dc7a345 100644 --- a/htdocs/fourn/paiement/fiche.php +++ b/htdocs/fourn/paiement/fiche.php @@ -1,7 +1,7 @@ * Copyright (C) 2005 Marc Barilley / Ocebo - * Copyright (C) 2006 Laurent Destailleur + * Copyright (C) 2006-2010 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 @@ -156,24 +156,6 @@ print ''; print ''; print ''; -if ($conf->banque->enabled) -{ - if ($paiement->bank_account) - { - // Si compte renseign�, on affiche libelle - $bank=new Account($db); - $bank->fetch($paiement->bank_account); - - $bankline=new AccountLine($db); - $bankline->fetch($paiement->bank_line); - - print ''; - print ''; - print ''; - print ''; - print ''; - } -} //switch through edition options for date (only available when statut is -not 1- (=validated)) if (empty($_GET['action']) || $_GET['action']!='edit_date') @@ -242,6 +224,25 @@ if ($conf->global->BILL_ADD_PAYMENT_VALIDATION) print ''; } +if ($conf->banque->enabled) +{ + if ($paiement->bank_account) + { + // Si compte renseigne, on affiche libelle + $bank=new Account($db); + $bank->fetch($paiement->bank_account); + + $bankline=new AccountLine($db); + $bankline->fetch($paiement->bank_line); + + print ''; + print ''; + print ''; + print ''; + print ''; + } +} + print ''; print '
'.$langs->trans('Ref').''.$paiement->id.'
'.$langs->trans('BankAccount').''.img_object($langs->trans('ShowAccount'),'account').' '.$bank->label.''.$langs->trans('BankLineConciliated').''.yn($bankline->rappro).'
'.$langs->trans('Status').''.$paiement->getLibStatut(4).'
'.$langs->trans('BankAccount').''.img_object($langs->trans('ShowAccount'),'account').' '.$bank->label.''.$langs->trans('BankLineConciliated').''.yn($bankline->rappro).'
'.$langs->trans('Note').''.nl2br($paiement->note).'
'; @@ -270,9 +271,10 @@ if ($resql) print ''; print ''.$langs->trans('Ref').''; print ''.$langs->trans('RefSupplier').''; - print ''.$langs->trans('Status').''; print ''.$langs->trans('Company').''; - print ''.$langs->trans('AmountTTC').''; + print ''.$langs->trans('ExpectedToPay').''; + print ''.$langs->trans('Status').''; + print ''.$langs->trans('PayedByThisPayment').''; print "\n"; if ($num > 0) @@ -286,12 +288,19 @@ if ($resql) $objp = $db->fetch_object($resql); $var=!$var; print ''; + // Ref print '
'.img_object($langs->trans('ShowBill'),'bill').' '; print $objp->ref; print "\n"; + // Ref supplier print ''.$objp->ref_supplier."\n"; - print ''.$facturestatic->LibStatut($objp->paye,$objp->fk_statut,2,1).''; + // Third party print ''.img_object($langs->trans('ShowCompany'),'company').' '.$objp->nom.''; + // Expected to pay + print ''.price($objp->total_ttc).''; + // Status + print ''.$facturestatic->LibStatut($objp->paye,$objp->fk_statut,2,1).''; + // Payed print ''.price($objp->amount).''; print "\n"; if ($objp->paye == 1) diff --git a/htdocs/langs/en_US/bills.lang b/htdocs/langs/en_US/bills.lang index c8b386f4627..d382aee9bfc 100644 --- a/htdocs/langs/en_US/bills.lang +++ b/htdocs/langs/en_US/bills.lang @@ -354,6 +354,8 @@ Cash=Cash Reported=Delayed DisabledBecausePayments=Not possible since there is some payments CantRemovePaymentWithOneInvoicePaid=Can't remove payment since there is at least on invoice classified payed +ExpectedToPay=Expected payment +PayedByThisPayment=Payed by this payment ##### Types de contacts ##### TypeContact_facture_internal_SALESREPFOLL=Representative following-up customer invoice TypeContact_facture_external_BILLING=Customer invoice contact diff --git a/htdocs/langs/fr_FR/bills.lang b/htdocs/langs/fr_FR/bills.lang index 014e83e90e2..5e777c37c46 100644 --- a/htdocs/langs/fr_FR/bills.lang +++ b/htdocs/langs/fr_FR/bills.lang @@ -356,6 +356,8 @@ InvoiceDepositAsk=Facture d'acompte InvoiceDepositDesc=La facture d'acompte est le type de facture qui fait suite à réception d'un acompte, s'il n'est pas encore possible de saisir le paiement sur une facture définitive. DisabledBecausePayments=Non disponible car il existe des paiements CantRemovePaymentWithOneInvoicePaid=Suppression impossible quand il existe au moins une facture classée payée. +ExpectedToPay=Paiement attendu +PayedByThisPayment=Payé par ce paiement ##### Types de contacts ##### TypeContact_facture_internal_SALESREPFOLL=Reponsable suivi facture client TypeContact_facture_external_BILLING=Contact client facturation diff --git a/htdocs/paiement.class.php b/htdocs/paiement.class.php index 10a605d85b6..20ced109760 100644 --- a/htdocs/paiement.class.php +++ b/htdocs/paiement.class.php @@ -68,9 +68,10 @@ class Paiement */ function fetch($id) { - $sql = 'SELECT p.rowid, p.datep as dp, p.amount, p.statut, p.fk_bank'; - $sql.= ', c.code as type_code, c.libelle as type_libelle'; - $sql.= ', p.num_paiement, p.note, b.fk_account'; + $sql = 'SELECT p.rowid, p.datep as dp, p.amount, p.statut, p.fk_bank,'; + $sql.= ' c.code as type_code, c.libelle as type_libelle,'; + $sql.= ' p.num_paiement, p.note,'; + $sql.= ' b.fk_account'; $sql.= ' FROM '.MAIN_DB_PREFIX.'c_paiement as c, '.MAIN_DB_PREFIX.'paiement as p'; $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'bank as b ON p.fk_bank = b.rowid '; $sql.= ' WHERE p.fk_paiement = c.id'; @@ -89,14 +90,15 @@ class Paiement $this->date = $this->db->jdate($obj->dp); $this->datepaye = $this->db->jdate($obj->dp); $this->numero = $obj->num_paiement; - $this->bank_account = $obj->fk_account; - $this->bank_line = $obj->fk_bank; $this->montant = $obj->amount; $this->note = $obj->note; $this->type_libelle = $obj->type_libelle; $this->type_code = $obj->type_code; $this->statut = $obj->statut; + $this->bank_account = $obj->fk_account; + $this->bank_line = $obj->fk_bank; + $this->db->free($result); return 1; }