diff --git a/htdocs/compta/paiement_charge.php b/htdocs/compta/paiement_charge.php index 7c1e1bf5c5d..b73b03074ca 100755 --- a/htdocs/compta/paiement_charge.php +++ b/htdocs/compta/paiement_charge.php @@ -32,6 +32,16 @@ include_once(DOL_DOCUMENT_ROOT."/compta/bank/account.class.php"); $chid=isset($_GET["id"])?$_GET["id"]:$_POST["id"]; +/* + * Sécurité accés client + */ +if ($user->societe_id > 0) +{ + $action = ''; + $socid = $user->societe_id; +} + + /* * Actions ajoute paiement */ @@ -40,7 +50,7 @@ if ($_POST["action"] == 'add_paiement') if ($_POST["paiementtype"] > 0) { - $datepaye = $db->idate(mktime(12, 0 , 0, + $datepaye = $db->idate(dolibarr_mktime(12, 0 , 0, $_POST["remonth"], $_POST["reday"], $_POST["reyear"])); @@ -93,15 +103,10 @@ if ($_POST["action"] == 'add_paiement') $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) - //{ - // $chid = $key; - // $fac = new Facture($db); - // $fac->fetch($chid); - // $fac->fetch_client(); - // $acc->add_url_line($bank_line_id, $paiement_id, DOL_URL_ROOT.'/compta/paiement/fiche.php?id=', "(paiement)"); - // $acc->add_url_line($bank_line_id, $fac->client->id, DOL_URL_ROOT.'/compta/fiche.php?socid=', $fac->client->nom); - //} + foreach ($paiement->amounts as $key => $value) + { + $acc->add_url_line($bank_line_id, $chid, DOL_URL_ROOT.'/compta/sociales/charges.php?id=', $chid); + } $db->commit(); @@ -111,29 +116,22 @@ if ($_POST["action"] == 'add_paiement') } else { $db->rollback(); - $fiche_erreur_message = "Echec de la création entrée compte: ".$db->error(); + $mesg = "Echec de la création entrée compte: ".$db->error(); } } else { $db->rollback(); - $fiche_erreur_message = "Echec de la création du paiement: paiement_id=$paiement_id ".$db->error(); + $mesg = "Echec de la création du paiement: paiement_id=$paiement_id ".$db->error(); } } else { - $fiche_erreur_message = "Vous devez sélectionner un mode de paiement"; + $mesg = "Vous devez sélectionner un mode de paiement"; } + $_GET["action"]='create'; } -/* - * Sécurité accés client - */ -if ($user->societe_id > 0) -{ - $action = ''; - $socid = $user->societe_id; -} /* * Affichage @@ -144,9 +142,9 @@ llxHeader(); $html=new Form($db); -if ($fiche_erreur_message) +if ($mesg) { - print "
$fiche_erreur_message

"; + print "
$mesg

"; } @@ -171,15 +169,15 @@ if ($_GET["action"] == 'create') print "Charge"; - print ''.$langs->trans("Ref").':'; - print ''.$chid.''; - print ''.$langs->trans("Type").":$charge->type_libelle\n"; - print "Période :$charge->periode\n"; - print ''.$langs->trans("Label").' :'.$charge->lib."\n"; - print "Date échéance :".dolibarr_print_date($charge->date_ech)."\n"; - - print ''.$langs->trans("AmountTTC").":".price($charge->amount).' '.$langs->trans("Currency".$conf->monnaie).''; + print ''.$langs->trans("Ref").''; + print ''.$chid.''; + print ''.$langs->trans("Type")."$charge->type_libelle\n"; + print ''.$langs->trans("Period")."$charge->periode\n"; + print ''.$langs->trans("Label").''.$charge->lib."\n"; + print ''.$langs->trans("DateDue")."".dolibarr_print_date($charge->date_ech)."\n"; + print ''.$langs->trans("AmountTTC")."".price($charge->amount).' '.$langs->trans("Currency".$conf->monnaie).''; + $sql = "SELECT sum(p.amount) as total"; $sql.= " FROM ".MAIN_DB_PREFIX."paiementcharge as p"; $sql.= " WHERE p.fk_charge = ".$chid; @@ -191,31 +189,33 @@ if ($_GET["action"] == 'create') $db->free(); } print ''.$langs->trans("AlreadyPayed").''.price($sumpayed).' '.$langs->trans("Currency".$conf->monnaie).''; + print "".$langs->trans("RemainderToPay")."".price($total - $sumpayed).' '.$langs->trans("Currency".$conf->monnaie).''; print "".$langs->trans("Payment").''; print ""; - print ''.$langs->trans("Date").' :'; + print ''.$langs->trans("Date").''; $html->select_date('','','','','',"add_paiement"); print ""; print ''.$langs->trans("Comments").''; - print ''.$langs->trans("Type").''; + print ''.$langs->trans("PaymentMode").''; $html->select_types_paiements($charge->paiementtype, "paiementtype"); print "\n"; - print ''; + print ''; - print "Numéro :
Numéro du chèque / virement\n"; + print ''; + print ''.$langs->trans('AccountToCredit').''; + print ''; + $html->select_comptes($charge->accountid, "accountid", 0, "courant=1"); // Affiche liste des comptes courant + print ''; - print 'Compte à créditer :'; - $html->select_comptes($charge->accountid, "accountid", 0, "courant=1"); // Affiche liste des comptes courant - print ''; + print ''.$langs->trans('Numero'); + print ' (Numéro chèque ou virement)'; // \todo a traduire + print "\n"; - print "".$langs->trans("RemainderToPay").":".price($total - $sumpayed).' '.$langs->trans("Currency".$conf->monnaie).''; -// print "Montant :\n"; - /* * Autres charges impayées */ @@ -240,7 +240,8 @@ if ($_GET["action"] == 'create') print ''; print ''; print ''; - print ''; + print ''; + print ''; print ''; print ''; print ''; @@ -260,7 +261,7 @@ if ($_GET["action"] == 'create') print ""; - print '\n"; if ($objp->date_ech > 0 ) diff --git a/htdocs/compta/sociales/charges.php b/htdocs/compta/sociales/charges.php index ffba9834453..7c859f1e3ed 100644 --- a/htdocs/compta/sociales/charges.php +++ b/htdocs/compta/sociales/charges.php @@ -149,7 +149,7 @@ if ($chid > 0) print ""; print "\n"; - print "\n"; + print "\n"; + print "\n"; $resteapayer = $cha->amount - $totalpaye; @@ -216,19 +216,21 @@ if ($chid > 0) print ""; - if ($cha->paye==0) + if ($cha->paye==0 && $_GET['action'] == 'edit') { - print ''; - print '"; - print '"; + print ''; + print '"; } else { print ''; print ""; - print ''; } - - + print ''; + print ''; print '
ChargeDate échéance'.$langs->trans("SocialContribution").''.$langs->trans("DateDue").''.$langs->trans("AmountTTC").''.$langs->trans("AlreadyPayed").''.$langs->trans("RemainderToPay").'
' . $objp->id; + print '' . $objp->id; print "
".$langs->trans("Period").""; - if ($cha->paye==0) + if ($cha->paye==0 && $_GET['action'] == 'edit') { print "period)."\">"; } @@ -197,8 +197,8 @@ if ($chid > 0) if ($cha->paye == 0) { - print "
Total payé:".price($totalpaye)."".$langs->trans("Currency".$conf->monnaie)."
Réclamé :".price($cha->amount)."".$langs->trans("Currency".$conf->monnaie)."
".$langs->trans("AlreadyPayed")." :".price($totalpaye)."".$langs->trans("Currency".$conf->monnaie)."
".$langs->trans("AmountExpected")." :".price($cha->amount)."".$langs->trans("Currency".$conf->monnaie)."
'.$langs->trans("Label").'
'.$langs->trans("DateDue")."date_ech)."\">
'.$langs->trans("AmountTTC")."amount."\">
'.$langs->trans("Label").''; + print ''; + print '
'.$langs->trans("DateDue").""; + print "date_ech)."\">"; + print "
'.$langs->trans("Label").''.$cha->lib.'
".$langs->trans("DateDue")."".dolibarr_print_date($cha->date_ech)."
'.$langs->trans("AmountTTC").''.price($cha->amount).'
'.$langs->trans("AmountTTC").''.price($cha->amount).'
'.$langs->trans("Status").''.$cha->getLibStatut(4).'
'; @@ -245,22 +247,28 @@ if ($chid > 0) print "
\n"; + // Editer + if ($cha->paye == 0 && $user->rights->tax->charges->creer) + { + print "id&action=edit\">".$langs->trans("Edit").""; + } + // Emettre paiement if ($cha->paye == 0 && round($resteapayer) > 0 && $user->rights->tax->charges->creer) { - print "id&action=create\">".$langs->trans("DoPaiement").""; + print "id&action=create\">".$langs->trans("DoPaiement").""; } // Classer 'payé' if ($cha->paye == 0 && round($resteapayer) <=0 && $user->rights->tax->charges->creer) { - print "id&action=payed\">".$langs->trans("ClassifyPayed").""; + print "id&action=payed\">".$langs->trans("ClassifyPayed").""; } // Supprimer if ($cha->paye == 0 && $totalpaye <=0 && $user->rights->tax->charges->supprimer) { - print "id&action=delete\">".$langs->trans("Delete").""; + print "id&action=delete\">".$langs->trans("Delete").""; } print "
";