From ce920364343934be1662602ca8a252711e486a32 Mon Sep 17 00:00:00 2001 From: Abbes Bahfir Date: Thu, 20 Jun 2019 23:13:46 +0100 Subject: [PATCH 001/312] new:Show object photos in modulebuilder lists with a constant to format output as user list photos --- .../template/class/myobject.class.php | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/htdocs/modulebuilder/template/class/myobject.class.php b/htdocs/modulebuilder/template/class/myobject.class.php index 1b4d1c7b52d..3acc7c649f4 100644 --- a/htdocs/modulebuilder/template/class/myobject.class.php +++ b/htdocs/modulebuilder/template/class/myobject.class.php @@ -548,7 +548,23 @@ class MyObject extends CommonObject $linkend=''; $result .= $linkstart; - if ($withpicto) $result.=img_object(($notooltip?'':$label), ($this->picto?$this->picto:'generic'), ($notooltip?(($withpicto != 2) ? 'class="paddingright"' : ''):'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip?0:1); + + list($class, $module) = explode('@', $this->picto); + $upload_dir = $conf->$module->multidir_output[$conf->entity] . "/$class/" . dol_sanitizeFileName($this->ref); + $filearray = dol_dir_list($upload_dir, "files"); + $filename = $filearray[0]['name']; + if(!empty($filename)){ + $pospoint = strpos($filearray[0]['name'], '.'); + + $pathtophoto = $class . '/' . $this->ref . '/thumbs/' . substr($filename, 0, $pospoint) . '_mini' . substr($filename, $pospoint); + if(empty($conf->global->{strtoupper($module).'_FORMATLISTPHOTOSASUSERS'})) + $result .= '
No photo
'; + else $result .= '
No photo
'; + + + $result .= ''; + } + elseif ($withpicto) $result.=img_object(($notooltip?'':$label), ($this->picto?$this->picto:'generic'), ($notooltip?(($withpicto != 2) ? 'class="paddingright"' : ''):'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip?0:1); if ($withpicto != 2) $result.= $this->ref; $result .= $linkend; //if ($withpicto != 2) $result.=(($addlabel && $this->label) ? $sep . dol_trunc($this->label, ($addlabel > 1 ? $addlabel : 0)) : ''); From 78e44ef0774d6769d0c089d0bff9512ac50d0e94 Mon Sep 17 00:00:00 2001 From: Bahfir Abbes Date: Thu, 20 Jun 2019 23:35:35 +0100 Subject: [PATCH 002/312] Update myobject.class.php --- htdocs/modulebuilder/template/class/myobject.class.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/modulebuilder/template/class/myobject.class.php b/htdocs/modulebuilder/template/class/myobject.class.php index 3acc7c649f4..52335984ac8 100644 --- a/htdocs/modulebuilder/template/class/myobject.class.php +++ b/htdocs/modulebuilder/template/class/myobject.class.php @@ -24,6 +24,7 @@ // Put here all includes required by your class file require_once DOL_DOCUMENT_ROOT . '/core/class/commonobject.class.php'; +require_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php'; //require_once DOL_DOCUMENT_ROOT . '/societe/class/societe.class.php'; //require_once DOL_DOCUMENT_ROOT . '/product/class/product.class.php'; From 79f6ec6facb370f762c1db3b846b38c4dd830b52 Mon Sep 17 00:00:00 2001 From: Bahfir Abbes Date: Fri, 21 Jun 2019 17:12:58 +0100 Subject: [PATCH 003/312] extend constant to objects into modules --- htdocs/modulebuilder/template/class/myobject.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/modulebuilder/template/class/myobject.class.php b/htdocs/modulebuilder/template/class/myobject.class.php index 52335984ac8..7caea9700f7 100644 --- a/htdocs/modulebuilder/template/class/myobject.class.php +++ b/htdocs/modulebuilder/template/class/myobject.class.php @@ -534,7 +534,7 @@ class MyObject extends CommonObject } $linkclose.=' title="'.dol_escape_htmltag($label, 1).'"'; $linkclose.=' class="classfortooltip'.($morecss?' '.$morecss:'').'"'; - +.'_'.$class /* $hookmanager->initHooks(array('myobjectdao')); $parameters=array('id'=>$this->id); @@ -558,7 +558,7 @@ class MyObject extends CommonObject $pospoint = strpos($filearray[0]['name'], '.'); $pathtophoto = $class . '/' . $this->ref . '/thumbs/' . substr($filename, 0, $pospoint) . '_mini' . substr($filename, $pospoint); - if(empty($conf->global->{strtoupper($module).'_FORMATLISTPHOTOSASUSERS'})) + if(empty($conf->global->{strtoupper($module.'_'.$class).'_FORMATLISTPHOTOSASUSERS'})) $result .= '
No photo
'; else $result .= '
No photo
'; From d949447670d420c123267b36a089380e423fbeda Mon Sep 17 00:00:00 2001 From: Bahfir Abbes Date: Fri, 21 Jun 2019 17:18:51 +0100 Subject: [PATCH 004/312] Update myobject.class.php --- htdocs/modulebuilder/template/class/myobject.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/modulebuilder/template/class/myobject.class.php b/htdocs/modulebuilder/template/class/myobject.class.php index 7caea9700f7..0ac92cba065 100644 --- a/htdocs/modulebuilder/template/class/myobject.class.php +++ b/htdocs/modulebuilder/template/class/myobject.class.php @@ -534,7 +534,7 @@ class MyObject extends CommonObject } $linkclose.=' title="'.dol_escape_htmltag($label, 1).'"'; $linkclose.=' class="classfortooltip'.($morecss?' '.$morecss:'').'"'; -.'_'.$class + /* $hookmanager->initHooks(array('myobjectdao')); $parameters=array('id'=>$this->id); From 3aef39c64d720520774a744b99c76f0eed7ad3c5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric?= <35066297+c3do@users.noreply.github.com> Date: Sat, 23 Nov 2019 13:45:58 +0100 Subject: [PATCH 005/312] New can customize the reference of a combination --- .../class/ProductCombination.class.php | 20 +++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/htdocs/variants/class/ProductCombination.class.php b/htdocs/variants/class/ProductCombination.class.php index 1c09aae62df..6dfa1bf94c5 100644 --- a/htdocs/variants/class/ProductCombination.class.php +++ b/htdocs/variants/class/ProductCombination.class.php @@ -502,9 +502,10 @@ WHERE c.fk_product_parent = ".(int) $productid." AND p.tosell = 1"; * @param bool $price_var_percent Is the price variation a relative variation? * @param bool|float $forced_pricevar If the price variation is forced * @param bool|float $forced_weightvar If the weight variation is forced + * @param bool|string $forced_refvar If the reference is forced * @return int <0 KO, >0 OK */ - public function createProductCombination(User $user, Product $product, array $combinations, array $variations, $price_var_percent = false, $forced_pricevar = false, $forced_weightvar = false) + public function createProductCombination(User $user, Product $product, array $combinations, array $variations, $price_var_percent = false, $forced_pricevar = false, $forced_weightvar = false, $forced_refvar = false) { global $db, $conf; @@ -528,7 +529,11 @@ WHERE c.fk_product_parent = ".(int) $productid." AND p.tosell = 1"; if ($forced_pricevar === false) { $price_impact = 0; } - + + if ($forced_refvar !== false) { + $forced_refvar = trim($forced_refvar); + } + $newcomb = new ProductCombination($db); $existingCombination = $newcomb->fetchByProductCombination2ValuePairs($product->id, $combinations); @@ -572,11 +577,14 @@ WHERE c.fk_product_parent = ".(int) $productid." AND p.tosell = 1"; if ($forced_pricevar === false) { $price_impact += (float) price2num($variations[$currcombattr][$currcombval]['price']); } - - if (isset($conf->global->PRODUIT_ATTRIBUTES_SEPARATOR)) { - $newproduct->ref .= $conf->global->PRODUIT_ATTRIBUTES_SEPARATOR . $prodattrval->ref; + if (empty($forced_refvar)) { + if (isset($conf->global->PRODUIT_ATTRIBUTES_SEPARATOR)) { + $newproduct->ref .= $conf->global->PRODUIT_ATTRIBUTES_SEPARATOR . $prodattrval->ref; + } else { + $newproduct->ref .= '_'.$prodattrval->ref; + } } else { - $newproduct->ref .= '_'.$prodattrval->ref; + $newproduct->ref = $forced_refvar; } //The first one should not contain a linebreak From 76fd79455901f684b9d4511612075d5a7c561be0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric?= <35066297+c3do@users.noreply.github.com> Date: Sat, 23 Nov 2019 14:04:00 +0100 Subject: [PATCH 006/312] API New can customize reference when addvariant --- htdocs/product/class/api_products.class.php | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/htdocs/product/class/api_products.class.php b/htdocs/product/class/api_products.class.php index 37c950e9956..b0ed902ffb3 100644 --- a/htdocs/product/class/api_products.class.php +++ b/htdocs/product/class/api_products.class.php @@ -1328,11 +1328,12 @@ class Products extends DolibarrApi * * "features" is a list of attributes pairs id_attribute=>id_value. Example: array(id_color=>id_Blue, id_size=>id_small, id_option=>id_val_a, ...) * - * @param int $id ID of Product - * @param float $weight_impact Weight impact of variant - * @param float $price_impact Price impact of variant - * @param bool $price_impact_is_percent Price impact in percent (true or false) - * @param array $features List of attributes pairs id_attribute->id_value. Example: array(id_color=>id_Blue, id_size=>id_small, id_option=>id_val_a, ...) + * @param int $id ID of Product + * @param float $weight_impact Weight impact of variant + * @param float $price_impact Price impact of variant + * @param bool $price_impact_is_percent Price impact in percent (true or false) + * @param array $features List of attributes pairs id_attribute->id_value. Example: array(id_color=>id_Blue, id_size=>id_small, id_option=>id_val_a, ...) + * @param bool|string $reference Customized reference of variant * @return int * * @throws RestException @@ -1341,7 +1342,7 @@ class Products extends DolibarrApi * * @url POST {id}/variants */ - public function addVariant($id, $weight_impact, $price_impact, $price_impact_is_percent, $features) + public function addVariant($id, $weight_impact, $price_impact, $price_impact_is_percent, $features, $reference = false) { if(! DolibarrApiAccess::$user->rights->produit->creer) { throw new RestException(401); @@ -1373,7 +1374,7 @@ class Products extends DolibarrApi $prodcomb = new ProductCombination($this->db); if (! $prodcomb->fetchByProductCombination2ValuePairs($id, $features)) { - $result = $prodcomb->createProductCombination(DolibarrApiAccess::$user, $this->product, $features, array(), $price_impact_is_percent, $price_impact, $weight_impact); + $result = $prodcomb->createProductCombination(DolibarrApiAccess::$user, $this->product, $features, array(), $price_impact_is_percent, $price_impact, $weight_impact, $reference); if ($result > 0) { return $result; From 6484ba10c52ac634c04f54fb24bae4243a470026 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric?= <35066297+c3do@users.noreply.github.com> Date: Sat, 23 Nov 2019 16:08:35 +0100 Subject: [PATCH 007/312] remove unecessary code already done by ::createProductCombination --- htdocs/product/class/api_products.class.php | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/htdocs/product/class/api_products.class.php b/htdocs/product/class/api_products.class.php index b0ed902ffb3..40d50357dc2 100644 --- a/htdocs/product/class/api_products.class.php +++ b/htdocs/product/class/api_products.class.php @@ -1372,18 +1372,13 @@ class Products extends DolibarrApi } $prodcomb = new ProductCombination($this->db); - if (! $prodcomb->fetchByProductCombination2ValuePairs($id, $features)) - { - $result = $prodcomb->createProductCombination(DolibarrApiAccess::$user, $this->product, $features, array(), $price_impact_is_percent, $price_impact, $weight_impact, $reference); - if ($result > 0) - { - return $result; - } else { - throw new RestException(500, "Error creating new product variant"); - } - } else { - return $prodcomb->id; - } + $result = $prodcomb->createProductCombination(DolibarrApiAccess::$user, $this->product, $features, array(), $price_impact_is_percent, $price_impact, $weight_impact, $reference); + if ($result > 0) + { + return $result; + } else { + throw new RestException(500, "Error creating new product variant"); + } } /** From 6086ecef864353cb908c905aa790529f8b74388b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric?= <35066297+c3do@users.noreply.github.com> Date: Sat, 23 Nov 2019 16:14:21 +0100 Subject: [PATCH 008/312] Can add already existing product as variant ONLY if the reference is forced --- .../class/ProductCombination.class.php | 147 ++++++++++-------- 1 file changed, 82 insertions(+), 65 deletions(-) diff --git a/htdocs/variants/class/ProductCombination.class.php b/htdocs/variants/class/ProductCombination.class.php index 6dfa1bf94c5..a3646147101 100644 --- a/htdocs/variants/class/ProductCombination.class.php +++ b/htdocs/variants/class/ProductCombination.class.php @@ -514,7 +514,23 @@ WHERE c.fk_product_parent = ".(int) $productid." AND p.tosell = 1"; $db->begin(); - $newproduct = clone $product; + $forced_refvar = trim($forced_refvar); + + if (!empty($forced_refvar) && $forced_refvar != $product->ref) { + $existingProduct = new Product($db); + $result = $existingProduct->fetch('', $forced_refvar); + if ($result > 0) { + $newproduct = $existingProduct; + } else { + $existingProduct = false; + $newproduct = clone $product; + $newproduct->ref = $forced_refvar; + } + } else { + $forced_refvar = false; + $existingProduct = false; + $newproduct = clone $product; + } //Final weight impact $weight_impact = $forced_weightvar; @@ -529,11 +545,7 @@ WHERE c.fk_product_parent = ".(int) $productid." AND p.tosell = 1"; if ($forced_pricevar === false) { $price_impact = 0; } - - if ($forced_refvar !== false) { - $forced_refvar = trim($forced_refvar); - } - + $newcomb = new ProductCombination($db); $existingCombination = $newcomb->fetchByProductCombination2ValuePairs($product->id, $combinations); @@ -541,7 +553,6 @@ WHERE c.fk_product_parent = ".(int) $productid." AND p.tosell = 1"; $newcomb = $existingCombination; } else { $newcomb->fk_product_parent = $product->id; - if ($newcomb->create($user) < 0) { // Create 1 entry into product_attribute_combination (1 entry for all combinations) $db->rollback(); return -1; @@ -577,14 +588,13 @@ WHERE c.fk_product_parent = ".(int) $productid." AND p.tosell = 1"; if ($forced_pricevar === false) { $price_impact += (float) price2num($variations[$currcombattr][$currcombval]['price']); } - if (empty($forced_refvar)) { - if (isset($conf->global->PRODUIT_ATTRIBUTES_SEPARATOR)) { - $newproduct->ref .= $conf->global->PRODUIT_ATTRIBUTES_SEPARATOR . $prodattrval->ref; - } else { - $newproduct->ref .= '_'.$prodattrval->ref; - } - } else { - $newproduct->ref = $forced_refvar; + + if ($forced_refvar === false) { + if (isset($conf->global->PRODUIT_ATTRIBUTES_SEPARATOR)) { + $newproduct->ref .= $conf->global->PRODUIT_ATTRIBUTES_SEPARATOR . $prodattrval->ref; + } else { + $newproduct->ref .= '_'.$prodattrval->ref; + } } //The first one should not contain a linebreak @@ -600,58 +610,65 @@ WHERE c.fk_product_parent = ".(int) $productid." AND p.tosell = 1"; $newproduct->weight += $weight_impact; - //To avoid wrong information in price history log - $newproduct->price = 0; - $newproduct->price_ttc = 0; - $newproduct->price_min = 0; - $newproduct->price_min_ttc = 0; - - // A new variant must use a new barcode (not same product) - $newproduct->barcode = -1; - // Now create the product //print 'Create prod '.$newproduct->ref.'
'."\n"; - $newprodid = $newproduct->create($user); - if ($newprodid < 0) - { - //In case the error is not related with an already existing product - if ($newproduct->error != 'ErrorProductAlreadyExists') { - $this->error[] = $newproduct->error; - $this->errors = $newproduct->errors; - $db->rollback(); - return -1; - } - - /** - * If there is an existing combination, then we update the prices and weight - * Otherwise, we try adding a random number to the ref - */ - - if ($newcomb->fk_product_child) { - $res = $newproduct->fetch($existingCombination->fk_product_child); - } else { - $orig_prod_ref = $newproduct->ref; - $i = 1; - - do { - $newproduct->ref = $orig_prod_ref.$i; - $res = $newproduct->create($user); - - if ($newproduct->error != 'ErrorProductAlreadyExists') { - $this->errors[] = $newproduct->error; - break; - } - - $i++; - } while ($res < 0); - } - - if ($res < 0) { - $db->rollback(); - return -1; - } - - $newproduct->weight += $weight_impact; + if ($existingProduct === false) { + //To avoid wrong information in price history log + $newproduct->price = 0; + $newproduct->price_ttc = 0; + $newproduct->price_min = 0; + $newproduct->price_min_ttc = 0; + + // A new variant must use a new barcode (not same product) + $newproduct->barcode = -1; + $result = $newproduct->create($user); + + if ($result < 0) + { + //In case the error is not related with an already existing product + if ($newproduct->error != 'ErrorProductAlreadyExists') { + $this->error[] = $newproduct->error; + $this->errors = $newproduct->errors; + $db->rollback(); + return -1; + } + + /** + * If there is an existing combination, then we update the prices and weight + * Otherwise, we try adding a random number to the ref + */ + + if ($newcomb->fk_product_child) { + $res = $newproduct->fetch($existingCombination->fk_product_child); + } else { + $orig_prod_ref = $newproduct->ref; + $i = 1; + + do { + $newproduct->ref = $orig_prod_ref.$i; + $res = $newproduct->create($user); + + if ($newproduct->error != 'ErrorProductAlreadyExists') { + $this->errors[] = $newproduct->error; + break; + } + + $i++; + } while ($res < 0); + } + + if ($res < 0) { + $db->rollback(); + return -1; + } + } + } else { + $result = $newproduct->update($newproduct->id, $user); + if ($result < 0) + { + $db->rollback(); + return -1; + } } $newcomb->fk_product_child = $newproduct->id; From 7a3f6c362d52b516165217d4c6847afa6cd8810a Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Sat, 23 Nov 2019 15:23:31 +0000 Subject: [PATCH 009/312] Fixing style errors. --- .../class/ProductCombination.class.php | 42 +++++++++---------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/htdocs/variants/class/ProductCombination.class.php b/htdocs/variants/class/ProductCombination.class.php index a3646147101..fc58d338220 100644 --- a/htdocs/variants/class/ProductCombination.class.php +++ b/htdocs/variants/class/ProductCombination.class.php @@ -515,17 +515,17 @@ WHERE c.fk_product_parent = ".(int) $productid." AND p.tosell = 1"; $db->begin(); $forced_refvar = trim($forced_refvar); - + if (!empty($forced_refvar) && $forced_refvar != $product->ref) { - $existingProduct = new Product($db); - $result = $existingProduct->fetch('', $forced_refvar); - if ($result > 0) { - $newproduct = $existingProduct; - } else { - $existingProduct = false; - $newproduct = clone $product; - $newproduct->ref = $forced_refvar; - } + $existingProduct = new Product($db); + $result = $existingProduct->fetch('', $forced_refvar); + if ($result > 0) { + $newproduct = $existingProduct; + } else { + $existingProduct = false; + $newproduct = clone $product; + $newproduct->ref = $forced_refvar; + } } else { $forced_refvar = false; $existingProduct = false; @@ -588,12 +588,12 @@ WHERE c.fk_product_parent = ".(int) $productid." AND p.tosell = 1"; if ($forced_pricevar === false) { $price_impact += (float) price2num($variations[$currcombattr][$currcombval]['price']); } - + if ($forced_refvar === false) { if (isset($conf->global->PRODUIT_ATTRIBUTES_SEPARATOR)) { - $newproduct->ref .= $conf->global->PRODUIT_ATTRIBUTES_SEPARATOR . $prodattrval->ref; + $newproduct->ref .= $conf->global->PRODUIT_ATTRIBUTES_SEPARATOR . $prodattrval->ref; } else { - $newproduct->ref .= '_'.$prodattrval->ref; + $newproduct->ref .= '_'.$prodattrval->ref; } } @@ -618,11 +618,11 @@ WHERE c.fk_product_parent = ".(int) $productid." AND p.tosell = 1"; $newproduct->price_ttc = 0; $newproduct->price_min = 0; $newproduct->price_min_ttc = 0; - + // A new variant must use a new barcode (not same product) $newproduct->barcode = -1; $result = $newproduct->create($user); - + if ($result < 0) { //In case the error is not related with an already existing product @@ -632,31 +632,31 @@ WHERE c.fk_product_parent = ".(int) $productid." AND p.tosell = 1"; $db->rollback(); return -1; } - + /** * If there is an existing combination, then we update the prices and weight * Otherwise, we try adding a random number to the ref */ - + if ($newcomb->fk_product_child) { $res = $newproduct->fetch($existingCombination->fk_product_child); } else { $orig_prod_ref = $newproduct->ref; $i = 1; - + do { $newproduct->ref = $orig_prod_ref.$i; $res = $newproduct->create($user); - + if ($newproduct->error != 'ErrorProductAlreadyExists') { $this->errors[] = $newproduct->error; break; } - + $i++; } while ($res < 0); } - + if ($res < 0) { $db->rollback(); return -1; From 31cfc9cd3586d5a0f5485bc4e4492ff0996d12a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric?= <35066297+c3do@users.noreply.github.com> Date: Sat, 23 Nov 2019 17:04:14 +0100 Subject: [PATCH 010/312] Add field reference in form --- htdocs/variants/combinations.php | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/htdocs/variants/combinations.php b/htdocs/variants/combinations.php index f8a8b9cc9e5..c2067a28ee1 100644 --- a/htdocs/variants/combinations.php +++ b/htdocs/variants/combinations.php @@ -33,6 +33,7 @@ $ref = GETPOST('ref', 'alpha'); $weight_impact = GETPOST('weight_impact', 'alpha'); $price_impact = GETPOST('price_impact', 'alpha'); $price_impact_percent = (bool) GETPOST('price_impact_percent'); +$reference = GETPOST('reference', 'alpha'); $form = new Form($db); $action = GETPOST('action', 'alpha'); @@ -106,6 +107,10 @@ if ($_POST) { } else { + $reference = trim($reference); + if (empty($reference)) { + $reference = false; + } $weight_impact = price2num($weight_impact); $price_impact = price2num($price_impact); $sanit_features = array(); @@ -141,7 +146,7 @@ if ($_POST) { if (!$prodcomb->fetchByProductCombination2ValuePairs($id, $sanit_features)) { - $result = $prodcomb->createProductCombination($user, $object, $sanit_features, array(), $price_impact_percent, $price_impact, $weight_impact); + $result = $prodcomb->createProductCombination($user, $object, $sanit_features, array(), $price_impact_percent, $price_impact, $weight_impact, $reference); if ($result > 0) { setEventMessages($langs->trans('RecordSaved'), null, 'mesgs'); @@ -587,6 +592,10 @@ if (! empty($id) || ! empty($ref)) + + + + From d647479794f6f7e9b1f4ccc1947efd8d7258afed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric?= <35066297+c3do@users.noreply.github.com> Date: Sat, 23 Nov 2019 17:17:25 +0100 Subject: [PATCH 011/312] Do not delete product automaticaly (unlink only) --- htdocs/variants/combinations.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/variants/combinations.php b/htdocs/variants/combinations.php index c2067a28ee1..e3993d02d3b 100644 --- a/htdocs/variants/combinations.php +++ b/htdocs/variants/combinations.php @@ -244,7 +244,7 @@ if ($action === 'confirm_deletecombination') { if ($prodcomb->fetch($valueid) > 0) { $db->begin(); - if ($prodcomb->delete($user) > 0 && $prodstatic->fetch($prodcomb->fk_product_child) > 0 && $prodstatic->delete($user) > 0) { + if ($prodcomb->delete($user) > 0) { $db->commit(); setEventMessages($langs->trans('RecordSaved'), null, 'mesgs'); header('Location: '.dol_buildpath('/variants/combinations.php?id='.$object->id, 2)); From 83de0fa7c19fee857fa9723da6fd6c449da674a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric?= <35066297+c3do@users.noreply.github.com> Date: Sat, 23 Nov 2019 18:03:46 +0100 Subject: [PATCH 012/312] Add the choice to delete the product linked --- htdocs/variants/combinations.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/htdocs/variants/combinations.php b/htdocs/variants/combinations.php index e3993d02d3b..adb2fa8b739 100644 --- a/htdocs/variants/combinations.php +++ b/htdocs/variants/combinations.php @@ -42,6 +42,7 @@ $show_files = GETPOST('show_files', 'int'); $confirm = GETPOST('confirm', 'alpha'); $toselect = GETPOST('toselect', 'array'); $cancel = GETPOST('cancel', 'alpha'); +$delete_product = GETPOST('delete_product', 'alpha'); // Security check $fieldvalue = (!empty($id) ? $id : $ref); @@ -244,7 +245,7 @@ if ($action === 'confirm_deletecombination') { if ($prodcomb->fetch($valueid) > 0) { $db->begin(); - if ($prodcomb->delete($user) > 0) { + if ($prodcomb->delete($user) > 0 && (empty($delete_product) || ($delete_product == 'on' && $prodstatic->fetch($prodcomb->fk_product_child) > 0 && $prodstatic->delete($user) > 0))) { $db->commit(); setEventMessages($langs->trans('RecordSaved'), null, 'mesgs'); header('Location: '.dol_buildpath('/variants/combinations.php?id='.$object->id, 2)); @@ -635,7 +636,7 @@ if (! empty($id) || ! empty($ref)) $langs->trans('Delete'), $langs->trans('ProductCombinationDeleteDialog', $prodstatic->ref), "confirm_deletecombination", - '', + array(array('label'=> $langs->trans('DeleteLinkedProduct'),'type'=> 'checkbox', 'name' => 'delete_product', 'value' => false)), 0, 1 ); From b959e595545d6b434122e52ac6fae05bf52804a3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric?= <35066297+c3do@users.noreply.github.com> Date: Sat, 23 Nov 2019 18:09:17 +0100 Subject: [PATCH 013/312] Checkbox label delete child product EN --- htdocs/langs/en_US/products.lang | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/langs/en_US/products.lang b/htdocs/langs/en_US/products.lang index 1ca335da637..103f13b7f75 100644 --- a/htdocs/langs/en_US/products.lang +++ b/htdocs/langs/en_US/products.lang @@ -347,4 +347,5 @@ ErrorDestinationProductNotFound=Destination product not found ErrorProductCombinationNotFound=Product variant not found ActionAvailableOnVariantProductOnly=Action only available on the variant of product ProductsPricePerCustomer=Product prices per customers -ProductSupplierExtraFields=Additional Attributes (Supplier Prices) \ No newline at end of file +ProductSupplierExtraFields=Additional Attributes (Supplier Prices) +DeleteLinkedProduct = Delete the child product linked to the combination From 950a32a433ae6f633eaabeb37cc5619bddc470fe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric?= <35066297+c3do@users.noreply.github.com> Date: Sat, 23 Nov 2019 18:11:20 +0100 Subject: [PATCH 014/312] Checkbox label delete child product FR --- htdocs/langs/fr_FR/products.lang | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/langs/fr_FR/products.lang b/htdocs/langs/fr_FR/products.lang index 0248f6470a9..d5465684736 100644 --- a/htdocs/langs/fr_FR/products.lang +++ b/htdocs/langs/fr_FR/products.lang @@ -347,3 +347,4 @@ ErrorDestinationProductNotFound=Produit destination non trouvé ErrorProductCombinationNotFound=Variante du produit non trouvé ActionAvailableOnVariantProductOnly=Action disponible uniquement sur la variante du produit ProductsPricePerCustomer=Prix produit par clients +DeleteLinkedProduct = Supprimer le produit enfant lié à la variante From 76c5a08242ec496c7d9a2b1ceefc33e1864e284e Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Thu, 28 Nov 2019 12:13:36 +0000 Subject: [PATCH 015/312] Fixing style errors. --- htdocs/product/class/api_products.class.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/product/class/api_products.class.php b/htdocs/product/class/api_products.class.php index 05e4fe3b1c6..8cb710ceab4 100644 --- a/htdocs/product/class/api_products.class.php +++ b/htdocs/product/class/api_products.class.php @@ -1373,13 +1373,13 @@ class Products extends DolibarrApi } $prodcomb = new ProductCombination($this->db); - + $result = $prodcomb->createProductCombination(DolibarrApiAccess::$user, $this->product, $features, array(), $price_impact_is_percent, $price_impact, $weight_impact, $reference); if ($result > 0) { - return $result; + return $result; } else { - throw new RestException(500, "Error creating new product variant"); + throw new RestException(500, "Error creating new product variant"); } } From 565a17dc47c6a032f21a42584c4ebda48fcec785 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric?= <35066297+c3do@users.noreply.github.com> Date: Sat, 30 Nov 2019 23:36:23 +0100 Subject: [PATCH 016/312] API New add purchase prices --- htdocs/product/class/api_products.class.php | 67 +++++++++++++++++++++ 1 file changed, 67 insertions(+) diff --git a/htdocs/product/class/api_products.class.php b/htdocs/product/class/api_products.class.php index 8cb710ceab4..b9d21b481e2 100644 --- a/htdocs/product/class/api_products.class.php +++ b/htdocs/product/class/api_products.class.php @@ -631,6 +631,73 @@ class Products extends DolibarrApi 'prices_by_qty_list'=>$this->product->prices_by_qty_list[0] ); } + + /** + * Add purchase prices for a product. + * + * @param int $id ID of Product + * @param float $qty Min quantity for which price is valid + * @param float $buyprice Purchase price for the quantity min + * @param string $price_base_type HT or TTC + * @param int $fourn_id Supplier ID + * @param int $availability Product availability + * @param string $ref_fourn Supplier ref + * @param float $tva_tx New VAT Rate (For example 8.5. Should not be a string) + * @param string $charges costs affering to product + * @param float $remise_percent Discount regarding qty (percent) + * @param float $remise Discount regarding qty (amount) + * @param int $newnpr Set NPR or not + * @param int $delivery_time_days Delay in days for delivery (max). May be '' if not defined. + * @param string $supplier_reputation Reputation with this product to the defined supplier (empty, FAVORITE, DONOTORDER) + * @param array $localtaxes_array Array with localtaxes info array('0'=>type1,'1'=>rate1,'2'=>type2,'3'=>rate2) (loaded by getLocalTaxesFromRate(vatrate, 0, ...) function). + * @param string $newdefaultvatcode Default vat code + * @param float $multicurrency_buyprice Purchase price for the quantity min in currency + * @param string $multicurrency_price_base_type HT or TTC in currency + * @param float $multicurrency_tx Rate currency + * @param string $multicurrency_code Currency code + * @param string $desc_fourn Custom description for product_fourn_price + * @param string $barcode Barcode + * @param int $fk_barcode_type Barcode type + * @return int + * + * @throws RestException + * @throws 401 + * + * @url POST {id}/purchase_prices + */ + public function addPurchasePrice($id, $qty, $buyprice, $price_base_type, $fourn_id, $availability, $ref_fourn, $tva_tx, $charges = 0, $remise_percent = 0, $remise = 0, $newnpr = 0, $delivery_time_days = 0, $supplier_reputation = '', $localtaxes_array = array(), $newdefaultvatcode = '', $multicurrency_buyprice = 0, $multicurrency_price_base_type = 'HT', $multicurrency_tx = 1, $multicurrency_code = '', $desc_fourn = '', $barcode = '', $fk_barcode_type = null) + { + if(! DolibarrApiAccess::$user->rights->produit->creer) { + throw new RestException(401); + } + + $result = $this->productsupplier->fetch($id); + if (!$result) { + throw new RestException(404, 'Product not found'); + } + + if (!DolibarrApi::_checkAccessToResource('product', $this->productsupplier->id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } + + $result = $this->productsupplier->add_fournisseur(DolibarrApiAccess::$user, $fourn_id, $ref_fourn, $qty); + if ($result <= 0) { + throw new RestException(500, "Error adding supplier to product : ".$this->db->lasterror()); + } + + $fourn = new Fournisseur($this->db); + $result = $fourn->fetch($fourn_id); + if ($result <= 0) { + throw new RestException(404, 'Supplier not found'); + } + + $result = $this->productsupplier->update_buyprice($qty, $buyprice, DolibarrApiAccess::$user, $price_base_type, $fourn, $availability, $ref_fourn, $tva_tx, $charges, $remise_percent, $remise, $newnpr, $delivery_time_days, $supplier_reputation, $localtaxes_array, $newdefaultvatcode, $multicurrency_buyprice, $multicurrency_price_base_type, $multicurrency_tx, $multicurrency_code, $desc_fourn, $barcode, $fk_barcode_type); + + if ($result <= 0) { + throw new RestException(500, "Error updating buy price : ".$this->db->lasterror()); + } + return (int) $this->productsupplier->product_fourn_price_id; + } /** * Delete purchase price for a product From 1bad6f5c9c783dc97a4f5bb69708a997aa6c509e Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Sat, 30 Nov 2019 22:38:05 +0000 Subject: [PATCH 017/312] Fixing style errors. --- htdocs/product/class/api_products.class.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/htdocs/product/class/api_products.class.php b/htdocs/product/class/api_products.class.php index b9d21b481e2..1bb5aed98f5 100644 --- a/htdocs/product/class/api_products.class.php +++ b/htdocs/product/class/api_products.class.php @@ -631,7 +631,7 @@ class Products extends DolibarrApi 'prices_by_qty_list'=>$this->product->prices_by_qty_list[0] ); } - + /** * Add purchase prices for a product. * @@ -670,29 +670,29 @@ class Products extends DolibarrApi if(! DolibarrApiAccess::$user->rights->produit->creer) { throw new RestException(401); } - + $result = $this->productsupplier->fetch($id); if (!$result) { throw new RestException(404, 'Product not found'); } - + if (!DolibarrApi::_checkAccessToResource('product', $this->productsupplier->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } - + $result = $this->productsupplier->add_fournisseur(DolibarrApiAccess::$user, $fourn_id, $ref_fourn, $qty); if ($result <= 0) { throw new RestException(500, "Error adding supplier to product : ".$this->db->lasterror()); } - + $fourn = new Fournisseur($this->db); $result = $fourn->fetch($fourn_id); if ($result <= 0) { throw new RestException(404, 'Supplier not found'); } - + $result = $this->productsupplier->update_buyprice($qty, $buyprice, DolibarrApiAccess::$user, $price_base_type, $fourn, $availability, $ref_fourn, $tva_tx, $charges, $remise_percent, $remise, $newnpr, $delivery_time_days, $supplier_reputation, $localtaxes_array, $newdefaultvatcode, $multicurrency_buyprice, $multicurrency_price_base_type, $multicurrency_tx, $multicurrency_code, $desc_fourn, $barcode, $fk_barcode_type); - + if ($result <= 0) { throw new RestException(500, "Error updating buy price : ".$this->db->lasterror()); } From 7b295bf738dc295cfd774871f7fdb54ea5708c17 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric?= <35066297+c3do@users.noreply.github.com> Date: Sun, 1 Dec 2019 14:56:39 +0100 Subject: [PATCH 018/312] addPurchasePrice Update the price if already exist --- htdocs/product/class/api_products.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/product/class/api_products.class.php b/htdocs/product/class/api_products.class.php index 1bb5aed98f5..4ce7750fddd 100644 --- a/htdocs/product/class/api_products.class.php +++ b/htdocs/product/class/api_products.class.php @@ -633,7 +633,7 @@ class Products extends DolibarrApi } /** - * Add purchase prices for a product. + * Add/Update purchase prices for a product. * * @param int $id ID of Product * @param float $qty Min quantity for which price is valid @@ -681,7 +681,7 @@ class Products extends DolibarrApi } $result = $this->productsupplier->add_fournisseur(DolibarrApiAccess::$user, $fourn_id, $ref_fourn, $qty); - if ($result <= 0) { + if ($result < 0) { throw new RestException(500, "Error adding supplier to product : ".$this->db->lasterror()); } From 275b5d1f77fef674ae6c8a87d5506e2bcce38963 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Tue, 11 Feb 2020 07:32:29 +0100 Subject: [PATCH 019/312] FIX #10309 --- htdocs/core/lib/security.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/lib/security.lib.php b/htdocs/core/lib/security.lib.php index 71d52f1bd9d..dc739220c07 100644 --- a/htdocs/core/lib/security.lib.php +++ b/htdocs/core/lib/security.lib.php @@ -122,7 +122,7 @@ function dol_hash($chain, $type = '0') } // Salt value - if (! empty($conf->global->MAIN_SECURITY_SALT)) $chain=$conf->global->MAIN_SECURITY_SALT.$chain; + if (! empty($conf->global->MAIN_SECURITY_SALT) && ( ! $type == '4' || ! $type == 'md5openldap')) $chain=$conf->global->MAIN_SECURITY_SALT.$chain; if ($type == '1' || $type == 'sha1') return sha1($chain); elseif ($type == '2' || $type == 'sha1md5') return sha1(md5($chain)); From f19f706c386e8dc4f123bea2b6e9453eeccb29d6 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Thu, 13 Feb 2020 07:55:52 +0100 Subject: [PATCH 020/312] FIX better check --- htdocs/core/lib/security.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/lib/security.lib.php b/htdocs/core/lib/security.lib.php index dc739220c07..483567aa3d0 100644 --- a/htdocs/core/lib/security.lib.php +++ b/htdocs/core/lib/security.lib.php @@ -122,7 +122,7 @@ function dol_hash($chain, $type = '0') } // Salt value - if (! empty($conf->global->MAIN_SECURITY_SALT) && ( ! $type == '4' || ! $type == 'md5openldap')) $chain=$conf->global->MAIN_SECURITY_SALT.$chain; + if (! empty($conf->global->MAIN_SECURITY_SALT) && ($type !== '4' || $type !== 'md5openldap')) $chain = $conf->global->MAIN_SECURITY_SALT.$chain; if ($type == '1' || $type == 'sha1') return sha1($chain); elseif ($type == '2' || $type == 'sha1md5') return sha1(md5($chain)); From 52506ddd05b3d73efec8b447aad32700b6c13186 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Thu, 13 Feb 2020 09:25:36 +0100 Subject: [PATCH 021/312] FIX can be a string or integer --- htdocs/core/lib/security.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/lib/security.lib.php b/htdocs/core/lib/security.lib.php index 483567aa3d0..481339916a3 100644 --- a/htdocs/core/lib/security.lib.php +++ b/htdocs/core/lib/security.lib.php @@ -122,7 +122,7 @@ function dol_hash($chain, $type = '0') } // Salt value - if (! empty($conf->global->MAIN_SECURITY_SALT) && ($type !== '4' || $type !== 'md5openldap')) $chain = $conf->global->MAIN_SECURITY_SALT.$chain; + if (! empty($conf->global->MAIN_SECURITY_SALT) && ($type != '4' || $type !== 'md5openldap')) $chain = $conf->global->MAIN_SECURITY_SALT.$chain; if ($type == '1' || $type == 'sha1') return sha1($chain); elseif ($type == '2' || $type == 'sha1md5') return sha1(md5($chain)); From 0ab0bb2e7de4049e17d7f801e63545f8acfb003c Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Fri, 14 Feb 2020 19:26:28 +0100 Subject: [PATCH 022/312] FIX wrong test --- htdocs/core/lib/security.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/lib/security.lib.php b/htdocs/core/lib/security.lib.php index 481339916a3..1a8045df014 100644 --- a/htdocs/core/lib/security.lib.php +++ b/htdocs/core/lib/security.lib.php @@ -122,7 +122,7 @@ function dol_hash($chain, $type = '0') } // Salt value - if (! empty($conf->global->MAIN_SECURITY_SALT) && ($type != '4' || $type !== 'md5openldap')) $chain = $conf->global->MAIN_SECURITY_SALT.$chain; + if (! empty($conf->global->MAIN_SECURITY_SALT) && $type != '4' && $type !== 'md5openldap') $chain = $conf->global->MAIN_SECURITY_SALT.$chain; if ($type == '1' || $type == 'sha1') return sha1($chain); elseif ($type == '2' || $type == 'sha1md5') return sha1(md5($chain)); From a7ca7dfbb639521bcb3d7bf6615c1b35364d4e72 Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Thu, 20 Feb 2020 06:00:17 +0100 Subject: [PATCH 023/312] FIX: z-index for moretabsList with constant MAIN_MAXTABS_IN_CARD --- htdocs/core/lib/functions.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 9208ebb9a6e..ed50e236ffe 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -1226,7 +1226,7 @@ function dol_get_fiche_head($links = array(), $active = '', $title = '', $notab $tabsname=str_replace("@", "", $picto); $out.='
'; $out.=''.$langs->trans("More").'... ('.$nbintab.')'; - $out.='
'; + $out.='
'; $out.=$outmore; $out.='
'; $out.='
'; From 523e161f33f3947ba82a95a09e6c29171cb6897c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Thu, 20 Feb 2020 09:45:17 +0100 Subject: [PATCH 024/312] fix CATEGORY_ADD_DESC_INTO_DOC $cate->add_category doesn't exists --- htdocs/core/lib/pdf.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/lib/pdf.lib.php b/htdocs/core/lib/pdf.lib.php index e7538725bc2..b75cb1e4bd6 100644 --- a/htdocs/core/lib/pdf.lib.php +++ b/htdocs/core/lib/pdf.lib.php @@ -1401,7 +1401,7 @@ function pdf_getlinedesc($object, $i, $outputlangs, $hideref = 0, $hidedesc = 0, foreach ($tblcateg as $cate) { // Adding the descriptions if they are filled - $desccateg = $cate->add_description; + $desccateg = $cate->description; if ($desccateg) $libelleproduitservice .= '__N__'.$desccateg; } From 9ff424e23b63ef50ce3b52e67b33154dbe423aed Mon Sep 17 00:00:00 2001 From: Ferran Marcet Date: Thu, 20 Feb 2020 11:45:46 +0100 Subject: [PATCH 025/312] FIX: Visualization rights correction on last modified contacts box --- htdocs/core/boxes/box_contacts.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/core/boxes/box_contacts.php b/htdocs/core/boxes/box_contacts.php index 2d9d7e9461b..ebe7f8f9be0 100644 --- a/htdocs/core/boxes/box_contacts.php +++ b/htdocs/core/boxes/box_contacts.php @@ -4,6 +4,7 @@ * Copyright (C) 2005-2009 Regis Houssin * Copyright (C) 2015 Frederic France * Copyright (C) 2018 Josep Lluís Amador + * Copyright (C) 2020 Ferran Marcet * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -90,7 +91,7 @@ class box_contacts extends ModeleBoxes $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON sp.fk_soc = s.rowid"; if (! $user->rights->societe->client->voir && ! $user->societe_id) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; $sql.= " WHERE sp.entity IN (".getEntity('socpeople').")"; - if (! $user->rights->societe->client->voir && ! $user->societe_id) $sql.= " AND sp.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; + if (! $user->rights->societe->client->voir && ! $user->societe_id) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; if ($user->societe_id) $sql.= " AND sp.fk_soc = ".$user->societe_id; $sql.= " ORDER BY sp.tms DESC"; $sql.= $db->plimit($max, 0); From 298853138a714144a59d0f786af1b78f14e31e62 Mon Sep 17 00:00:00 2001 From: Anthony Berton <34568357+bb2a@users.noreply.github.com> Date: Thu, 20 Feb 2020 12:17:55 +0100 Subject: [PATCH 026/312] Update contact.class.php --- htdocs/contact/class/contact.class.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/contact/class/contact.class.php b/htdocs/contact/class/contact.class.php index 013830ca864..ad68d88d643 100644 --- a/htdocs/contact/class/contact.class.php +++ b/htdocs/contact/class/contact.class.php @@ -314,9 +314,9 @@ class Contact extends CommonObject // Clean parameters $this->lastname = $this->lastname ?trim($this->lastname) : trim($this->name); $this->firstname = trim($this->firstname); - if (!empty($conf->global->MAIN_FIRST_TO_UPPER)) $this->lastname = ucwords($this->lastname); + if (!empty($conf->global->MAIN_FIRST_TO_UPPER)) $this->lastname = ucwords(strtolower($this->lastname)); if (!empty($conf->global->MAIN_ALL_TO_UPPER)) $this->lastname = strtoupper($this->lastname); - if (!empty($conf->global->MAIN_FIRST_TO_UPPER)) $this->firstname = ucwords($this->firstname); + if (!empty($conf->global->MAIN_FIRST_TO_UPPER)) $this->firstname = ucwords(strtolower($this->firstname)); if (empty($this->socid)) $this->socid = 0; if (empty($this->priv)) $this->priv = 0; if (empty($this->statut)) $this->statut = 0; // This is to convert '' into '0' to avoid bad sql request @@ -427,9 +427,9 @@ class Contact extends CommonObject $this->entity = ((isset($this->entity) && is_numeric($this->entity)) ? $this->entity : $conf->entity); // Clean parameters - if (!empty($conf->global->MAIN_FIRST_TO_UPPER)) $this->lastname = ucwords($this->lastname); + if (!empty($conf->global->MAIN_FIRST_TO_UPPER)) $this->lastname = ucwords(strtolower($this->lastname)); if (!empty($conf->global->MAIN_ALL_TO_UPPER)) $this->lastname = strtoupper($this->lastname); - if (!empty($conf->global->MAIN_FIRST_TO_UPPER)) $this->firstname = ucwords($this->firstname); + if (!empty($conf->global->MAIN_FIRST_TO_UPPER)) $this->firstname = ucwords(strtolower($this->firstname)); $this->lastname = trim($this->lastname) ?trim($this->lastname) : trim($this->lastname); $this->firstname = trim($this->firstname); From 3df3a2560c0b1ddf2d1d665d1ae7481e1266bedd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Thu, 20 Feb 2020 15:11:31 +0100 Subject: [PATCH 027/312] fix workflow with multicurrency --- htdocs/compta/facture/class/facture.class.php | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index cb2bf087652..93f4f500473 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -1253,6 +1253,14 @@ class Facture extends CommonInvoice $line->date_start = $object->lines[$i]->date_start; $line->date_end = $object->lines[$i]->date_end; + // Multicurrency + $line->fk_multicurrency = $object->lines[$i]->fk_multicurrency; + $line->multicurrency_code = $object->lines[$i]->multicurrency_code; + $line->multicurrency_subprice = $object->lines[$i]->multicurrency_subprice; + $line->multicurrency_total_ht = $object->lines[$i]->multicurrency_total_ht; + $line->multicurrency_total_tva = $object->lines[$i]->multicurrency_total_tva; + $line->multicurrency_total_ttc = $object->lines[$i]->multicurrency_total_ttc; + $line->fk_fournprice = $object->lines[$i]->fk_fournprice; $marginInfos = getMarginInfos($object->lines[$i]->subprice, $object->lines[$i]->remise_percent, $object->lines[$i]->tva_tx, $object->lines[$i]->localtax1_tx, $object->lines[$i]->localtax2_tx, $object->lines[$i]->fk_fournprice, $object->lines[$i]->pa_ht); $line->pa_ht = $marginInfos[0]; @@ -1267,6 +1275,7 @@ class Facture extends CommonInvoice $this->socid = $object->socid; $this->fk_project = $object->fk_project; + $this->fk_account = $object->fk_account; $this->cond_reglement_id = $object->cond_reglement_id; $this->mode_reglement_id = $object->mode_reglement_id; $this->availability_id = $object->availability_id; From 2942e85e47b5e67e256f34e0e087e6d600c8183e Mon Sep 17 00:00:00 2001 From: javierybar Date: Thu, 20 Feb 2020 15:16:17 +0100 Subject: [PATCH 028/312] More elegant and easy to understand printer setup --- htdocs/core/lib/takepos.lib.php | 11 +- htdocs/core/modules/modTakePos.class.php | 4 + htdocs/langs/en_US/cashdesk.lang | 5 + htdocs/takepos/admin/receipt.php | 174 +++++++++++++++++------ htdocs/takepos/admin/setup.php | 47 +----- htdocs/takepos/admin/terminal.php | 2 +- htdocs/takepos/invoice.php | 4 +- htdocs/takepos/takepos.php | 8 +- 8 files changed, 150 insertions(+), 105 deletions(-) diff --git a/htdocs/core/lib/takepos.lib.php b/htdocs/core/lib/takepos.lib.php index dc86853859e..65ad4c091a0 100644 --- a/htdocs/core/lib/takepos.lib.php +++ b/htdocs/core/lib/takepos.lib.php @@ -38,13 +38,10 @@ function takepos_prepare_head() $head[$h][2] = 'setup'; $h++; - if ($conf->global->TAKEPOS_CUSTOM_RECEIPT) - { - $head[$h][0] = DOL_URL_ROOT.'/takepos/admin/receipt.php'; - $head[$h][1] = $langs->trans("Receipt"); - $head[$h][2] = 'receipt'; - $h++; - } + $head[$h][0] = DOL_URL_ROOT.'/takepos/admin/receipt.php'; + $head[$h][1] = $langs->trans("Receipt"); + $head[$h][2] = 'receipt'; + $h++; $numterminals = max(1, $conf->global->TAKEPOS_NUM_TERMINALS); for ($i = 1; $i <= $numterminals; $i++) diff --git a/htdocs/core/modules/modTakePos.class.php b/htdocs/core/modules/modTakePos.class.php index 804ce8152ab..2243437d20f 100644 --- a/htdocs/core/modules/modTakePos.class.php +++ b/htdocs/core/modules/modTakePos.class.php @@ -265,6 +265,10 @@ class modTakePos extends DolibarrModules */ public function init($options = '') { + global $conf,$db; + + dolibarr_set_const($db, "TAKEPOS_PRINT_METHOD", "browser", 'chaine', 0, '', $conf->entity); + $this->_load_tables('/takepos/sql/'); $sql = array(); diff --git a/htdocs/langs/en_US/cashdesk.lang b/htdocs/langs/en_US/cashdesk.lang index a468b7d6ab1..28e87394089 100644 --- a/htdocs/langs/en_US/cashdesk.lang +++ b/htdocs/langs/en_US/cashdesk.lang @@ -85,3 +85,8 @@ ColorTheme=Color theme Colorful=Colorful HeadBar=Head Bar SortProductField=Field for sorting products +Browser=Browser +BrowserMethodDescription=Simple and easy receipt printing. Only a few parameters to configure the receipt. Print via browser. +TakeposConnectorMethodDescription=External module with extra features. Posibility to print from de cloud. +PrintMethod=Print method +ReceiptPrinterMethodDescription=Powerful method with a lot of parameters. Full customizable with templates. Cannot print from the cloud. \ No newline at end of file diff --git a/htdocs/takepos/admin/receipt.php b/htdocs/takepos/admin/receipt.php index 967881e33d7..ef31bc2392c 100644 --- a/htdocs/takepos/admin/receipt.php +++ b/htdocs/takepos/admin/receipt.php @@ -46,6 +46,9 @@ if (GETPOST('action', 'alpha') == 'set') $res = dolibarr_set_const($db, "TAKEPOS_FOOTER", GETPOST('TAKEPOS_FOOTER', 'alpha'), 'chaine', 0, '', $conf->entity); $res = dolibarr_set_const($db, "TAKEPOS_RECEIPT_NAME", GETPOST('TAKEPOS_RECEIPT_NAME', 'alpha'), 'chaine', 0, '', $conf->entity); $res = dolibarr_set_const($db, "TAKEPOS_SHOW_CUSTOMER", GETPOST('TAKEPOS_SHOW_CUSTOMER', 'alpha'), 'chaine', 0, '', $conf->entity); + $res = dolibarr_set_const($db, "TAKEPOS_AUTO_PRINT_TICKETS", GETPOST('TAKEPOS_AUTO_PRINT_TICKETS', 'int'), 'int', 0, '', $conf->entity); + $res = dolibarr_set_const($db, "TAKEPOS_PRINT_SERVER", GETPOST('TAKEPOS_PRINT_SERVER', 'alpha'), 'chaine', 0, '', $conf->entity); + dol_syslog("admin/cashdesk: level ".GETPOST('level', 'alpha')); @@ -62,6 +65,10 @@ if (GETPOST('action', 'alpha') == 'set') 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); +} /* @@ -79,64 +86,139 @@ $head = takepos_prepare_head(); dol_fiche_head($head, 'receipt', 'TakePOS', -1); print '
'; - -// Mode print '
'; print ''; print ''; +print load_fiche_titre($langs->trans("PrintMethod"), '', ''); + +print ''; +print ''; +print ''; +print "\n"; + +// Browser method +print '\n"; + +// Receipt printer module +if ($conf->receiptprinter->enabled) { + print '\n"; +} + +// TakePOS Connector +print '\n"; +print '
'.$langs->trans("Name").''.$langs->trans("Description").''.$langs->trans("Status").'
'; +print $langs->trans('Browser'); +print ''; +print $langs->trans('BrowserMethodDescription'); +print ''; +if ($conf->global->TAKEPOS_PRINT_METHOD == "browser") +{ + print img_picto($langs->trans("Activated"), 'switch_on'); +} +else +{ + print ''.img_picto($langs->trans("Disabled"), 'switch_off').''; +} +print "
'; + print $langs->trans('DolibarrReceiptPrinter'); + print ''; + print $langs->trans('ReceiptPrinterMethodDescription'); + print ''; + if ($conf->global->TAKEPOS_PRINT_METHOD == "receiptprinter") + { + print img_picto($langs->trans("Activated"), 'switch_on'); + } + else + { + print ''.img_picto($langs->trans("Disabled"), 'switch_off').''; + } + print "
'; +print "TakePOS Connector"; +print ''; +print $langs->trans('TakeposConnectorMethodDescription'); +print ''; +if ($conf->global->TAKEPOS_PRINT_METHOD == "takeposconnector") +{ + print img_picto($langs->trans("Activated"), 'switch_on'); +} +else +{ + print ''.img_picto($langs->trans("Disabled"), 'switch_off').''; +} +print "
'; + +print load_fiche_titre($langs->trans("Setup"), '', ''); + print ''; print ''; print ''; print "\n"; -$substitutionarray = pdf_getSubstitutionArray($langs, null, null, 2); -$substitutionarray['__(AnyTranslationKey)__'] = $langs->trans("Translation"); -$htmltext = ''.$langs->trans("AvailableVariables").':
'; -foreach ($substitutionarray as $key => $val) $htmltext .= $key.'
'; -$htmltext .= '
'; +if ($conf->global->TAKEPOS_PRINT_METHOD == "takeposconnector"){ + print ''; +} +if ($conf->global->TAKEPOS_PRINT_METHOD == "browser" || $conf->global->TAKEPOS_PRINT_METHOD == "takeposconnector"){ + $substitutionarray = pdf_getSubstitutionArray($langs, null, null, 2); + $substitutionarray['__(AnyTranslationKey)__'] = $langs->trans("Translation"); + $htmltext = ''.$langs->trans("AvailableVariables").':
'; + foreach ($substitutionarray as $key => $val) $htmltext .= $key.'
'; + $htmltext .= '
'; + + print '\n"; + + print '\n"; + + print ''; + + // Customer information + print '\n"; +} + +// Auto print tickets print '\n"; - -print '\n"; - -print ''; - -// Customer information -print '\n"; print '
'.$langs->trans("Parameters").''.$langs->trans("Value").'
'; + print $langs->trans("IPAddress").' ('.$langs->trans("TakeposConnectorNecesary").')'; + print ''; + print ''; + print '
'; + print $form->textwithpicto($langs->trans("FreeLegalTextOnInvoices")." - ".$langs->trans("Header"), $htmltext, 1, 'help', '', 0, 2, 'freetexttooltip').'
'; + print '
'; + $variablename = 'TAKEPOS_HEADER'; + if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) + { + print ''; + } + else + { + include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; + $doleditor = new DolEditor($variablename, $conf->global->$variablename, '', 80, 'dolibarr_notes'); + print $doleditor->Create(); + } + print "
'; + print $form->textwithpicto($langs->trans("FreeLegalTextOnInvoices")." - ".$langs->trans("Footer"), $htmltext, 1, 'help', '', 0, 2, 'freetexttooltip').'
'; + print '
'; + $variablename = 'TAKEPOS_FOOTER'; + if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) + { + print ''; + } + else + { + include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; + $doleditor = new DolEditor($variablename, $conf->global->$variablename, '', 80, 'dolibarr_notes'); + print $doleditor->Create(); + } + print "
'; + print ''; + print '
'; + print $langs->trans('ShowCustomer'); + print ''; + print $form->selectyesno("TAKEPOS_SHOW_CUSTOMER", $conf->global->TAKEPOS_SHOW_CUSTOMER, 1); + print "
'; -print $form->textwithpicto($langs->trans("FreeLegalTextOnInvoices")." - ".$langs->trans("Header"), $htmltext, 1, 'help', '', 0, 2, 'freetexttooltip').'
'; -print '
'; -$variablename = 'TAKEPOS_HEADER'; -if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) -{ - print ''; -} -else -{ - include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; - $doleditor = new DolEditor($variablename, $conf->global->$variablename, '', 80, 'dolibarr_notes'); - print $doleditor->Create(); -} -print "
'; -print $form->textwithpicto($langs->trans("FreeLegalTextOnInvoices")." - ".$langs->trans("Footer"), $htmltext, 1, 'help', '', 0, 2, 'freetexttooltip').'
'; -print '
'; -$variablename = 'TAKEPOS_FOOTER'; -if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) -{ - print ''; -} -else -{ - include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; - $doleditor = new DolEditor($variablename, $conf->global->$variablename, '', 80, 'dolibarr_notes'); - print $doleditor->Create(); -} -print "
'; -print ''; -print '
'; -print $langs->trans('ShowCustomer'); +print $langs->trans("AutoPrintTickets"); print ''; -print $form->selectyesno("TAKEPOS_SHOW_CUSTOMER", $conf->global->TAKEPOS_SHOW_CUSTOMER, 1); +print $form->selectyesno("TAKEPOS_AUTO_PRINT_TICKETS", $conf->global->TAKEPOS_AUTO_PRINT_TICKETS, 1); print "
'; diff --git a/htdocs/takepos/admin/setup.php b/htdocs/takepos/admin/setup.php index c1fa8b10b42..69cb042f064 100644 --- a/htdocs/takepos/admin/setup.php +++ b/htdocs/takepos/admin/setup.php @@ -66,18 +66,13 @@ if (GETPOST('action', 'alpha') == 'set') $res = dolibarr_set_const($db, "CASHDESK_SERVICES", GETPOST('CASHDESK_SERVICES', 'alpha'), 'chaine', 0, '', $conf->entity); $res = dolibarr_set_const($db, "TAKEPOS_ROOT_CATEGORY_ID", GETPOST('TAKEPOS_ROOT_CATEGORY_ID', 'alpha'), 'chaine', 0, '', $conf->entity); - - $res = dolibarr_set_const($db, "TAKEPOSCONNECTOR", GETPOST('TAKEPOSCONNECTOR', 'alpha'), 'chaine', 0, '', $conf->entity); - $res = dolibarr_set_const($db, "TAKEPOS_DOLIBARR_PRINTER", GETPOST('TAKEPOS_DOLIBARR_PRINTER', 'alpha'), 'chaine', 0, '', $conf->entity); $res = dolibarr_set_const($db, "TAKEPOS_BAR_RESTAURANT", GETPOST('TAKEPOS_BAR_RESTAURANT', 'alpha'), 'chaine', 0, '', $conf->entity); $res = dolibarr_set_const($db, "TAKEPOS_TICKET_VAT_GROUPPED", GETPOST('TAKEPOS_TICKET_VAT_GROUPPED', 'alpha'), 'chaine', 0, '', $conf->entity); - $res = dolibarr_set_const($db, "TAKEPOS_PRINT_SERVER", GETPOST('TAKEPOS_PRINT_SERVER', 'alpha'), 'chaine', 0, '', $conf->entity); $res = dolibarr_set_const($db, "TAKEPOS_ORDER_PRINTERS", GETPOST('TAKEPOS_ORDER_PRINTERS', 'alpha'), 'chaine', 0, '', $conf->entity); $res = dolibarr_set_const($db, "TAKEPOS_ORDER_NOTES", GETPOST('TAKEPOS_ORDER_NOTES', 'alpha'), 'chaine', 0, '', $conf->entity); $res = dolibarr_set_const($db, "TAKEPOS_PHONE_BASIC_LAYOUT", GETPOST('TAKEPOS_PHONE_BASIC_LAYOUT', 'alpha'), 'chaine', 0, '', $conf->entity); $res = dolibarr_set_const($db, "TAKEPOS_SUPPLEMENTS", GETPOST('TAKEPOS_SUPPLEMENTS', 'alpha'), 'chaine', 0, '', $conf->entity); $res = dolibarr_set_const($db, "TAKEPOS_SUPPLEMENTS_CATEGORY", GETPOST('TAKEPOS_SUPPLEMENTS_CATEGORY', 'alpha'), 'chaine', 0, '', $conf->entity); - $res = dolibarr_set_const($db, "TAKEPOS_AUTO_PRINT_TICKETS", GETPOST('TAKEPOS_AUTO_PRINT_TICKETS', 'int'), 'int', 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); @@ -158,13 +153,6 @@ if (!empty($conf->service->enabled)) print "\n"; } -// Auto print tickets -print ''; -print $langs->trans("AutoPrintTickets"); -print ''; -print $form->selectyesno("TAKEPOS_AUTO_PRINT_TICKETS", $conf->global->TAKEPOS_AUTO_PRINT_TICKETS, 1); -print "\n"; - // Root category for products print ''; print $form->textwithpicto($langs->trans("RootCategoryForProductsToSell"), $langs->trans("RootCategoryForProductsToSellDesc")); @@ -173,31 +161,6 @@ print $form->select_all_categories(Categorie::TYPE_PRODUCT, $conf->global->TAKEP print ajax_combobox('TAKEPOS_ROOT_CATEGORY_ID'); print "\n"; -if ($conf->receiptprinter->enabled) { - // Use Dolibarr printing - print ''; - print $langs->trans("DolibarrReceiptPrinterModule"); - print ''; - print $form->selectyesno("TAKEPOS_DOLIBARR_PRINTER", $conf->global->TAKEPOS_DOLIBARR_PRINTER, 1); - print "\n"; -} - -// Use Takepos printing -print ''; -print $langs->trans("DolibarrReceiptPrinter").' ('.$langs->trans("TakeposConnectorNecesary").')'; -print ''; -print $form->selectyesno("TAKEPOSCONNECTOR", $conf->global->TAKEPOSCONNECTOR, 1); -print "\n"; - -if ($conf->global->TAKEPOSCONNECTOR) { - print ''; - print $langs->trans("IPAddress").' ('.$langs->trans("TakeposConnectorNecesary").')'; - print ''; - print ''; - print ''; -} - - // Bar Restaurant mode print ''; print $langs->trans("EnableBarOrRestaurantFeatures"); @@ -206,7 +169,7 @@ print ''; print $form->selectyesno("TAKEPOS_BAR_RESTAURANT", $conf->global->TAKEPOS_BAR_RESTAURANT, 1); print "\n"; -if ($conf->global->TAKEPOS_BAR_RESTAURANT && $conf->global->TAKEPOSCONNECTOR) { +if ($conf->global->TAKEPOS_BAR_RESTAURANT && $conf->global->TAKEPOS_PRINT_METHOD != "browser") { print ''; print $langs->trans("OrderPrinters").' ('.$langs->trans("Setup").')'; print ''; @@ -276,6 +239,7 @@ $substitutionarray['__(AnyTranslationKey)__']=$langs->trans("Translation"); $htmltext = ''.$langs->trans("AvailableVariables").':
'; foreach($substitutionarray as $key => $val) $htmltext.=$key.'
'; $htmltext.='
'; + // Color theme print ''; print $langs->trans("ColorTheme"); @@ -291,13 +255,6 @@ print ''; print $form->selectyesno("TAKEPOS_DIRECT_PAYMENT", $conf->global->TAKEPOS_DIRECT_PAYMENT, 1); print "\n"; -// Custom Receipt -print ''; -print $langs->trans('CustomReceipt'); -print ''; -print $form->selectyesno("TAKEPOS_CUSTOM RECEIPT", $conf->global->TAKEPOS_CUSTOM_RECEIPT, 1); -print "\n"; - // Head Bar /*print ''; print $langs->trans('HeadBar'); diff --git a/htdocs/takepos/admin/terminal.php b/htdocs/takepos/admin/terminal.php index b30cb4e7032..0894ab734f8 100644 --- a/htdocs/takepos/admin/terminal.php +++ b/htdocs/takepos/admin/terminal.php @@ -209,7 +209,7 @@ if (!empty($conf->stock->enabled)) print ''; } -if ($conf->receiptprinter->enabled) { +if ($conf->global->TAKEPOS_PRINT_METHOD == "receiptprinter") { // Select printer to use with terminal require_once DOL_DOCUMENT_ROOT.'/core/class/dolreceiptprinter.class.php'; $printer = new dolReceiptPrinter($db); diff --git a/htdocs/takepos/invoice.php b/htdocs/takepos/invoice.php index 77c59b090ca..a01cc04d416 100644 --- a/htdocs/takepos/invoice.php +++ b/htdocs/takepos/invoice.php @@ -504,9 +504,9 @@ if ($action == "valid" || $action == "history") else $sectionwithinvoicelink .= $langs->trans('BillShortStatusValidated'); } $sectionwithinvoicelink .= ''; - if ($conf->global->TAKEPOSCONNECTOR) { + if ($conf->global->TAKEPOS_PRINT_METHOD == "takeposconnector"){ $sectionwithinvoicelink .= ' '; - } elseif ($conf->global->TAKEPOS_DOLIBARR_PRINTER) { + } elseif ($conf->global->TAKEPOS_PRINT_METHOD == "receiptprinter"){ $sectionwithinvoicelink .= ' '; } else { $sectionwithinvoicelink .= ' '; diff --git a/htdocs/takepos/takepos.php b/htdocs/takepos/takepos.php index 75145154c22..bd559c043b4 100644 --- a/htdocs/takepos/takepos.php +++ b/htdocs/takepos/takepos.php @@ -768,13 +768,13 @@ if ($conf->global->TAKEPOS_BAR_RESTAURANT) //add temp ticket button if ($conf->global->TAKEPOS_BAR_RESTAURANT) { - if ($conf->global->TAKEPOSCONNECTOR) { + if ($conf->global->TAKEPOS_PRINT_METHOD == "takeposconnector"){ $menus[$r++] = array('title'=>'
'.$langs->trans("Receipt").'
', 'action'=>'TakeposPrinting(placeid);'); } else { $menus[$r++] = array('title'=>'
'.$langs->trans("Receipt").'
', 'action'=>'Print(placeid);'); } } - if ($conf->global->TAKEPOSCONNECTOR && $conf->global->TAKEPOS_ORDER_NOTES == 1) + if ($conf->global->TAKEPOS_PRINT_METHOD == "takeposconnector" && $conf->global->TAKEPOS_ORDER_NOTES == 1) { $menus[$r++] = array('title'=>'
'.$langs->trans("OrderNotes").'
', 'action'=>'TakeposOrderNotes();'); } @@ -784,10 +784,10 @@ if ($conf->global->TAKEPOS_BAR_RESTAURANT) } } -if ($conf->global->TAKEPOSCONNECTOR) { +if ($conf->global->TAKEPOS_PRINT_METHOD == "takeposconnector"){ $menus[$r++] = array('title'=>'
'.$langs->trans("DOL_OPEN_DRAWER").'
', 'action'=>'OpenDrawer();'); } -if ($conf->global->TAKEPOS_DOLIBARR_PRINTER) { +if ($conf->global->TAKEPOS_PRINT_METHOD == "receiptprinter") { $menus[$r++] = array( 'title' => '
'.$langs->trans("DOL_OPEN_DRAWER").'
', 'action' => 'DolibarrOpenDrawer();', From 593091f39964dd15e0e6429653b0ba547a70f508 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 20 Feb 2020 15:25:32 +0100 Subject: [PATCH 029/312] FIX etrafield with visibilty=5 were not in read only FIX CSS FIX option for topbar search and bookmarks Conflicts: htdocs/theme/eldy/global.inc.php --- htdocs/core/tpl/extrafields_view.tpl.php | 4 +- htdocs/main.inc.php | 6 ++- htdocs/theme/eldy/dropdown.inc.php | 56 ++++++++++++++++++++++-- htdocs/theme/eldy/global.inc.php | 6 +++ 4 files changed, 65 insertions(+), 7 deletions(-) diff --git a/htdocs/core/tpl/extrafields_view.tpl.php b/htdocs/core/tpl/extrafields_view.tpl.php index f8767a82163..1ef3ef07255 100644 --- a/htdocs/core/tpl/extrafields_view.tpl.php +++ b/htdocs/core/tpl/extrafields_view.tpl.php @@ -73,7 +73,7 @@ if (empty($reshook) && is_array($extrafields->attributes[$object->table_element] //print $key.'-'.$enabled.'-'.$perms.'-'.$label.$_POST["options_" . $key].'
'."\n"; if (empty($enabled)) continue; // 0 = Never visible field - if (abs($enabled) != 1 && abs($enabled) != 3) continue; // <> -1 and <> 1 and <> 3 = not visible on forms, only on list + if (abs($enabled) != 1 && abs($enabled) != 3 && abs($enabled) != 5) continue; // <> -1 and <> 1 and <> 3 = not visible on forms, only on list if (empty($perms)) continue; // 0 = Not visible // Load language if required @@ -135,7 +135,7 @@ if (empty($reshook) && is_array($extrafields->attributes[$object->table_element] if ($object->element == 'productlot') $permok = $user->rights->stock->creer; if ($object->element == 'facturerec') $permok = $user->rights->facture->creer; if (($object->statut == 0 || !empty($extrafields->attributes[$object->table_element]['alwayseditable'][$key])) - && $permok && ($action != 'edit_extras' || GETPOST('attribute') != $key) + && $permok && $enabled != 5 && ($action != 'edit_extras' || GETPOST('attribute') != $key) && empty($extrafields->attributes[$object->table_element]['computed'][$key])) { $fieldid = 'id'; diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index 01a999c6a8b..438dbcda4ec 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -2031,7 +2031,7 @@ function top_menu_search() - '; @@ -2062,7 +2062,8 @@ function top_menu_search() // close drop down $(document).on("click", function(event) { - if (!$(event.target).closest("#topmenu-global-search-dropdown").length) { + if (!$(event.target).closest("#topmenu-global-search-dropdown").length) { + console.log("click close"); // Hide the menus. $("#topmenu-global-search-dropdown").removeClass("open"); } @@ -2070,6 +2071,7 @@ function top_menu_search() // Open drop down $("#topmenu-global-search-dropdown .dropdown-toggle").on("click", function(event) { + console.log("click open"); openGlobalSearchDropDown(); }); diff --git a/htdocs/theme/eldy/dropdown.inc.php b/htdocs/theme/eldy/dropdown.inc.php index fb8856d4687..63b7a268440 100644 --- a/htdocs/theme/eldy/dropdown.inc.php +++ b/htdocs/theme/eldy/dropdown.inc.php @@ -5,10 +5,60 @@ if (! defined('ISLOADEDBYSTEELSHEET')) die('Must be call by steelsheet'); ?> * Dropdown of user popup */ -.open>.dropdown-menu{ +button.dropdown-item.global-search-item { + outline: none; +} + +.open>.dropdown-search, .open>.dropdown-bookmark, .open>.dropdown-menu{ display: block; } +.dropdown-search { + border-color: #eee; + + position: absolute; + top: 100%; + left: 0; + z-index: 1000; + display: none; + float: left; + min-width: 160px; + margin: 2px 0 0; + font-size: 14px; + text-align: left; + list-style: none; + background-color: #fff; + -webkit-background-clip: padding-box; + background-clip: padding-box; + border: 1px solid #ccc; + border: 1px solid rgba(0,0,0,.15); + border-radius: 4px; + -webkit-box-shadow: 0 6px 12px rgba(0,0,0,.175); + box-shadow: 0 6px 12px rgba(0,0,0,.175); +} +.dropdown-bookmark { + border-color: #eee; + + position: absolute; + top: 100%; + left: 0; + z-index: 1000; + display: none; + float: left; + min-width: 160px; + margin: 2px 0 0; + font-size: 14px; + text-align: left; + list-style: none; + background-color: #fff; + -webkit-background-clip: padding-box; + background-clip: padding-box; + border: 1px solid #ccc; + border: 1px solid rgba(0,0,0,.15); + border-radius: 4px; + -webkit-box-shadow: 0 6px 12px rgba(0,0,0,.175); + box-shadow: 0 6px 12px rgba(0,0,0,.175); +} .dropdown-menu { border-color: #eee; @@ -34,7 +84,6 @@ if (! defined('ISLOADEDBYSTEELSHEET')) die('Must be call by steelsheet'); ?> } - .dropdown-toggle{ text-decoration: none !important; } @@ -177,7 +226,8 @@ a.top-menu-dropdown-link { .dropdown-body::-webkit-scrollbar-thumb { -webkit-border-radius: 0; border-radius: 0; - background: rgb(); + /* background: rgb(); */ + background: #aaa; } .dropdown-body::-webkit-scrollbar-track { -webkit-box-shadow: inset 0 0 6px rgba(0,0,0,0.3); diff --git a/htdocs/theme/eldy/global.inc.php b/htdocs/theme/eldy/global.inc.php index 670734e6706..fa4f751d6a6 100644 --- a/htdocs/theme/eldy/global.inc.php +++ b/htdocs/theme/eldy/global.inc.php @@ -1539,6 +1539,7 @@ div#id-top { background: rgb(); background-image: linear-gradient(-45deg, , rgb()); + /* box-shadow: 0px 0px 5px #eee; */ } @@ -4764,6 +4765,11 @@ div.dataTables_length select { /* Select2 */ /* ============================================================================== */ +.select2-container--default .select2-results__option--highlighted[aria-selected] { + background-color: rgb(); + color: #; +} + .select2-container--focus span.select2-selection.select2-selection--single { border-bottom: 1px solid #666 !important; } From 7200472427f461a0f176ddb57276ddda3cbd0b5d Mon Sep 17 00:00:00 2001 From: andreubisquerra Date: Thu, 20 Feb 2020 15:45:42 +0100 Subject: [PATCH 030/312] Travis fix --- htdocs/takepos/admin/receipt.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/htdocs/takepos/admin/receipt.php b/htdocs/takepos/admin/receipt.php index ef31bc2392c..7a87e13ff97 100644 --- a/htdocs/takepos/admin/receipt.php +++ b/htdocs/takepos/admin/receipt.php @@ -48,7 +48,6 @@ if (GETPOST('action', 'alpha') == 'set') $res = dolibarr_set_const($db, "TAKEPOS_SHOW_CUSTOMER", GETPOST('TAKEPOS_SHOW_CUSTOMER', 'alpha'), 'chaine', 0, '', $conf->entity); $res = dolibarr_set_const($db, "TAKEPOS_AUTO_PRINT_TICKETS", GETPOST('TAKEPOS_AUTO_PRINT_TICKETS', 'int'), 'int', 0, '', $conf->entity); $res = dolibarr_set_const($db, "TAKEPOS_PRINT_SERVER", GETPOST('TAKEPOS_PRINT_SERVER', 'alpha'), 'chaine', 0, '', $conf->entity); - dol_syslog("admin/cashdesk: level ".GETPOST('level', 'alpha')); @@ -185,7 +184,7 @@ if ($conf->global->TAKEPOS_PRINT_METHOD == "browser" || $conf->global->TAKEPOS_P print $doleditor->Create(); } print "\n"; - + print ''; print $form->textwithpicto($langs->trans("FreeLegalTextOnInvoices")." - ".$langs->trans("Footer"), $htmltext, 1, 'help', '', 0, 2, 'freetexttooltip').'
'; print ''; From 7a241ba0421a833f1933e605da5228b494b55ea2 Mon Sep 17 00:00:00 2001 From: andreubisquerra Date: Thu, 20 Feb 2020 15:47:40 +0100 Subject: [PATCH 031/312] Fix travis --- htdocs/core/modules/modTakePos.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/modules/modTakePos.class.php b/htdocs/core/modules/modTakePos.class.php index 2243437d20f..f3af7016d05 100644 --- a/htdocs/core/modules/modTakePos.class.php +++ b/htdocs/core/modules/modTakePos.class.php @@ -266,9 +266,9 @@ class modTakePos extends DolibarrModules public function init($options = '') { global $conf,$db; - + dolibarr_set_const($db, "TAKEPOS_PRINT_METHOD", "browser", 'chaine', 0, '', $conf->entity); - + $this->_load_tables('/takepos/sql/'); $sql = array(); From 4630525973d1c1fff57dc1d3254b27a3aa66e20c Mon Sep 17 00:00:00 2001 From: DEMAREST Maxime Date: Thu, 20 Feb 2020 16:19:28 +0100 Subject: [PATCH 032/312] Fix: Mouvementstock::get_origin modulenme whith origintype --- htdocs/product/stock/class/mouvementstock.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/product/stock/class/mouvementstock.class.php b/htdocs/product/stock/class/mouvementstock.class.php index aab0d428191..6bfe890cd64 100644 --- a/htdocs/product/stock/class/mouvementstock.class.php +++ b/htdocs/product/stock/class/mouvementstock.class.php @@ -984,7 +984,7 @@ class MouvementStock extends CommonObject // Separate originetype with "@" : left part is class name, right part is module name $origintype_array = explode('@', $origintype); $classname = ucfirst($origintype_array[0]); - $modulename = empty($origintype_array[1]) ? $classname : empty($origintype_array[1]); + $modulename = empty($origintype_array[1]) ? $classname : $origintype_array[1]; $result=dol_include_once('/'.$modulename.'/class/'.strtolower($classname).'.class.php'); if ($result) { From e316061a9aaa02e313b46d76083906880308e496 Mon Sep 17 00:00:00 2001 From: andreubisquerra Date: Thu, 20 Feb 2020 16:26:30 +0100 Subject: [PATCH 033/312] Fix travis --- htdocs/core/modules/modTakePos.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/modules/modTakePos.class.php b/htdocs/core/modules/modTakePos.class.php index f3af7016d05..4671f40dd40 100644 --- a/htdocs/core/modules/modTakePos.class.php +++ b/htdocs/core/modules/modTakePos.class.php @@ -266,9 +266,9 @@ class modTakePos extends DolibarrModules public function init($options = '') { global $conf,$db; - + dolibarr_set_const($db, "TAKEPOS_PRINT_METHOD", "browser", 'chaine', 0, '', $conf->entity); - + $this->_load_tables('/takepos/sql/'); $sql = array(); From 02a5c1b8d6a5a0fa334f62e7c5a439d5b81a3224 Mon Sep 17 00:00:00 2001 From: Anthony Berton <34568357+bb2a@users.noreply.github.com> Date: Thu, 20 Feb 2020 22:40:43 +0100 Subject: [PATCH 034/312] Update card.php --- htdocs/commande/card.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php index d4855e8933f..737a544eda8 100644 --- a/htdocs/commande/card.php +++ b/htdocs/commande/card.php @@ -112,6 +112,10 @@ $permissionnote = $usercancreate; // Used by the include of actions_setnotes.i $permissiondellink = $usercancreate; // Used by the include of actions_dellink.inc.php $permissiontoadd = $usercancreate; // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php +if (!empty($conf->expedition->enabled)){ + if (empty($object->warehouse_id) && !empty($conf->global->MAIN_DEFAULT_WAREHOUSE)) $object->warehouse_id = $conf->global->MAIN_DEFAULT_WAREHOUSE; + if (empty($object->warehouse_id) && !empty($conf->global->MAIN_DEFAULT_WAREHOUSE_USER)) $object->warehouse_id = $user->fk_warehouse; +} /* * Actions From bbb108133f36989b356f7f0e94dc185769c6be39 Mon Sep 17 00:00:00 2001 From: Anthony Berton <34568357+bb2a@users.noreply.github.com> Date: Thu, 20 Feb 2020 22:45:03 +0100 Subject: [PATCH 035/312] Update html.formproduct.class.php --- htdocs/product/class/html.formproduct.class.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/htdocs/product/class/html.formproduct.class.php b/htdocs/product/class/html.formproduct.class.php index af78ab5b59d..6443b0d03a3 100644 --- a/htdocs/product/class/html.formproduct.class.php +++ b/htdocs/product/class/html.formproduct.class.php @@ -254,6 +254,9 @@ class FormProduct $out.= $comboenhancement; } + if (empty($selected) && !empty($conf->global->MAIN_DEFAULT_WAREHOUSE)) $selected = $conf->global->MAIN_DEFAULT_WAREHOUSE; + if (empty($selected) && !empty($conf->global->MAIN_DEFAULT_WAREHOUSE_USER)) $selected = $user->fk_warehouse; + $out.=''; diff --git a/htdocs/core/class/html.formwebsite.class.php b/htdocs/core/class/html.formwebsite.class.php index 6cd88175a67..7b067fa11d6 100644 --- a/htdocs/core/class/html.formwebsite.class.php +++ b/htdocs/core/class/html.formwebsite.class.php @@ -269,7 +269,15 @@ class FormWebsite $valueforoption = '['.$valpage->type_container.' '.sprintf("%03d", $valpage->id).'] '; $valueforoption .= $valpage->pageurl.' - '.$valpage->title; - if ($website->fk_default_home && $key == $website->fk_default_home) $valueforoption .= ' ('.$langs->trans("HomePage").')'; + if ($website->otherlang) { // If there is alternative lang for this web site, we show the language code + if ($valpage->lang) { + $valueforoption .= ' ('.$valpage->lang.')'; + } + } + if ($website->fk_default_home && $key == $website->fk_default_home) { + //$valueforoption .= ' ('.$langs->trans("HomePage").')'; + $valueforoption .= ' '; + } $out .= '