Merge branch '18.0' of git@github.com:Dolibarr/dolibarr.git into develop

This commit is contained in:
Laurent Destailleur 2023-07-31 02:44:26 +02:00
commit 6277cb836f
10 changed files with 98 additions and 58 deletions

View file

@ -334,9 +334,11 @@ if ($resql) {
$resql_supplier_price = $object->db->query($sql_supplier_price);
if ($resql_supplier_price) {
$obj = $object->db->fetch_object($resql_supplier_price);
if (!empty($obj->qty) && !empty($sub_bom_line->qty) && !empty($line->qty)) $line_cost = $obj->min_price/$obj->qty * $sub_bom_line->qty * $line->qty;
else $line_cost = $obj->min_price;
if (!empty($obj->qty) && !empty($sub_bom_line->qty) && !empty($line->qty)) {
$line_cost = $obj->min_price/$obj->qty * $sub_bom_line->qty * $line->qty;
} else {
$line_cost = $obj->min_price;
}
print '<td class="linecolcost nowrap right" id="sub_bom_cost_'.$sub_bom_line->id.'"><span class="amount">'.price2num($line_cost, 'MT').'</span></td>';
$total_cost+= $line_cost;
}

View file

@ -219,7 +219,8 @@ class mailing_contacts1 extends MailingTargets
if ($level == $obj->code) {
$level = $langs->trans($obj->label);
}
$s .= '<option value="prospectslevel'.$obj->code.'">'.$langs->trans("ThirdPartyProspects").' ('.$langs->trans("ProspectLevelShort").'='.$level.')</option>';
$labeltoshow = $langs->trans("ThirdPartyProspects").' <span class="opacitymedium">('.$langs->trans("ProspectLevelShort").'='.$level.')</span>';
$s .= '<option value="prospectslevel'.$obj->code.'" data-html="'.dol_escape_htmltag($labeltoshow).'">'.$labeltoshow.'</option>';
$i++;
}
} else {
@ -311,7 +312,7 @@ class mailing_contacts1 extends MailingTargets
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formadmin.class.php';
$formadmin = new FormAdmin($this->db);
$s .= img_picto($langs->trans("DefaultLang"), 'language', 'class="pictofixedwidth"');
$s .= $formadmin->select_language($langs->getDefaultLang(1), 'filter_lang', 0, null, $langs->trans("DefaultLang"), 0, 0, '', 0, 0, 0, null, 1);
$s .= $formadmin->select_language(GETPOST('filter_lang', 'aZ09'), 'filter_lang', 0, null, $langs->trans("DefaultLang"), 0, 0, '', 0, 0, 0, null, 1);
}
return $s;
@ -412,7 +413,7 @@ class mailing_contacts1 extends MailingTargets
}
// Filter on language
if (!empty($filter_lang)) {
if (!empty($filter_lang) && $filter_lang != '-1') {
$sql .= " AND sp.default_lang LIKE '".$this->db->escape($filter_lang)."%'";
}
@ -442,8 +443,9 @@ class mailing_contacts1 extends MailingTargets
}
$sql .= " ORDER BY sp.email";
// print "wwwwwwx".$sql;
// Stocke destinataires dans cibles
//print "wwwwwwx".$sql;
// Store recipients in target tables
$result = $this->db->query($sql);
if ($result) {
$num = $this->db->num_rows($result);

View file

@ -126,11 +126,11 @@ class mailing_thirdparties extends MailingTargets
$addDescription .= $langs->trans("Disabled");
}
}
if (GETPOST('default_lang', 'alpha')) {
if (GETPOST('default_lang', 'alpha') && GETPOST('default_lang', 'alpha') != '-1') {
$addFilter .= " AND s.default_lang LIKE '".$this->db->escape(GETPOST('default_lang', 'alpha'))."%'";
$addDescription = $langs->trans('DefaultLang')."=";
}
if (GETPOST('filter_lang_thirdparties', 'alpha')) {
if (GETPOST('filter_lang_thirdparties', 'alpha') && GETPOST('filter_lang_thirdparties', 'alpha') != '-1') {
$addFilter .= " AND s.default_lang LIKE '".$this->db->escape(GETPOST('filter_lang_thirdparties', 'alpha'))."%'";
$addDescription = $langs->trans('DefaultLang')."=";
}
@ -280,7 +280,7 @@ class mailing_thirdparties extends MailingTargets
$langs->load("companies");
// filter
$s = '<select id="filter_thirdparties" name="filter_thirdparties" class="flat">';
$s = '<select id="filter_thirdparties" name="filter_thirdparties" class="flat maxwidth200">';
// Show categories
$sql = "SELECT rowid, label, type, visible";
@ -316,10 +316,12 @@ class mailing_thirdparties extends MailingTargets
if ($obj->type == 2) {
$type = $langs->trans("Customer");
}
$s .= '<option value="'.$obj->rowid.'">'.dol_trunc($obj->label, 38, 'middle');
$labeltoshow = $obj->label;
if ($type) {
$s .= ' ('.$type.')';
$labeltoshow .= ' <span class="opacitymedium">('.$type.')</span>';
}
$s .= '<option value="'.$obj->rowid.'" data-html="'.dol_escape_htmltag($labeltoshow).'">';
$s .= $labeltoshow;
$s .= '</option>';
$i++;
}
@ -370,7 +372,7 @@ class mailing_thirdparties extends MailingTargets
$formadmin = new FormAdmin($this->db);
$s .= img_picto($langs->trans("DefaultLang"), 'language', 'class="pictofixedwidth"');
//$s .= '<span class="opacitymedium">'.$langs->trans("DefaultLang").':</span> ';
$s .= $formadmin->select_language($langs->getDefaultLang(1), 'filter_lang_thirdparties', 0, null, $langs->trans("DefaultLang"), 0, 0, '', 0, 0, 0, null, 1);
$s .= $formadmin->select_language(GETPOST('filter_lang_thirdparties', 'aZ09'), 'filter_lang_thirdparties', 0, null, $langs->trans("DefaultLang"), 0, 0, '', 0, 0, 0, null, 1);
}
return $s;

