From 4449c6d2a7e692265ab8366f2db925ca38c35912 Mon Sep 17 00:00:00 2001 From: Anthony Berton <34568357+bb2a@users.noreply.github.com> Date: Fri, 8 Nov 2019 16:34:20 +0100 Subject: [PATCH 001/154] Update functions.lib.php --- htdocs/core/lib/functions.lib.php | 85 ++++++++++++++++++++++--------- 1 file changed, 61 insertions(+), 24 deletions(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 740093ba801..c62a9ff68fc 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -5954,16 +5954,27 @@ function getCommonSubstitutionArray($outputlangs, $onlykey = 0, $exclude = null, $substitutionarray['__THIRDPARTY_EMAIL__'] = '__THIRDPARTY_EMAIL__'; $substitutionarray['__THIRDPARTY_PHONE__'] = '__THIRDPARTY_PHONE__'; $substitutionarray['__THIRDPARTY_FAX__'] = '__THIRDPARTY_FAX__'; - $substitutionarray['__THIRDPARTY_ADRESSE__'] = '__THIRDPARTY_ADRESSE__'; + $substitutionarray['__THIRDPARTY_ADDRESS__'] = '__THIRDPARTY_ADDRESS__'; $substitutionarray['__THIRDPARTY_ZIP__'] = '__THIRDPARTY_ZIP__'; $substitutionarray['__THIRDPARTY_TOWN__'] = '__THIRDPARTY_TOWN__'; - $substitutionarray['__THIRDPARTY_SIREN__'] = '__THIRDPARTY_SIREN__'; - $substitutionarray['__THIRDPARTY_SIRET__'] = '__THIRDPARTY_SIRET__'; - $substitutionarray['__THIRDPARTY_APE__'] = '__THIRDPARTY_APE__'; - $substitutionarray['__THIRDPARTY_RCSRM__'] = '__THIRDPARTY_RCSRM__'; + $substitutionarray['__THIRDPARTY_IDPROF1__'] = '__THIRDPARTY_IDPROF1__'; + $substitutionarray['__THIRDPARTY_IDPROF2__'] = '__THIRDPARTY_IDPROF2__'; + $substitutionarray['__THIRDPARTY_IDPROF3__'] = '__THIRDPARTY_IDPROF3__'; + $substitutionarray['__THIRDPARTY_IDPROF4__'] = '__THIRDPARTY_IDPROF4__'; + $substitutionarray['__THIRDPARTY_IDPROF5__'] = '__THIRDPARTY_IDPROF5__'; + $substitutionarray['__THIRDPARTY_IDPROF6__'] = '__THIRDPARTY_IDPROF6__'; $substitutionarray['__THIRDPARTY_TVAINTRA__'] = '__THIRDPARTY_TVAINTRA__'; - /*$substitutionarray['__THIRDPARTY_NOTE_PUBLIC__'] = '__THIRDPARTY_NOTE_PUBLIC__'; - $substitutionarray['__THIRDPARTY_NOTE_PRIVATE__'] = '__THIRDPARTY_NOTE_PRIVATE__';*/ + $substitutionarray['__THIRDPARTY_SKYPE__'] = '__THIRDPARTY_SKYPE__'; + $substitutionarray['__THIRDPARTY_TWITTER__'] = '__THIRDPARTY_TWITTER__'; + $substitutionarray['__THIRDPARTY_FACEBOOK__'] = '__THIRDPARTY_FACEBOOK__'; + $substitutionarray['__THIRDPARTY_INSTAGRAM__'] = '__THIRDPARTY_INSTAGRAM__'; + $substitutionarray['__THIRDPARTY_SNAPCHAT__'] = '__THIRDPARTY_SNAPCHAT__'; + $substitutionarray['__THIRDPARTY_GOOGLEPLUS__'] = '__THIRDPARTY_GOOGLEPLUS__'; + $substitutionarray['__THIRDPARTY_YOUTUBE__'] = '__THIRDPARTY_YOUTUBE__'; + $substitutionarray['__THIRDPARTY_WHATSAPP__'] = '__THIRDPARTY_WHATSAPP__'; + $substitutionarray['__THIRDPARTY_LINKEDIN__'] = '__THIRDPARTY_LINKEDIN__'; + $substitutionarray['__THIRDPARTY_NOTE_PUBLIC__'] = '__THIRDPARTY_NOTE_PUBLIC__'; + $substitutionarray['__THIRDPARTY_NOTE_PRIVATE__'] = '__THIRDPARTY_NOTE_PRIVATE__'; } if (! empty($conf->adherent->enabled)) { @@ -6064,15 +6075,28 @@ function getCommonSubstitutionArray($outputlangs, $onlykey = 0, $exclude = null, $substitutionarray['__THIRDPARTY_CODE_FOURNISSEUR__'] = (is_object($object)?$object->code_fournisseur:''); $substitutionarray['__THIRDPARTY_EMAIL__'] = (is_object($object)?$object->email:''); $substitutionarray['__THIRDPARTY_PHONE__'] = (is_object($object)?$object->phone:''); - $substitutionarray['__THIRDPARTY_FAX__'] = (is_object($object)?$object->name_fax:''); - $substitutionarray['__THIRDPARTY_ADRESSE__'] = (is_object($object)?$object->address:''); + $substitutionarray['__THIRDPARTY_FAX__'] = (is_object($object)?$object->fax:''); + $substitutionarray['__THIRDPARTY_ADDRESS__'] = (is_object($object)?$object->address:''); $substitutionarray['__THIRDPARTY_ZIP__'] = (is_object($object)?$object->zip:''); $substitutionarray['__THIRDPARTY_TOWN__'] = (is_object($object)?$object->town:''); - $substitutionarray['__THIRDPARTY_SIREN__'] = (is_object($object)?$object->idprof1:''); - $substitutionarray['__THIRDPARTY_SIRET__'] = (is_object($object)?$object->idprof2:''); - $substitutionarray['__THIRDPARTY_APE__'] = (is_object($object)?$object->idprof3:''); - $substitutionarray['__THIRDPARTY_RCSRM__'] = (is_object($object)?$object->idprof4:''); + $substitutionarray['__THIRDPARTY_IDPROF1__'] = (is_object($object)?$object->idprof1:''); + $substitutionarray['__THIRDPARTY_IDPROF2__'] = (is_object($object)?$object->idprof2:''); + $substitutionarray['__THIRDPARTY_IDPROF3__'] = (is_object($object)?$object->idprof3:''); + $substitutionarray['__THIRDPARTY_IDPROF4__'] = (is_object($object)?$object->idprof4:''); + $substitutionarray['__THIRDPARTY_IDPROF5__'] = (is_object($object)?$object->idprof5:''); + $substitutionarray['__THIRDPARTY_IDPROF6__'] = (is_object($object)?$object->idprof6:''); $substitutionarray['__THIRDPARTY_TVAINTRA__'] = (is_object($object)?$object->tva_intra:''); + $substitutionarray['__THIRDPARTY_SKYPE__'] = (is_object($object)?$object->skype:''); + $substitutionarray['__THIRDPARTY_TWITTER__'] = (is_object($object)?$object->twitter:''); + $substitutionarray['__THIRDPARTY_FACEBOOK__'] = (is_object($object)?$object->facebook:''); + $substitutionarray['__THIRDPARTY_INSTAGRAM__'] = (is_object($object)?$object->instagram:''); + $substitutionarray['__THIRDPARTY_SNAPCHAT__'] = (is_object($object)?$object->snapchat:''); + $substitutionarray['__THIRDPARTY_GOOGLEPLUS__'] = (is_object($object)?$object->googleplus:''); + $substitutionarray['__THIRDPARTY_YOUTUBE__'] = (is_object($object)?$object->youtube:''); + $substitutionarray['__THIRDPARTY_WHATSAPP__'] = (is_object($object)?$object->watsapp:''); + $substitutionarray['__THIRDPARTY_LINKEDIN__'] = (is_object($object)?$object->linkedin:''); + $substitutionarray['__THIRDPARTY_NOTE_PUBLIC__'] = (is_object($object)?dol_htmlentitiesbr($object->note_public):''); + $substitutionarray['__THIRDPARTY_NOTE_PRIVATE__'] = (is_object($object)?dol_htmlentitiesbr($object->note_private):''); } elseif (is_object($object->thirdparty) && $object->thirdparty->id > 0) { @@ -6080,18 +6104,31 @@ function getCommonSubstitutionArray($outputlangs, $onlykey = 0, $exclude = null, $substitutionarray['__THIRDPARTY_NAME__'] = (is_object($object->thirdparty)?$object->thirdparty->name:''); $substitutionarray['__THIRDPARTY_NAME_ALIAS__'] = (is_object($object->thirdparty)?$object->thirdparty->name_alias:''); $substitutionarray['__THIRDPARTY_CODE_CLIENT__'] = (is_object($object->thirdparty)?$object->thirdparty->code_client:''); - $substitutionarray['__THIRDPARTY_CODE_FOURNISSEUR__'] = (is_object($object->thirdparty)?$object->thirdparty->code_fournisseur:''); + $substitutionarray['__THIRDPARTY_CODE_FOURNISSEUR__'] = (is_object($object->thirdparty)?$object->thirdparty->code_fournisseur:''); $substitutionarray['__THIRDPARTY_EMAIL__'] = (is_object($object->thirdparty)?$object->thirdparty->email:''); - $substitutionarray['__THIRDPARTY_PHONE__'] = (is_object($object->thirdparty)?$object->phone:''); - $substitutionarray['__THIRDPARTY_FAX__'] = (is_object($object->thirdparty)?$object->name_fax:''); - $substitutionarray['__THIRDPARTY_ADRESSE__'] = (is_object($object->thirdparty)?$object->address:''); - $substitutionarray['__THIRDPARTY_ZIP__'] = (is_object($object->thirdparty)?$object->zip:''); - $substitutionarray['__THIRDPARTY_TOWN__'] = (is_object($object->thirdparty)?$object->town:''); - $substitutionarray['__THIRDPARTY_SIREN__'] = (is_object($object->thirdparty)?$object->idprof1:''); - $substitutionarray['__THIRDPARTY_SIRET__'] = (is_object($object->thirdparty)?$object->idprof2:''); - $substitutionarray['__THIRDPARTY_APE__'] = (is_object($object->thirdparty)?$object->idprof3:''); - $substitutionarray['__THIRDPARTY_RCSRM__'] = (is_object($object->thirdparty)?$object->idprof4:''); - $substitutionarray['__THIRDPARTY_TVAINTRA__'] = (is_object($object->thirdparty)?$object->tva_intra:''); + $substitutionarray['__THIRDPARTY_PHONE__'] = (is_object($object->thirdparty)?$object->thirdparty->phone:''); + $substitutionarray['__THIRDPARTY_FAX__'] = (is_object($object->thirdparty)?$object->thirdparty->fax:''); + $substitutionarray['__THIRDPARTY_ADDRESS__'] = (is_object($object->thirdparty)?$object->thirdparty->address:''); + $substitutionarray['__THIRDPARTY_ZIP__'] = (is_object($object->thirdparty)?$object->thirdparty->zip:''); + $substitutionarray['__THIRDPARTY_TOWN__'] = (is_object($object->thirdparty)?$object->thirdparty->town:''); + $substitutionarray['__THIRDPARTY_IDPROF1__'] = (is_object($object->thirdparty)?$object->thirdparty->idprof1:''); + $substitutionarray['__THIRDPARTY_IDPROF2__'] = (is_object($object->thirdparty)?$object->thirdparty->idprof2:''); + $substitutionarray['__THIRDPARTY_IDPROF3__'] = (is_object($object->thirdparty)?$object->thirdparty->idprof3:''); + $substitutionarray['__THIRDPARTY_IDPROF4__'] = (is_object($object->thirdparty)?$object->thirdparty->idprof4:''); + $substitutionarray['__THIRDPARTY_IDPROF5__'] = (is_object($object->thirdparty)?$object->thirdparty->idprof5:''); + $substitutionarray['__THIRDPARTY_IDPROF6__'] = (is_object($object->thirdparty)?$object->thirdparty->idprof6:''); + $substitutionarray['__THIRDPARTY_TVAINTRA__'] = (is_object($object->thirdparty)?$object->thirdparty->tva_intra:''); + $substitutionarray['__THIRDPARTY_SKYPE__'] = (is_object($object->thirdparty)?$object->thirdparty->skype:''); + $substitutionarray['__THIRDPARTY_TWITTER__'] = (is_object($object->thirdparty)?$object->thirdparty->twitter:''); + $substitutionarray['__THIRDPARTY_FACEBOOK__'] = (is_object($object->thirdparty)?$object->thirdparty->facebook:''); + $substitutionarray['__THIRDPARTY_INSTAGRAM__'] = (is_object($object->thirdparty)?$object->thirdparty->instagram:''); + $substitutionarray['__THIRDPARTY_SNAPCHAT__'] = (is_object($object->thirdparty)?$object->thirdparty->snapchat:''); + $substitutionarray['__THIRDPARTY_GOOGLEPLUS__'] = (is_object($object->thirdparty)?$object->thirdparty->googleplus:''); + $substitutionarray['__THIRDPARTY_YOUTUBE__'] = (is_object($object->thirdparty)?$object->thirdparty->youtube:''); + $substitutionarray['__THIRDPARTY_WHATSAPP__'] = (is_object($object->thirdparty)?$object->thirdparty->watsapp:''); + $substitutionarray['__THIRDPARTY_LINKEDIN__'] = (is_object($object->thirdparty)?$object->thirdparty->linkedin:''); + $substitutionarray['__THIRDPARTY_NOTE_PUBLIC__'] = (is_object($object->thirdparty)?dol_htmlentitiesbr($object->thirdparty->note_public):''); + $substitutionarray['__THIRDPARTY_NOTE_PRIVATE__'] = (is_object($object->thirdparty)?dol_htmlentitiesbr($object->thirdparty->note_private):''); } if (is_object($object->project) && $object->project->id > 0) From f620b165d3b87d4c7f25c495375cd2e613ce11cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric?= <35066297+c3do@users.noreply.github.com> Date: Fri, 15 Nov 2019 22:17:53 +0100 Subject: [PATCH 002/154] API New get / add / remove product childs --- htdocs/product/class/api_products.class.php | 136 ++++++++++++++++++-- 1 file changed, 127 insertions(+), 9 deletions(-) diff --git a/htdocs/product/class/api_products.class.php b/htdocs/product/class/api_products.class.php index f9a4a12b0df..c2f61604cd9 100644 --- a/htdocs/product/class/api_products.class.php +++ b/htdocs/product/class/api_products.class.php @@ -66,15 +66,16 @@ class Products extends DolibarrApi * * @param int $id ID of product * @param int $includestockdata Load also information about stock (slower) + * @param bool $includesousproduits Load information about virtual product components * @return array|mixed Data without useless information * * @throws 401 * @throws 403 * @throws 404 */ - public function get($id, $includestockdata = 0) + public function get($id, $includestockdata = 0, $includesousproduits = false) { - return $this->_fetch($id, '', '', '', $includestockdata); + return $this->_fetch($id, '', '', '', $includestockdata, $includesousproduits); } /** @@ -84,6 +85,7 @@ class Products extends DolibarrApi * * @param string $ref Ref of element * @param int $includestockdata Load also information about stock (slower) + * @param bool $includesousproduits Load information about virtual product components * * @return array|mixed Data without useless information * @@ -93,9 +95,9 @@ class Products extends DolibarrApi * @throws 403 * @throws 404 */ - public function getByRef($ref, $includestockdata = 0) + public function getByRef($ref, $includestockdata = 0, $includesousproduits = false) { - return $this->_fetch('', $ref, '', '', $includestockdata); + return $this->_fetch('', $ref, '', '', $includestockdata, $includesousproduits); } /** @@ -105,6 +107,7 @@ class Products extends DolibarrApi * * @param string $ref_ext Ref_ext of element * @param int $includestockdata Load also information about stock (slower) + * @param bool $includesousproduits Load information about virtual product components * * @return array|mixed Data without useless information * @@ -114,9 +117,9 @@ class Products extends DolibarrApi * @throws 403 * @throws 404 */ - public function getByRefExt($ref_ext, $includestockdata = 0) + public function getByRefExt($ref_ext, $includestockdata = 0, $includesousproduits = false) { - return $this->_fetch('', '', $ref_ext, '', $includestockdata); + return $this->_fetch('', '', $ref_ext, '', $includestockdata, $includesousproduits); } /** @@ -126,6 +129,7 @@ class Products extends DolibarrApi * * @param string $barcode Barcode of element * @param int $includestockdata Load also information about stock (slower) + * @param bool $includesousproduits Load information about virtual product components * * @return array|mixed Data without useless information * @@ -135,9 +139,9 @@ class Products extends DolibarrApi * @throws 403 * @throws 404 */ - public function getByBarcode($barcode, $includestockdata = 0) + public function getByBarcode($barcode, $includestockdata = 0, $includesousproduits = false) { - return $this->_fetch('', '', '', $barcode, $includestockdata); + return $this->_fetch('', '', '', $barcode, $includestockdata, $includesousproduits); } /** @@ -369,6 +373,105 @@ class Products extends DolibarrApi return $this->product->delete(DolibarrApiAccess::$user); } + + /** + * Get the list of children of the product. + * + * @param int $id Id of parent product/service + * @return array + * + * @throws RestException + * @throws 401 + * @throws 404 + * + * @url GET {id}/childs + */ + public function getChilds($id) + { + if(! DolibarrApiAccess::$user->rights->produit->lire) { + throw new RestException(401); + } + + if(! DolibarrApi::_checkAccessToResource('product', $id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } + + $childsArbo = $this->product->getChildsArbo($id, 1); + + $keys = ['rowid', 'qty', 'fk_product_type', 'label', 'incdec']; + $childs = []; + foreach ($childsArbo as $values) { + $childs[] = array_combine($keys, $values); + } + + return $childs; + } + + /** + * Add product child. + * + * Link a product/service to a parent product/service + * + * @param int $id Id of parent product/service + * @param int $id_fils Id of child product/service + * @param int $qty Quantity + * @param int $incdec 1=Increase/decrease stock of child when parent stock increase/decrease + * @return int + * + * @throws RestException + * @throws 401 + * @throws 404 + * + * @url POST {id}/childs/add + */ + public function addChild($id, $child_id, $qty, $incdec = 1) + { + if(! DolibarrApiAccess::$user->rights->produit->creer) { + throw new RestException(401); + } + + if(! DolibarrApi::_checkAccessToResource('product', $id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } + + $result = $this->product->add_sousproduit($id, $child_id, $qty, $incdec); + if ($result <= 0) { + throw new RestException(500, "Error adding product child"); + } + return $result; + } + + /** + * Remove product child. + * + * Unlink a product/service from a parent product/service + * + * @param int $id Id of parent product/service + * @param int $child_id Id of child product/service + * @return int + * + * @throws RestException + * @throws 401 + * @throws 404 + * + * @url DELETE {id}/childs/remove + */ + public function delChild($id, $child_id) + { + if(! DolibarrApiAccess::$user->rights->produit->creer) { + throw new RestException(401); + } + + if(! DolibarrApi::_checkAccessToResource('product', $id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } + + $result = $this->product->del_sousproduit($id, $child_id); + if ($result <= 0) { + throw new RestException(500, "Error while removing product child"); + } + return $result; + } /** @@ -753,13 +856,14 @@ class Products extends DolibarrApi * @param string $ref_ext Ref ext of element * @param string $barcode Barcode of element * @param int $includestockdata Load also information about stock (slower) + * @param bool $includesousproduits Load information about virtual product components * @return array|mixed Data without useless information * * @throws 401 * @throws 403 * @throws 404 */ - private function _fetch($id, $ref = '', $ref_ext = '', $barcode = '', $includestockdata = 0) + private function _fetch($id, $ref = '', $ref_ext = '', $barcode = '', $includestockdata = 0, $includesousproduits = false) { if (empty($id) && empty($ref) && empty($ref_ext) && empty($barcode)) { throw new RestException(400, 'bad value for parameter id, ref, ref_ext or barcode'); @@ -783,6 +887,20 @@ class Products extends DolibarrApi if ($includestockdata) { $this->product->load_stock(); } + + + + if ($includesousproduits) { + $childsArbo = $this->product->getChildsArbo($id, 1); + + $keys = ['rowid', 'qty', 'fk_product_type', 'label', 'incdec']; + $childs = []; + foreach ($childsArbo as $values) { + $childs[] = array_combine($keys, $values); + } + + $this->product->sousprods = $childs; + } return $this->_cleanObjectDatas($this->product); } From aa7353d3cf25020b627fc7434a2defe5e9e6a67c Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Fri, 15 Nov 2019 21:18:40 +0000 Subject: [PATCH 003/154] Fixing style errors. --- htdocs/product/class/api_products.class.php | 36 ++++++++++----------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/htdocs/product/class/api_products.class.php b/htdocs/product/class/api_products.class.php index c2f61604cd9..1ec1479f24c 100644 --- a/htdocs/product/class/api_products.class.php +++ b/htdocs/product/class/api_products.class.php @@ -373,7 +373,7 @@ class Products extends DolibarrApi return $this->product->delete(DolibarrApiAccess::$user); } - + /** * Get the list of children of the product. * @@ -391,22 +391,22 @@ class Products extends DolibarrApi if(! DolibarrApiAccess::$user->rights->produit->lire) { throw new RestException(401); } - + if(! DolibarrApi::_checkAccessToResource('product', $id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } - + $childsArbo = $this->product->getChildsArbo($id, 1); - + $keys = ['rowid', 'qty', 'fk_product_type', 'label', 'incdec']; $childs = []; foreach ($childsArbo as $values) { $childs[] = array_combine($keys, $values); } - + return $childs; } - + /** * Add product child. * @@ -421,26 +421,26 @@ class Products extends DolibarrApi * @throws RestException * @throws 401 * @throws 404 - * + * * @url POST {id}/childs/add */ public function addChild($id, $child_id, $qty, $incdec = 1) - { + { if(! DolibarrApiAccess::$user->rights->produit->creer) { throw new RestException(401); } - + if(! DolibarrApi::_checkAccessToResource('product', $id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } - + $result = $this->product->add_sousproduit($id, $child_id, $qty, $incdec); if ($result <= 0) { throw new RestException(500, "Error adding product child"); } return $result; } - + /** * Remove product child. * @@ -461,11 +461,11 @@ class Products extends DolibarrApi if(! DolibarrApiAccess::$user->rights->produit->creer) { throw new RestException(401); } - + if(! DolibarrApi::_checkAccessToResource('product', $id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } - + $result = $this->product->del_sousproduit($id, $child_id); if ($result <= 0) { throw new RestException(500, "Error while removing product child"); @@ -887,18 +887,18 @@ class Products extends DolibarrApi if ($includestockdata) { $this->product->load_stock(); } - - - + + + if ($includesousproduits) { $childsArbo = $this->product->getChildsArbo($id, 1); - + $keys = ['rowid', 'qty', 'fk_product_type', 'label', 'incdec']; $childs = []; foreach ($childsArbo as $values) { $childs[] = array_combine($keys, $values); } - + $this->product->sousprods = $childs; } From 04f58f5d32e7b9b4e82c7db4949478b2a4021731 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric?= <35066297+c3do@users.noreply.github.com> Date: Sat, 16 Nov 2019 11:17:56 +0100 Subject: [PATCH 004/154] $includesubproducts and path consistency --- htdocs/product/class/api_products.class.php | 64 ++++++++++----------- 1 file changed, 32 insertions(+), 32 deletions(-) diff --git a/htdocs/product/class/api_products.class.php b/htdocs/product/class/api_products.class.php index 1ec1479f24c..ccfe8f1acf9 100644 --- a/htdocs/product/class/api_products.class.php +++ b/htdocs/product/class/api_products.class.php @@ -64,18 +64,18 @@ class Products extends DolibarrApi * * Return an array with product information. * - * @param int $id ID of product - * @param int $includestockdata Load also information about stock (slower) - * @param bool $includesousproduits Load information about virtual product components + * @param int $id ID of product + * @param int $includestockdata Load also information about stock (slower) + * @param bool $includesubproducts Load information about subproducts * @return array|mixed Data without useless information * * @throws 401 * @throws 403 * @throws 404 */ - public function get($id, $includestockdata = 0, $includesousproduits = false) + public function get($id, $includestockdata = 0, $includesubproducts = false) { - return $this->_fetch($id, '', '', '', $includestockdata, $includesousproduits); + return $this->_fetch($id, '', '', '', $includestockdata, $includesubproducts); } /** @@ -83,21 +83,21 @@ class Products extends DolibarrApi * * Return an array with product information. * - * @param string $ref Ref of element - * @param int $includestockdata Load also information about stock (slower) - * @param bool $includesousproduits Load information about virtual product components + * @param string $ref Ref of element + * @param int $includestockdata Load also information about stock (slower) + * @param bool $includesubproducts Load information about subproducts * * @return array|mixed Data without useless information * - * @url GET byRef/{ref} + * @url GET ref/{ref} * * @throws 401 * @throws 403 * @throws 404 */ - public function getByRef($ref, $includestockdata = 0, $includesousproduits = false) + public function getByRef($ref, $includestockdata = 0, $includesubproducts = false) { - return $this->_fetch('', $ref, '', '', $includestockdata, $includesousproduits); + return $this->_fetch('', $ref, '', '', $includestockdata, $includesubproducts); } /** @@ -105,21 +105,21 @@ class Products extends DolibarrApi * * Return an array with product information. * - * @param string $ref_ext Ref_ext of element - * @param int $includestockdata Load also information about stock (slower) - * @param bool $includesousproduits Load information about virtual product components + * @param string $ref_ext Ref_ext of element + * @param int $includestockdata Load also information about stock (slower) + * @param bool $includesubproducts Load information about subproducts * * @return array|mixed Data without useless information * - * @url GET byRefExt/{ref_ext} + * @url GET ref_ext/{ref_ext} * * @throws 401 * @throws 403 * @throws 404 */ - public function getByRefExt($ref_ext, $includestockdata = 0, $includesousproduits = false) + public function getByRefExt($ref_ext, $includestockdata = 0, $includesubproducts = false) { - return $this->_fetch('', '', $ref_ext, '', $includestockdata, $includesousproduits); + return $this->_fetch('', '', $ref_ext, '', $includestockdata, $includesubproducts); } /** @@ -127,21 +127,21 @@ class Products extends DolibarrApi * * Return an array with product information. * - * @param string $barcode Barcode of element - * @param int $includestockdata Load also information about stock (slower) - * @param bool $includesousproduits Load information about virtual product components + * @param string $barcode Barcode of element + * @param int $includestockdata Load also information about stock (slower) + * @param bool $includesubproducts Load information about subproducts * * @return array|mixed Data without useless information * - * @url GET byBarcode/{barcode} + * @url GET barcode/{barcode} * * @throws 401 * @throws 403 * @throws 404 */ - public function getByBarcode($barcode, $includestockdata = 0, $includesousproduits = false) + public function getByBarcode($barcode, $includestockdata = 0, $includesubproducts = false) { - return $this->_fetch('', '', '', $barcode, $includestockdata, $includesousproduits); + return $this->_fetch('', '', '', $barcode, $includestockdata, $includesubproducts); } /** @@ -851,19 +851,19 @@ class Products extends DolibarrApi * * Return an array with product information. * - * @param int $id ID of product - * @param string $ref Ref of element - * @param string $ref_ext Ref ext of element - * @param string $barcode Barcode of element - * @param int $includestockdata Load also information about stock (slower) - * @param bool $includesousproduits Load information about virtual product components - * @return array|mixed Data without useless information + * @param int $id ID of product + * @param string $ref Ref of element + * @param string $ref_ext Ref ext of element + * @param string $barcode Barcode of element + * @param int $includestockdata Load also information about stock (slower) + * @param bool $includesubproducts Load information about subproducts + * @return array|mixed Data without useless information * * @throws 401 * @throws 403 * @throws 404 */ - private function _fetch($id, $ref = '', $ref_ext = '', $barcode = '', $includestockdata = 0, $includesousproduits = false) + private function _fetch($id, $ref = '', $ref_ext = '', $barcode = '', $includestockdata = 0, $includesubproducts = false) { if (empty($id) && empty($ref) && empty($ref_ext) && empty($barcode)) { throw new RestException(400, 'bad value for parameter id, ref, ref_ext or barcode'); @@ -890,7 +890,7 @@ class Products extends DolibarrApi - if ($includesousproduits) { + if ($includesubproducts) { $childsArbo = $this->product->getChildsArbo($id, 1); $keys = ['rowid', 'qty', 'fk_product_type', 'label', 'incdec']; From 33d4c4b73cd09a064612438f9b3a1c07dad4379c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric?= <35066297+c3do@users.noreply.github.com> Date: Sat, 16 Nov 2019 11:23:50 +0100 Subject: [PATCH 005/154] Doc for $child_id --- htdocs/product/class/api_products.class.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/product/class/api_products.class.php b/htdocs/product/class/api_products.class.php index ccfe8f1acf9..06cf17ea66b 100644 --- a/htdocs/product/class/api_products.class.php +++ b/htdocs/product/class/api_products.class.php @@ -412,10 +412,10 @@ class Products extends DolibarrApi * * Link a product/service to a parent product/service * - * @param int $id Id of parent product/service - * @param int $id_fils Id of child product/service - * @param int $qty Quantity - * @param int $incdec 1=Increase/decrease stock of child when parent stock increase/decrease + * @param int $id Id of parent product/service + * @param int $child_id Id of child product/service + * @param int $qty Quantity + * @param int $incdec 1=Increase/decrease stock of child when parent stock increase/decrease * @return int * * @throws RestException From 256e256f62c00a8b0cdaff829a045f704833a960 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric?= <35066297+c3do@users.noreply.github.com> Date: Sat, 16 Nov 2019 12:30:47 +0100 Subject: [PATCH 006/154] Paths and vars: subproducts instead of childs --- htdocs/product/class/api_products.class.php | 34 ++++++++++----------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/htdocs/product/class/api_products.class.php b/htdocs/product/class/api_products.class.php index 06cf17ea66b..58d53583645 100644 --- a/htdocs/product/class/api_products.class.php +++ b/htdocs/product/class/api_products.class.php @@ -375,7 +375,7 @@ class Products extends DolibarrApi } /** - * Get the list of children of the product. + * Get the list of subproducts of the product. * * @param int $id Id of parent product/service * @return array @@ -384,9 +384,9 @@ class Products extends DolibarrApi * @throws 401 * @throws 404 * - * @url GET {id}/childs + * @url GET {id}/subproducts */ - public function getChilds($id) + public function getSubproducts($id) { if(! DolibarrApiAccess::$user->rights->produit->lire) { throw new RestException(401); @@ -408,23 +408,23 @@ class Products extends DolibarrApi } /** - * Add product child. + * Add subproduct. * * Link a product/service to a parent product/service * - * @param int $id Id of parent product/service - * @param int $child_id Id of child product/service - * @param int $qty Quantity - * @param int $incdec 1=Increase/decrease stock of child when parent stock increase/decrease + * @param int $id Id of parent product/service + * @param int $subproduct_id Id of child product/service + * @param int $qty Quantity + * @param int $incdec 1=Increase/decrease stock of child when parent stock increase/decrease * @return int * * @throws RestException * @throws 401 * @throws 404 * - * @url POST {id}/childs/add + * @url POST {id}/subproducts/add */ - public function addChild($id, $child_id, $qty, $incdec = 1) + public function addSubproducts($id, $subproduct_id, $qty, $incdec = 1) { if(! DolibarrApiAccess::$user->rights->produit->creer) { throw new RestException(401); @@ -434,7 +434,7 @@ class Products extends DolibarrApi throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } - $result = $this->product->add_sousproduit($id, $child_id, $qty, $incdec); + $result = $this->product->add_sousproduit($id, $subproduct_id, $qty, $incdec); if ($result <= 0) { throw new RestException(500, "Error adding product child"); } @@ -442,21 +442,21 @@ class Products extends DolibarrApi } /** - * Remove product child. + * Remove subproduct. * * Unlink a product/service from a parent product/service * - * @param int $id Id of parent product/service - * @param int $child_id Id of child product/service + * @param int $id Id of parent product/service + * @param int $subproduct_id Id of child product/service * @return int * * @throws RestException * @throws 401 * @throws 404 * - * @url DELETE {id}/childs/remove + * @url DELETE {id}/subproducts/remove */ - public function delChild($id, $child_id) + public function delSubproducts($id, $subproduct_id) { if(! DolibarrApiAccess::$user->rights->produit->creer) { throw new RestException(401); @@ -466,7 +466,7 @@ class Products extends DolibarrApi throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } - $result = $this->product->del_sousproduit($id, $child_id); + $result = $this->product->del_sousproduit($id, $subproduct_id); if ($result <= 0) { throw new RestException(500, "Error while removing product child"); } From e1f36ae107777ec3ade5300b3f6621909a071734 Mon Sep 17 00:00:00 2001 From: Anthony Berton <34568357+bb2a@users.noreply.github.com> Date: Sat, 16 Nov 2019 17:37:18 +0100 Subject: [PATCH 007/154] Update functions.lib.php --- 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 c62a9ff68fc..770a8234d06 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -6104,7 +6104,7 @@ function getCommonSubstitutionArray($outputlangs, $onlykey = 0, $exclude = null, $substitutionarray['__THIRDPARTY_NAME__'] = (is_object($object->thirdparty)?$object->thirdparty->name:''); $substitutionarray['__THIRDPARTY_NAME_ALIAS__'] = (is_object($object->thirdparty)?$object->thirdparty->name_alias:''); $substitutionarray['__THIRDPARTY_CODE_CLIENT__'] = (is_object($object->thirdparty)?$object->thirdparty->code_client:''); - $substitutionarray['__THIRDPARTY_CODE_FOURNISSEUR__'] = (is_object($object->thirdparty)?$object->thirdparty->code_fournisseur:''); + $substitutionarray['__THIRDPARTY_CODE_FOURNISSEUR__'] = (is_object($object->thirdparty)?$object->thirdparty->code_fournisseur:''); $substitutionarray['__THIRDPARTY_EMAIL__'] = (is_object($object->thirdparty)?$object->thirdparty->email:''); $substitutionarray['__THIRDPARTY_PHONE__'] = (is_object($object->thirdparty)?$object->thirdparty->phone:''); $substitutionarray['__THIRDPARTY_FAX__'] = (is_object($object->thirdparty)?$object->thirdparty->fax:''); From 8c057f1975d07aaa1b1c14dd506196bd07932361 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric?= <35066297+c3do@users.noreply.github.com> Date: Sun, 17 Nov 2019 01:20:15 +0100 Subject: [PATCH 008/154] API New Product variants --- htdocs/product/class/api_products.class.php | 546 ++++++++++++++++++++ 1 file changed, 546 insertions(+) diff --git a/htdocs/product/class/api_products.class.php b/htdocs/product/class/api_products.class.php index 58d53583645..e3fb4d6079c 100644 --- a/htdocs/product/class/api_products.class.php +++ b/htdocs/product/class/api_products.class.php @@ -21,6 +21,10 @@ use Luracast\Restler\RestException; require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.product.class.php'; require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; +require_once DOL_DOCUMENT_ROOT.'/variants/class/ProductAttribute.class.php'; +require_once DOL_DOCUMENT_ROOT.'/variants/class/ProductAttributeValue.class.php'; +require_once DOL_DOCUMENT_ROOT.'/variants/class/ProductCombination.class.php'; +require_once DOL_DOCUMENT_ROOT.'/variants/class/ProductCombination2ValuePair.class.php'; /** * API class for products @@ -798,6 +802,548 @@ class Products extends DolibarrApi return $this->_cleanObjectDatas($this->productsupplier); } + + /** + * Get attributes. + * + * @return array + * + * @throws RestException + * + * @url GET attributes + */ + public function getAttributes() + { + if(! (DolibarrApiAccess::$user->rights->produit->lire || DolibarrApiAccess::$user->rights->service->lire)) { + throw new RestException(401); + } + + $prodattr = new ProductAttribute($this->db); + return $prodattr->fetchAll(); + } + + /** + * Get attribute by ID. + * + * @param int $id ID of Attribute + * @return array + * + * @throws RestException + * @throws 401 + * @throws 404 + * + * @url GET attributes/{id} + */ + public function getAttributeById($id) + { + if(! (DolibarrApiAccess::$user->rights->produit->lire || DolibarrApiAccess::$user->rights->service->lire)) { + throw new RestException(401); + } + + $prodattr = new ProductAttribute($this->db); + $result = $prodattr->fetch((int) $id); + + if($result < 0) { + throw new RestException(404, "Attribute not found"); + } + + return $prodattr; + } + + /** + * Add attributes. + * + * @param string $ref Reference of Attribute + * @param string $label Label of Attribute + * @return int + * + * @throws RestException + * @throws 401 + * + * @url POST attributes + */ + public function addAttributes($ref, $label) + { + if(! (DolibarrApiAccess::$user->rights->produit->lire || DolibarrApiAccess::$user->rights->service->lire)) { + throw new RestException(401); + } + + $prodattr = new ProductAttribute($this->db); + $prodattr->label = $label; + $prodattr->ref = $ref; + + $resid = $prodattr->create(DolibarrApiAccess::$user); + if ($resid <= 0) { + throw new RestException(500, "Error creating new attribute"); + } + return $resid; + } + + /** + * Update attributes by id. + * + * @param int $id ID of Attribute + * @param string $ref Reference of Attribute + * @param string $label Label of Attribute + * @return int + * + * @throws RestException + * @throws 401 + * @throws 404 + * + * @url PUT attributes/{id} + */ + public function putAttributes($id, $ref, $label) + { + if(! (DolibarrApiAccess::$user->rights->produit->lire || DolibarrApiAccess::$user->rights->service->lire)) { + throw new RestException(401); + } + + $prodattr = new ProductAttribute($this->db); + + $result = $prodattr->fetch((int) $id); + if ($result == 0) { + throw new RestException(404, 'Attribute not found'); + } elseif ($result < 0) { + throw new RestException(500, "Error fetching attribute"); + } + + + $prodattr->label = $label; + $prodattr->ref = $ref; + + if ($prodattr->update(DolibarrApiAccess::$user) > 0) { + return 1; + } + throw new RestException(500, "Error updating attribute"); + } + + /** + * Delete attributes by id. + * + * @param int $id ID of Attribute + * @return int + * + * @throws RestException + * @throws 401 + * + * @url DELETE attributes/{id} + */ + public function deleteAttributes($id) + { + if(! (DolibarrApiAccess::$user->rights->produit->lire || DolibarrApiAccess::$user->rights->service->lire)) { + throw new RestException(401); + } + + $prodattr = new ProductAttribute($this->db); + $prodattr->id = (int) $id; + $result = $prodattr->delete(); + + if ($result > 0) { + return 1; + } + throw new RestException(500, "Error deleting attribute"); + } + + /** + * Delete attributes by ref. + * + * @param string $ref Reference of Attribute + * @return int + * + * @throws RestException + * @throws 401 + * + * @url DELETE attributes/ref/{ref} + */ + public function deleteAttributesByRef($ref) + { + if(! (DolibarrApiAccess::$user->rights->produit->lire || DolibarrApiAccess::$user->rights->service->lire)) { + throw new RestException(401); + } + + $sql = "DELETE FROM ".MAIN_DB_PREFIX."product_attribute WHERE ref LIKE '". trim($ref) ."'"; + + if ($this->db->query($sql)) { + return 1; + } + throw new RestException(500, "Error deleting attribute"); + } + + /** + * Get all values for an attribute id. + * + * @param int $id ID of an Attribute + * @return array + * + * @throws RestException + * @throws 401 + * + * @url GET attributes/{id}/values + */ + public function getAttributeValues($id) + { + if(! (DolibarrApiAccess::$user->rights->produit->lire || DolibarrApiAccess::$user->rights->service->lire)) { + throw new RestException(401); + } + + $objectval = new ProductAttributeValue($this->db); + return $objectval->fetchAllByProductAttribute((int) $id); + } + + /** + * Get all values for an attribute ref. + * + * @param string $ref Ref of an Attribute + * @return array + * + * @throws RestException + * @throws 401 + * + * @url GET attributes/ref/{ref}/values + */ + public function getAttributeValuesByRef($ref) + { + if(! (DolibarrApiAccess::$user->rights->produit->lire || DolibarrApiAccess::$user->rights->service->lire)) { + throw new RestException(401); + } + + $return = array(); + + $sql = 'SELECT '; + $sql .= 'v.fk_product_attribute, v.rowid, v.ref, v.value FROM '.MAIN_DB_PREFIX.'product_attribute_value v '; + $sql .= "WHERE v.fk_product_attribute = ( SELECT rowid FROM ".MAIN_DB_PREFIX."product_attribute WHERE ref LIKE '". strtoupper(trim($ref)) ."' LIMIT 1)"; + + $query = $this->db->query($sql); + + while ($result = $this->db->fetch_object($query)) { + $tmp = new ProductAttributeValue($this->db); + $tmp->fk_product_attribute = $result->fk_product_attribute; + $tmp->id = $result->rowid; + $tmp->ref = $result->ref; + $tmp->value = $result->value; + + $return[] = $tmp; + } + + return $return; + } + + /** + * Add attribute value. + * + * @param int $id ID of Attribute + * @param string $ref Reference of Attribute value + * @param string $value Value of Attribute value + * @return int + * + * @throws RestException + * @throws 401 + * + * @url POST attributes/{id}/values + */ + public function addAttributeValue($id, $ref, $value) + { + if(! (DolibarrApiAccess::$user->rights->produit->lire || DolibarrApiAccess::$user->rights->service->lire)) { + throw new RestException(401); + } + + if (empty($ref) || empty($value)) { + throw new RestException(401); + } + + $objectval = new ProductAttributeValue($this->db); + $objectval->fk_product_attribute = $id; + $objectval->ref = $ref; + $objectval->value = $value; + + if ($objectval->create(DolibarrApiAccess::$user) > 0) { + return $objectval->id; + } + throw new RestException(500, "Error creating new attribute value"); + } + + /** + * Delete attribute value by id. + * + * @param int $id ID of Attribute value + * @return int + * + * @throws RestException + * @throws 401 + * + * @url DELETE attributes/values/{id} + */ + public function deleteAttributeValueById($id) + { + if(! (DolibarrApiAccess::$user->rights->produit->lire || DolibarrApiAccess::$user->rights->service->lire)) { + throw new RestException(401); + } + + $objectval = new ProductAttributeValue($this->db); + $objectval->id = (int) $id; + + if ($objectval->delete() > 0) { + return 1; + } + throw new RestException(500, "Error deleting attribute value"); + } + + /** + * Delete attribute value by ref. + * + * @param string $ref Ref of Attribute value + * @return int + * + * @throws RestException + * @throws 401 + * + * @url DELETE attributes/values/ref/{ref} + */ + public function deleteAttributeValueByRef($ref) + { + if(! (DolibarrApiAccess::$user->rights->produit->lire || DolibarrApiAccess::$user->rights->service->lire)) { + throw new RestException(401); + } + + $sql = "DELETE FROM ".MAIN_DB_PREFIX."product_attribute_value WHERE ref LIKE '". trim($ref) ."'"; + + if ($this->db->query($sql)) { + return 1; + } + + throw new RestException(500, "Error deleting attribute value"); + } + + /** + * Get product variants. + * + * @param int $id ID of Product + * @return array + * + * @throws RestException + * @throws 401 + * + * @url GET {id}/variants + */ + public function getVariants($id) + { + if(! (DolibarrApiAccess::$user->rights->produit->lire || DolibarrApiAccess::$user->rights->service->lire)) { + throw new RestException(401); + } + + $prodcomb = new ProductCombination($this->db); + return $prodcomb->fetchAllByFkProductParent((int) $id); + } + + /** + * Get product variants by Product ref. + * + * @param string $ref Ref of Product + * @return array + * + * @throws RestException + * @throws 401 + * + * @url GET ref/{ref}/variants + */ + public function getVariantsByProdRef($ref) + { + if(! (DolibarrApiAccess::$user->rights->produit->lire || DolibarrApiAccess::$user->rights->service->lire)) { + throw new RestException(401); + } + + $result = $this->product->fetch('', $ref); + if(! $result ) { + throw new RestException(404, 'Product not found'); + } + + $prodcomb = new ProductCombination($this->db); + return $prodcomb->fetchAllByFkProductParent((int) $this->product->id); + } + + /** + * Add variant. + * + * "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, ...) + * @return int + * + * @throws RestException + * @throws 401 + * @throws 404 + * + * @url POST {id}/variants + */ + public function addVariant($id, $weight_impact, $price_impact, $price_impact_is_percent, $features) + { + if(! (DolibarrApiAccess::$user->rights->produit->creer || DolibarrApiAccess::$user->rights->service->creer)) { + throw new RestException(401); + } + + if (empty($id) || empty($weight_impact) || empty($price_impact) || empty($features) || !is_array($features)) { + throw new RestException(401); + } + + $prodattr = new ProductAttribute($this->db); + $prodattr_val = new ProductAttributeValue($this->db); + foreach ($features as $id_attr => $id_value) { + if ($prodattr->fetch((int) $id_attr) < 0) { + throw new RestException(401); + } + if ($prodattr_val->fetch((int) $id_value) < 0) { + throw new RestException(401); + } + } + + $result = $this->product->fetch((int) $id); + if(! $result ) { + throw new RestException(404, 'Product not found'); + } + + $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); + if ($result > 0) + { + return $result; + } else { + throw new RestException(500, "Error creating new product variant"); + } + } else { + return $prodcomb->id; + } + } + + /** + * Add variant by product ref. + * + * "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 string $ref Ref 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, ...) + * @return int + * + * @throws RestException + * @throws 401 + * @throws 404 + * + * @url POST ref/{ref}/variants + */ + public function addVariantByProductRef($ref, $weight_impact, $price_impact, $price_impact_is_percent, $features) + { + if(! (DolibarrApiAccess::$user->rights->produit->creer || DolibarrApiAccess::$user->rights->service->creer)) { + throw new RestException(401); + } + + if (empty($ref) || empty($weight_impact) || empty($price_impact) || empty($features) || !is_array($features)) { + throw new RestException(401); + } + + $prodattr = new ProductAttribute($this->db); + $prodattr_val = new ProductAttributeValue($this->db); + foreach ($features as $id_attr => $id_value) { + if ($prodattr->fetch((int) $id_attr) < 0) { + throw new RestException(404); + } + if ($prodattr_val->fetch((int) $id_value) < 0) { + throw new RestException(404); + } + } + + $result = $this->product->fetch('', trim($ref)); + if(! $result ) { + throw new RestException(404, 'Product not found'); + } + + $prodcomb = new ProductCombination($this->db); + if (! $prodcomb->fetchByProductCombination2ValuePairs($this->product->id, $features)) + { + $result = $prodcomb->createProductCombination(DolibarrApiAccess::$user, $this->product, $features, array(), $price_impact_is_percent, $price_impact, $weight_impact); + if ($result > 0) + { + return $result; + } else { + throw new RestException(500, "Error creating new product variant"); + } + } else { + return $prodcomb->id; + } + } + + /** + * Put product variants. + * + * @param int $id ID of Variant + * @param array $request_data Datas + * @return int + * + * @throws RestException + * @throws 401 + * + * @url PUT variants/{id} + */ + public function putVariant($id, $request_data = null) + { + if(! (DolibarrApiAccess::$user->rights->produit->creer || DolibarrApiAccess::$user->rights->service->creer)) { + throw new RestException(401); + } + + $prodcomb = new ProductCombination($this->db); + $prodcomb->fetch((int) $id); + + $old_prodcomb = dol_clone($prodcomb, 0); + + foreach($request_data as $field => $value) { + if ($field == 'rowid') { continue; + } + $prodcomb->$field = $value; + } + + $result = $prodcomb->update(DolibarrApiAccess::$user); + if ($result > 0) + { + return 1; + } + throw new RestException(500, "Error editing variant"); + } + + /** + * Delete product variants. + * + * @param int $id ID of Variant + * @return int + * + * @throws RestException + * @throws 401 + * + * @url DELETE variants/{id} + */ + public function deleteVariant($id) + { + if(! (DolibarrApiAccess::$user->rights->produit->supprimer || DolibarrApiAccess::$user->rights->service->supprimer)) { + throw new RestException(401); + } + + $prodcomb = new ProductCombination($this->db); + $prodcomb->id = (int) $id; + $result = $prodcomb->delete(DolibarrApiAccess::$user); + return $result; + if ($result > 0) + { + return 1; + } + throw new RestException(500, "Error deleting variant"); + } // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore /** From a17e183da906fddfc0f1a663f8365bcf2482e892 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Sun, 17 Nov 2019 00:18:43 +0000 Subject: [PATCH 009/154] Fixing style errors. --- htdocs/product/class/api_products.class.php | 132 ++++++++++---------- 1 file changed, 66 insertions(+), 66 deletions(-) diff --git a/htdocs/product/class/api_products.class.php b/htdocs/product/class/api_products.class.php index e3fb4d6079c..fd564b17278 100644 --- a/htdocs/product/class/api_products.class.php +++ b/htdocs/product/class/api_products.class.php @@ -802,7 +802,7 @@ class Products extends DolibarrApi return $this->_cleanObjectDatas($this->productsupplier); } - + /** * Get attributes. * @@ -813,15 +813,15 @@ class Products extends DolibarrApi * @url GET attributes */ public function getAttributes() - { + { if(! (DolibarrApiAccess::$user->rights->produit->lire || DolibarrApiAccess::$user->rights->service->lire)) { throw new RestException(401); } - + $prodattr = new ProductAttribute($this->db); return $prodattr->fetchAll(); } - + /** * Get attribute by ID. * @@ -839,17 +839,17 @@ class Products extends DolibarrApi if(! (DolibarrApiAccess::$user->rights->produit->lire || DolibarrApiAccess::$user->rights->service->lire)) { throw new RestException(401); } - + $prodattr = new ProductAttribute($this->db); $result = $prodattr->fetch((int) $id); - + if($result < 0) { throw new RestException(404, "Attribute not found"); } - + return $prodattr; } - + /** * Add attributes. * @@ -867,18 +867,18 @@ class Products extends DolibarrApi if(! (DolibarrApiAccess::$user->rights->produit->lire || DolibarrApiAccess::$user->rights->service->lire)) { throw new RestException(401); } - + $prodattr = new ProductAttribute($this->db); $prodattr->label = $label; $prodattr->ref = $ref; - + $resid = $prodattr->create(DolibarrApiAccess::$user); if ($resid <= 0) { throw new RestException(500, "Error creating new attribute"); } return $resid; } - + /** * Update attributes by id. * @@ -898,26 +898,26 @@ class Products extends DolibarrApi if(! (DolibarrApiAccess::$user->rights->produit->lire || DolibarrApiAccess::$user->rights->service->lire)) { throw new RestException(401); } - + $prodattr = new ProductAttribute($this->db); - + $result = $prodattr->fetch((int) $id); if ($result == 0) { throw new RestException(404, 'Attribute not found'); } elseif ($result < 0) { throw new RestException(500, "Error fetching attribute"); } - - + + $prodattr->label = $label; $prodattr->ref = $ref; - + if ($prodattr->update(DolibarrApiAccess::$user) > 0) { return 1; } throw new RestException(500, "Error updating attribute"); } - + /** * Delete attributes by id. * @@ -934,17 +934,17 @@ class Products extends DolibarrApi if(! (DolibarrApiAccess::$user->rights->produit->lire || DolibarrApiAccess::$user->rights->service->lire)) { throw new RestException(401); } - + $prodattr = new ProductAttribute($this->db); $prodattr->id = (int) $id; $result = $prodattr->delete(); - + if ($result > 0) { return 1; } throw new RestException(500, "Error deleting attribute"); } - + /** * Delete attributes by ref. * @@ -961,15 +961,15 @@ class Products extends DolibarrApi if(! (DolibarrApiAccess::$user->rights->produit->lire || DolibarrApiAccess::$user->rights->service->lire)) { throw new RestException(401); } - + $sql = "DELETE FROM ".MAIN_DB_PREFIX."product_attribute WHERE ref LIKE '". trim($ref) ."'"; - + if ($this->db->query($sql)) { return 1; } throw new RestException(500, "Error deleting attribute"); } - + /** * Get all values for an attribute id. * @@ -986,11 +986,11 @@ class Products extends DolibarrApi if(! (DolibarrApiAccess::$user->rights->produit->lire || DolibarrApiAccess::$user->rights->service->lire)) { throw new RestException(401); } - + $objectval = new ProductAttributeValue($this->db); return $objectval->fetchAllByProductAttribute((int) $id); } - + /** * Get all values for an attribute ref. * @@ -1007,28 +1007,28 @@ class Products extends DolibarrApi if(! (DolibarrApiAccess::$user->rights->produit->lire || DolibarrApiAccess::$user->rights->service->lire)) { throw new RestException(401); } - + $return = array(); - + $sql = 'SELECT '; $sql .= 'v.fk_product_attribute, v.rowid, v.ref, v.value FROM '.MAIN_DB_PREFIX.'product_attribute_value v '; $sql .= "WHERE v.fk_product_attribute = ( SELECT rowid FROM ".MAIN_DB_PREFIX."product_attribute WHERE ref LIKE '". strtoupper(trim($ref)) ."' LIMIT 1)"; $query = $this->db->query($sql); - + while ($result = $this->db->fetch_object($query)) { $tmp = new ProductAttributeValue($this->db); $tmp->fk_product_attribute = $result->fk_product_attribute; $tmp->id = $result->rowid; $tmp->ref = $result->ref; $tmp->value = $result->value; - + $return[] = $tmp; } - + return $return; } - + /** * Add attribute value. * @@ -1047,22 +1047,22 @@ class Products extends DolibarrApi if(! (DolibarrApiAccess::$user->rights->produit->lire || DolibarrApiAccess::$user->rights->service->lire)) { throw new RestException(401); } - + if (empty($ref) || empty($value)) { throw new RestException(401); } - + $objectval = new ProductAttributeValue($this->db); $objectval->fk_product_attribute = $id; $objectval->ref = $ref; $objectval->value = $value; - + if ($objectval->create(DolibarrApiAccess::$user) > 0) { return $objectval->id; } throw new RestException(500, "Error creating new attribute value"); } - + /** * Delete attribute value by id. * @@ -1079,16 +1079,16 @@ class Products extends DolibarrApi if(! (DolibarrApiAccess::$user->rights->produit->lire || DolibarrApiAccess::$user->rights->service->lire)) { throw new RestException(401); } - + $objectval = new ProductAttributeValue($this->db); $objectval->id = (int) $id; - + if ($objectval->delete() > 0) { return 1; } throw new RestException(500, "Error deleting attribute value"); } - + /** * Delete attribute value by ref. * @@ -1105,16 +1105,16 @@ class Products extends DolibarrApi if(! (DolibarrApiAccess::$user->rights->produit->lire || DolibarrApiAccess::$user->rights->service->lire)) { throw new RestException(401); } - + $sql = "DELETE FROM ".MAIN_DB_PREFIX."product_attribute_value WHERE ref LIKE '". trim($ref) ."'"; - + if ($this->db->query($sql)) { return 1; } - + throw new RestException(500, "Error deleting attribute value"); } - + /** * Get product variants. * @@ -1131,11 +1131,11 @@ class Products extends DolibarrApi if(! (DolibarrApiAccess::$user->rights->produit->lire || DolibarrApiAccess::$user->rights->service->lire)) { throw new RestException(401); } - + $prodcomb = new ProductCombination($this->db); return $prodcomb->fetchAllByFkProductParent((int) $id); } - + /** * Get product variants by Product ref. * @@ -1152,19 +1152,19 @@ class Products extends DolibarrApi if(! (DolibarrApiAccess::$user->rights->produit->lire || DolibarrApiAccess::$user->rights->service->lire)) { throw new RestException(401); } - + $result = $this->product->fetch('', $ref); if(! $result ) { throw new RestException(404, 'Product not found'); } - + $prodcomb = new ProductCombination($this->db); return $prodcomb->fetchAllByFkProductParent((int) $this->product->id); } - + /** * Add variant. - * + * * "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 @@ -1185,11 +1185,11 @@ class Products extends DolibarrApi if(! (DolibarrApiAccess::$user->rights->produit->creer || DolibarrApiAccess::$user->rights->service->creer)) { throw new RestException(401); } - + if (empty($id) || empty($weight_impact) || empty($price_impact) || empty($features) || !is_array($features)) { throw new RestException(401); } - + $prodattr = new ProductAttribute($this->db); $prodattr_val = new ProductAttributeValue($this->db); foreach ($features as $id_attr => $id_value) { @@ -1200,12 +1200,12 @@ class Products extends DolibarrApi throw new RestException(401); } } - + $result = $this->product->fetch((int) $id); if(! $result ) { throw new RestException(404, 'Product not found'); } - + $prodcomb = new ProductCombination($this->db); if (! $prodcomb->fetchByProductCombination2ValuePairs($id, $features)) { @@ -1220,10 +1220,10 @@ class Products extends DolibarrApi return $prodcomb->id; } } - + /** * Add variant by product ref. - * + * * "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 string $ref Ref of Product @@ -1244,11 +1244,11 @@ class Products extends DolibarrApi if(! (DolibarrApiAccess::$user->rights->produit->creer || DolibarrApiAccess::$user->rights->service->creer)) { throw new RestException(401); } - + if (empty($ref) || empty($weight_impact) || empty($price_impact) || empty($features) || !is_array($features)) { throw new RestException(401); } - + $prodattr = new ProductAttribute($this->db); $prodattr_val = new ProductAttributeValue($this->db); foreach ($features as $id_attr => $id_value) { @@ -1259,16 +1259,16 @@ class Products extends DolibarrApi throw new RestException(404); } } - + $result = $this->product->fetch('', trim($ref)); if(! $result ) { throw new RestException(404, 'Product not found'); } - + $prodcomb = new ProductCombination($this->db); if (! $prodcomb->fetchByProductCombination2ValuePairs($this->product->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); if ($result > 0) { return $result; @@ -1279,7 +1279,7 @@ class Products extends DolibarrApi return $prodcomb->id; } } - + /** * Put product variants. * @@ -1297,18 +1297,18 @@ class Products extends DolibarrApi if(! (DolibarrApiAccess::$user->rights->produit->creer || DolibarrApiAccess::$user->rights->service->creer)) { throw new RestException(401); } - + $prodcomb = new ProductCombination($this->db); $prodcomb->fetch((int) $id); - + $old_prodcomb = dol_clone($prodcomb, 0); - + foreach($request_data as $field => $value) { if ($field == 'rowid') { continue; } $prodcomb->$field = $value; } - + $result = $prodcomb->update(DolibarrApiAccess::$user); if ($result > 0) { @@ -1316,7 +1316,7 @@ class Products extends DolibarrApi } throw new RestException(500, "Error editing variant"); } - + /** * Delete product variants. * @@ -1333,7 +1333,7 @@ class Products extends DolibarrApi if(! (DolibarrApiAccess::$user->rights->produit->supprimer || DolibarrApiAccess::$user->rights->service->supprimer)) { throw new RestException(401); } - + $prodcomb = new ProductCombination($this->db); $prodcomb->id = (int) $id; $result = $prodcomb->delete(DolibarrApiAccess::$user); From 40e4af234de3fc0568bd9c9abd6b615f1b9b1d4e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric?= <35066297+c3do@users.noreply.github.com> Date: Sun, 17 Nov 2019 01:24:07 +0100 Subject: [PATCH 010/154] Inject $user instead of global var --- htdocs/variants/class/ProductCombination.class.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/htdocs/variants/class/ProductCombination.class.php b/htdocs/variants/class/ProductCombination.class.php index 4dfd40a8f53..1c09aae62df 100644 --- a/htdocs/variants/class/ProductCombination.class.php +++ b/htdocs/variants/class/ProductCombination.class.php @@ -495,6 +495,7 @@ WHERE c.fk_product_parent = ".(int) $productid." AND p.tosell = 1"; * [...] * ) * + * @param User $user Object user * @param Product $product Parent product * @param array $combinations Attribute and value combinations. * @param array $variations Price and weight variations @@ -503,9 +504,9 @@ WHERE c.fk_product_parent = ".(int) $productid." AND p.tosell = 1"; * @param bool|float $forced_weightvar If the weight variation is forced * @return int <0 KO, >0 OK */ - public function createProductCombination(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) { - global $db, $user, $conf; + global $db, $conf; require_once DOL_DOCUMENT_ROOT.'/variants/class/ProductAttribute.class.php'; require_once DOL_DOCUMENT_ROOT.'/variants/class/ProductAttributeValue.class.php'; @@ -660,11 +661,12 @@ WHERE c.fk_product_parent = ".(int) $productid." AND p.tosell = 1"; /** * Copies all product combinations from the origin product to the destination product * + * @param User $user Object user * @param int $origProductId Origin product id * @param Product $destProduct Destination product * @return int >0 OK <0 KO */ - public function copyAll($origProductId, Product $destProduct) + public function copyAll(User $user, $origProductId, Product $destProduct) { require_once DOL_DOCUMENT_ROOT.'/variants/class/ProductCombination2ValuePair.class.php'; @@ -686,6 +688,7 @@ WHERE c.fk_product_parent = ".(int) $productid." AND p.tosell = 1"; } if ($this->createProductCombination( + $user, $destProduct, $variations, array(), From a7f42b3fdfeba4783575e303d370877d665e949f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric?= <35066297+c3do@users.noreply.github.com> Date: Sun, 17 Nov 2019 01:25:44 +0100 Subject: [PATCH 011/154] Inject $user for createProductCombination --- htdocs/variants/combinations.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/variants/combinations.php b/htdocs/variants/combinations.php index 714ee07ed3f..f8a8b9cc9e5 100644 --- a/htdocs/variants/combinations.php +++ b/htdocs/variants/combinations.php @@ -141,7 +141,7 @@ if ($_POST) { if (!$prodcomb->fetchByProductCombination2ValuePairs($id, $sanit_features)) { - $result = $prodcomb->createProductCombination($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); if ($result > 0) { setEventMessages($langs->trans('RecordSaved'), null, 'mesgs'); @@ -268,7 +268,7 @@ if ($action === 'confirm_deletecombination') { if ($prodstatic->fetch('', $dest_product) > 0) { //To prevent from copying to the same product if ($prodstatic->ref != $object->ref) { - if ($prodcomb->copyAll($object->id, $prodstatic) > 0) { + if ($prodcomb->copyAll($user, $object->id, $prodstatic) > 0) { header('Location: '.dol_buildpath('/variants/combinations.php?id='.$prodstatic->id, 2)); exit(); } else { From 398f0e00f75bca7958db73ece512da9b28e7f381 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric?= <35066297+c3do@users.noreply.github.com> Date: Sun, 17 Nov 2019 01:27:23 +0100 Subject: [PATCH 012/154] inject $user for createProductCombination --- htdocs/variants/generator.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/variants/generator.php b/htdocs/variants/generator.php index 27f811fdafe..137186bd5b8 100644 --- a/htdocs/variants/generator.php +++ b/htdocs/variants/generator.php @@ -110,7 +110,7 @@ if ($_POST) $cartesianarray = cartesianArray($adapted_values); foreach ($cartesianarray as $currcomb) { - $res = $combination->createProductCombination($product, $currcomb, $sanitized_values, $price_var_percent); + $res = $combination->createProductCombination($user, $product, $currcomb, $sanitized_values, $price_var_percent); if ($res < 0) { $error++; setEventMessages($combination->error, $combination->errors, 'errors'); From 8fbf853b9421d0788469d72f9de18caeecfc0ca6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric?= <35066297+c3do@users.noreply.github.com> Date: Tue, 19 Nov 2019 14:40:50 +0100 Subject: [PATCH 013/154] Display attributes infos when get product variants --- htdocs/product/class/api_products.class.php | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/htdocs/product/class/api_products.class.php b/htdocs/product/class/api_products.class.php index fd564b17278..1d71246cab7 100644 --- a/htdocs/product/class/api_products.class.php +++ b/htdocs/product/class/api_products.class.php @@ -1133,7 +1133,14 @@ class Products extends DolibarrApi } $prodcomb = new ProductCombination($this->db); - return $prodcomb->fetchAllByFkProductParent((int) $id); + $combinations = $prodcomb->fetchAllByFkProductParent((int) $id); + + foreach ($combinations as $key => $combination) { + $prodc2vp = new ProductCombination2ValuePair($this->db); + $combinations[$key]->attributes = $prodc2vp->fetchByFkCombination((int) $combination->id); + } + + return $combinations; } /** @@ -1159,7 +1166,14 @@ class Products extends DolibarrApi } $prodcomb = new ProductCombination($this->db); - return $prodcomb->fetchAllByFkProductParent((int) $this->product->id); + $combinations = $prodcomb->fetchAllByFkProductParent((int) $this->product->id); + + foreach ($combinations as $key => $combination) { + $prodc2vp = new ProductCombination2ValuePair($this->db); + $combinations[$key]->attributes = $prodc2vp->fetchByFkCombination((int) $combination->id); + } + + return $combinations; } /** From c33506b4cc567d8e1134746227c161868769905c Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Tue, 19 Nov 2019 13:41:30 +0000 Subject: [PATCH 014/154] Fixing style errors. --- htdocs/product/class/api_products.class.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/product/class/api_products.class.php b/htdocs/product/class/api_products.class.php index 1d71246cab7..c9e95cb5fe0 100644 --- a/htdocs/product/class/api_products.class.php +++ b/htdocs/product/class/api_products.class.php @@ -1134,12 +1134,12 @@ class Products extends DolibarrApi $prodcomb = new ProductCombination($this->db); $combinations = $prodcomb->fetchAllByFkProductParent((int) $id); - + foreach ($combinations as $key => $combination) { $prodc2vp = new ProductCombination2ValuePair($this->db); $combinations[$key]->attributes = $prodc2vp->fetchByFkCombination((int) $combination->id); } - + return $combinations; } @@ -1167,12 +1167,12 @@ class Products extends DolibarrApi $prodcomb = new ProductCombination($this->db); $combinations = $prodcomb->fetchAllByFkProductParent((int) $this->product->id); - + foreach ($combinations as $key => $combination) { $prodc2vp = new ProductCombination2ValuePair($this->db); $combinations[$key]->attributes = $prodc2vp->fetchByFkCombination((int) $combination->id); } - + return $combinations; } From 8f5c8c63dfb7fbce04356d7c73c688d5f66e585a Mon Sep 17 00:00:00 2001 From: John Botella Date: Tue, 19 Nov 2019 16:35:31 +0100 Subject: [PATCH 015/154] Fix dom and showOptionals call --- htdocs/expedition/card.php | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/htdocs/expedition/card.php b/htdocs/expedition/card.php index be5ed4c757a..a33055d4b10 100644 --- a/htdocs/expedition/card.php +++ b/htdocs/expedition/card.php @@ -2443,10 +2443,10 @@ elseif ($id || $ref) // Display lines extrafields if (is_array($extralabelslines) && count($extralabelslines)>0) { $colspan= empty($conf->productbatch->enabled) ? 5 : 6; - $line = new ExpeditionLigne($db); - $line->fetch_optionals($lines[$i]->id); - print ''; - if ($action == 'editline' && $lines[$i]->id == $line_id) + $line = $lines[$i]; + $line->fetch_optionals($line->id); + + if ($action == 'editline' && $line->id == $line_id) { print $line->showOptionals($extrafieldsline, 'edit', array('style'=>$bc[$var], 'colspan'=>$colspan), $indiceAsked); } @@ -2454,7 +2454,6 @@ elseif ($id || $ref) { print $line->showOptionals($extrafieldsline, 'view', array('style'=>$bc[$var], 'colspan'=>$colspan), $indiceAsked); } - print ''; } } } From db0d352af3d485187f7b5a9ee20f03106b88f1f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=BCdiger=20Hahn?= Date: Wed, 20 Nov 2019 12:53:23 +0100 Subject: [PATCH 016/154] Use virtual stock when this has been configured When "Use virtual stock by default, instead of physical stock, for replenishment feature" has been set in configuration, this should really be used. Otherwise only physically missing items will be shown in replenishment. --- htdocs/product/stock/replenish.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/product/stock/replenish.php b/htdocs/product/stock/replenish.php index 0de9fa76786..99a4b4c286e 100644 --- a/htdocs/product/stock/replenish.php +++ b/htdocs/product/stock/replenish.php @@ -89,7 +89,7 @@ if (! empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT) { $virtualdiffersfromphysical=1; // According to increase/decrease stock options, virtual and physical stock may differs. } -$usevirtualstock=0; +$usevirtualstock = !empty($conf->global->STOCK_USE_VIRTUAL_STOCK); if ($mode == 'virtual') $usevirtualstock=1; $parameters=array(); From f73bd0e0a6fba4087e50e1f1548870b0068805ea Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Wed, 20 Nov 2019 13:07:26 +0100 Subject: [PATCH 017/154] FIX display job of contact list MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit can see différent contact with same name but different job --- htdocs/comm/action/card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/comm/action/card.php b/htdocs/comm/action/card.php index 4e5abac75d3..c057dc2dee3 100644 --- a/htdocs/comm/action/card.php +++ b/htdocs/comm/action/card.php @@ -1290,7 +1290,7 @@ if ($id > 0) // related contact print ''.$langs->trans("ActionOnContact").''; print '
'; - print $form->selectcontacts($object->socid, array_keys($object->socpeopleassigned), 'socpeopleassigned[]', 1, '', '', 0, 'quatrevingtpercent', false, 0, 0, array(), 'multiple', 'contactid'); + print $form->selectcontacts($object->socid, array_keys($object->socpeopleassigned), 'socpeopleassigned[]', 1, '', '', 1, 'quatrevingtpercent', false, 0, 0, array(), 'multiple', 'contactid'); print '
'; print ''; print ''; From 2f064567efbc2d505efa4801acd66ae06ca9645d Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Thu, 21 Nov 2019 07:50:44 +0100 Subject: [PATCH 018/154] NEW Add shipment widget --- htdocs/core/boxes/box_shipments.php | 191 ++++++++++++++++++++ htdocs/core/modules/modExpedition.class.php | 4 +- htdocs/langs/en_US/boxes.lang | 3 + 3 files changed, 197 insertions(+), 1 deletion(-) create mode 100644 htdocs/core/boxes/box_shipments.php diff --git a/htdocs/core/boxes/box_shipments.php b/htdocs/core/boxes/box_shipments.php new file mode 100644 index 00000000000..4852934af74 --- /dev/null +++ b/htdocs/core/boxes/box_shipments.php @@ -0,0 +1,191 @@ + + * Copyright (C) 2004-2009 Laurent Destailleur + * Copyright (C) 2005-2009 Regis Houssin + * Copyright (C) 2019 Alexandre Spangaro + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** + * \file htdocs/core/boxes/box_shipments.php + * \ingroup shipment + * \brief Module for generating the display of the shipment box + */ + +include_once DOL_DOCUMENT_ROOT.'/core/boxes/modules_boxes.php'; + + +/** + * Class to manage the box to show last shipments + */ +class box_shipments extends ModeleBoxes +{ + public $boxcode="lastcustomershipments"; + public $boximg="sending"; + public $boxlabel="BoxLastCustomerShipments"; + public $depends = array("expedition"); + + /** + * @var DoliDB Database handler. + */ + public $db; + + public $param; + + public $info_box_head = array(); + public $info_box_contents = array(); + + + /** + * Constructor + * + * @param DoliDB $db Database handler + * @param string $param More parameters + */ + public function __construct($db, $param) + { + global $user; + + $this->db=$db; + + $this->hidden=! ($user->rights->expedition->lire); + } + + /** + * Load data for box to show them later + * + * @param int $max Maximum number of records to load + * @return void + */ + public function loadBox($max = 5) + { + global $user, $langs, $conf; + $langs->loadLangs(array('orders', 'sendings')); + + $this->max = $max; + + include_once DOL_DOCUMENT_ROOT.'/expedition/class/expedition.class.php'; + include_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; + + $shipmentstatic = new Expedition($this->db); + $orderstatic = new Commande($this->db); + $societestatic = new Societe($this->db); + + $this->info_box_head = array('text' => $langs->trans("BoxTitleLastCustomerShipments", $max)); + + if ($user->rights->expedition->lire) + { + $sql = "SELECT s.nom as name"; + $sql.= ", s.rowid as socid"; + $sql.= ", s.code_client"; + $sql.= ", s.logo, s.email"; + $sql.= ", e.ref, e.tms"; + $sql.= ", e.rowid"; + $sql.= ", e.ref_customer"; + $sql.= ", e.fk_statut"; + $sql.= ", e.fk_user_valid"; + $sql.= ", c.ref as commande_ref"; + $sql.= ", c.rowid as commande_id"; + $sql.= " FROM ".MAIN_DB_PREFIX."expedition as e"; + $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."element_element as el ON e.rowid = el.fk_target AND el.targettype = 'shipping' AND el.sourcetype IN ('commande')"; + $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."commande as c ON el.fk_source = c.rowid AND el.sourcetype IN ('commande') AND el.targettype = 'shipping'"; + $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = e.fk_soc"; + if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON e.fk_soc = sc.fk_soc"; + $sql.= " WHERE e.entity = ".$conf->entity; + if (! empty($conf->global->ORDER_BOX_LAST_SHIPMENTS_VALIDATED_ONLY)) $sql.=" AND e.fk_statut = 1"; + if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= " AND sc.fk_user = " .$user->id; + else $sql.= " ORDER BY e.date_delivery, e.ref DESC "; + $sql.= $this->db->plimit($max, 0); + + $result = $this->db->query($sql); + if ($result) { + $num = $this->db->num_rows($result); + + $line = 0; + + while ($line < $num) { + $objp = $this->db->fetch_object($result); + + $shipmentstatic->id = $objp->rowid; + $shipmentstatic->ref = $objp->ref; + $shipmentstatic->ref_customer = $objp->ref_customer; + + $orderstatic->id= $objp->commande_id; + $orderstatic->ref=$objp->commande_ref; + print $orderstatic->getNomUrl(1); + + $societestatic->id = $objp->socid; + $societestatic->name = $objp->name; + $societestatic->email = $objp->email; + $societestatic->code_client = $objp->code_client; + $societestatic->logo = $objp->logo; + + $this->info_box_contents[$line][] = array( + 'td' => '', + 'text' => $shipmentstatic->getNomUrl(1), + 'asis' => 1, + ); + + $this->info_box_contents[$line][] = array( + 'td' => 'class="tdoverflowmax150 maxwidth150onsmartphone"', + 'text' => $societestatic->getNomUrl(1), + 'asis' => 1, + ); + + $this->info_box_contents[$line][] = array( + 'td' => '', + 'text' => $orderstatic->getNomUrl(1), + 'asis' => 1, + ); + + $this->info_box_contents[$line][] = array( + 'td' => 'class="right" width="18"', + 'text' => $shipmentstatic->LibStatut($objp->fk_statut, 3), + ); + + $line++; + } + + if ($num==0) $this->info_box_contents[$line][0] = array('td' => 'class="center"','text'=>$langs->trans("NoRecordedShipments")); + + $this->db->free($result); + } else { + $this->info_box_contents[0][0] = array( + 'td' => '', + 'maxlength'=>500, + 'text' => ($this->db->error().' sql='.$sql), + ); + } + } else { + $this->info_box_contents[0][0] = array( + 'td' => 'class="nohover opacitymedium left"', + 'text' => $langs->trans("ReadPermissionNotAllowed") + ); + } + } + + /** + * Method to show box + * + * @param array $head Array with properties of box title + * @param array $contents Array with properties of box lines + * @param int $nooutput No print, only return string + * @return string + */ + public function showBox($head = null, $contents = null, $nooutput = 0) + { + return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); + } +} diff --git a/htdocs/core/modules/modExpedition.class.php b/htdocs/core/modules/modExpedition.class.php index 68f4a3d5fba..d8225a1b2a5 100644 --- a/htdocs/core/modules/modExpedition.class.php +++ b/htdocs/core/modules/modExpedition.class.php @@ -133,7 +133,9 @@ class modExpedition extends DolibarrModules $r++; // Boxes - $this->boxes = array(); + $this->boxes = array( + 0=>array('file'=>'box_shipments.php','enabledbydefaulton'=>'Home'), + ); // Permissions $this->rights = array(); diff --git a/htdocs/langs/en_US/boxes.lang b/htdocs/langs/en_US/boxes.lang index a55a0194632..8fe1f84b149 100644 --- a/htdocs/langs/en_US/boxes.lang +++ b/htdocs/langs/en_US/boxes.lang @@ -97,3 +97,6 @@ BoxSuspenseAccount=Count accountancy operation with suspense account BoxTitleSuspenseAccount=Number of unallocated lines NumberOfLinesInSuspenseAccount=Number of line in suspense account SuspenseAccountNotDefined=Suspense account isn't defined +BoxLastCustomerShipments=Last customer shipments +BoxTitleLastCustomerShipments=Latest %s customer shipments +NoRecordedShipments=No recorded customer shipment From f6c5605fd5fdf05c38a6c4b86bae7f48c2be0895 Mon Sep 17 00:00:00 2001 From: Tobias Sekan Date: Thu, 21 Nov 2019 08:29:47 +0100 Subject: [PATCH 019/154] Fix number of tasks on dashboard always zero --- htdocs/projet/class/task.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/projet/class/task.class.php b/htdocs/projet/class/task.class.php index bc122367312..60657b08061 100644 --- a/htdocs/projet/class/task.class.php +++ b/htdocs/projet/class/task.class.php @@ -1985,7 +1985,7 @@ class Task extends CommonObject $sql .= " WHERE p.entity IN (".getEntity('project', 0).')'; $sql .= " AND p.fk_statut = 1"; $sql .= " AND t.fk_projet = p.rowid"; - $sql .= " AND t.progress < 100"; // tasks to do + $sql .= " AND (t.progress IS NULL OR t.progress < 100)"; // tasks to do if (!$user->rights->projet->all->lire) $sql .= " AND p.rowid IN (".$projectsListId.")"; // No need to check company, as filtering of projects must be done by getProjectsAuthorizedForUser //if ($socid || ! $user->rights->societe->client->voir) $sql.= " AND (p.fk_soc IS NULL OR p.fk_soc = 0 OR p.fk_soc = ".$socid.")"; From 2c183fe279cf34753c0b56942ba749743a57f264 Mon Sep 17 00:00:00 2001 From: Philippe GRAND Date: Thu, 21 Nov 2019 09:22:44 +0100 Subject: [PATCH 020/154] fix : invoid sql injection --- htdocs/commande/list.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/commande/list.php b/htdocs/commande/list.php index 1de1e64e0c7..9e34c745fab 100644 --- a/htdocs/commande/list.php +++ b/htdocs/commande/list.php @@ -80,7 +80,7 @@ $search_total_ttc = GETPOST('search_total_ttc', 'alpha'); $search_categ_cus = trim(GETPOST("search_categ_cus", 'int')); $optioncss = GETPOST('optioncss', 'alpha'); $billed = GETPOST('billed', 'int'); -$viewstatut = GETPOST('viewstatut'); +$viewstatut = GETPOST('viewstatut', 'int'); $search_btn = GETPOST('button_search', 'alpha'); $search_remove_btn = GETPOST('button_removefilter', 'alpha'); $search_project_ref = GETPOST('search_project_ref', 'alpha'); From 54d67de538b017aa47dbce26d103c75e3bd37244 Mon Sep 17 00:00:00 2001 From: Philippe GRAND Date: Thu, 21 Nov 2019 09:44:13 +0100 Subject: [PATCH 021/154] fix : invoid sql injection --- htdocs/accountancy/bookkeeping/balance.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/accountancy/bookkeeping/balance.php b/htdocs/accountancy/bookkeeping/balance.php index 02174ea2524..86ec1162832 100644 --- a/htdocs/accountancy/bookkeeping/balance.php +++ b/htdocs/accountancy/bookkeeping/balance.php @@ -38,7 +38,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; // Load translation files required by the page $langs->loadLangs(array("accountancy")); -$page = GETPOST("page"); +$page = GETPOST("page", 'int'); $sortorder = GETPOST("sortorder", 'alpha'); $sortfield = GETPOST("sortfield", 'alpha'); $action = GETPOST('action', 'aZ09'); From 9996c1ca7a9e19b89b0a6c4f122c11a4d43c4f41 Mon Sep 17 00:00:00 2001 From: Philippe GRAND Date: Thu, 21 Nov 2019 09:49:53 +0100 Subject: [PATCH 022/154] fix : invoid sql injection --- htdocs/accountancy/bookkeeping/list.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/accountancy/bookkeeping/list.php b/htdocs/accountancy/bookkeeping/list.php index d898be2b208..0db4c7b6c24 100644 --- a/htdocs/accountancy/bookkeeping/list.php +++ b/htdocs/accountancy/bookkeeping/list.php @@ -575,8 +575,8 @@ if ($action == 'delmouv') { } if ($action == 'delbookkeepingyear') { $form_question = array(); - $delyear = GETPOST('delyear'); - $deljournal = GETPOST('deljournal'); + $delyear = GETPOST('delyear', 'int'); + $deljournal = GETPOST('deljournal', 'alpha'); if (empty($delyear)) { $delyear = dol_print_date(dol_now(), '%Y'); From 496aa0c065a97d9ed9687e2641883c0664864300 Mon Sep 17 00:00:00 2001 From: Anthony Berton <34568357+bb2a@users.noreply.github.com> Date: Thu, 21 Nov 2019 10:38:59 +0100 Subject: [PATCH 023/154] Update functions.lib.php --- htdocs/core/lib/functions.lib.php | 27 --------------------------- 1 file changed, 27 deletions(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index df15088aec7..a36514059e9 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -5966,15 +5966,6 @@ function getCommonSubstitutionArray($outputlangs, $onlykey = 0, $exclude = null, $substitutionarray['__THIRDPARTY_IDPROF5__'] = '__THIRDPARTY_IDPROF5__'; $substitutionarray['__THIRDPARTY_IDPROF6__'] = '__THIRDPARTY_IDPROF6__'; $substitutionarray['__THIRDPARTY_TVAINTRA__'] = '__THIRDPARTY_TVAINTRA__'; - $substitutionarray['__THIRDPARTY_SKYPE__'] = '__THIRDPARTY_SKYPE__'; - $substitutionarray['__THIRDPARTY_TWITTER__'] = '__THIRDPARTY_TWITTER__'; - $substitutionarray['__THIRDPARTY_FACEBOOK__'] = '__THIRDPARTY_FACEBOOK__'; - $substitutionarray['__THIRDPARTY_INSTAGRAM__'] = '__THIRDPARTY_INSTAGRAM__'; - $substitutionarray['__THIRDPARTY_SNAPCHAT__'] = '__THIRDPARTY_SNAPCHAT__'; - $substitutionarray['__THIRDPARTY_GOOGLEPLUS__'] = '__THIRDPARTY_GOOGLEPLUS__'; - $substitutionarray['__THIRDPARTY_YOUTUBE__'] = '__THIRDPARTY_YOUTUBE__'; - $substitutionarray['__THIRDPARTY_WHATSAPP__'] = '__THIRDPARTY_WHATSAPP__'; - $substitutionarray['__THIRDPARTY_LINKEDIN__'] = '__THIRDPARTY_LINKEDIN__'; $substitutionarray['__THIRDPARTY_NOTE_PUBLIC__'] = '__THIRDPARTY_NOTE_PUBLIC__'; $substitutionarray['__THIRDPARTY_NOTE_PRIVATE__'] = '__THIRDPARTY_NOTE_PRIVATE__'; } @@ -6088,15 +6079,6 @@ function getCommonSubstitutionArray($outputlangs, $onlykey = 0, $exclude = null, $substitutionarray['__THIRDPARTY_IDPROF5__'] = (is_object($object)?$object->idprof5:''); $substitutionarray['__THIRDPARTY_IDPROF6__'] = (is_object($object)?$object->idprof6:''); $substitutionarray['__THIRDPARTY_TVAINTRA__'] = (is_object($object)?$object->tva_intra:''); - $substitutionarray['__THIRDPARTY_SKYPE__'] = (is_object($object)?$object->skype:''); - $substitutionarray['__THIRDPARTY_TWITTER__'] = (is_object($object)?$object->twitter:''); - $substitutionarray['__THIRDPARTY_FACEBOOK__'] = (is_object($object)?$object->facebook:''); - $substitutionarray['__THIRDPARTY_INSTAGRAM__'] = (is_object($object)?$object->instagram:''); - $substitutionarray['__THIRDPARTY_SNAPCHAT__'] = (is_object($object)?$object->snapchat:''); - $substitutionarray['__THIRDPARTY_GOOGLEPLUS__'] = (is_object($object)?$object->googleplus:''); - $substitutionarray['__THIRDPARTY_YOUTUBE__'] = (is_object($object)?$object->youtube:''); - $substitutionarray['__THIRDPARTY_WHATSAPP__'] = (is_object($object)?$object->watsapp:''); - $substitutionarray['__THIRDPARTY_LINKEDIN__'] = (is_object($object)?$object->linkedin:''); $substitutionarray['__THIRDPARTY_NOTE_PUBLIC__'] = (is_object($object)?dol_htmlentitiesbr($object->note_public):''); $substitutionarray['__THIRDPARTY_NOTE_PRIVATE__'] = (is_object($object)?dol_htmlentitiesbr($object->note_private):''); } @@ -6120,15 +6102,6 @@ function getCommonSubstitutionArray($outputlangs, $onlykey = 0, $exclude = null, $substitutionarray['__THIRDPARTY_IDPROF5__'] = (is_object($object->thirdparty)?$object->thirdparty->idprof5:''); $substitutionarray['__THIRDPARTY_IDPROF6__'] = (is_object($object->thirdparty)?$object->thirdparty->idprof6:''); $substitutionarray['__THIRDPARTY_TVAINTRA__'] = (is_object($object->thirdparty)?$object->thirdparty->tva_intra:''); - $substitutionarray['__THIRDPARTY_SKYPE__'] = (is_object($object->thirdparty)?$object->thirdparty->skype:''); - $substitutionarray['__THIRDPARTY_TWITTER__'] = (is_object($object->thirdparty)?$object->thirdparty->twitter:''); - $substitutionarray['__THIRDPARTY_FACEBOOK__'] = (is_object($object->thirdparty)?$object->thirdparty->facebook:''); - $substitutionarray['__THIRDPARTY_INSTAGRAM__'] = (is_object($object->thirdparty)?$object->thirdparty->instagram:''); - $substitutionarray['__THIRDPARTY_SNAPCHAT__'] = (is_object($object->thirdparty)?$object->thirdparty->snapchat:''); - $substitutionarray['__THIRDPARTY_GOOGLEPLUS__'] = (is_object($object->thirdparty)?$object->thirdparty->googleplus:''); - $substitutionarray['__THIRDPARTY_YOUTUBE__'] = (is_object($object->thirdparty)?$object->thirdparty->youtube:''); - $substitutionarray['__THIRDPARTY_WHATSAPP__'] = (is_object($object->thirdparty)?$object->thirdparty->watsapp:''); - $substitutionarray['__THIRDPARTY_LINKEDIN__'] = (is_object($object->thirdparty)?$object->thirdparty->linkedin:''); $substitutionarray['__THIRDPARTY_NOTE_PUBLIC__'] = (is_object($object->thirdparty)?dol_htmlentitiesbr($object->thirdparty->note_public):''); $substitutionarray['__THIRDPARTY_NOTE_PRIVATE__'] = (is_object($object->thirdparty)?dol_htmlentitiesbr($object->thirdparty->note_private):''); } From 3daeb24da1ff2adf2d0c312156c41bb46254441f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 21 Nov 2019 13:05:13 +0100 Subject: [PATCH 024/154] Fix confusion with field name in sql --- htdocs/comm/remx.php | 41 +++++++++++++++++++++++++---------------- 1 file changed, 25 insertions(+), 16 deletions(-) diff --git a/htdocs/comm/remx.php b/htdocs/comm/remx.php index eabb217fb99..7a8b03cde4e 100644 --- a/htdocs/comm/remx.php +++ b/htdocs/comm/remx.php @@ -739,8 +739,8 @@ if ($socid > 0) $sql.= " rc.datec as dc, rc.description, rc.fk_facture_line, rc.fk_facture,"; $sql.= " rc.fk_facture_source,"; $sql.= " u.login, u.rowid as user_id,"; - $sql.= " f.rowid, f.ref,"; - $sql.= " fa.ref as ref, fa.type as type"; + $sql.= " f.rowid as invoiceid, f.ref,"; + $sql.= " fa.ref as invoice_source_ref, fa.type as type"; $sql.= " FROM ".MAIN_DB_PREFIX."facture as f"; $sql.= " , ".MAIN_DB_PREFIX."user as u"; $sql.= " , ".MAIN_DB_PREFIX."facturedet as fc"; @@ -758,8 +758,8 @@ if ($socid > 0) $sql2.= " rc.datec as dc, rc.description, rc.fk_facture_line, rc.fk_facture,"; $sql2.= " rc.fk_facture_source,"; $sql2.= " u.login, u.rowid as user_id,"; - $sql2.= " f.rowid, f.ref,"; - $sql2.= " fa.ref as ref, fa.type as type"; + $sql2.= " f.rowid as invoiceid, f.ref,"; + $sql2.= " fa.ref as invoice_source_ref, fa.type as type"; $sql2.= " FROM ".MAIN_DB_PREFIX."facture as f"; $sql2.= " , ".MAIN_DB_PREFIX."user as u"; $sql2.= " , ".MAIN_DB_PREFIX."societe_remise_except as rc"; @@ -833,7 +833,7 @@ if ($socid > 0) { print ''; $facturestatic->id=$obj->fk_facture_source; - $facturestatic->ref=$obj->ref; + $facturestatic->ref=$obj->invoice_source_ref; $facturestatic->type=$obj->type; print preg_replace('/\(CREDIT_NOTE\)/', $langs->trans("CreditNote"), $obj->description).' '.$facturestatic->getNomURl(1); print ''; @@ -842,7 +842,7 @@ if ($socid > 0) { print ''; $facturestatic->id=$obj->fk_facture_source; - $facturestatic->ref=$obj->ref; + $facturestatic->ref=$obj->invoice_source_ref; $facturestatic->type=$obj->type; print preg_replace('/\(DEPOSIT\)/', $langs->trans("InvoiceDeposit"), $obj->description).' '.$facturestatic->getNomURl(1); print ''; @@ -851,7 +851,7 @@ if ($socid > 0) { print ''; $facturestatic->id=$obj->fk_facture_source; - $facturestatic->ref=$obj->ref; + $facturestatic->ref=$obj->invoice_source_ref; $facturestatic->type=$obj->type; print preg_replace('/\(EXCESS RECEIVED\)/', $langs->trans("Invoice"), $obj->description).' '.$facturestatic->getNomURl(1); print ''; @@ -862,7 +862,12 @@ if ($socid > 0) print $obj->description; print ''; } - print ''.img_object($langs->trans("ShowBill"), 'bill').' '.$obj->ref.''; + print ''; + if ($obj->invoiceid) + { + print ''.img_object($langs->trans("ShowBill"), 'bill').' '.$obj->ref.''; + } + print ''; print ''.price($obj->amount_ht).''; if (! empty($conf->multicurrency->enabled)) { @@ -909,8 +914,8 @@ if ($socid > 0) $sql.= " rc.datec as dc, rc.description, rc.fk_invoice_supplier_line, rc.fk_invoice_supplier,"; $sql.= " rc.fk_invoice_supplier_source,"; $sql.= " u.login, u.rowid as user_id,"; - $sql.= " f.rowid, f.ref as ref,"; - $sql.= " fa.ref, fa.type as type"; + $sql.= " f.rowid as invoiceid, f.ref as ref,"; + $sql.= " fa.ref as invoice_source_ref, fa.type as type"; $sql.= " FROM ".MAIN_DB_PREFIX."facture_fourn as f"; $sql.= " , ".MAIN_DB_PREFIX."user as u"; $sql.= " , ".MAIN_DB_PREFIX."facture_fourn_det as fc"; @@ -928,8 +933,8 @@ if ($socid > 0) $sql2.= " rc.datec as dc, rc.description, rc.fk_invoice_supplier_line, rc.fk_invoice_supplier,"; $sql2.= " rc.fk_invoice_supplier_source,"; $sql2.= " u.login, u.rowid as user_id,"; - $sql2.= " f.rowid, f.ref as ref,"; - $sql2.= " fa.ref, fa.type as type"; + $sql2.= " f.rowid as invoiceid, f.ref as ref,"; + $sql2.= " fa.ref as invoice_source_ref, fa.type as type"; $sql2.= " FROM ".MAIN_DB_PREFIX."facture_fourn as f"; $sql2.= " , ".MAIN_DB_PREFIX."user as u"; $sql2.= " , ".MAIN_DB_PREFIX."societe_remise_except as rc"; @@ -1003,7 +1008,7 @@ if ($socid > 0) { print ''; $facturefournstatic->id=$obj->fk_invoice_supplier_source; - $facturefournstatic->ref=$obj->ref; + $facturefournstatic->ref=$obj->invoice_source_ref; $facturefournstatic->type=$obj->type; print preg_replace('/\(CREDIT_NOTE\)/', $langs->trans("CreditNote"), $obj->description).' '.$facturefournstatic->getNomURl(1); print ''; @@ -1012,7 +1017,7 @@ if ($socid > 0) { print ''; $facturefournstatic->id=$obj->fk_invoice_supplier_source; - $facturefournstatic->ref=$obj->ref; + $facturefournstatic->ref=$obj->invoice_source_ref; $facturefournstatic->type=$obj->type; print preg_replace('/\(DEPOSIT\)/', $langs->trans("InvoiceDeposit"), $obj->description).' '.$facturefournstatic->getNomURl(1); print ''; @@ -1021,7 +1026,7 @@ if ($socid > 0) { print ''; $facturefournstatic->id=$obj->fk_invoice_supplier_source; - $facturefournstatic->ref=$obj->ref; + $facturefournstatic->ref=$obj->invoice_source_ref; $facturefournstatic->type=$obj->type; print preg_replace('/\(EXCESS PAID\)/', $langs->trans("Invoice"), $obj->description).' '.$facturefournstatic->getNomURl(1); print ''; @@ -1032,7 +1037,11 @@ if ($socid > 0) print $obj->description; print ''; } - print ''.img_object($langs->trans("ShowBill"), 'bill').' '.$obj->ref.''; + print ''; + if ($obj->invoiceid) { + print ''.img_object($langs->trans("ShowBill"), 'bill').' '.$obj->ref.''; + } + print ''; print ''.price($obj->amount_ht).''; if (! empty($conf->multicurrency->enabled)) { From a8d02615a843a5b9debf34d80a64a1245fe937ef Mon Sep 17 00:00:00 2001 From: gauthier Date: Thu, 21 Nov 2019 14:58:20 +0100 Subject: [PATCH 025/154] FIX : we need to be able to recalculate tva only if invoice not ventil --- htdocs/fourn/facture/card.php | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/htdocs/fourn/facture/card.php b/htdocs/fourn/facture/card.php index a294cf3c6ad..f82a2aeac0b 100644 --- a/htdocs/fourn/facture/card.php +++ b/htdocs/fourn/facture/card.php @@ -2642,11 +2642,14 @@ else else $calculationrule=(empty($conf->global->MAIN_ROUNDOFTOTAL_NOT_TOTALOFROUND)?'totalofround':'roundoftotal'); if ($calculationrule == 'totalofround') $calculationrulenum=1; else $calculationrulenum=2; - $s=$langs->trans("ReCalculate").' '; - $s.=''.$langs->trans("Mode1").''; - $s.=' / '; - $s.=''.$langs->trans("Mode2").''; - print $form->textwithtooltip($s, $langs->trans("CalculationRuleDesc",$calculationrulenum).'
'.$langs->trans("CalculationRuleDescSupplier"), 2, 1, img_picto('','help')); + + if(empty($object->getVentilExportCompta())) { + $s=$langs->trans("ReCalculate").' '; + $s.=''.$langs->trans("Mode1").''; + $s.=' / '; + $s.=''.$langs->trans("Mode2").''; + print $form->textwithtooltip($s, $langs->trans("CalculationRuleDesc",$calculationrulenum).'
'.$langs->trans("CalculationRuleDescSupplier"), 2, 1, img_picto('','help')); + } print ''; // Amount Local Taxes From 9a8c5d5c2932a9f4c0c254ee18c6a08905ba68c7 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 21 Nov 2019 15:36:30 +0100 Subject: [PATCH 026/154] Sanitize param --- htdocs/projet/info.php | 2 +- htdocs/projet/list.php | 2 +- htdocs/resource/list.php | 2 +- htdocs/ticket/agenda.php | 2 +- htdocs/ticket/messaging.php | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/htdocs/projet/info.php b/htdocs/projet/info.php index e6d35f5ee9e..7a9521c7518 100644 --- a/htdocs/projet/info.php +++ b/htdocs/projet/info.php @@ -39,7 +39,7 @@ $action = GETPOST('action', 'aZ09'); $limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit; $sortfield = GETPOST("sortfield", "alpha"); $sortorder = GETPOST("sortorder"); -$page = GETPOST("page"); +$page = GETPOST("page", 'int'); $page = is_numeric($page) ? $page : 0; $page = $page == -1 ? 0 : $page; if (! $sortfield) $sortfield="a.datep,a.id"; diff --git a/htdocs/projet/list.php b/htdocs/projet/list.php index d5c37b81fa6..1eed25433db 100644 --- a/htdocs/projet/list.php +++ b/htdocs/projet/list.php @@ -62,7 +62,7 @@ $diroutputmassaction = $conf->projet->dir_output.'/temp/massgeneration/'.$user-> $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST("sortfield", "alpha"); $sortorder = GETPOST("sortorder"); -$page = GETPOST("page"); +$page = GETPOST("page", 'int'); $page = is_numeric($page) ? $page : 0; $page = $page == -1 ? 0 : $page; if (!$sortfield) $sortfield = "p.ref"; diff --git a/htdocs/resource/list.php b/htdocs/resource/list.php index 98f30ac22db..e1bf458b6e4 100644 --- a/htdocs/resource/list.php +++ b/htdocs/resource/list.php @@ -93,7 +93,7 @@ if (empty($sortfield)) $sortfield="t.ref"; if (empty($arch)) $arch = 0; $limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit; -$page = GETPOST("page"); +$page = GETPOST("page", 'int'); if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 $offset = $limit * $page ; $pageprev = $page - 1; diff --git a/htdocs/ticket/agenda.php b/htdocs/ticket/agenda.php index 49b901c6d12..68cef779261 100644 --- a/htdocs/ticket/agenda.php +++ b/htdocs/ticket/agenda.php @@ -43,7 +43,7 @@ $action = GETPOST('action', 'aZ09'); $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST("sortfield", "alpha"); $sortorder = GETPOST("sortorder"); -$page = GETPOST("page"); +$page = GETPOST("page", 'int'); $page = is_numeric($page) ? $page : 0; $page = $page == -1 ? 0 : $page; if (!$sortfield) $sortfield = "a.datep,a.id"; diff --git a/htdocs/ticket/messaging.php b/htdocs/ticket/messaging.php index da7bf1aaadc..ee90a166b68 100644 --- a/htdocs/ticket/messaging.php +++ b/htdocs/ticket/messaging.php @@ -43,7 +43,7 @@ $action = GETPOST('action', 'aZ09'); $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST("sortfield", "alpha"); $sortorder = GETPOST("sortorder"); -$page = GETPOST("page"); +$page = GETPOST("page", 'int'); $page = is_numeric($page) ? $page : 0; $page = $page == -1 ? 0 : $page; if (!$sortfield) $sortfield = "a.datep,a.id"; From 0fffdd891e9549d697d05dbb8343f34a77c8c0bb Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 21 Nov 2019 15:37:59 +0100 Subject: [PATCH 027/154] Sanitize data --- htdocs/product/stock/replenishorders.php | 4 ++-- htdocs/product/stock/valo.php | 4 ++-- htdocs/projet/info.php | 2 +- htdocs/projet/list.php | 2 +- htdocs/ticket/agenda.php | 2 +- htdocs/ticket/messaging.php | 2 +- 6 files changed, 8 insertions(+), 8 deletions(-) diff --git a/htdocs/product/stock/replenishorders.php b/htdocs/product/stock/replenishorders.php index 13f7cca301f..c39f498d9b6 100644 --- a/htdocs/product/stock/replenishorders.php +++ b/htdocs/product/stock/replenishorders.php @@ -54,8 +54,8 @@ $search_dateday = GETPOST('search_dateday', 'int'); $search_date = dol_mktime(0, 0, 0, $search_datemonth, $search_dateday, $search_dateyear); $limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit; -$sortfield = GETPOST("sortfield"); -$sortorder = GETPOST("sortorder"); +$sortfield = GETPOST("sortfield", 'alpha'); +$sortorder = GETPOST("sortorder", 'alpha'); if (!$sortorder) $sortorder = 'DESC'; if (!$sortfield) $sortfield = 'cf.date_creation'; $page = GETPOST('page', 'int') ? GETPOST('page', 'int') : 0; diff --git a/htdocs/product/stock/valo.php b/htdocs/product/stock/valo.php index 32ffebdba76..e814bdfaac0 100644 --- a/htdocs/product/stock/valo.php +++ b/htdocs/product/stock/valo.php @@ -36,8 +36,8 @@ $sref=GETPOST("sref", 'alpha'); $snom=GETPOST("snom", 'alpha'); $sall=trim((GETPOST('search_all', 'alphanohtml')!='')?GETPOST('search_all', 'alphanohtml'):GETPOST('sall', 'alphanohtml')); -$sortfield = GETPOST("sortfield"); -$sortorder = GETPOST("sortorder"); +$sortfield = GETPOST("sortfield", 'alpha'); +$sortorder = GETPOST("sortorder", 'alpha'); if (! $sortfield) $sortfield="e.ref"; if (! $sortorder) $sortorder="ASC"; $page = $_GET["page"]; diff --git a/htdocs/projet/info.php b/htdocs/projet/info.php index 7a9521c7518..c28460e1045 100644 --- a/htdocs/projet/info.php +++ b/htdocs/projet/info.php @@ -38,7 +38,7 @@ $action = GETPOST('action', 'aZ09'); $limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit; $sortfield = GETPOST("sortfield", "alpha"); -$sortorder = GETPOST("sortorder"); +$sortorder = GETPOST("sortorder", 'alpha'); $page = GETPOST("page", 'int'); $page = is_numeric($page) ? $page : 0; $page = $page == -1 ? 0 : $page; diff --git a/htdocs/projet/list.php b/htdocs/projet/list.php index 1eed25433db..63240e9f842 100644 --- a/htdocs/projet/list.php +++ b/htdocs/projet/list.php @@ -61,7 +61,7 @@ $diroutputmassaction = $conf->projet->dir_output.'/temp/massgeneration/'.$user-> $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST("sortfield", "alpha"); -$sortorder = GETPOST("sortorder"); +$sortorder = GETPOST("sortorder", 'alpha'); $page = GETPOST("page", 'int'); $page = is_numeric($page) ? $page : 0; $page = $page == -1 ? 0 : $page; diff --git a/htdocs/ticket/agenda.php b/htdocs/ticket/agenda.php index 68cef779261..c5ffc4b0ab8 100644 --- a/htdocs/ticket/agenda.php +++ b/htdocs/ticket/agenda.php @@ -42,7 +42,7 @@ $action = GETPOST('action', 'aZ09'); $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST("sortfield", "alpha"); -$sortorder = GETPOST("sortorder"); +$sortorder = GETPOST("sortorder", 'alpha'); $page = GETPOST("page", 'int'); $page = is_numeric($page) ? $page : 0; $page = $page == -1 ? 0 : $page; diff --git a/htdocs/ticket/messaging.php b/htdocs/ticket/messaging.php index ee90a166b68..fd432fa6dde 100644 --- a/htdocs/ticket/messaging.php +++ b/htdocs/ticket/messaging.php @@ -42,7 +42,7 @@ $action = GETPOST('action', 'aZ09'); $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST("sortfield", "alpha"); -$sortorder = GETPOST("sortorder"); +$sortorder = GETPOST("sortorder", 'alpha'); $page = GETPOST("page", 'int'); $page = is_numeric($page) ? $page : 0; $page = $page == -1 ? 0 : $page; From d6ba06e271f7b98a410243416438f163a8678de1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric?= <35066297+c3do@users.noreply.github.com> Date: Thu, 21 Nov 2019 15:50:06 +0100 Subject: [PATCH 028/154] API New get attribute by ref + security update --- htdocs/product/class/api_products.class.php | 70 ++++++++++++++++----- 1 file changed, 53 insertions(+), 17 deletions(-) diff --git a/htdocs/product/class/api_products.class.php b/htdocs/product/class/api_products.class.php index c9e95cb5fe0..6010f6dbcdf 100644 --- a/htdocs/product/class/api_products.class.php +++ b/htdocs/product/class/api_products.class.php @@ -814,7 +814,7 @@ class Products extends DolibarrApi */ public function getAttributes() { - if(! (DolibarrApiAccess::$user->rights->produit->lire || DolibarrApiAccess::$user->rights->service->lire)) { + if(! DolibarrApiAccess::$user->rights->produit->lire) { throw new RestException(401); } @@ -836,7 +836,7 @@ class Products extends DolibarrApi */ public function getAttributeById($id) { - if(! (DolibarrApiAccess::$user->rights->produit->lire || DolibarrApiAccess::$user->rights->service->lire)) { + if(! DolibarrApiAccess::$user->rights->produit->lire) { throw new RestException(401); } @@ -849,6 +849,42 @@ class Products extends DolibarrApi return $prodattr; } + + /** + * Get attributes by ref. + * + * @param string $ref Reference of Attribute + * @return array + * + * @throws RestException + * @throws 401 + * + * @url GET attributes/ref/{ref} + */ + public function getAttributesByRef($ref) + { + if(! DolibarrApiAccess::$user->rights->produit->lire) { + throw new RestException(401); + } + + $sql = "SELECT rowid, ref, label, rang FROM ".MAIN_DB_PREFIX."product_attribute WHERE ref LIKE '". trim($ref) ."' AND entity IN (".getEntity('product').")"; + + $query = $this->db->query($sql); + + if (!$this->db->num_rows($query)) { + throw new RestException(404); + } + + $result = $this->db->fetch_object($query); + + $attr = []; + $attr['id'] = $result->rowid; + $attr['ref'] = $result->ref; + $attr['label'] = $result->label; + $attr['rang'] = $result->rang; + + return $attr; + } /** * Add attributes. @@ -864,7 +900,7 @@ class Products extends DolibarrApi */ public function addAttributes($ref, $label) { - if(! (DolibarrApiAccess::$user->rights->produit->lire || DolibarrApiAccess::$user->rights->service->lire)) { + if(! DolibarrApiAccess::$user->rights->produit->creer) { throw new RestException(401); } @@ -895,7 +931,7 @@ class Products extends DolibarrApi */ public function putAttributes($id, $ref, $label) { - if(! (DolibarrApiAccess::$user->rights->produit->lire || DolibarrApiAccess::$user->rights->service->lire)) { + if(! DolibarrApiAccess::$user->rights->produit->creer) { throw new RestException(401); } @@ -931,7 +967,7 @@ class Products extends DolibarrApi */ public function deleteAttributes($id) { - if(! (DolibarrApiAccess::$user->rights->produit->lire || DolibarrApiAccess::$user->rights->service->lire)) { + if(! DolibarrApiAccess::$user->rights->produit->supprimer) { throw new RestException(401); } @@ -958,7 +994,7 @@ class Products extends DolibarrApi */ public function deleteAttributesByRef($ref) { - if(! (DolibarrApiAccess::$user->rights->produit->lire || DolibarrApiAccess::$user->rights->service->lire)) { + if(! DolibarrApiAccess::$user->rights->produit->supprimer) { throw new RestException(401); } @@ -983,7 +1019,7 @@ class Products extends DolibarrApi */ public function getAttributeValues($id) { - if(! (DolibarrApiAccess::$user->rights->produit->lire || DolibarrApiAccess::$user->rights->service->lire)) { + if(! DolibarrApiAccess::$user->rights->produit->lire) { throw new RestException(401); } @@ -1004,7 +1040,7 @@ class Products extends DolibarrApi */ public function getAttributeValuesByRef($ref) { - if(! (DolibarrApiAccess::$user->rights->produit->lire || DolibarrApiAccess::$user->rights->service->lire)) { + if(! DolibarrApiAccess::$user->rights->produit->lire) { throw new RestException(401); } @@ -1044,7 +1080,7 @@ class Products extends DolibarrApi */ public function addAttributeValue($id, $ref, $value) { - if(! (DolibarrApiAccess::$user->rights->produit->lire || DolibarrApiAccess::$user->rights->service->lire)) { + if(! DolibarrApiAccess::$user->rights->produit->creer) { throw new RestException(401); } @@ -1076,7 +1112,7 @@ class Products extends DolibarrApi */ public function deleteAttributeValueById($id) { - if(! (DolibarrApiAccess::$user->rights->produit->lire || DolibarrApiAccess::$user->rights->service->lire)) { + if(! DolibarrApiAccess::$user->rights->produit->supprimer) { throw new RestException(401); } @@ -1102,7 +1138,7 @@ class Products extends DolibarrApi */ public function deleteAttributeValueByRef($ref) { - if(! (DolibarrApiAccess::$user->rights->produit->lire || DolibarrApiAccess::$user->rights->service->lire)) { + if(! DolibarrApiAccess::$user->rights->produit->supprimer) { throw new RestException(401); } @@ -1128,7 +1164,7 @@ class Products extends DolibarrApi */ public function getVariants($id) { - if(! (DolibarrApiAccess::$user->rights->produit->lire || DolibarrApiAccess::$user->rights->service->lire)) { + if(! DolibarrApiAccess::$user->rights->produit->lire) { throw new RestException(401); } @@ -1156,7 +1192,7 @@ class Products extends DolibarrApi */ public function getVariantsByProdRef($ref) { - if(! (DolibarrApiAccess::$user->rights->produit->lire || DolibarrApiAccess::$user->rights->service->lire)) { + if(! DolibarrApiAccess::$user->rights->produit->lire) { throw new RestException(401); } @@ -1196,7 +1232,7 @@ class Products extends DolibarrApi */ public function addVariant($id, $weight_impact, $price_impact, $price_impact_is_percent, $features) { - if(! (DolibarrApiAccess::$user->rights->produit->creer || DolibarrApiAccess::$user->rights->service->creer)) { + if(! DolibarrApiAccess::$user->rights->produit->creer) { throw new RestException(401); } @@ -1255,7 +1291,7 @@ class Products extends DolibarrApi */ public function addVariantByProductRef($ref, $weight_impact, $price_impact, $price_impact_is_percent, $features) { - if(! (DolibarrApiAccess::$user->rights->produit->creer || DolibarrApiAccess::$user->rights->service->creer)) { + if(! DolibarrApiAccess::$user->rights->produit->creer) { throw new RestException(401); } @@ -1308,7 +1344,7 @@ class Products extends DolibarrApi */ public function putVariant($id, $request_data = null) { - if(! (DolibarrApiAccess::$user->rights->produit->creer || DolibarrApiAccess::$user->rights->service->creer)) { + if(! DolibarrApiAccess::$user->rights->produit->creer) { throw new RestException(401); } @@ -1344,7 +1380,7 @@ class Products extends DolibarrApi */ public function deleteVariant($id) { - if(! (DolibarrApiAccess::$user->rights->produit->supprimer || DolibarrApiAccess::$user->rights->service->supprimer)) { + if(! DolibarrApiAccess::$user->rights->produit->supprimer) { throw new RestException(401); } From 4f747e2eb8e5054a8836eb99e0e4ef7fd1f623e2 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Thu, 21 Nov 2019 14:50:47 +0000 Subject: [PATCH 029/154] 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 6010f6dbcdf..faf312e77ff 100644 --- a/htdocs/product/class/api_products.class.php +++ b/htdocs/product/class/api_products.class.php @@ -849,7 +849,7 @@ class Products extends DolibarrApi return $prodattr; } - + /** * Get attributes by ref. * @@ -866,23 +866,23 @@ class Products extends DolibarrApi if(! DolibarrApiAccess::$user->rights->produit->lire) { throw new RestException(401); } - + $sql = "SELECT rowid, ref, label, rang FROM ".MAIN_DB_PREFIX."product_attribute WHERE ref LIKE '". trim($ref) ."' AND entity IN (".getEntity('product').")"; - + $query = $this->db->query($sql); - + if (!$this->db->num_rows($query)) { throw new RestException(404); } - + $result = $this->db->fetch_object($query); - + $attr = []; $attr['id'] = $result->rowid; $attr['ref'] = $result->ref; $attr['label'] = $result->label; $attr['rang'] = $result->rang; - + return $attr; } From 1068d9a62388606adceabcac241c681155ebc2d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric?= <35066297+c3do@users.noreply.github.com> Date: Thu, 21 Nov 2019 17:23:46 +0100 Subject: [PATCH 030/154] FIX deleteAttributeValueByRef / ADD getAttributeValueById, getAttributeValueByRef --- htdocs/product/class/api_products.class.php | 102 ++++++++++++++++++-- 1 file changed, 93 insertions(+), 9 deletions(-) diff --git a/htdocs/product/class/api_products.class.php b/htdocs/product/class/api_products.class.php index faf312e77ff..5be52795437 100644 --- a/htdocs/product/class/api_products.class.php +++ b/htdocs/product/class/api_products.class.php @@ -980,30 +980,114 @@ class Products extends DolibarrApi } throw new RestException(500, "Error deleting attribute"); } - + /** - * Delete attributes by ref. + * Get attribute value by id. * - * @param string $ref Reference of Attribute + * @param int $id ID of Attribute value + * @param string $ref Ref of Attribute value + * @return array + * + * @throws RestException + * @throws 401 + * + * @url GET attributes/values/{id} + */ + public function getAttributeValueById($id) + { + if(! DolibarrApiAccess::$user->rights->produit->lire) { + throw new RestException(401); + } + + $sql = "SELECT rowid, fk_product_attribute, ref, value FROM ".MAIN_DB_PREFIX."product_attribute_value WHERE rowid = ".(int) $id." AND entity IN (".getEntity('product').")"; + + $query = $this->db->query($sql); + + if (!$query) { + throw new RestException(401); + } + + if (!$this->db->num_rows($query)) { + throw new RestException(404, 'Attribute value not found'); + } + + $result = $this->db->fetch_object($query); + + $attrval = []; + $attrval['id'] = $result->rowid; + $attrval['fk_product_attribute'] = $result->fk_product_attribute; + $attrval['ref'] = $result->ref; + $attrval['value'] = $result->value; + + return $attrval; + } + + /** + * Get attribute value by ref. + * + * @param int $id ID of Attribute value + * @param string $ref Ref of Attribute value + * @return array + * + * @throws RestException + * @throws 401 + * + * @url GET attributes/{id}/values/ref/{ref} + */ + public function getAttributeValueByRef($id, $ref) + { + if(! DolibarrApiAccess::$user->rights->produit->lire) { + throw new RestException(401); + } + + $sql = "SELECT rowid, fk_product_attribute, ref, value FROM ".MAIN_DB_PREFIX."product_attribute_value WHERE ref LIKE '". trim($ref) ."' AND fk_product_attribute = ". (int) $id ." AND entity IN (".getEntity('product').")"; + + $query = $this->db->query($sql); + + if (!$query) { + throw new RestException(401); + } + + if (!$this->db->num_rows($query)) { + throw new RestException(404, 'Attribute value not found'); + } + + $result = $this->db->fetch_object($query); + + $attrval = []; + $attrval['id'] = $result->rowid; + $attrval['fk_product_attribute'] = $result->fk_product_attribute; + $attrval['ref'] = $result->ref; + $attrval['value'] = $result->value; + + return $attrval; + } + + /** + * Delete attribute value by ref. + * + * @param int $id ID of Attribute + * @param string $ref Ref of Attribute value * @return int * * @throws RestException * @throws 401 * - * @url DELETE attributes/ref/{ref} + * @url DELETE attributes/{id}/values/ref/{ref} */ - public function deleteAttributesByRef($ref) + public function deleteAttributeValueByRef($id, $ref) { if(! DolibarrApiAccess::$user->rights->produit->supprimer) { throw new RestException(401); } - - $sql = "DELETE FROM ".MAIN_DB_PREFIX."product_attribute WHERE ref LIKE '". trim($ref) ."'"; - + + $sql = "DELETE FROM ".MAIN_DB_PREFIX."product_attribute_value WHERE ref LIKE '". trim($ref) ."' AND fk_product_attribute = ". (int) $id; + if ($this->db->query($sql)) { return 1; } - throw new RestException(500, "Error deleting attribute"); + + throw new RestException(500, "Error deleting attribute value"); } /** From 0074589b6fa689ca1c355a78e153690292c3bb6f Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Thu, 21 Nov 2019 16:24:25 +0000 Subject: [PATCH 031/154] Fixing style errors. --- htdocs/product/class/api_products.class.php | 40 ++++++++++----------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/htdocs/product/class/api_products.class.php b/htdocs/product/class/api_products.class.php index 5be52795437..c614b013f83 100644 --- a/htdocs/product/class/api_products.class.php +++ b/htdocs/product/class/api_products.class.php @@ -980,7 +980,7 @@ class Products extends DolibarrApi } throw new RestException(500, "Error deleting attribute"); } - + /** * Get attribute value by id. * @@ -998,30 +998,30 @@ class Products extends DolibarrApi if(! DolibarrApiAccess::$user->rights->produit->lire) { throw new RestException(401); } - + $sql = "SELECT rowid, fk_product_attribute, ref, value FROM ".MAIN_DB_PREFIX."product_attribute_value WHERE rowid = ".(int) $id." AND entity IN (".getEntity('product').")"; - + $query = $this->db->query($sql); - + if (!$query) { throw new RestException(401); } - + if (!$this->db->num_rows($query)) { throw new RestException(404, 'Attribute value not found'); } - + $result = $this->db->fetch_object($query); - + $attrval = []; $attrval['id'] = $result->rowid; $attrval['fk_product_attribute'] = $result->fk_product_attribute; $attrval['ref'] = $result->ref; $attrval['value'] = $result->value; - + return $attrval; } - + /** * Get attribute value by ref. * @@ -1039,30 +1039,30 @@ class Products extends DolibarrApi if(! DolibarrApiAccess::$user->rights->produit->lire) { throw new RestException(401); } - + $sql = "SELECT rowid, fk_product_attribute, ref, value FROM ".MAIN_DB_PREFIX."product_attribute_value WHERE ref LIKE '". trim($ref) ."' AND fk_product_attribute = ". (int) $id ." AND entity IN (".getEntity('product').")"; - + $query = $this->db->query($sql); - + if (!$query) { throw new RestException(401); } - + if (!$this->db->num_rows($query)) { throw new RestException(404, 'Attribute value not found'); } - + $result = $this->db->fetch_object($query); - + $attrval = []; $attrval['id'] = $result->rowid; $attrval['fk_product_attribute'] = $result->fk_product_attribute; $attrval['ref'] = $result->ref; $attrval['value'] = $result->value; - + return $attrval; } - + /** * Delete attribute value by ref. * @@ -1080,13 +1080,13 @@ class Products extends DolibarrApi if(! DolibarrApiAccess::$user->rights->produit->supprimer) { throw new RestException(401); } - + $sql = "DELETE FROM ".MAIN_DB_PREFIX."product_attribute_value WHERE ref LIKE '". trim($ref) ."' AND fk_product_attribute = ". (int) $id; - + if ($this->db->query($sql)) { return 1; } - + throw new RestException(500, "Error deleting attribute value"); } From 416a2f7f1c0056c3cdebe6eb4505c8526bf10655 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric?= <35066297+c3do@users.noreply.github.com> Date: Thu, 21 Nov 2019 17:41:09 +0100 Subject: [PATCH 032/154] FIX putAttributes, ADD putAttributeValue --- htdocs/product/class/api_products.class.php | 80 +++++++++++++++++---- 1 file changed, 67 insertions(+), 13 deletions(-) diff --git a/htdocs/product/class/api_products.class.php b/htdocs/product/class/api_products.class.php index c614b013f83..2f3f7463b8d 100644 --- a/htdocs/product/class/api_products.class.php +++ b/htdocs/product/class/api_products.class.php @@ -914,14 +914,13 @@ class Products extends DolibarrApi } return $resid; } - + /** * Update attributes by id. * * @param int $id ID of Attribute - * @param string $ref Reference of Attribute - * @param string $label Label of Attribute - * @return int + * @param array $request_data Datas + * @return array * * @throws RestException * @throws 401 @@ -929,27 +928,36 @@ class Products extends DolibarrApi * * @url PUT attributes/{id} */ - public function putAttributes($id, $ref, $label) + public function putAttributes($id, $request_data = null) { if(! DolibarrApiAccess::$user->rights->produit->creer) { throw new RestException(401); } - + $prodattr = new ProductAttribute($this->db); - + $result = $prodattr->fetch((int) $id); if ($result == 0) { throw new RestException(404, 'Attribute not found'); } elseif ($result < 0) { throw new RestException(500, "Error fetching attribute"); } - - - $prodattr->label = $label; - $prodattr->ref = $ref; - + + foreach($request_data as $field => $value) { + if ($field == 'rowid') { continue; + } + $prodattr->$field = $value; + } + if ($prodattr->update(DolibarrApiAccess::$user) > 0) { - return 1; + $result = $prodattr->fetch((int) $id); + if ($result == 0) { + throw new RestException(404, 'Attribute not found'); + } elseif ($result < 0) { + throw new RestException(500, "Error fetching attribute"); + } else { + return $prodattr; + } } throw new RestException(500, "Error updating attribute"); } @@ -1182,6 +1190,52 @@ class Products extends DolibarrApi } throw new RestException(500, "Error creating new attribute value"); } + + /** + * Update attribute value. + * + * @param int $id ID of Attribute + * @param array $request_data Datas + * @return array + * + * @throws RestException + * @throws 401 + * + * @url PUT attributes/values/{id} + */ + public function putAttributeValue($id, $request_data) + { + if(! DolibarrApiAccess::$user->rights->produit->creer) { + throw new RestException(401); + } + + $objectval = new ProductAttributeValue($this->db); + $result = $objectval->fetch((int) $id); + + if ($result == 0) { + throw new RestException(404, 'Attribute value not found'); + } elseif ($result < 0) { + throw new RestException(500, "Error fetching attribute value"); + } + + foreach($request_data as $field => $value) { + if ($field == 'rowid') { continue; + } + $objectval->$field = $value; + } + + if ($objectval->update(DolibarrApiAccess::$user) > 0) { + $result = $objectval->fetch((int) $id); + if ($result == 0) { + throw new RestException(404, 'Attribute not found'); + } elseif ($result < 0) { + throw new RestException(500, "Error fetching attribute"); + } else { + return $objectval; + } + } + throw new RestException(500, "Error updating attribute"); + } /** * Delete attribute value by id. From cfa0860d244896fe64ca5e2e29b01b210e915a0a Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Thu, 21 Nov 2019 16:41:45 +0000 Subject: [PATCH 033/154] Fixing style errors. --- htdocs/product/class/api_products.class.php | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/htdocs/product/class/api_products.class.php b/htdocs/product/class/api_products.class.php index 2f3f7463b8d..04d9979cefe 100644 --- a/htdocs/product/class/api_products.class.php +++ b/htdocs/product/class/api_products.class.php @@ -914,7 +914,7 @@ class Products extends DolibarrApi } return $resid; } - + /** * Update attributes by id. * @@ -933,22 +933,22 @@ class Products extends DolibarrApi if(! DolibarrApiAccess::$user->rights->produit->creer) { throw new RestException(401); } - + $prodattr = new ProductAttribute($this->db); - + $result = $prodattr->fetch((int) $id); if ($result == 0) { throw new RestException(404, 'Attribute not found'); } elseif ($result < 0) { throw new RestException(500, "Error fetching attribute"); } - + foreach($request_data as $field => $value) { if ($field == 'rowid') { continue; } $prodattr->$field = $value; } - + if ($prodattr->update(DolibarrApiAccess::$user) > 0) { $result = $prodattr->fetch((int) $id); if ($result == 0) { @@ -1190,7 +1190,7 @@ class Products extends DolibarrApi } throw new RestException(500, "Error creating new attribute value"); } - + /** * Update attribute value. * @@ -1208,22 +1208,22 @@ class Products extends DolibarrApi if(! DolibarrApiAccess::$user->rights->produit->creer) { throw new RestException(401); } - + $objectval = new ProductAttributeValue($this->db); $result = $objectval->fetch((int) $id); - + if ($result == 0) { throw new RestException(404, 'Attribute value not found'); } elseif ($result < 0) { throw new RestException(500, "Error fetching attribute value"); } - + foreach($request_data as $field => $value) { if ($field == 'rowid') { continue; } $objectval->$field = $value; } - + if ($objectval->update(DolibarrApiAccess::$user) > 0) { $result = $objectval->fetch((int) $id); if ($result == 0) { From 351ba58bbe65f9ddf6e1f85d852ea39d620c613f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric?= <35066297+c3do@users.noreply.github.com> Date: Thu, 21 Nov 2019 17:43:40 +0100 Subject: [PATCH 034/154] Fix Superfluous parameter comment --- htdocs/product/class/api_products.class.php | 1 - 1 file changed, 1 deletion(-) diff --git a/htdocs/product/class/api_products.class.php b/htdocs/product/class/api_products.class.php index 04d9979cefe..32423c015fc 100644 --- a/htdocs/product/class/api_products.class.php +++ b/htdocs/product/class/api_products.class.php @@ -993,7 +993,6 @@ class Products extends DolibarrApi * Get attribute value by id. * * @param int $id ID of Attribute value - * @param string $ref Ref of Attribute value * @return array * * @throws RestException From e8bc8b68c1283226fd8b42e8d06006e257658e2c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 21 Nov 2019 18:17:40 +0100 Subject: [PATCH 035/154] Fix missing field in migration --- htdocs/core/lib/functions.lib.php | 4 ++-- htdocs/install/mysql/migration/10.0.0-11.0.0.sql | 5 +++++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 00ca3f3d45f..9faa3762111 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -3911,9 +3911,9 @@ function dol_print_error($db = '', $error = '', $errors = null) } if (empty($dolibarr_main_prod)) print $out; - else + else // This should not happen, except if there is a bug somewhere. Enabled and check log in such case. { - print 'This website is currently temporarly offline. This may be due to a maintenance operation. Current status of operation are on next line...

'."\n"; + print 'This website is currently temporarly offline.

This may be due to a maintenance operation. Current status of operation are on next line...

'."\n"; $langs->load("errors"); print $langs->trans("DolibarrHasDetectedError").'. '; print $langs->trans("YouCanSetOptionDolibarrMainProdToZero"); diff --git a/htdocs/install/mysql/migration/10.0.0-11.0.0.sql b/htdocs/install/mysql/migration/10.0.0-11.0.0.sql index fc488071d54..573facf541f 100644 --- a/htdocs/install/mysql/migration/10.0.0-11.0.0.sql +++ b/htdocs/install/mysql/migration/10.0.0-11.0.0.sql @@ -51,6 +51,11 @@ ALTER TABLE llx_adherent_type ADD UNIQUE INDEX uk_adherent_type_libelle (libelle ALTER TABLE llx_mailing_cibles MODIFY COLUMN lastname varchar(160); ALTER TABLE llx_mailing_cibles MODIFY COLUMN firstname varchar(160); +ALTER TABLE llx_emailcollector_emailcollector ADD COLUMN login varchar(128); +ALTER TABLE llx_emailcollector_emailcollector ADD COLUMN codelastresult varchar(16); + + + -- For v11 From 5a3f78088e2c42fd763d6493a4143783164c42fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric?= <35066297+c3do@users.noreply.github.com> Date: Thu, 21 Nov 2019 18:18:11 +0100 Subject: [PATCH 036/154] Fix double deleteAttributeValueByRef --- htdocs/product/class/api_products.class.php | 26 --------------------- 1 file changed, 26 deletions(-) diff --git a/htdocs/product/class/api_products.class.php b/htdocs/product/class/api_products.class.php index 32423c015fc..2fa4f600b11 100644 --- a/htdocs/product/class/api_products.class.php +++ b/htdocs/product/class/api_products.class.php @@ -1262,32 +1262,6 @@ class Products extends DolibarrApi throw new RestException(500, "Error deleting attribute value"); } - /** - * Delete attribute value by ref. - * - * @param string $ref Ref of Attribute value - * @return int - * - * @throws RestException - * @throws 401 - * - * @url DELETE attributes/values/ref/{ref} - */ - public function deleteAttributeValueByRef($ref) - { - if(! DolibarrApiAccess::$user->rights->produit->supprimer) { - throw new RestException(401); - } - - $sql = "DELETE FROM ".MAIN_DB_PREFIX."product_attribute_value WHERE ref LIKE '". trim($ref) ."'"; - - if ($this->db->query($sql)) { - return 1; - } - - throw new RestException(500, "Error deleting attribute value"); - } - /** * Get product variants. * From f9045aa41230bf9138c92518395284f3b6627b51 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 21 Nov 2019 18:39:41 +0100 Subject: [PATCH 037/154] Fix var not defined --- htdocs/admin/emailcollector_card.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/admin/emailcollector_card.php b/htdocs/admin/emailcollector_card.php index 43d0731c434..4662a12e6f8 100644 --- a/htdocs/admin/emailcollector_card.php +++ b/htdocs/admin/emailcollector_card.php @@ -509,11 +509,11 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea else { jQuery("#rulevalue").prop("disabled", false); } jQuery("#rulevalue").attr("placeholder", (jQuery("#filtertype option:selected").attr("data-placeholder"))); '; - $noparam = array(); + /*$noparam = array(); foreach ($arrayoftypes as $key => $value) { if ($value['noparam']) $noparam[] = $key; - } + }*/ print '})'; print ''."\n"; From 11be3b53f39b373f8818bff391869f956a585f7f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 21 Nov 2019 18:39:51 +0100 Subject: [PATCH 038/154] Fix migration --- htdocs/install/mysql/migration/10.0.0-11.0.0.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/install/mysql/migration/10.0.0-11.0.0.sql b/htdocs/install/mysql/migration/10.0.0-11.0.0.sql index 573facf541f..90e3b03319c 100644 --- a/htdocs/install/mysql/migration/10.0.0-11.0.0.sql +++ b/htdocs/install/mysql/migration/10.0.0-11.0.0.sql @@ -53,7 +53,7 @@ ALTER TABLE llx_mailing_cibles MODIFY COLUMN firstname varchar(160); ALTER TABLE llx_emailcollector_emailcollector ADD COLUMN login varchar(128); ALTER TABLE llx_emailcollector_emailcollector ADD COLUMN codelastresult varchar(16); - +ALTER TABLE llx_emailcollector_emailcollectoraction ADD COLUMN position integer DEFAULT 0; From 6ef01a09f3393303e2c11cc2b53169b18d23e00e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 21 Nov 2019 18:51:26 +0100 Subject: [PATCH 039/154] Fix error management --- htdocs/admin/emailcollector_card.php | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/htdocs/admin/emailcollector_card.php b/htdocs/admin/emailcollector_card.php index 4662a12e6f8..bfa2904d02d 100644 --- a/htdocs/admin/emailcollector_card.php +++ b/htdocs/admin/emailcollector_card.php @@ -418,10 +418,17 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea if (function_exists('imap_open')) { $connectstringserver = $object->getConnectStringIMAP(); - $connectstringsource = $connectstringserver.imap_utf7_encode($sourcedir); - $connectstringtarget = $connectstringserver.imap_utf7_encode($targetdir); - $connection = imap_open($connectstringsource, $object->login, $object->password); + try { + $connectstringsource = $connectstringserver.imap_utf7_encode($sourcedir); + $connectstringtarget = $connectstringserver.imap_utf7_encode($targetdir); + + $connection = imap_open($connectstringsource, $object->login, $object->password); + } + catch(Exception $e) + { + print $e->getMessage(); + } } else { From 394dc4b403874a055e84ab5a6cd66ffb084b154e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 21 Nov 2019 19:03:00 +0100 Subject: [PATCH 040/154] Try to fix php error with imap_utf7_encode --- .../class/emailcollector.class.php | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/htdocs/emailcollector/class/emailcollector.class.php b/htdocs/emailcollector/class/emailcollector.class.php index efdb3ea5d3b..c464e38d4a7 100644 --- a/htdocs/emailcollector/class/emailcollector.class.php +++ b/htdocs/emailcollector/class/emailcollector.class.php @@ -683,6 +683,38 @@ class EmailCollector extends CommonObject return $connectstringserver; } + /** + * Convert str to UTF-7 imap default mailbox names + * + * @param string $str String to encode + * @return string Encode string + */ + function getEncodedUtf7($str) { + if (function_exists('mb_convert_encoding')) { + # change spaces by entropy because mb_convert fail with spaces + $str=ereg_replace(" ","xyxy",$str); + # if mb_convert work + if ($str = mb_convert_encoding($str,"UTF-7")) { + # change characters + $str=preg_replace("/\+A/","&A",$str); + # change to spaces again + $str=preg_replace("/xyxy/"," ",$str); + # return encoded string + return $str; + # else + } else { + # print error and return false + echo "error: is not possible to encode this string '$str'.[". + imap_last_error(). + "]"; + return false; + } + } + else { + return $str; + } + } + /** * Action executed by scheduler * CAN BE A CRON TASK. In such a case, paramerts come from the schedule job setup field 'Parameters' From feb6e09a64071ede8979f6528350a0d6abbc3790 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 21 Nov 2019 19:09:23 +0100 Subject: [PATCH 041/154] Fix phpcs --- htdocs/emailcollector/class/emailcollector.class.php | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/htdocs/emailcollector/class/emailcollector.class.php b/htdocs/emailcollector/class/emailcollector.class.php index c464e38d4a7..10a9a847d74 100644 --- a/htdocs/emailcollector/class/emailcollector.class.php +++ b/htdocs/emailcollector/class/emailcollector.class.php @@ -692,21 +692,19 @@ class EmailCollector extends CommonObject function getEncodedUtf7($str) { if (function_exists('mb_convert_encoding')) { # change spaces by entropy because mb_convert fail with spaces - $str=ereg_replace(" ","xyxy",$str); + $str=preg_replace("/ /", "xyxy", $str); # if mb_convert work - if ($str = mb_convert_encoding($str,"UTF-7")) { + if ($str = mb_convert_encoding($str, "UTF-7")) { # change characters - $str=preg_replace("/\+A/","&A",$str); + $str=preg_replace("/\+A/", "&A", $str); # change to spaces again - $str=preg_replace("/xyxy/"," ",$str); + $str=preg_replace("/xyxy/", " ", $str); # return encoded string return $str; # else } else { # print error and return false - echo "error: is not possible to encode this string '$str'.[". - imap_last_error(). - "]"; + $this->error = "error: is not possible to encode this string '".$str."'"; return false; } } From ab7c5a7575f887c69c5cdf742c2e07ba150f2f82 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 21 Nov 2019 19:12:25 +0100 Subject: [PATCH 042/154] Fix connectstring imap --- htdocs/admin/emailcollector_card.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/htdocs/admin/emailcollector_card.php b/htdocs/admin/emailcollector_card.php index bfa2904d02d..e690c8839e3 100644 --- a/htdocs/admin/emailcollector_card.php +++ b/htdocs/admin/emailcollector_card.php @@ -420,8 +420,14 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea $connectstringserver = $object->getConnectStringIMAP(); try { - $connectstringsource = $connectstringserver.imap_utf7_encode($sourcedir); - $connectstringtarget = $connectstringserver.imap_utf7_encode($targetdir); + if ($sourcedir) { + //$connectstringsource = $connectstringserver.imap_utf7_encode($sourcedir); + $connectstringsource = $connectstringserver.$object->getEncodedUtf7($sourcedir); + } + if ($targetdir) { + //$connectstringtarget = $connectstringserver.imap_utf7_encode($targetdir); + $connectstringtarget = $connectstringserver.$object->getEncodedUtf7($targetdir); + } $connection = imap_open($connectstringsource, $object->login, $object->password); } From dcb52110b956fbc08cf6c0c80fe4f11e423a34a6 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 21 Nov 2019 19:42:31 +0100 Subject: [PATCH 043/154] Clean code --- htdocs/emailcollector/class/emailcollector.class.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/htdocs/emailcollector/class/emailcollector.class.php b/htdocs/emailcollector/class/emailcollector.class.php index 10a9a847d74..1b2baa4e335 100644 --- a/htdocs/emailcollector/class/emailcollector.class.php +++ b/htdocs/emailcollector/class/emailcollector.class.php @@ -1090,7 +1090,6 @@ class EmailCollector extends CommonObject // If there is a filter on trackid if ($searchfilterdoltrackid > 0) { - //if (empty($headers['X-Dolibarr-TRACKID'])) continue; if (empty($headers['References']) || !preg_match('/@'.preg_quote($host, '/').'/', $headers['References'])) { $nbemailprocessed++; @@ -1104,7 +1103,6 @@ class EmailCollector extends CommonObject $nbemailprocessed++; continue; } - //if (! empty($headers['X-Dolibarr-TRACKID']) continue; } $thirdpartystatic = new Societe($this->db); From 432a37522b0025bd98c46760a20c43d143e1770b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 21 Nov 2019 19:56:00 +0100 Subject: [PATCH 044/154] Add TODO to avoid duplicate --- .../class/emailcollector.class.php | 137 +++++++++--------- 1 file changed, 72 insertions(+), 65 deletions(-) diff --git a/htdocs/emailcollector/class/emailcollector.class.php b/htdocs/emailcollector/class/emailcollector.class.php index 1b2baa4e335..f2750f7e042 100644 --- a/htdocs/emailcollector/class/emailcollector.class.php +++ b/htdocs/emailcollector/class/emailcollector.class.php @@ -1487,78 +1487,85 @@ class EmailCollector extends CommonObject // Create event elseif ($operation['type'] == 'recordevent') { - if ($projectstatic->id > 0) - { - if ($projectfoundby) $descriptionmeta = dol_concatdesc($descriptionmeta, 'Project found from '.$projectfoundby); - } - if ($thirdpartystatic->id > 0) - { - if ($thirdpartyfoundby) $descriptionmeta = dol_concatdesc($descriptionmeta, 'Third party found from '.$thirdpartyfoundby); - } - if ($contactstatic->id > 0) - { - if ($contactfoundby) $descriptionmeta = dol_concatdesc($descriptionmeta, 'Contact/address found from '.$contactfoundby); - } + $alreadycreated = 0; + // TODO Check if $msg ID already in database for $conf->entity - $description = $descriptiontitle; - $description = dol_concatdesc($description, "-----"); - $description = dol_concatdesc($description, $descriptionmeta); - $description = dol_concatdesc($description, "-----"); - $description = dol_concatdesc($description, $messagetext); - $descriptionfull = $description; - $descriptionfull = dol_concatdesc($descriptionfull, "----- Header"); - $descriptionfull = dol_concatdesc($descriptionfull, $header); + if (! $alreadycreated) + { + if ($projectstatic->id > 0) + { + if ($projectfoundby) $descriptionmeta = dol_concatdesc($descriptionmeta, 'Project found from '.$projectfoundby); + } + if ($thirdpartystatic->id > 0) + { + if ($thirdpartyfoundby) $descriptionmeta = dol_concatdesc($descriptionmeta, 'Third party found from '.$thirdpartyfoundby); + } + if ($contactstatic->id > 0) + { + if ($contactfoundby) $descriptionmeta = dol_concatdesc($descriptionmeta, 'Contact/address found from '.$contactfoundby); + } - // Insert record of emails sent - $actioncomm = new ActionComm($this->db); - $actioncomm->type_code = 'AC_OTH_AUTO'; // Type of event ('AC_OTH', 'AC_OTH_AUTO', 'AC_XXX'...) - $actioncomm->code = 'AC_'.$actioncode; - $actioncomm->label = $langs->trans("ActionAC_".$actioncode).' - '.$langs->trans("MailFrom").' '.$from; - $actioncomm->note_private= $descriptionfull; - $actioncomm->fk_project = $projectstatic->id; - $actioncomm->datep = $date; - $actioncomm->datef = $date; - $actioncomm->percentage = -1; // Not applicable - $actioncomm->socid = $thirdpartystatic->id; - $actioncomm->contactid = $contactstatic->id; - $actioncomm->socpeopleassigned = (!empty($contactstatic->id) ? array($contactstatic->id => '') : array()); - $actioncomm->authorid = $user->id; // User saving action - $actioncomm->userownerid = $user->id; // Owner of action - // Fields when action is an email (content should be added into note) - $actioncomm->email_msgid = $msgid; - $actioncomm->email_from = $fromstring; - $actioncomm->email_sender= $sender; - $actioncomm->email_to = $to; - $actioncomm->email_tocc = $sendtocc; - $actioncomm->email_tobcc = $sendtobcc; - $actioncomm->email_subject = $subject; - $actioncomm->errors_to = ''; + $description = $descriptiontitle; + $description = dol_concatdesc($description, "-----"); + $description = dol_concatdesc($description, $descriptionmeta); + $description = dol_concatdesc($description, "-----"); + $description = dol_concatdesc($description, $messagetext); - if (! in_array($fk_element_type, array('societe','contact','project','user'))) - { - $actioncomm->fk_element = $fk_element_id; - $actioncomm->elementtype = $fk_element_type; - } + $descriptionfull = $description; + $descriptionfull = dol_concatdesc($descriptionfull, "----- Header"); + $descriptionfull = dol_concatdesc($descriptionfull, $header); - //$actioncomm->extraparams = $extraparams; + // Insert record of emails sent + $actioncomm = new ActionComm($this->db); + $actioncomm->type_code = 'AC_OTH_AUTO'; // Type of event ('AC_OTH', 'AC_OTH_AUTO', 'AC_XXX'...) + $actioncomm->code = 'AC_'.$actioncode; + $actioncomm->label = $langs->trans("ActionAC_".$actioncode).' - '.$langs->trans("MailFrom").' '.$from; + $actioncomm->note_private= $descriptionfull; + $actioncomm->fk_project = $projectstatic->id; + $actioncomm->datep = $date; + $actioncomm->datef = $date; + $actioncomm->percentage = -1; // Not applicable + $actioncomm->socid = $thirdpartystatic->id; + $actioncomm->contactid = $contactstatic->id; + $actioncomm->socpeopleassigned = (!empty($contactstatic->id) ? array($contactstatic->id => '') : array()); + $actioncomm->authorid = $user->id; // User saving action + $actioncomm->userownerid = $user->id; // Owner of action + // Fields when action is an email (content should be added into note) + $actioncomm->email_msgid = $msgid; + $actioncomm->email_from = $fromstring; + $actioncomm->email_sender= $sender; + $actioncomm->email_to = $to; + $actioncomm->email_tocc = $sendtocc; + $actioncomm->email_tobcc = $sendtobcc; + $actioncomm->email_subject = $subject; + $actioncomm->errors_to = ''; - // Overwrite values with values extracted from source email - $errorforthisaction = $this->overwritePropertiesOfObject($actioncomm, $operation['actionparam'], $messagetext, $subject, $header); + if (! in_array($fk_element_type, array('societe','contact','project','user'))) + { + $actioncomm->fk_element = $fk_element_id; + $actioncomm->elementtype = $fk_element_type; + } - if ($errorforthisaction) - { - $errorforactions++; - } - else - { - $result = $actioncomm->create($user); - if ($result <= 0) - { - $errorforactions++; - $this->errors = $actioncomm->errors; - } - } + //$actioncomm->extraparams = $extraparams; + + // Overwrite values with values extracted from source email + $errorforthisaction = $this->overwritePropertiesOfObject($actioncomm, $operation['actionparam'], $messagetext, $subject, $header); + + if ($errorforthisaction) + { + $errorforactions++; + } + else + { + $result = $actioncomm->create($user); + if ($result <= 0) + { + $errorforactions++; + $this->errors = $actioncomm->errors; + } + } + } } // Create event elseif ($operation['type'] == 'project') From c9b79c8aa10416c1234d22b20f60f8144ec59ab0 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 21 Nov 2019 20:07:22 +0100 Subject: [PATCH 045/154] Fix norsh --- htdocs/admin/emailcollector_card.php | 2 ++ htdocs/emailcollector/class/emailcollector.class.php | 8 ++++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/htdocs/admin/emailcollector_card.php b/htdocs/admin/emailcollector_card.php index e690c8839e3..f6146cb409b 100644 --- a/htdocs/admin/emailcollector_card.php +++ b/htdocs/admin/emailcollector_card.php @@ -435,6 +435,8 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea { print $e->getMessage(); } + + $morehtml .= $form->textwithpicto('', 'connect string '.$connectstringserver); } else { diff --git a/htdocs/emailcollector/class/emailcollector.class.php b/htdocs/emailcollector/class/emailcollector.class.php index f2750f7e042..55b6907f912 100644 --- a/htdocs/emailcollector/class/emailcollector.class.php +++ b/htdocs/emailcollector/class/emailcollector.class.php @@ -667,16 +667,20 @@ class EmailCollector extends CommonObject /** * Return the connectstring to use with IMAP connection function * + * @param int $norsh Add /norsh to connectstring * @return string */ - public function getConnectStringIMAP() + public function getConnectStringIMAP($ssl = 1, $norsh = 0) { + global $conf; + // Connect to IMAP $flags = '/service=imap'; // IMAP - $flags .= '/ssl'; // '/tls' + if ($ssl) $flags .= '/ssl'; // '/tls' $flags .= '/novalidate-cert'; //$flags.='/readonly'; //$flags.='/debug'; + if ($norsh || ! empty($conf->global->IMPA_FORCE_NORSH)) $flags .= '/norsh'; $connectstringserver = '{'.$this->host.':993'.$flags.'}'; From b46362dff980562832fbb839191e7e704dfc771b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 21 Nov 2019 20:45:19 +0100 Subject: [PATCH 046/154] More complete error message --- htdocs/core/class/CMailFile.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/class/CMailFile.class.php b/htdocs/core/class/CMailFile.class.php index 335c1b50111..fc5dff72a69 100644 --- a/htdocs/core/class/CMailFile.class.php +++ b/htdocs/core/class/CMailFile.class.php @@ -776,7 +776,7 @@ class CMailFile else { if (empty($this->error)) $this->error = $result; - dol_syslog("CMailFile::sendfile: mail end error=".$this->error, LOG_ERR); + dol_syslog("CMailFile::sendfile: mail end error with smtps lib to HOST=".$server.", PORT=".$conf->global->$keyforsmtpport."
".$this->error, LOG_ERR); $res = false; } } From 5fdd6f698d3b550c7537d37deab1e54b69a50033 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 21 Nov 2019 20:45:19 +0100 Subject: [PATCH 047/154] More complete error message Conflicts: htdocs/core/class/CMailFile.class.php --- 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 bf9b617693f..9b1a5a69525 100644 --- a/htdocs/core/class/CMailFile.class.php +++ b/htdocs/core/class/CMailFile.class.php @@ -752,9 +752,9 @@ class CMailFile } else { - if (empty($this->error)) $this->error=$result; - dol_syslog("CMailFile::sendfile: mail end error=".$this->error, LOG_ERR); - $res=false; + if (empty($this->error)) $this->error = $result; + dol_syslog("CMailFile::sendfile: mail end error with smtps lib to HOST=".$server.", PORT=".$conf->global->$keyforsmtpport."
".$this->error, LOG_ERR); + $res = false; } } } From 2f2ac90fbf49021e66ee0d515d409b7fc9f36d62 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 21 Nov 2019 21:35:16 +0100 Subject: [PATCH 048/154] Try to disable autocomplete --- htdocs/admin/mails.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/admin/mails.php b/htdocs/admin/mails.php index c52f899a03f..546a322fcdf 100644 --- a/htdocs/admin/mails.php +++ b/htdocs/admin/mails.php @@ -315,7 +315,7 @@ if ($action == 'edit') // SuperAdministrator access only if (empty($conf->multicompany->enabled) || ($user->admin && ! $user->entity)) { - print ''; + print ''; print ''; print ''.$langs->trans("SeeLocalSendMailSetup").''; } @@ -388,7 +388,7 @@ if ($action == 'edit') // SuperAdministrator access only if (empty($conf->multicompany->enabled) || ($user->admin && !$user->entity)) { - print ''; + print ''; } else { From 92a65a8039edad855ba5e927658218bba24acd89 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 21 Nov 2019 21:36:03 +0100 Subject: [PATCH 049/154] Log --- htdocs/core/class/CMailFile.class.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/core/class/CMailFile.class.php b/htdocs/core/class/CMailFile.class.php index fc5dff72a69..eb15710eb7c 100644 --- a/htdocs/core/class/CMailFile.class.php +++ b/htdocs/core/class/CMailFile.class.php @@ -626,6 +626,7 @@ class CMailFile } // Force parameters + //dol_syslog("CMailFile::sendfile conf->global->".$keyforsmtpserver."=".$conf->global->$keyforsmtpserver." cpnf->global->".$keyforsmtpport."=".$conf->global->$keyforsmtpport, LOG_DEBUG); if (!empty($conf->global->$keyforsmtpserver)) ini_set('SMTP', $conf->global->$keyforsmtpserver); if (!empty($conf->global->$keyforsmtpport)) ini_set('smtp_port', $conf->global->$keyforsmtpport); From 1bc8c57d6d2486d5f3919bf12dc5ff5204968f85 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric?= <35066297+c3do@users.noreply.github.com> Date: Thu, 21 Nov 2019 22:54:13 +0100 Subject: [PATCH 050/154] Fix $weight_impact $price_impact --- htdocs/product/class/api_products.class.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/htdocs/product/class/api_products.class.php b/htdocs/product/class/api_products.class.php index 2fa4f600b11..bb83630bb72 100644 --- a/htdocs/product/class/api_products.class.php +++ b/htdocs/product/class/api_products.class.php @@ -1347,9 +1347,12 @@ class Products extends DolibarrApi throw new RestException(401); } - if (empty($id) || empty($weight_impact) || empty($price_impact) || empty($features) || !is_array($features)) { + if (empty($id) || empty($features) || !is_array($features)) { throw new RestException(401); } + + $weight_impact = price2num($weight_impact); + $price_impact = price2num($price_impact); $prodattr = new ProductAttribute($this->db); $prodattr_val = new ProductAttributeValue($this->db); @@ -1406,9 +1409,12 @@ class Products extends DolibarrApi throw new RestException(401); } - if (empty($ref) || empty($weight_impact) || empty($price_impact) || empty($features) || !is_array($features)) { + if (empty($ref) || empty($features) || !is_array($features)) { throw new RestException(401); } + + $weight_impact = price2num($weight_impact); + $price_impact = price2num($price_impact); $prodattr = new ProductAttribute($this->db); $prodattr_val = new ProductAttributeValue($this->db); From 821ca724a5031f0825efec5a94334596505d8292 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Thu, 21 Nov 2019 21:54:51 +0000 Subject: [PATCH 051/154] Fixing style errors. --- 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 bb83630bb72..c5ca4271f75 100644 --- a/htdocs/product/class/api_products.class.php +++ b/htdocs/product/class/api_products.class.php @@ -1350,7 +1350,7 @@ class Products extends DolibarrApi if (empty($id) || empty($features) || !is_array($features)) { throw new RestException(401); } - + $weight_impact = price2num($weight_impact); $price_impact = price2num($price_impact); @@ -1412,7 +1412,7 @@ class Products extends DolibarrApi if (empty($ref) || empty($features) || !is_array($features)) { throw new RestException(401); } - + $weight_impact = price2num($weight_impact); $price_impact = price2num($price_impact); From e76a112099ec5eff39d77a3f4f87ba049e78146e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric?= <35066297+c3do@users.noreply.github.com> Date: Thu, 21 Nov 2019 23:09:18 +0100 Subject: [PATCH 052/154] Remove unecessary dol_clone in ::putVariant --- htdocs/product/class/api_products.class.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/htdocs/product/class/api_products.class.php b/htdocs/product/class/api_products.class.php index c5ca4271f75..37c950e9956 100644 --- a/htdocs/product/class/api_products.class.php +++ b/htdocs/product/class/api_products.class.php @@ -1468,8 +1468,6 @@ class Products extends DolibarrApi $prodcomb = new ProductCombination($this->db); $prodcomb->fetch((int) $id); - $old_prodcomb = dol_clone($prodcomb, 0); - foreach($request_data as $field => $value) { if ($field == 'rowid') { continue; } From f4e1361d068b62902b96ae787fba5d7c37005137 Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Fri, 22 Nov 2019 06:53:05 +0100 Subject: [PATCH 053/154] NEW small fix --- htdocs/core/boxes/box_shipments.php | 1 - 1 file changed, 1 deletion(-) diff --git a/htdocs/core/boxes/box_shipments.php b/htdocs/core/boxes/box_shipments.php index 4852934af74..957c738ad22 100644 --- a/htdocs/core/boxes/box_shipments.php +++ b/htdocs/core/boxes/box_shipments.php @@ -124,7 +124,6 @@ class box_shipments extends ModeleBoxes $orderstatic->id= $objp->commande_id; $orderstatic->ref=$objp->commande_ref; - print $orderstatic->getNomUrl(1); $societestatic->id = $objp->socid; $societestatic->name = $objp->name; From 383f095063b0bf5e7e214f1708c1ebeccac101d8 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 22 Nov 2019 09:45:14 +0100 Subject: [PATCH 054/154] Fix trans --- htdocs/langs/en_US/admin.lang | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index e7685ef25b9..05c076625f1 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -1905,8 +1905,8 @@ CodeLastResult=Latest result code NbOfEmailsInInbox=Number of emails in source directory LoadThirdPartyFromName=Load third party searching on %s (load only) LoadThirdPartyFromNameOrCreate=Load third party searching on %s (create if not found) -WithDolTrackingID=Dolibarr Tracking ID found -WithoutDolTrackingID=Dolibarr Tracking ID not found +WithDolTrackingID=Dolibarr Reference found in Message ID +WithoutDolTrackingID=Dolibarr Reference not found in Message ID FormatZip=Zip MainMenuCode=Menu entry code (mainmenu) ECMAutoTree=Show automatic ECM tree From 61913078654c3846cecfbcb3227ca15f450f875a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 22 Nov 2019 12:22:27 +0100 Subject: [PATCH 055/154] Debug v11 --- htdocs/admin/mails_senderprofile_list.php | 14 +++++-- .../core/class/emailsenderprofile.class.php | 37 ++++++++++++------- .../install/mysql/migration/10.0.0-11.0.0.sql | 1 + htdocs/theme/md/style.css.php | 3 ++ 4 files changed, 38 insertions(+), 17 deletions(-) diff --git a/htdocs/admin/mails_senderprofile_list.php b/htdocs/admin/mails_senderprofile_list.php index c5201adedeb..a22c9d79ac5 100644 --- a/htdocs/admin/mails_senderprofile_list.php +++ b/htdocs/admin/mails_senderprofile_list.php @@ -135,6 +135,10 @@ if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'e if (empty($reshook)) { + // Actions cancel, add, update, delete or clone + $backurlforlist = $_SERVER["PHP_SELF"].'?action=list'; + include DOL_DOCUMENT_ROOT.'/core/actions_addupdatedelete.inc.php'; + // Selection of new fields include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; @@ -344,7 +348,7 @@ print '
'; print ''; print ''; -print ''; +print ''; print ''; print ''; print ''; @@ -365,10 +369,14 @@ if ($action != 'create') { print ''; print ''; print ''; - print ''; + print ''; print ''; print ''; print '
'.$langs->trans("Label").'
'.$langs->trans("Email").'
'.$langs->trans("Signature").'
'.$langs->trans("Signature").''; + require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; + $doleditor = new DolEditor('signature', GETPOST('signature'), '', 138, 'dolibarr_notes', 'In', true, true, empty($conf->global->FCKEDITOR_ENABLE_USERSIGN) ? 0 : 1, ROWS_4, '90%'); + print $doleditor->Create(1); + print '
'.$langs->trans("Position").'
'.$langs->trans("Status").''; - print ''; + print $form->selectyesno('active', GETPOST('active', 'int'), 1); print '
'; print '
'; diff --git a/htdocs/core/class/emailsenderprofile.class.php b/htdocs/core/class/emailsenderprofile.class.php index b65d72332e0..41a0d485ce0 100644 --- a/htdocs/core/class/emailsenderprofile.class.php +++ b/htdocs/core/class/emailsenderprofile.class.php @@ -56,19 +56,28 @@ class EmailSenderProfile extends CommonObject public $picto = 'emailsenderprofile@monmodule'; + const STATUS_DISABLED = 0; + const STATUS_ENABLED = 1; + + /** - * 'type' if the field format. - * 'label' the translation key. - * 'enabled' is a condition when the filed must be managed. - * 'visible' says if field is visible in list (-1 means not shown by default but can be added into list to be viewed). - * 'notnull' is set to 1 if not null in database. Set to -1 if we must set data to null if empty ('' or 0). - * 'index' if we want an index in database. - * 'foreignkey'=>'tablename.field' if the field is a foreign key (it is recommanded to name the field fk_...). - * 'position' is the sort order of field. - * 'searchall' is 1 if we want to search in this field when making a search from the quick search button. - * 'isameasure' must be set to 1 if you want to have a total on list for this field. Field type must be summable like integer or double(24,8). - * 'help' is a string visible as a tooltip on field - * 'comment' is not used. You can store here any text of your choice. + * 'type' if the field format ('integer', 'integer:Class:pathtoclass', 'varchar(x)', 'double(24,8)', 'text', 'html', 'datetime', 'timestamp', 'float') + * 'label' the translation key. + * 'enabled' is a condition when the field must be managed. + * 'visible' says if field is visible in list (Examples: 0=Not visible, 1=Visible on list and create/update/view forms, 2=Visible on list only, 3=Visible on create/update/view form only (not list), 4=Visible on list and update/view form only (not create). Using a negative value means field is not shown by default on list but can be selected for viewing) + * 'noteditable' says if field is not editable (1 or 0) + * 'notnull' is set to 1 if not null in database. Set to -1 if we must set data to null if empty ('' or 0). + * 'default' is a default value for creation (can still be replaced by the global setup of default values) + * 'index' if we want an index in database. + * 'foreignkey'=>'tablename.field' if the field is a foreign key (it is recommanded to name the field fk_...). + * 'position' is the sort order of field. + * 'searchall' is 1 if we want to search in this field when making a search from the quick search button. + * 'isameasure' must be set to 1 if you want to have a total on list for this field. Field type must be summable like integer or double(24,8). + * 'css' is the CSS style to use on field. For example: 'maxwidth200' + * 'help' is a string visible as a tooltip on field + * 'comment' is not used. You can store here any text of your choice. It is not used by application. + * 'showoncombobox' if value of the field must be visible into the label of the combobox that list record + * 'arraykeyval' to set list of value if type is a list of predefined values. For example: array("0"=>"Draft","1"=>"Active","-1"=>"Cancel") */ // BEGIN MODULEBUILDER PROPERTIES @@ -78,7 +87,7 @@ class EmailSenderProfile extends CommonObject public $fields=array( 'rowid' => array('type'=>'integer', 'label'=>'TechnicalID', 'visible'=>-1, 'enabled'=>1, 'position'=>1, 'notnull'=>1, 'index'=>1, 'comment'=>'Id',), 'entity' => array('type'=>'integer', 'label'=>'Entity', 'visible'=>-1, 'enabled'=>1, 'position'=>20, 'notnull'=>1, 'index'=>1,), - 'label' => array('type'=>'varchar(255)', 'label'=>'Label', 'visible'=>1, 'enabled'=>1, 'position'=>30, 'notnull'=>-1), + 'label' => array('type'=>'varchar(255)', 'label'=>'Label', 'visible'=>1, 'enabled'=>1, 'position'=>30, 'notnull'=>1), 'email' => array('type'=>'varchar(255)', 'label'=>'Email', 'visible'=>1, 'enabled'=>1, 'position'=>40, 'notnull'=>-1), //'fk_user_creat' => array('type'=>'integer', 'label'=>'UserAuthor', 'visible'=>-1, 'enabled'=>1, 'position'=>500, 'notnull'=>1,), //'fk_user_modif' => array('type'=>'integer', 'label'=>'UserModif', 'visible'=>-1, 'enabled'=>1, 'position'=>500, 'notnull'=>-1,), @@ -86,7 +95,7 @@ class EmailSenderProfile extends CommonObject 'position' => array('type'=>'integer', 'label'=>'Position', 'visible'=>1, 'enabled'=>1, 'position'=>405, 'notnull'=>-1, 'index'=>1,), 'date_creation' => array('type'=>'datetime', 'label'=>'DateCreation', 'visible'=>-1, 'enabled'=>1, 'position'=>500, 'notnull'=>1,), 'tms' => array('type'=>'timestamp', 'label'=>'DateModification', 'visible'=>-1, 'enabled'=>1, 'position'=>500, 'notnull'=>1,), - 'active' => array('type'=>'integer', 'label'=>'Status', 'visible'=>1, 'enabled'=>1, 'position'=>1000, 'notnull'=>-1, 'index'=>1), + 'active' => array('type'=>'integer', 'label'=>'Status', 'visible'=>1, 'enabled'=>1, 'default'=>1, 'position'=>1000, 'notnull'=>-1, 'index'=>1), ); /** diff --git a/htdocs/install/mysql/migration/10.0.0-11.0.0.sql b/htdocs/install/mysql/migration/10.0.0-11.0.0.sql index 90e3b03319c..96ac938883c 100644 --- a/htdocs/install/mysql/migration/10.0.0-11.0.0.sql +++ b/htdocs/install/mysql/migration/10.0.0-11.0.0.sql @@ -59,6 +59,7 @@ ALTER TABLE llx_emailcollector_emailcollectoraction ADD COLUMN position integer -- For v11 +ALTER TABLE llx_c_email_senderprofile MODIFY COLUMN active tinyint DEFAULT 1 NOT NULL; insert into llx_c_type_container (code,label,module,active) values ('menu', 'Menu', 'system', 1); diff --git a/htdocs/theme/md/style.css.php b/htdocs/theme/md/style.css.php index d704ce13cbf..d25c106bf39 100644 --- a/htdocs/theme/md/style.css.php +++ b/htdocs/theme/md/style.css.php @@ -972,6 +972,9 @@ select.flat.selectlimit { -ms-overflow-style: -ms-autohiding-scrollbar; }*/ /* Style used for most tables */ +div.fiche>div.tabBar>form>div.div-table-responsive { + min-height: 392px; +} .div-table-responsive, .div-table-responsive-no-min { overflow-x: auto; min-height: 0.01%; From 1ed2eacbef482604cd2f120b21a84a854c366a2a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 22 Nov 2019 12:40:17 +0100 Subject: [PATCH 056/154] Debug add email profile --- htdocs/admin/mails_senderprofile_list.php | 7 ++++--- htdocs/core/actions_addupdatedelete.inc.php | 1 + 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/htdocs/admin/mails_senderprofile_list.php b/htdocs/admin/mails_senderprofile_list.php index a22c9d79ac5..e287db9c7c9 100644 --- a/htdocs/admin/mails_senderprofile_list.php +++ b/htdocs/admin/mails_senderprofile_list.php @@ -358,7 +358,7 @@ $newcardbutton = ''; if ($action != 'create') { $newcardbutton = dolGetButtonTitle($langs->trans('New'), '', 'fa fa-plus-circle', $_SERVER['PHP_SELF'].'?action=create', '', $permissiontoadd); } else { - print ''; + /*print ''; if ($optioncss != '') print ''; print ''; print ''; @@ -366,6 +366,7 @@ if ($action != 'create') { print ''; print ''; print ''; + */ print ''; print ''; print ''; @@ -374,7 +375,7 @@ if ($action != 'create') { $doleditor = new DolEditor('signature', GETPOST('signature'), '', 138, 'dolibarr_notes', 'In', true, true, empty($conf->global->FCKEDITOR_ENABLE_USERSIGN) ? 0 : 1, ROWS_4, '90%'); print $doleditor->Create(1); print ''; - print ''; + print ''; print ''; @@ -385,7 +386,7 @@ if ($action != 'create') { print '   '; print ''; print ''; - print ''; + //print ''; } print_barre_liste('', $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'title_companies', 0, $newcardbutton, '', $limit); diff --git a/htdocs/core/actions_addupdatedelete.inc.php b/htdocs/core/actions_addupdatedelete.inc.php index ee4208cd65e..0d718c2abc2 100644 --- a/htdocs/core/actions_addupdatedelete.inc.php +++ b/htdocs/core/actions_addupdatedelete.inc.php @@ -75,6 +75,7 @@ if ($action == 'add' && !empty($permissiontoadd)) if (preg_match('/^integer:/i', $object->fields[$key]['type']) && $value == '-1') $value = ''; // This is an implicit foreign key field if (!empty($object->fields[$key]['foreignkey']) && $value == '-1') $value = ''; // This is an explicit foreign key field + //var_dump($key.' '.$value.' '.$object->fields[$key]['type']); $object->$key = $value; if ($val['notnull'] > 0 && $object->$key == '' && !is_null($val['default']) && $val['default'] == '(PROV)') { From 00ad95c01e671abc6e87d1c088c2fa4e89342df0 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 22 Nov 2019 14:06:43 +0100 Subject: [PATCH 057/154] Figth against useless dependencies: Remove library the core never use. --- htdocs/core/class/html.form.class.php | 1 + .../multiselect/jquery.multi-select.js | 360 ------------------ .../multiselect/jquery.multi-select.min.js | 9 - htdocs/main.inc.php | 4 - 4 files changed, 1 insertion(+), 373 deletions(-) delete mode 100644 htdocs/includes/jquery/plugins/multiselect/jquery.multi-select.js delete mode 100644 htdocs/includes/jquery/plugins/multiselect/jquery.multi-select.min.js diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index cac859c53b5..d70993be51d 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -6521,6 +6521,7 @@ class Form elseif ($addjscombo == 2) { // Add other js lib + // TODO external lib multiselect/jquery.multi-select.js must have been loaded to use this multiselect plugin // ... $out .= '$(document).ready(function () { $(\'#'.$htmlname.'\').multiSelect({ diff --git a/htdocs/includes/jquery/plugins/multiselect/jquery.multi-select.js b/htdocs/includes/jquery/plugins/multiselect/jquery.multi-select.js deleted file mode 100644 index ee62d1f588d..00000000000 --- a/htdocs/includes/jquery/plugins/multiselect/jquery.multi-select.js +++ /dev/null @@ -1,360 +0,0 @@ -// jquery.multi-select.js -// by mySociety -// https://github.com/mysociety/jquery-multi-select - -;(function($) { - - "use strict"; - - var pluginName = "multiSelect", - defaults = { - 'containerHTML': '
', - 'menuHTML': '
', - 'buttonHTML': '', - 'menuItemsHTML': '
', - 'menuItemHTML': '
'; print ''. ''. ''. ''. ''; // Company - $href = DOL_URL_ROOT . '/fourn/card.php?socid=' . $obj->socid; + $href = DOL_URL_ROOT.'/fourn/card.php?socid='.$obj->socid; print ''; + ''. + img_object($langs->trans('ShowCompany'), 'company').' '. + $obj->name.''; // Author $userstatic->id = $obj->fk_user_author; @@ -288,7 +288,7 @@ if ($resql) if ($userstatic->id) { $txt = $userstatic->getLoginUrl(1); } else { - $txt = ' '; + $txt = ' '; } print ''; // Amount @@ -296,9 +296,9 @@ if ($resql) // Date if ($obj->dc) { - $date = dol_print_date($db->jdate($obj->dc), 'dayhour'); + $date = dol_print_date($db->jdate($obj->dc), 'dayhour'); } else { - $date = '-'; + $date = '-'; } print ''; // Statut diff --git a/htdocs/product/stock/valo.php b/htdocs/product/stock/valo.php index e814bdfaac0..816d97351b4 100644 --- a/htdocs/product/stock/valo.php +++ b/htdocs/product/stock/valo.php @@ -30,19 +30,19 @@ require_once DOL_DOCUMENT_ROOT.'/product/stock/class/entrepot.class.php'; $langs->load("stocks"); // Security check -$result=restrictedArea($user, 'stock'); +$result = restrictedArea($user, 'stock'); -$sref=GETPOST("sref", 'alpha'); -$snom=GETPOST("snom", 'alpha'); -$sall=trim((GETPOST('search_all', 'alphanohtml')!='')?GETPOST('search_all', 'alphanohtml'):GETPOST('sall', 'alphanohtml')); +$sref = GETPOST("sref", 'alpha'); +$snom = GETPOST("snom", 'alpha'); +$sall = trim((GETPOST('search_all', 'alphanohtml') != '') ?GETPOST('search_all', 'alphanohtml') : GETPOST('sall', 'alphanohtml')); $sortfield = GETPOST("sortfield", 'alpha'); $sortorder = GETPOST("sortorder", 'alpha'); -if (! $sortfield) $sortfield="e.ref"; -if (! $sortorder) $sortorder="ASC"; +if (!$sortfield) $sortfield = "e.ref"; +if (!$sortorder) $sortorder = "ASC"; $page = $_GET["page"]; if ($page < 0) $page = 0; -$limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit; +$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $offset = $limit * $page; $year = strftime("%Y", time()); @@ -53,23 +53,23 @@ $year = strftime("%Y", time()); */ $sql = "SELECT e.rowid, e.ref, e.statut, e.lieu, e.address, e.zip, e.town, e.fk_pays,"; -$sql.= " SUM(ps.pmp * ps.reel) as estimatedvalue, SUM(p.price * ps.reel) as sellvalue"; -$sql.= " FROM ".MAIN_DB_PREFIX."entrepot as e"; -$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product_stock as ps ON e.rowid = ps.fk_entrepot"; -$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON ps.fk_product = p.rowid"; -$sql.= " WHERE e.entity IN (".getEntity('stock').")"; -if ($sref) $sql.= natural_search("e.ref", $sref); +$sql .= " SUM(ps.pmp * ps.reel) as estimatedvalue, SUM(p.price * ps.reel) as sellvalue"; +$sql .= " FROM ".MAIN_DB_PREFIX."entrepot as e"; +$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product_stock as ps ON e.rowid = ps.fk_entrepot"; +$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON ps.fk_product = p.rowid"; +$sql .= " WHERE e.entity IN (".getEntity('stock').")"; +if ($sref) $sql .= natural_search("e.ref", $sref); if ($sall) { - $sql.= " AND (e.ref LIKE '%".$db->escape($sall)."%'"; - $sql.= " OR e.description LIKE '%".$db->escape($sall)."%'"; - $sql.= " OR e.lieu LIKE '%".$db->escape($sall)."%'"; - $sql.= " OR e.address LIKE '%".$db->escape($sall)."%'"; - $sql.= " OR e.town LIKE '%".$db->escape($sall)."%')"; + $sql .= " AND (e.ref LIKE '%".$db->escape($sall)."%'"; + $sql .= " OR e.description LIKE '%".$db->escape($sall)."%'"; + $sql .= " OR e.lieu LIKE '%".$db->escape($sall)."%'"; + $sql .= " OR e.address LIKE '%".$db->escape($sall)."%'"; + $sql .= " OR e.town LIKE '%".$db->escape($sall)."%')"; } -$sql.= " GROUP BY e.rowid, e.ref, e.statut, e.lieu, e.address, e.zip, e.town, e.fk_pays"; -$sql.= $db->order($sortfield, $sortorder); -$sql.= $db->plimit($limit + 1, $offset); +$sql .= " GROUP BY e.rowid, e.ref, e.statut, e.lieu, e.address, e.zip, e.town, e.fk_pays"; +$sql .= $db->order($sortfield, $sortorder); +$sql .= $db->plimit($limit + 1, $offset); $result = $db->query($sql); if ($result) @@ -78,7 +78,7 @@ if ($result) $i = 0; - $help_url='EN:Module_Stocks_En|FR:Module_Stock|ES:Módulo_Stocks'; + $help_url = 'EN:Module_Stocks_En|FR:Module_Stock|ES:Módulo_Stocks'; llxHeader("", $langs->trans("EnhancedValueOfWarehouses"), $help_url); print_barre_liste($langs->trans("EnhancedValueOfWarehouses"), $page, $_SERVER["PHP_SELF"], "", $sortfield, $sortorder, '', $num); @@ -94,9 +94,9 @@ if ($result) if ($num) { - $entrepot=new Entrepot($db); + $entrepot = new Entrepot($db); $total = $totalsell = 0; - $var=false; + $var = false; while ($i < min($num, $limit)) { $objp = $db->fetch_object($result); @@ -136,17 +136,17 @@ if ($result) print '
'; - $file='entrepot-'.$year.'.png'; + $file = 'entrepot-'.$year.'.png'; if (file_exists($conf->stock->dir_temp.'/'.$file)) { - $url=DOL_URL_ROOT.'/viewimage.php?modulepart=graph_stock&file='.$file; + $url = DOL_URL_ROOT.'/viewimage.php?modulepart=graph_stock&file='.$file; print ''; } - $file='entrepot-'.($year-1).'.png'; + $file = 'entrepot-'.($year - 1).'.png'; if (file_exists($conf->stock->dir_temp.'/'.$file)) { - $url=DOL_URL_ROOT.'/viewimage.php?modulepart=graph_stock&file='.$file; + $url = DOL_URL_ROOT.'/viewimage.php?modulepart=graph_stock&file='.$file; print '
'; } } diff --git a/htdocs/projet/info.php b/htdocs/projet/info.php index c28460e1045..ddb7673dece 100644 --- a/htdocs/projet/info.php +++ b/htdocs/projet/info.php @@ -36,34 +36,34 @@ $ref = GETPOST('ref', 'alpha'); $socid = GETPOST('socid', 'int'); $action = GETPOST('action', 'aZ09'); -$limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit; +$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST("sortfield", "alpha"); $sortorder = GETPOST("sortorder", 'alpha'); $page = GETPOST("page", 'int'); $page = is_numeric($page) ? $page : 0; $page = $page == -1 ? 0 : $page; -if (! $sortfield) $sortfield="a.datep,a.id"; -if (! $sortorder) $sortorder="DESC"; -$offset = $limit * $page ; +if (!$sortfield) $sortfield = "a.datep,a.id"; +if (!$sortorder) $sortorder = "DESC"; +$offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; if (GETPOST('actioncode', 'array')) { - $actioncode=GETPOST('actioncode', 'array', 3); - if (! count($actioncode)) $actioncode='0'; + $actioncode = GETPOST('actioncode', 'array', 3); + if (!count($actioncode)) $actioncode = '0'; } else { - $actioncode=GETPOST("actioncode", "alpha", 3)?GETPOST("actioncode", "alpha", 3):(GETPOST("actioncode")=='0'?'0':(empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT)?'':$conf->global->AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT)); + $actioncode = GETPOST("actioncode", "alpha", 3) ?GETPOST("actioncode", "alpha", 3) : (GETPOST("actioncode") == '0' ? '0' : (empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT) ? '' : $conf->global->AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT)); } -$search_agenda_label=GETPOST('search_agenda_label'); +$search_agenda_label = GETPOST('search_agenda_label'); // Security check $id = GETPOST("id", 'int'); -$socid=0; +$socid = 0; //if ($user->socid > 0) $socid = $user->socid; // For external user, no check is done on company because readability is managed by public status of project and assignement. -$result=restrictedArea($user, 'projet', $id, ''); +$result = restrictedArea($user, 'projet', $id, ''); if (!$user->rights->projet->lire) accessforbidden(); @@ -149,20 +149,20 @@ dol_fiche_end(); // Actions buttons -$out=''; -$permok=$user->rights->agenda->myactions->create; +$out = ''; +$permok = $user->rights->agenda->myactions->create; if ($permok) { - $out.='&projectid='.$object->id; + $out .= '&projectid='.$object->id; } //print '
'; -$morehtmlcenter=''; -if (! empty($conf->agenda->enabled)) +$morehtmlcenter = ''; +if (!empty($conf->agenda->enabled)) { - $addActionBtnRight = ! empty($user->rights->agenda->myactions->create) || ! empty($user->rights->agenda->allactions->create); - $morehtmlcenter.= dolGetButtonTitle($langs->trans('AddAction'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/comm/action/card.php?action=create'.$out.'&backtopage='.urlencode($_SERVER["PHP_SELF"].'?id='.$object->id), '', $addActionBtnRight); + $addActionBtnRight = !empty($user->rights->agenda->myactions->create) || !empty($user->rights->agenda->allactions->create); + $morehtmlcenter .= dolGetButtonTitle($langs->trans('AddAction'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/comm/action/card.php?action=create'.$out.'&backtopage='.urlencode($_SERVER["PHP_SELF"].'?id='.$object->id), '', $addActionBtnRight); } //print '
'; diff --git a/htdocs/resource/list.php b/htdocs/resource/list.php index e1bf458b6e4..d0f85eb9fe2 100644 --- a/htdocs/resource/list.php +++ b/htdocs/resource/list.php @@ -50,56 +50,56 @@ $extrafields = new ExtraFields($db); // fetch optionals attributes and labels $extrafields->fetch_name_optionals_label($object->table_element); -$search_array_options=$extrafields->getOptionalsFromPost($object->table_element, '', 'search_'); -if (! is_array($search_array_options)) $search_array_options = array(); -$search_ref=GETPOST("search_ref"); -$search_type=GETPOST("search_type"); +$search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_'); +if (!is_array($search_array_options)) $search_array_options = array(); +$search_ref = GETPOST("search_ref"); +$search_type = GETPOST("search_type"); -$filter=array(); +$filter = array(); -if ($search_ref != ''){ - $param.='&search_ref='.$search_ref; - $filter['t.ref']=$search_ref; +if ($search_ref != '') { + $param .= '&search_ref='.$search_ref; + $filter['t.ref'] = $search_ref; } -if ($search_type != ''){ - $param.='&search_type='.$search_type; - $filter['ty.label']=$search_type; +if ($search_type != '') { + $param .= '&search_type='.$search_type; + $filter['ty.label'] = $search_type; } -if ($search_label != '') $param.='&search_label='.$search_label; +if ($search_label != '') $param .= '&search_label='.$search_label; // Add $param from extra fields foreach ($search_array_options as $key => $val) { - $crit=$val; - $tmpkey=preg_replace('/search_options_/', '', $key); - $typ=$extrafields->attributes[$object->table_element]['type'][$tmpkey]; + $crit = $val; + $tmpkey = preg_replace('/search_options_/', '', $key); + $typ = $extrafields->attributes[$object->table_element]['type'][$tmpkey]; if ($val != '') { - $param.='&search_options_'.$tmpkey.'='.urlencode($val); + $param .= '&search_options_'.$tmpkey.'='.urlencode($val); } - $mode_search=0; - if (in_array($typ, array('int','double','real'))) $mode_search=1; // Search on a numeric - if (in_array($typ, array('sellist','link')) && $crit != '0' && $crit != '-1') $mode_search=2; // Search on a foreign key int - if ($crit != '' && (! in_array($typ, array('select','sellist')) || $crit != '0') && (! in_array($typ, array('link')) || $crit != '-1')) + $mode_search = 0; + if (in_array($typ, array('int', 'double', 'real'))) $mode_search = 1; // Search on a numeric + if (in_array($typ, array('sellist', 'link')) && $crit != '0' && $crit != '-1') $mode_search = 2; // Search on a foreign key int + if ($crit != '' && (!in_array($typ, array('select', 'sellist')) || $crit != '0') && (!in_array($typ, array('link')) || $crit != '-1')) { $filter['ef.'.$tmpkey] = natural_search('ef.'.$tmpkey, $crit, $mode_search); } } -if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage; +if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.$contextpage; $hookmanager->initHooks(array('resourcelist')); -if (empty($sortorder)) $sortorder="ASC"; -if (empty($sortfield)) $sortfield="t.ref"; +if (empty($sortorder)) $sortorder = "ASC"; +if (empty($sortfield)) $sortfield = "t.ref"; if (empty($arch)) $arch = 0; -$limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit; +$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $page = GETPOST("page", 'int'); if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 -$offset = $limit * $page ; +$offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; -if( ! $user->rights->resource->read) { +if (!$user->rights->resource->read) { accessforbidden(); } $arrayfields = array( @@ -115,10 +115,10 @@ $arrayfields = array( // Extra fields if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label']) > 0) { - foreach($extrafields->attributes[$object->table_element]['label'] as $key => $val) + foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) { - if (! empty($extrafields->attributes[$object->table_element]['list'][$key])) - $arrayfields["ef.".$key]=array('label'=>$extrafields->attributes[$object->table_element]['label'][$key], 'checked'=>(($extrafields->attributes[$object->table_element]['list'][$key]<0)?0:1), 'position'=>$extrafields->attributes[$object->table_element]['pos'][$key], 'enabled'=>(abs($extrafields->attributes[$object->table_element]['list'][$key])!=3 && $extrafields->attributes[$object->table_element]['perms'][$key])); + if (!empty($extrafields->attributes[$object->table_element]['list'][$key])) + $arrayfields["ef.".$key] = array('label'=>$extrafields->attributes[$object->table_element]['label'][$key], 'checked'=>(($extrafields->attributes[$object->table_element]['list'][$key] < 0) ? 0 : 1), 'position'=>$extrafields->attributes[$object->table_element]['pos'][$key], 'enabled'=>(abs($extrafields->attributes[$object->table_element]['list'][$key]) != 3 && $extrafields->attributes[$object->table_element]['perms'][$key])); } } $object->fields = dol_sort_array($object->fields, 'position'); From e36ee63ab60337c162fbb0570e2ba20c204df16c Mon Sep 17 00:00:00 2001 From: Scrutinizer Auto-Fixer Date: Fri, 22 Nov 2019 13:16:38 +0000 Subject: [PATCH 061/154] Scrutinizer Auto-Fixes This commit consists of patches automatically generated for this project on https://scrutinizer-ci.com --- htdocs/commande/tpl/linkedobjectblock.tpl.php | 16 +- htdocs/compta/facture/card.php | 2 +- .../expedition/tpl/linkedobjectblock.tpl.php | 16 +- htdocs/main.inc.php | 848 +++++++++--------- htdocs/theme/eldy/style.css.php | 212 ++--- htdocs/theme/md/theme_vars.inc.php | 96 +- htdocs/ticket/tpl/linkedobjectblock.tpl.php | 18 +- htdocs/user/document.php | 66 +- 8 files changed, 637 insertions(+), 637 deletions(-) diff --git a/htdocs/commande/tpl/linkedobjectblock.tpl.php b/htdocs/commande/tpl/linkedobjectblock.tpl.php index 1b69e035fba..a593e10adf4 100644 --- a/htdocs/commande/tpl/linkedobjectblock.tpl.php +++ b/htdocs/commande/tpl/linkedobjectblock.tpl.php @@ -18,7 +18,7 @@ */ // Protection to avoid direct call of template -if (empty($conf) || ! is_object($conf)) { +if (empty($conf) || !is_object($conf)) { print "Error, template page can't be called as URL"; exit; } @@ -36,14 +36,14 @@ $langs->load("orders"); $linkedObjectBlock = dol_sort_array($linkedObjectBlock, 'date', 'desc', 0, 0, 1); -$total=0; -$ilink=0; -foreach($linkedObjectBlock as $key => $objectlink) +$total = 0; +$ilink = 0; +foreach ($linkedObjectBlock as $key => $objectlink) { $ilink++; - $trclass='oddeven'; - if ($ilink == count($linkedObjectBlock) && empty($noMoreLinkedObjectBlockAfter) && count($linkedObjectBlock) <= 1) $trclass.=' liste_sub_total'; + $trclass = 'oddeven'; + if ($ilink == count($linkedObjectBlock) && empty($noMoreLinkedObjectBlockAfter) && count($linkedObjectBlock) <= 1) $trclass .= ' liste_sub_total'; echo ''; echo ''; echo ''; echo "\n"; } if (count($linkedObjectBlock) > 1) { - echo ''; + echo ''; echo ''; echo ''; echo ''; diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index 0d39cda6513..f0854eabde2 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -1216,7 +1216,7 @@ if (empty($reshook)) // Si facture standard $object->socid = GETPOST('socid', 'int'); $object->type = GETPOST('type'); - $object->ref = $_POST['ref']; + $object->ref = $_POST['ref']; $object->date = $dateinvoice; $object->date_pointoftax = $date_pointoftax; $object->note_public = trim(GETPOST('note_public', 'none')); diff --git a/htdocs/expedition/tpl/linkedobjectblock.tpl.php b/htdocs/expedition/tpl/linkedobjectblock.tpl.php index 1cc0e30934d..fbc1763beb3 100644 --- a/htdocs/expedition/tpl/linkedobjectblock.tpl.php +++ b/htdocs/expedition/tpl/linkedobjectblock.tpl.php @@ -17,7 +17,7 @@ */ // Protection to avoid direct call of template -if (empty($conf) || ! is_object($conf)) +if (empty($conf) || !is_object($conf)) { print "Error, template page can't be called as URL"; exit; @@ -35,14 +35,14 @@ $linkedObjectBlock = $GLOBALS['linkedObjectBlock']; // Load translation files required by the page $langs->load("sendings"); -$total=0; -$ilink=0; -foreach($linkedObjectBlock as $key => $objectlink) +$total = 0; +$ilink = 0; +foreach ($linkedObjectBlock as $key => $objectlink) { $ilink++; - $trclass='oddeven'; - if ($ilink == count($linkedObjectBlock) && empty($noMoreLinkedObjectBlockAfter) && count($linkedObjectBlock) <= 1) $trclass.=' liste_sub_total'; + $trclass = 'oddeven'; + if ($ilink == count($linkedObjectBlock) && empty($noMoreLinkedObjectBlockAfter) && count($linkedObjectBlock) <= 1) $trclass .= ' liste_sub_total'; ?> @@ -58,7 +58,7 @@ foreach($linkedObjectBlock as $key => $objectlink) $objectlink) } if (count($linkedObjectBlock) > 1) { ?> - + diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index 2fe3dbc140a..6b17bb6f947 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -89,28 +89,28 @@ function testSqlAndScriptInject($val, $type) $inj += preg_match('/'."\n"; + print ''."\n"; } } // Global js function print ''."\n"; - print ''."\n"; + print ''."\n"; // JS forced by modules (relative url starting with /) - if (! empty($conf->modules_parts['js'])) // $conf->modules_parts['js'] is array('module'=>array('file1','file2')) + if (!empty($conf->modules_parts['js'])) // $conf->modules_parts['js'] is array('module'=>array('file1','file2')) { - $arrayjs=(array) $conf->modules_parts['js']; - foreach($arrayjs as $modjs => $filesjs) + $arrayjs = (array) $conf->modules_parts['js']; + foreach ($arrayjs as $modjs => $filesjs) { - $filesjs=(array) $filesjs; // To be sure filejs is an array - foreach($filesjs as $jsfile) + $filesjs = (array) $filesjs; // To be sure filejs is an array + foreach ($filesjs as $jsfile) { // jsfile is a relative path - print ''."\n".''."\n"; + print ''."\n".''."\n"; } } } @@ -1613,15 +1613,15 @@ function top_menu($head, $title = '', $target = '', $disablejs = 0, $disablehead // Add login user link - $toprightmenu.=''."\n"; - $toprightmenu.=''; print $toprightmenu; - print "\n"; // end div class="login_block" + print "\n"; // end div class="login_block" print ''; @@ -1752,94 +1752,94 @@ function top_menu_user() global $menumanager; $userImage = $userDropDownImage = ''; - if (! empty($user->photo)) + if (!empty($user->photo)) { $userImage = Form::showphoto('userphoto', $user, 0, 0, 0, 'photouserphoto userphoto', 'small', 0, 1); $userDropDownImage = Form::showphoto('userphoto', $user, 0, 0, 0, 'dropdown-user-image', 'small', 0, 1); } else { - $nophoto='/public/theme/common/user_anonymous.png'; - if ($user->gender == 'man') $nophoto='/public/theme/common/user_man.png'; - if ($user->gender == 'woman') $nophoto='/public/theme/common/user_woman.png'; + $nophoto = '/public/theme/common/user_anonymous.png'; + if ($user->gender == 'man') $nophoto = '/public/theme/common/user_man.png'; + if ($user->gender == 'woman') $nophoto = '/public/theme/common/user_woman.png'; $userImage = 'No photo'; $userDropDownImage = 'No photo'; } $dropdownBody = ''; - $dropdownBody.= ' '.$langs->trans("ShowMoreInfos").''; - $dropdownBody.= '
'; + $dropdownBody .= ' '.$langs->trans("ShowMoreInfos").''; + $dropdownBody .= '
'; // login infos - if (! empty($user->admin)) { - $dropdownBody.= '
' . $langs->trans("Administrator").': '.yn($user->admin); + if (!empty($user->admin)) { + $dropdownBody .= '
'.$langs->trans("Administrator").': '.yn($user->admin); } - if (! empty($user->socid)) // Add thirdparty for external users + if (!empty($user->socid)) // Add thirdparty for external users { $thirdpartystatic = new Societe($db); $thirdpartystatic->fetch($user->socid); - $companylink = ' '.$thirdpartystatic->getNomUrl(2); // picto only of company - $company=' ('.$langs->trans("Company").': '.$thirdpartystatic->name.')'; + $companylink = ' '.$thirdpartystatic->getNomUrl(2); // picto only of company + $company = ' ('.$langs->trans("Company").': '.$thirdpartystatic->name.')'; } - $type=($user->socid?$langs->trans("External").$company:$langs->trans("Internal")); - $dropdownBody.= '
' . $langs->trans("Type") . ': ' . $type; - $dropdownBody.= '
' . $langs->trans("Status").': '.$user->getLibStatut(0); - $dropdownBody.= '
'; + $type = ($user->socid ? $langs->trans("External").$company : $langs->trans("Internal")); + $dropdownBody .= '
'.$langs->trans("Type").': '.$type; + $dropdownBody .= '
'.$langs->trans("Status").': '.$user->getLibStatut(0); + $dropdownBody .= '
'; - $dropdownBody.= '
'.$langs->trans("Session").''; - $dropdownBody.= '
'.$langs->trans("IPAddress").': '.dol_escape_htmltag($_SERVER["REMOTE_ADDR"]); - if (! empty($conf->global->MAIN_MODULE_MULTICOMPANY)) $dropdownBody.= '
'.$langs->trans("ConnectedOnMultiCompany").': '.$conf->entity.' (user entity '.$user->entity.')'; - $dropdownBody.= '
'.$langs->trans("AuthenticationMode").': '.$_SESSION["dol_authmode"].(empty($dolibarr_main_demo)?'':' (demo)'); - $dropdownBody.= '
'.$langs->trans("ConnectedSince").': '.dol_print_date($user->datelastlogin, "dayhour", 'tzuser'); - $dropdownBody.= '
'.$langs->trans("PreviousConnexion").': '.dol_print_date($user->datepreviouslogin, "dayhour", 'tzuser'); - $dropdownBody.= '
'.$langs->trans("CurrentTheme").': '.$conf->theme; - $dropdownBody.= '
'.$langs->trans("CurrentMenuManager").': '.$menumanager->name; - $langFlag=picto_from_langcode($langs->getDefaultLang()); - $dropdownBody.= '
'.$langs->trans("CurrentUserLanguage").': '.($langFlag?$langFlag.' ':'').$langs->getDefaultLang(); - $dropdownBody.= '
'.$langs->trans("Browser").': '.$conf->browser->name.($conf->browser->version?' '.$conf->browser->version:'').' ('.dol_escape_htmltag($_SERVER['HTTP_USER_AGENT']).')'; - $dropdownBody.= '
'.$langs->trans("Layout").': '.$conf->browser->layout; - $dropdownBody.= '
'.$langs->trans("Screen").': '.$_SESSION['dol_screenwidth'].' x '.$_SESSION['dol_screenheight']; - if ($conf->browser->layout == 'phone') $dropdownBody.= '
'.$langs->trans("Phone").': '.$langs->trans("Yes"); - if (! empty($_SESSION["disablemodules"])) $dropdownBody.= '
'.$langs->trans("DisabledModules").':
'.join(', ', explode(',', $_SESSION["disablemodules"])); - $dropdownBody.= '
'; + $dropdownBody .= '
'.$langs->trans("Session").''; + $dropdownBody .= '
'.$langs->trans("IPAddress").': '.dol_escape_htmltag($_SERVER["REMOTE_ADDR"]); + if (!empty($conf->global->MAIN_MODULE_MULTICOMPANY)) $dropdownBody .= '
'.$langs->trans("ConnectedOnMultiCompany").': '.$conf->entity.' (user entity '.$user->entity.')'; + $dropdownBody .= '
'.$langs->trans("AuthenticationMode").': '.$_SESSION["dol_authmode"].(empty($dolibarr_main_demo) ? '' : ' (demo)'); + $dropdownBody .= '
'.$langs->trans("ConnectedSince").': '.dol_print_date($user->datelastlogin, "dayhour", 'tzuser'); + $dropdownBody .= '
'.$langs->trans("PreviousConnexion").': '.dol_print_date($user->datepreviouslogin, "dayhour", 'tzuser'); + $dropdownBody .= '
'.$langs->trans("CurrentTheme").': '.$conf->theme; + $dropdownBody .= '
'.$langs->trans("CurrentMenuManager").': '.$menumanager->name; + $langFlag = picto_from_langcode($langs->getDefaultLang()); + $dropdownBody .= '
'.$langs->trans("CurrentUserLanguage").': '.($langFlag ? $langFlag.' ' : '').$langs->getDefaultLang(); + $dropdownBody .= '
'.$langs->trans("Browser").': '.$conf->browser->name.($conf->browser->version ? ' '.$conf->browser->version : '').' ('.dol_escape_htmltag($_SERVER['HTTP_USER_AGENT']).')'; + $dropdownBody .= '
'.$langs->trans("Layout").': '.$conf->browser->layout; + $dropdownBody .= '
'.$langs->trans("Screen").': '.$_SESSION['dol_screenwidth'].' x '.$_SESSION['dol_screenheight']; + if ($conf->browser->layout == 'phone') $dropdownBody .= '
'.$langs->trans("Phone").': '.$langs->trans("Yes"); + if (!empty($_SESSION["disablemodules"])) $dropdownBody .= '
'.$langs->trans("DisabledModules").':
'.join(', ', explode(',', $_SESSION["disablemodules"])); + $dropdownBody .= '
'; // Execute hook - $parameters=array('user'=>$user, 'langs' => $langs); - $result=$hookmanager->executeHooks('printTopRightMenuLoginDropdownBody', $parameters); // Note that $action and $object may have been modified by some hooks + $parameters = array('user'=>$user, 'langs' => $langs); + $result = $hookmanager->executeHooks('printTopRightMenuLoginDropdownBody', $parameters); // Note that $action and $object may have been modified by some hooks if (is_numeric($result)) { - if ($result == 0){ - $dropdownBody.= $hookmanager->resPrint; // add + if ($result == 0) { + $dropdownBody .= $hookmanager->resPrint; // add } - else{ - $dropdownBody = $hookmanager->resPrint; // replace + else { + $dropdownBody = $hookmanager->resPrint; // replace } } - $logoutLink =' '.$langs->trans("Logout").''; - $profilLink =' '.$langs->trans("Card").''; + $logoutLink = ' '.$langs->trans("Logout").''; + $profilLink = ' '.$langs->trans("Card").''; $profilName = $user->getFullName($langs).' ('.$user->login.')'; - if (! empty($user->admin)) { + if (!empty($user->admin)) { $profilName = ' '.$profilName; } // Define version to show - $appli=constant('DOL_APPLICATION_TITLE'); - if (! empty($conf->global->MAIN_APPLICATION_TITLE)) + $appli = constant('DOL_APPLICATION_TITLE'); + if (!empty($conf->global->MAIN_APPLICATION_TITLE)) { - $appli=$conf->global->MAIN_APPLICATION_TITLE; + $appli = $conf->global->MAIN_APPLICATION_TITLE; if (preg_match('/\d\.\d/', $appli)) { - if (! preg_match('/'.preg_quote(DOL_VERSION).'/', $appli)) $appli.=" (".DOL_VERSION.")"; // If new title contains a version that is different than core + if (!preg_match('/'.preg_quote(DOL_VERSION).'/', $appli)) $appli .= " (".DOL_VERSION.")"; // If new title contains a version that is different than core } - else $appli.=" ".DOL_VERSION; + else $appli .= " ".DOL_VERSION; } - else $appli.=" ".DOL_VERSION; + else $appli .= " ".DOL_VERSION; $btnUser = ''; - if (! defined('JS_JQUERY_DISABLE_DROPDOWN')) // This may be set by some pages that use different jquery version to avoid errors + if (!defined('JS_JQUERY_DISABLE_DROPDOWN')) // This may be set by some pages that use different jquery version to avoid errors { $btnUser .= ' @@ -1919,12 +1919,12 @@ function top_menu_bookmark() $html = ''; // Define $bookmarks - if (! empty($conf->bookmark->enabled) && $user->rights->bookmark->lire) + if (!empty($conf->bookmark->enabled) && $user->rights->bookmark->lire) { include_once DOL_DOCUMENT_ROOT.'/bookmarks/bookmarks.lib.php'; $langs->load("bookmarks"); - $html.= ' + $html .= '
'.$langs->trans("Label").'
'.$langs->trans("Email").'
'.$langs->trans("Position").'
'.$langs->trans("Position").'
'.$langs->trans("Status").''; print $form->selectyesno('active', GETPOST('active', 'int'), 1); print '
'. - ''. + ''. ''. - ''. + ''. ''. - ''. + ''. ''. - ''. + ''. ''. $form->selectDate($search_date, 'search_date', 0, 0, 1, '', 1, 0, 0, ''). @@ -260,7 +260,7 @@ if ($resql) $userstatic = new User($db); - while ($i < min($num, $sproduct?$num:$conf->liste_limit)) + while ($i < min($num, $sproduct ? $num : $conf->liste_limit)) { $obj = $db->fetch_object($resql); @@ -276,11 +276,11 @@ if ($resql) print ''. - ''. - img_object($langs->trans('ShowCompany'), 'company'). ' '. - $obj->name . ''.$txt.''.$date.'
'.$langs->trans("CustomerOrder"); if (!empty($showImportButton) && $conf->global->MAIN_ENABLE_IMPORT_LINKED_OBJECT_LINES) { @@ -62,14 +62,14 @@ foreach($linkedObjectBlock as $key => $objectlink) echo ''.$objectlink->getLibStatut(3).''; // For now, shipments must stay linked to order, so link is not deletable - if($object->element != 'shipping') { + if ($object->element != 'shipping') { echo ''.img_picto($langs->transnoentitiesnoconv("RemoveLink"), 'unlink').''; } echo '
'.$langs->trans("Total").'
trans("Shipment"); ?> element != 'commande') { + if ($object->element != 'commande') { ?> ">transnoentitiesnoconv("RemoveLink"), 'unlink'); ?>
trans("Total"); ?>
\n"; print ''; - print dol_fiche_end(); + dol_fiche_end(); From 84e1e6ccf1be2db2eff09804f89e6b96a8029141 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Mon, 25 Nov 2019 23:58:14 +0100 Subject: [PATCH 091/154] Update document.php --- htdocs/commande/document.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/commande/document.php b/htdocs/commande/document.php index 8d5afb985a3..6714e25ddeb 100644 --- a/htdocs/commande/document.php +++ b/htdocs/commande/document.php @@ -174,7 +174,7 @@ if ($id > 0 || !empty($ref)) print "\n"; - print dol_fiche_end(); + dol_fiche_end(); $modulepart = 'commande'; $permission = $user->rights->commande->creer; From aa12ec1f67f6752734a1a5a986ed6525264017ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Mon, 25 Nov 2019 23:58:53 +0100 Subject: [PATCH 092/154] Update agenda.php --- htdocs/contact/agenda.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/contact/agenda.php b/htdocs/contact/agenda.php index 515e5308903..24d49040c13 100644 --- a/htdocs/contact/agenda.php +++ b/htdocs/contact/agenda.php @@ -231,7 +231,7 @@ else print ''; - print dol_fiche_end(); + dol_fiche_end(); // Actions buttons From 2dbe3260a1542e257c9c655723761eed9f561673 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Mon, 25 Nov 2019 23:59:32 +0100 Subject: [PATCH 093/154] Update document.php --- htdocs/expedition/document.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/expedition/document.php b/htdocs/expedition/document.php index c12bd6decf3..e434bc524e2 100644 --- a/htdocs/expedition/document.php +++ b/htdocs/expedition/document.php @@ -168,7 +168,7 @@ if ($id > 0 || !empty($ref)) { print "\n"; - print dol_fiche_end(); + dol_fiche_end(); $modulepart = 'expedition'; $permission = $user->rights->expedition->creer; From 18e08420f429ad4f341fcae5948fa6b060c11302 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Tue, 26 Nov 2019 00:01:06 +0100 Subject: [PATCH 094/154] Update combinations.php --- htdocs/variants/combinations.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/variants/combinations.php b/htdocs/variants/combinations.php index f8a8b9cc9e5..c3f2b198301 100644 --- a/htdocs/variants/combinations.php +++ b/htdocs/variants/combinations.php @@ -394,7 +394,7 @@ if (! empty($id) || ! empty($ref)) } } $listofvariantselected .= ''; - //print dol_fiche_end(); + //dol_fiche_end(); } else { $title = $langs->trans('EditProductCombination'); } @@ -602,7 +602,7 @@ if (! empty($id) || ! empty($ref)) print ''; } - print dol_fiche_end(); + dol_fiche_end(); ?>
From 3edac06fae42f64c1c14327daf38ee72c9d8c729 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Tue, 26 Nov 2019 00:06:57 +0100 Subject: [PATCH 095/154] Form selectAvailabilityDelay returns void --- htdocs/comm/propal/list.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/comm/propal/list.php b/htdocs/comm/propal/list.php index 4a38ff4096a..1a44efa45ec 100644 --- a/htdocs/comm/propal/list.php +++ b/htdocs/comm/propal/list.php @@ -628,7 +628,7 @@ if ($resql) if (!empty($arrayfields['ava.rowid']['checked'])) { print ''; - print $form->selectAvailabilityDelay($search_availability, 'search_availability', '', 1); + $form->selectAvailabilityDelay($search_availability, 'search_availability', '', 1); print ajax_combobox('search_availability'); print ''; } From f3f308fc1bef665610b5e06d92b4dfb1996de705 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Tue, 26 Nov 2019 00:11:02 +0100 Subject: [PATCH 096/154] Update graph.php --- htdocs/compta/bank/graph.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/compta/bank/graph.php b/htdocs/compta/bank/graph.php index 15f6a1236d5..0f0c3d11386 100644 --- a/htdocs/compta/bank/graph.php +++ b/htdocs/compta/bank/graph.php @@ -107,7 +107,7 @@ else { dol_print_error($db); } - if (empty($min)) $min = dol_now - 3600 * 24; + if (empty($min)) $min = dol_now() - 3600 * 24; $log="graph.php: min=".$min." max=".$max; dol_syslog($log); From 77a300c9ae877c2b0eb209d3fddeec1162cc21ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Tue, 26 Nov 2019 00:20:40 +0100 Subject: [PATCH 097/154] doxygen --- htdocs/core/class/events.class.php | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/htdocs/core/class/events.class.php b/htdocs/core/class/events.class.php index 4c728256413..f6537bf6528 100644 --- a/htdocs/core/class/events.class.php +++ b/htdocs/core/class/events.class.php @@ -53,7 +53,14 @@ class Events // extends CommonObject */ public $error=''; + /** + * @var int timestamp + */ public $tms; + + /** + * @var string Type + */ public $type; /** @@ -63,8 +70,14 @@ class Events // extends CommonObject public $dateevent; + /** + * @var string IP + */ public $ip; + /** + * @var string User agent + */ public $user_agent; /** @@ -179,7 +192,7 @@ class Events // extends CommonObject public function update($user = null, $notrigger = 0) { // Clean parameters - $this->id=trim($this->id); + $this->id = (int) $this->id; $this->type=trim($this->type); $this->description=trim($this->description); @@ -234,7 +247,7 @@ class Events // extends CommonObject { $obj = $this->db->fetch_object($resql); - $this->id = $obj->rowid; + $this->id = $obj->rowid; $this->tms = $this->db->jdate($obj->tms); $this->type = $obj->type; $this->entity = $obj->entity; From a142c0050e3699b95e5795bde7663691e4d85c05 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Tue, 26 Nov 2019 00:24:00 +0100 Subject: [PATCH 098/154] $out does not seem to be defined for all execution paths --- htdocs/core/class/html.formcron.class.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/core/class/html.formcron.class.php b/htdocs/core/class/html.formcron.class.php index 0277630ae78..2a2a6c97078 100644 --- a/htdocs/core/class/html.formcron.class.php +++ b/htdocs/core/class/html.formcron.class.php @@ -64,6 +64,7 @@ class FormCron extends Form global $langs; $langs->load('cron@cron'); + $out = ''; if (!empty($readonly)) { if ($selected=='command') { $out= $langs->trans('CronType_command'); From 1ccf0808d0757c099f825bdeb084dc3bce9911ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Tue, 26 Nov 2019 00:28:26 +0100 Subject: [PATCH 099/154] doxygen --- htdocs/core/lib/ajax.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/lib/ajax.lib.php b/htdocs/core/lib/ajax.lib.php index 8991e1ad23b..d2626414ba6 100644 --- a/htdocs/core/lib/ajax.lib.php +++ b/htdocs/core/lib/ajax.lib.php @@ -326,7 +326,7 @@ function ajax_multiautocompleter($htmlname, $fields, $url, $option = '', $minLen * @param string $message Message of dialog box * @param int $w Width of dialog box * @param int $h height of dialog box - * @return void + * @return string */ function ajax_dialog($title, $message, $w = 350, $h = 150) { From 60f19d134c0794ae4a78d703e7d9bc2dd5fcc48c Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Tue, 26 Nov 2019 03:58:01 +0100 Subject: [PATCH 100/154] Fix Ticket - Align language type with datas for translation --- htdocs/langs/en_US/ticket.lang | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/htdocs/langs/en_US/ticket.lang b/htdocs/langs/en_US/ticket.lang index 70bd8220af0..f0e0ff8b726 100644 --- a/htdocs/langs/en_US/ticket.lang +++ b/htdocs/langs/en_US/ticket.lang @@ -33,8 +33,9 @@ TicketDictSeverity=Ticket - Severities TicketTypeShortBUGSOFT=Dysfonctionnement logiciel TicketTypeShortBUGHARD=Dysfonctionnement matériel TicketTypeShortCOM=Commercial question -TicketTypeShortINCIDENT=Request for assistance -TicketTypeShortPROJET=Project +TicketTypeShortISSUE=Request for assistance +TicketTypeShortREQUEST=Change or enhancement request +TicketTypeShortPROJECT=Project TicketTypeShortOTHER=Other TicketSeverityShortLOW=Low From 6cc61fef9c3001da486b5bc6a03c243c7b5664f5 Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Tue, 26 Nov 2019 04:32:38 +0100 Subject: [PATCH 101/154] Fix Ticket - Deprecated
--- htdocs/core/class/html.formticket.class.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/core/class/html.formticket.class.php b/htdocs/core/class/html.formticket.class.php index 747b2dbdf8b..1e51d54f37e 100644 --- a/htdocs/core/class/html.formticket.class.php +++ b/htdocs/core/class/html.formticket.class.php @@ -419,14 +419,14 @@ class FormTicket if ($withdolfichehead) dol_fiche_end(); - print '
'; + print '
'; print ''; if ($this->withcancel) { - print "     "; + print "      "; print "trans("Cancel") . "\">"; } - print "
\n"; + print '
'; print "\n"; print "\n"; From b440f2b1f4c5414aa6ce6b69551e91f8158c151a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 26 Nov 2019 08:53:54 +0100 Subject: [PATCH 102/154] Fix a ref is not null --- htdocs/install/mysql/migration/10.0.0-11.0.0.sql | 4 ++++ htdocs/install/mysql/tables/llx_holiday.sql | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/htdocs/install/mysql/migration/10.0.0-11.0.0.sql b/htdocs/install/mysql/migration/10.0.0-11.0.0.sql index 96ac938883c..d9ea8c01a62 100644 --- a/htdocs/install/mysql/migration/10.0.0-11.0.0.sql +++ b/htdocs/install/mysql/migration/10.0.0-11.0.0.sql @@ -59,6 +59,10 @@ ALTER TABLE llx_emailcollector_emailcollectoraction ADD COLUMN position integer -- For v11 +UPDATE llx_holiday SET ref = rowid WHERE ref IS NULL; +-- VMYSQL4.3 ALTER TABLE llx_holiday MODIFY COLUMN ref varchar(30) NOT NULL; +-- VPGSQL8.2 ALTER TABLE llx_holiday ALTER COLUMN ref SET NOT NULL; + ALTER TABLE llx_c_email_senderprofile MODIFY COLUMN active tinyint DEFAULT 1 NOT NULL; insert into llx_c_type_container (code,label,module,active) values ('menu', 'Menu', 'system', 1); diff --git a/htdocs/install/mysql/tables/llx_holiday.sql b/htdocs/install/mysql/tables/llx_holiday.sql index ce8383fe94d..e8116c477a8 100644 --- a/htdocs/install/mysql/tables/llx_holiday.sql +++ b/htdocs/install/mysql/tables/llx_holiday.sql @@ -19,7 +19,7 @@ CREATE TABLE llx_holiday ( rowid integer NOT NULL AUTO_INCREMENT PRIMARY KEY, -ref varchar(30) NULL, -- number +ref varchar(30) NOT NULL, ref_ext varchar(255), entity integer DEFAULT 1 NOT NULL, -- Multi company id fk_user integer NOT NULL, From 9d2a5e6c429fadd26d247b5713fd160baade5e45 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 26 Nov 2019 09:08:32 +0100 Subject: [PATCH 103/154] Trans --- htdocs/langs/en_US/admin.lang | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index 096a710bee8..d93b5930fed 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -625,7 +625,7 @@ Module5000Desc=Allows you to manage multiple companies Module6000Name=Workflow Module6000Desc=Workflow management (automatic creation of object and/or automatic status change) Module10000Name=Websites -Module10000Desc=Create websites (public) with a WYSIWYG editor. Just setup your web server (Apache, Nginx, ...) to point to the dedicated Dolibarr directory to have it online on the internet with your own domain name. +Module10000Desc=Create websites (public) with a WYSIWYG editor. This is a webmaster or developer oriented CMS (it is better to know HTML and CSS language). Just setup your web server (Apache, Nginx, ...) to point to the dedicated Dolibarr directory to have it online on the internet with your own domain name. Module20000Name=Leave Request Management Module20000Desc=Define and track employee leave requests Module39000Name=Product Lots From b0b579bdbf8f4d984f83e3e53f9832dc7136a30a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 26 Nov 2019 09:13:35 +0100 Subject: [PATCH 104/154] Fix phpcs --- htdocs/core/modules/modHoliday.class.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/htdocs/core/modules/modHoliday.class.php b/htdocs/core/modules/modHoliday.class.php index 917da8fec25..642c233c200 100644 --- a/htdocs/core/modules/modHoliday.class.php +++ b/htdocs/core/modules/modHoliday.class.php @@ -302,11 +302,12 @@ class modHoliday extends DolibarrModules return 0; } } + */ $sql = array( - "DELETE FROM ".MAIN_DB_PREFIX."document_model WHERE nom = '".$this->db->escape($this->const[0][2])."' AND type = 'holiday' AND entity = ".$conf->entity, - "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('".$this->db->escape($this->const[0][2])."','holiday',".$conf->entity.")" - );*/ + // "DELETE FROM ".MAIN_DB_PREFIX."document_model WHERE nom = '".$this->db->escape($this->const[0][2])."' AND type = 'holiday' AND entity = ".$conf->entity, + // "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('".$this->db->escape($this->const[0][2])."','holiday',".$conf->entity.")" + ); return $this->_init($sql, $options); } From cd6e81c46fae2747de9043a53a140efcb660191f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 26 Nov 2019 09:34:42 +0100 Subject: [PATCH 105/154] Choice of a parameter is lost when saving --- htdocs/stripe/admin/stripe.php | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/htdocs/stripe/admin/stripe.php b/htdocs/stripe/admin/stripe.php index 1ccb1631a31..9033a787cfa 100644 --- a/htdocs/stripe/admin/stripe.php +++ b/htdocs/stripe/admin/stripe.php @@ -111,11 +111,15 @@ if ($action == 'setvalue' && $user->admin) // Payment token for URL $result = dolibarr_set_const($db, "PAYMENT_SECURITY_TOKEN", GETPOST('PAYMENT_SECURITY_TOKEN', 'alpha'), 'chaine', 0, '', $conf->entity); - if (!$result > 0) - $error++; - $result = dolibarr_set_const($db, "PAYMENT_SECURITY_TOKEN_UNIQUE", GETPOST('PAYMENT_SECURITY_TOKEN_UNIQUE', 'alpha'), 'chaine', 0, '', $conf->entity); - if (!$result > 0) + if (!$result > 0) { $error++; + } + if (empty($conf->use_javascript_ajax)) { + $result = dolibarr_set_const($db, "PAYMENT_SECURITY_TOKEN_UNIQUE", GETPOST('PAYMENT_SECURITY_TOKEN_UNIQUE', 'alpha'), 'chaine', 0, '', $conf->entity); + if (!$result > 0) { + $error++; + } + } if (!$error) { $db->commit(); From 953ba8e3231314f200e9c4e3b27f73261636c842 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 26 Nov 2019 09:36:32 +0100 Subject: [PATCH 106/154] Trans --- htdocs/stripe/admin/stripe.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/stripe/admin/stripe.php b/htdocs/stripe/admin/stripe.php index 9033a787cfa..407140831d3 100644 --- a/htdocs/stripe/admin/stripe.php +++ b/htdocs/stripe/admin/stripe.php @@ -456,7 +456,7 @@ print ''; dol_fiche_end(); -print '
'; +print '
'; print ''; From 01ca5d8251567c2eff231b518c999fdd0845b326 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 26 Nov 2019 09:46:47 +0100 Subject: [PATCH 107/154] Update setup.php --- htdocs/takepos/admin/setup.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/htdocs/takepos/admin/setup.php b/htdocs/takepos/admin/setup.php index 63bb8fbd23b..b5944e914ae 100644 --- a/htdocs/takepos/admin/setup.php +++ b/htdocs/takepos/admin/setup.php @@ -81,9 +81,10 @@ if (GETPOST('action', 'alpha') == 'set') $res = dolibarr_set_const($db, "TAKEPOS_DIRECT_PAYMENT", GETPOST('TAKEPOS_DIRECT_PAYMENT', 'int'), 'int', 0, '', $conf->entity); $res = dolibarr_set_const($db, "TAKEPOS_CUSTOM_RECEIPT", GETPOST('TAKEPOS_CUSTOM_RECEIPT', 'int'), 'int', 0, '', $conf->entity); $res = dolibarr_set_const($db, "TAKEPOS_EMAIL_TEMPLATE_INVOICE", GETPOST('TAKEPOS_EMAIL_TEMPLATE_INVOICE', 'alpha'), 'chaine', 0, '', $conf->entity); - $res = dolibarr_set_const($db, "TAKEPOS_SUMUP_AFFILIATE", GETPOST('TAKEPOS_SUMUP_AFFILIATE', 'alpha'), 'chaine', 0, '', $conf->entity); - $res = dolibarr_set_const($db, "TAKEPOS_SUMUP_APPID", GETPOST('TAKEPOS_SUMUP_APPID', 'alpha'), 'chaine', 0, '', $conf->entity); - + if (! empty($conf->global->TAKEPOS_ENABLE_SUMUP)) { + $res = dolibarr_set_const($db, "TAKEPOS_SUMUP_AFFILIATE", GETPOST('TAKEPOS_SUMUP_AFFILIATE', 'alpha'), 'chaine', 0, '', $conf->entity); + $res = dolibarr_set_const($db, "TAKEPOS_SUMUP_APPID", GETPOST('TAKEPOS_SUMUP_APPID', 'alpha'), 'chaine', 0, '', $conf->entity); + } if ($conf->global->TAKEPOS_ORDER_NOTES == 1) { $extrafields = new ExtraFields($db); From 357af16ce1c36be76487a7272de20b6532f172b3 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 26 Nov 2019 09:47:56 +0100 Subject: [PATCH 108/154] Update terminal.php --- htdocs/takepos/admin/terminal.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/htdocs/takepos/admin/terminal.php b/htdocs/takepos/admin/terminal.php index 95af20fd4b8..e2839901a77 100644 --- a/htdocs/takepos/admin/terminal.php +++ b/htdocs/takepos/admin/terminal.php @@ -74,8 +74,10 @@ if (GETPOST('action', 'alpha') == 'set') $res = dolibarr_set_const($db, "CASHDESK_ID_BANKACCOUNT_CASH".$terminaltouse, (GETPOST('CASHDESK_ID_BANKACCOUNT_CASH'.$terminaltouse, 'alpha') > 0 ? GETPOST('CASHDESK_ID_BANKACCOUNT_CASH'.$terminaltouse, 'alpha') : ''), 'chaine', 0, '', $conf->entity); $res = dolibarr_set_const($db, "CASHDESK_ID_BANKACCOUNT_CHEQUE".$terminaltouse, (GETPOST('CASHDESK_ID_BANKACCOUNT_CHEQUE'.$terminaltouse, 'alpha') > 0 ? GETPOST('CASHDESK_ID_BANKACCOUNT_CHEQUE'.$terminaltouse, 'alpha') : ''), 'chaine', 0, '', $conf->entity); $res = dolibarr_set_const($db, "CASHDESK_ID_BANKACCOUNT_CB".$terminaltouse, (GETPOST('CASHDESK_ID_BANKACCOUNT_CB'.$terminaltouse, 'alpha') > 0 ? GETPOST('CASHDESK_ID_BANKACCOUNT_CB'.$terminaltouse, 'alpha') : ''), 'chaine', 0, '', $conf->entity); - $res = dolibarr_set_const($db, "CASHDESK_ID_BANKACCOUNT_SUMUP".$terminaltouse, (GETPOST('CASHDESK_ID_BANKACCOUNT_SUMUP'.$terminaltouse, 'alpha') > 0 ? GETPOST('CASHDESK_ID_BANKACCOUNT_SUMUP'.$terminaltouse, 'alpha') : ''), 'chaine', 0, '', $conf->entity); - foreach($paiements as $modep) { + if (! empty($conf->global->TAKEPOS_ENABLE_SUMUP)) { + $res = dolibarr_set_const($db, "CASHDESK_ID_BANKACCOUNT_SUMUP".$terminaltouse, (GETPOST('CASHDESK_ID_BANKACCOUNT_SUMUP'.$terminaltouse, 'alpha') > 0 ? GETPOST('CASHDESK_ID_BANKACCOUNT_SUMUP'.$terminaltouse, 'alpha') : ''), 'chaine', 0, '', $conf->entity); + } + foreach($paiements as $modep) { if (in_array($modep->code, array('LIQ', 'CB', 'CHQ'))) continue; $name="CASHDESK_ID_BANKACCOUNT_".$modep->code.$terminaltouse; $res = dolibarr_set_const($db, $name, (GETPOST($name, 'alpha') > 0 ? GETPOST($name, 'alpha') : ''), 'chaine', 0, '', $conf->entity); From 5eb24ba240533f87bfd0657b9b38b01990646673 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 26 Nov 2019 11:55:34 +0100 Subject: [PATCH 109/154] Fix phpcs --- htdocs/stripe/admin/stripe.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/stripe/admin/stripe.php b/htdocs/stripe/admin/stripe.php index 407140831d3..688b71bb68e 100644 --- a/htdocs/stripe/admin/stripe.php +++ b/htdocs/stripe/admin/stripe.php @@ -115,10 +115,10 @@ if ($action == 'setvalue' && $user->admin) $error++; } if (empty($conf->use_javascript_ajax)) { - $result = dolibarr_set_const($db, "PAYMENT_SECURITY_TOKEN_UNIQUE", GETPOST('PAYMENT_SECURITY_TOKEN_UNIQUE', 'alpha'), 'chaine', 0, '', $conf->entity); - if (!$result > 0) { - $error++; - } + $result = dolibarr_set_const($db, "PAYMENT_SECURITY_TOKEN_UNIQUE", GETPOST('PAYMENT_SECURITY_TOKEN_UNIQUE', 'alpha'), 'chaine', 0, '', $conf->entity); + if (!$result > 0) { + $error++; + } } if (!$error) { From f7e81314775b74eb05f772a44ecc747a36b79b9e Mon Sep 17 00:00:00 2001 From: gauthier Date: Tue, 26 Nov 2019 12:30:05 +0100 Subject: [PATCH 110/154] NEW : delay picto is currently useless because always displaied. If one day we add conf for supplier proposal in alert card, it will make sense, but not for now --- htdocs/supplier_proposal/list.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/supplier_proposal/list.php b/htdocs/supplier_proposal/list.php index 178c88a14ad..a3ffe34fff3 100644 --- a/htdocs/supplier_proposal/list.php +++ b/htdocs/supplier_proposal/list.php @@ -642,7 +642,7 @@ if ($resql) print ''; // Warning $warnornote = ''; - if ($obj->fk_statut == 1 && $db->jdate($obj->date_valid) < ($now - $conf->supplier_proposal->warning_delay)) $warnornote .= img_warning($langs->trans("Late")); + //if ($obj->fk_statut == 1 && $db->jdate($obj->date_valid) < ($now - $conf->supplier_proposal->warning_delay)) $warnornote .= img_warning($langs->trans("Late")); if (!empty($obj->note_private)) { $warnornote .= ($warnornote ? ' ' : ''); From b06c2811784d46c68016f7b994ce19a67da3d400 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 26 Nov 2019 12:39:31 +0100 Subject: [PATCH 111/154] Fix error with postgresql --- htdocs/holiday/class/holiday.class.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/htdocs/holiday/class/holiday.class.php b/htdocs/holiday/class/holiday.class.php index e1ba230fe38..4c4a5212abd 100644 --- a/htdocs/holiday/class/holiday.class.php +++ b/htdocs/holiday/class/holiday.class.php @@ -267,6 +267,7 @@ class Holiday extends CommonObject // Insert request $sql = "INSERT INTO ".MAIN_DB_PREFIX."holiday("; + $sql .= "ref,"; $sql .= "fk_user,"; $sql .= "date_create,"; $sql .= "description,"; @@ -279,6 +280,7 @@ class Holiday extends CommonObject $sql .= "fk_user_create,"; $sql .= "entity"; $sql .= ") VALUES ("; + $sql .= "'(PROV)',"; $sql .= "'".$this->db->escape($this->fk_user)."',"; $sql .= " '".$this->db->idate($now)."',"; $sql .= " '".$this->db->escape($this->description)."',"; From cb352407eb41fb36edbb023b4204ad8332588908 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 26 Nov 2019 12:46:40 +0100 Subject: [PATCH 112/154] Add submit --- htdocs/langs/en_US/main.lang | 1 + htdocs/public/members/new.php | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/langs/en_US/main.lang b/htdocs/langs/en_US/main.lang index 6e3ba31d36c..b177abf75fd 100644 --- a/htdocs/langs/en_US/main.lang +++ b/htdocs/langs/en_US/main.lang @@ -847,6 +847,7 @@ Progress=Progress ProgressShort=Progr. FrontOffice=Front office BackOffice=Back office +Submit=Submit View=View Export=Export Exports=Exports diff --git a/htdocs/public/members/new.php b/htdocs/public/members/new.php index 4c1e8b0e62e..a6e06dfb5ff 100644 --- a/htdocs/public/members/new.php +++ b/htdocs/public/members/new.php @@ -729,7 +729,7 @@ dol_fiche_end(); // Save print '
'; -print ''; +print ''; if (!empty($backtopage)) { print '     '; From 057ab6a059d6b63624fe90b87d4aa0318ddbf276 Mon Sep 17 00:00:00 2001 From: Scrutinizer Auto-Fixer Date: Tue, 26 Nov 2019 11:52:04 +0000 Subject: [PATCH 113/154] Scrutinizer Auto-Fixes This commit consists of patches automatically generated for this project on https://scrutinizer-ci.com --- htdocs/admin/holiday.php | 126 +++--- htdocs/core/lib/security.lib.php | 374 +++++++++--------- .../class/emailcollector.class.php | 340 ++++++++-------- 3 files changed, 420 insertions(+), 420 deletions(-) diff --git a/htdocs/admin/holiday.php b/htdocs/admin/holiday.php index 5f6d52e1169..5eb36b111c8 100644 --- a/htdocs/admin/holiday.php +++ b/htdocs/admin/holiday.php @@ -39,7 +39,7 @@ $action = GETPOST('action', 'alpha'); $value = GETPOST('value', 'alpha'); $label = GETPOST('label', 'alpha'); $scandir = GETPOST('scan_dir', 'alpha'); -$type='contract'; +$type = 'contract'; if (empty($conf->global->HOLIDAY_ADDON)) { @@ -56,12 +56,12 @@ include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php'; if ($action == 'updateMask') { $maskconst = GETPOST('maskconstholiday', 'alpha'); - $maskvalue = GETPOST('maskholiday', 'alpha'); + $maskvalue = GETPOST('maskholiday', 'alpha'); if ($maskconst) $res = dolibarr_set_const($db, $maskconst, $maskvalue, 'chaine', 0, '', $conf->entity); - if (! $res > 0) $error++; + if (!$res > 0) $error++; - if (! $error) + if (!$error) { setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); } @@ -73,20 +73,20 @@ if ($action == 'updateMask') elseif ($action == 'specimen') // For contract { - $modele= GETPOST('module', 'alpha'); + $modele = GETPOST('module', 'alpha'); $holiday = new Holiday($db); $holiday->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/holiday/doc/pdf_".$modele.".modules.php", 0); + $file = dol_buildpath($reldir."core/modules/holiday/doc/pdf_".$modele.".modules.php", 0); if (file_exists($file)) { - $filefound=1; + $filefound = 1; $classname = "pdf_".$modele; break; } @@ -159,15 +159,15 @@ elseif ($action == 'setmod') elseif ($action == 'set_other') { - $freetext= GETPOST('HOLIDAY_FREE_TEXT', 'none'); // No alpha here, we want exact string + $freetext = GETPOST('HOLIDAY_FREE_TEXT', 'none'); // No alpha here, we want exact string $res1 = dolibarr_set_const($db, "HOLIDAY_FREE_TEXT", $freetext, 'chaine', 0, '', $conf->entity); - $draft= GETPOST('HOLIDAY_DRAFT_WATERMARK', 'alpha'); + $draft = GETPOST('HOLIDAY_DRAFT_WATERMARK', 'alpha'); $res2 = dolibarr_set_const($db, "HOLIDAY_DRAFT_WATERMARK", trim($draft), 'chaine', 0, '', $conf->entity); - if (! $res1 > 0 || ! $res2 > 0) $error++; + if (!$res1 > 0 || !$res2 > 0) $error++; - if (! $error) + if (!$error) { setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); } @@ -182,16 +182,16 @@ elseif ($action == 'set_other') * View */ -$dirmodels=array_merge(array('/'), (array) $conf->modules_parts['models']); +$dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); llxHeader(); -$form=new Form($db); +$form = new Form($db); -$linkback=''.$langs->trans("BackToModuleList").''; +$linkback = ''.$langs->trans("BackToModuleList").''; print load_fiche_titre($langs->trans("HolidaySetup"), $linkback, 'title_setup'); -$head=holiday_admin_prepare_head(); +$head = holiday_admin_prepare_head(); dol_fiche_head($head, 'holiday', $langs->trans("Holidays"), -1, 'holiday'); @@ -222,18 +222,18 @@ foreach ($dirmodels as $reldir) $handle = opendir($dir); if (is_resource($handle)) { - while (($file = readdir($handle))!==false) + while (($file = readdir($handle)) !== false) { - if (substr($file, 0, 12) == 'mod_holiday_' && substr($file, dol_strlen($file)-3, 3) == 'php') + if (substr($file, 0, 12) == 'mod_holiday_' && substr($file, dol_strlen($file) - 3, 3) == 'php') { - $file = substr($file, 0, dol_strlen($file)-4); + $file = substr($file, 0, dol_strlen($file) - 4); require_once $dir.$file.'.php'; $module = new $file($db); // Show modules according to features level - if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) continue; + if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) continue; if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) continue; if ($module->isEnabled()) @@ -244,9 +244,9 @@ foreach ($dirmodels as $reldir) // Show example of numbering model print ''; - $tmp=$module->getExample(); + $tmp = $module->getExample(); if (preg_match('/^Error/', $tmp)) { $langs->load("errors"); print '
'.$langs->trans($tmp).'
'; } - elseif ($tmp=='NotConfigured') print $langs->trans($tmp); + elseif ($tmp == 'NotConfigured') print $langs->trans($tmp); else print $tmp; print ''."\n"; @@ -263,21 +263,21 @@ foreach ($dirmodels as $reldir) } print ''; - $holiday=new Holiday($db); + $holiday = new Holiday($db); $holiday->initAsSpecimen(); // Info - $htmltooltip=''; - $htmltooltip.=''.$langs->trans("Version").': '.$module->getVersion().'
'; - $nextval=$module->getNextValue($mysoc, $holiday); + $htmltooltip = ''; + $htmltooltip .= ''.$langs->trans("Version").': '.$module->getVersion().'
'; + $nextval = $module->getNextValue($mysoc, $holiday); if ("$nextval" != $langs->trans("NotAvailable")) { // Keep " on nextval - $htmltooltip.=''.$langs->trans("NextValue").': '; + $htmltooltip .= ''.$langs->trans("NextValue").': '; if ($nextval) { - if (preg_match('/^Error/', $nextval) || $nextval=='NotConfigured') + if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured') $nextval = $langs->trans($nextval); - $htmltooltip.=$nextval.'
'; + $htmltooltip .= $nextval.'
'; } else { - $htmltooltip.=$langs->trans($module->error).'
'; + $htmltooltip .= $langs->trans($module->error).'
'; } } @@ -317,14 +317,14 @@ print load_fiche_titre($langs->trans("TemplatePDFHolidays"), '', ''); // Defined model definition table $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); @@ -353,42 +353,42 @@ clearstatcache(); foreach ($dirmodels as $reldir) { - foreach (array('','/doc') as $valdir) + foreach (array('', '/doc') as $valdir) { $dir = dol_buildpath($reldir."core/modules/holiday".$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; @@ -423,18 +423,18 @@ 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("PaymentMode").': '.yn($module->option_modereg, 1, 1); - $htmltooltip.='
'.$langs->trans("PaymentConditions").': '.yn($module->option_condreg, 1, 1); - $htmltooltip.='
'.$langs->trans("MultiLanguage").': '.yn($module->option_multilang, 1, 1); - $htmltooltip.='
'.$langs->trans("WatermarkOnDraftOrders").': '.yn($module->option_draft_watermark, 1, 1); + $htmltooltip .= '

'.$langs->trans("FeaturesSupported").':'; + $htmltooltip .= '
'.$langs->trans("Logo").': '.yn($module->option_logo, 1, 1); + $htmltooltip .= '
'.$langs->trans("PaymentMode").': '.yn($module->option_modereg, 1, 1); + $htmltooltip .= '
'.$langs->trans("PaymentConditions").': '.yn($module->option_condreg, 1, 1); + $htmltooltip .= '
'.$langs->trans("MultiLanguage").': '.yn($module->option_multilang, 1, 1); + $htmltooltip .= '
'.$langs->trans("WatermarkOnDraftOrders").': '.yn($module->option_draft_watermark, 1, 1); print ''; @@ -485,16 +485,16 @@ print ''.$langs->trans("Parameter").''; print ''.$langs->trans("Value").''; print "\n"; -$substitutionarray=pdf_getSubstitutionArray($langs, array('objectamount'), null, 2); -$substitutionarray['__(AnyTranslationKey)__']=$langs->trans("Translation"); +$substitutionarray = pdf_getSubstitutionArray($langs, array('objectamount'), 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 .= ''; print ''; print $form->textwithpicto($langs->trans("FreeLegalTextOnHolidays"), $langs->trans("AddCRIfTooLong").'

'.$htmltext, 1, 'help', '', 0, 2, 'tooltiphelp'); print '
'; -$variablename='HOLIDAY_FREE_TEXT'; +$variablename = 'HOLIDAY_FREE_TEXT'; if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) { print ''; @@ -502,7 +502,7 @@ if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) else { include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; - $doleditor=new DolEditor($variablename, $conf->global->$variablename, '', 80, 'dolibarr_notes'); + $doleditor = new DolEditor($variablename, $conf->global->$variablename, '', 80, 'dolibarr_notes'); print $doleditor->Create(); } print ''."\n"; diff --git a/htdocs/core/lib/security.lib.php b/htdocs/core/lib/security.lib.php index 7a3102e8aca..5a7b8342bd6 100644 --- a/htdocs/core/lib/security.lib.php +++ b/htdocs/core/lib/security.lib.php @@ -38,24 +38,24 @@ function dol_encode($chain, $key = '1') { if (is_numeric($key) && $key == '1') // rule 1 is offset of 17 for char { - $output_tab=array(); - $strlength=dol_strlen($chain); - for ($i=0; $i < $strlength; $i++) + $output_tab = array(); + $strlength = dol_strlen($chain); + for ($i = 0; $i < $strlength; $i++) { - $output_tab[$i] = chr(ord(substr($chain, $i, 1))+17); + $output_tab[$i] = chr(ord(substr($chain, $i, 1)) + 17); } $chain = implode("", $output_tab); } elseif ($key) { - $result=''; - $strlength=dol_strlen($chain); - for ($i=0; $i < $strlength; $i++) + $result = ''; + $strlength = dol_strlen($chain); + for ($i = 0; $i < $strlength; $i++) { - $keychar = substr($key, ($i % strlen($key))-1, 1); - $result.= chr(ord(substr($chain, $i, 1))+(ord($keychar)-65)); + $keychar = substr($key, ($i % strlen($key)) - 1, 1); + $result .= chr(ord(substr($chain, $i, 1)) + (ord($keychar) - 65)); } - $chain=$result; + $chain = $result; } return base64_encode($chain); @@ -76,25 +76,25 @@ function dol_decode($chain, $key = '1') if (is_numeric($key) && $key == '1') // rule 1 is offset of 17 for char { - $output_tab=array(); - $strlength=dol_strlen($chain); - for ($i=0; $i < $strlength;$i++) + $output_tab = array(); + $strlength = dol_strlen($chain); + for ($i = 0; $i < $strlength; $i++) { - $output_tab[$i] = chr(ord(substr($chain, $i, 1))-17); + $output_tab[$i] = chr(ord(substr($chain, $i, 1)) - 17); } $chain = implode("", $output_tab); } elseif ($key) { - $result=''; - $strlength=dol_strlen($chain); - for ($i=0; $i < $strlength; $i++) + $result = ''; + $strlength = dol_strlen($chain); + for ($i = 0; $i < $strlength; $i++) { - $keychar = substr($key, ($i % strlen($key))-1, 1); - $result.= chr(ord(substr($chain, $i, 1))-(ord($keychar)-65)); + $keychar = substr($key, ($i % strlen($key)) - 1, 1); + $result .= chr(ord(substr($chain, $i, 1)) - (ord($keychar) - 65)); } - $chain=$result; + $chain = $result; } return $chain; @@ -116,21 +116,21 @@ function dol_hash($chain, $type = '0') global $conf; // No need to add salt for password_hash - if (($type == '0' || $type == 'auto') && ! empty($conf->global->MAIN_SECURITY_HASH_ALGO) && $conf->global->MAIN_SECURITY_HASH_ALGO == 'password_hash' && function_exists('password_hash')) + if (($type == '0' || $type == 'auto') && !empty($conf->global->MAIN_SECURITY_HASH_ALGO) && $conf->global->MAIN_SECURITY_HASH_ALGO == 'password_hash' && function_exists('password_hash')) { return password_hash($chain, PASSWORD_DEFAULT); } // Salt value - if (! empty($conf->global->MAIN_SECURITY_SALT)) $chain=$conf->global->MAIN_SECURITY_SALT.$chain; + if (!empty($conf->global->MAIN_SECURITY_SALT)) $chain = $conf->global->MAIN_SECURITY_SALT.$chain; if ($type == '1' || $type == 'sha1') return sha1($chain); elseif ($type == '2' || $type == 'sha1md5') return sha1(md5($chain)); elseif ($type == '3' || $type == 'md5') return md5($chain); elseif ($type == '4' || $type == 'md5openldap') return '{md5}'.base64_encode(mhash(MHASH_MD5, $chain)); // For OpenLdap with md5 (based on an unencrypted password in base) elseif ($type == '5') return hash('sha256', $chain); - elseif (! empty($conf->global->MAIN_SECURITY_HASH_ALGO) && $conf->global->MAIN_SECURITY_HASH_ALGO == 'sha1') return sha1($chain); - elseif (! empty($conf->global->MAIN_SECURITY_HASH_ALGO) && $conf->global->MAIN_SECURITY_HASH_ALGO == 'sha1md5') return sha1(md5($chain)); + elseif (!empty($conf->global->MAIN_SECURITY_HASH_ALGO) && $conf->global->MAIN_SECURITY_HASH_ALGO == 'sha1') return sha1($chain); + elseif (!empty($conf->global->MAIN_SECURITY_HASH_ALGO) && $conf->global->MAIN_SECURITY_HASH_ALGO == 'sha1md5') return sha1(md5($chain)); // No particular encoding defined, use default return md5($chain); @@ -151,10 +151,10 @@ function dol_verifyHash($chain, $hash, $type = '0') { global $conf; - if ($type == '0' && ! empty($conf->global->MAIN_SECURITY_HASH_ALGO) && $conf->global->MAIN_SECURITY_HASH_ALGO == 'password_hash' && function_exists('password_verify')) { + if ($type == '0' && !empty($conf->global->MAIN_SECURITY_HASH_ALGO) && $conf->global->MAIN_SECURITY_HASH_ALGO == 'password_hash' && function_exists('password_verify')) { if ($hash[0] == '$') return password_verify($chain, $hash); - elseif(strlen($hash) == 32) return dol_verifyHash($chain, $hash, '3'); // md5 - elseif(strlen($hash) == 40) return dol_verifyHash($chain, $hash, '2'); // sha1md5 + elseif (strlen($hash) == 32) return dol_verifyHash($chain, $hash, '3'); // md5 + elseif (strlen($hash) == 40) return dol_verifyHash($chain, $hash, '2'); // sha1md5 return false; } @@ -189,9 +189,9 @@ function restrictedArea($user, $features, $objectid = 0, $tableandshare = '', $f //print ", perm: ".$features."->".$feature2."=".($user->rights->$features->$feature2->lire)."
"; // Get more permissions checks from hooks - $parameters=array('features'=>$features, 'objectid'=>$objectid, 'idtype'=>$dbt_select); - $reshook=$hookmanager->executeHooks('restrictedArea', $parameters); - if (! empty($hookmanager->resArray['result'])) return true; + $parameters = array('features'=>$features, 'objectid'=>$objectid, 'idtype'=>$dbt_select); + $reshook = $hookmanager->executeHooks('restrictedArea', $parameters); + if (!empty($hookmanager->resArray['result'])) return true; if ($reshook > 0) return false; if ($dbt_select != 'rowid' && $dbt_select != 'id') $objectid = "'".$objectid."'"; @@ -202,227 +202,227 @@ function restrictedArea($user, $features, $objectid = 0, $tableandshare = '', $f elseif (preg_match('/\|/', $features)) $featuresarray = explode("|", $features); // More subfeatures to check - if (! empty($feature2)) $feature2 = explode("|", $feature2); + if (!empty($feature2)) $feature2 = explode("|", $feature2); // More parameters $params = explode('&', $tableandshare); - $dbtablename=(! empty($params[0]) ? $params[0] : ''); - $sharedelement=(! empty($params[1]) ? $params[1] : $dbtablename); + $dbtablename = (!empty($params[0]) ? $params[0] : ''); + $sharedelement = (!empty($params[1]) ? $params[1] : $dbtablename); - $listofmodules=explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL); + $listofmodules = explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL); // Check read permission from module - $readok=1; $nbko=0; + $readok = 1; $nbko = 0; foreach ($featuresarray as $feature) // first we check nb of test ko { - $featureforlistofmodule=$feature; - if ($featureforlistofmodule == 'produit') $featureforlistofmodule='product'; - if (! empty($user->socid) && ! empty($conf->global->MAIN_MODULES_FOR_EXTERNAL) && ! in_array($featureforlistofmodule, $listofmodules)) // If limits on modules for external users, module must be into list of modules for external users + $featureforlistofmodule = $feature; + if ($featureforlistofmodule == 'produit') $featureforlistofmodule = 'product'; + if (!empty($user->socid) && !empty($conf->global->MAIN_MODULES_FOR_EXTERNAL) && !in_array($featureforlistofmodule, $listofmodules)) // If limits on modules for external users, module must be into list of modules for external users { - $readok=0; $nbko++; + $readok = 0; $nbko++; continue; } if ($feature == 'societe') { - if (! $user->rights->societe->lire && ! $user->rights->fournisseur->lire) { $readok=0; $nbko++; } + if (!$user->rights->societe->lire && !$user->rights->fournisseur->lire) { $readok = 0; $nbko++; } } elseif ($feature == 'contact') { - if (! $user->rights->societe->contact->lire) { $readok=0; $nbko++; } + if (!$user->rights->societe->contact->lire) { $readok = 0; $nbko++; } } elseif ($feature == 'produit|service') { - if (! $user->rights->produit->lire && ! $user->rights->service->lire) { $readok=0; $nbko++; } + if (!$user->rights->produit->lire && !$user->rights->service->lire) { $readok = 0; $nbko++; } } elseif ($feature == 'prelevement') { - if (! $user->rights->prelevement->bons->lire) { $readok=0; $nbko++; } + if (!$user->rights->prelevement->bons->lire) { $readok = 0; $nbko++; } } elseif ($feature == 'cheque') { - if (! $user->rights->banque->cheque) { $readok=0; $nbko++; } + if (!$user->rights->banque->cheque) { $readok = 0; $nbko++; } } elseif ($feature == 'projet') { - if (! $user->rights->projet->lire && ! $user->rights->projet->all->lire) { $readok=0; $nbko++; } + if (!$user->rights->projet->lire && !$user->rights->projet->all->lire) { $readok = 0; $nbko++; } } - elseif (! empty($feature2)) // This is for permissions on 2 levels + elseif (!empty($feature2)) // This is for permissions on 2 levels { - $tmpreadok=1; - foreach($feature2 as $subfeature) + $tmpreadok = 1; + foreach ($feature2 as $subfeature) { if ($subfeature == 'user' && $user->id == $objectid) continue; // A user can always read its own card - if (! empty($subfeature) && empty($user->rights->$feature->$subfeature->lire) && empty($user->rights->$feature->$subfeature->read)) { $tmpreadok=0; } - elseif (empty($subfeature) && empty($user->rights->$feature->lire) && empty($user->rights->$feature->read)) { $tmpreadok=0; } - else { $tmpreadok=1; break; } // Break is to bypass second test if the first is ok + if (!empty($subfeature) && empty($user->rights->$feature->$subfeature->lire) && empty($user->rights->$feature->$subfeature->read)) { $tmpreadok = 0; } + elseif (empty($subfeature) && empty($user->rights->$feature->lire) && empty($user->rights->$feature->read)) { $tmpreadok = 0; } + else { $tmpreadok = 1; break; } // Break is to bypass second test if the first is ok } - if (! $tmpreadok) // We found a test on feature that is ko + if (!$tmpreadok) // We found a test on feature that is ko { - $readok=0; // All tests are ko (we manage here the and, the or will be managed later using $nbko). + $readok = 0; // All tests are ko (we manage here the and, the or will be managed later using $nbko). $nbko++; } } - elseif (! empty($feature) && ($feature!='user' && $feature!='usergroup')) // This is permissions on 1 level + elseif (!empty($feature) && ($feature != 'user' && $feature != 'usergroup')) // This is permissions on 1 level { if (empty($user->rights->$feature->lire) && empty($user->rights->$feature->read) - && empty($user->rights->$feature->run)) { $readok=0; $nbko++; } + && empty($user->rights->$feature->run)) { $readok = 0; $nbko++; } } } // If a or and at least one ok - if (preg_match('/\|/', $features) && $nbko < count($featuresarray)) $readok=1; + if (preg_match('/\|/', $features) && $nbko < count($featuresarray)) $readok = 1; - if (! $readok) accessforbidden(); + if (!$readok) accessforbidden(); //print "Read access is ok"; // Check write permission from module (we need to know write permission to create but also to delete drafts record) - $createok=1; $nbko=0; - if (GETPOST('action', 'aZ09') == 'create' || GETPOST('action', 'aZ09') == 'update' || ((GETPOST("action", "aZ09") == 'confirm_delete' && GETPOST("confirm", "aZ09") == 'yes') || GETPOST("action", "aZ09") == 'delete')) + $createok = 1; $nbko = 0; + if (GETPOST('action', 'aZ09') == 'create' || GETPOST('action', 'aZ09') == 'update' || ((GETPOST("action", "aZ09") == 'confirm_delete' && GETPOST("confirm", "aZ09") == 'yes') || GETPOST("action", "aZ09") == 'delete')) { foreach ($featuresarray as $feature) { if ($feature == 'contact') { - if (! $user->rights->societe->contact->creer) { $createok=0; $nbko++; } + if (!$user->rights->societe->contact->creer) { $createok = 0; $nbko++; } } elseif ($feature == 'produit|service') { - if (! $user->rights->produit->creer && ! $user->rights->service->creer) { $createok=0; $nbko++; } + if (!$user->rights->produit->creer && !$user->rights->service->creer) { $createok = 0; $nbko++; } } elseif ($feature == 'prelevement') { - if (! $user->rights->prelevement->bons->creer) { $createok=0; $nbko++; } + if (!$user->rights->prelevement->bons->creer) { $createok = 0; $nbko++; } } elseif ($feature == 'commande_fournisseur') { - if (! $user->rights->fournisseur->commande->creer) { $createok=0; $nbko++; } + if (!$user->rights->fournisseur->commande->creer) { $createok = 0; $nbko++; } } elseif ($feature == 'banque') { - if (! $user->rights->banque->modifier) { $createok=0; $nbko++; } + if (!$user->rights->banque->modifier) { $createok = 0; $nbko++; } } elseif ($feature == 'cheque') { - if (! $user->rights->banque->cheque) { $createok=0; $nbko++; } + if (!$user->rights->banque->cheque) { $createok = 0; $nbko++; } } - elseif (! empty($feature2)) // This is for permissions on one level + elseif (!empty($feature2)) // This is for permissions on one level { - foreach($feature2 as $subfeature) + foreach ($feature2 as $subfeature) { if (empty($user->rights->$feature->$subfeature->creer) && empty($user->rights->$feature->$subfeature->write) && empty($user->rights->$feature->$subfeature->create)) { - $createok=0; + $createok = 0; $nbko++; } else { - $createok=1; + $createok = 1; // Break to bypass second test if the first is ok break; } } } - elseif (! empty($feature)) // This is for permissions on 2 levels ('creer' or 'write') + elseif (!empty($feature)) // This is for permissions on 2 levels ('creer' or 'write') { //print '
feature='.$feature.' creer='.$user->rights->$feature->creer.' write='.$user->rights->$feature->write; if (empty($user->rights->$feature->creer) && empty($user->rights->$feature->write) && empty($user->rights->$feature->create)) { - $createok=0; + $createok = 0; $nbko++; } } } // If a or and at least one ok - if (preg_match('/\|/', $features) && $nbko < count($featuresarray)) $createok=1; + if (preg_match('/\|/', $features) && $nbko < count($featuresarray)) $createok = 1; - if ((GETPOST('action', 'aZ09') == 'create' || GETPOST('action', 'aZ09') == 'update') && ! $createok) accessforbidden(); + if ((GETPOST('action', 'aZ09') == 'create' || GETPOST('action', 'aZ09') == 'update') && !$createok) accessforbidden(); //print "Write access is ok"; } // Check create user permission - $createuserok=1; + $createuserok = 1; if (GETPOST('action', 'aZ09') == 'confirm_create_user' && GETPOST("confirm", 'aZ09') == 'yes') { - if (! $user->rights->user->user->creer) $createuserok=0; + if (!$user->rights->user->user->creer) $createuserok = 0; - if (! $createuserok) accessforbidden(); + if (!$createuserok) accessforbidden(); //print "Create user access is ok"; } // Check delete permission from module - $deleteok=1; $nbko=0; - if ((GETPOST("action", "aZ09") == 'confirm_delete' && GETPOST("confirm", "aZ09") == 'yes') || GETPOST("action", "aZ09") == 'delete') + $deleteok = 1; $nbko = 0; + if ((GETPOST("action", "aZ09") == 'confirm_delete' && GETPOST("confirm", "aZ09") == 'yes') || GETPOST("action", "aZ09") == 'delete') { foreach ($featuresarray as $feature) { if ($feature == 'contact') { - if (! $user->rights->societe->contact->supprimer) $deleteok=0; + if (!$user->rights->societe->contact->supprimer) $deleteok = 0; } elseif ($feature == 'produit|service') { - if (! $user->rights->produit->supprimer && ! $user->rights->service->supprimer) $deleteok=0; + if (!$user->rights->produit->supprimer && !$user->rights->service->supprimer) $deleteok = 0; } elseif ($feature == 'commande_fournisseur') { - if (! $user->rights->fournisseur->commande->supprimer) $deleteok=0; + if (!$user->rights->fournisseur->commande->supprimer) $deleteok = 0; } elseif ($feature == 'banque') { - if (! $user->rights->banque->modifier) $deleteok=0; + if (!$user->rights->banque->modifier) $deleteok = 0; } elseif ($feature == 'cheque') { - if (! $user->rights->banque->cheque) $deleteok=0; + if (!$user->rights->banque->cheque) $deleteok = 0; } elseif ($feature == 'ecm') { - if (! $user->rights->ecm->upload) $deleteok=0; + if (!$user->rights->ecm->upload) $deleteok = 0; } elseif ($feature == 'ftp') { - if (! $user->rights->ftp->write) $deleteok=0; + if (!$user->rights->ftp->write) $deleteok = 0; }elseif ($feature == 'salaries') { - if (! $user->rights->salaries->delete) $deleteok=0; + if (!$user->rights->salaries->delete) $deleteok = 0; } elseif ($feature == 'salaries') { - if (! $user->rights->salaries->delete) $deleteok=0; + if (!$user->rights->salaries->delete) $deleteok = 0; } - elseif (! empty($feature2)) // This is for permissions on 2 levels + elseif (!empty($feature2)) // This is for permissions on 2 levels { - foreach($feature2 as $subfeature) + foreach ($feature2 as $subfeature) { - if (empty($user->rights->$feature->$subfeature->supprimer) && empty($user->rights->$feature->$subfeature->delete)) $deleteok=0; - else { $deleteok=1; break; } // For bypass the second test if the first is ok + if (empty($user->rights->$feature->$subfeature->supprimer) && empty($user->rights->$feature->$subfeature->delete)) $deleteok = 0; + else { $deleteok = 1; break; } // For bypass the second test if the first is ok } } - elseif (! empty($feature)) // This is used for permissions on 1 level + elseif (!empty($feature)) // This is used for permissions on 1 level { //print '
feature='.$feature.' creer='.$user->rights->$feature->supprimer.' write='.$user->rights->$feature->delete; if (empty($user->rights->$feature->supprimer) && empty($user->rights->$feature->delete) - && empty($user->rights->$feature->run)) $deleteok=0; + && empty($user->rights->$feature->run)) $deleteok = 0; } } // If a or and at least one ok - if (preg_match('/\|/', $features) && $nbko < count($featuresarray)) $deleteok=1; + if (preg_match('/\|/', $features) && $nbko < count($featuresarray)) $deleteok = 1; - if (! $deleteok && ! ($isdraft && $createok)) accessforbidden(); + if (!$deleteok && !($isdraft && $createok)) accessforbidden(); //print "Delete access is ok"; } // If we have a particular object to check permissions on, we check this object // is linked to a company allowed to $user. - if (! empty($objectid) && $objectid > 0) + if (!empty($objectid) && $objectid > 0) { $ok = checkUserAccessToObject($user, $featuresarray, $objectid, $tableandshare, $feature2, $dbt_keyfield, $dbt_select); - $params=array('objectid' => $objectid, 'features' => join(',', $featuresarray), 'features2' => $feature2); + $params = array('objectid' => $objectid, 'features' => join(',', $featuresarray), 'features2' => $feature2); return $ok ? 1 : accessforbidden('', 1, 1, 0, $params); } @@ -449,65 +449,65 @@ function checkUserAccessToObject($user, $featuresarray, $objectid = 0, $tableand // More parameters $params = explode('&', $tableandshare); - $dbtablename=(! empty($params[0]) ? $params[0] : ''); - $sharedelement=(! empty($params[1]) ? $params[1] : $dbtablename); + $dbtablename = (!empty($params[0]) ? $params[0] : ''); + $sharedelement = (!empty($params[1]) ? $params[1] : $dbtablename); foreach ($featuresarray as $feature) { - $sql=''; + $sql = ''; // For backward compatibility - if ($feature == 'member') $feature='adherent'; - if ($feature == 'project') $feature='projet'; - if ($feature == 'task') $feature='projet_task'; + if ($feature == 'member') $feature = 'adherent'; + if ($feature == 'project') $feature = 'projet'; + if ($feature == 'task') $feature = 'projet_task'; - $check = array('adherent','banque','bom','don','user','usergroup','product','produit','service','produit|service','categorie','resource','expensereport','holiday'); // Test on entity only (Objects with no link to company) - $checksoc = array('societe'); // Test for societe object - $checkother = array('contact','agenda'); // Test on entity and link to third party. Allowed if link is empty (Ex: contacts...). - $checkproject = array('projet','project'); // Test for project object + $check = array('adherent', 'banque', 'bom', 'don', 'user', 'usergroup', 'product', 'produit', 'service', 'produit|service', 'categorie', 'resource', 'expensereport', 'holiday'); // Test on entity only (Objects with no link to company) + $checksoc = array('societe'); // Test for societe object + $checkother = array('contact', 'agenda'); // Test on entity and link to third party. Allowed if link is empty (Ex: contacts...). + $checkproject = array('projet', 'project'); // Test for project object $checktask = array('projet_task'); - $nocheck = array('barcode','stock'); // No test + $nocheck = array('barcode', 'stock'); // No test //$checkdefault = 'all other not already defined'; // Test on entity and link to third party. Not allowed if link is empty (Ex: invoice, orders...). // If dbtablename not defined, we use same name for table than module name if (empty($dbtablename)) { $dbtablename = $feature; - $sharedelement = (! empty($params[1]) ? $params[1] : $dbtablename); // We change dbtablename, so we set sharedelement too. + $sharedelement = (!empty($params[1]) ? $params[1] : $dbtablename); // We change dbtablename, so we set sharedelement too. } // Check permission for object with entity if (in_array($feature, $check)) { $sql = "SELECT COUNT(dbt.".$dbt_select.") as nb"; - $sql.= " FROM ".MAIN_DB_PREFIX.$dbtablename." as dbt"; - if (($feature == 'user' || $feature == 'usergroup') && ! empty($conf->multicompany->enabled)) + $sql .= " FROM ".MAIN_DB_PREFIX.$dbtablename." as dbt"; + if (($feature == 'user' || $feature == 'usergroup') && !empty($conf->multicompany->enabled)) { - if (! empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) + if (!empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) { - if ($conf->entity == 1 && $user->admin && ! $user->entity) + if ($conf->entity == 1 && $user->admin && !$user->entity) { - $sql.= " WHERE dbt.".$dbt_select." IN (".$objectid.")"; - $sql.= " AND dbt.entity IS NOT NULL"; + $sql .= " WHERE dbt.".$dbt_select." IN (".$objectid.")"; + $sql .= " AND dbt.entity IS NOT NULL"; } else { - $sql.= ",".MAIN_DB_PREFIX."usergroup_user as ug"; - $sql.= " WHERE dbt.".$dbt_select." IN (".$objectid.")"; - $sql.= " AND ((ug.fk_user = dbt.rowid"; - $sql.= " AND ug.entity IN (".getEntity('usergroup')."))"; - $sql.= " OR dbt.entity = 0)"; // Show always superadmin + $sql .= ",".MAIN_DB_PREFIX."usergroup_user as ug"; + $sql .= " WHERE dbt.".$dbt_select." IN (".$objectid.")"; + $sql .= " AND ((ug.fk_user = dbt.rowid"; + $sql .= " AND ug.entity IN (".getEntity('usergroup')."))"; + $sql .= " OR dbt.entity = 0)"; // Show always superadmin } } else { - $sql.= " WHERE dbt.".$dbt_select." IN (".$objectid.")"; - $sql.= " AND dbt.entity IN (".getEntity($sharedelement, 1).")"; + $sql .= " WHERE dbt.".$dbt_select." IN (".$objectid.")"; + $sql .= " AND dbt.entity IN (".getEntity($sharedelement, 1).")"; } } else { - $sql.= " WHERE dbt.".$dbt_select." IN (".$objectid.")"; - $sql.= " AND dbt.entity IN (".getEntity($sharedelement, 1).")"; + $sql .= " WHERE dbt.".$dbt_select." IN (".$objectid.")"; + $sql .= " AND dbt.entity IN (".getEntity($sharedelement, 1).")"; } } elseif (in_array($feature, $checksoc)) // We check feature = checksoc @@ -518,23 +518,23 @@ function checkUserAccessToObject($user, $featuresarray, $objectid = 0, $tableand if ($user->socid <> $objectid) return false; } // If internal user: Check permission for internal users that are restricted on their objects - elseif (! empty($conf->societe->enabled) && ($user->rights->societe->lire && ! $user->rights->societe->client->voir)) + elseif (!empty($conf->societe->enabled) && ($user->rights->societe->lire && !$user->rights->societe->client->voir)) { $sql = "SELECT COUNT(sc.fk_soc) as nb"; - $sql.= " FROM (".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql.= ", ".MAIN_DB_PREFIX."societe as s)"; - $sql.= " WHERE sc.fk_soc IN (".$objectid.")"; - $sql.= " AND sc.fk_user = ".$user->id; - $sql.= " AND sc.fk_soc = s.rowid"; - $sql.= " AND s.entity IN (".getEntity($sharedelement, 1).")"; + $sql .= " FROM (".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql .= ", ".MAIN_DB_PREFIX."societe as s)"; + $sql .= " WHERE sc.fk_soc IN (".$objectid.")"; + $sql .= " AND sc.fk_user = ".$user->id; + $sql .= " AND sc.fk_soc = s.rowid"; + $sql .= " AND s.entity IN (".getEntity($sharedelement, 1).")"; } // If multicompany and internal users with all permissions, check user is in correct entity - elseif (! empty($conf->multicompany->enabled)) + elseif (!empty($conf->multicompany->enabled)) { $sql = "SELECT COUNT(s.rowid) as nb"; - $sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; - $sql.= " WHERE s.rowid IN (".$objectid.")"; - $sql.= " AND s.entity IN (".getEntity($sharedelement, 1).")"; + $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; + $sql .= " WHERE s.rowid IN (".$objectid.")"; + $sql .= " AND s.entity IN (".getEntity($sharedelement, 1).")"; } } elseif (in_array($feature, $checkother)) // Test on entity and link to societe. Allowed if link is empty (Ex: contacts...). @@ -543,110 +543,110 @@ function checkUserAccessToObject($user, $featuresarray, $objectid = 0, $tableand if ($user->socid > 0) { $sql = "SELECT COUNT(dbt.".$dbt_select.") as nb"; - $sql.= " FROM ".MAIN_DB_PREFIX.$dbtablename." as dbt"; - $sql.= " WHERE dbt.".$dbt_select." IN (".$objectid.")"; - $sql.= " AND dbt.fk_soc = ".$user->socid; + $sql .= " FROM ".MAIN_DB_PREFIX.$dbtablename." as dbt"; + $sql .= " WHERE dbt.".$dbt_select." IN (".$objectid.")"; + $sql .= " AND dbt.fk_soc = ".$user->socid; } // If internal user: Check permission for internal users that are restricted on their objects - elseif (! empty($conf->societe->enabled) && ($user->rights->societe->lire && ! $user->rights->societe->client->voir)) + elseif (!empty($conf->societe->enabled) && ($user->rights->societe->lire && !$user->rights->societe->client->voir)) { $sql = "SELECT COUNT(dbt.".$dbt_select.") as nb"; - $sql.= " FROM ".MAIN_DB_PREFIX.$dbtablename." as dbt"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON dbt.fk_soc = sc.fk_soc AND sc.fk_user = '".$user->id."'"; - $sql.= " WHERE dbt.".$dbt_select." IN (".$objectid.")"; - $sql.= " AND (dbt.fk_soc IS NULL OR sc.fk_soc IS NOT NULL)"; // Contact not linked to a company or to a company of user - $sql.= " AND dbt.entity IN (".getEntity($sharedelement, 1).")"; + $sql .= " FROM ".MAIN_DB_PREFIX.$dbtablename." as dbt"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON dbt.fk_soc = sc.fk_soc AND sc.fk_user = '".$user->id."'"; + $sql .= " WHERE dbt.".$dbt_select." IN (".$objectid.")"; + $sql .= " AND (dbt.fk_soc IS NULL OR sc.fk_soc IS NOT NULL)"; // Contact not linked to a company or to a company of user + $sql .= " AND dbt.entity IN (".getEntity($sharedelement, 1).")"; } // If multicompany and internal users with all permissions, check user is in correct entity - elseif (! empty($conf->multicompany->enabled)) + elseif (!empty($conf->multicompany->enabled)) { $sql = "SELECT COUNT(dbt.".$dbt_select.") as nb"; - $sql.= " FROM ".MAIN_DB_PREFIX.$dbtablename." as dbt"; - $sql.= " WHERE dbt.".$dbt_select." IN (".$objectid.")"; - $sql.= " AND dbt.entity IN (".getEntity($sharedelement, 1).")"; + $sql .= " FROM ".MAIN_DB_PREFIX.$dbtablename." as dbt"; + $sql .= " WHERE dbt.".$dbt_select." IN (".$objectid.")"; + $sql .= " AND dbt.entity IN (".getEntity($sharedelement, 1).")"; } } elseif (in_array($feature, $checkproject)) { - if (! empty($conf->projet->enabled) && empty($user->rights->projet->all->lire)) + if (!empty($conf->projet->enabled) && empty($user->rights->projet->all->lire)) { include_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; - $projectstatic=new Project($db); - $tmps=$projectstatic->getProjectsAuthorizedForUser($user, 0, 1, 0); - $tmparray=explode(',', $tmps); - if (! in_array($objectid, $tmparray)) return false; + $projectstatic = new Project($db); + $tmps = $projectstatic->getProjectsAuthorizedForUser($user, 0, 1, 0); + $tmparray = explode(',', $tmps); + if (!in_array($objectid, $tmparray)) return false; } else { $sql = "SELECT COUNT(dbt.".$dbt_select.") as nb"; - $sql.= " FROM ".MAIN_DB_PREFIX.$dbtablename." as dbt"; - $sql.= " WHERE dbt.".$dbt_select." IN (".$objectid.")"; - $sql.= " AND dbt.entity IN (".getEntity($sharedelement, 1).")"; + $sql .= " FROM ".MAIN_DB_PREFIX.$dbtablename." as dbt"; + $sql .= " WHERE dbt.".$dbt_select." IN (".$objectid.")"; + $sql .= " AND dbt.entity IN (".getEntity($sharedelement, 1).")"; } } elseif (in_array($feature, $checktask)) { - if (! empty($conf->projet->enabled) && empty($user->rights->projet->all->lire)) + if (!empty($conf->projet->enabled) && empty($user->rights->projet->all->lire)) { $task = new Task($db); $task->fetch($objectid); include_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; - $projectstatic=new Project($db); - $tmps=$projectstatic->getProjectsAuthorizedForUser($user, 0, 1, 0); - $tmparray=explode(',', $tmps); - if (! in_array($task->fk_project, $tmparray)) return false; + $projectstatic = new Project($db); + $tmps = $projectstatic->getProjectsAuthorizedForUser($user, 0, 1, 0); + $tmparray = explode(',', $tmps); + if (!in_array($task->fk_project, $tmparray)) return false; } else { $sql = "SELECT COUNT(dbt.".$dbt_select.") as nb"; - $sql.= " FROM ".MAIN_DB_PREFIX.$dbtablename." as dbt"; - $sql.= " WHERE dbt.".$dbt_select." IN (".$objectid.")"; - $sql.= " AND dbt.entity IN (".getEntity($sharedelement, 1).")"; + $sql .= " FROM ".MAIN_DB_PREFIX.$dbtablename." as dbt"; + $sql .= " WHERE dbt.".$dbt_select." IN (".$objectid.")"; + $sql .= " AND dbt.entity IN (".getEntity($sharedelement, 1).")"; } } - elseif (! in_array($feature, $nocheck)) // By default (case of $checkdefault), we check on object entity + link to third party on field $dbt_keyfield + elseif (!in_array($feature, $nocheck)) // By default (case of $checkdefault), we check on object entity + link to third party on field $dbt_keyfield { // If external user: Check permission for external users if ($user->socid > 0) { if (empty($dbt_keyfield)) dol_print_error('', 'Param dbt_keyfield is required but not defined'); $sql = "SELECT COUNT(dbt.".$dbt_keyfield.") as nb"; - $sql.= " FROM ".MAIN_DB_PREFIX.$dbtablename." as dbt"; - $sql.= " WHERE dbt.rowid IN (".$objectid.")"; - $sql.= " AND dbt.".$dbt_keyfield." = ".$user->socid; + $sql .= " FROM ".MAIN_DB_PREFIX.$dbtablename." as dbt"; + $sql .= " WHERE dbt.rowid IN (".$objectid.")"; + $sql .= " AND dbt.".$dbt_keyfield." = ".$user->socid; } // If internal user: Check permission for internal users that are restricted on their objects - elseif (! empty($conf->societe->enabled) && ($user->rights->societe->lire && ! $user->rights->societe->client->voir)) + elseif (!empty($conf->societe->enabled) && ($user->rights->societe->lire && !$user->rights->societe->client->voir)) { if (empty($dbt_keyfield)) dol_print_error('', 'Param dbt_keyfield is required but not defined'); $sql = "SELECT COUNT(sc.fk_soc) as nb"; - $sql.= " FROM ".MAIN_DB_PREFIX.$dbtablename." as dbt"; - $sql.= ", ".MAIN_DB_PREFIX."societe as s"; - $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql.= " WHERE dbt.".$dbt_select." IN (".$objectid.")"; - $sql.= " AND sc.fk_soc = dbt.".$dbt_keyfield; - $sql.= " AND dbt.".$dbt_keyfield." = s.rowid"; - $sql.= " AND dbt.entity IN (".getEntity($sharedelement, 1).")"; - $sql.= " AND sc.fk_user = ".$user->id; + $sql .= " FROM ".MAIN_DB_PREFIX.$dbtablename." as dbt"; + $sql .= ", ".MAIN_DB_PREFIX."societe as s"; + $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql .= " WHERE dbt.".$dbt_select." IN (".$objectid.")"; + $sql .= " AND sc.fk_soc = dbt.".$dbt_keyfield; + $sql .= " AND dbt.".$dbt_keyfield." = s.rowid"; + $sql .= " AND dbt.entity IN (".getEntity($sharedelement, 1).")"; + $sql .= " AND sc.fk_user = ".$user->id; } // If multicompany and internal users with all permissions, check user is in correct entity - elseif (! empty($conf->multicompany->enabled)) + elseif (!empty($conf->multicompany->enabled)) { $sql = "SELECT COUNT(dbt.".$dbt_select.") as nb"; - $sql.= " FROM ".MAIN_DB_PREFIX.$dbtablename." as dbt"; - $sql.= " WHERE dbt.".$dbt_select." IN (".$objectid.")"; - $sql.= " AND dbt.entity IN (".getEntity($sharedelement, 1).")"; + $sql .= " FROM ".MAIN_DB_PREFIX.$dbtablename." as dbt"; + $sql .= " WHERE dbt.".$dbt_select." IN (".$objectid.")"; + $sql .= " AND dbt.entity IN (".getEntity($sharedelement, 1).")"; } } if ($sql) { - $resql=$db->query($sql); + $resql = $db->query($sql); if ($resql) { $obj = $db->fetch_object($resql); - if (! $obj || $obj->nb < count(explode(',', $objectid))) return false; + if (!$obj || $obj->nb < count(explode(',', $objectid))) return false; } else { @@ -671,10 +671,10 @@ function checkUserAccessToObject($user, $featuresarray, $objectid = 0, $tableand function accessforbidden($message = '', $printheader = 1, $printfooter = 1, $showonlymessage = 0, $params = null) { global $conf, $db, $user, $langs, $hookmanager; - if (! is_object($langs)) + if (!is_object($langs)) { include_once DOL_DOCUMENT_ROOT.'/core/class/translate.class.php'; - $langs=new Translate('', $conf); + $langs = new Translate('', $conf); $langs->setDefaultLang(); } @@ -686,7 +686,7 @@ function accessforbidden($message = '', $printheader = 1, $printfooter = 1, $sho elseif (function_exists("llxHeaderVierge")) llxHeaderVierge(''); } print '
'; - if (! $message) print $langs->trans("ErrorForbidden"); + if (!$message) print $langs->trans("ErrorForbidden"); else print $message; print '
'; print '
'; @@ -700,7 +700,7 @@ function accessforbidden($message = '', $printheader = 1, $printfooter = 1, $sho $hookmanager->initHooks(array('main')); } $parameters = array('message'=>$message, 'params'=>$params); - $reshook=$hookmanager->executeHooks('getAccessForbiddenMessage', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks + $reshook = $hookmanager->executeHooks('getAccessForbiddenMessage', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks print $hookmanager->resPrint; if (empty($reshook)) { diff --git a/htdocs/emailcollector/class/emailcollector.class.php b/htdocs/emailcollector/class/emailcollector.class.php index 711249576a1..d988711ae12 100644 --- a/htdocs/emailcollector/class/emailcollector.class.php +++ b/htdocs/emailcollector/class/emailcollector.class.php @@ -64,11 +64,11 @@ class EmailCollector extends CommonObject /** * @var array List of child tables. To test if we can delete object. */ - protected $childtables=array(); + protected $childtables = array(); /** * @var array List of child tables. To know object to delete on cascade. */ - protected $childtablesoncascade=array('emailcollector_emailcollectorfilter','emailcollector_emailcollectoraction'); + protected $childtablesoncascade = array('emailcollector_emailcollectorfilter', 'emailcollector_emailcollectoraction'); /** @@ -94,10 +94,10 @@ class EmailCollector extends CommonObject /** * @var array Array with all fields and their property. Do not use it as a static var. It may be modified by constructor. */ - public $fields=array( - 'rowid' => array('type'=>'integer', 'label'=>'TechnicalID','visible'=>2, 'enabled'=>1, 'position'=>1, 'notnull'=>1, 'index'=>1), - 'entity' => array('type'=>'integer', 'label'=>'Entity', 'enabled'=>1, 'visible'=>0, 'default'=>1, 'notnull'=>1, 'index'=>1, 'position'=>20), - 'ref' => array('type'=>'varchar(128)', 'label'=>'Ref', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'showoncombobox'=>1, 'index'=>1, 'position'=>10, 'searchall'=>1, 'help'=>'Example: MyCollector1'), + public $fields = array( + 'rowid' => array('type'=>'integer', 'label'=>'TechnicalID', 'visible'=>2, 'enabled'=>1, 'position'=>1, 'notnull'=>1, 'index'=>1), + 'entity' => array('type'=>'integer', 'label'=>'Entity', 'enabled'=>1, 'visible'=>0, 'default'=>1, 'notnull'=>1, 'index'=>1, 'position'=>20), + 'ref' => array('type'=>'varchar(128)', 'label'=>'Ref', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'showoncombobox'=>1, 'index'=>1, 'position'=>10, 'searchall'=>1, 'help'=>'Example: MyCollector1'), 'label' => array('type'=>'varchar(255)', 'label'=>'Label', 'visible'=>1, 'enabled'=>1, 'position'=>30, 'notnull'=>-1, 'searchall'=>1, 'help'=>'Example: My Email collector'), 'description' => array('type'=>'text', 'label'=>'Description', 'visible'=>-1, 'enabled'=>1, 'position'=>60, 'notnull'=>-1), 'host' => array('type'=>'varchar(255)', 'label'=>'EMailHost', 'visible'=>1, 'enabled'=>1, 'position'=>100, 'notnull'=>1, 'searchall'=>1, 'comment'=>"IMAP server", 'help'=>'Example: imap.gmail.com'), @@ -107,7 +107,7 @@ class EmailCollector extends CommonObject //'filter' => array('type'=>'text', 'label'=>'Filter', 'visible'=>1, 'enabled'=>1, 'position'=>105), //'actiontodo' => array('type'=>'varchar(255)', 'label'=>'ActionToDo', 'visible'=>1, 'enabled'=>1, 'position'=>106), 'target_directory' => array('type'=>'varchar(255)', 'label'=>'MailboxTargetDirectory', 'visible'=>1, 'enabled'=>1, 'position'=>110, 'notnull'=>0, 'comment'=>"Where to store messages once processed"), - 'maxemailpercollect' => array('type'=>'integer', 'label'=>'MaxEmailCollectPerCollect','visible'=>-1, 'enabled'=>1, 'position'=>111, 'default'=>100), + 'maxemailpercollect' => array('type'=>'integer', 'label'=>'MaxEmailCollectPerCollect', 'visible'=>-1, 'enabled'=>1, 'position'=>111, 'default'=>100), 'datelastresult' => array('type'=>'datetime', 'label'=>'DateLastCollectResult', 'visible'=>1, 'enabled'=>'$action != "create" && $action != "edit"', 'position'=>121, 'notnull'=>-1,), 'codelastresult' => array('type'=>'varchar(16)', 'label'=>'CodeLastResult', 'visible'=>1, 'enabled'=>'$action != "create" && $action != "edit"', 'position'=>122, 'notnull'=>-1,), 'lastresult' => array('type'=>'varchar(255)', 'label'=>'LastResult', 'visible'=>1, 'enabled'=>'$action != "create" && $action != "edit"', 'position'=>123, 'notnull'=>-1,), @@ -222,13 +222,13 @@ class EmailCollector extends CommonObject } // Translate some data of arrayofkeyval - foreach($this->fields as $key => $val) + foreach ($this->fields as $key => $val) { if (is_array($val['arrayofkeyval'])) { - foreach($val['arrayofkeyval'] as $key2 => $val2) + foreach ($val['arrayofkeyval'] as $key2 => $val2) { - $this->fields[$key]['arrayofkeyval'][$key2]=$langs->trans($val2); + $this->fields[$key]['arrayofkeyval'][$key2] = $langs->trans($val2); } } } @@ -279,10 +279,10 @@ class EmailCollector extends CommonObject if (is_array($object->array_options) && count($object->array_options) > 0) { $extrafields->fetch_name_optionals_label($this->table_element); - foreach($object->array_options as $key => $option) + foreach ($object->array_options as $key => $option) { $shortkey = preg_replace('/options_/', '', $key); - if (! empty($extrafields->attributes[$this->element]['unique'][$shortkey])) + if (!empty($extrafields->attributes[$this->element]['unique'][$shortkey])) { //var_dump($key); var_dump($clonedObj->array_options[$key]); exit; unset($object->array_options[$key]); @@ -437,38 +437,38 @@ class EmailCollector extends CommonObject { global $conf, $langs, $hookmanager; - if (! empty($conf->dol_no_mouse_hover)) $notooltip=1; // Force disable tooltips + if (!empty($conf->dol_no_mouse_hover)) $notooltip = 1; // Force disable tooltips $result = ''; - $label = '' . $langs->trans("EmailCollector") . ''; - $label.= '
'; - $label.= '' . $langs->trans('Ref') . ': ' . $this->ref; + $label = ''.$langs->trans("EmailCollector").''; + $label .= '
'; + $label .= ''.$langs->trans('Ref').': '.$this->ref; $url = dol_buildpath('/admin/emailcollector_card.php', 1).'?id='.$this->id; if ($option != 'nolink') { // Add param to save lastsearch_values or not - $add_save_lastsearch_values=($save_lastsearch_value == 1 ? 1 : 0); + $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0); if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) { - $add_save_lastsearch_values=1; + $add_save_lastsearch_values = 1; } if ($add_save_lastsearch_values) { - $url.='&save_lastsearch_values=1'; + $url .= '&save_lastsearch_values=1'; } } - $linkclose=''; + $linkclose = ''; if (empty($notooltip)) { - if (! empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) + if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { - $label=$langs->trans("ShowEmailCollector"); - $linkclose.=' alt="'.dol_escape_htmltag($label, 1).'"'; + $label = $langs->trans("ShowEmailCollector"); + $linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"'; } - $linkclose.=' title="'.dol_escape_htmltag($label, 1).'"'; - $linkclose.=' class="classfortooltip'.($morecss?' '.$morecss:'').'"'; + $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"'; + $linkclose .= ' class="classfortooltip'.($morecss ? ' '.$morecss : '').'"'; /* $hookmanager->initHooks(array('myobjectdao')); @@ -681,7 +681,7 @@ class EmailCollector extends CommonObject $flags .= '/novalidate-cert'; //$flags.='/readonly'; //$flags.='/debug'; - if ($norsh || ! empty($conf->global->IMPA_FORCE_NORSH)) $flags .= '/norsh'; + if ($norsh || !empty($conf->global->IMPA_FORCE_NORSH)) $flags .= '/norsh'; $connectstringserver = '{'.$this->host.':993'.$flags.'}'; @@ -698,13 +698,13 @@ class EmailCollector extends CommonObject { if (function_exists('mb_convert_encoding')) { // change spaces by entropy because mb_convert fail with spaces - $str=preg_replace("/ /", "xyxy", $str); + $str = preg_replace("/ /", "xyxy", $str); // if mb_convert work if ($str = mb_convert_encoding($str, "UTF-7")) { // change characters - $str=preg_replace("/\+A/", "&A", $str); + $str = preg_replace("/\+A/", "&A", $str); // change to spaces again - $str=preg_replace("/xyxy/", " ", $str); + $str = preg_replace("/xyxy/", " ", $str); return $str; } else { // print error and return false @@ -762,59 +762,59 @@ class EmailCollector extends CommonObject // Overwrite values with values extracted from source email // $this->actionparam = 'opportunity_status=123;abc=EXTRACT:BODY:....' $arrayvaluetouse = dolExplodeIntoArray($actionparam, ';', '='); - foreach($arrayvaluetouse as $propertytooverwrite => $valueforproperty) + foreach ($arrayvaluetouse as $propertytooverwrite => $valueforproperty) { - $tmpclass=''; $tmpproperty=''; - $tmparray=explode('.', $propertytooverwrite); + $tmpclass = ''; $tmpproperty = ''; + $tmparray = explode('.', $propertytooverwrite); if (count($tmparray) == 2) { - $tmpclass=$tmparray[0]; - $tmpproperty=$tmparray[1]; + $tmpclass = $tmparray[0]; + $tmpproperty = $tmparray[1]; } else { - $tmpproperty=$tmparray[0]; + $tmpproperty = $tmparray[0]; } - if ($tmpclass && ($tmpclass != $object->element)) continue; // Property is for another type of object + if ($tmpclass && ($tmpclass != $object->element)) continue; // Property is for another type of object //if (property_exists($object, $tmpproperty) || preg_match('/^options_/', $tmpproperty)) if ($tmpproperty) { - $sourcestring=''; - $sourcefield=''; - $regexstring=''; + $sourcestring = ''; + $sourcefield = ''; + $regexstring = ''; //$transformationstring=''; - $regforregex=array(); + $regforregex = array(); if (preg_match('/^EXTRACT:([a-zA-Z0-9]+):(.*):([^:])$/', $valueforproperty, $regforregex)) { - $sourcefield=$regforregex[1]; - $regexstring=$regforregex[2]; + $sourcefield = $regforregex[1]; + $regexstring = $regforregex[2]; //$transofrmationstring=$regforregex[3]; } elseif (preg_match('/^EXTRACT:([a-zA-Z0-9]+):(.*)$/', $valueforproperty, $regforregex)) { - $sourcefield=$regforregex[1]; - $regexstring=$regforregex[2]; + $sourcefield = $regforregex[1]; + $regexstring = $regforregex[2]; } - if (! empty($sourcefield) && ! empty($regexstring)) + if (!empty($sourcefield) && !empty($regexstring)) { - if (strtolower($sourcefield) == 'body') $sourcestring=$messagetext; - elseif (strtolower($sourcefield) == 'subject') $sourcestring=$subject; - elseif (strtolower($sourcefield) == 'header') $sourcestring=$header; + if (strtolower($sourcefield) == 'body') $sourcestring = $messagetext; + elseif (strtolower($sourcefield) == 'subject') $sourcestring = $subject; + elseif (strtolower($sourcefield) == 'header') $sourcestring = $header; if ($sourcestring) { - $regforval=array(); - $regexoptions=''; - if (strtolower($sourcefield) == 'body') $regexoptions='ms'; // The m means ^ and $ char is valid at each new line. The s means the char '.' is valid for new lines char too - if (strtolower($sourcefield) == 'header') $regexoptions='m'; // The m means ^ and $ char is valid at each new line. + $regforval = array(); + $regexoptions = ''; + if (strtolower($sourcefield) == 'body') $regexoptions = 'ms'; // The m means ^ and $ char is valid at each new line. The s means the char '.' is valid for new lines char too + if (strtolower($sourcefield) == 'header') $regexoptions = 'm'; // The m means ^ and $ char is valid at each new line. //var_dump($tmpproperty.' - '.$regexstring.' - '.$regexoptions.' - '.$sourcestring); if (preg_match('/'.$regexstring.'/'.$regexoptions, $sourcestring, $regforval)) { //var_dump($regforval[1]);exit; // Overwrite param $tmpproperty - $object->$tmpproperty = isset($regforval[1])?trim($regforval[1]):null; + $object->$tmpproperty = isset($regforval[1]) ?trim($regforval[1]) : null; } else { @@ -832,24 +832,24 @@ class EmailCollector extends CommonObject } elseif (preg_match('/^(SET|SETIFEMPTY):(.*)$/', $valueforproperty, $regforregex)) { - $valuecurrent=''; + $valuecurrent = ''; if (preg_match('/^options_/', $tmpproperty)) $valuecurrent = $object->array_options[preg_replace('/^options_/', '', $tmpproperty)]; else $valuecurrent = $object->$tmpproperty; if ($regforregex[1] == 'SET' || empty($valuecurrent)) { $valuetouse = $regforregex[2]; - $substitutionarray=array(); - $matcharray=array(); + $substitutionarray = array(); + $matcharray = array(); preg_match_all('/__([a-z0-9]+(?:_[a-z0-9]+)?)__/i', $valuetouse, $matcharray); //var_dump($tmpproperty.' - '.$object->$tmpproperty.' - '.$valuetouse); var_dump($matcharray); if (is_array($matcharray[1])) // $matcharray[1] is array with list of substitution key found without the __ { - foreach($matcharray[1] as $keytoreplace) + foreach ($matcharray[1] as $keytoreplace) { if ($keytoreplace && isset($object->$keytoreplace)) { - $substitutionarray['__'.$keytoreplace.'__']=$object->$keytoreplace; + $substitutionarray['__'.$keytoreplace.'__'] = $object->$keytoreplace; } } } @@ -921,73 +921,73 @@ class EmailCollector extends CommonObject $this->fetchActions(); $sourcedir = $this->source_directory; - $targetdir = ($this->target_directory ? $this->target_directory : ''); // Can be '[Gmail]/Trash' or 'mytag' + $targetdir = ($this->target_directory ? $this->target_directory : ''); // Can be '[Gmail]/Trash' or 'mytag' $connectstringserver = $this->getConnectStringIMAP(); $connectstringsource = $connectstringserver.imap_utf7_encode($sourcedir); $connectstringtarget = $connectstringserver.imap_utf7_encode($targetdir); $connection = imap_open($connectstringsource, $this->login, $this->password); - if (! $connection) + if (!$connection) { $this->error = 'Failed to open IMAP connection '.$connectstringsource; return -3; } - imap_errors(); // Clear stack of errors. + imap_errors(); // Clear stack of errors. // $conf->global->MAIL_PREFIX_FOR_EMAIL_ID must be defined - $host=dol_getprefix('email'); + $host = dol_getprefix('email'); // Define the IMAP search string // See https://tools.ietf.org/html/rfc3501#section-6.4.4 for IMAPv4 (PHP not yet compatible) // See https://tools.ietf.org/html/rfc1064 page 13 for IMAPv2 //$search='ALL'; - $search='UNDELETED'; // Seems not supported by some servers - $searchhead=''; - $searchfilterdoltrackid=0; - $searchfilternodoltrackid=0; - foreach($this->filters as $rule) + $search = 'UNDELETED'; // Seems not supported by some servers + $searchhead = ''; + $searchfilterdoltrackid = 0; + $searchfilternodoltrackid = 0; + foreach ($this->filters as $rule) { if (empty($rule['status'])) continue; - if ($rule['type'] == 'to') $search.=($search?' ':'').'TO "'.str_replace('"', '', $rule['rulevalue']).'"'; - if ($rule['type'] == 'bcc') $search.=($search?' ':'').'BCC'; - if ($rule['type'] == 'cc') $search.=($search?' ':'').'CC'; - if ($rule['type'] == 'from') $search.=($search?' ':'').'FROM "'.str_replace('"', '', $rule['rulevalue']).'"'; - if ($rule['type'] == 'subject') $search.=($search?' ':'').'SUBJECT "'.str_replace('"', '', $rule['rulevalue']).'"'; - if ($rule['type'] == 'body') $search.=($search?' ':'').'BODY "'.str_replace('"', '', $rule['rulevalue']).'"'; - if ($rule['type'] == 'header') $search.=($search?' ':'').'HEADER '.$rule['rulevalue']; + if ($rule['type'] == 'to') $search .= ($search ? ' ' : '').'TO "'.str_replace('"', '', $rule['rulevalue']).'"'; + if ($rule['type'] == 'bcc') $search .= ($search ? ' ' : '').'BCC'; + if ($rule['type'] == 'cc') $search .= ($search ? ' ' : '').'CC'; + if ($rule['type'] == 'from') $search .= ($search ? ' ' : '').'FROM "'.str_replace('"', '', $rule['rulevalue']).'"'; + if ($rule['type'] == 'subject') $search .= ($search ? ' ' : '').'SUBJECT "'.str_replace('"', '', $rule['rulevalue']).'"'; + if ($rule['type'] == 'body') $search .= ($search ? ' ' : '').'BODY "'.str_replace('"', '', $rule['rulevalue']).'"'; + if ($rule['type'] == 'header') $search .= ($search ? ' ' : '').'HEADER '.$rule['rulevalue']; - if ($rule['type'] == 'notinsubject') $search.=($search?' ':'').'SUBJECT NOT "'.str_replace('"', '', $rule['rulevalue']).'"'; - if ($rule['type'] == 'notinbody') $search.=($search?' ':'').'BODY NOT "'.str_replace('"', '', $rule['rulevalue']).'"'; + if ($rule['type'] == 'notinsubject') $search .= ($search ? ' ' : '').'SUBJECT NOT "'.str_replace('"', '', $rule['rulevalue']).'"'; + if ($rule['type'] == 'notinbody') $search .= ($search ? ' ' : '').'BODY NOT "'.str_replace('"', '', $rule['rulevalue']).'"'; - if ($rule['type'] == 'seen') $search.=($search?' ':'').'SEEN'; - if ($rule['type'] == 'unseen') $search.=($search?' ':'').'UNSEEN'; - if ($rule['type'] == 'unanswered') $search.=($search?' ':'').'UNANSWERED'; - if ($rule['type'] == 'answered') $search.=($search?' ':'').'ANSWERED'; - if ($rule['type'] == 'smaller') $search.=($search?' ':'').'SMALLER "'.str_replace('"', '', $rule['rulevalue']).'"'; - if ($rule['type'] == 'larger') $search.=($search?' ':'').'LARGER "'.str_replace('"', '', $rule['rulevalue']).'"'; + if ($rule['type'] == 'seen') $search .= ($search ? ' ' : '').'SEEN'; + if ($rule['type'] == 'unseen') $search .= ($search ? ' ' : '').'UNSEEN'; + if ($rule['type'] == 'unanswered') $search .= ($search ? ' ' : '').'UNANSWERED'; + if ($rule['type'] == 'answered') $search .= ($search ? ' ' : '').'ANSWERED'; + if ($rule['type'] == 'smaller') $search .= ($search ? ' ' : '').'SMALLER "'.str_replace('"', '', $rule['rulevalue']).'"'; + if ($rule['type'] == 'larger') $search .= ($search ? ' ' : '').'LARGER "'.str_replace('"', '', $rule['rulevalue']).'"'; - if ($rule['type'] == 'withtrackingid') { $searchfilterdoltrackid++; $searchhead.='/References.*@'.preg_quote($host, '/').'/'; } - if ($rule['type'] == 'withouttrackingid') { $searchfilternodoltrackid++; $searchhead.='! /References.*@'.preg_quote($host, '/').'/';} + if ($rule['type'] == 'withtrackingid') { $searchfilterdoltrackid++; $searchhead .= '/References.*@'.preg_quote($host, '/').'/'; } + if ($rule['type'] == 'withouttrackingid') { $searchfilternodoltrackid++; $searchhead .= '! /References.*@'.preg_quote($host, '/').'/'; } } if (empty($targetdir)) // Use last date as filter if there is no targetdir defined. { - $fromdate=0; + $fromdate = 0; if ($this->datelastok) $fromdate = $this->datelastok; - if ($fromdate > 0) $search.=($search?' ':'').'SINCE '.date('j-M-Y', $fromdate - 1); // SENTSINCE not supported. Date must be X-Abc-9999 (X on 1 digit if < 10) + if ($fromdate > 0) $search .= ($search ? ' ' : '').'SINCE '.date('j-M-Y', $fromdate - 1); // SENTSINCE not supported. Date must be X-Abc-9999 (X on 1 digit if < 10) //$search.=($search?' ':'').'SINCE 8-Apr-2018'; } dol_syslog("IMAP search string = ".$search); //var_dump($search); - $nbemailprocessed=0; - $nbemailok=0; - $nbactiondone=0; + $nbemailprocessed = 0; + $nbemailok = 0; + $nbactiondone = 0; // Scan IMAP inbox - $arrayofemail= imap_search($connection, $search, null, "UTF-8"); + $arrayofemail = imap_search($connection, $search, null, "UTF-8"); if ($arrayofemail === false) { // Nothing found or search string not understood @@ -1001,7 +1001,7 @@ class EmailCollector extends CommonObject } // Loop on each email found - if (! $error && ! empty($arrayofemail) && count($arrayofemail) > 0) + if (!$error && !empty($arrayofemail) && count($arrayofemail) > 0) { // Loop to get part html and plain /* @@ -1078,15 +1078,15 @@ class EmailCollector extends CommonObject dol_syslog("Start of loop on email", LOG_INFO, 1); - foreach($arrayofemail as $imapemail) + foreach ($arrayofemail as $imapemail) { if ($nbemailprocessed > 1000) { - break; // Do not process more than 1000 email per launch (this is a different protection than maxnbcollectedpercollect + break; // Do not process more than 1000 email per launch (this is a different protection than maxnbcollectedpercollect } $header = imap_fetchheader($connection, $imapemail, 0); - $matches=array(); + $matches = array(); preg_match_all('/([^: ]+): (.+?(?:\r\n\s(?:.+?))*)\r\n/m', $header, $matches); $headers = array_combine($matches[1], $matches[2]); //var_dump($headers); @@ -1206,26 +1206,26 @@ class EmailCollector extends CommonObject //print $messagetext; //exit; - $fromstring=$overview[0]->from; - $sender=$overview[0]->sender; - $to=$overview[0]->to; - $sendtocc=$overview[0]->cc; - $sendtobcc=$overview[0]->bcc; - $date=$overview[0]->udate; - $msgid=str_replace(array('<','>'), '', $overview[0]->message_id); - $subject=$overview[0]->subject; + $fromstring = $overview[0]->from; + $sender = $overview[0]->sender; + $to = $overview[0]->to; + $sendtocc = $overview[0]->cc; + $sendtobcc = $overview[0]->bcc; + $date = $overview[0]->udate; + $msgid = str_replace(array('<', '>'), '', $overview[0]->message_id); + $subject = $overview[0]->subject; //var_dump($msgid);exit; - $reg=array(); + $reg = array(); if (preg_match('/^(.*)<(.*)>$/', $fromstring, $reg)) { - $from=$reg[2]; - $fromtext=$reg[1]; + $from = $reg[2]; + $fromtext = $reg[1]; } else { $from = $fromstring; - $fromtext=''; + $fromtext = ''; } $fk_element_id = 0; $fk_element_type = ''; @@ -1375,10 +1375,10 @@ class EmailCollector extends CommonObject else $descriptiontitle = $langs->trans("ActionAC_".$actioncode).' - '.$langs->trans("MailFrom").' '.$from; $descriptionmeta = dol_concatdesc($descriptionmeta, $langs->trans("MailTopic").' : '.dol_escape_htmltag($subject)); - $descriptionmeta = dol_concatdesc($descriptionmeta, $langs->trans("MailFrom").($langs->trans("MailFrom") != 'From' ? ' (From)':'').' : '.dol_escape_htmltag($fromstring)); - if ($sender) $descriptionmeta = dol_concatdesc($descriptionmeta, $langs->trans("Sender").($langs->trans("Sender") != 'Sender' ? ' (Sender)':'').' : '.dol_escape_htmltag($sender)); - $descriptionmeta = dol_concatdesc($descriptionmeta, $langs->trans("MailTo").($langs->trans("MailTo") != 'To' ? ' (To)':'').' : '.dol_escape_htmltag($to)); - if ($sendtocc) $descriptionmeta = dol_concatdesc($descriptionmeta, $langs->trans("MailCC").($langs->trans("MailCC") != 'CC' ? ' (CC)':'').' : '.dol_escape_htmltag($sendtocc)); + $descriptionmeta = dol_concatdesc($descriptionmeta, $langs->trans("MailFrom").($langs->trans("MailFrom") != 'From' ? ' (From)' : '').' : '.dol_escape_htmltag($fromstring)); + if ($sender) $descriptionmeta = dol_concatdesc($descriptionmeta, $langs->trans("Sender").($langs->trans("Sender") != 'Sender' ? ' (Sender)' : '').' : '.dol_escape_htmltag($sender)); + $descriptionmeta = dol_concatdesc($descriptionmeta, $langs->trans("MailTo").($langs->trans("MailTo") != 'To' ? ' (To)' : '').' : '.dol_escape_htmltag($to)); + if ($sendtocc) $descriptionmeta = dol_concatdesc($descriptionmeta, $langs->trans("MailCC").($langs->trans("MailCC") != 'CC' ? ' (CC)' : '').' : '.dol_escape_htmltag($sendtocc)); //if ($bcc) $descriptionmeta = dol_concatdesc($descriptionmeta, $langs->trans("Bcc").' : '.dol_escape_htmltag($bcc)); } @@ -1394,38 +1394,38 @@ class EmailCollector extends CommonObject else { $actionparam = $operation['actionparam']; - $nametouseforthirdparty=''; + $nametouseforthirdparty = ''; // $this->actionparam = 'SET:aaa' or 'EXTRACT:BODY:....' $arrayvaluetouse = dolExplodeIntoArray($actionparam, ';', '='); - foreach($arrayvaluetouse as $propertytooverwrite => $valueforproperty) + foreach ($arrayvaluetouse as $propertytooverwrite => $valueforproperty) { - $sourcestring=''; - $sourcefield=''; - $regexstring=''; - $regforregex=array(); + $sourcestring = ''; + $sourcefield = ''; + $regexstring = ''; + $regforregex = array(); if (preg_match('/^EXTRACT:([a-zA-Z0-9]+):(.*)$/', $valueforproperty, $regforregex)) { - $sourcefield=$regforregex[1]; - $regexstring=$regforregex[2]; + $sourcefield = $regforregex[1]; + $regexstring = $regforregex[2]; } - if (! empty($sourcefield) && ! empty($regexstring)) + if (!empty($sourcefield) && !empty($regexstring)) { - if (strtolower($sourcefield) == 'body') $sourcestring=$messagetext; - elseif (strtolower($sourcefield) == 'subject') $sourcestring=$subject; - elseif (strtolower($sourcefield) == 'header') $sourcestring=$header; + if (strtolower($sourcefield) == 'body') $sourcestring = $messagetext; + elseif (strtolower($sourcefield) == 'subject') $sourcestring = $subject; + elseif (strtolower($sourcefield) == 'header') $sourcestring = $header; if ($sourcestring) { - $regforval=array(); + $regforval = array(); //var_dump($regexstring);var_dump($sourcestring); if (preg_match('/'.$regexstring.'/ms', $sourcestring, $regforval)) { //var_dump($regforval[1]);exit; // Overwrite param $tmpproperty - $nametouseforthirdparty = isset($regforval[1])?trim($regforval[1]):null; + $nametouseforthirdparty = isset($regforval[1]) ?trim($regforval[1]) : null; } else { @@ -1515,7 +1515,7 @@ class EmailCollector extends CommonObject // TODO Check if $msg ID already in database for $conf->entity - if (! $alreadycreated) + if (!$alreadycreated) { if ($projectstatic->id > 0) { @@ -1542,30 +1542,30 @@ class EmailCollector extends CommonObject // Insert record of emails sent $actioncomm = new ActionComm($this->db); - $actioncomm->type_code = 'AC_OTH_AUTO'; // Type of event ('AC_OTH', 'AC_OTH_AUTO', 'AC_XXX'...) + $actioncomm->type_code = 'AC_OTH_AUTO'; // Type of event ('AC_OTH', 'AC_OTH_AUTO', 'AC_XXX'...) $actioncomm->code = 'AC_'.$actioncode; $actioncomm->label = $langs->trans("ActionAC_".$actioncode).' - '.$langs->trans("MailFrom").' '.$from; - $actioncomm->note_private= $descriptionfull; + $actioncomm->note_private = $descriptionfull; $actioncomm->fk_project = $projectstatic->id; $actioncomm->datep = $date; $actioncomm->datef = $date; - $actioncomm->percentage = -1; // Not applicable + $actioncomm->percentage = -1; // Not applicable $actioncomm->socid = $thirdpartystatic->id; $actioncomm->contactid = $contactstatic->id; $actioncomm->socpeopleassigned = (!empty($contactstatic->id) ? array($contactstatic->id => '') : array()); - $actioncomm->authorid = $user->id; // User saving action - $actioncomm->userownerid = $user->id; // Owner of action + $actioncomm->authorid = $user->id; // User saving action + $actioncomm->userownerid = $user->id; // Owner of action // Fields when action is an email (content should be added into note) $actioncomm->email_msgid = $msgid; $actioncomm->email_from = $fromstring; - $actioncomm->email_sender= $sender; + $actioncomm->email_sender = $sender; $actioncomm->email_to = $to; $actioncomm->email_tocc = $sendtocc; $actioncomm->email_tobcc = $sendtobcc; $actioncomm->email_subject = $subject; $actioncomm->errors_to = ''; - if (! in_array($fk_element_type, array('societe','contact','project','user'))) + if (!in_array($fk_element_type, array('societe', 'contact', 'project', 'user'))) { $actioncomm->fk_element = $fk_element_id; $actioncomm->elementtype = $fk_element_type; @@ -1637,18 +1637,18 @@ class EmailCollector extends CommonObject if (empty($projecttocreate->ref)) { // Get next project Ref - $defaultref=''; - $modele = empty($conf->global->PROJECT_ADDON)?'mod_project_simple':$conf->global->PROJECT_ADDON; + $defaultref = ''; + $modele = empty($conf->global->PROJECT_ADDON) ? 'mod_project_simple' : $conf->global->PROJECT_ADDON; // Search template files - $file=''; $classname=''; $filefound=0; $reldir=''; - $dirmodels=array_merge(array('/'), (array) $conf->modules_parts['models']); - foreach($dirmodels as $reldir) + $file = ''; $classname = ''; $filefound = 0; $reldir = ''; + $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); + foreach ($dirmodels as $reldir) { - $file=dol_buildpath($reldir."core/modules/project/".$modele.'.php', 0); + $file = dol_buildpath($reldir."core/modules/project/".$modele.'.php', 0); if (file_exists($file)) { - $filefound=1; + $filefound = 1; $classname = $modele; break; } @@ -1656,7 +1656,7 @@ class EmailCollector extends CommonObject if ($filefound) { - $result=dol_include_once($reldir."core/modules/project/".$modele.'.php'); + $result = dol_include_once($reldir."core/modules/project/".$modele.'.php'); $modProject = new $classname; if ($savesocid > 0) @@ -1752,18 +1752,18 @@ class EmailCollector extends CommonObject if (empty($tickettocreate->ref)) { // Get next project Ref - $defaultref=''; - $modele = empty($conf->global->TICKET_ADDON)?'mod_ticket_simple':$conf->global->TICKET_ADDON; + $defaultref = ''; + $modele = empty($conf->global->TICKET_ADDON) ? 'mod_ticket_simple' : $conf->global->TICKET_ADDON; // Search template files - $file=''; $classname=''; $filefound=0; $reldir=''; - $dirmodels=array_merge(array('/'), (array) $conf->modules_parts['models']); - foreach($dirmodels as $reldir) + $file = ''; $classname = ''; $filefound = 0; $reldir = ''; + $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); + foreach ($dirmodels as $reldir) { - $file=dol_buildpath($reldir."core/modules/ticket/".$modele.'.php', 0); + $file = dol_buildpath($reldir."core/modules/ticket/".$modele.'.php', 0); if (file_exists($file)) { - $filefound=1; + $filefound = 1; $classname = $modele; break; } @@ -1771,7 +1771,7 @@ class EmailCollector extends CommonObject if ($filefound) { - $result=dol_include_once($reldir."core/modules/ticket/".$modele.'.php'); + $result = dol_include_once($reldir."core/modules/ticket/".$modele.'.php'); $modTicket = new $classname; if ($savesocid > 0) @@ -1878,16 +1878,16 @@ class EmailCollector extends CommonObject } } - $output=$langs->trans('XEmailsDoneYActionsDone', $nbemailprocessed, $nbemailok, $nbactiondone); + $output = $langs->trans('XEmailsDoneYActionsDone', $nbemailprocessed, $nbemailok, $nbactiondone); dol_syslog("End of loop on emails", LOG_INFO, -1); } else { - $output=$langs->trans('NoNewEmailToProcess'); + $output = $langs->trans('NoNewEmailToProcess'); } - imap_expunge($connection); // To validate any move + imap_expunge($connection); // To validate any move imap_close($connection); @@ -1896,7 +1896,7 @@ class EmailCollector extends CommonObject $this->debuginfo = 'IMAP search string used : '.$search; if ($searchhead) $this->debuginfo .= '
Then search string into email header : '.$searchhead; - if (! $error) $this->datelastok = $now; + if (!$error) $this->datelastok = $now; if (!empty($this->errors)) $this->lastresult .= " - ".join(" - ", $this->errors); $this->codelastresult = ($error ? 'KO' : 'OK'); @@ -1922,7 +1922,7 @@ class EmailCollector extends CommonObject { // input $mbox = IMAP stream, $mid = message id // output all the following: - global $charset,$htmlmsg,$plainmsg,$attachments; + global $charset, $htmlmsg, $plainmsg, $attachments; $htmlmsg = $plainmsg = $charset = ''; $attachments = array(); @@ -1935,11 +1935,11 @@ class EmailCollector extends CommonObject if (!$s->parts) { // simple - $this->getpart($mbox, $mid, $s, 0); // pass 0 as part-number + $this->getpart($mbox, $mid, $s, 0); // pass 0 as part-number } else { // multipart: cycle through each part foreach ($s->parts as $partno0 => $p) { - $this->getpart($mbox, $mid, $p, $partno0+1); + $this->getpart($mbox, $mid, $p, $partno0 + 1); } } } @@ -1971,16 +1971,16 @@ class EmailCollector extends CommonObject private function getpart($mbox, $mid, $p, $partno) { // $partno = '1', '2', '2.1', '2.1.3', etc for multipart, 0 if simple - global $htmlmsg,$plainmsg,$charset,$attachments; + global $htmlmsg, $plainmsg, $charset, $attachments; // DECODE DATA - $data = ($partno)? - imap_fetchbody($mbox, $mid, $partno): // multipart - imap_body($mbox, $mid); // simple + $data = ($partno) ? + imap_fetchbody($mbox, $mid, $partno) : // multipart + imap_body($mbox, $mid); // simple // Any part may be encoded, even plain text messages, so check everything. - if ($p->encoding==4) + if ($p->encoding == 4) $data = quoted_printable_decode($data); - elseif ($p->encoding==3) + elseif ($p->encoding == 3) $data = base64_decode($data); // PARAMETERS @@ -2006,20 +2006,20 @@ class EmailCollector extends CommonObject // so an attached text file (type 0) is not mistaken as the message. if ($params['filename'] || $params['name']) { // filename may be given as 'Filename' or 'Name' or both - $filename = ($params['filename'])? $params['filename'] : $params['name']; + $filename = ($params['filename']) ? $params['filename'] : $params['name']; // filename may be encoded, so see imap_mime_header_decode() - $attachments[$filename] = $data; // this is a problem if two files have same name + $attachments[$filename] = $data; // this is a problem if two files have same name } // TEXT - if ($p->type==0 && $data) { + if ($p->type == 0 && $data) { // Messages may be split in different parts because of inline attachments, // so append parts together with blank row. - if (strtolower($p->subtype)=='plain') - $plainmsg .= trim($data) ."\n\n"; + if (strtolower($p->subtype) == 'plain') + $plainmsg .= trim($data)."\n\n"; else - $htmlmsg .= $data ."

"; - $charset = $params['charset']; // assume all parts are same charset + $htmlmsg .= $data."

"; + $charset = $params['charset']; // assume all parts are same charset } // EMBEDDED MESSAGE @@ -2027,7 +2027,7 @@ class EmailCollector extends CommonObject // but AOL uses type 1 (multipart), which is not handled here. // There are no PHP functions to parse embedded messages, // so this just appends the raw source to the main message. - elseif ($p->type==2 && $data) { + elseif ($p->type == 2 && $data) { $plainmsg .= $data."\n\n"; } @@ -2035,7 +2035,7 @@ class EmailCollector extends CommonObject if ($p->parts) { foreach ($p->parts as $partno0=>$p2) { - $this->getpart($mbox, $mid, $p2, $partno.'.'.($partno0+1)); // 1.2, 1.2.1, etc. + $this->getpart($mbox, $mid, $p2, $partno.'.'.($partno0 + 1)); // 1.2, 1.2.1, etc. } } } From 30ea48a7150b3d99b9f529cfc53c51908585b0f5 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 26 Nov 2019 12:58:41 +0100 Subject: [PATCH 114/154] Fix api for deletion of attributes --- htdocs/product/class/api_products.class.php | 24 +++++++++---------- .../variants/class/ProductAttribute.class.php | 5 ++-- 2 files changed, 15 insertions(+), 14 deletions(-) diff --git a/htdocs/product/class/api_products.class.php b/htdocs/product/class/api_products.class.php index 37c950e9956..05d5818b3ff 100644 --- a/htdocs/product/class/api_products.class.php +++ b/htdocs/product/class/api_products.class.php @@ -965,8 +965,8 @@ class Products extends DolibarrApi /** * Delete attributes by id. * - * @param int $id ID of Attribute - * @return int + * @param int $id ID of Attribute + * @return int Result of deletion * * @throws RestException * @throws 401 @@ -981,12 +981,13 @@ class Products extends DolibarrApi $prodattr = new ProductAttribute($this->db); $prodattr->id = (int) $id; - $result = $prodattr->delete(); + $result = $prodattr->delete(DolibarrApiAccess::$user); - if ($result > 0) { - return 1; + if ($result <= 0) { + throw new RestException(500, "Error deleting attribute"); } - throw new RestException(500, "Error deleting attribute"); + + return $result; } /** @@ -1485,8 +1486,8 @@ class Products extends DolibarrApi /** * Delete product variants. * - * @param int $id ID of Variant - * @return int + * @param int $id ID of Variant + * @return int Result of deletion * * @throws RestException * @throws 401 @@ -1502,12 +1503,11 @@ class Products extends DolibarrApi $prodcomb = new ProductCombination($this->db); $prodcomb->id = (int) $id; $result = $prodcomb->delete(DolibarrApiAccess::$user); - return $result; - if ($result > 0) + if ($result <= 0) { - return 1; + throw new RestException(500, "Error deleting variant"); } - throw new RestException(500, "Error deleting variant"); + return $result; } // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore diff --git a/htdocs/variants/class/ProductAttribute.class.php b/htdocs/variants/class/ProductAttribute.class.php index 1172d08f74d..3ccdb6dbf03 100644 --- a/htdocs/variants/class/ProductAttribute.class.php +++ b/htdocs/variants/class/ProductAttribute.class.php @@ -174,9 +174,10 @@ class ProductAttribute /** * Deletes a product attribute * - * @return int <0 KO, >0 OK + * @param User $user Object user + * @return int <0 KO, >0 OK */ - public function delete() + public function delete($user = null) { $sql = "DELETE FROM ".MAIN_DB_PREFIX."product_attribute WHERE rowid = ".(int) $this->id; From 1e6b93500a50ebfb0d4d2253cd168981be645908 Mon Sep 17 00:00:00 2001 From: oscim Date: Tue, 26 Nov 2019 16:34:16 +0100 Subject: [PATCH 115/154] Put $object in complete_head_from_modules Add object for correctly usage in function complete_head_from_modules --- htdocs/core/lib/admin.lib.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/lib/admin.lib.php b/htdocs/core/lib/admin.lib.php index a38a9c4289c..948064d3b5c 100644 --- a/htdocs/core/lib/admin.lib.php +++ b/htdocs/core/lib/admin.lib.php @@ -702,9 +702,9 @@ function modulehelp_prepare_head($object) $h++; } - complete_head_from_modules($conf, $langs, null, $head, $h, 'modulehelp_admin'); + complete_head_from_modules($conf, $langs, $object, $head, $h, 'modulehelp_admin'); - complete_head_from_modules($conf, $langs, null, $head, $h, 'modulehelp_admin', 'remove'); + complete_head_from_modules($conf, $langs, $object, $head, $h, 'modulehelp_admin', 'remove'); return $head; From d36cc22d392c1b77172d76860a1c888b687c451a Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Tue, 26 Nov 2019 17:38:49 +0100 Subject: [PATCH 116/154] NEW get company info by API --- htdocs/api/class/api_setup.class.php | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/htdocs/api/class/api_setup.class.php b/htdocs/api/class/api_setup.class.php index 72ad45921d5..6b1c7eb6ee9 100644 --- a/htdocs/api/class/api_setup.class.php +++ b/htdocs/api/class/api_setup.class.php @@ -1326,7 +1326,21 @@ class Setup extends DolibarrApi return $list; } + + /** + * Get properties of company + * + * @url GET /company + * + * @return array|mixed Data without useless information + * + */ + public function getCompany() + { + global $mysoc; + return $this->_cleanObjectDatas($mysoc); + } /** * Do a test of integrity for files and setup. From 247ef7b6195a65e57865c09b98aa0b217a6c79a0 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Tue, 26 Nov 2019 16:40:45 +0000 Subject: [PATCH 117/154] Fixing style errors. --- htdocs/api/class/api_setup.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/api/class/api_setup.class.php b/htdocs/api/class/api_setup.class.php index 6b1c7eb6ee9..0dfdc9362ed 100644 --- a/htdocs/api/class/api_setup.class.php +++ b/htdocs/api/class/api_setup.class.php @@ -1326,7 +1326,7 @@ class Setup extends DolibarrApi return $list; } - + /** * Get properties of company * From 3a687b1daea90777cd21d60de9290273af098273 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 26 Nov 2019 17:44:21 +0100 Subject: [PATCH 118/154] Fix box of task hidden if tasks are not used --- htdocs/core/boxes/box_task.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/boxes/box_task.php b/htdocs/core/boxes/box_task.php index 193bcdae2d6..0f5a5e35225 100644 --- a/htdocs/core/boxes/box_task.php +++ b/htdocs/core/boxes/box_task.php @@ -56,7 +56,7 @@ class box_task extends ModeleBoxes */ public function __construct($db, $param = '') { - global $user, $langs; + global $conf, $user, $langs; // Load translation files required by the page $langs->loadLangs(array('boxes', 'projects')); @@ -64,7 +64,7 @@ class box_task extends ModeleBoxes $this->boxlabel = "Tasks"; $this->db = $db; - $this->hidden = !($user->rights->projet->lire); + $this->hidden = (!empty($conf->global->PROJECT_HIDE_TASKS) || !($user->rights->projet->lire)); } /** From 250b8d0b67e76d7bef4b2f36cf52bd82091b21a3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Tue, 26 Nov 2019 17:54:48 +0100 Subject: [PATCH 119/154] delete file not used --- htdocs/takepos/admin/about.php | 75 ---------------------------------- 1 file changed, 75 deletions(-) delete mode 100644 htdocs/takepos/admin/about.php diff --git a/htdocs/takepos/admin/about.php b/htdocs/takepos/admin/about.php deleted file mode 100644 index 7882ee3eb08..00000000000 --- a/htdocs/takepos/admin/about.php +++ /dev/null @@ -1,75 +0,0 @@ - - * Copyright (C) 2018 SuperAdmin - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -/** - * \file takepos/admin/about.php - * \ingroup takepos - * \brief About page of module TakePos. - */ - -require '../../main.inc.php'; // Load $user and permissions -require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; -require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; -require_once '../lib/takepos.lib.php'; - -// Translations -$langs->loadLangs(array("errors","admin","cashdesk")); - -// Access control -if (! $user->admin) { - accessforbidden(); -} - -// Parameters -$action = GETPOST('action', 'alpha'); -$backtopage = GETPOST('backtopage', 'alpha'); - - -/* - * Actions - */ - -// None - - -/* - * View - */ - -$form = new Form($db); - -$page_name = "TakePosAbout"; -llxHeader('', $langs->trans($page_name)); - -// Subheader -$linkback = ''.$langs->trans("BackToModuleList").''; - -print load_fiche_titre($langs->trans($page_name), $linkback, 'object_takepos@takepos'); - -// Configuration header -$head = takeposAdminPrepareHead(); -dol_fiche_head($head, 'about', '', 0, 'takepos@takepos'); - -dol_include_once('/takepos/core/modules/modTakePos.class.php'); -$tmpmodule = new modTakePos($db); -print $tmpmodule->getDescLong(); - -// Page end -dol_fiche_end(); -llxFooter(); -$db->close(); From 59e85d5518f552472d5435e7c15b2235893b7352 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Tue, 26 Nov 2019 17:55:33 +0100 Subject: [PATCH 120/154] Create index.html --- htdocs/takepos/admin/index.html | 1 + 1 file changed, 1 insertion(+) create mode 100644 htdocs/takepos/admin/index.html diff --git a/htdocs/takepos/admin/index.html b/htdocs/takepos/admin/index.html new file mode 100644 index 00000000000..8b137891791 --- /dev/null +++ b/htdocs/takepos/admin/index.html @@ -0,0 +1 @@ + From c7e8194df9acd9f77123b33441033f450412a2fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Tue, 26 Nov 2019 18:28:44 +0100 Subject: [PATCH 121/154] dol_print_error returns void --- htdocs/core/class/extrafields.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/class/extrafields.class.php b/htdocs/core/class/extrafields.class.php index 889a38efddb..8479db591d9 100644 --- a/htdocs/core/class/extrafields.class.php +++ b/htdocs/core/class/extrafields.class.php @@ -557,7 +557,7 @@ class ExtraFields } else { - print dol_print_error($this->db); + dol_print_error($this->db); return -1; } } @@ -813,7 +813,7 @@ class ExtraFields else { $this->db->rollback(); - print dol_print_error($this->db); + dol_print_error($this->db); return -1; } } From b104133f7a8776e15e955e15785645eb2542d946 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Tue, 26 Nov 2019 18:29:52 +0100 Subject: [PATCH 122/154] Update orderstoinvoice.php --- htdocs/fourn/commande/orderstoinvoice.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/fourn/commande/orderstoinvoice.php b/htdocs/fourn/commande/orderstoinvoice.php index 098b6b93710..2a1cf24b3b7 100644 --- a/htdocs/fourn/commande/orderstoinvoice.php +++ b/htdocs/fourn/commande/orderstoinvoice.php @@ -630,7 +630,7 @@ if (($action != 'create' && $action != 'add') && !$error) { $db->free($resql); } else { - print dol_print_error($db); + dol_print_error($db); } } From a04fa05b6ca8f0cfe93a9ac461730a84f22cf848 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Tue, 26 Nov 2019 18:41:38 +0100 Subject: [PATCH 123/154] image2wbmp() is deprecated as of PHP 7.3.0 https://www.php.net/manual/en/function.image2wbmp.php image2wbmp() is deprecated as of PHP 7.3.0, and will be removed in the next major version. Use imagewbmp() instead. --- htdocs/core/lib/images.lib.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/lib/images.lib.php b/htdocs/core/lib/images.lib.php index 4c089640915..177bad24376 100644 --- a/htdocs/core/lib/images.lib.php +++ b/htdocs/core/lib/images.lib.php @@ -281,7 +281,7 @@ function dol_imageResizeOrCrop($file, $mode, $newWidth, $newHeight, $src_x = 0, imagepng($imgThumb, $imgThumbName, $newquality); break; case 4: // Bmp - image2wbmp($imgThumb, $imgThumbName); + imagewbmp($imgThumb, $imgThumbName); break; } @@ -584,7 +584,7 @@ function vignette($file, $maxWidth = 160, $maxHeight = 120, $extName = '_small', // Not supported by PHP GD break; case IMAGETYPE_WBMP: // 15 - image2wbmp($imgThumb, $imgThumbName); + imagewbmp($imgThumb, $imgThumbName); break; } From 0357d134d52fb2c68c504706a3f45ee222286879 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Tue, 26 Nov 2019 18:46:27 +0100 Subject: [PATCH 124/154] fix missing $langs --- htdocs/supplier_proposal/class/supplier_proposal.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/supplier_proposal/class/supplier_proposal.class.php b/htdocs/supplier_proposal/class/supplier_proposal.class.php index 769f879061c..b6ff684fa7c 100644 --- a/htdocs/supplier_proposal/class/supplier_proposal.class.php +++ b/htdocs/supplier_proposal/class/supplier_proposal.class.php @@ -405,7 +405,7 @@ class SupplierProposal extends CommonObject */ public function addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1 = 0, $txlocaltax2 = 0, $fk_product = 0, $remise_percent = 0, $price_base_type = 'HT', $pu_ttc = 0, $info_bits = 0, $type = 0, $rang = -1, $special_code = 0, $fk_parent_line = 0, $fk_fournprice = 0, $pa_ht = 0, $label = '', $array_option = 0, $ref_supplier = '', $fk_unit = '', $origin = '', $origin_id = 0, $pu_ht_devise = 0, $date_start = 0, $date_end = 0) { - global $mysoc, $conf; + global $mysoc, $conf, $langs; dol_syslog(get_class($this)."::addline supplier_proposalid=$this->id, desc=$desc, pu_ht=$pu_ht, qty=$qty, txtva=$txtva, fk_product=$fk_product, remise_except=$remise_percent, price_base_type=$price_base_type, pu_ttc=$pu_ttc, info_bits=$info_bits, type=$type"); include_once DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php'; From 757d05e907c8b5e974e038d05b75b3eb7dafa1eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Tue, 26 Nov 2019 18:59:26 +0100 Subject: [PATCH 125/154] fix doxygen --- htdocs/core/lib/project.lib.php | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/htdocs/core/lib/project.lib.php b/htdocs/core/lib/project.lib.php index 875705cd8c3..58a46aef0ec 100644 --- a/htdocs/core/lib/project.lib.php +++ b/htdocs/core/lib/project.lib.php @@ -1990,11 +1990,11 @@ function print_projecttasks_array($db, $form, $socid, $projectsListId, $mytasks } /** - * @param task $task Task the task object - * @param label $label bool|string true = auto, false = dont display, string = replace output - * @param progressNumber $progressNumber bool|string true = auto, false = dont display, string = replace output - * @param hideOnProgressNull $hideOnProgressNull bool hide if progress is null - * @param spaced $spaced bool used to add space at bottom (made by css) + * @param Task $task the task object + * @param bool|string $label true = auto, false = dont display, string = replace output + * @param bool|string $progressNumber true = auto, false = dont display, string = replace output + * @param bool $hideOnProgressNull hide if progress is null + * @param bool $spaced used to add space at bottom (made by css) * @return string * @see getTaskProgressBadge() */ @@ -2113,10 +2113,10 @@ function getTaskProgressView($task, $label = true, $progressNumber = true, $hide return $out; } /** - * @param task $task Task the task object - * @param label $label string empty = auto (progress), string = replace output - * @param tooltip $tooltip string empty = auto , string = replace output - * @return string + * @param Task $task the task object + * @param string $label empty = auto (progress), string = replace output + * @param string $tooltip empty = auto , string = replace output + * @return string * @see getTaskProgressView() */ function getTaskProgressBadge($task, $label = '', $tooltip = '') From d77ad7dcbf82355649fbaf4a4ed57cd6cd6dc1a8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Tue, 26 Nov 2019 19:46:56 +0100 Subject: [PATCH 126/154] fix urlsource line 767: $reception->id = $obj->rowid; --- htdocs/reception/list.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/reception/list.php b/htdocs/reception/list.php index beadddc6397..eaf4f14bbe6 100644 --- a/htdocs/reception/list.php +++ b/htdocs/reception/list.php @@ -781,7 +781,7 @@ if ($resql) print $reception->getNomUrl(1); $filename = dol_sanitizeFileName($reception->ref); $filedir = $conf->reception->dir_output.'/'.dol_sanitizeFileName($reception->ref); - $urlsource = $_SERVER['PHP_SELF'].'?id='.$reception->rowid; + $urlsource = $_SERVER['PHP_SELF'].'?id='.$reception->id; print $formfile->getDocumentsLink($reception->element, $filename, $filedir); print "\n"; From 32aca5f1863be0cde0c4a2c6009775544935db9c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Tue, 26 Nov 2019 19:52:10 +0100 Subject: [PATCH 127/154] Update pdf_standard.class.php --- htdocs/core/modules/member/doc/pdf_standard.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/modules/member/doc/pdf_standard.class.php b/htdocs/core/modules/member/doc/pdf_standard.class.php index a2d70dc98f4..b9acf8c9c9c 100644 --- a/htdocs/core/modules/member/doc/pdf_standard.class.php +++ b/htdocs/core/modules/member/doc/pdf_standard.class.php @@ -261,7 +261,7 @@ class pdf_standard extends CommonStickerGenerator // List of values to scan for a replacement $substitutionarray = array ( - '__ID__'=>$object->rowid, + '__ID__' => $object->id, '__LOGIN__'=>$object->login, '__FIRSTNAME__'=>$object->firstname, '__LASTNAME__'=>$object->lastname, From 28b70a539929e8f87c3008b2ed75cf78418e392a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Tue, 26 Nov 2019 20:14:46 +0100 Subject: [PATCH 128/154] remove deprecated --- htdocs/product/stock/card.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/htdocs/product/stock/card.php b/htdocs/product/stock/card.php index 034e0076f09..c169c22f0a9 100644 --- a/htdocs/product/stock/card.php +++ b/htdocs/product/stock/card.php @@ -355,10 +355,10 @@ else $formconfirm = ''; - // Confirm delete third party + // Confirm delete warehouse if ($action == 'delete') { - $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$object->id, $langs->trans("DeleteAWarehouse"), $langs->trans("ConfirmDeleteWarehouse", $object->libelle), "confirm_delete", '', 0, 2); + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$object->id, $langs->trans("DeleteAWarehouse"), $langs->trans("ConfirmDeleteWarehouse", $object->label), "confirm_delete", '', 0, 2); } // Call Hook formConfirm @@ -389,10 +389,10 @@ else print ''; // Parent entrepot - $e = new Entrepot($db); - if(!empty($object->fk_parent) && $e->fetch($object->fk_parent) > 0) { + $parentwarehouse = new Entrepot($db); + if(!empty($object->fk_parent) && $parentwarehouse->fetch($object->fk_parent) > 0) { print ''; } @@ -668,7 +668,7 @@ else print '
'.$langs->trans("ParentWarehouse").''; - print $e->getNomUrl(3); + print $parentwarehouse->getNomUrl(3); print '
'; // Ref - print ''; + print ''; print ''; From 6ea204bd739d415d4e86a3dd381a20fb2a9c3642 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Tue, 26 Nov 2019 20:20:46 +0100 Subject: [PATCH 129/154] Update entrepot.class.php --- htdocs/product/stock/class/entrepot.class.php | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/htdocs/product/stock/class/entrepot.class.php b/htdocs/product/stock/class/entrepot.class.php index a8a9a3a55b8..a8a724f3575 100644 --- a/htdocs/product/stock/class/entrepot.class.php +++ b/htdocs/product/stock/class/entrepot.class.php @@ -53,9 +53,13 @@ class Entrepot extends CommonObject /** * @var string Label * @deprecated + * @see $label */ public $libelle; + /** + * @var string Label + */ public $label; /** @@ -64,6 +68,10 @@ class Entrepot extends CommonObject public $description; public $statut; + + /** + * @var string Place + */ public $lieu; /** @@ -82,11 +90,13 @@ class Entrepot extends CommonObject public $town; /** - * @var int ID + * @var int ID of parent */ public $fk_parent; - // List of short language codes for status + /** + * @var array List of short language codes for status + */ public $statuts = array(); /** From d910b05a3803fc7b398be8243bfa388cd0e6393f Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Tue, 26 Nov 2019 20:28:24 +0100 Subject: [PATCH 130/154] Look & Feel v11 --- htdocs/compta/bank/various_payment/list.php | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/htdocs/compta/bank/various_payment/list.php b/htdocs/compta/bank/various_payment/list.php index d279041e2af..7b8730ebc93 100644 --- a/htdocs/compta/bank/various_payment/list.php +++ b/htdocs/compta/bank/various_payment/list.php @@ -154,12 +154,10 @@ if ($result) if ($optioncss != '') $param.='&optioncss='.urlencode($optioncss); - $newcardbutton=''; + $newcardbutton = ''; if ($user->rights->banque->modifier) { - $newcardbutton=''.$langs->trans('MenuNewVariousPayment').''; - $newcardbutton.= ''; - $newcardbutton.= ''; + $newcardbutton .= dolGetButtonTitle($langs->trans('MenuNewVariousPayment', ($ltt + 1)), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/compta/bank/various_payment/card.php?action=create'); } print '
'; @@ -306,7 +304,7 @@ if ($result) } // Debit - print "
"; // Credit - print ""; + print '' ; + print ''; - print ""; + if (! $i) $totalarray['nbfield']++; + + print "\n"; $i++; } - $colspan = 4; - if (!empty($conf->banque->enabled)) $colspan++; - if (!empty($conf->accounting->enabled)) $colspan++; - // Show total line include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php'; From 659e3aca8e2f0924fae187befaf5d78a0905808e Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Tue, 26 Nov 2019 21:14:44 +0100 Subject: [PATCH 131/154] Look & field v11 --- htdocs/compta/sociales/list.php | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/htdocs/compta/sociales/list.php b/htdocs/compta/sociales/list.php index 1ac766a4e34..b7ee278f02c 100644 --- a/htdocs/compta/sociales/list.php +++ b/htdocs/compta/sociales/list.php @@ -171,9 +171,7 @@ if ($resql) $newcardbutton = ''; if ($user->rights->tax->charges->creer) { - $newcardbutton = ''.$langs->trans('MenuNewSocialContribution').''; - $newcardbutton .= ''; - $newcardbutton .= ''; + $newcardbutton .= dolGetButtonTitle($langs->trans('MenuNewSocialContribution'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/compta/sociales/card.php?action=create'); } print ''; @@ -267,15 +265,16 @@ if ($resql) print ''; // Ref - print ''; + print "\n"; + if (! $i) $totalarray['nbfield']++; // Label - print ''; + print "\n"; + if (! $i) $totalarray['nbfield']++; // Type - print ''; + print "\n"; + if (! $i) $totalarray['nbfield']++; // Date end period print ''; + print "\n"; + if (! $i) $totalarray['nbfield']++; // Amount - print ''; + print ''; if (! $i) $totalarray['nbfield']++; if (! $i) $totalarray['pos'][$totalarray['nbfield']]='totalttcfield'; $totalarray['val']['totalttcfield'] += $obj->amount; // Due date print ''; + if (! $i) $totalarray['nbfield']++; print ''; + if (! $i) $totalarray['nbfield']++; print ''; + if (! $i) $totalarray['nbfield']++; + print ''; $i++; } From 0f6de0049cfe1c9fa011b04d25d47b3d5b0f6a72 Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Tue, 26 Nov 2019 21:17:22 +0100 Subject: [PATCH 132/154] Fix --- htdocs/compta/bank/various_payment/list.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/compta/bank/various_payment/list.php b/htdocs/compta/bank/various_payment/list.php index 7b8730ebc93..81c2a10ba13 100644 --- a/htdocs/compta/bank/various_payment/list.php +++ b/htdocs/compta/bank/various_payment/list.php @@ -157,7 +157,7 @@ if ($result) $newcardbutton = ''; if ($user->rights->banque->modifier) { - $newcardbutton .= dolGetButtonTitle($langs->trans('MenuNewVariousPayment', ($ltt + 1)), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/compta/bank/various_payment/card.php?action=create'); + $newcardbutton .= dolGetButtonTitle($langs->trans('MenuNewVariousPayment'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/compta/bank/various_payment/card.php?action=create'); } print ''; From 27d6071a73bcde203566a1bb7d8f977efd3cf0b5 Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Tue, 26 Nov 2019 21:33:42 +0100 Subject: [PATCH 133/154] NEW add list of group and object group API --- htdocs/user/class/api_users.class.php | 110 ++++++++++++++++++++++++++ 1 file changed, 110 insertions(+) diff --git a/htdocs/user/class/api_users.class.php b/htdocs/user/class/api_users.class.php index 1fa9e971306..a155827c673 100644 --- a/htdocs/user/class/api_users.class.php +++ b/htdocs/user/class/api_users.class.php @@ -363,6 +363,116 @@ class Users extends DolibarrApi return 1; } + + /** + * List Groups + * + * Return an array with a list of Groups + * + * @url GET /groups + * + * @param string $sortfield Sort field + * @param string $sortorder Sort order + * @param int $limit Limit for list + * @param int $page Page number + * @param string $group_ids Groups ids filter field. Example: '1' or '1,2,3' {@pattern /^[0-9,]*$/i} + * @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.ref:like:'SO-%') and (t.date_creation:<:'20160101')" + * @return array Array of User objects + */ + public function listGroups($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $group_ids = 0, $sqlfilters = '') + { + global $db, $conf; + + $obj_ret = array(); + + if (!DolibarrApiAccess::$user->rights->user->group_advance->read) { + throw new RestException(401, "You are not allowed to read list of groups"); + } + + // case of external user, $societe param is ignored and replaced by user's socid + //$socid = DolibarrApiAccess::$user->socid ? DolibarrApiAccess::$user->socid : $societe; + + $sql = "SELECT t.rowid"; + $sql .= " FROM ".MAIN_DB_PREFIX."usergroup as t"; + $sql .= ' WHERE t.entity IN ('.getEntity('user').')'; + if ($group_ids) $sql .= " AND t.rowid IN (".$group_ids.")"; + // Add sql filters + if ($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).")"; + } + + $sql .= $db->order($sortfield, $sortorder); + if ($limit) { + if ($page < 0) + { + $page = 0; + } + $offset = $limit * $page; + + $sql .= $db->plimit($limit + 1, $offset); + } + + $result = $db->query($sql); + + if ($result) + { + $i = 0; + $num = $db->num_rows($result); + $min = min($num, ($limit <= 0 ? $num : $limit)); + while ($i < $min) + { + $obj = $db->fetch_object($result); + $group_static = new UserGroup($this->db); + if ($group_static->fetch($obj->rowid)) { + $obj_ret[] = $this->_cleanObjectDatas($group_static); + } + $i++; + } + } + else { + throw new RestException(503, 'Error when retrieve Group list : '.$db->lasterror()); + } + if (!count($obj_ret)) { + throw new RestException(404, 'No Group found'); + } + return $obj_ret; + } + + /** + * Get properties of an user object + * + * Return an array with group informations + * + * @url GET /groups/{id} + * + * @param int $id ID of group + * @param int $load_members Load members list or not {@min 0} {@max 1} + * @return array Array of User objects + */ + public function infoGroups($id, $load_members = 0) + { + global $db, $conf; + + if (!DolibarrApiAccess::$user->rights->user->group_advance->read) { + throw new RestException(401, "You are not allowed to read groups"); + } + + $group_static = new UserGroup($this->db); + $result = $group_static->fetch($id, '', $load_members); + + if (!$result) + { + throw new RestException(404, 'Group not found'); + } + + return $this->_cleanObjectDatas($group_static); + } /** * Delete account From bc1f9f5aaa00fb1f2a85a1f7b14af200ced070cd Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Tue, 26 Nov 2019 21:34:45 +0100 Subject: [PATCH 134/154] Update api_users.class.php --- htdocs/user/class/api_users.class.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/user/class/api_users.class.php b/htdocs/user/class/api_users.class.php index a155827c673..ab85177c6f0 100644 --- a/htdocs/user/class/api_users.class.php +++ b/htdocs/user/class/api_users.class.php @@ -449,13 +449,13 @@ class Users extends DolibarrApi * * Return an array with group informations * - * @url GET /groups/{id} + * @url GET /groups/{group} * * @param int $id ID of group * @param int $load_members Load members list or not {@min 0} {@max 1} * @return array Array of User objects */ - public function infoGroups($id, $load_members = 0) + public function infoGroups($group, $load_members = 0) { global $db, $conf; @@ -464,7 +464,7 @@ class Users extends DolibarrApi } $group_static = new UserGroup($this->db); - $result = $group_static->fetch($id, '', $load_members); + $result = $group_static->fetch($group, '', $load_members); if (!$result) { From bba4ed02d285be2e4d577e8a1f47b92bdaff14b2 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Tue, 26 Nov 2019 20:36:30 +0000 Subject: [PATCH 135/154] Fixing style errors. --- htdocs/user/class/api_users.class.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/htdocs/user/class/api_users.class.php b/htdocs/user/class/api_users.class.php index ab85177c6f0..761638f007b 100644 --- a/htdocs/user/class/api_users.class.php +++ b/htdocs/user/class/api_users.class.php @@ -363,12 +363,12 @@ class Users extends DolibarrApi return 1; } - + /** * List Groups * * Return an array with a list of Groups - * + * * @url GET /groups * * @param string $sortfield Sort field @@ -443,12 +443,12 @@ class Users extends DolibarrApi } return $obj_ret; } - + /** * Get properties of an user object * * Return an array with group informations - * + * * @url GET /groups/{group} * * @param int $id ID of group @@ -464,13 +464,13 @@ class Users extends DolibarrApi } $group_static = new UserGroup($this->db); - $result = $group_static->fetch($group, '', $load_members); + $result = $group_static->fetch($group, '', $load_members); if (!$result) { throw new RestException(404, 'Group not found'); } - + return $this->_cleanObjectDatas($group_static); } From aa3b6533f11a90518285ef549250e4a56d8550d7 Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Wed, 27 Nov 2019 02:45:43 +0100 Subject: [PATCH 136/154] Look & Feel v11 --- htdocs/salaries/list.php | 38 +++++++++++++++++++++++++------------- 1 file changed, 25 insertions(+), 13 deletions(-) diff --git a/htdocs/salaries/list.php b/htdocs/salaries/list.php index 51fd8462180..e9014e423c6 100644 --- a/htdocs/salaries/list.php +++ b/htdocs/salaries/list.php @@ -150,9 +150,7 @@ if ($result) $newcardbutton=''; if (! empty($user->rights->salaries->write)) { - $newcardbutton=''.$langs->trans('NewSalaryPayment').''; - $newcardbutton.= ''; - $newcardbutton.= ''; + $newcardbutton .= dolGetButtonTitle($langs->trans('NewSalaryPayment'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/salaries/card.php?action=create'); } print ''; @@ -234,14 +232,24 @@ if ($result) // Ref print "\n"; + if (! $i) $totalarray['nbfield']++; + // Employee print "\n"; + if (! $i) $totalarray['nbfield']++; + // Label payment print "\n"; + if (! $i) $totalarray['nbfield']++; + // Date payment print '\n"; + if (! $i) $totalarray['nbfield']++; + // Type print ''; + if (! $i) $totalarray['nbfield']++; + // Account if (! empty($conf->banque->enabled)) { @@ -267,22 +275,26 @@ if ($result) } else print ' '; print ''; + if (! $i) $totalarray['nbfield']++; } - // Amount - print ''; - print ''; - print "\n"; - $total = $total + $obj->amount; + // Amount + print ''; + if (! $i) $totalarray['nbfield']++; + if (! $i) $totalarray['pos'][$totalarray['nbfield']]='totalttcfield'; + $totalarray['val']['totalttcfield'] += $obj->amount; + + print ''; + + if (! $i) $totalarray['nbfield']++; + + print "\n"; $i++; } - $colspan=5; - if (! empty($conf->banque->enabled)) $colspan++; - print ''; - print '"; - print ""; + // Show total line + include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php'; print "
'.$langs->trans("Ref").'
'.$langs->trans("Ref").'
'.$langs->trans("LocationSummary").'
"; + print ''; if ($obj->sens == 0) { print price($obj->amount); @@ -317,7 +315,7 @@ if ($result) print ""; + print ''; if ($obj->sens == 1) { print price($obj->amount); @@ -325,17 +323,16 @@ if ($result) } if (! $i) $totalarray['nbfield']++; if (! $i) $totalarray['pos'][$totalarray['nbfield']]='total_cred'; - print "
'; - print $chargesociale_static->getNomUrl(1, '20'); - print '".$chargesociale_static->getNomUrl(1, '20')."'.dol_trunc($obj->label, 42).'".dol_trunc($obj->label, 42)."'.$obj->type_label.'".$obj->type_label."'; @@ -287,21 +286,26 @@ if ($resql) { print ' '; } - print ''.price($obj->amount).''.price($obj->amount).''.dol_print_date($db->jdate($obj->date_ech), 'day').''.$chargesociale_static->LibStatut($obj->paye, 5, $obj->alreadypayed).'
".$salstatic->getNomUrl(1)."".$userstatic->getNomUrl(1)."".dol_trunc($obj->label, 40)."'.dol_print_date($db->jdate($obj->datep), 'day')."'.$langs->trans("PaymentTypeShort".$obj->payment_code).' '.$obj->num_payment.''.price($obj->amount).'
'.price($obj->amount).'
'.$langs->trans("Total").''.price($total)."
"; print '
'; From 9a9a43fc4dbb800bc57da0080a55485be23ccc4b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 27 Nov 2019 11:34:10 +0100 Subject: [PATCH 137/154] Return OS with ping --- htdocs/core/lib/functions2.lib.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/htdocs/core/lib/functions2.lib.php b/htdocs/core/lib/functions2.lib.php index 12d9b06fee6..cd636d02e9c 100644 --- a/htdocs/core/lib/functions2.lib.php +++ b/htdocs/core/lib/functions2.lib.php @@ -1564,11 +1564,13 @@ function dol_print_reduction($reduction, $langs) * Return OS version. * Note that PHP_OS returns only OS (not version) and OS PHP was built on, not necessarly OS PHP runs on. * - * @return string OS version + * @param string $option Option string + * @return string OS version */ -function version_os() +function version_os($option = '') { - $osversion = php_uname(); + if ($option) $osversion = php_uname($option); + else $osversion = php_uname(); return $osversion; } From c22fea52e54f29b43c9c683f20ef00eef9d38296 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 27 Nov 2019 11:38:30 +0100 Subject: [PATCH 138/154] Fix do not ping name of server --- htdocs/admin/system/os.php | 4 ++-- htdocs/core/lib/functions2.lib.php | 2 +- htdocs/main.inc.php | 6 +++++- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/htdocs/admin/system/os.php b/htdocs/admin/system/os.php index 7399a218e9c..d171fcaa2ec 100644 --- a/htdocs/admin/system/os.php +++ b/htdocs/admin/system/os.php @@ -42,11 +42,11 @@ print ''.$langs->trans("Parameter").''.$lan print "\n"; // Recupere l'OS au sens PHP -print "".$langs->trans("PHP_OS")."".PHP_OS."\n"; +print ''.$langs->trans("PHP_OS")."".PHP_OS."\n"; // Recupere la version de l'OS $osversion=version_os(); -print "".$langs->trans("Version")."".$osversion."\n"; +print ''.$langs->trans("Version")."".$osversion."\n"; print ''; // End of page diff --git a/htdocs/core/lib/functions2.lib.php b/htdocs/core/lib/functions2.lib.php index cd636d02e9c..0356ecc8b23 100644 --- a/htdocs/core/lib/functions2.lib.php +++ b/htdocs/core/lib/functions2.lib.php @@ -1569,7 +1569,7 @@ function dol_print_reduction($reduction, $langs) */ function version_os($option = '') { - if ($option) $osversion = php_uname($option); + if ($option == 'smr') $osversion = php_uname('s').' '.php_uname('m').' '.php_uname('r'); else $osversion = php_uname(); return $osversion; } diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index 6b17bb6f947..938f4411b57 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -2551,6 +2551,7 @@ if (!function_exists("llxFooter")) print ''."\n"; // Add code for the asynchronous anonymous first ping (for telemetry) + // You can use &forceping=1 in parameters to force the ping. if (($_SERVER["PHP_SELF"] == DOL_URL_ROOT.'/index.php') || GETPOST('forceping', 'alpha')) { //print ''; @@ -2560,6 +2561,8 @@ if (!function_exists("llxFooter")) { if (empty($_COOKIE['DOLINSTALLNOPING_'.md5($conf->file->instance_unique_id)])) { + include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; + print "\n".''."\n"; print "\n\n"; $hash_unique_id = md5('dolibarr'.$conf->file->instance_unique_id); @@ -2580,7 +2583,8 @@ if (!function_exists("llxFooter")) entity: "entity; ?>", dbtype: "type); ?>", country_code: "country_code); ?>", - php_version: "" + php_version: "", + os_version: "" }, success: function (data, status, xhr) { // success callback function (data contains body of response) console.log("Ping ok"); From 723222ec8f30245b26fcad96c2ec47dd6aa324de Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 27 Nov 2019 13:58:24 +0100 Subject: [PATCH 139/154] Prepare v11 - Add CHANGELOG --- ChangeLog | 179 +++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 178 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 6fdbcfcd899..6258b36e084 100644 --- a/ChangeLog +++ b/ChangeLog @@ -6,9 +6,184 @@ English Dolibarr ChangeLog ***** ChangeLog for 11.0.0 compared to 10.0.0 ***** For Users: +NEW: Module BOM is now stable (Module MO - Manufacturing Order is still in development). +NEW: A nicer dashboard for opened elements on Home page. +NEW: Add task widget and add task progress bar +NEW: Accountancy - Can add specific widget in this accountancy area. +NEW: Accountancy - Add export model LDCompta V9 & higher +NEW: Accountancy - Add permission on export, delete operations in ledger +NEW: Add 2 hidden options to set the default sorting (sort and order) on document page. +NEW: add ability to edit price without tax before adding a line of a predefined product. +NEW: Add a tab to setup "Opening hours" of company (information only). +NEW: Add attendee to ical export + cleanup. +NEW: Add bank data of users into the expense report exports. +NEW: add clone customers prices in clone product or service. +NEW: Add column of module source and POS terminal in the invoice list. +NEW: Add column last modification date into the table of targets for emailing. +NEW: Add column VAT rate in product list +NEW: add constant DISPATCH_FORCE_QTY_INPUT +NEW: Add constant MAIN_DISABLE_GLOBAL_WORKBOARD to disable workboard in home page +NEW: add country code in import product model +NEW: Add 'Direct Cash Payment' button in TakePOS +NEW: Add odt support to supplier orders +NEW: Add experimental SumUp payment to TakePOS (need to set a hidden constant) +NEW: Add feature to search a string into website containers +NEW: Add GET and POST /supplierinvoices/payments REST API endpoints. +NEW: Show progress bar for declared progression of tasks. +NEW: Add hidden option to update supplier buying price during receptions. +NEW: Add hidden option PROPOSAL_SHOW_INVOICED_AMOUNT (not reliable if one invoice is done on several order or several proposal) +NEW: Add hidden option SUPPLIER_ORDER_CAN_UPDATE_BUYINGPRICE_DURING_RECEIPT for add possibility to update supplier buying price in the reception on a supplier order +NEW: Add hidden option THIRDPARTY_PROPAGATE_EXTRAFIELDS_TO_ORDER to copy extrafields from third party to order. +NEW: Add hidden options to send by email even for object with draft status. +NEW: Add last change date in page "Other setup". Can sort page on name/date. +NEW: Add link to export targets of an emailings into a CSV file. +NEW: Add link to the public interface on the ticket card. +NEW: Add location into event tooltip. Use full day for fullday events +NEW: add MAIN_LANGUAGES_ALLOWED constant to limit languages displayed. +NEW: add MAIN_SHOW_COMPANY_NAME_IN_BANNER_ADDRESS constant. +NEW: add mass actions in shipment list. +NEW: add minimum stock filter in load warehoues for product form. +NEW: add name_alias in fields to search all +NEW: add new rule fetchidfromcodeandlabel for categories import +NEW: add office phone for salespresentatives +NEW: add office phone & job on user tooltips +NEW: Add option MAIN_PDF_FORCE_FONT_SIZE +NEW: Add option MEMBER_CAN_CONVERT_CUSTOMERS_TO_MEMBERS +NEW: Add option multiselect for developers on the selector of language. +NEW: Add option WORKFLOW_CAN_CREATE_PURCHASE_ORDER_FROM_PROPOSAL +NEW: Add pagination on list of object of a category +NEW: add parent category id or label in import category module +NEW: add parent id or ref column in warehouse import +NEW: Can set the Address/Contact by default on third parties. +NEW: Add search into template +NEW: Add shipment widget +NEW: add socialnetworks dictionary +NEW: Add statistics on product into contracts +NEW: Add status of warehouse in tooltip of a warehouse. +NEW: add supplier's product list +NEW: add units fields in buying price tab of product card +NEW: Add units in select products lines +NEW: Add upload document on account statement +NEW: Add widgets for BOMs and MOs +NEW: Amount invoiced column in proposal list +NEW: Ask the new label and new dates in confirm popup when cloning tax +NEW: auto set closing date and user on invoice +NEW: Avoid wrap between picto and text on getNomUrl +NEW: Balance Stripe connect account for supplier +NEW: Bank Add an option for colorize background color of debit or credit movement +NEW: Beautify the select box of warehouses +NEW: birthday widget for member +NEW: Widgets uses fiscal year +NEW: Can change supplier when cloning a Purchase Order +NEW: can choose lines while creating order from origin +NEW: Can crop/resize image attached on a bank record +NEW: Can defined a position of numbering submodules for thirdparties +NEW: Can edit date or RUM mandate. +NEW: Can edit link to the translation page in website module +NEW: Can edit the price of predefined product during adding in documents +NEW: Can enter price tax incl on vendor proposal and purchase orders +NEW: Can filter on description on bank account transaction lists. +NEW: Can filter on label on invoice in accounting vendor binding pages +NEW: Can load multilang translation in same step than fetch_lines +NEW: Can restrict access using DAV module to some host IPs only +NEW: Can restrict API usage to some IP only +NEW: Can select website templates from available default templates with a preview. +NEW: Can set a filter on object linked in modulebuilder. +NEW: Can set a squarred icon on your company setup +NEW: can specify hour start end for selectDate and step for minutes +NEW: Categories/Tags are also available on warehouses +NEW: Check if a resource is in use in an event +NEW: Code for extrafields uses the new array $extrafields->attributes +NEW: Compute column value from others columns in import module +NEW: Copy linked categories on product clone process. +NEW: Default for Stripe is STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION +NEW: Digitaria model for numbering accountancy thirdparty +NEW: Display membership in takepos if member linked to the thirdparty +NEW: Display supplier in objectline if defined +NEW: Add default duration of subscriptions on members type +NEW: Email template for Takepos (to send invoice) +NEW: Expense request and holiday validator fields +NEW: Export ledger table in Charlemagne format +NEW: Export livre Charlemagne +NEW: Extend option ORDER_ADD_ORDERS_WITH_PARENT_PROD_IF_INCDEC for all virtual product stats (renamed into PRODUCT_STATS_WITH_PARENT_PROD_IF_INCDEC) +NEW: FCKeditor setup for tickets +NEW: GeoIP v2 support is natively provided -> So IPv6 is supported +NEW: List by closing date on order list and proposal list +NEW: Look and feel v11: Some setup pages are by default direclty in edit mode. +NEW: Management of retained warranty on situation invoices +NEW: Mass email action on invoice list use billing contact if exists +NEW: more living colors for charts and option for "color bind" people +NEW: Supports multiple payments in a TakePOS sale +NEW: multiselect with checkbox in categories/tags search for product list +NEW: Option to allow to create members from third-party +NEW: Platform compliance with Stripe Connect +NEW: print / send email form in TakePOS +NEW: Public holidays are now in a dictionary table (no more hard coded per country) +NEW: Better performance by reducing the $companystatic calls on some pages. +NEW: Replace the "info" tab on contract with the more complete "agenda" tab. +NEW: Save user of last modification in donation record. +NEW: Show html combo list instead input text for extrafields typed as list. +NEW: Show POS application and the terminal used on invoice card. +NEW: Add categories/tags for stocks. +NEW: Support Net Measure in product's card.php +NEW: Extrafields separator can be collapsed or not +NEW: Extrafields support on Leave requests. +NEW: Extrafields support on Salaries. +NEW: Extrafields support in Product supplier prices. +NEW: Add extrafields for warehouses +NEW: Add extrafields in export of expense report (and holiday) +NEW: The integrity checker now show also the expected size of files. +NEW: The order method in purchase order is now mandatory when recording an order. +NEW: update / delete stripe account for supplier +NEW: Use the gender of member for picto in member lists. +NEW: Use the squarre logo as favicon of pages +NEW: VAT list - Add date start & date end in filters +NEW: widget box for supplier orders awaiting reception +NEW: Update translations +NEW: #4301 -For Developers: +For Developers or integrators: +NEW: Add a manifest.json.php file for web app. +NEW: Removed deprecated code that create linked object from ->origin +NEW: experimental zapier for dolibarr +NEW: Accountancy - Add hook bookkeepinglist on general ledger +NEW: Can update product type with the update method. +NEW: add API shipment mode dictionnary +NEW: Add API to get Country by code and iso +NEW: Add API to get objects by ref, ref_ext, ... +NEW: Add anonymous telemetry +NEW: Add a category to a contact in API +NEW: Add fk projet on stock movement +NEW: Add hidden option to set fields for the quick search on products. +NEW: add hook on commongeneratedocument +NEW: Add hook on fileupload.class.php to enable modules to override… +NEW: Add hooks on index pages +NEW: adding 'formObjectOptions' hooks loading at card.php of adherents module +NEW: Add method getStructuredData for website +NEW: Add payments GET and POST REST API endpoints for supplierinvoices. +NEW: Add POST /bankaccounts/transfer REST API endpoint. +NEW: add "printBucktrackInfo" hook, an external module can add info +NEW: Add trigger DIRECT_DEBIT_ORDER_CREATE on widthdraw is missing +NEW: API to post documents for "product" and Delete document +NEW: add new function "setEntity()" and better compatibility with Multicompany +NEW: Can add a button "Create" after combo of object with modulebuilder. +NEW: contacts type dictionnary in api_setup.class.php +NEW: Look and feel v11: Introduce CSS "trforbreak" +NEW: list of measuring units API +NEW: get social networks dictionary by API +NEW: Get thirdparty's salesrepresentatives by API +NEW: get user connected informations in REST API +NEW: mode for list thirdparty API (add easy filter for supplier only) +NEW: purchase_prices API +NEW: Provides more complete demo data +NEW: Module builder can generate CSS of JS file. +NEW: Use a dedicated css for the pencil to edit a field. +NEW: multilangs in fetch_lines +NEW: Add more complete info for triggers actioncom +NEW: add multicurrency rate at currency list API +NEW: Update jquery library to 3.4.1 +NEW: Upgrade ACE editor to v1.4.6 WARNING: @@ -31,6 +206,8 @@ Following changes may create regressions for some external modules, but were nec * Renamed property of thirdparty "statut_commercial" into "status_prospect_label" * The jquery plugin/dependency multiselect has been removed. It was not used by Dolibarr core. + + ***** ChangeLog for 10.0.3 compared to 10.0.2 ***** IMPORTANT : This version fixes a serious bug in saving the units of weight, size, surface and volume on product card. The unit were not saved correctly in database making calculation on shipments wrong. From 825349e07e8815e3e0f6a3ec070fbcb6b22abf61 Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Wed, 27 Nov 2019 16:04:52 +0100 Subject: [PATCH 140/154] Update api_users.class.php --- htdocs/user/class/api_users.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/user/class/api_users.class.php b/htdocs/user/class/api_users.class.php index 761638f007b..be768a3e15a 100644 --- a/htdocs/user/class/api_users.class.php +++ b/htdocs/user/class/api_users.class.php @@ -445,13 +445,13 @@ class Users extends DolibarrApi } /** - * Get properties of an user object + * Get properties of an group object * * Return an array with group informations * * @url GET /groups/{group} * - * @param int $id ID of group + * @param int $group ID of group * @param int $load_members Load members list or not {@min 0} {@max 1} * @return array Array of User objects */ From 5f99e25c45d619f1e3a5174bf2035d516b1d4228 Mon Sep 17 00:00:00 2001 From: Scrutinizer Auto-Fixer Date: Thu, 28 Nov 2019 11:36:20 +0000 Subject: [PATCH 141/154] Scrutinizer Auto-Fixes This commit consists of patches automatically generated for this project on https://scrutinizer-ci.com --- htdocs/admin/emailcollector_card.php | 2 +- htdocs/admin/expensereport_rules.php | 28 +- htdocs/admin/mails.php | 236 +++++------ htdocs/bom/bom_agenda.php | 16 +- htdocs/bom/bom_card.php | 10 +- htdocs/comm/remx.php | 8 +- htdocs/compta/bank/graph.php | 382 +++++++++--------- htdocs/core/boxes/box_shipments.php | 56 +-- .../core/class/emailsenderprofile.class.php | 38 +- htdocs/core/class/events.class.php | 144 +++---- htdocs/core/class/html.formcron.class.php | 42 +- htdocs/core/lib/functions.lib.php | 80 ++-- htdocs/core/modules/modExpedition.class.php | 140 +++---- htdocs/main.inc.php | 78 ++-- htdocs/mrp/mo_agenda.php | 80 ++-- htdocs/product/class/api_products.class.php | 186 ++++----- htdocs/product/inventory/inventory.php | 58 +-- htdocs/takepos/admin/setup.php | 20 +- htdocs/takepos/admin/terminal.php | 74 ++-- htdocs/takepos/pay.php | 66 +-- htdocs/takepos/smpcb.php | 4 +- htdocs/zapier/hook_agenda.php | 16 +- 22 files changed, 882 insertions(+), 882 deletions(-) diff --git a/htdocs/admin/emailcollector_card.php b/htdocs/admin/emailcollector_card.php index 6bd27da529b..804c2a37a6f 100644 --- a/htdocs/admin/emailcollector_card.php +++ b/htdocs/admin/emailcollector_card.php @@ -431,7 +431,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea $connection = imap_open($connectstringsource, $object->login, $object->password); } - catch(Exception $e) + catch (Exception $e) { print $e->getMessage(); } diff --git a/htdocs/admin/expensereport_rules.php b/htdocs/admin/expensereport_rules.php index 6a719c25b5f..becf50fa7a2 100644 --- a/htdocs/admin/expensereport_rules.php +++ b/htdocs/admin/expensereport_rules.php @@ -32,7 +32,7 @@ require_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport.class.php'; require_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport_rule.class.php'; // Load translation files required by the page -$langs->loadLangs(array("admin","other","trips","errors","dict")); +$langs->loadLangs(array("admin", "other", "trips", "errors", "dict")); if (!$user->admin) accessforbidden(); @@ -96,18 +96,18 @@ if ($action == 'save') { $object->setValues($_POST); - if($apply_to=='U'){ + if ($apply_to == 'U') { $object->fk_user = (int) $fk_user; - $object->fk_usergroup=0; - $object->is_for_all=0; - }elseif($apply_to=='G'){ + $object->fk_usergroup = 0; + $object->is_for_all = 0; + }elseif ($apply_to == 'G') { $object->fk_usergroup = (int) $fk_usergroup; - $object->fk_user=0; - $object->is_for_all=0; - }elseif($apply_to=='A'){ - $object->is_for_all=1; - $object->fk_user=0; - $object->fk_usergroup=0; + $object->fk_user = 0; + $object->is_for_all = 0; + }elseif ($apply_to == 'A') { + $object->is_for_all = 1; + $object->fk_user = 0; + $object->fk_usergroup = 0; } $object->dates = $dates; @@ -145,12 +145,12 @@ $tab_rules_type = array('EX_DAY' => $langs->trans('Day'), 'EX_MON' => $langs->tr llxHeader('', $langs->trans("ExpenseReportsSetup")); -$form=new Form($db); +$form = new Form($db); -$linkback=''.$langs->trans("BackToModuleList").''; +$linkback = ''.$langs->trans("BackToModuleList").''; print load_fiche_titre($langs->trans("ExpenseReportsRulesSetup"), $linkback, 'title_setup'); -$head=expensereport_admin_prepare_head(); +$head = expensereport_admin_prepare_head(); dol_fiche_head($head, 'expenserules', $langs->trans("ExpenseReportsRules"), -1, 'trip'); echo $langs->trans('ExpenseReportRulesDesc'); diff --git a/htdocs/admin/mails.php b/htdocs/admin/mails.php index 5f59a198fa4..fb76c3c0676 100644 --- a/htdocs/admin/mails.php +++ b/htdocs/admin/mails.php @@ -30,23 +30,23 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; // Load translation files required by the page $langs->loadLangs(array("companies", "products", "admin", "mails", "other", "errors")); -$action=GETPOST('action', 'alpha'); +$action = GETPOST('action', 'alpha'); -if (! $user->admin) accessforbidden(); +if (!$user->admin) accessforbidden(); -$usersignature=$user->signature; +$usersignature = $user->signature; // For action = test or send, we ensure that content is not html, even for signature, because this we want a test with NO html. if ($action == 'test' || $action == 'send') { - $usersignature=dol_string_nohtmltag($usersignature); + $usersignature = dol_string_nohtmltag($usersignature); } -$substitutionarrayfortest=array( +$substitutionarrayfortest = array( '__DOL_MAIN_URL_ROOT__'=>DOL_MAIN_URL_ROOT, '__ID__' => 'RecipientIdRecord', //'__EMAIL__' => 'RecipientEMail', // Done into actions_sendmails -'__CHECK_READ__' => (is_object($object) && is_object($object->thirdparty))?'':'', -'__USER_SIGNATURE__' => (($user->signature && empty($conf->global->MAIN_MAIL_DO_NOT_USE_SIGN))?$usersignature:''), // Done into actions_sendmails +'__CHECK_READ__' => (is_object($object) && is_object($object->thirdparty)) ? '' : '', +'__USER_SIGNATURE__' => (($user->signature && empty($conf->global->MAIN_MAIL_DO_NOT_USE_SIGN)) ? $usersignature : ''), // Done into actions_sendmails '__LOGIN__' => 'RecipientLogin', '__LASTNAME__' => 'RecipientLastname', '__FIRSTNAME__' => 'RecipientFirstname', @@ -93,16 +93,16 @@ if ($action == 'update' && empty($_POST["cancel"])) // Actions to send emails -$id=0; -$actiontypecode=''; // Not an event for agenda -$trigger_name=''; // Disable triggers -$paramname='id'; -$mode='emailfortest'; -$trackid=(($action == 'testhtml')?"testhtml":"test"); +$id = 0; +$actiontypecode = ''; // Not an event for agenda +$trigger_name = ''; // Disable triggers +$paramname = 'id'; +$mode = 'emailfortest'; +$trackid = (($action == 'testhtml') ? "testhtml" : "test"); include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php'; -if ($action == 'presend' && GETPOST('trackid', 'alphanohtml') == 'test') $action='test'; -if ($action == 'presend' && GETPOST('trackid', 'alphanohtml') == 'testhtml') $action='testhtml'; +if ($action == 'presend' && GETPOST('trackid', 'alphanohtml') == 'test') $action = 'test'; +if ($action == 'presend' && GETPOST('trackid', 'alphanohtml') == 'testhtml') $action = 'testhtml'; @@ -113,18 +113,18 @@ if ($action == 'presend' && GETPOST('trackid', 'alphanohtml') == 'testhtml') $ $form = new Form($db); -$linuxlike=1; -if (preg_match('/^win/i', PHP_OS)) $linuxlike=0; -if (preg_match('/^mac/i', PHP_OS)) $linuxlike=0; +$linuxlike = 1; +if (preg_match('/^win/i', PHP_OS)) $linuxlike = 0; +if (preg_match('/^mac/i', PHP_OS)) $linuxlike = 0; -if (empty($conf->global->MAIN_MAIL_SENDMODE)) $conf->global->MAIN_MAIL_SENDMODE='mail'; -$port=! empty($conf->global->MAIN_MAIL_SMTP_PORT)?$conf->global->MAIN_MAIL_SMTP_PORT:ini_get('smtp_port'); -if (! $port) $port=25; -$server=! empty($conf->global->MAIN_MAIL_SMTP_SERVER)?$conf->global->MAIN_MAIL_SMTP_SERVER:ini_get('SMTP'); -if (! $server) $server='127.0.0.1'; +if (empty($conf->global->MAIN_MAIL_SENDMODE)) $conf->global->MAIN_MAIL_SENDMODE = 'mail'; +$port = !empty($conf->global->MAIN_MAIL_SMTP_PORT) ? $conf->global->MAIN_MAIL_SMTP_PORT : ini_get('smtp_port'); +if (!$port) $port = 25; +$server = !empty($conf->global->MAIN_MAIL_SMTP_SERVER) ? $conf->global->MAIN_MAIL_SMTP_SERVER : ini_get('SMTP'); +if (!$server) $server = '127.0.0.1'; -$wikihelp='EN:Setup_EMails|FR:Paramétrage_EMails|ES:Configuración_EMails'; +$wikihelp = 'EN:Setup_EMails|FR:Paramétrage_EMails|ES:Configuración_EMails'; llxHeader('', $langs->trans("Setup"), $wikihelp); print load_fiche_titre($langs->trans("EMailsSetup"), '', 'title_setup'); @@ -132,11 +132,11 @@ print load_fiche_titre($langs->trans("EMailsSetup"), '', 'title_setup'); $head = email_admin_prepare_head(); // List of sending methods -$listofmethods=array(); -$listofmethods['mail']='PHP mail function'; +$listofmethods = array(); +$listofmethods['mail'] = 'PHP mail function'; //$listofmethods['simplemail']='Simplemail class'; -$listofmethods['smtps']='SMTP/SMTPS socket library'; -$listofmethods['swiftmailer']='Swift Mailer socket library'; +$listofmethods['smtps'] = 'SMTP/SMTPS socket library'; +$listofmethods['swiftmailer'] = 'Swift Mailer socket library'; if ($action == 'edit') @@ -267,7 +267,7 @@ if ($action == 'edit') // Force e-mail recipient print ''.$langs->trans("MAIN_MAIL_FORCE_SENDTO").''; - print ''; + print ''; print ''; @@ -299,7 +299,7 @@ if ($action == 'edit') // Host server print ''; - if (! $conf->use_javascript_ajax && $linuxlike && $conf->global->MAIN_MAIL_SENDMODE == 'mail') + if (!$conf->use_javascript_ajax && $linuxlike && $conf->global->MAIN_MAIL_SENDMODE == 'mail') { print $langs->trans("MAIN_MAIL_SMTP_SERVER_NotAvailableOnLinuxLike"); print ''; @@ -307,21 +307,21 @@ if ($action == 'edit') } else { - $mainserver = (! empty($conf->global->MAIN_MAIL_SMTP_SERVER)?$conf->global->MAIN_MAIL_SMTP_SERVER:''); - $smtpserver = ini_get('SMTP')?ini_get('SMTP'):$langs->transnoentities("Undefined"); + $mainserver = (!empty($conf->global->MAIN_MAIL_SMTP_SERVER) ? $conf->global->MAIN_MAIL_SMTP_SERVER : ''); + $smtpserver = ini_get('SMTP') ?ini_get('SMTP') : $langs->transnoentities("Undefined"); if ($linuxlike) print $langs->trans("MAIN_MAIL_SMTP_SERVER_NotAvailableOnLinuxLike"); else print $langs->trans("MAIN_MAIL_SMTP_SERVER", $smtpserver); print ''; // SuperAdministrator access only - if (empty($conf->multicompany->enabled) || ($user->admin && ! $user->entity)) + if (empty($conf->multicompany->enabled) || ($user->admin && !$user->entity)) { - print ''; - print ''; + print ''; + print ''; print ''.$langs->trans("SeeLocalSendMailSetup").''; } else { - $text = ! empty($mainserver) ? $mainserver : $smtpserver; + $text = !empty($mainserver) ? $mainserver : $smtpserver; $htmltext = $langs->trans("ContactSuperAdminForChange"); print $form->textwithpicto($text, $htmltext, 1, 'superadmin'); print ''; @@ -331,7 +331,7 @@ if ($action == 'edit') // Port print ''; - if (! $conf->use_javascript_ajax && $linuxlike && $conf->global->MAIN_MAIL_SENDMODE == 'mail') + if (!$conf->use_javascript_ajax && $linuxlike && $conf->global->MAIN_MAIL_SENDMODE == 'mail') { print $langs->trans("MAIN_MAIL_SMTP_PORT_NotAvailableOnLinuxLike"); print ''; @@ -339,21 +339,21 @@ if ($action == 'edit') } else { - $mainport = (! empty($conf->global->MAIN_MAIL_SMTP_PORT) ? $conf->global->MAIN_MAIL_SMTP_PORT : ''); - $smtpport = ini_get('smtp_port')?ini_get('smtp_port'):$langs->transnoentities("Undefined"); + $mainport = (!empty($conf->global->MAIN_MAIL_SMTP_PORT) ? $conf->global->MAIN_MAIL_SMTP_PORT : ''); + $smtpport = ini_get('smtp_port') ?ini_get('smtp_port') : $langs->transnoentities("Undefined"); if ($linuxlike) print $langs->trans("MAIN_MAIL_SMTP_PORT_NotAvailableOnLinuxLike"); else print $langs->trans("MAIN_MAIL_SMTP_PORT", $smtpport); print ''; // SuperAdministrator access only - if (empty($conf->multicompany->enabled) || ($user->admin && ! $user->entity)) + if (empty($conf->multicompany->enabled) || ($user->admin && !$user->entity)) { - print ''; - print ''; + print ''; + print ''; print ''.$langs->trans("SeeLocalSendMailSetup").''; } else { - $text = (! empty($mainport) ? $mainport : $smtpport); + $text = (!empty($mainport) ? $mainport : $smtpport); $htmltext = $langs->trans("ContactSuperAdminForChange"); print $form->textwithpicto($text, $htmltext, 1, 'superadmin'); print ''; @@ -362,14 +362,14 @@ if ($action == 'edit') print ''; // ID - if (! empty($conf->use_javascript_ajax) || (isset($conf->global->MAIN_MAIL_SENDMODE) && in_array($conf->global->MAIN_MAIL_SENDMODE, array('smtps', 'swiftmailer')))) + if (!empty($conf->use_javascript_ajax) || (isset($conf->global->MAIN_MAIL_SENDMODE) && in_array($conf->global->MAIN_MAIL_SENDMODE, array('smtps', 'swiftmailer')))) { - $mainstmpid=(! empty($conf->global->MAIN_MAIL_SMTPS_ID)?$conf->global->MAIN_MAIL_SMTPS_ID:''); + $mainstmpid = (!empty($conf->global->MAIN_MAIL_SMTPS_ID) ? $conf->global->MAIN_MAIL_SMTPS_ID : ''); print ''.$langs->trans("MAIN_MAIL_SMTPS_ID").''; // SuperAdministrator access only if (empty($conf->multicompany->enabled) || ($user->admin && !$user->entity)) { - print ''; + print ''; } else { @@ -381,16 +381,16 @@ if ($action == 'edit') } // PW - if (! empty($conf->use_javascript_ajax) || (isset($conf->global->MAIN_MAIL_SENDMODE) && in_array($conf->global->MAIN_MAIL_SENDMODE, array('smtps', 'swiftmailer')))) + if (!empty($conf->use_javascript_ajax) || (isset($conf->global->MAIN_MAIL_SENDMODE) && in_array($conf->global->MAIN_MAIL_SENDMODE, array('smtps', 'swiftmailer')))) { - $mainsmtppw=(! empty($conf->global->MAIN_MAIL_SMTPS_PW)?$conf->global->MAIN_MAIL_SMTPS_PW:''); + $mainsmtppw = (!empty($conf->global->MAIN_MAIL_SMTPS_PW) ? $conf->global->MAIN_MAIL_SMTPS_PW : ''); print ''; print $form->textwithpicto($langs->trans("MAIN_MAIL_SMTPS_PW"), $langs->trans("WithGMailYouCanCreateADedicatedPassword")); print ''; // SuperAdministrator access only if (empty($conf->multicompany->enabled) || ($user->admin && !$user->entity)) { - print ''; + print ''; } else { @@ -403,11 +403,11 @@ if ($action == 'edit') // TLS print ''.$langs->trans("MAIN_MAIL_EMAIL_TLS").''; - if (! empty($conf->use_javascript_ajax) || (isset($conf->global->MAIN_MAIL_SENDMODE) && in_array($conf->global->MAIN_MAIL_SENDMODE, array('smtps', 'swiftmailer')))) + if (!empty($conf->use_javascript_ajax) || (isset($conf->global->MAIN_MAIL_SENDMODE) && in_array($conf->global->MAIN_MAIL_SENDMODE, array('smtps', 'swiftmailer')))) { if (function_exists('openssl_open')) { - print $form->selectyesno('MAIN_MAIL_EMAIL_TLS', (! empty($conf->global->MAIN_MAIL_EMAIL_TLS)?$conf->global->MAIN_MAIL_EMAIL_TLS:0), 1); + print $form->selectyesno('MAIN_MAIL_EMAIL_TLS', (!empty($conf->global->MAIN_MAIL_EMAIL_TLS) ? $conf->global->MAIN_MAIL_EMAIL_TLS : 0), 1); } else print yn(0).' ('.$langs->trans("YourPHPDoesNotHaveSSLSupport").')'; } @@ -416,11 +416,11 @@ if ($action == 'edit') // STARTTLS print ''.$langs->trans("MAIN_MAIL_EMAIL_STARTTLS").''; - if (! empty($conf->use_javascript_ajax) || (isset($conf->global->MAIN_MAIL_SENDMODE) && in_array($conf->global->MAIN_MAIL_SENDMODE, array('smtps', 'swiftmailer')))) + if (!empty($conf->use_javascript_ajax) || (isset($conf->global->MAIN_MAIL_SENDMODE) && in_array($conf->global->MAIN_MAIL_SENDMODE, array('smtps', 'swiftmailer')))) { if (function_exists('openssl_open')) { - print $form->selectyesno('MAIN_MAIL_EMAIL_STARTTLS', (! empty($conf->global->MAIN_MAIL_EMAIL_STARTTLS)?$conf->global->MAIN_MAIL_EMAIL_STARTTLS:0), 1); + print $form->selectyesno('MAIN_MAIL_EMAIL_STARTTLS', (!empty($conf->global->MAIN_MAIL_EMAIL_STARTTLS) ? $conf->global->MAIN_MAIL_EMAIL_STARTTLS : 0), 1); } else print yn(0).' ('.$langs->trans("YourPHPDoesNotHaveSSLSupport").')'; } @@ -429,11 +429,11 @@ if ($action == 'edit') // DKIM print ''.$langs->trans("MAIN_MAIL_EMAIL_DKIM_ENABLED").''; - if (! empty($conf->use_javascript_ajax) || (isset($conf->global->MAIN_MAIL_SENDMODE) && in_array($conf->global->MAIN_MAIL_SENDMODE, array('swiftmailer')))) + if (!empty($conf->use_javascript_ajax) || (isset($conf->global->MAIN_MAIL_SENDMODE) && in_array($conf->global->MAIN_MAIL_SENDMODE, array('swiftmailer')))) { if (function_exists('openssl_open')) { - print $form->selectyesno('MAIN_MAIL_EMAIL_DKIM_ENABLED', (! empty($conf->global->MAIN_MAIL_EMAIL_DKIM_ENABLED)?$conf->global->MAIN_MAIL_EMAIL_DKIM_ENABLED:0), 1); + print $form->selectyesno('MAIN_MAIL_EMAIL_DKIM_ENABLED', (!empty($conf->global->MAIN_MAIL_EMAIL_DKIM_ENABLED) ? $conf->global->MAIN_MAIL_EMAIL_DKIM_ENABLED : 0), 1); } else print yn(0).' ('.$langs->trans("YourPHPDoesNotHaveSSLSupport").')'; } @@ -442,31 +442,31 @@ if ($action == 'edit') // DKIM Domain print ''.$langs->trans("MAIN_MAIL_EMAIL_DKIM_DOMAIN").''; - print ''; // DKIM Selector print ''.$langs->trans("MAIN_MAIL_EMAIL_DKIM_SELECTOR").''; - print ''; // DKIM PRIVATE KEY print ''.$langs->trans("MAIN_MAIL_EMAIL_DKIM_PRIVATE_KEY").''; - print ''; + print ''; print ''; // Separator print ' '; // From - print ''.$langs->trans("MAIN_MAIL_EMAIL_FROM", ini_get('sendmail_from')?ini_get('sendmail_from'):$langs->transnoentities("Undefined")).''; - print ''.$langs->trans("MAIN_MAIL_EMAIL_FROM", ini_get('sendmail_from') ?ini_get('sendmail_from') : $langs->transnoentities("Undefined")).''; + print ''; // Default from type $liste = array(); $liste['user'] = $langs->trans('UserEmail'); - $liste['company'] = $langs->trans('CompanyEmail').' ('.(empty($conf->global->MAIN_INFO_SOCIETE_MAIL)?$langs->trans("NotDefined"):$conf->global->MAIN_INFO_SOCIETE_MAIL).')'; + $liste['company'] = $langs->trans('CompanyEmail').' ('.(empty($conf->global->MAIN_INFO_SOCIETE_MAIL) ? $langs->trans("NotDefined") : $conf->global->MAIN_INFO_SOCIETE_MAIL).')'; /* $sql='SELECT rowid, label, email FROM '.MAIN_DB_PREFIX.'c_email_senderprofile WHERE active = 1'; $resql = $db->query($sql); @@ -495,12 +495,12 @@ if ($action == 'edit') // From print ''.$langs->trans("MAIN_MAIL_ERRORS_TO").''; - print ''; // Autocopy to print ''.$langs->trans("MAIN_MAIL_AUTOCOPY_TO").''; - print ''; print ''; @@ -527,14 +527,14 @@ else // Disable print ''.$langs->trans("MAIN_DISABLE_ALL_MAILS").''.yn($conf->global->MAIN_DISABLE_ALL_MAILS); - if (! empty($conf->global->MAIN_DISABLE_ALL_MAILS)) print img_warning($langs->trans("Disabled")); + if (!empty($conf->global->MAIN_DISABLE_ALL_MAILS)) print img_warning($langs->trans("Disabled")); print ''; // Force e-mail recipient print ''.$langs->trans("MAIN_MAIL_FORCE_SENDTO").''.$conf->global->MAIN_MAIL_FORCE_SENDTO; - if (! empty($conf->global->MAIN_MAIL_FORCE_SENDTO)) + if (!empty($conf->global->MAIN_MAIL_FORCE_SENDTO)) { - if (! isValidEmail($conf->global->MAIN_MAIL_FORCE_SENDTO)) print img_warning($langs->trans("ErrorBadEMail")); + if (!isValidEmail($conf->global->MAIN_MAIL_FORCE_SENDTO)) print img_warning($langs->trans("ErrorBadEMail")); else print img_warning($langs->trans("RecipientEmailsWillBeReplacedWithThisValue")); } print ''; @@ -547,8 +547,8 @@ else // Method print ''.$langs->trans("MAIN_MAIL_SENDMODE").''; - $text=$listofmethods[$conf->global->MAIN_MAIL_SENDMODE]; - if (empty($text)) $text=$langs->trans("Undefined").img_warning(); + $text = $listofmethods[$conf->global->MAIN_MAIL_SENDMODE]; + if (empty($text)) $text = $langs->trans("Undefined").img_warning(); print $text; print ''; @@ -559,7 +559,7 @@ else } else { - print ''.$langs->trans("MAIN_MAIL_SMTP_SERVER", ini_get('SMTP')?ini_get('SMTP'):$langs->transnoentities("Undefined")).''.(! empty($conf->global->MAIN_MAIL_SMTP_SERVER)?$conf->global->MAIN_MAIL_SMTP_SERVER:'').''; + print ''.$langs->trans("MAIN_MAIL_SMTP_SERVER", ini_get('SMTP') ?ini_get('SMTP') : $langs->transnoentities("Undefined")).''.(!empty($conf->global->MAIN_MAIL_SMTP_SERVER) ? $conf->global->MAIN_MAIL_SMTP_SERVER : '').''; } // Port @@ -569,7 +569,7 @@ else } else { - print ''.$langs->trans("MAIN_MAIL_SMTP_PORT", ini_get('smtp_port')?ini_get('smtp_port'):$langs->transnoentities("Undefined")).''.(! empty($conf->global->MAIN_MAIL_SMTP_PORT)?$conf->global->MAIN_MAIL_SMTP_PORT:'').''; + print ''.$langs->trans("MAIN_MAIL_SMTP_PORT", ini_get('smtp_port') ?ini_get('smtp_port') : $langs->transnoentities("Undefined")).''.(!empty($conf->global->MAIN_MAIL_SMTP_PORT) ? $conf->global->MAIN_MAIL_SMTP_PORT : '').''; } // SMTPS ID @@ -628,17 +628,17 @@ else // Domain print ''.$langs->trans("MAIN_MAIL_EMAIL_DKIM_DOMAIN").''; - print '' . $conf->global->MAIN_MAIL_EMAIL_DKIM_DOMAIN; + print ''.$conf->global->MAIN_MAIL_EMAIL_DKIM_DOMAIN; print ''; // Selector print ''.$langs->trans("MAIN_MAIL_EMAIL_DKIM_SELECTOR").''; - print '' . $conf->global->MAIN_MAIL_EMAIL_DKIM_SELECTOR; + print ''.$conf->global->MAIN_MAIL_EMAIL_DKIM_SELECTOR; print ''; // PRIVATE KEY print ''.$langs->trans("MAIN_MAIL_EMAIL_DKIM_PRIVATE_KEY").''; - print '' . $conf->global->MAIN_MAIL_EMAIL_DKIM_PRIVATE_KEY; + print ''.$conf->global->MAIN_MAIL_EMAIL_DKIM_PRIVATE_KEY; print ''; } @@ -646,22 +646,22 @@ else print ' '; // From - print ''.$langs->trans("MAIN_MAIL_EMAIL_FROM", ini_get('sendmail_from')?ini_get('sendmail_from'):$langs->transnoentities("Undefined")).''; + print ''.$langs->trans("MAIN_MAIL_EMAIL_FROM", ini_get('sendmail_from') ?ini_get('sendmail_from') : $langs->transnoentities("Undefined")).''; print ''.$conf->global->MAIN_MAIL_EMAIL_FROM; - if (! empty($conf->global->MAIN_MAIL_EMAIL_FROM) && ! isValidEmail($conf->global->MAIN_MAIL_EMAIL_FROM)) print img_warning($langs->trans("ErrorBadEMail")); + if (!empty($conf->global->MAIN_MAIL_EMAIL_FROM) && !isValidEmail($conf->global->MAIN_MAIL_EMAIL_FROM)) print img_warning($langs->trans("ErrorBadEMail")); print ''; // Default from type $liste = array(); $liste['user'] = $langs->trans('UserEmail'); - $liste['company'] = $langs->trans('CompanyEmail').' ('.(empty($conf->global->MAIN_INFO_SOCIETE_MAIL)?$langs->trans("NotDefined"):$conf->global->MAIN_INFO_SOCIETE_MAIL).')'; - $sql='SELECT rowid, label, email FROM '.MAIN_DB_PREFIX.'c_email_senderprofile WHERE active = 1'; + $liste['company'] = $langs->trans('CompanyEmail').' ('.(empty($conf->global->MAIN_INFO_SOCIETE_MAIL) ? $langs->trans("NotDefined") : $conf->global->MAIN_INFO_SOCIETE_MAIL).')'; + $sql = 'SELECT rowid, label, email FROM '.MAIN_DB_PREFIX.'c_email_senderprofile WHERE active = 1'; $resql = $db->query($sql); if ($resql) { $num = $db->num_rows($resql); - $i=0; - while($i < $num) + $i = 0; + while ($i < $num) { $obj = $db->fetch_object($resql); if ($obj) @@ -705,16 +705,16 @@ else // Errors To print ''.$langs->trans("MAIN_MAIL_ERRORS_TO").''; print ''.$conf->global->MAIN_MAIL_ERRORS_TO; - if (! empty($conf->global->MAIN_MAIL_ERRORS_TO) && ! isValidEmail($conf->global->MAIN_MAIL_ERRORS_TO)) print img_warning($langs->trans("ErrorBadEMail")); + if (!empty($conf->global->MAIN_MAIL_ERRORS_TO) && !isValidEmail($conf->global->MAIN_MAIL_ERRORS_TO)) print img_warning($langs->trans("ErrorBadEMail")); print ''; // Autocopy to print ''.$langs->trans("MAIN_MAIL_AUTOCOPY_TO").''; print ''; - if (! empty($conf->global->MAIN_MAIL_AUTOCOPY_TO)) + if (!empty($conf->global->MAIN_MAIL_AUTOCOPY_TO)) { print $conf->global->MAIN_MAIL_AUTOCOPY_TO; - if (! isValidEmail($conf->global->MAIN_MAIL_AUTOCOPY_TO)) print img_warning($langs->trans("ErrorBadEMail")); + if (!isValidEmail($conf->global->MAIN_MAIL_AUTOCOPY_TO)) print img_warning($langs->trans("ErrorBadEMail")); } else { @@ -732,7 +732,7 @@ else print ''.$langs->trans("Modify").''; - if ($conf->global->MAIN_MAIL_SENDMODE != 'mail' || ! $linuxlike) + if ($conf->global->MAIN_MAIL_SENDMODE != 'mail' || !$linuxlike) { if (function_exists('fsockopen') && $port && $server) { @@ -746,7 +746,7 @@ else print ''.$langs->trans("DoTestSend").''; - if (! empty($conf->fckeditor->enabled)) + if (!empty($conf->fckeditor->enabled)) { print ''.$langs->trans("DoTestSendHTML").''; } @@ -770,17 +770,17 @@ else print info_admin($langs->trans("SendmailOptionMayHurtBuggedMTA")); } - if (! in_array($action, array('testconnect', 'test', 'testhtml'))) + if (!in_array($action, array('testconnect', 'test', 'testhtml'))) { $text = ''; if ($conf->global->MAIN_MAIL_SENDMODE == 'mail') { - $text.= $langs->trans("WarningPHPMail"); + $text .= $langs->trans("WarningPHPMail"); } //$conf->global->MAIN_EXTERNAL_SMTP_CLIENT_IP_ADDRESS='1.2.3.4'; - if (! empty($conf->global->MAIN_EXTERNAL_SMTP_CLIENT_IP_ADDRESS)) + if (!empty($conf->global->MAIN_EXTERNAL_SMTP_CLIENT_IP_ADDRESS)) { - $text.= ($text?'
':'').$langs->trans("WarningPHPMail2", $conf->global->MAIN_EXTERNAL_SMTP_CLIENT_IP_ADDRESS); + $text .= ($text ? '
' : '').$langs->trans("WarningPHPMail2", $conf->global->MAIN_EXTERNAL_SMTP_CLIENT_IP_ADDRESS); } if ($text) print info_admin($text); } @@ -792,7 +792,7 @@ else include_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php'; $mail = new CMailFile('', '', '', ''); - $result=$mail->check_server_port($server, $port); + $result = $mail->check_server_port($server, $port); if ($result) print '
'.$langs->trans("ServerAvailableOnIPOrPort", $server, $port).'
'; else { @@ -811,45 +811,45 @@ else if ($action == 'test' || $action == 'testhtml') { print '
'; - print load_fiche_titre($action == 'testhtml'?$langs->trans("DoTestSendHTML"):$langs->trans("DoTestSend")); + print load_fiche_titre($action == 'testhtml' ? $langs->trans("DoTestSendHTML") : $langs->trans("DoTestSend")); dol_fiche_head(''); // Cree l'objet formulaire mail include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php'; $formmail = new FormMail($db); - $formmail->trackid=(($action == 'testhtml')?"testhtml":"test"); - $formmail->fromname = (isset($_POST['fromname'])?$_POST['fromname']:$conf->global->MAIN_MAIL_EMAIL_FROM); - $formmail->frommail = (isset($_POST['frommail'])?$_POST['frommail']:$conf->global->MAIN_MAIL_EMAIL_FROM); - $formmail->fromid=$user->id; - $formmail->fromalsorobot=1; - $formmail->fromtype=(GETPOSTISSET('fromtype')?GETPOST('fromtype', 'aZ09'):(!empty($conf->global->MAIN_MAIL_DEFAULT_FROMTYPE)?$conf->global->MAIN_MAIL_DEFAULT_FROMTYPE:'user')); - $formmail->withfromreadonly=1; - $formmail->withsubstit=1; - $formmail->withfrom=1; - $formmail->witherrorsto=1; - $formmail->withto=(! empty($_POST['sendto'])?$_POST['sendto']:($user->email?$user->email:1)); - $formmail->withtocc=(! empty($_POST['sendtocc'])?$_POST['sendtocc']:1); // ! empty to keep field if empty - $formmail->withtoccc=(! empty($_POST['sendtoccc'])?$_POST['sendtoccc']:1); // ! empty to keep field if empty - $formmail->withtopic=(isset($_POST['subject'])?$_POST['subject']:$langs->trans("Test")); - $formmail->withtopicreadonly=0; - $formmail->withfile=2; - $formmail->withbody=(isset($_POST['message'])?$_POST['message']:($action == 'testhtml'?$langs->transnoentities("PredefinedMailTestHtml"):$langs->transnoentities("PredefinedMailTest"))); - $formmail->withbodyreadonly=0; - $formmail->withcancel=1; - $formmail->withdeliveryreceipt=1; - $formmail->withfckeditor=($action == 'testhtml'?1:0); - $formmail->ckeditortoolbar='dolibarr_mailings'; + $formmail->trackid = (($action == 'testhtml') ? "testhtml" : "test"); + $formmail->fromname = (isset($_POST['fromname']) ? $_POST['fromname'] : $conf->global->MAIN_MAIL_EMAIL_FROM); + $formmail->frommail = (isset($_POST['frommail']) ? $_POST['frommail'] : $conf->global->MAIN_MAIL_EMAIL_FROM); + $formmail->fromid = $user->id; + $formmail->fromalsorobot = 1; + $formmail->fromtype = (GETPOSTISSET('fromtype') ?GETPOST('fromtype', 'aZ09') : (!empty($conf->global->MAIN_MAIL_DEFAULT_FROMTYPE) ? $conf->global->MAIN_MAIL_DEFAULT_FROMTYPE : 'user')); + $formmail->withfromreadonly = 1; + $formmail->withsubstit = 1; + $formmail->withfrom = 1; + $formmail->witherrorsto = 1; + $formmail->withto = (!empty($_POST['sendto']) ? $_POST['sendto'] : ($user->email ? $user->email : 1)); + $formmail->withtocc = (!empty($_POST['sendtocc']) ? $_POST['sendtocc'] : 1); // ! empty to keep field if empty + $formmail->withtoccc = (!empty($_POST['sendtoccc']) ? $_POST['sendtoccc'] : 1); // ! empty to keep field if empty + $formmail->withtopic = (isset($_POST['subject']) ? $_POST['subject'] : $langs->trans("Test")); + $formmail->withtopicreadonly = 0; + $formmail->withfile = 2; + $formmail->withbody = (isset($_POST['message']) ? $_POST['message'] : ($action == 'testhtml' ? $langs->transnoentities("PredefinedMailTestHtml") : $langs->transnoentities("PredefinedMailTest"))); + $formmail->withbodyreadonly = 0; + $formmail->withcancel = 1; + $formmail->withdeliveryreceipt = 1; + $formmail->withfckeditor = ($action == 'testhtml' ? 1 : 0); + $formmail->ckeditortoolbar = 'dolibarr_mailings'; // Tableau des substitutions - $formmail->substit=$substitutionarrayfortest; + $formmail->substit = $substitutionarrayfortest; // Tableau des parametres complementaires du post - $formmail->param["action"]="send"; - $formmail->param["models"]="body"; - $formmail->param["mailid"]=0; - $formmail->param["returnurl"]=$_SERVER["PHP_SELF"]; + $formmail->param["action"] = "send"; + $formmail->param["models"] = "body"; + $formmail->param["mailid"] = 0; + $formmail->param["returnurl"] = $_SERVER["PHP_SELF"]; // Init list of files - if (GETPOST("mode", "aZ09")=='init') + if (GETPOST("mode", "aZ09") == 'init') { $formmail->clear_attached_files(); } diff --git a/htdocs/bom/bom_agenda.php b/htdocs/bom/bom_agenda.php index 8e0afc77d0a..af41824fa08 100644 --- a/htdocs/bom/bom_agenda.php +++ b/htdocs/bom/bom_agenda.php @@ -32,32 +32,32 @@ require_once DOL_DOCUMENT_ROOT.'/bom/lib/bom.lib.php'; // Load translation files required by the page -$langs->loadLangs(array("mrp","other")); +$langs->loadLangs(array("mrp", "other")); // Get parameters -$id = GETPOST('id', 'int'); +$id = GETPOST('id', 'int'); $ref = GETPOST('ref', 'alpha'); -$action = GETPOST('action', 'alpha'); +$action = GETPOST('action', 'alpha'); $cancel = GETPOST('cancel', 'aZ09'); $backtopage = GETPOST('backtopage', 'alpha'); if (GETPOST('actioncode', 'array')) { - $actioncode=GETPOST('actioncode', 'array', 3); - if (! count($actioncode)) $actioncode='0'; + $actioncode = GETPOST('actioncode', 'array', 3); + if (!count($actioncode)) $actioncode = '0'; } else { - $actioncode=GETPOST("actioncode", "alpha", 3)?GETPOST("actioncode", "alpha", 3):(GETPOST("actioncode")=='0'?'0':(empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT)?'':$conf->global->AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT)); + $actioncode = GETPOST("actioncode", "alpha", 3) ?GETPOST("actioncode", "alpha", 3) : (GETPOST("actioncode") == '0' ? '0' : (empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT) ? '' : $conf->global->AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT)); } -$search_agenda_label=GETPOST('search_agenda_label'); +$search_agenda_label = GETPOST('search_agenda_label'); // Security check - Protection if external user //if ($user->socid > 0) accessforbidden(); //if ($user->socid > 0) $socid = $user->socid; //$result = restrictedArea($user, 'bom', $id); -$limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit; +$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST("sortfield", 'alpha'); $sortorder = GETPOST("sortorder", 'alpha'); $page = GETPOST("page", 'int'); diff --git a/htdocs/bom/bom_card.php b/htdocs/bom/bom_card.php index 252caa8da10..75f87067a4e 100644 --- a/htdocs/bom/bom_card.php +++ b/htdocs/bom/bom_card.php @@ -625,28 +625,28 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea // Close / Cancel if ($permissiontoadd && $object->status == $object::STATUS_VALIDATED) { - print '' . $langs->trans("Disable") . ''; + print ''.$langs->trans("Disable").''; } // Re-open if ($permissiontoadd && $object->status == $object::STATUS_CANCELED) { - print '' . $langs->trans("ReOpen") . ''; + print ''.$langs->trans("ReOpen").''; } // Create MO if ($conf->mrp->enabled) { - if ($object->status == $object::STATUS_VALIDATED && ! empty($user->rights->mrp->write)) + if ($object->status == $object::STATUS_VALIDATED && !empty($user->rights->mrp->write)) { - print '' . $langs->trans("CreateMO") . ''; + print ''.$langs->trans("CreateMO").''; } } // Clone if ($permissiontoadd) { - print '' . $langs->trans("ToClone") . ''; + print ''.$langs->trans("ToClone").''; } /* diff --git a/htdocs/comm/remx.php b/htdocs/comm/remx.php index 47a31f11a72..68be93f7ed1 100644 --- a/htdocs/comm/remx.php +++ b/htdocs/comm/remx.php @@ -745,7 +745,7 @@ if ($socid > 0) $sql .= " , ".MAIN_DB_PREFIX."facturedet as fc"; $sql .= " , ".MAIN_DB_PREFIX."societe_remise_except as rc"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."facture as fa ON rc.fk_facture_source = fa.rowid"; - $sql .= " WHERE rc.fk_soc =". $object->id; + $sql .= " WHERE rc.fk_soc =".$object->id; $sql .= " AND rc.fk_facture_line = fc.rowid"; $sql .= " AND fc.fk_facture = f.rowid"; $sql .= " AND rc.fk_user = u.rowid"; @@ -763,7 +763,7 @@ if ($socid > 0) $sql2 .= " , ".MAIN_DB_PREFIX."user as u"; $sql2 .= " , ".MAIN_DB_PREFIX."societe_remise_except as rc"; $sql2 .= " LEFT JOIN ".MAIN_DB_PREFIX."facture as fa ON rc.fk_facture_source = fa.rowid"; - $sql2 .= " WHERE rc.fk_soc =". $object->id; + $sql2 .= " WHERE rc.fk_soc =".$object->id; $sql2 .= " AND rc.fk_facture = f.rowid"; $sql2 .= " AND rc.fk_user = u.rowid"; $sql2 .= " AND rc.discount_type = 0"; // Eliminate supplier discounts @@ -920,7 +920,7 @@ if ($socid > 0) $sql .= " , ".MAIN_DB_PREFIX."facture_fourn_det as fc"; $sql .= " , ".MAIN_DB_PREFIX."societe_remise_except as rc"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."facture_fourn as fa ON rc.fk_invoice_supplier_source = fa.rowid"; - $sql .= " WHERE rc.fk_soc =". $object->id; + $sql .= " WHERE rc.fk_soc =".$object->id; $sql .= " AND rc.fk_invoice_supplier_line = fc.rowid"; $sql .= " AND fc.fk_facture_fourn = f.rowid"; $sql .= " AND rc.fk_user = u.rowid"; @@ -938,7 +938,7 @@ if ($socid > 0) $sql2 .= " , ".MAIN_DB_PREFIX."user as u"; $sql2 .= " , ".MAIN_DB_PREFIX."societe_remise_except as rc"; $sql2 .= " LEFT JOIN ".MAIN_DB_PREFIX."facture_fourn as fa ON rc.fk_invoice_supplier_source = fa.rowid"; - $sql2 .= " WHERE rc.fk_soc =". $object->id; + $sql2 .= " WHERE rc.fk_soc =".$object->id; $sql2 .= " AND rc.fk_invoice_supplier = f.rowid"; $sql2 .= " AND rc.fk_user = u.rowid"; $sql2 .= " AND rc.discount_type = 1"; // Eliminate customer discounts diff --git a/htdocs/compta/bank/graph.php b/htdocs/compta/bank/graph.php index 0f0c3d11386..fbcd06a51bc 100644 --- a/htdocs/compta/bank/graph.php +++ b/htdocs/compta/bank/graph.php @@ -31,22 +31,22 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php'; // Load translation files required by the page $langs->loadLangs(array('banks', 'categories')); -$WIDTH=DolGraph::getDefaultGraphSizeForStats('width', 768); -$HEIGHT=DolGraph::getDefaultGraphSizeForStats('height', 200); +$WIDTH = DolGraph::getDefaultGraphSizeForStats('width', 768); +$HEIGHT = DolGraph::getDefaultGraphSizeForStats('height', 200); // Security check if (isset($_GET["account"]) || isset($_GET["ref"])) { - $id = isset($_GET["account"])?$_GET["account"]:(isset($_GET["ref"])?$_GET["ref"]:''); + $id = isset($_GET["account"]) ? $_GET["account"] : (isset($_GET["ref"]) ? $_GET["ref"] : ''); } -$fieldid = isset($_GET["ref"])?'ref':'rowid'; -if ($user->socid) $socid=$user->socid; -$result=restrictedArea($user, 'banque', $id, 'bank_account&bank_account', '', '', $fieldid); +$fieldid = isset($_GET["ref"]) ? 'ref' : 'rowid'; +if ($user->socid) $socid = $user->socid; +$result = restrictedArea($user, 'banque', $id, 'bank_account&bank_account', '', '', $fieldid); -$account=GETPOST("account"); -$mode='standard'; -if (GETPOST("mode") == 'showalltime') $mode='showalltime'; -$error=0; +$account = GETPOST("account"); +$mode = 'standard'; +if (GETPOST("mode") == 'showalltime') $mode = 'showalltime'; +$error = 0; /* @@ -63,22 +63,22 @@ $datetime = dol_now(); $year = dol_print_date($datetime, "%Y"); $month = dol_print_date($datetime, "%m"); $day = dol_print_date($datetime, "%d"); -if (GETPOST("year")) $year=sprintf("%04d", GETPOST("year")); -if (GETPOST("month")) $month=sprintf("%02d", GETPOST("month")); +if (GETPOST("year")) $year = sprintf("%04d", GETPOST("year")); +if (GETPOST("month")) $month = sprintf("%02d", GETPOST("month")); $object = new Account($db); -if ($_GET["account"] && ! preg_match('/,/', $_GET["account"])) // if for a particular account and not a list +if ($_GET["account"] && !preg_match('/,/', $_GET["account"])) // if for a particular account and not a list { - $result=$object->fetch(GETPOST("account", "int")); + $result = $object->fetch(GETPOST("account", "int")); } if ($_GET["ref"]) { - $result=$object->fetch(0, GETPOST("ref")); - $account=$object->id; + $result = $object->fetch(0, GETPOST("ref")); + $account = $object->id; } -$result=dol_mkdir($conf->bank->dir_temp); +$result = dol_mkdir($conf->bank->dir_temp); if ($result < 0) { $langs->load("errors"); @@ -89,11 +89,11 @@ else { // Calcul $min and $max $sql = "SELECT MIN(b.datev) as min, MAX(b.datev) as max"; - $sql.= " FROM ".MAIN_DB_PREFIX."bank as b"; - $sql.= ", ".MAIN_DB_PREFIX."bank_account as ba"; - $sql.= " WHERE b.fk_account = ba.rowid"; - $sql.= " AND ba.entity IN (".getEntity('bank_account').")"; - if ($account && $_GET["option"]!='all') $sql.= " AND b.fk_account IN (".$account.")"; + $sql .= " FROM ".MAIN_DB_PREFIX."bank as b"; + $sql .= ", ".MAIN_DB_PREFIX."bank_account as ba"; + $sql .= " WHERE b.fk_account = ba.rowid"; + $sql .= " AND ba.entity IN (".getEntity('bank_account').")"; + if ($account && $_GET["option"] != 'all') $sql .= " AND b.fk_account IN (".$account.")"; $resql = $db->query($sql); if ($resql) @@ -109,7 +109,7 @@ else } if (empty($min)) $min = dol_now() - 3600 * 24; - $log="graph.php: min=".$min." max=".$max; + $log = "graph.php: min=".$min." max=".$max; dol_syslog($log); @@ -120,24 +120,24 @@ else // Loading table $amounts $amounts = array(); - $monthnext = $month+1; + $monthnext = $month + 1; $yearnext = $year; if ($monthnext > 12) { - $monthnext=1; + $monthnext = 1; $yearnext++; } $sql = "SELECT date_format(b.datev,'%Y%m%d')"; - $sql.= ", SUM(b.amount)"; - $sql.= " FROM ".MAIN_DB_PREFIX."bank as b"; - $sql.= ", ".MAIN_DB_PREFIX."bank_account as ba"; - $sql.= " WHERE b.fk_account = ba.rowid"; - $sql.= " AND ba.entity IN (".getEntity('bank_account').")"; - $sql.= " AND b.datev >= '".$year."-".$month."-01 00:00:00'"; - $sql.= " AND b.datev < '".$yearnext."-".$monthnext."-01 00:00:00'"; - if ($account && $_GET["option"]!='all') $sql.= " AND b.fk_account IN (".$account.")"; - $sql.= " GROUP BY date_format(b.datev,'%Y%m%d')"; + $sql .= ", SUM(b.amount)"; + $sql .= " FROM ".MAIN_DB_PREFIX."bank as b"; + $sql .= ", ".MAIN_DB_PREFIX."bank_account as ba"; + $sql .= " WHERE b.fk_account = ba.rowid"; + $sql .= " AND ba.entity IN (".getEntity('bank_account').")"; + $sql .= " AND b.datev >= '".$year."-".$month."-01 00:00:00'"; + $sql .= " AND b.datev < '".$yearnext."-".$monthnext."-01 00:00:00'"; + if ($account && $_GET["option"] != 'all') $sql .= " AND b.fk_account IN (".$account.")"; + $sql .= " GROUP BY date_format(b.datev,'%Y%m%d')"; $resql = $db->query($sql); if ($resql) @@ -161,12 +161,12 @@ else $solde = 0; $sql = "SELECT SUM(b.amount)"; - $sql.= " FROM ".MAIN_DB_PREFIX."bank as b"; - $sql.= ", ".MAIN_DB_PREFIX."bank_account as ba"; - $sql.= " WHERE b.fk_account = ba.rowid"; - $sql.= " AND ba.entity IN (".getEntity('bank_account').")"; - $sql.= " AND b.datev < '".$year."-".sprintf("%02s", $month)."-01'"; - if ($account && $_GET["option"]!='all') $sql.= " AND b.fk_account IN (".$account.")"; + $sql .= " FROM ".MAIN_DB_PREFIX."bank as b"; + $sql .= ", ".MAIN_DB_PREFIX."bank_account as ba"; + $sql .= " WHERE b.fk_account = ba.rowid"; + $sql .= " AND ba.entity IN (".getEntity('bank_account').")"; + $sql .= " AND b.datev < '".$year."-".sprintf("%02s", $month)."-01'"; + if ($account && $_GET["option"] != 'all') $sql .= " AND b.fk_account IN (".$account.")"; $resql = $db->query($sql); if ($resql) @@ -225,36 +225,36 @@ else //exit; // Fabrication tableau 1 - $file= $conf->bank->dir_temp."/balance".$account."-".$year.$month.".png"; - $fileurl=DOL_URL_ROOT.'/viewimage.php?modulepart=banque_temp&file='."/balance".$account."-".$year.$month.".png"; - $title=$langs->transnoentities("Balance").' - '.$langs->transnoentities("Month").': '.$month.' '.$langs->transnoentities("Year").': '.$year; - $graph_datas=array(); - foreach($datas as $i => $val) + $file = $conf->bank->dir_temp."/balance".$account."-".$year.$month.".png"; + $fileurl = DOL_URL_ROOT.'/viewimage.php?modulepart=banque_temp&file='."/balance".$account."-".$year.$month.".png"; + $title = $langs->transnoentities("Balance").' - '.$langs->transnoentities("Month").': '.$month.' '.$langs->transnoentities("Year").': '.$year; + $graph_datas = array(); + foreach ($datas as $i => $val) { - $graph_datas[$i]=array(isset($labels[$i])?$labels[$i]:'',$datas[$i]); + $graph_datas[$i] = array(isset($labels[$i]) ? $labels[$i] : '', $datas[$i]); if ($object->min_desired) array_push($graph_datas[$i], $datamin[$i]); if ($object->min_allowed) array_push($graph_datas[$i], $dataall[$i]); } $px1 = new DolGraph(); $px1->SetData($graph_datas); - $arraylegends=array($langs->transnoentities("Balance")); + $arraylegends = array($langs->transnoentities("Balance")); if ($object->min_desired) array_push($arraylegends, $langs->transnoentities("BalanceMinimalDesired")); if ($object->min_allowed) array_push($arraylegends, $langs->transnoentities("BalanceMinimalAllowed")); $px1->SetLegend($arraylegends); $px1->SetLegendWidthMin(180); - $px1->SetMaxValue($px1->GetCeilMaxValue()<0?0:$px1->GetCeilMaxValue()); - $px1->SetMinValue($px1->GetFloorMinValue()>0?0:$px1->GetFloorMinValue()); + $px1->SetMaxValue($px1->GetCeilMaxValue() < 0 ? 0 : $px1->GetCeilMaxValue()); + $px1->SetMinValue($px1->GetFloorMinValue() > 0 ? 0 : $px1->GetFloorMinValue()); $px1->SetTitle($title); $px1->SetWidth($WIDTH); $px1->SetHeight($HEIGHT); - $px1->SetType(array('lines','lines','lines')); + $px1->SetType(array('lines', 'lines', 'lines')); $px1->setBgColor('onglet'); - $px1->setBgColorGrid(array(255,255,255)); + $px1->setBgColorGrid(array(255, 255, 255)); $px1->SetHorizTickIncrement(1); $px1->draw($file, $fileurl); - $show1=$px1->show(); + $show1 = $px1->show(); unset($graph_datas); unset($px1); unset($datas); @@ -271,14 +271,14 @@ else // Loading table $amounts $amounts = array(); $sql = "SELECT date_format(b.datev,'%Y%m%d')"; - $sql.= ", SUM(b.amount)"; - $sql.= " FROM ".MAIN_DB_PREFIX."bank as b"; - $sql.= ", ".MAIN_DB_PREFIX."bank_account as ba"; - $sql.= " WHERE b.fk_account = ba.rowid"; - $sql.= " AND ba.entity IN (".getEntity('bank_account').")"; - $sql.= " AND b.datev >= '".$year."-01-01 00:00:00'"; - $sql.= " AND b.datev <= '".$year."-12-31 23:59:59'"; - if ($account && $_GET["option"]!='all') $sql.= " AND b.fk_account IN (".$account.")"; + $sql .= ", SUM(b.amount)"; + $sql .= " FROM ".MAIN_DB_PREFIX."bank as b"; + $sql .= ", ".MAIN_DB_PREFIX."bank_account as ba"; + $sql .= " WHERE b.fk_account = ba.rowid"; + $sql .= " AND ba.entity IN (".getEntity('bank_account').")"; + $sql .= " AND b.datev >= '".$year."-01-01 00:00:00'"; + $sql .= " AND b.datev <= '".$year."-12-31 23:59:59'"; + if ($account && $_GET["option"] != 'all') $sql .= " AND b.fk_account IN (".$account.")"; $sql .= " GROUP BY date_format(b.datev,'%Y%m%d')"; $resql = $db->query($sql); @@ -303,12 +303,12 @@ else $solde = 0; $sql = "SELECT SUM(b.amount)"; - $sql.= " FROM ".MAIN_DB_PREFIX."bank as b"; - $sql.= ", ".MAIN_DB_PREFIX."bank_account as ba"; - $sql.= " WHERE b.fk_account = ba.rowid"; - $sql.= " AND ba.entity IN (".getEntity('bank_account').")"; - $sql.= " AND b.datev < '".$year."-01-01'"; - if ($account && $_GET["option"]!='all') $sql.= " AND b.fk_account IN (".$account.")"; + $sql .= " FROM ".MAIN_DB_PREFIX."bank as b"; + $sql .= ", ".MAIN_DB_PREFIX."bank_account as ba"; + $sql .= " WHERE b.fk_account = ba.rowid"; + $sql .= " AND ba.entity IN (".getEntity('bank_account').")"; + $sql .= " AND b.datev < '".$year."-01-01'"; + if ($account && $_GET["option"] != 'all') $sql .= " AND b.fk_account IN (".$account.")"; $resql = $db->query($sql); if ($resql) @@ -361,36 +361,36 @@ else } // Fabrication tableau 2 - $file= $conf->bank->dir_temp."/balance".$account."-".$year.".png"; - $fileurl=DOL_URL_ROOT.'/viewimage.php?modulepart=banque_temp&file='."/balance".$account."-".$year.".png"; - $title=$langs->transnoentities("Balance").' - '.$langs->transnoentities("Year").': '.$year; - $graph_datas=array(); - foreach($datas as $i => $val) + $file = $conf->bank->dir_temp."/balance".$account."-".$year.".png"; + $fileurl = DOL_URL_ROOT.'/viewimage.php?modulepart=banque_temp&file='."/balance".$account."-".$year.".png"; + $title = $langs->transnoentities("Balance").' - '.$langs->transnoentities("Year").': '.$year; + $graph_datas = array(); + foreach ($datas as $i => $val) { - $graph_datas[$i]=array(isset($labels[$i])?$labels[$i]:'',$datas[$i]); + $graph_datas[$i] = array(isset($labels[$i]) ? $labels[$i] : '', $datas[$i]); if ($object->min_desired) array_push($graph_datas[$i], $datamin[$i]); if ($object->min_allowed) array_push($graph_datas[$i], $dataall[$i]); } $px2 = new DolGraph(); $px2->SetData($graph_datas); - $arraylegends=array($langs->transnoentities("Balance")); + $arraylegends = array($langs->transnoentities("Balance")); if ($object->min_desired) array_push($arraylegends, $langs->transnoentities("BalanceMinimalDesired")); if ($object->min_allowed) array_push($arraylegends, $langs->transnoentities("BalanceMinimalAllowed")); $px2->SetLegend($arraylegends); $px2->SetLegendWidthMin(180); - $px2->SetMaxValue($px2->GetCeilMaxValue()<0?0:$px2->GetCeilMaxValue()); - $px2->SetMinValue($px2->GetFloorMinValue()>0?0:$px2->GetFloorMinValue()); + $px2->SetMaxValue($px2->GetCeilMaxValue() < 0 ? 0 : $px2->GetCeilMaxValue()); + $px2->SetMinValue($px2->GetFloorMinValue() > 0 ? 0 : $px2->GetFloorMinValue()); $px2->SetTitle($title); $px2->SetWidth($WIDTH); $px2->SetHeight($HEIGHT); - $px2->SetType(array('linesnopoint','linesnopoint','linesnopoint')); + $px2->SetType(array('linesnopoint', 'linesnopoint', 'linesnopoint')); $px2->setBgColor('onglet'); - $px2->setBgColorGrid(array(255,255,255)); + $px2->setBgColorGrid(array(255, 255, 255)); $px2->SetHideXGrid(true); //$px2->SetHorizTickIncrement(30.41); // 30.41 jours/mois en moyenne $px2->draw($file, $fileurl); - $show2=$px2->show(); + $show2 = $px2->show(); unset($px2); unset($graph_datas); @@ -409,13 +409,13 @@ else $amounts = array(); $sql = "SELECT date_format(b.datev,'%Y%m%d')"; - $sql.= ", SUM(b.amount)"; - $sql.= " FROM ".MAIN_DB_PREFIX."bank as b"; - $sql.= ", ".MAIN_DB_PREFIX."bank_account as ba"; - $sql.= " WHERE b.fk_account = ba.rowid"; - $sql.= " AND ba.entity IN (".getEntity('bank_account').")"; - if ($account && $_GET["option"]!='all') $sql.= " AND b.fk_account IN (".$account.")"; - $sql.= " GROUP BY date_format(b.datev,'%Y%m%d')"; + $sql .= ", SUM(b.amount)"; + $sql .= " FROM ".MAIN_DB_PREFIX."bank as b"; + $sql .= ", ".MAIN_DB_PREFIX."bank_account as ba"; + $sql .= " WHERE b.fk_account = ba.rowid"; + $sql .= " AND ba.entity IN (".getEntity('bank_account').")"; + if ($account && $_GET["option"] != 'all') $sql .= " AND b.fk_account IN (".$account.")"; + $sql .= " GROUP BY date_format(b.datev,'%Y%m%d')"; $resql = $db->query($sql); if ($resql) @@ -447,20 +447,20 @@ else $subtotal = 0; $day = $min; - $textdate=strftime("%Y%m%d", $day); + $textdate = strftime("%Y%m%d", $day); //print "x".$textdate; $i = 0; - while ($day <= ($max+86400)) // On va au dela du dernier jour + while ($day <= ($max + 86400)) // On va au dela du dernier jour { $subtotal = $subtotal + (isset($amounts[$textdate]) ? $amounts[$textdate] : 0); //print strftime ("%e %d %m %y",$day)." ".$subtotal."\n
"; - if ($day > ($max+86400)) + if ($day > ($max + 86400)) { $datas[$i] = ''; // Valeur speciale permettant de ne pas tracer le graph } else { - $datas[$i] = '' + $solde + $subtotal; + $datas[$i] = '' +$solde + $subtotal; } $datamin[$i] = $object->min_desired; $dataall[$i] = $object->min_allowed; @@ -470,40 +470,40 @@ else } $day += 86400; - $textdate=strftime("%Y%m%d", $day); + $textdate = strftime("%Y%m%d", $day); $i++; } // Fabrication tableau 3 - $file= $conf->bank->dir_temp."/balance".$account.".png"; - $fileurl=DOL_URL_ROOT.'/viewimage.php?modulepart=banque_temp&file='."/balance".$account.".png"; - $title=$langs->transnoentities("Balance")." - ".$langs->transnoentities("AllTime"); - $graph_datas=array(); - foreach($datas as $i => $val) + $file = $conf->bank->dir_temp."/balance".$account.".png"; + $fileurl = DOL_URL_ROOT.'/viewimage.php?modulepart=banque_temp&file='."/balance".$account.".png"; + $title = $langs->transnoentities("Balance")." - ".$langs->transnoentities("AllTime"); + $graph_datas = array(); + foreach ($datas as $i => $val) { - $graph_datas[$i]=array(isset($labels[$i])?$labels[$i]:'',$datas[$i]); + $graph_datas[$i] = array(isset($labels[$i]) ? $labels[$i] : '', $datas[$i]); if ($object->min_desired) array_push($graph_datas[$i], $datamin[$i]); if ($object->min_allowed) array_push($graph_datas[$i], $dataall[$i]); } $px3 = new DolGraph(); $px3->SetData($graph_datas); - $arraylegends=array($langs->transnoentities("Balance")); + $arraylegends = array($langs->transnoentities("Balance")); if ($object->min_desired) array_push($arraylegends, $langs->transnoentities("BalanceMinimalDesired")); if ($object->min_allowed) array_push($arraylegends, $langs->transnoentities("BalanceMinimalAllowed")); $px3->SetLegend($arraylegends); $px3->SetLegendWidthMin(180); - $px3->SetMaxValue($px3->GetCeilMaxValue()<0?0:$px3->GetCeilMaxValue()); - $px3->SetMinValue($px3->GetFloorMinValue()>0?0:$px3->GetFloorMinValue()); + $px3->SetMaxValue($px3->GetCeilMaxValue() < 0 ? 0 : $px3->GetCeilMaxValue()); + $px3->SetMinValue($px3->GetFloorMinValue() > 0 ? 0 : $px3->GetFloorMinValue()); $px3->SetTitle($title); $px3->SetWidth($WIDTH); $px3->SetHeight($HEIGHT); - $px3->SetType(array('linesnopoint','linesnopoint','linesnopoint')); + $px3->SetType(array('linesnopoint', 'linesnopoint', 'linesnopoint')); $px3->setBgColor('onglet'); - $px3->setBgColorGrid(array(255,255,255)); + $px3->setBgColorGrid(array(255, 255, 255)); $px3->draw($file, $fileurl); - $show3=$px3->show(); + $show3 = $px3->show(); unset($px3); unset($graph_datas); @@ -522,25 +522,25 @@ else $credits = array(); $debits = array(); - $monthnext = $month+1; + $monthnext = $month + 1; $yearnext = $year; if ($monthnext > 12) { - $monthnext=1; + $monthnext = 1; $yearnext++; } $sql = "SELECT date_format(b.datev,'%d')"; - $sql.= ", SUM(b.amount)"; + $sql .= ", SUM(b.amount)"; $sql .= " FROM ".MAIN_DB_PREFIX."bank as b"; - $sql.= ", ".MAIN_DB_PREFIX."bank_account as ba"; - $sql.= " WHERE b.fk_account = ba.rowid"; - $sql.= " AND ba.entity IN (".getEntity('bank_account').")"; - $sql.= " AND b.datev >= '".$year."-".$month."-01 00:00:00'"; - $sql.= " AND b.datev < '".$yearnext."-".$monthnext."-01 00:00:00'"; - $sql.= " AND b.amount > 0"; - if ($account && $_GET["option"]!='all') $sql.= " AND b.fk_account IN (".$account.")"; - $sql.= " GROUP BY date_format(b.datev,'%d')"; + $sql .= ", ".MAIN_DB_PREFIX."bank_account as ba"; + $sql .= " WHERE b.fk_account = ba.rowid"; + $sql .= " AND ba.entity IN (".getEntity('bank_account').")"; + $sql .= " AND b.datev >= '".$year."-".$month."-01 00:00:00'"; + $sql .= " AND b.datev < '".$yearnext."-".$monthnext."-01 00:00:00'"; + $sql .= " AND b.amount > 0"; + if ($account && $_GET["option"] != 'all') $sql .= " AND b.fk_account IN (".$account.")"; + $sql .= " GROUP BY date_format(b.datev,'%d')"; $resql = $db->query($sql); if ($resql) @@ -560,24 +560,24 @@ else dol_print_error($db); } - $monthnext = $month+1; + $monthnext = $month + 1; $yearnext = $year; if ($monthnext > 12) { - $monthnext=1; + $monthnext = 1; $yearnext++; } $sql = "SELECT date_format(b.datev,'%d')"; - $sql.= ", SUM(b.amount)"; + $sql .= ", SUM(b.amount)"; $sql .= " FROM ".MAIN_DB_PREFIX."bank as b"; - $sql.= ", ".MAIN_DB_PREFIX."bank_account as ba"; - $sql.= " WHERE b.fk_account = ba.rowid"; - $sql.= " AND ba.entity IN (".getEntity('bank_account').")"; - $sql.= " AND b.datev >= '".$year."-".$month."-01 00:00:00'"; - $sql.= " AND b.datev < '".$yearnext."-".$monthnext."-01 00:00:00'"; - $sql.= " AND b.amount < 0"; - if ($account && $_GET["option"]!='all') $sql.= " AND b.fk_account IN (".$account.")"; + $sql .= ", ".MAIN_DB_PREFIX."bank_account as ba"; + $sql .= " WHERE b.fk_account = ba.rowid"; + $sql .= " AND ba.entity IN (".getEntity('bank_account').")"; + $sql .= " AND b.datev >= '".$year."-".$month."-01 00:00:00'"; + $sql .= " AND b.datev < '".$yearnext."-".$monthnext."-01 00:00:00'"; + $sql .= " AND b.amount < 0"; + if ($account && $_GET["option"] != 'all') $sql .= " AND b.fk_account IN (".$account.")"; $sql .= " GROUP BY date_format(b.datev,'%d')"; $resql = $db->query($sql); @@ -599,40 +599,40 @@ else $labels = array(); $data_credit = array(); $data_debit = array(); - for ($i = 0 ; $i < 31 ; $i++) + for ($i = 0; $i < 31; $i++) { - $data_credit[$i] = isset($credits[substr("0".($i+1), -2)]) ? $credits[substr("0".($i+1), -2)] : 0; - $data_debit[$i] = isset($debits[substr("0".($i+1), -2)]) ? $debits[substr("0".($i+1), -2)] : 0; - $labels[$i] = sprintf("%02d", $i+1); + $data_credit[$i] = isset($credits[substr("0".($i + 1), -2)]) ? $credits[substr("0".($i + 1), -2)] : 0; + $data_debit[$i] = isset($debits[substr("0".($i + 1), -2)]) ? $debits[substr("0".($i + 1), -2)] : 0; + $labels[$i] = sprintf("%02d", $i + 1); $datamin[$i] = $object->min_desired; } // Fabrication tableau 4a - $file= $conf->bank->dir_temp."/movement".$account."-".$year.$month.".png"; - $fileurl=DOL_URL_ROOT.'/viewimage.php?modulepart=banque_temp&file='."/movement".$account."-".$year.$month.".png"; - $title=$langs->transnoentities("BankMovements").' - '.$langs->transnoentities("Month").': '.$month.' '.$langs->transnoentities("Year").': '.$year; - $graph_datas=array(); - foreach($data_credit as $i => $val) + $file = $conf->bank->dir_temp."/movement".$account."-".$year.$month.".png"; + $fileurl = DOL_URL_ROOT.'/viewimage.php?modulepart=banque_temp&file='."/movement".$account."-".$year.$month.".png"; + $title = $langs->transnoentities("BankMovements").' - '.$langs->transnoentities("Month").': '.$month.' '.$langs->transnoentities("Year").': '.$year; + $graph_datas = array(); + foreach ($data_credit as $i => $val) { - $graph_datas[$i]=array($labels[$i],$data_credit[$i],$data_debit[$i]); + $graph_datas[$i] = array($labels[$i], $data_credit[$i], $data_debit[$i]); } $px4 = new DolGraph(); $px4->SetData($graph_datas); - $px4->SetLegend(array($langs->transnoentities("Credit"),$langs->transnoentities("Debit"))); + $px4->SetLegend(array($langs->transnoentities("Credit"), $langs->transnoentities("Debit"))); $px4->SetLegendWidthMin(180); - $px4->SetMaxValue($px4->GetCeilMaxValue()<0?0:$px4->GetCeilMaxValue()); - $px4->SetMinValue($px4->GetFloorMinValue()>0?0:$px4->GetFloorMinValue()); + $px4->SetMaxValue($px4->GetCeilMaxValue() < 0 ? 0 : $px4->GetCeilMaxValue()); + $px4->SetMinValue($px4->GetFloorMinValue() > 0 ? 0 : $px4->GetFloorMinValue()); $px4->SetTitle($title); $px4->SetWidth($WIDTH); $px4->SetHeight($HEIGHT); - $px4->SetType(array('bars','bars')); + $px4->SetType(array('bars', 'bars')); $px4->SetShading(3); $px4->setBgColor('onglet'); - $px4->setBgColorGrid(array(255,255,255)); + $px4->setBgColorGrid(array(255, 255, 255)); $px4->SetHorizTickIncrement(1); $px4->draw($file, $fileurl); - $show4=$px4->show(); + $show4 = $px4->show(); unset($graph_datas); unset($px4); @@ -648,15 +648,15 @@ else $credits = array(); $debits = array(); $sql = "SELECT date_format(b.datev,'%m')"; - $sql.= ", SUM(b.amount)"; - $sql.= " FROM ".MAIN_DB_PREFIX."bank as b"; - $sql.= ", ".MAIN_DB_PREFIX."bank_account as ba"; - $sql.= " WHERE b.fk_account = ba.rowid"; - $sql.= " AND ba.entity IN (".getEntity('bank_account').")"; - $sql.= " AND b.datev >= '".$year."-01-01 00:00:00'"; - $sql.= " AND b.datev <= '".$year."-12-31 23:59:59'"; - $sql.= " AND b.amount > 0"; - if ($account && $_GET["option"]!='all') $sql.= " AND b.fk_account IN (".$account.")"; + $sql .= ", SUM(b.amount)"; + $sql .= " FROM ".MAIN_DB_PREFIX."bank as b"; + $sql .= ", ".MAIN_DB_PREFIX."bank_account as ba"; + $sql .= " WHERE b.fk_account = ba.rowid"; + $sql .= " AND ba.entity IN (".getEntity('bank_account').")"; + $sql .= " AND b.datev >= '".$year."-01-01 00:00:00'"; + $sql .= " AND b.datev <= '".$year."-12-31 23:59:59'"; + $sql .= " AND b.amount > 0"; + if ($account && $_GET["option"] != 'all') $sql .= " AND b.fk_account IN (".$account.")"; $sql .= " GROUP BY date_format(b.datev,'%m');"; $resql = $db->query($sql); @@ -677,15 +677,15 @@ else dol_print_error($db); } $sql = "SELECT date_format(b.datev,'%m')"; - $sql.= ", SUM(b.amount)"; - $sql.= " FROM ".MAIN_DB_PREFIX."bank as b"; - $sql.= ", ".MAIN_DB_PREFIX."bank_account as ba"; - $sql.= " WHERE b.fk_account = ba.rowid"; - $sql.= " AND ba.entity IN (".getEntity('bank_account').")"; - $sql.= " AND b.datev >= '".$year."-01-01 00:00:00'"; - $sql.= " AND b.datev <= '".$year."-12-31 23:59:59'"; - $sql.= " AND b.amount < 0"; - if ($account && $_GET["option"]!='all') $sql.= " AND b.fk_account IN (".$account.")"; + $sql .= ", SUM(b.amount)"; + $sql .= " FROM ".MAIN_DB_PREFIX."bank as b"; + $sql .= ", ".MAIN_DB_PREFIX."bank_account as ba"; + $sql .= " WHERE b.fk_account = ba.rowid"; + $sql .= " AND ba.entity IN (".getEntity('bank_account').")"; + $sql .= " AND b.datev >= '".$year."-01-01 00:00:00'"; + $sql .= " AND b.datev <= '".$year."-12-31 23:59:59'"; + $sql .= " AND b.amount < 0"; + if ($account && $_GET["option"] != 'all') $sql .= " AND b.fk_account IN (".$account.")"; $sql .= " GROUP BY date_format(b.datev,'%m')"; $resql = $db->query($sql); @@ -707,40 +707,40 @@ else $labels = array(); $data_credit = array(); $data_debit = array(); - for ($i = 0 ; $i < 12 ; $i++) + for ($i = 0; $i < 12; $i++) { - $data_credit[$i] = isset($credits[substr("0".($i+1), -2)]) ? $credits[substr("0".($i+1), -2)] : 0; - $data_debit[$i] = isset($debits[substr("0".($i+1), -2)]) ? $debits[substr("0".($i+1), -2)] : 0; - $labels[$i] = dol_print_date(dol_mktime(12, 0, 0, $i+1, 1, 2000), "%b"); + $data_credit[$i] = isset($credits[substr("0".($i + 1), -2)]) ? $credits[substr("0".($i + 1), -2)] : 0; + $data_debit[$i] = isset($debits[substr("0".($i + 1), -2)]) ? $debits[substr("0".($i + 1), -2)] : 0; + $labels[$i] = dol_print_date(dol_mktime(12, 0, 0, $i + 1, 1, 2000), "%b"); $datamin[$i] = $object->min_desired; } // Fabrication tableau 4b - $file= $conf->bank->dir_temp."/movement".$account."-".$year.".png"; - $fileurl=DOL_URL_ROOT.'/viewimage.php?modulepart=banque_temp&file='."/movement".$account."-".$year.".png"; - $title=$langs->transnoentities("BankMovements").' - '.$langs->transnoentities("Year").': '.$year; - $graph_datas=array(); - foreach($data_credit as $i => $val) + $file = $conf->bank->dir_temp."/movement".$account."-".$year.".png"; + $fileurl = DOL_URL_ROOT.'/viewimage.php?modulepart=banque_temp&file='."/movement".$account."-".$year.".png"; + $title = $langs->transnoentities("BankMovements").' - '.$langs->transnoentities("Year").': '.$year; + $graph_datas = array(); + foreach ($data_credit as $i => $val) { - $graph_datas[$i]=array($labels[$i],$data_credit[$i],$data_debit[$i]); + $graph_datas[$i] = array($labels[$i], $data_credit[$i], $data_debit[$i]); } $px5 = new DolGraph(); $px5->SetData($graph_datas); - $px5->SetLegend(array($langs->transnoentities("Credit"),$langs->transnoentities("Debit"))); + $px5->SetLegend(array($langs->transnoentities("Credit"), $langs->transnoentities("Debit"))); $px5->SetLegendWidthMin(180); - $px5->SetMaxValue($px5->GetCeilMaxValue()<0?0:$px5->GetCeilMaxValue()); - $px5->SetMinValue($px5->GetFloorMinValue()>0?0:$px5->GetFloorMinValue()); + $px5->SetMaxValue($px5->GetCeilMaxValue() < 0 ? 0 : $px5->GetCeilMaxValue()); + $px5->SetMinValue($px5->GetFloorMinValue() > 0 ? 0 : $px5->GetFloorMinValue()); $px5->SetTitle($title); $px5->SetWidth($WIDTH); $px5->SetHeight($HEIGHT); - $px5->SetType(array('bars','bars')); + $px5->SetType(array('bars', 'bars')); $px5->SetShading(3); $px5->setBgColor('onglet'); - $px5->setBgColorGrid(array(255,255,255)); + $px5->setBgColorGrid(array(255, 255, 255)); $px5->SetHorizTickIncrement(1); $px5->draw($file, $fileurl); - $show5=$px5->show(); + $show5 = $px5->show(); unset($graph_datas); unset($px5); @@ -751,7 +751,7 @@ else // Onglets -$head=bank_prepare_head($object); +$head = bank_prepare_head($object); dol_fiche_head($head, 'graph', $langs->trans("FinancialAccount"), 0, 'account'); @@ -759,32 +759,32 @@ $linkback = ''.$langs->trans("ShowAllAccounts").''; + $morehtml = ''.$langs->trans("ShowAllAccounts").''; dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', '', $moreparam, 0, '', '', 1); } else { - $morehtml=''.$langs->trans("BackToAccount").''; + $morehtml = ''.$langs->trans("BackToAccount").''; print $langs->trans("AllAccounts"); //print $morehtml; } } else { - $bankaccount=new Account($db); - $listid=explode(',', $account); - foreach($listid as $key => $id) + $bankaccount = new Account($db); + $listid = explode(',', $account); + foreach ($listid as $key => $id) { $bankaccount->fetch($id); - $bankaccount->label=$bankaccount->ref; + $bankaccount->label = $bankaccount->ref; print $bankaccount->getNomUrl(1); - if ($key < (count($listid)-1)) print ', '; + if ($key < (count($listid) - 1)) print ', '; } } } @@ -818,13 +818,13 @@ print '

'; // Graphs if ($mode == 'standard') { - $prevyear=$year; $nextyear=$year; - $prevmonth=$month-1;$nextmonth=$month+1; - if ($prevmonth < 1) { $prevmonth=12; $prevyear--; } - if ($nextmonth > 12) { $nextmonth=1; $nextyear++; } + $prevyear = $year; $nextyear = $year; + $prevmonth = $month - 1; $nextmonth = $month + 1; + if ($prevmonth < 1) { $prevmonth = 12; $prevyear--; } + if ($nextmonth > 12) { $nextmonth = 1; $nextyear++; } // For month - $link="".img_previous('', 'class="valignbottom"')." ".$langs->trans("Month")." ".img_next('', 'class="valignbottom"').""; + $link = "".img_previous('', 'class="valignbottom"')." ".$langs->trans("Month")." ".img_next('', 'class="valignbottom"').""; print ''.$link.''; print ''; @@ -837,8 +837,8 @@ if ($mode == 'standard') print ''; // For year - $prevyear=$year-1;$nextyear=$year+1; - $link="".img_previous('', 'class="valignbottom"')." ".$langs->trans("Year")." ".img_next('', 'class="valignbottom"').""; + $prevyear = $year - 1; $nextyear = $year + 1; + $link = "".img_previous('', 'class="valignbottom"')." ".$langs->trans("Year")." ".img_next('', 'class="valignbottom"').""; print ''.$link.''; print ''; diff --git a/htdocs/core/boxes/box_shipments.php b/htdocs/core/boxes/box_shipments.php index 957c738ad22..3b07b5bbd68 100644 --- a/htdocs/core/boxes/box_shipments.php +++ b/htdocs/core/boxes/box_shipments.php @@ -32,9 +32,9 @@ include_once DOL_DOCUMENT_ROOT.'/core/boxes/modules_boxes.php'; */ class box_shipments extends ModeleBoxes { - public $boxcode="lastcustomershipments"; - public $boximg="sending"; - public $boxlabel="BoxLastCustomerShipments"; + public $boxcode = "lastcustomershipments"; + public $boximg = "sending"; + public $boxlabel = "BoxLastCustomerShipments"; public $depends = array("expedition"); /** @@ -58,9 +58,9 @@ class box_shipments extends ModeleBoxes { global $user; - $this->db=$db; + $this->db = $db; - $this->hidden=! ($user->rights->expedition->lire); + $this->hidden = !($user->rights->expedition->lire); } /** @@ -88,26 +88,26 @@ class box_shipments extends ModeleBoxes if ($user->rights->expedition->lire) { $sql = "SELECT s.nom as name"; - $sql.= ", s.rowid as socid"; - $sql.= ", s.code_client"; - $sql.= ", s.logo, s.email"; - $sql.= ", e.ref, e.tms"; - $sql.= ", e.rowid"; - $sql.= ", e.ref_customer"; - $sql.= ", e.fk_statut"; - $sql.= ", e.fk_user_valid"; - $sql.= ", c.ref as commande_ref"; - $sql.= ", c.rowid as commande_id"; - $sql.= " FROM ".MAIN_DB_PREFIX."expedition as e"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."element_element as el ON e.rowid = el.fk_target AND el.targettype = 'shipping' AND el.sourcetype IN ('commande')"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."commande as c ON el.fk_source = c.rowid AND el.sourcetype IN ('commande') AND el.targettype = 'shipping'"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = e.fk_soc"; - if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON e.fk_soc = sc.fk_soc"; - $sql.= " WHERE e.entity = ".$conf->entity; - if (! empty($conf->global->ORDER_BOX_LAST_SHIPMENTS_VALIDATED_ONLY)) $sql.=" AND e.fk_statut = 1"; - if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= " AND sc.fk_user = " .$user->id; - else $sql.= " ORDER BY e.date_delivery, e.ref DESC "; - $sql.= $this->db->plimit($max, 0); + $sql .= ", s.rowid as socid"; + $sql .= ", s.code_client"; + $sql .= ", s.logo, s.email"; + $sql .= ", e.ref, e.tms"; + $sql .= ", e.rowid"; + $sql .= ", e.ref_customer"; + $sql .= ", e.fk_statut"; + $sql .= ", e.fk_user_valid"; + $sql .= ", c.ref as commande_ref"; + $sql .= ", c.rowid as commande_id"; + $sql .= " FROM ".MAIN_DB_PREFIX."expedition as e"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."element_element as el ON e.rowid = el.fk_target AND el.targettype = 'shipping' AND el.sourcetype IN ('commande')"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."commande as c ON el.fk_source = c.rowid AND el.sourcetype IN ('commande') AND el.targettype = 'shipping'"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = e.fk_soc"; + if (!$user->rights->societe->client->voir && !$user->societe_id) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON e.fk_soc = sc.fk_soc"; + $sql .= " WHERE e.entity = ".$conf->entity; + if (!empty($conf->global->ORDER_BOX_LAST_SHIPMENTS_VALIDATED_ONLY)) $sql .= " AND e.fk_statut = 1"; + if (!$user->rights->societe->client->voir && !$user->societe_id) $sql .= " AND sc.fk_user = ".$user->id; + else $sql .= " ORDER BY e.date_delivery, e.ref DESC "; + $sql .= $this->db->plimit($max, 0); $result = $this->db->query($sql); if ($result) { @@ -122,8 +122,8 @@ class box_shipments extends ModeleBoxes $shipmentstatic->ref = $objp->ref; $shipmentstatic->ref_customer = $objp->ref_customer; - $orderstatic->id= $objp->commande_id; - $orderstatic->ref=$objp->commande_ref; + $orderstatic->id = $objp->commande_id; + $orderstatic->ref = $objp->commande_ref; $societestatic->id = $objp->socid; $societestatic->name = $objp->name; @@ -157,7 +157,7 @@ class box_shipments extends ModeleBoxes $line++; } - if ($num==0) $this->info_box_contents[$line][0] = array('td' => 'class="center"','text'=>$langs->trans("NoRecordedShipments")); + if ($num == 0) $this->info_box_contents[$line][0] = array('td' => 'class="center"', 'text'=>$langs->trans("NoRecordedShipments")); $this->db->free($result); } else { diff --git a/htdocs/core/class/emailsenderprofile.class.php b/htdocs/core/class/emailsenderprofile.class.php index 41a0d485ce0..9fbf98fc19c 100644 --- a/htdocs/core/class/emailsenderprofile.class.php +++ b/htdocs/core/class/emailsenderprofile.class.php @@ -26,7 +26,7 @@ */ // Put here all includes required by your class file -require_once DOL_DOCUMENT_ROOT . '/core/class/commonobject.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php'; //require_once DOL_DOCUMENT_ROOT . '/societe/class/societe.class.php'; //require_once DOL_DOCUMENT_ROOT . '/product/class/product.class.php'; @@ -84,7 +84,7 @@ class EmailSenderProfile extends CommonObject /** * @var array Array with all fields and their property. Do not use it as a static var. It may be modified by constructor. */ - public $fields=array( + public $fields = array( 'rowid' => array('type'=>'integer', 'label'=>'TechnicalID', 'visible'=>-1, 'enabled'=>1, 'position'=>1, 'notnull'=>1, 'index'=>1, 'comment'=>'Id',), 'entity' => array('type'=>'integer', 'label'=>'Entity', 'visible'=>-1, 'enabled'=>1, 'position'=>20, 'notnull'=>1, 'index'=>1,), 'label' => array('type'=>'varchar(255)', 'label'=>'Label', 'visible'=>1, 'enabled'=>1, 'position'=>30, 'notnull'=>1), @@ -167,8 +167,8 @@ class EmailSenderProfile extends CommonObject $this->db = $db; - if (empty($conf->global->MAIN_SHOW_TECHNICAL_ID)) $this->fields['rowid']['visible']=0; - if (empty($conf->multicompany->enabled)) $this->fields['entity']['enabled']=0; + if (empty($conf->global->MAIN_SHOW_TECHNICAL_ID)) $this->fields['rowid']['visible'] = 0; + if (empty($conf->multicompany->enabled)) $this->fields['entity']['enabled'] = 0; } /** @@ -244,7 +244,7 @@ class EmailSenderProfile extends CommonObject public function fetch($id, $ref = null) { $result = $this->fetchCommon($id, $ref); - if ($result > 0 && ! empty($this->table_element_line)) $this->fetchLines(); + if ($result > 0 && !empty($this->table_element_line)) $this->fetchLines(); return $result; } @@ -255,11 +255,11 @@ class EmailSenderProfile extends CommonObject */ public function fetchLines() { - $this->lines=array(); + $this->lines = array(); // Load lines with object EmailSenderProfileLine - return count($this->lines)?1:0; + return count($this->lines) ? 1 : 0; } /** @@ -301,19 +301,19 @@ class EmailSenderProfile extends CommonObject $result = ''; $companylink = ''; - $label=$this->label; + $label = $this->label; - $url=''; + $url = ''; //$url = dol_buildpath('/monmodule/emailsenderprofile_card.php',1).'?id='.$this->id; $linkstart = ''; - $linkend=''; + $linkend = ''; if ($withpicto) { - $result.=($linkstart.img_object($label, 'label', 'class="classfortooltip"').$linkend); - if ($withpicto != 2) $result.=' '; + $result .= ($linkstart.img_object($label, 'label', 'class="classfortooltip"').$linkend); + if ($withpicto != 2) $result .= ' '; } - $result.= $linkstart . $this->label . $linkend; + $result .= $linkstart.$this->label.$linkend; return $result; } @@ -381,10 +381,10 @@ class EmailSenderProfile extends CommonObject public function info($id) { $sql = 'SELECT rowid, date_creation as datec, tms as datem,'; - $sql.= ' fk_user_creat, fk_user_modif'; - $sql.= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t'; - $sql.= ' WHERE t.rowid = '.$id; - $result=$this->db->query($sql); + $sql .= ' fk_user_creat, fk_user_modif'; + $sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t'; + $sql .= ' WHERE t.rowid = '.$id; + $result = $this->db->query($sql); if ($result) { if ($this->db->num_rows($result)) @@ -395,7 +395,7 @@ class EmailSenderProfile extends CommonObject { $cuser = new User($this->db); $cuser->fetch($obj->fk_user_author); - $this->user_creation = $cuser; + $this->user_creation = $cuser; } if ($obj->fk_user_valid) @@ -409,7 +409,7 @@ class EmailSenderProfile extends CommonObject { $cluser = new User($this->db); $cluser->fetch($obj->fk_user_cloture); - $this->user_cloture = $cluser; + $this->user_cloture = $cluser; } $this->date_creation = $this->db->jdate($obj->datec); diff --git a/htdocs/core/class/events.class.php b/htdocs/core/class/events.class.php index f6537bf6528..c32fe1d77f2 100644 --- a/htdocs/core/class/events.class.php +++ b/htdocs/core/class/events.class.php @@ -31,12 +31,12 @@ class Events // extends CommonObject /** * @var string ID to identify managed object */ - public $element='events'; + public $element = 'events'; /** * @var string Name of table without prefix where object is stored */ - public $table_element='events'; + public $table_element = 'events'; /** * @var int ID @@ -51,7 +51,7 @@ class Events // extends CommonObject /** * @var string Error code (or message) */ - public $error=''; + public $error = ''; /** * @var int timestamp @@ -91,18 +91,18 @@ class Events // extends CommonObject public $prefix_session; // List of all Audit/Security events supported by triggers - public $eventstolog=array( - array('id'=>'USER_LOGIN', 'test'=>1), - array('id'=>'USER_LOGIN_FAILED', 'test'=>1), - array('id'=>'USER_LOGOUT', 'test'=>1), - array('id'=>'USER_CREATE', 'test'=>1), - array('id'=>'USER_MODIFY', 'test'=>1), - array('id'=>'USER_NEW_PASSWORD', 'test'=>1), - array('id'=>'USER_ENABLEDISABLE', 'test'=>1), - array('id'=>'USER_DELETE', 'test'=>1), - array('id'=>'GROUP_CREATE', 'test'=>1), - array('id'=>'GROUP_MODIFY', 'test'=>1), - array('id'=>'GROUP_DELETE', 'test'=>1), + public $eventstolog = array( + array('id'=>'USER_LOGIN', 'test'=>1), + array('id'=>'USER_LOGIN_FAILED', 'test'=>1), + array('id'=>'USER_LOGOUT', 'test'=>1), + array('id'=>'USER_CREATE', 'test'=>1), + array('id'=>'USER_MODIFY', 'test'=>1), + array('id'=>'USER_NEW_PASSWORD', 'test'=>1), + array('id'=>'USER_ENABLEDISABLE', 'test'=>1), + array('id'=>'USER_DELETE', 'test'=>1), + array('id'=>'GROUP_CREATE', 'test'=>1), + array('id'=>'GROUP_MODIFY', 'test'=>1), + array('id'=>'GROUP_DELETE', 'test'=>1), ); @@ -110,11 +110,11 @@ class Events // extends CommonObject /** * @var array Array with all fields and their property. Do not use it as a static var. It may be modified by constructor. */ - public $fields=array( - 'rowid' =>array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>1, 'visible'=>-2, 'noteditable'=>1, 'notnull'=> 1, 'index'=>1, 'position'=>1, 'comment'=>'Id'), - 'entity' =>array('type'=>'integer', 'label'=>'Entity', 'enabled'=>1, 'visible'=>0, 'notnull'=> 1, 'default'=>1, 'index'=>1, 'position'=>20), - 'prefix_session'=>array('type'=>'varchar(255)', 'label'=>'PrefixSession', 'enabled'=>1, 'visible'=>-1, 'notnull'=>-1, 'index'=>0, 'position'=>1000), - 'user_agent' =>array('type'=>'varchar(255)', 'label'=>'UserAgent', 'enabled'=>1, 'visible'=>-1, 'notnull'=> 1, 'default'=>0, 'index'=>1, 'position'=>1000), + public $fields = array( + 'rowid' =>array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>1, 'visible'=>-2, 'noteditable'=>1, 'notnull'=> 1, 'index'=>1, 'position'=>1, 'comment'=>'Id'), + 'entity' =>array('type'=>'integer', 'label'=>'Entity', 'enabled'=>1, 'visible'=>0, 'notnull'=> 1, 'default'=>1, 'index'=>1, 'position'=>20), + 'prefix_session'=>array('type'=>'varchar(255)', 'label'=>'PrefixSession', 'enabled'=>1, 'visible'=>-1, 'notnull'=>-1, 'index'=>0, 'position'=>1000), + 'user_agent' =>array('type'=>'varchar(255)', 'label'=>'UserAgent', 'enabled'=>1, 'visible'=>-1, 'notnull'=> 1, 'default'=>0, 'index'=>1, 'position'=>1000), ); @@ -140,35 +140,35 @@ class Events // extends CommonObject global $conf; // Clean parameters - $this->description=trim($this->description); - if (empty($this->user_agent) && !empty($_SERVER['HTTP_USER_AGENT'])) $this->user_agent=$_SERVER['HTTP_USER_AGENT']; + $this->description = trim($this->description); + if (empty($this->user_agent) && !empty($_SERVER['HTTP_USER_AGENT'])) $this->user_agent = $_SERVER['HTTP_USER_AGENT']; // Check parameters - if (empty($this->description)) { $this->error='ErrorBadValueForParameterCreateEventDesc'; return -1; } + if (empty($this->description)) { $this->error = 'ErrorBadValueForParameterCreateEventDesc'; return -1; } // Insert request $sql = "INSERT INTO ".MAIN_DB_PREFIX."events("; - $sql.= "type,"; - $sql.= "entity,"; - $sql.= "ip,"; - $sql.= "user_agent,"; - $sql.= "dateevent,"; - $sql.= "fk_user,"; - $sql.= "description,"; - $sql.= "prefix_session"; - $sql.= ") VALUES ("; - $sql.= " '".$this->db->escape($this->type)."',"; - $sql.= " ".$conf->entity.","; - $sql.= " '".$this->db->escape(getUserRemoteIP())."',"; - $sql.= " ".($this->user_agent ? "'".$this->db->escape(dol_trunc($this->user_agent, 250))."'" : 'NULL').","; - $sql.= " '".$this->db->idate($this->dateevent)."',"; - $sql.= " ".($user->id?"'".$this->db->escape($user->id)."'":'NULL').","; - $sql.= " '".$this->db->escape(dol_trunc($this->description, 250))."',"; - $sql.= " '".$this->db->escape(dol_getprefix())."'"; - $sql.= ")"; + $sql .= "type,"; + $sql .= "entity,"; + $sql .= "ip,"; + $sql .= "user_agent,"; + $sql .= "dateevent,"; + $sql .= "fk_user,"; + $sql .= "description,"; + $sql .= "prefix_session"; + $sql .= ") VALUES ("; + $sql .= " '".$this->db->escape($this->type)."',"; + $sql .= " ".$conf->entity.","; + $sql .= " '".$this->db->escape(getUserRemoteIP())."',"; + $sql .= " ".($this->user_agent ? "'".$this->db->escape(dol_trunc($this->user_agent, 250))."'" : 'NULL').","; + $sql .= " '".$this->db->idate($this->dateevent)."',"; + $sql .= " ".($user->id ? "'".$this->db->escape($user->id)."'" : 'NULL').","; + $sql .= " '".$this->db->escape(dol_trunc($this->description, 250))."',"; + $sql .= " '".$this->db->escape(dol_getprefix())."'"; + $sql .= ")"; dol_syslog(get_class($this)."::create", LOG_DEBUG); - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if ($resql) { $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."events"); @@ -176,7 +176,7 @@ class Events // extends CommonObject } else { - $this->error="Error ".$this->db->lasterror(); + $this->error = "Error ".$this->db->lasterror(); return -1; } } @@ -193,24 +193,24 @@ class Events // extends CommonObject { // Clean parameters $this->id = (int) $this->id; - $this->type=trim($this->type); - $this->description=trim($this->description); + $this->type = trim($this->type); + $this->description = trim($this->description); // Check parameters // Put here code to add control on parameters values // Update request $sql = "UPDATE ".MAIN_DB_PREFIX."events SET"; - $sql.= " type='".$this->db->escape($this->type)."',"; - $sql.= " dateevent='".$this->db->idate($this->dateevent)."',"; - $sql.= " description='".$this->db->escape($this->description)."'"; - $sql.= " WHERE rowid=".$this->id; + $sql .= " type='".$this->db->escape($this->type)."',"; + $sql .= " dateevent='".$this->db->idate($this->dateevent)."',"; + $sql .= " description='".$this->db->escape($this->description)."'"; + $sql .= " WHERE rowid=".$this->id; dol_syslog(get_class($this)."::update", LOG_DEBUG); $resql = $this->db->query($sql); - if (! $resql) + if (!$resql) { - $this->error="Error ".$this->db->lasterror(); + $this->error = "Error ".$this->db->lasterror(); return -1; } return 1; @@ -227,20 +227,20 @@ class Events // extends CommonObject public function fetch($id, $user = null) { $sql = "SELECT"; - $sql.= " t.rowid,"; - $sql.= " t.tms,"; - $sql.= " t.type,"; - $sql.= " t.entity,"; - $sql.= " t.dateevent,"; - $sql.= " t.description,"; - $sql.= " t.ip,"; - $sql.= " t.user_agent,"; - $sql.= " t.prefix_session"; - $sql.= " FROM ".MAIN_DB_PREFIX."events as t"; - $sql.= " WHERE t.rowid = ".$id; + $sql .= " t.rowid,"; + $sql .= " t.tms,"; + $sql .= " t.type,"; + $sql .= " t.entity,"; + $sql .= " t.dateevent,"; + $sql .= " t.description,"; + $sql .= " t.ip,"; + $sql .= " t.user_agent,"; + $sql .= " t.prefix_session"; + $sql .= " FROM ".MAIN_DB_PREFIX."events as t"; + $sql .= " WHERE t.rowid = ".$id; dol_syslog(get_class($this)."::fetch", LOG_DEBUG); - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if ($resql) { if ($this->db->num_rows($resql)) @@ -263,7 +263,7 @@ class Events // extends CommonObject } else { - $this->error="Error ".$this->db->lasterror(); + $this->error = "Error ".$this->db->lasterror(); return -1; } } @@ -278,13 +278,13 @@ class Events // extends CommonObject public function delete($user) { $sql = "DELETE FROM ".MAIN_DB_PREFIX."events"; - $sql.= " WHERE rowid=".$this->id; + $sql .= " WHERE rowid=".$this->id; dol_syslog(get_class($this)."::delete", LOG_DEBUG); $resql = $this->db->query($sql); - if (! $resql) + if (!$resql) { - $this->error="Error ".$this->db->lasterror(); + $this->error = "Error ".$this->db->lasterror(); return -1; } @@ -301,12 +301,12 @@ class Events // extends CommonObject */ public function initAsSpecimen() { - $this->id=0; + $this->id = 0; - $this->tms=time(); - $this->type=''; - $this->dateevent=time(); - $this->description='This is a specimen event'; + $this->tms = time(); + $this->type = ''; + $this->dateevent = time(); + $this->description = 'This is a specimen event'; $this->ip = '1.2.3.4'; $this->user_agent = 'Mozilla specimen User Agent X.Y'; $this->prefix_session = dol_getprefix(); diff --git a/htdocs/core/class/html.formcron.class.php b/htdocs/core/class/html.formcron.class.php index 2a2a6c97078..2701d126331 100644 --- a/htdocs/core/class/html.formcron.class.php +++ b/htdocs/core/class/html.formcron.class.php @@ -36,7 +36,7 @@ class FormCron extends Form /** * @var string Error code (or message) */ - public $error=''; + public $error = ''; /** * Constructor @@ -66,35 +66,35 @@ class FormCron extends Form $langs->load('cron@cron'); $out = ''; if (!empty($readonly)) { - if ($selected=='command') { - $out= $langs->trans('CronType_command'); - $out.=''; - } elseif ($selected=='method') { - $out= $langs->trans('CronType_method'); - $out.=''; + if ($selected == 'command') { + $out = $langs->trans('CronType_command'); + $out .= ''; + } elseif ($selected == 'method') { + $out = $langs->trans('CronType_method'); + $out .= ''; } } else { - $out=''; - if ($selected=='command') { - $selected_attr=' selected '; + if ($selected == 'command') { + $selected_attr = ' selected '; } else { - $selected_attr=''; + $selected_attr = ''; } - $out.= ''; + $out .= ''; - if ($selected=='method') { - $selected_attr=' selected '; + if ($selected == 'method') { + $selected_attr = ' selected '; } else { - $selected_attr=''; + $selected_attr = ''; } - $out.= ''; + $out .= ''; - $out.=''; + $out .= ''; } return $out; diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 0d614198d1e..9c5b92a47a0 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -6061,49 +6061,49 @@ function getCommonSubstitutionArray($outputlangs, $onlykey = 0, $exclude = null, if (is_object($object) && $object->element == 'societe') { - $substitutionarray['__THIRDPARTY_ID__'] = (is_object($object)?$object->id:''); - $substitutionarray['__THIRDPARTY_NAME__'] = (is_object($object)?$object->name:''); - $substitutionarray['__THIRDPARTY_NAME_ALIAS__'] = (is_object($object)?$object->name_alias:''); - $substitutionarray['__THIRDPARTY_CODE_CLIENT__'] = (is_object($object)?$object->code_client:''); - $substitutionarray['__THIRDPARTY_CODE_FOURNISSEUR__'] = (is_object($object)?$object->code_fournisseur:''); - $substitutionarray['__THIRDPARTY_EMAIL__'] = (is_object($object)?$object->email:''); - $substitutionarray['__THIRDPARTY_PHONE__'] = (is_object($object)?$object->phone:''); - $substitutionarray['__THIRDPARTY_FAX__'] = (is_object($object)?$object->fax:''); - $substitutionarray['__THIRDPARTY_ADDRESS__'] = (is_object($object)?$object->address:''); - $substitutionarray['__THIRDPARTY_ZIP__'] = (is_object($object)?$object->zip:''); - $substitutionarray['__THIRDPARTY_TOWN__'] = (is_object($object)?$object->town:''); - $substitutionarray['__THIRDPARTY_IDPROF1__'] = (is_object($object)?$object->idprof1:''); - $substitutionarray['__THIRDPARTY_IDPROF2__'] = (is_object($object)?$object->idprof2:''); - $substitutionarray['__THIRDPARTY_IDPROF3__'] = (is_object($object)?$object->idprof3:''); - $substitutionarray['__THIRDPARTY_IDPROF4__'] = (is_object($object)?$object->idprof4:''); - $substitutionarray['__THIRDPARTY_IDPROF5__'] = (is_object($object)?$object->idprof5:''); - $substitutionarray['__THIRDPARTY_IDPROF6__'] = (is_object($object)?$object->idprof6:''); - $substitutionarray['__THIRDPARTY_TVAINTRA__'] = (is_object($object)?$object->tva_intra:''); - $substitutionarray['__THIRDPARTY_NOTE_PUBLIC__'] = (is_object($object)?dol_htmlentitiesbr($object->note_public):''); - $substitutionarray['__THIRDPARTY_NOTE_PRIVATE__'] = (is_object($object)?dol_htmlentitiesbr($object->note_private):''); + $substitutionarray['__THIRDPARTY_ID__'] = (is_object($object) ? $object->id : ''); + $substitutionarray['__THIRDPARTY_NAME__'] = (is_object($object) ? $object->name : ''); + $substitutionarray['__THIRDPARTY_NAME_ALIAS__'] = (is_object($object) ? $object->name_alias : ''); + $substitutionarray['__THIRDPARTY_CODE_CLIENT__'] = (is_object($object) ? $object->code_client : ''); + $substitutionarray['__THIRDPARTY_CODE_FOURNISSEUR__'] = (is_object($object) ? $object->code_fournisseur : ''); + $substitutionarray['__THIRDPARTY_EMAIL__'] = (is_object($object) ? $object->email : ''); + $substitutionarray['__THIRDPARTY_PHONE__'] = (is_object($object) ? $object->phone : ''); + $substitutionarray['__THIRDPARTY_FAX__'] = (is_object($object) ? $object->fax : ''); + $substitutionarray['__THIRDPARTY_ADDRESS__'] = (is_object($object) ? $object->address : ''); + $substitutionarray['__THIRDPARTY_ZIP__'] = (is_object($object) ? $object->zip : ''); + $substitutionarray['__THIRDPARTY_TOWN__'] = (is_object($object) ? $object->town : ''); + $substitutionarray['__THIRDPARTY_IDPROF1__'] = (is_object($object) ? $object->idprof1 : ''); + $substitutionarray['__THIRDPARTY_IDPROF2__'] = (is_object($object) ? $object->idprof2 : ''); + $substitutionarray['__THIRDPARTY_IDPROF3__'] = (is_object($object) ? $object->idprof3 : ''); + $substitutionarray['__THIRDPARTY_IDPROF4__'] = (is_object($object) ? $object->idprof4 : ''); + $substitutionarray['__THIRDPARTY_IDPROF5__'] = (is_object($object) ? $object->idprof5 : ''); + $substitutionarray['__THIRDPARTY_IDPROF6__'] = (is_object($object) ? $object->idprof6 : ''); + $substitutionarray['__THIRDPARTY_TVAINTRA__'] = (is_object($object) ? $object->tva_intra : ''); + $substitutionarray['__THIRDPARTY_NOTE_PUBLIC__'] = (is_object($object) ?dol_htmlentitiesbr($object->note_public) : ''); + $substitutionarray['__THIRDPARTY_NOTE_PRIVATE__'] = (is_object($object) ?dol_htmlentitiesbr($object->note_private) : ''); } elseif (is_object($object->thirdparty) && $object->thirdparty->id > 0) { - $substitutionarray['__THIRDPARTY_ID__'] = (is_object($object->thirdparty)?$object->thirdparty->id:''); - $substitutionarray['__THIRDPARTY_NAME__'] = (is_object($object->thirdparty)?$object->thirdparty->name:''); - $substitutionarray['__THIRDPARTY_NAME_ALIAS__'] = (is_object($object->thirdparty)?$object->thirdparty->name_alias:''); - $substitutionarray['__THIRDPARTY_CODE_CLIENT__'] = (is_object($object->thirdparty)?$object->thirdparty->code_client:''); - $substitutionarray['__THIRDPARTY_CODE_FOURNISSEUR__'] = (is_object($object->thirdparty)?$object->thirdparty->code_fournisseur:''); - $substitutionarray['__THIRDPARTY_EMAIL__'] = (is_object($object->thirdparty)?$object->thirdparty->email:''); - $substitutionarray['__THIRDPARTY_PHONE__'] = (is_object($object->thirdparty)?$object->thirdparty->phone:''); - $substitutionarray['__THIRDPARTY_FAX__'] = (is_object($object->thirdparty)?$object->thirdparty->fax:''); - $substitutionarray['__THIRDPARTY_ADDRESS__'] = (is_object($object->thirdparty)?$object->thirdparty->address:''); - $substitutionarray['__THIRDPARTY_ZIP__'] = (is_object($object->thirdparty)?$object->thirdparty->zip:''); - $substitutionarray['__THIRDPARTY_TOWN__'] = (is_object($object->thirdparty)?$object->thirdparty->town:''); - $substitutionarray['__THIRDPARTY_IDPROF1__'] = (is_object($object->thirdparty)?$object->thirdparty->idprof1:''); - $substitutionarray['__THIRDPARTY_IDPROF2__'] = (is_object($object->thirdparty)?$object->thirdparty->idprof2:''); - $substitutionarray['__THIRDPARTY_IDPROF3__'] = (is_object($object->thirdparty)?$object->thirdparty->idprof3:''); - $substitutionarray['__THIRDPARTY_IDPROF4__'] = (is_object($object->thirdparty)?$object->thirdparty->idprof4:''); - $substitutionarray['__THIRDPARTY_IDPROF5__'] = (is_object($object->thirdparty)?$object->thirdparty->idprof5:''); - $substitutionarray['__THIRDPARTY_IDPROF6__'] = (is_object($object->thirdparty)?$object->thirdparty->idprof6:''); - $substitutionarray['__THIRDPARTY_TVAINTRA__'] = (is_object($object->thirdparty)?$object->thirdparty->tva_intra:''); - $substitutionarray['__THIRDPARTY_NOTE_PUBLIC__'] = (is_object($object->thirdparty)?dol_htmlentitiesbr($object->thirdparty->note_public):''); - $substitutionarray['__THIRDPARTY_NOTE_PRIVATE__'] = (is_object($object->thirdparty)?dol_htmlentitiesbr($object->thirdparty->note_private):''); + $substitutionarray['__THIRDPARTY_ID__'] = (is_object($object->thirdparty) ? $object->thirdparty->id : ''); + $substitutionarray['__THIRDPARTY_NAME__'] = (is_object($object->thirdparty) ? $object->thirdparty->name : ''); + $substitutionarray['__THIRDPARTY_NAME_ALIAS__'] = (is_object($object->thirdparty) ? $object->thirdparty->name_alias : ''); + $substitutionarray['__THIRDPARTY_CODE_CLIENT__'] = (is_object($object->thirdparty) ? $object->thirdparty->code_client : ''); + $substitutionarray['__THIRDPARTY_CODE_FOURNISSEUR__'] = (is_object($object->thirdparty) ? $object->thirdparty->code_fournisseur : ''); + $substitutionarray['__THIRDPARTY_EMAIL__'] = (is_object($object->thirdparty) ? $object->thirdparty->email : ''); + $substitutionarray['__THIRDPARTY_PHONE__'] = (is_object($object->thirdparty) ? $object->thirdparty->phone : ''); + $substitutionarray['__THIRDPARTY_FAX__'] = (is_object($object->thirdparty) ? $object->thirdparty->fax : ''); + $substitutionarray['__THIRDPARTY_ADDRESS__'] = (is_object($object->thirdparty) ? $object->thirdparty->address : ''); + $substitutionarray['__THIRDPARTY_ZIP__'] = (is_object($object->thirdparty) ? $object->thirdparty->zip : ''); + $substitutionarray['__THIRDPARTY_TOWN__'] = (is_object($object->thirdparty) ? $object->thirdparty->town : ''); + $substitutionarray['__THIRDPARTY_IDPROF1__'] = (is_object($object->thirdparty) ? $object->thirdparty->idprof1 : ''); + $substitutionarray['__THIRDPARTY_IDPROF2__'] = (is_object($object->thirdparty) ? $object->thirdparty->idprof2 : ''); + $substitutionarray['__THIRDPARTY_IDPROF3__'] = (is_object($object->thirdparty) ? $object->thirdparty->idprof3 : ''); + $substitutionarray['__THIRDPARTY_IDPROF4__'] = (is_object($object->thirdparty) ? $object->thirdparty->idprof4 : ''); + $substitutionarray['__THIRDPARTY_IDPROF5__'] = (is_object($object->thirdparty) ? $object->thirdparty->idprof5 : ''); + $substitutionarray['__THIRDPARTY_IDPROF6__'] = (is_object($object->thirdparty) ? $object->thirdparty->idprof6 : ''); + $substitutionarray['__THIRDPARTY_TVAINTRA__'] = (is_object($object->thirdparty) ? $object->thirdparty->tva_intra : ''); + $substitutionarray['__THIRDPARTY_NOTE_PUBLIC__'] = (is_object($object->thirdparty) ?dol_htmlentitiesbr($object->thirdparty->note_public) : ''); + $substitutionarray['__THIRDPARTY_NOTE_PRIVATE__'] = (is_object($object->thirdparty) ?dol_htmlentitiesbr($object->thirdparty->note_private) : ''); } if (is_object($object->project) && $object->project->id > 0) diff --git a/htdocs/core/modules/modExpedition.class.php b/htdocs/core/modules/modExpedition.class.php index 8f99dcc59a1..96d3d3f45a5 100644 --- a/htdocs/core/modules/modExpedition.class.php +++ b/htdocs/core/modules/modExpedition.class.php @@ -27,7 +27,7 @@ * \brief Fichier de description et activation du module Expedition */ -include_once DOL_DOCUMENT_ROOT .'/core/modules/DolibarrModules.class.php'; +include_once DOL_DOCUMENT_ROOT.'/core/modules/DolibarrModules.class.php'; /** @@ -76,11 +76,11 @@ class modExpedition extends DolibarrModules $this->depends = array("modCommande"); $this->requiredby = array(); $this->conflictwith = array(); - $this->langfiles = array('deliveries','sendings'); + $this->langfiles = array('deliveries', 'sendings'); // Constants $this->const = array(); - $r=0; + $r = 0; $this->const[$r][0] = "EXPEDITION_ADDON_PDF"; $this->const[$r][1] = "chaine"; @@ -133,13 +133,13 @@ class modExpedition extends DolibarrModules // Boxes $this->boxes = array( - 0=>array('file'=>'box_shipments.php','enabledbydefaulton'=>'Home'), + 0=>array('file'=>'box_shipments.php', 'enabledbydefaulton'=>'Home'), ); // Permissions $this->rights = array(); $this->rights_class = 'expedition'; - $r=0; + $r = 0; $r++; $this->rights[$r][0] = 101; @@ -221,92 +221,92 @@ class modExpedition 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; include_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; - $shipment=new Commande($this->db); - $contact_arrays=$shipment->liste_type_contact('external', '', 0, 0, ''); - if (is_array($contact_arrays) && count($contact_arrays)>0){ - $idcontacts=join(',', array_keys($shipment->liste_type_contact('external', '', 0, 0, ''))); + $shipment = new Commande($this->db); + $contact_arrays = $shipment->liste_type_contact('external', '', 0, 0, ''); + if (is_array($contact_arrays) && count($contact_arrays) > 0) { + $idcontacts = join(',', array_keys($shipment->liste_type_contact('external', '', 0, 0, ''))); } else { - $idcontacts=0; + $idcontacts = 0; } $r++; - $this->export_code[$r]=$this->rights_class.'_'.$r; - $this->export_label[$r]='Shipments'; // Translation key (used only if key ExportDataset_xxx_z not found) - $this->export_permission[$r]=array(array("expedition","shipment","export")); - $this->export_fields_array[$r]=array( - 's.rowid'=>"IdCompany",'s.nom'=>'ThirdParty','s.address'=>'Address','s.zip'=>'Zip','s.town'=>'Town','d.nom'=>'State','co.label'=>'Country', - 'co.code'=>'CountryCode','s.phone'=>'Phone','s.siren'=>'ProfId1','s.siret'=>'ProfId2','s.ape'=>'ProfId3','s.idprof4'=>'ProfId4','s.idprof5'=>'ProfId5', - 's.idprof6'=>'ProfId6','c.rowid'=>"Id",'c.ref'=>"Ref",'c.ref_customer'=>"RefCustomer",'c.fk_soc'=>"IdCompany",'c.date_creation'=>"DateCreation", - 'c.date_delivery'=>"DateDeliveryPlanned",'c.tracking_number'=>"TrackingNumber",'c.height'=>"Height",'c.width'=>"Width",'c.size'=>"Depth", - 'c.size_units'=>'SizeUnits','c.weight'=>"Weight",'c.weight_units'=>"WeightUnits",'c.fk_statut'=>'Status','c.note_public'=>"NotePublic", - 'ed.rowid'=>'LineId','cd.description'=>'Description','ed.qty'=>"Qty",'p.rowid'=>'ProductId','p.ref'=>'ProductRef','p.label'=>'ProductLabel', - 'p.weight'=>'ProductWeight','p.weight_units'=>'WeightUnits','p.volume'=>'ProductVolume','p.volume_units'=>'VolumeUnits' + $this->export_code[$r] = $this->rights_class.'_'.$r; + $this->export_label[$r] = 'Shipments'; // Translation key (used only if key ExportDataset_xxx_z not found) + $this->export_permission[$r] = array(array("expedition", "shipment", "export")); + $this->export_fields_array[$r] = array( + 's.rowid'=>"IdCompany", 's.nom'=>'ThirdParty', 's.address'=>'Address', 's.zip'=>'Zip', 's.town'=>'Town', 'd.nom'=>'State', 'co.label'=>'Country', + 'co.code'=>'CountryCode', 's.phone'=>'Phone', 's.siren'=>'ProfId1', 's.siret'=>'ProfId2', 's.ape'=>'ProfId3', 's.idprof4'=>'ProfId4', 's.idprof5'=>'ProfId5', + 's.idprof6'=>'ProfId6', 'c.rowid'=>"Id", 'c.ref'=>"Ref", 'c.ref_customer'=>"RefCustomer", 'c.fk_soc'=>"IdCompany", 'c.date_creation'=>"DateCreation", + 'c.date_delivery'=>"DateDeliveryPlanned", 'c.tracking_number'=>"TrackingNumber", 'c.height'=>"Height", 'c.width'=>"Width", 'c.size'=>"Depth", + 'c.size_units'=>'SizeUnits', 'c.weight'=>"Weight", 'c.weight_units'=>"WeightUnits", 'c.fk_statut'=>'Status', 'c.note_public'=>"NotePublic", + 'ed.rowid'=>'LineId', 'cd.description'=>'Description', 'ed.qty'=>"Qty", 'p.rowid'=>'ProductId', 'p.ref'=>'ProductRef', 'p.label'=>'ProductLabel', + 'p.weight'=>'ProductWeight', 'p.weight_units'=>'WeightUnits', 'p.volume'=>'ProductVolume', 'p.volume_units'=>'VolumeUnits' ); - if ($idcontacts && ! empty($conf->global->SHIPMENT_ADD_CONTACTS_IN_EXPORT)) $this->export_fields_array[$r]+=array('sp.rowid'=>'IdContact','sp.lastname'=>'Lastname','sp.firstname'=>'Firstname','sp.note_public'=>'NotePublic'); + if ($idcontacts && !empty($conf->global->SHIPMENT_ADD_CONTACTS_IN_EXPORT)) $this->export_fields_array[$r] += array('sp.rowid'=>'IdContact', 'sp.lastname'=>'Lastname', 'sp.firstname'=>'Firstname', 'sp.note_public'=>'NotePublic'); //$this->export_TypeFields_array[$r]=array( // 's.rowid'=>"List:societe:nom",'s.nom'=>'Text','s.address'=>'Text','s.zip'=>'Text','s.town'=>'Text','co.label'=>'List:c_country:label:label', // 'co.code'=>'Text','s.phone'=>'Text','s.siren'=>'Text','s.siret'=>'Text','s.ape'=>'Text','s.idprof4'=>'Text','c.ref'=>"Text",'c.ref_client'=>"Text", // 'c.date_creation'=>"Date",'c.date_commande'=>"Date",'c.amount_ht'=>"Numeric",'c.remise_percent'=>"Numeric",'c.total_ht'=>"Numeric", // 'c.total_ttc'=>"Numeric",'c.facture'=>"Boolean",'c.fk_statut'=>'Status','c.note_public'=>"Text",'c.date_livraison'=>'Date','ed.qty'=>"Text" //); - $this->export_TypeFields_array[$r]=array( - 's.nom'=>'Text','s.address'=>'Text','s.zip'=>'Text','s.town'=>'Text','co.label'=>'List:c_country:label:label','co.code'=>'Text','s.phone'=>'Text', - 's.siren'=>'Text','s.siret'=>'Text','s.ape'=>'Text','s.idprof4'=>'Text','c.ref'=>"Text",'c.ref_customer'=>"Text",'c.date_creation'=>"Date", - 'c.date_delivery'=>"Date",'c.tracking_number'=>"Numeric",'c.height'=>"Numeric",'c.width'=>"Numeric",'c.weight'=>"Numeric",'c.fk_statut'=>'Status', - 'c.note_public'=>"Text",'ed.qty'=>"Numeric",'d.nom'=>'Text' + $this->export_TypeFields_array[$r] = array( + 's.nom'=>'Text', 's.address'=>'Text', 's.zip'=>'Text', 's.town'=>'Text', 'co.label'=>'List:c_country:label:label', 'co.code'=>'Text', 's.phone'=>'Text', + 's.siren'=>'Text', 's.siret'=>'Text', 's.ape'=>'Text', 's.idprof4'=>'Text', 'c.ref'=>"Text", 'c.ref_customer'=>"Text", 'c.date_creation'=>"Date", + 'c.date_delivery'=>"Date", 'c.tracking_number'=>"Numeric", 'c.height'=>"Numeric", 'c.width'=>"Numeric", 'c.weight'=>"Numeric", 'c.fk_statut'=>'Status', + 'c.note_public'=>"Text", 'ed.qty'=>"Numeric", 'd.nom'=>'Text' ); - $this->export_entities_array[$r]=array( - 's.rowid'=>"company",'s.nom'=>'company','s.address'=>'company','s.zip'=>'company','s.town'=>'company','d.nom'=>'company','co.label'=>'company', - 'co.code'=>'company','s.fk_pays'=>'company','s.phone'=>'company','s.siren'=>'company','s.ape'=>'company','s.siret'=>'company','s.idprof4'=>'company', - 's.idprof5'=>'company','s.idprof6'=>'company','c.rowid'=>"shipment",'c.ref'=>"shipment",'c.ref_customer'=>"shipment",'c.fk_soc'=>"shipment", - 'c.date_creation'=>"shipment",'c.date_delivery'=>"shipment",'c.tracking_number'=>'shipment','c.height'=>"shipment",'c.width'=>"shipment", - 'c.size'=>'shipment','c.size_units'=>'shipment','c.weight'=>"shipment",'c.weight_units'=>'shipment','c.fk_statut'=>"shipment",'c.note_public'=>"shipment", - 'ed.rowid'=>'shipment_line','cd.description'=>'shipment_line','ed.qty'=>"shipment_line",'p.rowid'=>'product','p.ref'=>'product','p.label'=>'product', - 'p.weight'=>'product','p.weight_units'=>'product','p.volume'=>'product','p.volume_units'=>'product' + $this->export_entities_array[$r] = array( + 's.rowid'=>"company", 's.nom'=>'company', 's.address'=>'company', 's.zip'=>'company', 's.town'=>'company', 'd.nom'=>'company', 'co.label'=>'company', + 'co.code'=>'company', 's.fk_pays'=>'company', 's.phone'=>'company', 's.siren'=>'company', 's.ape'=>'company', 's.siret'=>'company', 's.idprof4'=>'company', + 's.idprof5'=>'company', 's.idprof6'=>'company', 'c.rowid'=>"shipment", 'c.ref'=>"shipment", 'c.ref_customer'=>"shipment", 'c.fk_soc'=>"shipment", + 'c.date_creation'=>"shipment", 'c.date_delivery'=>"shipment", 'c.tracking_number'=>'shipment', 'c.height'=>"shipment", 'c.width'=>"shipment", + 'c.size'=>'shipment', 'c.size_units'=>'shipment', 'c.weight'=>"shipment", 'c.weight_units'=>'shipment', 'c.fk_statut'=>"shipment", 'c.note_public'=>"shipment", + 'ed.rowid'=>'shipment_line', 'cd.description'=>'shipment_line', 'ed.qty'=>"shipment_line", 'p.rowid'=>'product', 'p.ref'=>'product', 'p.label'=>'product', + 'p.weight'=>'product', 'p.weight_units'=>'product', 'p.volume'=>'product', 'p.volume_units'=>'product' ); - if ($idcontacts && ! empty($conf->global->SHIPMENT_ADD_CONTACTS_IN_EXPORT)) $this->export_entities_array[$r]+=array('sp.rowid'=>'contact','sp.lastname'=>'contact','sp.firstname'=>'contact','sp.note_public'=>'contact'); - $this->export_dependencies_array[$r]=array('shipment_line'=>'ed.rowid','product'=>'ed.rowid'); // To add unique key if we ask a field of a child to avoid the DISTINCT to discard them - if ($idcontacts && ! empty($conf->global->SHIPMENT_ADD_CONTACTS_IN_EXPORT)) + if ($idcontacts && !empty($conf->global->SHIPMENT_ADD_CONTACTS_IN_EXPORT)) $this->export_entities_array[$r] += array('sp.rowid'=>'contact', 'sp.lastname'=>'contact', 'sp.firstname'=>'contact', 'sp.note_public'=>'contact'); + $this->export_dependencies_array[$r] = array('shipment_line'=>'ed.rowid', 'product'=>'ed.rowid'); // To add unique key if we ask a field of a child to avoid the DISTINCT to discard them + if ($idcontacts && !empty($conf->global->SHIPMENT_ADD_CONTACTS_IN_EXPORT)) { - $keyforselect='socpeople'; $keyforelement='contact'; $keyforaliasextra='extra3'; + $keyforselect = 'socpeople'; $keyforelement = 'contact'; $keyforaliasextra = 'extra3'; include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php'; } - $keyforselect='expedition'; $keyforelement='shipment'; $keyforaliasextra='extra'; + $keyforselect = 'expedition'; $keyforelement = 'shipment'; $keyforaliasextra = 'extra'; include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php'; - $keyforselect='expeditiondet'; $keyforelement='shipment_line'; $keyforaliasextra='extra2'; + $keyforselect = 'expeditiondet'; $keyforelement = 'shipment_line'; $keyforaliasextra = 'extra2'; include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php'; - $keyforselect='product'; $keyforelement='product'; $keyforaliasextra='extraprod'; + $keyforselect = 'product'; $keyforelement = 'product'; $keyforaliasextra = 'extraprod'; include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php'; - $this->export_sql_start[$r]='SELECT DISTINCT '; - $this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'expedition as c'; - $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'expedition_extrafields as extra ON c.rowid = extra.fk_object,'; - $this->export_sql_end[$r] .=' '.MAIN_DB_PREFIX.'societe as s'; - if(!$user->rights->societe->client->voir) $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'societe_commerciaux as sc ON sc.fk_soc = s.rowid'; - $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_departements as d ON s.fk_departement = d.rowid'; - $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_country as co ON s.fk_pays = co.rowid,'; - $this->export_sql_end[$r] .=' '.MAIN_DB_PREFIX.'expeditiondet as ed'; - $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'expeditiondet_extrafields as extra2 ON ed.rowid = extra2.fk_object'; - $this->export_sql_end[$r] .=' , '.MAIN_DB_PREFIX.'commandedet as cd'; - $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'product as p on cd.fk_product = p.rowid'; - $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'product_extrafields as extraprod ON p.rowid = extraprod.fk_object'; - if ($idcontacts && ! empty($conf->global->SHIPMENT_ADD_CONTACTS_IN_EXPORT)) { - $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'element_contact as ee ON ee.element_id = cd.fk_commande AND ee.fk_c_type_contact IN ('.$idcontacts.')'; - $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'socpeople as sp ON sp.rowid = ee.fk_socpeople'; - $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'socpeople_extrafields as extra3 ON sp.rowid = extra3.fk_object'; + $this->export_sql_start[$r] = 'SELECT DISTINCT '; + $this->export_sql_end[$r] = ' FROM '.MAIN_DB_PREFIX.'expedition as c'; + $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'expedition_extrafields as extra ON c.rowid = extra.fk_object,'; + $this->export_sql_end[$r] .= ' '.MAIN_DB_PREFIX.'societe as s'; + if (!$user->rights->societe->client->voir) $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe_commerciaux as sc ON sc.fk_soc = s.rowid'; + $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_departements as d ON s.fk_departement = d.rowid'; + $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_country as co ON s.fk_pays = co.rowid,'; + $this->export_sql_end[$r] .= ' '.MAIN_DB_PREFIX.'expeditiondet as ed'; + $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'expeditiondet_extrafields as extra2 ON ed.rowid = extra2.fk_object'; + $this->export_sql_end[$r] .= ' , '.MAIN_DB_PREFIX.'commandedet as cd'; + $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p on cd.fk_product = p.rowid'; + $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product_extrafields as extraprod ON p.rowid = extraprod.fk_object'; + if ($idcontacts && !empty($conf->global->SHIPMENT_ADD_CONTACTS_IN_EXPORT)) { + $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'element_contact as ee ON ee.element_id = cd.fk_commande AND ee.fk_c_type_contact IN ('.$idcontacts.')'; + $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'socpeople as sp ON sp.rowid = ee.fk_socpeople'; + $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'socpeople_extrafields as extra3 ON sp.rowid = extra3.fk_object'; } - $this->export_sql_end[$r] .=' WHERE c.fk_soc = s.rowid AND c.rowid = ed.fk_expedition AND ed.fk_origin_line = cd.rowid'; - $this->export_sql_end[$r] .=' AND c.entity IN ('.getEntity('expedition').')'; - if(!$user->rights->societe->client->voir) $this->export_sql_end[$r] .=' AND sc.fk_user = '.$user->id; + $this->export_sql_end[$r] .= ' WHERE c.fk_soc = s.rowid AND c.rowid = ed.fk_expedition AND ed.fk_origin_line = cd.rowid'; + $this->export_sql_end[$r] .= ' AND c.entity IN ('.getEntity('expedition').')'; + if (!$user->rights->societe->client->voir) $this->export_sql_end[$r] .= ' AND sc.fk_user = '.$user->id; } @@ -320,25 +320,25 @@ class modExpedition extends DolibarrModules */ public function init($options = '') { - global $conf,$langs; + global $conf, $langs; // Permissions $this->remove($options); //ODT template - $src=DOL_DOCUMENT_ROOT.'/install/doctemplates/shipment/template_shipment.odt'; - $dirodt=DOL_DATA_ROOT.'/doctemplates/shipment'; - $dest=$dirodt.'/template_shipment.odt'; + $src = DOL_DOCUMENT_ROOT.'/install/doctemplates/shipment/template_shipment.odt'; + $dirodt = DOL_DATA_ROOT.'/doctemplates/shipment'; + $dest = $dirodt.'/template_shipment.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; } } diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index 938f4411b57..1b538b016df 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -880,7 +880,7 @@ if (!defined('NOLOGIN')) if (GETPOST('theme', 'alpha')) { $conf->theme = GETPOST('theme', 'alpha', 1); - $conf->css = "/theme/".$conf->theme."/style.css.php"; + $conf->css = "/theme/".$conf->theme."/style.css.php"; } @@ -926,7 +926,7 @@ if (!empty($conf->dol_use_jmobile)) $conf->use_javascript_ajax = 1; if (!empty($conf->dol_use_jmobile) && in_array($conf->theme, array('bureau2crea', 'cameleo', 'amarok'))) { $conf->theme = 'eldy'; - $conf->css = "/theme/".$conf->theme."/style.css.php"; + $conf->css = "/theme/".$conf->theme."/style.css.php"; } if (!defined('NOREQUIRETRAN')) @@ -1361,93 +1361,93 @@ function top_htmlhead($head, $title = '', $disablejs = 0, $disablehead = 0, $arr } // Output standard javascript links - if (! defined('DISABLE_JQUERY') && ! $disablejs && ! empty($conf->use_javascript_ajax)) + if (!defined('DISABLE_JQUERY') && !$disablejs && !empty($conf->use_javascript_ajax)) { // JQuery. Must be before other includes print ''."\n"; - if (defined('JS_JQUERY') && constant('JS_JQUERY')) print ''."\n"; - else print ''."\n"; + if (defined('JS_JQUERY') && constant('JS_JQUERY')) print ''."\n"; + else print ''."\n"; /*if (! empty($conf->global->MAIN_FEATURES_LEVEL) && ! defined('JS_JQUERY_MIGRATE_DISABLED')) { if (defined('JS_JQUERY_MIGRATE') && constant('JS_JQUERY_MIGRATE')) print ''."\n"; else print ''."\n"; }*/ - if (defined('JS_JQUERY_UI') && constant('JS_JQUERY_UI')) print ''."\n"; - else print ''."\n"; - if (! defined('DISABLE_JQUERY_TABLEDND')) print ''."\n"; + if (defined('JS_JQUERY_UI') && constant('JS_JQUERY_UI')) print ''."\n"; + else print ''."\n"; + if (!defined('DISABLE_JQUERY_TABLEDND')) print ''."\n"; // jQuery jnotify - if (empty($conf->global->MAIN_DISABLE_JQUERY_JNOTIFY) && ! defined('DISABLE_JQUERY_JNOTIFY')) + if (empty($conf->global->MAIN_DISABLE_JQUERY_JNOTIFY) && !defined('DISABLE_JQUERY_JNOTIFY')) { - print ''."\n"; + print ''."\n"; } // Flot - if (empty($conf->global->MAIN_DISABLE_JQUERY_FLOT) && ! defined('DISABLE_JQUERY_FLOT')) + if (empty($conf->global->MAIN_DISABLE_JQUERY_FLOT) && !defined('DISABLE_JQUERY_FLOT')) { if (constant('JS_JQUERY_FLOT')) { - print ''."\n"; - print ''."\n"; - print ''."\n"; + print ''."\n"; + print ''."\n"; + print ''."\n"; } else { - print ''."\n"; - print ''."\n"; - print ''."\n"; + print ''."\n"; + print ''."\n"; + print ''."\n"; } } // jQuery jeditable - if (! empty($conf->global->MAIN_USE_JQUERY_JEDITABLE) && ! defined('DISABLE_JQUERY_JEDITABLE')) + if (!empty($conf->global->MAIN_USE_JQUERY_JEDITABLE) && !defined('DISABLE_JQUERY_JEDITABLE')) { print ''."\n"; - print ''."\n"; - print ''."\n"; - print ''."\n"; + print ''."\n"; + print ''."\n"; + print ''."\n"; print ''."\n"; - print ''."\n"; - print ''."\n"; + print ''."\n"; + print ''."\n"; } // jQuery Timepicker - if (! empty($conf->global->MAIN_USE_JQUERY_TIMEPICKER) || defined('REQUIRE_JQUERY_TIMEPICKER')) + if (!empty($conf->global->MAIN_USE_JQUERY_TIMEPICKER) || defined('REQUIRE_JQUERY_TIMEPICKER')) { - print ''."\n"; - print ''."\n"; + print ''."\n"; + print ''."\n"; } - if (! defined('DISABLE_SELECT2') && (! empty($conf->global->MAIN_USE_JQUERY_MULTISELECT) || defined('REQUIRE_JQUERY_MULTISELECT'))) // jQuery plugin "mutiselect", "multiple-select", "select2", ... + if (!defined('DISABLE_SELECT2') && (!empty($conf->global->MAIN_USE_JQUERY_MULTISELECT) || defined('REQUIRE_JQUERY_MULTISELECT'))) // jQuery plugin "mutiselect", "multiple-select", "select2", ... { - $tmpplugin=empty($conf->global->MAIN_USE_JQUERY_MULTISELECT)?constant('REQUIRE_JQUERY_MULTISELECT'):$conf->global->MAIN_USE_JQUERY_MULTISELECT; - print ''."\n"; // We include full because we need the support of containerCssClass + $tmpplugin = empty($conf->global->MAIN_USE_JQUERY_MULTISELECT) ?constant('REQUIRE_JQUERY_MULTISELECT') : $conf->global->MAIN_USE_JQUERY_MULTISELECT; + print ''."\n"; // We include full because we need the support of containerCssClass } } - if (! $disablejs && ! empty($conf->use_javascript_ajax)) + if (!$disablejs && !empty($conf->use_javascript_ajax)) { // CKEditor - if (! empty($conf->fckeditor->enabled) && (empty($conf->global->FCKEDITOR_EDITORNAME) || $conf->global->FCKEDITOR_EDITORNAME == 'ckeditor') && ! defined('DISABLE_CKEDITOR')) + if (!empty($conf->fckeditor->enabled) && (empty($conf->global->FCKEDITOR_EDITORNAME) || $conf->global->FCKEDITOR_EDITORNAME == 'ckeditor') && !defined('DISABLE_CKEDITOR')) { print ''."\n"; - $pathckeditor = DOL_URL_ROOT . '/includes/ckeditor/ckeditor/'; - $jsckeditor='ckeditor.js'; + $pathckeditor = DOL_URL_ROOT.'/includes/ckeditor/ckeditor/'; + $jsckeditor = 'ckeditor.js'; if (constant('JS_CKEDITOR')) // To use external ckeditor 4 js lib { - $pathckeditor=constant('JS_CKEDITOR'); + $pathckeditor = constant('JS_CKEDITOR'); } print ''."\n"; - print ''."\n"; + print ''."\n"; print '