Skip to content

Commit

Permalink
Merge remote-tracking branch 'uptream/develop' into 6.0-multijournal
Browse files Browse the repository at this point in the history
  • Loading branch information
aspangaro committed May 14, 2017
2 parents 143c019 + caae7e4 commit cedf5fb
Show file tree
Hide file tree
Showing 22 changed files with 2,109 additions and 524 deletions.
2 changes: 1 addition & 1 deletion htdocs/core/modules/modStripe.class.php
Expand Up @@ -65,7 +65,7 @@ function __construct($db)
$this->picto='stripe@stripe';

// Data directories to create when module is enabled.
$this->dirs = array('/stripe/temp');
$this->dirs = array();

// Config pages. Put here list of php page names stored in admmin directory used to setup module.
$this->config_page_url = array("stripe.php@stripe");
Expand Down
38 changes: 23 additions & 15 deletions htdocs/install/mysql/migration/5.0.0-6.0.0.sql
Expand Up @@ -117,17 +117,33 @@ CREATE TABLE llx_product_attribute_combination
entity INT DEFAULT 1 NOT NULL
);

INSERT INTO llx_accounting_journal (rowid, code, label, nature, active) VALUES (1,'VT', 'Journal des ventes', 1, 1);
INSERT INTO llx_accounting_journal (rowid, code, label, nature, active) VALUES (2,'AC', 'Journal des achats', 2, 1);
INSERT INTO llx_accounting_journal (rowid, code, label, nature, active) VALUES (3,'BQ', 'Journal de banque', 3, 1);
INSERT INTO llx_accounting_journal (rowid, code, label, nature, active) VALUES (4,'OD', 'Journal des opérations diverses', 0, 1);
INSERT INTO llx_accounting_journal (rowid, code, label, nature, active) VALUES (5,'AN', 'Journal des à-nouveaux', 9, 1);

ALTER TABLE llx_accounting_journal ADD COLUMN entity integer DEFAULT 1;
ALTER TABLE llx_bank_account drop foreign key bank_fk_accountancy_journal;

ALTER TABLE llx_paiementfourn ADD COLUMN model_pdf varchar(255);
-- Add journal entries
INSERT INTO llx_accounting_journal (rowid, code, label, nature, active) VALUES (1,'VT', 'Sale journal', 2, 1);
INSERT INTO llx_accounting_journal (rowid, code, label, nature, active) VALUES (2,'AC', 'Purchase journal', 3, 1);
INSERT INTO llx_accounting_journal (rowid, code, label, nature, active) VALUES (3,'BQ', 'Bank journal', 4, 1);
INSERT INTO llx_accounting_journal (rowid, code, label, nature, active) VALUES (4,'OD', 'Other journal', 1, 1);
INSERT INTO llx_accounting_journal (rowid, code, label, nature, active) VALUES (5,'AN', 'Has new journal', 9, 1);
-- Fix old entries
UPDATE llx_accounting_journal SET nature = 1 where code = 'OD' and nature = 0;
UPDATE llx_accounting_journal SET nature = 2 where code = 'VT' and nature = 1;
UPDATE llx_accounting_journal SET nature = 3 where code = 'AC' and nature = 2;
UPDATE llx_accounting_journal SET nature = 4 where (code = 'BK' or code = 'BQ') and nature = 3;

UPDATE llx_bank_account as ba set accountancy_journal = 'BQ' where accountancy_journal = 'BK';
UPDATE llx_bank_account as ba set accountancy_journal = 'OD' where accountancy_journal IS NULL;

ALTER TABLE llx_bank_account ADD COLUMN fk_accountancy_journal integer;
ALTER TABLE llx_bank_account ADD INDEX idx_fk_accountancy_journal (fk_accountancy_journal);

UPDATE llx_bank_account as ba set fk_accountancy_journal = (SELECT rowid FROM llx_accounting_journal as aj where ba.accountancy_journal = aj.code) where accountancy_journal not in ('1', '2', '3', '4', '5', '6', '5', '8', '9', '10', '11', '12', '13', '14', '15');
ALTER TABLE llx_bank_account ADD CONSTRAINT fk_bank_account_accountancy_journal FOREIGN KEY (fk_accountancy_journal) REFERENCES llx_accounting_journal (rowid);