View file

@ -676,9 +676,9 @@ class Products extends DolibarrApi
require_once DOL_DOCUMENT_ROOT.'/product/class/productcustomerprice.class.php';
$prodcustprice = new Productcustomerprice($this->db);
$filter = array();
$filter['t.fk_product'] .= $id;
$filter['t.fk_product'] = $id;
if ($thirdparty_id) {
$filter['t.fk_soc'] .= $thirdparty_id;
$filter['t.fk_soc'] = $thirdparty_id;
}
$result = $prodcustprice->fetchAll('', '', 0, 0, $filter);
}

View file

@ -1003,7 +1003,9 @@ if ($action == 'create' && $user->rights->projet->creer && (empty($object->third
}
// progress resume not searchable
print '<td class="liste_titre right"></td>';
if (!empty($arrayfields['t.progress_summary']['checked'])) {
print '<td class="liste_titre right"></td>';
}
if ($object->usage_bill_time) {
if (!empty($arrayfields['t.tobill']['checked'])) {

View file

@ -399,35 +399,44 @@ if ($conf->global->MAIN_FEATURES_LEVEL >= 2) { // TODO Not used by current code
$service = 'StripeLive';
$servicestatus = 1;
}
global $stripearrayofkeysbyenv;
$site_account = $stripearrayofkeysbyenv[$servicestatus]['secret_key'];
if (!empty($site_account)) {
\Stripe\Stripe::setApiKey($site_account);
}
if (isModEnabled('stripe') && (empty($conf->global->STRIPE_LIVE) || GETPOST('forcesandbox', 'alpha'))) {
$service = 'StripeTest';
$servicestatus = '0';
dol_htmloutput_mesg($langs->trans('YouAreCurrentlyInSandboxMode', 'Stripe'), '', 'warning');
} else {
$service = 'StripeLive';
$servicestatus = '1';
}
$stripe = new Stripe($db);
if (!empty($site_account)) {
// If $site_account not defined, then key not set and no way to call API Location
$stripeacc = $stripe->getStripeAccount($service);
if ($stripeacc) {
$locations = \Stripe\Terminal\Location::all('', array("stripe_account" => $stripeacc));
try {
global $stripearrayofkeysbyenv;
$site_account = $stripearrayofkeysbyenv[$servicestatus]['secret_key'];
if (!empty($site_account)) {
\Stripe\Stripe::setApiKey($site_account);
}
if (isModEnabled('stripe') && (empty($conf->global->STRIPE_LIVE) || GETPOST('forcesandbox', 'alpha'))) {
$service = 'StripeTest';
$servicestatus = '0';
dol_htmloutput_mesg($langs->trans('YouAreCurrentlyInSandboxMode', 'Stripe'), '', 'warning');
} else {
$locations = \Stripe\Terminal\Location::all();
$service = 'StripeLive';
$servicestatus = '1';
}
$stripe = new Stripe($db);
if (!empty($site_account)) {
// If $site_account not defined, then key not set and no way to call API Location
$stripeacc = $stripe->getStripeAccount($service);
if ($stripeacc) {
$locations = \Stripe\Terminal\Location::all('', array("stripe_account" => $stripeacc));
} else {
$locations = \Stripe\Terminal\Location::all();
}
}
} catch (Exception $e) {
print $e->getMessage().'<br>';
}
// Define the array $location
$location = array();
$location[""] = $langs->trans("NotDefined");
if (!empty($locations)) {
foreach ($locations as $tmplocation) {
$location[$tmplocation->id] = $tmplocation->display_name;
}
}
$location = array();
$location[""] = $langs->trans("NotDefined");
foreach ($locations as $tmplocation) {
$location[$tmplocation->id] = $tmplocation->display_name;
}
print $form->selectarray("STRIPE_LOCATION", $location, getDolGlobalString('STRIPE_LOCATION'));
print '</td></tr>';
}

View file

@ -18,6 +18,11 @@
/**
* \file htdocs/stripe/ajax/ajax.php
* \brief Ajax action for Stipe ie: Terminal
*
* Calling with
* action=getConnexionToken return a token of Stripe terminal
* action=createPaymentIntent generates a payment intent
* action=capturePaymentIntent generates a payment
*/
if (!defined('NOTOKENRENEWAL')) {
@ -49,7 +54,12 @@ $servicestatus = GETPOST('servicestatus', 'int');
$amount = GETPOST('amount', 'int');
if (empty($user->rights->takepos->run)) {
accessforbidden();
accessforbidden('Not allowed to use TakePOS');
}
$usestripeterminals = getDolGlobalString('STRIPE_LOCATION');
if (! $usestripeterminals) {
accessforbidden('Feature to use Stripe terminals not enabled');
}
@ -68,7 +78,9 @@ if ($action == 'getConnexionToken') {
// The ConnectionToken's secret lets you connect to any Stripe Terminal reader
// and take payments with your Stripe account.
$array = array();
if (isset($location) && !empty($location)) $array['location'] = $location;
if (isset($location) && !empty($location)) {
$array['location'] = $location;
}
if (empty($stripeacc)) { // If the Stripe connect account not set, we use common API usage
$connectionToken = \Stripe\Terminal\ConnectionToken::create($array);
} else {

View file

@ -459,9 +459,10 @@ if (empty($reshook)) {
$invoice->fetch($placeid);
}
// If we add a line and no invoice yet, we create the invoice
if (($action == "addline" || $action == "freezone") && $placeid == 0) {
$invoice->socid = getDolGlobalString($constforcompanyid);
$invoice->date = dol_now();
$invoice->date = dol_now('tzuserrel'); // We use the local date, only the day will be saved.
$invoice->module_source = 'takepos';
$invoice->pos_source = isset($_SESSION["takeposterminal"]) ? $_SESSION["takeposterminal"] : '' ;
$invoice->entity = !empty($_SESSION["takeposinvoiceentity"]) ? $_SESSION["takeposinvoiceentity"] : $conf->entity;
@ -470,6 +471,7 @@ if (empty($reshook)) {
$langs->load('errors');
dol_htmloutput_errors($langs->trans("ErrorModuleSetupNotComplete", "TakePos"), null, 1);
} else {
// Create invoice
$placeid = $invoice->create($user);
if ($placeid < 0) {
dol_htmloutput_errors($invoice->error, $invoice->errors, 1);

View file

@ -96,28 +96,34 @@ if (isModEnabled('stripe')) {
$stripeacc = $stripe->getStripeAccount($service); // Get Stripe OAuth connect account (no remote access to Stripe here)
$stripecu = $stripe->getStripeCustomerAccount($object->id, $servicestatus, $site_account); // Get remote Stripe customer 'cus_...' (no remote access to Stripe here)
$keyforstripeterminalbank = "CASHDESK_ID_BANKACCOUNT_STRIPETERMINAL".$_SESSION["takeposterminal"];
?>
$usestripeterminals = getDolGlobalString('STRIPE_LOCATION');
if ($usestripeterminals) {
?>
<script src="https://js.stripe.com/terminal/v1/"></script>
<script>
var terminal = StripeTerminal.create({
onFetchConnectionToken: fetchConnectionToken,
onUnexpectedReaderDisconnect: unexpectedDisconnect,
});
function unexpectedDisconnect() {
// In this function, your app should notify the user that the reader disconnected.
// You can also include a way to attempt to reconnect to a reader.
console.log("Disconnected from reader")
}
function fetchConnectionToken() {
<?php
$urlconnexiontoken = DOL_URL_ROOT.'/stripe/ajax/ajax.php?action=getConnexionToken&token='.newToken().'&servicestatus='.urlencode($servicestatus);
if (!empty($conf->global->STRIPE_LOCATION)) {
$urlconnexiontoken .= '&location='.urlencode($conf->global->STRIPE_LOCATION);
}
if (!empty($stripeacc)) {
$urlconnexiontoken .= '&stripeacc='.urlencode($stripeacc);
}
?>
<?php
$urlconnexiontoken = DOL_URL_ROOT.'/stripe/ajax/ajax.php?action=getConnexionToken&token='.newToken().'&servicestatus='.urlencode($servicestatus);
if (!empty($conf->global->STRIPE_LOCATION)) {
$urlconnexiontoken .= '&location='.urlencode($conf->global->STRIPE_LOCATION);
}
if (!empty($stripeacc)) {
$urlconnexiontoken .= '&stripeacc='.urlencode($stripeacc);
}
?>
// Do not cache or hardcode the ConnectionToken. The SDK manages the ConnectionToken's lifecycle.
return fetch('<?php echo $urlconnexiontoken; ?>', { method: "POST" })
.then(function(response) {
@ -127,8 +133,11 @@ function fetchConnectionToken() {
return data.secret;
});
}
</script>
<?php }
<?php
}
}
if (isModEnabled('stripe') && isset($keyforstripeterminalbank) && (empty($conf->global->STRIPE_LIVE) || GETPOST('forcesandbox', 'alpha'))) {
dol_htmloutput_mesg($langs->trans('YouAreCurrentlyInSandboxMode', 'Stripe'), '', 'warning', 1);

View file

@ -92,14 +92,14 @@ if ($subdir == 'propale' || $subdir == 'proposal') {
} else {
print 'Error, module not enabled'."\n";
}
} else if ($subdir == 'commande' || $subdir == 'order') {
} elseif ($subdir == 'commande' || $subdir == 'order') {
if (isModEnabled('commande')) {
require_once DOL_DOCUMENT_ROOT."/commande/class/commande.class.php";
$tmpobject = new Commande($db);
} else {
print 'Error, module not enabled'."\n";
}
} else if ($subdir == 'facture' || $subdir == 'invoice') {
} elseif ($subdir == 'facture' || $subdir == 'invoice') {
if (isModEnabled('facture')) {
require_once DOL_DOCUMENT_ROOT."/compta/facture/class/facture.class.php";
$tmpobject = new Facture($db);