From 640730539ed832dc948feb69188d6bff0f7677bb Mon Sep 17 00:00:00 2001 From: Marc Guenneugues Date: Sat, 2 May 2020 08:50:22 +0200 Subject: [PATCH 01/83] NEW: Add option to include products without alert in replenish --- htdocs/langs/en_US/stocks.lang | 1 + htdocs/product/stock/replenish.php | 158 ++++++++++++++++++----------- 2 files changed, 100 insertions(+), 59 deletions(-) diff --git a/htdocs/langs/en_US/stocks.lang b/htdocs/langs/en_US/stocks.lang index 9856649b834..e5fd3db9260 100644 --- a/htdocs/langs/en_US/stocks.lang +++ b/htdocs/langs/en_US/stocks.lang @@ -119,6 +119,7 @@ CurentlyUsingPhysicalStock=Physical stock RuleForStockReplenishment=Rule for stocks replenishment SelectProductWithNotNullQty=Select at least one product with a qty not null and a vendor AlertOnly= Alerts only +IncludeProductWithUndefinedAlerts = Include products with no defined alerts WarehouseForStockDecrease=The warehouse %s will be used for stock decrease WarehouseForStockIncrease=The warehouse %s will be used for stock increase ForThisWarehouse=For this warehouse diff --git a/htdocs/product/stock/replenish.php b/htdocs/product/stock/replenish.php index 97d3871c027..d00fdaabb5e 100644 --- a/htdocs/product/stock/replenish.php +++ b/htdocs/product/stock/replenish.php @@ -55,6 +55,7 @@ $sall = trim((GETPOST('search_all', 'alphanohtml') != '') ?GETPOST('search_all', $type = GETPOST('type', 'int'); $tobuy = GETPOST('tobuy', 'int'); $salert = GETPOST('salert', 'alpha'); +$allalert = GETPOST('allalert', 'alpha'); $mode = GETPOST('mode', 'alpha'); $draftorder = GETPOST('draftorder', 'alpha'); @@ -108,6 +109,7 @@ if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x' $snom = ''; $sal = ''; $salert = ''; + $allalert = ''; $draftorder = ''; } if ($draftorder == 'on') $draftchecked = "checked"; @@ -430,34 +432,65 @@ if ($usevirtualstock) $sql .= ' ('.$sqldesiredtock.' >= 0 AND ('.$sqldesiredtock.' > SUM('.$db->ifsql("s.reel IS NULL", "0", "s.reel").')'; $sql .= ' - ('.$sqlCommandesCli.' - '.$sqlExpeditionsCli.') + ('.$sqlCommandesFourn.' - '.$sqlReceptionFourn.') + ('.$sqlProductionToProduce.' - '.$sqlProductionToConsume.')))'; $sql .= ' OR '; - $sql .= ' ('.$sqlalertstock.' >= 0 AND ('.$sqlalertstock.' > SUM('.$db->ifsql("s.reel IS NULL", "0", "s.reel").')'; + if ($allalert == 'on') { + $sql .= ' (('.$sqlalertstock.' >= 0 OR '.$sqlalertstock.' IS NULL) AND ('.$db->ifsql("$sqlalertstock IS NULL", "0", $sqlalertstock).' > SUM('.$db->ifsql("s.reel IS NULL", "0", "s.reel").')'; + } else { + $sql .= ' ('.$sqlalertstock.' >= 0 AND ('.$sqlalertstock.' > SUM('.$db->ifsql("s.reel IS NULL", "0", "s.reel").')'; + } $sql .= ' - ('.$sqlCommandesCli.' - '.$sqlExpeditionsCli.') + ('.$sqlCommandesFourn.' - '.$sqlReceptionFourn.') + ('.$sqlProductionToProduce.' - '.$sqlProductionToConsume.')))'; $sql .= ')'; if ($salert == 'on') // Option to see when stock is lower than alert { - $sql .= ' AND ('; - $sql .= $sqlalertstock.' >= 0 AND ('.$sqlalertstock.' > SUM('.$db->ifsql("s.reel IS NULL", "0", "s.reel").')'; + $sql .= ' AND (('; + if ($allalert == 'on') { + $sql .= $sqlalertstock.' >= 0 OR '.$sqlalertstock.' IS NULL) AND ('.$db->ifsql("$sqlalertstock IS NULL", "0", $sqlalertstock).' > SUM('.$db->ifsql("s.reel IS NULL", "0", "s.reel").')'; + } else { + $sql .= $sqlalertstock.' >= 0 AND ('.$sqlalertstock.' > SUM('.$db->ifsql("s.reel IS NULL", "0", "s.reel").')'; + } $sql .= ' - ('.$sqlCommandesCli.' - '.$sqlExpeditionsCli.') + ('.$sqlCommandesFourn.' - '.$sqlReceptionFourn.') + ('.$sqlProductionToProduce.' - '.$sqlProductionToConsume.'))'; $sql .= ')'; $alertchecked = 'checked'; } } else { $sql .= ' HAVING (('.$sqldesiredtock.' >= 0 AND ('.$sqldesiredtock.' > SUM('.$db->ifsql("s.reel IS NULL", "0", "s.reel").')))'; - $sql .= ' OR ('.$sqlalertstock.' >= 0 AND ('.$sqlalertstock.' > SUM('.$db->ifsql("s.reel IS NULL", "0", "s.reel").'))))'; + if ($allalert == 'on') { + $sql .= ' OR (('.$sqlalertstock.' >= 0 OR '.$sqlalertstock.' IS NULL) AND ('.$db->ifsql("$sqlalertstock IS NULL", "0", $sqlalertstock).' > SUM('.$db->ifsql("s.reel IS NULL", "0", "s.reel").'))))'; + } else { + $sql .= ' OR ('.$sqlalertstock.' >= 0 AND ('.$sqlalertstock.' > SUM('.$db->ifsql("s.reel IS NULL", "0", "s.reel").'))))'; + } if ($salert == 'on') // Option to see when stock is lower than alert { - $sql .= ' AND ('.$sqlalertstock.' >= 0 AND ('.$sqlalertstock.' > SUM('.$db->ifsql("s.reel IS NULL", "0", "s.reel").')))'; + if ($allalert == 'on') { + $sql .= ' AND (('.$sqlalertstock.' >= 0 OR '.$sqlalertstock.' IS NULL) AND ('.$db->ifsql("$sqlalertstock IS NULL", "0", $sqlalertstock).' > SUM('.$db->ifsql("s.reel IS NULL", "0", "s.reel").')))'; + } else { + $sql .= ' AND ('.$sqlalertstock.' >= 0 AND ('.$sqlalertstock.' > SUM('.$db->ifsql("s.reel IS NULL", "0", "s.reel").')))'; + } $alertchecked = 'checked'; } } +$allalertchecked = ''; +if ($allalert == 'on') { + $allalertchecked = 'checked'; +} + // Add where from hooks $parameters = array(); $reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook $sql .= $hookmanager->resPrint; +$nbtotalofrecords = ''; +if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { + $result = $db->query($sql); + $nbtotalofrecords = $db->num_rows($result); + if (($page * $limit) > $nbtotalofrecords) { + $page = 0; + $offset = 0; + } +} + $sql .= $db->order($sortfield, $sortorder); $sql .= $db->plimit($limit + 1, $offset); @@ -510,6 +543,7 @@ print ''; print ''; print ''; print ''; +print ''; print ''; print ''; if (!empty($conf->global->STOCK_ALLOW_ADD_LIMIT_STOCK_BY_WAREHOUSE)) @@ -532,72 +566,78 @@ print ''; print ''; -if ($sref || $snom || $sall || $salert || $draftorder || GETPOST('search', 'alpha')) { - $filters = '&sref='.$sref.'&snom='.$snom; - $filters .= '&sall='.$sall; - $filters .= '&salert='.$salert; - $filters .= '&draftorder='.$draftorder; - $filters .= '&mode='.$mode; - $filters .= '&fk_supplier='.$fk_supplier; - $filters .= '&fk_entrepot='.$fk_entrepot; - print_barre_liste( - $texte, - $page, - 'replenish.php', - $filters, - $sortfield, - $sortorder, - '', - $num - ); -} else { - $filters = '&sref='.$sref.'&snom='.$snom; - $filters .= '&fourn_id='.$fourn_id; - $filters .= (isset($type) ? '&type='.$type : ''); - $filters .= '&='.$salert; - $filters .= '&draftorder='.$draftorder; - $filters .= '&mode='.$mode; - $filters .= '&fk_supplier='.$fk_supplier; - $filters .= '&fk_entrepot='.$fk_entrepot; - print_barre_liste( - $texte, - $page, - 'replenish.php', - $filters, - $sortfield, - $sortorder, - '', - $num - ); -} +print '
'. + ''. + ''. + ''. + ''. + ''. + ''. + ''. + ''. + ''; -print '
'; // You can use div-table-responsive-no-min if you dont need reserved height for your table -print ''; +$filters = '&sref='.$sref.'&snom='.$snom; +$filters .= '&fourn_id='.$fourn_id; +$filters .= (isset($type) ? '&type='.$type : ''); +$filters .= '&sall='.$sall; +$filters .= '&salert='.$salert; +$filters .= '&allalert='.$allalert; +$filters .= '&draftorder='.$draftorder; +$filters .= '&mode='.$mode; +$filters .= '&fk_supplier='.$fk_supplier; +$filters .= '&fk_entrepot='.$fk_entrepot; $param = (isset($type) ? '&type='.$type : ''); -$param .= '&fourn_id='.$fourn_id.'&snom='.$snom.'&salert='.$salert.'&draftorder='.$draftorder; +$param .= '&fourn_id='.$fourn_id.'&snom='.$snom.'&allalert='.$allalert.'&salert='.$salert.'&draftorder='.$draftorder; $param .= '&sref='.$sref; $param .= '&mode='.$mode; $param .= '&fk_supplier='.$fk_supplier; $param .= '&fk_entrepot='.$fk_entrepot; - $stocklabel = $langs->trans('Stock'); if ($usevirtualstock == 1) $stocklabel = $langs->trans('VirtualStock'); if ($usevirtualstock == 0) $stocklabel = $langs->trans('PhysicalStock'); if (!empty($conf->global->STOCK_ALLOW_ADD_LIMIT_STOCK_BY_WAREHOUSE) && $fk_entrepot > 0) { - $stocklabel .= ' ('.$langs->trans("AllWarehouses").')'; + $stocklabel .= ' ('.$langs->trans("AllWarehouses").')'; } -print ''; -print ''; -print ''; -print ''; -print ''; -print ''; -print ''; -print ''; -print ''; -print ''; +$texte = $langs->trans('Replenishment'); + +print '
'; // You can use div-table-responsive-no-min if you dont need reserved height for your table + +if (!empty($conf->global->REPLENISH_ALLOW_VARIABLESIZELIST)) { + print_barre_liste( + $texte, + $page, + 'replenish.php', + $filters, + $sortfield, + $sortorder, + '', + $num, + $nbtotalofrecords, + 'object_stock.png', + 0, + '', + '', + $limit + ); +} else { + print_barre_liste( + $texte, + $page, + 'replenish.php', + $filters, + $sortfield, + $sortorder, + '', + $num, + $nbtotalofrecords, + 'object_stock.png' + ); +} + +print '
'; // Fields title search print ''; @@ -606,7 +646,7 @@ print ''; if (!empty($conf->service->enabled) && $type == 1) print ''; print ''; -print ''; +print ''; print ''; print ''; print ''; From a03739962b78de98ba3da8f5b33bc92f523858db Mon Sep 17 00:00:00 2001 From: Marc Guenneugues Date: Sat, 2 May 2020 09:21:51 +0200 Subject: [PATCH 02/83] Propagate the value of limit --- htdocs/product/stock/replenish.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/htdocs/product/stock/replenish.php b/htdocs/product/stock/replenish.php index d00fdaabb5e..f6af90d09a1 100644 --- a/htdocs/product/stock/replenish.php +++ b/htdocs/product/stock/replenish.php @@ -546,6 +546,9 @@ print ''; print ''; print ''; print ''; +if ($limit > 0 && $limit != $conf->liste_limit) { + print ''; +} if (!empty($conf->global->STOCK_ALLOW_ADD_LIMIT_STOCK_BY_WAREHOUSE)) { print '
'; @@ -587,6 +590,9 @@ $filters .= '&draftorder='.$draftorder; $filters .= '&mode='.$mode; $filters .= '&fk_supplier='.$fk_supplier; $filters .= '&fk_entrepot='.$fk_entrepot; +if ($limit > 0 && $limit != $conf->liste_limit) { + $filters .= '&limit=' . urlencode($limit); +} $param = (isset($type) ? '&type='.$type : ''); $param .= '&fourn_id='.$fourn_id.'&snom='.$snom.'&allalert='.$allalert.'&salert='.$salert.'&draftorder='.$draftorder; @@ -594,6 +600,7 @@ $param .= '&sref='.$sref; $param .= '&mode='.$mode; $param .= '&fk_supplier='.$fk_supplier; $param .= '&fk_entrepot='.$fk_entrepot; + $stocklabel = $langs->trans('Stock'); if ($usevirtualstock == 1) $stocklabel = $langs->trans('VirtualStock'); if ($usevirtualstock == 0) $stocklabel = $langs->trans('PhysicalStock'); From 1e3f31041d7a2b2f96a3df0e6f3c131e9b3fb909 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Sat, 2 May 2020 07:23:06 +0000 Subject: [PATCH 03/83] Fixing style errors. --- htdocs/product/stock/replenish.php | 40 +++++++++++++++--------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/htdocs/product/stock/replenish.php b/htdocs/product/stock/replenish.php index f6af90d09a1..2423a95e49e 100644 --- a/htdocs/product/stock/replenish.php +++ b/htdocs/product/stock/replenish.php @@ -432,41 +432,41 @@ if ($usevirtualstock) $sql .= ' ('.$sqldesiredtock.' >= 0 AND ('.$sqldesiredtock.' > SUM('.$db->ifsql("s.reel IS NULL", "0", "s.reel").')'; $sql .= ' - ('.$sqlCommandesCli.' - '.$sqlExpeditionsCli.') + ('.$sqlCommandesFourn.' - '.$sqlReceptionFourn.') + ('.$sqlProductionToProduce.' - '.$sqlProductionToConsume.')))'; $sql .= ' OR '; - if ($allalert == 'on') { - $sql .= ' (('.$sqlalertstock.' >= 0 OR '.$sqlalertstock.' IS NULL) AND ('.$db->ifsql("$sqlalertstock IS NULL", "0", $sqlalertstock).' > SUM('.$db->ifsql("s.reel IS NULL", "0", "s.reel").')'; - } else { - $sql .= ' ('.$sqlalertstock.' >= 0 AND ('.$sqlalertstock.' > SUM('.$db->ifsql("s.reel IS NULL", "0", "s.reel").')'; - } + if ($allalert == 'on') { + $sql .= ' (('.$sqlalertstock.' >= 0 OR '.$sqlalertstock.' IS NULL) AND ('.$db->ifsql("$sqlalertstock IS NULL", "0", $sqlalertstock).' > SUM('.$db->ifsql("s.reel IS NULL", "0", "s.reel").')'; + } else { + $sql .= ' ('.$sqlalertstock.' >= 0 AND ('.$sqlalertstock.' > SUM('.$db->ifsql("s.reel IS NULL", "0", "s.reel").')'; + } $sql .= ' - ('.$sqlCommandesCli.' - '.$sqlExpeditionsCli.') + ('.$sqlCommandesFourn.' - '.$sqlReceptionFourn.') + ('.$sqlProductionToProduce.' - '.$sqlProductionToConsume.')))'; $sql .= ')'; if ($salert == 'on') // Option to see when stock is lower than alert { $sql .= ' AND (('; - if ($allalert == 'on') { - $sql .= $sqlalertstock.' >= 0 OR '.$sqlalertstock.' IS NULL) AND ('.$db->ifsql("$sqlalertstock IS NULL", "0", $sqlalertstock).' > SUM('.$db->ifsql("s.reel IS NULL", "0", "s.reel").')'; - } else { - $sql .= $sqlalertstock.' >= 0 AND ('.$sqlalertstock.' > SUM('.$db->ifsql("s.reel IS NULL", "0", "s.reel").')'; - } + if ($allalert == 'on') { + $sql .= $sqlalertstock.' >= 0 OR '.$sqlalertstock.' IS NULL) AND ('.$db->ifsql("$sqlalertstock IS NULL", "0", $sqlalertstock).' > SUM('.$db->ifsql("s.reel IS NULL", "0", "s.reel").')'; + } else { + $sql .= $sqlalertstock.' >= 0 AND ('.$sqlalertstock.' > SUM('.$db->ifsql("s.reel IS NULL", "0", "s.reel").')'; + } $sql .= ' - ('.$sqlCommandesCli.' - '.$sqlExpeditionsCli.') + ('.$sqlCommandesFourn.' - '.$sqlReceptionFourn.') + ('.$sqlProductionToProduce.' - '.$sqlProductionToConsume.'))'; $sql .= ')'; $alertchecked = 'checked'; } } else { $sql .= ' HAVING (('.$sqldesiredtock.' >= 0 AND ('.$sqldesiredtock.' > SUM('.$db->ifsql("s.reel IS NULL", "0", "s.reel").')))'; - if ($allalert == 'on') { - $sql .= ' OR (('.$sqlalertstock.' >= 0 OR '.$sqlalertstock.' IS NULL) AND ('.$db->ifsql("$sqlalertstock IS NULL", "0", $sqlalertstock).' > SUM('.$db->ifsql("s.reel IS NULL", "0", "s.reel").'))))'; - } else { - $sql .= ' OR ('.$sqlalertstock.' >= 0 AND ('.$sqlalertstock.' > SUM('.$db->ifsql("s.reel IS NULL", "0", "s.reel").'))))'; - } + if ($allalert == 'on') { + $sql .= ' OR (('.$sqlalertstock.' >= 0 OR '.$sqlalertstock.' IS NULL) AND ('.$db->ifsql("$sqlalertstock IS NULL", "0", $sqlalertstock).' > SUM('.$db->ifsql("s.reel IS NULL", "0", "s.reel").'))))'; + } else { + $sql .= ' OR ('.$sqlalertstock.' >= 0 AND ('.$sqlalertstock.' > SUM('.$db->ifsql("s.reel IS NULL", "0", "s.reel").'))))'; + } if ($salert == 'on') // Option to see when stock is lower than alert { - if ($allalert == 'on') { - $sql .= ' AND (('.$sqlalertstock.' >= 0 OR '.$sqlalertstock.' IS NULL) AND ('.$db->ifsql("$sqlalertstock IS NULL", "0", $sqlalertstock).' > SUM('.$db->ifsql("s.reel IS NULL", "0", "s.reel").')))'; - } else { - $sql .= ' AND ('.$sqlalertstock.' >= 0 AND ('.$sqlalertstock.' > SUM('.$db->ifsql("s.reel IS NULL", "0", "s.reel").')))'; - } + if ($allalert == 'on') { + $sql .= ' AND (('.$sqlalertstock.' >= 0 OR '.$sqlalertstock.' IS NULL) AND ('.$db->ifsql("$sqlalertstock IS NULL", "0", $sqlalertstock).' > SUM('.$db->ifsql("s.reel IS NULL", "0", "s.reel").')))'; + } else { + $sql .= ' AND ('.$sqlalertstock.' >= 0 AND ('.$sqlalertstock.' > SUM('.$db->ifsql("s.reel IS NULL", "0", "s.reel").')))'; + } $alertchecked = 'checked'; } } From b65a4649e7032a69e4bd0b0c2e31070cd196cfdb Mon Sep 17 00:00:00 2001 From: Marc Guenneugues Date: Sat, 2 May 2020 09:26:58 +0200 Subject: [PATCH 04/83] Correct lint errors --- htdocs/product/stock/replenish.php | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/htdocs/product/stock/replenish.php b/htdocs/product/stock/replenish.php index f6af90d09a1..a00c3a49481 100644 --- a/htdocs/product/stock/replenish.php +++ b/htdocs/product/stock/replenish.php @@ -569,16 +569,16 @@ print '
'; print ''; -print '
'. - ''. - ''. - ''. - ''. - ''. - ''. - ''. - ''. - ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; $filters = '&sref='.$sref.'&snom='.$snom; $filters .= '&fourn_id='.$fourn_id; From 69db790cf5fdd5fa96f9f524eb88a50d9af900fc Mon Sep 17 00:00:00 2001 From: atm-quentin Date: Mon, 8 Jun 2020 14:43:14 +0200 Subject: [PATCH 05/83] NEW multiselect type and date to date filter --- htdocs/core/class/html.form.class.php | 19 +++ htdocs/core/lib/company.lib.php | 161 ++++++++++++++++++-------- 2 files changed, 132 insertions(+), 48 deletions(-) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 289b92f84ae..f3560be0545 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -5241,6 +5241,25 @@ class Form print $retstring; return; } + /** + * Show 2 HTML widget to input a date or combo list for day, month, years and optionaly hours and minutes. + * Fields are preselected with : + * - set_time date (must be a local PHP server timestamp or string date with format 'YYYY-MM-DD' or 'YYYY-MM-DD HH:MM') + * - local date in user area, if set_time is '' (so if set_time is '', output may differs when done from two different location) + * - Empty (fields empty), if set_time is -1 (in this case, parameter empty must also have value 1) + * + * @param integer $set_time Pre-selected date (must be a local PHP server timestamp), -1 to keep date not preselected, '' to use current date with 00:00 hour (Parameter 'empty' must be 0 or 2). + * @param integer $set_time_end Pre-selected date (must be a local PHP server timestamp), -1 to keep date not preselected, '' to use current date with 00:00 hour (Parameter 'empty' must be 0 or 2). + * @param string $prefix Prefix for fields name + * @return string Html for selectDate + * @see form_date(), select_month(), select_year(), select_dayofweek() + */ + public function selectDateToDate($set_time = '', $set_time_end = '', $prefix = 're', $empty = 0) { + $ret = $this->selectDate($set_time, $prefix.'_start',0 ,0, $empty); + $ret .='
'; + $ret .=$this->selectDate($set_time_end, $prefix.'_end', 0 ,0, $empty); + return $ret; + } /** * Show a HTML widget to input a date or combo list for day, month, years and optionaly hours and minutes. diff --git a/htdocs/core/lib/company.lib.php b/htdocs/core/lib/company.lib.php index 3f6e8563a50..6e1f87bc962 100644 --- a/htdocs/core/lib/company.lib.php +++ b/htdocs/core/lib/company.lib.php @@ -1273,7 +1273,27 @@ function show_actions_done($conf, $langs, $db, $filterobj, $objcon = '', $noprin global $form; global $param, $massactionbutton; - + $start_year = GETPOST('dateevent_startyear'); + $start_month = GETPOST('dateevent_startmonth'); + $start_day = GETPOST('dateevent_startday'); + $end_year = GETPOST('dateevent_endyear'); + $end_month = GETPOST('dateevent_endmonth'); + $end_day = GETPOST('dateevent_endday'); + if(!empty($start_year) && !empty($start_month) && !empty($start_day)) { + $search_start = $start_year.'-'.$start_month.'-'.$start_day; + $tms_start = strtotime($search_start); + } + if(!empty($end_year) && !empty($end_month) && !empty($end_day)) { + $search_end = $end_year.'-'.$end_month.'-'.$end_day.' 23:59:59'; + $tms_end = strtotime($search_end); + } + if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // All test are required to be compatible with all browsers + { + $search_start = ''; + $tms_start = ''; + $search_end = ''; + $tms_end = ''; + } dol_include_once('/comm/action/class/actioncomm.class.php'); // Check parameters @@ -1379,54 +1399,47 @@ function show_actions_done($conf, $langs, $db, $filterobj, $objcon = '', $noprin } } - // Condition on actioncode - if (!empty($actioncode)) - { - if (empty($conf->global->AGENDA_USE_EVENT_TYPE)) - { - if ($actioncode == 'AC_NON_AUTO') $sql .= " AND c.type != 'systemauto'"; - elseif ($actioncode == 'AC_ALL_AUTO') $sql .= " AND c.type = 'systemauto'"; - else { - if ($actioncode == 'AC_OTH') $sql .= " AND c.type != 'systemauto'"; - elseif ($actioncode == 'AC_OTH_AUTO') $sql .= " AND c.type = 'systemauto'"; + if(! empty($search_start) && ! empty($search_end)) { + $sql .= " AND ((a.datep BETWEEN '$search_start' AND '$search_end') OR (a.datep2 BETWEEN '$search_start' AND '$search_end'))"; + } + else if(empty($search_start) && ! empty($search_end)) { + $sql .= " AND ((a.datep <= '$search_end') OR (a.datep2 <= '$search_end'))"; + } + else if(! empty($search_start) && empty($search_end)) { + $sql .= " AND ((a.datep >= '$search_start') OR (a.datep2 >= '$search_start'))"; + } + + if(is_array($actioncode) && ! empty($actioncode)) { + $sql .= ' AND ('; + foreach($actioncode as $key => $code) { + if($key != 0) $sql .= "OR ("; + if(! empty($code)) addEventTypeSQL($sql, $code, $donetodo, $now, $filters, ""); + if($key != 0) $sql .= ")"; + } + $sql .= ')'; + } + else if(! empty($actioncode)) addEventTypeSQL($sql, $actioncode, $donetodo, $now, $filters); + + if(is_array($actioncode)) { + + foreach($actioncode as $code) { + $sql2 = addMailingEventTypeSQL($code, $objcon, $filterobj); + if(! empty($sql2)) { + if(! empty($sql)) $sql = $sql." UNION ".$sql2; + else if(empty($sql)) $sql = $sql2; + break; } - } else { - if ($actioncode == 'AC_NON_AUTO') $sql .= " AND c.type != 'systemauto'"; - elseif ($actioncode == 'AC_ALL_AUTO') $sql .= " AND c.type = 'systemauto'"; - else $sql .= " AND c.code = '".$db->escape($actioncode)."'"; } } - if ($donetodo == 'todo') $sql .= " AND ((a.percent >= 0 AND a.percent < 100) OR (a.percent = -1 AND a.datep > '".$db->idate($now)."'))"; - elseif ($donetodo == 'done') $sql .= " AND (a.percent = 100 OR (a.percent = -1 AND a.datep <= '".$db->idate($now)."'))"; - if (is_array($filters) && $filters['search_agenda_label']) $sql .= natural_search('a.label', $filters['search_agenda_label']); - } - - // Add also event from emailings. TODO This should be replaced by an automatic event ? May be it's too much for very large emailing. - if (!empty($conf->mailing->enabled) && !empty($objcon->email) - && (empty($actioncode) || $actioncode == 'AC_OTH_AUTO' || $actioncode == 'AC_EMAILING')) - { - $langs->load("mails"); - - $sql2 = "SELECT m.rowid as id, m.titre as label, mc.date_envoi as dp, mc.date_envoi as dp2, '100' as percent, 'mailing' as type"; - $sql2 .= ", '' as fk_element, '' as elementtype, '' as contact_id"; - $sql2 .= ", 'AC_EMAILING' as acode, '' as alabel, '' as apicto"; - $sql2 .= ", u.rowid as user_id, u.login as user_login, u.photo as user_photo, u.firstname as user_firstname, u.lastname as user_lastname"; // User that valid action - if (is_object($filterobj) && get_class($filterobj) == 'Societe') $sql2 .= ", '' as lastname, '' as firstname"; - elseif (is_object($filterobj) && get_class($filterobj) == 'Adherent') $sql2 .= ", '' as lastname, '' as firstname"; - elseif (is_object($filterobj) && get_class($filterobj) == 'CommandeFournisseur') $sql2 .= ", '' as ref"; - elseif (is_object($filterobj) && get_class($filterobj) == 'Product') $sql2 .= ", '' as ref"; - elseif (is_object($filterobj) && get_class($filterobj) == 'Ticket') $sql2 .= ", '' as ref"; - $sql2 .= " FROM ".MAIN_DB_PREFIX."mailing as m, ".MAIN_DB_PREFIX."mailing_cibles as mc, ".MAIN_DB_PREFIX."user as u"; - $sql2 .= " WHERE mc.email = '".$db->escape($objcon->email)."'"; // Search is done on email. - $sql2 .= " AND mc.statut = 1"; - $sql2 .= " AND u.rowid = m.fk_user_valid"; - $sql2 .= " AND mc.fk_mailing=m.rowid"; - } - - if (!empty($sql) && !empty($sql2)) { - $sql = $sql." UNION ".$sql2; - } elseif (empty($sql) && !empty($sql2)) { - $sql = $sql2; + else { + $sql2 = addMailingEventTypeSQL($actioncode, $objcon, $filterobj); + if(! empty($sql) && ! empty($sql2)) { + $sql = $sql." UNION ".$sql2; + } + else if(empty($sql) && ! empty($sql2)) { + $sql = $sql2; + } + } } //TODO Add limit in nb of results @@ -1550,10 +1563,10 @@ function show_actions_done($conf, $langs, $db, $filterobj, $objcon = '', $noprin $out .= '
'; $out .= ''; $out .= ''; $out .= ''; - $out .= ''; + $out .= ''; $out .= ''; $out .= ''; $out .= ''; @@ -1830,3 +1843,55 @@ function show_subsidiaries($conf, $langs, $db, $object) return $i; } + +function addEventTypeSQL(&$sql, $actioncode, $donetodo, $now, $filters, $sqlANDOR = "AND") { + global $conf, $db; + // Condition on actioncode + + if (empty($conf->global->AGENDA_USE_EVENT_TYPE)) + { + if ($actioncode == 'AC_NON_AUTO') $sql .= " $sqlANDOR c.type != 'systemauto'"; + elseif ($actioncode == 'AC_ALL_AUTO') $sql .= " $sqlANDOR c.type = 'systemauto'"; + else + { + if ($actioncode == 'AC_OTH') $sql .= " $sqlANDOR c.type != 'systemauto'"; + elseif ($actioncode == 'AC_OTH_AUTO') $sql .= " $sqlANDOR c.type = 'systemauto'"; + } + } + else + { + if ($actioncode == 'AC_NON_AUTO') $sql .= " $sqlANDOR c.type != 'systemauto'"; + elseif ($actioncode == 'AC_ALL_AUTO') $sql .= " $sqlANDOR c.type = 'systemauto'"; + else $sql .= " $sqlANDOR c.code = '".$db->escape($actioncode)."'"; + } + + if ($donetodo == 'todo') $sql .= " AND ((a.percent >= 0 AND a.percent < 100) OR (a.percent = -1 AND a.datep > '".$db->idate($now)."'))"; + elseif ($donetodo == 'done') $sql .= " AND (a.percent = 100 OR (a.percent = -1 AND a.datep <= '".$db->idate($now)."'))"; + if (is_array($filters) && $filters['search_agenda_label']) $sql .= natural_search('a.label', $filters['search_agenda_label']); +} + +function addMailingEventTypeSQL($actioncode, $objcon, $filterobj) { + global $conf, $langs, $db; + // Add also event from emailings. TODO This should be replaced by an automatic event ? May be it's too much for very large emailing. + if (!empty($conf->mailing->enabled) && !empty($objcon->email) + && (empty($actioncode) || $actioncode == 'AC_OTH_AUTO' || $actioncode == 'AC_EMAILING')) { + $langs->load("mails"); + + $sql2 = "SELECT m.rowid as id, m.titre as label, mc.date_envoi as dp, mc.date_envoi as dp2, '100' as percent, 'mailing' as type"; + $sql2 .= ", '' as fk_element, '' as elementtype, '' as contact_id"; + $sql2 .= ", 'AC_EMAILING' as acode, '' as alabel, '' as apicto"; + $sql2 .= ", u.rowid as user_id, u.login as user_login, u.photo as user_photo, u.firstname as user_firstname, u.lastname as user_lastname"; // User that valid action + if(is_object($filterobj) && get_class($filterobj) == 'Societe') $sql2 .= ", '' as lastname, '' as firstname"; + else if(is_object($filterobj) && get_class($filterobj) == 'Adherent') $sql2 .= ", '' as lastname, '' as firstname"; + else if(is_object($filterobj) && get_class($filterobj) == 'CommandeFournisseur') $sql2 .= ", '' as ref"; + else if(is_object($filterobj) && get_class($filterobj) == 'Product') $sql2 .= ", '' as ref"; + else if(is_object($filterobj) && get_class($filterobj) == 'Ticket') $sql2 .= ", '' as ref"; + $sql2 .= " FROM ".MAIN_DB_PREFIX."mailing as m, ".MAIN_DB_PREFIX."mailing_cibles as mc, ".MAIN_DB_PREFIX."user as u"; + $sql2 .= " WHERE mc.email = '".$db->escape($objcon->email)."'"; // Search is done on email. + $sql2 .= " AND mc.statut = 1"; + $sql2 .= " AND u.rowid = m.fk_user_valid"; + $sql2 .= " AND mc.fk_mailing=m.rowid"; + return $sql2; + } + +} From 3dd7c81f54b8b17d4f9c606b161dc81162871c9b Mon Sep 17 00:00:00 2001 From: atm-quentin Date: Mon, 8 Jun 2020 15:58:20 +0200 Subject: [PATCH 06/83] FIX stickler --- htdocs/core/class/html.form.class.php | 10 ++++--- htdocs/core/lib/company.lib.php | 43 +++++++++++++++++++-------- 2 files changed, 37 insertions(+), 16 deletions(-) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index f3560be0545..76a203ad8df 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -5251,13 +5251,15 @@ class Form * @param integer $set_time Pre-selected date (must be a local PHP server timestamp), -1 to keep date not preselected, '' to use current date with 00:00 hour (Parameter 'empty' must be 0 or 2). * @param integer $set_time_end Pre-selected date (must be a local PHP server timestamp), -1 to keep date not preselected, '' to use current date with 00:00 hour (Parameter 'empty' must be 0 or 2). * @param string $prefix Prefix for fields name + * @param string $empty 0=Fields required, 1=Empty inputs are allowed, 2=Empty inputs are allowed for hours only * @return string Html for selectDate * @see form_date(), select_month(), select_year(), select_dayofweek() */ - public function selectDateToDate($set_time = '', $set_time_end = '', $prefix = 're', $empty = 0) { - $ret = $this->selectDate($set_time, $prefix.'_start',0 ,0, $empty); - $ret .='
'; - $ret .=$this->selectDate($set_time_end, $prefix.'_end', 0 ,0, $empty); + public function selectDateToDate($set_time = '', $set_time_end = '', $prefix = 're', $empty = 0) + { + $ret = $this->selectDate($set_time, $prefix.'_start', 0, 0, $empty); + $ret .= '
'; + $ret .= $this->selectDate($set_time_end, $prefix.'_end', 0, 0, $empty); return $ret; } diff --git a/htdocs/core/lib/company.lib.php b/htdocs/core/lib/company.lib.php index 6e1f87bc962..5f7d9f8fccf 100644 --- a/htdocs/core/lib/company.lib.php +++ b/htdocs/core/lib/company.lib.php @@ -1279,11 +1279,11 @@ function show_actions_done($conf, $langs, $db, $filterobj, $objcon = '', $noprin $end_year = GETPOST('dateevent_endyear'); $end_month = GETPOST('dateevent_endmonth'); $end_day = GETPOST('dateevent_endday'); - if(!empty($start_year) && !empty($start_month) && !empty($start_day)) { + if (!empty($start_year) && !empty($start_month) && !empty($start_day)) { $search_start = $start_year.'-'.$start_month.'-'.$start_day; $tms_start = strtotime($search_start); } - if(!empty($end_year) && !empty($end_month) && !empty($end_day)) { + if (!empty($end_year) && !empty($end_month) && !empty($end_day)) { $search_end = $end_year.'-'.$end_month.'-'.$end_day.' 23:59:59'; $tms_end = strtotime($search_end); } @@ -1399,13 +1399,13 @@ function show_actions_done($conf, $langs, $db, $filterobj, $objcon = '', $noprin } } - if(! empty($search_start) && ! empty($search_end)) { + if(! empty($search_start) && ! empty($search_end)) { $sql .= " AND ((a.datep BETWEEN '$search_start' AND '$search_end') OR (a.datep2 BETWEEN '$search_start' AND '$search_end'))"; } - else if(empty($search_start) && ! empty($search_end)) { + elseif (empty($search_start) && ! empty($search_end)) { $sql .= " AND ((a.datep <= '$search_end') OR (a.datep2 <= '$search_end'))"; } - else if(! empty($search_start) && empty($search_end)) { + elseif (! empty($search_start) && empty($search_end)) { $sql .= " AND ((a.datep >= '$search_start') OR (a.datep2 >= '$search_start'))"; } @@ -1418,25 +1418,25 @@ function show_actions_done($conf, $langs, $db, $filterobj, $objcon = '', $noprin } $sql .= ')'; } - else if(! empty($actioncode)) addEventTypeSQL($sql, $actioncode, $donetodo, $now, $filters); + elseif (! empty($actioncode)) addEventTypeSQL($sql, $actioncode, $donetodo, $now, $filters); if(is_array($actioncode)) { foreach($actioncode as $code) { $sql2 = addMailingEventTypeSQL($code, $objcon, $filterobj); - if(! empty($sql2)) { - if(! empty($sql)) $sql = $sql." UNION ".$sql2; - else if(empty($sql)) $sql = $sql2; + if (! empty($sql2)) { + if (! empty($sql)) $sql = $sql." UNION ".$sql2; + elseif (empty($sql)) $sql = $sql2; break; } } } else { $sql2 = addMailingEventTypeSQL($actioncode, $objcon, $filterobj); - if(! empty($sql) && ! empty($sql2)) { + if (! empty($sql) && ! empty($sql2)) { $sql = $sql." UNION ".$sql2; } - else if(empty($sql) && ! empty($sql2)) { + elseif (empty($sql) && ! empty($sql2)) { $sql = $sql2; } } @@ -1843,7 +1843,18 @@ function show_subsidiaries($conf, $langs, $db, $object) return $i; } - +/** + * Add Event Type SQL + * + * @param string $sql $sql modified + * @param string $actioncode Action code + * @param string $donetodo donetodo + * @param string $now now + * @param string $filters array + * @param string $donetodo donetodo + * @param string $sqlANDOR "AND", "OR" or "" + * @return void + */ function addEventTypeSQL(&$sql, $actioncode, $donetodo, $now, $filters, $sqlANDOR = "AND") { global $conf, $db; // Condition on actioncode @@ -1870,6 +1881,14 @@ function addEventTypeSQL(&$sql, $actioncode, $donetodo, $now, $filters, $sqlANDO if (is_array($filters) && $filters['search_agenda_label']) $sql .= natural_search('a.label', $filters['search_agenda_label']); } +/** + * Add Mailing Event Type SQL + * + * @param string $actioncode Action code + * @param string $objcon objcon + * @param Object $filterobj + * @return string + */ function addMailingEventTypeSQL($actioncode, $objcon, $filterobj) { global $conf, $langs, $db; // Add also event from emailings. TODO This should be replaced by an automatic event ? May be it's too much for very large emailing. From b4dd11ec98af2a07b62802128133f2228e0affc3 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Mon, 8 Jun 2020 14:00:57 +0000 Subject: [PATCH 07/83] Fixing style errors. --- htdocs/core/lib/company.lib.php | 62 ++++++++++++++++----------------- 1 file changed, 30 insertions(+), 32 deletions(-) diff --git a/htdocs/core/lib/company.lib.php b/htdocs/core/lib/company.lib.php index 5f7d9f8fccf..b98a61b451d 100644 --- a/htdocs/core/lib/company.lib.php +++ b/htdocs/core/lib/company.lib.php @@ -1399,7 +1399,7 @@ function show_actions_done($conf, $langs, $db, $filterobj, $objcon = '', $noprin } } - if(! empty($search_start) && ! empty($search_end)) { + if (! empty($search_start) && ! empty($search_end)) { $sql .= " AND ((a.datep BETWEEN '$search_start' AND '$search_end') OR (a.datep2 BETWEEN '$search_start' AND '$search_end'))"; } elseif (empty($search_start) && ! empty($search_end)) { @@ -1409,20 +1409,19 @@ function show_actions_done($conf, $langs, $db, $filterobj, $objcon = '', $noprin $sql .= " AND ((a.datep >= '$search_start') OR (a.datep2 >= '$search_start'))"; } - if(is_array($actioncode) && ! empty($actioncode)) { + if (is_array($actioncode) && ! empty($actioncode)) { $sql .= ' AND ('; - foreach($actioncode as $key => $code) { - if($key != 0) $sql .= "OR ("; - if(! empty($code)) addEventTypeSQL($sql, $code, $donetodo, $now, $filters, ""); - if($key != 0) $sql .= ")"; + foreach ($actioncode as $key => $code) { + if ($key != 0) $sql .= "OR ("; + if (! empty($code)) addEventTypeSQL($sql, $code, $donetodo, $now, $filters, ""); + if ($key != 0) $sql .= ")"; } $sql .= ')'; } elseif (! empty($actioncode)) addEventTypeSQL($sql, $actioncode, $donetodo, $now, $filters); - if(is_array($actioncode)) { - - foreach($actioncode as $code) { + if (is_array($actioncode)) { + foreach ($actioncode as $code) { $sql2 = addMailingEventTypeSQL($code, $objcon, $filterobj); if (! empty($sql2)) { if (! empty($sql)) $sql = $sql." UNION ".$sql2; @@ -1855,26 +1854,25 @@ function show_subsidiaries($conf, $langs, $db, $object) * @param string $sqlANDOR "AND", "OR" or "" * @return void */ -function addEventTypeSQL(&$sql, $actioncode, $donetodo, $now, $filters, $sqlANDOR = "AND") { +function addEventTypeSQL(&$sql, $actioncode, $donetodo, $now, $filters, $sqlANDOR = "AND") +{ global $conf, $db; // Condition on actioncode - if (empty($conf->global->AGENDA_USE_EVENT_TYPE)) + if (empty($conf->global->AGENDA_USE_EVENT_TYPE)) { - if ($actioncode == 'AC_NON_AUTO') $sql .= " $sqlANDOR c.type != 'systemauto'"; - elseif ($actioncode == 'AC_ALL_AUTO') $sql .= " $sqlANDOR c.type = 'systemauto'"; - else - { - if ($actioncode == 'AC_OTH') $sql .= " $sqlANDOR c.type != 'systemauto'"; - elseif ($actioncode == 'AC_OTH_AUTO') $sql .= " $sqlANDOR c.type = 'systemauto'"; - } - } - else - { - if ($actioncode == 'AC_NON_AUTO') $sql .= " $sqlANDOR c.type != 'systemauto'"; - elseif ($actioncode == 'AC_ALL_AUTO') $sql .= " $sqlANDOR c.type = 'systemauto'"; - else $sql .= " $sqlANDOR c.code = '".$db->escape($actioncode)."'"; - } + if ($actioncode == 'AC_NON_AUTO') $sql .= " $sqlANDOR c.type != 'systemauto'"; + elseif ($actioncode == 'AC_ALL_AUTO') $sql .= " $sqlANDOR c.type = 'systemauto'"; + else { + if ($actioncode == 'AC_OTH') $sql .= " $sqlANDOR c.type != 'systemauto'"; + elseif ($actioncode == 'AC_OTH_AUTO') $sql .= " $sqlANDOR c.type = 'systemauto'"; + } + } + else { + if ($actioncode == 'AC_NON_AUTO') $sql .= " $sqlANDOR c.type != 'systemauto'"; + elseif ($actioncode == 'AC_ALL_AUTO') $sql .= " $sqlANDOR c.type = 'systemauto'"; + else $sql .= " $sqlANDOR c.code = '".$db->escape($actioncode)."'"; + } if ($donetodo == 'todo') $sql .= " AND ((a.percent >= 0 AND a.percent < 100) OR (a.percent = -1 AND a.datep > '".$db->idate($now)."'))"; elseif ($donetodo == 'done') $sql .= " AND (a.percent = 100 OR (a.percent = -1 AND a.datep <= '".$db->idate($now)."'))"; @@ -1889,7 +1887,8 @@ function addEventTypeSQL(&$sql, $actioncode, $donetodo, $now, $filters, $sqlANDO * @param Object $filterobj * @return string */ -function addMailingEventTypeSQL($actioncode, $objcon, $filterobj) { +function addMailingEventTypeSQL($actioncode, $objcon, $filterobj) +{ global $conf, $langs, $db; // Add also event from emailings. TODO This should be replaced by an automatic event ? May be it's too much for very large emailing. if (!empty($conf->mailing->enabled) && !empty($objcon->email) @@ -1900,11 +1899,11 @@ function addMailingEventTypeSQL($actioncode, $objcon, $filterobj) { $sql2 .= ", '' as fk_element, '' as elementtype, '' as contact_id"; $sql2 .= ", 'AC_EMAILING' as acode, '' as alabel, '' as apicto"; $sql2 .= ", u.rowid as user_id, u.login as user_login, u.photo as user_photo, u.firstname as user_firstname, u.lastname as user_lastname"; // User that valid action - if(is_object($filterobj) && get_class($filterobj) == 'Societe') $sql2 .= ", '' as lastname, '' as firstname"; - else if(is_object($filterobj) && get_class($filterobj) == 'Adherent') $sql2 .= ", '' as lastname, '' as firstname"; - else if(is_object($filterobj) && get_class($filterobj) == 'CommandeFournisseur') $sql2 .= ", '' as ref"; - else if(is_object($filterobj) && get_class($filterobj) == 'Product') $sql2 .= ", '' as ref"; - else if(is_object($filterobj) && get_class($filterobj) == 'Ticket') $sql2 .= ", '' as ref"; + if (is_object($filterobj) && get_class($filterobj) == 'Societe') $sql2 .= ", '' as lastname, '' as firstname"; + elseif (is_object($filterobj) && get_class($filterobj) == 'Adherent') $sql2 .= ", '' as lastname, '' as firstname"; + elseif (is_object($filterobj) && get_class($filterobj) == 'CommandeFournisseur') $sql2 .= ", '' as ref"; + elseif (is_object($filterobj) && get_class($filterobj) == 'Product') $sql2 .= ", '' as ref"; + elseif (is_object($filterobj) && get_class($filterobj) == 'Ticket') $sql2 .= ", '' as ref"; $sql2 .= " FROM ".MAIN_DB_PREFIX."mailing as m, ".MAIN_DB_PREFIX."mailing_cibles as mc, ".MAIN_DB_PREFIX."user as u"; $sql2 .= " WHERE mc.email = '".$db->escape($objcon->email)."'"; // Search is done on email. $sql2 .= " AND mc.statut = 1"; @@ -1912,5 +1911,4 @@ function addMailingEventTypeSQL($actioncode, $objcon, $filterobj) { $sql2 .= " AND mc.fk_mailing=m.rowid"; return $sql2; } - } From 012574b487042cfa7ca878f0edc98c408b670b8c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 12 Jun 2020 00:51:19 +0200 Subject: [PATCH 08/83] Update html.form.class.php --- htdocs/core/class/html.form.class.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 76a203ad8df..d8d43931083 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -5241,6 +5241,7 @@ class Form print $retstring; return; } + /** * Show 2 HTML widget to input a date or combo list for day, month, years and optionaly hours and minutes. * Fields are preselected with : From f86f4c1e1d6635aea23d6b20560efb9ffade9e1f Mon Sep 17 00:00:00 2001 From: Marc Guenneugues Date: Sun, 21 Jun 2020 19:02:20 +0200 Subject: [PATCH 09/83] Change label of checkbox to be more explicit --- htdocs/langs/en_US/stocks.lang | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/langs/en_US/stocks.lang b/htdocs/langs/en_US/stocks.lang index e5fd3db9260..413eebd4d86 100644 --- a/htdocs/langs/en_US/stocks.lang +++ b/htdocs/langs/en_US/stocks.lang @@ -119,7 +119,7 @@ CurentlyUsingPhysicalStock=Physical stock RuleForStockReplenishment=Rule for stocks replenishment SelectProductWithNotNullQty=Select at least one product with a qty not null and a vendor AlertOnly= Alerts only -IncludeProductWithUndefinedAlerts = Include products with no defined alerts +IncludeProductWithUndefinedAlerts = Include also negative stock for products with no desired quantity defined, to restore them to 0 WarehouseForStockDecrease=The warehouse %s will be used for stock decrease WarehouseForStockIncrease=The warehouse %s will be used for stock increase ForThisWarehouse=For this warehouse From bf338b4d4f2566e58b11d4229a5665d89dcce882 Mon Sep 17 00:00:00 2001 From: lvessiller Date: Mon, 22 Jun 2020 08:57:52 +0200 Subject: [PATCH 10/83] NEW show links for select and multi-select in category extra field --- htdocs/core/class/extrafields.class.php | 136 ++++++++++++++++-------- 1 file changed, 89 insertions(+), 47 deletions(-) diff --git a/htdocs/core/class/extrafields.class.php b/htdocs/core/class/extrafields.class.php index 4de540c9009..dc576e26823 100644 --- a/htdocs/core/class/extrafields.class.php +++ b/htdocs/core/class/extrafields.class.php @@ -1621,6 +1621,13 @@ class ExtraFields $keyList .= implode(', ', $fields_label); } + $filter_categorie = false; + if (count($InfoFieldList) > 5) { + if ($InfoFieldList[0] == 'categorie') { + $filter_categorie = true; + } + } + $sql = 'SELECT '.$keyList; $sql .= ' FROM '.MAIN_DB_PREFIX.$InfoFieldList[0]; if (strpos($InfoFieldList[4], 'extra') !== false) @@ -1641,37 +1648,49 @@ class ExtraFields $resql = $this->db->query($sql); if ($resql) { - $value = ''; // value was used, so now we reste it to use it to build final output + if ($filter_categorie === false) { + $value = ''; // value was used, so now we reste it to use it to build final output - $obj = $this->db->fetch_object($resql); + $obj = $this->db->fetch_object($resql); - // Several field into label (eq table:code|libelle:rowid) - $fields_label = explode('|', $InfoFieldList[1]); + // Several field into label (eq table:code|libelle:rowid) + $fields_label = explode('|', $InfoFieldList[1]); - if (is_array($fields_label) && count($fields_label) > 1) - { - foreach ($fields_label as $field_toshow) - { - $translabel = ''; - if (!empty($obj->$field_toshow)) { - $translabel = $langs->trans($obj->$field_toshow); + if (is_array($fields_label) && count($fields_label) > 1) { + foreach ($fields_label as $field_toshow) { + $translabel = ''; + if (!empty($obj->$field_toshow)) { + $translabel = $langs->trans($obj->$field_toshow); + } + if ($translabel != $field_toshow) { + $value .= dol_trunc($translabel, 18) . ' '; + } else { + $value .= $obj->$field_toshow . ' '; + } } - if ($translabel != $field_toshow) { - $value .= dol_trunc($translabel, 18).' '; + } else { + $translabel = ''; + if (!empty($obj->{$InfoFieldList[1]})) { + $translabel = $langs->trans($obj->{$InfoFieldList[1]}); + } + if ($translabel != $obj->{$InfoFieldList[1]}) { + $value = dol_trunc($translabel, 18); } else { - $value .= $obj->$field_toshow.' '; + $value = $obj->{$InfoFieldList[1]}; } } } else { - $translabel = ''; - if (!empty($obj->{$InfoFieldList[1]})) { - $translabel = $langs->trans($obj->{$InfoFieldList[1]}); - } - if ($translabel != $obj->{$InfoFieldList[1]}) { - $value = dol_trunc($translabel, 18); - } else { - $value = $obj->{$InfoFieldList[1]}; + require_once DOL_DOCUMENT_ROOT . '/categories/class/categorie.class.php'; + + $toprint = array(); + $obj = $this->db->fetch_object($resql); + $c = new Categorie($this->db); + $c->fetch($obj->rowid); + $ways = $c->print_all_ways(); // $ways[0] = "ccc2 >> ccc2a >> ccc2a1" with html formatted text + foreach ($ways as $way) { + $toprint[] = '
  • color ? ' style="background: #' . $c->color . ';"' : ' style="background: #aaa"') . '>' . img_object('', 'category') . ' ' . $way . '
  • '; } + $value = '
      '.implode(' ', $toprint).'
    '; } } else dol_syslog(get_class($this).'::showOutputField error '.$this->db->lasterror(), LOG_WARNING); } elseif ($type == 'radio') @@ -1710,6 +1729,13 @@ class ExtraFields $keyList .= implode(', ', $fields_label); } + $filter_categorie = false; + if (count($InfoFieldList) > 5) { + if ($InfoFieldList[0] == 'categorie') { + $filter_categorie = true; + } + } + $sql = 'SELECT '.$keyList; $sql .= ' FROM '.MAIN_DB_PREFIX.$InfoFieldList[0]; if (strpos($InfoFieldList[4], 'extra') !== false) { @@ -1721,33 +1747,49 @@ class ExtraFields dol_syslog(get_class($this).':showOutputField:$type=chkbxlst', LOG_DEBUG); $resql = $this->db->query($sql); if ($resql) { - $value = ''; // value was used, so now we reste it to use it to build final output - $toprint = array(); - while ($obj = $this->db->fetch_object($resql)) { - // Several field into label (eq table:code|libelle:rowid) - $fields_label = explode('|', $InfoFieldList[1]); - if (is_array($value_arr) && in_array($obj->rowid, $value_arr)) { - if (is_array($fields_label) && count($fields_label) > 1) { - foreach ($fields_label as $field_toshow) { - $translabel = ''; - if (!empty($obj->$field_toshow)) { - $translabel = $langs->trans($obj->$field_toshow); + if ($filter_categorie === false) { + $value = ''; // value was used, so now we reste it to use it to build final output + $toprint = array(); + while ($obj = $this->db->fetch_object($resql)) { + // Several field into label (eq table:code|libelle:rowid) + $fields_label = explode('|', $InfoFieldList[1]); + if (is_array($value_arr) && in_array($obj->rowid, $value_arr)) { + if (is_array($fields_label) && count($fields_label) > 1) { + foreach ($fields_label as $field_toshow) { + $translabel = ''; + if (!empty($obj->$field_toshow)) { + $translabel = $langs->trans($obj->$field_toshow); + } + if ($translabel != $field_toshow) { + $toprint[] = '
  • ' . dol_trunc($translabel, 18) . '
  • '; + } else { + $toprint[] = '
  • ' . $obj->$field_toshow . '
  • '; + } } - if ($translabel != $field_toshow) { - $toprint[] = '
  • '.dol_trunc($translabel, 18).'
  • '; - } else { - $toprint[] = '
  • '.$obj->$field_toshow.'
  • '; - } - } - } else { - $translabel = ''; - if (!empty($obj->{$InfoFieldList[1]})) { - $translabel = $langs->trans($obj->{$InfoFieldList[1]}); - } - if ($translabel != $obj->{$InfoFieldList[1]}) { - $toprint[] = '
  • '.dol_trunc($translabel, 18).'
  • '; } else { - $toprint[] = '
  • '.$obj->{$InfoFieldList[1]}.'
  • '; + $translabel = ''; + if (!empty($obj->{$InfoFieldList[1]})) { + $translabel = $langs->trans($obj->{$InfoFieldList[1]}); + } + if ($translabel != $obj->{$InfoFieldList[1]}) { + $toprint[] = '
  • ' . dol_trunc($translabel, 18) . '
  • '; + } else { + $toprint[] = '
  • ' . $obj->{$InfoFieldList[1]} . '
  • '; + } + } + } + } + } else { + require_once DOL_DOCUMENT_ROOT . '/categories/class/categorie.class.php'; + + $toprint = array(); + while ($obj = $this->db->fetch_object($resql)) { + if (is_array($value_arr) && in_array($obj->rowid, $value_arr)) { + $c = new Categorie($this->db); + $c->fetch($obj->rowid); + $ways = $c->print_all_ways(); // $ways[0] = "ccc2 >> ccc2a >> ccc2a1" with html formatted text + foreach ($ways as $way) { + $toprint[] = '
  • color ? ' style="background: #' . $c->color . ';"' : ' style="background: #aaa"') . '>' . img_object('', 'category') . ' ' . $way . '
  • '; } } } From 731978fda6a35393f11e304d94fcc21926302092 Mon Sep 17 00:00:00 2001 From: Francis Appels Date: Sun, 28 Jun 2020 16:33:44 +0200 Subject: [PATCH 11/83] FIX html lost on html extrafield --- htdocs/core/class/extrafields.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/class/extrafields.class.php b/htdocs/core/class/extrafields.class.php index e1a834a42ca..ae5d41dba48 100644 --- a/htdocs/core/class/extrafields.class.php +++ b/htdocs/core/class/extrafields.class.php @@ -2086,7 +2086,7 @@ class ExtraFields $value_key = ''; } } - elseif (in_array($key_type, array('price', 'double'))) + elseif (in_array($key_type, array('price', 'double', 'html'))) { $value_arr = GETPOST("options_".$key, 'alpha'); $value_key = price2num($value_arr); From 245ba93895f54047c5836cc278648fea3a7a4979 Mon Sep 17 00:00:00 2001 From: Je2fb <46494485+Je2fb@users.noreply.github.com> Date: Sun, 28 Jun 2020 17:53:48 +0200 Subject: [PATCH 12/83] fix #14143 --- htdocs/core/class/evalmath.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/class/evalmath.class.php b/htdocs/core/class/evalmath.class.php index a520ebb3a21..dd665713679 100644 --- a/htdocs/core/class/evalmath.class.php +++ b/htdocs/core/class/evalmath.class.php @@ -194,7 +194,7 @@ class EvalMath * * @return string Output */ - private function vars() + public function vars() { $output = $this->v; unset($output['pi']); From 5d65b5f66025473cfca99bb6bd48f0c5f7fbfc71 Mon Sep 17 00:00:00 2001 From: Francis Appels Date: Mon, 29 Jun 2020 09:07:54 +0200 Subject: [PATCH 13/83] fix html should not do price2num --- htdocs/core/class/extrafields.class.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/htdocs/core/class/extrafields.class.php b/htdocs/core/class/extrafields.class.php index ae5d41dba48..caf43f94342 100644 --- a/htdocs/core/class/extrafields.class.php +++ b/htdocs/core/class/extrafields.class.php @@ -2086,11 +2086,15 @@ class ExtraFields $value_key = ''; } } - elseif (in_array($key_type, array('price', 'double', 'html'))) + elseif (in_array($key_type, array('price', 'double'))) { $value_arr = GETPOST("options_".$key, 'alpha'); $value_key = price2num($value_arr); } + elseif (in_array($key_type, array('html'))) + { + $value_key = GETPOST("options_".$key, 'alpha'); + } else { $value_key = GETPOST("options_".$key); From eb22947c07165dec6c56a942c9804012a4570398 Mon Sep 17 00:00:00 2001 From: oscim Date: Mon, 29 Jun 2020 14:01:48 +0200 Subject: [PATCH 14/83] Update project.class.php Fix order of delete extra prev table of project --- htdocs/projet/class/project.class.php | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/htdocs/projet/class/project.class.php b/htdocs/projet/class/project.class.php index 72f83317fb3..5d2eb217031 100644 --- a/htdocs/projet/class/project.class.php +++ b/htdocs/projet/class/project.class.php @@ -721,7 +721,18 @@ class Project extends CommonObject } } + if (!$error) + { + $sql = "DELETE FROM ".MAIN_DB_PREFIX."projet_extrafields"; + $sql .= " WHERE fk_object=".$this->id; + $resql = $this->db->query($sql); + if (!$resql) + { + $this->errors[] = $this->db->lasterror(); + $error++; + } + } // Delete project if (!$error) @@ -737,18 +748,7 @@ class Project extends CommonObject } } - if (!$error) - { - $sql = "DELETE FROM ".MAIN_DB_PREFIX."projet_extrafields"; - $sql .= " WHERE fk_object=".$this->id; - $resql = $this->db->query($sql); - if (!$resql) - { - $this->errors[] = $this->db->lasterror(); - $error++; - } - } if (empty($error)) { // We remove directory From f34a3785f07c17e4b9f8ad5c06a6367cae841253 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 29 Jun 2020 16:02:08 +0200 Subject: [PATCH 15/83] FIX CSS --- htdocs/theme/eldy/global.inc.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/theme/eldy/global.inc.php b/htdocs/theme/eldy/global.inc.php index 06feb97c2dd..ef6dd9a2b68 100644 --- a/htdocs/theme/eldy/global.inc.php +++ b/htdocs/theme/eldy/global.inc.php @@ -614,10 +614,10 @@ textarea.centpercent { padding-: 2px; } .paddingtop { - padding-bottom: 4px; + padding-top: 4px; } .paddingtop2 { - padding-bottom: 2px; + padding-top: 2px; } .paddingbottom { padding-bottom: 4px; From 9bb0ef04f54a240b7ebf0f98f0bc3a394cd63959 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 29 Jun 2020 18:07:51 +0200 Subject: [PATCH 16/83] Fix upload of file in import module --- htdocs/core/lib/security.lib.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/htdocs/core/lib/security.lib.php b/htdocs/core/lib/security.lib.php index 3ee5739bc6d..72713393025 100644 --- a/htdocs/core/lib/security.lib.php +++ b/htdocs/core/lib/security.lib.php @@ -289,6 +289,8 @@ function restrictedArea($user, $features, $objectid = 0, $tableandshare = '', $f if (!$user->rights->banque->modifier) { $createok = 0; $nbko++; } } elseif ($feature == 'cheque') { if (!$user->rights->banque->cheque) { $createok = 0; $nbko++; } + } elseif ($feature == 'import') { + if (!$user->rights->import->run) { $createok = 0; $nbko++; } } elseif ($feature == 'ecm') { if (!$user->rights->ecm->upload) { $createok = 0; $nbko++; } } From 6553c40bea8f467b58d79945e0b1b3bde74181d3 Mon Sep 17 00:00:00 2001 From: gauthier Date: Tue, 30 Jun 2020 11:23:55 +0200 Subject: [PATCH 17/83] FIX : create a deposit with amount using comma didn't work --- htdocs/compta/facture/card.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index ff7a1714757..a65d7f6ed81 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -1255,7 +1255,8 @@ if (empty($reshook)) if ($_POST['type'] == Facture::TYPE_DEPOSIT) { $typeamount = GETPOST('typedeposit', 'alpha'); - $valuedeposit = GETPOST('valuedeposit', 'int'); + $valuedeposit = GETPOST('valuedeposit'); + $valuedeposit = price2num($valuedeposit, 'MU'); $amountdeposit = array(); if (!empty($conf->global->MAIN_DEPOSIT_MULTI_TVA)) From 4f1ac84a199059a63e373ad7416ce6ebc37383d1 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 30 Jun 2020 12:07:24 +0200 Subject: [PATCH 18/83] Fix can't find link to edit table plan --- htdocs/langs/en_US/cashdesk.lang | 3 ++- htdocs/takepos/admin/bar.php | 23 ++++++++++++++++++++--- htdocs/takepos/admin/setup.php | 1 + htdocs/takepos/index.php | 2 +- 4 files changed, 24 insertions(+), 5 deletions(-) diff --git a/htdocs/langs/en_US/cashdesk.lang b/htdocs/langs/en_US/cashdesk.lang index 71a2a992e19..4494e10545d 100644 --- a/htdocs/langs/en_US/cashdesk.lang +++ b/htdocs/langs/en_US/cashdesk.lang @@ -111,4 +111,5 @@ AutoOrder=Order by the customer himself RestaurantMenu=Menu CustomerMenu=Customer menu ScanToMenu=Scan QR code to see the menu -ScanToOrder=Scan QR code to order \ No newline at end of file +ScanToOrder=Scan QR code to order +DefineTablePlan=Define table plan \ No newline at end of file diff --git a/htdocs/takepos/admin/bar.php b/htdocs/takepos/admin/bar.php index 97f651efdb2..3d4bd490dde 100644 --- a/htdocs/takepos/admin/bar.php +++ b/htdocs/takepos/admin/bar.php @@ -66,12 +66,14 @@ if (GETPOST('action', 'alpha') == 'set') $form = new Form($db); $formproduct = new FormProduct($db); -llxHeader('', $langs->trans("CashDeskSetup")); +$arrayofcss = array("/takepos/css/colorbox.css"); + +llxHeader('', $langs->trans("CashDeskSetup"), '', '', 0, 0, $arrayofjs, $arrayofcss); $linkback = ''.$langs->trans("BackToModuleList").''; print load_fiche_titre($langs->trans("CashDeskSetup").' (TakePOS)', $linkback, 'title_setup'); $head = takepos_prepare_head(); -dol_fiche_head($head, 'bar', 'TakePOS', -1); +dol_fiche_head($head, 'bar', 'TakePOS', -1, 'cash-register'); print '
    '; @@ -80,6 +82,20 @@ print ''; print ''; print ''; +?> + + + + '.$langs->trans("DefineTablePlan").'
    '; +print '

    '; + print '
    '; print '
       '.$langs->trans('IncludeProductWithUndefinedAlerts').' '.$langs->trans('AlertOnly').' '.$langs->trans('IncludeAlsoDraftOrders').'  '; - $out .= $formactions->select_type_actions($actioncode, "actioncode", '', empty($conf->global->AGENDA_USE_EVENT_TYPE) ? 1 : -1, 0, 0, 1); + $out .= $formactions->select_type_actions($actioncode, "actioncode", '', empty($conf->global->AGENDA_USE_EVENT_TYPE) ? 1 : -1, 0, !empty($conf->global->AGENDA_USE_MULTISELECT_TYPE) ? 1 : -1, 1); $out .= ''.$form->selectDateToDate($tms_start, $tms_end, 'dateevent', 1).'
    '; print ''; @@ -138,9 +154,9 @@ print ''; - print '
    '; print ajax_constantonoff("TAKEPOS_QR_MENU", array(), $conf->entity, 0, 0, 1, 0); print '
    '; + if ($conf->global->TAKEPOS_AUTO_ORDER) { print '
    '; @@ -168,6 +184,7 @@ if ($conf->global->TAKEPOS_AUTO_ORDER) print ''; } + if ($conf->global->TAKEPOS_QR_MENU) { $urlwithouturlroot = preg_replace('/'.preg_quote(DOL_URL_ROOT, '/').'$/i', '', trim($dolibarr_main_url_root)); diff --git a/htdocs/takepos/admin/setup.php b/htdocs/takepos/admin/setup.php index 03607409ea7..a6f8b4968cc 100644 --- a/htdocs/takepos/admin/setup.php +++ b/htdocs/takepos/admin/setup.php @@ -121,6 +121,7 @@ if ($action != '') { } } + /* * View */ diff --git a/htdocs/takepos/index.php b/htdocs/takepos/index.php index f4b83138416..63bbc5d1808 100644 --- a/htdocs/takepos/index.php +++ b/htdocs/takepos/index.php @@ -433,7 +433,7 @@ function CloseBill() { } function Floors() { - console.log("Open box to select floor"); + console.log("Open box to select floor place="+place); $.colorbox({href:"floors.php?place="+place, width:"90%", height:"90%", transition:"none", iframe:"true", title:"trans("Floors"); ?>"}); } From 5afd518718ab4a58308333c451fa42f2c94b5fe1 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 30 Jun 2020 13:06:44 +0200 Subject: [PATCH 19/83] Update vat rate for Congo --- htdocs/install/mysql/data/llx_c_tva.sql | 4 ++++ htdocs/install/mysql/migration/11.0.0-12.0.0.sql | 2 ++ 2 files changed, 6 insertions(+) diff --git a/htdocs/install/mysql/data/llx_c_tva.sql b/htdocs/install/mysql/data/llx_c_tva.sql index 0888c68783c..afd3a762ccc 100644 --- a/htdocs/install/mysql/data/llx_c_tva.sql +++ b/htdocs/install/mysql/data/llx_c_tva.sql @@ -86,6 +86,10 @@ insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values ( 9 insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values ( 93, 9, '3','0','VAT super reduced rate 0',1); insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values ( 94, 9, '17','0','VAT standard rate',1); +-- CONGO = REPUBLIQUE DU CONGO (id country=72) +insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (721, 72, '0','0','VAT Rate 0',1); +insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,localtax1,localtax1_type,note,active) values (722, 72, '18','0', '0.9', '1', 'VAT Rate 18+0.9', 1); + -- CYPRUS (id country=78) insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (781, 78, '0','0','VAT Rate 0',1); insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (782, 78, '9','0','VAT Rate 9',1); diff --git a/htdocs/install/mysql/migration/11.0.0-12.0.0.sql b/htdocs/install/mysql/migration/11.0.0-12.0.0.sql index 2a7fc17e77e..1d543fad548 100644 --- a/htdocs/install/mysql/migration/11.0.0-12.0.0.sql +++ b/htdocs/install/mysql/migration/11.0.0-12.0.0.sql @@ -322,3 +322,5 @@ UPDATE llx_prelevement_facture_demande SET entity = 1 WHERE entity IS NULL; ALTER TABLE llx_prelevement_facture_demande ADD INDEX idx_prelevement_facture_demande_fk_facture (fk_facture); ALTER TABLE llx_prelevement_facture_demande ADD INDEX idx_prelevement_facture_demande_fk_facture_fourn (fk_facture_fourn); +insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (721, 72, '0','0','VAT Rate 0',1); +insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,localtax1,localtax1_type,note,active) values (722, 72, '18','0', '0.9', '1', 'VAT Rate 18+0.9', 1); From 94a1d71fba0766c7872a0e300af47ef5daaa3c0b Mon Sep 17 00:00:00 2001 From: Tim Otte Date: Tue, 30 Jun 2020 15:20:30 +0200 Subject: [PATCH 20/83] Hotfix for an error in v12 --- htdocs/comm/propal/card.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/htdocs/comm/propal/card.php b/htdocs/comm/propal/card.php index 00c311d7209..5b5b7d59711 100644 --- a/htdocs/comm/propal/card.php +++ b/htdocs/comm/propal/card.php @@ -1085,6 +1085,9 @@ if (empty($reshook)) $outputlangs->setDefaultLang($newlang); } $ret = $object->fetch($id); // Reload to get new records + if ($ret > 0) { + $object->fetch_thirdparty(); + } $object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); } From 918e669c98755e896326380e3cfc5a3e45dbf03d Mon Sep 17 00:00:00 2001 From: lvessiller Date: Tue, 30 Jun 2020 16:33:18 +0200 Subject: [PATCH 21/83] FIX change selected fields on company card --- htdocs/societe/card.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/htdocs/societe/card.php b/htdocs/societe/card.php index d277632c348..d2f27419e76 100644 --- a/htdocs/societe/card.php +++ b/htdocs/societe/card.php @@ -846,6 +846,11 @@ if (empty($reshook)) $id=$socid; $object->fetch($socid); + // Selection of new fields + if (!empty($conf->global->MAIN_DUPLICATE_CONTACTS_TAB_ON_MAIN_CARD) && (empty($conf->global->SOCIETE_DISABLE_CONTACTS) || !empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT))) { + include DOL_DOCUMENT_ROOT . '/core/actions_changeselectedfields.inc.php'; + } + // Actions to send emails $trigger_name='COMPANY_SENTBYMAIL'; $paramname='socid'; From caa3661eeb509479dcb7e29cafcab0e3b6a3f718 Mon Sep 17 00:00:00 2001 From: lvessiller Date: Wed, 1 Jul 2020 09:16:44 +0200 Subject: [PATCH 22/83] NEW add order by lastname and firstname by default in get sales representatives --- htdocs/societe/class/societe.class.php | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index a74c0de7c52..935b44ab16d 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -2070,11 +2070,13 @@ class Societe extends CommonObject /** * Return array of sales representatives * - * @param User $user Object user - * @param int $mode 0=Array with properties, 1=Array of id. - * @return array Array of sales representatives of third party + * @param User $user Object user + * @param int $mode 0=Array with properties, 1=Array of id. + * @param string $sortfield List of sort fields, separated by comma. Example: 't1.fielda,t2.fieldb' + * @param string $sortorder Sort order, separated by comma. Example: 'ASC,DESC'; + * @return array Array of sales representatives of third party */ - public function getSalesRepresentatives(User $user, $mode = 0) + public function getSalesRepresentatives(User $user, $mode = 0, $sortfield = null, $sortorder = null) { global $conf; @@ -2091,6 +2093,11 @@ class Societe extends CommonObject } else $sql .= " WHERE entity in (0, ".$conf->entity.")"; $sql .= " AND u.rowid = sc.fk_user AND sc.fk_soc = ".$this->id; + if (empty($sortfield) && empty($sortorder)) { + $sortfield = 'u.lastname,u.firstname'; + $sortorder = 'ASC,ASC'; + } + $sql .= $this->db->order($sortfield, $sortorder); $resql = $this->db->query($sql); if ($resql) From a34c6ec7b08da4628c1d42dcd1c6d07661a363d4 Mon Sep 17 00:00:00 2001 From: laurantines Date: Wed, 1 Jul 2020 13:12:52 +0200 Subject: [PATCH 23/83] Update list.php in Adherents Add Address in search --- htdocs/adherents/list.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/adherents/list.php b/htdocs/adherents/list.php index bf8353da5c9..4dcb34610cf 100644 --- a/htdocs/adherents/list.php +++ b/htdocs/adherents/list.php @@ -298,6 +298,7 @@ if ($search_gender != '' && $search_gender != '-1') $sql .= " AND d.gender = '". if ($search_login) $sql .= natural_search("d.login", $search_login); if ($search_company) $sql .= natural_search("s.nom", $search_company); if ($search_email) $sql .= natural_search("d.email", $search_email); +if ($search_address) $sql .= natural_search("d.address", $search_address); if ($search_town) $sql .= natural_search("d.town", $search_town); if ($search_zip) $sql .= natural_search("d.zip", $search_zip); if ($search_state) $sql .= natural_search("state.nom", $search_state); From 5f37f54675ff7637c88136a04672552f2d437820 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 1 Jul 2020 13:16:06 +0200 Subject: [PATCH 24/83] Fix warning --- htdocs/master.inc.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/master.inc.php b/htdocs/master.inc.php index 4005e6a2ed5..0db06b121fd 100644 --- a/htdocs/master.inc.php +++ b/htdocs/master.inc.php @@ -49,7 +49,7 @@ $conf->db->host = $dolibarr_main_db_host; $conf->db->port = $dolibarr_main_db_port; $conf->db->name = $dolibarr_main_db_name; $conf->db->user = $dolibarr_main_db_user; -$conf->db->pass = $dolibarr_main_db_pass; +$conf->db->pass = empty($dolibarr_main_db_pass)?'':$dolibarr_main_db_pass; $conf->db->type = $dolibarr_main_db_type; $conf->db->prefix = $dolibarr_main_db_prefix; $conf->db->character_set = $dolibarr_main_db_character_set; From 5f2486049eefff6ab31501bb6e3b6bb2b14813f5 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 1 Jul 2020 13:22:15 +0200 Subject: [PATCH 25/83] Fix trans --- htdocs/core/menus/standard/eldy.lib.php | 2 +- htdocs/langs/en_US/banks.lang | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/core/menus/standard/eldy.lib.php b/htdocs/core/menus/standard/eldy.lib.php index f6e5c2c83d6..0bfa4cfd2db 100644 --- a/htdocs/core/menus/standard/eldy.lib.php +++ b/htdocs/core/menus/standard/eldy.lib.php @@ -1491,7 +1491,7 @@ function print_left_eldy_menu($db, $menu_array_before, $menu_array_after, &$tabM // Direct debit order if (!empty($conf->prelevement->enabled)) { - $newmenu->add("/compta/prelevement/index.php?leftmenu=withdraw&mainmenu=bank", $langs->trans("StandingOrders"), 0, $user->rights->prelevement->bons->lire, '', $mainmenu, 'withdraw'); + $newmenu->add("/compta/prelevement/index.php?leftmenu=withdraw&mainmenu=bank", $langs->trans("PaymentByDirectDebit"), 0, $user->rights->prelevement->bons->lire, '', $mainmenu, 'withdraw'); if ($usemenuhider || empty($leftmenu) || $leftmenu == "withdraw") { $newmenu->add("/compta/prelevement/create.php?mainmenu=bank", $langs->trans("NewStandingOrder"), 1, $user->rights->prelevement->bons->creer); diff --git a/htdocs/langs/en_US/banks.lang b/htdocs/langs/en_US/banks.lang index 7a36346733f..75f9549dca5 100644 --- a/htdocs/langs/en_US/banks.lang +++ b/htdocs/langs/en_US/banks.lang @@ -37,6 +37,7 @@ IbanValid=BAN valid IbanNotValid=BAN not valid StandingOrders=Direct debit orders StandingOrder=Direct debit order +PaymentByDirectDebit=Payment by direct debit PaymentByBankTransfers=Payments by credit transfer PaymentByBankTransfer=Payment by credit transfer AccountStatement=Account statement From 39651953b3c6048c40ab60adc548d723c9b0b964 Mon Sep 17 00:00:00 2001 From: quentin Date: Wed, 1 Jul 2020 14:04:41 +0200 Subject: [PATCH 26/83] FIX refacto --- htdocs/core/class/html.form.class.php | 2 +- htdocs/core/lib/company.lib.php | 9 +++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index ece403b3c51..762a22cc37a 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -5241,7 +5241,7 @@ class Form print $retstring; return; } - + /** * Show 2 HTML widget to input a date or combo list for day, month, years and optionaly hours and minutes. * Fields are preselected with : diff --git a/htdocs/core/lib/company.lib.php b/htdocs/core/lib/company.lib.php index b98a61b451d..2d58e545b41 100644 --- a/htdocs/core/lib/company.lib.php +++ b/htdocs/core/lib/company.lib.php @@ -1850,9 +1850,8 @@ function show_subsidiaries($conf, $langs, $db, $object) * @param string $donetodo donetodo * @param string $now now * @param string $filters array - * @param string $donetodo donetodo - * @param string $sqlANDOR "AND", "OR" or "" - * @return void + * @param string $sqlANDOR "AND", "OR" or "" sql condition + * @return string sql request */ function addEventTypeSQL(&$sql, $actioncode, $donetodo, $now, $filters, $sqlANDOR = "AND") { @@ -1877,6 +1876,8 @@ function addEventTypeSQL(&$sql, $actioncode, $donetodo, $now, $filters, $sqlANDO if ($donetodo == 'todo') $sql .= " AND ((a.percent >= 0 AND a.percent < 100) OR (a.percent = -1 AND a.datep > '".$db->idate($now)."'))"; elseif ($donetodo == 'done') $sql .= " AND (a.percent = 100 OR (a.percent = -1 AND a.datep <= '".$db->idate($now)."'))"; if (is_array($filters) && $filters['search_agenda_label']) $sql .= natural_search('a.label', $filters['search_agenda_label']); + + return $sql; } /** @@ -1884,7 +1885,7 @@ function addEventTypeSQL(&$sql, $actioncode, $donetodo, $now, $filters, $sqlANDO * * @param string $actioncode Action code * @param string $objcon objcon - * @param Object $filterobj + * @param Object $filterobj filterobj * @return string */ function addMailingEventTypeSQL($actioncode, $objcon, $filterobj) From d2a364eea85d49c357024ca34b73fc10ceac6970 Mon Sep 17 00:00:00 2001 From: quentin Date: Wed, 1 Jul 2020 14:10:43 +0200 Subject: [PATCH 27/83] NEW get all child recursively --- htdocs/core/class/commonobject.class.php | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 5f9582a475f..03b220f314a 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -2525,10 +2525,11 @@ abstract class CommonObject /** * Get children of line * - * @param int $id Id of parent line - * @return array Array with list of children lines id + * @param int $id Id of parent line + * @param int $includealltree 0 = 1st level child, 1 = All level child + * @return array Array with list of children lines id */ - public function getChildrenOfLine($id) + public function getChildrenOfLine($id, $includealltree = 0) { $rows = array(); @@ -2541,16 +2542,14 @@ abstract class CommonObject $resql = $this->db->query($sql); if ($resql) { - $i = 0; - $num = $this->db->num_rows($resql); - while ($i < $num) - { - $row = $this->db->fetch_row($resql); - $rows[$i] = $row[0]; - $i++; + if($this->db->num_rows($resql) > 0) { + while($row = $this->db->fetch_row($resql)) { + + $rows[] = $row[0]; + if (!empty($includealltree)) $rows = array_merge($rows, $this->getChildrenOfLine($row[0]), $includealltree); + } } } - return $rows; } From e2a9743dd403e9274b82959b9cb375872ebe5e97 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 1 Jul 2020 14:19:47 +0200 Subject: [PATCH 28/83] Debug module credit transfer --- htdocs/compta/facture/prelevement.php | 76 +++++++++++++------ htdocs/compta/paymentbybanktransfer/index.php | 11 +-- .../class/bonprelevement.class.php | 21 +++-- htdocs/compta/prelevement/create.php | 7 +- htdocs/compta/prelevement/index.php | 7 +- htdocs/core/lib/fourn.lib.php | 4 +- 6 files changed, 83 insertions(+), 43 deletions(-) diff --git a/htdocs/compta/facture/prelevement.php b/htdocs/compta/facture/prelevement.php index dd9c1394563..b24723330a0 100644 --- a/htdocs/compta/facture/prelevement.php +++ b/htdocs/compta/facture/prelevement.php @@ -48,13 +48,12 @@ $ref = GETPOST('ref', 'alpha'); $socid = GETPOST('socid', 'int'); $action = GETPOST('action', 'alpha'); $type = GETPOST('type', 'aZ09'); -$mode = GETPOST('mode', 'aZ09'); $fieldid = (!empty($ref) ? 'ref' : 'rowid'); if ($user->socid) $socid = $user->socid; $result = restrictedArea($user, 'facture', $id, '', '', 'fk_soc', $fieldid); -if ($mode == 'bank-transfer') { +if ($type == 'bank-transfer') { $object = new FactureFournisseur($db); } else { $object = new Facture($db); @@ -94,6 +93,7 @@ if (empty($reshook)) $sourcetype = 'facture'; if ($type == 'bank-transfer') { $sourcetype = 'supplier_invoice'; + $newtype = 'bank-transfer'; } $result = $object->demande_prelevement($user, price2num(GETPOST('withdraw_request_amount', 'alpha')), $newtype, $sourcetype); @@ -119,7 +119,7 @@ if (empty($reshook)) $result = $object->demande_prelevement_delete($user, GETPOST('did', 'int')); if ($result == 0) { - header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id.'&mode='.$mode); + header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id.'&type='.$type); exit; } } @@ -135,7 +135,7 @@ $form = new Form($db); $now = dol_now(); -if ($mode == 'bank-transfer') { +if ($type == 'bank-transfer') { $title = $langs->trans('InvoiceSupplier')." - ".$langs->trans('CreditTransfer'); $helpurl = ""; } else { @@ -170,7 +170,7 @@ if ($object->id > 0) if ($object->paye) $resteapayer = 0; $resteapayeraffiche = $resteapayer; - if ($mode == 'bank-transfer') { + if ($type == 'bank-transfer') { if (!empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) { // Never use this $filterabsolutediscount = "fk_invoice_supplier_source IS NULL"; // If we want deposit to be substracted to payments only and not to total of final invoice $filtercreditnote = "fk_invoice_supplier_source IS NOT NULL"; // If we want deposit to be substracted to payments only and not to total of final invoice @@ -204,7 +204,7 @@ if ($object->id > 0) $author->fetch($object->user_author); } - if ($mode == 'bank-transfer') { + if ($type == 'bank-transfer') { $head = facturefourn_prepare_head($object); } else { $head = facture_prepare_head($object); @@ -213,7 +213,7 @@ if ($object->id > 0) dol_fiche_head($head, 'standingorders', $title, -1, 'bill'); // Invoice content - if ($mode == 'bank-transfer') { + if ($type == 'bank-transfer') { $linkback = ''.$langs->trans("BackToList").''; } else { $linkback = ''.$langs->trans("BackToList").''; @@ -221,7 +221,7 @@ if ($object->id > 0) $morehtmlref = '
    '; // Ref customer - if ($mode == 'bank-transfer') { + if ($type == 'bank-transfer') { $morehtmlref .= $form->editfieldkey("RefSupplier", 'ref_supplier', $object->ref_supplier, $object, 0, 'string', '', 0, 1); $morehtmlref .= $form->editfieldval("RefSupplier", 'ref_supplier', $object->ref_supplier, $object, 0, 'string', '', null, null, '', 1); } else { @@ -230,7 +230,7 @@ if ($object->id > 0) } // Thirdparty $morehtmlref .= '
    '.$langs->trans('ThirdParty').' : '.$object->thirdparty->getNomUrl(1); - if ($mode == 'bank-transfer') { + if ($type == 'bank-transfer') { if (empty($conf->global->MAIN_DISABLE_OTHER_LINK) && $object->thirdparty->id > 0) $morehtmlref .= ' ('.$langs->trans("OtherBills").')'; } else { if (empty($conf->global->MAIN_DISABLE_OTHER_LINK) && $object->thirdparty->id > 0) $morehtmlref .= ' ('.$langs->trans("OtherBills").')'; @@ -290,7 +290,7 @@ if ($object->id > 0) } if ($object->type == $object::TYPE_REPLACEMENT) { - if ($mode == 'bank-transfer') { + if ($type == 'bank-transfer') { $facreplaced = new FactureFournisseur($db); } else { $facreplaced = new Facture($db); @@ -300,7 +300,7 @@ if ($object->id > 0) } if ($object->type == $object::TYPE_CREDIT_NOTE) { - if ($mode == 'bank-transfer') { + if ($type == 'bank-transfer') { $facusing = new FactureFournisseur($db); } else { $facusing = new Facture($db); @@ -318,7 +318,7 @@ if ($object->id > 0) { if ($i == 0) print ' '; else print ','; - if ($mode == 'bank-transfer') { + if ($type == 'bank-transfer') { $facavoir = new FactureFournisseur($db); } else { $facavoir = new Facture($db); @@ -341,7 +341,7 @@ if ($object->id > 0) // Discounts print ''.$langs->trans('Discounts').''; - if ($mode == 'bank-transfer') { + if ($type == 'bank-transfer') { //$societe = new Fournisseur($db); //$result = $societe->fetch($object->socid); $thirdparty = $object->thirdparty; @@ -357,7 +357,7 @@ if ($object->id > 0) print ''; // Label - if ($mode == 'bank-transfer') { + if ($type == 'bank-transfer') { print ''; print ''.$form->editfieldkey("Label", 'label', $object->label, $object, 0).''; print ''.$form->editfieldval("Label", 'label', $object->label, $object, 0).''; @@ -427,7 +427,7 @@ if ($object->id > 0) if ($object->type != $object::TYPE_CREDIT_NOTE) { $duedate = $object->date_lim_reglement; - if ($mode == 'bank-transfer') { + if ($type == 'bank-transfer') { $duedate = $object->date_echeance; } @@ -488,7 +488,7 @@ if ($object->id > 0) print ''; $title = 'CustomerIBAN'; - if ($mode == 'bank-transfer') { + if ($type == 'bank-transfer') { $title = 'SupplierIBAN'; } print ''.$langs->trans($title).''; @@ -649,7 +649,7 @@ if ($object->id > 0) print "\n
    \n"; $buttonlabel = $langs->trans("MakeWithdrawRequest"); - if ($mode == 'bank-transfer') { + if ($type == 'bank-transfer') { $buttonlabel = $langs->trans("MakeBankTransferOrder"); } @@ -665,6 +665,7 @@ if ($object->id > 0) print ''; print ''; print ''; + print ''; print ''; print ''; print ''; @@ -694,7 +695,7 @@ if ($object->id > 0) print "

    \n"; - if ($mode == 'bank-transfer') { + if ($type == 'bank-transfer') { print '
    '.$langs->trans("DoCreditTransferBeforePayments").'

    '; } else { print '
    '.$langs->trans("DoStandingOrdersBeforePayments").'

    '; @@ -711,7 +712,7 @@ if ($object->id > 0) print ''.$langs->trans("DateRequest").''; print ''.$langs->trans("User").''; print ''.$langs->trans("Amount").''; - if ($mode == 'bank-transfer') { + if ($type == 'bank-transfer') { print ''.$langs->trans("BankTransferReceipt").''; } else { print ''.$langs->trans("WithdrawalReceipt").''; @@ -723,7 +724,7 @@ if ($object->id > 0) $sql = "SELECT pfd.rowid, pfd.traite, pfd.date_demande as date_demande,"; $sql .= " pfd.date_traite as date_traite, pfd.amount,"; - $sql .= " u.rowid as user_id, u.lastname, u.firstname, u.login"; + $sql .= " u.rowid as user_id, u.email, u.lastname, u.firstname, u.login, u.statut as user_status"; $sql .= " FROM ".MAIN_DB_PREFIX."prelevement_facture_demande as pfd"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."user as u on pfd.fk_user_demande = u.rowid"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."prelevement_bons as pb ON pb.rowid = pfd.fk_prelevement_bons"; @@ -743,14 +744,29 @@ if ($object->id > 0) { $i = 0; + $tmpuser = new User($db); + $num = $db->num_rows($result); while ($i < $num) { $obj = $db->fetch_object($result_sql); + $tmpuser->id = $obj->user_id; + $tmpuser->login = $obj->login; + $tmpuser->ref = $obj->login; + $tmpuser->email = $obj->email; + $tmpuser->lastname = $obj->lastname; + $tmpuser->firstname = $obj->firstname; + $tmpuser->statut = $obj->user_status; + print ''; + print ''.dol_print_date($db->jdate($obj->date_demande), 'dayhour')."\n"; - print ''.img_object($langs->trans("ShowUser"), 'user').' '.$obj->login.''; + + print ''; + print $tmpuser->getNomUrl(1, '', 0, 0, 0, 0, 'login'); + print ''; + print ''.price($obj->amount).''; print '-'; print ' '; @@ -758,7 +774,7 @@ if ($object->id > 0) print ''.$langs->trans("OrderWaiting").''; print ''; - print ''; + print ''; print img_delete(); print ''; @@ -778,7 +794,7 @@ if ($object->id > 0) $sql = "SELECT pfd.rowid, pfd.traite, pfd.date_demande, pfd.date_traite, pfd.fk_prelevement_bons, pfd.amount,"; $sql .= " pb.ref,"; - $sql .= " u.rowid as user_id, u.lastname, u.firstname, u.login"; + $sql .= " u.rowid as user_id, u.email, u.lastname, u.firstname, u.login, u.statut as user_status"; $sql .= " FROM ".MAIN_DB_PREFIX."prelevement_facture_demande as pfd"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."user as u on pfd.fk_user_demande = u.rowid"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."prelevement_bons as pb ON pb.rowid = pfd.fk_prelevement_bons"; @@ -798,15 +814,27 @@ if ($object->id > 0) $numclosed = $num; $i = 0; + $tmpuser = new User($db); + while ($i < $num) { $obj = $db->fetch_object($result); + $tmpuser->id = $obj->user_id; + $tmpuser->login = $obj->login; + $tmpuser->ref = $obj->login; + $tmpuser->email = $obj->email; + $tmpuser->lastname = $obj->lastname; + $tmpuser->firstname = $obj->firstname; + $tmpuser->statut = $obj->user_status; + print ''; print ''.dol_print_date($db->jdate($obj->date_demande), 'day')."\n"; - print ''.img_object($langs->trans("ShowUser"), 'user').' '.$obj->login.''; + print ''; + print $tmpuser->getNomUrl(1, '', 0, 0, 0, 0, 'login'); + print ''; print ''.price($obj->amount).''; diff --git a/htdocs/compta/paymentbybanktransfer/index.php b/htdocs/compta/paymentbybanktransfer/index.php index 6172b3f1284..792507c56fd 100644 --- a/htdocs/compta/paymentbybanktransfer/index.php +++ b/htdocs/compta/paymentbybanktransfer/index.php @@ -94,11 +94,11 @@ print '

    '; */ $sql = "SELECT f.ref, f.rowid, f.total_ttc, f.fk_statut, f.paye, f.type,"; $sql .= " pfd.date_demande, pfd.amount,"; -$sql .= " s.nom as name, s.rowid as socid"; -$sql .= " FROM ".MAIN_DB_PREFIX."facture as f,"; +$sql .= " s.nom as name, s.email, s.rowid as socid"; +$sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn as f,"; $sql .= " ".MAIN_DB_PREFIX."societe as s"; if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; -$sql .= " , ".MAIN_DB_PREFIX."prelevement_facture_demande as pfd"; +$sql .= ", ".MAIN_DB_PREFIX."prelevement_facture_demande as pfd"; $sql .= " WHERE s.rowid = f.fk_soc"; $sql .= " AND f.entity IN (".getEntity('supplier_invoice').")"; $sql .= " AND f.total_ttc > 0"; @@ -133,14 +133,15 @@ if ($resql) $invoicestatic->type = $obj->type; $alreadypayed = $invoicestatic->getSommePaiement(); + $thirdpartystatic->id = $obj->socid; + $thirdpartystatic->name = $obj->name; + $thirdpartystatic->email = $obj->email; print ''; print $invoicestatic->getNomUrl(1, 'withdraw'); print ''; print ''; - $thirdpartystatic->id = $obj->socid; - $thirdpartystatic->name = $obj->name; print $thirdpartystatic->getNomUrl(1, 'customer'); print ''; diff --git a/htdocs/compta/prelevement/class/bonprelevement.class.php b/htdocs/compta/prelevement/class/bonprelevement.class.php index 1a13eb2edb9..193d352ae35 100644 --- a/htdocs/compta/prelevement/class/bonprelevement.class.php +++ b/htdocs/compta/prelevement/class/bonprelevement.class.php @@ -703,9 +703,16 @@ class BonPrelevement extends CommonObject $sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn as f,"; } $sql .= " ".MAIN_DB_PREFIX."prelevement_facture_demande as pfd"; - $sql .= " WHERE f.fk_statut = 1"; - $sql .= " AND f.entity IN (".getEntity('invoice').")"; - $sql .= " AND f.rowid = pfd.fk_facture"; + $sql .= " WHERE f.entity IN (".getEntity('invoice').")"; + if (empty($conf->global->WITHDRAWAL_ALLOW_ANY_INVOICE_STATUS)) + { + $sql .= " AND f.fk_statut = ".Facture::STATUS_VALIDATED; + } + if ($mode != 'bank-transfer') { + $sql .= " AND f.rowid = pfd.fk_facture"; + } else { + $sql .= " AND f.rowid = pfd.fk_facture_fourn"; + } $sql .= " AND f.paye = 0"; $sql .= " AND pfd.traite = 0"; $sql .= " AND f.total_ttc > 0"; @@ -744,16 +751,16 @@ class BonPrelevement extends CommonObject /** * Get number of invoices to withdrawal * - * @param string $mode 'direct-debit' or 'bank-transfer' + * @param string $type 'direct-debit' or 'bank-transfer' * @return int '; print ''; - print ''.$langs->trans("Invoice").''; + print ''.$langs->trans($tradinvoice).''; print ''.$langs->trans("ThirdParty").''; print ''.$langs->trans("RIB").''; print ''.$langs->trans("RUM").''; diff --git a/htdocs/compta/prelevement/index.php b/htdocs/compta/prelevement/index.php index eaec6d92f16..72c318a1024 100644 --- a/htdocs/compta/prelevement/index.php +++ b/htdocs/compta/prelevement/index.php @@ -94,7 +94,7 @@ print '

    '; */ $sql = "SELECT f.ref, f.rowid, f.total_ttc, f.fk_statut, f.paye, f.type,"; $sql .= " pfd.date_demande, pfd.amount,"; -$sql .= " s.nom as name, s.rowid as socid"; +$sql .= " s.nom as name, s.email, s.rowid as socid"; $sql .= " FROM ".MAIN_DB_PREFIX."facture as f,"; $sql .= " ".MAIN_DB_PREFIX."societe as s"; if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; @@ -133,14 +133,15 @@ if ($resql) $invoicestatic->type = $obj->type; $alreadypayed = $invoicestatic->getSommePaiement(); + $thirdpartystatic->id = $obj->socid; + $thirdpartystatic->name = $obj->name; + $thirdpartystatic->email = $obj->email; print ''; print $invoicestatic->getNomUrl(1, 'withdraw'); print ''; print ''; - $thirdpartystatic->id = $obj->socid; - $thirdpartystatic->name = $obj->name; print $thirdpartystatic->getNomUrl(1, 'customer'); print ''; diff --git a/htdocs/core/lib/fourn.lib.php b/htdocs/core/lib/fourn.lib.php index 8d0e767c943..201d74a9ff9 100644 --- a/htdocs/core/lib/fourn.lib.php +++ b/htdocs/core/lib/fourn.lib.php @@ -68,7 +68,7 @@ function facturefourn_prepare_head($object) if ($obj) $nbStandingOrders = $obj->nb; } else dol_print_error($db); - $head[$h][0] = DOL_URL_ROOT.'/compta/facture/prelevement.php?facid='.$object->id.'&mode=bank-transfer'; + $head[$h][0] = DOL_URL_ROOT.'/compta/facture/prelevement.php?facid='.$object->id.'&type=bank-transfer'; $head[$h][1] = $langs->trans('BankTransfer'); if ($nbStandingOrders > 0) $head[$h][1] .= ''.$nbStandingOrders.''; $head[$h][2] = 'standingorders'; @@ -233,8 +233,6 @@ function supplierorder_admin_prepare_head() $head[$h][2] = 'supplierorderdet'; $h++; - - $head[$h][0] = DOL_URL_ROOT.'/admin/supplierinvoice_extrafields.php'; $head[$h][1] = $langs->trans("ExtraFieldsSupplierInvoices"); $head[$h][2] = 'supplierinvoice'; From 5e259d26ab3cbe4b0eebfa010107f695dc93d466 Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Wed, 1 Jul 2020 15:20:42 +0200 Subject: [PATCH 29/83] FIX takepos hook can add more than 1 button within 1 module --- htdocs/takepos/index.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/htdocs/takepos/index.php b/htdocs/takepos/index.php index 63bbc5d1808..51358e24080 100644 --- a/htdocs/takepos/index.php +++ b/htdocs/takepos/index.php @@ -932,8 +932,14 @@ if ($resql) $hookmanager->initHooks(array('takeposfrontend')); $reshook = $hookmanager->executeHooks('ActionButtons'); if (!empty($reshook)) { +if (is_array($reshook) && !isset($reshook['title'])) { + foreach ($reshook as $reshook) { +$menus[$r++] = $reshook; + } +} else { $menus[$r++] = $reshook; } +} if ($r % 3 == 2) $menus[$r++] = array('title'=>'', 'style'=>'visibility: hidden;'); From 92f4744d11c49d2ec6a5dede2c75920a54f9a0fa Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Wed, 1 Jul 2020 13:22:43 +0000 Subject: [PATCH 30/83] Fixing style errors. --- htdocs/takepos/index.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/htdocs/takepos/index.php b/htdocs/takepos/index.php index 51358e24080..af9c3062ba3 100644 --- a/htdocs/takepos/index.php +++ b/htdocs/takepos/index.php @@ -932,13 +932,13 @@ if ($resql) $hookmanager->initHooks(array('takeposfrontend')); $reshook = $hookmanager->executeHooks('ActionButtons'); if (!empty($reshook)) { -if (is_array($reshook) && !isset($reshook['title'])) { - foreach ($reshook as $reshook) { -$menus[$r++] = $reshook; - } -} else { - $menus[$r++] = $reshook; -} + if (is_array($reshook) && !isset($reshook['title'])) { + foreach ($reshook as $reshook) { + $menus[$r++] = $reshook; + } + } else { + $menus[$r++] = $reshook; + } } if ($r % 3 == 2) $menus[$r++] = array('title'=>'', 'style'=>'visibility: hidden;'); From cc132775f3a896a63e0746bf3a4c966b79a048aa Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Wed, 1 Jul 2020 16:18:19 +0200 Subject: [PATCH 31/83] FIX non numeric value on comm/car.php --- htdocs/comm/card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/comm/card.php b/htdocs/comm/card.php index 4a97dc0f98c..9b385ea7ead 100644 --- a/htdocs/comm/card.php +++ b/htdocs/comm/card.php @@ -943,7 +943,7 @@ if ($object->id > 0) $late = ''; foreach ($contrat->lines as $line) { if ($contrat->statut == Contrat::STATUS_VALIDATED && $line->statut == ContratLigne::STATUS_OPEN) { - if (($line->date_fin_validite + $conf->contrat->services->expires->warning_delay) < $now) $late = img_warning($langs->trans("Late")); + if (((!empty($line->date_fin_validite)?$line->date_fin_validite:0) + $conf->contrat->services->expires->warning_delay) < $now) $late = img_warning($langs->trans("Late")); } } From 2a9311b2d8393071d5b17b6eb32650b0b90451e0 Mon Sep 17 00:00:00 2001 From: John Botella Date: Wed, 1 Jul 2020 16:55:23 +0200 Subject: [PATCH 32/83] Fix email spoofing - with hidden conf --- htdocs/core/class/CMailFile.class.php | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/htdocs/core/class/CMailFile.class.php b/htdocs/core/class/CMailFile.class.php index 853f2f98b05..e31053d1bf7 100644 --- a/htdocs/core/class/CMailFile.class.php +++ b/htdocs/core/class/CMailFile.class.php @@ -396,7 +396,23 @@ class CMailFile //$this->message->setFrom(array('john@doe.com' => 'John Doe')); if (! empty($from)) { try { - $result = $this->message->setFrom($this->getArrayAddress($from)); + + // Prevent email spoofing for smtp server with a strict configuration + $regexp = '/([a-z0-9_\.\-\+])+\@(([a-z0-9\-])+\.)+([a-z0-9]{2,4})+/i'; // This regular expression extracts all emails from a string + $emailMatchs = preg_match_all($regexp, $from, $adressEmailFrom); + $adressEmailFrom = reset($adressEmailFrom); + if($emailMatchs !== false + && $conf->global->MAIN_FORCE_DISABLE_MAIL_SPOOFING + && filter_var($conf->global->MAIN_MAIL_SMTPS_ID, FILTER_VALIDATE_EMAIL) + && $conf->global->MAIN_MAIL_SMTPS_ID !== $adressEmailFrom) + { + $result = $this->message->setFrom($conf->global->MAIN_MAIL_SMTPS_ID); + } + else + { + $result = $this->message->setFrom($this->getArrayAddress($from)); + } + } catch (Exception $e) { $this->errors[] = $e->getMessage(); } From 92a36dbeee93b6387bd32394b83e10e08f22e5df Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 1 Jul 2020 17:00:52 +0200 Subject: [PATCH 33/83] FIX Use of office365 TLS with SMTPs method. --- htdocs/core/class/smtps.class.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/htdocs/core/class/smtps.class.php b/htdocs/core/class/smtps.class.php index 51e375c5279..09a1f7f2949 100644 --- a/htdocs/core/class/smtps.class.php +++ b/htdocs/core/class/smtps.class.php @@ -428,7 +428,7 @@ class SMTPs $host = preg_replace('@ssl://@i', '', $host); // Remove prefix $host = preg_replace('@tls://@i', '', $host); // Remove prefix - if ($usetls) $host = 'tls://'.$host; + if ($usetls && ! empty($conf->global->MAIN_SMTPS_ADD_TLS_TO_HOST_FOR_HELO)) $host = 'tls://'.$host; $hosth = $host; @@ -565,6 +565,8 @@ class SMTPs $host = preg_replace('@ssl://@i', '', $host); // Remove prefix $host = preg_replace('@tls://@i', '', $host); // Remove prefix + if ($usetls && ! empty($conf->global->MAIN_SMTPS_ADD_TLS_TO_HOST_FOR_HELO)) $host = 'tls://'.$host; + $hosth = $host; if (!empty($conf->global->MAIL_SMTP_USE_FROM_FOR_HELO)) From 324c8e9b54930f2a0fc95e0cc8659a59f5fe2620 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 1 Jul 2020 17:00:52 +0200 Subject: [PATCH 34/83] FIX Use of office365 TLS with SMTPs method. Conflicts: htdocs/core/class/smtps.class.php --- htdocs/core/class/smtps.class.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/htdocs/core/class/smtps.class.php b/htdocs/core/class/smtps.class.php index df7647b330c..9c071a36f23 100644 --- a/htdocs/core/class/smtps.class.php +++ b/htdocs/core/class/smtps.class.php @@ -428,7 +428,7 @@ class SMTPs $host=preg_replace('@ssl://@i', '', $host); // Remove prefix $host=preg_replace('@tls://@i', '', $host); // Remove prefix - if ($usetls) $host='tls://'.$host; + if ($usetls && ! empty($conf->global->MAIN_SMTPS_ADD_TLS_TO_HOST_FOR_HELO)) $host = 'tls://'.$host; $hosth = $host; @@ -568,6 +568,8 @@ class SMTPs $host=preg_replace('@ssl://@i', '', $host); // Remove prefix $host=preg_replace('@tls://@i', '', $host); // Remove prefix + if ($usetls && ! empty($conf->global->MAIN_SMTPS_ADD_TLS_TO_HOST_FOR_HELO)) $host = 'tls://'.$host; + $hosth = $host; if (! empty($conf->global->MAIL_SMTP_USE_FROM_FOR_HELO)) From d3c23428d5cf773172ebeb573c234c1f10a12cc1 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 1 Jul 2020 17:00:52 +0200 Subject: [PATCH 35/83] FIX Use of office365 TLS with SMTPs method. Conflicts: htdocs/core/class/smtps.class.php --- htdocs/core/class/smtps.class.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/htdocs/core/class/smtps.class.php b/htdocs/core/class/smtps.class.php index f978fd47fba..bce175b3872 100644 --- a/htdocs/core/class/smtps.class.php +++ b/htdocs/core/class/smtps.class.php @@ -428,7 +428,7 @@ class SMTPs $host=preg_replace('@ssl://@i', '', $host); // Remove prefix $host=preg_replace('@tls://@i', '', $host); // Remove prefix - if ($usetls) $host='tls://'.$host; + if ($usetls && ! empty($conf->global->MAIN_SMTPS_ADD_TLS_TO_HOST_FOR_HELO)) $host = 'tls://'.$host; $hosth = $host; @@ -555,6 +555,8 @@ class SMTPs $host=preg_replace('@ssl://@i', '', $host); // Remove prefix $host=preg_replace('@tls://@i', '', $host); // Remove prefix + if ($usetls && ! empty($conf->global->MAIN_SMTPS_ADD_TLS_TO_HOST_FOR_HELO)) $host = 'tls://'.$host; + $hosth = $host; if (! empty($conf->global->MAIL_SMTP_USE_FROM_FOR_HELO)) From ae0c73898098ab949fb1a9eb80358fcfb941f07c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 1 Jul 2020 19:42:28 +0200 Subject: [PATCH 36/83] FIX Entry from stripe intent were reported into SEPA payments FIX Label of popup on thirdparty FIX Missing the tooltip when creating bank account --- htdocs/compta/paymentbybanktransfer/index.php | 9 +- .../class/bonprelevement.class.php | 156 +++++++++++------- htdocs/compta/prelevement/create.php | 20 ++- htdocs/compta/prelevement/index.php | 14 +- htdocs/societe/class/societe.class.php | 20 +-- htdocs/societe/paymentmodes.php | 17 +- 6 files changed, 155 insertions(+), 81 deletions(-) diff --git a/htdocs/compta/paymentbybanktransfer/index.php b/htdocs/compta/paymentbybanktransfer/index.php index 792507c56fd..1fc6c53cf99 100644 --- a/htdocs/compta/paymentbybanktransfer/index.php +++ b/htdocs/compta/paymentbybanktransfer/index.php @@ -106,7 +106,9 @@ if (empty($conf->global->WITHDRAWAL_ALLOW_ANY_INVOICE_STATUS)) { $sql .= " AND f.fk_statut = ".FactureFournisseur::STATUS_VALIDATED; } -$sql .= " AND pfd.traite = 0 AND pfd.fk_facture_fourn = f.rowid"; +$sql .= " AND pfd.traite = 0"; +$sql .= " AND pfd.ext_payment_id IS NULL"; +$sql .= " AND pfd.fk_facture_fourn = f.rowid"; if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; if ($socid) $sql .= " AND f.fk_soc = ".$socid; @@ -195,7 +197,8 @@ if ($result) print"\n\n"; print '
    '; print ''; - print ''; + print ''; + print ''; print ''; print ''; print ''; @@ -222,7 +225,7 @@ if ($result) $i++; } } else { - print ''; + print ''; } print "
    '.$langs->trans("LatestBankTransferReceipts", $limit).'
    '.$langs->trans("LatestBankTransferReceipts", $limit).''.$langs->trans("Date").''.$langs->trans("Amount").''.$langs->trans("Status").'
    '.$langs->trans("None").'
    '.$langs->trans("None").'

    "; diff --git a/htdocs/compta/prelevement/class/bonprelevement.class.php b/htdocs/compta/prelevement/class/bonprelevement.class.php index 193d352ae35..5db9ccde671 100644 --- a/htdocs/compta/prelevement/class/bonprelevement.class.php +++ b/htdocs/compta/prelevement/class/bonprelevement.class.php @@ -28,6 +28,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; +require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php'; @@ -118,7 +119,7 @@ class BonPrelevement extends CommonObject /** * Add invoice to withdrawal * - * @param int $facture_id id invoice to add + * @param int $invoice_id id invoice to add * @param int $client_id id invoice customer * @param string $client_nom customer name * @param int $amount amount of invoice @@ -126,14 +127,16 @@ class BonPrelevement extends CommonObject * @param string $code_guichet code of bank's office * @param string $number bank account number * @param string $number_key number key of account number + * @param string $type 'debit-order' or 'bank-transfer' * @return int >0 if OK, <0 if KO */ - public function AddFacture($facture_id, $client_id, $client_nom, $amount, $code_banque, $code_guichet, $number, $number_key) + public function AddFacture($invoice_id, $client_id, $client_nom, $amount, $code_banque, $code_guichet, $number, $number_key, $type = 'debit-order') { // phpcs:enable $result = 0; $line_id = 0; + // Add lines $result = $this->addline($line_id, $client_id, $client_nom, $amount, $code_banque, $code_guichet, $number, $number_key); if ($result == 0) @@ -141,10 +144,14 @@ class BonPrelevement extends CommonObject if ($line_id > 0) { $sql = "INSERT INTO ".MAIN_DB_PREFIX."prelevement_facture ("; - $sql .= "fk_facture"; + if ($type != 'bank-transfer') { + $sql .= "fk_facture"; + } else { + $sql .= "fk_facture_fourn"; + } $sql .= ",fk_prelevement_lignes"; $sql .= ") VALUES ("; - $sql .= $facture_id; + $sql .= $invoice_id; $sql .= ", ".$line_id; $sql .= ")"; @@ -155,19 +162,19 @@ class BonPrelevement extends CommonObject else { $result = -1; - dol_syslog(get_class($this)."::AddFacture Erreur $result"); + dol_syslog(get_class($this)."::AddFacture Error $result"); } } else { $result = -2; - dol_syslog(get_class($this)."::AddFacture Erreur $result"); + dol_syslog(get_class($this)."::AddFacture Error $result"); } } else { $result = -3; - dol_syslog(get_class($this)."::AddFacture Erreur $result"); + dol_syslog(get_class($this)."::AddFacture Error $result"); } return $result; @@ -686,7 +693,7 @@ class BonPrelevement extends CommonObject // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** - * Returns amount of withdrawal + * Returns amount waiting for direct debit payment or credit transfer payment * * @param string $mode 'direct-debit' or 'bank-transfer' * @return double db->query($sql); @@ -749,7 +757,7 @@ class BonPrelevement extends CommonObject // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** - * Get number of invoices to withdrawal + * Get number of invoices to pay * * @param string $type 'direct-debit' or 'bank-transfer' * @return int global->PRELEVEMENT_CODE_BANQUE."'"; //if ($agence) $sql.= " AND sr.code_guichet = '".$conf->global->PRELEVEMENT_CODE_GUICHET."'"; @@ -874,6 +893,12 @@ class BonPrelevement extends CommonObject { $row = $this->db->fetch_row($resql); $factures[$i] = $row; // All fields + if ($row[7] == 0) { + $error++; + dol_syslog(__METHOD__."::Read invoices error Found a null invoice", LOG_ERR); + $this->invoice_in_error[$row[0]] = "Error for invoice id ".$row[0].", found a null amount"; + break; + } $i++; } $this->db->free($resql); @@ -891,15 +916,19 @@ class BonPrelevement extends CommonObject require_once DOL_DOCUMENT_ROOT.'/societe/class/companybankaccount.class.php'; $soc = new Societe($this->db); - // Check RIB + // Check BAN $i = 0; - dol_syslog(__METHOD__."::Check RIB", LOG_DEBUG); + dol_syslog(__METHOD__."::Check BAN", LOG_DEBUG); if (count($factures) > 0) { foreach ($factures as $key => $fac) { - $fact = new Facture($this->db); + if ($type != 'bank-transfer') { + $fact = new Facture($this->db); + } else { + $fact = new FactureFournisseur($this->db); + } $resfetch = $fact->fetch($fac[0]); if ($resfetch >= 0) // Field 0 of $fac is rowid of invoice { @@ -908,13 +937,15 @@ class BonPrelevement extends CommonObject $bac = new CompanyBankAccount($this->db); $bac->fetch(0, $soc->id); - if ($format == 'FRST' && $bac->frstrecur != 'FRST') - { - continue; - } - if ($format == 'RCUR' && ($bac->frstrecur != 'RCUR' && $bac->frstrecur != 'RECUR')) - { - continue; + if ($type != 'bank-transfer') { + if ($format == 'FRST' && $bac->frstrecur != 'FRST') + { + continue; + } + if ($format == 'RCUR' && ($bac->frstrecur != 'RCUR' && $bac->frstrecur != 'RECUR')) + { + continue; + } } if ($bac->verif() >= 1) @@ -927,32 +958,32 @@ class BonPrelevement extends CommonObject } else { - dol_syslog(__METHOD__."::Check RIB Error on default bank number IBAN/BIC for thirdparty reported by verif() ".$fact->socid." ".$soc->name, LOG_WARNING); + dol_syslog(__METHOD__."::Check BAN Error on default bank number IBAN/BIC for thirdparty reported by verif() ".$fact->socid." ".$soc->name, LOG_WARNING); $this->invoice_in_error[$fac[0]] = "Error on default bank number IBAN/BIC for invoice ".$fact->getNomUrl(0)." for thirdparty ".$soc->getNomUrl(0); $this->thirdparty_in_error[$soc->id] = "Error on default bank number IBAN/BIC for invoice ".$fact->getNomUrl(0)." for thirdparty ".$soc->getNomUrl(0); } } else { - dol_syslog(__METHOD__."::Check RIB Failed to read company", LOG_WARNING); + dol_syslog(__METHOD__."::Check BAN Failed to read company", LOG_WARNING); } } else { - dol_syslog(__METHOD__."::Check RIB Failed to read invoice", LOG_WARNING); + dol_syslog(__METHOD__."::Check BAN Failed to read invoice", LOG_WARNING); } } } else { - dol_syslog(__METHOD__."::Check RIB No invoice to process", LOG_WARNING); + dol_syslog(__METHOD__."::Check BAN No invoice to process", LOG_WARNING); } } $ok = 0; // Withdraw invoices in factures_prev array - $out = count($factures_prev)." invoices will be withdrawn."; + $out = count($factures_prev)." invoices will be included."; //print $out."\n"; dol_syslog($out); @@ -982,14 +1013,14 @@ class BonPrelevement extends CommonObject { /* * We are in real mode. - * We create withdraw receipt and build withdraw into disk + * We create order and build file into disk */ $this->db->begin(); $now = dol_now(); /* - * Traitements + * Process order generation */ if (!$error) { @@ -1001,7 +1032,7 @@ class BonPrelevement extends CommonObject $sql .= " AND entity = ".$conf->entity; $sql .= " ORDER BY ref DESC LIMIT 1"; - dol_syslog(get_class($this)."::Create sql=".$sql, LOG_DEBUG); + dol_syslog(get_class($this)."::create sql=".$sql, LOG_DEBUG); $resql = $this->db->query($sql); if ($resql) @@ -1009,18 +1040,23 @@ class BonPrelevement extends CommonObject $row = $this->db->fetch_row($resql); $ref = "T".$ref.str_pad(dol_substr("00".intval($row[0]) + 1, 0, 2), 2, "0", STR_PAD_LEFT); - $dir = $conf->prelevement->dir_output.'/receipts'; + if ($type != 'bank-transfer') { + $dir = $conf->prelevement->dir_output.'/receipts'; + } else { + $dir = $conf->paymentbybanktransfer->dir_output.'/receipts'; + } if (!is_dir($dir)) dol_mkdir($dir); $this->filename = $dir.'/'.$ref.'.xml'; // Create withdraw receipt in database $sql = "INSERT INTO ".MAIN_DB_PREFIX."prelevement_bons ("; - $sql .= " ref, entity, datec"; + $sql .= " ref, entity, datec, type"; $sql .= ") VALUES ("; $sql .= "'".$this->db->escape($ref)."'"; $sql .= ", ".$conf->entity; $sql .= ", '".$this->db->idate($now)."'"; + $sql .= ", '".($type == 'bank-transfer' ? 'bank-transfer' : 'debit-order')."'"; $sql .= ")"; $resql = $this->db->query($sql); @@ -1058,7 +1094,9 @@ class BonPrelevement extends CommonObject /* * Add standing order * - * + * $fac[0] : invoice_id + * $fac[1] : ??? + * $fac[2] : third party id * $fac[3] : banque * $fac[4] : guichet * $fac[5] : number @@ -1067,7 +1105,8 @@ class BonPrelevement extends CommonObject * $fac[8] : client nom * $fac[2] : client id */ - $ri = $this->AddFacture($fac[0], $fac[2], $fac[8], $fac[7], $fac[3], $fac[4], $fac[5], $fac[6]); + + $ri = $this->AddFacture($fac[0], $fac[2], $fac[8], $fac[7], $fac[3], $fac[4], $fac[5], $fac[6], $type); if ($ri <> 0) { $error++; @@ -1080,13 +1119,12 @@ class BonPrelevement extends CommonObject $sql .= ", fk_prelevement_bons = ".$this->id; $sql .= " WHERE rowid = ".$fac[1]; - dol_syslog(__METHOD__."::Update Orders::Sql=".$sql, LOG_DEBUG); $resql = $this->db->query($sql); if (!$resql) { $error++; - dol_syslog(__METHOD__."::Update Orders::Error=".$this->db->error(), LOG_ERR); + dol_syslog(__METHOD__."::Update Error=".$this->db->error(), LOG_ERR); } } } @@ -1095,11 +1133,10 @@ class BonPrelevement extends CommonObject if (!$error) { /* - * Create direct debit order in a XML file + * Create file of direct debit order or credit transfer into a XML file */ - dol_syslog(__METHOD__."::Init withdraw receipt for ".count($factures_prev)." invoices", LOG_DEBUG); - + dol_syslog(__METHOD__."::Init direct debit file for ".count($factures_prev)." invoices", LOG_DEBUG); if (count($factures_prev) > 0) { @@ -1126,7 +1163,7 @@ class BonPrelevement extends CommonObject $this->context['factures_prev'] = $factures_prev; // Generation of SEPA file $this->filename - $this->generate($format, $executiondate); + $result = $this->generate($format, $executiondate); } dol_syslog(__METHOD__."::End withdraw receipt, file ".$this->filename, LOG_DEBUG); } @@ -1149,8 +1186,13 @@ class BonPrelevement extends CommonObject if (!$error && !$notrigger) { + $triggername = 'DIRECT_DEBIT_ORDER_CREATE'; + if ($type != 'bank-transfer') { + $triggername = 'CREDIT_TRANSFER_ORDER_CREATE'; + } + // Call trigger - $result = $this->call_trigger('DIRECT_DEBIT_ORDER_CREATE', $user); + $result = $this->call_trigger($triggername, $user); if ($result < 0) $error++; // End call triggers } @@ -1419,9 +1461,9 @@ class BonPrelevement extends CommonObject * - Others countries: Warning message * File is generated with name this->filename * - * @param string $format FRST, RCUR or ALL - * @param string $executiondate Date to execute transfer - * @return int 0 if OK, <0 if KO + * @param string $format FRST, RCUR or ALL + * @param string $executiondate Date to execute transfer + * @return int >=0 if OK, <0 if KO */ public function generate($format = 'ALL', $executiondate = '') { @@ -1468,7 +1510,7 @@ class BonPrelevement extends CommonObject $this->total = 0; /* - * section Debiteur (sepa Debiteurs bloc lines) + * Section Debitor (sepa Debiteurs bloc lines) */ $sql = "SELECT soc.code_client as code, soc.address, soc.zip, soc.town, c.code as country_code,"; @@ -1593,13 +1635,15 @@ class BonPrelevement extends CommonObject $langs->load('withdrawals'); // TODO Add here code to generate a generic file - fputs($this->file, $langs->trans('WithdrawalFileNotCapable', $mysoc->country_code)); + fputs($this->file, $langs->transnoentitiesnoconv('WithdrawalFileNotCapable', $mysoc->country_code)); } fclose($this->file); - if (!empty($conf->global->MAIN_UMASK)) + if (!empty($conf->global->MAIN_UMASK)) { @chmod($this->file, octdec($conf->global->MAIN_UMASK)); - return $result; + } + + return $result; } diff --git a/htdocs/compta/prelevement/create.php b/htdocs/compta/prelevement/create.php index f05e4f422d4..a6bc41734d4 100644 --- a/htdocs/compta/prelevement/create.php +++ b/htdocs/compta/prelevement/create.php @@ -5,7 +5,7 @@ * Copyright (C) 2010-2012 Juanjo Menent * Copyright (C) 2018 Nicolas ZABOURI * Copyright (C) 2018 Frédéric France - * Copyright (C) 2019 Markus Welters + * Copyright (C) 2019 Markus Welters * * 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 @@ -24,7 +24,7 @@ /** * \file htdocs/compta/prelevement/create.php * \ingroup prelevement - * \brief Prelevement creation page + * \brief Page to create a direct debit order or a credit transfer order */ require '../../main.inc.php'; @@ -77,11 +77,17 @@ if (empty($reshook)) } if ($action == 'create') { - // $conf->global->PRELEVEMENT_CODE_BANQUE and $conf->global->PRELEVEMENT_CODE_GUICHET should be empty + $delayindays = 0; + if ($type != 'bank-transfer') { + $conf->global->PRELEVEMENT_ADDDAYS; + } else { + $conf->global->PAYMENTBYBANKTRANSFER_ADDDAYS; + } $bprev = new BonPrelevement($db); - $executiondate = dol_mktime(0, 0, 0, GETPOST('remonth'), (GETPOST('reday') + $conf->global->PRELEVEMENT_ADDDAYS), GETPOST('reyear')); + $executiondate = dol_mktime(0, 0, 0, GETPOST('remonth', 'int'), (GETPOST('reday', 'int') + $delayindays), GETPOST('reyear', 'int')); - $result = $bprev->create($conf->global->PRELEVEMENT_CODE_BANQUE, $conf->global->PRELEVEMENT_CODE_GUICHET, $mode, $format, $executiondate); + // $conf->global->PRELEVEMENT_CODE_BANQUE and $conf->global->PRELEVEMENT_CODE_GUICHET should be empty (we don't use them anymore) + $result = $bprev->create($conf->global->PRELEVEMENT_CODE_BANQUE, $conf->global->PRELEVEMENT_CODE_GUICHET, $mode, $format, $executiondate, 0, $type); if ($result < 0) { setEventMessages($bprev->error, $bprev->errors, 'errors'); @@ -257,8 +263,10 @@ if (empty($conf->global->WITHDRAWAL_ALLOW_ANY_INVOICE_STATUS)) { $sql .= " AND f.fk_statut = ".Facture::STATUS_VALIDATED; } -$sql .= " AND f.total_ttc > 0"; +//$sql .= " AND pfd.amount > 0"; +$sql .= " AND f.total_ttc > 0"; // Avoid credit notes $sql .= " AND pfd.traite = 0"; +$sql .= " AND pfd.ext_payment_id IS NULL"; if ($type == 'bank-transfer') { $sql .= " AND pfd.fk_facture_fourn = f.rowid"; } else { diff --git a/htdocs/compta/prelevement/index.php b/htdocs/compta/prelevement/index.php index 72c318a1024..ef451146f55 100644 --- a/htdocs/compta/prelevement/index.php +++ b/htdocs/compta/prelevement/index.php @@ -22,7 +22,7 @@ /** * \file htdocs/compta/prelevement/index.php * \ingroup prelevement - * \brief Prelevement index page + * \brief Home page for direct debit orders */ @@ -106,7 +106,9 @@ if (empty($conf->global->WITHDRAWAL_ALLOW_ANY_INVOICE_STATUS)) { $sql .= " AND f.fk_statut = ".Facture::STATUS_VALIDATED; } -$sql .= " AND pfd.traite = 0 AND pfd.fk_facture = f.rowid"; +$sql .= " AND pfd.traite = 0"; +$sql .= " AND pfd.ext_payment_id IS NULL"; +$sql .= " AND pfd.fk_facture = f.rowid"; if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; if ($socid) $sql .= " AND f.fk_soc = ".$socid; @@ -176,8 +178,9 @@ print '
    '; /* - * Withdraw receipts + * Direct debit orders */ + $limit = 5; $sql = "SELECT p.rowid, p.ref, p.amount, p.datec, p.statut"; $sql .= " FROM ".MAIN_DB_PREFIX."prelevement_bons as p"; @@ -194,7 +197,8 @@ if ($result) print"\n\n"; print '
    '; print ''; - print ''; + print ''; + print ''; print ''; print ''; print ''; @@ -222,7 +226,7 @@ if ($result) $i++; } } else { - print ''; + print ''; } print "
    '.$langs->trans("LastWithdrawalReceipt", $limit).'
    '.$langs->trans("LastWithdrawalReceipt", $limit).''.$langs->trans("Date").''.$langs->trans("Amount").''.$langs->trans("Status").'
    '.$langs->trans("None").'
    '.$langs->trans("None").'

    "; diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index e80d433e7e0..730e66eaab8 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -2388,44 +2388,44 @@ class Societe extends CommonObject $label .= '
    '; - if ($option == 'customer' || $option == 'compta' || $option == 'category' || $option == 'category_supplier') + if ($option == 'customer' || $option == 'compta' || $option == 'category') { - $label .= ''.$langs->trans("ShowCustomer").''; + $label .= ''.$langs->trans("Customer").''; $linkstart = ''; + $label .= ''.$langs->trans("Prospect").''; $linkstart = ''; + $label .= ''.$langs->trans("Supplier").''; $linkstart = ''; + $label .= ''.$langs->trans("ThirdParty").''; $linkstart = ''; + $label .= ''.$langs->trans("ThirdParty").''; $linkstart = ''; + $label .= ''.$langs->trans("ThirdParty").''; $linkstart = ''; + $label .= ''.$langs->trans("ThirdParty").''; $linkstart = ''; + $label .= ''.$langs->trans("ThirdParty").''; $linkstart = 'LT12 1000 0111 0100 1000
    FR14 2004 1010 0505 0001 3M02 606
    LU28 0019 4006 4475 0000
    DE89 3704 0044 0532 0130 00'; } elseif ($val == 'BIC') { $name = 'bic'; $size = 12; + $content = $companybankaccount->bic; if ($companybankaccount->needIBAN()) $require = true; + $tooltip = $langs->trans("Example").': LIABLT2XXXX'; } - print ''.$langs->trans($val).''; + print ''; + if ($tooltip) { + print $form->textwithpicto($langs->trans($val), $tooltip, 4, 'help', '', 0, 3, $name); + } else { + print $langs->trans($val); + } + print ''; print ''; print ''; } From 22448b19f4868e14af7017edbff6320a1c1b9452 Mon Sep 17 00:00:00 2001 From: ksar <35605507+ksar-ksar@users.noreply.github.com> Date: Wed, 1 Jul 2020 22:19:10 +0200 Subject: [PATCH 37/83] FIX : Correct ModuleBuilder left menu --- 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 bbc4e08df23..7f544a7e7d5 100644 --- a/htdocs/modulebuilder/index.php +++ b/htdocs/modulebuilder/index.php @@ -2848,7 +2848,7 @@ elseif (!empty($module)) print ''; print ''; - print $menu['left']; + print $menu['leftmenu']; print ''; print ''; From 76f3724191ac2f4b42e7b7136a28593df3b1c8cb Mon Sep 17 00:00:00 2001 From: "jove@bisquerra.com" Date: Wed, 1 Jul 2020 22:34:35 +0200 Subject: [PATCH 38/83] NEW: Appearance tab in TakePOS with more visual parameters --- htdocs/core/lib/takepos.lib.php | 5 ++ htdocs/langs/en_US/cashdesk.lang | 6 +- htdocs/takepos/admin/appearance.php | 130 ++++++++++++++++++++++++++++ htdocs/takepos/admin/setup.php | 9 -- htdocs/takepos/css/pos.css.php | 2 +- htdocs/takepos/index.php | 4 +- 6 files changed, 143 insertions(+), 13 deletions(-) create mode 100644 htdocs/takepos/admin/appearance.php diff --git a/htdocs/core/lib/takepos.lib.php b/htdocs/core/lib/takepos.lib.php index d04fa5f77ef..1a8ace36d0b 100644 --- a/htdocs/core/lib/takepos.lib.php +++ b/htdocs/core/lib/takepos.lib.php @@ -37,6 +37,11 @@ function takepos_prepare_head() $head[$h][1] = $langs->trans("Parameters"); $head[$h][2] = 'setup'; $h++; + + $head[$h][0] = DOL_URL_ROOT.'/takepos/admin/appearance.php'; + $head[$h][1] = $langs->trans("Appearance"); + $head[$h][2] = 'appearance'; + $h++; $head[$h][0] = DOL_URL_ROOT.'/takepos/admin/receipt.php'; $head[$h][1] = $langs->trans("Receipt"); diff --git a/htdocs/langs/en_US/cashdesk.lang b/htdocs/langs/en_US/cashdesk.lang index 71a2a992e19..55044a00cec 100644 --- a/htdocs/langs/en_US/cashdesk.lang +++ b/htdocs/langs/en_US/cashdesk.lang @@ -111,4 +111,8 @@ AutoOrder=Order by the customer himself RestaurantMenu=Menu CustomerMenu=Customer menu ScanToMenu=Scan QR code to see the menu -ScanToOrder=Scan QR code to order \ No newline at end of file +ScanToOrder=Scan QR code to order +Appearance=Appearance +HideCategoryImages=Hide Category Images +HideProductImages=Hide Product Images +NumberOfLinesToShow=Number of lines to show in image box \ No newline at end of file diff --git a/htdocs/takepos/admin/appearance.php b/htdocs/takepos/admin/appearance.php new file mode 100644 index 00000000000..1c395fdbb29 --- /dev/null +++ b/htdocs/takepos/admin/appearance.php @@ -0,0 +1,130 @@ + + * Copyright (C) 2011-2017 Juanjo Menent + * Copyright (C) 2019 Andreu Bisquerra Gaya + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** + * \file htdocs/takepos/admin/terminal.php + * \ingroup takepos + * \brief Setup page for TakePos module + */ + +require '../../main.inc.php'; // Load $user and permissions +require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/pdf.lib.php'; +require_once DOL_DOCUMENT_ROOT."/core/lib/takepos.lib.php"; + +// Security check +if (!$user->admin) accessforbidden(); + +$langs->loadLangs(array("admin", "cashdesk", "commercial")); + +/* + * Actions + */ + +if (GETPOST('action', 'alpha') == 'set') +{ + $db->begin(); + + $res = dolibarr_set_const($db, "TAKEPOS_COLOR_THEME", GETPOST('TAKEPOS_COLOR_THEME', 'alpha'), 'chaine', 0, '', $conf->entity); + $res = dolibarr_set_const($db, "TAKEPOS_LINES_TO_SHOW", GETPOST('TAKEPOS_LINES_TO_SHOW', 'alpha'), 'chaine', 0, '', $conf->entity); + + dol_syslog("admin/cashdesk: level ".GETPOST('level', 'alpha')); + + if (!$res > 0) $error++; + + if (!$error) + { + $db->commit(); + setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); + } else { + $db->rollback(); + setEventMessages($langs->trans("Error"), null, 'errors'); + } +} elseif (GETPOST('action', 'alpha') == 'setmethod') +{ + dolibarr_set_const($db, "TAKEPOS_PRINT_METHOD", GETPOST('value', 'alpha'), 'chaine', 0, '', $conf->entity); +} + + +/* + * View + */ + +$form = new Form($db); +$formproduct = new FormProduct($db); + +llxHeader('', $langs->trans("CashDeskSetup")); + +$linkback = '
    '.$langs->trans("BackToModuleList").''; +print load_fiche_titre($langs->trans("CashDeskSetup").' (TakePOS)', $linkback, 'title_setup'); +$head = takepos_prepare_head(); +dol_fiche_head($head, 'appearance', 'TakePOS', -1, 'cash-register'); + +print ''; +print ''; +print ''; + +print ''; +print ''; +print ''; +print "\n"; + +// Color theme +print '\n"; + +// Hide category images to speed up +print '\n"; + +// Hide category images to speed up +print '\n"; + +// Terminals +print '\n"; + +print '
    '.$langs->trans("Parameters").''.$langs->trans("Value").'
    '; +print $langs->trans("ColorTheme"); +print ''; +$array = array(0=>"Eldy", 1=>$langs->trans("Colorful")); +print $form->selectarray('TAKEPOS_COLOR_THEME', $array, (empty($conf->global->TAKEPOS_COLOR_THEME) ? '0' : $conf->global->TAKEPOS_COLOR_THEME), 0); +print "
    '; +print $langs->trans('HideCategoryImages'); +print ''; +print ajax_constantonoff("TAKEPOS_HIDE_CATEGORY_IMAGES", array(), $conf->entity, 0, 0, 1, 0); +print "
    '; +print $langs->trans('HideProductImages'); +print ''; +print ajax_constantonoff("TAKEPOS_HIDE_PRODUCT_IMAGES", array(), $conf->entity, 0, 0, 1, 0); +print "
    '; +print $langs->trans("NumberOfLinesToShow"); +print ''; +$array = array(1=>"1", 2=>"2", 3=>"3", 4=>"4", 5=>"5", 6=>"6"); +print $form->selectarray('TAKEPOS_LINES_TO_SHOW', $array, (empty($conf->global->TAKEPOS_LINES_TO_SHOW) ? '2' : $conf->global->TAKEPOS_LINES_TO_SHOW), 0); +print "
    '; + +print '
    '; + +print '
    '; + +print "\n"; + +print '
    '; + +llxFooter(); +$db->close(); diff --git a/htdocs/takepos/admin/setup.php b/htdocs/takepos/admin/setup.php index 541c34e4e12..79f3b729bc4 100644 --- a/htdocs/takepos/admin/setup.php +++ b/htdocs/takepos/admin/setup.php @@ -75,7 +75,6 @@ if ($action == 'set') $res = dolibarr_set_const($db, "TAKEPOS_SUPPLEMENTS_CATEGORY", GETPOST('TAKEPOS_SUPPLEMENTS_CATEGORY', 'alpha'), 'chaine', 0, '', $conf->entity); $res = dolibarr_set_const($db, "TAKEPOS_NUMPAD", GETPOST('TAKEPOS_NUMPAD', 'alpha'), 'chaine', 0, '', $conf->entity); $res = dolibarr_set_const($db, "TAKEPOS_SORTPRODUCTFIELD", GETPOST('TAKEPOS_SORTPRODUCTFIELD', 'alpha'), 'chaine', 0, '', $conf->entity); - $res = dolibarr_set_const($db, "TAKEPOS_COLOR_THEME", GETPOST('TAKEPOS_COLOR_THEME', 'alpha'), 'chaine', 0, '', $conf->entity); $res = dolibarr_set_const($db, "TAKEPOS_NUM_TERMINALS", GETPOST('TAKEPOS_NUM_TERMINALS', 'alpha'), 'chaine', 0, '', $conf->entity); $res = dolibarr_set_const($db, "TAKEPOS_ADDON", GETPOST('TAKEPOS_ADDON', 'alpha'), 'int', 0, '', $conf->entity); $res = dolibarr_set_const($db, "TAKEPOS_EMAIL_TEMPLATE_INVOICE", GETPOST('TAKEPOS_EMAIL_TEMPLATE_INVOICE', 'alpha'), 'chaine', 0, '', $conf->entity); @@ -303,14 +302,6 @@ $htmltext = ''.$langs->trans("AvailableVariables").':
    '; foreach ($substitutionarray as $key => $val) $htmltext .= $key.'
    '; $htmltext .= '
    '; -// Color theme -print ''; -print $langs->trans("ColorTheme"); -print ''; -$array = array(0=>"Eldy", 1=>$langs->trans("Colorful")); -print $form->selectarray('TAKEPOS_COLOR_THEME', $array, (empty($conf->global->TAKEPOS_COLOR_THEME) ? '0' : $conf->global->TAKEPOS_COLOR_THEME), 0); -print "\n"; - // Payment numpad print ''; print $langs->trans("Paymentnumpad"); diff --git a/htdocs/takepos/css/pos.css.php b/htdocs/takepos/css/pos.css.php index 4c92fe888d2..80271e8bdb3 100644 --- a/htdocs/takepos/css/pos.css.php +++ b/htdocs/takepos/css/pos.css.php @@ -429,7 +429,7 @@ p.description_content{ div.description_content { display: -webkit-box; -webkit-box-orient: vertical; - -webkit-line-clamp: 2; + -webkit-line-clamp: global->TAKEPOS_LINES_TO_SHOW;?>; overflow: hidden; padding-left: 2px; padding-right: 2px; diff --git a/htdocs/takepos/index.php b/htdocs/takepos/index.php index 135723de966..0b81aa51391 100644 --- a/htdocs/takepos/index.php +++ b/htdocs/takepos/index.php @@ -982,7 +982,7 @@ if (!empty($conf->global->TAKEPOS_HIDE_HEAD_BAR)) { //echo ''; echo ''; } else { - echo ''; + if (!$conf->global->TAKEPOS_HIDE_CATEGORY_IMAGES) echo ''; } ?> @@ -1015,7 +1015,7 @@ if (!empty($conf->global->TAKEPOS_HIDE_HEAD_BAR)) { print ''; } else { print '
    '; - print ''; + if (!$conf->global->TAKEPOS_HIDE_PRODUCT_IMAGES) print ''; } ?> From d2a78b8aa49fb4b1fe1ce1a0d48aed2e99a07823 Mon Sep 17 00:00:00 2001 From: andreubisquerra Date: Wed, 1 Jul 2020 22:44:18 +0200 Subject: [PATCH 39/83] Update appearance.php --- htdocs/takepos/admin/appearance.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/takepos/admin/appearance.php b/htdocs/takepos/admin/appearance.php index 1c395fdbb29..5d3e401d751 100644 --- a/htdocs/takepos/admin/appearance.php +++ b/htdocs/takepos/admin/appearance.php @@ -1,7 +1,7 @@ * Copyright (C) 2011-2017 Juanjo Menent - * Copyright (C) 2019 Andreu Bisquerra Gaya + * Copyright (C) 2019-2020 Andreu Bisquerra Gaya * * 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 @@ -18,7 +18,7 @@ */ /** - * \file htdocs/takepos/admin/terminal.php + * \file htdocs/takepos/admin/appearance.php * \ingroup takepos * \brief Setup page for TakePos module */ From 9e4d7627f3a4aef826191fb4b4f2aa821bad198c Mon Sep 17 00:00:00 2001 From: andreubisquerra Date: Wed, 1 Jul 2020 22:55:00 +0200 Subject: [PATCH 40/83] Fix travis --- htdocs/core/lib/takepos.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/lib/takepos.lib.php b/htdocs/core/lib/takepos.lib.php index 1a8ace36d0b..083e54c66c0 100644 --- a/htdocs/core/lib/takepos.lib.php +++ b/htdocs/core/lib/takepos.lib.php @@ -37,7 +37,7 @@ function takepos_prepare_head() $head[$h][1] = $langs->trans("Parameters"); $head[$h][2] = 'setup'; $h++; - + $head[$h][0] = DOL_URL_ROOT.'/takepos/admin/appearance.php'; $head[$h][1] = $langs->trans("Appearance"); $head[$h][2] = 'appearance'; From d6ded950ac9d0f6eca6ef3996d57c2524f5a392b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 2 Jul 2020 00:07:18 +0200 Subject: [PATCH 41/83] Update doc --- ChangeLog | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/ChangeLog b/ChangeLog index a39c27e119f..edb66756ff2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -104,8 +104,8 @@ NEW: class tool for converting units NEW: Close #13011 Add button create thirdparty when creating intervention NEW: Colorful theme for TakePOS NEW: columns units in product list -NEW: compatibility of translabel with more dict -NEW: Confirm file delete on fracture card +NEW: compatibility of translabel with more dictionaries +NEW: Confirm file delete on invoice card NEW: "contact_civility" for ODT templates NEW: CUPS printing compatibility for TakePOS NEW: Customer command list - Add date start & date end @@ -113,16 +113,11 @@ NEW: display weight in shipment list NEW: Documentation about PHP support in Dolibarr NEW: Donation - Update FR CERFA to 11580*04 NEW: Easier way to setup the different types of tax. Better visibility. -NEW: enable put for agendaevents api NEW: Expedition list - Add date start & date end NEW: Experiment supplier packaging with option PRODUCT_USE_SUPPLIER_PACKAGING: Using price according to the minimum quantity NEW: Export module, add extrafields for Contract and Contract line NEW: Extend retained warranty to be available for all invoices -NEW: filter by product on supplier order API NEW: French new regions -NEW: get documents for categories with RESP API -NEW: get proposal by ref with API -NEW: Hidden option MAIN_TEMP_DIR NEW: hook and data id NEW: hook on ics generation to add more events in eventarray NEW: hook on product load stats @@ -209,6 +204,11 @@ NEW: Bookkeeping by account - Add selectfields & hook NEW: Can force position of legend of graph on right (instead of top) NEW: Can change destination of "Back to list" using a "backtolist" parameter NEW: add more category types from hook +NEW: enable put for agendaevents api +NEW: filter by product on supplier order API +NEW: get documents for categories with RESP API +NEW: get proposal by ref with API +NEW: Hidden option MAIN_TEMP_DIR WARNING: From d76ca6f569588de73f7156040b8838921e5d82ad Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 2 Jul 2020 00:09:52 +0200 Subject: [PATCH 42/83] Update doc --- ChangeLog | 1 - 1 file changed, 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index edb66756ff2..19c77c702fd 100644 --- a/ChangeLog +++ b/ChangeLog @@ -190,7 +190,6 @@ NEW: API filter bankaccounts by category NEW: API filter contacts by category NEW: API filter members by category NEW: API filter projects by category -NEW: API filter thirdpartie by category NEW: API filter thirdparty by category NEW: API filter user by category NEW: API filter warehouses by categorie From 452cca503ae11647a56b8e7c86c4d8200db5a9b6 Mon Sep 17 00:00:00 2001 From: andreubisquerra Date: Thu, 2 Jul 2020 00:11:17 +0200 Subject: [PATCH 43/83] Fixes --- htdocs/takepos/admin/appearance.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/takepos/admin/appearance.php b/htdocs/takepos/admin/appearance.php index 5d3e401d751..f085067197e 100644 --- a/htdocs/takepos/admin/appearance.php +++ b/htdocs/takepos/admin/appearance.php @@ -108,7 +108,7 @@ print ''; print ajax_constantonoff("TAKEPOS_HIDE_PRODUCT_IMAGES", array(), $conf->entity, 0, 0, 1, 0); print "\n"; -// Terminals +// Lines to show print ''; print $langs->trans("NumberOfLinesToShow"); print ''; From a5431a40daf64c1e7025ba3e838cee2cea2fb7a0 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Thu, 2 Jul 2020 10:16:20 +0200 Subject: [PATCH 44/83] FIX missing possibility to change entity when propal cloning --- htdocs/comm/propal/card.php | 15 +++++++-------- htdocs/comm/propal/class/propal.class.php | 4 +++- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/htdocs/comm/propal/card.php b/htdocs/comm/propal/card.php index 28fdc7845d2..996ad2e31af 100644 --- a/htdocs/comm/propal/card.php +++ b/htdocs/comm/propal/card.php @@ -194,7 +194,7 @@ if (empty($reshook)) } } - $result = $object->createFromClone($user, $socid); + $result = $object->createFromClone($user, $socid, (GETPOSTISSET('entity') ? GETPOST('entity', 'int') : null)); if ($result > 0) { header("Location: ".$_SERVER['PHP_SELF'].'?id='.$result); exit(); @@ -1832,10 +1832,9 @@ if ($action == 'create') print ''; print ''.$langs->trans("CreateEmptyPropal").''; + print ''; } - if (!empty($conf->global->PROPAL_CLONE_ON_CREATE_PAGE)) print ''; - dol_fiche_end(); $langs->load("bills"); @@ -1878,11 +1877,11 @@ if ($action == 'create') if ($action == 'clone') { // Create an array for form $formquestion = array( - // 'text' => $langs->trans("ConfirmClone"), - // array('type' => 'checkbox', 'name' => 'clone_content', 'label' => $langs->trans("CloneMainAttributes"), 'value' => 1), - // array('type' => 'checkbox', 'name' => 'update_prices', 'label' => $langs->trans("PuttingPricesUpToDate"), '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)'))); + // 'text' => $langs->trans("ConfirmClone"), + // array('type' => 'checkbox', 'name' => 'clone_content', 'label' => $langs->trans("CloneMainAttributes"), 'value' => 1), + // array('type' => 'checkbox', 'name' => 'update_prices', 'label' => $langs->trans("PuttingPricesUpToDate"), '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)')) + ); if (!empty($conf->global->PROPAL_CLONE_DATE_DELIVERY) && !empty($object->date_livraison)) { $formquestion[] = array('type' => 'date', 'name' => 'date_delivery', 'label' => $langs->trans("DeliveryDate"), 'value' => $object->date_livraison); } diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index 0101805cd88..3fd122c0103 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -1324,9 +1324,10 @@ class Propal extends CommonObject * * @param User $user User making the clone * @param int $socid Id of thirdparty + * @param int $forceentity Entity id to force * @return int New id of clone */ - public function createFromClone(User $user, $socid = 0) + public function createFromClone(User $user, $socid = 0, $forceentity = null) { global $conf, $hookmanager; @@ -1382,6 +1383,7 @@ class Propal extends CommonObject $object->id = 0; $object->ref = ''; + $object->entity = (! empty($forceentity) ? $forceentity : $object->entity); $object->statut = self::STATUS_DRAFT; // Clear fields From 642e75c3dd29b03d7eaf71f21678f05d2f5521d1 Mon Sep 17 00:00:00 2001 From: quentin Date: Thu, 2 Jul 2020 11:34:59 +0200 Subject: [PATCH 45/83] FIX wrong origin --- htdocs/commande/class/commande.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index 54506a4a816..c92de067c8e 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -1014,7 +1014,7 @@ class Commande extends CommonOrder // Complete vat rate with code $vatrate = $line->tva_tx; if ($line->vat_src_code && !preg_match('/\(.*\)/', $vatrate)) $vatrate .= ' ('.$line->vat_src_code.')'; - + $origin = !empty($line->origin) ? $line->origin : $this->element; $result = $this->addline( $line->desc, $line->subprice, @@ -1039,7 +1039,7 @@ class Commande extends CommonOrder $line->label, $line->array_options, $line->fk_unit, - $this->element, + $origin, $line->id ); if ($result < 0) From b3396a6454e52b2853142f3dbd1e574e00b7813d Mon Sep 17 00:00:00 2001 From: BENKE Charlene <1179011+defrance@users.noreply.github.com> Date: Thu, 2 Jul 2020 14:40:56 +0200 Subject: [PATCH 46/83] better look & feel icon on dropdown --- htdocs/main.inc.php | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index 2f62237bce9..1084c07f755 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -1884,7 +1884,7 @@ function top_menu_quickadd() @@ -1897,7 +1897,7 @@ function top_menu_quickadd() @@ -1910,7 +1910,7 @@ function top_menu_quickadd() @@ -1923,7 +1923,7 @@ function top_menu_quickadd() @@ -1936,7 +1936,7 @@ function top_menu_quickadd() @@ -1949,7 +1949,7 @@ function top_menu_quickadd() @@ -1962,7 +1962,7 @@ function top_menu_quickadd() @@ -1975,7 +1975,7 @@ function top_menu_quickadd() @@ -1988,7 +1988,7 @@ function top_menu_quickadd() @@ -2001,7 +2001,7 @@ function top_menu_quickadd() @@ -2014,7 +2014,7 @@ function top_menu_quickadd() @@ -2040,7 +2040,7 @@ function top_menu_quickadd() $html.= '