Merge branch 'develop' of https://github.com/Dolibarr/dolibarr into develop

This commit is contained in:
florian HENRY 2019-05-18 12:11:48 +02:00
commit 730820bb26
23 changed files with 530 additions and 248 deletions

View File

@ -121,7 +121,7 @@ NEW: Add constant XFRAMEOPTIONS_ALLOWALL
NEW: Add function isValidVATID()
NEW: ADD document's product support in APIs
NEW: REST API: get the list of objects in a category.
NEW: Update Stripe library to 6.34.3
NEW: Update Stripe library to 6.35
NEW: Upgrade jquery lib to 3.3.1
NEW: Add hook 'addHtmlHeader()'
NEW: Add hook 'createRecurringInvoices()'

261
htdocs/bom/bom_agenda.php Normal file
View File

@ -0,0 +1,261 @@
<?php
/* Copyright (C) 2017 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) ---Put here your own copyright and developer email---
*
* 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 <http://www.gnu.org/licenses/>.
*/
/**
* \file htdocs/modulebuilder/template/myobject_agenda.php
* \ingroup bom
* \brief Page of MyObject events
*/
// Load Dolibarr environment
$res=0;
// Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined)
if (! $res && ! empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) $res=@include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php";
// Try main.inc.php into web root detected using web root calculated from SCRIPT_FILENAME
$tmp=empty($_SERVER['SCRIPT_FILENAME'])?'':$_SERVER['SCRIPT_FILENAME'];$tmp2=realpath(__FILE__); $i=strlen($tmp)-1; $j=strlen($tmp2)-1;
while($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i]==$tmp2[$j]) { $i--; $j--; }
if (! $res && $i > 0 && file_exists(substr($tmp, 0, ($i+1))."/main.inc.php")) $res=@include substr($tmp, 0, ($i+1))."/main.inc.php";
if (! $res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i+1)))."/main.inc.php")) $res=@include dirname(substr($tmp, 0, ($i+1)))."/main.inc.php";
// Try main.inc.php using relative path
if (! $res && file_exists("../main.inc.php")) $res=@include "../main.inc.php";
if (! $res && file_exists("../../main.inc.php")) $res=@include "../../main.inc.php";
if (! $res && file_exists("../../../main.inc.php")) $res=@include "../../../main.inc.php";
if (! $res) die("Include of main fails");
require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
dol_include_once('/bom/class/bom.class.php');
dol_include_once('/bom/lib/bom.lib.php');
// Load translation files required by the page
$langs->loadLangs(array("mrp","other"));
// Get parameters
$id = GETPOST('id', 'int');
$ref = GETPOST('ref', 'alpha');
$action = GETPOST('action', 'alpha');
$cancel = GETPOST('cancel', 'aZ09');
$backtopage = GETPOST('backtopage', 'alpha');
if (GETPOST('actioncode', 'array'))
{
$actioncode=GETPOST('actioncode', 'array', 3);
if (! count($actioncode)) $actioncode='0';
}
else
{
$actioncode=GETPOST("actioncode", "alpha", 3)?GETPOST("actioncode", "alpha", 3):(GETPOST("actioncode")=='0'?'0':(empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT)?'':$conf->global->AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT));
}
$search_agenda_label=GETPOST('search_agenda_label');
// Security check - Protection if external user
//if ($user->societe_id > 0) access_forbidden();
//if ($user->societe_id > 0) $socid = $user->societe_id;
//$result = restrictedArea($user, 'bom', $id);
$limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit;
$sortfield = GETPOST("sortfield", 'alpha');
$sortorder = GETPOST("sortorder", 'alpha');
$page = GETPOST("page", 'int');
if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
$offset = $limit * $page;
$pageprev = $page - 1;
$pagenext = $page + 1;
if (! $sortfield) $sortfield='a.datep,a.id';
if (! $sortorder) $sortorder='DESC';
// Initialize technical objects
$object=new BOM($db);
$extrafields = new ExtraFields($db);
$diroutputmassaction=$conf->bom->dir_output . '/temp/massgeneration/'.$user->id;
$hookmanager->initHooks(array('bomagenda','globalcard')); // Note that conf->hooks_modules contains array
// Fetch optionals attributes and labels
$extralabels = $extrafields->fetch_name_optionals_label('bom');
// Load object
include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once // Must be include, not include_once. Include fetch and fetch_thirdparty but not fetch_optionals
if ($id > 0 || ! empty($ref)) $upload_dir = $conf->bom->multidir_output[$object->entity] . "/" . $object->id;
/*
* Actions
*/
$parameters=array('id'=>$socid);
$reshook=$hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
if (empty($reshook))
{
// Cancel
if (GETPOST('cancel', 'alpha') && ! empty($backtopage))
{
header("Location: ".$backtopage);
exit;
}
// Purge search criteria
if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // All tests are required to be compatible with all browsers
{
$actioncode='';
$search_agenda_label='';
}
}
/*
* View
*/
$contactstatic = new Contact($db);
$form = new Form($db);
if ($object->id > 0)
{
$title=$langs->trans("Agenda");
//if (! empty($conf->global->MAIN_HTML_TITLE) && preg_match('/thirdpartynameonly/',$conf->global->MAIN_HTML_TITLE) && $object->name) $title=$object->name." - ".$title;
$help_url = '';
llxHeader('', $title, $help_url);
if (! empty($conf->notification->enabled)) $langs->load("mails");
$head = bomPrepareHead($object);
dol_fiche_head($head, 'agenda', $langs->trans("BillOfMaterials"), -1, 'bom');
// Object card
// ------------------------------------------------------------
$linkback = '<a href="' .dol_buildpath('/bom/myobject_list.php', 1) . '?restore_lastsearch_values=1' . (! empty($socid) ? '&socid=' . $socid : '') . '">' . $langs->trans("BackToList") . '</a>';
$morehtmlref='<div class="refidno">';
/*
// Ref customer
$morehtmlref.=$form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', 0, 1);
$morehtmlref.=$form->editfieldval("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', null, null, '', 1);
// Thirdparty
$morehtmlref.='<br>'.$langs->trans('ThirdParty') . ' : ' . $object->thirdparty->getNomUrl(1);
// Project
if (! empty($conf->projet->enabled))
{
$langs->load("projects");
$morehtmlref.='<br>'.$langs->trans('Project') . ' ';
if ($user->rights->bom->creer)
{
if ($action != 'classify')
//$morehtmlref.='<a href="' . $_SERVER['PHP_SELF'] . '?action=classify&amp;id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a> : ';
$morehtmlref.=' : ';
if ($action == 'classify') {
//$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1);
$morehtmlref.='<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">';
$morehtmlref.='<input type="hidden" name="action" value="classin">';
$morehtmlref.='<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
$morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1);
$morehtmlref.='<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">';
$morehtmlref.='</form>';
} else {
$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1);
}
} else {
if (! empty($object->fk_project)) {
$proj = new Project($db);
$proj->fetch($object->fk_project);
$morehtmlref.='<a href="'.DOL_URL_ROOT.'/projet/card.php?id=' . $object->fk_project . '" title="' . $langs->trans('ShowProject') . '">';
$morehtmlref.=$proj->ref;
$morehtmlref.='</a>';
} else {
$morehtmlref.='';
}
}
}*/
$morehtmlref.='</div>';
dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref);
print '<div class="fichecenter">';
print '<div class="underbanner clearboth"></div>';
$object->info($object->id);
print dol_print_object_info($object, 1);
print '</div>';
dol_fiche_end();
// Actions buttons
$objthirdparty=$object;
$objcon=new stdClass();
$out='';
$permok=$user->rights->agenda->myactions->create;
if ((! empty($objthirdparty->id) || ! empty($objcon->id)) && $permok)
{
//$out.='<a href="'.DOL_URL_ROOT.'/comm/action/card.php?action=create';
if (get_class($objthirdparty) == 'Societe') $out.='&amp;socid='.$objthirdparty->id;
$out.=(! empty($objcon->id)?'&amp;contactid='.$objcon->id:'').'&amp;backtopage=1&amp;percentage=-1';
//$out.=$langs->trans("AddAnAction").' ';
//$out.=img_picto($langs->trans("AddAnAction"),'filenew');
//$out.="</a>";
}
print '<div class="tabsAction">';
if (! empty($conf->agenda->enabled))
{
if (! empty($user->rights->agenda->myactions->create) || ! empty($user->rights->agenda->allactions->create))
{
print '<a class="butAction" href="'.DOL_URL_ROOT.'/comm/action/card.php?action=create'.$out.'">'.$langs->trans("AddAction").'</a>';
}
else
{
print '<a class="butActionRefused classfortooltip" href="#">'.$langs->trans("AddAction").'</a>';
}
}
print '</div>';
if (! empty($conf->agenda->enabled) && (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read) ))
{
$param='&socid='.$socid;
if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage;
if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit;
//print load_fiche_titre($langs->trans("ActionsOnBom"), '', '');
// List of all actions
$filters=array();
$filters['search_agenda_label']=$search_agenda_label;
// TODO Replace this with same code than into list.php
//show_actions_done($conf,$langs,$db,$object,null,0,$actioncode, '', $filters, $sortfield, $sortorder);
}
}
// End of page
llxFooter();
$db->close();

