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

This commit is contained in:
Laurent Destailleur 2023-09-09 15:33:09 +02:00
commit 1acbbda254
4 changed files with 50 additions and 20 deletions

View file

@ -1004,7 +1004,7 @@ if ($contextpage != 'poslist') {
} elseif ($user->hasRight('societe', 'creer')) {
$url = DOL_URL_ROOT.'/societe/card.php?action=create&type=t&contextpage=poslist&optioncss=print&backtopage='.urlencode($_SERVER["PHP_SELF"].'?type=t&contextpage=poslist&nomassaction=1&optioncss=print&place='.$place);
$label = 'MenuNewCustomer';
$newcardbutton .= dolGetButtonTitle($langs->trans($label), '', 'fa fa-plus-circle', $url);
$newcardbutton = dolGetButtonTitle($langs->trans($label), '', 'fa fa-plus-circle', $url);
}
print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'" name="formfilter" autocomplete="off">'."\n";

View file

@ -41,6 +41,7 @@ if (!defined('NOBROWSERNOTIF')) {
require '../../main.inc.php'; // Load $user and permissions
require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
require_once DOL_DOCUMENT_ROOT."/product/class/product.class.php";
require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php';
$category = GETPOST('category', 'alphanohtml'); // Can be id of category or 'supplements'
$action = GETPOST('action', 'aZ09');
@ -56,11 +57,16 @@ if (empty($user->rights->takepos->run)) {
// Initialize technical object to manage hooks. Note that conf->hooks_modules contains array of hooks
$hookmanager->initHooks(array('takeposproductsearch')); // new context for product search hooks
$pricelevel = 1; // default price level if PRODUIT_MULTIPRICES. TODO Get price level from thirdparty.
/*
* View
*/
$thirdparty = new Societe($db);
if ($action == 'getProducts') {
$tosell = GETPOSTISSET('tosell') ? GETPOST('tosell', 'int') : '';
$limit = GETPOSTISSET('limit') ? GETPOST('limit', 'int') : 0;
@ -68,6 +74,14 @@ if ($action == 'getProducts') {
top_httphead('application/json');
// Search
if (GETPOSTINT('thirdpartyid') > 0) {
$result = $thirdparty->fetch(GETPOSTINT('thirdpartyid'));
if ($result > 0) {
$pricelevel = $thirdparty->price_level;
}
}
$object = new Categorie($db);
if ($category == "supplements") {
$category = getDolGlobalInt('TAKEPOS_SUPPLEMENTS_CATEGORY');
@ -98,8 +112,8 @@ if ($action == 'getProducts') {
unset($prod->fields);
unset($prod->db);
$prod->price_formated = price(price2num($prod->price, 'MT'), 1, $langs, 1, -1, -1, $conf->currency);
$prod->price_ttc_formated = price(price2num($prod->price_ttc, 'MT'), 1, $langs, 1, -1, -1, $conf->currency);
$prod->price_formated = price(price2num(empty($prod->multiprices[$pricelevel]) ? $prod->price : $prod->multiprices[$pricelevel], 'MT'), 1, $langs, 1, -1, -1, $conf->currency);
$prod->price_ttc_formated = price(price2num(empty($prod->multiprices_ttc[$pricelevel]) ? $prod->price_ttc : $prod->multiprices_ttc[$pricelevel], 'MT'), 1, $langs, 1, -1, -1, $conf->currency);
$res[] = $prod;
}
@ -111,10 +125,7 @@ if ($action == 'getProducts') {
} elseif ($action == 'search' && $term != '') {
top_httphead('application/json');
// Change thirdparty with barcode
require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php';
$thirdparty = new Societe($db);
// Search barcode into thirdparties. If found, it means we want to change thirdparties.
$result = $thirdparty->fetch('', '', '', $term);
if ($result && $thirdparty->id > 0) {
@ -129,6 +140,14 @@ if ($action == 'getProducts') {
exit;
}
// Search
if (GETPOSTINT('thirdpartyid') > 0) {
$result = $thirdparty->fetch(GETPOSTINT('thirdpartyid'));
if ($result > 0) {
$pricelevel = $thirdparty->price_level;
}
}
// Define $filteroncategids, the filter on category ID if there is a Root category defined.
$filteroncategids = '';
if ($conf->global->TAKEPOS_ROOT_CATEGORY_ID > 0) { // A root category is defined, we must filter on products inside this category tree
@ -196,10 +215,11 @@ if ($action == 'getProducts') {
$qty = floatval($qty_str);
}
$objProd = new Product($db);
$objProd->fetch($obj->rowid);
$ig = '../public/theme/common/nophoto.png';
if (empty($conf->global->TAKEPOS_HIDE_PRODUCT_IMAGES)) {
$objProd = new Product($db);
$objProd->fetch($obj->rowid);
$image = $objProd->show_photos('product', $conf->product->multidir_output[$objProd->entity], 'small', 1);
$match = array();
@ -222,8 +242,8 @@ if ($action == 'getProducts') {
'tosell' => $obj->tosell,
'tobuy' => $obj->tobuy,
'barcode' => $obj->barcode,
'price' => $obj->price,
'price_ttc' => $obj->price_ttc,
'price' => empty($objProd->multiprices[$pricelevel]) ? $obj->price : $objProd->multiprices[$pricelevel],
'price_ttc' => empty($objProd->multiprices_ttc[$pricelevel]) ? $obj->price_ttc : $objProd->multiprices_ttc[$pricelevel],
'object' => 'product',
'img' => $ig,
'qty' => $qty,
@ -244,7 +264,10 @@ if ($action == 'getProducts') {
if (getDolGlobalInt('TAKEPOS_PRODUCT_IN_STOCK') == 1) {
$sql .= ', ps.reel';
}
/* this will be possible when field archive will be supported into llx_product_price
if (getDolGlobalString('PRODUIT_MULTIPRICES')) {
$sql .= ', pp.price_level, pp.price as multiprice_ht, pp.price_ttc as multiprice_ttc';
}*/
// Add fields from hooks
$parameters = array();
$reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters);
@ -253,6 +276,11 @@ if ($action == 'getProducts') {
}
$sql .= ' FROM '.MAIN_DB_PREFIX.'product as p';
/* this will be possible when field archive will be supported into llx_product_price
if (getDolGlobalString('PRODUIT_MULTIPRICES')) {
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product_price as pp ON pp.fk_product = p.rowid AND pp.entity = ".((int) $conf->entity)." AND pp.price_level = ".((int) $pricelevel);
$sql .= " AND archive = 0";
}*/
if (getDolGlobalInt('TAKEPOS_PRODUCT_IN_STOCK') == 1) {
$sql .= ' INNER JOIN '.MAIN_DB_PREFIX.'product_stock as ps';
$sql .= ' ON (p.rowid = ps.fk_product';
@ -267,7 +295,7 @@ if ($action == 'getProducts') {
$sql .= $hookmanager->resPrint;
}
$sql .= ' WHERE entity IN ('.getEntity('product').')';
$sql .= ' WHERE p.entity IN ('.getEntity('product').')';
if ($filteroncategids) {
$sql .= ' AND EXISTS (SELECT cp.fk_product FROM '.MAIN_DB_PREFIX.'categorie_product as cp WHERE cp.fk_product = p.rowid AND cp.fk_categorie IN ('.$db->sanitize($filteroncategids).'))';
}
@ -316,13 +344,13 @@ if ($action == 'getProducts') {
'tosell' => $obj->tosell,
'tobuy' => $obj->tobuy,
'barcode' => $obj->barcode,
'price' => $obj->price,
'price_ttc' => $obj->price_ttc,
'price' => empty($objProd->multiprices[$pricelevel]) ? $obj->price : $objProd->multiprices[$pricelevel],
'price_ttc' => empty($objProd->multiprices_ttc[$pricelevel]) ? $obj->price_ttc : $objProd->multiprices_ttc[$pricelevel],
'object' => 'product',
'img' => $ig,
'qty' => 1,
'price_formated' => price(price2num($obj->price, 'MT'), 1, $langs, 1, -1, -1, $conf->currency),
'price_ttc_formated' => price(price2num($obj->price_ttc, 'MT'), 1, $langs, 1, -1, -1, $conf->currency)
'price_formated' => price(price2num(empty($objProd->multiprices[$pricelevel]) ? $obj->price : $objProd->multiprices[$pricelevel], 'MT'), 1, $langs, 1, -1, -1, $conf->currency),
'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();

View file

@ -331,7 +331,7 @@ function LoadProducts(position, issubcat) {
limit = maxproduct-1;
}
// Only show products for sale (tosell=1)
$.getJSON('<?php echo DOL_URL_ROOT ?>/takepos/ajax/ajax.php?action=getProducts&token=<?php echo newToken();?>&category='+currentcat+'&tosell=1&limit='+limit+'&offset=0', function(data) {
$.getJSON('<?php echo DOL_URL_ROOT ?>/takepos/ajax/ajax.php?action=getProducts&token=<?php echo newToken();?>&thirdpartyid=' + jQuery('#thirdpartyid').val() + '&category='+currentcat+'&tosell=1&limit='+limit+'&offset=0', function(data) {
console.log("Call ajax.php (in LoadProducts) to get Products of category "+currentcat+" then loop on result to fill image thumbs");
console.log(data);
while (ishow < maxproduct) {
@ -570,7 +570,7 @@ function Refresh() {
function New() {
// If we go here,it means $conf->global->TAKEPOS_BAR_RESTAURANT is not defined
invoiceid = $("#invoiceid").val();
invoiceid = $("#invoiceid").val(); // This is a hidden field added by invoice.php
console.log("New with place = <?php echo $place; ?>, js place="+place+", invoiceid="+invoiceid);
@ -644,7 +644,7 @@ function Search2(keyCodeForEnter, moreorless) {
pageproducts = 0;
jQuery(".wrapper2 .catwatermark").hide();
var nbsearchresults = 0;
$.getJSON('<?php echo DOL_URL_ROOT ?>/takepos/ajax/ajax.php?action=search&token=<?php echo newToken();?>&term=' + search_term + '&search_start=' + search_start + '&search_limit=' + search_limit, function (data) {
$.getJSON('<?php echo DOL_URL_ROOT ?>/takepos/ajax/ajax.php?action=search&token=<?php echo newToken();?>&term=' + search_term + '&thirdpartyid=' + jQuery('#thirdpartyid').val() + '&search_start=' + search_start + '&search_limit=' + search_limit, function (data) {
for (i = 0; i < <?php echo $MAXPRODUCT ?>; i++) {
if (typeof (data[i]) == "undefined") {
$("#prowatermark" + i).html("");

View file

@ -1319,7 +1319,9 @@ print '<tr class="liste_titre nodrag nodrop">';
print '<td class="linecoldescription">';
// In phone version only show when it is invoice page
if (empty($mobilepage) || $mobilepage == "invoice") {
print '<!-- hidden var used by some js functions -->';
print '<input type="hidden" name="invoiceid" id="invoiceid" value="'.$invoice->id.'">';
print '<input type="hidden" name="thirdpartyid" id="thirdpartyid" value="'.$invoice->socid.'">';
}
if (getDolGlobalString('TAKEPOS_BAR_RESTAURANT')) {
$sql = "SELECT floor, label FROM ".MAIN_DB_PREFIX."takepos_floor_tables where rowid=".((int) $place);