ALTER TABLE llx_paiementfourn ADD COLUMN model_pdf varchar(255);

insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('EXPENSE_REPORT_CREATE','Expense report created','Executed when an expense report is created','expensereport',201);
insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('EXPENSE_REPORT_VALIDATE','Expense report validated','Executed when an expense report is validated','expensereport',202);
insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('EXPENSE_REPORT_APPROVE','Expense report approved','Executed when an expense report is approved','expensereport',203);
Expand Down Expand Up @@ -262,14 +278,6 @@ insert into llx_c_tva(fk_pays,taux,code,recuperableonly,localtax1,localtax1_type

ALTER TABLE llx_events MODIFY COLUMN ip varchar(250);

UPDATE llx_accounting_journal SET nature = 1 where code = 'OD' and nature = 0;
UPDATE llx_accounting_journal SET nature = 2 where code = 'VT' and nature = 1;
UPDATE llx_accounting_journal SET nature = 3 where code = 'AC' and nature = 2;
UPDATE llx_accounting_journal SET nature = 4 where (code = 'BK' or code = 'BQ') and nature = 3;


ALTER TABLE llx_bank_account CHANGE COLUMN accountancy_journal fk_accountancy_journal integer;
--ALTER TABLE llx_bank_account ADD CONSTRAINT bank_fk_accountancy_journal FOREIGN KEY (fk_accountancy_journal) REFERENCES llx_accounting_journal (rowid);



Expand Down
3 changes: 2 additions & 1 deletion htdocs/install/mysql/tables/llx_bank_account.key.sql
Expand Up @@ -19,5 +19,6 @@


ALTER TABLE llx_bank_account ADD UNIQUE uk_bank_account_label (label,entity);
ALTER TABLE llx_bank_account ADD INDEX idx_fk_accountancy_journal (fk_accountancy_journal);

-- ALTER TABLE llx_bank_account ADD CONSTRAINT bank_fk_accountancy_journal FOREIGN KEY (fk_accountancy_journal) REFERENCES llx_accounting_journal (rowid);
ALTER TABLE llx_bank_account ADD CONSTRAINT fk_bank_account_accountancy_journal FOREIGN KEY (fk_accountancy_journal) REFERENCES llx_accounting_journal (rowid);
1 change: 1 addition & 0 deletions htdocs/langs/en_US/paybox.lang
Expand Up @@ -11,6 +11,7 @@ YourEMail=Email to receive payment confirmation
Creditor=Creditor
PaymentCode=Payment code
PayBoxDoPayment=Go on payment
ToPay=Do payment
YouWillBeRedirectedOnPayBox=You will be redirected on secured Paybox page to input you credit card information
Continue=Next
ToOfferALinkForOnlinePayment=URL for %s payment
Expand Down
10 changes: 6 additions & 4 deletions htdocs/langs/en_US/paypal.lang
Expand Up @@ -16,15 +16,17 @@ ThisIsTransactionId=This is id of transaction: <b>%s</b>
PAYPAL_ADD_PAYMENT_URL=Add the url of Paypal payment when you send a document by mail
PredefinedMailContentLink=You can click on the secure link below to make your payment (PayPal) if it is not already done.\n\n%s\n\n
YouAreCurrentlyInSandboxMode=You are currently in the "sandbox" mode
NewPaypalPaymentReceived=New Paypal payment received
NewPaypalPaymentFailed=New Paypal payment tried but failed
NewOnlinePaymentReceived=New online payment received
NewOnlinePaymentFailed=New online payment tried but failed
PAYPAL_PAYONLINE_SENDEMAIL=EMail to warn after a payment (success or not)
ReturnURLAfterPayment=Return URL after payment
ValidationOfPaypalPaymentFailed=Validation of Paypal payment failed
PaypalConfirmPaymentPageWasCalledButFailed=Payment confirmation page for Paypal was called by Paypal but confirmation failed
ValidationOfOnlinePaymentFailed=Validation of online payment failed
PaymentSystemConfirmPaymentPageWasCalledButFailed=Payment confirmation page was called by payment system returned an error
SetExpressCheckoutAPICallFailed=SetExpressCheckout API call failed.
DoExpressCheckoutPaymentAPICallFailed=DoExpressCheckoutPayment API call failed.
DetailedErrorMessage=Detailed Error Message
ShortErrorMessage=Short Error Message
ErrorCode=Error Code
ErrorSeverityCode=Error Severity Code
OnlinePaymentSystem=Online payment system
PaypalLiveEnabled=Paypal live enabled (otherwise test/sandbox mode)
3 changes: 2 additions & 1 deletion htdocs/langs/en_US/stripe.lang
Expand Up @@ -9,6 +9,7 @@ ThisScreenAllowsYouToPay=This screen allow you to make an online payment to %s.
ThisIsInformationOnPayment=This is information on payment to do
ToComplete=To complete
YourEMail=Email to receive payment confirmation
STRIPE_PAYONLINE_SENDEMAIL=EMail to warn after a payment (success or not)
Creditor=Creditor
PaymentCode=Payment code
StripeDoPayment=Go on payment
Expand Down Expand Up @@ -38,4 +39,4 @@ STRIPE_TEST_SECRET_KEY=Secret test key
STRIPE_TEST_PUBLISHABLE_KEY=Publishable test key
STRIPE_LIVE_SECRET_KEY=Secret live key
STRIPE_LIVE_PUBLISHABLE_KEY=Publishable live key
StripeLiveEnabled=Stripe live enabled
StripeLiveEnabled=Stripe live enabled (otherwise test/sandbox mode)
35 changes: 28 additions & 7 deletions htdocs/paypal/admin/paypal.php
Expand Up @@ -44,8 +44,6 @@
{
$db->begin();

$result=dolibarr_set_const($db, "PAYPAL_API_SANDBOX",GETPOST('PAYPAL_API_SANDBOX','alpha'),'chaine',0,'',$conf->entity);
if (! $result > 0) $error++;
$result=dolibarr_set_const($db, "PAYPAL_API_USER",GETPOST('PAYPAL_API_USER','alpha'),'chaine',0,'',$conf->entity);
if (! $result > 0) $error++;
$result=dolibarr_set_const($db, "PAYPAL_API_PASSWORD",GETPOST('PAYPAL_API_PASSWORD','alpha'),'chaine',0,'',$conf->entity);
Expand Down Expand Up @@ -85,6 +83,21 @@
}
}

