Skip to content

Commit 4a65230

Browse files
authored
Merge branch 'develop' into new_dev_add_constant_thirdparty_member
2 parents b8239e0 + 211514c commit 4a65230

File tree

21 files changed

+160
-100
lines changed

21 files changed

+160
-100
lines changed

htdocs/admin/remotestore/class/externalModules.class.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,11 @@ class ExternalModules
130130
*/
131131
public $numberOfProducts;
132132

133+
/**
134+
* @var string
135+
*/
136+
public $error;
137+
133138
/**
134139
* Constructor
135140
*

htdocs/admin/subcontractors.php

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,13 @@
2424

2525
// Load Dolibarr environment
2626
require '../main.inc.php';
27+
/**
28+
* @var Conf $conf
29+
* @var DoliDB $db
30+
* @var HookManager $hookmanager
31+
* @var Translate $langs
32+
* @var User $user
33+
*/
2734
require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
2835
require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
2936
require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
@@ -33,23 +40,13 @@
3340
$action = GETPOST('action', 'aZ09');
3441
$contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'adminsubcontractors'; // To manage different context of search
3542

36-
/**
37-
* @var Conf $conf
38-
* @var DoliDB $db
39-
* @var HookManager $hookmanager
40-
* @var Translate $langs
41-
* @var User $user
42-
*/
43-
4443
// Load translation files required by the page
4544
$langs->loadLangs(array('admin', 'companies'));
4645

4746
if (!$user->admin) {
4847
accessforbidden();
4948
}
5049

51-
$error = 0;
52-
5350
$object = new stdClass();
5451

5552

@@ -63,8 +60,7 @@
6360
setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
6461
}
6562

