From 66cdb1dad0ebe7b2d16b2da6589d46811d9d5e9a Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Wed, 26 Aug 2020 11:44:35 +0200 Subject: [PATCH 01/19] NEW display resiliate status in takepos for member --- htdocs/takepos/invoice.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/htdocs/takepos/invoice.php b/htdocs/takepos/invoice.php index d4274d90444..ac076a37993 100644 --- a/htdocs/takepos/invoice.php +++ b/htdocs/takepos/invoice.php @@ -818,7 +818,10 @@ $( document ).ready(function() { $adh->ref = $adh->getFullName($langs); $s .= $adh->getFullName($langs); $s .= ' - '.$adh->type; - if ($adh->datefin) + if (empty($adh->statut)) { + $s .= '
'.$langs->trans("MemberStatusResiliated"); + } + else if ($adh->datefin) { $s .= '
'.$langs->trans("SubscriptionEndDate").': '.dol_print_date($adh->datefin, 'day'); if ($adh->hasDelay()) { From 32ecf4dd9a536d8541256cc65d69cf674e6f6b44 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Wed, 26 Aug 2020 09:46:49 +0000 Subject: [PATCH 02/19] Fixing style errors. --- htdocs/takepos/invoice.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/takepos/invoice.php b/htdocs/takepos/invoice.php index ac076a37993..7819c28edb9 100644 --- a/htdocs/takepos/invoice.php +++ b/htdocs/takepos/invoice.php @@ -821,7 +821,7 @@ $( document ).ready(function() { if (empty($adh->statut)) { $s .= '
'.$langs->trans("MemberStatusResiliated"); } - else if ($adh->datefin) + elseif ($adh->datefin) { $s .= '
'.$langs->trans("SubscriptionEndDate").': '.dol_print_date($adh->datefin, 'day'); if ($adh->hasDelay()) { From 76e276e8e8dfe91648f018734ea0e02f2e51e80e Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Wed, 26 Aug 2020 12:00:45 +0200 Subject: [PATCH 03/19] Update invoice.php --- htdocs/takepos/invoice.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/takepos/invoice.php b/htdocs/takepos/invoice.php index 7819c28edb9..0ec346c01d0 100644 --- a/htdocs/takepos/invoice.php +++ b/htdocs/takepos/invoice.php @@ -818,7 +818,7 @@ $( document ).ready(function() { $adh->ref = $adh->getFullName($langs); $s .= $adh->getFullName($langs); $s .= ' - '.$adh->type; - if (empty($adh->statut)) { + if (empty($adh->statut) && $adh->datefin) { $s .= '
'.$langs->trans("MemberStatusResiliated"); } elseif ($adh->datefin) From 989130c0ad541ccffd88024fe5666f03a7aa29b2 Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Wed, 26 Aug 2020 12:20:49 +0200 Subject: [PATCH 04/19] Update invoice.php --- htdocs/takepos/invoice.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/takepos/invoice.php b/htdocs/takepos/invoice.php index 0ec346c01d0..1bc43e604e4 100644 --- a/htdocs/takepos/invoice.php +++ b/htdocs/takepos/invoice.php @@ -821,7 +821,7 @@ $( document ).ready(function() { if (empty($adh->statut) && $adh->datefin) { $s .= '
'.$langs->trans("MemberStatusResiliated"); } - elseif ($adh->datefin) + else if ($adh->datefin) { $s .= '
'.$langs->trans("SubscriptionEndDate").': '.dol_print_date($adh->datefin, 'day'); if ($adh->hasDelay()) { From eecab28203b8b37633ca4c31b9fb0eb7edbc43e4 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Wed, 26 Aug 2020 10:22:33 +0000 Subject: [PATCH 05/19] Fixing style errors. --- htdocs/takepos/invoice.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/takepos/invoice.php b/htdocs/takepos/invoice.php index 1bc43e604e4..0ec346c01d0 100644 --- a/htdocs/takepos/invoice.php +++ b/htdocs/takepos/invoice.php @@ -821,7 +821,7 @@ $( document ).ready(function() { if (empty($adh->statut) && $adh->datefin) { $s .= '
'.$langs->trans("MemberStatusResiliated"); } - else if ($adh->datefin) + elseif ($adh->datefin) { $s .= '
'.$langs->trans("SubscriptionEndDate").': '.dol_print_date($adh->datefin, 'day'); if ($adh->hasDelay()) { From a68d2fe91e3879cb27c49c680659d55db9b00c2a Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Sat, 29 Aug 2020 11:37:16 +0200 Subject: [PATCH 06/19] NEW API get thirdparty by barcode --- .../societe/class/api_thirdparties.class.php | 27 +++++++++++++++---- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/htdocs/societe/class/api_thirdparties.class.php b/htdocs/societe/class/api_thirdparties.class.php index 1efe6287c66..f6ff117a846 100644 --- a/htdocs/societe/class/api_thirdparties.class.php +++ b/htdocs/societe/class/api_thirdparties.class.php @@ -67,7 +67,7 @@ class Thirdparties extends DolibarrApi * * Return an array with thirdparty informations * - * @param int $id ID of thirdparty + * @param int $id Id of third party to load * @return array|mixed data without useless information * * @throws RestException @@ -82,7 +82,7 @@ class Thirdparties extends DolibarrApi * * Return an array with thirdparty informations * - * @param string $email Sort field + * @param string $email Email of third party to load * @return array|mixed data without useless information * * @url GET byEmail/{email} @@ -93,6 +93,23 @@ class Thirdparties extends DolibarrApi { return $this->_fetch('', '', '', '', '', '', '', '', '', '', $email); } + + /** + * Get properties of a thirdparty object by barcode. + * + * Return an array with thirdparty informations + * + * @param string $Barcode Barcode of third party to load + * @return array|mixed data without useless information + * + * @url GET barcode/{barcode} + * + * @throws RestException + */ + public function getByBarcode($barcode) + { + return $this->_fetch('', '', '', $barcode); + } /** * List thirdparties @@ -1810,7 +1827,7 @@ class Thirdparties extends DolibarrApi * @param int $rowid Id of third party to load * @param string $ref Reference of third party, name (Warning, this can return several records) * @param string $ref_ext External reference of third party (Warning, this information is a free field not provided by Dolibarr) - * @param string $ref_int Internal reference of third party (not used by dolibarr) + * @param string $barcode Barcode of third party to load * @param string $idprof1 Prof id 1 of third party (Warning, this can return several records) * @param string $idprof2 Prof id 2 of third party (Warning, this can return several records) * @param string $idprof3 Prof id 3 of third party (Warning, this can return several records) @@ -1823,14 +1840,14 @@ class Thirdparties extends DolibarrApi * * @throws RestException */ - private function _fetch($rowid, $ref = '', $ref_ext = '', $ref_int = '', $idprof1 = '', $idprof2 = '', $idprof3 = '', $idprof4 = '', $idprof5 = '', $idprof6 = '', $email = '', $ref_alias = '') + private function _fetch($rowid, $ref = '', $ref_ext = '', $barcode = '', $idprof1 = '', $idprof2 = '', $idprof3 = '', $idprof4 = '', $idprof5 = '', $idprof6 = '', $email = '', $ref_alias = '') { global $conf; if (!DolibarrApiAccess::$user->rights->societe->lire) { throw new RestException(401); } - $result = $this->company->fetch($rowid, $ref, $ref_ext, $ref_int, $idprof1, $idprof2, $idprof3, $idprof4, $idprof5, $idprof6, $email, $ref_alias); + $result = $this->company->fetch($rowid, $ref, $ref_ext, $barcode, $idprof1, $idprof2, $idprof3, $idprof4, $idprof5, $idprof6, $email, $ref_alias); if (!$result) { throw new RestException(404, 'Thirdparty not found'); } From 26f812b73bc5ecda3171eda0e62f73d1f4176929 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Sat, 29 Aug 2020 09:39:10 +0000 Subject: [PATCH 07/19] Fixing style errors. --- htdocs/societe/class/api_thirdparties.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/societe/class/api_thirdparties.class.php b/htdocs/societe/class/api_thirdparties.class.php index f6ff117a846..514d92bfaee 100644 --- a/htdocs/societe/class/api_thirdparties.class.php +++ b/htdocs/societe/class/api_thirdparties.class.php @@ -93,7 +93,7 @@ class Thirdparties extends DolibarrApi { return $this->_fetch('', '', '', '', '', '', '', '', '', '', $email); } - + /** * Get properties of a thirdparty object by barcode. * From 12676d020a237e718742c6627a0baa25f5d9ab82 Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Sat, 29 Aug 2020 11:43:56 +0200 Subject: [PATCH 08/19] Update api_thirdparties.class.php --- htdocs/societe/class/api_thirdparties.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/societe/class/api_thirdparties.class.php b/htdocs/societe/class/api_thirdparties.class.php index 514d92bfaee..ba807fa1706 100644 --- a/htdocs/societe/class/api_thirdparties.class.php +++ b/htdocs/societe/class/api_thirdparties.class.php @@ -99,7 +99,7 @@ class Thirdparties extends DolibarrApi * * Return an array with thirdparty informations * - * @param string $Barcode Barcode of third party to load + * @param string $barcode Barcode of third party to load * @return array|mixed data without useless information * * @url GET barcode/{barcode} From 7fe83b24baf2f12dad52fde0eaa48fdfd5d4cb24 Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Sat, 29 Aug 2020 12:38:22 +0200 Subject: [PATCH 09/19] NEW api get member by thirdparty --- htdocs/adherents/class/api_members.class.php | 113 +++++++++++++++++++ 1 file changed, 113 insertions(+) diff --git a/htdocs/adherents/class/api_members.class.php b/htdocs/adherents/class/api_members.class.php index 2128abe73d6..1c57e29375a 100644 --- a/htdocs/adherents/class/api_members.class.php +++ b/htdocs/adherents/class/api_members.class.php @@ -1,6 +1,7 @@ * Copyright (C) 2017 Regis Houssin + * Copyright (C) 2020 Thibault FOUCART * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -18,6 +19,7 @@ use Luracast\Restler\RestException; +require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; require_once DOL_DOCUMENT_ROOT.'/adherents/class/subscription.class.php'; require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; @@ -75,6 +77,117 @@ class Members extends DolibarrApi return $this->_cleanObjectDatas($member); } + + /** + * Get properties of a member object by linked thirdparty + * + * Return an array with member informations + * + * @param int $thirdparty ID of third party + * + * @return array|mixed Data without useless information + * + * @url GET thirdparty/{thirdparty} + * + * @throws RestException 401 + * @throws RestException 404 + */ + function getByThirdparty($thirdparty) + { + if(! DolibarrApiAccess::$user->rights->adherent->lire) { + throw new RestException(401); + } + + $member = new Adherent($this->db); + $result = $member->fetch('', '', $thirdparty); + if( ! $result ) { + throw new RestException(404, 'member not found'); + } + + if( ! DolibarrApi::_checkAccessToResource('adherent', $member->id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } + + return $this->_cleanObjectDatas($member); + } + + /** + * Get properties of a member object by linked thirdparty email + * + * Return an array with member informations + * + * @param string $email Email of third party + * + * @return array|mixed Data without useless information + * + * @url GET thirdparty/email/{email} + * + * @throws RestException 401 + * @throws RestException 404 + */ + function getByThirdpartyEmail($email) + { + if(! DolibarrApiAccess::$user->rights->adherent->lire) { + throw new RestException(401); + } + + $thirdparty = new Societe($this->db); + $result = $thirdparty->fetch('', '', '', '', '', '', '', '', '', '', $email); + if( ! $result ) { + throw new RestException(404, 'thirdparty not found'); + } + + $member = new Adherent($this->db); + $result = $member->fetch('', '', $thirdparty->id); + if( ! $result ) { + throw new RestException(404, 'member not found'); + } + + if( ! DolibarrApi::_checkAccessToResource('adherent', $member->id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } + + return $this->_cleanObjectDatas($member); + } + + /** + * Get properties of a member object by linked thirdparty barcode + * + * Return an array with member informations + * + * @param string $barcode Barcode of third party + * + * @return array|mixed Data without useless information + * + * @url GET thirdparty/barcode/{barcode} + * + * @throws RestException 401 + * @throws RestException 404 + */ + function getByThirdpartyBarcode($barcode) + { + if(! DolibarrApiAccess::$user->rights->adherent->lire) { + throw new RestException(401); + } + + $thirdparty = new Societe($this->db); + $result = $thirdparty->fetch('', '', '', $barcode); + if( ! $result ) { + throw new RestException(404, 'thirdparty not found'); + } + + $member = new Adherent($this->db); + $result = $member->fetch('', '', $thirdparty->id); + if( ! $result ) { + throw new RestException(404, 'member not found'); + } + + if( ! DolibarrApi::_checkAccessToResource('adherent', $member->id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } + + return $this->_cleanObjectDatas($member); + } /** * List members From 96b3474185c48d044112b8360305c4ec24e29f45 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Sat, 29 Aug 2020 10:40:30 +0000 Subject: [PATCH 10/19] Fixing style errors. --- htdocs/adherents/class/api_members.class.php | 38 ++++++++++---------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/htdocs/adherents/class/api_members.class.php b/htdocs/adherents/class/api_members.class.php index 1c57e29375a..d58a5840ad8 100644 --- a/htdocs/adherents/class/api_members.class.php +++ b/htdocs/adherents/class/api_members.class.php @@ -77,14 +77,14 @@ class Members extends DolibarrApi return $this->_cleanObjectDatas($member); } - + /** * Get properties of a member object by linked thirdparty * * Return an array with member informations * * @param int $thirdparty ID of third party - * + * * @return array|mixed Data without useless information * * @url GET thirdparty/{thirdparty} @@ -94,30 +94,30 @@ class Members extends DolibarrApi */ function getByThirdparty($thirdparty) { - if(! DolibarrApiAccess::$user->rights->adherent->lire) { + if (! DolibarrApiAccess::$user->rights->adherent->lire) { throw new RestException(401); } $member = new Adherent($this->db); $result = $member->fetch('', '', $thirdparty); - if( ! $result ) { + if ( ! $result ) { throw new RestException(404, 'member not found'); } - if( ! DolibarrApi::_checkAccessToResource('adherent', $member->id)) { + if ( ! DolibarrApi::_checkAccessToResource('adherent', $member->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } return $this->_cleanObjectDatas($member); } - + /** * Get properties of a member object by linked thirdparty email * * Return an array with member informations * * @param string $email Email of third party - * + * * @return array|mixed Data without useless information * * @url GET thirdparty/email/{email} @@ -127,36 +127,36 @@ class Members extends DolibarrApi */ function getByThirdpartyEmail($email) { - if(! DolibarrApiAccess::$user->rights->adherent->lire) { + if (! DolibarrApiAccess::$user->rights->adherent->lire) { throw new RestException(401); } $thirdparty = new Societe($this->db); $result = $thirdparty->fetch('', '', '', '', '', '', '', '', '', '', $email); - if( ! $result ) { + if ( ! $result ) { throw new RestException(404, 'thirdparty not found'); } - + $member = new Adherent($this->db); $result = $member->fetch('', '', $thirdparty->id); - if( ! $result ) { + if ( ! $result ) { throw new RestException(404, 'member not found'); } - if( ! DolibarrApi::_checkAccessToResource('adherent', $member->id)) { + if ( ! DolibarrApi::_checkAccessToResource('adherent', $member->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } return $this->_cleanObjectDatas($member); } - + /** * Get properties of a member object by linked thirdparty barcode * * Return an array with member informations * * @param string $barcode Barcode of third party - * + * * @return array|mixed Data without useless information * * @url GET thirdparty/barcode/{barcode} @@ -166,23 +166,23 @@ class Members extends DolibarrApi */ function getByThirdpartyBarcode($barcode) { - if(! DolibarrApiAccess::$user->rights->adherent->lire) { + if (! DolibarrApiAccess::$user->rights->adherent->lire) { throw new RestException(401); } $thirdparty = new Societe($this->db); $result = $thirdparty->fetch('', '', '', $barcode); - if( ! $result ) { + if ( ! $result ) { throw new RestException(404, 'thirdparty not found'); } - + $member = new Adherent($this->db); $result = $member->fetch('', '', $thirdparty->id); - if( ! $result ) { + if ( ! $result ) { throw new RestException(404, 'member not found'); } - if( ! DolibarrApi::_checkAccessToResource('adherent', $member->id)) { + if ( ! DolibarrApi::_checkAccessToResource('adherent', $member->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } From a64223f73dda36e75cdc431b983b5d521475ce71 Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Sat, 29 Aug 2020 12:44:17 +0200 Subject: [PATCH 11/19] Update api_members.class.php --- htdocs/adherents/class/api_members.class.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/adherents/class/api_members.class.php b/htdocs/adherents/class/api_members.class.php index d58a5840ad8..990e21dd08b 100644 --- a/htdocs/adherents/class/api_members.class.php +++ b/htdocs/adherents/class/api_members.class.php @@ -92,7 +92,7 @@ class Members extends DolibarrApi * @throws RestException 401 * @throws RestException 404 */ - function getByThirdparty($thirdparty) + public function getByThirdparty($thirdparty) { if (! DolibarrApiAccess::$user->rights->adherent->lire) { throw new RestException(401); @@ -125,7 +125,7 @@ class Members extends DolibarrApi * @throws RestException 401 * @throws RestException 404 */ - function getByThirdpartyEmail($email) + public function getByThirdpartyEmail($email) { if (! DolibarrApiAccess::$user->rights->adherent->lire) { throw new RestException(401); @@ -164,7 +164,7 @@ class Members extends DolibarrApi * @throws RestException 401 * @throws RestException 404 */ - function getByThirdpartyBarcode($barcode) + public function getByThirdpartyBarcode($barcode) { if (! DolibarrApiAccess::$user->rights->adherent->lire) { throw new RestException(401); From 6eeb1d3a96471e1fced632e3268bdfa69f8bdb9f Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Sat, 29 Aug 2020 13:36:52 +0200 Subject: [PATCH 12/19] Update invoice.php --- htdocs/takepos/invoice.php | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/htdocs/takepos/invoice.php b/htdocs/takepos/invoice.php index 0ec346c01d0..b23d6723ddf 100644 --- a/htdocs/takepos/invoice.php +++ b/htdocs/takepos/invoice.php @@ -816,12 +816,10 @@ $( document ).ready(function() { if ($result > 0) { $adh->ref = $adh->getFullName($langs); + if (empty($adh->statut)) { $s .= ""; } $s .= $adh->getFullName($langs); $s .= ' - '.$adh->type; - if (empty($adh->statut) && $adh->datefin) { - $s .= '
'.$langs->trans("MemberStatusResiliated"); - } - elseif ($adh->datefin) + if ($adh->datefin) { $s .= '
'.$langs->trans("SubscriptionEndDate").': '.dol_print_date($adh->datefin, 'day'); if ($adh->hasDelay()) { @@ -831,6 +829,7 @@ $( document ).ready(function() { $s .= '
'.$langs->trans("SubscriptionNotReceived"); if ($adh->statut > 0) $s .= " ".img_warning($langs->trans("Late")); // displays delay Pictogram only if not a draft and not terminated } + if (empty($adh->statut)) { $s .= "
"; } } else { $s .= '
'.$langs->trans("ThirdpartyNotLinkedToMember"); } From a963d6c0fcbcbf965387e675fd01da049f381e46 Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Sat, 29 Aug 2020 16:05:14 +0200 Subject: [PATCH 13/19] NEW change thirdparty with barcode scan in takepos --- htdocs/takepos/ajax/ajax.php | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/htdocs/takepos/ajax/ajax.php b/htdocs/takepos/ajax/ajax.php index 7c4471b0ec8..56a437f2f6a 100644 --- a/htdocs/takepos/ajax/ajax.php +++ b/htdocs/takepos/ajax/ajax.php @@ -1,5 +1,6 @@ +/* Copyright (C) 2020 Thibault FOUCART * * 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 @@ -68,6 +69,24 @@ if ($action == 'getProducts') { echo 'Failed to load category with id='.$category; } } elseif ($action == 'search' && $term != '') { + // Change thirdparty with barcode + require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; + + $thirdparty = new Societe($db); + $result = $thirdparty->fetch('', '', '', $term); + + if( $result && $thirdparty->id > 0) { + $rows = array(); + $rows[] = array( + 'rowid' => $thirdparty->id, + 'name' => $thirdparty->name, + 'barcode' => $thirdparty->barcode, + 'object' => 'thirdparty' + ); + echo json_encode($rows); + exit; + } + // Define $filteroncategids, the filter on category ID if there is a Root category defined. $filteroncategids = ''; if ($conf->global->TAKEPOS_ROOT_CATEGORY_ID > 0) { // A root category is defined, we must filter on products inside this category tree @@ -101,7 +120,8 @@ if ($action == 'getProducts') { 'tosell' => $obj->tosell, 'tobuy' => $obj->tobuy, 'barcode' => $obj->barcode, - 'price' => $obj->price + 'price' => $obj->price, + 'object' => 'product' //'price_formated' => price(price2num($obj->price, 'MU'), 1, $langs, 1, -1, -1, $conf->currency) ); } From d3024fdd1c3d0af3f7805ff989db25a764d2d8dc Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Sat, 29 Aug 2020 16:07:01 +0200 Subject: [PATCH 14/19] Update index.php --- htdocs/takepos/index.php | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/htdocs/takepos/index.php b/htdocs/takepos/index.php index ee304b7438e..ca6ea987456 100644 --- a/htdocs/takepos/index.php +++ b/htdocs/takepos/index.php @@ -1,6 +1,7 @@ * Copyright (C) 2019 Josep LluĂ­s Amador + * Copyright (C) 2020 Thibault FOUCART * * 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 @@ -399,6 +400,15 @@ function ClickProduct(position) { ClearSearch(); } +function ChangeThirdparty(idcustomer) { + console.log("ChangeThirdparty"); + // Call page list.php to change customer + $("#poslines").load("../societe/list.php?action=change&contextpage=poslist&idcustomer="+idcustomer+"&place="+place+"", function() { + }); + + ClearSearch(); +} + function deleteline() { console.log("Delete line"); $("#poslines").load("invoice.php?action=deleteline&place="+place+"&idline="+selectedline, function() { @@ -524,7 +534,11 @@ function Search2(keyCodeForEnter) { // If there is only 1 answer if ($('#search').val().length > 0 && data.length == 1) { console.log($('#search').val()+' - '+data[0]['barcode']); - if ($('#search').val() == data[0]['barcode']) { + if ($('#search').val() == data[0]['barcode'] && 'thirdparty' == data[0]['object']) { + console.log("There is only 1 answer with barcode matching the search, so we change the thirdparty "+data[0]['rowid']); + ChangeThirdparty(data[0]['rowid']); + } + else if ($('#search').val() == data[0]['barcode'] && 'product' == data[0]['object']) { console.log("There is only 1 answer with barcode matching the search, so we add the product in basket"); ClickProduct(0); } From e18b85ea872c5eef72e43b503a791c0b7e87c8a0 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Sat, 29 Aug 2020 14:08:42 +0000 Subject: [PATCH 15/19] Fixing style errors. --- htdocs/takepos/ajax/ajax.php | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/htdocs/takepos/ajax/ajax.php b/htdocs/takepos/ajax/ajax.php index 56a437f2f6a..7f9555c3226 100644 --- a/htdocs/takepos/ajax/ajax.php +++ b/htdocs/takepos/ajax/ajax.php @@ -69,13 +69,13 @@ if ($action == 'getProducts') { echo 'Failed to load category with id='.$category; } } elseif ($action == 'search' && $term != '') { - // Change thirdparty with barcode + // Change thirdparty with barcode require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; - $thirdparty = new Societe($db); - $result = $thirdparty->fetch('', '', '', $term); - - if( $result && $thirdparty->id > 0) { + $thirdparty = new Societe($db); + $result = $thirdparty->fetch('', '', '', $term); + + if ( $result && $thirdparty->id > 0) { $rows = array(); $rows[] = array( 'rowid' => $thirdparty->id, @@ -83,9 +83,9 @@ if ($action == 'getProducts') { 'barcode' => $thirdparty->barcode, 'object' => 'thirdparty' ); - echo json_encode($rows); - exit; - } + echo json_encode($rows); + exit; + } // Define $filteroncategids, the filter on category ID if there is a Root category defined. $filteroncategids = ''; @@ -121,7 +121,7 @@ if ($action == 'getProducts') { 'tobuy' => $obj->tobuy, 'barcode' => $obj->barcode, 'price' => $obj->price, - 'object' => 'product' + 'object' => 'product' //'price_formated' => price(price2num($obj->price, 'MU'), 1, $langs, 1, -1, -1, $conf->currency) ); } From 862c55ea075f16fa153136c1b579dca80475ba45 Mon Sep 17 00:00:00 2001 From: "jove@bisquerra.com" Date: Sun, 30 Aug 2020 09:19:35 +0200 Subject: [PATCH 16/19] NEW Keep takepos terminal when login/logout --- htdocs/takepos/index.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/htdocs/takepos/index.php b/htdocs/takepos/index.php index ee304b7438e..6ec72417119 100644 --- a/htdocs/takepos/index.php +++ b/htdocs/takepos/index.php @@ -44,9 +44,16 @@ $place = (GETPOST('place', 'aZ09') ? GETPOST('place', 'aZ09') : 0); // $place is $action = GETPOST('action', 'alpha'); $setterminal = GETPOST('setterminal', 'int'); +if ($_SESSION["takeposterminal"] == "") +{ + if ($conf->global->TAKEPOS_NUM_TERMINALS == "1") $_SESSION["takeposterminal"] = 1; // Use terminal 1 if there is only 1 terminal + else if (!empty($_COOKIE["takeposterminal"])) $_SESSION["takeposterminal"] = $_COOKIE["takeposterminal"]; // Restore takeposterminal from previous session +} + if ($setterminal > 0) { $_SESSION["takeposterminal"] = $setterminal; + setcookie("takeposterminal", $setterminal, (time() + (86400 * 354)), '/', null, false, true); // Permanent takeposterminal var in a cookie } $_SESSION["urlfrom"] = '/takepos/index.php'; @@ -734,8 +741,7 @@ $( document ).ready(function() { //IF NO TERMINAL SELECTED if ($_SESSION["takeposterminal"] == "") { - if ($conf->global->TAKEPOS_NUM_TERMINALS == "1") $_SESSION["takeposterminal"] = 1; - else print "TerminalsDialog();"; + print "TerminalsDialog();"; } if ($conf->global->TAKEPOS_CONTROL_CASH_OPENING) { From 59542cfbcd5ea56a1148e11b331fec17b01dc57f Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Sun, 30 Aug 2020 07:41:57 +0000 Subject: [PATCH 17/19] Fixing style errors. --- htdocs/takepos/index.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/takepos/index.php b/htdocs/takepos/index.php index 6ec72417119..2dd57ce391f 100644 --- a/htdocs/takepos/index.php +++ b/htdocs/takepos/index.php @@ -47,7 +47,7 @@ $setterminal = GETPOST('setterminal', 'int'); if ($_SESSION["takeposterminal"] == "") { if ($conf->global->TAKEPOS_NUM_TERMINALS == "1") $_SESSION["takeposterminal"] = 1; // Use terminal 1 if there is only 1 terminal - else if (!empty($_COOKIE["takeposterminal"])) $_SESSION["takeposterminal"] = $_COOKIE["takeposterminal"]; // Restore takeposterminal from previous session + elseif (!empty($_COOKIE["takeposterminal"])) $_SESSION["takeposterminal"] = $_COOKIE["takeposterminal"]; // Restore takeposterminal from previous session } if ($setterminal > 0) From 8b40d1786863d88dc91c762eea54f5871183d825 Mon Sep 17 00:00:00 2001 From: "Sekan, Tobias" Date: Mon, 31 Aug 2020 08:10:06 +0200 Subject: [PATCH 18/19] avoid use of curly braces on contact list --- htdocs/contact/list.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/htdocs/contact/list.php b/htdocs/contact/list.php index 9eeae17280f..071b19e2f54 100644 --- a/htdocs/contact/list.php +++ b/htdocs/contact/list.php @@ -77,7 +77,7 @@ $search_no_email = GETPOST("search_no_email", 'int'); if (!empty($conf->socialnetworks->enabled)) { foreach ($socialnetworks as $key => $value) { if ($value['active']) { - $search_{$key} = GETPOST("search_".$key, 'alpha'); + $search_[$key] = GETPOST("search_".$key, 'alpha'); } } } @@ -265,7 +265,7 @@ if (empty($reshook)) if (!empty($conf->socialnetworks->enabled)) { foreach ($socialnetworks as $key => $value) { if ($value['active']) { - $search_{$key} = ""; + $search_[$key] = ""; } } } @@ -407,8 +407,8 @@ if (strlen($search_phone_mobile)) $sql .= natural_search('p.phone_mobile', $se if (strlen($search_fax)) $sql .= natural_search('p.fax', $search_fax); if (!empty($conf->socialnetworks->enabled)) { foreach ($socialnetworks as $key => $value) { - if ($value['active'] && strlen($search_{$key})) { - $sql .= ' AND p.socialnetworks LIKE \'%"'.$key.'":"'.$search_{$key}.'%\''; + if ($value['active'] && strlen($search_[$key])) { + $sql .= ' AND p.socialnetworks LIKE \'%"'.$key.'":"'.$search_[$key].'%\''; } } } @@ -719,7 +719,7 @@ if (!empty($conf->socialnetworks->enabled)) { if (!empty($arrayfields['p.'.$key]['checked'])) { print ''; - print ''; + print ''; print ''; } } From 070a09d5ccaa4a54f70cc8ca06fe83cd88d833f1 Mon Sep 17 00:00:00 2001 From: "Sekan, Tobias" Date: Mon, 31 Aug 2020 13:41:22 +0200 Subject: [PATCH 19/19] Uniform availability desc. on propal --- htdocs/comm/propal/card.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/htdocs/comm/propal/card.php b/htdocs/comm/propal/card.php index f275f16ee03..9b27d64499f 100644 --- a/htdocs/comm/propal/card.php +++ b/htdocs/comm/propal/card.php @@ -1577,7 +1577,10 @@ if ($action == 'create') print ''; // Delivery delay - print ''.$langs->trans('AvailabilityPeriod').''; + print ''.$langs->trans('AvailabilityPeriod'); + if (!empty($conf->commande->enabled)) + print ' ('.$langs->trans('AfterOrder').')'; + print ''; $form->selectAvailabilityDelay('', 'availability_id', '', 1); print '';