diff --git a/htdocs/bom/tpl/objectline_view.tpl.php b/htdocs/bom/tpl/objectline_view.tpl.php index 25a86943a43..fdc06609c24 100644 --- a/htdocs/bom/tpl/objectline_view.tpl.php +++ b/htdocs/bom/tpl/objectline_view.tpl.php @@ -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 ''.price2num($line_cost, 'MT').''; $total_cost+= $line_cost; } diff --git a/htdocs/core/modules/mailings/contacts1.modules.php b/htdocs/core/modules/mailings/contacts1.modules.php index 13436761c3b..772c9900573 100644 --- a/htdocs/core/modules/mailings/contacts1.modules.php +++ b/htdocs/core/modules/mailings/contacts1.modules.php @@ -219,7 +219,8 @@ class mailing_contacts1 extends MailingTargets if ($level == $obj->code) { $level = $langs->trans($obj->label); } - $s .= ''; + $labeltoshow = $langs->trans("ThirdPartyProspects").' ('.$langs->trans("ProspectLevelShort").'='.$level.')'; + $s .= ''; $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); diff --git a/htdocs/core/modules/mailings/thirdparties.modules.php b/htdocs/core/modules/mailings/thirdparties.modules.php index bc9a763ab1f..e678dab33ed 100644 --- a/htdocs/core/modules/mailings/thirdparties.modules.php +++ b/htdocs/core/modules/mailings/thirdparties.modules.php @@ -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 = ''; // 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 .= ''; $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 .= ''.$langs->trans("DefaultLang").': '; - $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; diff --git a/htdocs/product/class/api_products.class.php b/htdocs/product/class/api_products.class.php index f144011fde3..d114d115e0e 100644 --- a/htdocs/product/class/api_products.class.php +++ b/htdocs/product/class/api_products.class.php @@ -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); } diff --git a/htdocs/projet/tasks.php b/htdocs/projet/tasks.php index ad3934f1dcc..196bc2d4582 100644 --- a/htdocs/projet/tasks.php +++ b/htdocs/projet/tasks.php @@ -1003,7 +1003,9 @@ if ($action == 'create' && $user->rights->projet->creer && (empty($object->third } // progress resume not searchable - print ''; + if (!empty($arrayfields['t.progress_summary']['checked'])) { + print ''; + } if ($object->usage_bill_time) { if (!empty($arrayfields['t.tobill']['checked'])) { diff --git a/htdocs/stripe/admin/stripe.php b/htdocs/stripe/admin/stripe.php index eb8c36fe4ba..6785869feb5 100644 --- a/htdocs/stripe/admin/stripe.php +++ b/htdocs/stripe/admin/stripe.php @@ -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().'
'; + } + + // 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 ''; } diff --git a/htdocs/stripe/ajax/ajax.php b/htdocs/stripe/ajax/ajax.php index 5fa4da88ae7..664e21303dd 100644 --- a/htdocs/stripe/ajax/ajax.php +++ b/htdocs/stripe/ajax/ajax.php @@ -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 { diff --git a/htdocs/takepos/invoice.php b/htdocs/takepos/invoice.php index 56a850f11fd..85f66e964a3 100644 --- a/htdocs/takepos/invoice.php +++ b/htdocs/takepos/invoice.php @@ -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); diff --git a/htdocs/takepos/pay.php b/htdocs/takepos/pay.php index ea4a106e808..e71bf4aa728 100644 --- a/htdocs/takepos/pay.php +++ b/htdocs/takepos/pay.php @@ -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) { + ?> -global->STRIPE_LIVE) || GETPOST('forcesandbox', 'alpha'))) { dol_htmloutput_mesg($langs->trans('YouAreCurrentlyInSandboxMode', 'Stripe'), '', 'warning', 1); diff --git a/scripts/doc/regenerate_docs.php b/scripts/doc/regenerate_docs.php index b0a3ee17cf2..e76cc615298 100755 --- a/scripts/doc/regenerate_docs.php +++ b/scripts/doc/regenerate_docs.php @@ -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);