View File

@ -73,10 +73,10 @@ class Invoices extends DolibarrApi
}
// Get payment details
$this->invoice->totalpaye = $this->invoice->getSommePaiement();
$this->invoice->totalpaid = $this->invoice->getSommePaiement();
$this->invoice->totalcreditnotes = $this->invoice->getSumCreditNotesUsed();
$this->invoice->totaldeposits = $this->invoice->getSumDepositsUsed();
$this->invoice->resteapayer = price2num($this->invoice->total_ttc - $this->invoice->totalpaye - $this->invoice->totalcreditnotes - $this->invoice->totaldeposits, 'MT');
$this->invoice->remaintopay = price2num($this->invoice->total_ttc - $this->invoice->totalpaid - $this->invoice->totalcreditnotes - $this->invoice->totaldeposits, 'MT');
if (! DolibarrApi::_checkAccessToResource('facture', $this->invoice->id)) {
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);

View File

@ -96,7 +96,7 @@ class FormMargin
$line->pa_ht = $line->subprice * (1 - ($line->remise_percent / 100));
}
$pv = $line->qty * $line->subprice * (1 - $line->remise_percent / 100);
$pv = $line->total_ht;
$pa_ht = ($pv < 0 ? - $line->pa_ht : $line->pa_ht); // We choosed to have line->pa_ht always positive in database, so we guess the correct sign
$pa = $line->qty * $pa_ht;

