Qual: Fix phan notices (takepos)

This commit is contained in:
MDW 2025-02-18 21:48:21 +01:00
parent 4c0918f0ae
commit 81e870f7c1
No known key found for this signature in database
14 changed files with 125 additions and 118 deletions

View File

@ -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'],

View File

@ -3,7 +3,7 @@
* Copyright (C) 2013-2014 Cedric GROSS <c.gross@kreiz-it.fr>
* Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
* Copyright (C) 2024 Ferran Marcet <fmarcet@2byte.es>
* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
* Copyright (C) 2024-2025 MDW <mdeweerd@users.noreply.github.com>
*
* 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
*/

View File

@ -3,7 +3,7 @@
* Copyright (C) 2005-2015 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2011 Jean Heimburger <jean@tiaris.info>
* Copyright (C) 2014 Cedric GROSS <c.gross@kreiz-it.fr>
* Copyright (C) 2024-2025 MDW <mdeweerd@users.noreply.github.com>
* Copyright (C) 2024-2025 MDW <mdeweerd@users.noreply.github.com>
* Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
*
* 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)

View File

@ -3,6 +3,7 @@
* Copyright (C) 2011-2017 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2022 Alexandre Spangaro <aspangaro@open-dsi.fr>
* Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
* Copyright (C) 2025 MDW <mdeweerd@users.noreply.github.com>
*
* 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');
}
/*

View File

@ -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 '</td></tr>';
$disabled = getDolGlobalString('CASHDESK_NO_DECREASE_STOCK'.$terminal);
$disabled = getDolGlobalInt('CASHDESK_NO_DECREASE_STOCK'.$terminal);
print '<tr class="oddeven"><td>';

View File

@ -2,6 +2,7 @@
/* Copyright (C) 2001-2004 Andreu Bisquerra <jove@bisquerra.com>
* Copyright (C) 2020 Thibault FOUCART <support@ptibogxiv.net>
* Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
* Copyright (C) 2025 MDW <mdeweerd@users.noreply.github.com>
*
* 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));
}

View File

@ -1,6 +1,6 @@
<?php
/* Copyright (C) 2018 Andreu Bisquerra <jove@bisquerra.com>
* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
* Copyright (C) 2024-2025 MDW <mdeweerd@users.noreply.github.com>
* Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
*
* 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";
}

View File

@ -2,6 +2,7 @@
/* Copyright (C) 2018 Andreu Bisquerra <jove@bisquerra.com>
* Copyright (C) 2020 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
* Copyright (C) 2025 MDW <mdeweerd@users.noreply.github.com>
*
* 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.')');
}

View File

@ -2,7 +2,7 @@
/* Copyright (C) 2018 Andreu Bisquerra <jove@bisquerra.com>
* Copyright (C) 2019 Josep Lluís Amador <joseplluis@lliuretic.cat>
* Copyright (C) 2020 Thibault FOUCART <support@ptibogxiv.net>
* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
* Copyright (C) 2024-2025 MDW <mdeweerd@users.noreply.github.com>
* Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
*
* 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 '<div class="wrapper2 arrow" id="prodiv'.$count.'" '; ?>
<?php if ($count == ($MAXPRODUCT - 2)) {
?> onclick="MoreProducts('less')" <?php
}
if ($count == ($MAXPRODUCT - 1)) {
?> onclick="MoreProducts('more')" <?php
} else {
echo 'onclick="ClickProduct('.$count.')"';
} ?>>
<?php if ($count == ($MAXPRODUCT - 2)) {
?> onclick="MoreProducts('less')" <?php
}
if ($count == ($MAXPRODUCT - 1)) {
?> onclick="MoreProducts('more')" <?php
} else {
echo 'onclick="ClickProduct('.$count.')"';
} ?>>
<?php
if ($count == ($MAXPRODUCT - 2)) {
//echo '<img class="imgwrapper" src="img/arrow-prev-top.png" height="100%" id="proimg'.$count.'" />';

View File

@ -3,7 +3,7 @@
* Copyright (C) 2018 Andreu Bisquerra <jove@bisquerra.com>
* Copyright (C) 2021 Nicolas ZABOURI <info@inovea-conseil.com>
* Copyright (C) 2022-2023 Christophe Battarel <christophe.battarel@altairis.fr>
* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
* Copyright (C) 2024-2025 MDW <mdeweerd@users.noreply.github.com>
* Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
*
* 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 '<td class="left">';
$detail = '';
$detail .= '<span class="opacitymedium">'.$langs->trans("LotSerial").':</span> '.$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 .= '</td><td>';
$detail .= '<span class="opacitymedium">'.$langs->trans("Qty").':</span> '.$dbatch->qty;
$detail .= '</td><td>';
@ -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 .= '</td></tr>';
}
}
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 "<script>";
@ -1234,7 +1244,7 @@ if (empty($reshook)) {
$order_receipt_printer3 .= '</td></tr>';
}
}
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 = 3;
echo "<script>";
@ -1247,7 +1257,6 @@ if (empty($reshook)) {
$invoice->fetch($placeid); //Reload object after set lines as printed
}
$sectionwithinvoicelink = '';
if (($action == "valid" || $action == "history" || $action == 'creditnote') && $user->hasRight('takepos', 'run')) {
$sectionwithinvoicelink .= '<!-- Section with invoice link -->'."\n";
$sectionwithinvoicelink .= '<span style="font-size:120%;" class="center">';
@ -1543,9 +1552,9 @@ $( document ).ready(function() {
$("#shoppingcart").html('');
<?php if (getDolGlobalInt('TAKEPOS_CHOOSE_CONTACT') == 0) { ?>
$("#customerandsales").append('<a class="valignmiddle tdoverflowmax100 minwidth100" id="customer" onclick="Customer();" title="<?php print dol_escape_js(dol_escape_htmltag($s)); ?>"><span class="fas fa-building paddingrightonly"></span><?php print dol_escape_js($s); ?></a>');
$("#customerandsales").append('<a class="valignmiddle tdoverflowmax100 minwidth100" id="customer" onclick="Customer();" title="<?php print dol_escape_js(dol_escape_htmltag((string) $s)); ?>"><span class="fas fa-building paddingrightonly"></span><?php print dol_escape_js((string) $s); ?></a>');
<?php } else { ?>
$("#customerandsales").append('<a class="valignmiddle tdoverflowmax300 minwidth100" id="contact" onclick="Contact();" title="<?php print dol_escape_js(dol_escape_htmltag($s)); ?>"><span class="fas fa-building paddingrightonly"></span><?php print dol_escape_js($s); ?></a>');
$("#customerandsales").append('<a class="valignmiddle tdoverflowmax300 minwidth100" id="contact" onclick="Contact();" title="<?php print dol_escape_js(dol_escape_htmltag((string) $s)); ?>"><span class="fas fa-building paddingrightonly"></span><?php print dol_escape_js((string) $s); ?></a>');
<?php } ?>
<?php
@ -1556,7 +1565,7 @@ $( document ).ready(function() {
$sql .= " AND ref LIKE '(PROV-POS".$db->escape(isset($_SESSION["takeposterminal"]) ? $_SESSION["takeposterminal"] : '')."-0%'";
} else {
// If TAKEPOS_CAN_EDIT_IF_ALREADY_VALIDATED set, we show also draft invoice that already has a reference defined
$sql .= " AND pos_source = '".$db->escape($_SESSION["takeposterminal"])."'";
$sql .= " AND pos_source = '".$db->escape((string) $_SESSION["takeposterminal"])."'";
$sql .= " AND module_source = 'takepos'";
}
@ -1598,7 +1607,7 @@ $( document ).ready(function() {
if (isModEnabled('stock')) {
if (getDolGlobalString($constantforkey) != "1") {
$constantforkey = 'CASHDESK_ID_WAREHOUSE'. (isset($_SESSION["takeposterminal"]) ? $_SESSION["takeposterminal"] : '');
$idwarehouse = getDolGlobalString($constantforkey);
$idwarehouse = getDolGlobalInt($constantforkey);
if ($idwarehouse > 0) {
$s = '<span class="small">';
$warehouse = new Entrepot($db);
@ -1637,7 +1646,7 @@ $( document ).ready(function() {
$langs->load("members");
$s .= $langs->trans("Member").': ';
$adh = new Adherent($db);
$result = $adh->fetch('', '', $invoice->socid);
$result = $adh->fetch(0, '', $invoice->socid);
if ($result > 0) {
$adh->ref = $adh->getFullName($langs);
if (empty($adh->statut) || $adh->statut == Adherent::STATUS_EXCLUDED) {

View File

@ -2,7 +2,7 @@
/* Copyright (C) 2018 Andreu Bisquerra <jove@bisquerra.com>
* Copyright (C) 2021-2022 Thibault FOUCART <support@ptibogxiv.net>
* Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
* Copyright (C) 2024-2025 MDW <mdeweerd@users.noreply.github.com>
*
* 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
@ -94,6 +94,7 @@ $usestripeterminals = 0;
$keyforstripeterminalbank = '';
$stripe = null;
$servicestatus = 0;
$stripeacc = null;
if (isModEnabled('stripe')) {
$service = 'StripeTest';
@ -184,7 +185,7 @@ if ($invoiceid > 0) {
<script>
<?php
if ($usestripeterminals && $invoice->type != $invoice::TYPE_CREDIT_NOTE) {
if (!getDolGlobalString($keyforstripeterminalbank)) { ?>
if (!getDolGlobalString((string) $keyforstripeterminalbank) || $stripeacc === null) { ?>
const config = {
simulated: <?php if (empty($servicestatus) && getDolGlobalString('STRIPE_TERMINAL_SIMULATED')) { ?> true <?php } else { ?> false <?php } ?>
<?php if (getDolGlobalString('STRIPE_LOCATION')) { ?>, location: '<?php echo dol_escape_js(getDolGlobalString('STRIPE_LOCATION')); ?>'<?php } ?>
@ -215,7 +216,7 @@ if ($usestripeterminals && $invoice->type != $invoice::TYPE_CREDIT_NOTE) {
}
});
<?php } else { ?>
terminal.connectReader(<?php echo json_encode($stripe->getSelectedReader(getDolGlobalString($keyforstripeterminalbank), $stripeacc, $servicestatus)); ?>).then(function(connectResult) {
terminal.connectReader(<?php echo json_encode($stripe->getSelectedReader(getDolGlobalString((string) $keyforstripeterminalbank), $stripeacc, $servicestatus)); ?>).then(function(connectResult) {
if (connectResult.error) {
document.getElementById("card-present-alert").innerHTML = '<div class="error clearboth">'+connectResult.error.message+'</div>';
console.log('Failed to connect: ', connectResult.error);
@ -233,8 +234,8 @@ if ($usestripeterminals && $invoice->type != $invoice::TYPE_CREDIT_NOTE) {
</script>
<?php
// Define list of possible payments
$arrayOfValidPaymentModes = array();
// Define list of possible payments
$arrayOfValidPaymentModes = array();
$arrayOfValidBankAccount = array();
$sql = "SELECT code, libelle as label FROM ".MAIN_DB_PREFIX."c_paiement";
@ -538,12 +539,11 @@ if (getDolGlobalString('TAKEPOS_CUSTOMER_DISPLAY')) {
</script>
<?php
$showothercurrency = 0;
$sessioncurrency = $_SESSION["takeposcustomercurrency"] ?? '';
print '<!-- conf->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 !
<div class="paymentbordline paymentbordlinetotal center">
<span class="takepospay colorwhite"><?php echo $langs->trans('TotalTTC'); ?>: <span id="totaldisplay" class="colorwhite"><?php
echo price($invoice->total_ttc, 1, '', 1, -1, -1, $conf->currency);
if ($showothercurrency) {
if ($multicurrency !== null) {
print ' &nbsp; <span id="linecolht-span-total opacitymedium" style="font-size:0.9em; font-style:italic;">(' . price($invoice->total_ht * $multicurrency->rate->rate) . ' ' . $sessioncurrency . ')</span>';
}
?></span></span>
@ -563,7 +563,7 @@ if (isModEnabled('multicurrency') && $sessioncurrency != "" && $conf->currency !
<div class="paymentbordline paymentbordlineremain center">
<span class="takepospay colorwhite"><?php echo $langs->trans('RemainToPay'); ?>: <span id="remaintopaydisplay" class="colorwhite"><?php
echo price($remaintopay, 1, '', 1, -1, -1, $conf->currency);
if ($showothercurrency) {
if ($multicurrency !== null) {
print ' &nbsp; <span id="linecolht-span-total opacitymedium" style="font-size:0.9em; font-style:italic;">(' . price($remaintopay * $multicurrency->rate->rate) . ' ' . $sessioncurrency . ')</span>';
}
?></span></span>
@ -572,7 +572,7 @@ if (isModEnabled('multicurrency') && $sessioncurrency != "" && $conf->currency !
<div class="paymentbordline paymentbordlinereceived center">
<span class="takepospay colorwhite"><?php echo $langs->trans("Received"); ?>: <span class="change1 colorred"><?php
echo price(0, 1, '', 1, -1, -1, $conf->currency);
if ($showothercurrency) {
if ($multicurrency !== null) {
print ' &nbsp; <span id="linecolht-span-total opacitymedium" style="font-size:0.9em; font-style:italic;">(' . price(0 * $multicurrency->rate->rate) . ' ' . $sessioncurrency . ')</span>';
}
?></span><input type="hidden" id="change1" class="change1" value="0"></span>
@ -580,7 +580,7 @@ if (isModEnabled('multicurrency') && $sessioncurrency != "" && $conf->currency !
<div class="paymentbordline paymentbordlinechange center">
<span class="takepospay colorwhite"><?php echo $langs->trans("Change"); ?>: <span class="change2 colorwhite"><?php
echo price(0, 1, '', 1, -1, -1, $conf->currency);
if ($showothercurrency) {
if ($multicurrency !== null) {
print ' &nbsp; <span id="linecolht-span-total opacitymedium" style="font-size:0.9em; font-style:italic;">(' . price(0 * $multicurrency->rate->rate) . ' ' . $sessioncurrency . ')</span>';
}
?></span><input type="hidden" id="change2" class="change2" value="0"></span>
@ -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 '<span id="StripeTerminal"></span>';
if (getDolGlobalString($keyforstripeterminalbank)) {
if (getDolGlobalString((string) $keyforstripeterminalbank)) {
// Nothing
} else {
$langs->loadLangs(array("errors", "admin"));

View File

@ -1,6 +1,7 @@
<?php
/* Copyright (C) 2018 Andreu Bisquerra <jove@bisquerra.com>
* Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
* Copyright (C) 2025 MDW <mdeweerd@users.noreply.github.com>
*
* 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();

View File

@ -2,6 +2,7 @@
/* Copyright (C) 2019 Thibault FOUCART <support@ptibogxiv.net>
* Copyright (C) 2020 Andreu Bisquerra Gaya <jove@bisquerra.com>
* Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
* Copyright (C) 2025 MDW <mdeweerd@users.noreply.github.com>
*
* 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;

View File

@ -1,6 +1,7 @@
<?php
/* Copyright (C) 2021 Andreu Bisquerra <jove@bisquerra.com>
* Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
* Copyright (C) 2025 MDW <mdeweerd@users.noreply.github.com>
*
* 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();
}
}