if ($action=="setlive")
{
$liveenable = GETPOST('value','int')?0:1;
$res = dolibarr_set_const($db, "PAYPAL_API_SANDBOX", $liveenable,'yesno',0,'',$conf->entity);
if (! $res > 0) $error++;
if (! $error)
{
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
}
else
{
setEventMessages($langs->trans("Error"), null, 'errors');
}
}


/*
* View
Expand Down Expand Up @@ -127,13 +140,21 @@
print '<td>'.$langs->trans("Value").'</td>';
print "</tr>\n";


print '<tr class="oddeven"><td class="fieldrequired">';
print $langs->trans("PAYPAL_API_SANDBOX").'</td><td>';
print $form->selectyesno("PAYPAL_API_SANDBOX",$conf->global->PAYPAL_API_SANDBOX,1);
print '<tr class="oddeven">';
print '<td class="titlefield fieldrequired">';
print $langs->trans("PaypalLiveEnabled").'</td><td>';
if (empty($conf->global->PAYPAL_API_SANDBOX))
{
print '<a href="'.$_SERVER['PHP_SELF'].'?action=setlive&value=0">';
print img_picto($langs->trans("Activated"),'switch_on');
}
else
{
print '<a href="'.$_SERVER['PHP_SELF'].'?action=setlive&value=1">';
print img_picto($langs->trans("Disabled"),'switch_off');
}
print '</td></tr>';


print '<tr class="oddeven"><td class="fieldrequired">';
print $langs->trans("PAYPAL_API_USER").'</td><td>';
print '<input size="32" type="text" name="PAYPAL_API_USER" value="'.$conf->global->PAYPAL_API_USER.'">';
Expand Down
110 changes: 67 additions & 43 deletions htdocs/public/paybox/paymentko.php
Expand Up @@ -20,7 +20,6 @@
* \file htdocs/public/paybox/paymentko.php
* \ingroup paybox
* \brief File to show page after a failed payment
* \author Laurent Destailleur
*/