66-
if (($action == 'update' && !GETPOST("cancel", 'alpha'))
67-
|| ($action == 'updateedit')) {
63+
if (($action == 'update' && !GETPOST("cancel", 'alpha')) || ($action == 'updateedit')) {
6864
dolibarr_set_const($db, "MAIN_INFO_ACCOUNTANT_NAME", GETPOST("nom", 'alphanohtml'), 'chaine', 0, '', $conf->entity);
6965
dolibarr_set_const($db, "MAIN_INFO_ACCOUNTANT_ADDRESS", GETPOST("address", 'alphanohtml'), 'chaine', 0, '', $conf->entity);
7066
dolibarr_set_const($db, "MAIN_INFO_ACCOUNTANT_TOWN", GETPOST("town", 'alphanohtml'), 'chaine', 0, '', $conf->entity);
@@ -93,7 +89,7 @@
9389
dolibarr_set_const($db, "MAIN_INFO_ITPROVIDER_CODE", GETPOST("itprovider_code", 'alphanohtml'), 'chaine', 0, '', $conf->entity);
9490
dolibarr_set_const($db, "MAIN_INFO_ITPROVIDER_NOTE", GETPOST("itprovider_note", 'restricthtml'), 'chaine', 0, '', $conf->entity);
9591

96-
if ($action != 'updateedit' && !$error) {
92+
if ($action != 'updateedit') {
9793
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
9894
}
9995
}

htdocs/admin/tools/purge.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,6 @@
2828

2929
// Load Dolibarr environment
3030
require '../../main.inc.php';
31-
include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
32-
3331
/**
3432
* @var Conf $conf
3533
* @var DoliDB $db
@@ -39,6 +37,8 @@
3937
*
4038
* @var string $dolibarr_main_data_root
4139
*/
40+
include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
41+
4242

4343
$langs->load("admin");
4444

htdocs/api/class/api.class.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,18 @@ public function __construct($db, $cachedir = '', $refreshCache = false)
5959

6060
$this->db = $db;
6161
$production_mode = getDolGlobalBool('API_PRODUCTION_MODE');
62+
63+
if ($production_mode) {
64+
// Create the directory Defaults::$cacheDirectory if it does not exists. If dir does not exists, using production_mode generates an error 500.
65+
include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
66+
if (!dol_is_dir(Defaults::$cacheDirectory)) {
67+
dol_mkdir(Defaults::$cacheDirectory, DOL_DATA_ROOT);
68+
}
69+
if (getDolGlobalString('MAIN_API_DEBUG')) {
70+
dol_syslog("Debug API construct::cacheDirectory=".Defaults::$cacheDirectory, LOG_DEBUG, 0, '_api');
71+
}
72+
}
73+
6274
$this->r = new Restler($production_mode, $refreshCache);
6375

6476
$urlwithouturlroot = preg_replace('/'.preg_quote(DOL_URL_ROOT, '/').'$/i', '', trim($dolibarr_main_url_root));

htdocs/api/index.php

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@
6363
if (!empty($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] == 'OPTIONS' && !empty($_SERVER['HTTP_ACCESS_CONTROL_REQUEST_HEADERS'])) {
6464
header('Access-Control-Allow-Origin: *');
6565
header('Access-Control-Allow-Methods: GET, POST, PUT, DELETE');
66-
header('Access-Control-Allow-Headers: Content-Type, Authorization, api_key, DOLAPIKEY');
66+
header('Access-Control-Allow-Headers: Content-Type, Authorization, api_key, DOLAPIKEY, DOLAPIENTITY');
6767
http_response_code(204);
6868
exit;
6969
}
@@ -72,13 +72,13 @@
7272
if (preg_match('/\/explorer\/swagger\.json/', $_SERVER["PHP_SELF"])) {
7373
header('Access-Control-Allow-Origin: *');
7474
header('Access-Control-Allow-Methods: GET, POST, PUT, DELETE');
75-
header('Access-Control-Allow-Headers: Content-Type, Authorization, api_key, DOLAPIKEY');
75+
header('Access-Control-Allow-Headers: Content-Type, Authorization, api_key, DOLAPIKEY, DOLAPIENTITY');
7676
}
7777
// When we request url to get an API, we accept Cross site so we can make js API call inside another website
7878
if (preg_match('/\/api\/index\.php/', $_SERVER["PHP_SELF"])) {
7979
header('Access-Control-Allow-Origin: *');
8080
header('Access-Control-Allow-Methods: GET, POST, PUT, DELETE');
81-
header('Access-Control-Allow-Headers: Content-Type, Authorization, api_key, DOLAPIKEY');
81+
header('Access-Control-Allow-Headers: Content-Type, Authorization, api_key, DOLAPIKEY, DOLAPIENTITY');
8282
}
8383
header('X-Frame-Options: SAMEORIGIN');
8484

@@ -432,7 +432,11 @@ static function () {
432432
}
433433
}
434434

435-
//dol_syslog('We found some compression algorithm: '.$foundonealgorithm.' -> usecompression='.$usecompression, LOG_DEBUG);
435+
436+
if (getDolGlobalString('MAIN_API_DEBUG')) {
437+
dol_syslog('We found some compression algorithm: '.$foundonealgorithm.' -> usecompression='.(int) $usecompression, LOG_DEBUG, 0, '_api');
438+
}
439+
436440

437441
Luracast\Restler\Defaults::$returnResponse = $usecompression;
438442

htdocs/comm/propal/class/propal.class.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -481,7 +481,7 @@ public function __construct($db, $socid = 0, $propalid = 0)
481481
public function add_product($idproduct, $qty, $remise_percent = 0)
482482
{
483483
// phpcs:enable
484-
global $conf, $mysoc;
484+
global $mysoc;
485485

486486
if (!$qty) {
487487
$qty = 1;
@@ -725,7 +725,7 @@ public function addline(
725725
$result = $product->fetch($fk_product);
726726
$product_type = $product->type;
727727

728-
if (getDolGlobalString('STOCK_MUST_BE_ENOUGH_FOR_PROPOSAL') && $product_type == 0 && $product->stock_reel < $qty) {
728+
if ($product->isStockManaged() && $product->stock_reel < $qty && getDolGlobalString('STOCK_MUST_BE_ENOUGH_FOR_PROPOSAL')) {
729729
$langs->load("errors");
730730
$this->error = $langs->trans('ErrorStockIsNotEnoughToAddProductOnProposal', $product->ref);
731731
$this->db->rollback();

htdocs/commande/class/commande.class.php

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -586,7 +586,7 @@ public function valid($user, $idwarehouse = 0, $notrigger = 0)
586586
$result = $mouvP->livraison($user, $this->lines[$i]->fk_product, $idwarehouse, $this->lines[$i]->qty, $this->lines[$i]->subprice, $langs->trans("OrderValidatedInDolibarr", $num));
587587
if ($result < 0) {
588588
$error++;
589-
$this->error = $mouvP->error;
589+
$this->setErrorsFromObject($mouvP);
590590
}
591591
}
592592
if ($error) {
@@ -721,7 +721,7 @@ public function setDraft($user, $idwarehouse = -1)
721721
$result = $mouvP->reception($user, $this->lines[$i]->fk_product, $idwarehouse, $this->lines[$i]->qty, 0, $langs->trans("OrderBackToDraftInDolibarr", $this->ref));
722722
if ($result < 0) {
723723
$error++;
724-
$this->error = $mouvP->error;
724+
$this->setErrorsFromObject($mouvP);
725725
break;
726726
}
727727
}
@@ -1673,7 +1673,7 @@ public function addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1 = 0, $txlocalt
16731673
$result = $product->fetch($fk_product);
16741674
$product_type = $product->type;
16751675

1676-
if (getDolGlobalString('STOCK_MUST_BE_ENOUGH_FOR_ORDER') && $product_type == 0) {
1676+
if (getDolGlobalString('STOCK_MUST_BE_ENOUGH_FOR_ORDER') && $product->isStockManaged()) {
16771677
// get real stock
16781678
$productChildrenNb = 0;
16791679
if (getDolGlobalInt('PRODUIT_SOUSPRODUITS')) {
@@ -1861,7 +1861,7 @@ public function addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1 = 0, $txlocalt
18611861
return -1;
18621862
}
18631863
} else {
1864-
$this->error = $this->line->error;
1864+
$this->setErrorsFromObject($this->line);
18651865
dol_syslog(get_class($this)."::addline error=".$this->error, LOG_ERR);
18661866
$this->db->rollback();
18671867
return -2;
@@ -2184,8 +2184,7 @@ public function insert_discount($idremise)
21842184
return -1;
21852185
}
21862186
} else {
2187-
$this->error = $line->error;
2188-
$this->errors = $line->errors;
2187+
$this->setErrorsFromObject($line);
21892188
$this->db->rollback();
21902189
return -2;
21912190
}
@@ -2522,7 +2521,7 @@ public function deleteLine($user = null, $lineid = 0, $id = 0)
25222521
}
25232522
} else {
25242523
$this->db->rollback();
2525-
$this->error = $line->error;
2524+
$this->setErrorsFromObject($line);
25262525
return -1;
25272526
}
25282527
} else {
@@ -3228,7 +3227,7 @@ public function updateline($rowid, $desc, $pu, $qty, $remise_percent, $txtva, $t
32283227
$result = $product->fetch($line->fk_product);
32293228
$product_type = $product->type;
32303229

3231-
if (getDolGlobalString('STOCK_MUST_BE_ENOUGH_FOR_ORDER') && $product_type == 0) {
3230+
if (getDolGlobalString('STOCK_MUST_BE_ENOUGH_FOR_ORDER') && $product->isStockManaged()) {
32323231
// get real stock
32333232
$productChildrenNb = 0;
32343233
if (getDolGlobalInt('PRODUIT_SOUSPRODUITS')) {
@@ -3350,7 +3349,7 @@ public function updateline($rowid, $desc, $pu, $qty, $remise_percent, $txtva, $t
33503349
$this->db->commit();
33513350
return $result;
33523351
} else {
3353-
$this->error = $this->line->error;
3352+
$this->setErrorsFromObject($this->line);
33543353

33553354
$this->db->rollback();
33563355
return -1;

htdocs/compta/facture/class/facture.class.php

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -918,8 +918,7 @@ public function create(User $user, $notrigger = 0, $forceduedate = 0, $updatecur
918918
);
919919

920920
if ($result < 0) {
921-
$this->error = $newinvoiceline->error;
922-
$this->errors = array_merge($this->errors, $newinvoiceline->errors);
921+
$this->setErrorsFromObject($newinvoiceline);
923922
$error++;
924923
break;
925924
}
@@ -3737,8 +3736,7 @@ public function validate($user, $force_number = '', $idwarehouse = 0, $notrigger
37373736
$result = $mouvP->reception($user, $this->lines[$i]->fk_product, $idwarehouse, $this->lines[$i]->qty, 0, $langs->trans("InvoiceValidatedInDolibarr", $num), '', '', $this->lines[$i]->batch);
37383737
if ($result < 0) {
37393738
$error++;
3740-
$this->error = $mouvP->error;
3741-
$this->errors = array_merge($this->errors, $mouvP->errors);
3739+
$this->setErrorsFromObject($mouvP);
37423740
}
37433741
} else {
37443742
// TODO If warehouseid has been set into invoice line, we should use this value in priority
@@ -3790,8 +3788,7 @@ public function validate($user, $force_number = '', $idwarehouse = 0, $notrigger
37903788
$result = $mouvP->livraison($user, $productStatic->id, $idwarehouse, $product_batch_qty, $this->lines[$i]->subprice, $langs->trans('InvoiceValidatedInDolibarr', $num), '', '', '', $batch->batch);
37913789
if ($result < 0) {
37923790
$error++;
3793-
$this->error = $mouvP->error;
3794-
$this->errors = array_merge($this->errors, $mouvP->errors);
3791+
$this->setErrorsFromObject($mouvP);
37953792
break;
37963793
}
37973794

@@ -3815,8 +3812,7 @@ public function validate($user, $force_number = '', $idwarehouse = 0, $notrigger
38153812
$result = $mouvP->livraison($user, $productStatic->id, $idwarehouse, $product_qty_remain, $this->lines[$i]->subprice, $langs->trans('InvoiceValidatedInDolibarr', $num), '', '', '', $batch->batch);
38163813
if ($result < 0) {
38173814
$error++;
3818-
$this->error = $mouvP->error;
3819-
$this->errors = array_merge($this->errors, $mouvP->errors);
3815+
$this->setErrorsFromObject($mouvP);
38203816
}
38213817
}
38223818
}
@@ -3828,8 +3824,7 @@ public function validate($user, $force_number = '', $idwarehouse = 0, $notrigger
38283824
$result = $mouvP->livraison($user, $this->lines[$i]->fk_product, $idwarehouse, $this->lines[$i]->qty, $this->lines[$i]->subprice, $langs->trans("InvoiceValidatedInDolibarr", $num));
38293825
if ($result < 0) {
38303826
$error++;
3831-
$this->error = $mouvP->error;
3832-
$this->errors = array_merge($this->errors, $mouvP->errors);
3827+
$this->setErrorsFromObject($mouvP);
38333828
}
38343829
}
38353830
}
@@ -4282,7 +4277,7 @@ public function addline(
42824277
$result = $product->fetch($fk_product);
42834278
$product_type = $product->type;
42844279

4285-
if (getDolGlobalString('STOCK_MUST_BE_ENOUGH_FOR_INVOICE') && $product_type == 0) {
4280+
if (getDolGlobalString('STOCK_MUST_BE_ENOUGH_FOR_INVOICE') && $product->isStockManaged()) {
42864281
// get real stock
42874282
$productChildrenNb = 0;
42884283
if (getDolGlobalInt('PRODUIT_SOUSPRODUITS')) {
@@ -4632,7 +4627,7 @@ public function updateline($rowid, $desc, $pu, $qty, $remise_percent, $date_star
46324627
$result = $product->fetch($line->fk_product);
46334628
$product_type = $product->type;
46344629

4635-
if (getDolGlobalString('STOCK_MUST_BE_ENOUGH_FOR_INVOICE') && $product_type == 0) {
4630+
if (getDolGlobalString('STOCK_MUST_BE_ENOUGH_FOR_INVOICE') && $product->isStockManaged()) {
46364631
// get real stock
46374632
$productChildrenNb = 0;
46384633
if (getDolGlobalInt('PRODUIT_SOUSPRODUITS')) {

htdocs/contrat/class/contrat.class.php

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -431,8 +431,7 @@ public function activateAll($user, $date_start = '', $notrigger = 0, $comment =
431431
$result = $contratline->active_line($user, $date_start, !empty($date_end) ? $date_end : -1, $comment); // This call trigger LINECONTRACT_ACTIVATE
432432
if ($result < 0) {
433433
$error++;
434-
$this->error = $contratline->error;
435-
$this->errors = $contratline->errors;
434+
$this->setErrorsFromObject($contratline);
436435
break;
437436
}
438437
}
@@ -1642,8 +1641,7 @@ public function addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1, $txlocaltax2,
16421641
$contractline->id = $contractlineid;
16431642
$result = $contractline->insertExtraFields();
16441643
if ($result < 0) {
1645-
$this->errors = array_merge($this->errors, $contractline->errors);
1646-
$this->error = $contractline->error;
1644+
$this->setErrorsFromObject($contractline);
16471645
$error++;
16481646
}
16491647

@@ -2680,8 +2678,7 @@ public function createFromClone(User $user, $socid = 0, $notrigger = 0)
26802678
$result = $clonedObj->addline($line->description, $line->subprice, $line->qty, $line->tva_tx, $line->localtax1_tx, $line->localtax2_tx, $line->fk_product, $line->remise_percent, $line->date_start, $line->date_cloture, 'HT', 0, $line->info_bits, $line->fk_fournprice, $line->pa_ht, $line->array_options, $line->fk_unit, $line->rang);
26812679
if ($result < 0) {
26822680
$error++;
2683-
$this->error = $clonedObj->error;
2684-
$this->errors[] = $clonedObj->error;
2681+
$this->setErrorsFromObject($clonedObj);
26852682
}
26862683
}
26872684
}

htdocs/core/ajax/selectsearchbox.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,9 @@
191191
if (isModEnabled('holiday') && !getDolGlobalString('MAIN_SEARCHFORM_HOLIDAY_DISABLED') && $user->hasRight('holiday', 'read')) {
192192
$arrayresult['searchintoleaves'] = array('position' => 220, 'img' => 'object_holiday', 'label' => $langs->trans("SearchIntoLeaves", $search_boxvalue), 'text' => img_picto('', 'object_holiday', 'class="pictofixedwidth"').' '.$langs->trans("SearchIntoLeaves", $search_boxvalue), 'url' => DOL_URL_ROOT.'/holiday/list.php?mainmenu=hrm'.($search_boxvalue ? '&search_all='.urlencode($search_boxvalue) : ''));
193193
}
194+
if (isModEnabled('resource') && !getDolGlobalString('MAIN_SEARCHFORM_RESOURCE_DISABLED') && $user->hasRight('resource', 'read')) {
195+
$arrayresult['searchintoresourcess'] = array('position' => 250, 'img' => 'object_resource', 'label' => $langs->trans("SearchIntoResources", $search_boxvalue), 'text' => img_picto('', 'object_resource', 'class="pictofixedwidth"').' '.$langs->trans("SearchIntoResources", $search_boxvalue), 'url' => DOL_URL_ROOT.'/resource/list.php?mainmenu=hrm'.($search_boxvalue ? '&search_all='.urlencode($search_boxvalue) : ''));
196+
}
194197

195198
// Execute hook addSearchEntry
196199
$parameters = array('search_boxvalue' => $search_boxvalue, 'arrayresult' => $arrayresult);

0 commit comments

Comments
 (0)