From 7cb657c99189a02695ba74e1b511ff5b3802e7aa Mon Sep 17 00:00:00 2001 From: Marc de Lima Lucio <68746600+marc-dll@users.noreply.github.com> Date: Fri, 19 Nov 2021 14:49:11 +0100 Subject: [PATCH 01/62] FIX: project timesheets: assume Saturday and Sunday are default weekend days when working days conf is empty or badly formed --- htdocs/projet/activity/perday.php | 5 +++++ htdocs/projet/activity/perweek.php | 6 +++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/htdocs/projet/activity/perday.php b/htdocs/projet/activity/perday.php index e315f638dd2..cefdf4d6463 100644 --- a/htdocs/projet/activity/perday.php +++ b/htdocs/projet/activity/perday.php @@ -620,6 +620,11 @@ $restrictviewformytask = ((!isset($conf->global->PROJECT_TIME_SHOW_TASK_NOT_ASSI // Get if user is available or not for each day $isavailable = array(); + +// Assume from Monday to Friday if conf empty or badly formed +$numstartworkingday = 1; +$numendworkingday = 5; + if (!empty($conf->global->MAIN_DEFAULT_WORKING_DAYS)) { $tmparray = explode('-', $conf->global->MAIN_DEFAULT_WORKING_DAYS); diff --git a/htdocs/projet/activity/perweek.php b/htdocs/projet/activity/perweek.php index 54283681029..becbb86157a 100644 --- a/htdocs/projet/activity/perweek.php +++ b/htdocs/projet/activity/perweek.php @@ -521,6 +521,11 @@ $startday = dol_mktime(12, 0, 0, $startdayarray['first_month'], $startdayarray[' // Get if user is available or not for each day $isavailable = array(); + +// Assume from Monday to Friday if conf empty or badly formed +$numstartworkingday = 1; +$numendworkingday = 5; + if (!empty($conf->global->MAIN_DEFAULT_WORKING_DAYS)) { $tmparray = explode('-', $conf->global->MAIN_DEFAULT_WORKING_DAYS); @@ -530,7 +535,6 @@ if (!empty($conf->global->MAIN_DEFAULT_WORKING_DAYS)) $numendworkingday = $tmparray[1]; } } - for ($idw = 0; $idw < 7; $idw++) { $dayinloopfromfirstdaytoshow = dol_time_plus_duree($firstdaytoshow, $idw, 'd'); // $firstdaytoshow is a date with hours = 0 From c5f0faad43315aaaf3a877aa1a6414eaba9b708b Mon Sep 17 00:00:00 2001 From: Marc de Lima Lucio <68746600+marc-dll@users.noreply.github.com> Date: Fri, 19 Nov 2021 15:36:00 +0100 Subject: [PATCH 02/62] FIX: project timesheet: public holidays offset by 1 day --- htdocs/projet/activity/perday.php | 6 +++++- htdocs/projet/activity/perweek.php | 4 +++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/htdocs/projet/activity/perday.php b/htdocs/projet/activity/perday.php index 79a259f1ccc..159f4f11b6b 100644 --- a/htdocs/projet/activity/perday.php +++ b/htdocs/projet/activity/perday.php @@ -87,6 +87,10 @@ $daytoparse = $now; if ($yearofday && $monthofday && $dayofday) $daytoparse = dol_mktime(0, 0, 0, $monthofday, $dayofday, $yearofday); // xxxofday is value of day after submit action 'addtime' elseif ($year && $month && $day) $daytoparse = dol_mktime(0, 0, 0, $month, $day, $year); // this are value submited after submit of action 'submitdateselect' +$daytoparsegmt = dol_now('gmt'); +if ($yearofday && $monthofday && $dayofday) $daytoparsegmt = dol_mktime(0, 0, 0, $monthofday, $dayofday, $yearofday, 'gmt'); // xxxofday is value of day after submit action 'addtime' +elseif ($year && $month && $day) $daytoparsegmt = dol_mktime(0, 0, 0, $month, $day, $year, 'gmt'); // this are value submited after submit of action 'submitdateselect' + if (empty($search_usertoprocessid) || $search_usertoprocessid == $user->id) { @@ -616,7 +620,7 @@ $statusofholidaytocheck = Holiday::STATUS_APPROVED; $isavailablefordayanduser = $holiday->verifDateHolidayForTimestamp($usertoprocess->id, $daytoparse, $statusofholidaytocheck); // $daytoparse is a date with hours = 0 $isavailable[$daytoparse] = $isavailablefordayanduser; // in projectLinesPerWeek later, we are using $firstdaytoshow and dol_time_plus_duree to loop on each day -$test = num_public_holiday($daytoparse, $daytoparse + 86400, $mysoc->country_code); +$test = num_public_holiday($daytoparsegmt, $daytoparsegmt + 86400, $mysoc->country_code); if ($test) $isavailable[$daytoparse] = array('morning'=>false, 'afternoon'=>false, 'morning_reason'=>'public_holiday', 'afternoon_reason'=>'public_holiday'); $tmparray = dol_getdate($daytoparse, true); // detail of current day diff --git a/htdocs/projet/activity/perweek.php b/htdocs/projet/activity/perweek.php index d7c0f874383..267106c5721 100644 --- a/htdocs/projet/activity/perweek.php +++ b/htdocs/projet/activity/perweek.php @@ -97,6 +97,7 @@ $next_day = $next['day']; // Define firstdaytoshow and lastdaytoshow (warning: lastdaytoshow is last second to show + 1) $firstdaytoshow = dol_mktime(0, 0, 0, $first_month, $first_day, $first_year); +$firstdaytoshowgmt = dol_mktime(0, 0, 0, $first_month, $first_day, $first_year, 'gmt'); $lastdaytoshow = dol_time_plus_duree($firstdaytoshow, 7, 'd'); if (empty($search_usertoprocessid) || $search_usertoprocessid == $user->id) @@ -520,6 +521,7 @@ if (!empty($conf->global->MAIN_DEFAULT_WORKING_DAYS)) for ($idw = 0; $idw < 7; $idw++) { $dayinloopfromfirstdaytoshow = dol_time_plus_duree($firstdaytoshow, $idw, 'd'); // $firstdaytoshow is a date with hours = 0 + $dayinloopfromfirstdaytoshowgmt = dol_time_plus_duree($firstdaytoshowgmt, $idw, 'd'); // $firstdaytoshow is a date with hours = 0 $dayinloop = dol_time_plus_duree($startday, $idw, 'd'); // Useless because $dayinloopwithouthours should be same than $dayinloopfromfirstdaytoshow @@ -534,7 +536,7 @@ for ($idw = 0; $idw < 7; $idw++) $isavailablefordayanduser = $holiday->verifDateHolidayForTimestamp($usertoprocess->id, $dayinloopfromfirstdaytoshow, $statusofholidaytocheck); $isavailable[$dayinloopfromfirstdaytoshow] = $isavailablefordayanduser; // in projectLinesPerWeek later, we are using $firstdaytoshow and dol_time_plus_duree to loop on each day - $test = num_public_holiday($dayinloopfromfirstdaytoshow, $dayinloopfromfirstdaytoshow + 86400, $mysoc->country_code); + $test = num_public_holiday($dayinloopfromfirstdaytoshowgmt, $dayinloopfromfirstdaytoshowgmt + 86400, $mysoc->country_code); if ($test) $isavailable[$dayinloopfromfirstdaytoshow] = array('morning'=>false, 'afternoon'=>false, 'morning_reason'=>'public_holiday', 'afternoon_reason'=>'public_holiday'); } //var_dump($isavailable); From 112922206469e35129ec5198bac125f40ce736fa Mon Sep 17 00:00:00 2001 From: Marc de Lima Lucio <68746600+marc-dll@users.noreply.github.com> Date: Fri, 19 Nov 2021 15:59:34 +0100 Subject: [PATCH 03/62] FIX: user employee tab: offset in open days messes up holiday length calculation --- htdocs/user/bank.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/user/bank.php b/htdocs/user/bank.php index 3bdc6b5390c..e97d6504369 100644 --- a/htdocs/user/bank.php +++ b/htdocs/user/bank.php @@ -327,7 +327,7 @@ if ($action != 'edit' && $action != 'create') // If not bank account yet, $acco $holiday->id = $objp->rowid; $holiday->ref = $objp->rowid; $holiday->fk_type = $objp->fk_type; - $nbopenedday = num_open_day($db->jdate($objp->date_debut), $db->jdate($objp->date_fin), 0, 1, $objp->halfday); + $nbopenedday = num_open_day($db->jdate($objp->date_debut, 'gmt'), $db->jdate($objp->date_fin, 'gmt'), 0, 1, $objp->halfday); print $holiday->getNomUrl(1); print ''.dol_print_date($db->jdate($objp->date_debut), 'day')."\n"; From ffa88b803ffd4636b626b6631d1a79b9122597cb Mon Sep 17 00:00:00 2001 From: Marc de Lima Lucio <68746600+marc-dll@users.noreply.github.com> Date: Fri, 19 Nov 2021 16:03:41 +0100 Subject: [PATCH 04/62] FIX: project timesheet by week: cleanup unused code --- htdocs/projet/activity/perweek.php | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/htdocs/projet/activity/perweek.php b/htdocs/projet/activity/perweek.php index 267106c5721..2e1926c8847 100644 --- a/htdocs/projet/activity/perweek.php +++ b/htdocs/projet/activity/perweek.php @@ -98,7 +98,6 @@ $next_day = $next['day']; // Define firstdaytoshow and lastdaytoshow (warning: lastdaytoshow is last second to show + 1) $firstdaytoshow = dol_mktime(0, 0, 0, $first_month, $first_day, $first_year); $firstdaytoshowgmt = dol_mktime(0, 0, 0, $first_month, $first_day, $first_year, 'gmt'); -$lastdaytoshow = dol_time_plus_duree($firstdaytoshow, 7, 'd'); if (empty($search_usertoprocessid) || $search_usertoprocessid == $user->id) { @@ -522,14 +521,6 @@ for ($idw = 0; $idw < 7; $idw++) { $dayinloopfromfirstdaytoshow = dol_time_plus_duree($firstdaytoshow, $idw, 'd'); // $firstdaytoshow is a date with hours = 0 $dayinloopfromfirstdaytoshowgmt = dol_time_plus_duree($firstdaytoshowgmt, $idw, 'd'); // $firstdaytoshow is a date with hours = 0 - $dayinloop = dol_time_plus_duree($startday, $idw, 'd'); - - // Useless because $dayinloopwithouthours should be same than $dayinloopfromfirstdaytoshow - //$tmparray = dol_getdate($dayinloop); - //$dayinloopwithouthours=dol_mktime(0, 0, 0, $tmparray['mon'], $tmparray['mday'], $tmparray['year']); - //print dol_print_date($dayinloop, 'dayhour').' '; - //print dol_print_date($dayinloopwithouthours, 'dayhour').' '; - //print dol_print_date($dayinloopfromfirstdaytoshow, 'dayhour').'
'; $statusofholidaytocheck = Holiday::STATUS_APPROVED; @@ -539,7 +530,6 @@ for ($idw = 0; $idw < 7; $idw++) $test = num_public_holiday($dayinloopfromfirstdaytoshowgmt, $dayinloopfromfirstdaytoshowgmt + 86400, $mysoc->country_code); if ($test) $isavailable[$dayinloopfromfirstdaytoshow] = array('morning'=>false, 'afternoon'=>false, 'morning_reason'=>'public_holiday', 'afternoon_reason'=>'public_holiday'); } -//var_dump($isavailable); @@ -659,7 +649,6 @@ print ''.$langs->trans("TimeSpent").($usertoprocess for ($idw = 0; $idw < 7; $idw++) { $dayinloopfromfirstdaytoshow = dol_time_plus_duree($firstdaytoshow, $idw, 'd'); // $firstdaytoshow is a date with hours = 0 - $dayinloop = dol_time_plus_duree($startday, $idw, 'd'); $cssweekend = ''; if ((($idw + 1) < $numstartworkingday) || (($idw + 1) > $numendworkingday)) // This is a day is not inside the setup of working days, so we use a week-end css. From 879afaa59e0251639e66981be8d00668f6800da3 Mon Sep 17 00:00:00 2001 From: Quentin VIAL-GOUTEYRON Date: Fri, 18 Feb 2022 12:16:50 +0100 Subject: [PATCH 05/62] 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 06/62] 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 07/62] 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 10/62] 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 11/62] 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 12/62] 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 13/62] 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 14/62] 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 15/62] 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 16/62] 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 17/62] 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 18/62] 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 19/62] 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 20/62] 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 21/62] 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 22/62] 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 23/62] 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 24/62] 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 25/62] 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 26/62] 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 89b7c8298b4f7f27b4d3b08079014826437677a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alo=C3=AFs=20Micard?= Date: Mon, 11 Apr 2022 17:25:45 +0200 Subject: [PATCH 27/62] Module builder: Translate permissions label --- 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 f3922aa6342..f8abd703bf0 100644 --- a/htdocs/modulebuilder/index.php +++ b/htdocs/modulebuilder/index.php @@ -3008,7 +3008,7 @@ if ($module == 'initmodule') print ''; print ''; - print $perm[1]; + print $langs->trans($perm[1]); print ''; print ''; From 9547b9e7febb4312bd491d6d3e089d0eb7c521e3 Mon Sep 17 00:00:00 2001 From: Ferran Marcet Date: Mon, 11 Apr 2022 18:01:25 +0200 Subject: [PATCH 28/62] 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 62b74962535ed38c424e569d9dbd79b25653ab16 Mon Sep 17 00:00:00 2001 From: Ferran Marcet Date: Mon, 11 Apr 2022 18:26:49 +0200 Subject: [PATCH 29/62] Fix: Direct download don't work with multicompany --- htdocs/document.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/htdocs/document.php b/htdocs/document.php index 060722e8d5b..fc894091615 100644 --- a/htdocs/document.php +++ b/htdocs/document.php @@ -5,6 +5,7 @@ * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2010 Pierre Morin * Copyright (C) 2010 Juanjo Menent + * 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 @@ -140,6 +141,11 @@ if (!empty($hashp)) $modulepart = $moduleparttocheck; $original_file = (($tmp[1] ? $tmp[1].'/' : '').$ecmfile->filename); // this is relative to module dir } + $entity = $ecmfile->entity; + if ($entity != $conf->entity) { + $conf->entity = $entity; + $conf->setValues($db); + } } else { $langs->load("errors"); accessforbidden($langs->trans("ErrorFileNotFoundWithSharedLink"), 0, 0, 1); From b8bccd62efa45ce1617eaa3d4a0278c3d3305adc Mon Sep 17 00:00:00 2001 From: Ferran Marcet Date: Mon, 11 Apr 2022 18:41:36 +0200 Subject: [PATCH 30/62] 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 31/62] 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 32/62] 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 f4023b4e44160e0861eb09a0d0d407e5420575e3 Mon Sep 17 00:00:00 2001 From: kevin Date: Tue, 12 Apr 2022 11:08:50 +0200 Subject: [PATCH 33/62] Add missing entity on salary's payment --- htdocs/salaries/class/paymentsalary.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/salaries/class/paymentsalary.class.php b/htdocs/salaries/class/paymentsalary.class.php index 76236bb88aa..506e9b73ea5 100644 --- a/htdocs/salaries/class/paymentsalary.class.php +++ b/htdocs/salaries/class/paymentsalary.class.php @@ -164,9 +164,9 @@ class PaymentSalary extends CommonObject $this->db->begin(); if ($totalamount != 0) { - $sql = "INSERT INTO ".MAIN_DB_PREFIX."payment_salary (fk_salary, datec, datep, amount,"; + $sql = "INSERT INTO ".MAIN_DB_PREFIX."payment_salary (entity, fk_salary, datec, datep, amount,"; $sql .= " fk_typepayment, num_payment, note, fk_user_author, fk_bank)"; - $sql .= " VALUES ($this->chid, '".$this->db->idate($now)."',"; + $sql .= " VALUES (".$conf->entity.", ".$this->chid.", '".$this->db->idate($now)."',"; $sql .= " '".$this->db->idate($this->datepaye)."',"; $sql .= " ".price2num($totalamount).","; $sql .= " ".((int) $this->paiementtype).", '".$this->db->escape($this->num_payment)."', '".$this->db->escape($this->note)."', ".((int) $user->id).","; 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 34/62] 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 35/62] 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 36/62] 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 37/62] 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 38/62] 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 39/62] 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 c51aff99af711f0a7a04fcd2de99ab243ad2175c Mon Sep 17 00:00:00 2001 From: kevin Date: Tue, 12 Apr 2022 14:38:17 +0200 Subject: [PATCH 40/62] 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 41/62] 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 1bfd9c695fda90db19047a04305877bf809580e3 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 12 Apr 2022 16:29:25 +0200 Subject: [PATCH 42/62] 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 43/62] 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 44/62] 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 45/62] 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 46/62] 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 e9e10e84b2adb333e276f8dd5fce713b34ed87bb Mon Sep 17 00:00:00 2001 From: Norbert Penel Date: Wed, 13 Apr 2022 10:47:33 +0200 Subject: [PATCH 47/62] 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 48/62] 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 49/62] 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 50/62] 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 ''; // 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 ''; @@ -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 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 ''; print $langs->trans("NoFields"); @@ -2177,65 +2136,22 @@ function show_elem($fieldssource, $pos, $key, $var, $isimportedfield, $nostyle = 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 ''; - print ''; - print $langs->trans("EmptyField").': '; - print ' ('.$example.')'; - print ''; - print ''; - } } else { // Print field of source file print ''; 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 ''; - 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 '