diff --git a/htdocs/compta/sociales/charges.php b/htdocs/compta/sociales/charges.php index 8495eddd510..d07c95002ef 100644 --- a/htdocs/compta/sociales/charges.php +++ b/htdocs/compta/sociales/charges.php @@ -28,33 +28,41 @@ if (!$user->admin && !$user->rights->compta->charges) accessforbidden(); require("../../chargesociales.class.php"); -require("../../paiement.class.php"); +//require("../../paiement_charge.class.php"); require("../bank/account.class.php"); - llxHeader(); +$chid=isset($_GET["id"])?$_GET["id"]:$_POST["id"]; + /* *************************************************************************** */ /* */ /* Mode fiche */ /* */ /* *************************************************************************** */ -if ($_GET["id"] > 0) +if ($chid > 0) { $html = new Form($db); - $cha = New ChargeSociales($db); - if ( $cha->fetch($_GET["id"]) > 0) + $cha = new ChargeSociales($db); + + if ( $cha->fetch($chid) > 0) { + /* * Charge */ - print_titre("Charge sociale : ".$cha->id); - print "
"; + //$head[0][0] = DOL_URL_ROOT.'/comm/propal.php?propalid='.$propal->id; + $head[0][1] = "Charge sociale : No $cha->id"; + $h = 1; + $a = 0; + + dolibarr_fiche_head($head, $a); + /* - * Confirmation de la suppression de la facture + * Confirmation de la suppression de la charge * */ if ($_GET["action"] == 'delete') @@ -65,25 +73,83 @@ if ($_GET["id"] > 0) print "
id&action=update\" method=\"post\">"; print ''; - print ""; - print ""; + + print ""; + + print ""; + print '"; + + print ""; + if ($cha->paye==0) { - print ''; - print ""; - print ""; + print ''; + print ""; + print ""; } else { - print ''; - print ""; - print ""; + print ''; + print ""; + print ""; } - print ""; + + + print ""; print "
Type$cha->type_libelle
PériodeNA
Type$cha->type_libellePaiements
PériodeNA'; + + /* + * Paiements + */ + $sql = "SELECT ".$db->pdate("datep")." as dp, p.amount,"; + $sql .= "c.libelle as paiement_type, p.num_paiement, p.rowid"; + $sql .= " FROM ".MAIN_DB_PREFIX."paiementcharge as p, ".MAIN_DB_PREFIX."c_paiement as c "; + $sql .= " WHERE p.fk_charge = ".$chid." AND p.fk_typepaiement = c.id"; + $sql .= " ORDER BY dp DESC"; + + $result = $db->query($sql); + if ($result) + { + $num = $db->num_rows(); + $i = 0; $total = 0; + echo ''; + print ''; + print ""; + + $var=True; + while ($i < $num) + { + $objp = $db->fetch_object( $i); + $var=!$var; + print "\n"; + print "\n"; + print '\n"; + print ""; + $totalpaye += $objp->amount; + $i++; + } + + if ($fac->paye == 0) + { + print "\n"; + print "\n"; + + $resteapayer = $cha->amount - $totalpaye; + + print ""; + print "\n"; + } + print "
DateTypeMontant 
"; + //print ''.img_file().''; + print dolibarr_print_date($objp->dp)."$objp->paiement_type $objp->num_paiement'.price($objp->amount)."".MAIN_MONNAIE."
Total payé:".price($totalpaye)."".MAIN_MONNAIE."
Réclamé :".price($cha->amount)."".MAIN_MONNAIE."
Reste à payer :".price($resteapayer)."".MAIN_MONNAIE."
"; + $db->free(); + } else { + print $db->error(); + } + print "
Libellé
Date d'échéancedate_ech)."\">Date de paiementNA
Montantamount\"> 
Libellé
Date d'échéancedate_ech)."\">
Montant TTCamount\">
Libellé'.stripslashes($cha->lib).'
Date d'échéance".strftime("%Y%m%d",$cha->date_ech)."Date de paiement".strftime("%Y%m%d",$cha->date_pai)."
Montant$cha->amount 
Libellé'.stripslashes($cha->lib).'
Date d'échéance".dolibarr_print_date($cha->date_ech)."
Montant TTC".price($cha->amount)."
Statut".($cha->paye==0?"Non paye":"Payé")." 
Statut".$cha->getLibStatut()."
"; print "
\n"; - + print ''; if (! $_GET["action"]) { @@ -91,7 +157,7 @@ if ($_GET["id"] > 0) * Boutons actions */ - print "
\n"; + print "
\n"; // Supprimer if ($cha->paye == 0 && $user->rights->facture->supprimer) @@ -102,7 +168,7 @@ if ($_GET["id"] > 0) // Emettre paiement if ($cha->paye == 0 && $user->rights->facture->paiement) { - print "id&action=create\">Emettre paiement"; + print "id&action=create\">Emettre paiement"; } // Classer 'payé' @@ -114,11 +180,6 @@ if ($_GET["id"] > 0) print "
"; } - if ($_GET["action"] == 'create') - { - print "Cette fonction n'a pas encore été implémentée"; - - } if ($_GET["action"] == 'payed') { print "Cette fonction n'a pas encore été implémentée";