diff --git a/htdocs/install/mysql/migration/7.0.0-8.0.0.sql b/htdocs/install/mysql/migration/7.0.0-8.0.0.sql
index eb3c865c106..227562ea9bc 100644
--- a/htdocs/install/mysql/migration/7.0.0-8.0.0.sql
+++ b/htdocs/install/mysql/migration/7.0.0-8.0.0.sql
@@ -97,3 +97,23 @@ ALTER TABLE llx_c_payment_term CHANGE COLUMN rowid rowid INTEGER AUTO_INCREMENT
ALTER TABLE llx_c_payment_term ADD UNIQUE INDEX uk_c_payment_term_code(entity, code);
ALTER TABLE llx_oauth_token ADD COLUMN tokenstring text;
+
+-- Add field for payment modes
+ALTER TABLE llx_societe_rib ADD COLUMN type varchar(32) DEFAULT 'ban' after rowid;
+ALTER TABLE llx_societe_rib ADD COLUMN last_four varchar(4);
+ALTER TABLE llx_societe_rib ADD COLUMN card_type varchar(255);
+ALTER TABLE llx_societe_rib ADD COLUMN cvn varchar(255);
+ALTER TABLE llx_societe_rib ADD COLUMN exp_date_month INTEGER;
+ALTER TABLE llx_societe_rib ADD COLUMN exp_date_year INTEGER;
+ALTER TABLE llx_societe_rib ADD COLUMN country_code varchar(10);
+ALTER TABLE llx_societe_rib ADD COLUMN approved integer DEFAULT 0;
+ALTER TABLE llx_societe_rib ADD COLUMN email varchar(255);
+ALTER TABLE llx_societe_rib ADD COLUMN ending_date date;
+ALTER TABLE llx_societe_rib ADD COLUMN max_total_amount_of_all_payments double(24,8);
+ALTER TABLE llx_societe_rib ADD COLUMN preapproval_key varchar(255);
+ALTER TABLE llx_societe_rib ADD COLUMN starting_date date;
+ALTER TABLE llx_societe_rib ADD COLUMN total_amount_of_all_payments double(24,8);
+ALTER TABLE llx_societe_rib ADD COLUMN stripe_card_ref varchar(128);
+ALTER TABLE llx_societe_rib ADD COLUMN status integer NOT NULL DEFAULT 1;
+
+
diff --git a/htdocs/install/mysql/tables/llx_societe_rib.sql b/htdocs/install/mysql/tables/llx_societe_rib.sql
index 168a2803c9d..6157af37830 100644
--- a/htdocs/install/mysql/tables/llx_societe_rib.sql
+++ b/htdocs/install/mysql/tables/llx_societe_rib.sql
@@ -17,15 +17,19 @@
-- You should have received a copy of the GNU General Public License
-- along with this program. If not, see .
--
+-- Table with the payment modes of a thirdparty (BAN, Paypal, Card, ...)
-- =============================================================================
create table llx_societe_rib
(
rowid integer AUTO_INCREMENT PRIMARY KEY,
+ type varchar(32) DEFAULT 'ban', -- 'ban' or 'paypal' or 'card' or 'stripe'
+ label varchar(30),
fk_soc integer NOT NULL,
datec datetime,
tms timestamp,
- label varchar(30),
+
+ -- For BAN
bank varchar(255), -- bank name
code_banque varchar(128), -- bank code
code_guichet varchar(6), -- desk code
@@ -37,10 +41,28 @@ create table llx_societe_rib
proprio varchar(60),
owner_address varchar(255),
default_rib smallint NOT NULL DEFAULT 0,
-
+ -- For BAN direct debit feature
rum varchar(32), -- RUM value to use for SEPA generation
date_rum date, -- Date of mandate
frstrecur varchar(16) default 'FRST', -- 'FRST' or 'RECUR'
-
+ --For credit card
+ last_four varchar(4), -- last 4
+ card_type varchar(255), -- card type 'VISA', 'MC' , ...
+ cvn varchar(255),
+ exp_date_month INTEGER,
+ exp_date_year INTEGER,
+ country_code varchar(10),
+ --For Paypal
+ approved INTEGER DEFAULT 0,
+ email varchar(255),
+ ending_date date,
+ max_total_amount_of_all_payments double(24,8),
+ preapproval_key varchar(255),
+ starting_date date,
+ total_amount_of_all_payments double(24,8),
+ --For Stripe
+ stripe_card_ref varchar(128), -- 'card_...'
+
+ status integer NOT NULL DEFAULT 1, -- 1=ACTIVE, 0=IN_TRASH
import_key varchar(14) -- import key
)ENGINE=innodb;
diff --git a/htdocs/societe/canvas/company/tpl/card_view.tpl.php b/htdocs/societe/canvas/company/tpl/card_view.tpl.php
index 3865e9b95a0..24ddfbaaaac 100644
--- a/htdocs/societe/canvas/company/tpl/card_view.tpl.php
+++ b/htdocs/societe/canvas/company/tpl/card_view.tpl.php
@@ -185,7 +185,7 @@ for ($i=1; $i<=4; $i++) {
trans('RIB'); ?> |
rights->societe->creer) { ?>
- control->tpl['image_edit']; ?>
+ control->tpl['image_edit']; ?>
diff --git a/htdocs/societe/canvas/individual/tpl/card_view.tpl.php b/htdocs/societe/canvas/individual/tpl/card_view.tpl.php
index 359f4ec7b44..fd9b3487f50 100644
--- a/htdocs/societe/canvas/individual/tpl/card_view.tpl.php
+++ b/htdocs/societe/canvas/individual/tpl/card_view.tpl.php
@@ -144,7 +144,7 @@ dol_fiche_head($head, 'card', $langs->trans("ThirdParty"),0,'company');
| trans('RIB'); ?> |
rights->societe->creer) { ?>
- control->tpl['image_edit']; ?>
+ control->tpl['image_edit']; ?>
diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php
index b936a431080..f7098d88478 100644
--- a/htdocs/societe/class/societe.class.php
+++ b/htdocs/societe/class/societe.class.php
@@ -1662,7 +1662,7 @@ class Societe extends CommonObject
return 1;
}
}
-
+
/**
* Definit la societe comme un client
*
@@ -1674,7 +1674,7 @@ class Societe extends CommonObject
function set_remise_supplier($remise, $note, User $user)
{
global $conf, $langs;
-
+
// Nettoyage parametres
$note=trim($note);
if (! $note)
@@ -1682,15 +1682,15 @@ class Societe extends CommonObject
$this->error=$langs->trans("ErrorFieldRequired",$langs->trans("NoteReason"));
return -2;
}
-
+
dol_syslog(get_class($this)."::set_remise_supplier ".$remise.", ".$note.", ".$user->id);
-
+
if ($this->id)
{
$this->db->begin();
-
+
$now=dol_now();
-
+
// Positionne remise courante
$sql = "UPDATE ".MAIN_DB_PREFIX."societe ";
$sql.= " SET remise_supplier = '".$this->db->escape($remise)."'";
@@ -1702,7 +1702,7 @@ class Societe extends CommonObject
$this->error=$this->db->error();
return -1;
}
-
+
// Ecrit trace dans historique des remises
$sql = "INSERT INTO ".MAIN_DB_PREFIX."societe_remise_supplier";
$sql.= " (entity, datec, fk_soc, remise_supplier, note, fk_user_author)";
@@ -1710,7 +1710,7 @@ class Societe extends CommonObject
$sql.= " '".$this->db->escape($note)."',";
$sql.= " ".$user->id;
$sql.= ")";
-
+
$resql=$this->db->query($sql);
if (! $resql)
{
@@ -1718,7 +1718,7 @@ class Societe extends CommonObject
$this->error=$this->db->lasterror();
return -1;
}
-
+
$this->db->commit();
return 1;
}
@@ -2037,7 +2037,7 @@ class Societe extends CommonObject
else if ($option == 'ban')
{
$label.= '' . $langs->trans("ShowBan") . '';
- $linkstart = 'id;
}
// By default
diff --git a/htdocs/societe/paymentmodes.php b/htdocs/societe/paymentmodes.php
index 4bd19295e7a..bf7f05ba50a 100644
--- a/htdocs/societe/paymentmodes.php
+++ b/htdocs/societe/paymentmodes.php
@@ -23,9 +23,9 @@
*/
/**
- * \file htdocs/societe/rib.php
+ * \file htdocs/societe/paymentmodes.php
* \ingroup societe
- * \brief BAN tab for companies
+ * \brief Tab of payment modes for the customer
*/
require '../main.inc.php';
@@ -162,7 +162,7 @@ if (empty($reshook))
$account->setAsDefault($id); // This will make sure there is only one default rib
}
- $url=DOL_URL_ROOT.'/societe/rib.php?socid='.$object->id;
+ $url=$_SERVER["PHP_SELF"].'?socid='.$object->id;
header('Location: '.$url);
exit;
}
@@ -261,7 +261,7 @@ if (empty($reshook))
{
$db->commit();
- $url=DOL_URL_ROOT.'/societe/rib.php?socid='.$object->id;
+ $url=$_SERVER["PHP_SELF"].'?socid='.$object->id;
header('Location: '.$url);
exit;
}
@@ -332,19 +332,23 @@ if (empty($reshook))
$id = $savid;
}
-if (class_exists('Stripe'))
+if (! empty($conf->stripe->enabled) && class_exists('Stripe'))
{
$stripe=new Stripe($db);
- $customerstripe=$stripe->CustomerStripe($socid,$stripe->GetStripeAccount($conf->entity));
+
+ if (empty($conf->global->STRIPE_LIVE) || empty($conf->global->STRIPECONNECT_LIVE) || GETPOST('forcesandbox','alpha')) $service = 'StripeTest';
+ else $service = 'StripeLive';
+
+ $customerstripe=$stripe->customerStripe($socid, $stripe->getStripeAccount($service));
if ($customerstripe->id) {
- $cu = \Stripe\Customer::retrieve("".$customerstripe->id."");}
+ $cu = \Stripe\Customer::retrieve("".$customerstripe->id."");}
$url=DOL_URL_ROOT.'/societe/paymentmodes.php?socid='.$object->id;
if ($action == 'setassourcedefault')
{
$cu->default_source = "$source"; // obtained with Stripe.js
$cu->save();
-
+
header('Location: '.$url);
exit;
}
@@ -366,7 +370,7 @@ $form = new Form($db);
$formfile = new FormFile($db);
llxHeader();
-
+
$head=societe_prepare_head($object);
if (! $id)
@@ -381,14 +385,14 @@ if (empty($account->socid)) $account->socid=$object->id;
if ($socid && $action == 'edit' && $user->rights->societe->creer)
{
- print ' |