diff --git a/htdocs/adherents/cotisations.php b/htdocs/adherents/cotisations.php index bca9e6e3610..378cb79ec29 100644 --- a/htdocs/adherents/cotisations.php +++ b/htdocs/adherents/cotisations.php @@ -21,11 +21,10 @@ * */ require("./pre.inc.php"); +require(DOL_DOCUMENT_ROOT."/compta/bank/account.class.php"); llxHeader(); -//$db = new Db(); - if ($action == 'add') { $datepaye = $db->idate(mktime(12, 0 , 0, $pmonth, $pday, $pyear)); @@ -44,7 +43,53 @@ if ($action == 'add') { $action = ''; } - +// Insertion de la cotisation dans le compte banquaire +if ($HTTP_POST_VARS["action"] == '2bank' && $HTTP_POST_VARS["rowid"] !=''){ + if (defined("ADHERENT_BANK_USE") && ADHERENT_BANK_USE !=0){ + $dateop=strftime("%Y%m%d",time()); + $sql="SELECT cotisation FROM llx_cotisation WHERE rowid=".$HTTP_POST_VARS["rowid"]." "; + $result = $db->query($sql); + if ($result) + { + $num = $db->num_rows(); + if ($num>0) + { + $objp = $db->fetch_object(0); + $amount=$objp->cotisation; + $acct=new Account($db,ADHERENT_BANK_ACCOUNT); + $insertid=$acct->addline($dateop, $HTTP_POST_VARS["operation"], $HTTP_POST_VARS["label"], $amount, $HTTP_POST_VARS["num_chq"],ADHERENT_BANK_CATEGORIE); + if ($insertid == '') + { + print "
Probleme d'insertion : ".$db->error(); + } + else + { + // met a jour la table cotisation + $sql="UPDATE llx_cotisation SET fk_bank=$insertid WHERE rowid=".$HTTP_POST_VARS["rowid"]." "; + $result = $db->query($sql); + if ($result) + { + //Header("Location: $PHP_SELF"); + } + else + { + print "
Probleme d'insertion $sql : ".$db->error(); + } + } + } + else + { + print "
Probleme SQL : $sql : ".$db->error(); + } + } + else + { + print "
Probleme SQL : $sql : ".$db->error(); + } + + + } +} if ($sortorder == "") { $sortorder="DESC"; } if ($sortfield == "") { $sortfield="c.dateadh"; } @@ -76,7 +121,7 @@ if ($result) $i++; } } -$sql = "SELECT d.rowid, d.prenom, d.nom, d.societe, c.cotisation, ".$db->pdate("c.dateadh")." as dateadh"; +$sql = "SELECT d.rowid, d.prenom, d.nom, d.societe, c.cotisation, ".$db->pdate("c.dateadh")." as dateadh, c.fk_bank as bank, c.rowid as crowid"; $sql .= " FROM llx_adherent as d, llx_cotisation as c"; $sql .= " WHERE d.rowid = c.fk_adherent"; if(isset($date_select) && $date_select != ''){ @@ -111,21 +156,27 @@ if ($result) print '