define("NOLOGIN",1); // This means this output page does not require to be logged.
Expand Down Expand Up @@ -52,6 +51,8 @@

$object = new stdClass(); // For triggers

$paymentmethod='paybox';


/*
* Actions
Expand All @@ -72,51 +73,74 @@
dol_syslog("POST=".$tracepost, LOG_DEBUG, 0, '_paybox');


// Appel des triggers
include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php';
$interface=new Interfaces($db);
$result=$interface->run_triggers('PAYBOX_PAYMENT_OK',$object,$user,$langs,$conf);
if ($result < 0) { $error++; $errors=$interface->errors; }
// Fin appel triggers


// Send an email
if (! empty($conf->global->PAYBOX_PAYONLINE_SENDEMAIL))
if (! empty($_SESSION['ipaddress'])) // To avoid to make action twice
{
$sendto=$conf->global->PAYBOX_PAYONLINE_SENDEMAIL;
$from=$conf->global->MAILING_EMAIL_FROM;

// Define link to login card
$appli=constant('DOL_APPLICATION_TITLE');
if (! empty($conf->global->MAIN_APPLICATION_TITLE))
{
$appli=$conf->global->MAIN_APPLICATION_TITLE;
if (preg_match('/\d\.\d/', $appli))
{
if (! preg_match('/'.preg_quote(DOL_VERSION).'/', $appli)) $appli.=" (".DOL_VERSION.")"; // If new title contains a version that is different than core
}
else $appli.=" ".DOL_VERSION;
}
else $appli.=" ".DOL_VERSION;

$urlback=$_SERVER["REQUEST_URI"];
$topic='['.$appli.'] '.$langs->transnoentitiesnoconv("NewPayboxPaymentFailed");
$content=$langs->transnoentitiesnoconv("NewPayboxPaymentFailed")."\n".$fulltag;
require_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php';
$mailfile = new CMailFile($topic, $sendto, $from, $content);

$result=$mailfile->sendfile();
if ($result)
{
dol_syslog("EMail sent to ".$sendto, LOG_DEBUG, 0, '_paybox');
}
else
{
dol_syslog("Failed to send EMail to ".$sendto, LOG_ERR, 0, '_paybox');
}
// Get on url call
$fulltag = $FULLTAG;
$onlinetoken = empty($PAYPALTOKEN)?$_SESSION['onlinetoken']:$PAYPALTOKEN;
$payerID = empty($PAYPALPAYERID)?$_SESSION['payerID']:$PAYPALPAYERID;
// Set by newpayment.php
$paymentType = $_SESSION['PaymentType'];
$currencyCodeType = $_SESSION['currencyCodeType'];
$FinalPaymentAmt = $_SESSION["Payment_Amount"];
// From env
$ipaddress = $_SESSION['ipaddress'];

// Appel des triggers
include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php';
$interface=new Interfaces($db);
$result=$interface->run_triggers('PAYBOX_PAYMENT_OK',$object,$user,$langs,$conf);
if ($result < 0) { $error++; $errors=$interface->errors; }
// Fin appel triggers

// Send an email
$sendemail = '';
if (! empty($conf->global->PAYBOX_PAYONLINE_SENDEMAIL)) $sendemail=$conf->global->PAYBOX_PAYONLINE_SENDEMAIL;

if ($sendemail)
{
$sendto=$sendemail;
$from=$conf->global->MAILING_EMAIL_FROM;

// Define link to login card
$appli=constant('DOL_APPLICATION_TITLE');
if (! empty($conf->global->MAIN_APPLICATION_TITLE))
{
$appli=$conf->global->MAIN_APPLICATION_TITLE;
if (preg_match('/\d\.\d/', $appli))
{
if (! preg_match('/'.preg_quote(DOL_VERSION).'/', $appli)) $appli.=" (".DOL_VERSION.")"; // If new title contains a version that is different than core
}
else $appli.=" ".DOL_VERSION;
}
else $appli.=" ".DOL_VERSION;

$urlback=$_SERVER["REQUEST_URI"];
$topic='['.$appli.'] '.$langs->transnoentitiesnoconv("NewOnlinePaymentFailed");
$content="";
$content.=$langs->transnoentitiesnoconv("ValidationOfOnlinePaymentFailed")."\n";
$content.="\n";
$content.=$langs->transnoentitiesnoconv("TechnicalInformation").":\n";
$content.=$langs->transnoentitiesnoconv("OnlinePaymentSystem").': '.$paymentmethod."<br>\n";
$content.=$langs->transnoentitiesnoconv("ReturnURLAfterPayment").': '.$urlback."\n";
$content.="tag=".$fulltag."\npaymentType=".$paymentType." currencycodeType=".$currencyCodeType." payerId=".$payerID." ipaddress=".$ipaddress." FinalPaymentAmt=".$FinalPaymentAmt;
require_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php';
$mailfile = new CMailFile($topic, $sendto, $from, $content);

$result=$mailfile->sendfile();
if ($result)
{
dol_syslog("EMail sent to ".$sendto, LOG_DEBUG, 0, '_paybox');
}
else
{
dol_syslog("Failed to send EMail to ".$sendto, LOG_ERR, 0, '_paybox');
}
}

unset($_SESSION['ipaddress']);
}


$head='';
if (! empty($conf->global->PAYBOX_CSS_URL)) $head='<link rel="stylesheet" type="text/css" href="'.$conf->global->PAYBOX_CSS_URL.'?lang='.$langs->defaultlang.'">'."\n";

Expand Down
12 changes: 7 additions & 5 deletions htdocs/public/paybox/paymentok.php
Expand Up @@ -20,7 +20,6 @@
* \file htdocs/public/paybox/paymentok.php
* \ingroup paybox
* \brief File to show page after a successful payment
* \author Laurent Destailleur
*/

