diff --git a/htdocs/compta/bank/account.class.php b/htdocs/compta/bank/account.class.php
index b563d184ff6..19a14a55d5f 100644
--- a/htdocs/compta/bank/account.class.php
+++ b/htdocs/compta/bank/account.class.php
@@ -21,6 +21,7 @@
class Account {
var $rowid;
+
var $bank;
var $label;
@@ -40,40 +41,117 @@ class Account {
return 1;
}
+ /*
+ *
+ *
+ */
+ /*
+ *
+ *
+ *
+ */
+ Function create()
+ {
+ $sql = "INSERT INTO llx_bank_account (datec, label) values (now(),'$this->label');";
+ if ($this->db->query($sql))
+ {
+ if ($this->db->affected_rows())
+ {
+ $this->id = $this->db->last_insert_id();
+ $this->update();
+ return $this->id;
+ }
+ }
+ else
+ {
+ print $this->db->error();
+ }
+ }
+ /*
+ *
+ *
+ */
- Function fetch($id) {
+ Function update()
+ {
+ $sql = "UPDATE llx_bank_account SET ";
+
+ $sql .= " bank = '" .$this->bank ."'";
+ $sql .= ",label = '".$this->label ."'";
+
+ $sql .= ",code_banque='".$this->code_banque."'";
+ $sql .= ",code_guichet='".$this->code_guichet."'";
+ $sql .= ",number='".$this->number."'";
+ $sql .= ",cle_rib='".$this->cle_rib."'";
+ $sql .= ",bic='".$this->bic."'";
+ $sql .= ",courant = ".$this->courant;
+
+ $sql .= " WHERE rowid = $this->id";
+
+ $result = $this->db->query($sql);
+
+ if ($result)
+ {
+ if ($this->db->affected_rows())
+ {
+ return 1;
+ }
+ }
+ else
+ {
+ print $this->db->error();
+ }
+ }
+ /*
+ *
+ *
+ */
+ Function fetch($id)
+ {
$this->id = $id;
- $sql = "SELECT rowid, label, bank, number, courant FROM llx_bank_account";
+ $sql = "SELECT rowid, label, bank, number, courant, code_banque,code_guichet,cle_rib FROM llx_bank_account";
$sql .= " WHERE rowid = ".$id;
$result = $this->db->query($sql);
- if ($result) {
- if ($this->db->num_rows()) {
- $obj = $this->db->fetch_object($result , 0);
+ if ($result)
+ {
+ if ($this->db->num_rows())
+ {
+ $obj = $this->db->fetch_object($result , 0);
+
+ $this->bank = $obj->bank;
+ $this->label = $obj->label;
+ $this->courant = $obj->courant;
- $this->bank = $obj->bank;
- $this->label = $obj->label;
- $this->number = $obj->number;
- $this->courant = $obj->courant;
+ $this->code_banque = $obj->code_banque;
+ $this->code_guichet = $obj->code_guichet;
+ $this->number = $obj->number;
+ $this->cle_rib = $obj->cle_rib;
+ }
+ $this->db->free();
}
- $this->db->free();
- }
}
-
- Function solde() {
+ /*
+ *
+ *
+ */
+ Function solde()
+ {
$sql = "SELECT sum(amount) FROM llx_bank WHERE fk_account=$this->id AND dateo <=" . $this->db->idate(time() );
$result = $this->db->query($sql);
- if ($result) {
- if ($this->db->num_rows()) {
- $solde = $this->db->result(0,0);
+ if ($result)
+ {
+ if ($this->db->num_rows())
+ {
+ $solde = $this->db->result(0,0);
- return $solde;
+ return $solde;
+ }
+ $this->db->free();
}
- $this->db->free();
- }
}
diff --git a/htdocs/compta/bank/account.php3 b/htdocs/compta/bank/account.php3
index d595a60ee8b..1e8c02d405e 100644
--- a/htdocs/compta/bank/account.php3
+++ b/htdocs/compta/bank/account.php3
@@ -28,62 +28,80 @@
require("./pre.inc.php3");
require("./bank.lib.php3");
-llxHeader();
+
$db = new Db();
-
-
-if ($account) {
-
- if ($action == 'add') {
- $author = $GLOBALS["REMOTE_USER"];
- if ($credit > 0) {
- $amount = $credit ;
- } else {
- $amount = - $debit ;
- }
-
- $dateop = "$dateoy" . "$dateo";
+if ($HTTP_POST_VARS["action"] == 'add' && $account)
+{
- if ($num_chq) {
+ if ($credit > 0)
+ {
+ $amount = $credit ;
+ }
+ else
+ {
+ $amount = - $debit ;
+ }
+
+ $dateop = "$dateoy" . "$dateo";
+
+ if ($num_chq)
+ {
$sql = "INSERT INTO llx_bank (datec, dateo, label, amount, author, num_chq,fk_account, fk_type)";
$sql .= " VALUES (now(), $dateop, '$label', $amount,'$author',$num_chq,$account,'$operation')";
- } else {
+ }
+ else
+ {
$sql = "INSERT INTO llx_bank (datec, dateo, label, amount, author,fk_account,fk_type)";
$sql .= " VALUES (now(), $dateop, '$label', $amount,'$author',$account,'$operation')";
}
-
- $result = $db->query($sql);
- if ($result) {
+
+ $result = $db->query($sql);
+ if ($result)
+ {
$rowid = $db->last_insert_id();
- if ($cat1) {
- $sql = "INSERT INTO llx_bank_class (lineid, fk_categ) VALUES ($rowid, $cat1)";
- $result = $db->query($sql);
- }
- } else {
+ if ($cat1)
+ {
+ $sql = "INSERT INTO llx_bank_class (lineid, fk_categ) VALUES ($rowid, $cat1)";
+ $result = $db->query($sql);
+ }
+ Header("Location: $PHP_SELF?account=$account");
+ }
+ else
+ {
print $db->error();
print "
$sql";
}
-
- }
- if ($action == 'del') {
- bank_delete_line($db, $rowid);
- }
+
+}
+if ($action == 'del' && $account)
+{
+ bank_delete_line($db, $rowid);
+}
- if ($vline) {
- $viewline = $vline;
- } else {
- $viewline = 20;
- }
- print "Bank - Reload -";
+llxHeader();
+
+if ($account)
+{
+
+ if ($vline)
+ {
+ $viewline = $vline;
+ }
+ else
+ {
+ $viewline = 20;
+ }
+
+ print "Bank - -";
print "Voir tout ";
print "
";
diff --git a/htdocs/compta/bank/config.php3 b/htdocs/compta/bank/config.php3
index 32a3c1b1244..ca46563a09f 100644
--- a/htdocs/compta/bank/config.php3
+++ b/htdocs/compta/bank/config.php3
@@ -25,14 +25,6 @@ require("./bank.lib.php3");
llxHeader();
$db = new Db();
-if ($action == 'add')
-{
- $author = $GLOBALS["REMOTE_USER"];
-
- $sql = "INSERT INTO llx_bank_account (label, number, bank) VALUES ('$label','$number','$bank')";
- $result = $db->query($sql);
-}
-
print_titre("Configuration");
print "";
@@ -55,7 +47,7 @@ if ($result) {
$objp = $db->fetch_object( $i);
- print "$objp->rowid $objp->label $objp->bank $objp->number ";
+ print "$objp->rowid rowid\">$objp->label $objp->bank $objp->number ";
$i++;
@@ -63,16 +55,27 @@ if ($result) {
$db->free();
}
print "
";
-echo ' ';
-print "";
+
+print "
";
+
+/*
+ * Case 1
+ */
+
+print "";
+print 'Nouveau compte ';
+/*
+ * Case 2
+ */
+
+print "- ";
+print "- ";
+print "- ";
+
+print "
";
+
+
$db->close();
diff --git a/htdocs/compta/bank/fiche.php b/htdocs/compta/bank/fiche.php
new file mode 100644
index 00000000000..83c841119fd
--- /dev/null
+++ b/htdocs/compta/bank/fiche.php
@@ -0,0 +1,220 @@
+
+ *
+ * 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
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * $Id$
+ * $Source$
+ */
+
+require("./pre.inc.php3");
+
+llxHeader();
+
+$db = new Db();
+
+if ($HTTP_POST_VARS["action"] == 'add')
+{
+ $account = new Account($db,0);
+
+ $account->bank = $HTTP_POST_VARS["bank"];
+ $account->label = $HTTP_POST_VARS["label"];
+
+ $account->courant = $HTTP_POST_VARS["courant"];
+
+ $account->code_banque = $HTTP_POST_VARS["code_banque"];
+ $account->code_guichet = $HTTP_POST_VARS["code_guichet"];
+ $account->number = $HTTP_POST_VARS["number"];
+ $account->cle_rib = $HTTP_POST_VARS["cle_rib"];
+ $account->bic = $HTTP_POST_VARS["bic"];
+
+ $id = $account->create($user->id);
+
+}
+
+if ($action == 'update')
+{
+ $account = new User($db, $id);
+ $account->fetch();
+
+ $account->nom = $nom;
+ $account->prenom = $prenom;
+ $account->login = $login;
+ $account->email = $email;
+
+ if (! $account->update($id, $user))
+ {
+ print $account->error();
+ }
+}
+
+
+
+/* ************************************************************************** */
+/* */
+/* Nouvel compte */
+/* */
+/* ************************************************************************** */
+
+if ($action == 'create')
+{
+
+ print 'Nouveau compte bancaire
';
+ print '
';
+ print ' ';
+ print '';
+ }
+
+ }
+
+}
+
+
+
+$db->close();
+
+llxFooter("Dernière modification $Date$ révision $Revision$ ");
+?>
diff --git a/htdocs/cyberpaiement.class.php b/htdocs/cyberpaiement.class.php
new file mode 100644
index 00000000000..3abe67cc6b8
--- /dev/null
+++ b/htdocs/cyberpaiement.class.php
@@ -0,0 +1,234 @@
+
+ *
+ * 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
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * $Id$
+ * $Source$
+ *
+ */
+
+class Cyberpaiement
+{
+
+ Function Cyberpaiement($conf)
+ /*
+ * Initialisation des valeurs par défaut
+ */
+ {
+
+ /* Numéro abonné Internet : 6 chiffres */
+
+ $this->champ000 = $conf->bplc->numabonne;
+
+ /* Code activité commercant : 4 chiffres */
+
+ $this->champ001 = $conf->bplc->code_activite;
+
+ /* Numéro de contrat : 10 chiffres */
+
+ $this->champ002 = $conf->bplc->num_contrat;
+
+ /* Type de paiement */
+
+ $this->champ003 = $conf->bplc->typepaiement;
+
+ /* Nom du serveur commercant, champ purement informatif */
+
+ $this->champ004 = trim($conf->bplc->nom_serveur);
+
+ /* Url du CGI de retour */
+
+ $this->champ005 = $conf->bplc->cgi_retour;
+
+ /* Nom du commercant */
+
+ $this->champ006 = $conf->bplc->nom_commercant;
+
+ /* url retour */
+
+ $this->champ007 = $conf->bplc->url_retour;
+
+ /* Email confirmation commercant*/
+
+ $this->champ008 = trim($conf->bplc->email_commercant);
+
+ /* Devise : EUR*/
+
+ $this->champ202 = $conf->bplc->devise;
+
+ /* Adhérent : 01 */
+
+ $this->champ900 = $conf->bplc->adherent;
+
+
+ /* *********************************************** */
+ /* Initialisation à vide des valeurs qui ne seront */
+ /* pas transmises */
+ /* *********************************************** */
+
+ $this->champ100 = ".";
+ $this->champ101 = ".";
+ $this->champ102 = ".";
+ $this->champ103 = ".";
+ $this->champ104 = ".";
+ $this->champ106 = ".";
+ $this->champ107 = ".";
+ $this->champ108 = ".";
+ $this->champ109 = ".";
+ $this->champ110 = ".";
+
+
+ }
+
+ /* ********************** */
+ /* */
+ /* Client */
+ /* */
+ /* ********************** */
+
+ Function set_client($nom,$prenom,$email,$societe='')
+ {
+ /* Nom */
+
+ $this->champ100 = $nom;
+
+ /* Prenom */
+
+ $this->champ101 = $prenom;
+
+ /* Société */
+ if (strlen(trim($societe)))
+ {
+ $this->champ102 = $societe;
+ }
+ /* Téléphone */
+ if (strlen(trim($telephone)))
+ {
+ $this->champ103 = $telephone;
+ }
+
+ /* Adresse email */
+
+ $this->champ104 = trim($email);
+
+ /* Fax */
+ if (strlen(trim($fax)))
+ {
+ $this->champ106 = $fax;
+ }
+
+ /* Adresse numéro et rue */
+ if (strlen(trim($adresse)))
+ {
+ $this->champ107 = $adresse;
+ }
+
+ /* Ville */
+ if (strlen(trim($ville)))
+ {
+ $this->champ108 = $ville;
+ }
+
+ /* Code Postal */
+ if (strlen(trim($cp)))
+ {
+ $this->champ109 = trim($cp);
+ }
+
+ /* Code Pays : purement Informatif */
+ if (strlen(trim($pays)))
+ {
+ $this->champ110 = trim($pays);
+ }
+ }
+ /* ********************** */
+ /* */
+ /* Commande */
+ /* */
+ /* ********************** */
+
+ Function set_commande($ref, $montant)
+ {
+ /* Référence */
+
+ $this->champ200 = $ref;
+
+ /* Montant */
+
+ $this->champ201 = $montant;
+ }
+ /*
+ *
+ *
+ *
+ */
+ Function print_hidden()
+ {
+ print ' ';
+ print "\n";
+ print ' ';
+ print "\n";
+ print ' ';
+ print "\n";
+ print ' ';
+ print "\n";
+ print ' ';
+ print "\n";
+ print ' ';
+ print "\n";
+ print ' ';
+ print "\n";
+ print ' ';
+ print "\n";
+ print ' ';
+ print "\n";
+ print ' ';
+ print "\n";
+ print ' ';
+ print "\n";
+ print ' ';
+ print "\n";
+ print ' ';
+ print "\n";
+ print ' ';
+ print "\n";
+ print ' ';
+ print "\n";
+ print ' ';
+ print "\n";
+ print ' ';
+ print "\n";
+ print ' ';
+ print "\n";
+ print ' ';
+ print "\n";
+ print ' ';
+ print "\n";
+ print ' ';
+ print "\n";
+ print ' ';
+ print "\n";
+ print ' ';
+ print "\n";
+ }
+ /*
+ *
+ *
+ *
+ */
+
+}
+?>
diff --git a/htdocs/public/dons/testretour.php b/htdocs/public/dons/testretour.php
index 30773b6c58c..7edf05fe535 100644
--- a/htdocs/public/dons/testretour.php
+++ b/htdocs/public/dons/testretour.php
@@ -23,14 +23,16 @@
-
-
+
+
-
+
-
+
+
+
diff --git a/htdocs/retourbplc.class.php b/htdocs/retourbplc.class.php
index 5eda2b0ef0c..cc97b880fc9 100644
--- a/htdocs/retourbplc.class.php
+++ b/htdocs/retourbplc.class.php
@@ -26,6 +26,10 @@ class Retourbplc
var $db;
var $ipclient;
+ var $montant;
+ var $num_compte;
+ var $ref_commande;
+ var $num_contrat;
var $num_transaction;
var $date_transaction;
var $heure_transaction;
@@ -49,30 +53,228 @@ class Retourbplc
Function insertdb()
{
- $sql = "INSERT INTO transaction_bplc";
- $sql .= " ( ipclient, num_transaction, date_transaction, heure_transaction, num_autorisation, cle_acceptation, code_retour, ref_commande)";
- $sql .= " VALUES ('$this->ipclient','$this->num_transaction','$this->date_transaction','$this->heure_transaction','$this->num_autorisation','$this->cle_acceptation','$this->code_retour','$this->ref_commande')";
+ if ($this->check_key($this->cle_acceptation))
+ {
- $result = $this->db->query($sql);
-
- if ($result)
- {
- return 1;
- }
- else
- {
- print $this->db->error();
- print " $sql ";
- return 0;
- }
+ $sql = "INSERT INTO transaction_bplc";
+ $sql .= " (ipclient,
+ num_transaction,
+ date_transaction,
+ heure_transaction,
+ num_autorisation,
+ cle_acceptation,
+ code_retour,
+ ref_commande)";
+
+ $sql .= " VALUES ('$this->ipclient',
+ '$this->num_transaction',
+ '$this->date_transaction',
+ '$this->heure_transaction',
+ '$this->num_autorisation',
+ '$this->cle_acceptation',
+ '$this->code_retour',
+ '$this->ref_commande')";
+
+ $result = $this->db->query($sql);
+
+ if ($result)
+ {
+ return 1;
+ }
+ else
+ {
+ print $this->db->error();
+ print " $sql ";
+ return 0;
+ }
+ }
}
-
-
/*
*
*
*
*/
+ Function check_key($key)
+ {
+ $A = $this->montant;
+ $B = $this->num_contrat;
+ $C = $this->num_transaction;
+ $D = $this->ref_commande;
+ $E = $this->num_compte;
+
+ /*
+ * Etape 1
+ *
+ */
+ $A1 = $A . $E;
+ $B1 = $B . $E;
+ $C1 = $C . $E;
+ $D1 = $D . $E;
+
+ $map = range(0, 9);
+
+ $L1= $this->cle_luhn($A1, $map);
+
+ $L2= $this->cle_luhn($B1, $map);
+
+ $L3= $this->cle_luhn($C1, $map);
+
+ $L4= $this->cle_luhn($D1, $map);
+ /*
+ * Etape 2
+ *
+ */
+
+ $N1 = $L1 . $L2 . $L3 . $L4;
+ $N0 = $L1 + $L2 + $L3 + $L4;
+
+ $C5 = $this->corres($N0);
+ /*
+ * Comparaison
+ *
+ */
+
+ if ($key == $this->calcul_pos($N1,$N0, $C5))
+ {
+ return 1;
+ }
+ else
+ {
+ return 0;
+ }
+ }
+ /*
+ *
+ *
+ */
+ Function corres($value)
+ {
+ $map[0] = 0;
+
+ for ($i = 65 ; $i < 91 ; $i++)
+ {
+ $map[$i-64] = chr($i);
+ }
+
+ for ($i = 0 ; $i < 10 ; $i++)
+ {
+ $map[27+$i] = $i;
+ }
+
+ return $map[$value];
+
+ }
+ /*
+ *
+ *
+ *
+ *
+ */
+ Function cle_luhn($cle, $map)
+ {
+ $buffer = $this->array_reverse($cle);
+
+ $totalVal = 0;
+ $flip = 1;
+
+ reset ($buffer);
+
+ while (list($key, $posVal) = each ($buffer))
+ {
+
+ if (!isset($map[$posVal])){
+ return FALSE;
+ }
+
+ $posVal = $map[$posVal];
+
+ if ( $flip = !$flip)
+ {
+ $posVal *= 2;
+ }
+
+ while ($posVal>0)
+ {
+ $totalVal += $posVal % 10;
+ $posVal = floor($posVal / 10);
+ }
+ }
+
+ return substr($totalVal, strlen($totalVal)-1, 1);
+ }
+ /*
+ * Postion de C5 dans N0
+ *
+ *
+ */
+ Function calcul_pos($N1, $N0, $C5)
+ {
+ if ($N0 >= 0 && $N0 <= 6)
+ {
+ /* clé = 2 premiers de N0 . C5 . 2 derniers de N0 */
+
+ $cle = substr($N1,0,2) . $C5 . substr($N1,2,2);
+
+ }
+ elseif ($N0 >= 7 && $N0 <= 14)
+ {
+ /* clé = 4 premiers de N0 . C5 */
+
+ $cle = substr($N1,0,4) . $C5;
+
+ }
+ elseif ($N0 >= 15 && $N0 <= 21)
+ {
+ /* clé = premier de N1 . C5 . 3 derniers de N1 */
+
+ $cle = substr($N1,0,1) . $C5 . substr($N1,1,3);
+
+ }
+ elseif ($N0 >= 22 && $N0 <= 29)
+ {
+ /* clé = C5 . 4 derniers de N1 */
+
+ $cle = $C5 . substr($N1,0,4);
+
+ }
+ elseif ($N0 >= 30 && $N0 <= 36)
+ {
+ /* clé = 3 premiers de N1 . C5 . dernier de N1 */
+
+ $cle = substr($N1,0,3) . $C5 . substr($N1,1,1);
+
+ }
+ else
+ {
+ $cle = "ERREUR";
+ }
+
+ return $cle;
+
+ }
+ /*
+ * Retournement du tableau
+ *
+ *
+ */
+ Function array_reverse($string)
+ {
+
+ $len = strlen($string);
+
+ $i = $len;
+ $j = 0;
+ $rever = array();
+ while ($i > 0)
+ {
+ $rever[$j]= substr($string, $i-1, 1);
+ $i = $i - 1;
+ $j = $j + 1;
+ }
+
+
+ return $rever;
+ }
}
?>
diff --git a/mysql/tables/llx_bank_account.sql b/mysql/tables/llx_bank_account.sql
index 8e7a9e46bc0..473a10cf9b9 100644
--- a/mysql/tables/llx_bank_account.sql
+++ b/mysql/tables/llx_bank_account.sql
@@ -23,12 +23,14 @@
create table llx_bank_account
(
rowid integer AUTO_INCREMENT PRIMARY KEY,
+ datec datetime,
+ tms timestamp,
label varchar(30),
bank varchar(255),
- number varchar(255),
code_banque varchar(7),
code_guichet varchar(6),
+ number varchar(255),
cle_rib varchar(5),
bic varchar(10),