diff --git a/dev/tools/phan/baseline.txt b/dev/tools/phan/baseline.txt index 6a051e0e047..37893741f78 100644 --- a/dev/tools/phan/baseline.txt +++ b/dev/tools/phan/baseline.txt @@ -9,16 +9,16 @@ */ return [ // # Issue statistics: - // PhanTypeMismatchArgument : 1520+ occurrences + // PhanTypeMismatchArgument : 1470+ occurrences // PhanUndeclaredProperty : 500+ occurrences // PhanTypeMismatchArgumentNullable : 320+ occurrences // PhanPluginUnknownArrayMethodReturnType : 170+ occurrences // PhanUndeclaredGlobalVariable : 160+ occurrences // PhanTypeMismatchProperty : 120+ occurrences // PhanPluginUnknownArrayMethodParamType : 110+ occurrences - // PhanPossiblyUndeclaredGlobalVariable : 55+ occurrences - // PhanTypeMismatchArgumentProbablyReal : 55+ occurrences + // PhanTypeMismatchArgumentProbablyReal : 35+ occurrences // PhanTypeExpectedObjectPropAccess : 30+ occurrences + // PhanPossiblyUndeclaredGlobalVariable : 25+ occurrences // PhanTypeInvalidDimOffset : 25+ occurrences // PhanTypeMismatchDimFetch : 20+ occurrences // PhanPluginUndeclaredVariableIsset : 15+ occurrences @@ -33,7 +33,6 @@ return [ // PhanEmptyFQSENInClasslike : 3 occurrences // PhanInvalidFQSENInClasslike : 3 occurrences // PhanPluginSuspiciousParamPosition : 3 occurrences - // PhanPluginEmptyStatementIf : 2 occurrences // PhanRedefineFunction : 2 occurrences // PhanTypeMismatchDimAssignment : 2 occurrences // PhanTypeSuspiciousStringExpression : 2 occurrences @@ -43,7 +42,6 @@ return [ // PhanPluginUnknownArrayPropertyType : 1 occurrence // PhanPossiblyUndeclaredVariable : 1 occurrence // PhanTypeExpectedObjectPropAccessButGotNull : 1 occurrence - // PhanUndeclaredVariable : 1 occurrence // Currently, file_suppressions and directory_suppressions are the only supported suppressions 'file_suppressions' => [ @@ -266,7 +264,6 @@ return [ 'htdocs/compta/prelevement/card.php' => ['PhanTypeMismatchArgument'], 'htdocs/compta/prelevement/class/bonprelevement.class.php' => ['PhanTypeMismatchArgumentNullable'], 'htdocs/compta/prelevement/class/rejetprelevement.class.php' => ['PhanTypeMismatchArgument'], - 'htdocs/compta/prelevement/create.php' => ['PhanTypeMismatchArgument'], 'htdocs/compta/prelevement/demandes.php' => ['PhanTypeMismatchArgumentNullable'], 'htdocs/compta/prelevement/line.php' => ['PhanTypeMismatchArgument', 'PhanTypeMismatchArgumentNullable'], 'htdocs/compta/resultat/clientfourn.php' => ['PhanTypeMismatchArgument'], @@ -518,7 +515,6 @@ return [ 'htdocs/expensereport/payment/info.php' => ['PhanUndeclaredGlobalVariable'], 'htdocs/expensereport/payment/list.php' => ['PhanTypeMismatchArgument'], 'htdocs/expensereport/tpl/linkedobjectblock.tpl.php' => ['PhanUndeclaredProperty'], - 'htdocs/exports/class/export.class.php' => ['PhanTypeMismatchArgument'], 'htdocs/exports/export.php' => ['PhanTypeMismatchArgument'], 'htdocs/externalsite/frames.php' => ['PhanUndeclaredGlobalVariable'], 'htdocs/fichinter/agenda.php' => ['PhanTypeMismatchArgument'], @@ -645,17 +641,9 @@ return [ 'htdocs/supplier_proposal/card.php' => ['PhanUndeclaredGlobalVariable', 'PhanUndeclaredProperty'], 'htdocs/supplier_proposal/class/api_supplier_proposals.class.php' => ['PhanPluginUnknownArrayMethodParamType', 'PhanPluginUnknownArrayMethodReturnType', 'PhanUndeclaredProperty'], 'htdocs/supplier_proposal/class/supplier_proposal.class.php' => ['PhanUndeclaredProperty'], - 'htdocs/takepos/admin/bar.php' => ['PhanTypeMismatchArgument'], - 'htdocs/takepos/admin/terminal.php' => ['PhanTypeMismatchArgument'], - 'htdocs/takepos/ajax/ajax.php' => ['PhanTypeMismatchArgument', 'PhanTypeMismatchArgumentProbablyReal', 'PhanUndeclaredProperty'], - 'htdocs/takepos/floors.php' => ['PhanTypeMismatchArgumentProbablyReal'], - 'htdocs/takepos/freezone.php' => ['PhanTypeMismatchArgument', 'PhanTypeMismatchArgumentProbablyReal'], - 'htdocs/takepos/index.php' => ['PhanPluginUndeclaredVariableIsset', 'PhanTypeMismatchArgument'], - 'htdocs/takepos/invoice.php' => ['PhanPluginEmptyStatementIf', 'PhanPossiblyUndeclaredGlobalVariable', 'PhanTypeMismatchArgument', 'PhanTypeMismatchArgumentNullable', 'PhanTypeMismatchArgumentProbablyReal', 'PhanUndeclaredGlobalVariable'], - 'htdocs/takepos/pay.php' => ['PhanPossiblyUndeclaredGlobalVariable', 'PhanTypeMismatchArgumentNullable'], - 'htdocs/takepos/phone.php' => ['PhanTypeMismatchArgument'], - 'htdocs/takepos/send.php' => ['PhanTypeMismatchArgument'], - 'htdocs/takepos/split.php' => ['PhanPluginUndeclaredVariableIsset', 'PhanPossiblyUndeclaredGlobalVariable', 'PhanTypeMismatchArgumentProbablyReal'], + 'htdocs/takepos/index.php' => ['PhanPluginUndeclaredVariableIsset'], + 'htdocs/takepos/invoice.php' => ['PhanPossiblyUndeclaredGlobalVariable', 'PhanUndeclaredGlobalVariable'], + 'htdocs/takepos/split.php' => ['PhanPluginUndeclaredVariableIsset'], 'htdocs/theme/eldy/badges.inc.php' => ['PhanRedefineFunction'], 'htdocs/theme/eldy/btn.inc.php' => ['PhanUndeclaredGlobalVariable'], 'htdocs/theme/eldy/dropdown.inc.php' => ['PhanUndeclaredGlobalVariable'], diff --git a/htdocs/product/class/productbatch.class.php b/htdocs/product/class/productbatch.class.php index 7ffc627d8b0..7ac2a896fe1 100644 --- a/htdocs/product/class/productbatch.class.php +++ b/htdocs/product/class/productbatch.class.php @@ -3,7 +3,7 @@ * Copyright (C) 2013-2014 Cedric GROSS * Copyright (C) 2024 Frédéric France * Copyright (C) 2024 Ferran Marcet - * Copyright (C) 2024 MDW + * Copyright (C) 2024-2025 MDW * * 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 @@ -75,19 +75,18 @@ class Productbatch extends CommonObject public $fk_product; /** - * * @var int Properties of the lot * ID in table of the details of properties of each lots */ public $lotid; /** - * @var int|string + * @var int|'' * @deprecated */ public $sellby = ''; // dlc /** - * @var int|string + * @var int|'' * @deprecated */ public $eatby = ''; // dmd/dluo @@ -107,9 +106,9 @@ class Productbatch extends CommonObject /** * Create object into database * - * @param User $user User that creates - * @param int $notrigger 0=launch triggers after, 1=disable triggers - * @return int Return integer <0 if KO, Id of created object if OK + * @param User $user User that creates + * @param int<0,1> $notrigger 0=launch triggers after, 1=disable triggers + * @return int Return integer <0 if KO, Id of created object if OK */ public function create($user, $notrigger = 0) { @@ -402,13 +401,13 @@ class Productbatch extends CommonObject * Find first detailed record that match either eat-by, sell-by or batch within the warehouse * * @param int $fk_product_stock id product_stock for object - * @param integer $eatby eat-by date for object - deprecated: a search must be done on batch number - * @param integer $sellby sell-by date for object - deprecated: a search must be done on batch number + * @param int|'' $eatby eat-by date for object - deprecated: a search must be done on batch number + * @param int|'' $sellby sell-by date for object - deprecated: a search must be done on batch number * @param string $batch_number batch number for object * @param int $fk_warehouse filter on warehouse (use it if you don't have $fk_product_stock) * @return int Return integer <0 if KO, >0 if OK */ - public function find($fk_product_stock = 0, $eatby = null, $sellby = null, $batch_number = '', $fk_warehouse = 0) + public function find($fk_product_stock = 0, $eatby = '', $sellby = '', $batch_number = '', $fk_warehouse = 0) { $where = array(); @@ -472,7 +471,7 @@ class Productbatch extends CommonObject * * @param DoliDB $dbs database object * @param int $fk_product_stock id product_stock for object - * @param int $with_qty 1 = doesn't return line with 0 quantity + * @param int<0,1> $with_qty 1 = doesn't return line with 0 quantity * @param int $fk_product If set to a product id, get eatby and sellby from table llx_product_lot * @return Productbatch[]|int Return integer <0 if KO, array of batch */ diff --git a/htdocs/product/stock/class/mouvementstock.class.php b/htdocs/product/stock/class/mouvementstock.class.php index 7659c066370..e7fb45d9590 100644 --- a/htdocs/product/stock/class/mouvementstock.class.php +++ b/htdocs/product/stock/class/mouvementstock.class.php @@ -3,7 +3,7 @@ * Copyright (C) 2005-2015 Laurent Destailleur * Copyright (C) 2011 Jean Heimburger * Copyright (C) 2014 Cedric GROSS - * Copyright (C) 2024-2025 MDW + * Copyright (C) 2024-2025 MDW * Copyright (C) 2024 Frédéric France * * This program is free software; you can redistribute it and/or modify @@ -201,11 +201,11 @@ class MouvementStock extends CommonObject * @param int $fk_product Id of product * @param int $entrepot_id Id of warehouse * @param float $qty Qty of movement (can be <0 or >0 depending on parameter type) - * @param int $type Direction of movement: + * @param int<0,3> $type Direction of movement: * 0=input (stock increase by a stock transfer), 1=output (stock decrease by a stock transfer), * 2=output (stock decrease), 3=input (stock increase) * Note that qty should be > 0 with 0 or 3, < 0 with 1 or 2. - * @param int $price Unit price HT of product, used to calculate average weighted price (AWP or PMP in french). If 0, average weighted price is not changed. + * @param float $price Unit price HT of product, used to calculate average weighted price (AWP or PMP in french). If 0, average weighted price is not changed. * @param string $label Label of stock movement * @param string $inventorycode Inventory code * @param int|string $datem Force date of movement @@ -785,10 +785,10 @@ class MouvementStock extends CommonObject * @param int $entrepot_id Warehouse id * @param float $qty Quantity * @param int $type Type - * @param int $price Price + * @param float $price Price * @param string $label Label of movement * @param string $inventorycode Inventory code - * @param integer|string $datem Force date of movement + * @param int|'' $datem Force date of movement * @return int Return integer <0 if KO, 0 if OK */ private function _createSubProduct($user, $idProduct, $entrepot_id, $qty, $type, $price = 0, $label = '', $inventorycode = '', $datem = '') @@ -847,15 +847,15 @@ class MouvementStock extends CommonObject * @param int $fk_product Id product * @param int $entrepot_id Warehouse id * @param float $qty Quantity - * @param int $price Price + * @param float $price Price * @param string $label Label of stock movement - * @param int|string $datem Force date of movement - * @param int|string $eatby eat-by date - * @param int|string $sellby sell-by date + * @param int|'' $datem Force date of movement + * @param int|'' $eatby eat-by date + * @param int|'' $sellby sell-by date * @param string $batch batch number * @param int $id_product_batch Id product_batch * @param string $inventorycode Inventory code - * @param int $donotcleanemptylines Do not clean lines that remains in stock table with qty=0 (because we want to have this done by the caller) + * @param int<0,1> $donotcleanemptylines Do not clean lines that remains in stock table with qty=0 (because we want to have this done by the caller) * @return int Return integer <0 if KO, >0 if OK */ public function livraison($user, $fk_product, $entrepot_id, $qty, $price = 0, $label = '', $datem = '', $eatby = '', $sellby = '', $batch = '', $id_product_batch = 0, $inventorycode = '', $donotcleanemptylines = 0) @@ -874,15 +874,15 @@ class MouvementStock extends CommonObject * @param int $fk_product Id product * @param int $entrepot_id Warehouse id * @param float $qty Quantity - * @param int $price Price + * @param float $price Price * @param string $label Label of stock movement - * @param integer|string $eatby eat-by date - * @param integer|string $sellby sell-by date + * @param int|'' $eatby eat-by date + * @param int|'' $sellby sell-by date * @param string $batch batch number - * @param integer|string $datem Force date of movement + * @param int|'' $datem Force date of movement * @param int $id_product_batch Id product_batch * @param string $inventorycode Inventory code - * @param int $donotcleanemptylines Do not clean lines that remains in stock table with qty=0 (because we want to have this done by the caller) + * @param int<0,1> $donotcleanemptylines Do not clean lines that remains in stock table with qty=0 (because we want to have this done by the caller) * @return int Return integer <0 if KO, >0 if OK */ public function reception($user, $fk_product, $entrepot_id, $qty, $price = 0, $label = '', $eatby = '', $sellby = '', $batch = '', $datem = '', $id_product_batch = 0, $inventorycode = '', $donotcleanemptylines = 0) diff --git a/htdocs/takepos/admin/bar.php b/htdocs/takepos/admin/bar.php index 9459557f18c..f49f8b8b2de 100644 --- a/htdocs/takepos/admin/bar.php +++ b/htdocs/takepos/admin/bar.php @@ -3,6 +3,7 @@ * Copyright (C) 2011-2017 Juanjo Menent * Copyright (C) 2022 Alexandre Spangaro * Copyright (C) 2024 Frédéric France + * Copyright (C) 2025 MDW * * 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 @@ -81,7 +82,7 @@ if (GETPOST('action', 'alpha') == 'set') { if (getDolGlobalInt('TAKEPOS_ORDER_NOTES') == 1) { $extrafields = new ExtraFields($db); - $extrafields->addExtraField('order_notes', 'Order notes', 'varchar', 0, 255, 'facturedet', 0, 0, '', '', 0, '', 0, 1); + $extrafields->addExtraField('order_notes', 'Order notes', 'varchar', 0, '255', 'facturedet', 0, 0, '', '', 0, '', '0', '1'); } /* diff --git a/htdocs/takepos/admin/terminal.php b/htdocs/takepos/admin/terminal.php index 06a8424daac..c430c572d3c 100644 --- a/htdocs/takepos/admin/terminal.php +++ b/htdocs/takepos/admin/terminal.php @@ -269,9 +269,9 @@ if (isModEnabled("bank")) { $stripe = new Stripe($db); $stripeacc = $stripe->getStripeAccount($service); if ($stripeacc) { - $readers = \Stripe\Terminal\Reader::all('', array("location" => getDolGlobalString('STRIPE_LOCATION'), "stripe_account" => $stripeacc)); + $readers = \Stripe\Terminal\Reader::all(null, array("location" => getDolGlobalString('STRIPE_LOCATION'), "stripe_account" => $stripeacc)); } else { - $readers = \Stripe\Terminal\Reader::all('', array("location" => getDolGlobalString('STRIPE_LOCATION'))); + $readers = \Stripe\Terminal\Reader::all(null, array("location" => getDolGlobalString('STRIPE_LOCATION'))); } $reader = array(); @@ -323,7 +323,7 @@ if (isModEnabled('stock')) { print ''; - $disabled = getDolGlobalString('CASHDESK_NO_DECREASE_STOCK'.$terminal); + $disabled = getDolGlobalInt('CASHDESK_NO_DECREASE_STOCK'.$terminal); print ''; diff --git a/htdocs/takepos/ajax/ajax.php b/htdocs/takepos/ajax/ajax.php index b90d55d2aa6..7855842ae5b 100644 --- a/htdocs/takepos/ajax/ajax.php +++ b/htdocs/takepos/ajax/ajax.php @@ -2,6 +2,7 @@ /* Copyright (C) 2001-2004 Andreu Bisquerra * Copyright (C) 2020 Thibault FOUCART * Copyright (C) 2024 Frédéric France + * Copyright (C) 2025 MDW * * 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 @@ -111,6 +112,7 @@ if ($action == 'getProducts' && $user->hasRight('takepos', 'run')) { $res = array(); if (is_array($prods) && count($prods) > 0) { foreach ($prods as $prod) { + '@phan-var-force Product $prod'; if (getDolGlobalInt('TAKEPOS_PRODUCT_IN_STOCK') == 1) { // remove products without stock $prod->load_stock('nobatch,novirtual'); @@ -134,8 +136,8 @@ if ($action == 'getProducts' && $user->hasRight('takepos', 'run')) { } elseif ($action == 'search' && $search_term != '' && $user->hasRight('takepos', 'run')) { top_httphead('application/json'); - // Search barcode into thirdparties. If found, it means we want to change thirdparties. - $result = $thirdparty->fetch('', '', '', $search_term); + // Search barcode into third parties. If found, it means we want to change third parties. + $result = $thirdparty->fetch(0, '', '', $search_term); if ($result && $thirdparty->id > 0) { $rows = array(); @@ -338,7 +340,7 @@ if ($action == 'getProducts' && $user->hasRight('takepos', 'run')) { } // load only one page of products - $sql.= $db->plimit($search_limit, $search_start); + $sql .= $db->plimit($search_limit, $search_start); $resql = $db->query($sql); if ($resql) { @@ -379,7 +381,7 @@ if ($action == 'getProducts' && $user->hasRight('takepos', 'run')) { 'price_ttc_formated' => price(price2num(empty($objProd->multiprices_ttc[$pricelevel]) ? $obj->price_ttc : $objProd->multiprices_ttc[$pricelevel], 'MT'), 1, $langs, 1, -1, -1, $conf->currency) ); // Add entries to row from hooks - $parameters=array(); + $parameters = array(); $parameters['row'] = $row; $parameters['obj'] = $obj; $reshook = $hookmanager->executeHooks('completeAjaxReturnArray', $parameters); @@ -429,7 +431,7 @@ if ($action == 'getProducts' && $user->hasRight('takepos', 'run')) { if ((getDolGlobalInt('TAKEPOS_PRINTER_TO_USE'.$term) > 0 || getDolGlobalString('TAKEPOS_PRINT_METHOD') == "takeposconnector") && getDolGlobalInt('TAKEPOS_TEMPLATE_TO_USE_FOR_INVOICES'.$term) > 0) { $object = new Facture($db); $object->fetch($id); - $ret = $printer->sendToPrinter($object, getDolGlobalString('TAKEPOS_TEMPLATE_TO_USE_FOR_INVOICES'.$term), getDolGlobalString('TAKEPOS_PRINTER_TO_USE'.$term)); + $ret = $printer->sendToPrinter($object, getDolGlobalInt('TAKEPOS_TEMPLATE_TO_USE_FOR_INVOICES'.$term), getDolGlobalInt('TAKEPOS_PRINTER_TO_USE'.$term)); } } elseif ($action == 'getInvoice' && $user->hasRight('takepos', 'run')) { top_httphead('application/json'); @@ -452,5 +454,5 @@ if ($action == 'getProducts' && $user->hasRight('takepos', 'run')) { $object = new Facture($db); $printer = new dolReceiptPrinter($db); - $printer->sendToPrinter($object, getDolGlobalString('TAKEPOS_TEMPLATE_TO_USE_FOR_INVOICES'.$term), getDolGlobalString('TAKEPOS_PRINTER_TO_USE'.$term)); + $printer->sendToPrinter($object, getDolGlobalInt('TAKEPOS_TEMPLATE_TO_USE_FOR_INVOICES'.$term), getDolGlobalInt('TAKEPOS_PRINTER_TO_USE'.$term)); } diff --git a/htdocs/takepos/floors.php b/htdocs/takepos/floors.php index 540244d87d6..e26369e97a8 100644 --- a/htdocs/takepos/floors.php +++ b/htdocs/takepos/floors.php @@ -1,6 +1,6 @@ - * Copyright (C) 2024 MDW + * Copyright (C) 2024-2025 MDW * Copyright (C) 2024 Frédéric France * * This program is free software; you can redistribute it and/or modify @@ -85,7 +85,7 @@ if ($action == "getTables" && $user->hasRight('takepos', 'run')) { $tmpplace = (int) $row['rowid']; $invoice = new Facture($db); - $result = $invoice->fetch('', '(PROV-POS'.$_SESSION['takeposterminal'].'-'.$tmpplace.')'); + $result = $invoice->fetch(0, '(PROV-POS'.$_SESSION['takeposterminal'].'-'.$tmpplace.')'); if ($result > 0) { $row['occupied'] = "red"; } diff --git a/htdocs/takepos/freezone.php b/htdocs/takepos/freezone.php index b25e42a77ea..245c60be2e3 100644 --- a/htdocs/takepos/freezone.php +++ b/htdocs/takepos/freezone.php @@ -2,6 +2,7 @@ /* Copyright (C) 2018 Andreu Bisquerra * Copyright (C) 2020 Laurent Destailleur * Copyright (C) 2024 Frédéric France + * Copyright (C) 2025 MDW * * 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 @@ -60,7 +61,7 @@ $langs->loadLangs(array("bills", "cashdesk")); $place = (GETPOST('place', 'aZ09') ? GETPOST('place', 'aZ09') : '0'); // $place is id of table for Bar or Restaurant -$invoiceid = GETPOST('invoiceid', 'int'); +$invoiceid = GETPOSTINT('invoiceid'); $idline = GETPOSTINT('idline'); $action = GETPOST('action', 'aZ09'); @@ -74,7 +75,7 @@ $invoice = new Facture($db); if ($invoiceid > 0) { $invoice->fetch($invoiceid); } else { - $invoice->fetch('', '(PROV-POS'.$_SESSION['takeposterminal'].'-'.$place.')'); + $invoice->fetch(0, '(PROV-POS'.$_SESSION['takeposterminal'].'-'.$place.')'); } diff --git a/htdocs/takepos/index.php b/htdocs/takepos/index.php index d6c17330525..659a22d10a8 100644 --- a/htdocs/takepos/index.php +++ b/htdocs/takepos/index.php @@ -2,7 +2,7 @@ /* Copyright (C) 2018 Andreu Bisquerra * Copyright (C) 2019 Josep Lluís Amador * Copyright (C) 2020 Thibault FOUCART - * Copyright (C) 2024 MDW + * Copyright (C) 2024-2025 MDW * Copyright (C) 2024 Frédéric France * * This program is free software; you can redistribute it and/or modify @@ -1363,7 +1363,7 @@ if (isset($_SESSION["takeposterminal"]) && $_SESSION["takeposterminal"]) { if (count($maincategories) == 0) { if (getDolGlobalInt('TAKEPOS_ROOT_CATEGORY_ID') > 0) { $tmpcategory = new Categorie($db); - $tmpcategory->fetch(getDolGlobalString('TAKEPOS_ROOT_CATEGORY_ID')); + $tmpcategory->fetch(getDolGlobalInt('TAKEPOS_ROOT_CATEGORY_ID')); setEventMessages($langs->trans("TakeposNeedsAtLeastOnSubCategoryIntoParentCategory", $tmpcategory->label), null, 'errors'); } else { setEventMessages($langs->trans("TakeposNeedsCategories"), null, 'errors'); @@ -1577,14 +1577,14 @@ if (getDolGlobalString('TAKEPOS_WEIGHING_SCALE')) { $count = 0; while ($count < $MAXPRODUCT) { print '
- onclick="MoreProducts('less')" onclick="MoreProducts('more')" > + onclick="MoreProducts('less')" onclick="MoreProducts('more')" > '; diff --git a/htdocs/takepos/invoice.php b/htdocs/takepos/invoice.php index 604fb1dd176..9975c744503 100644 --- a/htdocs/takepos/invoice.php +++ b/htdocs/takepos/invoice.php @@ -3,7 +3,7 @@ * Copyright (C) 2018 Andreu Bisquerra * Copyright (C) 2021 Nicolas ZABOURI * Copyright (C) 2022-2023 Christophe Battarel - * Copyright (C) 2024 MDW + * Copyright (C) 2024-2025 MDW * Copyright (C) 2024 Frédéric France * * This program is free software; you can redistribute it and/or modify @@ -96,7 +96,7 @@ $takeposterminal = isset($_SESSION["takeposterminal"]) ? $_SESSION["takepostermi * Abort invoice creation with a given error message * * @param string $message Message explaining the error to the user - * @return void + * @return never */ function fail($message) { @@ -106,7 +106,7 @@ function fail($message) -$number = GETPOST('number', 'alpha'); +$number = (float) GETPOST('number', 'alpha'); $idline = GETPOSTINT('idline'); $selectedline = GETPOSTINT('selectedline'); $desc = GETPOST('desc', 'alphanohtml'); @@ -145,7 +145,7 @@ $invoice = new Facture($db); if ($invoiceid > 0) { $ret = $invoice->fetch($invoiceid); } else { - $ret = $invoice->fetch('', '(PROV-POS'.$takeposterminal.'-'.$place.')'); + $ret = $invoice->fetch(0, '(PROV-POS'.$takeposterminal.'-'.$place.')'); } if ($ret > 0) { $placeid = $invoice->id; @@ -157,7 +157,7 @@ $soc = new Societe($db); if ($invoice->socid > 0) { $soc->fetch($invoice->socid); } else { - $soc->fetch(getDolGlobalString($constforcompanyid)); + $soc->fetch(getDolGlobalInt($constforcompanyid)); } // Assign a default project, if relevant @@ -185,6 +185,13 @@ if ($reshook < 0) { setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); } +$sectionwithinvoicelink = ''; +$CUSTOMER_DISPLAY_line1 = ''; +$CUSTOMER_DISPLAY_line2 = ''; +$headerorder = ''; +$footerorder = ''; +$printer = null; +$idoflineadded = 0; if (empty($reshook)) { // Action to record a payment on a TakePOS invoice if ($action == 'valid' && $user->hasRight('facture', 'creer')) { @@ -227,11 +234,12 @@ if (empty($reshook)) { $sql .= " AND fk_statut >= ".$invoice::STATUS_VALIDATED; $sql .= " ORDER BY rowid DESC"; + $fk_source = 0; $resql = $db->query($sql); if ($resql) { $obj = $db->fetch_object($resql); $fk_source = $obj->rowid; - if ($fk_source == null) { + if ((int) $fk_source == 0) { fail($langs->transnoentitiesnoconv("NoPreviousBillForCustomer")); } } else { @@ -342,6 +350,7 @@ if (empty($reshook)) { dol_htmloutput_errors($invoice->error, $invoice->errors, 1); } + $warehouseid = 0; // Update stock for batch products if (!$error && $res >= 0) { if (isModEnabled('stock') && isModEnabled('productbatch') && $allowstockchange) { @@ -392,6 +401,7 @@ if (empty($reshook)) { $db->rollback(); } } + $creditnote = null; if ($action == 'creditnote' && $user->hasRight('facture', 'creer')) { $db->begin(); @@ -535,7 +545,7 @@ if (empty($reshook)) { // Validate invoice with stock change into warehouse getDolGlobalInt($constantforkey) // Label of stock movement will be the same as when we validate invoice "Invoice XXXX validated" $batch_rule = 0; // Module productbatch is disabled here, so no need for a batch_rule. - $res = $creditnote->validate($user, '', getDolGlobalString($constantforkey), 0, $batch_rule); + $res = $creditnote->validate($user, '', getDolGlobalInt($constantforkey), 0, $batch_rule); if ($res < 0) { $error++; dol_htmloutput_errors($creditnote->error, $creditnote->errors, 1); @@ -600,7 +610,7 @@ if (empty($reshook)) { } if (($action == 'history' || $action == 'creditnote') && $user->hasRight('takepos', 'run')) { - if ($action == 'creditnote' && $creditnote->id > 0) { // Test on permission already done + if ($action == 'creditnote' && $creditnote !== null && $creditnote->id > 0) { // Test on permission already done $placeid = $creditnote->id; } else { $placeid = GETPOSTINT('placeid'); @@ -648,6 +658,7 @@ if (empty($reshook)) { } } + $tva_npr = 0; // If we add a line by click on product (invoice exists here because it was created juste before if it didn't exists) if ($action == "addline" && ($user->hasRight('takepos', 'run') || defined('INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE'))) { $prod = new Product($db); @@ -664,7 +675,7 @@ if (empty($reshook)) { //$price_min = $datapriceofproduct['price_min']; $price_base_type = empty($datapriceofproduct['price_base_type']) ? 'HT' : $datapriceofproduct['price_base_type']; $tva_tx = $datapriceofproduct['tva_tx']; - $tva_npr = $datapriceofproduct['tva_npr']; + $tva_npr = (int) $datapriceofproduct['tva_npr']; // Local Taxes $localtax1_tx = get_localtax($tva_tx, 1, $customer, $mysoc, $tva_npr); @@ -727,12 +738,12 @@ if (empty($reshook)) { print ''; $detail = ''; $detail .= ''.$langs->trans("LotSerial").': '.$dbatch->batch; - if (!getDolGlobalString('PRODUCT_DISABLE_SELLBY')) { - //$detail .= ' - '.$langs->trans("SellByDate").': '.dol_print_date($dbatch->sellby, "day"); - } - if (!getDolGlobalString('PRODUCT_DISABLE_EATBY')) { - //$detail .= ' - '.$langs->trans("EatByDate").': '.dol_print_date($dbatch->eatby, "day"); - } + //if (!getDolGlobalString('PRODUCT_DISABLE_SELLBY')) { + //$detail .= ' - '.$langs->trans("SellByDate").': '.dol_print_date($dbatch->sellby, "day"); + //} + //if (!getDolGlobalString('PRODUCT_DISABLE_EATBY')) { + //$detail .= ' - '.$langs->trans("EatByDate").': '.dol_print_date($dbatch->eatby, "day"); + //} $detail .= ''; $detail .= ''.$langs->trans("Qty").': '.$dbatch->qty; $detail .= ''; @@ -774,7 +785,6 @@ if (empty($reshook)) { } } - $idoflineadded = 0; $err = 0; // Group if enabled. Skip group if line already sent to the printer if (getDolGlobalString('TAKEPOS_GROUP_SAME_PRODUCT')) { @@ -849,7 +859,7 @@ if (empty($reshook)) { } if (empty($err)) { - $idoflineadded = $invoice->addline($line['description'], $line['price'], $qty, $line['tva_tx'], $line['localtax1_tx'], $line['localtax2_tx'], $idproduct, $line['remise_percent'], '', 0, 0, 0, '', $price_base_type, $line['price_ttc'], $prod->type, -1, 0, '', 0, (empty($parent_line) ? '' : $parent_line), (empty($line['fk_fournprice']) ? 0 : $line['fk_fournprice']), (empty($line['pa_ht']) ? '' : $line['pa_ht']), '', $line['array_options'], 100, '', null, 0); + $idoflineadded = $invoice->addline($line['description'], $line['price'], $qty, $line['tva_tx'], $line['localtax1_tx'], $line['localtax2_tx'], $idproduct, (float) $line['remise_percent'], '', 0, 0, 0, 0, $price_base_type, $line['price_ttc'], $prod->type, -1, 0, '', 0, (empty($parent_line) ? '' : $parent_line), (empty($line['fk_fournprice']) ? 0 : $line['fk_fournprice']), (empty($line['pa_ht']) ? '' : $line['pa_ht']), '', $line['array_options'], 100, 0, null, 0); } } @@ -862,7 +872,7 @@ if (empty($reshook)) { $invoice->fetch($placeid); } - // If we add a line by submitting freezone form (invoice exists here because it was created juste before if it didn't exists) + // If we add a line by submitting freezone form (invoice exists here because it was created just before if it didn't exist) if ($action == "freezone" && $user->hasRight('takepos', 'run')) { $customer = new Societe($db); $customer->fetch($invoice->socid); @@ -880,7 +890,7 @@ if (empty($reshook)) { $localtax1_tx = get_localtax($tva_tx, 1, $customer, $mysoc, $tva_npr); $localtax2_tx = get_localtax($tva_tx, 2, $customer, $mysoc, $tva_npr); - $res = $invoice->addline($desc, $number, 1, $tva_tx, $localtax1_tx, $localtax2_tx, 0, 0, '', 0, 0, 0, '', getDolGlobalInt('TAKEPOS_DISCOUNT_TTC') ? ($number >= 0 ? 'HT' : 'TTC') : (getDolGlobalInt('TAKEPOS_CHANGE_PRICE_HT') ? 'HT' : 'TTC'), $number, 0, -1, 0, '', 0, 0, null, '', '', 0, 100, '', null, 0); + $res = $invoice->addline($desc, $number, 1, $tva_tx, $localtax1_tx, $localtax2_tx, 0, 0, '', 0, 0, 0, 0, getDolGlobalInt('TAKEPOS_DISCOUNT_TTC') ? ($number >= 0 ? 'HT' : 'TTC') : (getDolGlobalInt('TAKEPOS_CHANGE_PRICE_HT') ? 'HT' : 'TTC'), $number, 0, -1, 0, '', 0, 0, 0, 0, '', array(), 100, 0, null, 0); if ($res < 0) { dol_htmloutput_errors($invoice->error, $invoice->errors, 1); } @@ -1170,7 +1180,7 @@ if (empty($reshook)) { $order_receipt_printer1 .= ''; } } - if (((isModEnabled('receiptprinter') && getDolGlobalInt('TAKEPOS_PRINTER_TO_USE'.$term) > 0) || getDolGlobalString('TAKEPOS_PRINT_METHOD') == "receiptprinter" || getDolGlobalString('TAKEPOS_PRINT_METHOD') == "takeposconnector") && $linestoprint > 0) { + if (((isModEnabled('receiptprinter') && getDolGlobalInt('TAKEPOS_PRINTER_TO_USE'.$term) > 0) || getDolGlobalString('TAKEPOS_PRINT_METHOD') == "receiptprinter" || getDolGlobalString('TAKEPOS_PRINT_METHOD') == "takeposconnector") && $linestoprint > 0 && $printer !== null) { $invoice->fetch($placeid); //Reload object before send to printer $printer->orderprinter = 1; echo " currency = '.$conf->currency.' - sessioncurrency = '.$sessioncurrency.' -->'."\n"; +$multicurrency = null; if (isModEnabled('multicurrency') && $sessioncurrency != "" && $conf->currency != $sessioncurrency) { // Only show customer currency if multicurrency module is enabled, if currency selected and if this currency selected is not the same as main currency - $showothercurrency = 1; include_once DOL_DOCUMENT_ROOT . '/multicurrency/class/multicurrency.class.php'; $multicurrency = new MultiCurrency($db); $multicurrency->fetch(0, $sessioncurrency); @@ -554,7 +554,7 @@ if (isModEnabled('multicurrency') && $sessioncurrency != "" && $conf->currency !
trans('TotalTTC'); ?>: total_ttc, 1, '', 1, -1, -1, $conf->currency); - if ($showothercurrency) { + if ($multicurrency !== null) { print '   (' . price($invoice->total_ht * $multicurrency->rate->rate) . ' ' . $sessioncurrency . ')'; } ?> @@ -563,7 +563,7 @@ if (isModEnabled('multicurrency') && $sessioncurrency != "" && $conf->currency !
trans('RemainToPay'); ?>: currency); - if ($showothercurrency) { + if ($multicurrency !== null) { print '   (' . price($remaintopay * $multicurrency->rate->rate) . ' ' . $sessioncurrency . ')'; } ?> @@ -572,7 +572,7 @@ if (isModEnabled('multicurrency') && $sessioncurrency != "" && $conf->currency !
trans("Received"); ?>: currency); - if ($showothercurrency) { + if ($multicurrency !== null) { print '   (' . price(0 * $multicurrency->rate->rate) . ' ' . $sessioncurrency . ')'; } ?> @@ -580,7 +580,7 @@ if (isModEnabled('multicurrency') && $sessioncurrency != "" && $conf->currency !
trans("Change"); ?>: currency); - if ($showothercurrency) { + if ($multicurrency !== null) { print '   (' . price(0 * $multicurrency->rate->rate) . ' ' . $sessioncurrency . ')'; } ?> @@ -729,7 +729,7 @@ while ($i < count($arrayOfValidPaymentModes)) { if (isModEnabled('stripe') && isset($keyforstripeterminalbank) && getDolGlobalString('STRIPE_CARD_PRESENT')) { $keyforstripeterminalbank = "CASHDESK_ID_BANKACCOUNT_STRIPETERMINAL".$_SESSION["takeposterminal"]; print ''; - if (getDolGlobalString($keyforstripeterminalbank)) { + if (getDolGlobalString((string) $keyforstripeterminalbank)) { // Nothing } else { $langs->loadLangs(array("errors", "admin")); diff --git a/htdocs/takepos/phone.php b/htdocs/takepos/phone.php index 81659654315..0a21e58fc89 100644 --- a/htdocs/takepos/phone.php +++ b/htdocs/takepos/phone.php @@ -1,6 +1,7 @@ * Copyright (C) 2024 Frédéric France + * Copyright (C) 2025 MDW * * 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 @@ -132,7 +133,7 @@ if ($action == "productinfo" && $user->hasRight('takepos', 'run')) { require_once DOL_DOCUMENT_ROOT.'/core/class/dolreceiptprinter.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; $printer = new dolReceiptPrinter($db); - $printer->initPrinter(getDolGlobalString('TAKEPOS_PRINTER_TO_USE'.$_SESSION["takeposterminal"])); + $printer->initPrinter(getDolGlobalInt('TAKEPOS_PRINTER_TO_USE'.$_SESSION["takeposterminal"])); if ($printer->getPrintConnector()) { if (!is_null($printer->printer)) { $printer->printer->feed(); diff --git a/htdocs/takepos/send.php b/htdocs/takepos/send.php index 9d85490f77d..35385cd8a09 100644 --- a/htdocs/takepos/send.php +++ b/htdocs/takepos/send.php @@ -2,6 +2,7 @@ /* Copyright (C) 2019 Thibault FOUCART * Copyright (C) 2020 Andreu Bisquerra Gaya * Copyright (C) 2024 Frédéric France + * Copyright (C) 2025 MDW * * 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 @@ -77,7 +78,7 @@ if ($action == "send" && $user->hasRight('takepos', 'run')) { include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php'; $formmail = new FormMail($db); $outputlangs = new Translate('', $conf); - $model_id = getDolGlobalString('TAKEPOS_EMAIL_TEMPLATE_INVOICE'); + $model_id = getDolGlobalInt('TAKEPOS_EMAIL_TEMPLATE_INVOICE'); $arraydefaultmessage = $formmail->getEMailTemplate($db, 'facture_send', $user, $outputlangs, $model_id); $subject = $arraydefaultmessage->topic; diff --git a/htdocs/takepos/split.php b/htdocs/takepos/split.php index 8fadea69c95..c61d9ed3ca9 100644 --- a/htdocs/takepos/split.php +++ b/htdocs/takepos/split.php @@ -1,6 +1,7 @@ * Copyright (C) 2024 Frédéric France + * Copyright (C) 2025 MDW * * 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 @@ -65,14 +66,16 @@ if (!$user->hasRight('takepos', 'run')) { if ($action == "split" && $user->hasRight('takepos', 'run')) { $line = GETPOSTINT('line'); $split = GETPOSTINT('split'); - if ($split==1) { // Split line + $invoice = null; + $placeid = 0; + if ($split == 1) { // Split line $invoice = new Facture($db); - $ret = $invoice->fetch('', '(PROV-POS'.$_SESSION["takeposterminal"].'-SPLIT)'); + $ret = $invoice->fetch(0, '(PROV-POS'.$_SESSION["takeposterminal"].'-SPLIT)'); if ($ret > 0) { $placeid = $invoice->id; } else { $constforcompanyid = 'CASHDESK_ID_THIRDPARTY'.$_SESSION["takeposterminal"]; - $invoice->socid =getDolGlobalInt($constforcompanyid); + $invoice->socid = getDolGlobalInt($constforcompanyid); $invoice->date = dol_now(); $invoice->module_source = 'takepos'; $invoice->pos_source = $_SESSION["takeposterminal"]; @@ -92,12 +95,12 @@ if ($action == "split" && $user->hasRight('takepos', 'run')) { } $sql = "UPDATE ".MAIN_DB_PREFIX."facturedet SET fk_facture = ".((int) $placeid)." WHERE rowid = ".((int) $line); $db->query($sql); - } elseif ($split==0) { // Unsplit line + } elseif ($split == 0) { // Unsplit line $invoice = new Facture($db); if ($place == "SPLIT") { $place = "0"; } // Avoid move line to the same place (from SPLIT to SPLIT place) - $ret = $invoice->fetch('', '(PROV-POS'.$_SESSION["takeposterminal"].'-'.$place.')'); + $ret = $invoice->fetch(0, '(PROV-POS'.$_SESSION["takeposterminal"].'-'.$place.')'); if ($ret > 0) { $placeid = $invoice->id; } else { @@ -124,11 +127,13 @@ if ($action == "split" && $user->hasRight('takepos', 'run')) { $sql = "UPDATE ".MAIN_DB_PREFIX."facturedet set fk_facture=".$placeid." where rowid=".$line; $db->query($sql); } - $invoice->fetch('', '(PROV-POS'.$_SESSION["takeposterminal"].'-SPLIT)'); - $invoice->update_price(); + if ($invoice !== null) { + $invoice->fetch(0, '(PROV-POS'.$_SESSION["takeposterminal"].'-SPLIT)'); + $invoice->update_price(); - $invoice->fetch('', '(PROV-POS'.$_SESSION["takeposterminal"].'-'.$place.')'); - $invoice->update_price(); + $invoice->fetch(0, '(PROV-POS'.$_SESSION["takeposterminal"].'-'.$place.')'); + $invoice->update_price(); + } }