From 879afaa59e0251639e66981be8d00668f6800da3 Mon Sep 17 00:00:00 2001 From: Quentin VIAL-GOUTEYRON Date: Fri, 18 Feb 2022 12:16:50 +0100 Subject: [PATCH 01/59] NEW : Beginning of PMP management on inventory --- .../install/mysql/migration/15.0.0-16.0.0.sql | 2 + .../mysql/tables/llx_inventorydet-stock.sql | 2 + htdocs/langs/en_US/products.lang | 4 + htdocs/product/inventory/inventory.php | 86 ++++++++++++++++++- .../product/stock/tpl/extrafields_add.tpl.php | 2 +- 5 files changed, 91 insertions(+), 5 deletions(-) diff --git a/htdocs/install/mysql/migration/15.0.0-16.0.0.sql b/htdocs/install/mysql/migration/15.0.0-16.0.0.sql index b78e53bd287..85d8763a4fe 100644 --- a/htdocs/install/mysql/migration/15.0.0-16.0.0.sql +++ b/htdocs/install/mysql/migration/15.0.0-16.0.0.sql @@ -237,4 +237,6 @@ ALTER TABLE llx_advtargetemailing RENAME TO llx_mailing_advtarget; ALTER TABLE llx_mailing ADD UNIQUE uk_mailing(titre, entity); +ALTER TABLE llx_inventorydet ADD COLUMN pmp_real double DEFAULT NULL; +ALTER TABLE llx_inventorydet ADD COLUMN valuation_real double DEFAULT NULL; diff --git a/htdocs/install/mysql/tables/llx_inventorydet-stock.sql b/htdocs/install/mysql/tables/llx_inventorydet-stock.sql index 8b75f68460d..5ce878124b6 100644 --- a/htdocs/install/mysql/tables/llx_inventorydet-stock.sql +++ b/htdocs/install/mysql/tables/llx_inventorydet-stock.sql @@ -29,6 +29,8 @@ CREATE TABLE llx_inventorydet qty_stock double DEFAULT NULL, -- Value or real stock we have, when we start the inventory (may be updated during intermediary steps). qty_view double DEFAULT NULL, -- Quantity found during inventory. It is the targeted value, filled during edition of inventory. qty_regulated double DEFAULT NULL, -- Never used. Deprecated because we already have the fk_movement now. + pmp_real double DEFAULT NULL, -- Never used. Deprecated because we already have the fk_movement now. + valuation_real double DEFAULT NULL, -- Never used. Deprecated because we already have the fk_movement now. fk_movement integer NULL -- can contain the id of stock movement we recorded to make the inventory regulation of this line ) ENGINE=innodb; diff --git a/htdocs/langs/en_US/products.lang b/htdocs/langs/en_US/products.lang index 14715670882..947b743fa7a 100644 --- a/htdocs/langs/en_US/products.lang +++ b/htdocs/langs/en_US/products.lang @@ -411,3 +411,7 @@ Rank=Rank SwitchOnSaleStatus=Switch on sale status SwitchOnPurchaseStatus=Switch on purchase status StockMouvementExtraFields= Extra Fields (stock mouvement) +PMPExpected=Expected PMP +ExpectedValuation=Expected Valuation +PMPReal=Real PMP +RealValuation=Real Valuation \ No newline at end of file diff --git a/htdocs/product/inventory/inventory.php b/htdocs/product/inventory/inventory.php index 95c9e2972cb..795e3ad11bb 100644 --- a/htdocs/product/inventory/inventory.php +++ b/htdocs/product/inventory/inventory.php @@ -45,7 +45,8 @@ $fk_warehouse = GETPOST('fk_warehouse', 'int'); $fk_product = GETPOST('fk_product', 'int'); $lineid = GETPOST('lineid', 'int'); $batch = GETPOST('batch', 'alphanohtml'); - +$totalExpectedValuation = 0; +$totalRealValuation = 0; if (empty($conf->global->MAIN_USE_ADVANCED_PERMS)) { $result = restrictedArea($user, 'stock', $id); } else { @@ -863,6 +864,12 @@ if ($object->id > 0) { print ''; print $form->textwithpicto($langs->trans("RealQty"), $langs->trans("InventoryRealQtyHelp")); print ''; + if(!empty($conf->global->INVENTORY_MANAGE_REAL_PMP)) { + print ''.$langs->trans('PMPExpected').''; + print ''.$langs->trans('ExpectedValuation').''; + print ''.$langs->trans('PMPReal').''; + print ''.$langs->trans('RealValuation').''; + } if ($object->status == $object::STATUS_DRAFT || $object->status == $object::STATUS_VALIDATED) { // Actions or link to stock movement print ''; @@ -893,6 +900,16 @@ if ($object->id > 0) { print ''; print ''; print ''; + if(!empty($conf->global->INVENTORY_MANAGE_REAL_PMP)) { + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + } // Actions print ''; print ''; @@ -902,7 +919,7 @@ if ($object->id > 0) { // Request to show lines of inventory (prefilled after start/validate step) $sql = 'SELECT id.rowid, id.datec as date_creation, id.tms as date_modification, id.fk_inventory, id.fk_warehouse,'; - $sql .= ' id.fk_product, id.batch, id.qty_stock, id.qty_view, id.qty_regulated, id.fk_movement'; + $sql .= ' id.fk_product, id.batch, id.qty_stock, id.qty_view, id.qty_regulated, id.fk_movement, id.pmp_real, id.valuation_real'; $sql .= ' FROM '.MAIN_DB_PREFIX.'inventorydet as id'; $sql .= ' WHERE id.fk_inventory = '.((int) $object->id); @@ -988,6 +1005,36 @@ if ($object->id > 0) { print ''; print ''; print ''; + if(! empty($conf->global->INVENTORY_MANAGE_REAL_PMP)) { + //PMP Expected + $pmp_valuation = $product_static->pmp * $valuetoshow; + print ''; + print price($product_static->pmp); + print ''; + print ''; + print price($pmp_valuation); + print ''; + //PMP Real + print ''; + print ''; + print img_picto('', 'eraser', 'class="opacitymedium"'); + print ''; + + if(! empty($obj->pmp_real)) $pmp_real = $obj->pmp_real; + else $pmp_real = $product_static->pmp; + $pmp_valuation_real = $pmp_real * $qty_view; + print ''; + print ''; + print ''; + print ''; + print img_picto('', 'eraser', 'class="opacitymedium"'); + print ''; + print ''; + print ''; + + $totalExpectedValuation += $pmp_valuation; + $totalRealValuation += $pmp_valuation_real; + } // Picto delete line print ''; @@ -999,7 +1046,31 @@ if ($object->id > 0) { print ''; print $obj->qty_view; // qty found print ''; - print ''; + if(!empty($conf->global->INVENTORY_MANAGE_REAL_PMP)) { + //PMP Expected + $pmp_valuation = $product_static->pmp * $valuetoshow; + $pmp_valuation_real = $pmp_real * $obj->qty_view; + print ''; + print price($product_static->pmp); + print ''; + print ''; + print price($pmp_valuation); + print ''; + + //PMP Real + print ''; + if(! empty($obj->pmp_real)) $pmp_real = $obj->pmp_real; + else $pmp_real = $product_static->pmp; + print price($pmp_real); + print ''; + print ''; + print price($pmp_valuation_real); + print ''; + print ''; + + $totalExpectedValuation += $pmp_valuation; + $totalRealValuation += $pmp_valuation_real; + } if ($obj->fk_movement > 0) { $stockmovment = new MouvementStock($db); $stockmovment->fetch($obj->fk_movement); @@ -1014,7 +1085,14 @@ if ($object->id > 0) { } else { dol_print_error($db); } - + if(!empty($conf->global->INVENTORY_MANAGE_REAL_PMP)) { + print ''; + print ''.$langs->trans("Total").''; + print ''.price($totalExpectedValuation).''; + print ''.price($totalRealValuation).''; + print ''; + print ''; + } print ''; print ''; diff --git a/htdocs/product/stock/tpl/extrafields_add.tpl.php b/htdocs/product/stock/tpl/extrafields_add.tpl.php index 62921f0a6e0..aec8c971deb 100644 --- a/htdocs/product/stock/tpl/extrafields_add.tpl.php +++ b/htdocs/product/stock/tpl/extrafields_add.tpl.php @@ -44,7 +44,7 @@ if (empty($reshook)) { $params = array(); if (isset($tpl_context)) $params['tpl_context'] = $tpl_context; $params['cols'] = $parameters['colspanvalue']; - print $movement->showOptionals($extrafields, 'create', $params); +// print $movement->showOptionals($extrafields, 'create', $params); } ?> From 5c2c06de3b2fd5bc6f74c829bf9c28dabfdaa673 Mon Sep 17 00:00:00 2001 From: Quentin VIAL-GOUTEYRON Date: Fri, 18 Feb 2022 15:39:56 +0100 Subject: [PATCH 02/59] NEW : JS inventory autocalc input --- htdocs/product/inventory/inventory.php | 76 +++++++++++++++++++++++--- 1 file changed, 67 insertions(+), 9 deletions(-) diff --git a/htdocs/product/inventory/inventory.php b/htdocs/product/inventory/inventory.php index 795e3ad11bb..06c8ae0d2f5 100644 --- a/htdocs/product/inventory/inventory.php +++ b/htdocs/product/inventory/inventory.php @@ -1016,20 +1016,15 @@ if ($object->id > 0) { print ''; //PMP Real print ''; - print ''; - print img_picto('', 'eraser', 'class="opacitymedium"'); - print ''; + if(! empty($obj->pmp_real)) $pmp_real = $obj->pmp_real; else $pmp_real = $product_static->pmp; $pmp_valuation_real = $pmp_real * $qty_view; - print ''; + print ''; print ''; print ''; - print ''; - print img_picto('', 'eraser', 'class="opacitymedium"'); - print ''; - print ''; + print ''; print ''; $totalExpectedValuation += $pmp_valuation; @@ -1089,7 +1084,7 @@ if ($object->id > 0) { print ''; print ''.$langs->trans("Total").''; print ''.price($totalExpectedValuation).''; - print ''.price($totalRealValuation).''; + print ''.price($totalRealValuation).''; print ''; print ''; } @@ -1115,6 +1110,69 @@ if ($object->id > 0) { '; } print ''; + + + if(! empty($conf->global->INVENTORY_MANAGE_REAL_PMP)) { + ?> + + Date: Mon, 21 Feb 2022 14:25:18 +0100 Subject: [PATCH 03/59] new pmp column --- .../install/mysql/migration/15.0.0-16.0.0.sql | 2 +- .../mysql/tables/llx_inventorydet-stock.sql | 4 +- .../inventory/class/inventory.class.php | 4 ++ htdocs/product/inventory/inventory.php | 62 +++++++++++++------ 4 files changed, 51 insertions(+), 21 deletions(-) diff --git a/htdocs/install/mysql/migration/15.0.0-16.0.0.sql b/htdocs/install/mysql/migration/15.0.0-16.0.0.sql index 85d8763a4fe..2667ac03e0e 100644 --- a/htdocs/install/mysql/migration/15.0.0-16.0.0.sql +++ b/htdocs/install/mysql/migration/15.0.0-16.0.0.sql @@ -238,5 +238,5 @@ ALTER TABLE llx_advtargetemailing RENAME TO llx_mailing_advtarget; ALTER TABLE llx_mailing ADD UNIQUE uk_mailing(titre, entity); ALTER TABLE llx_inventorydet ADD COLUMN pmp_real double DEFAULT NULL; -ALTER TABLE llx_inventorydet ADD COLUMN valuation_real double DEFAULT NULL; +ALTER TABLE llx_inventorydet ADD COLUMN pmp_expected double DEFAULT NULL; diff --git a/htdocs/install/mysql/tables/llx_inventorydet-stock.sql b/htdocs/install/mysql/tables/llx_inventorydet-stock.sql index 5ce878124b6..8999b0e298b 100644 --- a/htdocs/install/mysql/tables/llx_inventorydet-stock.sql +++ b/htdocs/install/mysql/tables/llx_inventorydet-stock.sql @@ -29,8 +29,8 @@ CREATE TABLE llx_inventorydet qty_stock double DEFAULT NULL, -- Value or real stock we have, when we start the inventory (may be updated during intermediary steps). qty_view double DEFAULT NULL, -- Quantity found during inventory. It is the targeted value, filled during edition of inventory. qty_regulated double DEFAULT NULL, -- Never used. Deprecated because we already have the fk_movement now. - pmp_real double DEFAULT NULL, -- Never used. Deprecated because we already have the fk_movement now. - valuation_real double DEFAULT NULL, -- Never used. Deprecated because we already have the fk_movement now. + pmp_real double DEFAULT NULL, + pmp_expected double DEFAULT NULL, fk_movement integer NULL -- can contain the id of stock movement we recorded to make the inventory regulation of this line ) ENGINE=innodb; diff --git a/htdocs/product/inventory/class/inventory.class.php b/htdocs/product/inventory/class/inventory.class.php index 92061972e60..81300d6bac8 100644 --- a/htdocs/product/inventory/class/inventory.class.php +++ b/htdocs/product/inventory/class/inventory.class.php @@ -755,6 +755,8 @@ class InventoryLine extends CommonObjectLine 'qty_stock' => array('type'=>'double', 'label'=>'QtyFound', 'visible'=>1, 'enabled'=>1, 'position'=>32, 'index'=>1, 'help'=>'Qty we found/want (to define during draft edition)'), 'qty_view' => array('type'=>'double', 'label'=>'QtyBefore', 'visible'=>1, 'enabled'=>1, 'position'=>33, 'index'=>1, 'help'=>'Qty before (filled once movements are validated)'), 'qty_regulated' => array('type'=>'double', 'label'=>'QtyDelta', 'visible'=>1, 'enabled'=>1, 'position'=>34, 'index'=>1, 'help'=>'Qty aadded or removed (filled once movements are validated)'), + 'pmp_real' => array('type'=>'double', 'label'=>'PMPReal', 'visible'=>1, 'enabled'=>1, 'position'=>35), + 'pmp_expected' => array('type'=>'double', 'label'=>'PMPExpected', 'visible'=>1, 'enabled'=>1, 'position'=>36), ); /** @@ -771,6 +773,8 @@ class InventoryLine extends CommonObjectLine public $qty_stock; public $qty_view; public $qty_regulated; + public $pmp_real; + public $pmp_expected; /** diff --git a/htdocs/product/inventory/inventory.php b/htdocs/product/inventory/inventory.php index 06c8ae0d2f5..b593fc1b414 100644 --- a/htdocs/product/inventory/inventory.php +++ b/htdocs/product/inventory/inventory.php @@ -127,7 +127,7 @@ if (empty($reshook)) { $db->begin(); $sql = 'SELECT id.rowid, id.datec as date_creation, id.tms as date_modification, id.fk_inventory, id.fk_warehouse,'; - $sql .= ' id.fk_product, id.batch, id.qty_stock, id.qty_view, id.qty_regulated'; + $sql .= ' id.fk_product, id.batch, id.qty_stock, id.qty_view, id.qty_regulated, id.pmp_real'; $sql .= ' FROM '.MAIN_DB_PREFIX.'inventorydet as id'; $sql .= ' WHERE id.fk_inventory = '.((int) $object->id); @@ -176,14 +176,26 @@ if (empty($reshook)) { $datemovement = ''; //$inventorycode = 'INV'.$object->id; $inventorycode = 'INV-'.$object->ref; + $price = 0; + if(!empty($line->pmp_real) && !empty($conf->global->INVENTORY_MANAGE_REAL_PMP)) $price = $line->pmp_real; - $idstockmove = $stockmovment->_create($user, $line->fk_product, $line->fk_warehouse, $stock_movement_qty, $movement_type, 0, $langs->trans('LabelOfInventoryMovemement', $object->ref), $inventorycode, $datemovement, '', '', $line->batch); + $idstockmove = $stockmovment->_create($user, $line->fk_product, $line->fk_warehouse, $stock_movement_qty, $movement_type, $price, $langs->trans('LabelOfInventoryMovemement', $object->ref), $inventorycode, $datemovement, '', '', $line->batch); if ($idstockmove < 0) { $error++; setEventMessages($stockmovment->error, $stockmovment->errors, 'errors'); break; } + if(!empty($line->pmp_real) && !empty($conf->global->INVENTORY_MANAGE_REAL_PMP)) { + $sqlpmp = 'UPDATE '.MAIN_DB_PREFIX.'product SET pmp = '.((float) $line->pmp_real).' WHERE rowid = '.((int) $line->fk_product); + $resqlpmp = $db->query($sqlpmp); + if(! $resqlpmp) { + $error++; + setEventMessages($db->lasterror(), null, 'errors'); + break; + } + } + // Update line with id of stock movement (and the start quantity if it has changed this last recording) $sqlupdate = "UPDATE ".MAIN_DB_PREFIX."inventorydet"; $sqlupdate .= " SET fk_movement = ".((int) $idstockmove); @@ -247,6 +259,8 @@ if (empty($reshook)) { if ($result > 0) { $inventoryline->qty_stock = price2num(GETPOST('stock_qty_'.$lineid, 'alpha'), 'MS'); // The new value that was set in as hidden field $inventoryline->qty_view = $qtytoupdate; // The new value we want + $inventoryline->pmp_real = price2num(GETPOST('realpmp_'.$lineid, 'alpha'), 'MS'); + $inventoryline->pmp_expected = price2num(GETPOST('expectedpmp_'.$lineid, 'alpha'), 'MS'); $resultupdate = $inventoryline->update($user); } } else { @@ -584,6 +598,7 @@ if ($object->id > 0) { var object = $(this)[0]; var objecttofill = $("#"+object.id+"_input")[0]; objecttofill.value = object.innerText; + jQuery(".realqty").trigger("change"); }) console.log("Values filled (after click on fillwithexpected)"); disablebuttonmakemovementandclose(); @@ -829,6 +844,7 @@ if ($object->id > 0) { $("#clearqty").on("click", function() { console.log("Clear all values"); jQuery(".realqty").val(""); + jQuery(".realqty").trigger("change"); return false; /* disable submit */ }); $(".undochangesqty").on("click", function undochangesqty() { @@ -919,7 +935,7 @@ if ($object->id > 0) { // Request to show lines of inventory (prefilled after start/validate step) $sql = 'SELECT id.rowid, id.datec as date_creation, id.tms as date_modification, id.fk_inventory, id.fk_warehouse,'; - $sql .= ' id.fk_product, id.batch, id.qty_stock, id.qty_view, id.qty_regulated, id.fk_movement, id.pmp_real, id.valuation_real'; + $sql .= ' id.fk_product, id.batch, id.qty_stock, id.qty_view, id.qty_regulated, id.fk_movement, id.pmp_real, id.pmp_expected'; $sql .= ' FROM '.MAIN_DB_PREFIX.'inventorydet as id'; $sql .= ' WHERE id.fk_inventory = '.((int) $object->id); @@ -1007,9 +1023,12 @@ if ($object->id > 0) { print ''; if(! empty($conf->global->INVENTORY_MANAGE_REAL_PMP)) { //PMP Expected - $pmp_valuation = $product_static->pmp * $valuetoshow; + if(! empty($obj->pmp_expected)) $pmp_expected = $obj->pmp_expected; + else $pmp_expected = $product_static->pmp; + $pmp_valuation = $pmp_expected * $valuetoshow; print ''; - print price($product_static->pmp); + print price($pmp_expected); + print ''; print ''; print ''; print price($pmp_valuation); @@ -1021,10 +1040,10 @@ if ($object->id > 0) { if(! empty($obj->pmp_real)) $pmp_real = $obj->pmp_real; else $pmp_real = $product_static->pmp; $pmp_valuation_real = $pmp_real * $qty_view; - print ''; + print ''; print ''; print ''; - print ''; + print ''; print ''; $totalExpectedValuation += $pmp_valuation; @@ -1043,10 +1062,11 @@ if ($object->id > 0) { print ''; if(!empty($conf->global->INVENTORY_MANAGE_REAL_PMP)) { //PMP Expected - $pmp_valuation = $product_static->pmp * $valuetoshow; - $pmp_valuation_real = $pmp_real * $obj->qty_view; + if(! empty($obj->pmp_expected)) $pmp_expected = $obj->pmp_expected; + else $pmp_expected = $product_static->pmp; + $pmp_valuation = $pmp_expected * $valuetoshow; print ''; - print price($product_static->pmp); + print price($pmp_expected); print ''; print ''; print price($pmp_valuation); @@ -1056,6 +1076,7 @@ if ($object->id > 0) { print ''; if(! empty($obj->pmp_real)) $pmp_real = $obj->pmp_real; else $pmp_real = $product_static->pmp; + $pmp_valuation_real = $pmp_real * $obj->qty_view; print price($pmp_real); print ''; print ''; @@ -1117,25 +1138,26 @@ if ($object->id > 0) { Date: Tue, 22 Feb 2022 10:06:05 +0100 Subject: [PATCH 06/59] WIP dolGetButtonAction --- htdocs/societe/card.php | 48 +++++++++++++++++++++++++++++++---------- 1 file changed, 37 insertions(+), 11 deletions(-) diff --git a/htdocs/societe/card.php b/htdocs/societe/card.php index b6c483fc026..d99f080ed24 100644 --- a/htdocs/societe/card.php +++ b/htdocs/societe/card.php @@ -2444,10 +2444,29 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { $formconfirm = ''; // Confirm delete third party - if ($action == 'delete' || ($conf->use_javascript_ajax && empty($conf->dol_use_jmobile))) { - $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"]."?socid=".$object->id, $langs->trans("DeleteACompany"), $langs->trans("ConfirmDeleteCompany"), "confirm_delete", '', 0, "action-delete"); +// if ($action == 'delete' ) { +// var_dump("dlzk,dmz,kdml,zdzd"); +// +// +// $formconfirm .= $form->formconfirm($_SERVER["PHP_SELF"]."?socid=".$object->id, $langs->trans("DeleteACompany"), $langs->trans("ConfirmDeleteCompany"), "confirm_delete", '', 0, "action-delete"); +// print $formconfirm; +// } + + + if ($action == 'delete') { + $formquestion = array( + array( + 'label' => $langs->trans('M456465645y'), + 'value' => 'yes', + ) + ); + + $formconfirm .= $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('DeleteThirdParty'), $langs->trans('ConfirmDeleteCompany'), 'confirm_delete', '', 0, 2); } + + + if ($action == 'merge') { $formquestion = array( array( @@ -2910,15 +2929,25 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { if (empty($user->socid)) { if (!empty($object->email) || $at_least_one_email_contact) { $langs->load("mails"); + //TODO replace to dolGetButtonAction + $params = array( + 'attr' => array( + 'title' => '' + ) + ); print ''.$langs->trans('SendMail').''."\n"; + print dolGetButtonAction($langs->trans('SendMaiAl'), '', 'default', $_SERVER['PHP_SELF'].'?socid='.$object->id.'&action=presend&mode=init#formmailbeforetitle', '',true,$params); } else { $langs->load("mails"); + //TODO replace to dolGetButtonAction print ''.$langs->trans('SendMail').''."\n"; + print dolGetButtonAction($langs->trans('SendMaiAl'), '', 'default', $_SERVER['PHP_SELF'].'?socid='.$object->id.'&action=presend&mode=init#formmailbeforetitle'.newToken(), '',false); } } if ($user->rights->societe->creer) { - print ''.$langs->trans("Modify").''."\n"; + //TODO MODIFIER OK + print dolGetButtonAction($langs->trans('Modify'), '', 'default', $_SERVER["PHP_SELF"].'?socid='.$object->id.'&action=edit&token='.newToken(), '', $permissiontoadd); } if (!empty($conf->adherent->enabled)) { @@ -2930,16 +2959,13 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { } if ($user->rights->societe->supprimer) { - print ''.$langs->trans('Merge').''."\n"; - } + //TODO FUSIONNER OK + print dolGetButtonAction($langs->trans('MergeThirdparties'), '', 'danger', $_SERVER["PHP_SELF"].'?socid='.$object->id.'&action=merge&token='.newToken(), '', $permissiontoadd); + - if ($user->rights->societe->supprimer) { - if ($conf->use_javascript_ajax && empty($conf->dol_use_jmobile)) { // We can't use preloaded confirm form with jmobile - print ''.$langs->trans('Delete').''."\n"; - } else { - print ''.$langs->trans('Delete').''."\n"; - } } + //TODO SUPPRIMER OK + print dolGetButtonAction($langs->trans('Delete'), '', 'delete', $_SERVER["PHP_SELF"].'?socid='.$object->id.'&action=delete&token='.newToken(), '', $user->rights->societe->supprimer); } print ''."\n"; From b05a5d63b210f3b341bf3017ce0edc3a56d3575d Mon Sep 17 00:00:00 2001 From: GregM Date: Tue, 22 Feb 2022 11:28:33 +0100 Subject: [PATCH 07/59] WIP dolGetButtonAction --- htdocs/societe/card.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/htdocs/societe/card.php b/htdocs/societe/card.php index d99f080ed24..9b097bfab99 100644 --- a/htdocs/societe/card.php +++ b/htdocs/societe/card.php @@ -2929,14 +2929,14 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { if (empty($user->socid)) { if (!empty($object->email) || $at_least_one_email_contact) { $langs->load("mails"); - //TODO replace to dolGetButtonAction + //TODO ENVOYER EMAIL $params = array( 'attr' => array( 'title' => '' ) ); - print ''.$langs->trans('SendMail').''."\n"; - print dolGetButtonAction($langs->trans('SendMaiAl'), '', 'default', $_SERVER['PHP_SELF'].'?socid='.$object->id.'&action=presend&mode=init#formmailbeforetitle', '',true,$params); + //print ''.$langs->trans('SendMail').''."\n"; + print dolGetButtonAction($langs->trans('SendMail'), '', 'default', $_SERVER['PHP_SELF'].'?socid='.$object->id.'&action=presend&mode=init#formmailbeforetitle', '',true,$params); } else { $langs->load("mails"); //TODO replace to dolGetButtonAction @@ -2947,7 +2947,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { if ($user->rights->societe->creer) { //TODO MODIFIER OK - print dolGetButtonAction($langs->trans('Modify'), '', 'default', $_SERVER["PHP_SELF"].'?socid='.$object->id.'&action=edit&token='.newToken(), '', $permissiontoadd); + print dolGetButtonAction($langs->trans('Modify'), '', 'default', $_SERVER["PHP_SELF"].'?socid='.$object->id.'&action=edit&token='.newToken(), '', $permissiontoadd,$params); } if (!empty($conf->adherent->enabled)) { @@ -2965,7 +2965,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { } //TODO SUPPRIMER OK - print dolGetButtonAction($langs->trans('Delete'), '', 'delete', $_SERVER["PHP_SELF"].'?socid='.$object->id.'&action=delete&token='.newToken(), '', $user->rights->societe->supprimer); + print dolGetButtonAction($langs->trans('Delete'), '', 'delete', $_SERVER["PHP_SELF"].'?socid='.$object->id.'&action=delete&token='.newToken(), '', $user->rights->societe->supprimer,$params); } print ''."\n"; From 69bb3aaad19884c7c54bae6f9238329899ec692e Mon Sep 17 00:00:00 2001 From: GregM Date: Tue, 22 Feb 2022 11:35:55 +0100 Subject: [PATCH 08/59] WIP dolGetButtonAction --- htdocs/societe/card.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/societe/card.php b/htdocs/societe/card.php index 9b097bfab99..ece24428a2e 100644 --- a/htdocs/societe/card.php +++ b/htdocs/societe/card.php @@ -2940,8 +2940,8 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { } else { $langs->load("mails"); //TODO replace to dolGetButtonAction - print ''.$langs->trans('SendMail').''."\n"; - print dolGetButtonAction($langs->trans('SendMaiAl'), '', 'default', $_SERVER['PHP_SELF'].'?socid='.$object->id.'&action=presend&mode=init#formmailbeforetitle'.newToken(), '',false); + //print ''.$langs->trans('SendMail').''."\n"; + print dolGetButtonAction($langs->trans('SendMail'), '', 'default', $_SERVER['PHP_SELF'].'?socid='.$object->id.'&action=presend&mode=init#formmailbeforetitle'.newToken(), '',false); } } @@ -2960,7 +2960,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { if ($user->rights->societe->supprimer) { //TODO FUSIONNER OK - print dolGetButtonAction($langs->trans('MergeThirdparties'), '', 'danger', $_SERVER["PHP_SELF"].'?socid='.$object->id.'&action=merge&token='.newToken(), '', $permissiontoadd); + print dolGetButtonAction($langs->trans('MergeThirdparties'), '', 'danger', $_SERVER["PHP_SELF"].'?socid='.$object->id.'&action=merge&token='.newToken(), '', $permissiontoadd, $params); } From b0473c475a2d62518605bf79ce2866cd59a85128 Mon Sep 17 00:00:00 2001 From: GregM Date: Tue, 22 Feb 2022 11:48:35 +0100 Subject: [PATCH 09/59] wip dolGetButtonAction --- htdocs/societe/card.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/societe/card.php b/htdocs/societe/card.php index ece24428a2e..7123bd1d18c 100644 --- a/htdocs/societe/card.php +++ b/htdocs/societe/card.php @@ -2941,7 +2941,8 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { $langs->load("mails"); //TODO replace to dolGetButtonAction //print ''.$langs->trans('SendMail').''."\n"; - print dolGetButtonAction($langs->trans('SendMail'), '', 'default', $_SERVER['PHP_SELF'].'?socid='.$object->id.'&action=presend&mode=init#formmailbeforetitle'.newToken(), '',false); + $params['attr']['title'] = $langs->trans('NoEMail'); + print dolGetButtonAction($langs->trans('SendMail'), '', 'default', $_SERVER['PHP_SELF'].'?socid='.$object->id.'&action=presend&mode=init#formmailbeforetitle'.newToken(), '',false,$params); } } From 059548105c83d0b1d06aa7c85e68c99f4fec01b5 Mon Sep 17 00:00:00 2001 From: GregM Date: Tue, 22 Feb 2022 12:14:18 +0100 Subject: [PATCH 10/59] WIP dolGetButtonAction --- htdocs/societe/card.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/societe/card.php b/htdocs/societe/card.php index 7123bd1d18c..4a3a33af83f 100644 --- a/htdocs/societe/card.php +++ b/htdocs/societe/card.php @@ -2948,7 +2948,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { if ($user->rights->societe->creer) { //TODO MODIFIER OK - print dolGetButtonAction($langs->trans('Modify'), '', 'default', $_SERVER["PHP_SELF"].'?socid='.$object->id.'&action=edit&token='.newToken(), '', $permissiontoadd,$params); + print dolGetButtonAction($langs->trans('Modify'), '', 'default', $_SERVER["PHP_SELF"].'?socid='.$object->id.'&action=edit&token='.newToken(), '', $permissiontoadd); } if (!empty($conf->adherent->enabled)) { @@ -2961,12 +2961,12 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { if ($user->rights->societe->supprimer) { //TODO FUSIONNER OK - print dolGetButtonAction($langs->trans('MergeThirdparties'), '', 'danger', $_SERVER["PHP_SELF"].'?socid='.$object->id.'&action=merge&token='.newToken(), '', $permissiontoadd, $params); + print dolGetButtonAction($langs->trans('MergeThirdparties'), $langs->trans('Merge'), 'danger', $_SERVER["PHP_SELF"].'?socid='.$object->id.'&action=merge&token='.newToken(), '', $permissiontoadd); } //TODO SUPPRIMER OK - print dolGetButtonAction($langs->trans('Delete'), '', 'delete', $_SERVER["PHP_SELF"].'?socid='.$object->id.'&action=delete&token='.newToken(), '', $user->rights->societe->supprimer,$params); + print dolGetButtonAction('', $langs->trans('Delete'),'delete', $_SERVER["PHP_SELF"].'?socid='.$object->id.'&action=delete&token='.newToken(), '', $user->rights->societe->supprimer); } print ''."\n"; From e21a9bdd7d832f6ef859af6e0c716f7170c68b78 Mon Sep 17 00:00:00 2001 From: GregM Date: Wed, 23 Feb 2022 09:25:43 +0100 Subject: [PATCH 11/59] WIP dolGetButtonAction lib --- htdocs/core/lib/functions.lib.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 7be3f5e3351..9a866303eb3 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -9965,6 +9965,7 @@ function dolGetButtonAction($label, $html = '', $actionType = 'default', $url = if (empty($html)) { $html = $label; + $attr['title'] = ''; // if html not set, leave label on title is redundant } else { $attr['aria-label'] = $label; } From 5dcb4c85ee0ced5776dcf6aec36e4d48d5113297 Mon Sep 17 00:00:00 2001 From: GregM Date: Wed, 23 Feb 2022 10:03:48 +0100 Subject: [PATCH 12/59] fix dolGetButtonAction societe card --- htdocs/societe/card.php | 24 +++--------------------- 1 file changed, 3 insertions(+), 21 deletions(-) diff --git a/htdocs/societe/card.php b/htdocs/societe/card.php index 4a3a33af83f..8c1c0102e30 100644 --- a/htdocs/societe/card.php +++ b/htdocs/societe/card.php @@ -2444,15 +2444,6 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { $formconfirm = ''; // Confirm delete third party -// if ($action == 'delete' ) { -// var_dump("dlzk,dmz,kdml,zdzd"); -// -// -// $formconfirm .= $form->formconfirm($_SERVER["PHP_SELF"]."?socid=".$object->id, $langs->trans("DeleteACompany"), $langs->trans("ConfirmDeleteCompany"), "confirm_delete", '', 0, "action-delete"); -// print $formconfirm; -// } - - if ($action == 'delete') { $formquestion = array( array( @@ -2929,25 +2920,20 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { if (empty($user->socid)) { if (!empty($object->email) || $at_least_one_email_contact) { $langs->load("mails"); - //TODO ENVOYER EMAIL $params = array( 'attr' => array( 'title' => '' ) ); - //print ''.$langs->trans('SendMail').''."\n"; - print dolGetButtonAction($langs->trans('SendMail'), '', 'default', $_SERVER['PHP_SELF'].'?socid='.$object->id.'&action=presend&mode=init#formmailbeforetitle', '',true,$params); + print dolGetButtonAction($langs->trans('SendMail'), '', 'default', $_SERVER['PHP_SELF'].'?socid='.$object->id.'&action=presend&mode=init#formmailbeforetitle', '', true, $params); } else { $langs->load("mails"); - //TODO replace to dolGetButtonAction - //print ''.$langs->trans('SendMail').''."\n"; $params['attr']['title'] = $langs->trans('NoEMail'); - print dolGetButtonAction($langs->trans('SendMail'), '', 'default', $_SERVER['PHP_SELF'].'?socid='.$object->id.'&action=presend&mode=init#formmailbeforetitle'.newToken(), '',false,$params); + print dolGetButtonAction($langs->trans('SendMail'), '', 'default', $_SERVER['PHP_SELF'].'?socid='.$object->id.'&action=presend&mode=init#formmailbeforetitle'.newToken(), '', false, $params); } } if ($user->rights->societe->creer) { - //TODO MODIFIER OK print dolGetButtonAction($langs->trans('Modify'), '', 'default', $_SERVER["PHP_SELF"].'?socid='.$object->id.'&action=edit&token='.newToken(), '', $permissiontoadd); } @@ -2960,13 +2946,9 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { } if ($user->rights->societe->supprimer) { - //TODO FUSIONNER OK print dolGetButtonAction($langs->trans('MergeThirdparties'), $langs->trans('Merge'), 'danger', $_SERVER["PHP_SELF"].'?socid='.$object->id.'&action=merge&token='.newToken(), '', $permissiontoadd); - - } - //TODO SUPPRIMER OK - print dolGetButtonAction('', $langs->trans('Delete'),'delete', $_SERVER["PHP_SELF"].'?socid='.$object->id.'&action=delete&token='.newToken(), '', $user->rights->societe->supprimer); + print dolGetButtonAction('', $langs->trans('Delete'), 'delete', $_SERVER["PHP_SELF"].'?socid='.$object->id.'&action=delete&token='.newToken(), '', $user->rights->societe->supprimer); } print ''."\n"; From f866f9641e1898c6178cd3004894955891709532 Mon Sep 17 00:00:00 2001 From: GregM Date: Wed, 23 Feb 2022 10:12:43 +0100 Subject: [PATCH 13/59] update change on another PR --- htdocs/core/lib/functions.lib.php | 1 - 1 file changed, 1 deletion(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 9a866303eb3..7be3f5e3351 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -9965,7 +9965,6 @@ function dolGetButtonAction($label, $html = '', $actionType = 'default', $url = if (empty($html)) { $html = $label; - $attr['title'] = ''; // if html not set, leave label on title is redundant } else { $attr['aria-label'] = $label; } From b95460844396600d4f49b1cf5206233e24a0ce41 Mon Sep 17 00:00:00 2001 From: GregM Date: Wed, 23 Feb 2022 12:09:15 +0100 Subject: [PATCH 14/59] Update card --- htdocs/societe/card.php | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/htdocs/societe/card.php b/htdocs/societe/card.php index 8c1c0102e30..995e731cdca 100644 --- a/htdocs/societe/card.php +++ b/htdocs/societe/card.php @@ -2447,12 +2447,11 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { if ($action == 'delete') { $formquestion = array( array( - 'label' => $langs->trans('M456465645y'), 'value' => 'yes', ) ); - $formconfirm .= $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('DeleteThirdParty'), $langs->trans('ConfirmDeleteCompany'), 'confirm_delete', '', 0, 2); + $formconfirm .= $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('DeleteACompany'), $langs->trans('ConfirmDeleteCompany'), 'confirm_delete', '', 0, 2); } @@ -2933,9 +2932,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { } } - if ($user->rights->societe->creer) { - print dolGetButtonAction($langs->trans('Modify'), '', 'default', $_SERVER["PHP_SELF"].'?socid='.$object->id.'&action=edit&token='.newToken(), '', $permissiontoadd); - } + print dolGetButtonAction('', $langs->trans('Modify'), 'default', $_SERVER["PHP_SELF"].'?socid='.$object->id.'&action=edit&token='.newToken(), '', $permissiontoadd); if (!empty($conf->adherent->enabled)) { $adh = new Adherent($db); @@ -2945,10 +2942,15 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { } } + print dolGetButtonAction($langs->trans('MergeThirdparties'), $langs->trans('Merge'), 'danger', $_SERVER["PHP_SELF"].'?socid='.$object->id.'&action=merge&token='.newToken(), '', $permissiontodelete); + if ($user->rights->societe->supprimer) { - print dolGetButtonAction($langs->trans('MergeThirdparties'), $langs->trans('Merge'), 'danger', $_SERVER["PHP_SELF"].'?socid='.$object->id.'&action=merge&token='.newToken(), '', $permissiontoadd); + if ($conf->use_javascript_ajax && empty($conf->dol_use_jmobile)) { // We can't use preloaded confirm form with jmobile + print dolGetButtonAction('', $langs->trans('Delete'), 'delete', $_SERVER["PHP_SELF"].'?socid='.$object->id.'&action=delete&token='.newToken(), 'action-delete', $permissiontodelete); + } else { + print dolGetButtonAction('', $langs->trans('Delete'), 'delete', $_SERVER["PHP_SELF"].'?socid='.$object->id.'&action=delete&token='.newToken(), '', $permissiontodelete); + } } - print dolGetButtonAction('', $langs->trans('Delete'), 'delete', $_SERVER["PHP_SELF"].'?socid='.$object->id.'&action=delete&token='.newToken(), '', $user->rights->societe->supprimer); } print ''."\n"; From 74bfdb0842f9e45b8e5a9e1b653ff7f00bcedc10 Mon Sep 17 00:00:00 2001 From: GregM Date: Wed, 23 Feb 2022 15:34:17 +0100 Subject: [PATCH 15/59] fix retour --- htdocs/societe/card.php | 25 +++++++++---------------- 1 file changed, 9 insertions(+), 16 deletions(-) diff --git a/htdocs/societe/card.php b/htdocs/societe/card.php index 995e731cdca..3a9fcaff07b 100644 --- a/htdocs/societe/card.php +++ b/htdocs/societe/card.php @@ -2917,19 +2917,10 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { } if (empty($user->socid)) { - if (!empty($object->email) || $at_least_one_email_contact) { - $langs->load("mails"); - $params = array( - 'attr' => array( - 'title' => '' - ) - ); - print dolGetButtonAction($langs->trans('SendMail'), '', 'default', $_SERVER['PHP_SELF'].'?socid='.$object->id.'&action=presend&mode=init#formmailbeforetitle', '', true, $params); - } else { - $langs->load("mails"); - $params['attr']['title'] = $langs->trans('NoEMail'); - print dolGetButtonAction($langs->trans('SendMail'), '', 'default', $_SERVER['PHP_SELF'].'?socid='.$object->id.'&action=presend&mode=init#formmailbeforetitle'.newToken(), '', false, $params); - } + $langs->load("mails"); + $title = ''; + if (empty($object->email) && !$at_least_one_email_contact) { $title = $langs->trans('NoEMail'); } + print dolGetButtonAction($title, $langs->trans('SendMail'), 'default', $_SERVER['PHP_SELF'].'?socid='.$object->id.'&action=presend&mode=init#formmailbeforetitle', 'btn-send-mail', !empty($object->email) || $at_least_one_email_contact); } print dolGetButtonAction('', $langs->trans('Modify'), 'default', $_SERVER["PHP_SELF"].'?socid='.$object->id.'&action=edit&token='.newToken(), '', $permissiontoadd); @@ -2945,11 +2936,13 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { print dolGetButtonAction($langs->trans('MergeThirdparties'), $langs->trans('Merge'), 'danger', $_SERVER["PHP_SELF"].'?socid='.$object->id.'&action=merge&token='.newToken(), '', $permissiontodelete); if ($user->rights->societe->supprimer) { + $deleteUrl = $_SERVER["PHP_SELF"].'?socid='.$object->id.'&action=delete&token='.newToken(); + $buttonId = 'action-delete-no-ajax'; if ($conf->use_javascript_ajax && empty($conf->dol_use_jmobile)) { // We can't use preloaded confirm form with jmobile - print dolGetButtonAction('', $langs->trans('Delete'), 'delete', $_SERVER["PHP_SELF"].'?socid='.$object->id.'&action=delete&token='.newToken(), 'action-delete', $permissiontodelete); - } else { - print dolGetButtonAction('', $langs->trans('Delete'), 'delete', $_SERVER["PHP_SELF"].'?socid='.$object->id.'&action=delete&token='.newToken(), '', $permissiontodelete); + $deleteUrl = ''; + $buttonId = 'action-delete'; } + print dolGetButtonAction($langs->trans('Delete'), '', 'delete', $deleteUrl, $buttonId, $permissiontodelete); } } From 114827934eac8374cfa02f627f282f9139ba9305 Mon Sep 17 00:00:00 2001 From: GregM Date: Wed, 23 Feb 2022 15:51:44 +0100 Subject: [PATCH 16/59] Fix merge conflict --- htdocs/societe/card.php | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/htdocs/societe/card.php b/htdocs/societe/card.php index d598e310aaf..25b48936341 100644 --- a/htdocs/societe/card.php +++ b/htdocs/societe/card.php @@ -2455,19 +2455,10 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { $formconfirm = ''; // Confirm delete third party - if ($action == 'delete') { - $formquestion = array( - array( - 'value' => 'yes', - ) - ); - - $formconfirm .= $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('DeleteACompany'), $langs->trans('ConfirmDeleteCompany'), 'confirm_delete', '', 0, 2); + if ($action == 'delete' || ($conf->use_javascript_ajax && empty($conf->dol_use_jmobile))) { + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"]."?socid=".$object->id, $langs->trans("DeleteACompany"), $langs->trans("ConfirmDeleteCompany"), "confirm_delete", '', 0, "action-delete"); } - - - if ($action == 'merge') { $formquestion = array( array( From 6462fd83067f07f9a7a667fcd3f7b55668be0c4a Mon Sep 17 00:00:00 2001 From: Quentin VIAL-GOUTEYRON Date: Mon, 28 Mar 2022 16:02:18 +0200 Subject: [PATCH 17/59] update pmp real even if it's not edit --- htdocs/product/inventory/inventory.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/htdocs/product/inventory/inventory.php b/htdocs/product/inventory/inventory.php index 536aaf7d354..895ff8105cd 100644 --- a/htdocs/product/inventory/inventory.php +++ b/htdocs/product/inventory/inventory.php @@ -268,6 +268,8 @@ if (empty($reshook)) { $result = $inventoryline->fetch($lineid); if ($result > 0) { $inventoryline->qty_view = null; // The new value we want + $inventoryline->pmp_real = price2num(GETPOST('realpmp_'.$lineid, 'alpha'), 'MS'); + $inventoryline->pmp_expected = price2num(GETPOST('expectedpmp_'.$lineid, 'alpha'), 'MS'); $resultupdate = $inventoryline->update($user); } } From ca7ecfbb579e6115b78698ef16ddde56d5bc5076 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Tue, 29 Mar 2022 11:06:18 +0200 Subject: [PATCH 18/59] FIX avoid warning for missing cookie samesite params (and more secure) --- htdocs/main.inc.php | 32 ++++++++++++++++++++++++++++---- 1 file changed, 28 insertions(+), 4 deletions(-) diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index fe0986e8d13..c13f7cbe2c9 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -265,10 +265,22 @@ if (!empty($_POST["DOL_AUTOSET_COOKIE"])) { $cookiearrayvalue[$tmpkey] = $_POST[$postkey]; } } - $cookiename = $tmpautoset[0]; + $cookiename = (empty($dolibarr_main_force_https) ? $tmpautoset[0] : '__Secure-'.$tmpautoset[0]); // __Secure- || __Host- $cookievalue = json_encode($cookiearrayvalue); //var_dump('setcookie cookiename='.$cookiename.' cookievalue='.$cookievalue); - setcookie($cookiename, empty($cookievalue) ? '' : $cookievalue, empty($cookievalue) ? 0 : (time() + (86400 * 354)), '/', null, (empty($dolibarr_main_force_https) ? false : true), true); // keep cookie 1 year and add tag httponly + if (PHP_VERSION_ID < 70300) { + setcookie($cookiename, empty($cookievalue) ? '' : $cookievalue, empty($cookievalue) ? 0 : (time() + (86400 * 354)), '/', null, (empty($dolibarr_main_force_https) ? false : true), true); // keep cookie 1 year and add tag httponly + } else { + $cookieparams = array( + 'expires' => empty($cookievalue) ? 0 : (time() + (86400 * 354)), + 'path' => '/', + //'domain' => '.mywebsite.com', // the dot at the beginning allows compatibility with subdomains + 'secure' => (empty($dolibarr_main_force_https) ? false : true), + 'httponly' => true, + 'samesite' => 'Lax' // None || Lax || Strict + ); + setcookie($cookiename, empty($cookievalue) ? '' : $cookievalue, $cookieparams); + } if (empty($cookievalue)) { unset($_COOKIE[$cookiename]); } @@ -284,7 +296,7 @@ if (!empty($php_session_save_handler) && $php_session_save_handler == 'db') { // Must be done after the include of filefunc.inc.php so global variables of conf file are defined (like $dolibarr_main_instance_unique_id or $dolibarr_main_force_https). // Note: the function dol_getprefix() is defined into functions.lib.php but may have been defined to return a different key to manage another area to protect. $prefix = dol_getprefix(''); -$sessionname = 'DOLSESSID_'.$prefix; +$sessionname = (empty($dolibarr_main_force_https) ? 'DOLSESSID_'.$prefix : '__Secure-DOLSESSID_'.$prefix); // __Secure- || __Host- $sessiontimeout = 'DOLSESSTIMEOUT_'.$prefix; if (!empty($_COOKIE[$sessiontimeout])) { ini_set('session.gc_maxlifetime', $_COOKIE[$sessiontimeout]); @@ -293,7 +305,19 @@ if (!empty($_COOKIE[$sessiontimeout])) { // This create lock, released by session_write_close() or end of page. // We need this lock as long as we read/write $_SESSION ['vars']. We can remove lock when finished. if (!defined('NOSESSION')) { - session_set_cookie_params(0, '/', null, (empty($dolibarr_main_force_https) ? false : true), true); // Add tag secure and httponly on session cookie (same as setting session.cookie_httponly into php.ini). Must be called before the session_start. + if (PHP_VERSION_ID < 70300) { + session_set_cookie_params(0, '/', null, (empty($dolibarr_main_force_https) ? false : true), true); // Add tag secure and httponly on session cookie (same as setting session.cookie_httponly into php.ini). Must be called before the session_start. + } else { + $sessioncookieparams = array( + 'lifetime' => 0, + 'path' => '/', + //'domain' => '.mywebsite.com', // the dot at the beginning allows compatibility with subdomains + 'secure' => (empty($dolibarr_main_force_https) ? false : true), + 'httponly' => true, + 'samesite' => 'Lax' // None || Lax || Strict + ); + session_set_cookie_params($sessioncookieparams); + } session_name($sessionname); session_start(); // This call the open and read of session handler //exit; // this exist generates a call to write and close From b7d6436e339a9e2653344620abd3e5567afc341a Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Tue, 29 Mar 2022 11:10:41 +0200 Subject: [PATCH 19/59] FIX add doc --- htdocs/main.inc.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index c13f7cbe2c9..eba557ffe17 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -271,6 +271,7 @@ if (!empty($_POST["DOL_AUTOSET_COOKIE"])) { if (PHP_VERSION_ID < 70300) { setcookie($cookiename, empty($cookievalue) ? '' : $cookievalue, empty($cookievalue) ? 0 : (time() + (86400 * 354)), '/', null, (empty($dolibarr_main_force_https) ? false : true), true); // keep cookie 1 year and add tag httponly } else { + // Only available for php >= 7.3 $cookieparams = array( 'expires' => empty($cookievalue) ? 0 : (time() + (86400 * 354)), 'path' => '/', @@ -308,6 +309,7 @@ if (!defined('NOSESSION')) { if (PHP_VERSION_ID < 70300) { session_set_cookie_params(0, '/', null, (empty($dolibarr_main_force_https) ? false : true), true); // Add tag secure and httponly on session cookie (same as setting session.cookie_httponly into php.ini). Must be called before the session_start. } else { + // Only available for php >= 7.3 $sessioncookieparams = array( 'lifetime' => 0, 'path' => '/', From 29a4e7c725612b08c898eb3830f23d2010ff83e3 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Tue, 29 Mar 2022 12:03:18 +0200 Subject: [PATCH 20/59] FIX check if https or not --- htdocs/main.inc.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index eba557ffe17..e66c9e9d313 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -265,18 +265,18 @@ if (!empty($_POST["DOL_AUTOSET_COOKIE"])) { $cookiearrayvalue[$tmpkey] = $_POST[$postkey]; } } - $cookiename = (empty($dolibarr_main_force_https) ? $tmpautoset[0] : '__Secure-'.$tmpautoset[0]); // __Secure- || __Host- + $cookiename = ((empty($dolibarr_main_force_https) && isHTTPS() === false) ? $tmpautoset[0] : '__Secure-'.$tmpautoset[0]); // __Secure- || __Host- $cookievalue = json_encode($cookiearrayvalue); //var_dump('setcookie cookiename='.$cookiename.' cookievalue='.$cookievalue); if (PHP_VERSION_ID < 70300) { - setcookie($cookiename, empty($cookievalue) ? '' : $cookievalue, empty($cookievalue) ? 0 : (time() + (86400 * 354)), '/', null, (empty($dolibarr_main_force_https) ? false : true), true); // keep cookie 1 year and add tag httponly + setcookie($cookiename, empty($cookievalue) ? '' : $cookievalue, empty($cookievalue) ? 0 : (time() + (86400 * 354)), '/', null, ((empty($dolibarr_main_force_https) && isHTTPS() === false) ? false : true), true); // keep cookie 1 year and add tag httponly } else { // Only available for php >= 7.3 $cookieparams = array( 'expires' => empty($cookievalue) ? 0 : (time() + (86400 * 354)), 'path' => '/', //'domain' => '.mywebsite.com', // the dot at the beginning allows compatibility with subdomains - 'secure' => (empty($dolibarr_main_force_https) ? false : true), + 'secure' => ((empty($dolibarr_main_force_https) && isHTTPS() === false) ? false : true), 'httponly' => true, 'samesite' => 'Lax' // None || Lax || Strict ); @@ -297,7 +297,7 @@ if (!empty($php_session_save_handler) && $php_session_save_handler == 'db') { // Must be done after the include of filefunc.inc.php so global variables of conf file are defined (like $dolibarr_main_instance_unique_id or $dolibarr_main_force_https). // Note: the function dol_getprefix() is defined into functions.lib.php but may have been defined to return a different key to manage another area to protect. $prefix = dol_getprefix(''); -$sessionname = (empty($dolibarr_main_force_https) ? 'DOLSESSID_'.$prefix : '__Secure-DOLSESSID_'.$prefix); // __Secure- || __Host- +$sessionname = ((empty($dolibarr_main_force_https) && isHTTPS() === false) ? 'DOLSESSID_'.$prefix : '__Secure-DOLSESSID_'.$prefix); // __Secure- || __Host- $sessiontimeout = 'DOLSESSTIMEOUT_'.$prefix; if (!empty($_COOKIE[$sessiontimeout])) { ini_set('session.gc_maxlifetime', $_COOKIE[$sessiontimeout]); @@ -307,14 +307,14 @@ if (!empty($_COOKIE[$sessiontimeout])) { // We need this lock as long as we read/write $_SESSION ['vars']. We can remove lock when finished. if (!defined('NOSESSION')) { if (PHP_VERSION_ID < 70300) { - session_set_cookie_params(0, '/', null, (empty($dolibarr_main_force_https) ? false : true), true); // Add tag secure and httponly on session cookie (same as setting session.cookie_httponly into php.ini). Must be called before the session_start. + session_set_cookie_params(0, '/', null, ((empty($dolibarr_main_force_https) && isHTTPS() === false) ? false : true), true); // Add tag secure and httponly on session cookie (same as setting session.cookie_httponly into php.ini). Must be called before the session_start. } else { // Only available for php >= 7.3 $sessioncookieparams = array( 'lifetime' => 0, 'path' => '/', //'domain' => '.mywebsite.com', // the dot at the beginning allows compatibility with subdomains - 'secure' => (empty($dolibarr_main_force_https) ? false : true), + 'secure' => ((empty($dolibarr_main_force_https) && isHTTPS() === false) ? false : true), 'httponly' => true, 'samesite' => 'Lax' // None || Lax || Strict ); From 67e7c91c3ed34b1c8a0f94c0e5032e4ee7ce8edb Mon Sep 17 00:00:00 2001 From: Quentin VIAL-GOUTEYRON Date: Mon, 11 Apr 2022 15:47:38 +0200 Subject: [PATCH 21/59] pmp inventory conf MAIN_PRODUCT_PERENTITY_SHARED --- htdocs/product/inventory/inventory.php | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/htdocs/product/inventory/inventory.php b/htdocs/product/inventory/inventory.php index 2b21de99079..77cdc965164 100644 --- a/htdocs/product/inventory/inventory.php +++ b/htdocs/product/inventory/inventory.php @@ -194,6 +194,15 @@ if (empty($reshook)) { setEventMessages($db->lasterror(), null, 'errors'); break; } + if(!empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED)) { + $sqlpmp = 'UPDATE '.MAIN_DB_PREFIX.'product_perentity SET pmp = '.((float) $line->pmp_real).' WHERE fk_product = '.((int) $line->fk_product).' AND entity='.$conf->entity; + $resqlpmp = $db->query($sqlpmp); + if (! $resqlpmp) { + $error++; + setEventMessages($db->lasterror(), null, 'errors'); + break; + } + } } // Update line with id of stock movement (and the start quantity if it has changed this last recording) From ddb50264aeb5c132ec89aa39c09c074f0b65e234 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Mon, 11 Apr 2022 13:58:59 +0000 Subject: [PATCH 22/59] Fixing style errors. --- htdocs/product/inventory/inventory.php | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/htdocs/product/inventory/inventory.php b/htdocs/product/inventory/inventory.php index 77cdc965164..9cef5671041 100644 --- a/htdocs/product/inventory/inventory.php +++ b/htdocs/product/inventory/inventory.php @@ -194,15 +194,15 @@ if (empty($reshook)) { setEventMessages($db->lasterror(), null, 'errors'); break; } - if(!empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED)) { - $sqlpmp = 'UPDATE '.MAIN_DB_PREFIX.'product_perentity SET pmp = '.((float) $line->pmp_real).' WHERE fk_product = '.((int) $line->fk_product).' AND entity='.$conf->entity; - $resqlpmp = $db->query($sqlpmp); - if (! $resqlpmp) { - $error++; - setEventMessages($db->lasterror(), null, 'errors'); - break; - } - } + if (!empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED)) { + $sqlpmp = 'UPDATE '.MAIN_DB_PREFIX.'product_perentity SET pmp = '.((float) $line->pmp_real).' WHERE fk_product = '.((int) $line->fk_product).' AND entity='.$conf->entity; + $resqlpmp = $db->query($sqlpmp); + if (! $resqlpmp) { + $error++; + setEventMessages($db->lasterror(), null, 'errors'); + break; + } + } } // Update line with id of stock movement (and the start quantity if it has changed this last recording) From 9547b9e7febb4312bd491d6d3e089d0eb7c521e3 Mon Sep 17 00:00:00 2001 From: Ferran Marcet Date: Mon, 11 Apr 2022 18:01:25 +0200 Subject: [PATCH 23/59] Fix: Online signature of proposals does not work well with multicompany --- htdocs/core/ajax/onlineSign.php | 4 ++++ htdocs/public/onlinesign/newonlinesign.php | 3 ++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/htdocs/core/ajax/onlineSign.php b/htdocs/core/ajax/onlineSign.php index 5110918541f..ce9ae57864d 100644 --- a/htdocs/core/ajax/onlineSign.php +++ b/htdocs/core/ajax/onlineSign.php @@ -48,6 +48,10 @@ if (!defined('NOIPCHECK')) { if (!defined('NOBROWSERNOTIF')) { define('NOBROWSERNOTIF', '1'); } +$entity = (!empty($_GET['entity']) ? (int) $_GET['entity'] : (!empty($_POST['entity']) ? (int) $_POST['entity'] : 1)); +if (is_numeric($entity)) { + define("DOLENTITY", $entity); +} include '../../main.inc.php'; $action = GETPOST('action', 'aZ09'); diff --git a/htdocs/public/onlinesign/newonlinesign.php b/htdocs/public/onlinesign/newonlinesign.php index 8bd95d23c8d..2a9ed568fe8 100644 --- a/htdocs/public/onlinesign/newonlinesign.php +++ b/htdocs/public/onlinesign/newonlinesign.php @@ -431,11 +431,12 @@ if ($action == "dosign" && empty($cancel)) { "ref" : \''.dol_escape_js($REF).'\', "securekey" : \''.dol_escape_js($SECUREKEY).'\', "mode" : \''.dol_escape_htmltag($source).'\', + "entity" : \''.dol_escape_htmltag($entity).'\', }, success: function(response) { if(response == "success"){ console.log("Success on saving signature"); - window.location.replace("'.$_SERVER["PHP_SELF"].'?ref='.urlencode($ref).'&message=signed&securekey='.urlencode($SECUREKEY).'"); + window.location.replace("'.$_SERVER["PHP_SELF"].'?ref='.urlencode($ref).'&message=signed&securekey='.urlencode($SECUREKEY).($conf->multicompany->enabled?'&entity='.$entity:'').'"); }else{ console.error(response); } From b8bccd62efa45ce1617eaa3d4a0278c3d3305adc Mon Sep 17 00:00:00 2001 From: Ferran Marcet Date: Mon, 11 Apr 2022 18:41:36 +0200 Subject: [PATCH 24/59] Update newonlinesign.php --- htdocs/public/onlinesign/newonlinesign.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/public/onlinesign/newonlinesign.php b/htdocs/public/onlinesign/newonlinesign.php index 2a9ed568fe8..d1020dc2c1d 100644 --- a/htdocs/public/onlinesign/newonlinesign.php +++ b/htdocs/public/onlinesign/newonlinesign.php @@ -193,7 +193,7 @@ $replacemainarea = (empty($conf->dol_hide_leftmenu) ? '
' : '').'
'; llxHeader($head, $langs->trans("OnlineSignature"), '', '', 0, 0, '', '', '', 'onlinepaymentbody', $replacemainarea, 1); if ($action == 'refusepropal') { - print $form->formconfirm($_SERVER["PHP_SELF"].'?ref='.urlencode($ref).'&securekey='.urlencode($SECUREKEY), $langs->trans('RefusePropal'), $langs->trans('ConfirmRefusePropal', $object->ref), 'confirm_refusepropal', '', '', 1); + print $form->formconfirm($_SERVER["PHP_SELF"].'?ref='.urlencode($ref).'&securekey='.urlencode($SECUREKEY).($conf->multicompany->enabled?'&entity='.$entity:''), $langs->trans('RefusePropal'), $langs->trans('ConfirmRefusePropal', $object->ref), 'confirm_refusepropal', '', '', 1); } // Check link validity for param 'source' to avoid use of the examples as value From f679392d26ad3f902c9f42d0e38f6a5c897e29d1 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 12 Apr 2022 02:26:37 +0200 Subject: [PATCH 25/59] FIX missing picto in combo of mass actions of thirdparties. --- htdocs/societe/list.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/societe/list.php b/htdocs/societe/list.php index da056ec33da..bdc0fae08e0 100644 --- a/htdocs/societe/list.php +++ b/htdocs/societe/list.php @@ -870,10 +870,10 @@ if ($user->rights->societe->creer) { $arrayofmassactions['preaffecttag'] = img_picto('', 'category', 'class="pictofixedwidth"').$langs->trans("AffectTag"); } if ($user->rights->societe->creer) { - $arrayofmassactions['preenable'] = img_picto('', '', 'class="pictofixedwidth"').$langs->trans("SetToEnabled"); + $arrayofmassactions['preenable'] = img_picto('', 'stop-circle', 'class="pictofixedwidth"').$langs->trans("SetToEnabled"); } if ($user->rights->societe->creer) { - $arrayofmassactions['predisable'] = img_picto('', '', 'class="pictofixedwidth"').$langs->trans("SetToDisabled"); + $arrayofmassactions['predisable'] = img_picto('', 'stop-circle', 'class="pictofixedwidth"').$langs->trans("SetToDisabled"); } if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend', 'predelete', 'preaffecttag', 'preenable', 'preclose'))) { $arrayofmassactions = array(); From cfe554b04cbec7987f1f4b8951ba75a9d87a3831 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 12 Apr 2022 03:08:31 +0200 Subject: [PATCH 26/59] Fix var not defined --- htdocs/modulebuilder/index.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/htdocs/modulebuilder/index.php b/htdocs/modulebuilder/index.php index 872a88b28aa..39f70d30d2d 100644 --- a/htdocs/modulebuilder/index.php +++ b/htdocs/modulebuilder/index.php @@ -46,6 +46,9 @@ $action = GETPOST('action', 'aZ09'); $confirm = GETPOST('confirm', 'alpha'); $cancel = GETPOST('cancel', 'alpha'); +$sortfield = ''; +$sortorder = ''; + $module = GETPOST('module', 'alpha'); $tab = GETPOST('tab', 'aZ09'); $tabobj = GETPOST('tabobj', 'alpha'); From 98c7139859afd3cf4810137deeb87621702641f0 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 12 Apr 2022 10:34:50 +0200 Subject: [PATCH 27/59] Fix regression on fetchObjectLinked when used in loop on a static object --- htdocs/compta/facture/class/facture.class.php | 2 -- htdocs/core/class/commonobject.class.php | 17 +++++++++-------- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 87a59c2c960..7ad0a8ed4bc 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -1630,8 +1630,6 @@ class Facture extends CommonInvoice */ public function fetch($rowid, $ref = '', $ref_ext = '', $notused = '', $fetch_situation = false) { - global $conf; - if (empty($rowid) && empty($ref) && empty($ref_ext)) { return -1; } diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 09c0e591ac7..d53080437a7 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -126,10 +126,9 @@ abstract class CommonObject public $linkedObjects; /** - * @var boolean is linkedObjects full loaded. Loaded by ->fetchObjectLinked - * important for pdf generation time reduction + * @var boolean Array of boolean with object id as key and value as true if linkedObjects full loaded. Loaded by ->fetchObjectLinked. Important for pdf generation time reduction. */ - public $linkedObjectsFullLoaded = false; + public $linkedObjectsFullLoaded = array(); /** * @var Object To store a cloned copy of object before to edit it and keep track of old properties @@ -3781,9 +3780,11 @@ abstract class CommonObject { global $conf, $hookmanager, $action; - // important for pdf generation time reduction - // this boolean is true if $this->linkedObjects has already been loaded with all objects linked without filter - if ($this->linkedObjectsFullLoaded) return 1; + // Important for pdf generation time reduction + // This boolean is true if $this->linkedObjects has already been loaded with all objects linked without filter + if ($this->id > 0 && !empty($this->linkedObjectsFullLoaded[$this->id])) { + return 1; + } $this->linkedObjectsIds = array(); $this->linkedObjects = array(); @@ -3846,8 +3847,8 @@ abstract class CommonObject } else { $sql .= "(fk_source = ".((int) $sourceid)." AND sourcetype = '".$this->db->escape($sourcetype)."')"; $sql .= " ".$clause." (fk_target = ".((int) $targetid)." AND targettype = '".$this->db->escape($targettype)."')"; - if ($sourceid == $this->id && $sourcetype == $this->element && $targetid == $this->id && $targettype == $this->element && $clause == 'OR') { - $this->linkedObjectsFullLoaded = true; + if ($this->id > 0 && $sourceid == $this->id && $sourcetype == $this->element && $targetid == $this->id && $targettype == $this->element && $clause == 'OR') { + $this->linkedObjectsFullLoaded[$this->id] = true; } } $sql .= " ORDER BY ".$orderby; From a6407257dd2752b6f2931f43b0c4bcdf9b1ffe05 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alo=C3=AFs=20Micard?= Date: Tue, 12 Apr 2022 11:11:26 +0200 Subject: [PATCH 28/59] Allow to view tabs in module builder --- htdocs/langs/en_US/modulebuilder.lang | 5 +- htdocs/modulebuilder/index.php | 127 ++++++++++++++++++++++++++ 2 files changed, 131 insertions(+), 1 deletion(-) diff --git a/htdocs/langs/en_US/modulebuilder.lang b/htdocs/langs/en_US/modulebuilder.lang index 7ba539d3bd4..6376024ea0b 100644 --- a/htdocs/langs/en_US/modulebuilder.lang +++ b/htdocs/langs/en_US/modulebuilder.lang @@ -143,4 +143,7 @@ AsciiToHtmlConverter=Ascii to HTML converter AsciiToPdfConverter=Ascii to PDF converter TableNotEmptyDropCanceled=Table not empty. Drop has been canceled. ModuleBuilderNotAllowed=The module builder is available but not allowed to your user. -ImportExportProfiles=Import and export profiles \ No newline at end of file +ImportExportProfiles=Import and export profiles +ListOfTabsEntries=List of tab entries +TabsDefDesc= Define here the tabs provided by your module +TabsDefDescTooltip=The tabs provided by your module/application are defined into the array $this->tabs into the module descriptor file. You can edit manually this file or use the embedded editor. diff --git a/htdocs/modulebuilder/index.php b/htdocs/modulebuilder/index.php index 82567e05fac..16671ddf137 100644 --- a/htdocs/modulebuilder/index.php +++ b/htdocs/modulebuilder/index.php @@ -1931,6 +1931,11 @@ if ($module == 'initmodule') { $head2[$h][2] = 'permissions'; $h++; + $head2[$h][0] = $_SERVER["PHP_SELF"].'?tab=tabs&module='.$module.($forceddirread ? '@'.$dirread : ''); + $head2[$h][1] = $langs->trans("Tabs"); + $head2[$h][2] = 'tabs'; + $h++; + $head2[$h][0] = $_SERVER["PHP_SELF"].'?tab=menus&module='.$module.($forceddirread ? '@'.$dirread : ''); $head2[$h][1] = $langs->trans("Menus"); $head2[$h][2] = 'menus'; @@ -3902,6 +3907,128 @@ if ($module == 'initmodule') { print ''; } + if ($tab == 'tabs') { + $pathtofile = $listofmodules[strtolower($module)]['moduledescriptorrelpath']; + + $tabs = $moduleobj->tabs; + + if ($action != 'editfile' || empty($file)) { + print ''; + $htmlhelp = $langs->trans("TabsDefDescTooltip", '{s1}'); + $htmlhelp = str_replace('{s1}', ''.$langs->trans('Setup').' - '.$langs->trans('Tabs').'', $htmlhelp); + print $form->textwithpicto($langs->trans("TabsDefDesc"), $htmlhelp, 1, 'help', '', 0, 2, 'helpondesc').'
'; + print '
'; + print '
'; + + print ' '.$langs->trans("DescriptorFile").' : '.$pathtofile.''; + print ' '.img_picto($langs->trans("Edit"), 'edit').''; + print '
'; + + print '
'; + print load_fiche_titre($langs->trans("ListOfTabsEntries"), '', ''); + + print '
'; + print ''; + print ''; + print ''; + print ''; + print ''; + + print '
'; + print ''; + + print ''; + print_liste_field_titre("ObjectType", $_SERVER["PHP_SELF"], '', "", $param, '', $sortfield, $sortorder); + print_liste_field_titre("Tab", $_SERVER["PHP_SELF"], '', "", $param, '', $sortfield, $sortorder); + print_liste_field_titre("Title", $_SERVER["PHP_SELF"], '', "", $param, '', $sortfield, $sortorder); + print_liste_field_titre("LangFile", $_SERVER["PHP_SELF"], '', "", $param, '', $sortfield, $sortorder); + print_liste_field_titre("Condition", $_SERVER["PHP_SELF"], '', "", $param, '', $sortfield, $sortorder); + print_liste_field_titre("Path", $_SERVER["PHP_SELF"], '', "", $param, '', $sortfield, $sortorder); + print "\n"; + + if (count($tabs)) { + foreach ($tabs as $tab) { + $parts = explode(':', $tab['data']); + + $objectType = $parts[0]; + $tabName = $parts[1]; + $tabTitle = isset($parts[2]) ? $parts[2] : ''; + $langFile = isset($parts[3]) ? $parts[3] : ''; + $condition = isset($parts[4]) ? $parts[4] : ''; + $path = isset($parts[5]) ? $parts[5] : ''; + + // If we want to remove the tab, then the format is 'tabname:optionalcondition' + // See: https://wiki.dolibarr.org/index.php?title=Tabs_system#To_remove_an_existing_tab + if ($tabName[0] === '-') { + $tabTitle = ''; + $condition = isset($parts[2]) ? $parts[2] : ''; + } + + print ''; + + print ''; + + print ''; + + print ''; + + print ''; + + print ''; + + print ''; + + print ''; + } + } else { + print ''; + } + + print '
'; + print dol_escape_htmltag($parts[0]); + print ''; + if ($tabName[0] === "+") + print '' . dol_escape_htmltag($tabName) . ''; + else + print '' . dol_escape_htmltag($tabName) . ''; + print ''; + print dol_escape_htmltag($tabTitle); + print ''; + print dol_escape_htmltag($langFile); + print ''; + print dol_escape_htmltag($condition); + print ''; + print dol_escape_htmltag($path); + print '
'.$langs->trans("None").'
'; + print '
'; + + print '
'; + } else { + $fullpathoffile = dol_buildpath($file, 0); + + $content = file_get_contents($fullpathoffile); + + // New module + print '
'; + print ''; + print ''; + print ''; + print ''; + print ''; + + $doleditor = new DolEditor('editfilecontent', $content, '', '300', 'Full', 'In', true, false, 'ace', 0, '99%'); + print $doleditor->Create(1, '', false, $langs->trans("File").' : '.$file, (GETPOST('format', 'aZ09') ?GETPOST('format', 'aZ09') : 'html')); + print '
'; + print '
'; + print ''; + print '   '; + print ''; + print '
'; + + print '
'; + } + } + if ($tab != 'description') { print dol_get_fiche_end(); } From 25a851ac70f70df00e5408e344b26b3b5a979c49 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alo=C3=AFs=20Micard?= Date: Tue, 12 Apr 2022 11:12:43 +0200 Subject: [PATCH 29/59] Fix translation --- htdocs/langs/en_US/modulebuilder.lang | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/langs/en_US/modulebuilder.lang b/htdocs/langs/en_US/modulebuilder.lang index 6376024ea0b..5544c2b932a 100644 --- a/htdocs/langs/en_US/modulebuilder.lang +++ b/htdocs/langs/en_US/modulebuilder.lang @@ -145,5 +145,5 @@ TableNotEmptyDropCanceled=Table not empty. Drop has been canceled. ModuleBuilderNotAllowed=The module builder is available but not allowed to your user. ImportExportProfiles=Import and export profiles ListOfTabsEntries=List of tab entries -TabsDefDesc= Define here the tabs provided by your module +TabsDefDesc=Define here the tabs provided by your module TabsDefDescTooltip=The tabs provided by your module/application are defined into the array $this->tabs into the module descriptor file. You can edit manually this file or use the embedded editor. From a747f574b3dc5144e9e695f1ec42d19935ca1ebf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alo=C3=AFs=20Micard?= Date: Tue, 12 Apr 2022 11:15:40 +0200 Subject: [PATCH 30/59] Improve comment --- htdocs/modulebuilder/index.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/modulebuilder/index.php b/htdocs/modulebuilder/index.php index 16671ddf137..14385864b6b 100644 --- a/htdocs/modulebuilder/index.php +++ b/htdocs/modulebuilder/index.php @@ -3957,7 +3957,7 @@ if ($module == 'initmodule') { $condition = isset($parts[4]) ? $parts[4] : ''; $path = isset($parts[5]) ? $parts[5] : ''; - // If we want to remove the tab, then the format is 'tabname:optionalcondition' + // If we want to remove the tab, then the format is 'objecttype:tabname:optionalcondition' // See: https://wiki.dolibarr.org/index.php?title=Tabs_system#To_remove_an_existing_tab if ($tabName[0] === '-') { $tabTitle = ''; From 752cc6f4a7adbc4fd791ef6229ce28feb5c8569d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alo=C3=AFs=20Micard?= Date: Tue, 12 Apr 2022 11:17:24 +0200 Subject: [PATCH 31/59] Lint source code --- htdocs/modulebuilder/index.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/htdocs/modulebuilder/index.php b/htdocs/modulebuilder/index.php index 14385864b6b..937ef6d83fb 100644 --- a/htdocs/modulebuilder/index.php +++ b/htdocs/modulebuilder/index.php @@ -3971,10 +3971,11 @@ if ($module == 'initmodule') { print ''; print ''; - if ($tabName[0] === "+") + if ($tabName[0] === "+") { print '' . dol_escape_htmltag($tabName) . ''; - else + } else { print '' . dol_escape_htmltag($tabName) . ''; + } print ''; print ''; From a006eaecdeac66bf6f1c67112a9dde9e77e8029e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 12 Apr 2022 13:02:33 +0200 Subject: [PATCH 32/59] Fix trans --- htdocs/adherents/list.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/adherents/list.php b/htdocs/adherents/list.php index 996f2d16c8d..441ce85ec86 100644 --- a/htdocs/adherents/list.php +++ b/htdocs/adherents/list.php @@ -482,7 +482,7 @@ if (GETPOSTISSET("search_status")) { $titre = $langs->trans("MembersListToValid"); } if ($search_status == Adherent::STATUS_VALIDATED && $filter == '') { - $titre = $langs->trans("MembersValidated"); + $titre = $langs->trans("MenuMembersValidated"); } if ($search_status == Adherent::STATUS_VALIDATED && $filter == 'withoutsubscription') { $titre = $langs->trans("MembersWithSubscriptionToReceive"); From d41676cf8bd71789a90eeb08ed66f72cdf0f1de9 Mon Sep 17 00:00:00 2001 From: lmarcouiller Date: Tue, 12 Apr 2022 13:57:00 +0200 Subject: [PATCH 33/59] Close #20609 : new massaction asign sale representative --- htdocs/core/actions_massactions.inc.php | 38 +++++++++++++++++++++++++ htdocs/core/tpl/massactions_pre.tpl.php | 10 ++++++- htdocs/langs/en_US/main.lang | 4 +++ htdocs/societe/list.php | 3 ++ 4 files changed, 54 insertions(+), 1 deletion(-) diff --git a/htdocs/core/actions_massactions.inc.php b/htdocs/core/actions_massactions.inc.php index c5ff1d8f82a..5ec011f5017 100644 --- a/htdocs/core/actions_massactions.inc.php +++ b/htdocs/core/actions_massactions.inc.php @@ -1602,6 +1602,44 @@ if (!$error && ($massaction == 'disable' || ($action == 'disable' && $confirm == } } +if (!$error && ($massaction == 'affectcommercial' || ($action == 'affectcommercial' && $confirm == 'yes')) && $permissiontoadd) { + $db->begin(); + + $objecttmp = new $objectclass($db); + $nbok = 0; + + foreach ($toselect as $toselectid) { + $result = $objecttmp->fetch($toselectid); + if ($result>0) { + if (in_array($objecttmp->element, array('societe'))) { + $result = $objecttmp->setSalesRep(GETPOST("commercial", "alpha")); + } + if ($result <= 0) { + setEventMessages($objecttmp->error, $objecttmp->errors, 'errors'); + $error++; + break; + } else { + $nbok++; + } + } else { + setEventMessages($objecttmp->error, $objecttmp->errors, 'errors'); + $error++; + break; + } + } + + if (!$error) { + if ($nbok > 1) { + setEventMessages($langs->trans("CommercialsAffected", $nbok), null, 'mesgs'); + } else { + setEventMessages($langs->trans("CommercialAffected"), null, 'mesgs'); + } + $db->commit(); + } else { + $db->rollback(); + } +} + // Approve for leave only if (!$error && ($massaction == 'approveleave' || ($action == 'approveleave' && $confirm == 'yes')) && $permissiontoapprove) { $db->begin(); diff --git a/htdocs/core/tpl/massactions_pre.tpl.php b/htdocs/core/tpl/massactions_pre.tpl.php index de034f652d3..4e138b0f1dc 100644 --- a/htdocs/core/tpl/massactions_pre.tpl.php +++ b/htdocs/core/tpl/massactions_pre.tpl.php @@ -217,7 +217,15 @@ if ($massaction == 'preenable') { if ($massaction == 'predisable') { print $form->formconfirm($_SERVER["PHP_SELF"], $langs->trans("ConfirmMassDisabling"), $langs->trans("ConfirmMassDisablingQuestion", count($toselect)), "disable", null, '', 0, 200, 500, 1); } - +if ($massaction == 'presetcommercial') { + $formquestion = array(); + $userlist = $form->select_dolusers('', '', 0, null, 0, '', '', 0, 0, 0, 'AND u.statut = 1', 0, '', '', 0, 1); + $formquestion[] = array('type' => 'other', + 'name' => 'affectedcommercial', + 'label' => $form->editfieldkey('AllocateCommercial', 'commercial_id', '', $object, 0), + 'value' => $form->multiselectarray('commercial', $userlist, null, 0, 0, 'quatrevingtpercent widthcentpercentminusx', 0, 0, '', '', '', 1)); + print $form->formconfirm($_SERVER["PHP_SELF"], $langs->trans("ConfirmAllocateCommercial"), $langs->trans("ConfirmAllocateCommercialQuestion", count($toselect)), "affectcommercial", $formquestion, 1, 0, 200, 500, 1); +} if ($massaction == 'preapproveleave') { print $form->formconfirm($_SERVER["PHP_SELF"], $langs->trans("ConfirmMassLeaveApproval"), $langs->trans("ConfirmMassLeaveApprovalQuestion", count($toselect)), "approveleave", null, 'yes', 0, 200, 500, 1); } diff --git a/htdocs/langs/en_US/main.lang b/htdocs/langs/en_US/main.lang index c66895e58a4..b39124c7c53 100644 --- a/htdocs/langs/en_US/main.lang +++ b/htdocs/langs/en_US/main.lang @@ -1169,3 +1169,7 @@ CanceledShown=Canceled shown Terminate=Terminate Terminated=Terminated AddLineOnPosition=Add line on position (at the end if empty) +ConfirmAllocateCommercial=Assign sales representative confirmation +ConfirmAllocateCommercialQuestion=Are you sure you want to assign the %s selected record(s)? +CommercialsAffected=Sales representatives affected +CommercialAffected=Sales representative affected \ No newline at end of file diff --git a/htdocs/societe/list.php b/htdocs/societe/list.php index 3544611ac45..26e955e7ab4 100644 --- a/htdocs/societe/list.php +++ b/htdocs/societe/list.php @@ -875,6 +875,9 @@ if ($user->rights->societe->creer) { if ($user->rights->societe->creer) { $arrayofmassactions['predisable'] = img_picto('', '', 'class="pictofixedwidth"').$langs->trans("SetToDisabled"); } +if ($user->rights->societe->creer) { + $arrayofmassactions['presetcommercial'] = img_picto('', '', 'class="pictofixedwidth"').$langs->trans("AllocateCommercial"); +} if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend', 'predelete', 'preaffecttag', 'preenable', 'preclose'))) { $arrayofmassactions = array(); } From b1cc271ad5d6c6aa0916d9c25add1e20c60cb026 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 12 Apr 2022 14:23:39 +0200 Subject: [PATCH 34/59] Fix trans --- htdocs/langs/en_US/modulebuilder.lang | 2 +- htdocs/modulebuilder/index.php | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/langs/en_US/modulebuilder.lang b/htdocs/langs/en_US/modulebuilder.lang index 7610aa78e9e..5466900bbe0 100644 --- a/htdocs/langs/en_US/modulebuilder.lang +++ b/htdocs/langs/en_US/modulebuilder.lang @@ -144,6 +144,6 @@ AsciiToPdfConverter=Ascii to PDF converter TableNotEmptyDropCanceled=Table not empty. Drop has been canceled. ModuleBuilderNotAllowed=The module builder is available but not allowed to your user. ImportExportProfiles=Import and export profiles -ValidateModBuilderDesc=Put 1 if this field need to be validated with $this->validateField() or 0 if validation required +ValidateModBuilderDesc=Set this to 1 if you want to have the method $this->validateField() of object being called to validate the content of the field during insert or upadate. Set 0 if there is no validation required. WarningDatabaseIsNotUpdated=Warning: The database is not updated automatically, you must destroy tables and disable-enable the module to have tables recreated LinkToParentMenu=Parent menu (fk_xxxxmenu) \ No newline at end of file diff --git a/htdocs/modulebuilder/index.php b/htdocs/modulebuilder/index.php index b3a7ce9dfaf..1a5987f3e80 100644 --- a/htdocs/modulebuilder/index.php +++ b/htdocs/modulebuilder/index.php @@ -2726,7 +2726,7 @@ if ($module == 'initmodule') { print '
'; print ''; print ''; - print ''; print ''; print ''; print ''; - print ''; + print ''; print ''; // We must use $reflectorpropdefault['fields'] to get list of fields because $tmpobjet->fields may have been @@ -2763,7 +2763,7 @@ if ($module == 'initmodule') { if (!empty($properties)) { // Line to add a property print ''; - print ''; + print ''; print ''; print ''; print ''; From c51aff99af711f0a7a04fcd2de99ab243ad2175c Mon Sep 17 00:00:00 2001 From: kevin Date: Tue, 12 Apr 2022 14:38:17 +0200 Subject: [PATCH 35/59] Add missing entity on adding new VAT --- htdocs/compta/tva/class/tva.class.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/htdocs/compta/tva/class/tva.class.php b/htdocs/compta/tva/class/tva.class.php index 45d3d2e74b4..ce5ff657eca 100644 --- a/htdocs/compta/tva/class/tva.class.php +++ b/htdocs/compta/tva/class/tva.class.php @@ -125,6 +125,7 @@ class Tva extends CommonObject // Insert request $sql = "INSERT INTO ".MAIN_DB_PREFIX."tva("; + $sql .= "entity,"; $sql .= "datec,"; $sql .= "datep,"; $sql .= "datev,"; @@ -136,6 +137,7 @@ class Tva extends CommonObject $sql .= "fk_user_creat,"; $sql .= "fk_user_modif"; $sql .= ") VALUES ("; + $sql .= " '".$conf->entity."',"; $sql .= " '".$this->db->idate($now)."',"; $sql .= " '".$this->db->idate($this->datep)."',"; $sql .= " '".$this->db->idate($this->datev)."',"; From adda436dab9acc806ff33c5ea25e9f21df41f90d Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Tue, 12 Apr 2022 12:45:05 +0000 Subject: [PATCH 36/59] Fixing style errors. --- htdocs/compta/tva/class/tva.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/compta/tva/class/tva.class.php b/htdocs/compta/tva/class/tva.class.php index ce5ff657eca..c9fcf18d587 100644 --- a/htdocs/compta/tva/class/tva.class.php +++ b/htdocs/compta/tva/class/tva.class.php @@ -125,7 +125,7 @@ class Tva extends CommonObject // Insert request $sql = "INSERT INTO ".MAIN_DB_PREFIX."tva("; - $sql .= "entity,"; + $sql .= "entity,"; $sql .= "datec,"; $sql .= "datep,"; $sql .= "datev,"; @@ -137,7 +137,7 @@ class Tva extends CommonObject $sql .= "fk_user_creat,"; $sql .= "fk_user_modif"; $sql .= ") VALUES ("; - $sql .= " '".$conf->entity."',"; + $sql .= " '".$conf->entity."',"; $sql .= " '".$this->db->idate($now)."',"; $sql .= " '".$this->db->idate($this->datep)."',"; $sql .= " '".$this->db->idate($this->datev)."',"; From 599c90ae6be05967f29e349b38a19ea6290c53fe Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 12 Apr 2022 14:57:12 +0200 Subject: [PATCH 37/59] FIX dol_string_onlythesehtmltags can keep html comments --- htdocs/core/lib/functions.lib.php | 9 +++++++-- htdocs/modulebuilder/index.php | 5 ++++- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 50d0e8ee9e3..24557d1e90e 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -6521,7 +6521,8 @@ function dol_string_onlythesehtmltags($stringtoclean, $cleanalsosomestyles = 1, { $allowed_tags = array( "html", "head", "meta", "body", "article", "a", "abbr", "b", "blockquote", "br", "cite", "div", "dl", "dd", "dt", "em", "font", "img", "ins", "hr", "i", "li", "link", - "ol", "p", "q", "s", "section", "span", "strike", "strong", "title", "table", "tr", "th", "td", "u", "ul", "sup", "sub", "blockquote", "pre", "h1", "h2", "h3", "h4", "h5", "h6" + "ol", "p", "q", "s", "section", "span", "strike", "strong", "title", "table", "tr", "th", "td", "u", "ul", "sup", "sub", "blockquote", "pre", "h1", "h2", "h3", "h4", "h5", "h6", + "comment" // this tags is added to manage comment that are replaced into ... ); if ($allowiframe) { $allowed_tags[] = "iframe"; @@ -6534,7 +6535,8 @@ function dol_string_onlythesehtmltags($stringtoclean, $cleanalsosomestyles = 1, $stringtoclean = dol_string_nounprintableascii($stringtoclean, 0); - $stringtoclean = preg_replace('//', '', $stringtoclean); + //$stringtoclean = preg_replace('//', '', $stringtoclean); + $stringtoclean = preg_replace('//', '\1', $stringtoclean); $stringtoclean = preg_replace('/:/i', ':', $stringtoclean); $stringtoclean = preg_replace('/:|�+58|:/i', '', $stringtoclean); // refused string ':' encoded (no reason to have a : encoded like this) to disable 'javascript:...' @@ -6557,6 +6559,9 @@ function dol_string_onlythesehtmltags($stringtoclean, $cleanalsosomestyles = 1, $temp = str_replace('__!DOCTYPE_HTML__', '', $temp); // Restore the DOCTYPE + $temp = preg_replace('/([^>]*)<\/comment>/', '', $temp); // Restore html comments + + return $temp; } diff --git a/htdocs/modulebuilder/index.php b/htdocs/modulebuilder/index.php index 1a5987f3e80..95e83c3ed39 100644 --- a/htdocs/modulebuilder/index.php +++ b/htdocs/modulebuilder/index.php @@ -1641,6 +1641,7 @@ if ($action == 'savefile' && empty($cancel)) { $content = GETPOST('editfilecontent', $check); + // Save file on disk if ($content) { dol_delete_file($pathoffile); @@ -2128,7 +2129,9 @@ if ($module == 'initmodule') { print ''; print ''; } @@ -2299,6 +2312,7 @@ if ($module == 'initmodule') { } if ($tab == 'dictionaries') { + print ''."\n"; $pathtofile = $listofmodules[strtolower($module)]['moduledescriptorrelpath']; $dicts = $moduleobj->dictionaries; @@ -2333,7 +2347,7 @@ if ($module == 'initmodule') { print '
'.$langs->trans("Property"); + print ''.$langs->trans("Property"); print ' ('.$langs->trans("SeeExamples").')'; print ''; @@ -2752,7 +2752,7 @@ if ($module == 'initmodule') { //print ''.$langs->trans("Disabled").''.$form->textwithpicto($langs->trans("Validate"), $langs->trans("ValidateModBuilderDesc")).''.$langs->trans("Comment").'
'; print $langs->trans("EditorUrl"); print ''; - print $moduleobj->editor_url; + if (!empty($moduleobj->editor_url)) { + print ''.$moduleobj->editor_url.' '.img_picto('', 'globe').''; + } print '
'; From 386b8bee5e0be25d49e78b4df609bbe2332a71bb Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 12 Apr 2022 15:26:21 +0200 Subject: [PATCH 38/59] Fix deletion/creation of extrafields. --- htdocs/modulebuilder/index.php | 30 ++++++++++++++++++++++++------ 1 file changed, 24 insertions(+), 6 deletions(-) diff --git a/htdocs/modulebuilder/index.php b/htdocs/modulebuilder/index.php index 95e83c3ed39..01c05dadac8 100644 --- a/htdocs/modulebuilder/index.php +++ b/htdocs/modulebuilder/index.php @@ -466,7 +466,12 @@ if ($dirins && $action == 'initsqlextrafields' && !empty($module)) { dolReplaceInFile($destfile2, $arrayreplacement); } else { $langs->load("errors"); - setEventMessages($langs->trans('ErrorFailToCreateFile', ''), null, 'errors'); + if ($result1 <= 0) { + setEventMessages($langs->trans('ErrorFailToCreateFile', $destfile1), null, 'errors'); + } + if ($result2 <= 0) { + setEventMessages($langs->trans('ErrorFailToCreateFile', $destfile2), null, 'errors'); + } } // TODO Enable in class the property $isextrafieldmanaged = 1 } @@ -780,6 +785,19 @@ if ($dirins && $action == 'confirm_removefile' && !empty($module)) { if (!$result) { setEventMessages($langs->trans("ErrorFailToDeleteFile", basename($filetodelete)), null, 'errors'); } else { + // If we delete a sql file + if (preg_match('/\.sql$/', $relativefilename)) { + if (preg_match('/\.key\.sql$/', $relativefilename)) { + $relativefilename = preg_replace('/\.key\.sql$/', '.sql', $relativefilename); + $filetodelete = $dirins.'/'.$relativefilename; + $result = dol_delete_file($filetodelete); + } elseif (preg_match('/\.sql$/', $relativefilename)) { + $relativefilename = preg_replace('/\.sql$/', '.key.sql', $relativefilename); + $filetodelete = $dirins.'/'.$relativefilename; + $result = dol_delete_file($filetodelete); + } + } + if (dol_is_dir_empty($dirtodelete)) { dol_delete_dir($dirtodelete); } @@ -1641,7 +1659,6 @@ if ($action == 'savefile' && empty($cancel)) { $content = GETPOST('editfilecontent', $check); - // Save file on disk if ($content) { dol_delete_file($pathoffile); @@ -2573,8 +2590,9 @@ if ($module == 'initmodule') { print '
'; print ' '.$langs->trans("ClassFile").' : '.($realpathtoclass ? '' : '').preg_replace('/^'.strtolower($module).'\//', '', $pathtoclass).($realpathtoclass ? '' : '').''; print ' '.img_picto($langs->trans("Edit"), 'edit').''; + // API file print '
'; - print ' '.$langs->trans("ApiClassFile").' : '.($realpathtoapi ? '' : '').preg_replace('/^'.strtolower($module).'\//', '', $pathtoapi).($realpathtoapi ? '' : '').''; + print ' '.$langs->trans("ApiClassFile").' : '.($realpathtoapi ? '' : '').(dol_is_file($realpathtoapi)?'':'').preg_replace('/^'.strtolower($module).'\//', '', $pathtoapi).(dol_is_file($realpathtoapi)?'':'').($realpathtoapi ? '' : '').''; if (dol_is_file($realpathtoapi)) { print ' '.img_picto($langs->trans("Edit"), 'edit').''; print ' '; @@ -2591,7 +2609,7 @@ if ($module == 'initmodule') { } // PHPUnit print '
'; - print ' '.$langs->trans("TestClassFile").' : '.($realpathtophpunit ? '' : '').preg_replace('/^'.strtolower($module).'\//', '', $pathtophpunit).($realpathtophpunit ? '' : '').''; + print ' '.$langs->trans("TestClassFile").' : '.($realpathtophpunit ? '' : '').(dol_is_file($realpathtophpunit)?'':'').preg_replace('/^'.strtolower($module).'\//', '', $pathtophpunit).(dol_is_file($realpathtophpunit)?'':'').($realpathtophpunit ? '' : '').''; if (dol_is_file($realpathtophpunit)) { print ' '.img_picto($langs->trans("Edit"), 'edit').''; print ' '; @@ -2624,7 +2642,7 @@ if ($module == 'initmodule') { print ' '.img_picto($langs->trans("Edit"), 'edit').''; //print '   '.$langs->trans("RunSql").''; print '
'; - print ' '.$langs->trans("SqlFileExtraFields").' : '.($realpathtosqlextra ? '' : '').preg_replace('/^'.strtolower($module).'\//', '', $pathtosqlextra).($realpathtosqlextra ? '' : '').''; + print ' '.$langs->trans("SqlFileExtraFields").' : '.($realpathtosqlextra ? '' : '').(dol_is_file($realpathtosqlextra) && dol_is_file($realpathtosqlextrakey) ? '' : '').preg_replace('/^'.strtolower($module).'\//', '', $pathtosqlextra).(dol_is_file($realpathtosqlextra) && dol_is_file($realpathtosqlextrakey) ? '' : '').($realpathtosqlextra ? '' : '').''; if (dol_is_file($realpathtosqlextra) && dol_is_file($realpathtosqlextrakey)) { print ' '.img_picto($langs->trans("Edit"), 'edit').''; print ' '; @@ -2636,7 +2654,7 @@ if ($module == 'initmodule') { } //print '   '.$langs->trans("RunSql").''; print '
'; - print ' '.$langs->trans("SqlFileKeyExtraFields").' : '.($realpathtosqlextrakey ? '' : '').preg_replace('/^'.strtolower($module).'\//', '', $pathtosqlextrakey).($realpathtosqlextrakey ? '' : '').''; + print ' '.$langs->trans("SqlFileKeyExtraFields").' : '.($realpathtosqlextrakey ? '' : '').(dol_is_file($realpathtosqlextra) && dol_is_file($realpathtosqlextrakey) ? '' : '').preg_replace('/^'.strtolower($module).'\//', '', $pathtosqlextrakey).(dol_is_file($realpathtosqlextra) && dol_is_file($realpathtosqlextrakey) ? '' : '').($realpathtosqlextrakey ? '' : '').''; if (dol_is_file($realpathtosqlextra) && dol_is_file($realpathtosqlextrakey)) { print ' '.img_picto($langs->trans("Edit"), 'edit').''; print ' '; From 04ad919a2cdb8c31d7a080388a2ab29ed2766ca5 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 12 Apr 2022 15:51:46 +0200 Subject: [PATCH 39/59] Debug modulebuilder for v16. --- htdocs/modulebuilder/index.php | 53 ++++++++++++++++++++++++++++------ 1 file changed, 44 insertions(+), 9 deletions(-) diff --git a/htdocs/modulebuilder/index.php b/htdocs/modulebuilder/index.php index 01c05dadac8..7389e2ea7a5 100644 --- a/htdocs/modulebuilder/index.php +++ b/htdocs/modulebuilder/index.php @@ -473,7 +473,11 @@ if ($dirins && $action == 'initsqlextrafields' && !empty($module)) { setEventMessages($langs->trans('ErrorFailToCreateFile', $destfile2), null, 'errors'); } } - // TODO Enable in class the property $isextrafieldmanaged = 1 + + // Now we update the object file to set $isextrafieldmanaged to 0 + $srcfile = $dirins.'/'.strtolower($module).'/class/'.strtolower($objectname).'.class.php'; + $arrayreplacement = array('/\$isextrafieldmanaged = 0;/' => '$isextrafieldmanaged = 1;'); + dolReplaceInFile($srcfile, $arrayreplacement, '', 0, 0, 1); } @@ -775,6 +779,8 @@ if ($dirins && $action == 'addlanguage' && !empty($module)) { // remove/delete File if ($dirins && $action == 'confirm_removefile' && !empty($module)) { + $objectname = $tabobj; + $relativefilename = dol_sanitizePathName(GETPOST('file', 'restricthtml')); if ($relativefilename) { $dirnametodelete = dirname($relativefilename); @@ -808,6 +814,11 @@ if ($dirins && $action == 'confirm_removefile' && !empty($module)) { $arrayreplacement = array('/^\s*\''.preg_quote('/'.$relativefilename, '/').'\',*/m'=>' // \'/'.$relativefilename.'\','); dolReplaceInFile($srcfile, $arrayreplacement, '', 0, 0, 1); } + + // Now we update the object file to set $isextrafieldmanaged to 0 + $srcfile = $dirins.'/'.strtolower($module).'/class/'.strtolower($objectname).'.class.php'; + $arrayreplacement = array('/\$isextrafieldmanaged = 1;/' => '$isextrafieldmanaged = 0;'); + dolReplaceInFile($srcfile, $arrayreplacement, '', 0, 0, 1); } } } @@ -2064,6 +2075,7 @@ if ($module == 'initmodule') { // Note module is inside $dirread if ($tab == 'description') { + print ''."\n"; $pathtofile = $listofmodules[strtolower($module)]['moduledescriptorrelpath']; $pathtofilereadme = $modulelowercase.'/README.md'; $pathtochangelog = $modulelowercase.'/ChangeLog.md'; @@ -2224,6 +2236,7 @@ if ($module == 'initmodule') { } if ($tab == 'languages') { + print ''."\n"; if ($action != 'editfile' || empty($file)) { print ''.$langs->trans("LanguageDefDesc").'
'; print '
'; @@ -2263,7 +2276,7 @@ if ($module == 'initmodule') { $pathtofile = 'langs/'.$langfile['relativename']; } print '
'.$langs->trans("LanguageFile").' '.basename(dirname($pathtofile)).' : '.$pathtofile.''; - print ''.img_picto($langs->trans("Edit"), 'edit').''; + print ''.img_picto($langs->trans("Edit"), 'edit').''; print ''.img_picto($langs->trans("Delete"), 'delete').''; print '
'; print ''; - print_liste_field_titre("#", $_SERVER["PHP_SELF"], '', "", $param, '', $sortfield, $sortorder, ' aaa '); + print_liste_field_titre("#", $_SERVER["PHP_SELF"], '', "", $param, '', $sortfield, $sortorder, 'thsticky thstickygrey '); print_liste_field_titre("Table", $_SERVER["PHP_SELF"], '', "", $param, '', $sortfield, $sortorder); print_liste_field_titre("Label", $_SERVER["PHP_SELF"], '', "", $param, '', $sortfield, $sortorder); print_liste_field_titre("SQL", $_SERVER["PHP_SELF"], '', "", $param, '', $sortfield, $sortorder); @@ -2351,7 +2365,7 @@ if ($module == 'initmodule') { while ($i < $maxi) { print ''; - print ''; @@ -2395,7 +2409,7 @@ if ($module == 'initmodule') { $i++; } } else { - print ''; + print ''; } print '
'; + print ''; print ($i + 1); print '
'.$langs->trans("None").'
'.$langs->trans("None").'
'; @@ -2429,6 +2443,7 @@ if ($module == 'initmodule') { } if ($tab == 'objects') { + print ''."\n"; $head3 = array(); $h = 0; @@ -3096,6 +3111,7 @@ if ($module == 'initmodule') { } if ($tab == 'menus') { + print ''."\n"; $pathtofile = $listofmodules[strtolower($module)]['moduledescriptorrelpath']; $menus = $moduleobj->menu; @@ -3126,6 +3142,7 @@ if ($module == 'initmodule') { print ''; print ''; + print_liste_field_titre("#", $_SERVER["PHP_SELF"], '', "", $param, '', $sortfield, $sortorder, 'thsticky '); print_liste_field_titre("Type", $_SERVER["PHP_SELF"], '', "", $param, '', $sortfield, $sortorder); print_liste_field_titre("LinkToParentMenu", $_SERVER["PHP_SELF"], '', "", $param, '', $sortfield, $sortorder); print_liste_field_titre("Title", $_SERVER["PHP_SELF"], '', "", $param, '', $sortfield, $sortorder); @@ -3141,9 +3158,16 @@ if ($module == 'initmodule') { print "\n"; if (count($menus)) { + $i = 0; foreach ($menus as $menu) { + $i++; + print ''; + print ''; + print ''; @@ -3229,6 +3253,7 @@ if ($module == 'initmodule') { } if ($tab == 'permissions') { + print ''."\n"; $pathtofile = $listofmodules[strtolower($module)]['moduledescriptorrelpath']; $perms = $moduleobj->rights; @@ -3322,6 +3347,7 @@ if ($module == 'initmodule') { } if ($tab == 'hooks') { + print ''."\n"; if ($action != 'editfile' || empty($file)) { print ''.$langs->trans("HooksDefDesc").'
'; print '
'; @@ -3342,7 +3368,7 @@ if ($module == 'initmodule') { print ''.$pathtohook.''; print ''; print ''; + print ''.img_picto($langs->trans("Delete"), 'delete').''; } else { print ''.$langs->trans("FileNotYetGenerated").''; print ''.img_picto('Generate', 'generate', 'class="paddingleft"').''; @@ -3376,6 +3402,7 @@ if ($module == 'initmodule') { } if ($tab == 'triggers') { + print ''."\n"; require_once DOL_DOCUMENT_ROOT.'/core/class/interfaces.class.php'; $interfaces = new Interfaces($db); @@ -3401,7 +3428,7 @@ if ($module == 'initmodule') { print ''; - print ''; + print ''; print ''; } } else { @@ -3441,6 +3468,7 @@ if ($module == 'initmodule') { } if ($tab == 'css') { + print ''."\n"; if ($action != 'editfile' || empty($file)) { print ''.$langs->trans("CSSDesc").'
'; print '
'; @@ -3452,8 +3480,8 @@ if ($module == 'initmodule') { print ' '.$langs->trans("CSSFile").' : '; if (dol_is_file($dirins.'/'.$pathtohook)) { print ''.$pathtohook.''; - print '
'; - print ''; + print ''; + print ''; } else { print ''.$langs->trans("FileNotYetGenerated").''; print ''; @@ -3486,6 +3514,7 @@ if ($module == 'initmodule') { } if ($tab == 'js') { + print ''."\n"; if ($action != 'editfile' || empty($file)) { print ''.$langs->trans("JSDesc").'
'; print '
'; @@ -3531,6 +3560,7 @@ if ($module == 'initmodule') { } if ($tab == 'widgets') { + print ''."\n"; require_once DOL_DOCUMENT_ROOT.'/core/boxes/modules_boxes.php'; $widgets = ModeleBoxes::getWidgetsList(array('/'.strtolower($module).'/core/boxes')); @@ -3582,6 +3612,7 @@ if ($module == 'initmodule') { } if ($tab == 'exportimport') { + print ''."\n"; $pathtofile = $listofmodules[strtolower($module)]['moduledescriptorrelpath']; $exportlist = $moduleobj->export_label; @@ -3621,6 +3652,7 @@ if ($module == 'initmodule') { } if ($tab == 'cli') { + print ''."\n"; $clifiles = array(); $i = 0; @@ -3699,6 +3731,7 @@ if ($module == 'initmodule') { } if ($tab == 'cron') { + print ''."\n"; $pathtofile = $listofmodules[strtolower($module)]['moduledescriptorrelpath']; $cronjobs = $moduleobj->cronjobs; @@ -3820,6 +3853,7 @@ if ($module == 'initmodule') { } if ($tab == 'specifications') { + print ''."\n"; $specs = dol_dir_list(dol_buildpath($modulelowercase.'/doc', 0), 'files', 1, '(\.md|\.asciidoc)$', array('\/temp\/')); if ($action != 'editfile' || empty($file)) { @@ -3933,6 +3967,7 @@ if ($module == 'initmodule') { } if ($tab == 'buildpackage') { + print ''."\n"; print ''.$langs->trans("BuildPackageDesc").''; print '
'; From 1bfd9c695fda90db19047a04305877bf809580e3 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 12 Apr 2022 16:29:25 +0200 Subject: [PATCH 40/59] Update tva.class.php --- htdocs/compta/tva/class/tva.class.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/compta/tva/class/tva.class.php b/htdocs/compta/tva/class/tva.class.php index c9fcf18d587..a6828587763 100644 --- a/htdocs/compta/tva/class/tva.class.php +++ b/htdocs/compta/tva/class/tva.class.php @@ -137,7 +137,7 @@ class Tva extends CommonObject $sql .= "fk_user_creat,"; $sql .= "fk_user_modif"; $sql .= ") VALUES ("; - $sql .= " '".$conf->entity."',"; + $sql .= " ".((int) $conf->entity.", "; $sql .= " '".$this->db->idate($now)."',"; $sql .= " '".$this->db->idate($this->datep)."',"; $sql .= " '".$this->db->idate($this->datev)."',"; @@ -146,8 +146,8 @@ class Tva extends CommonObject $sql .= " '".$this->db->escape($this->note)."',"; $sql .= " '".$this->db->escape($this->fk_account)."',"; $sql .= " '".$this->db->escape($this->type_payment)."',"; - $sql .= " '".($this->fk_user_creat > 0 ? (int) $this->fk_user_creat : (int) $user->id)."',"; - $sql .= " '".$this->db->escape($this->fk_user_modif)."'"; + $sql .= " ".($this->fk_user_creat > 0 ? (int) $this->fk_user_creat : (int) $user->id).","; + $sql .= " ".($this->fk_user_modif > 0 ? (int) $this->fk_user_modif : (int) $user->id); $sql .= ")"; dol_syslog(get_class($this)."::create", LOG_DEBUG); From 6cbcc54bd964eab272fd3e7f6ea63efc65dec6b5 Mon Sep 17 00:00:00 2001 From: Ferran Marcet Date: Tue, 12 Apr 2022 19:19:41 +0200 Subject: [PATCH 41/59] Fix: The resource dropdown does not show the values --- htdocs/resource/class/html.formresource.class.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/htdocs/resource/class/html.formresource.class.php b/htdocs/resource/class/html.formresource.class.php index 99916b8ed70..fa775bf5d58 100644 --- a/htdocs/resource/class/html.formresource.class.php +++ b/htdocs/resource/class/html.formresource.class.php @@ -1,6 +1,7 @@ * Copyright (C) 2019 Frédéric France + * Copyright (C) 2022 Ferran Marcet * * 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 @@ -224,9 +225,10 @@ class FormResource $value = ($maxlength ?dol_trunc($arraytypes['label'], $maxlength) : $arraytypes['label']); } elseif ($format == 3) { $value = $arraytypes['code']; - } elseif (empty($value)) { - print ' '; + } else { + $value = ' '; } + print $value; print ''; } } From ed172421f0bf1b425fb86227686dbcc633558d54 Mon Sep 17 00:00:00 2001 From: Ferran Marcet Date: Tue, 12 Apr 2022 19:20:45 +0200 Subject: [PATCH 42/59] Fix: The resource dropdown does not show the values --- htdocs/resource/class/html.formresource.class.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/resource/class/html.formresource.class.php b/htdocs/resource/class/html.formresource.class.php index fa775bf5d58..a541dfab700 100644 --- a/htdocs/resource/class/html.formresource.class.php +++ b/htdocs/resource/class/html.formresource.class.php @@ -225,7 +225,8 @@ class FormResource $value = ($maxlength ?dol_trunc($arraytypes['label'], $maxlength) : $arraytypes['label']); } elseif ($format == 3) { $value = $arraytypes['code']; - } else { + } + if (empty($value)) { $value = ' '; } print $value; From 5e76c1a45d627ab077413ceab556694549558c0f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 12 Apr 2022 21:59:34 +0200 Subject: [PATCH 43/59] Fix doc --- htdocs/install/mysql/migration/14.0.0-15.0.0.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/install/mysql/migration/14.0.0-15.0.0.sql b/htdocs/install/mysql/migration/14.0.0-15.0.0.sql index 30636a8bb98..6f35a9f1c44 100644 --- a/htdocs/install/mysql/migration/14.0.0-15.0.0.sql +++ b/htdocs/install/mysql/migration/14.0.0-15.0.0.sql @@ -512,5 +512,5 @@ INSERT INTO llx_c_action_trigger (code,label,description,elementtype,rang) value -- Add column to help to fix a very critical bug when transferring into accounting bank record of a bank account into another currency. -- Idea is to update this column manually in v15 with value in currency of company for bank that are not into the main currency and the transfer --- into accounting will use it in priority if value is not null. +-- into accounting will use it in priority if value is not null. The script repair.sql contains the sequence to fix datas in llx_bank. ALTER TABLE llx_bank ADD COLUMN amount_main_currency double(24,8) NULL; From 6a7212a48df1a03baeed55960379992303141ad6 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 12 Apr 2022 22:02:46 +0200 Subject: [PATCH 44/59] Fix sql error --- htdocs/compta/tva/class/tva.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/compta/tva/class/tva.class.php b/htdocs/compta/tva/class/tva.class.php index a6828587763..1b71cb261e1 100644 --- a/htdocs/compta/tva/class/tva.class.php +++ b/htdocs/compta/tva/class/tva.class.php @@ -137,7 +137,7 @@ class Tva extends CommonObject $sql .= "fk_user_creat,"; $sql .= "fk_user_modif"; $sql .= ") VALUES ("; - $sql .= " ".((int) $conf->entity.", "; + $sql .= " ".((int) $conf->entity).", "; $sql .= " '".$this->db->idate($now)."',"; $sql .= " '".$this->db->idate($this->datep)."',"; $sql .= " '".$this->db->idate($this->datev)."',"; From 914b037a9aa0a458cc253f5d4d3f7888d3ec9dae Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 12 Apr 2022 22:35:12 +0200 Subject: [PATCH 45/59] Fix regression: bad cache management of linked object loading. --- htdocs/core/class/commonobject.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index d53080437a7..a3c9c2e8122 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -3847,7 +3847,7 @@ abstract class CommonObject } else { $sql .= "(fk_source = ".((int) $sourceid)." AND sourcetype = '".$this->db->escape($sourcetype)."')"; $sql .= " ".$clause." (fk_target = ".((int) $targetid)." AND targettype = '".$this->db->escape($targettype)."')"; - if ($this->id > 0 && $sourceid == $this->id && $sourcetype == $this->element && $targetid == $this->id && $targettype == $this->element && $clause == 'OR') { + if ($loadalsoobjects && $this->id > 0 && $sourceid == $this->id && $sourcetype == $this->element && $targetid == $this->id && $targettype == $this->element && $clause == 'OR') { $this->linkedObjectsFullLoaded[$this->id] = true; } } From e9e10e84b2adb333e276f8dd5fce713b34ed87bb Mon Sep 17 00:00:00 2001 From: Norbert Penel Date: Wed, 13 Apr 2022 10:47:33 +0200 Subject: [PATCH 46/59] ensure priority in this usage ensure priority in this usage --- htdocs/product/class/product.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index bd3cf69c86a..6fd09ed9723 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -1690,7 +1690,7 @@ class Product extends CommonObject $testExit = array('multiprices','multiprices_ttc','multiprices_base_type','multiprices_min','multiprices_min_ttc','multiprices_tva_tx','multiprices_recuperableonly'); foreach ($testExit as $field) { - if (!isset($this->$field[$level])) { + if (!isset($this->{$field}[$level])) { return array(); } } From 29242a23c36be39dfe7f76a21ae02aecce75165b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 13 Apr 2022 12:11:35 +0200 Subject: [PATCH 47/59] Update product.class.php --- htdocs/product/class/product.class.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index 6fd09ed9723..8ff89d8d086 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -1690,7 +1690,11 @@ class Product extends CommonObject $testExit = array('multiprices','multiprices_ttc','multiprices_base_type','multiprices_min','multiprices_min_ttc','multiprices_tva_tx','multiprices_recuperableonly'); foreach ($testExit as $field) { - if (!isset($this->{$field}[$level])) { + if (!isset($this->$field)) { + return array(); + } + $tmparray = $this->$field; + if (!isset($tmparray[$level])) { return array(); } } From d154696c32b3ccdeb02b161fd3e04d27db2a3c02 Mon Sep 17 00:00:00 2001 From: BB2A Anthony Berton Date: Wed, 13 Apr 2022 16:15:07 +0200 Subject: [PATCH 48/59] morecss select_compagny --- htdocs/comm/propal/card.php | 2 +- htdocs/commande/card.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/comm/propal/card.php b/htdocs/comm/propal/card.php index 0153f554169..f6989d90d59 100644 --- a/htdocs/comm/propal/card.php +++ b/htdocs/comm/propal/card.php @@ -1921,7 +1921,7 @@ if ($action == 'create') { $formquestion = array( // 'text' => $langs->trans("ConfirmClone"), // array('type' => 'checkbox', 'name' => 'clone_content', 'label' => $langs->trans("CloneMainAttributes"), 'value' => 1), - array('type' => 'other', 'name' => 'socid', 'label' => $langs->trans("SelectThirdParty"), 'value' => $form->select_company(GETPOST('socid', 'int'), 'socid', '(s.client=1 OR s.client=2 OR s.client=3)')), + array('type' => 'other', 'name' => 'socid', 'label' => $langs->trans("SelectThirdParty"), 'value' => $form->select_company(GETPOST('socid', 'int'), 'socid', '(s.client=1 OR s.client=2 OR s.client=3)', '', 0, 0, null, 0, 'maxwidth300')), array('type' => 'checkbox', 'name' => 'update_prices', 'label' => $langs->trans('PuttingPricesUpToDate'), 'value' => (!empty($conf->global->PROPOSAL_CLONE_UPDATE_PRICES) ? 1 : 0)), ); if (!empty($conf->global->PROPAL_CLONE_DATE_DELIVERY) && !empty($object->delivery_date)) { diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php index 3a903e233de..53b6d40d6b0 100644 --- a/htdocs/commande/card.php +++ b/htdocs/commande/card.php @@ -2043,7 +2043,7 @@ if ($action == 'create' && $usercancreate) { if ($action == 'clone') { // Create an array for form $formquestion = array( - array('type' => 'other', 'name' => 'socid', 'label' => $langs->trans("SelectThirdParty"), 'value' => $form->select_company(GETPOST('socid', 'int'), 'socid', '(s.client=1 OR s.client = 2 OR s.client=3)')) + array('type' => 'other', 'name' => 'socid', 'label' => $langs->trans("SelectThirdParty"), 'value' => $form->select_company(GETPOST('socid', 'int'), 'socid', '(s.client=1 OR s.client = 2 OR s.client=3)', '', 0, 0, null, 0, 'maxwidth300')) ); $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ToClone'), $langs->trans('ConfirmCloneOrder', $object->ref), 'confirm_clone', $formquestion, 'yes', 1); } From 90366b1b81799d1244275e1559f1b9d8589204d8 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 13 Apr 2022 16:21:25 +0200 Subject: [PATCH 49/59] Revert "NEW : Import with select boxes" --- htdocs/imports/import.php | 188 +++++++++----------------------- htdocs/langs/en_US/exports.lang | 4 +- htdocs/langs/fr_FR/exports.lang | 4 +- 3 files changed, 54 insertions(+), 142 deletions(-) diff --git a/htdocs/imports/import.php b/htdocs/imports/import.php index 9ec98f8a495..01f152f1ea5 100644 --- a/htdocs/imports/import.php +++ b/htdocs/imports/import.php @@ -136,14 +136,13 @@ $step = (GETPOST('step') ? GETPOST('step') : 1); $import_name = GETPOST('import_name'); $hexa = GETPOST('hexa'); $importmodelid = GETPOST('importmodelid'); -$excludefirstline = (GETPOST('excludefirstline') ? GETPOST('excludefirstline') : 2); +$excludefirstline = (GETPOST('excludefirstline') ? GETPOST('excludefirstline') : 1); $endatlinenb = (GETPOST('endatlinenb') ? GETPOST('endatlinenb') : ''); $updatekeys = (GETPOST('updatekeys', 'array') ? GETPOST('updatekeys', 'array') : array()); $separator = (GETPOST('separator', 'nohtml') ? GETPOST('separator', 'nohtml') : (!empty($conf->global->IMPORT_CSV_SEPARATOR_TO_USE) ? $conf->global->IMPORT_CSV_SEPARATOR_TO_USE : ',')); $enclosure = (GETPOST('enclosure', 'nohtml') ? GETPOST('enclosure', 'nohtml') : '"'); $separator_used = str_replace('\t', "\t", $separator); - $objimport = new Import($db); $objimport->load_arrays($user, ($step == 1 ? '' : $datatoimport)); @@ -161,7 +160,7 @@ foreach ($fieldsarray as $elem) { $tabelem = explode('=', $elem, 2); $key = $tabelem[0]; $val = (isset($tabelem[1]) ? $tabelem[1] : ''); - if ($key && $val && ($key > 0 && $step != 4)) { + if ($key && $val) { $array_match_file_to_database[$key] = $val; } } @@ -326,16 +325,13 @@ if ($action == 'saveorder') { $pos = 0; foreach ($fieldsarray as $fieldnb) { // For each elem in list. fieldnb start from 1 to ... // Get name of database fields at position $pos and put it into $namefield - $posbis = 0; - - $namefield = ''; + $posbis = 0; $namefield = ''; foreach ($fieldstarget as $key => $val) { // key: val: //dol_syslog('AjaxImport key='.$key.' val='.$val); if ($posbis < $pos) { $posbis++; continue; } - // We found the key of targets that is at position pos $namefield = $key; //dol_syslog('AjaxImport Field name found for file field nb '.$fieldnb.'='.$namefield); @@ -1008,7 +1004,7 @@ if ($step == 4 && $datatoimport) { $lefti = 1; foreach ($array_match_file_to_database as $key => $val) { $var = !$var; - show_elem($fieldssource, $key, $val, $var, 1, '', $listofkeys); // key is field number in source file + show_elem($fieldssource, $key, $val, $var); // key is field number in source file //print '> '.$lefti.'-'.$key.'-'.$val; $listofkeys[$key] = 1; $fieldsplaced[$key] = 1; @@ -1027,7 +1023,7 @@ if ($step == 4 && $datatoimport) { while ($lefti <= $num) { $var = !$var; $newkey = getnewkey($fieldssource, $listofkeys); - show_elem($fieldssource, $newkey, '', $var, 1, '', $listofkeys); // key start after field number in source file + show_elem($fieldssource, $newkey, '', $var); // key start after field number in source file //print '> '.$lefti.'-'.$newkey; $listofkeys[$key] = 1; $lefti++; @@ -1041,14 +1037,11 @@ if ($step == 4 && $datatoimport) { print '
'; @@ -1188,51 +1180,35 @@ if ($step == 4 && $datatoimport) { if ($conf->use_javascript_ajax) { print ''."\n"; @@ -1495,20 +1471,6 @@ if ($step == 5 && $datatoimport) { if ($action == 'launchsimu') { print '   '.$langs->trans("Modify").''; } - if ($excludefirstline == 2) { - print $form->textwithpicto("", $langs->trans("WarningFirstImportedLine", $excludefirstline), 1, 'warning', "warningexcludefirstline"); - print ''; - } print ''; // Keys for data UPDATE (not INSERT of new data) @@ -2131,21 +2093,18 @@ $db->close(); /** * Function to put the movable box of a source field * - * @param array $fieldssource List of source fields - * @param int $pos Pos - * @param string $key Key - * @param boolean $var Line style (odd or not) - * @param boolean $isimportedfield Verify if it's an imported field - * @param int $nostyle Hide style - * @param array $listofkeys List of keys for select boxes + * @param array $fieldssource List of source fields + * @param int $pos Pos + * @param string $key Key + * @param boolean $var Line style (odd or not) + * @param int $nostyle Hide style * @return void */ -function show_elem($fieldssource, $pos, $key, $var, $isimportedfield, $nostyle = '', &$listofkeys = array()) +function show_elem($fieldssource, $pos, $key, $var, $nostyle = '') { global $langs, $bc; - // $height = '24px'; - $height = '30px'; + $height = '24px'; if ($key == 'none') { //stop multiple duplicate ids with no number @@ -2162,7 +2121,7 @@ function show_elem($fieldssource, $pos, $key, $var, $isimportedfield, $nostyle = if ($pos && $pos > count($fieldssource)) { // No fields print ''; print ''; print ''; print ''; - } elseif (empty($isimportedfield)) { - $example = !empty($fieldssource[$pos]['example1'])?$fieldssource[$pos]['example1']:""; - if ($example) { - if (!utf8_check($example)) { - $example = utf8_encode($example); - } - print ''; - print ''; - print ''; - print ''; - } } else { // Print field of source file print ''; print ''; - print ''; print ''; print ''; } diff --git a/htdocs/langs/en_US/exports.lang b/htdocs/langs/en_US/exports.lang index 8bbc6f1ad98..f2f2d2cf587 100644 --- a/htdocs/langs/en_US/exports.lang +++ b/htdocs/langs/en_US/exports.lang @@ -8,7 +8,7 @@ ImportableDatas=Importable dataset SelectExportDataSet=Choose dataset you want to export... SelectImportDataSet=Choose dataset you want to import... SelectExportFields=Choose the fields you want to export, or select a predefined export profile -SelectImportFields=Choose the source file fields you want to import and their target field in database by choosing the fields with the select box, or select a predefined import profile: +SelectImportFields=Choose the source file fields you want to import and their target field in database by moving them up and down with anchor %s, or select a predefined import profile: NotImportedFields=Fields of source file not imported SaveExportModel=Save your selections as an export profile/template (for reuse). SaveImportModel=Save this import profile (for reuse) ... @@ -135,5 +135,3 @@ NbInsert=Number of inserted lines: %s NbUpdate=Number of updated lines: %s MultipleRecordFoundWithTheseFilters=Multiple records have been found with these filters: %s StocksWithBatch=Stocks and location (warehouse) of products with batch/serial number -WarningFirstImportedLine=The first line(s) will not be imported with the current selection -EmptyField=Empty field \ No newline at end of file diff --git a/htdocs/langs/fr_FR/exports.lang b/htdocs/langs/fr_FR/exports.lang index 4f4490ef4a5..5c87e8f186f 100644 --- a/htdocs/langs/fr_FR/exports.lang +++ b/htdocs/langs/fr_FR/exports.lang @@ -8,7 +8,7 @@ ImportableDatas=Lot de données importables SelectExportDataSet=Choisissez un lot prédéfini de données que vous désirez exporter… SelectImportDataSet=Choisissez un lot prédéfini de données que vous désirez importer… SelectExportFields=Choisissez les champs à exporter, ou choisissez un profil d'export prédéfini -SelectImportFields=Choisissez les champs du fichier source à importer et leur destination dans la base en utilisant les boîtes de sélection, ou choisissez un profil d'import prédéfini: +SelectImportFields=Choisissez les champs du fichier source à importer et leur destination dans la base en les déplaçant vers le haut ou vers le bas via l'ancre %s, ou choisissez un profil d'import prédéfini: NotImportedFields=Champs du fichier source non importés SaveExportModel=Enregistrer ce profil d'export (si vous désirez le réutiliser ultérieurement) … SaveImportModel=Enregistrer ce profil d'import (si vous désirez le réutiliser ultérieurement) … @@ -135,5 +135,3 @@ NbInsert=Nombre de lignes insérées: %s NbUpdate=Nombre de lignes mises à jour: %s MultipleRecordFoundWithTheseFilters=Plusieurs enregistrements ont été trouvés avec ces filtres: %s StocksWithBatch=Stocks et entrepôts des produits avec numéro de lot/série -WarningFirstImportedLine=Les première(s) ligne(s) ne seront pas importée(s) avec cette selection -EmptyField=Champ vide From 5f7f9a751508dc5840151b0f674a671a2a88281a Mon Sep 17 00:00:00 2001 From: lvessiller Date: Thu, 14 Apr 2022 09:48:06 +0200 Subject: [PATCH 50/59] FIX include tpl path in product stock --- htdocs/product/stock/tpl/stockcorrection.tpl.php | 2 +- htdocs/product/stock/tpl/stocktransfer.tpl.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/product/stock/tpl/stockcorrection.tpl.php b/htdocs/product/stock/tpl/stockcorrection.tpl.php index eb84df7d14e..6afea0abe54 100644 --- a/htdocs/product/stock/tpl/stockcorrection.tpl.php +++ b/htdocs/product/stock/tpl/stockcorrection.tpl.php @@ -180,7 +180,7 @@ print ''; print ''; // Extrafield template -include 'extrafields_add.tpl.php'; +include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_add.tpl.php'; print '
'; + print $i; + print ''; print dol_escape_htmltag($menu['type']); print ''.img_picto($langs->trans("Edit"), 'edit').' '; - print ''.img_picto($langs->trans("Delete"), 'delete').'
'; print ' '.$langs->trans("TriggersFile").' : '.$pathtofile.''; print ''.img_picto($langs->trans("Edit"), 'edit').''.img_picto($langs->trans("Delete"), 'delete').''.img_picto($langs->trans("Delete"), 'delete').'
'.img_picto($langs->trans("Edit"), 'edit').''.img_picto($langs->trans("Delete"), 'delete').''.img_picto($langs->trans("Edit"), 'edit').''.img_picto($langs->trans("Delete"), 'delete').''.img_picto('Generate', 'generate', 'class="paddingleft"').''; // List of target fields - // $height = '24px'; //needs px for css height attribute below - $height = '30px'; + $height = '24px'; //needs px for css height attribute below $i = 0; $mandatoryfieldshavesource = true; - $fieldselect = 1; - print ''; - $pos = 1; + print '
'; foreach ($fieldstarget as $code => $label) { print ''; @@ -1058,7 +1051,7 @@ if ($step == 4 && $datatoimport) { $tablealias = preg_replace('/(\..*)$/i', '', $code); $tablename = $objimport->array_import_tables[0][$tablealias]; - $entityicon = !empty($entitytoicon[$entity]) ? $entitytoicon[$entity] : $entity; // $entityicon must string name of picto of the field like 'project', 'company', 'contact', 'modulename', ... + $entityicon = $entitytoicon[$entity] ? $entitytoicon[$entity] : $entity; // $entityicon must string name of picto of the field like 'project', 'company', 'contact', 'modulename', ... $entitylang = $entitytolang[$entity] ? $entitytolang[$entity] : $objimport->array_import_label[0]; // $entitylang must be a translation key to describe object the field is related to, like 'Company', 'Contact', 'MyModyle', ... print ''; @@ -1078,7 +1071,7 @@ if ($step == 4 && $datatoimport) { print ''; // Info field print ''; print ''; - $fieldselect++; } print '
=>'.img_object('', $entityicon).' '.$langs->trans($entitylang).''; - $filecolumn = !empty($array_match_database_to_file[$code])?$array_match_database_to_file[$code]:0; + $filecolumn = $array_match_database_to_file[$code]; // Source field info $htmltext = ''.$langs->trans("FieldSource").'
'; if ($filecolumn > count($fieldssource)) { @@ -1098,7 +1091,7 @@ if ($step == 4 && $datatoimport) { } // Source required $htmltext .= $langs->trans("SourceRequired").': '.yn(preg_match('/\*$/', $label)).'
'; - $example = !empty($objimport->array_import_examplevalues[0][$code])?$objimport->array_import_examplevalues[0][$code]:""; + $example = $objimport->array_import_examplevalues[0][$code]; // Example if (empty($objimport->array_import_convertvalue[0][$code])) { // If source file does not need convertion if ($example) { @@ -1136,7 +1129,6 @@ if ($step == 4 && $datatoimport) { print '
'; @@ -1155,7 +1147,7 @@ if ($step == 4 && $datatoimport) { if (empty($fieldsplaced[$key])) { // $nbofnotimportedfields++; - show_elem($fieldssource, $key, '', $var, 0, 'nostyle', $listofkeys); + show_elem($fieldssource, $key, '', $var, 'nostyle'); //print '> '.$lefti.'-'.$key; $listofkeys[$key] = 1; $lefti++; @@ -1164,7 +1156,7 @@ if ($step == 4 && $datatoimport) { // Print one more empty field $newkey = getnewkey($fieldssource, $listofkeys); - show_elem($fieldssource, $newkey, '', $var, 1, 'nostyle', $listofkeys); + show_elem($fieldssource, $newkey, '', $var, 'nostyle'); //print '> '.$lefti.'-'.$newkey; $listofkeys[$newkey] = 1; $nbofnotimportedfields++; @@ -1177,7 +1169,7 @@ if ($step == 4 && $datatoimport) { $i = 0; while ($i < $nbofnotimportedfields) { // Print empty cells - show_elem('', '', 'none', $var, 0, 'nostyle', $listofkeys); + show_elem('', '', 'none', $var, 'nostyle'); $i++; } print '
'; - //print img_picto(($pos > 0 ? $langs->trans("MoveField", $pos) : ''), 'grip_title', 'class="boxhandle" style="cursor:move;"'); + print img_picto(($pos > 0 ? $langs->trans("MoveField", $pos) : ''), 'grip_title', 'class="boxhandle" style="cursor:move;"'); print ''; print $langs->trans("NoFields"); @@ -2177,65 +2136,22 @@ function show_elem($fieldssource, $pos, $key, $var, $isimportedfield, $nostyle = print ' '; print '
'; - print ' '; - print ''; - print $langs->trans("EmptyField").': '; - print ' ('.$example.')'; - print '
'; // The image must have the class 'boxhandle' beause it's value used in DOM draggable objects to define the area used to catch the full object - //print img_picto($langs->trans("MoveField", $pos), 'grip_title', 'class="boxhandle" style="cursor:move;"'); + print img_picto($langs->trans("MoveField", $pos), 'grip_title', 'class="boxhandle" style="cursor:move;"'); print ''; - $example = !empty($fieldssource[$pos]['example1'])?$fieldssource[$pos]['example1']:""; - if ($example != "") { - print $langs->trans("Field").' '.$pos.': '; - } else { - print $langs->trans("EmptyField").': '; - } + print ''; + print $langs->trans("Field").' '.$pos; + $example = $fieldssource[$pos]['example1']; if ($example) { if (!utf8_check($example)) { $example = utf8_encode($example); } - } - $nameselect = ($pos > 0) ? $pos : (-$pos); - print ''; - print '
'; diff --git a/htdocs/product/stock/tpl/stocktransfer.tpl.php b/htdocs/product/stock/tpl/stocktransfer.tpl.php index ccedf993221..f1c08b7673e 100644 --- a/htdocs/product/stock/tpl/stocktransfer.tpl.php +++ b/htdocs/product/stock/tpl/stocktransfer.tpl.php @@ -137,7 +137,7 @@ print ''; print ''; // Extrafield template -include 'extrafields_add.tpl.php'; +include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_add.tpl.php'; print ''; From c90d758b0ff06021b5eafd72b69c0276fa88e4eb Mon Sep 17 00:00:00 2001 From: lmarcouiller Date: Thu, 14 Apr 2022 11:06:54 +0200 Subject: [PATCH 51/59] New : add of unique(entity,label) --- htdocs/install/mysql/migration/15.0.0-16.0.0.sql | 2 ++ .../tables/llx_takepos_floor_tables.key.sql | 16 ++++++++++++++++ htdocs/takepos/floors.php | 2 +- 3 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 htdocs/install/mysql/tables/llx_takepos_floor_tables.key.sql diff --git a/htdocs/install/mysql/migration/15.0.0-16.0.0.sql b/htdocs/install/mysql/migration/15.0.0-16.0.0.sql index 5f8b1d886c3..745955c7bcd 100644 --- a/htdocs/install/mysql/migration/15.0.0-16.0.0.sql +++ b/htdocs/install/mysql/migration/15.0.0-16.0.0.sql @@ -324,3 +324,5 @@ ALTER TABLE llx_actioncomm MODIFY COLUMN note mediumtext; DELETE FROM llx_boxes WHERE box_id IN (select rowid FROM llx_boxes_def WHERE file IN ('box_bom.php@bom', 'box_bom.php')); DELETE FROM llx_boxes_def WHERE file IN ('box_bom.php@bom', 'box_bom.php'); + +ALTER TABLE llx_takepos_floor_tables ADD UNIQUE(entity,label); \ No newline at end of file diff --git a/htdocs/install/mysql/tables/llx_takepos_floor_tables.key.sql b/htdocs/install/mysql/tables/llx_takepos_floor_tables.key.sql new file mode 100644 index 00000000000..e90cd67e889 --- /dev/null +++ b/htdocs/install/mysql/tables/llx_takepos_floor_tables.key.sql @@ -0,0 +1,16 @@ +-- Copyright (C) 2018 SuperAdmin +-- +-- 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 +-- the Free Software Foundation, either version 3 of the License, or +-- (at your option) any later version. +-- +-- This program is distributed in the hope that it will be useful, +-- but WITHOUT ANY WARRANTY; without even the implied warranty of +-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +-- GNU General Public License for more details. +-- +-- You should have received a copy of the GNU General Public License +-- along with this program. If not, see https://www.gnu.org/licenses/. + +ALTER TABLE llx_takepos_floor_tables ADD UNIQUE(entity,label); \ No newline at end of file diff --git a/htdocs/takepos/floors.php b/htdocs/takepos/floors.php index 64040a24466..73e84109116 100644 --- a/htdocs/takepos/floors.php +++ b/htdocs/takepos/floors.php @@ -104,7 +104,7 @@ if ($action == "updatename") { if (strlen($newname) > 3) { $newname = substr($newname, 0, 3); // Only 3 chars } - $db->query("UPDATE ".MAIN_DB_PREFIX."takepos_floor_tables set label='".$db->escape($newname)."' WHERE rowid = ".((int) $place)); + $resql = $db->query("UPDATE ".MAIN_DB_PREFIX."takepos_floor_tables set label='".$db->escape($newname)."' WHERE rowid = ".((int) $place)); } if ($action == "add") { From f15438dd039dc3f6ecb7c4c3642d83f8e57e7927 Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Thu, 14 Apr 2022 12:28:51 +0200 Subject: [PATCH 52/59] NEW: data sign on propal list --- htdocs/comm/propal/list.php | 71 ++++++++++++++++++++++++++++++++++++- 1 file changed, 70 insertions(+), 1 deletion(-) diff --git a/htdocs/comm/propal/list.php b/htdocs/comm/propal/list.php index 73b4c479b2e..561682ba02f 100644 --- a/htdocs/comm/propal/list.php +++ b/htdocs/comm/propal/list.php @@ -123,6 +123,15 @@ $search_fk_input_reason = GETPOST("search_fk_input_reason", 'int'); $search_fk_mode_reglement = GETPOST("search_fk_mode_reglement", 'int'); $search_btn = GETPOST('button_search', 'alpha'); $search_remove_btn = GETPOST('button_removefilter', 'alpha'); +$search_date_signature_startday = GETPOST('search_date_signature_startday', 'int'); +$search_date_signature_startmonth = GETPOST('search_date_signature_startmonth', 'int'); +$search_date_signature_startyear = GETPOST('search_date_signature_startyear', 'int'); +$search_date_signature_endday = GETPOST('search_date_signature_endday', 'int'); +$search_date_signature_endmonth = GETPOST('search_date_signature_endmonth', 'int'); +$search_date_signature_endyear = GETPOST('search_date_signature_endyear', 'int'); +$search_date_signature_start = dol_mktime(0, 0, 0, $search_date_signature_startmonth, $search_date_signature_startday, $search_date_signature_startyear); +$search_date_signature_end = dol_mktime(23, 59, 59, $search_date_signature_endmonth, $search_date_signature_endday, $search_date_signature_endyear); + $search_status = GETPOST('search_status', 'alpha'); $optioncss = GETPOST('optioncss', 'alpha'); @@ -207,6 +216,7 @@ $arrayfields = array( 'p.date'=>array('label'=>"DatePropal", 'checked'=>1), 'p.fin_validite'=>array('label'=>"DateEnd", 'checked'=>1), 'p.date_livraison'=>array('label'=>"DeliveryDate", 'checked'=>0), + 'p.date_signature'=>array('label'=>"DateSigning", 'checked'=>0), 'ava.rowid'=>array('label'=>"AvailabilityPeriod", 'checked'=>0), 'p.fk_shipping_method'=>array('label'=>"SendingMethod", 'checked'=>0, 'enabled'=>!empty($conf->expedition->enabled)), 'p.fk_input_reason'=>array('label'=>"Origin", 'checked'=>0, 'enabled'=>1), @@ -337,6 +347,14 @@ if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x' $search_fk_shipping_method = ''; $search_fk_input_reason = ''; $search_fk_mode_reglement = ''; + $search_date_signature_startday = ''; + $search_date_signature_startmonth = ''; + $search_date_signature_startyear = ''; + $search_date_signature_endday = ''; + $search_date_signature_endmonth = ''; + $search_date_signature_endyear = ''; + $search_date_signature_start = ''; + $search_date_signature_end = ''; } if ($object_statut != '') { $search_status = $object_statut; @@ -517,6 +535,7 @@ $sql .= " state.code_departement as state_code, state.nom as state_name,"; $sql .= ' p.rowid, p.entity as propal_entity, p.note_private, p.total_ht, p.total_tva, p.total_ttc, p.localtax1, p.localtax2, p.ref, p.ref_client, p.fk_statut as status, p.fk_user_author, p.datep as dp, p.fin_validite as dfv,p.date_livraison as ddelivery,'; $sql .= ' p.fk_multicurrency, p.multicurrency_code, p.multicurrency_tx, p.multicurrency_total_ht, p.multicurrency_total_tva, p.multicurrency_total_ttc,'; $sql .= ' p.datec as date_creation, p.tms as date_update, p.date_cloture as date_cloture,'; +$sql .= ' p.date_signature as dsignature,'; $sql .= ' p.note_public, p.note_private,'; $sql .= ' p.fk_cond_reglement,p.fk_mode_reglement,p.fk_shipping_method,p.fk_input_reason,'; $sql .= " pr.rowid as project_id, pr.ref as project_ref, pr.title as project_label,"; @@ -701,6 +720,12 @@ if ($search_sale > 0) { if ($search_user > 0) { $sql .= " AND c.fk_c_type_contact = tc.rowid AND tc.element='propal' AND tc.source='internal' AND c.element_id = p.rowid AND c.fk_socpeople = ".((int) $search_user); } +if ($search_date_signature_start) { + $sql .= " AND p.date_signature >= '".$db->idate($search_date_signature_start)."'"; +} +if ($search_date_signature_end) { + $sql .= " AND p.date_signature <= '".$db->idate($search_date_signature_end)."'"; +} // Add where from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php'; @@ -917,6 +942,24 @@ if ($resql) { if ($search_country) { $param .= '&search_country='.urlencode($search_country); } + if ($search_date_signature_startday) { + $param .= '&search_date_signature_startday='.urlencode($search_date_signature_startday); + } + if ($search_date_signature_startmonth) { + $param .= '&search_date_signature_startmonth='.urlencode($search_date_signature_startmonth); + } + if ($search_date_signature_startyear) { + $param .= '&search_date_signature_startyear='.urlencode($search_date_signature_startyear); + } + if ($search_date_signature_endday) { + $param .= '&search_date_signature_endday='.urlencode($search_date_signature_endday); + } + if ($search_date_signature_endmonth) { + $param .= '&search_date_signature_endmonth='.urlencode($search_date_signature_endmonth); + } + if ($search_date_signature_endyear) { + $param .= '&search_date_signature_endyear='.urlencode($search_date_signature_endyear); + } // Add $param from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; @@ -1148,6 +1191,17 @@ if ($resql) { print '
'; print ''; } + // Date Signature + if (!empty($arrayfields['p.date_signature']['checked'])) { + print ''; + print '
'; + print $form->selectDate($search_date_signature_start ? $search_date_signature_start : -1, 'search_date_signature_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From')); + print '
'; + print '
'; + print $form->selectDate($search_date_signature_end ? $search_date_signature_end : -1, 'search_date_signature_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From')); + print '
'; + print ''; + } // Availability if (!empty($arrayfields['ava.rowid']['checked'])) { print ''; @@ -1361,7 +1415,10 @@ if ($resql) { print_liste_field_titre($arrayfields['p.fin_validite']['label'], $_SERVER["PHP_SELF"], 'dfv', '', $param, 'align="center"', $sortfield, $sortorder); } if (!empty($arrayfields['p.date_livraison']['checked'])) { - print_liste_field_titre($arrayfields['p.date_livraison']['label'], $_SERVER["PHP_SELF"], 'ddelivery', '', $param, 'align="center"', $sortfield, $sortorder); + print_liste_field_titre($arrayfields['p.date_livraison']['label'], $_SERVER["PHP_SELF"], 'p.date_livraison', '', $param, 'align="center"', $sortfield, $sortorder); + } + if (!empty($arrayfields['p.date_signature']['checked'])) { + print_liste_field_titre($arrayfields['p.date_signature']['label'], $_SERVER["PHP_SELF"], 'p.date_signature', '', $param, 'align="center"', $sortfield, $sortorder); } if (!empty($arrayfields['ava.rowid']['checked'])) { print_liste_field_titre($arrayfields['ava.rowid']['label'], $_SERVER["PHP_SELF"], 'availability', '', $param, '', $sortfield, $sortorder); @@ -1720,6 +1777,18 @@ if ($resql) { $totalarray['nbfield']++; } } + // Date Signature + if (!empty($arrayfields['p.date_signature']['checked'])) { + if ($obj->dsignature) { + print ''.dol_print_date($db->jdate($obj->dsignature), 'day'); + print ''; + } else { + print ' '; + } + if (!$i) { + $totalarray['nbfield']++; + } + } // Availability if (!empty($arrayfields['ava.rowid']['checked'])) { print ''; From 3d21023110a27ab96d6ff0fafb8ae6eb3117709a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 14 Apr 2022 14:11:40 +0200 Subject: [PATCH 53/59] Label of option --- htdocs/admin/pdf.php | 6 +++--- htdocs/langs/en_US/companies.lang | 1 + 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/htdocs/admin/pdf.php b/htdocs/admin/pdf.php index fd8377b0a27..1e015d69f9c 100644 --- a/htdocs/admin/pdf.php +++ b/htdocs/admin/pdf.php @@ -309,7 +309,7 @@ print ''.$langs->trans("Par // Show sender name -/* Set option as hidden because no need of this for 99.99% of users. +/* Set option as hidden because no need of this for 99.99% of users. Having it as hidden feature is enough. print ''.$langs->trans("MAIN_PDF_HIDE_SENDER_NAME").''; if ($conf->use_javascript_ajax) { print ajax_constantonoff('MAIN_PDF_HIDE_SENDER_NAME'); @@ -321,7 +321,7 @@ print ''; // Hide VAT Intra on address -print ''.$langs->trans("ShowVATIntaInAddress").''; +print ''.$langs->trans("ShowVATIntaInAddress").' - '.$langs->trans("ThirdPartyAddress").''; if ($conf->use_javascript_ajax) { print ajax_constantonoff('MAIN_TVAINTRA_NOT_IN_ADDRESS'); } else { @@ -340,7 +340,7 @@ for ($i = 1; $i <= 6; $i++) { $pid = img_warning().' '.$langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("CompanyCountry")).''; } if ($pid) { - print ''.$langs->trans("ShowProfIdInAddress").' - '.$pid.''; + print ''.$langs->trans("ShowProfIdInAddress").' - '.$pid.' - '.$langs->trans("ThirdPartyAddress").''; $keyforconstant = 'MAIN_PROFID'.$i.'_IN_ADDRESS'; if ($conf->use_javascript_ajax) { print ajax_constantonoff($keyforconstant); diff --git a/htdocs/langs/en_US/companies.lang b/htdocs/langs/en_US/companies.lang index 093fb47189d..b1438691cd9 100644 --- a/htdocs/langs/en_US/companies.lang +++ b/htdocs/langs/en_US/companies.lang @@ -19,6 +19,7 @@ ProspectionArea=Prospection area IdThirdParty=Id third party IdCompany=Company Id IdContact=Contact Id +ThirdPartyAddress=Third-party address ThirdPartyContacts=Third-party contacts ThirdPartyContact=Third-party contact/address Company=Company From 8a9be6705d4c674013dfa2ab74184b2370d73df4 Mon Sep 17 00:00:00 2001 From: kamel Date: Thu, 14 Apr 2022 14:14:07 +0200 Subject: [PATCH 54/59] FIX: Call of printOriginObjectLine hook --- htdocs/core/class/commonobject.class.php | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 02421ea9157..7828e61b166 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -4824,11 +4824,9 @@ abstract class CommonObject if (!empty($this->lines)) { foreach ($this->lines as $line) { if (is_object($hookmanager) && (($line->product_type == 9 && !empty($line->special_code)) || !empty($line->fk_parent_line))) { - if (empty($line->fk_parent_line)) { - $parameters = array('line'=>$line, 'i'=>$i); - $action = ''; - $hookmanager->executeHooks('printOriginObjectLine', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks - } + $parameters = array('line' => $line, 'i' => $i); + $action = ''; + $hookmanager->executeHooks('printOriginObjectLine', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks } else { $this->printOriginLine($line, '', $restrictlist, '/core/tpl', $selectedLines); } From e0d208214731df7f404c33b1488f543e4ad0d109 Mon Sep 17 00:00:00 2001 From: UT from dolibit <45215329+dolibit-ut@users.noreply.github.com> Date: Thu, 14 Apr 2022 16:49:08 +0200 Subject: [PATCH 55/59] Update barcode_EAN13.txt start formatting & english translation --- dev/resources/iso-normes/barcode_EAN13.txt | 64 +++++++++++----------- 1 file changed, 32 insertions(+), 32 deletions(-) diff --git a/dev/resources/iso-normes/barcode_EAN13.txt b/dev/resources/iso-normes/barcode_EAN13.txt index f4496327ee4..f6b3c5f5ebb 100644 --- a/dev/resources/iso-normes/barcode_EAN13.txt +++ b/dev/resources/iso-normes/barcode_EAN13.txt @@ -16,57 +16,57 @@ Voici la liste des codes pays ou systeme : EN == -Meaning of the numbers. +Meaning of the numbers: -- 2 digits for the country code or system code +- first 2-3 digits for the country code or system code - 5 digits for the company identifier - 5 digits for item identifier - 1 digit for checksum This rule has been twisted many times to improve the use of the available numbers. -Here is the list of country codes or system: +Here is the list of country codes or system: List ==== -00 � 13 UCC (Etats-Unis et Canada) -20 � 29 Codification interne en magasin -30 � 37 GENCOD-EAN France -380 BCCI (Bulgarie) -383 SANA (Slovenie) -385 CRO-EAN (Croatie) -387 EAN-BIH (Bosnie-Herzegovine) -400 � 440 CCG (Allemagne) -45 + 49 Distribution Code Center � DCC (Japon) -460 � 469 UNISCAN - EAN Russie (Federation de Russie) -471 CAN (Taiwan) -474 EAN Estonie -475 EAN Lettonie -476 EAN Azerba� djan -477 EAN Lituanie -478 EAN Ouzbekistan -479 EAN Sri Lanka -480 PANC (Philippines) -481 EAN Bielorussie -482 EAN Ukraine -484 EAN Moldavie -485 EAN Armenie -486 EAN Georgie -487 EAN Kazakhstan -489 HKANA (Hong Kong) -50 E Centre UK +00 - 13 UCC (U.S.A / États-Unis & Canada) +20 - 29 Flag for internal numbering / Codification interne en magasin +30 - 37 GENCOD-EAN France +380 BCCI (Bulgaria) +383 SANA (Slovenia) +385 CRO-EAN (Croatia) +387 EAN-BIH (Bosnia-Herzegovina) +400-440 CCG (Allemagne/Germany) +45 + 49 Distribution Code Center - DCC (Japan) +460-469 UNISCAN - EAN Russia (Federation de Russie) +471 CAN Taiwan +474 EAN Estonia +475 EAN Latvia +476 EAN Azerbaijan +477 EAN Lithuania +478 EAN Uzbekistan +479 EAN Sri Lanka +480 PANC Philippines +481 EAN Belarus +482 EAN Ukraine +484 EAN Moldova +485 EAN Armenia +486 EAN Georgia +487 EAN Kazakhstan +489 HKANA Hong Kong +50 E Centre UK - United Kingdom 520 HELLCAN-EAN HELLAS (Grece) 528 EAN Liban 529 EAN Chypre -531 EAN-MAC (FYR Mac�donie) +531 EAN-MAC (FYR Macedonie) 535 EAN Malte 539 EAN Irlande -54 ICODIF/EAN Belgique. Luxembourg +54 ICODIF/EAN Belgique. Luxembourg 560 CODIPOR (Portugal) 569 EAN Islande -57 EAN Danemark +57 EAN Danemark 590 EAN Pologne 594 EAN Roumanie 599 H.A.P.M.H. (Hongrie) From d62d24a337778890f042a58aaa17d3ab459160aa Mon Sep 17 00:00:00 2001 From: Philippe GRAND Date: Thu, 14 Apr 2022 21:47:35 +0200 Subject: [PATCH 56/59] add code to get documents list by knowledgemanagement with api --- htdocs/api/class/api_documents.class.php | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/htdocs/api/class/api_documents.class.php b/htdocs/api/class/api_documents.class.php index da49e4cbba7..d4e35e848ac 100644 --- a/htdocs/api/class/api_documents.class.php +++ b/htdocs/api/class/api_documents.class.php @@ -458,6 +458,20 @@ class Documents extends DolibarrApi } $upload_dir = $conf->expensereport->dir_output.'/'.dol_sanitizeFileName($object->ref); + } elseif ($modulepart == 'knowledgemanagement') { + require_once DOL_DOCUMENT_ROOT.'/knowledgemanagement/class/knowledgerecord.class.php'; + + if (!DolibarrApiAccess::$user->rights->knowledgemanagement->knowledgerecord->read && !DolibarrApiAccess::$user->rights->knowledgemanagement->knowledgerecord->read) { + throw new RestException(401); + } + + $object = new KnowledgeRecord($this->db); + $result = $object->fetch($id, $ref); + if (!$result) { + throw new RestException(404, 'Expense report not found'); + } + + $upload_dir = $conf->knowledgemanagement->dir_output.'/knowledgerecord/'.dol_sanitizeFileName($object->ref); } elseif ($modulepart == 'categorie' || $modulepart == 'category') { require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; From 0023850c9a6f37c31db33d95a018ea3ee8d55fb5 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 14 Apr 2022 22:16:17 +0200 Subject: [PATCH 57/59] Update api_documents.class.php --- htdocs/api/class/api_documents.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/api/class/api_documents.class.php b/htdocs/api/class/api_documents.class.php index d4e35e848ac..9bf7dd7c117 100644 --- a/htdocs/api/class/api_documents.class.php +++ b/htdocs/api/class/api_documents.class.php @@ -468,7 +468,7 @@ class Documents extends DolibarrApi $object = new KnowledgeRecord($this->db); $result = $object->fetch($id, $ref); if (!$result) { - throw new RestException(404, 'Expense report not found'); + throw new RestException(404, 'KM article not found'); } $upload_dir = $conf->knowledgemanagement->dir_output.'/knowledgerecord/'.dol_sanitizeFileName($object->ref); From 06f112d3ce5454cd428d7862bea2fdd7402d426e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 14 Apr 2022 22:43:43 +0200 Subject: [PATCH 58/59] Update main.inc.php --- htdocs/main.inc.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index e66c9e9d313..dd8010dfa92 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -265,7 +265,7 @@ if (!empty($_POST["DOL_AUTOSET_COOKIE"])) { $cookiearrayvalue[$tmpkey] = $_POST[$postkey]; } } - $cookiename = ((empty($dolibarr_main_force_https) && isHTTPS() === false) ? $tmpautoset[0] : '__Secure-'.$tmpautoset[0]); // __Secure- || __Host- + $cookiename = $tmpautoset[0]; $cookievalue = json_encode($cookiearrayvalue); //var_dump('setcookie cookiename='.$cookiename.' cookievalue='.$cookievalue); if (PHP_VERSION_ID < 70300) { From 75d3b3527c148aa2e444f0ac70da2b2aaac7eb4c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 14 Apr 2022 22:45:56 +0200 Subject: [PATCH 59/59] Update main.inc.php --- htdocs/main.inc.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index dd8010dfa92..3b5793a2cf1 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -297,7 +297,7 @@ if (!empty($php_session_save_handler) && $php_session_save_handler == 'db') { // Must be done after the include of filefunc.inc.php so global variables of conf file are defined (like $dolibarr_main_instance_unique_id or $dolibarr_main_force_https). // Note: the function dol_getprefix() is defined into functions.lib.php but may have been defined to return a different key to manage another area to protect. $prefix = dol_getprefix(''); -$sessionname = ((empty($dolibarr_main_force_https) && isHTTPS() === false) ? 'DOLSESSID_'.$prefix : '__Secure-DOLSESSID_'.$prefix); // __Secure- || __Host- +$sessionname = 'DOLSESSID_'.$prefix; $sessiontimeout = 'DOLSESSTIMEOUT_'.$prefix; if (!empty($_COOKIE[$sessiontimeout])) { ini_set('session.gc_maxlifetime', $_COOKIE[$sessiontimeout]);