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 01/94] 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 02/94] 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 03/94] 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 04/94] 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 05/94] 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 06/94] 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 07/94] 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 08/94] 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 09/94] 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 10/94] 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 11/94] 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 828aa9bd93cc8a4ecc3069b9071196e4984c1e65 Mon Sep 17 00:00:00 2001 From: David Beniamine Date: Fri, 29 Nov 2019 15:59:25 +0100 Subject: [PATCH 12/94] Sort products by reference --- htdocs/takepos/ajax.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/htdocs/takepos/ajax.php b/htdocs/takepos/ajax.php index 74f69618a0f..f889615660e 100644 --- a/htdocs/takepos/ajax.php +++ b/htdocs/takepos/ajax.php @@ -46,6 +46,10 @@ if ($action=="getProducts") { $object = new Categorie($db); $result=$object->fetch($category); $prods = $object->getObjectsInCateg("product"); + function sort_by_ref($a, $b) { + return strcmp($a->ref, $b->ref); + } + usort($prods, "sort_by_ref"); echo json_encode($prods); } elseif ($action=="search" && $term != '') { 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 13/94] 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 14/94] 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 15/94] 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 305a821b623e4e14be7f3e1fbb7c11ee8038c654 Mon Sep 17 00:00:00 2001 From: David Beniamine Date: Mon, 16 Dec 2019 17:30:31 +0100 Subject: [PATCH 16/94] TakePOS : setting to choose product field for sort --- htdocs/categories/class/categorie.class.php | 9 ++++++++- htdocs/takepos/admin/setup.php | 13 +++++++++++++ htdocs/takepos/ajax.php | 6 +----- 3 files changed, 22 insertions(+), 6 deletions(-) diff --git a/htdocs/categories/class/categorie.class.php b/htdocs/categories/class/categorie.class.php index f31e8f9b048..489b4034e3a 100644 --- a/htdocs/categories/class/categorie.class.php +++ b/htdocs/categories/class/categorie.class.php @@ -748,10 +748,11 @@ class Categorie extends CommonObject * * @param string $type Type of category ('customer', 'supplier', 'contact', 'product', 'member') * @param int $onlyids Return only ids of objects (consume less memory) + * @param string $orderby field for order * @return array|int -1 if KO, array of instance of object if OK * @see containsObject() */ - public function getObjectsInCateg($type, $onlyids = 0) + public function getObjectsInCateg($type, $onlyids = 0, $orderby='') { $objs = array(); @@ -763,6 +764,12 @@ class Categorie extends CommonObject $sql .= " WHERE o.entity IN (" . getEntity($obj->element).")"; $sql.= " AND c.fk_categorie = ".$this->id; $sql .= " AND c.fk_" . $this->MAP_CAT_FK[$type] . " = o.rowid"; + if ($orderby) { + $prod = new Product($db); + if(array_key_exists($orderby, $prod->fields)){ + $sql .= " ORDER BY $orderby"; + } + } dol_syslog(get_class($this)."::getObjectsInCateg", LOG_DEBUG); $resql = $this->db->query($sql); diff --git a/htdocs/takepos/admin/setup.php b/htdocs/takepos/admin/setup.php index f331587723b..1c9aa911e82 100644 --- a/htdocs/takepos/admin/setup.php +++ b/htdocs/takepos/admin/setup.php @@ -77,6 +77,7 @@ if (GETPOST('action', 'alpha') == 'set') $res = dolibarr_set_const($db, "TAKEPOS_HEADER", GETPOST('TAKEPOS_HEADER', 'alpha'), 'chaine', 0, '', $conf->entity); $res = dolibarr_set_const($db, "TAKEPOS_FOOTER", GETPOST('TAKEPOS_FOOTER', 'alpha'), 'chaine', 0, '', $conf->entity); $res = dolibarr_set_const($db, "TAKEPOS_NUMPAD", GETPOST('TAKEPOS_NUMPAD', 'alpha'), 'chaine', 0, '', $conf->entity); + $res = dolibarr_set_const($db, "TAKEPOS_SORTPRODUCTFIELD", GETPOST('TAKEPOS_SORTPRODUCTFIELD', 'alpha'), 'chaine', 0, '', $conf->entity); $res = dolibarr_set_const($db, "TAKEPOS_NUM_TERMINALS", GETPOST('TAKEPOS_NUM_TERMINALS', 'alpha'), 'chaine', 0, '', $conf->entity); if ($conf->global->TAKEPOS_ORDER_NOTES==1) @@ -213,6 +214,18 @@ $array=array(0=>$langs->trans("Numberspad"), 1=>$langs->trans("BillsCoinsPad")); print $form->selectarray('TAKEPOS_NUMPAD', $array, (empty($conf->global->TAKEPOS_NUMPAD)?'0':$conf->global->TAKEPOS_NUMPAD), 0); print "\n"; +// Sort product +print ''; +print $langs->trans("SortProductField"); +print ''; +$prod = new Product($db); +$array = []; +foreach($prod->fields as $k => $v) { + $array[$k]=$k; +} +print $form->selectarray('TAKEPOS_SORTPRODUCTFIELD', $array, (empty($conf->global->TAKEPOS_SORTPRODUCTFIELD)?'rowid':$conf->global->TAKEPOS_SORTPRODUCTFIELD), 0); +print "\n"; + $substitutionarray=pdf_getSubstitutionArray($langs, null, null, 2); $substitutionarray['__(AnyTranslationKey)__']=$langs->trans("Translation"); $htmltext = ''.$langs->trans("AvailableVariables").':
'; diff --git a/htdocs/takepos/ajax.php b/htdocs/takepos/ajax.php index f889615660e..415f6c6f680 100644 --- a/htdocs/takepos/ajax.php +++ b/htdocs/takepos/ajax.php @@ -45,11 +45,7 @@ $term = GETPOST('term', 'alpha'); if ($action=="getProducts") { $object = new Categorie($db); $result=$object->fetch($category); - $prods = $object->getObjectsInCateg("product"); - function sort_by_ref($a, $b) { - return strcmp($a->ref, $b->ref); - } - usort($prods, "sort_by_ref"); + $prods = $object->getObjectsInCateg("product", 0, $conf->global->TAKEPOS_SORTPRODUCTFIELD); echo json_encode($prods); } elseif ($action=="search" && $term != '') { From f1bbe1c64da6c6f6441af4a5f3d93a9ed6cc935b Mon Sep 17 00:00:00 2001 From: Pierre Ardoin <32256817+mapiolca@users.noreply.github.com> Date: Mon, 17 Feb 2020 19:09:58 +0100 Subject: [PATCH 17/94] Fix issue not show photo. --- htdocs/core/boxes/box_clients.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/core/boxes/box_clients.php b/htdocs/core/boxes/box_clients.php index ea2a7814f14..bb5b7023264 100644 --- a/htdocs/core/boxes/box_clients.php +++ b/htdocs/core/boxes/box_clients.php @@ -95,7 +95,7 @@ class box_clients extends ModeleBoxes $sql.= ", s.code_compta_fournisseur"; $sql.= ", s.logo"; $sql.= ", s.email"; - $sql.= ", s.datec, s.tms, s.status"; + $sql.= ", s.datec, s.tms, s.status, s.entity"; $sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; $sql.= " WHERE s.client IN (1, 3)"; @@ -127,6 +127,7 @@ class box_clients extends ModeleBoxes $thirdpartystatic->fournisseur = $objp->fournisseur; $thirdpartystatic->logo = $objp->logo; $thirdpartystatic->email = $objp->email; + $thirdpartystatic->entity = $objp->entity; $this->info_box_contents[$line][] = array( 'td' => '', From 29cfd6d8579ef138e58bf908c0392f7a47b2704a Mon Sep 17 00:00:00 2001 From: Pierre Ardoin <32256817+mapiolca@users.noreply.github.com> Date: Mon, 17 Feb 2020 19:18:22 +0100 Subject: [PATCH 18/94] Fix issue with Multicompany Before : can't find photo Now : ok --- htdocs/core/boxes/box_propales.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/htdocs/core/boxes/box_propales.php b/htdocs/core/boxes/box_propales.php index 6bf6a2c2166..3edb4d84c0c 100644 --- a/htdocs/core/boxes/box_propales.php +++ b/htdocs/core/boxes/box_propales.php @@ -3,6 +3,7 @@ * Copyright (C) 2004-2007 Laurent Destailleur * Copyright (C) 2005-2009 Regis Houssin * Copyright (C) 2015 Frederic France + * Copyright (C) 2020 Pierre Ardoin * * 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 @@ -84,7 +85,7 @@ class box_propales extends ModeleBoxes if ($user->rights->propale->lire) { - $sql = "SELECT s.nom as name, s.rowid as socid, s.code_client, s.logo,"; + $sql = "SELECT s.nom as name, s.rowid as socid, s.code_client, s.logo, s.entity,"; $sql.= " p.rowid, p.ref, p.fk_statut, p.datep as dp, p.datec, p.fin_validite, p.date_cloture, p.total_ht, p.tva as total_tva, p.total as total_ttc, p.tms"; $sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; $sql.= ", ".MAIN_DB_PREFIX."propal as p"; @@ -121,6 +122,7 @@ class box_propales extends ModeleBoxes $societestatic->name = $objp->name; $societestatic->code_client = $objp->code_client; $societestatic->logo = $objp->logo; + $societestatic->entity = $objp->entity; $late = ''; if ($objp->fk_statut == 1 && $dateterm < ($now - $conf->propal->cloture->warning_delay)) { From a773b86ad18dae65b866435b4e176f9d97cbd240 Mon Sep 17 00:00:00 2001 From: Pierre Ardoin <32256817+mapiolca@users.noreply.github.com> Date: Mon, 17 Feb 2020 19:23:48 +0100 Subject: [PATCH 19/94] Fix not displayed value --- htdocs/core/boxes/box_fournisseurs.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/htdocs/core/boxes/box_fournisseurs.php b/htdocs/core/boxes/box_fournisseurs.php index 01f62bc38c9..4922d9556c1 100644 --- a/htdocs/core/boxes/box_fournisseurs.php +++ b/htdocs/core/boxes/box_fournisseurs.php @@ -2,6 +2,7 @@ /* Copyright (C) 2004-2006 Destailleur Laurent * Copyright (C) 2005-2009 Regis Houssin * Copyright (C) 2015 Frederic France + * Copyright (C) 2020 Pierre Ardoin * * 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 @@ -86,7 +87,7 @@ class box_fournisseurs extends ModeleBoxes { $sql = "SELECT s.nom as name, s.rowid as socid, s.datec, s.tms, s.status,"; $sql.= " s.code_fournisseur,"; - $sql.= " s.logo"; + $sql.= " s.logo, s.email, s.code_compta_fournisseur, s.entity"; $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; $sql.= " WHERE s.fournisseur = 1"; @@ -111,6 +112,9 @@ class box_fournisseurs extends ModeleBoxes $thirdpartytmp->name = $objp->name; $thirdpartytmp->code_client = $objp->code_client; $thirdpartytmp->logo = $objp->logo; + $thirdpartytmp->email = $objp->email; + $thirdpartytmp->code_compta_fournisseur = $objp->code_compta_fournisseur; + $thirdpartytmp->entity = $objp->entity; $this->info_box_contents[$line][] = array( 'td' => '', From f8e18a3826dc652531747ed8d0c8787479a5570d Mon Sep 17 00:00:00 2001 From: Pierre Ardoin <32256817+mapiolca@users.noreply.github.com> Date: Mon, 17 Feb 2020 19:25:25 +0100 Subject: [PATCH 20/94] Fix Not displayed email --- htdocs/core/boxes/box_propales.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/core/boxes/box_propales.php b/htdocs/core/boxes/box_propales.php index 3edb4d84c0c..7e73166ed90 100644 --- a/htdocs/core/boxes/box_propales.php +++ b/htdocs/core/boxes/box_propales.php @@ -85,7 +85,7 @@ class box_propales extends ModeleBoxes if ($user->rights->propale->lire) { - $sql = "SELECT s.nom as name, s.rowid as socid, s.code_client, s.logo, s.entity,"; + $sql = "SELECT s.nom as name, s.rowid as socid, s.code_client, s.logo, s.entity, s.email,"; $sql.= " p.rowid, p.ref, p.fk_statut, p.datep as dp, p.datec, p.fin_validite, p.date_cloture, p.total_ht, p.tva as total_tva, p.total as total_ttc, p.tms"; $sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; $sql.= ", ".MAIN_DB_PREFIX."propal as p"; @@ -123,6 +123,7 @@ class box_propales extends ModeleBoxes $societestatic->code_client = $objp->code_client; $societestatic->logo = $objp->logo; $societestatic->entity = $objp->entity; + $societestatic->email = $objp->email; $late = ''; if ($objp->fk_statut == 1 && $dateterm < ($now - $conf->propal->cloture->warning_delay)) { From ef64e203671d9bb1618e1acb2512af4204e6fe3a Mon Sep 17 00:00:00 2001 From: Pierre Ardoin <32256817+mapiolca@users.noreply.github.com> Date: Mon, 17 Feb 2020 19:34:09 +0100 Subject: [PATCH 21/94] Fix not display value --- htdocs/societe/index.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/htdocs/societe/index.php b/htdocs/societe/index.php index 2404c11861e..e5b49ee3bea 100644 --- a/htdocs/societe/index.php +++ b/htdocs/societe/index.php @@ -267,7 +267,10 @@ $max=15; $sql = "SELECT s.rowid, s.nom as name, s.email, s.client, s.fournisseur"; $sql.= ", s.code_client"; $sql.= ", s.code_fournisseur"; +$sql.= ", s.code_compta_fournisseur"; +$sql.= ", s.code_compta"; $sql.= ", s.logo"; +$sql.= ", s.entity"; $sql.= ", s.canvas, s.tms as datem, s.status as status"; $sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; if (! $user->rights->societe->client->voir && ! $socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; @@ -314,6 +317,9 @@ if ($result) $thirdparty_static->code_fournisseur = $objp->code_fournisseur; $thirdparty_static->canvas=$objp->canvas; $thirdparty_static->email = $objp->email; + $thirdparty_static->entity = $objp->entity; + $thirdparty_static->code_compta_fournisseur = $objp->code_compta_fournisseur; + $thirdparty_static->code_compta = $objp->code_compta; print ''; // Name From 49dd8e30aae0005ce4c8cc540af612ed71db3a5c Mon Sep 17 00:00:00 2001 From: Pierre Ardoin <32256817+mapiolca@users.noreply.github.com> Date: Tue, 18 Feb 2020 08:28:39 +0100 Subject: [PATCH 22/94] Fix not display data --- htdocs/comm/index.php | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/htdocs/comm/index.php b/htdocs/comm/index.php index 651d2c54ec7..c374120c8d2 100644 --- a/htdocs/comm/index.php +++ b/htdocs/comm/index.php @@ -3,6 +3,7 @@ * Copyright (C) 2004-2015 Laurent Destailleur * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2015 Jean-François Ferry + * Copyright (C) 2020 Pierre Ardoin * * 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 @@ -141,6 +142,9 @@ if (! empty($conf->propal->enabled) && $user->rights->propal->lire) $sql = "SELECT p.rowid, p.ref, p.ref_client, p.total_ht, p.tva as total_tva, p.total as total_ttc, s.rowid as socid, s.nom as name, s.client, s.canvas"; $sql.= ", s.code_client"; + $sql.= ", s.email"; + $sql.= ", s.entity"; + $sql.= ", s.code_compta"; $sql.= " FROM ".MAIN_DB_PREFIX."propal as p"; $sql.= ", ".MAIN_DB_PREFIX."societe as s"; if (! $user->rights->societe->client->voir && ! $socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; @@ -184,6 +188,9 @@ if (! empty($conf->propal->enabled) && $user->rights->propal->lire) $companystatic->client=$obj->client; $companystatic->code_client = $obj->code_client; $companystatic->code_fournisseur = $obj->code_fournisseur; + $companystatic->entity = $obj->entity; + $companystatic->email = $obj->email; + $companystatic->code_compta = $obj->code_compta; $companystatic->canvas=$obj->canvas; print $companystatic->getNomUrl(1, 'customer', 16); print ''; @@ -226,6 +233,8 @@ if (! empty($conf->supplier_proposal->enabled) && $user->rights->supplier_propos $sql = "SELECT p.rowid, p.ref, p.total_ht, p.tva as total_tva, p.total as total_ttc, s.rowid as socid, s.nom as name, s.client, s.canvas"; $sql.= ", s.code_client"; + $sql.= ", s.entity"; + $sql.= ", s.email"; $sql.= " FROM ".MAIN_DB_PREFIX."supplier_proposal as p"; $sql.= ", ".MAIN_DB_PREFIX."societe as s"; if (! $user->rights->societe->client->voir && ! $socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; @@ -268,6 +277,8 @@ if (! empty($conf->supplier_proposal->enabled) && $user->rights->supplier_propos $companystatic->client=$obj->client; $companystatic->code_client = $obj->code_client; $companystatic->code_fournisseur = $obj->code_fournisseur; + $companystatic->entity = $obj->entity; + $companystatic->email = $obj->email; $companystatic->canvas=$obj->canvas; print $companystatic->getNomUrl(1, 'supplier', 16); print ''; @@ -308,6 +319,9 @@ if (! empty($conf->commande->enabled) && $user->rights->commande->lire) $sql = "SELECT c.rowid, c.ref, c.ref_client, c.total_ht, c.tva as total_tva, c.total_ttc, s.rowid as socid, s.nom as name, s.client, s.canvas"; $sql.= ", s.code_client"; + $sql.= ", s.email"; + $sql.= ", s.entity"; + $sql.= ", s.code_compta"; $sql.= " FROM ".MAIN_DB_PREFIX."commande as c"; $sql.= ", ".MAIN_DB_PREFIX."societe as s"; if (! $user->rights->societe->client->voir && ! $socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; @@ -350,6 +364,9 @@ if (! empty($conf->commande->enabled) && $user->rights->commande->lire) $companystatic->client=$obj->client; $companystatic->code_client = $obj->code_client; $companystatic->code_fournisseur = $obj->code_fournisseur; + $companystatic->canvas=$obj->canvas; + $companystatic->email=$obj->email; + $companystatic->entity=$obj->entity; $companystatic->canvas=$obj->canvas; print $companystatic->getNomUrl(1, 'customer', 16); print ''; @@ -398,6 +415,8 @@ if (! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->commande $sql = "SELECT cf.rowid, cf.ref, cf.ref_supplier, cf.total_ttc, s.rowid as socid, s.nom as name, s.client, s.canvas"; $sql.= ", s.code_client"; $sql.= ", s.code_fournisseur"; + $sql.= ", s.entity"; + $sql.= ", s.email"; $sql.= " FROM ".MAIN_DB_PREFIX."commande_fournisseur as cf"; $sql.= ", ".MAIN_DB_PREFIX."societe as s"; if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; @@ -441,6 +460,8 @@ if (! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->commande $companystatic->client=$obj->client; $companystatic->code_client = $obj->code_client; $companystatic->code_fournisseur = $obj->code_fournisseur; + $companystatic->entity=$obj->entity; + $companystatic->email=$obj->email; $companystatic->canvas=$obj->canvas; print $companystatic->getNomUrl(1, 'supplier', 16); print ''; @@ -492,6 +513,9 @@ if (! empty($conf->societe->enabled) && $user->rights->societe->lire) $sql = "SELECT s.rowid, s.nom as name, s.client, s.datec, s.tms, s.canvas"; $sql.= ", s.code_client"; + $sql.= ", s.code_compta"; + $sql.= ", s.entity"; + $sql.= ", s.email"; $sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; if (! $user->rights->societe->client->voir && ! $socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; $sql.= " WHERE s.client IN (1, 2, 3)"; @@ -527,6 +551,9 @@ if (! empty($conf->societe->enabled) && $user->rights->societe->lire) $companystatic->client=$objp->client; $companystatic->code_client = $objp->code_client; $companystatic->code_fournisseur = $objp->code_fournisseur; + $companystatic->code_compta = $objp->code_compta; + $companystatic->entity = $objp->entity; + $companystatic->email = $objp->email; $companystatic->canvas=$objp->canvas; print ''; print ''.$companystatic->getNomUrl(1, 'customer', 48).''; @@ -556,6 +583,8 @@ if (! empty($conf->fournisseur->enabled) && $user->rights->societe->lire) $sql = "SELECT s.nom as name, s.rowid, s.datec as dc, s.canvas, s.tms as dm"; $sql.= ", s.code_fournisseur"; + $sql.= ", s.entity"; + $sql.= ", s.email"; $sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; if (! $user->rights->societe->client->voir && ! $user->societe_id) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; $sql.= " WHERE s.fournisseur = 1"; @@ -586,6 +615,8 @@ if (! empty($conf->fournisseur->enabled) && $user->rights->societe->lire) $companystatic->name=$objp->name; $companystatic->code_client = $objp->code_client; $companystatic->code_fournisseur = $objp->code_fournisseur; + $companystatic->entity = $objp->entity; + $companystatic->email = $objp->email; $companystatic->canvas=$objp->canvas; print ''; print ''.$companystatic->getNomUrl(1, 'supplier', 44).''; @@ -632,6 +663,8 @@ if (! empty($conf->contrat->enabled) && $user->rights->contrat->lire && 0) // TO $sql = "SELECT s.nom as name, s.rowid, s.canvas, "; $sql.= ", s.code_client"; + $sql.= ", s.entity"; + $sql.= ", s.email"; $sql.= " c.statut, c.rowid as contratid, p.ref, c.mise_en_service as datemes, c.fin_validite as datefin, c.date_cloture as dateclo"; $sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; $sql.= ", ".MAIN_DB_PREFIX."contrat as c"; @@ -668,6 +701,8 @@ if (! empty($conf->contrat->enabled) && $user->rights->contrat->lire && 0) // TO $companystatic->name=$objp->name; $companystatic->code_client = $objp->code_client; $companystatic->code_fournisseur = $objp->code_fournisseur; + $companystatic->entity = $objp->entity; + $companystatic->email = $objp->email; $companystatic->canvas=$objp->canvas; print $companystatic->getNomUrl(1, 'customer', 44); print ''."\n"; @@ -693,6 +728,8 @@ if (! empty($conf->propal->enabled) && $user->rights->propal->lire) $langs->load("propal"); $sql = "SELECT s.nom as name, s.rowid, s.code_client"; + $sql.= ", s.entity"; + $sql.= ", s.email"; $sql.= ", p.rowid as propalid, p.entity, p.total as total_ttc, p.total_ht, p.tva as total_tva, p.ref, p.ref_client, p.fk_statut, p.datep as dp, p.fin_validite as dfv"; $sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; $sql.= ", ".MAIN_DB_PREFIX."propal as p"; @@ -755,6 +792,8 @@ if (! empty($conf->propal->enabled) && $user->rights->propal->lire) $companystatic->client=$obj->client; $companystatic->code_client = $obj->code_client; $companystatic->code_fournisseur = $obj->code_fournisseur; + $companystatic->entity = $objp->entity; + $companystatic->email = $objp->email; $companystatic->canvas=$obj->canvas; print $companystatic->getNomUrl(1, 'customer', 44); print ''; @@ -798,6 +837,8 @@ if (! empty($conf->commande->enabled) && $user->rights->commande->lire) $sql = "SELECT s.nom as name, s.rowid, c.rowid as commandeid, c.total_ttc, c.total_ht, c.tva as total_tva, c.ref, c.ref_client, c.fk_statut, c.date_valid as dv, c.facture as billed"; $sql.= ", s.code_client"; + $sql.= ", s.entity"; + $sql.= ", s.email"; $sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; $sql.= ", ".MAIN_DB_PREFIX."commande as c"; if (! $user->rights->societe->client->voir && ! $socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; @@ -859,6 +900,8 @@ if (! empty($conf->commande->enabled) && $user->rights->commande->lire) $companystatic->client=$obj->client; $companystatic->code_client = $obj->code_client; $companystatic->code_fournisseur = $obj->code_fournisseur; + $companystatic->entity = $objp->entity; + $companystatic->email = $objp->email; $companystatic->canvas=$obj->canvas; print $companystatic->getNomUrl(1, 'customer', 44); print ''; From dbb7db376bc8c1b664b6360f46fea466944644ce Mon Sep 17 00:00:00 2001 From: Pierre Ardoin <32256817+mapiolca@users.noreply.github.com> Date: Tue, 18 Feb 2020 09:16:12 +0100 Subject: [PATCH 23/94] fix error code --- htdocs/comm/index.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/comm/index.php b/htdocs/comm/index.php index c374120c8d2..6e14e565085 100644 --- a/htdocs/comm/index.php +++ b/htdocs/comm/index.php @@ -792,8 +792,8 @@ if (! empty($conf->propal->enabled) && $user->rights->propal->lire) $companystatic->client=$obj->client; $companystatic->code_client = $obj->code_client; $companystatic->code_fournisseur = $obj->code_fournisseur; - $companystatic->entity = $objp->entity; - $companystatic->email = $objp->email; + $companystatic->entity = $obj->entity; + $companystatic->email = $obj->email; $companystatic->canvas=$obj->canvas; print $companystatic->getNomUrl(1, 'customer', 44); print ''; @@ -900,8 +900,8 @@ if (! empty($conf->commande->enabled) && $user->rights->commande->lire) $companystatic->client=$obj->client; $companystatic->code_client = $obj->code_client; $companystatic->code_fournisseur = $obj->code_fournisseur; - $companystatic->entity = $objp->entity; - $companystatic->email = $objp->email; + $companystatic->entity = $obj->entity; + $companystatic->email = $obj->email; $companystatic->canvas=$obj->canvas; print $companystatic->getNomUrl(1, 'customer', 44); print ''; From d1e9f3a5050622fbca30dbcbfe3bae0427d8dace Mon Sep 17 00:00:00 2001 From: VESSILLER Date: Tue, 18 Feb 2020 11:18:00 +0100 Subject: [PATCH 24/94] FIX keep assigned users in session when loading projects and tasks --- htdocs/comm/action/card.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/comm/action/card.php b/htdocs/comm/action/card.php index c057dc2dee3..066d5cf8b7a 100644 --- a/htdocs/comm/action/card.php +++ b/htdocs/comm/action/card.php @@ -908,7 +908,7 @@ if ($action == 'create') $numproject=$formproject->select_projects((! empty($societe->id)?$societe->id:-1), $projectid, 'projectid', 0, 0, 1, 1); print '   '.$langs->trans("AddProject").''; - $urloption='?action=create'; + $urloption = '?action=create&donotclearsession=1'; $url = dol_buildpath('comm/action/card.php', 2).$urloption; // update task list @@ -1325,7 +1325,7 @@ if ($id > 0) { print ''; - $urloption='?action=create'; // we use create not edit for more flexibility + $urloption = '?action=create&donotclearsession=1'; // we use create not edit for more flexibility $url = DOL_URL_ROOT.'/comm/action/card.php'.$urloption; // update task list From afadf9dc0e11ddf846a63a945964d2e32a91b026 Mon Sep 17 00:00:00 2001 From: Pierre Ardoin <32256817+mapiolca@users.noreply.github.com> Date: Tue, 18 Feb 2020 18:34:15 +0100 Subject: [PATCH 25/94] Fix Not Display Photo with Multicompany --- htdocs/societe/list.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/htdocs/societe/list.php b/htdocs/societe/list.php index be4b0125698..3ad44f224da 100644 --- a/htdocs/societe/list.php +++ b/htdocs/societe/list.php @@ -10,6 +10,7 @@ * Copyright (C) 2017 Rui Strecht * Copyright (C) 2017 Juanjo Menent * Copyright (C) 2018 Nicolas ZABOURI + * * 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 @@ -371,6 +372,7 @@ if ($resql) else dol_print_error($db); $sql = "SELECT s.rowid, s.nom as name, s.name_alias, s.barcode, s.town, s.zip, s.datec, s.code_client, s.code_fournisseur, s.logo,"; +$sql.= " s.entity,"; $sql.= " st.libelle as stcomm, s.fk_stcomm as stcomm_id, s.fk_prospectlevel, s.prefix_comm, s.client, s.fournisseur, s.canvas, s.status as status,"; $sql.= " s.email, s.phone, s.fax, s.url, s.siren as idprof1, s.siret as idprof2, s.ape as idprof3, s.idprof4 as idprof4, s.idprof5 as idprof5, s.idprof6 as idprof6, s.tva_intra, s.fk_pays,"; $sql.= " s.tms as date_update, s.datec as date_creation,"; @@ -1003,6 +1005,7 @@ while ($i < min($num, $limit)) $companystatic->fk_prospectlevel=$obj->fk_prospectlevel; $companystatic->fk_parent = $obj->fk_parent; + $companystatic->entity = $obj->entity; print ' Date: Tue, 18 Feb 2020 17:36:00 +0000 Subject: [PATCH 26/94] Fixing style errors. --- htdocs/societe/list.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/societe/list.php b/htdocs/societe/list.php index 3ad44f224da..c1fedf7cfe6 100644 --- a/htdocs/societe/list.php +++ b/htdocs/societe/list.php @@ -10,7 +10,7 @@ * Copyright (C) 2017 Rui Strecht * Copyright (C) 2017 Juanjo Menent * Copyright (C) 2018 Nicolas ZABOURI - + * * 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 From 016c7ad875c571e659e1bf9bd7719e3ae06b28f9 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 19 Feb 2020 01:17:16 +0100 Subject: [PATCH 27/94] FIX #13135 --- htdocs/core/class/CMailFile.class.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/core/class/CMailFile.class.php b/htdocs/core/class/CMailFile.class.php index f794c76bcac..6127a7d6044 100644 --- a/htdocs/core/class/CMailFile.class.php +++ b/htdocs/core/class/CMailFile.class.php @@ -144,6 +144,9 @@ class CMailFile } } + // Add autocopy to (Note: Adding bcc for specific modules are also done from pages) + if (!empty($conf->global->MAIN_MAIL_AUTOCOPY_TO)) $addr_bcc .= ($addr_bcc ? ', ' : '').$conf->global->MAIN_MAIL_AUTOCOPY_TO; + $this->subject = $subject; $this->addr_to = $to; $this->addr_from = $from; @@ -268,9 +271,6 @@ class CMailFile } } - // Add autocopy to (Note: Adding bcc for specific modules are also done from pages) - if (!empty($conf->global->MAIN_MAIL_AUTOCOPY_TO)) $addr_bcc .= ($addr_bcc ? ', ' : '').$conf->global->MAIN_MAIL_AUTOCOPY_TO; - // We set all data according to choosed sending method. // We also set a value for ->msgid if ($this->sendmode == 'mail') From 43b173ef76e2873313b9becd5ec6aacb04546b24 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 19 Feb 2020 01:23:54 +0100 Subject: [PATCH 28/94] FIX #13131 --- htdocs/compta/facture/card.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index 34134f49d79..2f1941ff836 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -101,6 +101,9 @@ $usehm = (!empty($conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE) ? $conf->global- $object = new Facture($db); $extrafields = new ExtraFields($db); +// Fetch optionals attributes and labels +$extrafields->fetch_name_optionals_label($object->table_element); + // Load object if ($id > 0 || !empty($ref)) { if ($action != 'add') { @@ -138,6 +141,7 @@ $result = restrictedArea($user, 'facture', $id, '', '', 'fk_soc', $fieldid, $isd + /* * Actions */ From 7c07589850526007767f8e93866b2356e7145265 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 19 Feb 2020 03:07:12 +0100 Subject: [PATCH 29/94] FIX #13124 --- htdocs/core/class/html.form.class.php | 5 +- htdocs/core/lib/ajax.lib.php | 1 + htdocs/core/tpl/objectline_create.tpl.php | 68 ++++++++++++++--------- 3 files changed, 45 insertions(+), 29 deletions(-) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 73e9ae0709b..83fd976f627 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -2432,6 +2432,7 @@ class Form $outlabel = $objp->label; $outdesc = $objp->description; $outbarcode = $objp->barcode; + $outpbq = empty($objp->price_by_qty_rowid) ? '' : $objp->price_by_qty_rowid; $outtype = $objp->fk_product_type; $outdurationvalue = $outtype == Product::TYPE_SERVICE ?substr($objp->duration, 0, dol_strlen($objp->duration) - 1) : ''; @@ -2479,7 +2480,7 @@ class Form $opt .= ($objp->rowid == $selected) ? ' selected' : ''; if (!empty($objp->price_by_qty_rowid) && $objp->price_by_qty_rowid > 0) { - $opt .= ' pbq="'.$objp->price_by_qty_rowid.'" data-pbq="'.$objp->price_by_qty_rowid.'" data-pbqqty="'.$objp->price_by_qty_quantity.'" data-pbqpercent="'.$objp->price_by_qty_remise_percent.'"'; + $opt .= ' pbq="'.$objp->price_by_qty_rowid.'" data-pbq="'.$objp->price_by_qty_rowid.'" data-pbqup="'.$objp->price_by_qty_unitprice.'" data-pbqbase="'.$objp->price_by_qty_price_base_type.'" data-pbqqty="'.$objp->price_by_qty_quantity.'" data-pbqpercent="'.$objp->price_by_qty_remise_percent.'"'; } if (!empty($conf->stock->enabled) && isset($objp->stock) && ($objp->fk_product_type == Product::TYPE_PRODUCT || !empty($conf->global->STOCK_SUPPORTS_SERVICES))) { @@ -2665,7 +2666,7 @@ class Form } $opt .= "\n"; - $optJson = array('key'=>$outkey, 'value'=>$outref, 'label'=>$outval, 'label2'=>$outlabel, 'desc'=>$outdesc, 'type'=>$outtype, 'price_ht'=>price2num($outprice_ht), 'price_ttc'=>price2num($outprice_ttc), 'pricebasetype'=>$outpricebasetype, 'tva_tx'=>$outtva_tx, 'qty'=>$outqty, 'discount'=>$outdiscount, 'duration_value'=>$outdurationvalue, 'duration_unit'=>$outdurationunit); + $optJson = array('key'=>$outkey, 'value'=>$outref, 'label'=>$outval, 'label2'=>$outlabel, 'desc'=>$outdesc, 'type'=>$outtype, 'price_ht'=>price2num($outprice_ht), 'price_ttc'=>price2num($outprice_ttc), 'pricebasetype'=>$outpricebasetype, 'tva_tx'=>$outtva_tx, 'qty'=>$outqty, 'discount'=>$outdiscount, 'duration_value'=>$outdurationvalue, 'duration_unit'=>$outdurationunit, 'pbq'=>$outpbq); } // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps diff --git a/htdocs/core/lib/ajax.lib.php b/htdocs/core/lib/ajax.lib.php index d2626414ba6..a430a1612af 100644 --- a/htdocs/core/lib/ajax.lib.php +++ b/htdocs/core/lib/ajax.lib.php @@ -107,6 +107,7 @@ function ajax_autocompleter($selected, $htmlname, $url, $urloption = '', $minLen } } }); + $("input#search_'.$htmlname.'").autocomplete({ source: function( request, response ) { $.get("'.$url.($urloption?'?'.$urloption:'').'", { '.$htmlname.': request.term }, function(data){ diff --git a/htdocs/core/tpl/objectline_create.tpl.php b/htdocs/core/tpl/objectline_create.tpl.php index b60c48da09c..6fd135af821 100644 --- a/htdocs/core/tpl/objectline_create.tpl.php +++ b/htdocs/core/tpl/objectline_create.tpl.php @@ -541,6 +541,7 @@ if (!empty($usemargins) && $user->rights->margins->creer) else if (npRate == "np_markRate") price = ((bpjs / (1 - ratejs / 100)) / (1 - remisejs / 100)); } + $("input[name='price_ht']:first").val(price); // TODO Must use a function like php price to have here a formated value return true; @@ -552,26 +553,26 @@ if (!empty($usemargins) && $user->rights->margins->creer) /* JQuery for product free or predefined select */ jQuery(document).ready(function() { - jQuery("#price_ht").keyup(function(event) { - // console.log(event.which); // discard event tag and arrows - if (event.which != 9 && (event.which < 37 ||event.which > 40) && jQuery("#price_ht").val() != '') { - jQuery("#price_ttc").val(''); - jQuery("#multicurrency_subprice").val(''); - } + jQuery("#price_ht").keyup(function(event) { + // console.log(event.which); // discard event tag and arrows + if (event.which != 9 && (event.which < 37 ||event.which > 40) && jQuery("#price_ht").val() != '') { + jQuery("#price_ttc").val(''); + jQuery("#multicurrency_subprice").val(''); + } }); jQuery("#price_ttc").keyup(function(event) { - // console.log(event.which); // discard event tag and arrows - if (event.which != 9 && (event.which < 37 || event.which > 40) && jQuery("#price_ttc").val() != '') { - jQuery("#price_ht").val(''); - jQuery("#multicurrency_subprice").val(''); - } + // console.log(event.which); // discard event tag and arrows + if (event.which != 9 && (event.which < 37 || event.which > 40) && jQuery("#price_ttc").val() != '') { + jQuery("#price_ht").val(''); + jQuery("#multicurrency_subprice").val(''); + } }); jQuery("#multicurrency_subprice").keyup(function(event) { - // console.log(event.which); // discard event tag and arrows - if (event.which != 9 && (event.which < 37 || event.which > 40) && jQuery("#price_ttc").val() != '') { - jQuery("#price_ht").val(''); - jQuery("#price_ttc").val(''); - } + // console.log(event.which); // discard event tag and arrows + if (event.which != 9 && (event.which < 37 || event.which > 40) && jQuery("#price_ttc").val() != '') { + jQuery("#price_ht").val(''); + jQuery("#price_ttc").val(''); + } }); $("#prod_entry_mode_free").on( "click", function() { @@ -630,15 +631,24 @@ if (!empty($usemargins) && $user->rights->margins->creer) if (empty($conf->global->MAIN_DISABLE_EDIT_PREDEF_PRICEHT) && empty($senderissupplier)) { ?> - // Get the HT price for the product and display it - console.log("Load price without tax and set it into #price_ht"); - $.post('/product/ajax/products.php?action=fetch', - { 'id': $(this).val(), 'socid' : socid; ?> }, - function(data) { jQuery("#price_ht").val(data.price_ht); }, - 'json' - ); + var pbq = parseInt($('option:selected', this).attr('data-pbq')); + if ((jQuery('#idprod').val() > 0 || jQuery('#idprodfournprice').val()) && ! isNaN(pbq) && pbq > 0) + { + console.log("We are in a price per qty context, we do not call ajax/product"); + } else { + // Get the HT price for the product and display it + console.log("Load price without tax and set it into #price_ht for id="+$(this).val()+" socid=socid; ?>"); + $.post('/product/ajax/products.php?action=fetch', + { 'id': $(this).val(), 'socid': socid; ?> }, + function(data) { + jQuery("#price_ht").val(data.price_ht); + }, + 'json' + ); + } rights->margins->creer) { $langs->load('stocks'); @@ -744,15 +754,20 @@ if (!empty($usemargins) && $user->rights->margins->creer) } ?> - /* To process customer price per quantity */ + /* To process customer price per quantity (CUSTOMER_PRICE_PER_QTY works only if combo product is not an ajax after x key pressed) */ var pbq = parseInt($('option:selected', this).attr('data-pbq')); + var pbqup = parseInt($('option:selected', this).attr('data-pbqup')); + var pbqbase = $('option:selected', this).attr('data-pbqbase'); var pbqqty = parseFloat($('option:selected', this).attr('data-pbqqty')); var pbqpercent = parseFloat($('option:selected', this).attr('data-pbqpercent')); - if ((jQuery('#idprod').val() > 0 || jQuery('#idprodfournprice').val()) && typeof pbq !== "undefined") + if ((jQuery('#idprod').val() > 0 || jQuery('#idprodfournprice').val()) && ! isNaN(pbq) && pbq > 0) { - console.log("We choose a price by quanty price_by_qty id = "+pbq+" price_by_qty qty = "+pbqqty+" price_by_qty percent = "+pbqpercent); + var pbqupht = pbqup; /* TODO support of price per qty TTC not yet available */ + + console.log("We choose a price by quanty price_by_qty id = "+pbq+" price_by_qty upht = "+pbqupht+" price_by_qty qty = "+pbqqty+" price_by_qty percent = "+pbqpercent); jQuery("#pbq").val(pbq); + jQuery("#price_ht").val(pbqupht); if (jQuery("#qty").val() < pbqqty) { jQuery("#qty").val(pbqqty); @@ -809,7 +824,6 @@ if (!empty($usemargins) && $user->rights->margins->creer) jQuery("#price_ht").val('').hide(); jQuery("#multicurrency_price_ht").val('').hide(); - jQuery("#price_ht").val(''); jQuery("#price_ttc, #fourn_ref, #tva_tx, #title_vat, #title_up_ht_currency, #title_up_ttc, #title_up_ttc_currency").hide(); jQuery("#np_marginRate, #np_markRate, .np_marginRate, .np_markRate, #units, #title_units").hide(); jQuery("#buying_price").show(); From d0d352be1af0d6e4c76dd78c1e20e5b0800853a6 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 19 Feb 2020 03:37:28 +0100 Subject: [PATCH 30/94] FIX #13118 --- htdocs/compta/paiement.php | 10 +++++++--- htdocs/fourn/facture/paiement.php | 10 +++++++--- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/htdocs/compta/paiement.php b/htdocs/compta/paiement.php index 5b297eed309..b00ef1d9a0a 100644 --- a/htdocs/compta/paiement.php +++ b/htdocs/compta/paiement.php @@ -95,6 +95,8 @@ if (empty($reshook)) $totalpayment = 0; $multicurrency_totalpayment = 0; $atleastonepaymentnotnull = 0; + $formquestion = array(); + $i = 0; // Generate payment array and check if there is payment higher than invoice and payment date before invoice date $tmpinvoice = new Facture($db); @@ -214,7 +216,7 @@ if (empty($reshook)) { $error = 0; - $datepaye = dol_mktime(12, 0, 0, GETPOST('remonth'), GETPOST('reday'), GETPOST('reyear')); + $datepaye = dol_mktime(12, 0, 0, GETPOST('remonth', 'int'), GETPOST('reday', 'int'), GETPOST('reyear', 'int')); $db->begin(); @@ -260,8 +262,10 @@ if (empty($reshook)) $paiement->amounts = $amounts; // Array with all payments dispatching with invoice id $paiement->multicurrency_amounts = $multicurrency_amounts; // Array with all payments dispatching $paiement->paiementid = dol_getIdFromCode($db, GETPOST('paiementcode'), 'c_paiement', 'code', 'id', 1); - $paiement->num_paiement = GETPOST('num_paiement', 'alpha'); - $paiement->note = GETPOST('comment', 'alpha'); + $paiement->num_payment = GETPOST('num_paiement', 'alpha'); + $paiement->note_private = GETPOST('comment', 'alpha'); + $paiement->num_paiement = $paiement->num_payment; // For bacward compatibility + $paiement->note = $paiement->note_private; // For bacward compatibility if (!$error) { diff --git a/htdocs/fourn/facture/paiement.php b/htdocs/fourn/facture/paiement.php index e9198ebcc91..19fed7a3387 100644 --- a/htdocs/fourn/facture/paiement.php +++ b/htdocs/fourn/facture/paiement.php @@ -297,9 +297,13 @@ if (empty($reshook)) $paiement->datepaye = $datepaye; $paiement->amounts = $amounts; // Array of amounts $paiement->multicurrency_amounts = $multicurrency_amounts; - $paiement->paiementid = $_POST['paiementid']; - $paiement->num_paiement = $_POST['num_paiement']; - $paiement->note = $_POST['comment']; + $paiement->paiementid = GETPOST('paiementid', 'int'); + + $paiement->num_payment = GETPOST('num_paiement', 'alpha'); + $paiement->note_private = GETPOST('comment', 'alpha'); + $paiement->num_paiement = $paiement->num_payment; // For bacward compatibility + $paiement->note = $paiement->note_private; // For bacward compatibility + if (!$error) { $paiement_id = $paiement->create($user, (GETPOST('closepaidinvoices') == 'on' ? 1 : 0), $thirdparty); From 34d7fb887fff25636b983f75ae21842b5421da07 Mon Sep 17 00:00:00 2001 From: Pierre Ardoin <32256817+mapiolca@users.noreply.github.com> Date: Wed, 19 Feb 2020 08:50:49 +0100 Subject: [PATCH 31/94] Show project Ref support if enable Add search and Project Ref column in the list, only if project module is enable. --- htdocs/compta/sociales/list.php | 36 ++++++++++++++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) diff --git a/htdocs/compta/sociales/list.php b/htdocs/compta/sociales/list.php index 5f7f7d0fc0a..6e7277c2f93 100644 --- a/htdocs/compta/sociales/list.php +++ b/htdocs/compta/sociales/list.php @@ -29,6 +29,7 @@ require_once DOL_DOCUMENT_ROOT.'/compta/sociales/class/chargesociales.class.php' require_once DOL_DOCUMENT_ROOT.'/core/class/html.formsocialcontrib.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; +if (! empty($conf->projet->enabled)) require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; // Load translation files required by the page $langs->loadLangs(array('compta', 'banks', 'bills')); @@ -53,6 +54,11 @@ $search_day_lim = GETPOST('search_day_lim', 'int'); $search_month_lim = GETPOST('search_month_lim', 'int'); $search_year_lim = GETPOST('search_year_lim', 'int'); +if (! empty($conf->projet->enabled)) { + $search_project_ref=GETPOST('search_project_ref', 'alpha'); + $search_project=GETPOST('search_project', 'alpha'); +} + $limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit; $sortfield = GETPOST("sortfield", 'alpha'); $sortorder = GETPOST("sortorder", 'alpha'); @@ -95,6 +101,11 @@ if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x' $search_month_lim=''; $toselect=''; $search_array_options=array(); + + if (! empty($conf->projet->enabled)) { + $search_project_ref=''; + $search_project=''; + } } @@ -106,21 +117,25 @@ $form = new Form($db); $formother = new FormOther($db); $formsocialcontrib = new FormSocialContrib($db); $chargesociale_static=new ChargeSociales($db); +if (! empty($conf->projet->enabled)) $projectstatic=new Project($db); llxHeader('', $langs->trans("SocialContributions")); $sql = "SELECT cs.rowid as id, cs.fk_type as type, "; $sql.= " cs.amount, cs.date_ech, cs.libelle, cs.paye, cs.periode,"; +if (! empty($conf->projet->enabled)) $sql.= " p.rowid as project_id, p.ref as project_ref, p.title as project_label,"; $sql.= " c.libelle as type_lib,"; $sql.= " SUM(pc.amount) as alreadypayed"; $sql.= " FROM ".MAIN_DB_PREFIX."c_chargesociales as c,"; $sql.= " ".MAIN_DB_PREFIX."chargesociales as cs"; +if (! empty($conf->projet->enabled)) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."projet as p ON p.rowid = cs.fk_projet"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."paiementcharge as pc ON pc.fk_charge = cs.rowid"; $sql.= " WHERE cs.fk_type = c.id"; $sql.= " AND cs.entity = ".$conf->entity; // Search criteria if ($search_ref) $sql.=" AND cs.rowid=".$db->escape($search_ref); if ($search_label) $sql.=natural_search("cs.libelle", $search_label); +if (! empty($conf->projet->enabled)) if ($search_project_ref != '') $sql.= natural_search("p.ref", $search_project_ref); if ($search_amount) $sql.=natural_search("cs.amount", price2num(trim($search_amount)), 1); if ($search_status != '' && $search_status >= 0) $sql.=" AND cs.paye = ".$db->escape($search_status); $sql.= dolSqlDateFilter("cs.periode", $search_day_lim, $search_month_lim, $search_year_lim); @@ -163,6 +178,7 @@ if ($resql) if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.urlencode($limit); if ($search_ref) $param.='&search_ref='.urlencode($search_ref); if ($search_label) $param.='&search_label='.urlencode($search_label); + if (! empty($conf->projet->enabled)) if ($search_project_ref >= 0) $param.="&search_project_ref=".urlencode($search_project_ref); if ($search_amount) $param.='&search_amount='.urlencode($search_amount); if ($search_typeid) $param.='&search_typeid='.urlencode($search_typeid); if ($search_status != '' && $search_status != '-1') $param.='&search_status='.urlencode($search_status); @@ -219,6 +235,8 @@ if ($resql) print ''; $formsocialcontrib->select_type_socialcontrib($search_typeid, 'search_typeid', 1, 0, 0, 'maxwidth100onsmartphone'); print ''; + // Ref Project + if (! empty($conf->projet->enabled)) print ''; // Period end date print ''; if (! empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print ''; @@ -246,6 +264,7 @@ if ($resql) print_liste_field_titre("Ref", $_SERVER["PHP_SELF"], "id", "", $param, "", $sortfield, $sortorder); print_liste_field_titre("Label", $_SERVER["PHP_SELF"], "cs.libelle", "", $param, 'class="left"', $sortfield, $sortorder); print_liste_field_titre("Type", $_SERVER["PHP_SELF"], "type", "", $param, 'class="left"', $sortfield, $sortorder); + if (! empty($conf->projet->enabled)) print_liste_field_titre('ProjectRef', $_SERVER["PHP_SELF"], "p.ref", "", $param, '', $sortfield, $sortorder); print_liste_field_titre("PeriodEndDate", $_SERVER["PHP_SELF"], "periode", "", $param, 'align="center"', $sortfield, $sortorder); print_liste_field_titre("Amount", $_SERVER["PHP_SELF"], "cs.amount", "", $param, 'class="right"', $sortfield, $sortorder); print_liste_field_titre("DateDue", $_SERVER["PHP_SELF"], "cs.date_ech", "", $param, 'align="center"', $sortfield, $sortorder); @@ -263,7 +282,11 @@ if ($resql) $chargesociale_static->ref=$obj->id; $chargesociale_static->lib=$obj->libelle; $chargesociale_static->type_libelle=$obj->type_lib; - + if (! empty($conf->projet->enabled)) { + $projectstatic->id=$obj->project_id; + $projectstatic->ref=$obj->project_ref; + $projectstatic->title=$obj->project_label; + } print ''; // Ref @@ -277,6 +300,16 @@ if ($resql) // Type print ''.$obj->type_lib.''; + // Project Ref + if (! empty($conf->projet->enabled)) { + print ''; + if ($obj->project_id > 0) + { + print $projectstatic->getNomUrl(1); + } + print ''; + } + // Date end period print ''; if ($obj->periode) @@ -314,6 +347,7 @@ if ($resql) else print ''.$langs->trans("Totalforthispage").''; print ''; print ''; + if (! empty($conf->projet->enabled)) print ''; print ''; print ''.price($totalarray['totalttc']).''; print ''; From bebc37abe39fd6371250b1e2954bc4f392be9a66 Mon Sep 17 00:00:00 2001 From: Pierre Ardoin <32256817+mapiolca@users.noreply.github.com> Date: Wed, 19 Feb 2020 08:54:10 +0100 Subject: [PATCH 32/94] Update list.php --- htdocs/compta/sociales/list.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/compta/sociales/list.php b/htdocs/compta/sociales/list.php index 6e7277c2f93..11f5fe43d19 100644 --- a/htdocs/compta/sociales/list.php +++ b/htdocs/compta/sociales/list.php @@ -3,6 +3,7 @@ * Copyright (C) 2004-2017 Laurent Destailleur * Copyright (C) 2005-2009 Regis Houssin * Copyright (C) 2016 Frédéric France + * Copyright (C) 2020 Pierre Ardoin * * 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 From ac16857501177f44ac3f691926503c7d812df95d Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 19 Feb 2020 11:33:45 +0100 Subject: [PATCH 33/94] GETPOST(..., 'alpha') remove " if found instead of returning '' --- htdocs/core/class/html.form.class.php | 3 ++- htdocs/core/lib/functions.lib.php | 12 ++++-------- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index ba8fcabe3f1..b5c9920a6a8 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -2431,6 +2431,7 @@ class Form $outlabel = $objp->label; $outdesc = $objp->description; $outbarcode = $objp->barcode; + $outpbq = empty($objp->price_by_qty_rowid) ? '' : $objp->price_by_qty_rowid; $outtype = $objp->fk_product_type; $outdurationvalue = $outtype == Product::TYPE_SERVICE ?substr($objp->duration, 0, dol_strlen($objp->duration) - 1) : ''; @@ -2664,7 +2665,7 @@ class Form } $opt .= "\n"; - $optJson = array('key'=>$outkey, 'value'=>$outref, 'label'=>$outval, 'label2'=>$outlabel, 'desc'=>$outdesc, 'type'=>$outtype, 'price_ht'=>price2num($outprice_ht), 'price_ttc'=>price2num($outprice_ttc), 'pricebasetype'=>$outpricebasetype, 'tva_tx'=>$outtva_tx, 'qty'=>$outqty, 'discount'=>$outdiscount, 'duration_value'=>$outdurationvalue, 'duration_unit'=>$outdurationunit); + $optJson = array('key'=>$outkey, 'value'=>$outref, 'label'=>$outval, 'label2'=>$outlabel, 'desc'=>$outdesc, 'type'=>$outtype, 'price_ht'=>price2num($outprice_ht), 'price_ttc'=>price2num($outprice_ttc), 'pricebasetype'=>$outpricebasetype, 'tva_tx'=>$outtva_tx, 'qty'=>$outqty, 'discount'=>$outdiscount, 'duration_value'=>$outdurationvalue, 'duration_unit'=>$outdurationunit, 'pbq'=>$outpbq); } // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 431e0f0dadc..e938f1a00d8 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -559,11 +559,9 @@ function GETPOST($paramname, $check = 'alphanohtml', $method = 0, $filter = null case 'alpha': if (!is_array($out)) { - $out = trim($out); // '"' is dangerous because param in url can close the href= or src= and add javascript functions. // '../' is dangerous because it allows dir transversals - if (preg_match('/"/', $out)) $out = ''; - elseif (preg_match('/\.\.\//', $out)) $out = ''; + $out = str_replace(array('"', '../'), '', trim($out)); } break; case 'san_alpha': @@ -593,17 +591,15 @@ function GETPOST($paramname, $check = 'alphanohtml', $method = 0, $filter = null case 'array': if (!is_array($out) || empty($out)) $out = array(); break; - case 'nohtml': // Recommended for most scalar parameters + case 'nohtml': $out = dol_string_nohtmltag($out, 0); break; - case 'alphanohtml': // Recommended for search parameters + case 'alphanohtml': // Recommended for most scalar parameters and search parameters if (!is_array($out)) { - $out = trim($out); // '"' is dangerous because param in url can close the href= or src= and add javascript functions. // '../' is dangerous because it allows dir transversals - if (preg_match('/"/', $out)) $out = ''; - elseif (preg_match('/\.\.\//', $out)) $out = ''; + $out = str_replace(array('"', '../'), '', trim($out)); $out = dol_string_nohtmltag($out); } break; From 996ae2336d67674d256bb297aced5af68d5ce2c5 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 19 Feb 2020 11:59:27 +0100 Subject: [PATCH 34/94] Prepare PHP v8 - No more 'each' operator --- htdocs/core/class/ldap.class.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/core/class/ldap.class.php b/htdocs/core/class/ldap.class.php index b22473ec483..10d34afd867 100644 --- a/htdocs/core/class/ldap.class.php +++ b/htdocs/core/class/ldap.class.php @@ -1397,7 +1397,8 @@ class Ldap //Parse flags to text $retval = array(); - while (list($flag, $val) = each($flags)) { + //while (list($flag, $val) = each($flags)) { + foreach ($flags as $flag => $val) { if ($uacf >= $val) { $uacf -= $val; $retval[$val] = $flag; From 1dd5ba093d694daf35d37298d86abf5ba066373e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 19 Feb 2020 11:59:27 +0100 Subject: [PATCH 35/94] Prepare PHP v8 - mktime() and gmmktime() are no more allowed --- dev/examples/code/create_invoice.php | 5 +++-- dev/examples/code/create_order.php | 5 +++-- htdocs/compta/stats/index.php | 2 +- htdocs/core/class/ldap.class.php | 3 ++- htdocs/core/lib/functions.lib.php | 4 +--- htdocs/expensereport/class/expensereport.class.php | 2 +- htdocs/fichinter/card.php | 2 +- 7 files changed, 12 insertions(+), 11 deletions(-) diff --git a/dev/examples/code/create_invoice.php b/dev/examples/code/create_invoice.php index dbbe9d84c1c..1b212e0a5d7 100755 --- a/dev/examples/code/create_invoice.php +++ b/dev/examples/code/create_invoice.php @@ -66,8 +66,9 @@ $obj = new Facture($db); $obj->ref = 'ABCDE'; $obj->socid = 4; // Put id of third party (rowid in llx_societe table) -$obj->date = mktime(); -$obj->note = 'A comment'; +$obj->date = dol_now(); +$obj->note_public = 'A public comment'; +$obj->note_private = 'A private comment'; $obj->cond_reglement_id = 1; $line1=new FactureLigne($db); diff --git a/dev/examples/code/create_order.php b/dev/examples/code/create_order.php index 30265d5462e..703254ad5e9 100755 --- a/dev/examples/code/create_order.php +++ b/dev/examples/code/create_order.php @@ -66,8 +66,9 @@ $com = new Commande($db); $com->ref = 'ABCDE'; $com->socid = 4; // Put id of third party (rowid in llx_societe table) -$com->date_commande = mktime(); -$com->note = 'A comment'; +$com->date = dol_now(); +$com->note_public = 'A public comment'; +$com->note_private = 'A private comment'; $com->source = 1; $com->remise_percent = 0; diff --git a/htdocs/compta/stats/index.php b/htdocs/compta/stats/index.php index 684ef337fcd..9be5607b62d 100644 --- a/htdocs/compta/stats/index.php +++ b/htdocs/compta/stats/index.php @@ -407,7 +407,7 @@ for ($mois = 1 + $nb_mois_decalage; $mois <= 12 + $nb_mois_decalage; $mois++) print "".dol_print_date(dol_mktime(12,0,0,$mois,1,2000),"%B").""; for ($annee = $year_start ; $annee <= $year_end ; $annee++) { - $casenow = dol_print_date(mktime(),"%Y-%m"); + $casenow = dol_print_date(dol_now(),"%Y-%m"); $case = dol_print_date(dol_mktime(1,1,1,$mois,1,$annee),"%Y-%m"); $caseprev = dol_print_date(dol_mktime(1,1,1,$mois,1,$annee-1),"%Y-%m"); diff --git a/htdocs/core/class/ldap.class.php b/htdocs/core/class/ldap.class.php index b22473ec483..10d34afd867 100644 --- a/htdocs/core/class/ldap.class.php +++ b/htdocs/core/class/ldap.class.php @@ -1397,7 +1397,8 @@ class Ldap //Parse flags to text $retval = array(); - while (list($flag, $val) = each($flags)) { + //while (list($flag, $val) = each($flags)) { + foreach ($flags as $flag => $val) { if ($uacf >= $val) { $uacf -= $val; $retval[$val] = $flag; diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index e938f1a00d8..dff1d84dddc 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -2102,8 +2102,6 @@ function dol_now($mode = 'gmt') { $ret = 0; - // Note that gmmktime and mktime return same value (GMT) when used without parameters - //if ($mode == 'gmt') $ret=gmmktime(); // Strict Standards: gmmktime(): You should be using the time() function instead if ($mode == 'gmt') $ret = time(); // Time for now at greenwich. elseif ($mode == 'tzserver') // Time for now with PHP server timezone added { @@ -2119,7 +2117,7 @@ function dol_now($mode = 'gmt') }*/ elseif ($mode == 'tzuser') // Time for now with user timezone added { - //print 'time: '.time().'-'.mktime().'-'.gmmktime(); + //print 'time: '.time(); $offsettz = (empty($_SESSION['dol_tz']) ? 0 : $_SESSION['dol_tz']) * 60 * 60; $offsetdst = (empty($_SESSION['dol_dst']) ? 0 : $_SESSION['dol_dst']) * 60 * 60; $ret = (int) (dol_now('gmt') + ($offsettz + $offsetdst)); diff --git a/htdocs/expensereport/class/expensereport.class.php b/htdocs/expensereport/class/expensereport.class.php index 05272aa2ff7..14ab2b88f22 100644 --- a/htdocs/expensereport/class/expensereport.class.php +++ b/htdocs/expensereport/class/expensereport.class.php @@ -1486,7 +1486,7 @@ class ExpenseReport extends CommonObject { // phpcs:enable $error = 0; - $this->date_cancel = $this->db->idate(gmmktime()); + $this->date_cancel = $this->db->idate(dol_now()); if ($this->fk_statut != self::STATUS_CANCELED) { $this->db->begin(); diff --git a/htdocs/fichinter/card.php b/htdocs/fichinter/card.php index 93d5e3339b1..3d1a23ee26d 100644 --- a/htdocs/fichinter/card.php +++ b/htdocs/fichinter/card.php @@ -353,7 +353,7 @@ if (empty($reshook)) $desc .= '
'; $desc .= ' ('.$langs->trans('Quantity').': '.$lines[$i]->qty.')'; - $timearray = dol_getdate(mktime()); + $timearray = dol_getdate(dol_now()); $date_intervention = dol_mktime(0, 0, 0, $timearray['mon'], $timearray['mday'], $timearray['year']); if ($product_type == Product::TYPE_PRODUCT) { From f10986467098705cd65fbe1295687d9389a0c7e8 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 19 Feb 2020 13:22:24 +0100 Subject: [PATCH 36/94] NEW Add a profil to import contact categories Load roles of contact only when required --- htdocs/contact/card.php | 26 +++++----- htdocs/contact/class/contact.class.php | 52 +++++++++++-------- .../modules/import/import_csv.modules.php | 5 +- htdocs/core/modules/modCategorie.class.php | 21 +++++++- htdocs/langs/en_US/categories.lang | 1 + 5 files changed, 69 insertions(+), 36 deletions(-) diff --git a/htdocs/contact/card.php b/htdocs/contact/card.php index bc680c5250a..73862b65b2e 100644 --- a/htdocs/contact/card.php +++ b/htdocs/contact/card.php @@ -554,6 +554,8 @@ else setEventMessages($object->error, $object->errors, 'errors'); } + $object->fetchRoles(); + // Show tabs $head = contact_prepare_head($object); @@ -580,7 +582,7 @@ else $object->country = $tmparray['label']; } - $title = $addcontact = (!empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) ? $langs->trans("AddContact") : $langs->trans("AddContactAddress")); + $title = (!empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) ? $langs->trans("AddContact") : $langs->trans("AddContactAddress")); $linkback = ''; print load_fiche_titre($title, $linkback, 'address'); @@ -654,7 +656,7 @@ else // Civility print ''; - print $formcompany->select_civility(GETPOSTISSET("civility_code") ?GETPOST("civility_code", 'alpha') : $object->civility_code, 'civility_code'); + print $formcompany->select_civility(GETPOSTISSET("civility_code") ? GETPOST("civility_code", 'alpha') : $object->civility_code, 'civility_code'); print ''; print ''; @@ -683,13 +685,13 @@ else if (($objsoc->typent_code == 'TE_PRIVATE' || !empty($conf->global->CONTACT_USE_COMPANY_ADDRESS)) && dol_strlen(trim($object->zip)) == 0) $object->zip = $objsoc->zip; // Predefined with third party if (($objsoc->typent_code == 'TE_PRIVATE' || !empty($conf->global->CONTACT_USE_COMPANY_ADDRESS)) && dol_strlen(trim($object->town)) == 0) $object->town = $objsoc->town; // Predefined with third party print ' / '; - print $formcompany->select_ziptown((GETPOST("zipcode", 'alpha') ?GETPOST("zipcode", 'alpha') : $object->zip), 'zipcode', array('town', 'selectcountry_id', 'state_id'), 6).' '; - print $formcompany->select_ziptown((GETPOST("town", 'alpha') ?GETPOST("town", 'alpha') : $object->town), 'town', array('zipcode', 'selectcountry_id', 'state_id')); + print $formcompany->select_ziptown((GETPOST("zipcode", 'alpha') ? GETPOST("zipcode", 'alpha') : $object->zip), 'zipcode', array('town', 'selectcountry_id', 'state_id'), 6).' '; + print $formcompany->select_ziptown((GETPOST("town", 'alpha') ? GETPOST("town", 'alpha') : $object->town), 'town', array('zipcode', 'selectcountry_id', 'state_id')); print ''; // Country print ''; - print $form->select_country((GETPOST("country_id", 'alpha') ?GETPOST("country_id", 'alpha') : $object->country_id), 'country_id'); + print $form->select_country((GETPOST("country_id", 'alpha') ? GETPOST("country_id", 'alpha') : $object->country_id), 'country_id'); if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); print ''; @@ -707,7 +709,7 @@ else if ($object->country_id) { - print $formcompany->select_state(GETPOST("state_id", 'alpha') ?GETPOST("state_id", 'alpha') : $object->state_id, $object->country_code, 'state_id'); + print $formcompany->select_state(GETPOST("state_id", 'alpha') ? GETPOST("state_id", 'alpha') : $object->state_id, $object->country_code, 'state_id'); } else { @@ -721,23 +723,23 @@ else // Phone / Fax print ''.img_picto('', 'object_phoning').' '.$form->editfieldkey('PhonePro', 'phone_pro', '', $object, 0).''; - print ''; + print ''; if ($conf->browser->layout == 'phone') print ''; print ''.img_picto('', 'object_phoning').' '.$form->editfieldkey('PhonePerso', 'phone_perso', '', $object, 0).''; - print ''; + print ''; print ''.img_picto('', 'object_phoning_mobile').' '.$form->editfieldkey('PhoneMobile', 'phone_mobile', '', $object, 0).''; - print ''; + print ''; if ($conf->browser->layout == 'phone') print ''; print ''.img_picto('', 'object_phoning_fax').' '.$form->editfieldkey('Fax', 'fax', '', $object, 0).''; - print ''; + print ''; print ''; if (($objsoc->typent_code == 'TE_PRIVATE' || !empty($conf->global->CONTACT_USE_COMPANY_ADDRESS)) && dol_strlen(trim($object->email)) == 0) $object->email = $objsoc->email; // Predefined with third party // Email print ''.img_picto('', 'object_email').' '.$form->editfieldkey('EMail', 'email', '', $object, 0, 'string', '').''; - print ''; + print ''; print ''; if (!empty($conf->mailing->enabled)) @@ -757,7 +759,7 @@ else print ''; print ''; - print ''.$form->selectyesno('no_email', (GETPOSTISSET("no_email") ?GETPOST("no_email", 'alpha') : $noemail), 1).''; + print ''.$form->selectyesno('no_email', (GETPOSTISSET("no_email") ? GETPOST("no_email", 'alpha') : $noemail), 1).''; print ''; } print ''; diff --git a/htdocs/contact/class/contact.class.php b/htdocs/contact/class/contact.class.php index 16279187b97..013830ca864 100644 --- a/htdocs/contact/class/contact.class.php +++ b/htdocs/contact/class/contact.class.php @@ -802,20 +802,19 @@ class Contact extends CommonObject /** - * Load object contact + * Load object contact. * - * @param int $id id du contact - * @param User $user Utilisateur (abonnes aux alertes) qui veut les alertes de ce contact - * @param string $ref_ext External reference, not given by Dolibarr - * @param string $email Email - * @return int -1 if KO, 0 if OK but not found, 1 if OK + * @param int $id Id of contact + * @param User $user Load also alerts of this user (subscribing to alerts) that want alerts about this contact + * @param string $ref_ext External reference, not given by Dolibarr + * @param string $email Email + * @param int $loadalsoroles Load also roles + * @return int >0 if OK, <0 if KO or if two records found for same ref or idprof, 0 if not found. */ - public function fetch($id, $user = null, $ref_ext = '', $email = '') + public function fetch($id, $user = null, $ref_ext = '', $email = '', $loadalsoroles = 0) { global $langs; - $langs->load("dict"); - dol_syslog(get_class($this)."::fetch id=".$id." ref_ext=".$ref_ext." email=".$email, LOG_DEBUG); if (empty($id) && empty($ref_ext) && empty($email)) @@ -824,7 +823,7 @@ class Contact extends CommonObject return -1; } - $langs->load("companies"); + $langs->loadLangs(array("dict", "companies")); $sql = "SELECT c.rowid, c.entity, c.fk_soc, c.ref_ext, c.civility as civility_code, c.lastname, c.firstname,"; $sql .= " c.address, c.statut, c.zip, c.town,"; @@ -861,7 +860,15 @@ class Contact extends CommonObject $resql = $this->db->query($sql); if ($resql) { - if ($this->db->num_rows($resql)) + $num = $this->db->num_rows($resql); + if ($num > 1) + { + $this->error = 'Fetch found several records. Rename one of contact to avoid duplicate.'; + dol_syslog($this->error, LOG_ERR); + + return 2; + } + elseif ($num) // $num = 1 { $obj = $this->db->fetch_object($resql); @@ -942,7 +949,11 @@ class Contact extends CommonObject return -1; } - // Charge alertes du user + // Retreive all extrafield + // fetch optionals attributes and labels + $this->fetch_optionals(); + + // Load also alerts of this user if ($user) { $sql = "SELECT fk_user"; @@ -967,13 +978,12 @@ class Contact extends CommonObject } } - // Retreive all extrafield - // fetch optionals attributes and labels - $this->fetch_optionals(); - - $resultRole = $this->fetchRoles(); - if ($resultRole < 0) { - return $resultRole; + // Load also roles of this address + if ($loadalsoroles) { + $resultRole = $this->fetchRoles(); + if ($resultRole < 0) { + return $resultRole; + } } return 1; @@ -1587,7 +1597,7 @@ class Contact extends CommonObject } /** - * Fetch Role for a contact + * Fetch Roles for a contact * * @return float|int * @throws Exception @@ -1599,7 +1609,7 @@ class Contact extends CommonObject $num = 0; $sql = "SELECT tc.rowid, tc.element, tc.source, tc.code, tc.libelle, sc.rowid as contactroleid"; - $sql .= " FROM ".MAIN_DB_PREFIX."societe_contacts as sc "; + $sql .= " FROM ".MAIN_DB_PREFIX."societe_contacts as sc"; $sql .= " INNER JOIN ".MAIN_DB_PREFIX."c_type_contact as tc"; $sql .= " ON tc.rowid = sc.fk_c_type_contact"; $sql .= " AND sc.fk_socpeople = ".$this->id; diff --git a/htdocs/core/modules/import/import_csv.modules.php b/htdocs/core/modules/import/import_csv.modules.php index 93d68691a11..6c9dd9062a8 100644 --- a/htdocs/core/modules/import/import_csv.modules.php +++ b/htdocs/core/modules/import/import_csv.modules.php @@ -425,6 +425,7 @@ class ImportCsv extends ModeleImports // New val can be an id or ref. If it start with id: it is forced to id, if it start with ref: it is forced to ref. It not, we try to guess. $isidorref = 'id'; if (!is_numeric($newval) && $newval != '' && !preg_match('/^id:/i', $newval)) $isidorref = 'ref'; + $newval = preg_replace('/^(id|ref):/i', '', $newval); // Remove id: or ref: that was used to force if field is id or ref //print 'Val is now '.$newval.' and is type '.$isidorref."
\n"; @@ -448,8 +449,7 @@ class ImportCsv extends ModeleImports $classinstance = new $class($this->db); // Try the fetch from code or ref $param_array = array('', $newval); - if ($class == 'AccountingAccount') - { + if ($class == 'AccountingAccount') { //var_dump($arrayrecord[0]['val']); /*include_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountancysystem.class.php'; $tmpchartofaccount = new AccountancySystem($this->db); @@ -464,6 +464,7 @@ class ImportCsv extends ModeleImports }*/ $param_array = array('', $newval, 0, $arrayrecord[0]['val']); // Param to fetch parent from account, in chart. } + call_user_func_array(array($classinstance, $method), $param_array); // If not found, try the fetch from label if (! ($classinstance->id != '') && $objimport->array_import_convertvalue[0][$val]['rule']=='fetchidfromcodeorlabel') diff --git a/htdocs/core/modules/modCategorie.class.php b/htdocs/core/modules/modCategorie.class.php index b53a9630598..7f92dcef6d6 100644 --- a/htdocs/core/modules/modCategorie.class.php +++ b/htdocs/core/modules/modCategorie.class.php @@ -452,7 +452,7 @@ class modCategorie extends DolibarrModules if (! empty($conf->societe->enabled)) { - //Customers + // Customers $r++; $this->import_code[$r]=$this->rights_class.'_'.$r; $this->import_label[$r]="CatCusLinks"; // Translation key @@ -470,6 +470,25 @@ class modCategorie extends DolibarrModules 'cs.fk_soc'=>array('rule'=>'fetchidfromref','classfile'=>'/societe/class/societe.class.php','class'=>'Societe','method'=>'fetch','element'=>'ThirdParty') ); $this->import_examplevalues_array[$r]=array('cs.fk_categorie'=>"Imported category",'cs.fk_soc'=>"MyBigCompany"); + + // Contacts/Addresses + $r++; + $this->import_code[$r]=$this->rights_class.'_'.$r; + $this->import_label[$r]="CatContactsLinks"; // Translation key + $this->import_icon[$r]=$this->picto; + $this->import_entities_array[$r]=array(); // We define here only fields that use another icon that the one defined into import_icon + $this->import_tables_array[$r]=array('cs'=>MAIN_DB_PREFIX.'categorie_contact'); + $this->import_fields_array[$r]=array('cs.fk_categorie'=>"Category*",'cs.fk_socpeople'=>"Contact ID*"); + $this->import_regex_array[$r]=array( + 'cs.fk_categorie'=>'rowid@'.MAIN_DB_PREFIX.'categorie:type=4' + //'cs.fk_socpeople'=>'rowid@'.MAIN_DB_PREFIX.'socpeople' + ); + + $this->import_convertvalue_array[$r]=array( + 'cs.fk_categorie'=>array('rule'=>'fetchidfromref','classfile'=>'/categories/class/categorie.class.php','class'=>'Categorie','method'=>'fetch','element'=>'category') + //'cs.fk_socpeople'=>array('rule'=>'fetchidfromref','classfile'=>'/contact/class/contact.class.php','class'=>'Contact','method'=>'fetch','element'=>'Contact') + ); + $this->import_examplevalues_array[$r]=array('cs.fk_categorie'=>"Imported category",'cs.fk_socpeople'=>"123"); } if (! empty($conf->fournisseur->enabled)) diff --git a/htdocs/langs/en_US/categories.lang b/htdocs/langs/en_US/categories.lang index 7207bbacc38..1ec9b5bd409 100644 --- a/htdocs/langs/en_US/categories.lang +++ b/htdocs/langs/en_US/categories.lang @@ -78,6 +78,7 @@ CatMemberList=List of members tags/categories CatContactList=List of contact tags/categories CatSupLinks=Links between suppliers and tags/categories CatCusLinks=Links between customers/prospects and tags/categories +CatContactsLinks=Links between contacts/addresses and tags/categories CatProdLinks=Links between products/services and tags/categories CatProJectLinks=Links between projects and tags/categories DeleteFromCat=Remove from tags/category From db1e324ba537923888d131840c540c9db3715355 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 19 Feb 2020 13:58:04 +0100 Subject: [PATCH 37/94] Fix trans --- htdocs/langs/en_US/products.lang | 2 +- htdocs/langs/en_US/projects.lang | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/langs/en_US/products.lang b/htdocs/langs/en_US/products.lang index b9293b6187c..6f3994572c6 100644 --- a/htdocs/langs/en_US/products.lang +++ b/htdocs/langs/en_US/products.lang @@ -363,7 +363,7 @@ UsePercentageVariations=Use percentage variations PercentageVariation=Percentage variation ErrorDeletingGeneratedProducts=There was an error while trying to delete existing product variants NbOfDifferentValues=No. of different values -NbProducts=No. of products +NbProducts=Number of products ParentProduct=Parent product HideChildProducts=Hide variant products ShowChildProducts=Show variant products diff --git a/htdocs/langs/en_US/projects.lang b/htdocs/langs/en_US/projects.lang index 55f70e68b21..9c1f5029604 100644 --- a/htdocs/langs/en_US/projects.lang +++ b/htdocs/langs/en_US/projects.lang @@ -39,8 +39,8 @@ ShowProject=Show project ShowTask=Show task SetProject=Set project NoProject=No project defined or owned -NbOfProjects=No. of projects -NbOfTasks=No. of tasks +NbOfProjects=Number of projects +NbOfTasks=Number of tasks TimeSpent=Time spent TimeSpentByYou=Time spent by you TimeSpentByUser=Time spent by user From 0c571c037668a29b1a8ce7eacc25fce36f58c882 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 19 Feb 2020 13:59:01 +0100 Subject: [PATCH 38/94] Restore common behaviour: Draft object are on left under graph. Open and live objects are on right --- htdocs/core/lib/project.lib.php | 65 ++++++++++++++++++++++----------- htdocs/projet/index.php | 29 ++++++++++++--- 2 files changed, 68 insertions(+), 26 deletions(-) diff --git a/htdocs/core/lib/project.lib.php b/htdocs/core/lib/project.lib.php index 7609d7b759b..8e78e4e45be 100644 --- a/htdocs/core/lib/project.lib.php +++ b/htdocs/core/lib/project.lib.php @@ -2147,16 +2147,17 @@ function print_projecttasks_array($db, $form, $socid, $projectsListId, $mytasks print_liste_field_titre("ThirdParty", $_SERVER["PHP_SELF"], "", "", "", "", $sortfield, $sortorder); if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES)) { + if (!in_array('prospectionstatus', $hiddenfields)) print_liste_field_titre("OpportunityStatus", "", "", "", "", '', $sortfield, $sortorder, 'right '); print_liste_field_titre("OpportunityAmount", "", "", "", "", 'align="right"', $sortfield, $sortorder); print_liste_field_titre('OpportunityWeightedAmount', '', '', '', '', 'align="right"', $sortfield, $sortorder); } if (empty($conf->global->PROJECT_HIDE_TASKS)) { print_liste_field_titre("Tasks", "", "", "", "", 'align="right"', $sortfield, $sortorder); - if (!in_array('plannedworkload', $hiddenfields)) print_liste_field_titre("PlannedWorkload", "", "", "", "", 'align="right"', $sortfield, $sortorder); - if (!in_array('declaredprogress', $hiddenfields)) print_liste_field_titre("ProgressDeclared", "", "", "", "", 'align="right"', $sortfield, $sortorder); + if (!in_array('plannedworkload', $hiddenfields)) print_liste_field_titre("PlannedWorkload", "", "", "", "", '', $sortfield, $sortorder, 'right '); + if (!in_array('declaredprogress', $hiddenfields)) print_liste_field_titre("ProgressDeclared", "", "", "", "", '', $sortfield, $sortorder, 'right '); } - print_liste_field_titre("Status", "", "", "", "", 'align="right"', $sortfield, $sortorder); + if (!in_array('projectstatus', $hiddenfields)) print_liste_field_titre("Status", "", "", "", "", '', $sortfield, $sortorder, 'right '); print "\n"; $total_plannedworkload = 0; @@ -2179,8 +2180,8 @@ function print_projecttasks_array($db, $form, $socid, $projectsListId, $mytasks $projectstatic->datee = $db->jdate($objp->datee); $projectstatic->dateo = $db->jdate($objp->dateo); - print ''; + print ''; print $projectstatic->getNomUrl(1); if (!in_array('projectlabel', $hiddenfields)) print '
'.dol_trunc($objp->title, 24); @@ -2194,8 +2195,35 @@ function print_projecttasks_array($db, $form, $socid, $projectsListId, $mytasks print $thirdpartystatic->getNomUrl(1); } print ''; + if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES)) { + if (!in_array('prospectionstatus', $hiddenfields)) { + print ''; + // Because color of prospection status has no meaning yet, it is used if hidden constant is set + if (empty($conf->global->USE_COLOR_FOR_PROSPECTION_STATUS)) { + if ($langs->trans("OppStatus" . $oppStatusCode) != "OppStatus" . $oppStatusCode) { + print $langs->trans("OppStatus" . $oppStatusCode); + } + } else { + if (isset($statusOppList[$objp->opp_status])) { + $oppStatusCode = $statusOppList[$objp->opp_status]['code']; + $oppStatusColor = $statusOppList[$objp->opp_status]['color']; + } else { + $oppStatusCode = dol_getIdFromCode($db, $objp->opp_status, 'c_lead_status', 'rowid', 'code'); + $oppStatusColor = ''; + } + if ($oppStatusCode) { + if (!empty($oppStatusColor)) { + print ''; + } else { + print '' . $oppStatusCode . ''; + } + } + } + print ''; + } + print ''; if ($objp->opp_amount) print price($objp->opp_amount, 0, '', 1, -1, -1, $conf->currency); print ''; @@ -2207,6 +2235,7 @@ function print_projecttasks_array($db, $form, $socid, $projectsListId, $mytasks } print ''; } + if (empty($conf->global->PROJECT_HIDE_TASKS)) { print ''.$objp->nb.''; @@ -2228,23 +2257,12 @@ function print_projecttasks_array($db, $form, $socid, $projectsListId, $mytasks } } - print ''; - //print $projectstatic->getLibStatut(3); - if (isset($statusOppList[$objp->opp_status])) { - $oppStatusCode = $statusOppList[$objp->opp_status]['code']; - $oppStatusColor = $statusOppList[$objp->opp_status]['color']; - } else { - $oppStatusCode = dol_getIdFromCode($db, $objp->opp_status, 'c_lead_status', 'rowid', 'code'); - $oppStatusColor = ''; + if (!in_array('projectstatus', $hiddenfields)) { + print ''; + print $projectstatic->getLibStatut(3); + print ''; } - if ($oppStatusCode) { - if (!empty($oppStatusColor)) { - print ''; - } else { - print '' . $oppStatusCode . ''; - } - } - print ''; + print "\n"; $total_task = $total_task + $objp->nb; @@ -2258,6 +2276,9 @@ function print_projecttasks_array($db, $form, $socid, $projectsListId, $mytasks print ''.$langs->trans("Total").""; if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES)) { + if (!in_array('prospectionstatus', $hiddenfields)) { + print ''; + } print ''.price($total_opp_amount, 0, '', 1, -1, -1, $conf->currency).''; print ''.$form->textwithpicto(price($ponderated_opp_amount, 0, '', 1, -1, -1, $conf->currency), $langs->trans("OpportunityPonderatedAmountDesc"), 1).''; } @@ -2267,7 +2288,9 @@ function print_projecttasks_array($db, $form, $socid, $projectsListId, $mytasks if (!in_array('plannedworkload', $hiddenfields)) print ''.($total_plannedworkload ?convertSecondToTime($total_plannedworkload) : '').''; if (!in_array('declaredprogress', $hiddenfields)) print ''.($total_plannedworkload ?round(100 * $total_declaredprogressworkload / $total_plannedworkload, 0).'%' : '').''; } - print ''; + if (!in_array('projectstatus', $hiddenfields)) { + print ''; + } print ''; $db->free($resql); diff --git a/htdocs/projet/index.php b/htdocs/projet/index.php index 9ab79a3b677..0613fd75e8f 100644 --- a/htdocs/projet/index.php +++ b/htdocs/projet/index.php @@ -166,7 +166,7 @@ include DOL_DOCUMENT_ROOT.'/projet/graph_opportunities.inc.php'; // List of draft projects -print_projecttasks_array($db, $form, $socid, $projectsListId, 0, 0, $listofoppstatus, array('projectlabel', 'plannedworkload', 'declaredprogress')); +print_projecttasks_array($db, $form, $socid, $projectsListId, 0, 0, $listofoppstatus, array('projectlabel', 'plannedworkload', 'declaredprogress', 'prospectionstatus', 'projectstatus')); print '
'; @@ -274,17 +274,25 @@ if ($mine || empty($user->rights->projet->all->lire)) $sql .= " AND p.rowid IN ( if ($socid) $sql .= " AND (p.fk_soc IS NULL OR p.fk_soc = 0 OR p.fk_soc = ".$socid.")"; $sql .= " GROUP BY s.nom, s.rowid"; $sql .= $db->order($sortfield, $sortorder); +//$sql .= $db->plimit($max + 1, 0); $resql = $db->query($sql); if ($resql) { $num = $db->num_rows($resql); $i = 0; + $othernb = 0; while ($i < $num) { $obj = $db->fetch_object($resql); + if ($i >= $max) { + $othernb += $obj->nb; + $i++; + continue; + } + print ''; print ''; if ($obj->socid) @@ -296,6 +304,7 @@ if ($resql) else { print $langs->trans("OthersNotLinkedToThirdParty"); + $i--; } print ''; print ''; @@ -306,6 +315,16 @@ if ($resql) $i++; } + if ($othernb) { + print ''; + print ''; + print '...'; + print ''; + print ''; + print $othernb; + print ''; + print "\n"; + } $db->free($resql); } @@ -316,10 +335,10 @@ else print ""; print '
'; -if (!empty($conf->global->PROJECT_SHOW_PROJECT_LIST_ON_PROJECT_AREA)) +if (empty($conf->global->PROJECT_HIDE_PROJECT_LIST_ON_PROJECT_AREA)) { - // This list can be very long, so we don't show it by default on task area. We prefer to use the list page. - // Add constant PROJECT_SHOW_PROJECT_LIST_ON_PROJECT_AREA to show this list + // This list can be very long, so we allow to hide it to prefer to use the list page. + // Add constant PROJECT_HIDE_PROJECT_LIST_ON_PROJECT_AREA to show this list print '
'; @@ -329,7 +348,7 @@ if (!empty($conf->global->PROJECT_SHOW_PROJECT_LIST_ON_PROJECT_AREA)) print '
'; $parameters = array('user' => $user); -$reshook = $hookmanager->executeHooks('dashboardProjects', $parameters, $object); // Note that $action and $object may have been modified by hook +$reshook = $hookmanager->executeHooks('dashboardProjects', $parameters, $projectstatic); // Note that $action and $object may have been modified by hook // End of page llxFooter(); From ace0c7f89dc9cd072de163ca39bb61056ad62bf0 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 19 Feb 2020 14:31:32 +0100 Subject: [PATCH 39/94] Fix list of opportunity with filter on search_usage_opportunity --- htdocs/core/menus/standard/eldy.lib.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/menus/standard/eldy.lib.php b/htdocs/core/menus/standard/eldy.lib.php index 109de3a99c4..f66768b7ffb 100644 --- a/htdocs/core/menus/standard/eldy.lib.php +++ b/htdocs/core/menus/standard/eldy.lib.php @@ -1683,11 +1683,11 @@ function print_left_eldy_menu($db, $menu_array_before, $menu_array_after, &$tabM elseif ($conf->global->PROJECT_USE_OPPORTUNITIES == 1) { $newmenu->add("/projet/list.php?leftmenu=projets".($search_project_user ? '&search_project_user='.$search_project_user : ''), $langs->trans("List"), 1, $showmode, '', 'project', 'list'); - $newmenu->add('/projet/list.php?mainmenu=project&leftmenu=list&search_opp_status=openedopp&search_status=99&contextpage=lead', $langs->trans("ListOpenLeads"), 2, $showmode); + $newmenu->add('/projet/list.php?mainmenu=project&leftmenu=list&search_usage_opportunity=1&search_status=99&contextpage=lead', $langs->trans("ListOpenLeads"), 2, $showmode); $newmenu->add('/projet/list.php?mainmenu=project&leftmenu=list&search_opp_status=notopenedopp&search_status=99&contextpage=project', $langs->trans("ListOpenProjects"), 2, $showmode); } elseif ($conf->global->PROJECT_USE_OPPORTUNITIES == 2) { // 2 = leads only - $newmenu->add('/projet/list.php?mainmenu=project&leftmenu=list&search_opp_status=openedopp&search_status=99', $langs->trans("List"), 2, $showmode); + $newmenu->add('/projet/list.php?mainmenu=project&leftmenu=list&search_usage_opportunity=1&search_status=99', $langs->trans("List"), 2, $showmode); } $newmenu->add("/projet/stats/index.php?leftmenu=projects", $langs->trans("Statistics"), 1, $user->rights->projet->lire); From 91899d2f56c18761a28bfe2dc11207d91d3ed2cc Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 19 Feb 2020 14:31:32 +0100 Subject: [PATCH 40/94] Fix list of opportunity with filter on search_usage_opportunity --- htdocs/core/menus/standard/eldy.lib.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/menus/standard/eldy.lib.php b/htdocs/core/menus/standard/eldy.lib.php index 109de3a99c4..f66768b7ffb 100644 --- a/htdocs/core/menus/standard/eldy.lib.php +++ b/htdocs/core/menus/standard/eldy.lib.php @@ -1683,11 +1683,11 @@ function print_left_eldy_menu($db, $menu_array_before, $menu_array_after, &$tabM elseif ($conf->global->PROJECT_USE_OPPORTUNITIES == 1) { $newmenu->add("/projet/list.php?leftmenu=projets".($search_project_user ? '&search_project_user='.$search_project_user : ''), $langs->trans("List"), 1, $showmode, '', 'project', 'list'); - $newmenu->add('/projet/list.php?mainmenu=project&leftmenu=list&search_opp_status=openedopp&search_status=99&contextpage=lead', $langs->trans("ListOpenLeads"), 2, $showmode); + $newmenu->add('/projet/list.php?mainmenu=project&leftmenu=list&search_usage_opportunity=1&search_status=99&contextpage=lead', $langs->trans("ListOpenLeads"), 2, $showmode); $newmenu->add('/projet/list.php?mainmenu=project&leftmenu=list&search_opp_status=notopenedopp&search_status=99&contextpage=project', $langs->trans("ListOpenProjects"), 2, $showmode); } elseif ($conf->global->PROJECT_USE_OPPORTUNITIES == 2) { // 2 = leads only - $newmenu->add('/projet/list.php?mainmenu=project&leftmenu=list&search_opp_status=openedopp&search_status=99', $langs->trans("List"), 2, $showmode); + $newmenu->add('/projet/list.php?mainmenu=project&leftmenu=list&search_usage_opportunity=1&search_status=99', $langs->trans("List"), 2, $showmode); } $newmenu->add("/projet/stats/index.php?leftmenu=projects", $langs->trans("Statistics"), 1, $user->rights->projet->lire); From 3fafbb372b39900adc7bb9a6bb9746f1f49199c2 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 19 Feb 2020 15:51:27 +0100 Subject: [PATCH 41/94] Remove call of $mc->dao than hangs. Replaced with $mc use. --- htdocs/compta/accounting-files.php | 21 ++++++++++++++++----- htdocs/compta/bank/treso.php | 7 +++++-- 2 files changed, 21 insertions(+), 7 deletions(-) diff --git a/htdocs/compta/accounting-files.php b/htdocs/compta/accounting-files.php index ac019de8088..b7d1cdd633e 100644 --- a/htdocs/compta/accounting-files.php +++ b/htdocs/compta/accounting-files.php @@ -77,7 +77,13 @@ if ($user->socid > 0) { accessforbidden(); } -$entity = GETPOST('entity', 'int') ?GETPOST('entity', 'int') : $conf->entity; +$entity = (GETPOSTISSET('entity') ? GETPOST('entity', 'int') : (GETPOSTISSET('search_entity') ? GETPOST('search_entity', 'int') : $conf->entity)); +if (empty($entity) && ! empty($conf->global->MULTICOMPANY_ALLOW_EXPORT_ACCOUNTING_DOC_FOR_ALL_ENTITIES)) { + $tmparray = $mc->getEntitiesList(); + $entity = '0,'.join(',', array_keys($tmparray)); +} +if (empty($entity)) $entity = $conf->entity; + /* @@ -400,13 +406,18 @@ print ''; print $langs->trans("ReportPeriod").': '.$form->selectDate($date_start, 'date_start', 0, 0, 0, "", 1, 1, 0); print ' - '.$form->selectDate($date_stop, 'date_stop', 0, 0, 0, "", 1, 1, 0)."\n"; -// Export is for current company only ! +// Export is for current company only if (!empty($conf->multicompany->enabled) && is_object($mc)) { + $mc->getInfo($conf->entity); print '('.$langs->trans("Entity").' : '; - $mc->dao->getEntities(); - $mc->dao->fetch($conf->entity); - print $mc->dao->label; + print ""; + if (! empty($conf->global->MULTICOMPANY_ALLOW_EXPORT_ACCOUNTING_DOC_FOR_ALL_ENTITIES)) { + print $mc->select_entities(GETPOSTISSET('search_entity') ? GETPOST('search_entity', 'int') : $mc->id, 'search_entity', '', false, false, false, false, true); + } else { + print $mc->label; + } + print ""; print ")\n"; } diff --git a/htdocs/compta/bank/treso.php b/htdocs/compta/bank/treso.php index 7ca62b67ab8..906ef09ac6b 100644 --- a/htdocs/compta/bank/treso.php +++ b/htdocs/compta/bank/treso.php @@ -286,11 +286,14 @@ if ($_REQUEST["account"] || $_REQUEST["ref"]) else print $langs->trans("NotDefined"); print ""; print "".$ref.""; - if($conf->global->MULTICOMPANY_INVOICE_SHARING_ENABLED ){ + if ($conf->global->MULTICOMPANY_INVOICE_SHARING_ENABLED) { if($obj->family == 'invoice'){ $mc->getInfo($obj->entity); print "".$mc->label.""; - }else print ""; + } + else { + print ""; + } } print "".$refcomp.""; if ($obj->total_ttc < 0) { print ''.price(abs($total_ttc))." "; }; From 44c2909696c8197561f11d71f5cd25995e60a0c2 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 19 Feb 2020 16:08:33 +0100 Subject: [PATCH 42/94] FIX Multicompany compatibility --- htdocs/compta/accounting-files.php | 41 ++++++++++++++++++++++-------- 1 file changed, 31 insertions(+), 10 deletions(-) diff --git a/htdocs/compta/accounting-files.php b/htdocs/compta/accounting-files.php index b7d1cdd633e..af18b834edf 100644 --- a/htdocs/compta/accounting-files.php +++ b/htdocs/compta/accounting-files.php @@ -77,13 +77,22 @@ if ($user->socid > 0) { accessforbidden(); } +// Define $arrayofentities if multientity is set. +$arrayofentities = array(); +if (!empty($conf->multicompany->enabled) && is_object($mc)) { + $arrayofentities = $mc->getEntitiesList(); +} + $entity = (GETPOSTISSET('entity') ? GETPOST('entity', 'int') : (GETPOSTISSET('search_entity') ? GETPOST('search_entity', 'int') : $conf->entity)); -if (empty($entity) && ! empty($conf->global->MULTICOMPANY_ALLOW_EXPORT_ACCOUNTING_DOC_FOR_ALL_ENTITIES)) { - $tmparray = $mc->getEntitiesList(); - $entity = '0,'.join(',', array_keys($tmparray)); +if (!empty($conf->multicompany->enabled) && is_object($mc)) { + if (empty($entity) && ! empty($conf->global->MULTICOMPANY_ALLOW_EXPORT_ACCOUNTING_DOC_FOR_ALL_ENTITIES)) { + $entity = '0,'.join(',', array_keys($arrayofentities)); + } } if (empty($entity)) $entity = $conf->entity; +$error = 0; + /* @@ -114,42 +123,42 @@ if (($action == "searchfiles" || $action == "dl")) { $wheretail = " '".$db->idate($date_start)."' AND '".$db->idate($date_stop)."'"; // Customer invoices - $sql = "SELECT t.rowid as id, t.ref, t.paye as paid, total as total_ht, total_ttc, tva as total_vat, fk_soc, t.datef as date, 'Invoice' as item, s.nom as thirdparty_name, s.code_client as thirdparty_code, c.code as country_code, s.tva_intra as vatnum"; + $sql = "SELECT t.rowid as id, t.entity, t.ref, t.paye as paid, total as total_ht, total_ttc, tva as total_vat, fk_soc, t.datef as date, 'Invoice' as item, s.nom as thirdparty_name, s.code_client as thirdparty_code, c.code as country_code, s.tva_intra as vatnum"; $sql .= " FROM ".MAIN_DB_PREFIX."facture as t LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = t.fk_soc LEFT JOIN ".MAIN_DB_PREFIX."c_country as c ON c.rowid = s.fk_pays"; $sql .= " WHERE datef between ".$wheretail; $sql .= " AND t.entity IN (".($entity == 1 ? '0,1' : $entity).')'; $sql .= " AND t.fk_statut <> ".Facture::STATUS_DRAFT; $sql .= " UNION ALL"; // Vendor invoices - $sql .= " SELECT t.rowid as id, t.ref, paye as paid, total_ht, total_ttc, total_tva as total_vat, fk_soc, datef as date, 'SupplierInvoice' as item, s.nom as thirdparty_name, s.code_fournisseur as thirdparty_code, c.code as country_code, s.tva_intra as vatnum"; + $sql .= " SELECT t.rowid as id, t.entity, t.ref, paye as paid, total_ht, total_ttc, total_tva as total_vat, fk_soc, datef as date, 'SupplierInvoice' as item, s.nom as thirdparty_name, s.code_fournisseur as thirdparty_code, c.code as country_code, s.tva_intra as vatnum"; $sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn as t LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = t.fk_soc LEFT JOIN ".MAIN_DB_PREFIX."c_country as c ON c.rowid = s.fk_pays"; $sql .= " WHERE datef between ".$wheretail; $sql .= " AND t.entity IN (".($entity == 1 ? '0,1' : $entity).')'; $sql .= " AND t.fk_statut <> ".FactureFournisseur::STATUS_DRAFT; $sql .= " UNION ALL"; // Expense reports - $sql .= " SELECT t.rowid as id, t.ref, paid, total_ht, total_ttc, total_tva as total_vat, fk_user_author as fk_soc, date_fin as date, 'ExpenseReport' as item, CONCAT(CONCAT(u.lastname, ' '), u.firstname) as thirdparty_name, '' as thirdparty_code, c.code as country_code, '' as vatnum"; + $sql .= " SELECT t.rowid as id, t.entity, t.ref, paid, total_ht, total_ttc, total_tva as total_vat, fk_user_author as fk_soc, date_fin as date, 'ExpenseReport' as item, CONCAT(CONCAT(u.lastname, ' '), u.firstname) as thirdparty_name, '' as thirdparty_code, c.code as country_code, '' as vatnum"; $sql .= " FROM ".MAIN_DB_PREFIX."expensereport as t LEFT JOIN ".MAIN_DB_PREFIX."user as u ON u.rowid = t.fk_user_author LEFT JOIN ".MAIN_DB_PREFIX."c_country as c ON c.rowid = u.fk_country"; $sql .= " WHERE date_fin between ".$wheretail; $sql .= " AND t.entity IN (".($entity == 1 ? '0,1' : $entity).')'; $sql .= " AND t.fk_statut <> ".ExpenseReport::STATUS_DRAFT; $sql .= " UNION ALL"; // Donations - $sql .= " SELECT t.rowid as id, t.ref, paid, amount as total_ht, amount as total_ttc, 0 as total_vat, 0 as fk_soc, datedon as date, 'Donation' as item, t.societe as thirdparty_name, '' as thirdparty_code, c.code as country_code, '' as vatnum"; + $sql .= " SELECT t.rowid as id, t.entity, t.ref, paid, amount as total_ht, amount as total_ttc, 0 as total_vat, 0 as fk_soc, datedon as date, 'Donation' as item, t.societe as thirdparty_name, '' as thirdparty_code, c.code as country_code, '' as vatnum"; $sql .= " FROM ".MAIN_DB_PREFIX."don as t LEFT JOIN ".MAIN_DB_PREFIX."c_country as c ON c.rowid = t.fk_country"; $sql .= " WHERE datedon between ".$wheretail; $sql .= " AND t.entity IN (".($entity == 1 ? '0,1' : $entity).')'; $sql .= " AND t.fk_statut <> ".Don::STATUS_DRAFT; $sql .= " UNION ALL"; // Paiements of salaries - $sql .= " SELECT t.rowid as id, t.ref as ref, 1 as paid, amount as total_ht, amount as total_ttc, 0 as total_vat, t.fk_user as fk_soc, datep as date, 'SalaryPayment' as item, CONCAT(CONCAT(u.lastname, ' '), u.firstname) as thirdparty_name, '' as thirdparty_code, c.code as country_code, '' as vatnum"; + $sql .= " SELECT t.rowid as id, t.entity, t.ref as ref, 1 as paid, amount as total_ht, amount as total_ttc, 0 as total_vat, t.fk_user as fk_soc, datep as date, 'SalaryPayment' as item, CONCAT(CONCAT(u.lastname, ' '), u.firstname) as thirdparty_name, '' as thirdparty_code, c.code as country_code, '' as vatnum"; $sql .= " FROM ".MAIN_DB_PREFIX."payment_salary as t LEFT JOIN ".MAIN_DB_PREFIX."user as u ON u.rowid = t.fk_user LEFT JOIN ".MAIN_DB_PREFIX."c_country as c ON c.rowid = u.fk_country"; $sql .= " WHERE datep between ".$wheretail; $sql .= " AND t.entity IN (".($entity == 1 ? '0,1' : $entity).')'; //$sql.=" AND fk_statut <> ".PaymentSalary::STATUS_DRAFT; $sql .= " UNION ALL"; // Social contributions - $sql .= " SELECT t.rowid as id, t.libelle as ref, paye as paid, amount as total_ht, amount as total_ttc, 0 as total_tva, 0 as fk_soc, date_creation as date, 'SocialContributions' as item, '' as thirdparty_name, '' as thirdparty_code, '' as country_code, '' as vatnum"; + $sql .= " SELECT t.rowid as id, t.entity, t.libelle as ref, paye as paid, amount as total_ht, amount as total_ttc, 0 as total_tva, 0 as fk_soc, date_creation as date, 'SocialContributions' as item, '' as thirdparty_name, '' as thirdparty_code, '' as country_code, '' as vatnum"; $sql .= " FROM ".MAIN_DB_PREFIX."chargesociales as t"; $sql .= " WHERE date_creation between ".$wheretail; $sql .= " AND t.entity IN (".($entity == 1 ? '0,1' : $entity).')'; @@ -234,6 +243,7 @@ if (($action == "searchfiles" || $action == "dl")) { { $nofile = array(); $nofile['id'] = $objd->id; + $nofile['entity'] = $objd->entity; $nofile['date'] = $db->idate($objd->date); $nofile['paid'] = $objd->paid; $nofile['amount_ht'] = $objd->total_ht; @@ -254,6 +264,7 @@ if (($action == "searchfiles" || $action == "dl")) { foreach ($files as $key => $file) { $file['id'] = $objd->id; + $file['entity'] = $objd->entity; $file['date'] = $db->idate($objd->date); $file['paid'] = $objd->paid; $file['amount_ht'] = $objd->total_ht; @@ -320,6 +331,10 @@ if ($result && $action == "dl" && !$error) dol_mkdir($dirfortmpfile); $log = $langs->transnoentitiesnoconv("Type"); + if (!empty($conf->multicompany->enabled) && is_object($mc)) + { + $log .= ','.$langs->transnoentitiesnoconv("Entity"); + } $log .= ','.$langs->transnoentitiesnoconv("Date"); $log .= ','.$langs->transnoentitiesnoconv("Ref"); $log .= ','.$langs->transnoentitiesnoconv("TotalHT"); @@ -348,6 +363,10 @@ if ($result && $action == "dl" && !$error) } $log .= $file['item']; + if (!empty($conf->multicompany->enabled) && is_object($mc)) + { + $log .= ','.(empty($arrayofentities[$file['entity']]) ? $file['entity'] : $arrayofentities[$file['entity']]); + } $log .= ','.dol_print_date($file['date'], 'dayrfc'); $log .= ','.$file['ref']; $log .= ','.$file['amount_ht']; @@ -389,11 +408,13 @@ $form = new Form($db); $userstatic = new User($db); $title = $langs->trans("ComptaFiles").' - '.$langs->trans("List"); +$help_url = ''; llxHeader('', $title, $help_url); $h = 0; -$head[$h][0] = $_SERVER["PHP_SELF"].$varlink; +$head = array(); +$head[$h][0] = $_SERVER["PHP_SELF"]; $head[$h][1] = $langs->trans("AccountantFiles"); $head[$h][2] = 'AccountancyFiles'; From c14daa2790f9f383b650e244a96dfef699b141ae Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 19 Feb 2020 18:32:04 +0100 Subject: [PATCH 43/94] Can set main language and sublanguages of a website --- .../install/mysql/migration/11.0.0-12.0.0.sql | 3 + htdocs/install/mysql/tables/llx_website.sql | 2 + htdocs/langs/en_US/website.lang | 3 + htdocs/website/class/website.class.php | 55 ++++++++++++++++++- htdocs/website/index.php | 51 +++++++++++++++-- 5 files changed, 107 insertions(+), 7 deletions(-) diff --git a/htdocs/install/mysql/migration/11.0.0-12.0.0.sql b/htdocs/install/mysql/migration/11.0.0-12.0.0.sql index 447630e7eb2..9e718148794 100644 --- a/htdocs/install/mysql/migration/11.0.0-12.0.0.sql +++ b/htdocs/install/mysql/migration/11.0.0-12.0.0.sql @@ -44,6 +44,9 @@ ALTER TABLE llx_commande_fournisseur_dispatch_extrafields ADD INDEX idx_commande -- For v12 +ALTER TABLE llx_website ADD COLUMN lang varchar(8); +ALTER TABLE llx_website ADD COLUMN otherlang varchar(255); + ALTER TABLE llx_holiday_users DROP INDEX uk_holiday_users; ALTER TABLE llx_holiday_users ADD UNIQUE INDEX uk_holiday_users(fk_user, fk_type); diff --git a/htdocs/install/mysql/tables/llx_website.sql b/htdocs/install/mysql/tables/llx_website.sql index 645343544a4..743d4ec9ca8 100644 --- a/htdocs/install/mysql/tables/llx_website.sql +++ b/htdocs/install/mysql/tables/llx_website.sql @@ -26,6 +26,8 @@ CREATE TABLE llx_website description varchar(255), maincolor varchar(16), maincolorbis varchar(16), + lang varchar(8), + otherlang varchar(255), status integer DEFAULT 1, fk_default_home integer, use_manifest integer, diff --git a/htdocs/langs/en_US/website.lang b/htdocs/langs/en_US/website.lang index 1d31a763523..ee46c9f4954 100644 --- a/htdocs/langs/en_US/website.lang +++ b/htdocs/langs/en_US/website.lang @@ -121,3 +121,6 @@ BackToHomePage=Back to home page... TranslationLinks=Translation links YouTryToAccessToAFileThatIsNotAWebsitePage=You try to access to a page that is not a website page UseTextBetween5And70Chars=For good SEO practices, use a text between 5 and 70 characters +MainLanguage=Main language +OtherLanguages=Other languages +UseManifest=Provide a manifest.json file \ No newline at end of file diff --git a/htdocs/website/class/website.class.php b/htdocs/website/class/website.class.php index c722b7adc36..927d54f5b29 100644 --- a/htdocs/website/class/website.class.php +++ b/htdocs/website/class/website.class.php @@ -70,6 +70,16 @@ class Website extends CommonObject */ public $description; + /** + * @var string Main language of web site + */ + public $lang; + + /** + * @var string List of languages of web site ('fr', 'es_MX', ...) + */ + public $otherlang; + /** * @var int Status */ @@ -171,6 +181,8 @@ class Website extends CommonObject $sql .= 'entity,'; $sql .= 'ref,'; $sql .= 'description,'; + $sql .= 'lang,'; + $sql .= 'otherlang,'; $sql .= 'status,'; $sql .= 'fk_default_home,'; $sql .= 'virtualhost,'; @@ -181,6 +193,8 @@ class Website extends CommonObject $sql .= ' '.((empty($this->entity) && $this->entity != '0') ? 'NULL' : $this->entity).','; $sql .= ' '.(!isset($this->ref) ? 'NULL' : "'".$this->db->escape($this->ref)."'").','; $sql .= ' '.(!isset($this->description) ? 'NULL' : "'".$this->db->escape($this->description)."'").','; + $sql .= ' '.(!isset($this->lang) ? 'NULL' : "'".$this->db->escape($this->lang)."'").','; + $sql .= ' '.(!isset($this->otherlang) ? 'NULL' : "'".$this->db->escape($this->otherlang)."'").','; $sql .= ' '.(!isset($this->status) ? '1' : $this->status).','; $sql .= ' '.(!isset($this->fk_default_home) ? 'NULL' : $this->fk_default_home).','; $sql .= ' '.(!isset($this->virtualhost) ? 'NULL' : "'".$this->db->escape($this->virtualhost)."'").","; @@ -201,6 +215,16 @@ class Website extends CommonObject if (!$error) { $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX.$this->table_element); + // Create subdirectory per language + $tmplangarray = explode(',', $this->otherlang); + if (is_array($tmplangarray)) { + dol_mkdir($conf->website->dir_output.'/'.$this->ref); + foreach($tmplangarray as $val) { + if (trim($val) == $this->lang) continue; + dol_mkdir($conf->website->dir_output.'/'.$this->ref.'/'.trim($val)); + } + } + // Uncomment this and change MYOBJECT to your own tag if you // want this action to call a trigger. // if (!$notrigger) { @@ -240,6 +264,8 @@ class Website extends CommonObject $sql .= " t.entity,"; $sql .= " t.ref,"; $sql .= " t.description,"; + $sql .= " t.lang,"; + $sql .= " t.otherlang,"; $sql .= " t.status,"; $sql .= " t.fk_default_home,"; $sql .= " t.use_manifest,"; @@ -267,6 +293,8 @@ class Website extends CommonObject $this->entity = $obj->entity; $this->ref = $obj->ref; $this->description = $obj->description; + $this->lang = $obj->lang; + $this->otherlang = $obj->otherlang; $this->status = $obj->status; $this->fk_default_home = $obj->fk_default_home; $this->virtualhost = $obj->virtualhost; @@ -332,6 +360,8 @@ class Website extends CommonObject $sql .= " t.entity,"; $sql .= " t.ref,"; $sql .= " t.description,"; + $sql .= " t.lang,"; + $sql .= " t.otherlang,"; $sql .= " t.status,"; $sql .= " t.fk_default_home,"; $sql .= " t.virtualhost,"; @@ -372,6 +402,8 @@ class Website extends CommonObject $line->entity = $obj->entity; $line->ref = $obj->ref; $line->description = $obj->description; + $line->lang = $obj->lang; + $line->otherlang = $obj->otherlang; $line->status = $obj->status; $line->fk_default_home = $obj->fk_default_home; $line->virtualhost = $obj->virtualhost; @@ -403,6 +435,8 @@ class Website extends CommonObject */ public function update(User $user, $notrigger = false) { + global $conf; + $error = 0; dol_syslog(__METHOD__, LOG_DEBUG); @@ -430,6 +464,8 @@ class Website extends CommonObject $sql .= ' entity = '.(isset($this->entity) ? $this->entity : "null").','; $sql .= ' ref = '.(isset($this->ref) ? "'".$this->db->escape($this->ref)."'" : "null").','; $sql .= ' description = '.(isset($this->description) ? "'".$this->db->escape($this->description)."'" : "null").','; + $sql .= ' lang = '.(isset($this->lang) ? "'".$this->db->escape($this->lang)."'" : "null").','; + $sql .= ' otherlang = '.(isset($this->otherlang) ? "'".$this->db->escape($this->otherlang)."'" : "null").','; $sql .= ' status = '.(isset($this->status) ? $this->status : "null").','; $sql .= ' fk_default_home = '.(($this->fk_default_home > 0) ? $this->fk_default_home : "null").','; $sql .= ' use_manifest = '.((int) $this->use_manifest).','; @@ -452,6 +488,16 @@ class Website extends CommonObject // Uncomment this and change MYOBJECT to your own tag if you // want this action calls a trigger. + // Create subdirectory per language + $tmplangarray = explode(',', $this->otherlang); + if (is_array($tmplangarray)) { + dol_mkdir($conf->website->dir_output.'/'.$this->ref); + foreach($tmplangarray as $val) { + if (trim($val) == $this->lang) continue; + dol_mkdir($conf->website->dir_output.'/'.$this->ref.'/'.trim($val)); + } + } + //// Call triggers //$result=$this->call_trigger('MYOBJECT_MODIFY',$user); //if ($result < 0) { $error++; //Do also what you must do to rollback action if trigger fail} @@ -715,7 +761,8 @@ class Website extends CommonObject $label = ''.$langs->trans("WebSite").''; $label .= '
'; - $label .= ''.$langs->trans('Ref').': '.$this->ref; + $label .= ''.$langs->trans('Ref').': '.$this->ref.'
'; + $label .= ''.$langs->trans('MainLanguage').': '.$this->lang; $linkstart = 'entity = 1; $this->ref = 'myspecimenwebsite'; $this->description = 'A specimen website'; + $this->lang = 'en'; + $this->otherlang = 'fr,es_MX'; $this->status = ''; $this->fk_default_home = null; $this->virtualhost = 'http://myvirtualhost'; @@ -926,7 +975,7 @@ class Website extends CommonObject fputs($fp, $line); // Warning: We must keep llx_ here. It is a generic SQL. - $line = 'INSERT INTO llx_website_page(rowid, fk_page, fk_website, pageurl, aliasalt, title, description, image, keywords, status, date_creation, tms, lang, import_key, grabbed_from, type_container, htmlheader, content)'; + $line = 'INSERT INTO llx_website_page(rowid, fk_page, fk_website, pageurl, aliasalt, title, description, lang, otherlang, image, keywords, status, date_creation, tms, lang, import_key, grabbed_from, type_container, htmlheader, content)'; $line .= " VALUES("; $line .= $objectpageold->newid."__+MAX_llx_website_page__, "; @@ -936,6 +985,8 @@ class Website extends CommonObject $line .= "'".$this->db->escape($objectpageold->aliasalt)."', "; $line .= "'".$this->db->escape($objectpageold->title)."', "; $line .= "'".$this->db->escape($objectpageold->description)."', "; + $line .= "'".$this->db->escape($objectpageold->lang)."', "; + $line .= "'".$this->db->escape($objectpageold->otherlang)."', "; $line .= "'".$this->db->escape($objectpageold->image)."', "; $line .= "'".$this->db->escape($objectpageold->keywords)."', "; $line .= "'".$this->db->escape($objectpageold->status)."', "; diff --git a/htdocs/website/index.php b/htdocs/website/index.php index 85b50b3d13b..c44341e0361 100644 --- a/htdocs/website/index.php +++ b/htdocs/website/index.php @@ -398,7 +398,9 @@ if ($action == 'addsite') { $tmpobject = new Website($db); $tmpobject->ref = GETPOST('WEBSITE_REF', 'alpha'); - $tmpobject->description = GETPOST('WEBSITE_DESCRIPTION', 'alpha'); + $tmpobject->description = GETPOST('WEBSITE_DESCRIPTION', 'alphanohtml'); + $tmpobject->lang = GETPOST('WEBSITE_LANG', 'aZ09'); + $tmpobject->otherlang = GETPOST('WEBSITE_OTHERLANG', 'aZ09comma'); $tmpobject->virtualhost = GETPOST('virtualhost', 'alpha'); $result = $tmpobject->create($user); @@ -782,6 +784,8 @@ if ($action == 'addcontainer') $objectpage->pageurl = GETPOST('WEBSITE_PAGENAME', 'alpha'); $objectpage->aliasalt = GETPOST('WEBSITE_ALIASALT', 'alpha'); $objectpage->description = GETPOST('WEBSITE_DESCRIPTION', 'alpha'); + $objectpage->lang = GETPOST('WEBSITE_LANG', 'alpha'); + $objectpage->otherlang = GETPOST('WEBSITE_OTHERLANG', 'alpha'); $objectpage->image = GETPOST('WEBSITE_IMAGE', 'alpha'); $objectpage->keywords = GETPOST('WEBSITE_KEYWORDS', 'alpha'); $objectpage->lang = GETPOST('WEBSITE_LANG', 'aZ09'); @@ -1060,6 +1064,8 @@ if ($action == 'updatecss') if (!$error) { $object->virtualhost = GETPOST('virtualhost', 'alpha'); + $object->lang = GETPOST('WEBSITE_LANG', 'aZ09'); + $object->otherlang = GETPOST('WEBSITE_OTHERLANG', 'aZ09comma'); $object->use_manifest = GETPOST('use_manifest', 'alpha'); $result = $object->update($user); @@ -1403,11 +1409,13 @@ if ($action == 'updatemeta') { $objectpage->old_object = clone $objectpage; - $objectpage->title = GETPOST('WEBSITE_TITLE', 'alpha'); - $objectpage->type_container = GETPOST('WEBSITE_TYPE_CONTAINER', 'alpha'); + $objectpage->title = GETPOST('WEBSITE_TITLE', 'alphanohtml'); + $objectpage->type_container = GETPOST('WEBSITE_TYPE_CONTAINER', 'alphanohtml'); $objectpage->pageurl = GETPOST('WEBSITE_PAGENAME', 'alpha'); $objectpage->aliasalt = GETPOST('WEBSITE_ALIASALT', 'alpha'); - $objectpage->description = GETPOST('WEBSITE_DESCRIPTION', 'alpha'); + $objectpage->lang = GETPOST('WEBSITE_LANG', 'aZ09'); + $objectpage->otherlang = GETPOST('WEBSITE_OTHERLANG', 'aZ09comma'); + $objectpage->description = GETPOST('WEBSITE_DESCRIPTION', 'alphanohtml'); $objectpage->image = GETPOST('WEBSITE_IMAGE', 'alpha'); $objectpage->keywords = GETPOST('WEBSITE_KEYWORDS', 'alpha'); $objectpage->lang = GETPOST('WEBSITE_LANG', 'aZ09'); @@ -2691,6 +2699,24 @@ if ($action == 'editcss') print $websitekey; print ''; + // Main language + print ''; + $htmltext=''; + print $form->textwithpicto($langs->trans('MainLanguage'), $htmltext, 1, 'help', '', 0, 2, 'WEBSITE_LANG'); + print ''; + print $formadmin->select_language((GETPOSTISSET('WEBSITE_LANG') ? GETPOST('WEBSITE_LANG', 'alpha') : ($object->lang ? $object->lang : $langs->defaultlang)), 'WEBSITE_LANG', 0, 0, 0, 0, 0, 'minwidth300', 2); + print ''; + print ''; + + // Other languages + print ''; + $htmltext= ''; + print $form->textwithpicto($langs->trans('OtherLanguages'), $htmltext, 1, 'help', '', 0, 2, 'WEBSITE_OTHERLANG'); + print ''; + print ''; + print ''; + print ''; + // VirtualHost print ''; @@ -2816,8 +2842,11 @@ if ($action == 'createsite') print ''; + $siteref = $sitedesc = $sitelang = $siteotherlang = ''; if (GETPOST('WEBSITE_REF')) $siteref = GETPOST('WEBSITE_REF', 'alpha'); if (GETPOST('WEBSITE_DESCRIPTION')) $sitedesc = GETPOST('WEBSITE_DESCRIPTION', 'alpha'); + if (GETPOST('WEBSITE_LANG')) $sitelang = GETPOST('WEBSITE_LANG', 'aZ09'); + if (GETPOST('WEBSITE_OTHERLANG')) $siteotherlang = GETPOST('WEBSITE_OTHERLANG', 'aZ09comma'); print ''; + + print ''; + + print ''; print ''; print ''; @@ -2863,7 +2861,7 @@ if ($action == 'createsite') print ''; print ''; // Translation of From 39c19ea3f60401b40b745c69f2304edb85d81241 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 20 Feb 2020 01:14:30 +0100 Subject: [PATCH 46/94] Disable action greeting --- .github/workflows/greetings-pr.yml | 2 +- .github/workflows/stale-issues.yml | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/greetings-pr.yml b/.github/workflows/greetings-pr.yml index e8bbb023b38..7e96b4ae6e1 100644 --- a/.github/workflows/greetings-pr.yml +++ b/.github/workflows/greetings-pr.yml @@ -1,6 +1,6 @@ name: Greetings PR -on: [pull_request] +#on: [pull_request] jobs: greeting: diff --git a/.github/workflows/stale-issues.yml b/.github/workflows/stale-issues.yml index 4d15f84b3f8..81a8c48a367 100644 --- a/.github/workflows/stale-issues.yml +++ b/.github/workflows/stale-issues.yml @@ -1,4 +1,5 @@ name: "Close stale issues (bugs and feature requests)" + on: schedule: - cron: "0 0 * * *" From 04c71bc79b0a2a4e7ab83a8fb912f4744c621312 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 20 Feb 2020 01:22:40 +0100 Subject: [PATCH 47/94] Comment --- .../workflows/{greetings-pr.yml => greetings-pr.yml.disabled} | 3 ++- .github/workflows/stale-issues.yml | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) rename .github/workflows/{greetings-pr.yml => greetings-pr.yml.disabled} (73%) diff --git a/.github/workflows/greetings-pr.yml b/.github/workflows/greetings-pr.yml.disabled similarity index 73% rename from .github/workflows/greetings-pr.yml rename to .github/workflows/greetings-pr.yml.disabled index 7e96b4ae6e1..2a930929a6d 100644 --- a/.github/workflows/greetings-pr.yml +++ b/.github/workflows/greetings-pr.yml.disabled @@ -1,6 +1,7 @@ +# See syntax file on https://help.github.com/en/actions/reference/workflow-syntax-for-github-actions name: Greetings PR -#on: [pull_request] +on: [pull_request] jobs: greeting: diff --git a/.github/workflows/stale-issues.yml b/.github/workflows/stale-issues.yml index 81a8c48a367..66eb3f0cd40 100644 --- a/.github/workflows/stale-issues.yml +++ b/.github/workflows/stale-issues.yml @@ -1,3 +1,4 @@ +# See syntax file on https://help.github.com/en/actions/reference/workflow-syntax-for-github-actions name: "Close stale issues (bugs and feature requests)" on: From 76f0df138b1deaeb279d0bfb0713489c386d4246 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 20 Feb 2020 01:26:40 +0100 Subject: [PATCH 48/94] Try to fix doc --- 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 dff1d84dddc..f5c05fdf969 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -297,7 +297,7 @@ function GETPOSTISSET($paramname) * @param int $filter Filter to apply when $check is set to 'custom'. (See http://php.net/manual/en/filter.filters.php for détails) * @param mixed $options Options to pass to filter_var when $check is set to 'custom' * @param string $noreplace Force disable of replacement of __xxx__ strings. - * @return string|string[] Value found (string or array), or '' if check fails + * @return string|array Value found (string or array), or '' if check fails */ function GETPOST($paramname, $check = 'alphanohtml', $method = 0, $filter = null, $options = null, $noreplace = 0) { From 1be6c43ed2b6bee2b8c5a66cb2af29e63ee24750 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 20 Feb 2020 01:29:34 +0100 Subject: [PATCH 49/94] Try to fix scrutinizer warnings --- htdocs/blockedlog/admin/blockedlog.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/htdocs/blockedlog/admin/blockedlog.php b/htdocs/blockedlog/admin/blockedlog.php index 065dd4cda9e..d5ee9aa0c58 100644 --- a/htdocs/blockedlog/admin/blockedlog.php +++ b/htdocs/blockedlog/admin/blockedlog.php @@ -40,11 +40,12 @@ $backtopage = GETPOST('backtopage', 'alpha'); * Actions */ +$reg = array(); if (preg_match('/set_(.*)/', $action, $reg)) { - $code=$reg[1]; + $code = $reg[1]; $values = GETPOST($code); - if(is_array($values))$values = implode(',', $values); + if (is_array($values)) $values = implode(',', $values); if (dolibarr_set_const($db, $code, $values, 'chaine', 0, '', $conf->entity) > 0) { @@ -59,7 +60,7 @@ if (preg_match('/set_(.*)/', $action, $reg)) if (preg_match('/del_(.*)/', $action, $reg)) { - $code=$reg[1]; + $code = $reg[1]; if (dolibarr_del_const($db, $code, 0) > 0) { Header("Location: ".$_SERVER["PHP_SELF"]); From ac5e9ce5b31e282fc722dff84d1803f10bb20d0e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 20 Feb 2020 01:34:33 +0100 Subject: [PATCH 50/94] Fix doc --- htdocs/core/class/html.formmail.class.php | 9 +-------- htdocs/core/class/html.formsms.class.php | 5 +++++ 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/htdocs/core/class/html.formmail.class.php b/htdocs/core/class/html.formmail.class.php index b7e9c53a845..238c3cad60a 100644 --- a/htdocs/core/class/html.formmail.class.php +++ b/htdocs/core/class/html.formmail.class.php @@ -112,14 +112,7 @@ class FormMail extends Form public $withfrom; /** - * @var int - * @deprecated Fill withto with array before calling method. - * @see $withto - */ - public $withtosocid; - - /** - * @var int|int[] + * @var int|string|array */ public $withto; // Show recipient emails diff --git a/htdocs/core/class/html.formsms.class.php b/htdocs/core/class/html.formsms.class.php index fc30f0798b3..d16ec9efc94 100644 --- a/htdocs/core/class/html.formsms.class.php +++ b/htdocs/core/class/html.formsms.class.php @@ -53,6 +53,11 @@ class FormSms public $withtopic; public $withbody; + /** + * @var int Id of company + */ + public $withtosocid; + public $withfromreadonly; public $withreplytoreadonly; public $withtoreadonly; 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 51/94] 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 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 52/94] 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 e73d83767c45257a39e39fae7a45b36a3ed566ca Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 20 Feb 2020 12:34:51 +0100 Subject: [PATCH 53/94] Fix phpcs --- htdocs/compta/sociales/list.php | 8 ++++---- htdocs/contact/class/contact.class.php | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/htdocs/compta/sociales/list.php b/htdocs/compta/sociales/list.php index 4b8500f5206..7f5d6b5ba3f 100644 --- a/htdocs/compta/sociales/list.php +++ b/htdocs/compta/sociales/list.php @@ -173,7 +173,7 @@ if ($resql) if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit); if ($search_ref) $param .= '&search_ref='.urlencode($search_ref); if ($search_label) $param .= '&search_label='.urlencode($search_label); - if ($search_project_ref >= 0) $param.="&search_project_ref=".urlencode($search_project_ref); + if ($search_project_ref >= 0) $param.="&search_project_ref=".urlencode($search_project_ref); if ($search_amount) $param .= '&search_amount='.urlencode($search_amount); if ($search_typeid) $param .= '&search_typeid='.urlencode($search_typeid); if ($search_status != '' && $search_status != '-1') $param .= '&search_status='.urlencode($search_status); @@ -282,7 +282,7 @@ if ($resql) $projectstatic->title=$obj->project_label; } - print ''; + print ''; // Ref print "\n"; @@ -304,9 +304,9 @@ if ($resql) print $projectstatic->getNomUrl(1); } print ''; - if (!$i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } - + // Date print ''; if (!$i) $totalarray['nbfield']++; diff --git a/htdocs/contact/class/contact.class.php b/htdocs/contact/class/contact.class.php index 013830ca864..28e9b0d0ae3 100644 --- a/htdocs/contact/class/contact.class.php +++ b/htdocs/contact/class/contact.class.php @@ -865,7 +865,7 @@ class Contact extends CommonObject { $this->error = 'Fetch found several records. Rename one of contact to avoid duplicate.'; dol_syslog($this->error, LOG_ERR); - + return 2; } elseif ($num) // $num = 1 @@ -952,7 +952,7 @@ class Contact extends CommonObject // Retreive all extrafield // fetch optionals attributes and labels $this->fetch_optionals(); - + // Load also alerts of this user if ($user) { From 7234d841e11784e9f3ec8385864957dd34078aa0 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 20 Feb 2020 12:59:53 +0100 Subject: [PATCH 54/94] Fix doxygen --- htdocs/don/class/api_donations.class.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/don/class/api_donations.class.php b/htdocs/don/class/api_donations.class.php index 4adef57e816..95ea92f1ff3 100644 --- a/htdocs/don/class/api_donations.class.php +++ b/htdocs/don/class/api_donations.class.php @@ -284,10 +284,10 @@ class Donations extends DolibarrApi * * @url POST {id}/validate * - * @throws 304 - * @throws 401 - * @throws 404 - * @throws 500 + * @throws RestException 304 + * @throws RestException 401 + * @throws RestException 404 + * @throws RestException 500 * * @return array */ From b41c1c10a0b8fbd40394707f1a86a99f2ef8ed5e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 20 Feb 2020 13:00:27 +0100 Subject: [PATCH 55/94] Fix doxygen --- htdocs/contrat/class/api_contracts.class.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/htdocs/contrat/class/api_contracts.class.php b/htdocs/contrat/class/api_contracts.class.php index 9d201d6fef1..71458e76050 100644 --- a/htdocs/contrat/class/api_contracts.class.php +++ b/htdocs/contrat/class/api_contracts.class.php @@ -439,8 +439,9 @@ class Contracts extends DolibarrApi * @url DELETE {id}/lines/{lineid} * * @return int - * @throws 401 - * @throws 404 + * + * @throws RestException 401 + * @throws RestException 404 */ public function deleteLine($id, $lineid) { From 44eda2d4ad07b987f832223026e0a9a2dddeec64 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 20 Feb 2020 13:42:43 +0100 Subject: [PATCH 56/94] Fix doxygen --- .../comm/propal/class/api_proposals.class.php | 25 ++-- htdocs/commande/class/api_orders.class.php | 51 +++---- .../bank/class/api_bankaccounts.class.php | 8 +- .../facture/class/api_invoices.class.php | 126 ++++++++-------- .../expedition/class/api_shipments.class.php | 21 +-- .../class/api_supplier_invoices.class.php | 38 ++--- htdocs/product/class/api_products.class.php | 136 +++++++++--------- .../societe/class/api_thirdparties.class.php | 85 +++++------ 8 files changed, 245 insertions(+), 245 deletions(-) diff --git a/htdocs/comm/propal/class/api_proposals.class.php b/htdocs/comm/propal/class/api_proposals.class.php index 1337c62da94..d0ce31b5369 100644 --- a/htdocs/comm/propal/class/api_proposals.class.php +++ b/htdocs/comm/propal/class/api_proposals.class.php @@ -377,8 +377,9 @@ class Proposals extends DolibarrApi * @url DELETE {id}/lines/{lineid} * * @return int - * @throws 401 - * @throws 404 + * + * @throws RestException 401 + * @throws RestException 404 */ public function deleteLine($id, $lineid) { @@ -417,8 +418,9 @@ class Proposals extends DolibarrApi * @url POST {id}/contact/{contactid}/{type} * * @return int - * @throws 401 - * @throws 404 + * + * @throws RestException 401 + * @throws RestException 404 */ public function postContact($id, $contactid, $type) { @@ -458,9 +460,10 @@ class Proposals extends DolibarrApi * @url DELETE {id}/contact/{rowid} * * @return int - * @throws 401 - * @throws 404 - * @throws 500 + * + * @throws RestException 401 + * @throws RestException 404 + * @throws RestException 500 */ public function deleteContact($id, $rowid) { @@ -629,10 +632,10 @@ class Proposals extends DolibarrApi * * @url POST {id}/validate * - * @throws 304 - * @throws 401 - * @throws 404 - * @throws 500 + * @throws RestException 304 + * @throws RestException 401 + * @throws RestException 404 + * @throws RestException 500 * * @return array */ diff --git a/htdocs/commande/class/api_orders.class.php b/htdocs/commande/class/api_orders.class.php index 5069135dd88..60c9e23710b 100644 --- a/htdocs/commande/class/api_orders.class.php +++ b/htdocs/commande/class/api_orders.class.php @@ -425,8 +425,9 @@ class Orders extends DolibarrApi * @url DELETE {id}/lines/{lineid} * * @return int - * @throws 401 - * @throws 404 + * + * @throws RestException 401 + * @throws RestException 404 */ public function deleteLine($id, $lineid) { @@ -463,8 +464,9 @@ class Orders extends DolibarrApi * @url POST {id}/contact/{contactid}/{type} * * @return int - * @throws 401 - * @throws 404 + * + * @throws RestException 401 + * @throws RestException 404 */ public function postContact($id, $contactid, $type) { @@ -499,9 +501,10 @@ class Orders extends DolibarrApi * @url DELETE {id}/contact/{rowid} * * @return int - * @throws 401 - * @throws 404 - * @throws 500 + * + * @throws RestException 401 + * @throws RestException 404 + * @throws RestException 500 */ public function deleteContact($id, $rowid) { @@ -617,10 +620,10 @@ class Orders extends DolibarrApi * * @url POST {id}/validate * - * @throws 304 - * @throws 401 - * @throws 404 - * @throws 500 + * @throws RestException 304 + * @throws RestException 401 + * @throws RestException 404 + * @throws RestException 500 * * @return array */ @@ -670,11 +673,11 @@ class Orders extends DolibarrApi * * @return int * - * @throws 304 - * @throws 400 - * @throws 401 - * @throws 404 - * @throws 405 + * @throws RestException 304 + * @throws RestException 400 + * @throws RestException 401 + * @throws RestException 404 + * @throws RestException 405 */ public function reopen($id) { @@ -709,10 +712,10 @@ class Orders extends DolibarrApi * * @return int * - * @throws 400 - * @throws 401 - * @throws 404 - * @throws 405 + * @throws RestException 400 + * @throws RestException 401 + * @throws RestException 404 + * @throws RestException 405 */ public function setinvoiced($id) { @@ -849,10 +852,10 @@ class Orders extends DolibarrApi * @url POST /createfromproposal/{proposalid} * * @return int - * @throws 400 - * @throws 401 - * @throws 404 - * @throws 405 + * @throws RestException 400 + * @throws RestException 401 + * @throws RestException 404 + * @throws RestException 405 */ public function createOrderFromProposal($proposalid) { diff --git a/htdocs/compta/bank/class/api_bankaccounts.class.php b/htdocs/compta/bank/class/api_bankaccounts.class.php index 2ecb59861d9..1272cfcad85 100644 --- a/htdocs/compta/bank/class/api_bankaccounts.class.php +++ b/htdocs/compta/bank/class/api_bankaccounts.class.php @@ -183,10 +183,10 @@ class BankAccounts extends DolibarrApi * * @status 201 * - * @throws 401 Unauthorized: User does not have permission to configure bank accounts - * @throws 404 Not Found: Either the source or the destination bankaccount for the provided id does not exist - * @throws 422 Unprocessable Entity: Refer to detailed exception message for the cause - * @throws 500 Internal Server Error: Error(s) returned by the RDBMS + * @throws RestException 401 Unauthorized: User does not have permission to configure bank accounts + * @throws RestException 404 Not Found: Either the source or the destination bankaccount for the provided id does not exist + * @throws RestException 422 Unprocessable Entity: Refer to detailed exception message for the cause + * @throws RestException 500 Internal Server Error: Error(s) returned by the RDBMS */ public function transfer($bankaccount_from_id = 0, $bankaccount_to_id = 0, $date = null, $description = "", $amount = 0.0, $amount_to = 0.0) { diff --git a/htdocs/compta/facture/class/api_invoices.class.php b/htdocs/compta/facture/class/api_invoices.class.php index 7c7437bfb8e..e68966f4663 100644 --- a/htdocs/compta/facture/class/api_invoices.class.php +++ b/htdocs/compta/facture/class/api_invoices.class.php @@ -242,10 +242,10 @@ class Invoices extends DolibarrApi * @url POST /createfromorder/{orderid} * * @return int - * @throws 400 - * @throws 401 - * @throws 404 - * @throws 405 + * @throws RestException 400 + * @throws RestException 401 + * @throws RestException 404 + * @throws RestException 405 */ public function createInvoiceFromOrder($orderid) { @@ -318,10 +318,9 @@ class Invoices extends DolibarrApi * * @return array * - * @throws 200 - * @throws 304 - * @throws 401 - * @throws 404 + * @throws RestException 304 + * @throws RestException 401 + * @throws RestException 404 Invoice not found */ public function putLine($id, $lineid, $request_data = null) { @@ -383,8 +382,9 @@ class Invoices extends DolibarrApi * @url POST {id}/contact/{contactid}/{type} * * @return int - * @throws 401 - * @throws 404 + * + * @throws RestException 401 + * @throws RestException 404 */ public function postContact($id, $contactid, $type) { @@ -424,9 +424,10 @@ class Invoices extends DolibarrApi * @url DELETE {id}/contact/{rowid} * * @return array - * @throws 401 - * @throws 404 - * @throws 500 + * + * @throws RestException 401 + * @throws RestException 404 + * @throws RestException 500 */ public function deleteContact($id, $rowid) { @@ -463,10 +464,10 @@ class Invoices extends DolibarrApi * * @return array * - * @throws 400 - * @throws 401 - * @throws 404 - * @throws 405 + * @throws RestException 400 + * @throws RestException 401 + * @throws RestException 404 + * @throws RestException 405 */ public function deleteLine($id, $lineid) { @@ -591,10 +592,9 @@ class Invoices extends DolibarrApi * * @return int * - * @throws 200 - * @throws 401 - * @throws 404 - * @throws 400 + * @throws RestException 401 + * @throws RestException 404 + * @throws RestException 400 */ public function postLine($id, $request_data = null) { @@ -673,11 +673,10 @@ class Invoices extends DolibarrApi * * @return array * - * @throws 200 - * @throws 304 - * @throws 401 - * @throws 404 - * @throws 500 + * @throws RestException 304 + * @throws RestException 401 + * @throws RestException 404 + * @throws RestException 500 * */ public function addContact($id, $fk_socpeople, $type_contact, $source, $notrigger = 0) @@ -723,11 +722,10 @@ class Invoices extends DolibarrApi * * @return array * - * @throws 200 - * @throws 304 - * @throws 401 - * @throws 404 - * @throws 500 + * @throws RestException 304 + * @throws RestException 401 + * @throws RestException 404 + * @throws RestException 500 * */ public function settodraft($id, $idwarehouse = -1) @@ -827,11 +825,10 @@ class Invoices extends DolibarrApi * * @return array An invoice object * - * @throws 200 - * @throws 304 - * @throws 401 - * @throws 404 - * @throws 500 + * @throws RestException 304 + * @throws RestException 401 + * @throws RestException 404 + * @throws RestException 500 */ public function settopaid($id, $close_code = '', $close_note = '') { @@ -878,11 +875,10 @@ class Invoices extends DolibarrApi * * @return array An invoice object * - * @throws 200 - * @throws 304 - * @throws 401 - * @throws 404 - * @throws 500 + * @throws RestException 304 + * @throws RestException 401 + * @throws RestException 404 + * @throws RestException 500 */ public function settounpaid($id) { @@ -927,11 +923,10 @@ class Invoices extends DolibarrApi * * @return array An invoice object * - * @throws 200 - * @throws 304 - * @throws 401 - * @throws 404 - * @throws 500 + * @throws RestException 304 + * @throws RestException 401 + * @throws RestException 404 + * @throws RestException 500 */ public function markAsCreditAvailable($id) { @@ -1103,10 +1098,10 @@ class Invoices extends DolibarrApi * @url POST {id}/usediscount/{discountid} * * @return int - * @throws 400 - * @throws 401 - * @throws 404 - * @throws 405 + * @throws RestException 400 + * @throws RestException 401 + * @throws RestException 404 + * @throws RestException 405 */ public function useDiscount($id, $discountid) { @@ -1149,10 +1144,10 @@ class Invoices extends DolibarrApi * @url POST {id}/usecreditnote/{discountid} * * @return int - * @throws 400 - * @throws 401 - * @throws 404 - * @throws 405 + * @throws RestException 400 + * @throws RestException 401 + * @throws RestException 404 + * @throws RestException 405 */ public function useCreditNote($id, $discountid) { @@ -1194,10 +1189,11 @@ class Invoices extends DolibarrApi * @url GET {id}/payments * * @return array - * @throws 400 - * @throws 401 - * @throws 404 - * @throws 405 + * + * @throws RestException 400 + * @throws RestException 401 + * @throws RestException 404 + * @throws RestException 405 */ public function getPayments($id) { @@ -1243,9 +1239,9 @@ class Invoices extends DolibarrApi * @url POST {id}/payments * * @return int Payment ID - * @throws 400 - * @throws 401 - * @throws 404 + * @throws RestException 400 + * @throws RestException 401 + * @throws RestException 404 */ public function addPayment($id, $datepaye, $paiementid, $closepaidinvoices, $accountid, $num_paiement = '', $comment = '', $chqemetteur = '', $chqbank = '') { @@ -1362,10 +1358,10 @@ class Invoices extends DolibarrApi * @url POST /paymentsdistributed * * @return int Payment ID - * @throws 400 - * @throws 401 - * @throws 403 - * @throws 404 + * @throws RestException 400 + * @throws RestException 401 + * @throws RestException 403 + * @throws RestException 404 */ public function addPaymentDistributed($arrayofamounts, $datepaye, $paiementid, $closepaidinvoices, $accountid, $num_paiement = '', $comment = '', $chqemetteur = '', $chqbank = '') { diff --git a/htdocs/expedition/class/api_shipments.class.php b/htdocs/expedition/class/api_shipments.class.php index 5aca14fb28d..8526f0c9610 100644 --- a/htdocs/expedition/class/api_shipments.class.php +++ b/htdocs/expedition/class/api_shipments.class.php @@ -373,8 +373,9 @@ class Shipments extends DolibarrApi * @url DELETE {id}/lines/{lineid} * * @return int - * @throws 401 - * @throws 404 + * + * @throws RestException 401 + * @throws RestException 404 */ public function deleteLine($id, $lineid) { @@ -537,10 +538,10 @@ class Shipments extends DolibarrApi // * // * @return int // * - // * @throws 400 - // * @throws 401 - // * @throws 404 - // * @throws 405 + // * @throws RestException 400 + // * @throws RestException 401 + // * @throws RestException 404 + // * @throws RestException 405 // */ /* public function setinvoiced($id) @@ -574,10 +575,10 @@ class Shipments extends DolibarrApi // * @url POST /createfromorder/{orderid} // * // * @return int - // * @throws 400 - // * @throws 401 - // * @throws 404 - // * @throws 405 + // * @throws RestException 400 + // * @throws RestException 401 + // * @throws RestException 404 + // * @throws RestException 405 // */ /* public function createShipmentFromOrder($orderid) diff --git a/htdocs/fourn/class/api_supplier_invoices.class.php b/htdocs/fourn/class/api_supplier_invoices.class.php index 21e5e82c13b..204471bc9e7 100644 --- a/htdocs/fourn/class/api_supplier_invoices.class.php +++ b/htdocs/fourn/class/api_supplier_invoices.class.php @@ -194,8 +194,8 @@ class SupplierInvoices extends DolibarrApi * * @return int ID of supplier invoice * - * @throws 401 - * @throws 500 + * @throws RestException 401 + * @throws RestException 500 */ public function post($request_data = null) { @@ -226,8 +226,8 @@ class SupplierInvoices extends DolibarrApi * * @return int * - * @throws 401 - * @throws 404 + * @throws RestException 401 + * @throws RestException 404 */ public function put($id, $request_data = null) { @@ -262,9 +262,9 @@ class SupplierInvoices extends DolibarrApi * * @return array * - * @throws 401 - * @throws 404 - * @throws 500 + * @throws RestException 401 + * @throws RestException 404 + * @throws RestException 500 */ public function delete($id) { @@ -304,11 +304,11 @@ class SupplierInvoices extends DolibarrApi * * @return array * - * @throws 304 - * @throws 401 - * @throws 404 - * @throws 405 - * @throws 500 + * @throws RestException 304 + * @throws RestException 401 + * @throws RestException 404 + * @throws RestException 405 + * @throws RestException 500 */ public function validate($id, $idwarehouse = 0, $notrigger = 0) { @@ -348,10 +348,10 @@ class SupplierInvoices extends DolibarrApi * @url GET {id}/payments * * @return array - * @throws 400 - * @throws 401 - * @throws 404 - * @throws 405 + * @throws RestException 400 + * @throws RestException 401 + * @throws RestException 404 + * @throws RestException 405 */ public function getPayments($id) { @@ -396,9 +396,9 @@ class SupplierInvoices extends DolibarrApi * @url POST {id}/payments * * @return int Payment ID - * @throws 400 - * @throws 401 - * @throws 404 + * @throws RestException 400 + * @throws RestException 401 + * @throws RestException 404 */ public function addPayment($id, $datepaye, $paiementid, $closepaidinvoices, $accountid, $num_paiement = '', $comment = '', $chqemetteur = '', $chqbank = '') { diff --git a/htdocs/product/class/api_products.class.php b/htdocs/product/class/api_products.class.php index 1e189026366..dc4d2e79481 100644 --- a/htdocs/product/class/api_products.class.php +++ b/htdocs/product/class/api_products.class.php @@ -73,9 +73,9 @@ class Products extends DolibarrApi * @param bool $includesubproducts Load information about subproducts * @return array|mixed Data without useless information * - * @throws 401 - * @throws 403 - * @throws 404 + * @throws RestException 401 + * @throws RestException 403 + * @throws RestException 404 */ public function get($id, $includestockdata = 0, $includesubproducts = false) { @@ -95,9 +95,9 @@ class Products extends DolibarrApi * * @url GET ref/{ref} * - * @throws 401 - * @throws 403 - * @throws 404 + * @throws RestException 401 + * @throws RestException 403 + * @throws RestException 404 */ public function getByRef($ref, $includestockdata = 0, $includesubproducts = false) { @@ -117,9 +117,9 @@ class Products extends DolibarrApi * * @url GET ref_ext/{ref_ext} * - * @throws 401 - * @throws 403 - * @throws 404 + * @throws RestException 401 + * @throws RestException 403 + * @throws RestException 404 */ public function getByRefExt($ref_ext, $includestockdata = 0, $includesubproducts = false) { @@ -139,9 +139,9 @@ class Products extends DolibarrApi * * @url GET barcode/{barcode} * - * @throws 401 - * @throws 403 - * @throws 404 + * @throws RestException 401 + * @throws RestException 403 + * @throws RestException 404 */ public function getByBarcode($barcode, $includestockdata = 0, $includesubproducts = false) { @@ -263,9 +263,8 @@ class Products extends DolibarrApi * @param array $request_data Datas * @return int * - * @throws RestException - * @throws 401 - * @throws 404 + * @throws RestException 401 + * @throws RestException 404 */ public function put($id, $request_data = null) { @@ -385,8 +384,8 @@ class Products extends DolibarrApi * @return array * * @throws RestException - * @throws 401 - * @throws 404 + * @throws RestException 401 + * @throws RestException 404 * * @url GET {id}/subproducts */ @@ -423,8 +422,8 @@ class Products extends DolibarrApi * @return int * * @throws RestException - * @throws 401 - * @throws 404 + * @throws RestException 401 + * @throws RestException 404 * * @url POST {id}/subproducts/add */ @@ -454,9 +453,8 @@ class Products extends DolibarrApi * @param int $subproduct_id Id of child product/service * @return int * - * @throws RestException - * @throws 401 - * @throws 404 + * @throws RestException 401 + * @throws RestException 404 * * @url DELETE {id}/subproducts/remove */ @@ -642,8 +640,8 @@ class Products extends DolibarrApi * * @return int * - * @throws 401 - * @throws 404 + * @throws RestException 401 + * @throws RestException 404 * */ public function deletePurchasePrice($id, $priceid) @@ -769,9 +767,9 @@ class Products extends DolibarrApi * * @url GET {id}/purchase_prices * - * @throws 401 - * @throws 403 - * @throws 404 + * @throws RestException 401 + * @throws RestException 403 + * @throws RestException 404 * */ public function getPurchasePrices($id, $ref = '', $ref_ext = '', $barcode = '') @@ -829,8 +827,8 @@ class Products extends DolibarrApi * @return array * * @throws RestException - * @throws 401 - * @throws 404 + * @throws RestException 401 + * @throws RestException 404 * * @url GET attributes/{id} */ @@ -856,8 +854,8 @@ class Products extends DolibarrApi * @param string $ref Reference of Attribute * @return array * - * @throws RestException - * @throws 401 + * @throws RestException 500 + * @throws RestException 401 * * @url GET attributes/ref/{ref} */ @@ -893,8 +891,8 @@ class Products extends DolibarrApi * @param string $label Label of Attribute * @return int * - * @throws RestException - * @throws 401 + * @throws RestException 500 + * @throws RestException 401 * * @url POST attributes */ @@ -923,8 +921,8 @@ class Products extends DolibarrApi * @return array * * @throws RestException - * @throws 401 - * @throws 404 + * @throws RestException 401 + * @throws RestException 404 * * @url PUT attributes/{id} */ @@ -968,8 +966,8 @@ class Products extends DolibarrApi * @param int $id ID of Attribute * @return int Result of deletion * - * @throws RestException - * @throws 401 + * @throws RestException 500 + * @throws RestException 401 * * @url DELETE attributes/{id} */ @@ -996,8 +994,8 @@ class Products extends DolibarrApi * @param int $id ID of Attribute value * @return array * - * @throws RestException - * @throws 401 + * @throws RestException 500 + * @throws RestException 401 * * @url GET attributes/values/{id} */ @@ -1037,8 +1035,8 @@ class Products extends DolibarrApi * @param string $ref Ref of Attribute value * @return array * - * @throws RestException - * @throws 401 + * @throws RestException 500 + * @throws RestException 401 * * @url GET attributes/{id}/values/ref/{ref} */ @@ -1078,8 +1076,7 @@ class Products extends DolibarrApi * @param string $ref Ref of Attribute value * @return int * - * @throws RestException - * @throws 401 + * @throws RestException 401 * * @url DELETE attributes/{id}/values/ref/{ref} */ @@ -1104,8 +1101,8 @@ class Products extends DolibarrApi * @param int $id ID of an Attribute * @return array * - * @throws RestException - * @throws 401 + * @throws RestException 401 + * @throws RestException 500 * * @url GET attributes/{id}/values */ @@ -1125,8 +1122,7 @@ class Products extends DolibarrApi * @param string $ref Ref of an Attribute * @return array * - * @throws RestException - * @throws 401 + * @throws RestException 401 * * @url GET attributes/ref/{ref}/values */ @@ -1165,8 +1161,8 @@ class Products extends DolibarrApi * @param string $value Value of Attribute value * @return int * - * @throws RestException - * @throws 401 + * @throws RestException 500 + * @throws RestException 401 * * @url POST attributes/{id}/values */ @@ -1198,8 +1194,8 @@ class Products extends DolibarrApi * @param array $request_data Datas * @return array * - * @throws RestException - * @throws 401 + * @throws RestException 401 + * @throws RestException 500 * * @url PUT attributes/values/{id} */ @@ -1243,8 +1239,8 @@ class Products extends DolibarrApi * @param int $id ID of Attribute value * @return int * - * @throws RestException - * @throws 401 + * @throws RestException 500 + * @throws RestException 401 * * @url DELETE attributes/values/{id} */ @@ -1269,8 +1265,8 @@ class Products extends DolibarrApi * @param int $id ID of Product * @return array * - * @throws RestException - * @throws 401 + * @throws RestException 500 + * @throws RestException 401 * * @url GET {id}/variants */ @@ -1297,8 +1293,8 @@ class Products extends DolibarrApi * @param string $ref Ref of Product * @return array * - * @throws RestException - * @throws 401 + * @throws RestException 500 + * @throws RestException 401 * * @url GET ref/{ref}/variants */ @@ -1336,9 +1332,9 @@ class Products extends DolibarrApi * @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, ...) * @return int * - * @throws RestException - * @throws 401 - * @throws 404 + * @throws RestException 500 + * @throws RestException 401 + * @throws RestException 404 * * @url POST {id}/variants */ @@ -1398,9 +1394,9 @@ class Products extends DolibarrApi * @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, ...) * @return int * - * @throws RestException - * @throws 401 - * @throws 404 + * @throws RestException 500 + * @throws RestException 401 + * @throws RestException 404 * * @url POST ref/{ref}/variants */ @@ -1455,8 +1451,8 @@ class Products extends DolibarrApi * @param array $request_data Datas * @return int * - * @throws RestException - * @throws 401 + * @throws RestException 500 + * @throws RestException 401 * * @url PUT variants/{id} */ @@ -1489,8 +1485,8 @@ class Products extends DolibarrApi * @param int $id ID of Variant * @return int Result of deletion * - * @throws RestException - * @throws 401 + * @throws RestException 500 + * @throws RestException 401 * * @url DELETE variants/{id} */ @@ -1570,9 +1566,9 @@ class Products extends DolibarrApi * @param bool $includesubproducts Load information about subproducts * @return array|mixed Data without useless information * - * @throws 401 - * @throws 403 - * @throws 404 + * @throws RestException 401 + * @throws RestException 403 + * @throws RestException 404 */ private function _fetch($id, $ref = '', $ref_ext = '', $barcode = '', $includestockdata = 0, $includesubproducts = false) { diff --git a/htdocs/societe/class/api_thirdparties.class.php b/htdocs/societe/class/api_thirdparties.class.php index 07dd2ba6031..e055026910d 100644 --- a/htdocs/societe/class/api_thirdparties.class.php +++ b/htdocs/societe/class/api_thirdparties.class.php @@ -731,9 +731,9 @@ class Thirdparties extends DolibarrApi * * @return array List of outstandings proposals of thirdparty * - * @throws 400 - * @throws 401 - * @throws 404 + * @throws RestException 400 + * @throws RestException 401 + * @throws RestException 404 */ public function getOutStandingProposals($id, $mode = 'customer') { @@ -775,9 +775,9 @@ class Thirdparties extends DolibarrApi * * @return array List of outstandings orders of thirdparty * - * @throws 400 - * @throws 401 - * @throws 404 + * @throws RestException 400 + * @throws RestException 401 + * @throws RestException 404 */ public function getOutStandingOrder($id, $mode = 'customer') { @@ -818,9 +818,9 @@ class Thirdparties extends DolibarrApi * * @return array List of outstandings invoices of thirdparty * - * @throws 400 - * @throws 401 - * @throws 404 + * @throws RestException 400 + * @throws RestException 401 + * @throws RestException 404 */ public function getOutStandingInvoices($id, $mode = 'customer') { @@ -861,9 +861,9 @@ class Thirdparties extends DolibarrApi * * @return array List of representatives of thirdparty * - * @throws 400 - * @throws 401 - * @throws 404 + * @throws RestException 400 + * @throws RestException 401 + * @throws RestException 404 */ public function getSalesRepresentatives($id, $mode = 0) { @@ -903,10 +903,10 @@ class Thirdparties extends DolibarrApi * * @return array List of fixed discount of thirdparty * - * @throws 400 - * @throws 401 - * @throws 404 - * @throws 503 + * @throws RestException 400 + * @throws RestException 401 + * @throws RestException 404 + * @throws RestException 503 */ public function getFixedAmountDiscounts($id, $filter = "none", $sortfield = "f.type", $sortorder = 'ASC') { @@ -961,10 +961,10 @@ class Thirdparties extends DolibarrApi * @url GET {id}/getinvoicesqualifiedforreplacement * * @return array - * @throws 400 - * @throws 401 - * @throws 404 - * @throws 405 + * @throws RestException 400 + * @throws RestException 401 + * @throws RestException 404 + * @throws RestException 405 */ public function getInvoicesQualifiedForReplacement($id) { @@ -1003,10 +1003,11 @@ class Thirdparties extends DolibarrApi * @url GET {id}/getinvoicesqualifiedforcreditnote * * @return array - * @throws 400 - * @throws 401 - * @throws 404 - * @throws 405 + * + * @throws RestException 400 + * @throws RestException 401 + * @throws RestException 404 + * @throws RestException 405 */ public function getInvoicesQualifiedForCreditNote($id) { @@ -1313,8 +1314,8 @@ class Thirdparties extends DolibarrApi * @param string $site Site key * * @return SocieteAccount[] - * @throws 401 Unauthorized: User does not have permission to read thirdparties - * @throws 404 Not Found: Specified thirdparty ID does not belongs to an existing thirdparty + * @throws RestException 401 Unauthorized: User does not have permission to read thirdparties + * @throws RestException 404 Not Found: Specified thirdparty ID does not belongs to an existing thirdparty * * @url GET {id}/gateways/ */ @@ -1387,11 +1388,11 @@ class Thirdparties extends DolibarrApi * @param array $request_data Request data * * @return SocieteAccount - * @throws 401 Unauthorized: User does not have permission to read thirdparties - * @throws 409 Conflict: A SocieteAccount entity (gateway) already exists for this company and site. - * @throws 422 Unprocessable Entity: You must pass the site attribute in your request data ! - * @throws 500 Internal Server Error: Error creating SocieteAccount account - * @status 201 + * @throws RestException 401 Unauthorized: User does not have permission to read thirdparties + * @throws RestException 409 Conflict: A SocieteAccount entity (gateway) already exists for this company and site. + * @throws RestException 422 Unprocessable Entity: You must pass the site attribute in your request data ! + * @throws RestException 500 Internal Server Error: Error creating SocieteAccount account + * @status RestException 201 * * @url POST {id}/gateways */ @@ -1447,11 +1448,11 @@ class Thirdparties extends DolibarrApi * @param array $request_data Request data * * @return SocieteAccount - * @throws 401 Unauthorized: User does not have permission to read thirdparties - * @throws 422 Unprocessable Entity: You must pass the site attribute in your request data ! - * @throws 500 Internal Server Error: Error updating SocieteAccount entity * - * @throws RestException + * @throws RestException 401 Unauthorized: User does not have permission to read thirdparties + * @throws RestException 422 Unprocessable Entity: You must pass the site attribute in your request data ! + * @throws RestException 500 Internal Server Error: Error updating SocieteAccount entity + * * @url PUT {id}/gateways/{site} */ public function putSocieteAccount($id, $site, $request_data = null) @@ -1529,10 +1530,10 @@ class Thirdparties extends DolibarrApi * @param array $request_data Request data * * @return SocieteAccount - * @throws 401 Unauthorized: User does not have permission to read thirdparties - * @throws 404 Not Found: Specified thirdparty ID does not belongs to an existing thirdparty - * @throws 409 Conflict: Another SocieteAccount entity already exists for this thirdparty with this site key. - * @throws 500 Internal Server Error: Error updating SocieteAccount entity + * @throws RestException 401 Unauthorized: User does not have permission to read thirdparties + * @throws RestException 404 Not Found: Specified thirdparty ID does not belongs to an existing thirdparty + * @throws RestException 409 Conflict: Another SocieteAccount entity already exists for this thirdparty with this site key. + * @throws RestException 500 Internal Server Error: Error updating SocieteAccount entity * * @url PATCH {id}/gateways/{site} */ @@ -1583,9 +1584,9 @@ class Thirdparties extends DolibarrApi * @param int $site Site key * * @return void - * @throws 401 Unauthorized: User does not have permission to delete thirdparties gateways - * @throws 404 Not Found: Specified thirdparty ID does not belongs to an existing thirdparty - * @throws 500 Internal Server Error: Error deleting SocieteAccount entity + * @throws RestException 401 Unauthorized: User does not have permission to delete thirdparties gateways + * @throws RestException 404 Not Found: Specified thirdparty ID does not belongs to an existing thirdparty + * @throws RestException 500 Internal Server Error: Error deleting SocieteAccount entity * * @url DELETE {id}/gateways/{site} */ From 2c477c71692f4a9c4c4984dfb4ad1031dc41ab60 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 20 Feb 2020 13:54:41 +0100 Subject: [PATCH 57/94] Fix doxygen --- .../template/class/api_mymodule.class.php | 7 +++++++ htdocs/societe/class/api_contacts.class.php | 12 ++++-------- .../societe/class/api_thirdparties.class.php | 3 ++- htdocs/ticket/class/api_tickets.class.php | 18 +++++++++--------- htdocs/user/class/api_users.class.php | 7 +++---- 5 files changed, 25 insertions(+), 22 deletions(-) diff --git a/htdocs/modulebuilder/template/class/api_mymodule.class.php b/htdocs/modulebuilder/template/class/api_mymodule.class.php index d7a810ac2cd..6dd93aceacd 100644 --- a/htdocs/modulebuilder/template/class/api_mymodule.class.php +++ b/htdocs/modulebuilder/template/class/api_mymodule.class.php @@ -63,6 +63,7 @@ class MyModuleApi extends DolibarrApi * @return array|mixed data without useless information * * @url GET myobjects/{id} + * * @throws RestException */ public function get($id) @@ -186,6 +187,8 @@ class MyModuleApi extends DolibarrApi * @param array $request_data Request datas * @return int ID of myobject * + * @throws RestException + * * @url POST myobjects/ */ public function post($request_data = null) @@ -212,6 +215,8 @@ class MyModuleApi extends DolibarrApi * @param array $request_data Datas * @return int * + * @throws RestException + * * @url PUT myobjects/{id} */ public function put($id, $request_data = null) @@ -250,6 +255,8 @@ class MyModuleApi extends DolibarrApi * @param int $id MyObject ID * @return array * + * @throws RestException + * * @url DELETE myobjects/{id} */ public function delete($id) diff --git a/htdocs/societe/class/api_contacts.class.php b/htdocs/societe/class/api_contacts.class.php index 6b6c5a439a6..2ae9fd34869 100644 --- a/htdocs/societe/class/api_contacts.class.php +++ b/htdocs/societe/class/api_contacts.class.php @@ -391,10 +391,8 @@ class Contacts extends DolibarrApi * * @return mixed * - * @throws 401 RestException Insufficient rights - * @throws 401 RestException Access not allowed for login - * @throws 404 RestException Category not found - * @throws 404 RestException Contact not found + * @throws RestException 401 Insufficient rights + * @throws RestException 404 Category or contact not found */ public function addCategory($id, $category_id) { @@ -433,10 +431,8 @@ class Contacts extends DolibarrApi * @param int $category_id Id of category * @return mixed * - * @throws 401 RestException Insufficient rights - * @throws 401 RestException Access not allowed for login - * @throws 404 RestException Category not found - * @throws 404 RestException Contact not found + * @throws RestException 401 Insufficient rights + * @throws RestException 404 Category or contact not found */ public function deleteCategory($id, $category_id) { diff --git a/htdocs/societe/class/api_thirdparties.class.php b/htdocs/societe/class/api_thirdparties.class.php index e055026910d..5f031137c1f 100644 --- a/htdocs/societe/class/api_thirdparties.class.php +++ b/htdocs/societe/class/api_thirdparties.class.php @@ -1388,11 +1388,11 @@ class Thirdparties extends DolibarrApi * @param array $request_data Request data * * @return SocieteAccount + * * @throws RestException 401 Unauthorized: User does not have permission to read thirdparties * @throws RestException 409 Conflict: A SocieteAccount entity (gateway) already exists for this company and site. * @throws RestException 422 Unprocessable Entity: You must pass the site attribute in your request data ! * @throws RestException 500 Internal Server Error: Error creating SocieteAccount account - * @status RestException 201 * * @url POST {id}/gateways */ @@ -1530,6 +1530,7 @@ class Thirdparties extends DolibarrApi * @param array $request_data Request data * * @return SocieteAccount + * * @throws RestException 401 Unauthorized: User does not have permission to read thirdparties * @throws RestException 404 Not Found: Specified thirdparty ID does not belongs to an existing thirdparty * @throws RestException 409 Conflict: Another SocieteAccount entity already exists for this thirdparty with this site key. diff --git a/htdocs/ticket/class/api_tickets.class.php b/htdocs/ticket/class/api_tickets.class.php index 707fe403c6c..ba82f0ba1f0 100644 --- a/htdocs/ticket/class/api_tickets.class.php +++ b/htdocs/ticket/class/api_tickets.class.php @@ -68,9 +68,9 @@ class Tickets extends DolibarrApi * @param int $id ID of ticket * @return array|mixed Data without useless information * - * @throws 401 - * @throws 403 - * @throws 404 + * @throws RestException 401 + * @throws RestException 403 + * @throws RestException 404 */ public function get($id) { @@ -87,9 +87,9 @@ class Tickets extends DolibarrApi * * @url GET track_id/{track_id} * - * @throws 401 - * @throws 403 - * @throws 404 + * @throws RestException 401 + * @throws RestException 403 + * @throws RestException 404 */ public function getByTrackId($track_id) { @@ -106,9 +106,9 @@ class Tickets extends DolibarrApi * * @url GET ref/{ref} * - * @throws 401 - * @throws 403 - * @throws 404 + * @throws RestException 401 + * @throws RestException 403 + * @throws RestException 404 */ public function getByRef($ref) { diff --git a/htdocs/user/class/api_users.class.php b/htdocs/user/class/api_users.class.php index fa139e2c69f..373a8b55f0e 100644 --- a/htdocs/user/class/api_users.class.php +++ b/htdocs/user/class/api_users.class.php @@ -171,9 +171,8 @@ class Users extends DolibarrApi * * @return array|mixed Data without useless information * - * @throws 401 RestException Insufficient rights - * @throws 404 RestException User not found - * @throws 404 RestException User group not found + * @throws RestException 401 Insufficient rights + * @throws RestException 404 User or group not found */ public function getInfo() { @@ -508,7 +507,7 @@ class Users extends DolibarrApi * Clean sensible object datas * * @param object $object Object to clean - * @return array Array of cleaned object properties + * @return array Array of cleaned object properties */ protected function _cleanObjectDatas($object) { From 52c7f908a056e1328b21b6666922c7a10c8c147f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 20 Feb 2020 14:02:27 +0100 Subject: [PATCH 58/94] Doxygen --- .../compta/sociales/class/paymentsocialcontribution.class.php | 2 +- htdocs/contrat/tpl/linkedobjectblock.tpl.php | 2 +- .../template/core/tpl/linkedobjectblock_myobject.tpl.php | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/compta/sociales/class/paymentsocialcontribution.class.php b/htdocs/compta/sociales/class/paymentsocialcontribution.class.php index a5279ecbeae..629a73578b2 100644 --- a/htdocs/compta/sociales/class/paymentsocialcontribution.class.php +++ b/htdocs/compta/sociales/class/paymentsocialcontribution.class.php @@ -57,7 +57,7 @@ class PaymentSocialContribution extends CommonObject /** * @deprecated - * @see amount + * @see $amount */ public $total; diff --git a/htdocs/contrat/tpl/linkedobjectblock.tpl.php b/htdocs/contrat/tpl/linkedobjectblock.tpl.php index b7ec9574ccb..b200baef726 100644 --- a/htdocs/contrat/tpl/linkedobjectblock.tpl.php +++ b/htdocs/contrat/tpl/linkedobjectblock.tpl.php @@ -63,7 +63,7 @@ foreach($linkedObjectBlock as $key => $objectlink) echo price($totalcontrat); } ?> - + $objectlink) - + Date: Thu, 20 Feb 2020 14:07:25 +0100 Subject: [PATCH 59/94] Fix phpcs --- test/phpunit/SecurityTest.php | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/test/phpunit/SecurityTest.php b/test/phpunit/SecurityTest.php index 36f29685e29..4130426d806 100644 --- a/test/phpunit/SecurityTest.php +++ b/test/phpunit/SecurityTest.php @@ -187,28 +187,28 @@ class SecurityTest extends PHPUnit\Framework\TestCase print __METHOD__." result=".$result."\n"; $this->assertEquals($result, $_GET["param2"]); - $result=GETPOST("param3", 'alpha'); // Must return '' as there is a forbidden char " + $result=GETPOST("param3", 'alpha'); // Must return string sanitized from char " print __METHOD__." result=".$result."\n"; - $this->assertEquals($result, ''); + $this->assertEquals($result, 'a/b#e(pr)qq-rr\cc'); - $result=GETPOST("param4", 'alpha'); // Must return '' as there is a forbidden char ../ + $result=GETPOST("param4", 'alpha'); // Must return string sanitized from ../ print __METHOD__." result=".$result."\n"; - $this->assertEquals($result, ''); + $this->assertEquals($result, 'dir'); // Test aZ09 - $result=GETPOST("param1", 'aZ09'); // Must return '' as there is a forbidden char ../ + $result=GETPOST("param1", 'aZ09'); print __METHOD__." result=".$result."\n"; $this->assertEquals($result, $_GET["param1"]); - $result=GETPOST("param2", 'aZ09'); // Must return '' as there is a forbidden char ../ + $result=GETPOST("param2", 'aZ09'); // Must return '' as string contains car not in aZ09 definition print __METHOD__." result=".$result."\n"; $this->assertEquals($result, ''); - $result=GETPOST("param3", 'aZ09'); // Must return '' as there is a forbidden char ../ + $result=GETPOST("param3", 'aZ09'); // Must return '' as string contains car not in aZ09 definition print __METHOD__." result=".$result."\n"; $this->assertEquals($result, ''); - $result=GETPOST("param4", 'aZ09'); // Must return '' as there is a forbidden char ../ + $result=GETPOST("param4", 'aZ09'); // Must return '' as string contains car not in aZ09 definition print __METHOD__." result=".$result."\n"; $this->assertEquals($result, ''); 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 60/94] 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 61/94] 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 $langs->trans('Ref'); @@ -2828,7 +2857,19 @@ if ($action == 'createsite') print '
'; print $langs->trans('Description'); print ''; - print ''; + print ''; + print '
'; + print $langs->trans('MainLanguage'); + print ''; + print $formadmin->select_language((GETPOSTISSET('WEBSITE_LANG') ? GETPOST('WEBSITE_LANG', 'alpha') : $langs->defaultlang), 'WEBSITE_LANG', 0, 0, 0, 0, 0, 'minwidth300', 2); + print '
'; + print $langs->trans('OtherLanguages'); + print ''; + print ''; print '
'; From 7796724d6372b865ad386989cdc46eaadac022ff Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 20 Feb 2020 01:07:41 +0100 Subject: [PATCH 44/94] Update list.php --- htdocs/compta/sociales/list.php | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/htdocs/compta/sociales/list.php b/htdocs/compta/sociales/list.php index 94a7eadf0fb..4b8500f5206 100644 --- a/htdocs/compta/sociales/list.php +++ b/htdocs/compta/sociales/list.php @@ -54,11 +54,8 @@ $search_status = GETPOST('search_status', 'int'); $search_day_lim = GETPOST('search_day_lim', 'int'); $search_month_lim = GETPOST('search_month_lim', 'int'); $search_year_lim = GETPOST('search_year_lim', 'int'); - -if (! empty($conf->projet->enabled)) { - $search_project_ref=GETPOST('search_project_ref', 'alpha'); - $search_project=GETPOST('search_project', 'alpha'); -} +$search_project_ref = GETPOST('search_project_ref', 'alpha'); +$search_project = GETPOST('search_project', 'alpha'); $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST("sortfield", 'alpha'); From 5c48f6f405d4ad1b6fa879a8e230bd56bc2ab167 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 20 Feb 2020 01:08:53 +0100 Subject: [PATCH 45/94] Lang of web site is optional --- htdocs/core/class/html.formadmin.class.php | 13 ++++--- htdocs/website/index.php | 44 +++++++++++++++------- 2 files changed, 38 insertions(+), 19 deletions(-) diff --git a/htdocs/core/class/html.formadmin.class.php b/htdocs/core/class/html.formadmin.class.php index 7012b813f7d..ff99431b221 100644 --- a/htdocs/core/class/html.formadmin.class.php +++ b/htdocs/core/class/html.formadmin.class.php @@ -50,7 +50,7 @@ class FormAdmin * @param string $selected Language pre-selected * @param string $htmlname Name of HTML select * @param int $showauto Show 'auto' choice - * @param array $filter Array of keys to exclude in list + * @param array $filter Array of keys to exclude in list (opposite of $onlykeys) * @param string $showempty '1'=Add empty value or string to show * @param int $showwarning Show a warning if language is not complete * @param int $disabled Disable edit of select @@ -58,9 +58,10 @@ class FormAdmin * @param int $showcode 1=Add language code into label at begining, 2=Add language code into label at end * @param int $forcecombo Force to use combo box (so no ajax beautify effect) * @param int $multiselect Make the combo a multiselect + * @param array $onlykeys Show only the following keys (opposite of $filter) * @return string Return HTML select string with list of languages */ - public function select_language($selected = '', $htmlname = 'lang_id', $showauto = 0, $filter = null, $showempty = '', $showwarning = 0, $disabled = 0, $morecss = '', $showcode = 0, $forcecombo = 0, $multiselect = 0) + public function select_language($selected = '', $htmlname = 'lang_id', $showauto = 0, $filter = null, $showempty = '', $showwarning = 0, $disabled = 0, $morecss = '', $showcode = 0, $forcecombo = 0, $multiselect = 0, $onlykeys = array()) { // phpcs:enable global $conf, $langs; @@ -96,11 +97,13 @@ class FormAdmin if ($showcode == 1) $valuetoshow=$key.' - '.$value; if ($showcode == 2) $valuetoshow=$value.' ('.$key.')'; - if ($filter && is_array($filter) && array_key_exists($key, $filter)) - { + if ($filter && is_array($filter) && array_key_exists($key, $filter)) { continue; } - elseif ($selected == $key) + if ($onlykeys && is_array($onlykeys) && ! array_key_exists($key, $onlykeys)) { + continue; + } + if ($selected == $key) { $out.= ''; } diff --git a/htdocs/website/index.php b/htdocs/website/index.php index c44341e0361..cd00989b339 100644 --- a/htdocs/website/index.php +++ b/htdocs/website/index.php @@ -1,5 +1,5 @@ +/* Copyright (C) 2016-2020 Laurent Destailleur * * 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 @@ -779,16 +779,15 @@ if ($action == 'addcontainer') } else { - $objectpage->title = GETPOST('WEBSITE_TITLE', 'alpha'); - $objectpage->type_container = GETPOST('WEBSITE_TYPE_CONTAINER', 'alpha'); + $objectpage->title = GETPOST('WEBSITE_TITLE', 'alphanohtml'); + $objectpage->type_container = GETPOST('WEBSITE_TYPE_CONTAINER', 'aZ09'); $objectpage->pageurl = GETPOST('WEBSITE_PAGENAME', 'alpha'); - $objectpage->aliasalt = GETPOST('WEBSITE_ALIASALT', 'alpha'); - $objectpage->description = GETPOST('WEBSITE_DESCRIPTION', 'alpha'); - $objectpage->lang = GETPOST('WEBSITE_LANG', 'alpha'); - $objectpage->otherlang = GETPOST('WEBSITE_OTHERLANG', 'alpha'); - $objectpage->image = GETPOST('WEBSITE_IMAGE', 'alpha'); - $objectpage->keywords = GETPOST('WEBSITE_KEYWORDS', 'alpha'); + $objectpage->aliasalt = GETPOST('WEBSITE_ALIASALT', 'alphanohtml'); + $objectpage->description = GETPOST('WEBSITE_DESCRIPTION', 'alphanohtml'); $objectpage->lang = GETPOST('WEBSITE_LANG', 'aZ09'); + $objectpage->otherlang = GETPOST('WEBSITE_OTHERLANG', 'aZ09comma'); + $objectpage->image = GETPOST('WEBSITE_IMAGE', 'alpha'); + $objectpage->keywords = GETPOST('WEBSITE_KEYWORDS', 'alphanohtml'); $objectpage->htmlheader = GETPOST('htmlheader', 'none'); $substitutionarray = array(); @@ -1417,8 +1416,7 @@ if ($action == 'updatemeta') $objectpage->otherlang = GETPOST('WEBSITE_OTHERLANG', 'aZ09comma'); $objectpage->description = GETPOST('WEBSITE_DESCRIPTION', 'alphanohtml'); $objectpage->image = GETPOST('WEBSITE_IMAGE', 'alpha'); - $objectpage->keywords = GETPOST('WEBSITE_KEYWORDS', 'alpha'); - $objectpage->lang = GETPOST('WEBSITE_LANG', 'aZ09'); + $objectpage->keywords = GETPOST('WEBSITE_KEYWORDS', 'alphanohtml'); $objectpage->htmlheader = trim(GETPOST('htmlheader', 'none')); $objectpage->fk_page = (GETPOST('pageidfortranslation', 'int') > 0 ? GETPOST('pageidfortranslation', 'int') : 0); @@ -2704,7 +2702,7 @@ if ($action == 'editcss') $htmltext=''; print $form->textwithpicto($langs->trans('MainLanguage'), $htmltext, 1, 'help', '', 0, 2, 'WEBSITE_LANG'); print ''; - print $formadmin->select_language((GETPOSTISSET('WEBSITE_LANG') ? GETPOST('WEBSITE_LANG', 'alpha') : ($object->lang ? $object->lang : $langs->defaultlang)), 'WEBSITE_LANG', 0, 0, 0, 0, 0, 'minwidth300', 2); + print $formadmin->select_language((GETPOSTISSET('WEBSITE_LANG') ? GETPOST('WEBSITE_LANG', 'aZ09comma') : ($object->lang ? $object->lang : '0')), 'WEBSITE_LANG', 0, null, 1, 0, 0, 'minwidth300', 2); print '
'; print $langs->trans('MainLanguage'); print ''; - print $formadmin->select_language((GETPOSTISSET('WEBSITE_LANG') ? GETPOST('WEBSITE_LANG', 'alpha') : $langs->defaultlang), 'WEBSITE_LANG', 0, 0, 0, 0, 0, 'minwidth300', 2); + print $formadmin->select_language((GETPOSTISSET('WEBSITE_LANG') ? GETPOST('WEBSITE_LANG', 'aZ09comma') : '0'), 'WEBSITE_LANG', 0, null, 1, 0, 0, 'minwidth300', 2); print '
'; @@ -3098,7 +3096,25 @@ if ($action == 'editmeta' || $action == 'createcontainer') print '
'; print $langs->trans('Language'); print ''; - print $formadmin->select_language($pagelang ? $pagelang : $langs->defaultlang, 'WEBSITE_LANG', 0, null, '1', 0, 0, 'minwidth200'); + $onlykeys = array(); + if ($object->lang) $onlykeys[$object->lang] = $object->lang; + else $onlykeys[$langs->defaultlang] = $langs->defaultlang; + if ($object->otherlang) { + $tmparray = explode(',', $object->otherlang); + foreach($tmparray as $key) { + $tmpkey = trim($key); + if (strlen($key) == 2) { + $tmpkey = strtolower($key).'_'.strtoupper($tmpkey); + } + $onlykeys[$tmpkey] = $tmpkey; + } + } + if (empty($object->lang) && empty($object->otherlang)) { + $onlykeys = null; // We keep full list of languages + } + print $formadmin->select_language($pagelang ? $pagelang : '', 'WEBSITE_LANG', 0, null, '1', 0, 0, 'minwidth200', 0, 0, 0, $onlykeys); + $htmltext = $langs->trans("AvailableLanguagesAreDefinedIntoWebsiteProperties"); + print $form->textwithpicto('', $htmltext); print '
".$chargesociale_static->getNomUrl(1, '20')."'.dol_print_date($db->jdate($obj->date_ech), 'day').'getLibStatut(7); ?>'.img_picto($langs->transnoentitiesnoconv("RemoveLink"), 'unlink'); ?>">transnoentitiesnoconv("RemoveLink"), 'unlink'); ?>
date, 'day'); ?> getLibStatut(7); ?>'.img_picto($langs->transnoentitiesnoconv("RemoveLink"), 'unlink'); ?>">transnoentitiesnoconv("RemoveLink"), 'unlink'); ?>
'; +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 a3fce650d9bd613d2a0529505fc35b227d6af8ed Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 20 Feb 2020 15:25:32 +0100 Subject: [PATCH 62/94] FIX etrafield with visibilty=5 were not in read only FIX CSS FIX option for topbar search and bookmarks --- 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 738b8b6ec18..42cb6587eee 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -2046,7 +2046,7 @@ function top_menu_search() - '; @@ -2077,7 +2077,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"); } @@ -2085,6 +2086,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 191247c9ca6..ce7e707e53d 100644 --- a/htdocs/theme/eldy/global.inc.php +++ b/htdocs/theme/eldy/global.inc.php @@ -1592,6 +1592,7 @@ div#id-top { background: rgb(); background-image: linear-gradient(-45deg, , rgb()); + /* box-shadow: 0px 0px 5px #eee; */ } @@ -4853,6 +4854,11 @@ div.dataTables_length select { /* Select2 */ /* ============================================================================== */ +.select2-container--default .select2-results__option--highlighted[aria-selected] { + background-color: rgb(); + color: #; +} + span.select2.select2-container.select2-container--default { border-left: none; border-top: none; From 593091f39964dd15e0e6429653b0ba547a70f508 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 20 Feb 2020 15:25:32 +0100 Subject: [PATCH 63/94] 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 c29e1e78f3048e2f677697d3f3e665ff7e8ba75d Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 20 Feb 2020 15:43:31 +0100 Subject: [PATCH 64/94] NEW Bookmarks are now in top menu bar --- htdocs/core/class/conf.class.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/htdocs/core/class/conf.class.php b/htdocs/core/class/conf.class.php index 4f5602fc5ef..cec04a3ac5e 100644 --- a/htdocs/core/class/conf.class.php +++ b/htdocs/core/class/conf.class.php @@ -688,6 +688,8 @@ class Conf if (empty($this->global->MAIN_MODULE_DOLISTORE_API_SRV)) $this->global->MAIN_MODULE_DOLISTORE_API_SRV = 'https://www.dolistore.com'; if (empty($this->global->MAIN_MODULE_DOLISTORE_API_KEY)) $this->global->MAIN_MODULE_DOLISTORE_API_KEY = 'dolistorecatalogpublickey1234567'; + if (! isset($this->global->MAIN_USE_TOP_MENU_BOOKMARK_DROPDOWN)) $this->global->MAIN_USE_TOP_MENU_BOOKMARK_DROPDOWN = 1; + // If we are in develop mode, we activate the option MAIN_SECURITY_CSRF_WITH_TOKEN to 1 if not already defined. if (!isset($this->global->MAIN_SECURITY_CSRF_WITH_TOKEN) && $this->global->MAIN_FEATURES_LEVEL >= 2) $this->global->MAIN_SECURITY_CSRF_WITH_TOKEN = 1; From 7200472427f461a0f176ddb57276ddda3cbd0b5d Mon Sep 17 00:00:00 2001 From: andreubisquerra Date: Thu, 20 Feb 2020 15:45:42 +0100 Subject: [PATCH 65/94] 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 66/94] 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 67/94] 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 68/94] 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 6cd4d15245ba34b94b1268b06800acb867486caf Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 20 Feb 2020 17:05:28 +0100 Subject: [PATCH 69/94] Debug the new bookmark in top menu + support for MD theme --- htdocs/bookmarks/bookmarks.lib.php | 176 ++----------- htdocs/main.inc.php | 17 +- htdocs/theme/eldy/dropdown.inc.php | 5 + htdocs/theme/md/dropdown.inc.php | 395 ++++++++++++++++++++++++++++- htdocs/theme/md/style.css.php | 38 +-- 5 files changed, 437 insertions(+), 194 deletions(-) diff --git a/htdocs/bookmarks/bookmarks.lib.php b/htdocs/bookmarks/bookmarks.lib.php index 8d772bf5b33..6bb4b243aff 100644 --- a/htdocs/bookmarks/bookmarks.lib.php +++ b/htdocs/bookmarks/bookmarks.lib.php @@ -21,132 +21,6 @@ * \brief File with library for bookmark module */ -/** - * Add area with bookmarks in menu - * - * @return string - */ -function printBookmarksList() -{ - global $conf, $user, $db, $langs; - - $ret = ''."\n"; - - if (! empty($conf->use_javascript_ajax)) { // Bookmark autosubmit can't work when javascript is off. - require_once DOL_DOCUMENT_ROOT.'/bookmarks/class/bookmark.class.php'; - if (! isset($conf->global->BOOKMARKS_SHOW_IN_MENU)) $conf->global->BOOKMARKS_SHOW_IN_MENU=5; - - $langs->load("bookmarks"); - - $url= $_SERVER["PHP_SELF"]; - - if (! empty($_SERVER["QUERY_STRING"])) - { - $url.=(dol_escape_htmltag($_SERVER["QUERY_STRING"])?'?'.dol_escape_htmltag($_SERVER["QUERY_STRING"]):''); - } - else - { - global $sortfield,$sortorder; - $tmpurl=''; - // No urlencode, all param $url will be urlencoded later - if ($sortfield) $tmpurl.=($tmpurl?'&':'').'sortfield='.$sortfield; - if ($sortorder) $tmpurl.=($tmpurl?'&':'').'sortorder='.$sortorder; - if (is_array($_POST)) - { - foreach($_POST as $key => $val) - { - if (preg_match('/^search_/', $key) && $val != '') $tmpurl.=($tmpurl?'&':'').$key.'='.$val; - } - } - $url.=($tmpurl?'?'.$tmpurl:''); - } - - // Menu bookmark - $ret = ''."\n"; - - $ret.= ''."\n"; - $ret.= ''; - $ret.= ''; - $ret.= ''; - $ret.= ''; - - $ret.=ajax_combobox('boxbookmark'); - - $ret.=''; - } - - $ret.= ''."\n"; - - return $ret; -} - - /** * Add area with bookmarks in top menu @@ -158,7 +32,6 @@ function printDropdownBookmarksList() global $conf, $user, $db, $langs; require_once DOL_DOCUMENT_ROOT.'/bookmarks/class/bookmark.class.php'; - if (! isset($conf->global->BOOKMARKS_SHOW_IN_MENU)) $conf->global->BOOKMARKS_SHOW_IN_MENU=5; $langs->load("bookmarks"); @@ -204,42 +77,35 @@ function printDropdownBookmarksList() $newbtn.= img_picto('', 'bookmark').' '.dol_escape_htmltag($langs->trans('AddThisPageToBookmarks')).''; } - $bookmarkList=''; - $html= ''; - if (! empty($conf->global->BOOKMARKS_SHOW_IN_MENU)) { - $html.= ' + $html = ' '; - } $html.= ' @@ -256,8 +122,7 @@ function printDropdownBookmarksList() '; - if (! empty($conf->global->BOOKMARKS_SHOW_IN_MENU)) { - $html .= ''; - } return $html; } diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index 42cb6587eee..cb95d143b97 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -1940,7 +1940,7 @@ function top_menu_bookmark() $langs->load("bookmarks"); $html .= ' - '; - - $html .= ' '; + $script .= ''; return $script; } @@ -225,8 +225,8 @@ function ajax_autocompleter($selected, $htmlname, $url, $urloption = '', $minLen function ajax_multiautocompleter($htmlname, $fields, $url, $option = '', $minLength = 2, $autoselect = 0) { $script = ''."\n"; - $script.= ''; + $script .= ''; return $script; } @@ -333,11 +333,11 @@ function ajax_dialog($title, $message, $w = 350, $h = 150) { global $langs; - $newtitle=dol_textishtml($title)?dol_string_nohtmltag($title, 1):$title; - $msg= '
'; - $msg.= $message; - $msg.= '
'."\n"; - $msg.= ''; - $msg.= "\n"; + $msg .= "\n"; return $msg; } @@ -377,20 +377,20 @@ function ajax_combobox($htmlname, $events = array(), $minLengthToAutocomplete = global $conf; // select2 can be disabled for smartphones - if (! empty($conf->browser->layout) && $conf->browser->layout == 'phone' && ! empty($conf->global->MAIN_DISALLOW_SELECT2_WITH_SMARTPHONE)) return ''; + if (!empty($conf->browser->layout) && $conf->browser->layout == 'phone' && !empty($conf->global->MAIN_DISALLOW_SELECT2_WITH_SMARTPHONE)) return ''; - if (! empty($conf->global->MAIN_DISABLE_AJAX_COMBOX)) return ''; + if (!empty($conf->global->MAIN_DISABLE_AJAX_COMBOX)) return ''; if (empty($conf->use_javascript_ajax)) return ''; - if (empty($conf->global->MAIN_USE_JQUERY_MULTISELECT) && ! defined('REQUIRE_JQUERY_MULTISELECT')) return ''; - if (! empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) return ''; + if (empty($conf->global->MAIN_USE_JQUERY_MULTISELECT) && !defined('REQUIRE_JQUERY_MULTISELECT')) return ''; + if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) return ''; - if (empty($minLengthToAutocomplete)) $minLengthToAutocomplete=0; + if (empty($minLengthToAutocomplete)) $minLengthToAutocomplete = 0; - $tmpplugin='select2'; - $msg="\n".' + $tmpplugin = 'select2'; + $msg = "\n".' \n"; + $msg .= '});'."\n"; + $msg .= "\n"; return $msg; } @@ -495,7 +495,7 @@ function ajax_constantonoff($code, $input = array(), $entity = null, $revertonof } else { - $out= "\n".' + $out = "\n".' '."\n"; - $out.= ''; - $out.= ''.($revertonoff?img_picto($langs->trans("Enabled"), 'switch_on'):img_picto($langs->trans("Disabled"), 'switch_off')).''; - $out.= ''.($revertonoff?img_picto($langs->trans("Disabled"), 'switch_off'):img_picto($langs->trans("Enabled"), 'switch_on')).''; - $out.="\n"; + $out .= ''; + $out .= ''.($revertonoff ?img_picto($langs->trans("Enabled"), 'switch_on') : img_picto($langs->trans("Disabled"), 'switch_off')).''; + $out .= ''.($revertonoff ?img_picto($langs->trans("Disabled"), 'switch_off') : img_picto($langs->trans("Enabled"), 'switch_on')).''; + $out .= "\n"; } return $out; @@ -555,7 +555,7 @@ function ajax_object_onoff($object, $code, $field, $text_on, $text_off, $input = { global $langs; - $out= ''; - $out.= ''.img_picto($langs->trans($text_off), 'switch_off').''; - $out.= ''.img_picto($langs->trans($text_on), 'switch_on').''; + $out .= ''.img_picto($langs->trans($text_off), 'switch_off').''; + $out .= ''.img_picto($langs->trans($text_on), 'switch_on').''; return $out; } diff --git a/htdocs/core/lib/product.lib.php b/htdocs/core/lib/product.lib.php index da480048ede..79d77e0268f 100644 --- a/htdocs/core/lib/product.lib.php +++ b/htdocs/core/lib/product.lib.php @@ -76,13 +76,13 @@ function product_prepare_head($object) } // Sub products - if (! empty($conf->global->PRODUIT_SOUSPRODUITS)) + if (!empty($conf->global->PRODUIT_SOUSPRODUITS)) { $head[$h][0] = DOL_URL_ROOT."/product/composition/card.php?id=".$object->id; $head[$h][1] = $langs->trans('AssociatedProducts'); $nbFatherAndChild = $object->hasFatherOrChild(); - if ($nbFatherAndChild > 0) $head[$h][1].= ''.$nbFatherAndChild.''; + if ($nbFatherAndChild > 0) $head[$h][1] .= ''.$nbFatherAndChild.''; $head[$h][2] = 'subproduct'; $h++; } @@ -110,15 +110,15 @@ function product_prepare_head($object) $head[$h][1] = $langs->trans('ProductCombinations'); $head[$h][2] = 'combinations'; $nbVariant = $prodcomb->countNbOfCombinationForFkProductParent($object->id); - if ($nbVariant > 0) $head[$h][1].= ''.$nbVariant.''; + if ($nbVariant > 0) $head[$h][1] .= ''.$nbVariant.''; } $h++; } - if ($object->isProduct() || ($object->isService() && ! empty($conf->global->STOCK_SUPPORTS_SERVICES))) // If physical product we can stock (or service with option) + if ($object->isProduct() || ($object->isService() && !empty($conf->global->STOCK_SUPPORTS_SERVICES))) // If physical product we can stock (or service with option) { - if (! empty($conf->stock->enabled) && $user->rights->stock->lire) + if (!empty($conf->stock->enabled) && $user->rights->stock->lire) { $head[$h][0] = DOL_URL_ROOT."/product/stock/product.php?id=".$object->id; $head[$h][1] = $langs->trans("Stock"); @@ -156,11 +156,11 @@ function product_prepare_head($object) if (empty($conf->global->MAIN_DISABLE_NOTES_TAB)) { $nbNote = 0; - if(!empty($object->note_private)) $nbNote++; - if(!empty($object->note_public)) $nbNote++; + if (!empty($object->note_private)) $nbNote++; + if (!empty($object->note_public)) $nbNote++; $head[$h][0] = DOL_URL_ROOT.'/product/note.php?id='.$object->id; $head[$h][1] = $langs->trans('Notes'); - if ($nbNote > 0) $head[$h][1].= ''.$nbNote.''; + if ($nbNote > 0) $head[$h][1] .= ''.$nbNote.''; $head[$h][2] = 'note'; $h++; } @@ -168,18 +168,18 @@ function product_prepare_head($object) // Attachments require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php'; - if (! empty($conf->product->enabled) && ($object->type==Product::TYPE_PRODUCT)) $upload_dir = $conf->product->multidir_output[$object->entity].'/'.dol_sanitizeFileName($object->ref); - if (! empty($conf->service->enabled) && ($object->type==Product::TYPE_SERVICE)) $upload_dir = $conf->service->multidir_output[$object->entity].'/'.dol_sanitizeFileName($object->ref); + if (!empty($conf->product->enabled) && ($object->type == Product::TYPE_PRODUCT)) $upload_dir = $conf->product->multidir_output[$object->entity].'/'.dol_sanitizeFileName($object->ref); + if (!empty($conf->service->enabled) && ($object->type == Product::TYPE_SERVICE)) $upload_dir = $conf->service->multidir_output[$object->entity].'/'.dol_sanitizeFileName($object->ref); $nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png)$')); - if (! empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO)) { - if (! empty($conf->product->enabled) && ($object->type==Product::TYPE_PRODUCT)) $upload_dir = $conf->product->multidir_output[$object->entity].'/'.get_exdir($object->id, 2, 0, 0, $object, 'product').$object->id.'/photos'; - if (! empty($conf->service->enabled) && ($object->type==Product::TYPE_SERVICE)) $upload_dir = $conf->service->multidir_output[$object->entity].'/'.get_exdir($object->id, 2, 0, 0, $object, 'product').$object->id.'/photos'; + if (!empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO)) { + if (!empty($conf->product->enabled) && ($object->type == Product::TYPE_PRODUCT)) $upload_dir = $conf->product->multidir_output[$object->entity].'/'.get_exdir($object->id, 2, 0, 0, $object, 'product').$object->id.'/photos'; + if (!empty($conf->service->enabled) && ($object->type == Product::TYPE_SERVICE)) $upload_dir = $conf->service->multidir_output[$object->entity].'/'.get_exdir($object->id, 2, 0, 0, $object, 'product').$object->id.'/photos'; $nbFiles += count(dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png)$')); } - $nbLinks=Link::count($db, $object->element, $object->id); + $nbLinks = Link::count($db, $object->element, $object->id); $head[$h][0] = DOL_URL_ROOT.'/product/document.php?id='.$object->id; $head[$h][1] = $langs->trans('Documents'); - if (($nbFiles+$nbLinks) > 0) $head[$h][1].= ''.($nbFiles+$nbLinks).''; + if (($nbFiles + $nbLinks) > 0) $head[$h][1] .= ''.($nbFiles + $nbLinks).''; $head[$h][2] = 'documents'; $h++; @@ -225,10 +225,10 @@ function productlot_prepare_head($object) require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php'; $upload_dir = $conf->productbatch->multidir_output[$object->entity].'/'.dol_sanitizeFileName($object->ref); $nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png)$')); - $nbLinks=Link::count($db, $object->element, $object->id); + $nbLinks = Link::count($db, $object->element, $object->id); $head[$h][0] = DOL_URL_ROOT."/product/stock/productlot_document.php?id=".$object->id; $head[$h][1] = $langs->trans("Documents"); - if (($nbFiles+$nbLinks) > 0) $head[$h][1].= ''.($nbFiles+$nbLinks).''; + if (($nbFiles + $nbLinks) > 0) $head[$h][1] .= ''.($nbFiles + $nbLinks).''; $head[$h][2] = 'documents'; $h++; @@ -536,7 +536,7 @@ function measuringUnitString($unit, $measuring_style = '', $scale = '', $use_sho if (empty($measuring_unit_cache[$unit.'_'.$measuring_style.'_'.$scale.'_'.$use_short_label])) { require_once DOL_DOCUMENT_ROOT.'/core/class/cunits.class.php'; - $measuringUnits= new CUnits($db); + $measuringUnits = new CUnits($db); if ($measuring_style == '' && $scale == '') { diff --git a/htdocs/core/lib/project.lib.php b/htdocs/core/lib/project.lib.php index 8e78e4e45be..ddca8ef1153 100644 --- a/htdocs/core/lib/project.lib.php +++ b/htdocs/core/lib/project.lib.php @@ -265,7 +265,7 @@ function project_timesheet_prepare_head($mode, $fuser = null) if (empty($conf->global->PROJECT_DISABLE_TIMESHEET_PERMONTH)) { - $head[$h][0] = DOL_URL_ROOT."/projet/activity/permonth.php".($param?'?'.$param:''); + $head[$h][0] = DOL_URL_ROOT."/projet/activity/permonth.php".($param ? '?'.$param : ''); $head[$h][1] = $langs->trans("InputPerMonth"); $head[$h][2] = 'inputpermonth'; $h++; @@ -1735,19 +1735,19 @@ function projectLinesPerMonth(&$inc, $firstdaytoshow, $fuser, $parent, $lines, & global $conf, $db, $user, $bc, $langs; global $form, $formother, $projectstatic, $taskstatic, $thirdpartystatic; - $numlines=count($lines); + $numlines = count($lines); - $lastprojectid=0; - $workloadforid=array(); - $totalforeachweek=array(); - $lineswithoutlevel0=array(); + $lastprojectid = 0; + $workloadforid = array(); + $totalforeachweek = array(); + $lineswithoutlevel0 = array(); // Create a smaller array with sublevels only to be used later. This increase dramatically performances. if ($parent == 0) // Always and only if at first level { - for ($i = 0 ; $i < $numlines ; $i++) + for ($i = 0; $i < $numlines; $i++) { - if ($lines[$i]->fk_task_parent) $lineswithoutlevel0[]=$lines[$i]; + if ($lines[$i]->fk_task_parent) $lineswithoutlevel0[] = $lines[$i]; } } @@ -1755,24 +1755,24 @@ function projectLinesPerMonth(&$inc, $firstdaytoshow, $fuser, $parent, $lines, & if (empty($oldprojectforbreak)) { - $oldprojectforbreak = (empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT)?0:-1); // 0 = start break, -1 = never break + $oldprojectforbreak = (empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT) ? 0 : -1); // 0 = start break, -1 = never break } - for ($i = 0 ; $i < $numlines ; $i++) + for ($i = 0; $i < $numlines; $i++) { if ($parent == 0) $level = 0; if ($lines[$i]->fk_task_parent == $parent) { // If we want all or we have a role on task, we show it - if (empty($mine) || ! empty($tasksrole[$lines[$i]->id])) + if (empty($mine) || !empty($tasksrole[$lines[$i]->id])) { //dol_syslog("projectLinesPerWeek Found line ".$i.", a qualified task (i have role or want to show all tasks) with id=".$lines[$i]->id." project id=".$lines[$i]->fk_project); // Break on a new project if ($parent == 0 && $lines[$i]->fk_project != $lastprojectid) { - $lastprojectid=$lines[$i]->fk_project; + $lastprojectid = $lines[$i]->fk_project; $projectstatic->id = $lines[$i]->fk_project; } @@ -1780,32 +1780,32 @@ function projectLinesPerMonth(&$inc, $firstdaytoshow, $fuser, $parent, $lines, & //var_dump($projectstatic->weekWorkLoadPerTask); if (empty($workloadforid[$projectstatic->id])) { - $projectstatic->loadTimeSpentMonth($firstdaytoshow, 0, $fuser->id); // Load time spent from table projet_task_time for the project into this->weekWorkLoad and this->weekWorkLoadPerTask for all days of a week - $workloadforid[$projectstatic->id]=1; + $projectstatic->loadTimeSpentMonth($firstdaytoshow, 0, $fuser->id); // Load time spent from table projet_task_time for the project into this->weekWorkLoad and this->weekWorkLoadPerTask for all days of a week + $workloadforid[$projectstatic->id] = 1; } //var_dump($projectstatic->weekWorkLoadPerTask); //var_dump('--- '.$projectstatic->id.' '.$workloadforid[$projectstatic->id]); - $projectstatic->id=$lines[$i]->fk_project; - $projectstatic->ref=$lines[$i]->projectref; - $projectstatic->title=$lines[$i]->projectlabel; - $projectstatic->public=$lines[$i]->public; - $projectstatic->thirdparty_name=$lines[$i]->thirdparty_name; + $projectstatic->id = $lines[$i]->fk_project; + $projectstatic->ref = $lines[$i]->projectref; + $projectstatic->title = $lines[$i]->projectlabel; + $projectstatic->public = $lines[$i]->public; + $projectstatic->thirdparty_name = $lines[$i]->thirdparty_name; - $taskstatic->id=$lines[$i]->id; - $taskstatic->ref=($lines[$i]->ref?$lines[$i]->ref:$lines[$i]->id); - $taskstatic->label=$lines[$i]->label; - $taskstatic->date_start=$lines[$i]->date_start; - $taskstatic->date_end=$lines[$i]->date_end; + $taskstatic->id = $lines[$i]->id; + $taskstatic->ref = ($lines[$i]->ref ? $lines[$i]->ref : $lines[$i]->id); + $taskstatic->label = $lines[$i]->label; + $taskstatic->date_start = $lines[$i]->date_start; + $taskstatic->date_end = $lines[$i]->date_end; - $thirdpartystatic->id=$lines[$i]->thirdparty_id; - $thirdpartystatic->name=$lines[$i]->thirdparty_name; - $thirdpartystatic->email=$lines[$i]->thirdparty_email; + $thirdpartystatic->id = $lines[$i]->thirdparty_id; + $thirdpartystatic->name = $lines[$i]->thirdparty_name; + $thirdpartystatic->email = $lines[$i]->thirdparty_email; if (empty($oldprojectforbreak) || ($oldprojectforbreak != -1 && $oldprojectforbreak != $projectstatic->id)) { print ''."\n"; - print ''; + print ''; print $projectstatic->getNomUrl(1, '', 0, ''.$langs->transnoentitiesnoconv("YourRole").': '.$projectsrole[$lines[$i]->fk_project]); if ($thirdpartystatic->id > 0) print ' - '.$thirdpartystatic->getNomUrl(1); if ($projectstatic->title) @@ -1840,11 +1840,11 @@ function projectLinesPerMonth(&$inc, $firstdaytoshow, $fuser, $parent, $lines, & // Ref print ''; print ''; - for ($k = 0 ; $k < $level ; $k++) print "   "; + for ($k = 0; $k < $level; $k++) print "   "; print $taskstatic->getNomUrl(1, 'withproject', 'time'); // Label task print '
'; - for ($k = 0 ; $k < $level ; $k++) print "   "; + for ($k = 0; $k < $level; $k++) print "   "; //print $taskstatic->getNomUrl(0, 'withproject', 'time'); print $taskstatic->label; //print "
"; @@ -1860,7 +1860,7 @@ function projectLinesPerMonth(&$inc, $firstdaytoshow, $fuser, $parent, $lines, & // Progress declared % print ''; - print $formother->select_percent($lines[$i]->progress, $lines[$i]->id . 'progress'); + print $formother->select_percent($lines[$i]->progress, $lines[$i]->id.'progress'); print ''; // Time spent by everybody @@ -1877,66 +1877,66 @@ function projectLinesPerMonth(&$inc, $firstdaytoshow, $fuser, $parent, $lines, & // Time spent by user print ''; - $tmptimespent=$taskstatic->getSummaryOfTimeSpent($fuser->id); + $tmptimespent = $taskstatic->getSummaryOfTimeSpent($fuser->id); if ($tmptimespent['total_duration']) print convertSecondToTime($tmptimespent['total_duration'], 'allhourmin'); else print '--:--'; print "\n"; - $disabledproject=1;$disabledtask=1; + $disabledproject = 1; $disabledtask = 1; //print "x".$lines[$i]->fk_project; //var_dump($lines[$i]); //var_dump($projectsrole[$lines[$i]->fk_project]); // If at least one role for project - if ($lines[$i]->public || ! empty($projectsrole[$lines[$i]->fk_project]) || $user->rights->projet->all->creer) + if ($lines[$i]->public || !empty($projectsrole[$lines[$i]->fk_project]) || $user->rights->projet->all->creer) { - $disabledproject=0; - $disabledtask=0; + $disabledproject = 0; + $disabledtask = 0; } // If $restricteditformytask is on and I have no role on task, i disable edit if ($restricteditformytask && empty($tasksrole[$lines[$i]->id])) { - $disabledtask=1; + $disabledtask = 1; } //var_dump($projectstatic->weekWorkLoadPerTask); //TODO // Fields to show current time - $tableCell=''; $modeinput='hours'; + $tableCell = ''; $modeinput = 'hours'; $TFirstDay = getFirstDayOfEachWeek($TWeek, date('Y', $firstdaytoshow)); $TFirstDay[reset($TWeek)] = 1; - foreach($TFirstDay as &$fday) { + foreach ($TFirstDay as &$fday) { $fday--; } foreach ($TWeek as $weekNb) { $weekWorkLoad = $projectstatic->monthWorkLoadPerTask[$weekNb][$lines[$i]->id]; - $totalforeachweek[$weekNb]+=$weekWorkLoad; + $totalforeachweek[$weekNb] += $weekWorkLoad; - $alreadyspent=''; - if ($weekWorkLoad > 0) $alreadyspent=convertSecondToTime($weekWorkLoad, 'allhourmin'); - $alttitle=$langs->trans("AddHereTimeSpentForWeek", $weekNb); + $alreadyspent = ''; + if ($weekWorkLoad > 0) $alreadyspent = convertSecondToTime($weekWorkLoad, 'allhourmin'); + $alttitle = $langs->trans("AddHereTimeSpentForWeek", $weekNb); - $tableCell =''; - $placeholder=''; + $tableCell = ''; + $placeholder = ''; if ($alreadyspent) { - $tableCell.=''; + $tableCell .= ''; //$placeholder=' placeholder="00:00"'; //$tableCell.='+'; } - $tableCell.=''; - $tableCell.=''; + $tableCell .= ''; + $tableCell .= ''; print $tableCell; } // Warning print ''; - if ((! $lines[$i]->public) && $disabledproject) print $form->textwithpicto('', $langs->trans("UserIsNotContactOfProject")); + if ((!$lines[$i]->public) && $disabledproject) print $form->textwithpicto('', $langs->trans("UserIsNotContactOfProject")); elseif ($disabledtask) { $titleassigntask = $langs->trans("AssignTaskToMe"); @@ -1959,9 +1959,9 @@ function projectLinesPerMonth(&$inc, $firstdaytoshow, $fuser, $parent, $lines, & $ret = projectLinesPerMonth($inc, $firstdaytoshow, $fuser, $lines[$i]->id, ($parent == 0 ? $lineswithoutlevel0 : $lines), $level, $projectsrole, $tasksrole, $mine, $restricteditformytask, $isavailable, $oldprojectforbreak, $TWeek); //var_dump('ret with parent='.$lines[$i]->id.' level='.$level); //var_dump($ret); - foreach($ret as $key => $val) + foreach ($ret as $key => $val) { - $totalforeachweek[$key]+=$val; + $totalforeachweek[$key] += $val; } //var_dump('totalforeachday after taskid='.$lines[$i]->id.' and previous one on level '.$level.' + subtasks'); //var_dump($totalforeachday); @@ -2202,8 +2202,8 @@ function print_projecttasks_array($db, $form, $socid, $projectsListId, $mytasks print ''; // Because color of prospection status has no meaning yet, it is used if hidden constant is set if (empty($conf->global->USE_COLOR_FOR_PROSPECTION_STATUS)) { - if ($langs->trans("OppStatus" . $oppStatusCode) != "OppStatus" . $oppStatusCode) { - print $langs->trans("OppStatus" . $oppStatusCode); + if ($langs->trans("OppStatus".$oppStatusCode) != "OppStatus".$oppStatusCode) { + print $langs->trans("OppStatus".$oppStatusCode); } } else { if (isset($statusOppList[$objp->opp_status])) { @@ -2215,9 +2215,9 @@ function print_projecttasks_array($db, $form, $socid, $projectsListId, $mytasks } if ($oppStatusCode) { if (!empty($oppStatusColor)) { - print ''; + print ''; } else { - print '' . $oppStatusCode . ''; + print ''.$oppStatusCode.''; } } } diff --git a/htdocs/core/modules/commande/doc/pdf_einstein.modules.php b/htdocs/core/modules/commande/doc/pdf_einstein.modules.php index 6e3d887cbce..b8740fa60de 100644 --- a/htdocs/core/modules/commande/doc/pdf_einstein.modules.php +++ b/htdocs/core/modules/commande/doc/pdf_einstein.modules.php @@ -1315,27 +1315,27 @@ class pdf_einstein extends ModelePDFCommandes $pdf->MultiCell(100, 3, $outputlangs->transnoentities("RefCustomer")." : ".$outputlangs->convToOutputCharset($object->ref_client), '', 'R'); } - if (! empty($conf->global->PDF_SHOW_PROJECT_TITLE)) + if (!empty($conf->global->PDF_SHOW_PROJECT_TITLE)) { $object->fetch_projet(); - if (! empty($object->project->ref)) + if (!empty($object->project->ref)) { - $posy+=3; + $posy += 3; $pdf->SetXY($posx, $posy); $pdf->SetTextColor(0, 0, 60); - $pdf->MultiCell($w, 3, $outputlangs->transnoentities("Project")." : " . (empty($object->project->title)?'':$object->projet->title), '', 'R'); + $pdf->MultiCell($w, 3, $outputlangs->transnoentities("Project")." : ".(empty($object->project->title) ? '' : $object->projet->title), '', 'R'); } } - if (! empty($conf->global->PDF_SHOW_PROJECT)) + if (!empty($conf->global->PDF_SHOW_PROJECT)) { $object->fetch_projet(); - if (! empty($object->project->ref)) + if (!empty($object->project->ref)) { - $posy+=3; + $posy += 3; $pdf->SetXY($posx, $posy); $pdf->SetTextColor(0, 0, 60); - $pdf->MultiCell($w, 3, $outputlangs->transnoentities("RefProject")." : " . (empty($object->project->ref)?'':$object->projet->ref), '', 'R'); + $pdf->MultiCell($w, 3, $outputlangs->transnoentities("RefProject")." : ".(empty($object->project->ref) ? '' : $object->projet->ref), '', 'R'); } } diff --git a/htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php b/htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php index f4fc2b3cb2f..5bdc591c2fb 100644 --- a/htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php +++ b/htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php @@ -621,7 +621,7 @@ class pdf_eratosthene extends ModelePDFCommandes { // We found a page break // Allows data in the first page if description is long enough to break in multiples pages - if(!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE)) + if (!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE)) $showpricebeforepagebreak = 1; else $showpricebeforepagebreak = 0; @@ -1475,27 +1475,27 @@ class pdf_eratosthene extends ModelePDFCommandes $pdf->MultiCell(100, 3, $outputlangs->transnoentities("RefCustomer")." : ".$outputlangs->convToOutputCharset($object->ref_client), '', 'R'); } - if (! empty($conf->global->PDF_SHOW_PROJECT_TITLE)) + if (!empty($conf->global->PDF_SHOW_PROJECT_TITLE)) { $object->fetch_projet(); - if (! empty($object->project->ref)) + if (!empty($object->project->ref)) { - $posy+=3; + $posy += 3; $pdf->SetXY($posx, $posy); $pdf->SetTextColor(0, 0, 60); - $pdf->MultiCell($w, 3, $outputlangs->transnoentities("Project")." : " . (empty($object->project->title)?'':$object->projet->title), '', 'R'); + $pdf->MultiCell($w, 3, $outputlangs->transnoentities("Project")." : ".(empty($object->project->title) ? '' : $object->projet->title), '', 'R'); } } - if (! empty($conf->global->PDF_SHOW_PROJECT)) + if (!empty($conf->global->PDF_SHOW_PROJECT)) { $object->fetch_projet(); - if (! empty($object->project->ref)) + if (!empty($object->project->ref)) { - $posy+=3; + $posy += 3; $pdf->SetXY($posx, $posy); $pdf->SetTextColor(0, 0, 60); - $pdf->MultiCell($w, 3, $outputlangs->transnoentities("RefProject")." : " . (empty($object->project->ref)?'':$object->projet->ref), '', 'R'); + $pdf->MultiCell($w, 3, $outputlangs->transnoentities("RefProject")." : ".(empty($object->project->ref) ? '' : $object->projet->ref), '', 'R'); } } diff --git a/htdocs/core/modules/dons/html_cerfafr.modules.php b/htdocs/core/modules/dons/html_cerfafr.modules.php index 01ebd673041..4c025750f04 100644 --- a/htdocs/core/modules/dons/html_cerfafr.modules.php +++ b/htdocs/core/modules/dons/html_cerfafr.modules.php @@ -42,7 +42,7 @@ class html_cerfafr extends ModeleDon */ public function __construct($db) { - global $conf,$langs; + global $conf, $langs; $this->db = $db; $this->name = "cerfafr"; @@ -76,46 +76,46 @@ class html_cerfafr extends ModeleDon public function write_file($don, $outputlangs, $currency = '') { // phpcs:enable - global $user,$conf,$langs,$mysoc; + global $user, $conf, $langs, $mysoc; - $now=dol_now(); - $id = (! is_object($don)?$don:''); + $now = dol_now(); + $id = (!is_object($don) ? $don : ''); - if (! is_object($outputlangs)) $outputlangs=$langs; + if (!is_object($outputlangs)) $outputlangs = $langs; // Load traductions files required by page $outputlangs->loadLangs(array("main", "dict", "companies", "bills", "products", "donations")); $currency = !empty($currency) ? $currency : $conf->currency; - if (! empty($conf->don->dir_output)) + if (!empty($conf->don->dir_output)) { // Definition of the object don (for upward compatibility) - if (! is_object($don)) + if (!is_object($don)) { $don = new Don($this->db); - $ret=$don->fetch($id); - $id=$don->id; + $ret = $don->fetch($id); + $id = $don->id; } // Definition of $dir and $file - if (! empty($don->specimen)) + if (!empty($don->specimen)) { $dir = $conf->don->dir_output; - $file = $dir . "/SPECIMEN.html"; + $file = $dir."/SPECIMEN.html"; } else { $donref = dol_sanitizeFileName($don->ref); - $dir = $conf->don->dir_output . "/" . $donref; - $file = $dir . "/" . $donref . ".html"; + $dir = $conf->don->dir_output."/".$donref; + $file = $dir."/".$donref.".html"; } - if (! file_exists($dir)) + if (!file_exists($dir)) { if (dol_mkdir($dir) < 0) { - $this->error=$langs->trans("ErrorCanNotCreateDir", $dir); + $this->error = $langs->trans("ErrorCanNotCreateDir", $dir); return -1; } } @@ -133,13 +133,13 @@ class html_cerfafr extends ModeleDon } else $paymentmode = ''; - if ($don->modepaymentcode=='CHQ'){ + if ($don->modepaymentcode == 'CHQ') { $ModePaiement = ' Remise d\'espèces Chèque Virement, prélèvement, carte bancaire'; } - elseif ($don->modepaymentcode=='LIQ'){ + elseif ($don->modepaymentcode == 'LIQ') { $ModePaiement = ' Remise d\'espèces Chèque Virement, prélèvement, carte bancaire'; } - elseif ($don->modepaymentcode=='VIR' || $don->modepaymentcode=='PRE' || $don->modepaymentcode=='CB'){ + elseif ($don->modepaymentcode == 'VIR' || $don->modepaymentcode == 'PRE' || $don->modepaymentcode == 'CB') { $ModePaiement = ' Remise d\'espèces Chèque Virement, prélèvement, carte bancaire'; } else @@ -159,7 +159,7 @@ class html_cerfafr extends ModeleDon */ // Define contents - $donmodel=DOL_DOCUMENT_ROOT ."/core/modules/dons/html_cerfafr.html"; + $donmodel = DOL_DOCUMENT_ROOT."/core/modules/dons/html_cerfafr.html"; $form = implode('', file($donmodel)); $form = str_replace('__REF__', $don->id, $form); $form = str_replace('__DATE__', dol_print_date($don->date, 'day', false, $outputlangs), $form); @@ -203,59 +203,59 @@ class html_cerfafr extends ModeleDon $form = str_replace('__ModePaiement__', $ModePaiement, $form); - $frencharticle=''; - if (preg_match('/fr/i', $outputlangs->defaultlang)) $frencharticle='Article 200, 238 bis et 978 du code général des impôts (CGI)'; + $frencharticle = ''; + if (preg_match('/fr/i', $outputlangs->defaultlang)) $frencharticle = 'Article 200, 238 bis et 978 du code général des impôts (CGI)'; $form = str_replace('__FrenchArticle__', $frencharticle, $form); - $frencheligibility=''; - if (preg_match('/fr/i', $outputlangs->defaultlang)) $frencheligibility='Le bénéficiaire certifie sur l\'honneur que les dons et versements qu\'il reçoit ouvrent droit à la réduction d\'impôt prévue à l\'article :'; + $frencheligibility = ''; + if (preg_match('/fr/i', $outputlangs->defaultlang)) $frencheligibility = 'Le bénéficiaire certifie sur l\'honneur que les dons et versements qu\'il reçoit ouvrent droit à la réduction d\'impôt prévue à l\'article :'; $form = str_replace('__FrenchEligibility__', $frencheligibility, $form); - $art200=''; + $art200 = ''; if (preg_match('/fr/i', $outputlangs->defaultlang)) { if ($conf->global->DONATION_ART200 >= 1) { - $art200='200 du CGI'; + $art200 = '200 du CGI'; } else { - $art200='200 du CGI'; + $art200 = '200 du CGI'; } } $form = str_replace('__ARTICLE200__', $art200, $form); - $art238=''; + $art238 = ''; if (preg_match('/fr/i', $outputlangs->defaultlang)) { if ($conf->global->DONATION_ART238 >= 1) { - $art238='238 bis du CGI'; + $art238 = '238 bis du CGI'; } else { - $art238='238 bis du CGI'; + $art238 = '238 bis du CGI'; } } $form = str_replace('__ARTICLE238__', $art238, $form); - $art978=''; + $art978 = ''; if (preg_match('/fr/i', $outputlangs->defaultlang)) { if ($conf->global->DONATION_ART978 >= 1) { - $art978='978 du CGI'; + $art978 = '978 du CGI'; } else { - $art978='978 du CGI'; + $art978 = '978 du CGI'; } } $form = str_replace('__ARTICLE978__', $art978, $form); // Save file on disk dol_syslog("html_cerfafr::write_file $file"); - $handle=fopen($file, "w"); + $handle = fopen($file, "w"); fwrite($handle, $form); fclose($handle); - if (! empty($conf->global->MAIN_UMASK)) + if (!empty($conf->global->MAIN_UMASK)) @chmod($file, octdec($conf->global->MAIN_UMASK)); $this->result = array('fullpath'=>$file); @@ -264,13 +264,13 @@ class html_cerfafr extends ModeleDon } else { - $this->error=$langs->trans("ErrorCanNotCreateDir", $dir); + $this->error = $langs->trans("ErrorCanNotCreateDir", $dir); return 0; } } else { - $this->error=$langs->trans("ErrorConstantNotDefined", "DON_OUTPUTDIR"); + $this->error = $langs->trans("ErrorConstantNotDefined", "DON_OUTPUTDIR"); return 0; } } @@ -288,147 +288,147 @@ class html_cerfafr extends ModeleDon $unite = array(); $dix = array(); $cent = array(); - if(empty($devise1)) $dev1='euros'; - else $dev1=$devise1; - if(empty($devise2)) $dev2='centimes'; - else $dev2=$devise2; - $valeur_entiere=intval($montant); - $valeur_decimal=intval(round($montant-intval($montant), 2)*100); - $dix_c=intval($valeur_decimal%100/10); - $cent_c=intval($valeur_decimal%1000/100); - $unite[1]=$valeur_entiere%10; - $dix[1]=intval($valeur_entiere%100/10); - $cent[1]=intval($valeur_entiere%1000/100); - $unite[2]=intval($valeur_entiere%10000/1000); - $dix[2]=intval($valeur_entiere%100000/10000); - $cent[2]=intval($valeur_entiere%1000000/100000); - $unite[3]=intval($valeur_entiere%10000000/1000000); - $dix[3]=intval($valeur_entiere%100000000/10000000); - $cent[3]=intval($valeur_entiere%1000000000/100000000); - $chif=array('', 'un', 'deux', 'trois', 'quatre', 'cinq', 'six', 'sept', 'huit', 'neuf', 'dix', 'onze', 'douze', 'treize', 'quatorze', 'quinze', 'seize', 'dix sept', 'dix huit', 'dix neuf'); - $secon_c=''; - $trio_c=''; - for($i=1; $i<=3; $i++) { - $prim[$i]=''; - $secon[$i]=''; - $trio[$i]=''; - if ($dix[$i]==0) { - $secon[$i]=''; - $prim[$i]=$chif[$unite[$i]]; + if (empty($devise1)) $dev1 = 'euros'; + else $dev1 = $devise1; + if (empty($devise2)) $dev2 = 'centimes'; + else $dev2 = $devise2; + $valeur_entiere = intval($montant); + $valeur_decimal = intval(round($montant - intval($montant), 2) * 100); + $dix_c = intval($valeur_decimal % 100 / 10); + $cent_c = intval($valeur_decimal % 1000 / 100); + $unite[1] = $valeur_entiere % 10; + $dix[1] = intval($valeur_entiere % 100 / 10); + $cent[1] = intval($valeur_entiere % 1000 / 100); + $unite[2] = intval($valeur_entiere % 10000 / 1000); + $dix[2] = intval($valeur_entiere % 100000 / 10000); + $cent[2] = intval($valeur_entiere % 1000000 / 100000); + $unite[3] = intval($valeur_entiere % 10000000 / 1000000); + $dix[3] = intval($valeur_entiere % 100000000 / 10000000); + $cent[3] = intval($valeur_entiere % 1000000000 / 100000000); + $chif = array('', 'un', 'deux', 'trois', 'quatre', 'cinq', 'six', 'sept', 'huit', 'neuf', 'dix', 'onze', 'douze', 'treize', 'quatorze', 'quinze', 'seize', 'dix sept', 'dix huit', 'dix neuf'); + $secon_c = ''; + $trio_c = ''; + for ($i = 1; $i <= 3; $i++) { + $prim[$i] = ''; + $secon[$i] = ''; + $trio[$i] = ''; + if ($dix[$i] == 0) { + $secon[$i] = ''; + $prim[$i] = $chif[$unite[$i]]; } - elseif ($dix[$i]==1) { - $secon[$i]=''; - $prim[$i]=$chif[($unite[$i]+10)]; + elseif ($dix[$i] == 1) { + $secon[$i] = ''; + $prim[$i] = $chif[($unite[$i] + 10)]; } - elseif ($dix[$i]==2) { - if ($unite[$i]==1) { - $secon[$i]='vingt et'; - $prim[$i]=$chif[$unite[$i]]; + elseif ($dix[$i] == 2) { + if ($unite[$i] == 1) { + $secon[$i] = 'vingt et'; + $prim[$i] = $chif[$unite[$i]]; } else { - $secon[$i]='vingt'; - $prim[$i]=$chif[$unite[$i]]; + $secon[$i] = 'vingt'; + $prim[$i] = $chif[$unite[$i]]; } } - elseif ($dix[$i]==3) { - if ($unite[$i]==1) { - $secon[$i]='trente et'; - $prim[$i]=$chif[$unite[$i]]; + elseif ($dix[$i] == 3) { + if ($unite[$i] == 1) { + $secon[$i] = 'trente et'; + $prim[$i] = $chif[$unite[$i]]; } else { - $secon[$i]='trente'; - $prim[$i]=$chif[$unite[$i]]; + $secon[$i] = 'trente'; + $prim[$i] = $chif[$unite[$i]]; } } - elseif ($dix[$i]==4) { - if ($unite[$i]==1) { - $secon[$i]='quarante et'; - $prim[$i]=$chif[$unite[$i]]; + elseif ($dix[$i] == 4) { + if ($unite[$i] == 1) { + $secon[$i] = 'quarante et'; + $prim[$i] = $chif[$unite[$i]]; } else { - $secon[$i]='quarante'; - $prim[$i]=$chif[$unite[$i]]; + $secon[$i] = 'quarante'; + $prim[$i] = $chif[$unite[$i]]; } } - elseif ($dix[$i]==5) { - if ($unite[$i]==1) { - $secon[$i]='cinquante et'; - $prim[$i]=$chif[$unite[$i]]; + elseif ($dix[$i] == 5) { + if ($unite[$i] == 1) { + $secon[$i] = 'cinquante et'; + $prim[$i] = $chif[$unite[$i]]; } else { - $secon[$i]='cinquante'; - $prim[$i]=$chif[$unite[$i]]; + $secon[$i] = 'cinquante'; + $prim[$i] = $chif[$unite[$i]]; } } - elseif ($dix[$i]==6) { - if ($unite[$i]==1) { - $secon[$i]='soixante et'; - $prim[$i]=$chif[$unite[$i]]; + elseif ($dix[$i] == 6) { + if ($unite[$i] == 1) { + $secon[$i] = 'soixante et'; + $prim[$i] = $chif[$unite[$i]]; } else { - $secon[$i]='soixante'; - $prim[$i]=$chif[$unite[$i]]; + $secon[$i] = 'soixante'; + $prim[$i] = $chif[$unite[$i]]; } } - elseif ($dix[$i]==7) { - if ($unite[$i]==1) { - $secon[$i]='soixante et'; - $prim[$i]=$chif[$unite[$i]+10]; + elseif ($dix[$i] == 7) { + if ($unite[$i] == 1) { + $secon[$i] = 'soixante et'; + $prim[$i] = $chif[$unite[$i] + 10]; } else { - $secon[$i]='soixante'; - $prim[$i]=$chif[$unite[$i]+10]; + $secon[$i] = 'soixante'; + $prim[$i] = $chif[$unite[$i] + 10]; } } - elseif ($dix[$i]==8) { - if ($unite[$i]==1) { - $secon[$i]='quatre-vingts et'; - $prim[$i]=$chif[$unite[$i]]; + elseif ($dix[$i] == 8) { + if ($unite[$i] == 1) { + $secon[$i] = 'quatre-vingts et'; + $prim[$i] = $chif[$unite[$i]]; } else { - $secon[$i]='quatre-vingt'; - $prim[$i]=$chif[$unite[$i]]; + $secon[$i] = 'quatre-vingt'; + $prim[$i] = $chif[$unite[$i]]; } } - elseif ($dix[$i]==9) { - if ($unite[$i]==1) { - $secon[$i]='quatre-vingts et'; - $prim[$i]=$chif[$unite[$i]+10]; + elseif ($dix[$i] == 9) { + if ($unite[$i] == 1) { + $secon[$i] = 'quatre-vingts et'; + $prim[$i] = $chif[$unite[$i] + 10]; } else { - $secon[$i]='quatre-vingts'; - $prim[$i]=$chif[$unite[$i]+10]; + $secon[$i] = 'quatre-vingts'; + $prim[$i] = $chif[$unite[$i] + 10]; } } - if($cent[$i]==1) $trio[$i]='cent'; - elseif($cent[$i]!=0 || $cent[$i]!='') $trio[$i]=$chif[$cent[$i]] .' cents'; + if ($cent[$i] == 1) $trio[$i] = 'cent'; + elseif ($cent[$i] != 0 || $cent[$i] != '') $trio[$i] = $chif[$cent[$i]].' cents'; } - $chif2=array('', 'dix', 'vingt', 'trente', 'quarante', 'cinquante', 'soixante', 'soixante-dix', 'quatre-vingts', 'quatre-vingts dix'); - $secon_c=$chif2[$dix_c]; - if ($cent_c==1) $trio_c='cent'; - elseif ($cent_c!=0 || $cent_c!='') $trio_c=$chif[$cent_c] .' cents'; + $chif2 = array('', 'dix', 'vingt', 'trente', 'quarante', 'cinquante', 'soixante', 'soixante-dix', 'quatre-vingts', 'quatre-vingts dix'); + $secon_c = $chif2[$dix_c]; + if ($cent_c == 1) $trio_c = 'cent'; + elseif ($cent_c != 0 || $cent_c != '') $trio_c = $chif[$cent_c].' cents'; - if (($cent[3]==0 || $cent[3]=='') && ($dix[3]==0 || $dix[3]=='') && ($unite[3]==1)) - $somme = $trio[3]. ' ' .$secon[3]. ' ' . $prim[3]. ' million '; - elseif (($cent[3]!=0 && $cent[3]!='') || ($dix[3]!=0 && $dix[3]!='') || ($unite[3]!=0 && $unite[3]!='')) - $somme = $trio[3]. ' ' .$secon[3]. ' ' . $prim[3]. ' millions '; + if (($cent[3] == 0 || $cent[3] == '') && ($dix[3] == 0 || $dix[3] == '') && ($unite[3] == 1)) + $somme = $trio[3].' '.$secon[3].' '.$prim[3].' million '; + elseif (($cent[3] != 0 && $cent[3] != '') || ($dix[3] != 0 && $dix[3] != '') || ($unite[3] != 0 && $unite[3] != '')) + $somme = $trio[3].' '.$secon[3].' '.$prim[3].' millions '; else - $somme = $trio[3]. ' ' .$secon[3]. ' ' . $prim[3]; + $somme = $trio[3].' '.$secon[3].' '.$prim[3]; - if (($cent[2]==0 || $cent[2]=='') && ($dix[2]==0 || $dix[2]=='') && ($unite[2]==1)) + if (($cent[2] == 0 || $cent[2] == '') && ($dix[2] == 0 || $dix[2] == '') && ($unite[2] == 1)) $somme = $somme.' mille '; - elseif (($cent[2]!=0 && $cent[2]!='') || ($dix[2]!=0 && $dix[2]!='') || ($unite[2]!=0 && $unite[2]!='')) - $somme = $somme. $trio[2]. ' ' .$secon[2]. ' ' . $prim[2]. ' milles '; + elseif (($cent[2] != 0 && $cent[2] != '') || ($dix[2] != 0 && $dix[2] != '') || ($unite[2] != 0 && $unite[2] != '')) + $somme = $somme.$trio[2].' '.$secon[2].' '.$prim[2].' milles '; else - $somme = $somme. $trio[2]. ' ' .$secon[2]. ' ' . $prim[2]; + $somme = $somme.$trio[2].' '.$secon[2].' '.$prim[2]; - $somme = $somme. $trio[1]. ' ' .$secon[1]. ' ' . $prim[1]; + $somme = $somme.$trio[1].' '.$secon[1].' '.$prim[1]; - $somme = $somme. ' '. $dev1 .' ' ; + $somme = $somme.' '.$dev1.' '; - if (($cent_c=='0' || $cent_c=='') && ($dix_c=='0' || $dix_c=='')) - return $somme. ' et zéro '. $dev2; + if (($cent_c == '0' || $cent_c == '') && ($dix_c == '0' || $dix_c == '')) + return $somme.' et zéro '.$dev2; else - return $somme. $trio_c. ' ' .$secon_c. ' ' . $dev2; + return $somme.$trio_c.' '.$secon_c.' '.$dev2; } } diff --git a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php index 6e8918920a6..7154fcc5836 100644 --- a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php +++ b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php @@ -494,7 +494,7 @@ class pdf_crabe extends ModelePDFFactures $curY = $tab_top_newpage; // Allows data in the first page if description is long enough to break in multiples pages - if(!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE)) + if (!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE)) $showpricebeforepagebreak = 1; else $showpricebeforepagebreak = 0; @@ -539,7 +539,7 @@ class pdf_crabe extends ModelePDFFactures // We found a page break // Allows data in the first page if description is long enough to break in multiples pages - if(!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE)) + if (!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE)) $showpricebeforepagebreak = 1; else $showpricebeforepagebreak = 0; @@ -1051,15 +1051,15 @@ class pdf_crabe extends ModelePDFFactures $pdf->MultiCell(80, 5, $lib_mode_reg, 0, 'L'); // Show online payment link - $useonlinepayment = ((! empty($conf->paypal->enabled) || ! empty($conf->stripe->enabled) || ! empty($conf->paybox->enabled)) && !empty($conf->global->PDF_SHOW_LINK_TO_ONLINE_PAYMENT)); + $useonlinepayment = ((!empty($conf->paypal->enabled) || !empty($conf->stripe->enabled) || !empty($conf->paybox->enabled)) && !empty($conf->global->PDF_SHOW_LINK_TO_ONLINE_PAYMENT)); if (($object->mode_reglement_code == 'CB' || $object->mode_reglement_code == 'VAD') && $object->statut != Facture::STATUS_DRAFT && $useonlinepayment) { require_once DOL_DOCUMENT_ROOT.'/core/lib/payments.lib.php'; global $langs; $langs->loadLangs(array('payment', 'paybox')); - $servicename=$langs->transnoentities('Online'); + $servicename = $langs->transnoentities('Online'); $paiement_url = getOnlinePaymentUrl('', 'invoice', $object->ref, '', '', ''); - $linktopay = $langs->trans("ToOfferALinkForOnlinePayment", $servicename).' '.$outputlangs->transnoentities("ClickHere").''; + $linktopay = $langs->trans("ToOfferALinkForOnlinePayment", $servicename).' '.$outputlangs->transnoentities("ClickHere").''; $pdf->writeHTMLCell(80, 10, '', '', dol_htmlentitiesbr($linktopay), 0, 1); } @@ -1707,27 +1707,27 @@ class pdf_crabe extends ModelePDFFactures $pdf->MultiCell($w, 3, $outputlangs->transnoentities("RefCustomer")." : ".$outputlangs->convToOutputCharset($object->ref_client), '', 'R'); } - if (! empty($conf->global->PDF_SHOW_PROJECT_TITLE)) + if (!empty($conf->global->PDF_SHOW_PROJECT_TITLE)) { $object->fetch_projet(); - if (! empty($object->project->ref)) + if (!empty($object->project->ref)) { - $posy+=3; + $posy += 3; $pdf->SetXY($posx, $posy); $pdf->SetTextColor(0, 0, 60); - $pdf->MultiCell($w, 3, $outputlangs->transnoentities("Project")." : " . (empty($object->project->title)?'':$object->projet->title), '', 'R'); + $pdf->MultiCell($w, 3, $outputlangs->transnoentities("Project")." : ".(empty($object->project->title) ? '' : $object->projet->title), '', 'R'); } } - if (! empty($conf->global->PDF_SHOW_PROJECT)) + if (!empty($conf->global->PDF_SHOW_PROJECT)) { $object->fetch_projet(); - if (! empty($object->project->ref)) + if (!empty($object->project->ref)) { - $posy+=3; + $posy += 3; $pdf->SetXY($posx, $posy); $pdf->SetTextColor(0, 0, 60); - $pdf->MultiCell($w, 3, $outputlangs->transnoentities("RefProject")." : " . (empty($object->project->ref)?'':$object->projet->ref), '', 'R'); + $pdf->MultiCell($w, 3, $outputlangs->transnoentities("RefProject")." : ".(empty($object->project->ref) ? '' : $object->projet->ref), '', 'R'); } } diff --git a/htdocs/core/modules/facture/doc/pdf_sponge.modules.php b/htdocs/core/modules/facture/doc/pdf_sponge.modules.php index a9d1230fdec..4fb6a55362e 100644 --- a/htdocs/core/modules/facture/doc/pdf_sponge.modules.php +++ b/htdocs/core/modules/facture/doc/pdf_sponge.modules.php @@ -1963,27 +1963,27 @@ class pdf_sponge extends ModelePDFFactures $pdf->MultiCell($w, 3, $outputlangs->transnoentities("RefCustomer")." : ".$outputlangs->convToOutputCharset($object->ref_client), '', 'R'); } - if (! empty($conf->global->PDF_SHOW_PROJECT_TITLE)) + if (!empty($conf->global->PDF_SHOW_PROJECT_TITLE)) { $object->fetch_projet(); - if (! empty($object->project->ref)) + if (!empty($object->project->ref)) { - $posy+=3; + $posy += 3; $pdf->SetXY($posx, $posy); $pdf->SetTextColor(0, 0, 60); - $pdf->MultiCell($w, 3, $outputlangs->transnoentities("Project")." : " . (empty($object->project->title)?'':$object->projet->title), '', 'R'); + $pdf->MultiCell($w, 3, $outputlangs->transnoentities("Project")." : ".(empty($object->project->title) ? '' : $object->projet->title), '', 'R'); } } - if (! empty($conf->global->PDF_SHOW_PROJECT)) + if (!empty($conf->global->PDF_SHOW_PROJECT)) { $object->fetch_projet(); - if (! empty($object->project->ref)) + if (!empty($object->project->ref)) { - $posy+=3; + $posy += 3; $pdf->SetXY($posx, $posy); $pdf->SetTextColor(0, 0, 60); - $pdf->MultiCell($w, 3, $outputlangs->transnoentities("RefProject")." : " . (empty($object->project->ref)?'':$object->projet->ref), '', 'R'); + $pdf->MultiCell($w, 3, $outputlangs->transnoentities("RefProject")." : ".(empty($object->project->ref) ? '' : $object->projet->ref), '', 'R'); } } diff --git a/htdocs/core/modules/modCategorie.class.php b/htdocs/core/modules/modCategorie.class.php index 7f92dcef6d6..61a4dd67d5c 100644 --- a/htdocs/core/modules/modCategorie.class.php +++ b/htdocs/core/modules/modCategorie.class.php @@ -24,7 +24,7 @@ * \ingroup category * \brief Fichier de description et activation du module Categorie */ -include_once DOL_DOCUMENT_ROOT .'/core/modules/DolibarrModules.class.php'; +include_once DOL_DOCUMENT_ROOT.'/core/modules/DolibarrModules.class.php'; /** @@ -64,11 +64,11 @@ class modCategorie extends DolibarrModules // Config pages $this->config_page_url = array('categorie.php@categories'); - $this->langfiles = array("products","companies","categories","members"); + $this->langfiles = array("products", "companies", "categories", "members"); // Constants $this->const = array(); - $r=0; + $r = 0; $this->const[$r][0] = "CATEGORIE_RECURSIV_ADD"; $this->const[$r][1] = "yesno"; $this->const[$r][2] = "0"; @@ -83,7 +83,7 @@ class modCategorie extends DolibarrModules $this->rights = array(); $this->rights_class = 'categorie'; - $r=0; + $r = 0; $this->rights[$r][0] = 241; // id de la permission $this->rights[$r][1] = 'Lire les categories'; // libelle de la permission @@ -109,115 +109,115 @@ class modCategorie extends DolibarrModules // Menus //------- - $this->menu = 1; // This module add menu entries. They are coded into menu manager. + $this->menu = 1; // This module add menu entries. They are coded into menu manager. // Exports //-------- - $r=0; + $r = 0; $r++; - $this->export_code[$r]='category_'.$r; - $this->export_label[$r]='CatSupList'; - $this->export_icon[$r]='category'; - $this->export_enabled[$r]='$conf->fournisseur->enabled'; - $this->export_permission[$r]=array(array("categorie","lire"),array("fournisseur","lire")); - $this->export_fields_array[$r]=array( - 'u.rowid'=>"CategId",'u.label'=>"Label",'u.description'=>"Description",'s.rowid'=>'IdThirdParty','s.nom'=>'Name','s.prefix_comm'=>"Prefix", - 's.client'=>"Customer",'s.datec'=>"DateCreation",'s.tms'=>"DateLastModification",'s.code_client'=>"CustomerCode",'s.address'=>"Address", - 's.zip'=>"Zip",'s.town'=>"Town",'c.label'=>"Country",'c.code'=>"CountryCode",'s.phone'=>"Phone",'s.fax'=>"Fax",'s.url'=>"Url",'s.email'=>"Email", - 's.siret'=>"ProfId1",'s.siren'=>"ProfId2",'s.ape'=>"ProfId3",'s.idprof4'=>"ProfId4",'s.tva_intra'=>"VATIntraShort",'s.capital'=>"Capital", + $this->export_code[$r] = 'category_'.$r; + $this->export_label[$r] = 'CatSupList'; + $this->export_icon[$r] = 'category'; + $this->export_enabled[$r] = '$conf->fournisseur->enabled'; + $this->export_permission[$r] = array(array("categorie", "lire"), array("fournisseur", "lire")); + $this->export_fields_array[$r] = array( + 'u.rowid'=>"CategId", 'u.label'=>"Label", 'u.description'=>"Description", 's.rowid'=>'IdThirdParty', 's.nom'=>'Name', 's.prefix_comm'=>"Prefix", + 's.client'=>"Customer", 's.datec'=>"DateCreation", 's.tms'=>"DateLastModification", 's.code_client'=>"CustomerCode", 's.address'=>"Address", + 's.zip'=>"Zip", 's.town'=>"Town", 'c.label'=>"Country", 'c.code'=>"CountryCode", 's.phone'=>"Phone", 's.fax'=>"Fax", 's.url'=>"Url", 's.email'=>"Email", + 's.siret'=>"ProfId1", 's.siren'=>"ProfId2", 's.ape'=>"ProfId3", 's.idprof4'=>"ProfId4", 's.tva_intra'=>"VATIntraShort", 's.capital'=>"Capital", 's.note_public'=>"NotePublic" ); - $this->export_TypeFields_array[$r]=array( - 'u.label'=>"Text",'u.description'=>"Text",'s.rowid'=>'List:societe:nom','s.nom'=>'Text','s.prefix_comm'=>"Text",'s.client'=>"Text",'s.datec'=>"Date", - 's.tms'=>"Date",'s.code_client'=>"Text",'s.address'=>"Text",'s.zip'=>"Text",'s.town'=>"Text",'c.label'=>"List:c_country:label:label",'c.code'=>"Text", - 's.phone'=>"Text",'s.fax'=>"Text",'s.url'=>"Text",'s.email'=>"Text",'s.siret'=>"Text",'s.siren'=>"Text",'s.ape'=>"Text",'s.idprof4'=>"Text", - 's.tva_intra'=>"Text",'s.capital'=>"Numeric",'s.note_public'=>"Text" + $this->export_TypeFields_array[$r] = array( + 'u.label'=>"Text", 'u.description'=>"Text", 's.rowid'=>'List:societe:nom', 's.nom'=>'Text', 's.prefix_comm'=>"Text", 's.client'=>"Text", 's.datec'=>"Date", + 's.tms'=>"Date", 's.code_client'=>"Text", 's.address'=>"Text", 's.zip'=>"Text", 's.town'=>"Text", 'c.label'=>"List:c_country:label:label", 'c.code'=>"Text", + 's.phone'=>"Text", 's.fax'=>"Text", 's.url'=>"Text", 's.email'=>"Text", 's.siret'=>"Text", 's.siren'=>"Text", 's.ape'=>"Text", 's.idprof4'=>"Text", + 's.tva_intra'=>"Text", 's.capital'=>"Numeric", 's.note_public'=>"Text" ); - $this->export_entities_array[$r]=array( - 's.rowid'=>'company','s.nom'=>'company','s.prefix_comm'=>"company",'s.client'=>"company",'s.datec'=>"company",'s.tms'=>"company", - 's.code_client'=>"company",'s.address'=>"company",'s.zip'=>"company",'s.town'=>"company",'c.label'=>"company",'c.code'=>"company", - 's.phone'=>"company",'s.fax'=>"company",'s.url'=>"company",'s.email'=>"company",'s.siret'=>"company",'s.siren'=>"company",'s.ape'=>"company", - 's.idprof4'=>"company",'s.tva_intra'=>"company",'s.capital'=>"company",'s.note_public'=>"company" - ); // We define here only fields that use another picto - $this->export_sql_start[$r]='SELECT DISTINCT '; - $this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'categorie as u, '; + $this->export_entities_array[$r] = array( + 's.rowid'=>'company', 's.nom'=>'company', 's.prefix_comm'=>"company", 's.client'=>"company", 's.datec'=>"company", 's.tms'=>"company", + 's.code_client'=>"company", 's.address'=>"company", 's.zip'=>"company", 's.town'=>"company", 'c.label'=>"company", 'c.code'=>"company", + 's.phone'=>"company", 's.fax'=>"company", 's.url'=>"company", 's.email'=>"company", 's.siret'=>"company", 's.siren'=>"company", 's.ape'=>"company", + 's.idprof4'=>"company", 's.tva_intra'=>"company", 's.capital'=>"company", 's.note_public'=>"company" + ); // We define here only fields that use another picto + $this->export_sql_start[$r] = 'SELECT DISTINCT '; + $this->export_sql_end[$r] = ' FROM '.MAIN_DB_PREFIX.'categorie as u, '; $this->export_sql_end[$r] .= MAIN_DB_PREFIX.'categorie_fournisseur as cf, '; $this->export_sql_end[$r] .= MAIN_DB_PREFIX.'societe as s LEFT JOIN '.MAIN_DB_PREFIX.'c_typent as t ON s.fk_typent = t.id LEFT JOIN '.MAIN_DB_PREFIX.'c_country as c ON s.fk_pays = c.rowid LEFT JOIN '.MAIN_DB_PREFIX.'c_effectif as ce ON s.fk_effectif = ce.id LEFT JOIN '.MAIN_DB_PREFIX.'c_forme_juridique as cfj ON s.fk_forme_juridique = cfj.code'; - $this->export_sql_end[$r] .=' WHERE u.rowid = cf.fk_categorie AND cf.fk_soc = s.rowid'; - $this->export_sql_end[$r] .=' AND u.entity IN ('.getEntity('category').')'; - $this->export_sql_end[$r] .=' AND u.type = 1'; // Supplier categories + $this->export_sql_end[$r] .= ' WHERE u.rowid = cf.fk_categorie AND cf.fk_soc = s.rowid'; + $this->export_sql_end[$r] .= ' AND u.entity IN ('.getEntity('category').')'; + $this->export_sql_end[$r] .= ' AND u.type = 1'; // Supplier categories $r++; - $this->export_code[$r]='category_'.$r; - $this->export_label[$r]='CatCusList'; - $this->export_icon[$r]='category'; - $this->export_enabled[$r]='$conf->societe->enabled'; - $this->export_permission[$r]=array(array("categorie","lire"),array("societe","lire")); - $this->export_fields_array[$r]=array( - 'u.rowid'=>"CategId",'u.label'=>"Label",'u.description'=>"Description",'s.rowid'=>'IdThirdParty','s.nom'=>'Name','s.prefix_comm'=>"Prefix", - 's.client'=>"Customer",'s.datec'=>"DateCreation",'s.tms'=>"DateLastModification",'s.code_client'=>"CustomerCode",'s.address'=>"Address", - 's.zip'=>"Zip",'s.town'=>"Town",'c.label'=>"Country",'c.code'=>"CountryCode",'s.phone'=>"Phone",'s.fax'=>"Fax",'s.url'=>"Url",'s.email'=>"Email", - 's.siret'=>"ProfId1",'s.siren'=>"ProfId2",'s.ape'=>"ProfId3",'s.idprof4'=>"ProfId4",'s.tva_intra'=>"VATIntraShort",'s.capital'=>"Capital", - 's.note_public'=>"NotePublic",'s.fk_prospectlevel'=>'ProspectLevel','s.fk_stcomm'=>'ProspectStatus' + $this->export_code[$r] = 'category_'.$r; + $this->export_label[$r] = 'CatCusList'; + $this->export_icon[$r] = 'category'; + $this->export_enabled[$r] = '$conf->societe->enabled'; + $this->export_permission[$r] = array(array("categorie", "lire"), array("societe", "lire")); + $this->export_fields_array[$r] = array( + 'u.rowid'=>"CategId", 'u.label'=>"Label", 'u.description'=>"Description", 's.rowid'=>'IdThirdParty', 's.nom'=>'Name', 's.prefix_comm'=>"Prefix", + 's.client'=>"Customer", 's.datec'=>"DateCreation", 's.tms'=>"DateLastModification", 's.code_client'=>"CustomerCode", 's.address'=>"Address", + 's.zip'=>"Zip", 's.town'=>"Town", 'c.label'=>"Country", 'c.code'=>"CountryCode", 's.phone'=>"Phone", 's.fax'=>"Fax", 's.url'=>"Url", 's.email'=>"Email", + 's.siret'=>"ProfId1", 's.siren'=>"ProfId2", 's.ape'=>"ProfId3", 's.idprof4'=>"ProfId4", 's.tva_intra'=>"VATIntraShort", 's.capital'=>"Capital", + 's.note_public'=>"NotePublic", 's.fk_prospectlevel'=>'ProspectLevel', 's.fk_stcomm'=>'ProspectStatus' ); - $this->export_TypeFields_array[$r]=array( - 'u.label'=>"Text",'u.description'=>"Text",'s.rowid'=>'List:societe:nom','s.nom'=>'Text','s.prefix_comm'=>"Text",'s.client'=>"Text", - 's.datec'=>"Date",'s.tms'=>"Date",'s.code_client'=>"Text",'s.address'=>"Text",'s.zip'=>"Text",'s.town'=>"Text",'c.label'=>"List:c_country:label:label", - 'c.code'=>"Text",'s.phone'=>"Text",'s.fax'=>"Text",'s.url'=>"Text",'s.email'=>"Text",'s.siret'=>"Text",'s.siren'=>"Text",'s.ape'=>"Text", - 's.idprof4'=>"Text",'s.tva_intra'=>"Text",'s.capital'=>"Numeric",'s.note_public'=>"Text",'s.fk_prospectlevel'=>'List:c_prospectlevel:label:code', + $this->export_TypeFields_array[$r] = array( + 'u.label'=>"Text", 'u.description'=>"Text", 's.rowid'=>'List:societe:nom', 's.nom'=>'Text', 's.prefix_comm'=>"Text", 's.client'=>"Text", + 's.datec'=>"Date", 's.tms'=>"Date", 's.code_client'=>"Text", 's.address'=>"Text", 's.zip'=>"Text", 's.town'=>"Text", 'c.label'=>"List:c_country:label:label", + 'c.code'=>"Text", 's.phone'=>"Text", 's.fax'=>"Text", 's.url'=>"Text", 's.email'=>"Text", 's.siret'=>"Text", 's.siren'=>"Text", 's.ape'=>"Text", + 's.idprof4'=>"Text", 's.tva_intra'=>"Text", 's.capital'=>"Numeric", 's.note_public'=>"Text", 's.fk_prospectlevel'=>'List:c_prospectlevel:label:code', 's.fk_stcomm'=>'List:c_stcomm:libelle:code' ); - $this->export_entities_array[$r]=array( - 's.rowid'=>'company','s.nom'=>'company','s.prefix_comm'=>"company",'s.client'=>"company",'s.datec'=>"company",'s.tms'=>"company", - 's.code_client'=>"company",'s.address'=>"company",'s.zip'=>"company",'s.town'=>"company",'c.label'=>"company",'c.code'=>"company", - 's.phone'=>"company",'s.fax'=>"company",'s.url'=>"company",'s.email'=>"company",'s.siret'=>"company",'s.siren'=>"company",'s.ape'=>"company", - 's.idprof4'=>"company",'s.tva_intra'=>"company",'s.capital'=>"company",'s.note_public'=>"company",'s.fk_prospectlevel'=>'company', + $this->export_entities_array[$r] = array( + 's.rowid'=>'company', 's.nom'=>'company', 's.prefix_comm'=>"company", 's.client'=>"company", 's.datec'=>"company", 's.tms'=>"company", + 's.code_client'=>"company", 's.address'=>"company", 's.zip'=>"company", 's.town'=>"company", 'c.label'=>"company", 'c.code'=>"company", + 's.phone'=>"company", 's.fax'=>"company", 's.url'=>"company", 's.email'=>"company", 's.siret'=>"company", 's.siren'=>"company", 's.ape'=>"company", + 's.idprof4'=>"company", 's.tva_intra'=>"company", 's.capital'=>"company", 's.note_public'=>"company", 's.fk_prospectlevel'=>'company', 's.fk_stcomm'=>'company' - ); // We define here only fields that use another picto - $this->export_sql_start[$r]='SELECT DISTINCT '; - $this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'categorie as u, '; + ); // We define here only fields that use another picto + $this->export_sql_start[$r] = 'SELECT DISTINCT '; + $this->export_sql_end[$r] = ' FROM '.MAIN_DB_PREFIX.'categorie as u, '; $this->export_sql_end[$r] .= MAIN_DB_PREFIX.'categorie_societe as cf, '; $this->export_sql_end[$r] .= MAIN_DB_PREFIX.'societe as s LEFT JOIN '.MAIN_DB_PREFIX.'c_typent as t ON s.fk_typent = t.id LEFT JOIN '.MAIN_DB_PREFIX.'c_country as c ON s.fk_pays = c.rowid LEFT JOIN '.MAIN_DB_PREFIX.'c_effectif as ce ON s.fk_effectif = ce.id LEFT JOIN '.MAIN_DB_PREFIX.'c_forme_juridique as cfj ON s.fk_forme_juridique = cfj.code LEFT JOIN '.MAIN_DB_PREFIX.'societe_extrafields as extra ON s.rowid = extra.fk_object '; - $this->export_sql_end[$r] .=' WHERE u.rowid = cf.fk_categorie AND cf.fk_soc = s.rowid'; - $this->export_sql_end[$r] .=' AND u.entity IN ('.getEntity('category').')'; - $this->export_sql_end[$r] .=' AND u.type = 2'; // Customer/Prospect categories + $this->export_sql_end[$r] .= ' WHERE u.rowid = cf.fk_categorie AND cf.fk_soc = s.rowid'; + $this->export_sql_end[$r] .= ' AND u.entity IN ('.getEntity('category').')'; + $this->export_sql_end[$r] .= ' AND u.type = 2'; // Customer/Prospect categories // Add extra fields - $sql="SELECT name, label, type, param FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'societe' AND entity IN (0, ".$conf->entity.")"; - $resql=$this->db->query($sql); + $sql = "SELECT name, label, type, param FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'societe' AND entity IN (0, ".$conf->entity.")"; + $resql = $this->db->query($sql); if ($resql) // This can fail when class is used on old database (during migration for example) { - while ($obj=$this->db->fetch_object($resql)) + while ($obj = $this->db->fetch_object($resql)) { - $fieldname='extra.'.$obj->name; - $fieldlabel=ucfirst($obj->label); - $typeFilter="Text"; - switch($obj->type) + $fieldname = 'extra.'.$obj->name; + $fieldlabel = ucfirst($obj->label); + $typeFilter = "Text"; + switch ($obj->type) { case 'int': case 'double': case 'price': - $typeFilter="Numeric"; + $typeFilter = "Numeric"; break; case 'date': case 'datetime': - $typeFilter="Date"; + $typeFilter = "Date"; break; case 'boolean': - $typeFilter="Boolean"; + $typeFilter = "Boolean"; break; case 'sellist': - $typeFilter="List:".$obj->param; + $typeFilter = "List:".$obj->param; break; case 'select': - $typeFilter="Select:".$obj->param; + $typeFilter = "Select:".$obj->param; break; } - $this->export_fields_array[$r][$fieldname]=$fieldlabel; - $this->export_TypeFields_array[$r][$fieldname]=$typeFilter; - $this->export_entities_array[$r][$fieldname]='company'; + $this->export_fields_array[$r][$fieldname] = $fieldlabel; + $this->export_TypeFields_array[$r][$fieldname] = $typeFilter; + $this->export_entities_array[$r][$fieldname] = 'company'; } } // End add axtra fields @@ -227,42 +227,42 @@ class modCategorie extends DolibarrModules $r++; - $this->export_code[$r]='category_'.$r; - $this->export_label[$r]='CatProdList'; - $this->export_icon[$r]='category'; - $this->export_enabled[$r]='$conf->product->enabled || $conf->service->enabled'; - $this->export_permission[$r]=array(array("categorie","lire"),array("produit","lire")); - $this->export_fields_array[$r]=array('u.rowid'=>"CategId",'u.label'=>"Label",'u.description'=>"Description",'p.rowid'=>'ProductId','p.ref'=>'Ref'); - $this->export_TypeFields_array[$r]=array('u.label'=>"Text",'u.description'=>"Text",'p.ref'=>'Text'); - $this->export_entities_array[$r]=array('p.rowid'=>'product','p.ref'=>'product'); // We define here only fields that use another picto - $this->export_sql_start[$r]='SELECT DISTINCT '; - $this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'categorie as u, '.MAIN_DB_PREFIX.'categorie_product as cp, '.MAIN_DB_PREFIX.'product as p'; - $this->export_sql_end[$r] .=' WHERE u.rowid = cp.fk_categorie AND cp.fk_product = p.rowid'; - $this->export_sql_end[$r] .=' AND u.entity IN ('.getEntity('category').')'; - $this->export_sql_end[$r] .=' AND u.type = 0'; // Supplier categories + $this->export_code[$r] = 'category_'.$r; + $this->export_label[$r] = 'CatProdList'; + $this->export_icon[$r] = 'category'; + $this->export_enabled[$r] = '$conf->product->enabled || $conf->service->enabled'; + $this->export_permission[$r] = array(array("categorie", "lire"), array("produit", "lire")); + $this->export_fields_array[$r] = array('u.rowid'=>"CategId", 'u.label'=>"Label", 'u.description'=>"Description", 'p.rowid'=>'ProductId', 'p.ref'=>'Ref'); + $this->export_TypeFields_array[$r] = array('u.label'=>"Text", 'u.description'=>"Text", 'p.ref'=>'Text'); + $this->export_entities_array[$r] = array('p.rowid'=>'product', 'p.ref'=>'product'); // We define here only fields that use another picto + $this->export_sql_start[$r] = 'SELECT DISTINCT '; + $this->export_sql_end[$r] = ' FROM '.MAIN_DB_PREFIX.'categorie as u, '.MAIN_DB_PREFIX.'categorie_product as cp, '.MAIN_DB_PREFIX.'product as p'; + $this->export_sql_end[$r] .= ' WHERE u.rowid = cp.fk_categorie AND cp.fk_product = p.rowid'; + $this->export_sql_end[$r] .= ' AND u.entity IN ('.getEntity('category').')'; + $this->export_sql_end[$r] .= ' AND u.type = 0'; // Supplier categories $r++; - $this->export_code[$r]='category_'.$r; - $this->export_label[$r]='CatMemberList'; - $this->export_icon[$r]='category'; - $this->export_enabled[$r]='$conf->adherent->enabled'; - $this->export_permission[$r]=array(array("categorie","lire"),array("adherent","lire")); - $this->export_fields_array[$r]=array('u.rowid'=>"CategId",'u.label'=>"Label",'u.description'=>"Description",'p.rowid'=>'MemberId','p.lastname'=>'LastName','p.firstname'=>'Firstname'); - $this->export_TypeFields_array[$r]=array('u.label'=>"Text",'u.description'=>"Text",'p.lastname'=>'Text','p.firstname'=>'Text'); - $this->export_entities_array[$r]=array('p.rowid'=>'member','p.lastname'=>'member','p.firstname'=>'member'); // We define here only fields that use another picto - $this->export_sql_start[$r]='SELECT DISTINCT '; - $this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'categorie as u, '.MAIN_DB_PREFIX.'categorie_member as cp, '.MAIN_DB_PREFIX.'adherent as p'; - $this->export_sql_end[$r] .=' WHERE u.rowid = cp.fk_categorie AND cp.fk_member = p.rowid'; - $this->export_sql_end[$r] .=' AND u.entity IN ('.getEntity('category').')'; - $this->export_sql_end[$r] .=' AND u.type = 3'; // Member categories + $this->export_code[$r] = 'category_'.$r; + $this->export_label[$r] = 'CatMemberList'; + $this->export_icon[$r] = 'category'; + $this->export_enabled[$r] = '$conf->adherent->enabled'; + $this->export_permission[$r] = array(array("categorie", "lire"), array("adherent", "lire")); + $this->export_fields_array[$r] = array('u.rowid'=>"CategId", 'u.label'=>"Label", 'u.description'=>"Description", 'p.rowid'=>'MemberId', 'p.lastname'=>'LastName', 'p.firstname'=>'Firstname'); + $this->export_TypeFields_array[$r] = array('u.label'=>"Text", 'u.description'=>"Text", 'p.lastname'=>'Text', 'p.firstname'=>'Text'); + $this->export_entities_array[$r] = array('p.rowid'=>'member', 'p.lastname'=>'member', 'p.firstname'=>'member'); // We define here only fields that use another picto + $this->export_sql_start[$r] = 'SELECT DISTINCT '; + $this->export_sql_end[$r] = ' FROM '.MAIN_DB_PREFIX.'categorie as u, '.MAIN_DB_PREFIX.'categorie_member as cp, '.MAIN_DB_PREFIX.'adherent as p'; + $this->export_sql_end[$r] .= ' WHERE u.rowid = cp.fk_categorie AND cp.fk_member = p.rowid'; + $this->export_sql_end[$r] .= ' AND u.entity IN ('.getEntity('category').')'; + $this->export_sql_end[$r] .= ' AND u.type = 3'; // Member categories $r++; - $this->export_code[$r]='category_'.$r; - $this->export_label[$r]='CatContactList'; - $this->export_icon[$r]='category'; - $this->export_enabled[$r]='$conf->societe->enabled'; - $this->export_permission[$r]=array(array("categorie", "lire"), array ("societe", "lire")); - $this->export_fields_array[$r]=array ( + $this->export_code[$r] = 'category_'.$r; + $this->export_label[$r] = 'CatContactList'; + $this->export_icon[$r] = 'category'; + $this->export_enabled[$r] = '$conf->societe->enabled'; + $this->export_permission[$r] = array(array("categorie", "lire"), array("societe", "lire")); + $this->export_fields_array[$r] = array( 'u.rowid' => "CategId", 'u.label' => "Label", 'u.description' => "Description", @@ -297,7 +297,7 @@ class modCategorie extends DolibarrModules 's.url'=>"Url", 's.email'=>"Email" ); - $this->export_TypeFields_array[$r] = array ( + $this->export_TypeFields_array[$r] = array( 'u.label' => "Text", 'u.description' => "Text", 'p.lastname' => 'Text', @@ -313,7 +313,7 @@ class modCategorie extends DolibarrModules 's.url'=>"Text", 's.email'=>"Text" ); - $this->export_entities_array[$r] = array ( + $this->export_entities_array[$r] = array( 'u.rowid' => "category", 'u.label' => "category", 'u.description' => "category", @@ -350,67 +350,67 @@ class modCategorie extends DolibarrModules ); // We define here only fields that use another picto // Add extra fields - $sql="SELECT name, label, type, param FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'socpeople' AND entity IN (0, ".$conf->entity.")"; - $resql=$this->db->query($sql); + $sql = "SELECT name, label, type, param FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'socpeople' AND entity IN (0, ".$conf->entity.")"; + $resql = $this->db->query($sql); if ($resql) // This can fail when class is used on old database (during migration for example) { - while ($obj=$this->db->fetch_object($resql)) + while ($obj = $this->db->fetch_object($resql)) { - $fieldname='extra.'.$obj->name; - $fieldlabel=ucfirst($obj->label); - $typeFilter="Text"; - switch($obj->type) + $fieldname = 'extra.'.$obj->name; + $fieldlabel = ucfirst($obj->label); + $typeFilter = "Text"; + switch ($obj->type) { case 'int': case 'double': case 'price': - $typeFilter="Numeric"; + $typeFilter = "Numeric"; break; case 'date': case 'datetime': - $typeFilter="Date"; + $typeFilter = "Date"; break; case 'boolean': - $typeFilter="Boolean"; + $typeFilter = "Boolean"; break; case 'sellist': - $typeFilter="List:".$obj->param; + $typeFilter = "List:".$obj->param; break; case 'select': - $typeFilter="Select:".$obj->param; + $typeFilter = "Select:".$obj->param; break; } - $this->export_fields_array[$r][$fieldname]=$fieldlabel; - $this->export_TypeFields_array[$r][$fieldname]=$typeFilter; - $this->export_entities_array[$r][$fieldname]='contact'; + $this->export_fields_array[$r][$fieldname] = $fieldlabel; + $this->export_TypeFields_array[$r][$fieldname] = $typeFilter; + $this->export_entities_array[$r][$fieldname] = 'contact'; } } // End add axtra fields $this->export_sql_start[$r] = 'SELECT DISTINCT '; - $this->export_sql_end[$r] = ' FROM ' . MAIN_DB_PREFIX . 'categorie as u, '.MAIN_DB_PREFIX . 'categorie_contact as cp, '.MAIN_DB_PREFIX . 'socpeople as p'; - $this->export_sql_end[$r] .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'c_country as country ON p.fk_pays = country.rowid'; - $this->export_sql_end[$r] .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'societe as s ON s.rowid = p.fk_soc'; - $this->export_sql_end[$r] .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'socpeople_extrafields as extra ON extra.fk_object = p.rowid'; + $this->export_sql_end[$r] = ' FROM '.MAIN_DB_PREFIX.'categorie as u, '.MAIN_DB_PREFIX.'categorie_contact as cp, '.MAIN_DB_PREFIX.'socpeople as p'; + $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_country as country ON p.fk_pays = country.rowid'; + $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe as s ON s.rowid = p.fk_soc'; + $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'socpeople_extrafields as extra ON extra.fk_object = p.rowid'; $this->export_sql_end[$r] .= ' WHERE u.rowid = cp.fk_categorie AND cp.fk_socpeople = p.rowid AND u.entity IN ('.getEntity('category').')'; $this->export_sql_end[$r] .= ' AND u.type = 4'; // contact categories // Imports //-------- - $r=0; + $r = 0; $r++; - $this->import_code[$r]=$this->rights_class.'_'.$r; - $this->import_label[$r]="CatList"; // Translation key - $this->import_icon[$r]=$this->picto; - $this->import_entities_array[$r]=array(); // We define here only fields that use another icon that the one defined into import_icon - $this->import_tables_array[$r]=array('ca'=>MAIN_DB_PREFIX.'categorie'); - $this->import_fields_array[$r]=array( - 'ca.label'=>"Label*",'ca.type'=>"Type*",'ca.description'=>"Description", + $this->import_code[$r] = $this->rights_class.'_'.$r; + $this->import_label[$r] = "CatList"; // Translation key + $this->import_icon[$r] = $this->picto; + $this->import_entities_array[$r] = array(); // We define here only fields that use another icon that the one defined into import_icon + $this->import_tables_array[$r] = array('ca'=>MAIN_DB_PREFIX.'categorie'); + $this->import_fields_array[$r] = array( + 'ca.label'=>"Label*", 'ca.type'=>"Type*", 'ca.description'=>"Description", 'ca.fk_parent' => 'Parent' ); - $this->import_regex_array[$r]=array('ca.type'=>'^[0|1|2|3]'); + $this->import_regex_array[$r] = array('ca.type'=>'^[0|1|2|3]'); $this->import_convertvalue_array[$r] = array( 'ca.fk_parent' => array( 'rule' => 'fetchidfromcodeandlabel', @@ -421,96 +421,96 @@ class modCategorie extends DolibarrModules 'codefromfield' => 'ca.type' ) ); - $typeexample=""; - if ($conf->product->enabled) { $typeexample.=($typeexample?"/":"")."0=Product"; } - if ($conf->fournisseur->enabled) { $typeexample.=($typeexample?"/":"")."1=Supplier"; } - if ($conf->societe->enabled) { $typeexample.=($typeexample?"/":"")."2=Customer-Prospect"; } - if ($conf->adherent->enabled) { $typeexample.=($typeexample?"/":"")."3=Member"; } + $typeexample = ""; + if ($conf->product->enabled) { $typeexample .= ($typeexample ? "/" : "")."0=Product"; } + if ($conf->fournisseur->enabled) { $typeexample .= ($typeexample ? "/" : "")."1=Supplier"; } + if ($conf->societe->enabled) { $typeexample .= ($typeexample ? "/" : "")."2=Customer-Prospect"; } + if ($conf->adherent->enabled) { $typeexample .= ($typeexample ? "/" : "")."3=Member"; } $this->import_examplevalues_array[$r] = array( - 'ca.label'=>"Supplier Category",'ca.type'=>$typeexample,'ca.description'=>"My Category description", + 'ca.label'=>"Supplier Category", 'ca.type'=>$typeexample, 'ca.description'=>"My Category description", 'ca.fk_parent' => '0' ); - if (! empty($conf->product->enabled)) + if (!empty($conf->product->enabled)) { //Products $r++; - $this->import_code[$r]=$this->rights_class.'_'.$r; - $this->import_label[$r]="CatProdLinks"; // Translation key - $this->import_icon[$r]=$this->picto; - $this->import_entities_array[$r]=array(); // We define here only fields that use another icon that the one defined into import_icon - $this->import_tables_array[$r]=array('cp'=>MAIN_DB_PREFIX.'categorie_product'); - $this->import_fields_array[$r]=array('cp.fk_categorie'=>"Category*",'cp.fk_product'=>"Product*"); - $this->import_regex_array[$r]=array('cp.fk_categorie'=>'rowid@'.MAIN_DB_PREFIX.'categorie:type=0'); + $this->import_code[$r] = $this->rights_class.'_'.$r; + $this->import_label[$r] = "CatProdLinks"; // Translation key + $this->import_icon[$r] = $this->picto; + $this->import_entities_array[$r] = array(); // We define here only fields that use another icon that the one defined into import_icon + $this->import_tables_array[$r] = array('cp'=>MAIN_DB_PREFIX.'categorie_product'); + $this->import_fields_array[$r] = array('cp.fk_categorie'=>"Category*", 'cp.fk_product'=>"Product*"); + $this->import_regex_array[$r] = array('cp.fk_categorie'=>'rowid@'.MAIN_DB_PREFIX.'categorie:type=0'); - $this->import_convertvalue_array[$r]=array( - 'cp.fk_categorie'=>array('rule'=>'fetchidfromref','classfile'=>'/categories/class/categorie.class.php','class'=>'Categorie','method'=>'fetch','element'=>'category'), - 'cp.fk_product'=>array('rule'=>'fetchidfromref','classfile'=>'/product/class/product.class.php','class'=>'Product','method'=>'fetch','element'=>'product') + $this->import_convertvalue_array[$r] = array( + 'cp.fk_categorie'=>array('rule'=>'fetchidfromref', 'classfile'=>'/categories/class/categorie.class.php', 'class'=>'Categorie', 'method'=>'fetch', 'element'=>'category'), + 'cp.fk_product'=>array('rule'=>'fetchidfromref', 'classfile'=>'/product/class/product.class.php', 'class'=>'Product', 'method'=>'fetch', 'element'=>'product') ); - $this->import_examplevalues_array[$r]=array('cp.fk_categorie'=>"Imported category",'cp.fk_product'=>"PREF123456"); + $this->import_examplevalues_array[$r] = array('cp.fk_categorie'=>"Imported category", 'cp.fk_product'=>"PREF123456"); } - if (! empty($conf->societe->enabled)) + if (!empty($conf->societe->enabled)) { // Customers $r++; - $this->import_code[$r]=$this->rights_class.'_'.$r; - $this->import_label[$r]="CatCusLinks"; // Translation key - $this->import_icon[$r]=$this->picto; - $this->import_entities_array[$r]=array(); // We define here only fields that use another icon that the one defined into import_icon - $this->import_tables_array[$r]=array('cs'=>MAIN_DB_PREFIX.'categorie_societe'); - $this->import_fields_array[$r]=array('cs.fk_categorie'=>"Category*",'cs.fk_soc'=>"ThirdParty*"); - $this->import_regex_array[$r]=array( + $this->import_code[$r] = $this->rights_class.'_'.$r; + $this->import_label[$r] = "CatCusLinks"; // Translation key + $this->import_icon[$r] = $this->picto; + $this->import_entities_array[$r] = array(); // We define here only fields that use another icon that the one defined into import_icon + $this->import_tables_array[$r] = array('cs'=>MAIN_DB_PREFIX.'categorie_societe'); + $this->import_fields_array[$r] = array('cs.fk_categorie'=>"Category*", 'cs.fk_soc'=>"ThirdParty*"); + $this->import_regex_array[$r] = array( 'cs.fk_categorie'=>'rowid@'.MAIN_DB_PREFIX.'categorie:type=2', 'cs.fk_soc'=>'rowid@'.MAIN_DB_PREFIX.'societe:client>0' ); - $this->import_convertvalue_array[$r]=array( - 'cs.fk_categorie'=>array('rule'=>'fetchidfromref','classfile'=>'/categories/class/categorie.class.php','class'=>'Categorie','method'=>'fetch','element'=>'category'), - 'cs.fk_soc'=>array('rule'=>'fetchidfromref','classfile'=>'/societe/class/societe.class.php','class'=>'Societe','method'=>'fetch','element'=>'ThirdParty') + $this->import_convertvalue_array[$r] = array( + 'cs.fk_categorie'=>array('rule'=>'fetchidfromref', 'classfile'=>'/categories/class/categorie.class.php', 'class'=>'Categorie', 'method'=>'fetch', 'element'=>'category'), + 'cs.fk_soc'=>array('rule'=>'fetchidfromref', 'classfile'=>'/societe/class/societe.class.php', 'class'=>'Societe', 'method'=>'fetch', 'element'=>'ThirdParty') ); - $this->import_examplevalues_array[$r]=array('cs.fk_categorie'=>"Imported category",'cs.fk_soc'=>"MyBigCompany"); + $this->import_examplevalues_array[$r] = array('cs.fk_categorie'=>"Imported category", 'cs.fk_soc'=>"MyBigCompany"); // Contacts/Addresses $r++; - $this->import_code[$r]=$this->rights_class.'_'.$r; - $this->import_label[$r]="CatContactsLinks"; // Translation key - $this->import_icon[$r]=$this->picto; - $this->import_entities_array[$r]=array(); // We define here only fields that use another icon that the one defined into import_icon - $this->import_tables_array[$r]=array('cs'=>MAIN_DB_PREFIX.'categorie_contact'); - $this->import_fields_array[$r]=array('cs.fk_categorie'=>"Category*",'cs.fk_socpeople'=>"Contact ID*"); - $this->import_regex_array[$r]=array( + $this->import_code[$r] = $this->rights_class.'_'.$r; + $this->import_label[$r] = "CatContactsLinks"; // Translation key + $this->import_icon[$r] = $this->picto; + $this->import_entities_array[$r] = array(); // We define here only fields that use another icon that the one defined into import_icon + $this->import_tables_array[$r] = array('cs'=>MAIN_DB_PREFIX.'categorie_contact'); + $this->import_fields_array[$r] = array('cs.fk_categorie'=>"Category*", 'cs.fk_socpeople'=>"Contact ID*"); + $this->import_regex_array[$r] = array( 'cs.fk_categorie'=>'rowid@'.MAIN_DB_PREFIX.'categorie:type=4' //'cs.fk_socpeople'=>'rowid@'.MAIN_DB_PREFIX.'socpeople' ); - $this->import_convertvalue_array[$r]=array( - 'cs.fk_categorie'=>array('rule'=>'fetchidfromref','classfile'=>'/categories/class/categorie.class.php','class'=>'Categorie','method'=>'fetch','element'=>'category') + $this->import_convertvalue_array[$r] = array( + 'cs.fk_categorie'=>array('rule'=>'fetchidfromref', 'classfile'=>'/categories/class/categorie.class.php', 'class'=>'Categorie', 'method'=>'fetch', 'element'=>'category') //'cs.fk_socpeople'=>array('rule'=>'fetchidfromref','classfile'=>'/contact/class/contact.class.php','class'=>'Contact','method'=>'fetch','element'=>'Contact') ); - $this->import_examplevalues_array[$r]=array('cs.fk_categorie'=>"Imported category",'cs.fk_socpeople'=>"123"); + $this->import_examplevalues_array[$r] = array('cs.fk_categorie'=>"Imported category", 'cs.fk_socpeople'=>"123"); } - if (! empty($conf->fournisseur->enabled)) + if (!empty($conf->fournisseur->enabled)) { // Suppliers $r++; - $this->import_code[$r]=$this->rights_class.'_'.$r; - $this->import_label[$r]="CatSupLinks"; // Translation key - $this->import_icon[$r]=$this->picto; - $this->import_entities_array[$r]=array(); // We define here only fields that use another icon that the one defined into import_icon - $this->import_tables_array[$r]=array('cs'=>MAIN_DB_PREFIX.'categorie_fournisseur'); - $this->import_fields_array[$r]=array('cs.fk_categorie'=>"Category*",'cs.fk_soc'=>"Supplier*"); - $this->import_regex_array[$r]=array( + $this->import_code[$r] = $this->rights_class.'_'.$r; + $this->import_label[$r] = "CatSupLinks"; // Translation key + $this->import_icon[$r] = $this->picto; + $this->import_entities_array[$r] = array(); // We define here only fields that use another icon that the one defined into import_icon + $this->import_tables_array[$r] = array('cs'=>MAIN_DB_PREFIX.'categorie_fournisseur'); + $this->import_fields_array[$r] = array('cs.fk_categorie'=>"Category*", 'cs.fk_soc'=>"Supplier*"); + $this->import_regex_array[$r] = array( 'cs.fk_categorie'=>'rowid@'.MAIN_DB_PREFIX.'categorie:type=1', 'cs.fk_soc'=>'rowid@'.MAIN_DB_PREFIX.'societe:fournisseur>0' ); - $this->import_convertvalue_array[$r]=array( - 'cs.fk_categorie'=>array('rule'=>'fetchidfromref','classfile'=>'/categories/class/categorie.class.php','class'=>'Categorie','method'=>'fetch','element'=>'category'), - 'cs.fk_soc'=>array('rule'=>'fetchidfromref','classfile'=>'/societe/class/societe.class.php','class'=>'Societe','method'=>'fetch','element'=>'ThirdParty') + $this->import_convertvalue_array[$r] = array( + 'cs.fk_categorie'=>array('rule'=>'fetchidfromref', 'classfile'=>'/categories/class/categorie.class.php', 'class'=>'Categorie', 'method'=>'fetch', 'element'=>'category'), + 'cs.fk_soc'=>array('rule'=>'fetchidfromref', 'classfile'=>'/societe/class/societe.class.php', 'class'=>'Societe', 'method'=>'fetch', 'element'=>'ThirdParty') ); - $this->import_examplevalues_array[$r]=array('cs.fk_categorie'=>"Imported category",'cs.fk_soc'=>"MyBigCompany"); + $this->import_examplevalues_array[$r] = array('cs.fk_categorie'=>"Imported category", 'cs.fk_soc'=>"MyBigCompany"); } } diff --git a/htdocs/core/modules/modProjet.class.php b/htdocs/core/modules/modProjet.class.php index aa68fdeb698..77d339da035 100644 --- a/htdocs/core/modules/modProjet.class.php +++ b/htdocs/core/modules/modProjet.class.php @@ -28,7 +28,7 @@ * \ingroup projet * \brief Fichier de description et activation du module Projet */ -include_once DOL_DOCUMENT_ROOT .'/core/modules/DolibarrModules.class.php'; +include_once DOL_DOCUMENT_ROOT.'/core/modules/DolibarrModules.class.php'; /** @@ -58,22 +58,22 @@ class modProjet extends DolibarrModules $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); $this->config_page_url = array("project.php@projet"); - $this->picto='project'; + $this->picto = 'project'; // Data directories to create when module is enabled $this->dirs = array("/projet/temp"); // Dependencies - $this->hidden = false; // A condition to hide module - $this->depends = array(); // List of module class names as string that must be enabled if this module is enabled - $this->requiredby = array(); // List of module ids to disable if this one is disabled - $this->conflictwith = array(); // List of module class names as string this module is in conflict with - $this->phpmin = array(5,4); // Minimum version of PHP required by module + $this->hidden = false; // A condition to hide module + $this->depends = array(); // List of module class names as string that must be enabled if this module is enabled + $this->requiredby = array(); // List of module ids to disable if this one is disabled + $this->conflictwith = array(); // List of module class names as string this module is in conflict with + $this->phpmin = array(5, 4); // Minimum version of PHP required by module $this->langfiles = array('projects'); // Constants $this->const = array(); - $r=0; + $r = 0; $this->const[$r][0] = "PROJECT_ADDON_PDF"; $this->const[$r][1] = "chaine"; @@ -139,7 +139,7 @@ class modProjet extends DolibarrModules // Boxes $this->boxes = array(); - $r=0; + $r = 0; $this->boxes[$r][1] = "box_project.php"; $r++; $this->boxes[$r][1] = "box_task.php"; @@ -148,7 +148,7 @@ class modProjet extends DolibarrModules // Permissions $this->rights = array(); $this->rights_class = 'projet'; - $r=0; + $r = 0; $r++; $this->rights[$r][0] = 41; // id de la permission @@ -205,43 +205,43 @@ class modProjet extends DolibarrModules // Menus //------- - $this->menu = 1; // This module add menu entries. They are coded into menu manager. + $this->menu = 1; // This module add menu entries. They are coded into menu manager. //Exports //-------- - $r=1; + $r = 1; - $this->export_code[$r]=$this->rights_class.'_'.$r; - $this->export_label[$r]='ProjectsAndTasksLines'; // Translation key (used only if key ExportDataset_xxx_z not found) - $this->export_permission[$r]=array(array("projet","export")); - $this->export_dependencies_array[$r]=array('projecttask'=>'pt.rowid', 'task_time'=>'ptt.rowid'); + $this->export_code[$r] = $this->rights_class.'_'.$r; + $this->export_label[$r] = 'ProjectsAndTasksLines'; // Translation key (used only if key ExportDataset_xxx_z not found) + $this->export_permission[$r] = array(array("projet", "export")); + $this->export_dependencies_array[$r] = array('projecttask'=>'pt.rowid', 'task_time'=>'ptt.rowid'); - $this->export_TypeFields_array[$r]=array( - 's.rowid'=>"List:societe:nom::thirdparty",'s.nom'=>'Text','s.address'=>'Text','s.zip'=>'Text','s.town'=>'Text','s.fk_pays'=>'List:c_country:label', - 's.phone'=>'Text','s.email'=>'Text','s.siren'=>'Text','s.siret'=>'Text','s.ape'=>'Text','s.idprof4'=>'Text','s.code_compta'=>'Text','s.code_compta_fournisseur'=>'Text', - 'p.rowid'=>"List:projet:ref::project",'p.ref'=>"Text",'p.title'=>"Text", + $this->export_TypeFields_array[$r] = array( + 's.rowid'=>"List:societe:nom::thirdparty", 's.nom'=>'Text', 's.address'=>'Text', 's.zip'=>'Text', 's.town'=>'Text', 's.fk_pays'=>'List:c_country:label', + 's.phone'=>'Text', 's.email'=>'Text', 's.siren'=>'Text', 's.siret'=>'Text', 's.ape'=>'Text', 's.idprof4'=>'Text', 's.code_compta'=>'Text', 's.code_compta_fournisseur'=>'Text', + 'p.rowid'=>"List:projet:ref::project", 'p.ref'=>"Text", 'p.title'=>"Text", 'p.usage_opportunity'=>'Boolean', 'p.usage_task'=>'Boolean', 'p.usage_bill_time'=>'Boolean', - 'p.datec'=>"Date",'p.dateo'=>"Date",'p.datee'=>"Date",'p.fk_statut'=>'Status','cls.code'=>"Text",'p.opp_percent'=>'Numeric','p.opp_amount'=>'Numeric','p.description'=>"Text",'p.entity'=>'Numeric', - 'pt.rowid'=>'Numeric','pt.ref'=>'Text','pt.label'=>'Text','pt.dateo'=>"Date",'pt.datee'=>"Date",'pt.duration_effective'=>"Duree",'pt.planned_workload'=>"Numeric",'pt.progress'=>"Numeric",'pt.description'=>"Text", - 'ptt.rowid'=>'Numeric','ptt.task_date'=>'Date','ptt.task_duration'=>"Duree",'ptt.fk_user'=>"List:user:CONCAT(lastname,' ',firstname)",'ptt.note'=>"Text" + 'p.datec'=>"Date", 'p.dateo'=>"Date", 'p.datee'=>"Date", 'p.fk_statut'=>'Status', 'cls.code'=>"Text", 'p.opp_percent'=>'Numeric', 'p.opp_amount'=>'Numeric', 'p.description'=>"Text", 'p.entity'=>'Numeric', + 'pt.rowid'=>'Numeric', 'pt.ref'=>'Text', 'pt.label'=>'Text', 'pt.dateo'=>"Date", 'pt.datee'=>"Date", 'pt.duration_effective'=>"Duree", 'pt.planned_workload'=>"Numeric", 'pt.progress'=>"Numeric", 'pt.description'=>"Text", + 'ptt.rowid'=>'Numeric', 'ptt.task_date'=>'Date', 'ptt.task_duration'=>"Duree", 'ptt.fk_user'=>"List:user:CONCAT(lastname,' ',firstname)", 'ptt.note'=>"Text" ); - $this->export_entities_array[$r]=array( - 's.rowid'=>"company",'s.nom'=>'company','s.address'=>'company','s.zip'=>'company','s.town'=>'company','s.fk_pays'=>'company', - 's.phone'=>'company','s.email'=>'company','s.siren'=>'company','s.siret'=>'company','s.ape'=>'company','s.idprof4'=>'company','s.code_compta'=>'company','s.code_compta_fournisseur'=>'company' + $this->export_entities_array[$r] = array( + 's.rowid'=>"company", 's.nom'=>'company', 's.address'=>'company', 's.zip'=>'company', 's.town'=>'company', 's.fk_pays'=>'company', + 's.phone'=>'company', 's.email'=>'company', 's.siren'=>'company', 's.siret'=>'company', 's.ape'=>'company', 's.idprof4'=>'company', 's.code_compta'=>'company', 's.code_compta_fournisseur'=>'company' ); - $this->export_fields_array[$r]=array( - 's.rowid'=>"IdCompany",'s.nom'=>'CompanyName','s.address'=>'Address','s.zip'=>'Zip','s.town'=>'Town','s.fk_pays'=>'Country', - 's.phone'=>'Phone','s.email'=>'Email','s.siren'=>'ProfId1','s.siret'=>'ProfId2','s.ape'=>'ProfId3','s.idprof4'=>'ProfId4','s.code_compta'=>'CustomerAccountancyCode','s.code_compta_fournisseur'=>'SupplierAccountancyCode', - 'p.rowid'=>"ProjectId",'p.ref'=>"RefProject",'p.title'=>'ProjectLabel', + $this->export_fields_array[$r] = array( + 's.rowid'=>"IdCompany", 's.nom'=>'CompanyName', 's.address'=>'Address', 's.zip'=>'Zip', 's.town'=>'Town', 's.fk_pays'=>'Country', + 's.phone'=>'Phone', 's.email'=>'Email', 's.siren'=>'ProfId1', 's.siret'=>'ProfId2', 's.ape'=>'ProfId3', 's.idprof4'=>'ProfId4', 's.code_compta'=>'CustomerAccountancyCode', 's.code_compta_fournisseur'=>'SupplierAccountancyCode', + 'p.rowid'=>"ProjectId", 'p.ref'=>"RefProject", 'p.title'=>'ProjectLabel', 'p.usage_opportunity'=>'ProjectFollowOpportunity', 'p.usage_task'=>'ProjectFollowTasks', 'p.usage_bill_time'=>'BillTime', - 'p.datec'=>"DateCreation",'p.dateo'=>"DateStart",'p.datee'=>"DateEnd",'p.fk_statut'=>'ProjectStatus','cls.code'=>'OpportunityStatus','p.opp_percent'=>'OpportunityProbability','p.opp_amount'=>'OpportunityAmount','p.description'=>"Description" + 'p.datec'=>"DateCreation", 'p.dateo'=>"DateStart", 'p.datee'=>"DateEnd", 'p.fk_statut'=>'ProjectStatus', 'cls.code'=>'OpportunityStatus', 'p.opp_percent'=>'OpportunityProbability', 'p.opp_amount'=>'OpportunityAmount', 'p.description'=>"Description" ); // Add multicompany field - if (! empty($conf->global->MULTICOMPANY_ENTITY_IN_EXPORT_IF_SHARED)) + if (!empty($conf->global->MULTICOMPANY_ENTITY_IN_EXPORT_IF_SHARED)) { - $nbofallowedentities=count(explode(',', getEntity('project'))); // If project are shared, nb will be > 1 - if (! empty($conf->multicompany->enabled) && $nbofallowedentities > 1) $this->export_fields_array[$r]+=array('p.entity'=>'Entity'); + $nbofallowedentities = count(explode(',', getEntity('project'))); // If project are shared, nb will be > 1 + if (!empty($conf->multicompany->enabled) && $nbofallowedentities > 1) $this->export_fields_array[$r] += array('p.entity'=>'Entity'); } if (empty($conf->global->PROJECT_USE_OPPORTUNITIES)) { @@ -251,68 +251,68 @@ class modProjet extends DolibarrModules } // Add fields for project - $this->export_fields_array[$r]=array_merge($this->export_fields_array[$r], array()); + $this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array()); // Add extra fields for project - $keyforselect='projet'; $keyforelement='project'; $keyforaliasextra='extra'; + $keyforselect = 'projet'; $keyforelement = 'project'; $keyforaliasextra = 'extra'; include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php'; // Add fields for tasks - $this->export_fields_array[$r]=array_merge($this->export_fields_array[$r], array('pt.rowid'=>'TaskId', 'pt.ref'=>'RefTask', 'pt.label'=>'LabelTask', 'pt.dateo'=>"TaskDateStart", 'pt.datee'=>"TaskDateEnd", 'pt.duration_effective'=>"DurationEffective", 'pt.planned_workload'=>"PlannedWorkload", 'pt.progress'=>"Progress", 'pt.description'=>"TaskDescription")); - $this->export_entities_array[$r]=array_merge($this->export_entities_array[$r], array('pt.rowid'=>'projecttask', 'pt.ref'=>'projecttask', 'pt.label'=>'projecttask', 'pt.dateo'=>"projecttask", 'pt.datee'=>"projecttask", 'pt.duration_effective'=>"projecttask", 'pt.planned_workload'=>"projecttask", 'pt.progress'=>"projecttask", 'pt.description'=>"projecttask")); + $this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array('pt.rowid'=>'TaskId', 'pt.ref'=>'RefTask', 'pt.label'=>'LabelTask', 'pt.dateo'=>"TaskDateStart", 'pt.datee'=>"TaskDateEnd", 'pt.duration_effective'=>"DurationEffective", 'pt.planned_workload'=>"PlannedWorkload", 'pt.progress'=>"Progress", 'pt.description'=>"TaskDescription")); + $this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array('pt.rowid'=>'projecttask', 'pt.ref'=>'projecttask', 'pt.label'=>'projecttask', 'pt.dateo'=>"projecttask", 'pt.datee'=>"projecttask", 'pt.duration_effective'=>"projecttask", 'pt.planned_workload'=>"projecttask", 'pt.progress'=>"projecttask", 'pt.description'=>"projecttask")); // Add extra fields for task - $keyforselect='projet_task'; $keyforelement='projecttask'; $keyforaliasextra='extra2'; + $keyforselect = 'projet_task'; $keyforelement = 'projecttask'; $keyforaliasextra = 'extra2'; include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php'; // End add extra fields - $this->export_fields_array[$r]=array_merge($this->export_fields_array[$r], array('ptt.rowid'=>'IdTaskTime','ptt.task_date'=>'TaskTimeDate','ptt.task_duration'=>"TimesSpent",'ptt.fk_user'=>"TaskTimeUser",'ptt.note'=>"TaskTimeNote")); - $this->export_entities_array[$r]=array_merge($this->export_entities_array[$r], array('ptt.rowid'=>'task_time','ptt.task_date'=>'task_time','ptt.task_duration'=>"task_time",'ptt.fk_user'=>"task_time",'ptt.note'=>"task_time")); + $this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array('ptt.rowid'=>'IdTaskTime', 'ptt.task_date'=>'TaskTimeDate', 'ptt.task_duration'=>"TimesSpent", 'ptt.fk_user'=>"TaskTimeUser", 'ptt.note'=>"TaskTimeNote")); + $this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array('ptt.rowid'=>'task_time', 'ptt.task_date'=>'task_time', 'ptt.task_duration'=>"task_time", 'ptt.fk_user'=>"task_time", 'ptt.note'=>"task_time")); if (empty($conf->global->PROJECT_HIDE_TASKS)) { - $this->export_fields_array[$r]=array_merge($this->export_fields_array[$r], array('f.ref'=>"Billed")); - $this->export_entities_array[$r]=array_merge($this->export_entities_array[$r], array('f.ref'=>"task_time")); + $this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array('f.ref'=>"Billed")); + $this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array('f.ref'=>"task_time")); } - $this->export_sql_start[$r]='SELECT DISTINCT '; - $this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'projet as p'; - $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'projet_extrafields as extra ON p.rowid = extra.fk_object'; - $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_lead_status as cls ON p.fk_opp_status = cls.rowid'; - $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX."projet_task as pt ON p.rowid = pt.fk_projet"; - $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'projet_task_extrafields as extra2 ON pt.rowid = extra2.fk_object'; - $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX."projet_task_time as ptt ON pt.rowid = ptt.fk_task"; - $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'societe as s ON p.fk_soc = s.rowid'; + $this->export_sql_start[$r] = 'SELECT DISTINCT '; + $this->export_sql_end[$r] = ' FROM '.MAIN_DB_PREFIX.'projet as p'; + $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'projet_extrafields as extra ON p.rowid = extra.fk_object'; + $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_lead_status as cls ON p.fk_opp_status = cls.rowid'; + $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX."projet_task as pt ON p.rowid = pt.fk_projet"; + $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'projet_task_extrafields as extra2 ON pt.rowid = extra2.fk_object'; + $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX."projet_task_time as ptt ON pt.rowid = ptt.fk_task"; + $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe as s ON p.fk_soc = s.rowid'; if (empty($conf->global->PROJECT_HIDE_TASKS)) { - $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'facture as f ON ptt.invoice_id = f.rowid'; + $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'facture as f ON ptt.invoice_id = f.rowid'; } - $this->export_sql_end[$r] .=" WHERE p.entity IN (".getEntity('project').")"; + $this->export_sql_end[$r] .= " WHERE p.entity IN (".getEntity('project').")"; // Import list of tasks if (empty($conf->global->PROJECT_HIDE_TASKS)) { $r++; - $this->import_code[$r]='tasksofprojects'; - $this->import_label[$r]='ImportDatasetTasks'; - $this->import_icon[$r]='task'; - $this->import_entities_array[$r]=array('t.fk_projet'=>'project'); // We define here only fields that use another icon that the one defined into import_icon - $this->import_tables_array[$r]=array('t'=>MAIN_DB_PREFIX.'projet_task','extra'=>MAIN_DB_PREFIX.'projet_task_extrafields'); // List of tables to insert into (insert done in same order) - $this->import_fields_array[$r]=array('t.fk_projet'=>'ProjectRef*','t.ref'=>'RefTask*','t.label'=>'LabelTask*','t.dateo'=>"DateStart",'t.datee'=>"DateEnd",'t.planned_workload'=>"PlannedWorkload",'t.progress'=>"Progress",'t.note_private'=>"NotePrivate",'t.note_public'=>"NotePublic",'t.datec'=>"DateCreation"); + $this->import_code[$r] = 'tasksofprojects'; + $this->import_label[$r] = 'ImportDatasetTasks'; + $this->import_icon[$r] = 'task'; + $this->import_entities_array[$r] = array('t.fk_projet'=>'project'); // We define here only fields that use another icon that the one defined into import_icon + $this->import_tables_array[$r] = array('t'=>MAIN_DB_PREFIX.'projet_task', 'extra'=>MAIN_DB_PREFIX.'projet_task_extrafields'); // List of tables to insert into (insert done in same order) + $this->import_fields_array[$r] = array('t.fk_projet'=>'ProjectRef*', 't.ref'=>'RefTask*', 't.label'=>'LabelTask*', 't.dateo'=>"DateStart", 't.datee'=>"DateEnd", 't.planned_workload'=>"PlannedWorkload", 't.progress'=>"Progress", 't.note_private'=>"NotePrivate", 't.note_public'=>"NotePublic", 't.datec'=>"DateCreation"); // Add extra fields - $sql="SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'projet_task' AND entity IN (0,".$conf->entity.")"; - $resql=$this->db->query($sql); + $sql = "SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'projet_task' AND entity IN (0,".$conf->entity.")"; + $resql = $this->db->query($sql); if ($resql) // This can fail when class is used on old database (during migration for example) { - while ($obj=$this->db->fetch_object($resql)) + while ($obj = $this->db->fetch_object($resql)) { - $fieldname='extra.'.$obj->name; - $fieldlabel=ucfirst($obj->label); - $this->import_fields_array[$r][$fieldname]=$fieldlabel.($obj->fieldrequired?'*':''); + $fieldname = 'extra.'.$obj->name; + $fieldlabel = ucfirst($obj->label); + $this->import_fields_array[$r][$fieldname] = $fieldlabel.($obj->fieldrequired ? '*' : ''); } } // End add extra fields - $this->import_fieldshidden_array[$r]=array('t.fk_user_creat'=>'user->id','extra.fk_object'=>'lastrowid-'.MAIN_DB_PREFIX.'projet_task'); // aliastable.field => ('user->id' or 'lastrowid-'.tableparent) - $this->import_convertvalue_array[$r]=array( - 't.fk_projet'=>array('rule'=>'fetchidfromref','classfile'=>'/projet/class/project.class.php','class'=>'Project','method'=>'fetch','element'=>'Project'), + $this->import_fieldshidden_array[$r] = array('t.fk_user_creat'=>'user->id', 'extra.fk_object'=>'lastrowid-'.MAIN_DB_PREFIX.'projet_task'); // aliastable.field => ('user->id' or 'lastrowid-'.tableparent) + $this->import_convertvalue_array[$r] = array( + 't.fk_projet'=>array('rule'=>'fetchidfromref', 'classfile'=>'/projet/class/project.class.php', 'class'=>'Project', 'method'=>'fetch', 'element'=>'Project'), 't.ref'=>array('rule'=>'getrefifauto') ); //$this->import_convertvalue_array[$r]=array('s.fk_soc'=>array('rule'=>'lastrowid',table='t'); - $this->import_regex_array[$r]=array('t.dateo'=>'^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]$','t.datee'=>'^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]$','t.datec'=>'^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]( [0-9][0-9]:[0-9][0-9]:[0-9][0-9])?$'); - $this->import_examplevalues_array[$r]=array('t.fk_projet'=>'MyProjectRef','t.ref'=>"auto or TK2010-1234",'t.label'=>"My task",'t.progress'=>"0 (not started) to 100 (finished)",'t.datec'=>'1972-10-10','t.note_private'=>"My private note",'t.note_public'=>"My public note"); + $this->import_regex_array[$r] = array('t.dateo'=>'^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]$', 't.datee'=>'^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]$', 't.datec'=>'^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]( [0-9][0-9]:[0-9][0-9]:[0-9][0-9])?$'); + $this->import_examplevalues_array[$r] = array('t.fk_projet'=>'MyProjectRef', 't.ref'=>"auto or TK2010-1234", 't.label'=>"My task", 't.progress'=>"0 (not started) to 100 (finished)", 't.datec'=>'1972-10-10', 't.note_private'=>"My private note", 't.note_public'=>"My public note"); } } @@ -327,54 +327,54 @@ class modProjet extends DolibarrModules */ public function init($options = '') { - global $conf,$langs; + global $conf, $langs; // Permissions $this->remove($options); //ODT template for project - $src=DOL_DOCUMENT_ROOT.'/install/doctemplates/projects/template_project.odt'; - $dirodt=DOL_DATA_ROOT.'/doctemplates/projects'; - $dest=$dirodt.'/template_project.odt'; + $src = DOL_DOCUMENT_ROOT.'/install/doctemplates/projects/template_project.odt'; + $dirodt = DOL_DATA_ROOT.'/doctemplates/projects'; + $dest = $dirodt.'/template_project.odt'; - if (file_exists($src) && ! file_exists($dest)) + if (file_exists($src) && !file_exists($dest)) { require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; dol_mkdir($dirodt); - $result=dol_copy($src, $dest, 0, 0); + $result = dol_copy($src, $dest, 0, 0); if ($result < 0) { $langs->load("errors"); - $this->error=$langs->trans('ErrorFailToCopyFile', $src, $dest); + $this->error = $langs->trans('ErrorFailToCopyFile', $src, $dest); return 0; } } //ODT template for tasks - $src=DOL_DOCUMENT_ROOT.'/install/doctemplates/tasks/template_task_summary.odt'; - $dirodt=DOL_DATA_ROOT.'/doctemplates/tasks'; - $dest=$dirodt.'/template_task_summary.odt'; + $src = DOL_DOCUMENT_ROOT.'/install/doctemplates/tasks/template_task_summary.odt'; + $dirodt = DOL_DATA_ROOT.'/doctemplates/tasks'; + $dest = $dirodt.'/template_task_summary.odt'; - if (file_exists($src) && ! file_exists($dest)) + if (file_exists($src) && !file_exists($dest)) { require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; dol_mkdir($dirodt); - $result=dol_copy($src, $dest, 0, 0); + $result = dol_copy($src, $dest, 0, 0); if ($result < 0) { $langs->load("errors"); - $this->error=$langs->trans('ErrorFailToCopyFile', $src, $dest); + $this->error = $langs->trans('ErrorFailToCopyFile', $src, $dest); return 0; } } $sql = array(); - $sql[] ="DELETE FROM ".MAIN_DB_PREFIX."document_model WHERE nom = '".$this->db->escape($this->const[3][2])."' AND type = 'task' AND entity = ".$conf->entity; - $sql[] ="INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('".$this->db->escape($this->const[3][2])."','task',".$conf->entity.")"; - $sql[] ="DELETE FROM ".MAIN_DB_PREFIX."document_model WHERE nom = 'beluga' AND type = 'project' AND entity = ".$conf->entity; - $sql[] ="INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('beluga','project',".$conf->entity.")"; - $sql[] ="DELETE FROM ".MAIN_DB_PREFIX."document_model WHERE nom = 'baleine' AND type = 'project' AND entity = ".$conf->entity; - $sql[] ="INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('baleine','project',".$conf->entity.")"; + $sql[] = "DELETE FROM ".MAIN_DB_PREFIX."document_model WHERE nom = '".$this->db->escape($this->const[3][2])."' AND type = 'task' AND entity = ".$conf->entity; + $sql[] = "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('".$this->db->escape($this->const[3][2])."','task',".$conf->entity.")"; + $sql[] = "DELETE FROM ".MAIN_DB_PREFIX."document_model WHERE nom = 'beluga' AND type = 'project' AND entity = ".$conf->entity; + $sql[] = "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('beluga','project',".$conf->entity.")"; + $sql[] = "DELETE FROM ".MAIN_DB_PREFIX."document_model WHERE nom = 'baleine' AND type = 'project' AND entity = ".$conf->entity; + $sql[] = "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('baleine','project',".$conf->entity.")"; return $this->_init($sql, $options); diff --git a/htdocs/core/modules/propale/doc/pdf_azur.modules.php b/htdocs/core/modules/propale/doc/pdf_azur.modules.php index 3810ad67237..0167d900b3f 100644 --- a/htdocs/core/modules/propale/doc/pdf_azur.modules.php +++ b/htdocs/core/modules/propale/doc/pdf_azur.modules.php @@ -502,7 +502,7 @@ class pdf_azur extends ModelePDFPropales $curY = $tab_top_newpage; // Allows data in the first page if description is long enough to break in multiples pages - if(!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE)) + if (!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE)) $showpricebeforepagebreak = 1; else $showpricebeforepagebreak = 0; @@ -548,7 +548,7 @@ class pdf_azur extends ModelePDFPropales // We found a page break // Allows data in the first page if description is long enough to break in multiples pages - if(!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE)) + if (!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE)) $showpricebeforepagebreak = 1; else $showpricebeforepagebreak = 0; @@ -1101,28 +1101,28 @@ class pdf_azur extends ModelePDFPropales //Local tax 1 before VAT //if (! empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION=='localtax1on') //{ - foreach($this->localtax1 as $localtax_type => $localtax_rate) + foreach ($this->localtax1 as $localtax_type => $localtax_rate) { - if (in_array((string) $localtax_type, array('1','3','5'))) continue; + if (in_array((string) $localtax_type, array('1', '3', '5'))) continue; - foreach($localtax_rate as $tvakey => $tvaval) + foreach ($localtax_rate as $tvakey => $tvaval) { - if ($tvakey!=0) // On affiche pas taux 0 + if ($tvakey != 0) // On affiche pas taux 0 { //$this->atleastoneratenotnull++; $index++; $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); - $tvacompl=''; + $tvacompl = ''; if (preg_match('/\*/', $tvakey)) { - $tvakey=str_replace('*', '', $tvakey); + $tvakey = str_replace('*', '', $tvakey); $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")"; } $totalvat = $outputlangs->transcountrynoentities("TotalLT1", $mysoc->country_code).' '; - $totalvat.=vatrate(abs($tvakey), 1).$tvacompl; - $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1); + $totalvat .= vatrate(abs($tvakey), 1).$tvacompl; + $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1); $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1); @@ -1133,13 +1133,13 @@ class pdf_azur extends ModelePDFPropales //Local tax 2 before VAT //if (! empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION=='localtax2on') //{ - foreach($this->localtax2 as $localtax_type => $localtax_rate) + foreach ($this->localtax2 as $localtax_type => $localtax_rate) { - if (in_array((string) $localtax_type, array('1','3','5'))) continue; + if (in_array((string) $localtax_type, array('1', '3', '5'))) continue; - foreach($localtax_rate as $tvakey => $tvaval) + foreach ($localtax_rate as $tvakey => $tvaval) { - if ($tvakey!=0) // On affiche pas taux 0 + if ($tvakey != 0) // On affiche pas taux 0 { //$this->atleastoneratenotnull++; @@ -1148,15 +1148,15 @@ class pdf_azur extends ModelePDFPropales $index++; $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); - $tvacompl=''; + $tvacompl = ''; if (preg_match('/\*/', $tvakey)) { - $tvakey=str_replace('*', '', $tvakey); + $tvakey = str_replace('*', '', $tvakey); $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")"; } $totalvat = $outputlangs->transcountrynoentities("TotalLT2", $mysoc->country_code).' '; - $totalvat.=vatrate(abs($tvakey), 1).$tvacompl; - $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1); + $totalvat .= vatrate(abs($tvakey), 1).$tvacompl; + $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1); $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1); @@ -1192,11 +1192,11 @@ class pdf_azur extends ModelePDFPropales //Local tax 1 after VAT //if (! empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION=='localtax1on') //{ - foreach($this->localtax1 as $localtax_type => $localtax_rate) + foreach ($this->localtax1 as $localtax_type => $localtax_rate) { - if (in_array((string) $localtax_type, array('2','4','6'))) continue; + if (in_array((string) $localtax_type, array('2', '4', '6'))) continue; - foreach($localtax_rate as $tvakey => $tvaval) + foreach ($localtax_rate as $tvakey => $tvaval) { if ($tvakey != 0) // On affiche pas taux 0 { @@ -1205,16 +1205,16 @@ class pdf_azur extends ModelePDFPropales $index++; $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); - $tvacompl=''; + $tvacompl = ''; if (preg_match('/\*/', $tvakey)) { - $tvakey=str_replace('*', '', $tvakey); + $tvakey = str_replace('*', '', $tvakey); $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")"; } $totalvat = $outputlangs->transcountrynoentities("TotalLT1", $mysoc->country_code).' '; - $totalvat.=vatrate(abs($tvakey), 1).$tvacompl; - $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1); + $totalvat .= vatrate(abs($tvakey), 1).$tvacompl; + $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1); $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1); } @@ -1224,11 +1224,11 @@ class pdf_azur extends ModelePDFPropales //Local tax 2 after VAT //if (! empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION=='localtax2on') //{ - foreach($this->localtax2 as $localtax_type => $localtax_rate) + foreach ($this->localtax2 as $localtax_type => $localtax_rate) { - if (in_array((string) $localtax_type, array('2','4','6'))) continue; + if (in_array((string) $localtax_type, array('2', '4', '6'))) continue; - foreach($localtax_rate as $tvakey => $tvaval) + foreach ($localtax_rate as $tvakey => $tvaval) { // retrieve global local tax if ($tvakey != 0) // On affiche pas taux 0 @@ -1238,16 +1238,16 @@ class pdf_azur extends ModelePDFPropales $index++; $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); - $tvacompl=''; + $tvacompl = ''; if (preg_match('/\*/', $tvakey)) { - $tvakey=str_replace('*', '', $tvakey); + $tvakey = str_replace('*', '', $tvakey); $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")"; } $totalvat = $outputlangs->transcountrynoentities("TotalLT2", $mysoc->country_code).' '; - $totalvat.=vatrate(abs($tvakey), 1).$tvacompl; - $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1); + $totalvat .= vatrate(abs($tvakey), 1).$tvacompl; + $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1); $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1); @@ -1476,7 +1476,7 @@ class pdf_azur extends ModelePDFPropales if ($this->emetteur->logo) { $logodir = $conf->mycompany->dir_output; - if (! empty($conf->mycompany->multidir_output[$object->entity])) $logodir = $conf->mycompany->multidir_output[$object->entity]; + if (!empty($conf->mycompany->multidir_output[$object->entity])) $logodir = $conf->mycompany->multidir_output[$object->entity]; if (empty($conf->global->MAIN_PDF_USE_LARGE_LOGO)) { $logo = $logodir.'/logos/thumbs/'.$this->emetteur->logo_small; @@ -1528,27 +1528,27 @@ class pdf_azur extends ModelePDFPropales $pdf->MultiCell(100, 3, $outputlangs->transnoentities("RefCustomer")." : ".$outputlangs->convToOutputCharset($object->ref_client), '', 'R'); } - if (! empty($conf->global->PDF_SHOW_PROJECT_TITLE)) + if (!empty($conf->global->PDF_SHOW_PROJECT_TITLE)) { $object->fetch_projet(); - if (! empty($object->project->ref)) + if (!empty($object->project->ref)) { - $posy+=3; + $posy += 3; $pdf->SetXY($posx, $posy); $pdf->SetTextColor(0, 0, 60); - $pdf->MultiCell($w, 3, $outputlangs->transnoentities("Project")." : " . (empty($object->project->title)?'':$object->projet->title), '', 'R'); + $pdf->MultiCell($w, 3, $outputlangs->transnoentities("Project")." : ".(empty($object->project->title) ? '' : $object->projet->title), '', 'R'); } } - if (! empty($conf->global->PDF_SHOW_PROJECT)) + if (!empty($conf->global->PDF_SHOW_PROJECT)) { $object->fetch_projet(); - if (! empty($object->project->ref)) + if (!empty($object->project->ref)) { - $posy+=3; + $posy += 3; $pdf->SetXY($posx, $posy); $pdf->SetTextColor(0, 0, 60); - $pdf->MultiCell($w, 3, $outputlangs->transnoentities("RefProject")." : " . (empty($object->project->ref)?'':$object->projet->ref), '', 'R'); + $pdf->MultiCell($w, 3, $outputlangs->transnoentities("RefProject")." : ".(empty($object->project->ref) ? '' : $object->projet->ref), '', 'R'); } } diff --git a/htdocs/core/modules/propale/doc/pdf_cyan.modules.php b/htdocs/core/modules/propale/doc/pdf_cyan.modules.php index 07ceb461803..cbbf462b446 100644 --- a/htdocs/core/modules/propale/doc/pdf_cyan.modules.php +++ b/htdocs/core/modules/propale/doc/pdf_cyan.modules.php @@ -594,7 +594,7 @@ class pdf_cyan extends ModelePDFPropales $curY = $tab_top_newpage; // Allows data in the first page if description is long enough to break in multiples pages - if(!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE)) + if (!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE)) $showpricebeforepagebreak = 1; else $showpricebeforepagebreak = 0; @@ -640,7 +640,7 @@ class pdf_cyan extends ModelePDFPropales { // We found a page break // Allows data in the first page if description is long enough to break in multiples pages - if(!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE)) + if (!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE)) $showpricebeforepagebreak = 1; else $showpricebeforepagebreak = 0; @@ -1588,27 +1588,27 @@ class pdf_cyan extends ModelePDFPropales $pdf->MultiCell(100, 3, $outputlangs->transnoentities("RefCustomer")." : ".$outputlangs->convToOutputCharset($object->ref_client), '', 'R'); } - if (! empty($conf->global->PDF_SHOW_PROJECT_TITLE)) + if (!empty($conf->global->PDF_SHOW_PROJECT_TITLE)) { $object->fetch_projet(); - if (! empty($object->project->ref)) + if (!empty($object->project->ref)) { - $posy+=3; + $posy += 3; $pdf->SetXY($posx, $posy); $pdf->SetTextColor(0, 0, 60); - $pdf->MultiCell($w, 3, $outputlangs->transnoentities("Project")." : " . (empty($object->project->title)?'':$object->projet->title), '', 'R'); + $pdf->MultiCell($w, 3, $outputlangs->transnoentities("Project")." : ".(empty($object->project->title) ? '' : $object->projet->title), '', 'R'); } } - if (! empty($conf->global->PDF_SHOW_PROJECT)) + if (!empty($conf->global->PDF_SHOW_PROJECT)) { $object->fetch_projet(); - if (! empty($object->project->ref)) + if (!empty($object->project->ref)) { - $posy+=3; + $posy += 3; $pdf->SetXY($posx, $posy); $pdf->SetTextColor(0, 0, 60); - $pdf->MultiCell($w, 3, $outputlangs->transnoentities("RefProject")." : " . (empty($object->project->ref)?'':$object->projet->ref), '', 'R'); + $pdf->MultiCell($w, 3, $outputlangs->transnoentities("RefProject")." : ".(empty($object->project->ref) ? '' : $object->projet->ref), '', 'R'); } } diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php index 6ca038a8a3d..bed02b94d55 100644 --- a/htdocs/fourn/class/fournisseur.commande.class.php +++ b/htdocs/fourn/class/fournisseur.commande.class.php @@ -185,7 +185,7 @@ class CommandeFournisseur extends CommonOrder - public $fields=array( + public $fields = array( 'rowid' =>array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>10), 'tms' =>array('type'=>'timestamp', 'label'=>'DateModification', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>15), 'fk_soc' =>array('type'=>'integer:Societe:societe/class/societe.class.php', 'label'=>'ThirdParty', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>20), @@ -455,11 +455,11 @@ class CommandeFournisseur extends CommonOrder $sql .= " l.date_start, l.date_end,"; $sql .= ' l.fk_multicurrency, l.multicurrency_code, l.multicurrency_subprice, l.multicurrency_total_ht, l.multicurrency_total_tva, l.multicurrency_total_ttc'; if (!empty($conf->global->PRODUCT_USE_SUPPLIER_PACKAGING)) - $sql.= ", pfp.rowid as fk_pfp, pfp.packaging"; + $sql .= ", pfp.rowid as fk_pfp, pfp.packaging"; $sql .= " FROM ".MAIN_DB_PREFIX."commande_fournisseurdet as l"; $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON l.fk_product = p.rowid'; if (!empty($conf->global->PRODUCT_USE_SUPPLIER_PACKAGING)) - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product_fournisseur_price as pfp ON l.fk_product = pfp.fk_product and l.ref = pfp.ref_fourn"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product_fournisseur_price as pfp ON l.fk_product = pfp.fk_product and l.ref = pfp.ref_fourn"; $sql .= " WHERE l.fk_commande = ".$this->id; if ($only_product) $sql .= ' AND p.fk_product_type = 0'; $sql .= " ORDER BY l.rang, l.rowid"; @@ -516,7 +516,7 @@ class CommandeFournisseur extends CommonOrder $line->packaging = $objp->packaging; } - $line->date_start = $this->db->jdate($objp->date_start); + $line->date_start = $this->db->jdate($objp->date_start); $line->date_end = $this->db->jdate($objp->date_end); $line->fk_unit = $objp->fk_unit; @@ -1701,7 +1701,7 @@ class CommandeFournisseur extends CommonOrder if (!empty($conf->global->PRODUCT_USE_SUPPLIER_PACKAGING)) { $prod = new Product($this->db, $fk_product); - $prod->get_buyprice($fk_prod_fourn_price, $qty, $fk_product, 'none', ($this->fk_soc?$this->fk_soc:$this->socid)); + $prod->get_buyprice($fk_prod_fourn_price, $qty, $fk_product, 'none', ($this->fk_soc ? $this->fk_soc : $this->socid)); if ($qty < $prod->packaging) { $qty = $prod->packaging; @@ -1710,7 +1710,7 @@ class CommandeFournisseur extends CommonOrder { if (($qty % $prod->packaging) > 0) { - $coeff = intval($qty/$prod->packaging) + 1; + $coeff = intval($qty / $prod->packaging) + 1; $qty = $prod->packaging * $coeff; setEventMessage($langs->trans('QtyRecalculatedWithPackaging'), 'mesgs'); } @@ -2679,7 +2679,7 @@ class CommandeFournisseur extends CommonOrder { if (($qty % $this->line->packaging) > 0) { - $coeff = intval($qty/$this->line->packaging) + 1; + $coeff = intval($qty / $this->line->packaging) + 1; $qty = $this->line->packaging * $coeff; setEventMessage($langs->trans('QtyRecalculatedWithPackaging'), 'mesgs'); } @@ -3451,11 +3451,11 @@ class CommandeFournisseurLigne extends CommonOrderLine $sql .= ' cd.date_start, cd.date_end, cd.fk_unit,'; $sql .= ' cd.multicurrency_subprice, cd.multicurrency_total_ht, cd.multicurrency_total_tva, cd.multicurrency_total_ttc'; if (!empty($conf->global->PRODUCT_USE_SUPPLIER_PACKAGING)) - $sql.= ", pfp.rowid as fk_pfp, pfp.packaging"; + $sql .= ", pfp.rowid as fk_pfp, pfp.packaging"; $sql .= ' FROM '.MAIN_DB_PREFIX.'commande_fournisseurdet as cd'; $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON cd.fk_product = p.rowid'; if (!empty($conf->global->PRODUCT_USE_SUPPLIER_PACKAGING)) - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product_fournisseur_price as pfp ON cd.fk_product = pfp.fk_product and cd.ref = pfp.ref_fourn"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product_fournisseur_price as pfp ON cd.fk_product = pfp.fk_product and cd.ref = pfp.ref_fourn"; $sql .= ' WHERE cd.rowid = '.$rowid; $result = $this->db->query($sql); if ($result) diff --git a/htdocs/fourn/class/fournisseur.facture.class.php b/htdocs/fourn/class/fournisseur.facture.class.php index a0cf142a23b..6178bc5ae3c 100644 --- a/htdocs/fourn/class/fournisseur.facture.class.php +++ b/htdocs/fourn/class/fournisseur.facture.class.php @@ -218,7 +218,7 @@ class FactureFournisseur extends CommonInvoice public $fk_facture_source; - public $fields=array( + public $fields = array( 'rowid' =>array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>10), 'ref' =>array('type'=>'varchar(255)', 'label'=>'Ref', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'showoncombobox'=>1, 'position'=>15), 'ref_supplier' =>array('type'=>'varchar(255)', 'label'=>'RefSupplier', 'enabled'=>1, 'visible'=>-1, 'position'=>20), @@ -2287,7 +2287,7 @@ class FactureFournisseur extends CommonInvoice if ($facturestatic->hasDelay()) { $response->nbtodolate++; - $response->url_late=DOL_URL_ROOT.'/fourn/facture/list.php?option=late&mainmenu=billing&leftmenu=suppliers_bills'; + $response->url_late = DOL_URL_ROOT.'/fourn/facture/list.php?option=late&mainmenu=billing&leftmenu=suppliers_bills'; } } $this->db->free($resql); diff --git a/htdocs/fourn/class/fournisseur.product.class.php b/htdocs/fourn/class/fournisseur.product.class.php index 6c139d73707..332e33ece59 100644 --- a/htdocs/fourn/class/fournisseur.product.class.php +++ b/htdocs/fourn/class/fournisseur.product.class.php @@ -360,7 +360,7 @@ class ProductFournisseur extends Product $sql .= " supplier_reputation = ".(empty($supplier_reputation) ? 'NULL' : "'".$this->db->escape($supplier_reputation)."'").","; $sql .= " barcode = ".(empty($barcode) ? 'NULL' : "'".$this->db->escape($barcode)."'").","; $sql .= " fk_barcode_type = ".(empty($fk_barcode_type) ? 'NULL' : "'".$this->db->escape($fk_barcode_type)."'"); - if (!empty($conf->global->PRODUCT_USE_SUPPLIER_PACKAGING)) $sql.= ", packaging = ".(empty($packaging) ? 1 : $packaging); + if (!empty($conf->global->PRODUCT_USE_SUPPLIER_PACKAGING)) $sql .= ", packaging = ".(empty($packaging) ? 1 : $packaging); $sql .= " WHERE rowid = ".$this->product_fourn_price_id; // TODO Add price_base_type and price_ttc @@ -410,7 +410,7 @@ class ProductFournisseur extends Product $sql = "INSERT INTO ".MAIN_DB_PREFIX."product_fournisseur_price("; $sql .= " multicurrency_price, multicurrency_unitprice, multicurrency_tx, fk_multicurrency, multicurrency_code,"; $sql .= "datec, fk_product, fk_soc, ref_fourn, desc_fourn, fk_user, price, quantity, remise_percent, remise, unitprice, tva_tx, charges, fk_availability, default_vat_code, info_bits, entity, delivery_time_days, supplier_reputation, barcode, fk_barcode_type)"; - if (!empty($conf->global->PRODUCT_USE_SUPPLIER_PACKAGING)) $sql.= ", packaging"; + if (!empty($conf->global->PRODUCT_USE_SUPPLIER_PACKAGING)) $sql .= ", packaging"; $sql .= " values("; $sql .= (isset($multicurrency_buyprice) ? "'".$this->db->escape(price2num($multicurrency_buyprice))."'" : 'null').","; $sql .= (isset($multicurrency_unitBuyPrice) ? "'".$this->db->escape(price2num($multicurrency_unitBuyPrice))."'" : 'null').","; @@ -438,14 +438,14 @@ class ProductFournisseur extends Product $sql .= (empty($supplier_reputation) ? 'NULL' : "'".$this->db->escape($supplier_reputation)."'").","; $sql .= (empty($barcode) ? 'NULL' : "'".$this->db->escape($barcode)."'").","; $sql .= (empty($fk_barcode_type) ? 'NULL' : "'".$this->db->escape($fk_barcode_type)."'"); - if (!empty($conf->global->PRODUCT_USE_SUPPLIER_PACKAGING)) $sql.= ", ".(empty($this->packaging) ? 1 : $this->db->escape($this->packaging)) ; + if (!empty($conf->global->PRODUCT_USE_SUPPLIER_PACKAGING)) $sql .= ", ".(empty($this->packaging) ? 1 : $this->db->escape($this->packaging)); $sql .= ")"; $this->product_fourn_price_id = 0; $resql = $this->db->query($sql); if ($resql) { - $this->product_fourn_price_id = $this->db->last_insert_id(MAIN_DB_PREFIX . "product_fournisseur_price"); + $this->product_fourn_price_id = $this->db->last_insert_id(MAIN_DB_PREFIX."product_fournisseur_price"); } else { $error++; @@ -505,7 +505,7 @@ class ProductFournisseur extends Product $sql .= " pfp.supplier_reputation, pfp.fk_user, pfp.datec,"; $sql .= " pfp.multicurrency_price, pfp.multicurrency_unitprice, pfp.multicurrency_tx, pfp.fk_multicurrency, pfp.multicurrency_code,"; $sql .= " pfp.barcode, pfp.fk_barcode_type"; - if (!empty($conf->global->PRODUCT_USE_SUPPLIER_PACKAGING)) $sql.= ", pfp.packaging"; + if (!empty($conf->global->PRODUCT_USE_SUPPLIER_PACKAGING)) $sql .= ", pfp.packaging"; $sql .= " FROM ".MAIN_DB_PREFIX."product_fournisseur_price as pfp"; $sql .= " WHERE pfp.rowid = ".(int) $rowid; @@ -609,7 +609,7 @@ class ProductFournisseur extends Product $sql .= " pfp.price, pfp.quantity, pfp.unitprice, pfp.remise_percent, pfp.remise, pfp.tva_tx, pfp.fk_availability, pfp.charges, pfp.info_bits, pfp.delivery_time_days, pfp.supplier_reputation,"; $sql .= " pfp.multicurrency_price, pfp.multicurrency_unitprice, pfp.multicurrency_tx, pfp.fk_multicurrency, pfp.multicurrency_code, pfp.datec, pfp.tms,"; $sql .= " pfp.barcode, pfp.fk_barcode_type"; - if (!empty($conf->global->PRODUCT_USE_SUPPLIER_PACKAGING)) $sql.= ", pfp.packaging"; + if (!empty($conf->global->PRODUCT_USE_SUPPLIER_PACKAGING)) $sql .= ", pfp.packaging"; $sql .= " FROM ".MAIN_DB_PREFIX."product_fournisseur_price as pfp, ".MAIN_DB_PREFIX."societe as s"; $sql .= " WHERE pfp.entity IN (".getEntity('productsupplierprice').")"; $sql .= " AND pfp.fk_soc = s.rowid"; diff --git a/htdocs/fourn/commande/index.php b/htdocs/fourn/commande/index.php index b6720a93e57..45abd70e0be 100644 --- a/htdocs/fourn/commande/index.php +++ b/htdocs/fourn/commande/index.php @@ -166,7 +166,7 @@ $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; $sql .= ", ".MAIN_DB_PREFIX."commande_fournisseur as cf"; if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; $sql .= " WHERE cf.fk_soc = s.rowid"; -$sql.= " AND cf.entity IN (".getEntity("supplier_order").")"; // Thirdparty sharing is mandatory with supplier order sharing +$sql .= " AND cf.entity IN (".getEntity("supplier_order").")"; // Thirdparty sharing is mandatory with supplier order sharing if ($user->socid) $sql .= ' AND cf.fk_soc = '.$user->socid; if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; $sql .= " GROUP BY cf.fk_statut"; @@ -253,23 +253,23 @@ if (!empty($conf->fournisseur->enabled)) */ $sql = "SELECT"; -if (! empty($conf->multicompany->enabled) && ! empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) { +if (!empty($conf->multicompany->enabled) && !empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) { $sql .= " DISTINCT"; } -$sql.= " u.rowid, u.lastname, u.firstname, u.email, u.statut"; -$sql.= " FROM ".MAIN_DB_PREFIX."user as u"; -if (! empty($conf->multicompany->enabled) && ! empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) +$sql .= " u.rowid, u.lastname, u.firstname, u.email, u.statut"; +$sql .= " FROM ".MAIN_DB_PREFIX."user as u"; +if (!empty($conf->multicompany->enabled) && !empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) { - $sql.= ",".MAIN_DB_PREFIX."usergroup_user as ug"; - $sql.= " WHERE ((ug.fk_user = u.rowid"; - $sql.= " AND ug.entity IN (".getEntity('usergroup')."))"; - $sql.= " OR u.entity = 0)"; // Show always superadmin + $sql .= ",".MAIN_DB_PREFIX."usergroup_user as ug"; + $sql .= " WHERE ((ug.fk_user = u.rowid"; + $sql .= " AND ug.entity IN (".getEntity('usergroup')."))"; + $sql .= " OR u.entity = 0)"; // Show always superadmin } else { - $sql.= " WHERE (u.entity IN (".getEntity('user').")"; + $sql .= " WHERE (u.entity IN (".getEntity('user').")"; } -$sql.= " AND u.fk_soc IS NULL"; // An external user can not approved +$sql .= " AND u.fk_soc IS NULL"; // An external user can not approved $resql = $db->query($sql); if ($resql) @@ -290,7 +290,7 @@ if ($resql) $userstatic->id = $obj->rowid; $userstatic->getrights('fournisseur'); - if (! empty($userstatic->rights->fournisseur->commande->approuver)) + if (!empty($userstatic->rights->fournisseur->commande->approuver)) { print ''; print ''; diff --git a/htdocs/fourn/facture/paiement.php b/htdocs/fourn/facture/paiement.php index b93b239ef72..1b6f8257977 100644 --- a/htdocs/fourn/facture/paiement.php +++ b/htdocs/fourn/facture/paiement.php @@ -301,8 +301,8 @@ if (empty($reshook)) $paiement->num_payment = GETPOST('num_paiement', 'alpha'); $paiement->note_private = GETPOST('comment', 'alpha'); - $paiement->num_paiement = $paiement->num_payment; // For bacward compatibility - $paiement->note = $paiement->note_private; // For bacward compatibility + $paiement->num_paiement = $paiement->num_payment; // For bacward compatibility + $paiement->note = $paiement->note_private; // For bacward compatibility if (!$error) { diff --git a/htdocs/modulebuilder/template/mymoduleindex.php b/htdocs/modulebuilder/template/mymoduleindex.php index fe2f932c129..2d9bdf2f1e6 100644 --- a/htdocs/modulebuilder/template/mymoduleindex.php +++ b/htdocs/modulebuilder/template/mymoduleindex.php @@ -25,39 +25,39 @@ */ // Load Dolibarr environment -$res=0; +$res = 0; // Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined) -if (! $res && ! empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) $res=@include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php"; +if (!$res && !empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) $res = @include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php"; // Try main.inc.php into web root detected using web root calculated from SCRIPT_FILENAME -$tmp=empty($_SERVER['SCRIPT_FILENAME'])?'':$_SERVER['SCRIPT_FILENAME'];$tmp2=realpath(__FILE__); $i=strlen($tmp)-1; $j=strlen($tmp2)-1; -while($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i]==$tmp2[$j]) { $i--; $j--; } -if (! $res && $i > 0 && file_exists(substr($tmp, 0, ($i+1))."/main.inc.php")) $res=@include substr($tmp, 0, ($i+1))."/main.inc.php"; -if (! $res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i+1)))."/main.inc.php")) $res=@include dirname(substr($tmp, 0, ($i+1)))."/main.inc.php"; +$tmp = empty($_SERVER['SCRIPT_FILENAME']) ? '' : $_SERVER['SCRIPT_FILENAME']; $tmp2 = realpath(__FILE__); $i = strlen($tmp) - 1; $j = strlen($tmp2) - 1; +while ($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) { $i--; $j--; } +if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1))."/main.inc.php")) $res = @include substr($tmp, 0, ($i + 1))."/main.inc.php"; +if (!$res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php")) $res = @include dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php"; // Try main.inc.php using relative path -if (! $res && file_exists("../main.inc.php")) $res=@include "../main.inc.php"; -if (! $res && file_exists("../../main.inc.php")) $res=@include "../../main.inc.php"; -if (! $res && file_exists("../../../main.inc.php")) $res=@include "../../../main.inc.php"; -if (! $res) die("Include of main fails"); +if (!$res && file_exists("../main.inc.php")) $res = @include "../main.inc.php"; +if (!$res && file_exists("../../main.inc.php")) $res = @include "../../main.inc.php"; +if (!$res && file_exists("../../../main.inc.php")) $res = @include "../../../main.inc.php"; +if (!$res) die("Include of main fails"); require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; // Load translation files required by the page $langs->loadLangs(array("mymodule@mymodule")); -$action=GETPOST('action', 'alpha'); +$action = GETPOST('action', 'alpha'); // Security check //if (! $user->rights->mymodule->myobject->read) accessforbidden(); -$socid=GETPOST('socid', 'int'); +$socid = GETPOST('socid', 'int'); if (isset($user->socid) && $user->socid > 0) { $action = ''; $socid = $user->socid; } -$max=5; -$now=dol_now(); +$max = 5; +$now = dol_now(); /* @@ -164,8 +164,8 @@ END MODULEBUILDER DRAFT MYOBJECT */ print '
'; -$NBMAX=3; -$max=3; +$NBMAX = 3; +$max = 3; /* BEGIN MODULEBUILDER LASTMODIFIED MYOBJECT // Last modified myobject diff --git a/htdocs/mrp/class/mo.class.php b/htdocs/mrp/class/mo.class.php index 6de52586763..d7f4384c5cd 100644 --- a/htdocs/mrp/class/mo.class.php +++ b/htdocs/mrp/class/mo.class.php @@ -624,7 +624,7 @@ class Mo extends CommonObject $moline->role = 'toproduce'; $moline->position = 1; - $resultline = $moline->create($user, false); // Never use triggers here + $resultline = $moline->create($user, false); // Never use triggers here if ($resultline <= 0) { $error++; $this->error = $moline->error; @@ -639,14 +639,14 @@ class Mo extends CommonObject if ($bom->id > 0) { // Lines to consume - if (! $error) { + if (!$error) { foreach ($bom->lines as $line) { $moline = new MoLine($this->db); $moline->fk_mo = $this->id; if ($line->qty_frozen) { - $moline->qty = $line->qty; // Qty to consume does not depends on quantity to produce + $moline->qty = $line->qty; // Qty to consume does not depends on quantity to produce } else { $moline->qty = round($line->qty * $this->qty / $bom->efficiency, 2); } @@ -662,7 +662,7 @@ class Mo extends CommonObject $moline->qty_frozen = $line->qty_frozen; $moline->disable_stock_change = $line->disable_stock_change; - $resultline = $moline->create($user, false); // Never use triggers here + $resultline = $moline->create($user, false); // Never use triggers here if ($resultline <= 0) { $error++; $this->error = $moline->error; diff --git a/htdocs/mrp/mo_movements.php b/htdocs/mrp/mo_movements.php index ace336b7d29..82742868c9c 100644 --- a/htdocs/mrp/mo_movements.php +++ b/htdocs/mrp/mo_movements.php @@ -670,57 +670,57 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea print "\n"; print ''; - if (! empty($arrayfields['m.rowid']['checked'])) + if (!empty($arrayfields['m.rowid']['checked'])) print_liste_field_titre($arrayfields['m.rowid']['label'], $_SERVER["PHP_SELF"], 'm.rowid', '', $param, '', $sortfield, $sortorder); - if (! empty($arrayfields['m.datem']['checked'])) + if (!empty($arrayfields['m.datem']['checked'])) print_liste_field_titre($arrayfields['m.datem']['label'], $_SERVER["PHP_SELF"], 'm.datem', '', $param, '', $sortfield, $sortorder); - if (! empty($arrayfields['p.ref']['checked'])) + if (!empty($arrayfields['p.ref']['checked'])) print_liste_field_titre($arrayfields['p.ref']['label'], $_SERVER["PHP_SELF"], 'p.ref', '', $param, '', $sortfield, $sortorder); - if (! empty($arrayfields['p.label']['checked'])) + if (!empty($arrayfields['p.label']['checked'])) print_liste_field_titre($arrayfields['p.label']['label'], $_SERVER["PHP_SELF"], 'p.label', '', $param, '', $sortfield, $sortorder); - if (! empty($arrayfields['m.batch']['checked'])) + if (!empty($arrayfields['m.batch']['checked'])) print_liste_field_titre($arrayfields['m.batch']['label'], $_SERVER["PHP_SELF"], 'm.batch', '', $param, '', $sortfield, $sortorder, 'center '); - if (! empty($arrayfields['pl.eatby']['checked'])) + if (!empty($arrayfields['pl.eatby']['checked'])) print_liste_field_titre($arrayfields['pl.eatby']['label'], $_SERVER["PHP_SELF"], 'pl.eatby', '', $param, '', $sortfield, $sortorder, 'center '); - if (! empty($arrayfields['pl.sellby']['checked'])) + if (!empty($arrayfields['pl.sellby']['checked'])) print_liste_field_titre($arrayfields['pl.sellby']['label'], $_SERVER["PHP_SELF"], 'pl.sellby', '', $param, '', $sortfield, $sortorder, 'center '); - if (! empty($arrayfields['e.ref']['checked'])) { + if (!empty($arrayfields['e.ref']['checked'])) { // We are on a specific warehouse card, no filter on other should be possible print_liste_field_titre($arrayfields['e.ref']['label'], $_SERVER["PHP_SELF"], "e.ref", "", $param, "", $sortfield, $sortorder); } - if (! empty($arrayfields['m.fk_user_author']['checked'])) + if (!empty($arrayfields['m.fk_user_author']['checked'])) print_liste_field_titre($arrayfields['m.fk_user_author']['label'], $_SERVER["PHP_SELF"], "m.fk_user_author", "", $param, "", $sortfield, $sortorder); - if (! empty($arrayfields['m.inventorycode']['checked'])) + if (!empty($arrayfields['m.inventorycode']['checked'])) print_liste_field_titre($arrayfields['m.inventorycode']['label'], $_SERVER["PHP_SELF"], "m.inventorycode", "", $param, "", $sortfield, $sortorder); - if (! empty($arrayfields['m.label']['checked'])) + if (!empty($arrayfields['m.label']['checked'])) print_liste_field_titre($arrayfields['m.label']['label'], $_SERVER["PHP_SELF"], "m.label", "", $param, "", $sortfield, $sortorder); - if (! empty($arrayfields['m.type_mouvement']['checked'])) + if (!empty($arrayfields['m.type_mouvement']['checked'])) print_liste_field_titre($arrayfields['m.type_mouvement']['label'], $_SERVER["PHP_SELF"], "m.type_mouvement", "", $param, '', $sortfield, $sortorder, 'center '); - if (! empty($arrayfields['origin']['checked'])) + if (!empty($arrayfields['origin']['checked'])) print_liste_field_titre($arrayfields['origin']['label'], $_SERVER["PHP_SELF"], "", "", $param, "", $sortfield, $sortorder); - if (! empty($arrayfields['m.value']['checked'])) + if (!empty($arrayfields['m.value']['checked'])) print_liste_field_titre($arrayfields['m.value']['label'], $_SERVER["PHP_SELF"], "m.value", "", $param, '', $sortfield, $sortorder, 'right '); - if (! empty($arrayfields['m.price']['checked'])) + if (!empty($arrayfields['m.price']['checked'])) print_liste_field_titre($arrayfields['m.price']['label'], $_SERVER["PHP_SELF"], "m.price", "", $param, '', $sortfield, $sortorder, 'right '); // Extra fields - include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_list_search_title.tpl.php'; + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; // Hook fields - $parameters = array('arrayfields' => $arrayfields,'param' => $param,'sortfield' => $sortfield,'sortorder' => $sortorder); + $parameters = array('arrayfields' => $arrayfields, 'param' => $param, 'sortfield' => $sortfield, 'sortorder' => $sortorder); $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; - if (! empty($arrayfields['m.datec']['checked'])) { + if (!empty($arrayfields['m.datec']['checked'])) { print_liste_field_titre($arrayfields['p.datec']['label'], $_SERVER["PHP_SELF"], "p.datec", "", $param, '', $sortfield, $sortorder, 'center nowrap '); } - if (! empty($arrayfields['m.tms']['checked'])) { + if (!empty($arrayfields['m.tms']['checked'])) { print_liste_field_titre($arrayfields['p.tms']['label'], $_SERVER["PHP_SELF"], "p.tms", "", $param, '', $sortfield, $sortorder, 'center nowrap '); } print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch '); print "\n"; $resql = $db->query($sql); - if (! $resql) { + if (!$resql) { dol_print_error($db); } $num = $db->num_rows($resql); @@ -752,7 +752,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea $warehousestatic->label = $objp->warehouse_ref; $warehousestatic->lieu = $objp->lieu; - if (! empty($objp->fk_origin)) { + if (!empty($objp->fk_origin)) { $origin = $objectlist->get_origin($objp->fk_origin, $objp->origintype); } else { $origin = ''; @@ -760,21 +760,21 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea print ''; // Id movement - if (! empty($arrayfields['m.rowid']['checked'])) { + if (!empty($arrayfields['m.rowid']['checked'])) { // This is primary not movement id - print '' . $objp->mid . ''; + print ''.$objp->mid.''; } - if (! empty($arrayfields['m.datem']['checked'])) { + if (!empty($arrayfields['m.datem']['checked'])) { // Date - print '' . dol_print_date($db->jdate($objp->datem), 'dayhour') . ''; + print ''.dol_print_date($db->jdate($objp->datem), 'dayhour').''; } - if (! empty($arrayfields['p.ref']['checked'])) { + if (!empty($arrayfields['p.ref']['checked'])) { // Product ref print ''; print $productstatic->getNomUrl(1, 'stock', 16); print "\n"; } - if (! empty($arrayfields['p.label']['checked'])) { + if (!empty($arrayfields['p.label']['checked'])) { // Product label print ''; /* @@ -786,7 +786,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea print $productstatic->label; print "\n"; } - if (! empty($arrayfields['m.batch']['checked'])) { + if (!empty($arrayfields['m.batch']['checked'])) { print ''; if ($productlot->id > 0) print $productlot->getNomUrl(1); @@ -794,25 +794,25 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea print $productlot->batch; // the id may not be defined if movement was entered when lot was not saved or if lot was removed after movement. print ''; } - if (! empty($arrayfields['pl.eatby']['checked'])) { - print '' . dol_print_date($objp->eatby, 'day') . ''; + if (!empty($arrayfields['pl.eatby']['checked'])) { + print ''.dol_print_date($objp->eatby, 'day').''; } - if (! empty($arrayfields['pl.sellby']['checked'])) { - print '' . dol_print_date($objp->sellby, 'day') . ''; + if (!empty($arrayfields['pl.sellby']['checked'])) { + print ''.dol_print_date($objp->sellby, 'day').''; } // Warehouse - if (! empty($arrayfields['e.ref']['checked'])) { + if (!empty($arrayfields['e.ref']['checked'])) { print ''; print $warehousestatic->getNomUrl(1); print "\n"; } // Author - if (! empty($arrayfields['m.fk_user_author']['checked'])) { + if (!empty($arrayfields['m.fk_user_author']['checked'])) { print ''; - print $userstatic->getNomUrl(- 1); + print $userstatic->getNomUrl(-1); print "\n"; } - if (! empty($arrayfields['m.inventorycode']['checked'])) { + if (!empty($arrayfields['m.inventorycode']['checked'])) { // Inventory code print ''; //print ''; @@ -820,32 +820,32 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea //print ''; print ''; } - if (! empty($arrayfields['m.label']['checked'])) { + if (!empty($arrayfields['m.label']['checked'])) { // Label of movement - print '' . $objp->label . ''; + print ''.$objp->label.''; } - if (! empty($arrayfields['m.type_mouvement']['checked'])) { + if (!empty($arrayfields['m.type_mouvement']['checked'])) { // Type of movement switch ($objp->type_mouvement) { case "0": - print '' . $langs->trans('StockIncreaseAfterCorrectTransfer') . ''; + print ''.$langs->trans('StockIncreaseAfterCorrectTransfer').''; break; case "1": - print '' . $langs->trans('StockDecreaseAfterCorrectTransfer') . ''; + print ''.$langs->trans('StockDecreaseAfterCorrectTransfer').''; break; case "2": - print '' . $langs->trans('StockDecrease') . ''; + print ''.$langs->trans('StockDecrease').''; break; case "3": - print '' . $langs->trans('StockIncrease') . ''; + print ''.$langs->trans('StockIncrease').''; break; } } - if (! empty($arrayfields['origin']['checked'])) { + if (!empty($arrayfields['origin']['checked'])) { // Origin of movement - print '' . $origin . ''; + print ''.$origin.''; } - if (! empty($arrayfields['m.value']['checked'])) { + if (!empty($arrayfields['m.value']['checked'])) { // Qty print ''; if ($objp->qt > 0) @@ -853,7 +853,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea print $objp->qty; print ''; } - if (! empty($arrayfields['m.price']['checked'])) { + if (!empty($arrayfields['m.price']['checked'])) { // Price print ''; if ($objp->price != 0) @@ -867,11 +867,11 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea $selected = 0; if (in_array($obj->rowid, $arrayofselected)) $selected = 1; - print ''; + print ''; } print ''; - if (! $i) - $totalarray['nbfield'] ++; + if (!$i) + $totalarray['nbfield']++; print "\n"; $i++; diff --git a/htdocs/mrp/mo_production.php b/htdocs/mrp/mo_production.php index f6866ba26bd..6cf45bf238b 100644 --- a/htdocs/mrp/mo_production.php +++ b/htdocs/mrp/mo_production.php @@ -167,12 +167,12 @@ if (empty($reshook)) // Line to produce $moline->fk_mo = $object->id; - $moline->qty = GETPOST('qtytoadd', 'int');; + $moline->qty = GETPOST('qtytoadd', 'int'); ; $moline->fk_product = GETPOST('productidtoadd', 'int'); $moline->role = 'toconsume'; $moline->position = 0; - $resultline = $moline->create($user, false); // Never use triggers here + $resultline = $moline->create($user, false); // Never use triggers here if ($resultline <= 0) { $error++; setEventMessages($moline->error, $molines->errors, 'errors'); @@ -546,7 +546,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea dol_fiche_end(); - if (! in_array($action, array('consumeorproduce', 'consumeandproduceall'))) + if (!in_array($action, array('consumeorproduce', 'consumeandproduceall'))) { print '
'; @@ -700,14 +700,14 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea if (!empty($object->lines)) { $nblinetoconsume = 0; - foreach($object->lines as $line) { + foreach ($object->lines as $line) { if ($line->role == 'toconsume') { $nblinetoconsume++; } } $nblinetoconsumecursor = 0; - foreach($object->lines as $line) { + foreach ($object->lines as $line) { if ($line->role == 'toconsume') { $nblinetoconsumecursor++; @@ -716,7 +716,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea $arrayoflines = $object->fetchLinesLinked('consumed', $line->id); $alreadyconsumed = 0; - foreach($arrayoflines as $line2) { + foreach ($arrayoflines as $line2) { $alreadyconsumed += $line2['qty']; } @@ -756,7 +756,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea } print ' '.$alreadyconsumed; print ''; - print ''; // Warehouse + print ''; // Warehouse print ''; if ($conf->productbatch->enabled) { print ''; // Lot @@ -764,7 +764,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea print ''; // Show detailed of already consumed with js code to collapse - foreach($arrayoflines as $line2) { + foreach ($arrayoflines as $line2) { print ''; print ''; print dol_print_date($line2['date'], 'dayhour'); @@ -792,7 +792,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea print ''; print ''.$langs->trans("ToConsume").''; $preselected = (GETPOSTISSET('qty-'.$line->id.'-'.$i) ? GETPOST('qty-'.$line->id.'-'.$i) : max(0, $line->qty - $alreadyconsumed)); - if ($action == 'consumeorproduce' && ! GETPOSTISSET('qty-'.$line->id.'-'.$i)) $preselected = 0; + if ($action == 'consumeorproduce' && !GETPOSTISSET('qty-'.$line->id.'-'.$i)) $preselected = 0; print ''; print ''; print ''; @@ -851,14 +851,14 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea if (!empty($object->lines)) { $nblinetoproduce = 0; - foreach($object->lines as $line) { + foreach ($object->lines as $line) { if ($line->role == 'toproduce') { $nblinetoproduce++; } } $nblinetoproducecursor = 0; - foreach($object->lines as $line) { + foreach ($object->lines as $line) { if ($line->role == 'toproduce') { $nblinetoproducecursor++; @@ -867,7 +867,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea $arrayoflines = $object->fetchLinesLinked('produced', $line->id); $alreadyproduced = 0; - foreach($arrayoflines as $line2) { + foreach ($arrayoflines as $line2) { $alreadyproduced += $line2['qty']; } @@ -894,7 +894,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea } print ' '.$alreadyproduced; print ''; - print ''; // Warehouse + print ''; // Warehouse print ''; if ($conf->productbatch->enabled) { print ''; // Lot @@ -902,7 +902,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea print ''; // Show detailed of already consumed with js code to collapse - foreach($arrayoflines as $line2) { + foreach ($arrayoflines as $line2) { print ''; print ''; print dol_print_date($line2['date'], 'dayhour'); @@ -928,7 +928,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea print ''; print ''.$langs->trans("ToProduce").''; $preselected = (GETPOSTISSET('qtytoproduce-'.$line->id.'-'.$i) ? GETPOST('qtytoproduce-'.$line->id.'-'.$i) : max(0, $line->qty - $alreadyproduced)); - if ($action == 'consumeorproduce' && ! GETPOSTISSET('qtytoproduce-'.$line->id.'-'.$i)) $preselected = 0; + if ($action == 'consumeorproduce' && !GETPOSTISSET('qtytoproduce-'.$line->id.'-'.$i)) $preselected = 0; print ''; print ''; print ''; diff --git a/htdocs/product/admin/product.php b/htdocs/product/admin/product.php index d1a4f6bcf6f..f3ef5441144 100644 --- a/htdocs/product/admin/product.php +++ b/htdocs/product/admin/product.php @@ -37,31 +37,31 @@ require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formbarcode.class.php'; // Load translation files required by the page -$langs->loadLangs(array("admin","products")); +$langs->loadLangs(array("admin", "products")); // Security check -if (! $user->admin || (empty($conf->product->enabled) && empty($conf->service->enabled))) +if (!$user->admin || (empty($conf->product->enabled) && empty($conf->service->enabled))) accessforbidden(); $action = GETPOST('action', 'alpha'); $value = GETPOST('value', 'alpha'); $label = GETPOST('label', 'alpha'); $scandir = GETPOST('scan_dir', 'alpha'); -$type='product'; +$type = 'product'; // Pricing Rules -$select_pricing_rules=array( - 'PRODUCT_PRICE_UNIQ'=>$langs->trans('PriceCatalogue'), // Unique price - 'PRODUIT_MULTIPRICES'=>$langs->trans('MultiPricesAbility'), // Several prices according to a customer level - 'PRODUIT_CUSTOMER_PRICES'=>$langs->trans('PriceByCustomer'), // Different price for each customer +$select_pricing_rules = array( + 'PRODUCT_PRICE_UNIQ'=>$langs->trans('PriceCatalogue'), // Unique price + 'PRODUIT_MULTIPRICES'=>$langs->trans('MultiPricesAbility'), // Several prices according to a customer level + 'PRODUIT_CUSTOMER_PRICES'=>$langs->trans('PriceByCustomer'), // Different price for each customer ); -$keyforparam='PRODUIT_CUSTOMER_PRICES_BY_QTY'; -if ($conf->global->MAIN_FEATURES_LEVEL >= 1 || ! empty($conf->global->$keyforparam)) $select_pricing_rules['PRODUIT_CUSTOMER_PRICES_BY_QTY'] = $langs->trans('PriceByQuantity').' ('.$langs->trans("VersionExperimental").')'; // TODO If this is enabled, price must be hidden when price by qty is enabled, also price for quantity must be used when adding product into order/propal/invoice -$keyforparam='PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES'; -if ($conf->global->MAIN_FEATURES_LEVEL >= 2 || ! empty($conf->global->$keyforparam)) $select_pricing_rules['PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES'] = $langs->trans('MultiPricesAbility') . '+' . $langs->trans('PriceByQuantity').' ('.$langs->trans("VersionExperimental").')'; +$keyforparam = 'PRODUIT_CUSTOMER_PRICES_BY_QTY'; +if ($conf->global->MAIN_FEATURES_LEVEL >= 1 || !empty($conf->global->$keyforparam)) $select_pricing_rules['PRODUIT_CUSTOMER_PRICES_BY_QTY'] = $langs->trans('PriceByQuantity').' ('.$langs->trans("VersionExperimental").')'; // TODO If this is enabled, price must be hidden when price by qty is enabled, also price for quantity must be used when adding product into order/propal/invoice +$keyforparam = 'PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES'; +if ($conf->global->MAIN_FEATURES_LEVEL >= 2 || !empty($conf->global->$keyforparam)) $select_pricing_rules['PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES'] = $langs->trans('MultiPricesAbility').'+'.$langs->trans('PriceByQuantity').' ('.$langs->trans("VersionExperimental").')'; // Clean param -if (! empty($conf->global->PRODUIT_MULTIPRICES) && empty($conf->global->PRODUIT_MULTIPRICES_LIMIT)) { +if (!empty($conf->global->PRODUIT_MULTIPRICES) && empty($conf->global->PRODUIT_MULTIPRICES_LIMIT)) { dolibarr_set_const($db, 'PRODUIT_MULTIPRICES_LIMIT', 5, 'chaine', 0, '', $conf->entity); } @@ -72,7 +72,7 @@ $error = 0; * Actions */ -$nomessageinsetmoduleoptions=1; +$nomessageinsetmoduleoptions = 1; include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php'; if ($action == 'setcodeproduct') @@ -91,12 +91,12 @@ if ($action == 'setcodeproduct') if ($action == 'other' && GETPOST('value_PRODUIT_LIMIT_SIZE') >= 0) { $res = dolibarr_set_const($db, "PRODUIT_LIMIT_SIZE", GETPOST('value_PRODUIT_LIMIT_SIZE'), 'chaine', 0, '', $conf->entity); - if (! $res > 0) $error++; + if (!$res > 0) $error++; } if ($action == 'other' && GETPOST('value_PRODUIT_MULTIPRICES_LIMIT') > 0) { $res = dolibarr_set_const($db, "PRODUIT_MULTIPRICES_LIMIT", GETPOST('value_PRODUIT_MULTIPRICES_LIMIT'), 'chaine', 0, '', $conf->entity); - if (! $res > 0) $error++; + if (!$res > 0) $error++; } if ($action == 'other') { @@ -114,8 +114,8 @@ if ($action == 'other') } else { - $multirule=explode('&', $princingrules); - foreach($multirule as $rulesselected) + $multirule = explode('&', $princingrules); + foreach ($multirule as $rulesselected) { $res = dolibarr_set_const($db, $rulesselected, 1, 'chaine', 0, '', $conf->entity); } @@ -123,7 +123,7 @@ if ($action == 'other') } else // We clear this mode { - if (strpos($rule, '&')===false) { + if (strpos($rule, '&') === false) { $res = dolibarr_set_const($db, $rule, 0, 'chaine', 0, '', $conf->entity); } } @@ -172,20 +172,20 @@ if ($action == 'other') if ($action == 'specimen') // For products { - $modele= GETPOST('module', 'alpha'); + $modele = GETPOST('module', 'alpha'); $product = new Product($db); $product->initAsSpecimen(); // Search template files - $file=''; $classname=''; $filefound=0; - $dirmodels=array_merge(array('/'), (array) $conf->modules_parts['models']); - foreach($dirmodels as $reldir) + $file = ''; $classname = ''; $filefound = 0; + $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); + foreach ($dirmodels as $reldir) { - $file=dol_buildpath($reldir."core/modules/product/doc/pdf_".$modele.".modules.php", 0); + $file = dol_buildpath($reldir."core/modules/product/doc/pdf_".$modele.".modules.php", 0); if (file_exists($file)) { - $filefound=1; + $filefound = 1; $classname = "pdf_".$modele; break; } @@ -255,7 +255,7 @@ if ($action == 'set') $value = GETPOST('value'); if (GETPOST('value', 'alpha')) $res = dolibarr_set_const($db, $const, $value, 'chaine', 0, '', $conf->entity); else $res = dolibarr_del_const($db, $const, $conf->entity); - if (! $res > 0) $error++; + if (!$res > 0) $error++; } //if ($action == 'other') @@ -267,7 +267,7 @@ if ($action == 'set') if ($action) { - if (! $error) + if (!$error) { setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); } @@ -281,7 +281,7 @@ if ($action) * View */ -$formbarcode=new FormBarCode($db); +$formbarcode = new FormBarCode($db); $title = $langs->trans('ProductServiceSetup'); $tab = $langs->trans("ProductsAndServices"); @@ -298,17 +298,17 @@ elseif (empty($conf->service->enabled)) llxHeader('', $title); -$linkback=''.$langs->trans("BackToModuleList").''; +$linkback = ''.$langs->trans("BackToModuleList").''; print load_fiche_titre($title, $linkback, 'title_setup'); $head = product_admin_prepare_head(); dol_fiche_head($head, 'general', $tab, -1, 'product'); -$form=new Form($db); +$form = new Form($db); // Module to manage product / services code -$dirproduct=array('/core/modules/product/'); -$dirmodels=array_merge(array('/'), (array) $conf->modules_parts['models']); +$dirproduct = array('/core/modules/product/'); +$dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); print load_fiche_titre($langs->trans("ProductCodeChecker"), '', ''); @@ -330,16 +330,16 @@ foreach ($dirproduct as $dirroot) if (is_resource($handle)) { // Loop on each module find in opened directory - while (($file = readdir($handle))!==false) + while (($file = readdir($handle)) !== false) { if (substr($file, 0, 16) == 'mod_codeproduct_' && substr($file, -3) == 'php') { - $file = substr($file, 0, dol_strlen($file)-4); + $file = substr($file, 0, dol_strlen($file) - 4); try { dol_include_once($dirroot.$file.'.php'); } - catch(Exception $e) + catch (Exception $e) { dol_syslog($e->getMessage(), LOG_ERR); } @@ -347,7 +347,7 @@ foreach ($dirproduct as $dirroot) $modCodeProduct = new $file; // Show modules according to features level - if ($modCodeProduct->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) continue; + if ($modCodeProduct->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) continue; if ($modCodeProduct->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) continue; $var = !$var; @@ -356,7 +356,7 @@ foreach ($dirproduct as $dirroot) print ''.$modCodeProduct->info($langs).''."\n"; print ''.$modCodeProduct->getExample($langs).''."\n"; - if (! empty($conf->global->PRODUCT_CODEPRODUCT_ADDON) && $conf->global->PRODUCT_CODEPRODUCT_ADDON == $file) + if (!empty($conf->global->PRODUCT_CODEPRODUCT_ADDON) && $conf->global->PRODUCT_CODEPRODUCT_ADDON == $file) { print ''."\n"; print img_picto($langs->trans("Activated"), 'switch_on'); @@ -365,16 +365,16 @@ foreach ($dirproduct as $dirroot) else { $disabled = false; - if (! empty($conf->multicompany->enabled) && (is_object($mc) && ! empty($mc->sharings['referent']) && $mc->sharings['referent'] == $conf->entity) ? false : true); + if (!empty($conf->multicompany->enabled) && (is_object($mc) && !empty($mc->sharings['referent']) && $mc->sharings['referent'] == $conf->entity) ? false : true); print ''; - if (! $disabled) print ''; + if (!$disabled) print ''; print img_picto($langs->trans("Disabled"), 'switch_off'); - if (! $disabled) print ''; + if (!$disabled) print ''; print ''; } print ''; - $s=$modCodeProduct->getToolTip($langs, null, -1); + $s = $modCodeProduct->getToolTip($langs, null, -1); print $form->textwithpicto('', $s, 1); print ''; @@ -389,14 +389,14 @@ print ''; // Module to build doc $def = array(); $sql = "SELECT nom"; -$sql.= " FROM ".MAIN_DB_PREFIX."document_model"; -$sql.= " WHERE type = '".$type."'"; -$sql.= " AND entity = ".$conf->entity; -$resql=$db->query($sql); +$sql .= " FROM ".MAIN_DB_PREFIX."document_model"; +$sql .= " WHERE type = '".$type."'"; +$sql .= " AND entity = ".$conf->entity; +$resql = $db->query($sql); if ($resql) { $i = 0; - $num_rows=$db->num_rows($resql); + $num_rows = $db->num_rows($resql); while ($i < $num_rows) { $array = $db->fetch_array($resql); @@ -427,41 +427,41 @@ clearstatcache(); foreach ($dirmodels as $reldir) { - foreach (array('','/doc') as $valdir) + foreach (array('', '/doc') as $valdir) { $dir = dol_buildpath($reldir."core/modules/product".$valdir); if (is_dir($dir)) { - $handle=opendir($dir); + $handle = opendir($dir); if (is_resource($handle)) { - while (($file = readdir($handle))!==false) + while (($file = readdir($handle)) !== false) { - $filelist[]=$file; + $filelist[] = $file; } closedir($handle); arsort($filelist); - foreach($filelist as $file) + foreach ($filelist as $file) { if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file)) { if (file_exists($dir.'/'.$file)) { - $name = substr($file, 4, dol_strlen($file) -16); - $classname = substr($file, 0, dol_strlen($file) -12); + $name = substr($file, 4, dol_strlen($file) - 16); + $classname = substr($file, 0, dol_strlen($file) - 12); require_once $dir.'/'.$file; $module = new $classname($db); - $modulequalified=1; - if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) $modulequalified=0; - if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) $modulequalified=0; + $modulequalified = 1; + if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) $modulequalified = 0; + if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) $modulequalified = 0; if ($modulequalified) { print ''; - print (empty($module->name)?$name:$module->name); + print (empty($module->name) ? $name : $module->name); print "\n"; if (method_exists($module, 'info')) print $module->info($langs); else print $module->description; @@ -496,15 +496,15 @@ foreach ($dirmodels as $reldir) print ''; // Info - $htmltooltip = ''.$langs->trans("Name").': '.$module->name; - $htmltooltip.='
'.$langs->trans("Type").': '.($module->type?$module->type:$langs->trans("Unknown")); + $htmltooltip = ''.$langs->trans("Name").': '.$module->name; + $htmltooltip .= '
'.$langs->trans("Type").': '.($module->type ? $module->type : $langs->trans("Unknown")); if ($module->type == 'pdf') { - $htmltooltip.='
'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur; + $htmltooltip .= '
'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur; } - $htmltooltip.='

'.$langs->trans("FeaturesSupported").':'; - $htmltooltip.='
'.$langs->trans("Logo").': '.yn($module->option_logo, 1, 1); - $htmltooltip.='
'.$langs->trans("MultiLanguage").': '.yn($module->option_multilang, 1, 1); + $htmltooltip .= '

'.$langs->trans("FeaturesSupported").':'; + $htmltooltip .= '
'.$langs->trans("Logo").': '.yn($module->option_logo, 1, 1); + $htmltooltip .= '
'.$langs->trans("MultiLanguage").': '.yn($module->option_multilang, 1, 1); print ''; @@ -561,10 +561,10 @@ print ' '."\n"; */ $rowspan = 4; -if (! empty($conf->global->PRODUIT_MULTIPRICES) || ! empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES)) $rowspan++; +if (!empty($conf->global->PRODUIT_MULTIPRICES) || !empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES)) $rowspan++; if (empty($conf->global->PRODUIT_USE_SEARCH_TO_SELECT)) $rowspan++; -if (! empty($conf->global->MAIN_MULTILANGS)) $rowspan++; -if (! empty($conf->fournisseur->enabled)) $rowspan++; +if (!empty($conf->global->MAIN_MULTILANGS)) $rowspan++; +if (!empty($conf->fournisseur->enabled)) $rowspan++; print ''; @@ -578,10 +578,10 @@ else } print ''; $current_rule = 'PRODUCT_PRICE_UNIQ'; -if (!empty($conf->global->PRODUIT_MULTIPRICES)) $current_rule='PRODUIT_MULTIPRICES'; -if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY)) $current_rule='PRODUIT_CUSTOMER_PRICES_BY_QTY'; -if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES)) $current_rule='PRODUIT_CUSTOMER_PRICES'; -if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES)) $current_rule='PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES'; +if (!empty($conf->global->PRODUIT_MULTIPRICES)) $current_rule = 'PRODUIT_MULTIPRICES'; +if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY)) $current_rule = 'PRODUIT_CUSTOMER_PRICES_BY_QTY'; +if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES)) $current_rule = 'PRODUIT_CUSTOMER_PRICES'; +if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES)) $current_rule = 'PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES'; print $form->selectarray("princingrule", $select_pricing_rules, $current_rule); print ''; print ''; @@ -590,7 +590,7 @@ print ''; // multiprix nombre de prix a proposer -if (! empty($conf->global->PRODUIT_MULTIPRICES) || ! empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES)) +if (!empty($conf->global->PRODUIT_MULTIPRICES) || !empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES)) { print ''; print ''.$langs->trans("MultiPricesNumPrices").''; @@ -620,7 +620,7 @@ if (empty($conf->use_javascript_ajax)) else { print ''; - $arrval=array( + $arrval = array( '0'=>$langs->trans("No"), '1'=>$langs->trans("Yes").' ('.$langs->trans("NumberOfKeyToSearch", 1).')', '2'=>$langs->trans("Yes").' ('.$langs->trans("NumberOfKeyToSearch", 2).')', @@ -670,38 +670,38 @@ print ''; */ // View product description in thirdparty language -if (! empty($conf->global->MAIN_MULTILANGS)) +if (!empty($conf->global->MAIN_MULTILANGS)) { print ''; print ''.$langs->trans("ViewProductDescInThirdpartyLanguageAbility").''; print ''; - print $form->selectyesno("activate_viewProdTextsInThirdpartyLanguage", (! empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE)?$conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE:0), 1); + print $form->selectyesno("activate_viewProdTextsInThirdpartyLanguage", (!empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE) ? $conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE : 0), 1); print ''; print ''; } -if (! empty($conf->fournisseur->enabled)) +if (!empty($conf->fournisseur->enabled)) { print ''; print ''.$langs->trans("UseProductFournDesc").''; print ''; - print $form->selectyesno("activate_useProdFournDesc", (! empty($conf->global->PRODUIT_FOURN_TEXTS)?$conf->global->PRODUIT_FOURN_TEXTS:0), 1); + print $form->selectyesno("activate_useProdFournDesc", (!empty($conf->global->PRODUIT_FOURN_TEXTS) ? $conf->global->PRODUIT_FOURN_TEXTS : 0), 1); print ''; print ''; print ''; print ''.$langs->trans("UseProductSupplierPackaging").''; print ''; - print $form->selectyesno("activate_useProdSupplierPackaging", (! empty($conf->global->PRODUCT_USE_SUPPLIER_PACKAGING)?$conf->global->PRODUCT_USE_SUPPLIER_PACKAGING:0), 1); + print $form->selectyesno("activate_useProdSupplierPackaging", (!empty($conf->global->PRODUCT_USE_SUPPLIER_PACKAGING) ? $conf->global->PRODUCT_USE_SUPPLIER_PACKAGING : 0), 1); print ''; print ''; } -if (! empty($conf->global->PRODUCT_CANVAS_ABILITY)) +if (!empty($conf->global->PRODUCT_CANVAS_ABILITY)) { // Add canvas feature - $dir = DOL_DOCUMENT_ROOT . "/product/canvas/"; + $dir = DOL_DOCUMENT_ROOT."/product/canvas/"; print ''; print ''.$langs->trans("ProductSpecial").''."\n"; @@ -710,12 +710,12 @@ if (! empty($conf->global->PRODUCT_CANVAS_ABILITY)) if (is_dir($dir)) { - require_once DOL_DOCUMENT_ROOT . '/product/class/product.class.php'; + require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; - $handle=opendir($dir); + $handle = opendir($dir); if (is_resource($handle)) { - while (($file = readdir($handle))!==false) + while (($file = readdir($handle)) !== false) { if (file_exists($dir.$file.'/product.'.$file.'.class.php')) { diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index 473671fd1a3..bffc941a35c 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -1724,7 +1724,7 @@ class Product extends CommonObject $sql .= " pfp.fk_product, pfp.ref_fourn, pfp.desc_fourn, pfp.fk_soc, pfp.tva_tx, pfp.fk_supplier_price_expression"; $sql .= " ,pfp.default_vat_code"; $sql .= " ,pfp.multicurrency_price, pfp.multicurrency_unitprice, pfp.multicurrency_tx, pfp.fk_multicurrency, pfp.multicurrency_code"; - if (!empty($conf->global->PRODUCT_USE_SUPPLIER_PACKAGING)) $sql.= ", pfp.packaging"; + if (!empty($conf->global->PRODUCT_USE_SUPPLIER_PACKAGING)) $sql .= ", pfp.packaging"; $sql .= " FROM ".MAIN_DB_PREFIX."product_fournisseur_price as pfp"; $sql .= " WHERE pfp.rowid = ".$prodfournprice; if ($qty > 0) { $sql .= " AND pfp.quantity <= ".$qty; @@ -1778,7 +1778,7 @@ class Product extends CommonObject $sql .= " pfp.fk_product, pfp.ref_fourn as ref_supplier, pfp.desc_fourn as desc_supplier, pfp.tva_tx, pfp.fk_supplier_price_expression"; $sql .= " ,pfp.default_vat_code"; $sql .= " ,pfp.multicurrency_price, pfp.multicurrency_unitprice, pfp.multicurrency_tx, pfp.fk_multicurrency, pfp.multicurrency_code"; - if (!empty($conf->global->PRODUCT_USE_SUPPLIER_PACKAGING)) $sql.= ", pfp.packaging"; + if (!empty($conf->global->PRODUCT_USE_SUPPLIER_PACKAGING)) $sql .= ", pfp.packaging"; $sql .= " FROM ".MAIN_DB_PREFIX."product_fournisseur_price as pfp"; $sql .= " WHERE pfp.fk_product = ".$product_id; if ($fourn_ref != 'none') { $sql .= " AND pfp.ref_fourn = '".$fourn_ref."'"; diff --git a/htdocs/product/dynamic_price/class/price_parser.class.php b/htdocs/product/dynamic_price/class/price_parser.class.php index 4b0c61073cf..d0eae2f3b17 100644 --- a/htdocs/product/dynamic_price/class/price_parser.class.php +++ b/htdocs/product/dynamic_price/class/price_parser.class.php @@ -181,7 +181,7 @@ class PriceParser //Do processing $res = $entry->process(); //Store any error or clear status if OK - $entry->update_status($res < 1?$entry->error:'', $user); + $entry->update_status($res < 1 ? $entry->error : '', $user); } //Get all global values @@ -216,7 +216,7 @@ class PriceParser { $data = explode($this->special_chr, $expression); $variable = $this->special_chr.$data[1]; - if (isset($data[2])) $variable.= $this->special_chr; + if (isset($data[2])) $variable .= $this->special_chr; $this->error_parser = array(23, array($variable, $expression)); return -6; } @@ -276,7 +276,7 @@ class PriceParser if ($res < 0) { $this->error_parser = array(25, null); return -1; - } elseif($res == 0){ + } elseif ($res == 0) { $supplier_min_price = 0; } else { $supplier_min_price = $productFournisseur->fourn_unitprice; diff --git a/htdocs/product/stock/class/mouvementstock.class.php b/htdocs/product/stock/class/mouvementstock.class.php index aab0d428191..55d12f26c6c 100644 --- a/htdocs/product/stock/class/mouvementstock.class.php +++ b/htdocs/product/stock/class/mouvementstock.class.php @@ -77,7 +77,7 @@ class MouvementStock extends CommonObject public $batch; - public $fields=array( + public $fields = array( 'rowid' =>array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>10, 'showoncombobox'=>1), 'tms' =>array('type'=>'timestamp', 'label'=>'DateModification', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>15), 'datem' =>array('type'=>'datetime', 'label'=>'Datem', 'enabled'=>1, 'visible'=>-1, 'position'=>20), @@ -376,8 +376,8 @@ class MouvementStock extends CommonObject if ($movestock && $entrepot_id > 0) // Change stock for current product, change for subproduct is done after { $fk_project = 0; - if(!empty($this->origin)) { // This is set by caller for tracking reason - $origintype = empty($this->origin->origin_type)?$this->origin->element:$this->origin->origin_type; + if (!empty($this->origin)) { // This is set by caller for tracking reason + $origintype = empty($this->origin->origin_type) ? $this->origin->element : $this->origin->origin_type; $fk_origin = $this->origin->id; if ($origintype == 'project') $fk_project = $fk_origin; else @@ -985,7 +985,7 @@ class MouvementStock extends CommonObject $origintype_array = explode('@', $origintype); $classname = ucfirst($origintype_array[0]); $modulename = empty($origintype_array[1]) ? $classname : empty($origintype_array[1]); - $result=dol_include_once('/'.$modulename.'/class/'.strtolower($classname).'.class.php'); + $result = dol_include_once('/'.$modulename.'/class/'.strtolower($classname).'.class.php'); if ($result) { $classname = ucfirst($classname); diff --git a/htdocs/product/stock/replenish.php b/htdocs/product/stock/replenish.php index 2ad465bdedb..bd7941e1448 100644 --- a/htdocs/product/stock/replenish.php +++ b/htdocs/product/stock/replenish.php @@ -160,7 +160,7 @@ if ($action == 'order' && isset($_POST['valid'])) $desc = $productsupplier->description; } $line->desc = $desc; - if (! empty($conf->global->MAIN_MULTILANGS)) + if (!empty($conf->global->MAIN_MULTILANGS)) { // TODO Get desc in language of thirdparty } @@ -362,8 +362,8 @@ $sql .= ', s.fk_product'; if ($usevirtualstock) { - if (! empty($conf->commande->enabled)) { - $sqlCommandesCli = "(SELECT ".$db->ifsql("SUM(cd1.qty) IS NULL", "0", "SUM(cd1.qty)")." as qty"; // We need the ifsql because if result is 0 for product p.rowid, we must return 0 and not NULL + if (!empty($conf->commande->enabled)) { + $sqlCommandesCli = "(SELECT ".$db->ifsql("SUM(cd1.qty) IS NULL", "0", "SUM(cd1.qty)")." as qty"; // We need the ifsql because if result is 0 for product p.rowid, we must return 0 and not NULL $sqlCommandesCli .= " FROM ".MAIN_DB_PREFIX."commandedet as cd1, ".MAIN_DB_PREFIX."commande as c1"; $sqlCommandesCli .= " WHERE c1.rowid = cd1.fk_commande AND c1.entity IN (".getEntity('commande').")"; $sqlCommandesCli .= " AND cd1.fk_product = p.rowid"; @@ -372,8 +372,8 @@ if ($usevirtualstock) $sqlCommandesCli = '0'; } - if (! empty($conf->expedition->enabled)) { - $sqlExpeditionsCli = "(SELECT ".$db->ifsql("SUM(ed2.qty) IS NULL", "0", "SUM(ed2.qty)")." as qty"; // We need the ifsql because if result is 0 for product p.rowid, we must return 0 and not NULL + if (!empty($conf->expedition->enabled)) { + $sqlExpeditionsCli = "(SELECT ".$db->ifsql("SUM(ed2.qty) IS NULL", "0", "SUM(ed2.qty)")." as qty"; // We need the ifsql because if result is 0 for product p.rowid, we must return 0 and not NULL $sqlExpeditionsCli .= " FROM ".MAIN_DB_PREFIX."expedition as e2,"; $sqlExpeditionsCli .= " ".MAIN_DB_PREFIX."expeditiondet as ed2,"; $sqlExpeditionsCli .= " ".MAIN_DB_PREFIX."commandedet as cd2"; @@ -384,8 +384,8 @@ if ($usevirtualstock) $sqlExpeditionsCli = '0'; } - if (! empty($conf->fournisseur->enabled)) { - $sqlCommandesFourn = "(SELECT ".$db->ifsql("SUM(cd3.qty) IS NULL", "0", "SUM(cd3.qty)")." as qty"; // We need the ifsql because if result is 0 for product p.rowid, we must return 0 and not NULL + if (!empty($conf->fournisseur->enabled)) { + $sqlCommandesFourn = "(SELECT ".$db->ifsql("SUM(cd3.qty) IS NULL", "0", "SUM(cd3.qty)")." as qty"; // We need the ifsql because if result is 0 for product p.rowid, we must return 0 and not NULL $sqlCommandesFourn .= " FROM ".MAIN_DB_PREFIX."commande_fournisseurdet as cd3,"; $sqlCommandesFourn .= " ".MAIN_DB_PREFIX."commande_fournisseur as c3"; $sqlCommandesFourn .= " WHERE c3.rowid = cd3.fk_commande"; @@ -393,7 +393,7 @@ if ($usevirtualstock) $sqlCommandesFourn .= " AND cd3.fk_product = p.rowid"; $sqlCommandesFourn .= " AND c3.fk_statut IN (3,4))"; - $sqlReceptionFourn = "(SELECT ".$db->ifsql("SUM(fd4.qty) IS NULL", "0", "SUM(fd4.qty)")." as qty"; // We need the ifsql because if result is 0 for product p.rowid, we must return 0 and not NULL + $sqlReceptionFourn = "(SELECT ".$db->ifsql("SUM(fd4.qty) IS NULL", "0", "SUM(fd4.qty)")." as qty"; // We need the ifsql because if result is 0 for product p.rowid, we must return 0 and not NULL $sqlReceptionFourn .= " FROM ".MAIN_DB_PREFIX."commande_fournisseur as cf4,"; $sqlReceptionFourn .= " ".MAIN_DB_PREFIX."commande_fournisseur_dispatch as fd4"; $sqlReceptionFourn .= " WHERE fd4.fk_commande = cf4.rowid AND cf4.entity IN (".getEntity('supplier_order').")"; @@ -404,8 +404,8 @@ if ($usevirtualstock) $sqlReceptionFourn = '0'; } - if (! empty($conf->mrp->enabled)) { - $sqlProductionToConsume = "(SELECT GREATEST(0, ".$db->ifsql("SUM(".$db->ifsql("mp5.role = 'toconsume'", 'mp5.qty', '- mp5.qty').") IS NULL", "0", "SUM(".$db->ifsql("mp5.role = 'toconsume'", 'mp5.qty', '- mp5.qty').")").") as qty"; // We need the ifsql because if result is 0 for product p.rowid, we must return 0 and not NULL + if (!empty($conf->mrp->enabled)) { + $sqlProductionToConsume = "(SELECT GREATEST(0, ".$db->ifsql("SUM(".$db->ifsql("mp5.role = 'toconsume'", 'mp5.qty', '- mp5.qty').") IS NULL", "0", "SUM(".$db->ifsql("mp5.role = 'toconsume'", 'mp5.qty', '- mp5.qty').")").") as qty"; // We need the ifsql because if result is 0 for product p.rowid, we must return 0 and not NULL $sqlProductionToConsume .= " FROM ".MAIN_DB_PREFIX."mrp_mo as mm5,"; $sqlProductionToConsume .= " ".MAIN_DB_PREFIX."mrp_production as mp5"; $sqlProductionToConsume .= " WHERE mm5.rowid = mp5.fk_mo AND mm5.entity IN (".getEntity('mo').")"; @@ -413,7 +413,7 @@ if ($usevirtualstock) $sqlProductionToConsume .= " AND mp5.role IN ('toconsume', 'consummed')"; $sqlProductionToConsume .= " AND mm5.status IN (1,2))"; - $sqlProductionToProduce = "(SELECT GREATEST(0, ".$db->ifsql("SUM(".$db->ifsql("mp5.role = 'toproduce'", 'mp5.qty', '- mp5.qty').") IS NULL", "0", "SUM(".$db->ifsql("mp5.role = 'toconsume'", 'mp5.qty', '- mp5.qty').")").") as qty"; // We need the ifsql because if result is 0 for product p.rowid, we must return 0 and not NULL + $sqlProductionToProduce = "(SELECT GREATEST(0, ".$db->ifsql("SUM(".$db->ifsql("mp5.role = 'toproduce'", 'mp5.qty', '- mp5.qty').") IS NULL", "0", "SUM(".$db->ifsql("mp5.role = 'toconsume'", 'mp5.qty', '- mp5.qty').")").") as qty"; // We need the ifsql because if result is 0 for product p.rowid, we must return 0 and not NULL $sqlProductionToProduce .= " FROM ".MAIN_DB_PREFIX."mrp_mo as mm5,"; $sqlProductionToProduce .= " ".MAIN_DB_PREFIX."mrp_production as mp5"; $sqlProductionToProduce .= " WHERE mm5.rowid = mp5.fk_mo AND mm5.entity IN (".getEntity('mo').")"; diff --git a/htdocs/projet/card.php b/htdocs/projet/card.php index 7baefc6964e..d80c7220866 100644 --- a/htdocs/projet/card.php +++ b/htdocs/projet/card.php @@ -263,8 +263,8 @@ if (empty($reshook)) $object->socid = GETPOST('socid', 'int'); $object->description = GETPOST('description', 'none'); // Do not use 'alpha' here, we want field as it is $object->public = GETPOST('public', 'alpha'); - $object->date_start = (! GETPOST('projectstart')) ? '' : $date_start; - $object->date_end = (! GETPOST('projectend')) ? '' : $date_end; + $object->date_start = (!GETPOST('projectstart')) ? '' : $date_start; + $object->date_end = (!GETPOST('projectend')) ? '' : $date_end; if (GETPOSTISSET('opp_amount')) $object->opp_amount = price2num(GETPOST('opp_amount', 'alpha')); if (GETPOSTISSET('budget_amount')) $object->budget_amount = price2num(GETPOST('budget_amount', 'alpha')); if (GETPOSTISSET('opp_status')) $object->opp_status = $opp_status; diff --git a/htdocs/projet/list.php b/htdocs/projet/list.php index b7a4c800ee3..f7f7cce75e1 100644 --- a/htdocs/projet/list.php +++ b/htdocs/projet/list.php @@ -131,7 +131,7 @@ $arrayfields = array( 'p.opp_amount'=>array('label'=>$langs->trans("OpportunityAmountShort"), 'checked'=>1, 'enabled'=>($conf->global->PROJECT_USE_OPPORTUNITIES ? 1 : 0), 'position'=>103), 'p.fk_opp_status'=>array('label'=>$langs->trans("OpportunityStatusShort"), 'checked'=>1, 'enabled'=>($conf->global->PROJECT_USE_OPPORTUNITIES ? 1 : 0), 'position'=>104), 'p.opp_percent'=>array('label'=>$langs->trans("OpportunityProbabilityShort"), 'checked'=>1, 'enabled'=>($conf->global->PROJECT_USE_OPPORTUNITIES ? 1 : 0), 'position'=>105), - 'opp_weighted_amount'=>array('label'=>$langs->trans('OpportunityWeightedAmountShort'), 'checked'=>0, 'enabled'=>($conf->global->PROJECT_USE_OPPORTUNITIES?1:0), 'position'=>106), + 'opp_weighted_amount'=>array('label'=>$langs->trans('OpportunityWeightedAmountShort'), 'checked'=>0, 'enabled'=>($conf->global->PROJECT_USE_OPPORTUNITIES ? 1 : 0), 'position'=>106), 'p.budget_amount'=>array('label'=>$langs->trans("Budget"), 'checked'=>0, 'position'=>110), 'p.usage_opportunity'=>array('label'=>$langs->trans("UsageOpportunity"), 'checked'=>0, 'enabled'=>($conf->global->PROJECT_USE_OPPORTUNITIES ? 1 : 0), 'position'=>115), 'p.usage_task'=>array('label'=>$langs->trans("UsageTasks"), 'checked'=>0, 'enabled'=>($conf->global->PROJECT_HIDE_TASKS ? 0 : 1), 'position'=>116), @@ -847,16 +847,16 @@ while ($i < min($num, $limit)) $totalarray['val']['p.opp_amount'] += $obj->opp_amount; } print ''; - if (! $i) $totalarray['nbfield']++; - if (! $i) $totalarray['pos'][$totalarray['nbfield']]='p.opp_amount'; + if (!$i) $totalarray['nbfield']++; + if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 'p.opp_amount'; } // Opp percent - if (! empty($arrayfields['p.opp_percent']['checked'])) + if (!empty($arrayfields['p.opp_percent']['checked'])) { print ''; if ($obj->opp_percent) print price($obj->opp_percent, 1, $langs, 1, 0).'%'; print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Opp weighted amount if (!empty($arrayfields['opp_weighted_amount']['checked'])) @@ -868,11 +868,11 @@ while ($i < min($num, $limit)) $totalarray['val']['opp_weighted_amount'] += $obj->opp_weighted_amount; } print ''; - if (! $i) $totalarray['nbfield']++; - if (! $i) $totalarray['pos'][$totalarray['nbfield']] = 'opp_weighted_amount'; + if (!$i) $totalarray['nbfield']++; + if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 'opp_weighted_amount'; } // Budget - if (! empty($arrayfields['p.budget_amount']['checked'])) + if (!empty($arrayfields['p.budget_amount']['checked'])) { print ''; if ($obj->budget_amount != '') @@ -881,11 +881,11 @@ while ($i < min($num, $limit)) $totalarray['val']['p.budget_amount'] += $obj->budget_amount; } print ''; - if (! $i) $totalarray['nbfield']++; - if (! $i) $totalarray['pos'][$totalarray['nbfield']]='p.budget_amount'; + if (!$i) $totalarray['nbfield']++; + if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 'p.budget_amount'; } // Usage opportunity - if (! empty($arrayfields['p.usage_opportunity']['checked'])) + if (!empty($arrayfields['p.usage_opportunity']['checked'])) { print ''; if ($obj->usage_opportunity) diff --git a/htdocs/public/error-401.php b/htdocs/public/error-401.php index ac921fc9f78..87da7c347e3 100644 --- a/htdocs/public/error-401.php +++ b/htdocs/public/error-401.php @@ -21,7 +21,7 @@ Sorry. You are not allowed to access this resource.
- +
diff --git a/htdocs/public/error-404.php b/htdocs/public/error-404.php index 34a4ac03e9e..baaa26cd833 100644 --- a/htdocs/public/error-404.php +++ b/htdocs/public/error-404.php @@ -21,7 +21,7 @@ You requested a website or a page that does not exists.
- +
diff --git a/htdocs/societe/class/api_contacts.class.php b/htdocs/societe/class/api_contacts.class.php index 2ae9fd34869..d8efc00f85e 100644 --- a/htdocs/societe/class/api_contacts.class.php +++ b/htdocs/societe/class/api_contacts.class.php @@ -74,7 +74,7 @@ class Contacts extends DolibarrApi { throw new RestException(401, 'No permission to read contacts'); } - if ($id ==0) { + if ($id == 0) { $result = $this->contact->initAsSpecimen(); } else { $result = $this->contact->fetch($id); @@ -87,7 +87,7 @@ class Contacts extends DolibarrApi if (!DolibarrApi::_checkAccessToResource('contact', $this->contact->id, 'socpeople&societe')) { - throw new RestException(401, 'Access not allowed for login ' . DolibarrApiAccess::$user->login); + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } if ($includecount) @@ -134,37 +134,37 @@ class Contacts extends DolibarrApi $search_sale = DolibarrApiAccess::$user->id; $sql = "SELECT t.rowid"; - $sql.= " FROM " . MAIN_DB_PREFIX . "socpeople as t"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX . "socpeople_extrafields as te ON te.fk_object = t.rowid"; + $sql .= " FROM ".MAIN_DB_PREFIX."socpeople as t"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."socpeople_extrafields as te ON te.fk_object = t.rowid"; if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) { // We need this table joined to the select in order to filter by sale - $sql.= ", " . MAIN_DB_PREFIX . "societe_commerciaux as sc"; + $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; } - $sql.= " LEFT JOIN " . MAIN_DB_PREFIX . "societe as s ON t.fk_soc = s.rowid"; - $sql.= ' WHERE t.entity IN (' . getEntity('socpeople') . ')'; - if ($socids) $sql.= " AND t.fk_soc IN (" . $socids . ")"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON t.fk_soc = s.rowid"; + $sql .= ' WHERE t.entity IN ('.getEntity('socpeople').')'; + if ($socids) $sql .= " AND t.fk_soc IN (".$socids.")"; if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) - $sql.= " AND t.fk_soc = sc.fk_soc"; + $sql .= " AND t.fk_soc = sc.fk_soc"; if ($search_sale > 0) - $sql.= " AND s.rowid = sc.fk_soc"; // Join for the needed table to filter by sale + $sql .= " AND s.rowid = sc.fk_soc"; // Join for the needed table to filter by sale // Insert sale filter if ($search_sale > 0) { - $sql .= " AND sc.fk_user = " . $search_sale; + $sql .= " AND sc.fk_user = ".$search_sale; } // Add sql filters if ($sqlfilters) { - if (! DolibarrApi::_checkFilters($sqlfilters)) + if (!DolibarrApi::_checkFilters($sqlfilters)) { throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters); } - $regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; - $sql.=" AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")"; + $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; + $sql .= " AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")"; } - $sql.= $db->order($sortfield, $sortorder); + $sql .= $db->order($sortfield, $sortorder); if ($limit) { @@ -174,7 +174,7 @@ class Contacts extends DolibarrApi } $offset = $limit * $page; - $sql.= $db->plimit($limit + 1, $offset); + $sql .= $db->plimit($limit + 1, $offset); } $result = $db->query($sql); if ($result) @@ -199,7 +199,7 @@ class Contacts extends DolibarrApi } } else { - throw new RestException(503, 'Error when retrieve contacts : ' . $sql); + throw new RestException(503, 'Error when retrieve contacts : '.$sql); } if (!count($obj_ret)) { @@ -255,7 +255,7 @@ class Contacts extends DolibarrApi if (!DolibarrApi::_checkAccessToResource('contact', $this->contact->id, 'socpeople&societe')) { - throw new RestException(401, 'Access not allowed for login ' . DolibarrApiAccess::$user->login); + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } foreach ($request_data as $field => $value) @@ -290,7 +290,7 @@ class Contacts extends DolibarrApi if (!DolibarrApi::_checkAccessToResource('contact', $this->contact->id, 'socpeople&societe')) { - throw new RestException(401, 'Access not allowed for login ' . DolibarrApiAccess::$user->login); + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } $this->contact->oldcopy = clone $this->contact; return $this->contact->delete(); @@ -330,7 +330,7 @@ class Contacts extends DolibarrApi } if (!DolibarrApi::_checkAccessToResource('contact', $contact->id, 'socpeople&societe')) { - throw new RestException(401, 'Access not allowed for login ' . DolibarrApiAccess::$user->login); + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } // Check mandatory fields @@ -362,7 +362,7 @@ class Contacts extends DolibarrApi */ public function getCategories($id, $sortfield = "s.rowid", $sortorder = 'ASC', $limit = 0, $page = 0) { - if (! DolibarrApiAccess::$user->rights->categorie->lire) { + if (!DolibarrApiAccess::$user->rights->categorie->lire) { throw new RestException(401); } @@ -396,24 +396,24 @@ class Contacts extends DolibarrApi */ public function addCategory($id, $category_id) { - if(! DolibarrApiAccess::$user->rights->societe->contact->creer) { + if (!DolibarrApiAccess::$user->rights->societe->contact->creer) { throw new RestException(401, 'Insufficient rights'); } $result = $this->contact->fetch($id); - if (! $result) { + if (!$result) { throw new RestException(404, 'Contact not found'); } $category = new Categorie($this->db); $result = $category->fetch($category_id); - if (! $result) { + if (!$result) { throw new RestException(404, 'category not found'); } - if (! DolibarrApi::_checkAccessToResource('contact', $this->contact->id)) { + if (!DolibarrApi::_checkAccessToResource('contact', $this->contact->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } - if (! DolibarrApi::_checkAccessToResource('category', $category->id)) { + if (!DolibarrApi::_checkAccessToResource('category', $category->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } @@ -436,24 +436,24 @@ class Contacts extends DolibarrApi */ public function deleteCategory($id, $category_id) { - if(! DolibarrApiAccess::$user->rights->societe->contact->creer) { + if (!DolibarrApiAccess::$user->rights->societe->contact->creer) { throw new RestException(401, 'Insufficient rights'); } $result = $this->contact->fetch($id); - if( ! $result ) { + if (!$result) { throw new RestException(404, 'Contact not found'); } $category = new Categorie($this->db); $result = $category->fetch($category_id); - if( ! $result ) { + if (!$result) { throw new RestException(404, 'category not found'); } - if( ! DolibarrApi::_checkAccessToResource('contact', $this->contact->id)) { + if (!DolibarrApi::_checkAccessToResource('contact', $this->contact->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } - if( ! DolibarrApi::_checkAccessToResource('category', $category->id)) { + if (!DolibarrApi::_checkAccessToResource('category', $category->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } diff --git a/htdocs/societe/list.php b/htdocs/societe/list.php index e480d68eca4..9402627e44a 100644 --- a/htdocs/societe/list.php +++ b/htdocs/societe/list.php @@ -236,17 +236,17 @@ if ($action == "change") // Change customer for TakePOS $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."facture where ref='(PROV-POS".$_SESSION["takeposterminal"]."-".$place.")' AND entity IN (".getEntity('invoice').")"; $result = $db->query($sql); $num_lines = $db->num_rows($result); - if ($num_lines==0) + if ($num_lines == 0) { - require_once DOL_DOCUMENT_ROOT . '/compta/facture/class/facture.class.php'; + require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; $invoice = new Facture($db); $constforthirdpartyid = 'CASHDESK_ID_THIRDPARTY'.$_SESSION["takeposterminal"]; $invoice->socid = $conf->global->$constforthirdpartyid; $invoice->date = dol_now(); $invoice->module_source = 'takepos'; $invoice->pos_source = $_SESSION["takeposterminal"]; - $placeid =$invoice->create($user); - $sql="UPDATE ".MAIN_DB_PREFIX."facture set ref='(PROV-POS".$_SESSION["takeposterminal"]."-".$place.")' where rowid=".$placeid; + $placeid = $invoice->create($user); + $sql = "UPDATE ".MAIN_DB_PREFIX."facture set ref='(PROV-POS".$_SESSION["takeposterminal"]."-".$place.")' where rowid=".$placeid; $db->query($sql); } @@ -356,140 +356,140 @@ if ($search_status == '') $search_status = 1; // always display active thirdpart External user socid=x + No permission to see ALL customers => Can see only himself */ -$form=new Form($db); -$formother=new FormOther($db); -$companystatic=new Societe($db); -$companyparent=new Societe($db); -$formcompany=new FormCompany($db); -$prospectstatic=new Client($db); -$prospectstatic->client=2; +$form = new Form($db); +$formother = new FormOther($db); +$companystatic = new Societe($db); +$companyparent = new Societe($db); +$formcompany = new FormCompany($db); +$prospectstatic = new Client($db); +$prospectstatic->client = 2; $prospectstatic->loadCacheOfProspStatus(); -$title=$langs->trans("ListOfThirdParties"); -if ($type == 'c' && (empty($search_type) || ($search_type == '1,3'))) $title=$langs->trans("ListOfCustomers"); -if ($type == 'p' && (empty($search_type) || ($search_type == '2,3'))) $title=$langs->trans("ListOfProspects"); -if ($type == 'f' && (empty($search_type) || ($search_type == '4'))) $title=$langs->trans("ListOfSuppliers"); +$title = $langs->trans("ListOfThirdParties"); +if ($type == 'c' && (empty($search_type) || ($search_type == '1,3'))) $title = $langs->trans("ListOfCustomers"); +if ($type == 'p' && (empty($search_type) || ($search_type == '2,3'))) $title = $langs->trans("ListOfProspects"); +if ($type == 'f' && (empty($search_type) || ($search_type == '4'))) $title = $langs->trans("ListOfSuppliers"); // Select every potentiels, and note each potentiels which fit in search parameters $tab_level = array(); $sql = "SELECT code, label, sortorder"; -$sql.= " FROM ".MAIN_DB_PREFIX."c_prospectlevel"; -$sql.= " WHERE active > 0"; -$sql.= " ORDER BY sortorder"; +$sql .= " FROM ".MAIN_DB_PREFIX."c_prospectlevel"; +$sql .= " WHERE active > 0"; +$sql .= " ORDER BY sortorder"; $resql = $db->query($sql); if ($resql) { while ($obj = $db->fetch_object($resql)) { // Compute level text - $level=$langs->trans($obj->code); - if ($level == $obj->code) $level=$langs->trans($obj->label); + $level = $langs->trans($obj->code); + if ($level == $obj->code) $level = $langs->trans($obj->label); $tab_level[$obj->code] = $level; } } else dol_print_error($db); $sql = "SELECT s.rowid, s.nom as name, s.name_alias, s.barcode, s.town, s.zip, s.datec, s.code_client, s.code_fournisseur, s.logo,"; -$sql.= " s.entity,"; -$sql.= " st.libelle as stcomm, s.fk_stcomm as stcomm_id, s.fk_prospectlevel, s.prefix_comm, s.client, s.fournisseur, s.canvas, s.status as status,"; -$sql.= " s.email, s.phone, s.fax, s.url, s.siren as idprof1, s.siret as idprof2, s.ape as idprof3, s.idprof4 as idprof4, s.idprof5 as idprof5, s.idprof6 as idprof6, s.tva_intra, s.fk_pays,"; -$sql.= " s.tms as date_update, s.datec as date_creation,"; -$sql.= " s.code_compta, s.code_compta_fournisseur, s.parent as fk_parent,"; -$sql.= " s2.nom as name2,"; -$sql.= " typent.code as typent_code,"; -$sql.= " staff.code as staff_code,"; -$sql.= " country.code as country_code, country.label as country_label,"; -$sql.= " state.code_departement as state_code, state.nom as state_name,"; -$sql.= " region.code_region as region_code, region.nom as region_name"; +$sql .= " s.entity,"; +$sql .= " st.libelle as stcomm, s.fk_stcomm as stcomm_id, s.fk_prospectlevel, s.prefix_comm, s.client, s.fournisseur, s.canvas, s.status as status,"; +$sql .= " s.email, s.phone, s.fax, s.url, s.siren as idprof1, s.siret as idprof2, s.ape as idprof3, s.idprof4 as idprof4, s.idprof5 as idprof5, s.idprof6 as idprof6, s.tva_intra, s.fk_pays,"; +$sql .= " s.tms as date_update, s.datec as date_creation,"; +$sql .= " s.code_compta, s.code_compta_fournisseur, s.parent as fk_parent,"; +$sql .= " s2.nom as name2,"; +$sql .= " typent.code as typent_code,"; +$sql .= " staff.code as staff_code,"; +$sql .= " country.code as country_code, country.label as country_label,"; +$sql .= " state.code_departement as state_code, state.nom as state_name,"; +$sql .= " region.code_region as region_code, region.nom as region_name"; // We'll need these fields in order to filter by sale (including the case where the user can only see his prospects) if ($search_sale) $sql .= ", sc.fk_soc, sc.fk_user"; // We'll need these fields in order to filter by categ if ($search_categ_cus) $sql .= ", cc.fk_categorie, cc.fk_soc"; if ($search_categ_sup) $sql .= ", cs.fk_categorie, cs.fk_soc"; // Add fields from extrafields -if (! empty($extrafields->attributes[$object->table_element]['label'])) { - foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) $sql.=($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key.' as options_'.$key : ''); +if (!empty($extrafields->attributes[$object->table_element]['label'])) { + foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key.' as options_'.$key : ''); } // Add fields from hooks -$parameters=array(); -$reshook=$hookmanager->executeHooks('printFieldListSelect', $parameters); // Note that $action and $object may have been modified by hook -$sql.=$hookmanager->resPrint; -$sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; -$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s2 ON s.parent = s2.rowid"; -if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (s.rowid = ef.fk_object)"; -$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as country on (country.rowid = s.fk_pays)"; -$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_typent as typent on (typent.id = s.fk_typent)"; -$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_effectif as staff on (staff.id = s.fk_effectif)"; -$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_departements as state on (state.rowid = s.fk_departement)"; -$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_regions as region on (region. code_region = state.fk_region)"; +$parameters = array(); +$reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters); // Note that $action and $object may have been modified by hook +$sql .= $hookmanager->resPrint; +$sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; +$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s2 ON s.parent = s2.rowid"; +if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (s.rowid = ef.fk_object)"; +$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as country on (country.rowid = s.fk_pays)"; +$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_typent as typent on (typent.id = s.fk_typent)"; +$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_effectif as staff on (staff.id = s.fk_effectif)"; +$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_departements as state on (state.rowid = s.fk_departement)"; +$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_regions as region on (region. code_region = state.fk_region)"; // We'll need this table joined to the select in order to filter by categ -if (! empty($search_categ_cus)) $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX."categorie_societe as cc ON s.rowid = cc.fk_soc"; // We'll need this table joined to the select in order to filter by categ -if (! empty($search_categ_sup)) $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX."categorie_fournisseur as cs ON s.rowid = cs.fk_soc"; // We'll need this table joined to the select in order to filter by categ -$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX."c_stcomm as st ON s.fk_stcomm = st.id"; +if (!empty($search_categ_cus)) $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX."categorie_societe as cc ON s.rowid = cc.fk_soc"; // We'll need this table joined to the select in order to filter by categ +if (!empty($search_categ_sup)) $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX."categorie_fournisseur as cs ON s.rowid = cs.fk_soc"; // We'll need this table joined to the select in order to filter by categ +$sql .= ' LEFT JOIN '.MAIN_DB_PREFIX."c_stcomm as st ON s.fk_stcomm = st.id"; // We'll need this table joined to the select in order to filter by sale -if ($search_sale == -2) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON sc.fk_soc = s.rowid"; -elseif ($search_sale || (!$user->rights->societe->client->voir && !$socid)) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; -$sql.= " WHERE s.entity IN (".getEntity('societe').")"; -if (! $user->rights->societe->client->voir && ! $socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; -if ($socid) $sql.= " AND s.rowid = ".$socid; -if ($search_sale && $search_sale != -2) $sql.= " AND s.rowid = sc.fk_soc"; // Join for the needed table to filter by sale -if (! $user->rights->fournisseur->lire) $sql.=" AND (s.fournisseur <> 1 OR s.client <> 0)"; // client=0, fournisseur=0 must be visible -if ($search_sale == -2) $sql.= " AND sc.fk_user IS NULL"; -elseif ($search_sale) $sql.= " AND sc.fk_user = ".$db->escape($search_sale); -if ($search_categ_cus > 0) $sql.= " AND cc.fk_categorie = ".$db->escape($search_categ_cus); -if ($search_categ_sup > 0) $sql.= " AND cs.fk_categorie = ".$db->escape($search_categ_sup); -if ($search_categ_cus == -2) $sql.= " AND cc.fk_categorie IS NULL"; -if ($search_categ_sup == -2) $sql.= " AND cs.fk_categorie IS NULL"; +if ($search_sale == -2) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON sc.fk_soc = s.rowid"; +elseif ($search_sale || (!$user->rights->societe->client->voir && !$socid)) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; +$sql .= " WHERE s.entity IN (".getEntity('societe').")"; +if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; +if ($socid) $sql .= " AND s.rowid = ".$socid; +if ($search_sale && $search_sale != -2) $sql .= " AND s.rowid = sc.fk_soc"; // Join for the needed table to filter by sale +if (!$user->rights->fournisseur->lire) $sql .= " AND (s.fournisseur <> 1 OR s.client <> 0)"; // client=0, fournisseur=0 must be visible +if ($search_sale == -2) $sql .= " AND sc.fk_user IS NULL"; +elseif ($search_sale) $sql .= " AND sc.fk_user = ".$db->escape($search_sale); +if ($search_categ_cus > 0) $sql .= " AND cc.fk_categorie = ".$db->escape($search_categ_cus); +if ($search_categ_sup > 0) $sql .= " AND cs.fk_categorie = ".$db->escape($search_categ_sup); +if ($search_categ_cus == -2) $sql .= " AND cc.fk_categorie IS NULL"; +if ($search_categ_sup == -2) $sql .= " AND cs.fk_categorie IS NULL"; -if ($search_all) $sql.= natural_search(array_keys($fieldstosearchall), $search_all); -if (strlen($search_cti)) $sql.= natural_search('s.phone', $search_cti); +if ($search_all) $sql .= natural_search(array_keys($fieldstosearchall), $search_all); +if (strlen($search_cti)) $sql .= natural_search('s.phone', $search_cti); -if ($search_id > 0) $sql.= natural_search("s.rowid", $search_id, 1); -if ($search_nom) $sql.= natural_search("s.nom", $search_nom); -if ($search_alias) $sql.= natural_search("s.name_alias", $search_alias); -if ($search_nom_only) $sql.= natural_search("s.nom", $search_nom_only); -if ($search_customer_code) $sql.= natural_search("s.code_client", $search_customer_code); -if ($search_supplier_code) $sql.= natural_search("s.code_fournisseur", $search_supplier_code); -if ($search_account_customer_code) $sql.= natural_search("s.code_compta", $search_account_customer_code); -if ($search_account_supplier_code) $sql.= natural_search("s.code_compta_fournisseur", $search_account_supplier_code); -if ($search_town) $sql.= natural_search("s.town", $search_town); -if (strlen($search_zip)) $sql.= natural_search("s.zip", $search_zip); -if ($search_state) $sql.= natural_search("state.nom", $search_state); -if ($search_region) $sql.= natural_search("region.nom", $search_region); +if ($search_id > 0) $sql .= natural_search("s.rowid", $search_id, 1); +if ($search_nom) $sql .= natural_search("s.nom", $search_nom); +if ($search_alias) $sql .= natural_search("s.name_alias", $search_alias); +if ($search_nom_only) $sql .= natural_search("s.nom", $search_nom_only); +if ($search_customer_code) $sql .= natural_search("s.code_client", $search_customer_code); +if ($search_supplier_code) $sql .= natural_search("s.code_fournisseur", $search_supplier_code); +if ($search_account_customer_code) $sql .= natural_search("s.code_compta", $search_account_customer_code); +if ($search_account_supplier_code) $sql .= natural_search("s.code_compta_fournisseur", $search_account_supplier_code); +if ($search_town) $sql .= natural_search("s.town", $search_town); +if (strlen($search_zip)) $sql .= natural_search("s.zip", $search_zip); +if ($search_state) $sql .= natural_search("state.nom", $search_state); +if ($search_region) $sql .= natural_search("region.nom", $search_region); if ($search_country && $search_country != '-1') $sql .= " AND s.fk_pays IN (".$db->escape($search_country).')'; -if ($search_email) $sql.= natural_search("s.email", $search_email); -if (strlen($search_phone)) $sql.= natural_search("s.phone", $search_phone); -if (strlen($search_fax)) $sql.= natural_search("s.fax", $search_fax); -if ($search_url) $sql.= natural_search("s.url", $search_url); -if (strlen($search_idprof1)) $sql.= natural_search("s.siren", $search_idprof1); -if (strlen($search_idprof2)) $sql.= natural_search("s.siret", $search_idprof2); -if (strlen($search_idprof3)) $sql.= natural_search("s.ape", $search_idprof3); -if (strlen($search_idprof4)) $sql.= natural_search("s.idprof4", $search_idprof4); -if (strlen($search_idprof5)) $sql.= natural_search("s.idprof5", $search_idprof5); -if (strlen($search_idprof6)) $sql.= natural_search("s.idprof6", $search_idprof6); -if (strlen($search_vat)) $sql.= natural_search("s.tva_intra", $search_vat); +if ($search_email) $sql .= natural_search("s.email", $search_email); +if (strlen($search_phone)) $sql .= natural_search("s.phone", $search_phone); +if (strlen($search_fax)) $sql .= natural_search("s.fax", $search_fax); +if ($search_url) $sql .= natural_search("s.url", $search_url); +if (strlen($search_idprof1)) $sql .= natural_search("s.siren", $search_idprof1); +if (strlen($search_idprof2)) $sql .= natural_search("s.siret", $search_idprof2); +if (strlen($search_idprof3)) $sql .= natural_search("s.ape", $search_idprof3); +if (strlen($search_idprof4)) $sql .= natural_search("s.idprof4", $search_idprof4); +if (strlen($search_idprof5)) $sql .= natural_search("s.idprof5", $search_idprof5); +if (strlen($search_idprof6)) $sql .= natural_search("s.idprof6", $search_idprof6); +if (strlen($search_vat)) $sql .= natural_search("s.tva_intra", $search_vat); // Filter on type of thirdparty -if ($search_type > 0 && in_array($search_type, array('1,3','2,3'))) $sql .= " AND s.client IN (".$db->escape($search_type).")"; +if ($search_type > 0 && in_array($search_type, array('1,3', '2,3'))) $sql .= " AND s.client IN (".$db->escape($search_type).")"; if ($search_type > 0 && in_array($search_type, array('4'))) $sql .= " AND s.fournisseur = 1"; if ($search_type == '0') $sql .= " AND s.client = 0 AND s.fournisseur = 0"; -if ($search_status!='' && $search_status >= 0) $sql .= natural_search("s.status", $search_status, 2); -if (!empty($conf->barcode->enabled) && $search_barcode) $sql.= natural_search("s.barcode", $search_barcode); -if ($search_type_thirdparty && $search_type_thirdparty != '-1') $sql.= natural_search("s.fk_typent", $search_type_thirdparty, 2); -if (! empty($search_staff) && $search_staff != '-1') $sql.= natural_search("s.fk_effectif", $search_staff, 2); +if ($search_status != '' && $search_status >= 0) $sql .= natural_search("s.status", $search_status, 2); +if (!empty($conf->barcode->enabled) && $search_barcode) $sql .= natural_search("s.barcode", $search_barcode); +if ($search_type_thirdparty && $search_type_thirdparty != '-1') $sql .= natural_search("s.fk_typent", $search_type_thirdparty, 2); +if (!empty($search_staff) && $search_staff != '-1') $sql .= natural_search("s.fk_effectif", $search_staff, 2); if ($search_level) $sql .= natural_search("s.fk_prospectlevel", join(',', $search_level), 3); -if ($search_parent_name) $sql.= natural_search("s2.nom", $search_parent_name); -if ($search_stcomm != '' && $search_stcomm != -2) $sql.= natural_search("s.fk_stcomm", $search_stcomm, 2); -if ($search_import_key) $sql.= natural_search("s.import_key", $search_import_key); +if ($search_parent_name) $sql .= natural_search("s2.nom", $search_parent_name); +if ($search_stcomm != '' && $search_stcomm != -2) $sql .= natural_search("s.fk_stcomm", $search_stcomm, 2); +if ($search_import_key) $sql .= natural_search("s.import_key", $search_import_key); // Add where from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php'; // Add where from hooks -$parameters=array(); -$reshook=$hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook -$sql.=$hookmanager->resPrint; +$parameters = array(); +$reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook +$sql .= $hookmanager->resPrint; -$sql.= $db->order($sortfield, $sortorder); +$sql .= $db->order($sortfield, $sortorder); // Count total nb of records $nbtotalofrecords = ''; @@ -626,258 +626,258 @@ print ''; print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'building', 0, $newcardbutton, '', $limit); $langs->load("other"); -$textprofid=array(); -foreach(array(1,2,3,4,5,6) as $key) +$textprofid = array(); +foreach (array(1, 2, 3, 4, 5, 6) as $key) { - $label=$langs->transnoentities("ProfId".$key.$mysoc->country_code); - $textprofid[$key]=''; + $label = $langs->transnoentities("ProfId".$key.$mysoc->country_code); + $textprofid[$key] = ''; if ($label != "ProfId".$key.$mysoc->country_code) { // Get only text between () - if (preg_match('/\((.*)\)/i', $label, $reg)) $label=$reg[1]; - $textprofid[$key]=$langs->trans("ProfIdShortDesc", $key, $mysoc->country_code, $label); + if (preg_match('/\((.*)\)/i', $label, $reg)) $label = $reg[1]; + $textprofid[$key] = $langs->trans("ProfIdShortDesc", $key, $mysoc->country_code, $label); } } -$topicmail="Information"; -$modelmail="thirdparty"; -$objecttmp=new Societe($db); -$trackid='thi'.$object->id; +$topicmail = "Information"; +$modelmail = "thirdparty"; +$objecttmp = new Societe($db); +$trackid = 'thi'.$object->id; include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php'; if ($search_all) { - foreach($fieldstosearchall as $key => $val) $fieldstosearchall[$key]=$langs->trans($val); - print '
'.$langs->trans("FilterOnInto", $search_all) . join(', ', $fieldstosearchall).'
'; + foreach ($fieldstosearchall as $key => $val) $fieldstosearchall[$key] = $langs->trans($val); + print '
'.$langs->trans("FilterOnInto", $search_all).join(', ', $fieldstosearchall).'
'; } // Filter on categories -$moreforfilter=''; +$moreforfilter = ''; if (empty($type) || $type == 'c' || $type == 'p') { - if (! empty($conf->categorie->enabled)) + if (!empty($conf->categorie->enabled)) { - require_once DOL_DOCUMENT_ROOT . '/categories/class/categorie.class.php'; - $moreforfilter.='
'; - $moreforfilter.=$langs->trans('CustomersProspectsCategoriesShort').': '; - $moreforfilter.=$formother->select_categories('customer', $search_categ_cus, 'search_categ_cus', 1, $langs->trans('CustomersProspectsCategoriesShort')); - $moreforfilter.='
'; + require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; + $moreforfilter .= '
'; + $moreforfilter .= $langs->trans('CustomersProspectsCategoriesShort').': '; + $moreforfilter .= $formother->select_categories('customer', $search_categ_cus, 'search_categ_cus', 1, $langs->trans('CustomersProspectsCategoriesShort')); + $moreforfilter .= '
'; } } if (empty($type) || $type == 'f') { - if (! empty($conf->categorie->enabled)) + if (!empty($conf->categorie->enabled)) { - require_once DOL_DOCUMENT_ROOT . '/categories/class/categorie.class.php'; - $moreforfilter.='
'; - $moreforfilter.=$langs->trans('SuppliersCategoriesShort').': '; - $moreforfilter.=$formother->select_categories('supplier', $search_categ_sup, 'search_categ_sup', 1); - $moreforfilter.='
'; + require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; + $moreforfilter .= '
'; + $moreforfilter .= $langs->trans('SuppliersCategoriesShort').': '; + $moreforfilter .= $formother->select_categories('supplier', $search_categ_sup, 'search_categ_sup', 1); + $moreforfilter .= '
'; } } // If the user can view prospects other than his' if ($user->rights->societe->client->voir || $socid) { - $moreforfilter.='
'; - $moreforfilter.=$langs->trans('SalesRepresentatives'). ': '; - $moreforfilter.=$formother->select_salesrepresentatives($search_sale, 'search_sale', $user, 0, 1, 'maxwidth300', 1); - $moreforfilter.='
'; + $moreforfilter .= '
'; + $moreforfilter .= $langs->trans('SalesRepresentatives').': '; + $moreforfilter .= $formother->select_salesrepresentatives($search_sale, 'search_sale', $user, 0, 1, 'maxwidth300', 1); + $moreforfilter .= '
'; } if ($moreforfilter) { print '
'; print $moreforfilter; - $parameters=array('type'=>$type); - $reshook=$hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook + $parameters = array('type'=>$type); + $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; print '
'; } -$varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage; -$selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields -if ($massactionbutton && $contextpage != 'poslist') $selectedfields.=$form->showCheckAddButtons('checkforselect', 1); +$varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage; +$selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields +if ($massactionbutton && $contextpage != 'poslist') $selectedfields .= $form->showCheckAddButtons('checkforselect', 1); if (empty($arrayfields['customerorsupplier']['checked'])) print ''; print '
'; -print ''."\n"; +print '
'."\n"; // Fields title search print ''; -if (! empty($arrayfields['s.rowid']['checked'])) +if (!empty($arrayfields['s.rowid']['checked'])) { print ''; } -if (! empty($arrayfields['s.nom']['checked'])) +if (!empty($arrayfields['s.nom']['checked'])) { print ''; } -if (! empty($arrayfields['s.name_alias']['checked'])) +if (!empty($arrayfields['s.name_alias']['checked'])) { print ''; } // Barcode -if (! empty($arrayfields['s.barcode']['checked'])) +if (!empty($arrayfields['s.barcode']['checked'])) { print ''; } // Customer code -if (! empty($arrayfields['s.code_client']['checked'])) +if (!empty($arrayfields['s.code_client']['checked'])) { print ''; } // Supplier code -if (! empty($arrayfields['s.code_fournisseur']['checked'])) +if (!empty($arrayfields['s.code_fournisseur']['checked'])) { print ''; } // Account Customer code -if (! empty($arrayfields['s.code_compta']['checked'])) +if (!empty($arrayfields['s.code_compta']['checked'])) { print ''; } // Account Supplier code -if (! empty($arrayfields['s.code_compta_fournisseur']['checked'])) +if (!empty($arrayfields['s.code_compta_fournisseur']['checked'])) { print ''; } // Town -if (! empty($arrayfields['s.town']['checked'])) +if (!empty($arrayfields['s.town']['checked'])) { print ''; } // Zip -if (! empty($arrayfields['s.zip']['checked'])) +if (!empty($arrayfields['s.zip']['checked'])) { print ''; } // State -if (! empty($arrayfields['state.nom']['checked'])) +if (!empty($arrayfields['state.nom']['checked'])) { print ''; } // Region -if (! empty($arrayfields['region.nom']['checked'])) +if (!empty($arrayfields['region.nom']['checked'])) { print ''; } // Country -if (! empty($arrayfields['country.code_iso']['checked'])) +if (!empty($arrayfields['country.code_iso']['checked'])) { print ''; } // Company type -if (! empty($arrayfields['typent.code']['checked'])) +if (!empty($arrayfields['typent.code']['checked'])) { print ''; } // Staff -if (! empty($arrayfields['staff.code']['checked'])) +if (!empty($arrayfields['staff.code']['checked'])) { print ''; } -if (! empty($arrayfields['s.email']['checked'])) +if (!empty($arrayfields['s.email']['checked'])) { // Email print ''; } -if (! empty($arrayfields['s.phone']['checked'])) +if (!empty($arrayfields['s.phone']['checked'])) { // Phone print ''; } -if (! empty($arrayfields['s.fax']['checked'])) +if (!empty($arrayfields['s.fax']['checked'])) { // Fax print ''; } -if (! empty($arrayfields['s.url']['checked'])) +if (!empty($arrayfields['s.url']['checked'])) { // Url print ''; } -if (! empty($arrayfields['s.siren']['checked'])) +if (!empty($arrayfields['s.siren']['checked'])) { // IdProf1 print ''; } -if (! empty($arrayfields['s.siret']['checked'])) +if (!empty($arrayfields['s.siret']['checked'])) { // IdProf2 print ''; } -if (! empty($arrayfields['s.ape']['checked'])) +if (!empty($arrayfields['s.ape']['checked'])) { // IdProf3 print ''; } -if (! empty($arrayfields['s.idprof4']['checked'])) +if (!empty($arrayfields['s.idprof4']['checked'])) { // IdProf4 print ''; } -if (! empty($arrayfields['s.idprof5']['checked'])) +if (!empty($arrayfields['s.idprof5']['checked'])) { // IdProf5 print ''; } -if (! empty($arrayfields['s.idprof6']['checked'])) +if (!empty($arrayfields['s.idprof6']['checked'])) { // IdProf6 print ''; } -if (! empty($arrayfields['s.tva_intra']['checked'])) +if (!empty($arrayfields['s.tva_intra']['checked'])) { // Vat number print '
'; print ''; print ''; - if (! empty($search_nom_only) && empty($search_nom)) $search_nom=$search_nom_only; + if (!empty($search_nom_only) && empty($search_nom)) $search_nom = $search_nom_only; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print $form->select_country($search_country, 'search_country', '', 0, 'minwidth100imp maxwidth100'); print ''; - print $form->selectarray("search_type_thirdparty", $formcompany->typent_array(0), $search_type_thirdparty, 0, 0, 0, '', 0, 0, 0, (empty($conf->global->SOCIETE_SORT_ON_TYPEENT)?'ASC':$conf->global->SOCIETE_SORT_ON_TYPEENT)); + print $form->selectarray("search_type_thirdparty", $formcompany->typent_array(0), $search_type_thirdparty, 0, 0, 0, '', 0, 0, 0, (empty($conf->global->SOCIETE_SORT_ON_TYPEENT) ? 'ASC' : $conf->global->SOCIETE_SORT_ON_TYPEENT)); print ''; print $form->selectarray("search_staff", $formcompany->effectif_array(0), $search_staff, 0, 0, 0, '', 0, 0, 0, $sort, 'maxwidth100'); print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; diff --git a/htdocs/societe/project.php b/htdocs/societe/project.php index c6029544c90..1c2604e0e44 100644 --- a/htdocs/societe/project.php +++ b/htdocs/societe/project.php @@ -35,7 +35,7 @@ $langs->loadLangs(array("companies", "projects")); // Security check $socid = GETPOST('socid', 'int'); -if ($user->socid) $socid=$user->socid; +if ($user->socid) $socid = $user->socid; $result = restrictedArea($user, 'societe', $socid, '&societe'); // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context @@ -46,8 +46,8 @@ $hookmanager->initHooks(array('projectthirdparty')); * Actions */ -$parameters=array('id'=>$socid); -$reshook=$hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks +$parameters = array('id'=>$socid); +$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); @@ -71,25 +71,25 @@ if ($socid) $object = new Societe($db); $result = $object->fetch($socid); - $title=$langs->trans("Projects"); - if (! empty($conf->global->MAIN_HTML_TITLE) && preg_match('/thirdpartynameonly/', $conf->global->MAIN_HTML_TITLE) && $object->name) $title=$object->name." - ".$title; + $title = $langs->trans("Projects"); + if (!empty($conf->global->MAIN_HTML_TITLE) && preg_match('/thirdpartynameonly/', $conf->global->MAIN_HTML_TITLE) && $object->name) $title = $object->name." - ".$title; llxHeader('', $title); - if (! empty($conf->notification->enabled)) $langs->load("mails"); + if (!empty($conf->notification->enabled)) $langs->load("mails"); $head = societe_prepare_head($object); dol_fiche_head($head, 'project', $langs->trans("ThirdParty"), -1, 'company'); $linkback = ''.$langs->trans("BackToList").''; - dol_banner_tab($object, 'socid', $linkback, ($user->socid?0:1), 'rowid', 'nom'); + dol_banner_tab($object, 'socid', $linkback, ($user->socid ? 0 : 1), 'rowid', 'nom'); print '
'; print '
'; print ''; - if (! empty($conf->global->SOCIETE_USEPREFIX)) // Old not used prefix field + if (!empty($conf->global->SOCIETE_USEPREFIX)) // Old not used prefix field { print ''; } @@ -126,7 +126,7 @@ if ($socid) // Projects list - $result=show_projects($conf, $langs, $db, $object, $_SERVER["PHP_SELF"].'?socid='.$object->id, 1, $newcardbutton); + $result = show_projects($conf, $langs, $db, $object, $_SERVER["PHP_SELF"].'?socid='.$object->id, 1, $newcardbutton); } // End of page diff --git a/htdocs/takepos/admin/setup.php b/htdocs/takepos/admin/setup.php index c1fa8b10b42..17e286d2064 100644 --- a/htdocs/takepos/admin/setup.php +++ b/htdocs/takepos/admin/setup.php @@ -265,17 +265,17 @@ print $langs->trans("SortProductField"); print '\n"; -$substitutionarray=pdf_getSubstitutionArray($langs, null, null, 2); -$substitutionarray['__(AnyTranslationKey)__']=$langs->trans("Translation"); +$substitutionarray = pdf_getSubstitutionArray($langs, null, null, 2); +$substitutionarray['__(AnyTranslationKey)__'] = $langs->trans("Translation"); $htmltext = ''.$langs->trans("AvailableVariables").':
'; -foreach($substitutionarray as $key => $val) $htmltext.=$key.'
'; -$htmltext.='
'; +foreach ($substitutionarray as $key => $val) $htmltext .= $key.'
'; +$htmltext .= ''; // Color theme print '
'.$langs->trans('Prefix').''.$object->prefix_comm.'
'; $prod = new Product($db); $array = []; -foreach($prod->fields as $k => $v) { - $array[$k]=$k; +foreach ($prod->fields as $k => $v) { + $array[$k] = $k; } -print $form->selectarray('TAKEPOS_SORTPRODUCTFIELD', $array, (empty($conf->global->TAKEPOS_SORTPRODUCTFIELD)?'rowid':$conf->global->TAKEPOS_SORTPRODUCTFIELD), 0); +print $form->selectarray('TAKEPOS_SORTPRODUCTFIELD', $array, (empty($conf->global->TAKEPOS_SORTPRODUCTFIELD) ? 'rowid' : $conf->global->TAKEPOS_SORTPRODUCTFIELD), 0); print "
'; print $langs->trans("ColorTheme"); diff --git a/htdocs/theme/md/dropdown.inc.php b/htdocs/theme/md/dropdown.inc.php index 93dfc532197..5889485664a 100644 --- a/htdocs/theme/md/dropdown.inc.php +++ b/htdocs/theme/md/dropdown.inc.php @@ -1,5 +1,5 @@ +if (!defined('ISLOADEDBYSTEELSHEET')) die('Must be call by steelsheet'); ?> /*