Skip to content
This repository has been archived by the owner on Jul 27, 2024. It is now read-only.

Commit

Permalink
correct bug (#16)
Browse files Browse the repository at this point in the history
  • Loading branch information
stephtkd authored Oct 14, 2021
1 parent 3a00162 commit fd90d69
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
2 changes: 0 additions & 2 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
<!-----------------------------------------------------------------------------
Thank you for contributing to the PrestaShop project!
MERCI
COUCOU
Please take the time to edit the "Answers" rows below with the necessary information.
Check out our contribution guidelines to find out how to complete it:
Expand Down
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ Il faut indiquer dans la configuration du module quel group joue le rôle du gro


## Historique des versions ##
### v 1.2.2 ###
- Correction du bug qui ne permettait plus de modifier un client

### v 1.2.1 ###
- Affectation automatique du groupe 'Client Privilégié' (groupe id 5) lorsqu'un client particulier crée un compte en renseignant son code privilège et que le code privilège est bien valide

Expand Down
13 changes: 8 additions & 5 deletions sbu_privilege.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public function __construct()
{
$this->name = 'sbu_privilege';
$this->tab = 'others';
$this->version = '1.2.1';
$this->version = '1.2.2';
$this->author = 'Stéphane Burlet';
$this->need_instance = 0;

Expand Down Expand Up @@ -167,10 +167,10 @@ public function hookactionObjectCustomerAddAfter($params)
*/
public function writeModuleValues(int $customerId)
{
error_log("writeModuleValues - $customerId - ".Tools::getValue('privilege_code')." - ".Tools::getValue('private_sponsor'));
error_log("writeModuleValues - customerId=$customerId - privilege_code=".Tools::getValue('privilege_code')." - private_sponsor=".Tools::getValue('private_sponsor'));
// ATTENTION : getValue marche dans le FO mais pas dans le BO (ex : quand on modifie un customer)
$PrivilegeCodeValue = trim(Tools::getValue('privilege_code'));
$PrivateSponsorValue = trim(Tools::getValue('private_sponsor'));
$PrivateSponsorValue = (int)trim(Tools::getValue('private_sponsor'));

/*
$query = 'UPDATE `'._DB_PREFIX_.'sbu_privilege` priv '
Expand Down Expand Up @@ -200,12 +200,13 @@ public function writeModuleValues(int $customerId)

$privilegeCode = new PrivilegeCode($PrivilegeCodeId);
//error_log("privilegeCode = ".print_r($privilegeCode,true));
// En testant $privilegeCode->id, ça marche que je vienne du FO ou du BO (car Tools::getValue ne marche pas en venant du BO)
if (0 >= $privilegeCode->id) {
error_log("je crée un nouveau privilege_code : id = $customerId; privilege-code = $PrivilegeCodeValue; Private-sponsor = $PrivateSponsorValue");
error_log("je crée un nouveau privilege_code : customerId = $customerId; privilege-code = $PrivilegeCodeValue; Private-sponsor = $PrivateSponsorValue");
$privilegeCode = $this->createPrivilegeCode($customerId,$PrivilegeCodeValue,$PrivateSponsorValue);
}
else {
error_log("modification d'un privilege_code existant : id = $customerId; privilege-code = $PrivilegeCodeValue; Private-sponsor = $PrivateSponsorValue");
error_log("modification d'un privilege_code existant : customerId = $customerId; privilege-code = $PrivilegeCodeValue; Private-sponsor = $PrivateSponsorValue");
$privilegeCode->privilege_code = $PrivilegeCodeValue;
$privilegeCode->private_sponsor = $PrivateSponsorValue;
// error_log("privilegeCode = ".print_r($privilegeCode,true));
Expand Down Expand Up @@ -237,6 +238,8 @@ public function writeModuleValues(int $customerId)
*/
public function affectPrivilegeGroup( int $customerId, string $PrivilegeCodeValue)
{
if (empty($PrivilegeCodeValue)) return true;

$sql = new DbQuery();
//SELECT
// pc.privilege_code,
Expand Down

0 comments on commit fd90d69

Please sign in to comment.