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

develop
This commit is contained in:
Laurent Destailleur 2022-04-29 16:42:43 +02:00
commit bc03658f18
7 changed files with 126 additions and 11 deletions

View File

@ -1,10 +1,10 @@
<?php
/* Copyright (C) 2013-2014 Olivier Geffroy <jeff@jeffinfo.com>
* Copyright (C) 2013-2021 Alexandre Spangaro <aspangaro@open-dsi.fr>
* Copyright (C) 2014 Florian Henry <florian.henry@open-concept.pro>
* Copyright (C) 2014 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2015 Ari Elbaz (elarifr) <github@accedinfo.com>
* Copyright (C) 2021 Gauthier VERDOL <gauthier.verdol@atm-consulting.fr>
* Copyright (C) 2013-2022 Alexandre Spangaro <aspangaro@open-dsi.fr>
* Copyright (C) 2014 Florian Henry <florian.henry@open-concept.pro>
* Copyright (C) 2014 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2015 Ari Elbaz (elarifr) <github@accedinfo.com>
* Copyright (C) 2021 Gauthier VERDOL <gauthier.verdol@atm-consulting.fr>
*
* 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
@ -34,6 +34,9 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php';
require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingaccount.class.php';
require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
if (!empty($conf->categorie->enabled)) {
require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
}
// Load translation files required by the page
$langs->loadLangs(array("companies", "compta", "accountancy", "products"));
@ -59,6 +62,8 @@ $account_number_sell = GETPOST('account_number_sell');
$changeaccount = GETPOST('changeaccount', 'array');
$changeaccount_buy = GETPOST('changeaccount_buy', 'array');
$changeaccount_sell = GETPOST('changeaccount_sell', 'array');
$searchCategoryProductOperator = (GETPOST('search_category_product_operator', 'int') ? GETPOST('search_category_product_operator', 'int') : 0);
$searchCategoryProductList = GETPOST('search_category_product_list', 'array');
$search_ref = GETPOST('search_ref', 'alpha');
$search_label = GETPOST('search_label', 'alpha');
$search_desc = GETPOST('search_desc', 'alpha');
@ -144,6 +149,8 @@ if ($reshook < 0) {
// Purge search criteria
if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // All test are required to be compatible with all browsers
$searchCategoryProductOperator = 0;
$searchCategoryProductList = array();
$search_ref = '';
$search_label = '';
$search_desc = '';
@ -283,7 +290,16 @@ $aacompta_prodsell = getDolGlobalString('ACCOUNTING_PRODUCT_SOLD_ACCOUN
$aacompta_prodsell_intra = getDolGlobalString('ACCOUNTING_PRODUCT_SOLD_INTRA_ACCOUNT', $langs->trans("CodeNotDef"));
$aacompta_prodsell_export = getDolGlobalString('ACCOUNTING_PRODUCT_SOLD_EXPORT_ACCOUNT', $langs->trans("CodeNotDef"));
llxHeader('', $langs->trans("ProductsBinding"));
$title = $langs->trans("ProductsBinding");
$helpurl = '';
$paramsCat = '';
foreach ($searchCategoryProductList as $searchCategoryProduct) {
$paramsCat .= "&search_category_product_list[]=".urlencode($searchCategoryProduct);
}
llxHeader('', $title, $helpurl, '', 0, 0, array(), array(), $paramsCat, '');
$pcgverid = getDolGlobalString('CHARTOFACCOUNTS');
$pcgvercode = dol_getIdFromCode($db, $pcgverid, 'accounting_system', 'rowid', 'pcg_version');
@ -308,6 +324,9 @@ if (!empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED)) {
} else {
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa ON aa.account_number = p." . $accountancy_field_name . " AND aa.fk_pcg_version = '" . $db->escape($pcgvercode) . "'";
}
if (!empty($searchCategoryProductList)) {
$sql .= ' LEFT JOIN '.MAIN_DB_PREFIX."categorie_product as cp ON p.rowid = cp.fk_product"; // We'll need this table joined to the select in order to filter by categ
}
$sql .= ' WHERE p.entity IN ('.getEntity('product').')';
if (strlen(trim($search_current_account))) {
$sql .= natural_search((empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED) ? "p." : "ppe.") . $accountancy_field_name, $search_current_account);
@ -318,6 +337,30 @@ if ($search_current_account_valid == 'withoutvalidaccount') {
if ($search_current_account_valid == 'withvalidaccount') {
$sql .= " AND aa.account_number IS NOT NULL";
}
$searchCategoryProductSqlList = array();
if ($searchCategoryProductOperator == 1) {
foreach ($searchCategoryProductList as $searchCategoryProduct) {
if (intval($searchCategoryProduct) == -2) {
$searchCategoryProductSqlList[] = "cp.fk_categorie IS NULL";
} elseif (intval($searchCategoryProduct) > 0) {
$searchCategoryProductSqlList[] = "cp.fk_categorie = ".$db->escape($searchCategoryProduct);
}
}
if (!empty($searchCategoryProductSqlList)) {
$sql .= " AND (".implode(' OR ', $searchCategoryProductSqlList).")";
}
} else {
foreach ($searchCategoryProductList as $searchCategoryProduct) {
if (intval($searchCategoryProduct) == -2) {
$searchCategoryProductSqlList[] = "cp.fk_categorie IS NULL";
} elseif (intval($searchCategoryProduct) > 0) {
$searchCategoryProductSqlList[] = "p.rowid IN (SELECT fk_product FROM ".MAIN_DB_PREFIX."categorie_product WHERE fk_categorie = ".((int) $searchCategoryProduct).")";
}
}
if (!empty($searchCategoryProductSqlList)) {
$sql .= " AND (".implode(' AND ', $searchCategoryProductSqlList).")";
}
}
// Add search filter like
if (strlen(trim($search_ref))) {
$sql .= natural_search("p.ref", $search_ref);
@ -338,6 +381,15 @@ if ($search_onpurchase != '' && $search_onpurchase != '-1') {
$sql .= natural_search('p.tobuy', $search_onpurchase, 1);
}
$sql .= " GROUP BY p.rowid, p.ref, p.label, p.description, p.tosell, p.tobuy, p.tva_tx,";
$sql .= " p.fk_product_type,";
$sql .= ' p.tms,';
if (empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED)) {
$sql .= " p.accountancy_code_sell, p.accountancy_code_sell_intra, p.accountancy_code_sell_export, p.accountancy_code_buy, p.accountancy_code_buy_intra, p.accountancy_code_buy_export";
} else {
$sql .= " ppe.accountancy_code_sell, ppe.accountancy_code_sell_intra, ppe.accountancy_code_sell_export, ppe.accountancy_code_buy, ppe.accountancy_code_buy_intra, ppe.accountancy_code_buy_export";
}
$sql .= $db->order($sortfield, $sortorder);
$nbtotalofrecords = '';
@ -365,11 +417,17 @@ if ($result) {
if ($limit > 0 && $limit != $conf->liste_limit) {
$param .= '&limit='.urlencode($limit);
}
if ($searchCategoryProductOperator == 1) {
$param .= "&search_category_product_operator=".urlencode($searchCategoryProductOperator);
}
foreach ($searchCategoryProductList as $searchCategoryProduct) {
$param .= "&search_category_product_list[]=".urlencode($searchCategoryProduct);
}
if ($search_ref > 0) {
$param .= "&search_desc=".urlencode($search_ref);
$param .= "&search_ref=".urlencode($search_ref);
}
if ($search_label > 0) {
$param .= "&search_desc=".urlencode($search_label);
$param .= "&search_label=".urlencode($search_label);
}
if ($search_desc > 0) {
$param .= "&search_desc=".urlencode($search_desc);
@ -461,6 +519,40 @@ if ($result) {
print $form->formconfirm($_SERVER["PHP_SELF"], $langs->trans("ConfirmPreselectAccount"), $langs->trans("ConfirmPreselectAccountQuestion", count($chk_prod)), "confirm_set_default_account", $formquestion, 1, 0, 200, 500, 1);
}
// Filter on categories
$moreforfilter = '';
if (!empty($conf->categorie->enabled) && $user->rights->categorie->lire) {
$moreforfilter .= '<div class="divsearchfield">';
$moreforfilter .= img_picto($langs->trans('Categories'), 'category', 'class="pictofixedwidth"');
$categoriesProductArr = $form->select_all_categories(Categorie::TYPE_PRODUCT, '', '', 64, 0, 1);
$categoriesProductArr[-2] = '- '.$langs->trans('NotCategorized').' -';
$moreforfilter .= Form::multiselectarray('search_category_product_list', $categoriesProductArr, $searchCategoryProductList, 0, 0, 'minwidth300');
$moreforfilter .= ' <input type="checkbox" class="valignmiddle" name="search_category_product_operator" value="1"'.($searchCategoryProductOperator == 1 ? ' checked="checked"' : '').'/> <span class="none">'.$langs->trans('UseOrOperatorForCategories').'</span>';
$moreforfilter .= '</div>';
}
//Show/hide child products. Hidden by default
if (!empty($conf->variants->enabled) && !empty($conf->global->PRODUIT_ATTRIBUTES_HIDECHILD)) {
$moreforfilter .= '<div class="divsearchfield">';
$moreforfilter .= '<input type="checkbox" id="search_show_childproducts" name="search_show_childproducts"'.($show_childproducts ? 'checked="checked"' : '').'>';
$moreforfilter .= ' <label for="search_show_childproducts">'.$langs->trans('ShowChildProducts').'</label>';
$moreforfilter .= '</div>';
}
$parameters = array();
$reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook
if (empty($reshook)) {
$moreforfilter .= $hookmanager->resPrint;
} else {
$moreforfilter = $hookmanager->resPrint;
}
if ($moreforfilter) {
print '<div class="liste_titre liste_titre_bydiv centpercent">';
print $moreforfilter;
print '</div>';
}
print '<div class="div-table-responsive">';
print '<table class="liste '.($moreforfilter ? "listwithfilterbefore" : "").'">';

View File

@ -1202,6 +1202,9 @@ class FormMail extends Form
if (!empty($conf->global->MAIL_FORCE_DELIVERY_RECEIPT_INVOICE) && !empty($this->param['models']) && $this->param['models'] == 'facture_send') {
$defaultvaluefordeliveryreceipt = 1;
}
if (!empty($conf->global->MAIL_FORCE_DELIVERY_RECEIPT_SUPPLIER_ORDER) && !empty($this->param['models']) && $this->param['models'] == 'order_supplier_send') {
$defaultvaluefordeliveryreceipt = 1;
}
$out .= $form->selectyesno('deliveryreceipt', (GETPOSTISSET("deliveryreceipt") ? GETPOST("deliveryreceipt") : $defaultvaluefordeliveryreceipt), 1);
}
$out .= "</td></tr>\n";

View File

@ -186,6 +186,14 @@ class InterfaceActionsAuto extends DolibarrTriggers
}
$object->actionmsg = $langs->transnoentities("PropalValidatedInDolibarr", ($object->newref ? $object->newref : $object->ref));
$object->sendtoid = 0;
} elseif ($action == 'PROPAL_MODIFY') {
// Load translation files required by the page
$langs->loadLangs(array("agenda", "other", "propal"));
if (empty($object->actionmsg2)) $object->actionmsg2 = $langs->transnoentities("PropalBackToDraftInDolibarr", ($object->newref ? $object->newref : $object->ref));
$object->actionmsg = $langs->transnoentities("PropalBackToDraftInDolibarr", ($object->newref ? $object->newref : $object->ref));
$object->sendtoid = 0;
} elseif ($action == 'PROPAL_SENTBYMAIL') {
// Load translation files required by the page

View File

@ -45,6 +45,7 @@ CONTRACT_DELETEInDolibarr=Contract %s deleted
PropalClosedSignedInDolibarr=Proposal %s signed
PropalClosedRefusedInDolibarr=Proposal %s refused
PropalValidatedInDolibarr=Proposal %s validated
PropalBackToDraftInDolibarr=Proposal %s go back to draft status
PropalClassifiedBilledInDolibarr=Proposal %s classified billed
InvoiceValidatedInDolibarr=Invoice %s validated
InvoiceValidatedInDolibarrFromPos=Invoice %s validated from POS

View File

@ -1802,7 +1802,17 @@ class Product extends CommonObject
*/
public function getSellPrice($thirdparty_seller, $thirdparty_buyer, $pqp = 0)
{
global $conf, $db;
global $conf, $db, $hookmanager, $action;
// Call hook if any
if (is_object($hookmanager)) {
$parameters = array('thirdparty_seller'=>$thirdparty_seller, 'thirdparty_buyer' => $thirdparty_buyer, 'pqp' => $pqp);
// Note that $action and $object may have been modified by some hooks
$reshook = $hookmanager->executeHooks('getSellPrice', $parameters, $this, $action);
if ($reshook > 0) {
return $hookmanager->resArray;
}
}
// Update if prices fields are defined
$tva_tx = get_default_tva($thirdparty_seller, $thirdparty_buyer, $this->id);

View File

@ -1115,11 +1115,12 @@ if ($object->id > 0) {
print '<td class="right">';
print price($pmp_valuation_real);
print '</td>';
print '<td class="nowraponall right">';
$totalExpectedValuation += $pmp_valuation;
$totalRealValuation += $pmp_valuation_real;
}
print '<td class="nowraponall right">';
if ($obj->fk_movement > 0) {
$stockmovment = new MouvementStock($db);
$stockmovment->fetch($obj->fk_movement);

View File

@ -210,7 +210,7 @@ if ($action == 'getProducts') {
}
}
$sql = 'SELECT rowid, ref, label, tosell, tobuy, barcode, price' ;
$sql = 'SELECT p.rowid, p.ref, p.label, p.tosell, p.tobuy, p.barcode, p.price' ;
// Add fields from hooks
$parameters=array();
$reshook=$hookmanager->executeHooks('printFieldListSelect', $parameters); // Note that $action and $object may have been modified by hook