From d428f79d46157ca3e474e860f4e262902339d109 Mon Sep 17 00:00:00 2001 From: Marc de Lima Lucio Date: Wed, 15 May 2019 12:26:39 +0200 Subject: [PATCH 01/62] NEW: new line template: hidden conf to fill service dates from the last service line --- htdocs/core/tpl/objectline_create.tpl.php | 47 +++++++++++++++++++++++ htdocs/langs/en_US/products.lang | 1 + 2 files changed, 48 insertions(+) diff --git a/htdocs/core/tpl/objectline_create.tpl.php b/htdocs/core/tpl/objectline_create.tpl.php index 4a4febe65d3..b76a2f55219 100644 --- a/htdocs/core/tpl/objectline_create.tpl.php +++ b/htdocs/core/tpl/objectline_create.tpl.php @@ -464,6 +464,27 @@ if ((! empty($conf->service->enabled) || ($object->element == 'contrat')) && $da global->MAIN_FILL_SERVICE_DATES_FROM_LAST_SERVICE_LINE) && ! empty($object->lines)) + { + for($i = count($object->lines) - 1; $i >= 0; $i--) + { + $lastline = $object->lines[$i]; + + if($lastline->product_type == Product::TYPE_SERVICE && (! empty($lastline->date_start) || ! empty($lastline->date_end))) + { + $date_start_prefill = $lastline->date_start; + $date_end_prefill = $lastline->date_end; + + $prefillDates = true; + break; + } + } + } + + if (! empty($object->element) && $object->element == 'contrat') { print $langs->trans("DateStartPlanned").' '; @@ -478,7 +499,33 @@ if ((! empty($conf->service->enabled) || ($object->element == 'contrat')) && $da echo ' '.$langs->trans('to').' '; print $form->selectDate($date_end, 'date_end', empty($conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE)?0:1, empty($conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE)?0:1, 1, "addproduct", 1, 0); }; + + if($prefillDates) + { + echo ' ' . $langs->trans('FillWithLastServiceDates') . ''; + } + print ' +
value="trans('Create') : $langs->trans('Save') ?>" class="button">   From 1cc673a9c61722dd9c628f3dde9d386c374bc7bb Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Wed, 12 Aug 2020 08:53:24 +0000 Subject: [PATCH 44/62] Fixing style errors. --- .../class/ProductCombination.class.php | 65 +++++++++---------- htdocs/variants/combinations.php | 32 ++++----- 2 files changed, 48 insertions(+), 49 deletions(-) diff --git a/htdocs/variants/class/ProductCombination.class.php b/htdocs/variants/class/ProductCombination.class.php index 777cb136b05..17d1688d268 100644 --- a/htdocs/variants/class/ProductCombination.class.php +++ b/htdocs/variants/class/ProductCombination.class.php @@ -139,13 +139,13 @@ class ProductCombination public function fetchCombinationPriceLevels($fk_price_level = 0, $useCache = true) { // Check cache - if(!empty($this->combination_price_levels) && $useCache){ - if((!empty($fk_price_level) && isset($this->combination_price_levels[$fk_price_level])) || empty($fk_price_level)){ + if (!empty($this->combination_price_levels) && $useCache){ + if ((!empty($fk_price_level) && isset($this->combination_price_levels[$fk_price_level])) || empty($fk_price_level)){ return 1; } } - if(!is_array($this->combination_price_levels) + if (!is_array($this->combination_price_levels) || empty($fk_price_level) // if fetch an unique level dont erase all already fetched ){ $this->combination_price_levels = array(); @@ -178,15 +178,15 @@ class ProductCombination $staticProductCombinationLevel = new ProductCombinationLevel($this->db); // Delete all - if(empty($this->combination_price_levels)){ + if (empty($this->combination_price_levels)){ return $staticProductCombinationLevel->deleteAllForCombination($this->id); } // Clean not needed price levels - if($clean){ + if ($clean){ $res = $staticProductCombinationLevel->clean($this->id); - if($res<0){ + if ($res<0){ $this->errors[] = 'Fail to clean not needed price levels'; return -1; } @@ -194,17 +194,17 @@ class ProductCombination foreach ($this->combination_price_levels as $fk_price_level => $combination_price_level){ $res = $combination_price_level->save(); - if($res<1){ + if ($res<1){ $this->error = 'save combination price level '.$fk_price_level . ' '.$combination_price_level->error; $this->errors[] = $this->error; $errors ++; } } - if($errors > 0){ + if ($errors > 0){ return $errors*-1; } - else{ + else { return 1; } } @@ -331,7 +331,7 @@ class ProductCombination if (!empty($conf->global->PRODUIT_MULTIPRICES)) { $res = $this->saveCombinationPriceLevels(); - if($res<0){ + if ($res<0){ return -2; } } @@ -365,7 +365,7 @@ class ProductCombination if (!empty($conf->global->PRODUIT_MULTIPRICES)) { $res = $this->saveCombinationPriceLevels(); - if($res<0){ + if ($res<0){ return -2; } } @@ -392,7 +392,7 @@ class ProductCombination $comb2val->deleteByFkCombination($this->id); // remove combination price levels - if(!$this->db->query("DELETE FROM ".MAIN_DB_PREFIX."product_attribute_combination_price_level WHERE fk_product_attribute_combination = ".(int) $this->id)) { + if (!$this->db->query("DELETE FROM ".MAIN_DB_PREFIX."product_attribute_combination_price_level WHERE fk_product_attribute_combination = ".(int) $this->id)) { $this->db->rollback(); return -1; } @@ -682,10 +682,10 @@ WHERE c.fk_product_parent = ".(int) $productid." AND p.tosell = 1"; $weight_impact = (float) $forced_weightvar; // If false, return 0 //Final price impact - if(!is_array($forced_pricevar)){ + if (!is_array($forced_pricevar)){ $price_impact[1] = (float) $forced_pricevar; // If false, return 0 } - else{ + else { $price_impact = $forced_pricevar; } @@ -732,7 +732,7 @@ WHERE c.fk_product_parent = ".(int) $productid." AND p.tosell = 1"; $price_impact[1] += (float) price2num($variations[$currcombattr][$currcombval]['price']); // Manage Price levels - if($conf->global->PRODUIT_MULTIPRICES){ + if ($conf->global->PRODUIT_MULTIPRICES){ for ($i = 2; $i <= $conf->global->PRODUIT_MULTIPRICES_LIMIT; $i++) { $price_impact[$i] += (float) price2num($variations[$currcombattr][$currcombval]['price']); @@ -760,16 +760,16 @@ WHERE c.fk_product_parent = ".(int) $productid." AND p.tosell = 1"; $newcomb->variation_weight = $weight_impact; // Init price level - if($conf->global->PRODUIT_MULTIPRICES){ + if ($conf->global->PRODUIT_MULTIPRICES){ for ($i = 1; $i <= $conf->global->PRODUIT_MULTIPRICES_LIMIT; $i++){ $productCombinationLevel = new ProductCombinationLevel($this->db); $productCombinationLevel->fk_product_attribute_combination = 0; $productCombinationLevel->fk_price_level = $i; $productCombinationLevel->variation_price = $price_impact[$i]; - if(is_array($price_var_percent)){ + if (is_array($price_var_percent)){ $productCombinationLevel->variation_price_percentage = !empty($price_var_percent[$i]) ? $price_var_percent[$i] : 0; - }else{ + }else { $productCombinationLevel->variation_price_percentage = $price_var_percent; } @@ -1000,11 +1000,11 @@ class ProductCombinationLevel */ public function fetch($rowid) { - $sql = "SELECT rowid, fk_product_attribute_combination, fk_price_level, variation_price, variation_price_percentage FROM " . MAIN_DB_PREFIX . $this->table_element." WHERE rowid = " . (int)$rowid; + $sql = "SELECT rowid, fk_product_attribute_combination, fk_price_level, variation_price, variation_price_percentage FROM " . MAIN_DB_PREFIX . $this->table_element." WHERE rowid = " . (int) $rowid; $obj = $this->db->getRow($sql); - if($obj){ + if ($obj){ return $this->fetchFormObj($obj); } @@ -1026,7 +1026,7 @@ class ProductCombinationLevel ." FROM ".MAIN_DB_PREFIX.$this->table_element ." WHERE fk_product_attribute_combination = ".intval($fk_product_attribute_combination); - if(!empty($fk_price_level)){ + if (!empty($fk_price_level)){ $sql.= ' AND fk_price_level = '.intval($fk_price_level); } @@ -1039,7 +1039,7 @@ class ProductCombinationLevel $result = array(); // For more simple usage set level as array key - foreach($combination_price_levels as $k => $row){ + foreach ($combination_price_levels as $k => $row){ $productCombinationLevel = new ProductCombinationLevel($this->db); $productCombinationLevel->fetchFormObj($row); $result[$row->fk_price_level] = $productCombinationLevel; @@ -1064,7 +1064,7 @@ class ProductCombinationLevel $this->fk_product_attribute_combination = doubleval($obj->fk_product_attribute_combination); $this->fk_price_level = intval($obj->fk_price_level); $this->variation_price = doubleval($obj->variation_price); - $this->variation_price_percentage = (bool)$obj->variation_price_percentage; + $this->variation_price_percentage = (bool) $obj->variation_price_percentage; return 1; } @@ -1080,41 +1080,41 @@ class ProductCombinationLevel $errors = 0; - if(empty($this->fk_product_attribute_combination) || empty($this->fk_price_level)){ + if (empty($this->fk_product_attribute_combination) || empty($this->fk_price_level)){ return -1; } // check if level exist in DB before add - if(empty($this->id)){ + if (empty($this->id)){ $sql = "SELECT rowid id" ." FROM ".MAIN_DB_PREFIX . $this->table_element ." WHERE fk_product_attribute_combination = ".(int) $this->fk_product_attribute_combination .' AND fk_price_level = '.intval($this->fk_price_level); $existObj = $this->db->getRow($sql); - if($existObj){ + if ($existObj){ $this->id = $existObj->id; } } // Update - if(!empty($this->id)) { + if (!empty($this->id)) { $sql = 'UPDATE ' . MAIN_DB_PREFIX . $this->table_element . ' SET ' . ' variation_price = '.doubleval($this->variation_price) . ' , variation_price_percentage = '.intval($this->variation_price_percentage) . ' WHERE rowid = '.intval($this->id); $res = $this->db->query($sql); - if($res>0){ + if ($res>0){ return $this->id; } - else{ + else { $this->error = $this->db->error(); $this->errors[] = $this->error; return -1; } } - else{ + else { // ADD $sql = "INSERT INTO " . MAIN_DB_PREFIX . $this->table_element . " (" . " fk_product_attribute_combination, fk_price_level, variation_price, variation_price_percentage" @@ -1126,10 +1126,10 @@ class ProductCombinationLevel . " )"; $res = $this->db->query($sql); - if($res){ + if ($res){ $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX . $this->table_element); } - else{ + else { $this->error = $this->db->error(); $this->errors[] = $this->error; return -1; @@ -1186,5 +1186,4 @@ class ProductCombinationLevel return $res ? 1 : -1; } - } diff --git a/htdocs/variants/combinations.php b/htdocs/variants/combinations.php index 5ad7b38af2e..b9f62bdcf73 100644 --- a/htdocs/variants/combinations.php +++ b/htdocs/variants/combinations.php @@ -118,11 +118,11 @@ if ($_POST) { $price_impact = price2num($price_impact); // for conf PRODUIT_MULTIPRICES - if($conf->global->PRODUIT_MULTIPRICES) { + if ($conf->global->PRODUIT_MULTIPRICES) { $level_price_impact = array_map('price2num', $level_price_impact); $level_price_impact_percent = array_map('price2num', $level_price_impact_percent); } - else{ + else { $level_price_impact = array(1 => $weight_impact); $level_price_impact_percent = array(1 => $price_impact_percent); } @@ -243,19 +243,20 @@ if ($_POST) { $prodcomb->variation_weight = $weight_impact; // for conf PRODUIT_MULTIPRICES - if($conf->global->PRODUIT_MULTIPRICES) { + if ($conf->global->PRODUIT_MULTIPRICES) { $level_price_impact = array_map('price2num', $level_price_impact); - $level_price_impact_percent = array_map(function($a){ return !empty($a);}, $level_price_impact_percent); + $level_price_impact_percent = array_map(function ($a) { + return !empty($a);}, $level_price_impact_percent); $prodcomb->variation_price = $level_price_impact[1]; - $prodcomb->variation_price_percentage = (bool)$level_price_impact_percent[1]; + $prodcomb->variation_price_percentage = (bool) $level_price_impact_percent[1]; } - else{ + else { $level_price_impact = array(1 => $weight_impact); $level_price_impact_percent = array(1 => $price_impact_percent); } - if($conf->global->PRODUIT_MULTIPRICES){ + if ($conf->global->PRODUIT_MULTIPRICES){ $prodcomb->combination_price_levels = array(); for ($i = 1; $i <= $conf->global->PRODUIT_MULTIPRICES_LIMIT; $i++){ $productCombinationLevel = new ProductCombinationLevel($db); @@ -634,23 +635,22 @@ if (!empty($id) || !empty($ref)) -global->PRODUIT_MULTIPRICES)){ ?> + global->PRODUIT_MULTIPRICES)){ ?> > -fetchCombinationPriceLevels(); for ($i = 1; $i <= $conf->global->PRODUIT_MULTIPRICES_LIMIT; $i++) { - print ''; - print ''; - if($i===1){ + print ''; + if ($i===1){ print ' ('.$langs->trans('ApplyToAllPriceImpactLevel').')'; } print ''; @@ -672,7 +672,7 @@ if (!empty($id) || !empty($ref)) } if (!empty($conf->global->PRODUIT_MULTIPRICES)){ -?> + ?> - + ?>
value="trans('Create') : $langs->trans('Save') ?>" class="button">   From 355d62e7db0d050a1e7296bb4f7195d78f3a6129 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 12 Aug 2020 20:24:44 +0200 Subject: [PATCH 45/62] FIX Update line of BOM --- htdocs/bom/bom_card.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/htdocs/bom/bom_card.php b/htdocs/bom/bom_card.php index c98dee97f51..bd5e6fe7789 100644 --- a/htdocs/bom/bom_card.php +++ b/htdocs/bom/bom_card.php @@ -194,10 +194,10 @@ if (empty($reshook)) $error = 0; // Set if we used free entry or predefined product - $qty = GETPOST('qty', 'int'); + $qty = price2num(GETPOST('qty', 'int')); $qty_frozen = GETPOST('qty_frozen', 'int'); $disable_stock_change = GETPOST('disable_stock_change', 'int'); - $efficiency = GETPOST('efficiency', 'int'); + $efficiency = price2num(GETPOST('efficiency', 'int')); if ($qty == '') { setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Qty')), null, 'errors'); @@ -223,6 +223,8 @@ if (empty($reshook)) unset($_POST['qty']); unset($_POST['qty_frozen']); unset($_POST['disable_stock_change']); + + $object->fetchLines(); } } } @@ -545,7 +547,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea if (!empty($object->table_element_line)) { - print '
+ print ' From 4e1f554c15b0368a43fa2eb56fca821801d9cea5 Mon Sep 17 00:00:00 2001 From: John Botella Date: Thu, 13 Aug 2020 11:43:33 +0200 Subject: [PATCH 46/62] Fix - add variation price fallback behavior --- .../class/ProductCombination.class.php | 39 +++++++++++++++---- 1 file changed, 32 insertions(+), 7 deletions(-) diff --git a/htdocs/variants/class/ProductCombination.class.php b/htdocs/variants/class/ProductCombination.class.php index 777cb136b05..0b3b3843867 100644 --- a/htdocs/variants/class/ProductCombination.class.php +++ b/htdocs/variants/class/ProductCombination.class.php @@ -138,6 +138,8 @@ class ProductCombination */ public function fetchCombinationPriceLevels($fk_price_level = 0, $useCache = true) { + global $conf; + // Check cache if(!empty($this->combination_price_levels) && $useCache){ if((!empty($fk_price_level) && isset($this->combination_price_levels[$fk_price_level])) || empty($fk_price_level)){ @@ -154,10 +156,31 @@ class ProductCombination $staticProductCombinationLevel = new ProductCombinationLevel($this->db); $combination_price_levels = $staticProductCombinationLevel->fetchAll($this->id, $fk_price_level); - if (!$combination_price_levels || !is_array($combination_price_levels)) { + if (!is_array($combination_price_levels)) { return -1; } + if(empty($combination_price_levels)){ + + /** + * for auto retrocompatibility with last behavior + */ + $productCombinationLevel = new ProductCombinationLevel($this->db); + $productCombinationLevel->fk_price_level = intval($fk_price_level); + $productCombinationLevel->fk_product_attribute_combination = $this->id; + $productCombinationLevel->variation_price = $this->variation_price; + $productCombinationLevel->variation_price_percentage = $this->variation_price_percentage; + + if($fk_price_level>0){ + $combination_price_levels[$fk_price_level] = $productCombinationLevel; + } + else{ + for ($i = 1; $i <= $conf->global->PRODUIT_MULTIPRICES_LIMIT; $i++){ + $combination_price_levels[$i] = $productCombinationLevel; + } + } + } + $this->combination_price_levels = $combination_price_levels; return 1; @@ -1032,17 +1055,19 @@ class ProductCombinationLevel $combination_price_levels = $this->db->getRows($sql); - if (!$combination_price_levels || !is_array($combination_price_levels)) { + if (!is_array($combination_price_levels)) { return -1; } $result = array(); - // For more simple usage set level as array key - foreach($combination_price_levels as $k => $row){ - $productCombinationLevel = new ProductCombinationLevel($this->db); - $productCombinationLevel->fetchFormObj($row); - $result[$row->fk_price_level] = $productCombinationLevel; + if(!empty($combination_price_levels)) { + // For more simple usage set level as array key + foreach($combination_price_levels as $k => $row){ + $productCombinationLevel = new ProductCombinationLevel($this->db); + $productCombinationLevel->fetchFormObj($row); + $result[$row->fk_price_level] = $productCombinationLevel; + } } return $result; From 959ccce7770fe1174a07b31991f5a15e478c34c5 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Thu, 13 Aug 2020 09:48:28 +0000 Subject: [PATCH 47/62] Fixing style errors. --- .../class/ProductCombination.class.php | 73 +++++++++---------- 1 file changed, 36 insertions(+), 37 deletions(-) diff --git a/htdocs/variants/class/ProductCombination.class.php b/htdocs/variants/class/ProductCombination.class.php index 0b3b3843867..7d6a07d736d 100644 --- a/htdocs/variants/class/ProductCombination.class.php +++ b/htdocs/variants/class/ProductCombination.class.php @@ -141,13 +141,13 @@ class ProductCombination global $conf; // Check cache - if(!empty($this->combination_price_levels) && $useCache){ - if((!empty($fk_price_level) && isset($this->combination_price_levels[$fk_price_level])) || empty($fk_price_level)){ + if (!empty($this->combination_price_levels) && $useCache){ + if ((!empty($fk_price_level) && isset($this->combination_price_levels[$fk_price_level])) || empty($fk_price_level)){ return 1; } } - if(!is_array($this->combination_price_levels) + if (!is_array($this->combination_price_levels) || empty($fk_price_level) // if fetch an unique level dont erase all already fetched ){ $this->combination_price_levels = array(); @@ -160,7 +160,7 @@ class ProductCombination return -1; } - if(empty($combination_price_levels)){ + if (empty($combination_price_levels)){ /** * for auto retrocompatibility with last behavior @@ -171,10 +171,10 @@ class ProductCombination $productCombinationLevel->variation_price = $this->variation_price; $productCombinationLevel->variation_price_percentage = $this->variation_price_percentage; - if($fk_price_level>0){ + if ($fk_price_level>0){ $combination_price_levels[$fk_price_level] = $productCombinationLevel; } - else{ + else { for ($i = 1; $i <= $conf->global->PRODUIT_MULTIPRICES_LIMIT; $i++){ $combination_price_levels[$i] = $productCombinationLevel; } @@ -201,15 +201,15 @@ class ProductCombination $staticProductCombinationLevel = new ProductCombinationLevel($this->db); // Delete all - if(empty($this->combination_price_levels)){ + if (empty($this->combination_price_levels)){ return $staticProductCombinationLevel->deleteAllForCombination($this->id); } // Clean not needed price levels - if($clean){ + if ($clean){ $res = $staticProductCombinationLevel->clean($this->id); - if($res<0){ + if ($res<0){ $this->errors[] = 'Fail to clean not needed price levels'; return -1; } @@ -217,17 +217,17 @@ class ProductCombination foreach ($this->combination_price_levels as $fk_price_level => $combination_price_level){ $res = $combination_price_level->save(); - if($res<1){ + if ($res<1){ $this->error = 'save combination price level '.$fk_price_level . ' '.$combination_price_level->error; $this->errors[] = $this->error; $errors ++; } } - if($errors > 0){ + if ($errors > 0){ return $errors*-1; } - else{ + else { return 1; } } @@ -354,7 +354,7 @@ class ProductCombination if (!empty($conf->global->PRODUIT_MULTIPRICES)) { $res = $this->saveCombinationPriceLevels(); - if($res<0){ + if ($res<0){ return -2; } } @@ -388,7 +388,7 @@ class ProductCombination if (!empty($conf->global->PRODUIT_MULTIPRICES)) { $res = $this->saveCombinationPriceLevels(); - if($res<0){ + if ($res<0){ return -2; } } @@ -415,7 +415,7 @@ class ProductCombination $comb2val->deleteByFkCombination($this->id); // remove combination price levels - if(!$this->db->query("DELETE FROM ".MAIN_DB_PREFIX."product_attribute_combination_price_level WHERE fk_product_attribute_combination = ".(int) $this->id)) { + if (!$this->db->query("DELETE FROM ".MAIN_DB_PREFIX."product_attribute_combination_price_level WHERE fk_product_attribute_combination = ".(int) $this->id)) { $this->db->rollback(); return -1; } @@ -705,10 +705,10 @@ WHERE c.fk_product_parent = ".(int) $productid." AND p.tosell = 1"; $weight_impact = (float) $forced_weightvar; // If false, return 0 //Final price impact - if(!is_array($forced_pricevar)){ + if (!is_array($forced_pricevar)){ $price_impact[1] = (float) $forced_pricevar; // If false, return 0 } - else{ + else { $price_impact = $forced_pricevar; } @@ -755,7 +755,7 @@ WHERE c.fk_product_parent = ".(int) $productid." AND p.tosell = 1"; $price_impact[1] += (float) price2num($variations[$currcombattr][$currcombval]['price']); // Manage Price levels - if($conf->global->PRODUIT_MULTIPRICES){ + if ($conf->global->PRODUIT_MULTIPRICES){ for ($i = 2; $i <= $conf->global->PRODUIT_MULTIPRICES_LIMIT; $i++) { $price_impact[$i] += (float) price2num($variations[$currcombattr][$currcombval]['price']); @@ -783,16 +783,16 @@ WHERE c.fk_product_parent = ".(int) $productid." AND p.tosell = 1"; $newcomb->variation_weight = $weight_impact; // Init price level - if($conf->global->PRODUIT_MULTIPRICES){ + if ($conf->global->PRODUIT_MULTIPRICES){ for ($i = 1; $i <= $conf->global->PRODUIT_MULTIPRICES_LIMIT; $i++){ $productCombinationLevel = new ProductCombinationLevel($this->db); $productCombinationLevel->fk_product_attribute_combination = 0; $productCombinationLevel->fk_price_level = $i; $productCombinationLevel->variation_price = $price_impact[$i]; - if(is_array($price_var_percent)){ + if (is_array($price_var_percent)){ $productCombinationLevel->variation_price_percentage = !empty($price_var_percent[$i]) ? $price_var_percent[$i] : 0; - }else{ + }else { $productCombinationLevel->variation_price_percentage = $price_var_percent; } @@ -1023,11 +1023,11 @@ class ProductCombinationLevel */ public function fetch($rowid) { - $sql = "SELECT rowid, fk_product_attribute_combination, fk_price_level, variation_price, variation_price_percentage FROM " . MAIN_DB_PREFIX . $this->table_element." WHERE rowid = " . (int)$rowid; + $sql = "SELECT rowid, fk_product_attribute_combination, fk_price_level, variation_price, variation_price_percentage FROM " . MAIN_DB_PREFIX . $this->table_element." WHERE rowid = " . (int) $rowid; $obj = $this->db->getRow($sql); - if($obj){ + if ($obj){ return $this->fetchFormObj($obj); } @@ -1049,7 +1049,7 @@ class ProductCombinationLevel ." FROM ".MAIN_DB_PREFIX.$this->table_element ." WHERE fk_product_attribute_combination = ".intval($fk_product_attribute_combination); - if(!empty($fk_price_level)){ + if (!empty($fk_price_level)){ $sql.= ' AND fk_price_level = '.intval($fk_price_level); } @@ -1061,9 +1061,9 @@ class ProductCombinationLevel $result = array(); - if(!empty($combination_price_levels)) { + if (!empty($combination_price_levels)) { // For more simple usage set level as array key - foreach($combination_price_levels as $k => $row){ + foreach ($combination_price_levels as $k => $row){ $productCombinationLevel = new ProductCombinationLevel($this->db); $productCombinationLevel->fetchFormObj($row); $result[$row->fk_price_level] = $productCombinationLevel; @@ -1089,7 +1089,7 @@ class ProductCombinationLevel $this->fk_product_attribute_combination = doubleval($obj->fk_product_attribute_combination); $this->fk_price_level = intval($obj->fk_price_level); $this->variation_price = doubleval($obj->variation_price); - $this->variation_price_percentage = (bool)$obj->variation_price_percentage; + $this->variation_price_percentage = (bool) $obj->variation_price_percentage; return 1; } @@ -1105,41 +1105,41 @@ class ProductCombinationLevel $errors = 0; - if(empty($this->fk_product_attribute_combination) || empty($this->fk_price_level)){ + if (empty($this->fk_product_attribute_combination) || empty($this->fk_price_level)){ return -1; } // check if level exist in DB before add - if(empty($this->id)){ + if (empty($this->id)){ $sql = "SELECT rowid id" ." FROM ".MAIN_DB_PREFIX . $this->table_element ." WHERE fk_product_attribute_combination = ".(int) $this->fk_product_attribute_combination .' AND fk_price_level = '.intval($this->fk_price_level); $existObj = $this->db->getRow($sql); - if($existObj){ + if ($existObj){ $this->id = $existObj->id; } } // Update - if(!empty($this->id)) { + if (!empty($this->id)) { $sql = 'UPDATE ' . MAIN_DB_PREFIX . $this->table_element . ' SET ' . ' variation_price = '.doubleval($this->variation_price) . ' , variation_price_percentage = '.intval($this->variation_price_percentage) . ' WHERE rowid = '.intval($this->id); $res = $this->db->query($sql); - if($res>0){ + if ($res>0){ return $this->id; } - else{ + else { $this->error = $this->db->error(); $this->errors[] = $this->error; return -1; } } - else{ + else { // ADD $sql = "INSERT INTO " . MAIN_DB_PREFIX . $this->table_element . " (" . " fk_product_attribute_combination, fk_price_level, variation_price, variation_price_percentage" @@ -1151,10 +1151,10 @@ class ProductCombinationLevel . " )"; $res = $this->db->query($sql); - if($res){ + if ($res){ $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX . $this->table_element); } - else{ + else { $this->error = $this->db->error(); $this->errors[] = $this->error; return -1; @@ -1211,5 +1211,4 @@ class ProductCombinationLevel return $res ? 1 : -1; } - } From 88c07e86add27428ea6f919408e87baafb3620dd Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 13 Aug 2020 13:46:53 +0200 Subject: [PATCH 48/62] Organization of setup for Takepos bar features --- htdocs/core/lib/takepos.lib.php | 11 +- htdocs/langs/en_US/cashdesk.lang | 8 +- htdocs/takepos/admin/bar.php | 263 ++++++++++++++++--------------- htdocs/takepos/admin/receipt.php | 13 ++ htdocs/takepos/admin/setup.php | 16 -- 5 files changed, 160 insertions(+), 151 deletions(-) diff --git a/htdocs/core/lib/takepos.lib.php b/htdocs/core/lib/takepos.lib.php index 083e54c66c0..bf90f818b3e 100644 --- a/htdocs/core/lib/takepos.lib.php +++ b/htdocs/core/lib/takepos.lib.php @@ -48,13 +48,10 @@ function takepos_prepare_head() $head[$h][2] = 'receipt'; $h++; - if ($conf->global->TAKEPOS_BAR_RESTAURANT) - { - $head[$h][0] = DOL_URL_ROOT.'/takepos/admin/bar.php'; - $head[$h][1] = $langs->trans("BarRestaurant"); - $head[$h][2] = 'bar'; - $h++; - } + $head[$h][0] = DOL_URL_ROOT.'/takepos/admin/bar.php'; + $head[$h][1] = $langs->trans("BarRestaurant"); + $head[$h][2] = 'bar'; + $h++; $numterminals = max(1, $conf->global->TAKEPOS_NUM_TERMINALS); for ($i = 1; $i <= $numterminals; $i++) diff --git a/htdocs/langs/en_US/cashdesk.lang b/htdocs/langs/en_US/cashdesk.lang index 73d8bdaa0df..a96f919e4f4 100644 --- a/htdocs/langs/en_US/cashdesk.lang +++ b/htdocs/langs/en_US/cashdesk.lang @@ -77,7 +77,7 @@ POSModule=POS Module BasicPhoneLayout=Use basic layout for phones SetupOfTerminalNotComplete=Setup of terminal %s is not complete DirectPayment=Direct payment -DirectPaymentButton=Direct cash payment button +DirectPaymentButton=Add a "Direct cash payment" button InvoiceIsAlreadyValidated=Invoice is already validated NoLinesToBill=No lines to bill CustomReceipt=Custom Receipt @@ -94,12 +94,12 @@ TakeposConnectorMethodDescription=External module with extra features. Posibilit PrintMethod=Print method ReceiptPrinterMethodDescription=Powerful method with a lot of parameters. Full customizable with templates. Cannot print from the cloud. ByTerminal=By terminal -TakeposNumpadUsePaymentIcon=Use payment icon on numpad +TakeposNumpadUsePaymentIcon=Use icon instead of text on payment buttons of numpad CashDeskRefNumberingModules=Numbering module for POS sales CashDeskGenericMaskCodes6 =
{TN} tag is used to add the terminal number TakeposGroupSameProduct=Group same products lines StartAParallelSale=Start a new parallel sale -ControlCashOpening=Control cash box at opening pos +ControlCashOpening=Control cash box at opening POS CloseCashFence=Close cash fence CashReport=Cash report MainPrinterToUse=Main printer to use @@ -117,6 +117,6 @@ HideCategoryImages=Hide Category Images HideProductImages=Hide Product Images NumberOfLinesToShow=Number of lines of images to show DefineTablePlan=Define tables plan -GiftReceiptButton=Gift receipt button +GiftReceiptButton=Add a "Gift receipt" button GiftReceipt=Gift receipt ModuleReceiptPrinterMustBeEnabled=Module Receipt printer must have been enabled first diff --git a/htdocs/takepos/admin/bar.php b/htdocs/takepos/admin/bar.php index b6a06dee9fb..2ec623024c7 100644 --- a/htdocs/takepos/admin/bar.php +++ b/htdocs/takepos/admin/bar.php @@ -34,7 +34,8 @@ if (!$user->admin) accessforbidden(); $langs->loadLangs(array("admin", "cashdesk", "printing")); -global $db; +$res = 0; + /* * Actions @@ -44,9 +45,15 @@ if (GETPOST('action', 'alpha') == 'set') { $db->begin(); - dol_syslog("admin/cashdesk: level ".GETPOST('level', 'alpha')); + dol_syslog("admin/bar"); - if (!$res > 0) $error++; + $suplement_category = GETPOST('TAKEPOS_SUPPLEMENTS_CATEGORY', 'alpha'); + if ($suplement_category < 0) $suplement_category= 0; + + $res = dolibarr_set_const($db, "TAKEPOS_SUPPLEMENTS_CATEGORY", $suplement_category, 'chaine', 0, '', $conf->entity); + if ($res <= 0) { + $error++; + } if (!$error) { @@ -74,7 +81,6 @@ $linkback = ''.$langs->trans("BackT print load_fiche_titre($langs->trans("CashDeskSetup").' (TakePOS)', $linkback, 'title_setup'); $head = takepos_prepare_head(); dol_fiche_head($head, 'bar', 'TakePOS', -1, 'cash-register'); -print '
'; // Mode @@ -93,129 +99,138 @@ function Floors() { '.$langs->trans("DefineTablePlan").'

'; -print '

'; - -print '
'; -print ''; -print ''; -print ''; -print "\n"; - -if ($conf->global->TAKEPOS_BAR_RESTAURANT && $conf->global->TAKEPOS_PRINT_METHOD != "browser") { - print ''; - print ''; - - print ''; - print ''; -} - -print ''; -print ''; - -print ''; -print ''; - -if ($conf->global->TAKEPOS_SUPPLEMENTS) -{ - print ''; - print '\n"; -} - -print ''; -print ''; - -print ''; -print ''; - -print '
'.$langs->trans("Parameters").''.$langs->trans("Value").'
'; - print $langs->trans("OrderPrinters").' ('.$langs->trans("Setup").')'; - print ''; - print ajax_constantonoff("TAKEPOS_ORDER_PRINTERS", array(), $conf->entity, 0, 0, 1, 0); - //print $form->selectyesno("TAKEPOS_ORDER_PRINTERS", $conf->global->TAKEPOS_ORDER_PRINTERS, 1); - print '
'; - print $langs->trans("OrderNotes"); - print ''; - print ajax_constantonoff("TAKEPOS_ORDER_NOTES", array(), $conf->entity, 0, 0, 1, 0); - //print $form->selectyesno("TAKEPOS_ORDER_NOTES", $conf->global->TAKEPOS_ORDER_NOTES, 1); - print '
'; -print $langs->trans("BasicPhoneLayout"); -print ''; -//print $form->selectyesno("TAKEPOS_PHONE_BASIC_LAYOUT", $conf->global->TAKEPOS_PHONE_BASIC_LAYOUT, 1); -print ajax_constantonoff("TAKEPOS_PHONE_BASIC_LAYOUT", array(), $conf->entity, 0, 0, 1, 0); -print '
'; -print $langs->trans("ProductSupplements"); -print ''; -//print $form->selectyesno("TAKEPOS_SUPPLEMENTS", $conf->global->TAKEPOS_SUPPLEMENTS, 1); -print ajax_constantonoff("TAKEPOS_SUPPLEMENTS", array(), $conf->entity, 0, 0, 1, 0); -print '
'; - print $langs->trans("SupplementCategory"); - print ''; - print $form->select_all_categories(Categorie::TYPE_PRODUCT, $conf->global->TAKEPOS_SUPPLEMENTS_CATEGORY, 'TAKEPOS_SUPPLEMENTS_CATEGORY', 64, 0, 0); - print ajax_combobox('TAKEPOS_SUPPLEMENTS_CATEGORY'); - print "
'; -print 'QR - '.$langs->trans("CustomerMenu"); -print ''; -print ajax_constantonoff("TAKEPOS_QR_MENU", array(), $conf->entity, 0, 0, 1, 0); -print '
'; -print 'QR - '.$langs->trans("AutoOrder"); -print ''; -print ajax_constantonoff("TAKEPOS_AUTO_ORDER", array(), $conf->entity, 0, 0, 1, 0); -print '
'; - - -if ($conf->global->TAKEPOS_QR_MENU) -{ - $urlwithouturlroot = preg_replace('/'.preg_quote(DOL_URL_ROOT, '/').'$/i', '', trim($dolibarr_main_url_root)); - $urlwithroot = $urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file - print '
'; - print ''; - print ''; - print ''; - print "\n"; - print ''; - print ''; - print '
'.$langs->trans("URL").''.$langs->trans("QR").'
'; - print "".$urlwithroot."/takepos/public/menu.php"; - print ''; - print ""; - print '
'; -} - -if ($conf->global->TAKEPOS_AUTO_ORDER) -{ - print '
'; - print ''; - print ''; - print ''; - print "\n"; - - //global $dolibarr_main_url_root; - $urlwithouturlroot = preg_replace('/'.preg_quote(DOL_URL_ROOT, '/').'$/i', '', trim($dolibarr_main_url_root)); - $urlwithroot = $urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file - $sql = "SELECT rowid, entity, label, leftpos, toppos, floor FROM ".MAIN_DB_PREFIX."takepos_floor_tables"; - $resql = $db->query($sql); - $rows = array(); - while ($row = $db->fetch_array($resql)) { - print ''; - print ''; - print ''; - } - - print '
'.$langs->trans("Table").''.$langs->trans("URL").''.$langs->trans("QR").'
'; - print $langs->trans("Table")." ".$row['label']; - print ''; - print "".$urlwithroot."/takepos/public/auto_order.php?key=".dol_encode($row['rowid']).""; - print ''; - print ""; - print '
'; -} - -print '
'; +print $langs->trans("EnableBarOrRestaurantFeatures"); +print ajax_constantonoff("TAKEPOS_BAR_RESTAURANT", array(), $conf->entity, 0, 0, 1, 0); print '
'; -print '
'; +if ($conf->global->TAKEPOS_BAR_RESTAURANT) { + print '
'; + print ' '.$langs->trans("DefineTablePlan").'
'; + print '

'; + + print '
'; + print ''; + print ''; + print ''; + print "\n"; + + if ($conf->global->TAKEPOS_PRINT_METHOD != "browser") { + print ''; + print ''; + + print ''; + print ''; + } + + print ''; + print ''; + + print ''; + print ''; + + if ($conf->global->TAKEPOS_SUPPLEMENTS) + { + print ''; + print '\n"; + } + + print ''; + print ''; + + print ''; + print ''; + + print '
'.$langs->trans("Parameters").''.$langs->trans("Value").'
'; + print $langs->trans("OrderPrinters").' ('.$langs->trans("Setup").')'; + print ''; + print ajax_constantonoff("TAKEPOS_ORDER_PRINTERS", array(), $conf->entity, 0, 0, 1, 0); + //print $form->selectyesno("TAKEPOS_ORDER_PRINTERS", $conf->global->TAKEPOS_ORDER_PRINTERS, 1); + print '
'; + print $langs->trans("OrderNotes"); + print ''; + print ajax_constantonoff("TAKEPOS_ORDER_NOTES", array(), $conf->entity, 0, 0, 1, 0); + //print $form->selectyesno("TAKEPOS_ORDER_NOTES", $conf->global->TAKEPOS_ORDER_NOTES, 1); + print '
'; + print $langs->trans("BasicPhoneLayout"); + print ''; + //print $form->selectyesno("TAKEPOS_PHONE_BASIC_LAYOUT", $conf->global->TAKEPOS_PHONE_BASIC_LAYOUT, 1); + print ajax_constantonoff("TAKEPOS_PHONE_BASIC_LAYOUT", array(), $conf->entity, 0, 0, 1, 0); + print '
'; + print $langs->trans("ProductSupplements"); + print ''; + //print $form->selectyesno("TAKEPOS_SUPPLEMENTS", $conf->global->TAKEPOS_SUPPLEMENTS, 1); + print ajax_constantonoff("TAKEPOS_SUPPLEMENTS", array(), $conf->entity, 0, 0, 1, 0); + print '
'; + print $langs->trans("SupplementCategory"); + print ''; + print $form->select_all_categories(Categorie::TYPE_PRODUCT, $conf->global->TAKEPOS_SUPPLEMENTS_CATEGORY, 'TAKEPOS_SUPPLEMENTS_CATEGORY', 64, 0, 0); + print ajax_combobox('TAKEPOS_SUPPLEMENTS_CATEGORY'); + print "
'; + print 'QR - '.$langs->trans("CustomerMenu"); + print ''; + print ajax_constantonoff("TAKEPOS_QR_MENU", array(), $conf->entity, 0, 0, 1, 0); + print '
'; + print 'QR - '.$langs->trans("AutoOrder"); + print ''; + print ajax_constantonoff("TAKEPOS_AUTO_ORDER", array(), $conf->entity, 0, 0, 1, 0); + print '
'; + print '
'; + + print '
'; + + print '
'; +} + +if ($conf->global->TAKEPOS_BAR_RESTAURANT) { + if ($conf->global->TAKEPOS_QR_MENU) + { + $urlwithouturlroot = preg_replace('/'.preg_quote(DOL_URL_ROOT, '/').'$/i', '', trim($dolibarr_main_url_root)); + $urlwithroot = $urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file + print '
'; + print ''; + print ''; + print ''; + print "\n"; + print ''; + print ''; + print '
'.$langs->trans("URL").''.$langs->trans("QR").'
'; + print "".$urlwithroot."/takepos/public/menu.php"; + print ''; + print ""; + print '
'; + } + + if ($conf->global->TAKEPOS_AUTO_ORDER) + { + print '
'; + print ''; + print ''; + print ''; + print "\n"; + + //global $dolibarr_main_url_root; + $urlwithouturlroot = preg_replace('/'.preg_quote(DOL_URL_ROOT, '/').'$/i', '', trim($dolibarr_main_url_root)); + $urlwithroot = $urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file + $sql = "SELECT rowid, entity, label, leftpos, toppos, floor FROM ".MAIN_DB_PREFIX."takepos_floor_tables"; + $resql = $db->query($sql); + $rows = array(); + while ($row = $db->fetch_array($resql)) { + print ''; + print ''; + print ''; + } + + print '
'.$langs->trans("Table").''.$langs->trans("URL").''.$langs->trans("QR").'
'; + print $langs->trans("Table")." ".$row['label']; + print ''; + print "".$urlwithroot."/takepos/public/auto_order.php?key=".dol_encode($row['rowid']).""; + print ''; + print ""; + print '
'; + } +} + print "\n"; diff --git a/htdocs/takepos/admin/receipt.php b/htdocs/takepos/admin/receipt.php index 59e0f3da96c..252781ec635 100644 --- a/htdocs/takepos/admin/receipt.php +++ b/htdocs/takepos/admin/receipt.php @@ -87,6 +87,7 @@ print ''; print load_fiche_titre($langs->trans("PrintMethod"), '', ''); +print '
'; print ''; print ''; print ''; @@ -143,14 +144,25 @@ if ($conf->global->TAKEPOS_PRINT_METHOD == "takeposconnector") } print "\n"; print '
'.$langs->trans("Name").''.$langs->trans("Description").''.$langs->trans("Status").'
'; +print '
'; + print load_fiche_titre($langs->trans("Setup"), '', ''); +print '
'; print ''; print ''; print ''; print "\n"; +// VAT Grouped on ticket +print '\n"; + if ($conf->global->TAKEPOS_PRINT_METHOD == "takeposconnector") { print '\n"; print '
'.$langs->trans("Parameters").''.$langs->trans("Value").'
'; +print $langs->trans('TicketVatGrouped'); +print ''; +print ajax_constantonoff("TAKEPOS_TICKET_VAT_GROUPPED", array(), $conf->entity, 0, 0, 1, 0); +//print $form->selectyesno("TAKEPOS_TICKET_VAT_GROUPPED", $conf->global->TAKEPOS_TICKET_VAT_GROUPPED, 1); +print "
'; print $langs->trans("URL")." / ".$langs->trans("IPAddress").' ('.$langs->trans("TakeposConnectorNecesary").')'; @@ -214,6 +226,7 @@ print $form->selectyesno("TAKEPOS_AUTO_PRINT_TICKETS", $conf->global->TAKEPOS_AU print "
'; +print '
'; print '
'; diff --git a/htdocs/takepos/admin/setup.php b/htdocs/takepos/admin/setup.php index 22355c70d9d..ab3b200df35 100644 --- a/htdocs/takepos/admin/setup.php +++ b/htdocs/takepos/admin/setup.php @@ -274,14 +274,6 @@ print img_object('', 'category', 'class="paddingright"').$form->select_all_categ print ajax_combobox('TAKEPOS_ROOT_CATEGORY_ID'); print "\n"; -// VAT Grouped on ticket -print ''; -print $langs->trans('TicketVatGrouped'); -print ''; -print ajax_constantonoff("TAKEPOS_TICKET_VAT_GROUPPED", array(), $conf->entity, 0, 0, 1, 0); -//print $form->selectyesno("TAKEPOS_TICKET_VAT_GROUPPED", $conf->global->TAKEPOS_TICKET_VAT_GROUPPED, 1); -print "\n"; - // Sort product print ''; print $langs->trans("SortProductField"); @@ -429,14 +421,6 @@ print "\n"; //print $form->selectarray('TAKEPOS_ADDON', $array, (empty($conf->global->TAKEPOS_ADDON) ? '0' : $conf->global->TAKEPOS_ADDON), 0); //print "\n"; -print ''; -print $langs->trans("EnableBarOrRestaurantFeatures"); -print ''; -print ''; -print ajax_constantonoff("TAKEPOS_BAR_RESTAURANT", array(), $conf->entity, 0, 0, 1, 0); -//print $form->selectyesno("TAKEPOS_BAR_RESTAURANT", $conf->global->TAKEPOS_BAR_RESTAURANT, 1); -print "\n"; - print ''; print '
'; From 7ce1d36b59423d44d2ca05ddfb31755db283cf5d Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 13 Aug 2020 13:51:08 +0200 Subject: [PATCH 49/62] FIX Category for suplements not saved --- htdocs/takepos/admin/bar.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/htdocs/takepos/admin/bar.php b/htdocs/takepos/admin/bar.php index b6a06dee9fb..c9e53a86664 100644 --- a/htdocs/takepos/admin/bar.php +++ b/htdocs/takepos/admin/bar.php @@ -44,9 +44,15 @@ if (GETPOST('action', 'alpha') == 'set') { $db->begin(); - dol_syslog("admin/cashdesk: level ".GETPOST('level', 'alpha')); + dol_syslog("admin/bar"); - if (!$res > 0) $error++; + $suplement_category = GETPOST('TAKEPOS_SUPPLEMENTS_CATEGORY', 'alpha'); + if ($suplement_category < 0) $suplement_category= 0; + + $res = dolibarr_set_const($db, "TAKEPOS_SUPPLEMENTS_CATEGORY", $suplement_category, 'chaine', 0, '', $conf->entity); + if ($res <= 0) { + $error++; + } if (!$error) { From 990217fcb00b5354c9853b79fe9254094231b019 Mon Sep 17 00:00:00 2001 From: Adrien Raze Date: Thu, 13 Aug 2020 16:59:27 +0200 Subject: [PATCH 50/62] FIX : task leftmenu --- htdocs/core/menus/standard/eldy.lib.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/htdocs/core/menus/standard/eldy.lib.php b/htdocs/core/menus/standard/eldy.lib.php index f6d8aa401a5..78d3d8d91b8 100644 --- a/htdocs/core/menus/standard/eldy.lib.php +++ b/htdocs/core/menus/standard/eldy.lib.php @@ -531,6 +531,7 @@ function print_eldy_menu($db, $atarget, $type_user, &$tabMenu, &$menu, $noout = } if (empty($noout)) { + foreach ($menu->liste as $menuval) { print_start_menu_entry($menuval['idsel'], $menuval['classname'], $menuval['enabled']); print_text_menu_entry($menuval['titre'], $menuval['enabled'], (($menuval['url'] != '#' && !preg_match('/^(http:\/\/|https:\/\/)/i', $menuval['url'])) ? DOL_URL_ROOT:'').$menuval['url'], $menuval['id'], $menuval['idsel'], $menuval['classname'], ($menuval['target'] ? $menuval['target'] : $atarget)); @@ -540,6 +541,7 @@ function print_eldy_menu($db, $atarget, $type_user, &$tabMenu, &$menu, $noout = $showmode = 1; if (empty($noout)) { + print_start_menu_entry('', 'class="tmenuend"', $showmode); print_end_menu_entry($showmode); print_end_menu_array(); @@ -1706,7 +1708,7 @@ function print_left_eldy_menu($db, $menu_array_before, $menu_array_after, &$tabM if (empty($conf->global->PROJECT_HIDE_TASKS)) { // Project affected to user - $newmenu->add("/projet/activity/index.php?leftmenu=tasks".($search_project_user ? '&search_project_user='.$search_project_user : ''), $langs->trans("Activities"), 0, $user->rights->projet->lire); + $newmenu->add("/projet/activity/index.php?leftmenu=tasks".($search_project_user ? '&search_project_user='.$search_project_user : ''), $langs->trans("Activities"), 0, $user->rights->projet->lire, '', 'project', 'tasks'); $newmenu->add("/projet/tasks.php?leftmenu=tasks&action=create", $langs->trans("NewTask"), 1, $user->rights->projet->creer); $newmenu->add("/projet/tasks/list.php?leftmenu=tasks".($search_project_user ? '&search_project_user='.$search_project_user : ''), $langs->trans("List"), 1, $user->rights->projet->lire); $newmenu->add("/projet/tasks/stats/index.php?leftmenu=projects", $langs->trans("Statistics"), 1, $user->rights->projet->lire); From d784c621c99d64c600309c84da3cada8c9d8e46e Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Thu, 13 Aug 2020 15:07:06 +0000 Subject: [PATCH 51/62] Fixing style errors. --- htdocs/core/menus/standard/eldy.lib.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/htdocs/core/menus/standard/eldy.lib.php b/htdocs/core/menus/standard/eldy.lib.php index 78d3d8d91b8..ca7220037a5 100644 --- a/htdocs/core/menus/standard/eldy.lib.php +++ b/htdocs/core/menus/standard/eldy.lib.php @@ -531,7 +531,6 @@ function print_eldy_menu($db, $atarget, $type_user, &$tabMenu, &$menu, $noout = } if (empty($noout)) { - foreach ($menu->liste as $menuval) { print_start_menu_entry($menuval['idsel'], $menuval['classname'], $menuval['enabled']); print_text_menu_entry($menuval['titre'], $menuval['enabled'], (($menuval['url'] != '#' && !preg_match('/^(http:\/\/|https:\/\/)/i', $menuval['url'])) ? DOL_URL_ROOT:'').$menuval['url'], $menuval['id'], $menuval['idsel'], $menuval['classname'], ($menuval['target'] ? $menuval['target'] : $atarget)); @@ -541,7 +540,6 @@ function print_eldy_menu($db, $atarget, $type_user, &$tabMenu, &$menu, $noout = $showmode = 1; if (empty($noout)) { - print_start_menu_entry('', 'class="tmenuend"', $showmode); print_end_menu_entry($showmode); print_end_menu_array(); From b57c2585ad5337d4e8289f14cbde808866fa7b60 Mon Sep 17 00:00:00 2001 From: Tim Otte Date: Fri, 14 Aug 2020 10:00:40 +0200 Subject: [PATCH 52/62] Fixed the smtps recipent to use the forced address --- htdocs/core/class/CMailFile.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/class/CMailFile.class.php b/htdocs/core/class/CMailFile.class.php index 48a2b503eca..79791854a8f 100644 --- a/htdocs/core/class/CMailFile.class.php +++ b/htdocs/core/class/CMailFile.class.php @@ -355,7 +355,7 @@ class CMailFile } $smtps->setSubject($subjecttouse); - $smtps->setTO($this->getValidAddress($this->to, 0, 1)); + $smtps->setTO($this->getValidAddress($this->addr_to, 0, 1)); $smtps->setFrom($this->getValidAddress($this->from, 0, 1)); $smtps->setTrackId($this->trackid); $smtps->setReplyTo($this->getValidAddress($this->replyto, 0, 1)); From d35c7ed49b6322053e8abd3ddf8a64e5260fd86e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 14 Aug 2020 11:03:12 +0200 Subject: [PATCH 53/62] Fix trans --- htdocs/langs/en_US/main.lang | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/langs/en_US/main.lang b/htdocs/langs/en_US/main.lang index 051dde11ff7..e7c35f6d9f7 100644 --- a/htdocs/langs/en_US/main.lang +++ b/htdocs/langs/en_US/main.lang @@ -353,8 +353,8 @@ PriceUTTC=U.P. (inc. tax) Amount=Amount AmountInvoice=Invoice amount AmountInvoiced=Amount invoiced -AmountInvoicedHT=Amount invoiced (incl. tax) -AmountInvoicedTTC=Amount invoiced (excl. tax) +AmountInvoicedHT=Amount invoiced (excl. tax) +AmountInvoicedTTC=Amount invoiced (inc. tax) AmountPayment=Payment amount AmountHTShort=Amount (excl.) AmountTTCShort=Amount (inc. tax) From d8c6e17efd0159f1595ccef86fd82aed1524875c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 14 Aug 2020 11:59:51 +0200 Subject: [PATCH 54/62] Fix travis --- htdocs/core/tpl/objectline_create.tpl.php | 8 ++++---- htdocs/product/stock/list.php | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/htdocs/core/tpl/objectline_create.tpl.php b/htdocs/core/tpl/objectline_create.tpl.php index 305be25347d..42c5ea0d2a9 100644 --- a/htdocs/core/tpl/objectline_create.tpl.php +++ b/htdocs/core/tpl/objectline_create.tpl.php @@ -426,9 +426,9 @@ if ((!empty($conf->service->enabled) || ($object->element == 'contrat')) && $dat $prefillDates = false; - if(! empty($conf->global->MAIN_FILL_SERVICE_DATES_FROM_LAST_SERVICE_LINE) && ! empty($object->lines)) + if (!empty($conf->global->MAIN_FILL_SERVICE_DATES_FROM_LAST_SERVICE_LINE) && ! empty($object->lines)) { - for($i = count($object->lines) - 1; $i >= 0; $i--) + for ($i = count($object->lines) - 1; $i >= 0; $i--) { $lastline = $object->lines[$i]; @@ -457,14 +457,14 @@ if ((!empty($conf->service->enabled) || ($object->element == 'contrat')) && $dat print $form->selectDate($date_end, 'date_end', empty($conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE) ? 0 : 1, empty($conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE) ? 0 : 1, 1, "addproduct", 1, 0); }; - if($prefillDates) + if ($prefillDates) { echo ' ' . $langs->trans('FillWithLastServiceDates') . ''; } print ' - +
global->MAIN_AUTO_OPEN_SELECT2_ON_FOCUS_FOR_CUSTOMER_PRODUCTS)) { ?> - - + google->enabled) && !empty($conf->global->MAIN_GOOGLE_AD_CLIEN if (empty($conf->dol_use_jmobile)) { print '
'."\n"; - print ''."\n"; - print ''."\n"; + print ''."\n"; print '
'."\n"; } else { print ''."\n"; From 99809b487e042ac55d5e8159a2fabc1b8ecdd02f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 16 Aug 2020 23:33:50 +0200 Subject: [PATCH 61/62] Standardize code --- htdocs/accountancy/admin/fiscalyear.php | 9 ++- htdocs/core/class/fiscalyear.class.php | 75 +++++++++++++++++++++++++ 2 files changed, 81 insertions(+), 3 deletions(-) diff --git a/htdocs/accountancy/admin/fiscalyear.php b/htdocs/accountancy/admin/fiscalyear.php index b5cc46a3d0d..89aad6e2d0d 100644 --- a/htdocs/accountancy/admin/fiscalyear.php +++ b/htdocs/accountancy/admin/fiscalyear.php @@ -79,6 +79,7 @@ $object = new Fiscalyear($db); $max = 100; $form = new Form($db); +$fiscalyearstatic = new Fiscalyear($db); $title = $langs->trans('AccountingPeriods'); $helpurl = ""; @@ -132,13 +133,15 @@ if ($result) print ''; if ($num) { - $fiscalyearstatic = new Fiscalyear($db); - while ($i < $num && $i < $max) { $obj = $db->fetch_object($result); + $fiscalyearstatic->id = $obj->rowid; + print ''; - print ''.img_object($langs->trans("ShowFiscalYear"), "technic").' '.$obj->rowid.''; + print ''; + print $fiscalyearstatic->getNomUrl(1); + print ''; print ''.$obj->label.''; print ''.dol_print_date($db->jdate($obj->date_start), 'day').''; print ''.dol_print_date($db->jdate($obj->date_end), 'day').''; diff --git a/htdocs/core/class/fiscalyear.class.php b/htdocs/core/class/fiscalyear.class.php index 0686b68115a..c0216f16a19 100644 --- a/htdocs/core/class/fiscalyear.class.php +++ b/htdocs/core/class/fiscalyear.class.php @@ -35,6 +35,8 @@ class Fiscalyear extends CommonObject */ public $element = 'fiscalyear'; + public $picto = 'technic'; + /** * @var string Name of table without prefix where object is stored */ @@ -97,6 +99,7 @@ class Fiscalyear extends CommonObject public $statuts = array(); public $statuts_short = array(); + /** * Constructor * @@ -267,6 +270,78 @@ class Fiscalyear extends CommonObject } } + /** + * Return clicable link of object (with eventually picto) + * + * @param int $withpicto Add picto into link + * @param int $notooltip 1=Disable tooltip + * @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking + * @return string String with URL + */ + public function getNomUrl($withpicto = 0, $notooltip = 0, $save_lastsearch_value = -1) + { + global $conf, $langs, $user; + + if (empty($this->ref)) $this->ref = $this->id; + + if (!empty($conf->dol_no_mouse_hover)) $notooltip = 1; // Force disable tooltips + + $result = ''; + + $url = DOL_URL_ROOT.'/accountancy/admin/fiscalyear_card.php?id='.$this->id; + + if (!$user->rights->accounting->fiscalyear->write) + $option = 'nolink'; + + if ($option !== 'nolink') + { + // Add param to save lastsearch_values or not + $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0); + if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) $add_save_lastsearch_values = 1; + if ($add_save_lastsearch_values) $url .= '&save_lastsearch_values=1'; + } + + if ($short) return $url; + + $label = ''; + + if ($user->rights->accounting->fiscalyear->write) { + $label = ''.$langs->trans("FiscalPeriod").''; + $label .= '
'.$langs->trans('Ref').': '.$this->id; + if (isset($this->statut)) { + $label .= '
'.$langs->trans("Status").": ".$this->getLibStatut(5); + } + } + + $linkclose = ''; + if (empty($notooltip) && $user->rights->accounting->fiscalyear->write) + { + if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) + { + $label = $langs->trans("FiscalYear"); + $linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"'; + } + $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"'; + $linkclose .= ' class="classfortooltip"'; + } + + $linkstart = ''; + $linkend = ''; + + if ($option === 'nolink') { + $linkstart = ''; + $linkend = ''; + } + + $result .= $linkstart; + if ($withpicto) $result .= img_object(($notooltip ? '' : $label), $this->picto, ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1); + if ($withpicto != 2) $result .= $this->ref; + $result .= $linkend; + + return $result; + } + /** * Give a label from a status * From d2db1a3557ac221f5d5d5b0f824334934fd32d10 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 16 Aug 2020 23:38:19 +0200 Subject: [PATCH 62/62] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index d15808d2cac..17d56c6ec62 100644 --- a/README.md +++ b/README.md @@ -142,7 +142,7 @@ See the [ChangeLog](https://github.com/Dolibarr/dolibarr/blob/develop/ChangeLog) - customizable Dashboard - Highly customizable: enable only the modules you need, add user personalized fields, choose your skin, several menu managers (can be used by internal users as a back-office with a particular menu, or by external users as a front-office with another one) -- SOAP & REST APIs +- APIs - Code that is easy to understand, maintain and develop (PHP with no heavy framework; trigger and hook architecture) - Support a lot of country specific features: - Spanish Tax RE and ISPF