+--
+-- 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 3 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, see .
+--
+--
+-- Historique evolution de la remise relative des tiers
+-- ========================================================================
+
+create table llx_societe_remise_supplier
+(
+ rowid integer AUTO_INCREMENT PRIMARY KEY,
+ entity integer DEFAULT 1 NOT NULL, -- multi company id
+ fk_soc integer NOT NULL,
+ tms timestamp,
+ datec datetime, -- creation date
+ fk_user_author integer, -- creation user
+ remise_supplier double(6,3) DEFAULT 0 NOT NULL, -- discount
+ note text
+
+)ENGINE=innodb;
+
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/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang
index d6514db4d2c..6648e43501e 100644
--- a/htdocs/langs/en_US/admin.lang
+++ b/htdocs/langs/en_US/admin.lang
@@ -1444,6 +1444,9 @@ SyslogFilename=File name and path
YouCanUseDOL_DATA_ROOT=You can use DOL_DATA_ROOT/dolibarr.log for a log file in Dolibarr "documents" directory. You can set a different path to store this file.
ErrorUnknownSyslogConstant=Constant %s is not a known Syslog constant
OnlyWindowsLOG_USER=Windows only supports LOG_USER
+CompressSyslogs=Syslog files compression and backup
+SyslogFileNumberOfSaves=Log backups
+ConfigureCleaningCronjobToSetFrequencyOfSaves=Configure cleaning scheduled job to set log backup frequency
##### Donations #####
DonationsSetup=Donation module setup
DonationsReceiptModel=Template of donation receipt
diff --git a/htdocs/langs/en_US/bills.lang b/htdocs/langs/en_US/bills.lang
index 668090129ff..62386adbe99 100644
--- a/htdocs/langs/en_US/bills.lang
+++ b/htdocs/langs/en_US/bills.lang
@@ -67,6 +67,7 @@ PaidBack=Paid back
DeletePayment=Delete payment
ConfirmDeletePayment=Are you sure you want to delete this payment?
ConfirmConvertToReduc=Do you want to convert this %s into an absolute discount ?
The amount will so be saved among all discounts and could be used as a discount for a current or a future invoice for this customer.
+ConfirmConvertToReducSupplier=Do you want to convert this %s into an absolute discount ?
The amount will so be saved among all discounts and could be used as a discount for a current or a future invoice for this supplier.
SupplierPayments=Suppliers payments
ReceivedPayments=Received payments
ReceivedCustomersPayments=Payments received from customers
@@ -91,7 +92,7 @@ PaymentAmount=Payment amount
ValidatePayment=Validate payment
PaymentHigherThanReminderToPay=Payment higher than reminder to pay
HelpPaymentHigherThanReminderToPay=Attention, the payment amount of one or more bills is higher than the rest to pay.
Edit your entry, otherwise confirm and think about creating a credit note of the excess received for each overpaid invoices.
-HelpPaymentHigherThanReminderToPaySupplier=Attention, the payment amount of one or more bills is higher than the rest to pay.
Edit your entry, otherwise confirm.
+HelpPaymentHigherThanReminderToPaySupplier=Attention, the payment amount of one or more bills is higher than the rest to pay.
Edit your entry, otherwise confirm and think about creating a credit note of the excess paid for each overpaid invoice.
ClassifyPaid=Classify 'Paid'
ClassifyPaidPartially=Classify 'Paid partially'
ClassifyCanceled=Classify 'Abandoned'
@@ -110,6 +111,7 @@ DoPayment=Enter payment
DoPaymentBack=Enter refund
ConvertToReduc=Convert into future discount
ConvertExcessReceivedToReduc=Convert excess received into future discount
+ConvertExcessPaidToReduc=Convert excess paid into future discount
EnterPaymentReceivedFromCustomer=Enter payment received from customer
EnterPaymentDueToCustomer=Make payment due to customer
DisabledBecauseRemainderToPayIsZero=Disabled because remaining unpaid is zero
@@ -220,6 +222,7 @@ RemainderToPayBack=Remaining amount to refund
Rest=Pending
AmountExpected=Amount claimed
ExcessReceived=Excess received
+ExcessPaid=Excess paid
EscompteOffered=Discount offered (payment before term)
EscompteOfferedShort=Discount
SendBillRef=Submission of invoice %s
@@ -284,15 +287,19 @@ Deposits=Down payments
DiscountFromCreditNote=Discount from credit note %s
DiscountFromDeposit=Down payments from invoice %s
DiscountFromExcessReceived=Payments from excess received of invoice %s
+DiscountFromExcessPaid=Payments from excess paid of invoice %s
AbsoluteDiscountUse=This kind of credit can be used on invoice before its validation
CreditNoteDepositUse=Invoice must be validated to use this kind of credits
NewGlobalDiscount=New absolute discount
NewRelativeDiscount=New relative discount
+DiscountType=Discount type
NoteReason=Note/Reason
ReasonDiscount=Reason
DiscountOfferedBy=Granted by
DiscountStillRemaining=Discounts available
DiscountAlreadyCounted=Discounts already consumed
+CustomerDiscounts=Customer discounts
+SupplierDiscounts=Supplier discounts
BillAddress=Bill address
HelpEscompte=This discount is a discount granted to customer because its payment was made before term.
HelpAbandonBadCustomer=This amount has been abandoned (customer said to be a bad customer) and is considered as an exceptional loose.
diff --git a/htdocs/langs/en_US/companies.lang b/htdocs/langs/en_US/companies.lang
index 57ff05ed8ac..36339d5ce08 100644
--- a/htdocs/langs/en_US/companies.lang
+++ b/htdocs/langs/en_US/companies.lang
@@ -79,6 +79,7 @@ VATIsUsed=Sales tax is used
VATIsNotUsed=Sales tax is not used
CopyAddressFromSoc=Fill address with third party address
ThirdpartyNotCustomerNotSupplierSoNoRef=Thirdparty neither customer nor supplier, no available refering objects
+ThirdpartyIsNeitherCustomerNorClientSoCannotHaveDiscounts=Thirdparty neither customer nor supplier, discounts are not available
PaymentBankAccount=Payment bank account
OverAllProposals=Proposals
OverAllOrders=Orders
@@ -268,12 +269,20 @@ CustomerRelativeDiscountShort=Relative discount
CustomerAbsoluteDiscountShort=Absolute discount
CompanyHasRelativeDiscount=This customer has a default discount of %s%%
CompanyHasNoRelativeDiscount=This customer has no relative discount by default
+HasRelativeDiscountFromSupplier=You have a default discount of %s%% from this supplier
+HasNoRelativeDiscountFromSupplier=You have no default relative discount from this supplier
CompanyHasAbsoluteDiscount=This customer has discount available (credits notes or down payments) for %s %s
CompanyHasDownPaymentOrCommercialDiscount=This customer has discount available (commercial, down payments) for %s %s
CompanyHasCreditNote=This customer still has credit notes for %s %s
+HasNoAbsoluteDiscountFromSupplier=You have no discount credit available from this supplier
+HasAbsoluteDiscountFromSupplier=You have discounts available (credits notes or down payments) for %s %s from this supplier
+HasDownPaymentOrCommercialDiscountFromSupplier=You have discounts available (commercial, down payments) for %s %s from this supplier
+HasCreditNoteFromSupplier=You have credit notes for %s %s from this supplier
CompanyHasNoAbsoluteDiscount=This customer has no discount credit available
-CustomerAbsoluteDiscountAllUsers=Absolute discounts (granted by all users)
-CustomerAbsoluteDiscountMy=Absolute discounts (granted by yourself)
+CustomerAbsoluteDiscountAllUsers=Absolute customer discounts (granted by all users)
+CustomerAbsoluteDiscountMy=Absolute customer discounts (granted by yourself)
+SupplierAbsoluteDiscountAllUsers=Absolute supplier discounts (granted by all users)
+SupplierAbsoluteDiscountMy=Absolute supplier discounts (granted by yourself)
DiscountNone=None
Supplier=Supplier
AddContact=Create contact
diff --git a/htdocs/langs/en_US/stripe.lang b/htdocs/langs/en_US/stripe.lang
index 9bc202685dd..782c49ce61e 100644
--- a/htdocs/langs/en_US/stripe.lang
+++ b/htdocs/langs/en_US/stripe.lang
@@ -39,8 +39,14 @@ STRIPE_TEST_WEBHOOK_KEY=Webhook test key
STRIPE_LIVE_SECRET_KEY=Secret live key
STRIPE_LIVE_PUBLISHABLE_KEY=Publishable live key
STRIPE_LIVE_WEBHOOK_KEY=Webhook live key
-ONLINE_PAYMENT_WAREHOUSE=Stock to use for stock decrease when payment online payment is done (TODO When option to decrease stock is done on an action on invoice and the online payment generate itself the invoice ?)
+ONLINE_PAYMENT_WAREHOUSE=Stock to use for stock decrease when payment online payment is done
(TODO When option to decrease stock is done on an action on invoice and the online payment generate itself the invoice ?)
StripeLiveEnabled=Stripe live enabled (otherwise test/sandbox mode)
StripeImportPayment=Import Stripe payments
ExampleOfTestCreditCard=Example of credit card for test: %s (valid), %s (error CVC), %s (expired), %s (charge fails)
-StripeGateways=Stripe gateways
\ No newline at end of file
+StripeGateways=Stripe gateways
+OAUTH_STRIPE_TEST_ID=Stripe Connect Client ID (ca_...)
+OAUTH_STRIPE_LIVE_ID=Stripe Connect Client ID (ca_...)
+BankAccountForBankTransfer=Bank account for fund payouts
+StripeAccount=Stripe account
+StripeChargeList=List of Stripe charges
+StripeCustomer=Stripe customer id
\ No newline at end of file
diff --git a/htdocs/langs/fr_FR/admin.lang b/htdocs/langs/fr_FR/admin.lang
index 15cebb242f7..0ab3342ed4f 100644
--- a/htdocs/langs/fr_FR/admin.lang
+++ b/htdocs/langs/fr_FR/admin.lang
@@ -278,6 +278,10 @@ MAIN_MAIL_SMTPS_ID=Identifiant d'authentification SMTP si authentification SMTP
MAIN_MAIL_SMTPS_PW=Mot de passe d'authentification SMTP si authentification SMTP requise
MAIN_MAIL_EMAIL_TLS= Utilisation du chiffrement TLS (SSL)
MAIN_MAIL_EMAIL_STARTTLS= Utiliser le cryptage TTS (STARTTLS)
+MAIN_MAIL_EMAIL_DKIM_ENABLED= Utiliser la signature DKIM
+MAIN_MAIL_EMAIL_DKIM_DOMAIN=Domaine DKIM
+MAIN_MAIL_EMAIL_DKIM_SELECTOR=Sélecteur de clé DKIM
+MAIN_MAIL_EMAIL_DKIM_PRIVATE_KEY=Clé privée RSA DKIM
MAIN_DISABLE_ALL_SMS=Désactiver globalement tout envoi de SMS (pour mode test ou démos)
MAIN_SMS_SENDMODE=Méthode d'envoi des SMS
MAIN_MAIL_SMS_FROM=Numéro de téléphone par défaut pour l'envoi des SMS
diff --git a/htdocs/modulebuilder/index.php b/htdocs/modulebuilder/index.php
index 3b2e36e21d8..dbc69c943dd 100644
--- a/htdocs/modulebuilder/index.php
+++ b/htdocs/modulebuilder/index.php
@@ -490,8 +490,7 @@ if ($dirins && $action == 'addproperty' && !empty($module) && ! empty($tabobj))
setEventMessages($langs->trans('FilesForObjectUpdated', $objectname), null);
clearstatcache(true);
- sleep(4); // With sleep 2, after the header("Location...", the new page output does not see the change. TODO Why do we need this sleep ?
-
+
// Make a redirect to reload all data
header("Location: ".DOL_URL_ROOT.'/modulebuilder/index.php?tab=objects&module='.$module.'&tabobj='.$objectname.'&nocache='.time());
@@ -526,8 +525,7 @@ if ($dirins && $action == 'confirm_deleteproperty' && $propertykey)
setEventMessages($langs->trans('FilesForObjectUpdated', $objectname), null);
clearstatcache(true);
- sleep(4); // With sleep 2, after the header("Location...", the new page output does not see the change. TODO Why do we need this sleep ?
-
+
// Make a redirect to reload all data
header("Location: ".DOL_URL_ROOT.'/modulebuilder/index.php?tab=objects&module='.$module.'&tabobj='.$objectname);
@@ -1550,6 +1548,8 @@ elseif (! empty($module))
print '
';
+ if(function_exists('opcache_invalidate')) opcache_invalidate($dirread.'/'.$pathtoclass,true); // remove the include cache hell !
+
if (empty($forceddirread))
{
$result = dol_include_once($pathtoclass);
diff --git a/htdocs/modulebuilder/template/myobject_card.php b/htdocs/modulebuilder/template/myobject_card.php
index a82ec237006..4e43063cc94 100644
--- a/htdocs/modulebuilder/template/myobject_card.php
+++ b/htdocs/modulebuilder/template/myobject_card.php
@@ -113,7 +113,7 @@ if (empty($reshook))
{
$error=0;
- $permissiontoadd = $user->rights->mymodule->create;
+ $permissiontoadd = $user->rights->mymodule->write;
$permissiontodelete = $user->rights->mymodule->delete;
$backurlforlist = dol_buildpath('/mymodule/myobject_list.php',1);
diff --git a/htdocs/projet/tasks/time.php b/htdocs/projet/tasks/time.php
index 5f826baf03e..44a2ed1b8a8 100644
--- a/htdocs/projet/tasks/time.php
+++ b/htdocs/projet/tasks/time.php
@@ -1096,13 +1096,14 @@ if (($id > 0 || ! empty($ref)) || $projectidforalltimes > 0)
{
if ($task_time->fk_user == $user->id || in_array($task_time->fk_user, $childids) || $user->rights->projet->all->creer)
{
+ //$param = ($projectidforalltimes?'projectid='.$projectidforalltimes.'&':'').'.($withproject?'&withproject=1':'');
print ' ';
- print 'fk_task.'&action=editline&lineid='.$task_time->rowid.($withproject?'&withproject=1':'').'">';
+ print 'fk_task.'&action=editline&lineid='.$task_time->rowid.$param.'">';
print img_edit();
print '';
print ' ';
- print 'fk_task.'&action=deleteline&lineid='.$task_time->rowid.($withproject?'&withproject=1':'').'">';
+ print 'fk_task.'&action=deleteline&lineid='.$task_time->rowid.$param.'">';
print img_delete();
print '';
}
diff --git a/htdocs/public/paybox/paymentok.php b/htdocs/public/paybox/paymentok.php
index 63c15b035f2..9e711ade51b 100644
--- a/htdocs/public/paybox/paymentok.php
+++ b/htdocs/public/paybox/paymentok.php
@@ -157,7 +157,7 @@ if (! empty($conf->global->ONLINE_PAYMENT_SENDEMAIL))
if (! empty($tmptag['MEM']))
{
$langs->load("members");
- $url=$urlwithroot."/adherents/card_subscriptions.php?rowid=".$tmptag['MEM'];
+ $url=$urlwithroot."/adherents/subscription.php?rowid=".$tmptag['MEM'];
$content.=$langs->trans("PaymentSubscription")."
\n";
$content.=$langs->trans("MemberId").': '.$tmptag['MEM']."
\n";
$content.=$langs->trans("Link").': '.$url.''."
\n";
diff --git a/htdocs/public/paypal/paymentok.php b/htdocs/public/paypal/paymentok.php
index d50dd66d903..1e6adb7ca51 100644
--- a/htdocs/public/paypal/paymentok.php
+++ b/htdocs/public/paypal/paymentok.php
@@ -212,7 +212,7 @@ if ($PAYPALTOKEN)
if (! empty($tmptag['MEM']))
{
$langs->load("members");
- $url=$urlwithroot."/adherents/subscriptions/card.php?rowid=".$tmptag['MEM'];
+ $url=$urlwithroot."/adherents/subscription.php?rowid=".$tmptag['MEM'];
$content.=$langs->trans("PaymentSubscription")."
\n";
$content.=$langs->trans("MemberId").': '.$tmptag['MEM']."
\n";
$content.=$langs->trans("Link").': '.$url.''."
\n";
diff --git a/htdocs/public/stripe/paymentok.php b/htdocs/public/stripe/paymentok.php
index d0ce82d1ca8..52b3dac8a7f 100644
--- a/htdocs/public/stripe/paymentok.php
+++ b/htdocs/public/stripe/paymentok.php
@@ -158,7 +158,7 @@ if ($ispaymentok)
if (! empty($tmptag['MEM']))
{
$langs->load("members");
- $url=$urlwithroot."/adherents/card_subscriptions.php?rowid=".$tmptag['MEM'];
+ $url=$urlwithroot."/adherents/subscription.php?rowid=".$tmptag['MEM'];
$content.=$langs->trans("PaymentSubscription")."
\n";
$content.=$langs->trans("MemberId").': '.$tmptag['MEM']."
\n";
$content.=$langs->trans("Link").': '.$url.''."
\n";
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/card.php b/htdocs/societe/card.php
index dfe6f07cd53..aafea674bcf 100644
--- a/htdocs/societe/card.php
+++ b/htdocs/societe/card.php
@@ -149,7 +149,7 @@ if (empty($reshook))
$listofproperties=array(
'address', 'zip', 'town', 'state_id', 'country_id', 'phone', 'phone_pro', 'fax', 'email', 'skype', 'url', 'barcode',
'idprof1', 'idprof2', 'idprof3', 'idprof4', 'idprof5', 'idprof6',
- 'tva_intra', 'effectif_id', 'forme_juridique', 'remise_percent', 'mode_reglement_supplier_id', 'cond_reglement_supplier_id', 'name_bis',
+ 'tva_intra', 'effectif_id', 'forme_juridique', 'remise_percent', 'remise_supplier_percent', 'mode_reglement_supplier_id', 'cond_reglement_supplier_id', 'name_bis',
'stcomm_id', 'outstanding_limit', 'price_level', 'parent', 'default_lang', 'ref', 'ref_ext', 'import_key', 'fk_incoterms', 'fk_multicurrency',
'code_client', 'code_fournisseur', 'code_compta', 'code_compta_fournisseur',
'model_pdf', 'fk_projet'
@@ -822,8 +822,10 @@ if (empty($reshook))
$result = $object->setIncoterms(GETPOST('incoterm_id', 'int'), GETPOST('location_incoterms', 'alpha'));
}
- // Actions to send emails
$id=$socid;
+ $object->fetch($socid);
+
+ // Actions to send emails
$trigger_name='COMPANY_SENTBYMAIL';
$paramname='socid';
$mode='emailfromthirdparty';
diff --git a/htdocs/societe/class/api_thirdparties.class.php b/htdocs/societe/class/api_thirdparties.class.php
index fa52c73f597..1cdfabf7fca 100644
--- a/htdocs/societe/class/api_thirdparties.class.php
+++ b/htdocs/societe/class/api_thirdparties.class.php
@@ -83,8 +83,14 @@ class Thirdparties extends DolibarrApi
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
}
- $filterabsolutediscount = "fk_facture_source IS NULL OR (fk_facture_source IS NOT NULL AND (description LIKE '(DEPOSIT)%' AND description NOT LIKE '(EXCESS RECEIVED)%'))";
- $filtercreditnote = "fk_facture_source IS NOT NULL AND (description NOT LIKE '(DEPOSIT)%' OR description LIKE '(EXCESS RECEIVED)%')";
+ if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) {
+ $filterabsolutediscount = "fk_facture_source IS NULL"; // If we want deposit to be substracted to payments only and not to total of final invoice
+ $filtercreditnote = "fk_facture_source IS NOT NULL"; // If we want deposit to be substracted to payments only and not to total of final invoice
+ } else {
+ $filterabsolutediscount = "fk_facture_source IS NULL OR (description LIKE '(DEPOSIT)%' AND description NOT LIKE '(EXCESS RECEIVED)%')";
+ $filtercreditnote = "fk_facture_source IS NOT NULL AND (description NOT LIKE '(DEPOSIT)%' OR description LIKE '(EXCESS RECEIVED)%')";
+ }
+
$absolute_discount = $this->company->getAvailableDiscounts('', $filterabsolutediscount);
$absolute_creditnote = $this->company->getAvailableDiscounts('', $filtercreditnote);
$this->company->absolute_discount = price2num($absolute_discount, 'MT');
@@ -308,7 +314,7 @@ class Thirdparties extends DolibarrApi
$listofproperties=array(
'address', 'zip', 'town', 'state_id', 'country_id', 'phone', 'phone_pro', 'fax', 'email', 'skype', 'url', 'barcode',
'idprof1', 'idprof2', 'idprof3', 'idprof4', 'idprof5', 'idprof6',
- 'tva_intra', 'effectif_id', 'forme_juridique', 'remise_percent', 'mode_reglement_supplier_id', 'cond_reglement_supplier_id', 'name_bis',
+ 'tva_intra', 'effectif_id', 'forme_juridique', 'remise_percent', 'remise_supplier_percent', 'mode_reglement_supplier_id', 'cond_reglement_supplier_id', 'name_bis',
'stcomm_id', 'outstanding_limit', 'price_level', 'parent', 'default_lang', 'ref', 'ref_ext', 'import_key', 'fk_incoterms', 'fk_multicurrency',
'code_client', 'code_fournisseur', 'code_compta', 'code_compta_fournisseur',
'model_pdf', 'fk_projet'
diff --git a/htdocs/societe/class/companybankaccount.class.php b/htdocs/societe/class/companybankaccount.class.php
index 428f5b96f42..97c8871202e 100644
--- a/htdocs/societe/class/companybankaccount.class.php
+++ b/htdocs/societe/class/companybankaccount.class.php
@@ -72,7 +72,7 @@ class CompanyBankAccount extends Account
$now = dol_now();
$error = 0;
// Correct default_rib to be sure to have always one default
- $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."societe_rib where fk_soc = ".$this->socid." AND default_rib = 1";
+ $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."societe_rib where fk_soc = ".$this->socid." AND default_rib = 1 AND type = 'ban'";
$result = $this->db->query($sql);
if ($result)
{
@@ -81,8 +81,8 @@ class CompanyBankAccount extends Account
if (empty($this->default_rib) && $numrows == 0) $this->default_rib = 1;
}
- $sql = "INSERT INTO ".MAIN_DB_PREFIX."societe_rib (fk_soc, datec)";
- $sql.= " VALUES (".$this->socid.", '".$this->db->idate($now)."')";
+ $sql = "INSERT INTO ".MAIN_DB_PREFIX."societe_rib (fk_soc, type, datec)";
+ $sql.= " VALUES (".$this->socid.", 'ban', '".$this->db->idate($now)."')";
$resql=$this->db->query($sql);
if ($resql)
{
@@ -204,7 +204,7 @@ class CompanyBankAccount extends Account
{
if (empty($id) && empty($socid)) return -1;
- $sql = "SELECT rowid, fk_soc, bank, number, code_banque, code_guichet, cle_rib, bic, iban_prefix as iban, domiciliation, proprio,";
+ $sql = "SELECT rowid, type, fk_soc, bank, number, code_banque, code_guichet, cle_rib, bic, iban_prefix as iban, domiciliation, proprio,";
$sql.= " owner_address, default_rib, label, datec, tms as datem, rum, frstrecur";
$sql.= " FROM ".MAIN_DB_PREFIX."societe_rib";
if ($id) $sql.= " WHERE rowid = ".$id;
@@ -220,6 +220,7 @@ class CompanyBankAccount extends Account
$this->ref = $obj->fk_soc.'-'.$obj->label; // Generate an artificial ref
$this->id = $obj->rowid;
+ $this->type = $obj->type;
$this->socid = $obj->fk_soc;
$this->bank = $obj->bank;
$this->code_banque = $obj->code_banque;
@@ -321,7 +322,7 @@ class CompanyBankAccount extends Account
}
/**
- * Set RIB as Default
+ * Set a BAN as Default
*
* @param int $rib RIB id
* @return int 0 if KO, 1 if OK
@@ -345,13 +346,13 @@ class CompanyBankAccount extends Account
$this->db->begin();
- $sql2 = "UPDATE ".MAIN_DB_PREFIX."societe_rib SET default_rib = 0 ";
- $sql2.= "WHERE fk_soc = ".$obj->fk_soc;
+ $sql2 = "UPDATE ".MAIN_DB_PREFIX."societe_rib SET default_rib = 0";
+ $sql2.= " WHERE type = 'ban' AND fk_soc = ".$obj->fk_soc;
dol_syslog(get_class($this).'::setAsDefault', LOG_DEBUG);
$result2 = $this->db->query($sql2);
- $sql3 = "UPDATE ".MAIN_DB_PREFIX."societe_rib SET default_rib = 1 ";
- $sql3.= "WHERE rowid = ".$obj->id;
+ $sql3 = "UPDATE ".MAIN_DB_PREFIX."societe_rib SET default_rib = 1";
+ $sql3.= " WHERE rowid = ".$obj->id;
dol_syslog(get_class($this).'::setAsDefault', LOG_DEBUG);
$result3 = $this->db->query($sql3);
diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php
index 94b686c3b35..dbf3015ba1e 100644
--- a/htdocs/societe/class/societe.class.php
+++ b/htdocs/societe/class/societe.class.php
@@ -234,6 +234,7 @@ class Societe extends CommonObject
var $forme_juridique;
var $remise_percent;
+ var $remise_supplier_percent;
var $mode_reglement_supplier_id;
var $cond_reglement_supplier_id;
var $fk_prospectlevel;
@@ -1144,7 +1145,7 @@ class Societe extends CommonObject
$sql .= ', s.fk_forme_juridique as forme_juridique_code';
$sql .= ', s.webservices_url, s.webservices_key';
$sql .= ', s.code_client, s.code_fournisseur, s.code_compta, s.code_compta_fournisseur, s.parent, s.barcode';
- $sql .= ', s.fk_departement, s.fk_pays as country_id, s.fk_stcomm, s.remise_client, s.mode_reglement, s.cond_reglement, s.fk_account, s.tva_assuj';
+ $sql .= ', s.fk_departement, s.fk_pays as country_id, s.fk_stcomm, s.remise_client, s.remise_supplier, s.mode_reglement, s.cond_reglement, s.fk_account, s.tva_assuj';
$sql .= ', s.mode_reglement_supplier, s.cond_reglement_supplier, s.localtax1_assuj, s.localtax1_value, s.localtax2_assuj, s.localtax2_value, s.fk_prospectlevel, s.default_lang, s.logo';
$sql .= ', s.fk_shipping_method';
$sql .= ', s.outstanding_limit, s.import_key, s.canvas, s.fk_incoterms, s.location_incoterms';
@@ -1277,6 +1278,7 @@ class Societe extends CommonObject
$this->prefix_comm = $obj->prefix_comm;
$this->remise_percent = $obj->remise_client;
+ $this->remise_supplier_percent = $obj->remise_supplier;
$this->mode_reglement_id = $obj->mode_reglement;
$this->cond_reglement_id = $obj->cond_reglement;
$this->mode_reglement_supplier_id = $obj->mode_reglement_supplier;
@@ -1661,16 +1663,78 @@ class Societe extends CommonObject
}
}
+ /**
+ * Definit la societe comme un client
+ *
+ * @param float $remise Valeur en % de la remise
+ * @param string $note Note/Motif de modification de la remise
+ * @param User $user Utilisateur qui definie la remise
+ * @return int <0 if KO, >0 if OK
+ */
+ function set_remise_supplier($remise, $note, User $user)
+ {
+ global $conf, $langs;
+
+ // Nettoyage parametres
+ $note=trim($note);
+ if (! $note)
+ {
+ $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)."'";
+ $sql.= " WHERE rowid = " . $this->id;
+ $resql=$this->db->query($sql);
+ if (! $resql)
+ {
+ $this->db->rollback();
+ $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)";
+ $sql.= " VALUES (".$conf->entity.", '".$this->db->idate($now)."', ".$this->id.", '".$this->db->escape($remise)."',";
+ $sql.= " '".$this->db->escape($note)."',";
+ $sql.= " ".$user->id;
+ $sql.= ")";
+
+ $resql=$this->db->query($sql);
+ if (! $resql)
+ {
+ $this->db->rollback();
+ $this->error=$this->db->lasterror();
+ return -1;
+ }
+
+ $this->db->commit();
+ return 1;
+ }
+ }
+
/**
* Add a discount for third party
*
- * @param float $remise Amount of discount
- * @param User $user User adding discount
- * @param string $desc Reason of discount
- * @param float $tva_tx VAT rate
+ * @param float $remise Amount of discount
+ * @param User $user User adding discount
+ * @param string $desc Reason of discount
+ * @param float $tva_tx VAT rate
+ * @param int $discount_type 0 => customer discount, 1 => supplier discount
* @return int <0 if KO, id of discount record if OK
*/
- function set_remise_except($remise, User $user, $desc, $tva_tx=0)
+ function set_remise_except($remise, User $user, $desc, $tva_tx=0, $discount_type=0)
{
global $langs;
@@ -1696,11 +1760,13 @@ class Societe extends CommonObject
$discount = new DiscountAbsolute($this->db);
$discount->fk_soc=$this->id;
+ $discount->discount_type=$discount_type;
$discount->amount_ht=price2num($remise,'MT');
$discount->amount_tva=price2num($remise*$tva_tx/100,'MT');
$discount->amount_ttc=price2num($discount->amount_ht+$discount->amount_tva,'MT');
$discount->tva_tx=price2num($tva_tx,'MT');
$discount->description=$desc;
+
$result=$discount->create($user);
if ($result > 0)
{
@@ -1718,17 +1784,18 @@ class Societe extends CommonObject
/**
* Renvoie montant TTC des reductions/avoirs en cours disponibles de la societe
*
- * @param User $user Filtre sur un user auteur des remises
- * @param string $filter Filtre autre
- * @param integer $maxvalue Filter on max value for discount
+ * @param User $user Filtre sur un user auteur des remises
+ * @param string $filter Filtre autre
+ * @param integer $maxvalue Filter on max value for discount
+ * @param int $discount_type 0 => customer discount, 1 => supplier discount
* @return int <0 if KO, Credit note amount otherwise
*/
- function getAvailableDiscounts($user='',$filter='',$maxvalue=0)
+ function getAvailableDiscounts($user='',$filter='',$maxvalue=0,$discount_type=0)
{
require_once DOL_DOCUMENT_ROOT.'/core/class/discount.class.php';
$discountstatic=new DiscountAbsolute($this->db);
- $result=$discountstatic->getAvailableDiscounts($this,$user,$filter,$maxvalue);
+ $result=$discountstatic->getAvailableDiscounts($this,$user,$filter,$maxvalue,$discount_type);
if ($result >= 0)
{
return $result;
@@ -1970,7 +2037,7 @@ class Societe extends CommonObject
else if ($option == 'ban')
{
$label.= '' . $langs->trans("ShowBan") . '';
- $linkstart = 'id;
}
// By default
@@ -2366,7 +2433,7 @@ class Societe extends CommonObject
function get_all_rib()
{
require_once DOL_DOCUMENT_ROOT . '/societe/class/companybankaccount.class.php';
- $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."societe_rib WHERE fk_soc = ".$this->id;
+ $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."societe_rib WHERE type='ban' AND fk_soc = ".$this->id;
$result = $this->db->query($sql);
if (!$result) {
$this->error++;
diff --git a/htdocs/societe/consumption.php b/htdocs/societe/consumption.php
index ffb4cac77fa..1a6a4be6199 100644
--- a/htdocs/societe/consumption.php
+++ b/htdocs/societe/consumption.php
@@ -491,6 +491,7 @@ if ($sql_select)
print img_object($langs->trans("ShowReduc"),'reduc').' ';
if ($objp->description == '(DEPOSIT)') $txt=$langs->trans("Deposit");
elseif ($objp->description == '(EXCESS RECEIVED)') $txt=$langs->trans("ExcessReceived");
+ elseif ($objp->description == '(EXCESS PAID)') $txt=$langs->trans("ExcessPaid");
//else $txt=$langs->trans("Discount");
print $txt;
?>
@@ -510,6 +511,12 @@ if ($sql_select)
$discount->fetch($objp->fk_remise_except);
echo ($txt?' - ':'').$langs->transnoentities("DiscountFromExcessReceived",$discount->getNomUrl(0));
}
+ elseif ($objp->description == '(EXCESS PAID)' && $objp->fk_remise_except > 0)
+ {
+ $discount=new DiscountAbsolute($db);
+ $discount->fetch($objp->fk_remise_except);
+ echo ($txt?' - ':'').$langs->transnoentities("DiscountFromExcessPaid",$discount->getNomUrl(0));
+ }
elseif ($objp->description == '(DEPOSIT)' && $objp->fk_remise_except > 0)
{
$discount=new DiscountAbsolute($db);
diff --git a/htdocs/societe/list.php b/htdocs/societe/list.php
index 9861f4b8d66..d046c325eca 100644
--- a/htdocs/societe/list.php
+++ b/htdocs/societe/list.php
@@ -9,6 +9,7 @@
* Copyright (C) 2016 Ferran Marcet
* Copyright (C) 2017 Rui Strecht
* Copyright (C) 2017 Juanjo Menent
+ * Copyright (C) 2018 Nicolas ZABOURI
*
* 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
@@ -137,6 +138,7 @@ $fieldstosearchall = array(
's.siren'=>"ProfId1",
's.siret'=>"ProfId2",
's.ape'=>"ProfId3",
+ 's.phone'=>"Phone",
);
if (($tmp = $langs->transnoentities("ProfId4".$mysoc->country_code)) && $tmp != "ProfId4".$mysoc->country_code && $tmp != '-') $fieldstosearchall['s.idprof4']='ProfId4';
if (($tmp = $langs->transnoentities("ProfId5".$mysoc->country_code)) && $tmp != "ProfId5".$mysoc->country_code && $tmp != '-') $fieldstosearchall['s.idprof5']='ProfId5';
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 ' |