define("NOLOGIN",1); // This means this output page does not require to be logged.
Expand Down Expand Up @@ -62,6 +61,8 @@

$object = new stdClass(); // For triggers

$paymentmethod='paybox';


/*
* Actions
Expand Down Expand Up @@ -97,7 +98,7 @@

// Get on url call
/*
$token = $PAYBOXTOKEN;
$onlinetoken = $PAYBOXTOKEN;
*/
$fulltag = $FULLTAG;
/*$payerID = $PAYBOXPAYERID;
Expand All @@ -108,7 +109,7 @@
// From env
$ipaddress = $_SESSION['ipaddress'];
dol_syslog("Call newpaymentok with token=".$token." paymentType=".$paymentType." currencyCodeType=".$currencyCodeType." payerID=".$payerID." ipaddress=".$ipaddress." FinalPaymentAmt=".$FinalPaymentAmt." fulltag=".$fulltag);
dol_syslog("Call newpaymentok with token=".$onlinetoken." paymentType=".$paymentType." currencyCodeType=".$currencyCodeType." payerID=".$payerID." ipaddress=".$ipaddress." FinalPaymentAmt=".$FinalPaymentAmt." fulltag=".$fulltag);
*/


Expand Down Expand Up @@ -149,7 +150,7 @@
else $appli.=" ".DOL_VERSION;

$urlback=$_SERVER["REQUEST_URI"];
$topic='['.$appli.'] '.$langs->transnoentitiesnoconv("NewPayboxPaymentReceived");
$topic='['.$appli.'] '.$langs->transnoentitiesnoconv("NewOnlinePaymentReceived");
$tmptag=dolExplodeIntoArray($fulltag,'.','=');
$content="";
if (! empty($tmptag['MEM']))
Expand All @@ -162,10 +163,11 @@
}
else
{
$content.=$langs->transnoentitiesnoconv("NewPayboxPaymentReceived")."<br>\n";
$content.=$langs->transnoentitiesnoconv("NewOnlinePaymentReceived")."<br>\n";
}
$content.="<br>\n";
$content.=$langs->transnoentitiesnoconv("TechnicalInformation").":<br>\n";
$content.=$langs->transnoentitiesnoconv("OnlinePaymentSystem").': '.$paymentmethod."<br>\n";
$content.=$langs->transnoentitiesnoconv("ReturnURLAfterPayment").': '.$urlback."<br>\n";
$content.="tag=".$fulltag."<br>\n";

Expand Down

0 comments on commit cedf5fb

Please sign in to comment.