diff --git a/htdocs/comm/action/card.php b/htdocs/comm/action/card.php index ee8fff4adc8..aa513e07794 100644 --- a/htdocs/comm/action/card.php +++ b/htdocs/comm/action/card.php @@ -701,7 +701,7 @@ if (empty($reshook) && $action == 'update') { $categories = GETPOST('categories', 'array'); $object->setCategories($categories); - $object->loadReminders(); + $object->loadReminders($remindertype, 0, false); if (!empty($object->reminders) && $object->datep > dol_now()) { foreach ($object->reminders as $reminder) { $reminder->delete($user); diff --git a/htdocs/compta/facture/list.php b/htdocs/compta/facture/list.php index cd04b31fc4d..c92b744c03f 100644 --- a/htdocs/compta/facture/list.php +++ b/htdocs/compta/facture/list.php @@ -10,7 +10,7 @@ * Copyright (C) 2013 Florian Henry * Copyright (C) 2013 Cédric Salvador * Copyright (C) 2015 Jean-François Ferry - * Copyright (C) 2015-2021 Ferran Marcet + * Copyright (C) 2015-2022 Ferran Marcet * Copyright (C) 2017 Josep Lluís Amador * Copyright (C) 2018 Charlene Benke * Copyright (C) 2019-2021 Alexandre Spangaro @@ -2077,7 +2077,7 @@ if ($resql) { // Sales representatives print ''; if ($obj->socid > 0) { - $listsalesrepresentatives = $thirdpartystatic->getSalesRepresentatives($user); + $listsalesrepresentatives = $companystatic->getSalesRepresentatives($user); if ($listsalesrepresentatives < 0) { dol_print_error($db); } diff --git a/htdocs/compta/stats/casoc.php b/htdocs/compta/stats/casoc.php index 76dbc56beef..0bef7ff555a 100644 --- a/htdocs/compta/stats/casoc.php +++ b/htdocs/compta/stats/casoc.php @@ -57,6 +57,7 @@ $socid = GETPOST('socid', 'int'); // Category $selected_cat = (int) GETPOST('search_categ', 'int'); +if ($selected_cat == -1) $selected_cat = ''; $subcat = false; if (GETPOST('subcat', 'alpha') === 'yes') { $subcat = true; diff --git a/htdocs/conf/conf.php.example b/htdocs/conf/conf.php.example index 8cd46352ac9..487576ed058 100644 --- a/htdocs/conf/conf.php.example +++ b/htdocs/conf/conf.php.example @@ -204,7 +204,7 @@ $dolibarr_main_authentication='dolibarr'; // $dolibarr_main_auth_ldap_servertype='openldap'; // openldap, activedirectory or egroupware // $dolibarr_main_auth_ldap_login_attribute='loginfield'; // Ex: uid or samaccountname for active directory // $dolibarr_main_auth_ldap_dn='ou=users,dc=my-domain,dc=com'; // Ex: ou=users,dc=my-domain,dc=com -// $dolibarr_main_auth_ldap_filter = ''; // If defined, two previous parameters are not used to find a user into LDAP. Ex: (uid=%1%) or &(uid=%1%)(isMemberOf=cn=Sales,ou=Groups,dc=opencsi,dc=com). +// $dolibarr_main_auth_ldap_filter = ''; // If defined, the two previous parameters (dolibarr_main_auth_ldap_login_attribute and dolibarr_main_auth_ldap_dn) are not used to find a user into LDAP. Instead we use this search string. Ex: (uid=%1%) or &(uid=%1%)(isMemberOf=cn=Sales,ou=Groups,dc=opencsi,dc=com). // $dolibarr_main_auth_ldap_admin_login=''; // Required only if anonymous bind disabled. Ex: cn=admin,dc=example,dc=com // $dolibarr_main_auth_ldap_admin_pass=''; // Required only if anonymous bind disabled. Ex: secret // $dolibarr_main_auth_ldap_debug='false'; diff --git a/htdocs/core/boxes/box_dolibarr_state_board.php b/htdocs/core/boxes/box_dolibarr_state_board.php index 0381b493448..24be4100dab 100644 --- a/htdocs/core/boxes/box_dolibarr_state_board.php +++ b/htdocs/core/boxes/box_dolibarr_state_board.php @@ -79,6 +79,9 @@ class box_dolibarr_state_board extends ModeleBoxes if (empty($user->socid) && empty($conf->global->MAIN_DISABLE_GLOBAL_BOXSTATS)) { $hookmanager = new HookManager($this->db); $hookmanager->initHooks(array('index')); + $object = new stdClass; + $action = ''; + $hookmanager->executeHooks('addStatisticLine', array(), $object, $action); $boxstatItems = array(); $boxstatFromHook = ''; $boxstatFromHook = $hookmanager->resPrint; diff --git a/htdocs/core/modules/modResource.class.php b/htdocs/core/modules/modResource.class.php index 51117868e35..da1fdcbf016 100644 --- a/htdocs/core/modules/modResource.class.php +++ b/htdocs/core/modules/modResource.class.php @@ -252,7 +252,7 @@ class modResource extends DolibarrModules $this->export_sql_end[$r] = ' FROM '.MAIN_DB_PREFIX.'resource as r'; $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_type_resource as c ON c.rowid=r.fk_code_type_resource'; $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'resource_extrafields as extra ON extra.fk_object = r.rowid'; - $this->export_sql_end[$r] .= ' AND r.entity IN ('.getEntity('resource').')'; + $this->export_sql_end[$r] .= ' WHERE r.entity IN ('.getEntity('resource').')'; // Imports diff --git a/htdocs/fourn/commande/list.php b/htdocs/fourn/commande/list.php index cd9a1922524..fb90e598a8b 100644 --- a/htdocs/fourn/commande/list.php +++ b/htdocs/fourn/commande/list.php @@ -355,6 +355,8 @@ if (empty($reshook)) { $db->begin(); + $default_ref_supplier=dol_print_date(dol_now(), '%Y%m%d%H%M%S'); + foreach ($orders as $id_order) { $cmd = new CommandeFournisseur($db); if ($cmd->fetch($id_order) <= 0) { @@ -372,7 +374,8 @@ if (empty($reshook)) { $objecttmp->fk_project = $cmd->fk_project; $objecttmp->multicurrency_code = $cmd->multicurrency_code; if (empty($createbills_onebythird)) { - $objecttmp->ref_client = $cmd->ref_client; + $objecttmp->ref_supplier = !empty($cmd->ref_supplier) ? $cmd->ref_supplier : $default_ref_supplier; + $default_ref_supplier+=1; } $datefacture = dol_mktime(12, 0, 0, GETPOST('remonth', 'int'), GETPOST('reday', 'int'), GETPOST('reyear', 'int')); diff --git a/htdocs/product/inventory/inventory.php b/htdocs/product/inventory/inventory.php index 6026e4316e4..6a6d4c345ce 100644 --- a/htdocs/product/inventory/inventory.php +++ b/htdocs/product/inventory/inventory.php @@ -307,6 +307,7 @@ if (empty($reshook)) { include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php';*/ if (GETPOST('addline', 'alpha')) { + $qty= (GETPOST('qtytoadd') != '' ? price2num(GETPOST('qtytoadd', 'MS')) : null); if ($fk_warehouse <= 0) { $error++; setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Warehouse")), null, 'errors'); @@ -323,12 +324,17 @@ if (empty($reshook)) { $tmpproduct = new Product($db); $result = $tmpproduct->fetch($fk_product); - if (!$error && $tmpproduct->status_batch && !$batch) { + if (empty($error) && $tmpproduct->status_batch>0 && empty($batch)) { $error++; $langs->load("errors"); setEventMessages($langs->trans("ErrorProductNeedBatchNumber", $tmpproduct->ref), null, 'errors'); } - if (!$error && !$tmpproduct->status_batch && $batch) { + if (empty($error) && $tmpproduct->status_batch==2 && !empty($batch) && $qty>1) { + $error++; + $langs->load("errors"); + setEventMessages($langs->trans("TooManyQtyForSerialNumber", $tmpproduct->ref, $batch), null, 'errors'); + } + if (empty($error) && empty($tmpproduct->status_batch) && !empty($batch)) { $error++; $langs->load("errors"); setEventMessages($langs->trans("ErrorProductDoesNotNeedBatchNumber", $tmpproduct->ref), null, 'errors'); @@ -341,7 +347,7 @@ if (empty($reshook)) { $tmp->fk_product = $fk_product; $tmp->batch = $batch; $tmp->datec = $now; - $tmp->qty_view = (GETPOST('qtytoadd') != '' ? price2num(GETPOST('qtytoadd', 'MS')) : null); + $tmp->qty_view = $qty; $result = $tmp->create($user); if ($result < 0) { diff --git a/htdocs/product/stock/class/mouvementstock.class.php b/htdocs/product/stock/class/mouvementstock.class.php index 67119ff6839..79260263148 100644 --- a/htdocs/product/stock/class/mouvementstock.class.php +++ b/htdocs/product/stock/class/mouvementstock.class.php @@ -597,7 +597,7 @@ class MouvementStock extends CommonObject if ($product->status_batch == 2 && $qty > 0) { // We check only if we increased qty if ($this->getBatchCount($fk_product, $batch) > 1) { $error++; - $this->errors[] = $langs->trans("TooManyQtyForSerialNumber", $batch, $product->ref); + $this->errors[] = $langs->trans("TooManyQtyForSerialNumber", $product->ref, $batch); } } } diff --git a/htdocs/societe/admin/societe.php b/htdocs/societe/admin/societe.php index 55161f42e09..2fb9285379f 100644 --- a/htdocs/societe/admin/societe.php +++ b/htdocs/societe/admin/societe.php @@ -1,9 +1,9 @@ - * Copyright (C) 2004 Eric Seigne - * Copyright (C) 2005-2011 Laurent Destailleur - * Copyright (C) 2005-2012 Regis Houssin - * Copyright (C) 2011-2012 Juanjo Menent +/* Copyright (C) 2004 Rodolphe Quiedeville + * Copyright (C) 2004 Eric Seigne + * Copyright (C) 2005-2011 Laurent Destailleur + * Copyright (C) 2005-2012 Regis Houssin + * Copyright (C) 2011-2012 Juanjo Menent * * 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 @@ -254,7 +254,7 @@ if ($action == "setaskforshippingmet") { } } -//Activate "Disable prospect/customer type" +// Activate "Disable prospect/customer type" if ($action == "setdisableprospectcustomer") { $setdisableprospectcustomer = GETPOST('value', 'int'); $res = dolibarr_set_const($db, "SOCIETE_DISABLE_PROSPECTSCUSTOMERS", $setdisableprospectcustomer, 'yesno', 0, '', $conf->entity); diff --git a/htdocs/societe/card.php b/htdocs/societe/card.php index 10edb21483e..45bbefabdab 100644 --- a/htdocs/societe/card.php +++ b/htdocs/societe/card.php @@ -6,7 +6,7 @@ * Copyright (C) 2005-2017 Regis Houssin * Copyright (C) 2008 Patrick Raguin * Copyright (C) 2010-2020 Juanjo Menent - * Copyright (C) 2011-2021 Alexandre Spangaro + * Copyright (C) 2011-2022 Alexandre Spangaro * Copyright (C) 2015 Jean-François Ferry * Copyright (C) 2015 Marcos García * Copyright (C) 2015 Raphaël Doursenaud @@ -1004,23 +1004,28 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { $modCodeFournisseur = new $module; // Define if customer/prospect or supplier status is set or not - if (GETPOST("type") != 'f') { + if (GETPOST("type", 'aZ') != 'f') { $object->client = -1; if (!empty($conf->global->THIRDPARTY_CUSTOMERPROSPECT_BY_DEFAULT)) { $object->client = 3; } } // Prospect / Customer - if (GETPOST("type") == 'c') { + if (GETPOST("type", 'aZ') == 'c') { if (!empty($conf->global->THIRDPARTY_CUSTOMERTYPE_BY_DEFAULT)) { $object->client = $conf->global->THIRDPARTY_CUSTOMERTYPE_BY_DEFAULT; } else { $object->client = 3; } } - if (GETPOST("type") == 'p') { + if (GETPOST("type", 'aZ') == 'p') { $object->client = 2; } + + if (!empty($conf->global->SOCIETE_DISABLE_PROSPECTSCUSTOMERS) && $object->client == 3) { + $object->client = 1; + } + if (((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || !empty($conf->supplier_order->enabled) || !empty($conf->supplier_invoice->enabled)) && (GETPOST("type") == 'f' || (GETPOST("type") == '' && !empty($conf->global->THIRDPARTY_SUPPLIER_BY_DEFAULT)))) { $object->fournisseur = 1; } diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index 7fab734a12c..efa868b7aad 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -1450,11 +1450,13 @@ class Societe extends CommonObject $sql .= ",prefix_comm = ".(!empty($this->prefix_comm) ? "'".$this->db->escape($this->prefix_comm)."'" : "null"); - $sql .= ",fk_effectif = ".(!empty($this->effectif_id) ? "'".$this->db->escape($this->effectif_id)."'" : "null"); + $sql .= ",fk_effectif = ".($this->effectif_id > 0 ? ((int) $this->effectif_id) : "null"); if (isset($this->stcomm_id)) { - $sql .= ",fk_stcomm=".(!empty($this->stcomm_id) ? $this->stcomm_id : "0"); + $sql .= ",fk_stcomm=".($this->stcomm_id > 0 ? ((int) $this->stcomm_id) : "0"); + } + if (isset($this->typent_id)) { + $sql .= ",fk_typent = ".($this->typent_id > 0 ? ((int) $this->typent_id) : "0"); } - $sql .= ",fk_typent = ".(!empty($this->typent_id) ? "'".$this->db->escape($this->typent_id)."'" : "0"); $sql .= ",fk_forme_juridique = ".(!empty($this->forme_juridique_code) ? "'".$this->db->escape($this->forme_juridique_code)."'" : "null");