View File

@ -145,8 +145,8 @@ function user_prepare_head($object)
if ((! empty($conf->salaries->enabled) && ! empty($user->rights->salaries->read))
|| (! empty($conf->hrm->enabled) && ! empty($user->rights->hrm->employee->read))
|| (! empty($conf->expensereport->enabled) && ! empty($user->rights->expensereport->lire) && $user->id == $object->id)
|| (! empty($conf->holiday->enabled) && ! empty($user->rights->holiday->read) && $user->id == $object->id )
|| (! empty($conf->expensereport->enabled) && ! empty($user->rights->expensereport->lire) && ($user->id == $object->id || $user->rights->expensereport->readall))
|| (! empty($conf->holiday->enabled) && ! empty($user->rights->holiday->read) && ($user->id == $object->id || $user->rights->holiday->read_all))
)
{
// Bank

View File

@ -301,7 +301,7 @@ class pdf_beluga extends ModelePDFProjects
'table'=>'commande',
'datefieldname'=>'date_commande',
'test'=>$conf->commande->enabled && $user->rights->commande->lire,
'lang'=>'order'),
'lang'=>'orders'),
'invoice'=>array(
'name'=>"CustomersInvoices",
'title'=>"ListInvoicesAssociatedProject",

View File

@ -33,7 +33,7 @@ class DolibarrDebugBar extends DebugBar
//$this->addCollector(new PhpInfoCollector());
//$this->addCollector(new DolMessagesCollector());
$this->addCollector(new DolRequestDataCollector());
$this->addCollector(new DolConfigCollector());
//$this->addCollector(new DolConfigCollector()); // Disabled for security purpose
$this->addCollector(new DolTimeDataCollector());
$this->addCollector(new DolMemoryCollector());
//$this->addCollector(new DolExceptionsCollector());

View File

@ -26,7 +26,7 @@ CREATE TABLE llx_asset(
note_public text,
note_private text,
date_creation datetime NOT NULL,
tms timestamp NOT NULL,
tms timestamp,
fk_user_creat integer NOT NULL,
fk_user_modif integer,
import_key varchar(14),

View File

@ -24,7 +24,7 @@ CREATE TABLE llx_bom_bom(
note_public text,
note_private text,
date_creation datetime NOT NULL,
tms timestamp NOT NULL,
tms timestamp,
date_valid datetime,
fk_user_creat integer NOT NULL,
fk_user_modif integer,

View File

@ -34,7 +34,7 @@ CREATE TABLE llx_emailcollector_emailcollector(
note_public text,
note_private text,
date_creation datetime NOT NULL,
tms timestamp NOT NULL,
tms timestamp,
fk_user_creat integer NOT NULL,
fk_user_modif integer,
import_key varchar(14),

View File

@ -21,7 +21,7 @@ CREATE TABLE llx_emailcollector_emailcollectoraction(
type varchar(128) NOT NULL,
actionparam varchar(255) NULL,
date_creation datetime NOT NULL,
tms timestamp NOT NULL,
tms timestamp,
fk_user_creat integer NOT NULL,
fk_user_modif integer,
position integer DEFAULT 0,

View File

@ -21,7 +21,7 @@ CREATE TABLE llx_emailcollector_emailcollectorfilter(
type varchar(128) NOT NULL,
rulevalue varchar(128) NULL,
date_creation datetime NOT NULL,
tms timestamp NOT NULL,
tms timestamp,
fk_user_creat integer NOT NULL,
fk_user_modif integer,
import_key varchar(14),

View File

@ -33,6 +33,6 @@ CREATE TABLE llx_pos_cash_fence(
posnumber VARCHAR(30),
fk_user_creat integer,
fk_user_valid integer,
tms TIMESTAMP NOT NULL,
tms TIMESTAMP,
import_key VARCHAR(14)
) ENGINE=innodb;

View File

@ -32,7 +32,7 @@ CREATE TABLE llx_societe_account(
date_last_login datetime,
date_previous_login datetime,
date_creation datetime NOT NULL,
tms timestamp NOT NULL,
tms timestamp,
fk_user_creat integer NOT NULL,
fk_user_modif integer,
import_key varchar(14),

View File

@ -69,6 +69,12 @@ CREATE TRIGGER update_customer_modtime BEFORE UPDATE ON llx_adherent_type_extraf
CREATE TRIGGER update_customer_modtime BEFORE UPDATE ON llx_bank FOR EACH ROW EXECUTE PROCEDURE update_modified_column_tms();
CREATE TRIGGER update_customer_modtime BEFORE UPDATE ON llx_bank_account FOR EACH ROW EXECUTE PROCEDURE update_modified_column_tms();
CREATE TRIGGER update_customer_modtime BEFORE UPDATE ON llx_bank_account_extrafields FOR EACH ROW EXECUTE PROCEDURE update_modified_column_tms();
CREATE TRIGGER update_customer_modtime BEFORE UPDATE ON llx_blockedlog FOR EACH ROW EXECUTE PROCEDURE update_modified_column_tms();
CREATE TRIGGER update_customer_modtime BEFORE UPDATE ON llx_blockedlog_authority FOR EACH ROW EXECUTE PROCEDURE update_modified_column_tms();
CREATE TRIGGER update_customer_modtime BEFORE UPDATE ON llx_bom_bom FOR EACH ROW EXECUTE PROCEDURE update_modified_column_tms();
CREATE TRIGGER update_customer_modtime BEFORE UPDATE ON llx_bom_bom_extrafields FOR EACH ROW EXECUTE PROCEDURE update_modified_column_tms();
CREATE TRIGGER update_customer_modtime BEFORE UPDATE ON llx_bom_bomline FOR EACH ROW EXECUTE PROCEDURE update_modified_column_tms();
CREATE TRIGGER update_customer_modtime BEFORE UPDATE ON llx_bom_bomline_extrafields FOR EACH ROW EXECUTE PROCEDURE update_modified_column_tms();
CREATE TRIGGER update_customer_modtime BEFORE UPDATE ON llx_bordereau_cheque FOR EACH ROW EXECUTE PROCEDURE update_modified_column_tms();
CREATE TRIGGER update_customer_modtime BEFORE UPDATE ON llx_boxes_def FOR EACH ROW EXECUTE PROCEDURE update_modified_column_tms();
CREATE TRIGGER update_customer_modtime BEFORE UPDATE ON llx_c_email_templates FOR EACH ROW EXECUTE PROCEDURE update_modified_column_tms();
@ -96,6 +102,9 @@ CREATE TRIGGER update_customer_modtime BEFORE UPDATE ON llx_deplacement FOR EACH
CREATE TRIGGER update_customer_modtime BEFORE UPDATE ON llx_don FOR EACH ROW EXECUTE PROCEDURE update_modified_column_tms();
CREATE TRIGGER update_customer_modtime BEFORE UPDATE ON llx_don_extrafields FOR EACH ROW EXECUTE PROCEDURE update_modified_column_tms();
CREATE TRIGGER update_customer_modtime BEFORE UPDATE ON llx_element_resources FOR EACH ROW EXECUTE PROCEDURE update_modified_column_tms();
CREATE TRIGGER update_customer_modtime BEFORE UPDATE ON llx_emailcollector_emailcollector FOR EACH ROW EXECUTE PROCEDURE update_modified_column_tms();
CREATE TRIGGER update_customer_modtime BEFORE UPDATE ON llx_emailcollector_emailcollectoraction FOR EACH ROW EXECUTE PROCEDURE update_modified_column_tms();
CREATE TRIGGER update_customer_modtime BEFORE UPDATE ON llx_emailcollector_emailcollectorfilter FOR EACH ROW EXECUTE PROCEDURE update_modified_column_tms();
CREATE TRIGGER update_customer_modtime BEFORE UPDATE ON llx_entrepot FOR EACH ROW EXECUTE PROCEDURE update_modified_column_tms();
CREATE TRIGGER update_customer_modtime BEFORE UPDATE ON llx_events FOR EACH ROW EXECUTE PROCEDURE update_modified_column_tms();
CREATE TRIGGER update_customer_modtime BEFORE UPDATE ON llx_expedition FOR EACH ROW EXECUTE PROCEDURE update_modified_column_tms();

View File

@ -292,6 +292,9 @@ class InterfaceMyModuleTriggers extends DolibarrTriggers
//case 'TASK_TIMESPENT_CREATE':
//case 'TASK_TIMESPENT_MODIFY':
//case 'TASK_TIMESPENT_DELETE':
//case 'PROJECT_ADD_CONTACT':
//case 'PROJECT_DELETE_CONTACT':
//case 'PROJECT_DELETE_RESOURCE':
// Shipping
//case 'SHIPPING_CREATE':

View File

@ -127,7 +127,7 @@ if (empty($reshook))
$backurlforlist = dol_buildpath('/mymodule/myobject_list.php', 1);
if (empty($backtopage)) {
if (empty($id)) $backtopage = $backurlforlist;
else $backtopage = dol_buildpath('/mymodule/myobject_card.php', 1).($id > 0 ? $id : '__ID__');
else $backtopage = dol_buildpath('/mymodule/myobject_card.php', 1).'?id='.($id > 0 ? $id : '__ID__');
}
$triggermodname = 'MYMODULE_MYOBJECT_MODIFY'; // Name of trigger action code to execute when we modify record

View File

@ -22,7 +22,7 @@ CREATE TABLE llx_mymodule_myobject(
qty INTEGER,
status INTEGER,
date_creation DATETIME NOT NULL,
tms TIMESTAMP NOT NULL,
tms TIMESTAMP,
import_key VARCHAR(14)
-- END MODULEBUILDER FIELDS
) ENGINE=innodb;

View File

@ -1943,241 +1943,249 @@ if (preg_match('/^dopayment/', $action))
print '</form>'."\n";
print '<script src="https://js.stripe.com/v3/"></script>'."\n";
// Code to ask the credit card. This use the default "API version". No way to force API version when using JS code.
print '<script type="text/javascript" language="javascript">'."\n";
if (! empty($conf->global->STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION))
if (empty($stripearrayofkeys['publishable_key']))
{
?>
// Create a Stripe client.
var stripe = Stripe('<?php echo $stripearrayofkeys['publishable_key']; // Defined into config.php ?>');
// Create an instance of Elements
var elements = stripe.elements();
// Custom styling can be passed to options when creating an Element.
// (Note that this demo uses a wider set of styles than the guide below.)
var style = {
base: {
color: '#32325d',
lineHeight: '24px',
fontFamily: '"Helvetica Neue", Helvetica, sans-serif',
fontSmoothing: 'antialiased',
fontSize: '16px',
'::placeholder': {
color: '#aab7c4'
}
},
invalid: {
color: '#fa755a',
iconColor: '#fa755a'
}
};
var cardElement = elements.create('card', {style: style});
// Add an instance of the card Element into the `card-element` <div>
cardElement.mount('#card-element');
// Handle real-time validation errors from the card Element.
cardElement.addEventListener('change', function(event) {
var displayError = document.getElementById('card-errors');
print info_admin($langs->trans("ErrorModuleSetupNotComplete", "stripe"), 0, 0, 'error');
}
else
{
print '<script src="https://js.stripe.com/v3/"></script>'."\n";
// Code to ask the credit card. This use the default "API version". No way to force API version when using JS code.
print '<script type="text/javascript" language="javascript">'."\n";
if (! empty($conf->global->STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION))
{
?>
// Code for payment with option STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION set
// Create a Stripe client.
var stripe = Stripe('<?php echo $stripearrayofkeys['publishable_key']; // Defined into config.php ?>');
// Create an instance of Elements
var elements = stripe.elements();
// Custom styling can be passed to options when creating an Element.
// (Note that this demo uses a wider set of styles than the guide below.)
var style = {
base: {
color: '#32325d',
lineHeight: '24px',
fontFamily: '"Helvetica Neue", Helvetica, sans-serif',
fontSmoothing: 'antialiased',
fontSize: '16px',
'::placeholder': {
color: '#aab7c4'
}
},
invalid: {
color: '#fa755a',
iconColor: '#fa755a'
}
};
var cardElement = elements.create('card', {style: style});
// Add an instance of the card Element into the `card-element` <div>
cardElement.mount('#card-element');
// Handle real-time validation errors from the card Element.
cardElement.addEventListener('change', function(event) {
var displayError = document.getElementById('card-errors');
if (event.error) {
console.log("Show event error (like 'Incorrect card number', ...)");
displayError.textContent = event.error.message;
} else {
console.log("Reset error message");
displayError.textContent = '';
}
});
// Handle form submission
var cardholderName = document.getElementById('cardholder-name');
var cardButton = document.getElementById('buttontopay');
var clientSecret = cardButton.dataset.secret;
cardButton.addEventListener('click', function(event) {
console.log("We click on buttontopay");
event.preventDefault();
if (cardholderName.value == '')
{
console.log("Field Card holder is empty");
var displayError = document.getElementById('card-errors');
displayError.textContent = '<?php print dol_escape_js($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("CardOwner"))); ?>';
}
else
{
stripe.handleCardPayment(
clientSecret, cardElement, {
payment_method_data: {
billing_details: {
name: cardholderName.value
<?php if (GETPOST('email', 'alpha')) { ?>, email: '<?php echo GETPOST('email', 'alpha'); ?>'<?php } ?>
<?php if (is_object($object) && is_object($object->thirdparty) && is_object($object->thirdparty->phone)) { ?>, phone: '<?php echo $object->thirdparty->phone; ?>'<?php } ?>
<?php if (is_object($object) && is_object($object->thirdparty)) { ?>, address: {
city: '<?php echo $object->thirdparty->town; ?>',
country: '<?php echo $object->thirdparty->country_code; ?>',
line1: '<?php echo $object->thirdparty->address; ?>',
postal_code: '<?php echo $object->thirdparty->zip; ?>'}<?php } ?>
} /* TODO Add all other known data like emails, ... to be SCA compliant */
},
save_payment_method: true /* the card will be saved */
}
).then(function(result) {
console.log(result);
if (result.error) {
console.log("Error on result of handleCardPayment");
jQuery('#buttontopay').show();
jQuery('#hourglasstopay').hide();
// Inform the user if there was an error
var errorElement = document.getElementById('card-errors');
errorElement.textContent = result.error.message;
} else {
// The payment has succeeded. Display a success message.
console.log("No error on result of handleCardPayment, so we submit the form");
// Submit the form
jQuery('#buttontopay').hide();
jQuery('#hourglasstopay').show();
// Send form (action=charge that will do nothing)
jQuery('#payment-form').submit();
}
});
}
});
<?php
}
else
{
?>
// Code for payment with option STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION off
// Create a Stripe client.
var stripe = Stripe('<?php echo $stripearrayofkeys['publishable_key']; // Defined into config.php ?>');
// Create an instance of Elements
var elements = stripe.elements();
// Custom styling can be passed to options when creating an Element.
// (Note that this demo uses a wider set of styles than the guide below.)
var style = {
base: {
color: '#32325d',
lineHeight: '24px',
fontFamily: '"Helvetica Neue", Helvetica, sans-serif',
fontSmoothing: 'antialiased',
fontSize: '16px',
'::placeholder': {
color: '#aab7c4'
}
},
invalid: {
color: '#fa755a',
iconColor: '#fa755a'
}
};
// Create an instance of the card Element
var card = elements.create('card', {style: style});
// Add an instance of the card Element into the `card-element` <div>
card.mount('#card-element');
// Handle real-time validation errors from the card Element.
card.addEventListener('change', function(event) {
var displayError = document.getElementById('card-errors');
if (event.error) {
console.log("Show event error (like 'Incorrect card number', ...)");
displayError.textContent = event.error.message;
} else {
console.log("Reset error message");
displayError.textContent = '';
}
});
// Handle form submission
var cardholderName = document.getElementById('cardholder-name');
var cardButton = document.getElementById('buttontopay');
var clientSecret = cardButton.dataset.secret;
cardButton.addEventListener('click', function(event) {
console.log("We click on buttontopay");
event.preventDefault();
if (cardholderName.value == '')
{
console.log("Field Card holder is empty");
var displayError = document.getElementById('card-errors');
displayError.textContent = '<?php print dol_escape_js($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("CardOwner"))); ?>';
}
else
{
stripe.handleCardPayment(
clientSecret, cardElement, {
payment_method_data: {
billing_details: {
name: cardholderName.value
<?php if (GETPOST('email', 'alpha')) { ?>, email: '<?php echo GETPOST('email', 'alpha'); ?>'<?php } ?>
<?php if (is_object($object) && is_object($object->thirdparty) && is_object($object->thirdparty->phone)) { ?>, phone: '<?php echo $object->thirdparty->phone; ?>'<?php } ?>
<?php if (is_object($object) && is_object($object->thirdparty)) { ?>, address: {
city: '<?php echo $object->thirdparty->town; ?>',
country: '<?php echo $object->thirdparty->country_code; ?>',
line1: '<?php echo $object->thirdparty->address; ?>',
postal_code: '<?php echo $object->thirdparty->zip; ?>'}<?php } ?>
} /* TODO Add all other known data like emails, ... to be SCA compliant */
},
save_payment_method: true /* the card will be saved */
}
).then(function(result) {
console.log(result);
if (result.error) {
console.log("Error on result of handleCardPayment");
jQuery('#buttontopay').show();
jQuery('#hourglasstopay').hide();
// Inform the user if there was an error
var errorElement = document.getElementById('card-errors');
errorElement.textContent = result.error.message;
} else {
// The payment has succeeded. Display a success message.
console.log("No error on result of handleCardPayment, so we submit the form");
// Submit the form
jQuery('#buttontopay').hide();
jQuery('#hourglasstopay').show();
// Send form (action=charge that will do nothing)
jQuery('#payment-form').submit();
}
});
}
});
<?php
});
// Handle form submission
var form = document.getElementById('payment-form');
console.log(form);
form.addEventListener('submit', function(event) {
event.preventDefault();
<?php
if (empty($conf->global->STRIPE_USE_3DSECURE)) // Ask credit card directly, no 3DS test
{
?>
/* Use token */
stripe.createToken(card).then(function(result) {
if (result.error) {
// Inform the user if there was an error
var errorElement = document.getElementById('card-errors');
errorElement.textContent = result.error.message;
} else {
// Send the token to your server
stripeTokenHandler(result.token);
}
});
<?php
}
else // Ask credit card with 3DS test
{
?>
/* Use 3DS source */
stripe.createSource(card).then(function(result) {
if (result.error) {
// Inform the user if there was an error
var errorElement = document.getElementById('card-errors');
errorElement.textContent = result.error.message;
} else {
// Send the source to your server
stripeSourceHandler(result.source);
}
});
<?php
}
?>
});
/* Insert the Token into the form so it gets submitted to the server */
function stripeTokenHandler(token) {
// Insert the token ID into the form so it gets submitted to the server
var form = document.getElementById('payment-form');
var hiddenInput = document.createElement('input');
hiddenInput.setAttribute('type', 'hidden');
hiddenInput.setAttribute('name', 'stripeToken');
hiddenInput.setAttribute('value', token.id);
form.appendChild(hiddenInput);
// Submit the form
jQuery('#buttontopay').hide();
jQuery('#hourglasstopay').show();
console.log("submit token");
form.submit();
}
/* Insert the Source into the form so it gets submitted to the server */
function stripeSourceHandler(source) {
// Insert the source ID into the form so it gets submitted to the server
var form = document.getElementById('payment-form');
var hiddenInput = document.createElement('input');
hiddenInput.setAttribute('type', 'hidden');
hiddenInput.setAttribute('name', 'stripeSource');
hiddenInput.setAttribute('value', source.id);
form.appendChild(hiddenInput);
// Submit the form
jQuery('#buttontopay').hide();
jQuery('#hourglasstopay').show();
console.log("submit source");
form.submit();
}
<?php
}
print '</script>';
}
else
{
?>
// Create a Stripe client.
var stripe = Stripe('<?php echo $stripearrayofkeys['publishable_key']; // Defined into config.php ?>');
// Create an instance of Elements
var elements = stripe.elements();
// Custom styling can be passed to options when creating an Element.
// (Note that this demo uses a wider set of styles than the guide below.)
var style = {
base: {
color: '#32325d',
lineHeight: '24px',
fontFamily: '"Helvetica Neue", Helvetica, sans-serif',
fontSmoothing: 'antialiased',
fontSize: '16px',
'::placeholder': {
color: '#aab7c4'
}
},
invalid: {
color: '#fa755a',
iconColor: '#fa755a'
}
};
// Create an instance of the card Element
var card = elements.create('card', {style: style});
// Add an instance of the card Element into the `card-element` <div>
card.mount('#card-element');
// Handle real-time validation errors from the card Element.
card.addEventListener('change', function(event) {
var displayError = document.getElementById('card-errors');
if (event.error) {
displayError.textContent = event.error.message;
} else {
displayError.textContent = '';
}
});
// Handle form submission
var form = document.getElementById('payment-form');
console.log(form);
form.addEventListener('submit', function(event) {
event.preventDefault();
<?php
if (empty($conf->global->STRIPE_USE_3DSECURE)) // Ask credit card directly, no 3DS test
{
?>
/* Use token */
stripe.createToken(card).then(function(result) {
if (result.error) {
// Inform the user if there was an error
var errorElement = document.getElementById('card-errors');
errorElement.textContent = result.error.message;
} else {
// Send the token to your server
stripeTokenHandler(result.token);
}
});
<?php
}
else // Ask credit card with 3DS test
{
?>
/* Use 3DS source */
stripe.createSource(card).then(function(result) {
if (result.error) {
// Inform the user if there was an error
var errorElement = document.getElementById('card-errors');
errorElement.textContent = result.error.message;
} else {
// Send the source to your server
stripeSourceHandler(result.source);
}
});
<?php
}
?>
});
/* Insert the Token into the form so it gets submitted to the server */
function stripeTokenHandler(token) {
// Insert the token ID into the form so it gets submitted to the server
var form = document.getElementById('payment-form');
var hiddenInput = document.createElement('input');
hiddenInput.setAttribute('type', 'hidden');
hiddenInput.setAttribute('name', 'stripeToken');
hiddenInput.setAttribute('value', token.id);
form.appendChild(hiddenInput);
// Submit the form
jQuery('#buttontopay').hide();
jQuery('#hourglasstopay').show();
console.log("submit token");
form.submit();
}
/* Insert the Source into the form so it gets submitted to the server */
function stripeSourceHandler(source) {
// Insert the source ID into the form so it gets submitted to the server
var form = document.getElementById('payment-form');
var hiddenInput = document.createElement('input');
hiddenInput.setAttribute('type', 'hidden');
hiddenInput.setAttribute('name', 'stripeSource');
hiddenInput.setAttribute('value', source.id);
form.appendChild(hiddenInput);
// Submit the form
jQuery('#buttontopay').hide();
jQuery('#hourglasstopay').show();
console.log("submit source");
form.submit();
}
<?php
}
print '</script>';
}
}

View File

@ -408,6 +408,7 @@ class Dolresource extends CommonObject
public function delete($rowid, $notrigger = 0)
{
global $user,$langs,$conf;
require_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php';
$error=0;

View File

@ -1207,7 +1207,7 @@ else
{
// Supplier
print '<tr>';
print '<td>'.$form->editfieldkey('Supplier', 'fournisseur', '', $object, 0, 'string', '', 1).'</td><td>';
print '<td>'.$form->editfieldkey('Vendor', 'fournisseur', '', $object, 0, 'string', '', 1).'</td><td>';
$default = -1;
if (! empty($conf->global->THIRDPARTY_SUPPLIER_BY_DEFAULT)) $default=1;
print $form->selectyesno("fournisseur", (GETPOST('fournisseur', 'int')!=''?GETPOST('fournisseur', 'int'):(GETPOST("type", 'alpha') == '' ? $default : $object->fournisseur)), 1, 0, (GETPOST("type", 'alpha') == '' ? 1 : 0));

View File

@ -84,7 +84,7 @@ if ($resql) {
if ($paycode == 'CB') $paycode = 'CB';
if ($paycode == 'CHQ') $paycode = 'CHEQUE';
$accountname="CASHDESK_ID_BANKACCOUNT_".$paycode;
$accountname="CASHDESK_ID_BANKACCOUNT_".$paycode.$_SESSION["takeposterminal"];
if (! empty($conf->global->$accountname) && $conf->global->$accountname > 0) array_push($paiements, $obj);
}
}

View File

@ -624,7 +624,7 @@ if ($resql){
if ($paycode == 'CB') $paycode = 'CARD';
if ($paycode == 'CHQ') $paycode = 'CHEQUE';
$accountname="CASHDESK_ID_BANKACCOUNT_".$paycode;
$accountname="CASHDESK_ID_BANKACCOUNT_".$paycode.$_SESSION["takeposterminal"];
if (! empty($conf->global->$accountname) && $conf->global->$accountname > 0) array_push($paiementsModes, $obj);
}
}