From d264e6c3217435034b1d96f9af571f460cef6c47 Mon Sep 17 00:00:00 2001 From: asus Date: Tue, 19 Mar 2024 22:06:17 +0100 Subject: [PATCH] wip cahngin states --- .../cipf_plugin/php/paypal/user_can_pay.php | 4 +- plugins/cipf_plugin/php/profs_states.php | 60 ++++++++++++++----- plugins/cipf_plugin/utils/plgntls_class.php | 23 +++---- 3 files changed, 60 insertions(+), 27 deletions(-) diff --git a/plugins/cipf_plugin/php/paypal/user_can_pay.php b/plugins/cipf_plugin/php/paypal/user_can_pay.php index 554be09..b8263ca 100644 --- a/plugins/cipf_plugin/php/paypal/user_can_pay.php +++ b/plugins/cipf_plugin/php/paypal/user_can_pay.php @@ -15,9 +15,9 @@ if (!defined('ABSPATH')) { * */ function get_acf_value_CIPF($acf_field, $acf_id) { - $field_object = get_field_object($acf_field['_key'], $acf_id); + $field = get_field_init_CIPF($acf_field['_name'], $acf_id); + $field_object = get_field_object($acf_field['_name'], $acf_id); $return_format = $field_object['return_format']; - $field = get_field($acf_field['_key'], $acf_id); $value = null; if ($return_format === 'array') { diff --git a/plugins/cipf_plugin/php/profs_states.php b/plugins/cipf_plugin/php/profs_states.php index 780d777..3c81825 100644 --- a/plugins/cipf_plugin/php/profs_states.php +++ b/plugins/cipf_plugin/php/profs_states.php @@ -14,16 +14,14 @@ if (!defined('ABSPATH')) { * 1. new . 'nouveau prof' -> ok 1/1 : [1: at inscription - ok] * 2. to_pay . 'doit payer' -> ko 3/4 : [1: after form & new - ok], [2: after form choose paypal & expired - ok], [3: after payment failed - ok], [4: after transfert failed - ko] * 3. valid . 'carte valide' -> ko 1/2 : [1: after payment success - ok], [2: after transfert success - ko] -* 4. waiting_invalid . 'en attente invalide' -> ok 1/1 : [1: after form choose transfert & expired - ok] -* 5. waiting_valid . 'en attente valide' -> ok 1/1 : [1: after form choose transfert & not expired - ok] -* 6. expired . 'carte expiree' -> ko 1/2 : [1: when prof access profil & expired - ok], [2: when event card expired fire - ko] +* 4. expired . 'carte expiree' -> ko 1/2 : [1: when prof access profil & expired - ok], [2: when event card expired fire - ko] * * [/] etat carte ('etat_carte') : * - 'Commande' -> ok 1/1 : [1: at inscription - ok] * - 'Renouvellement' -> ko 1/1 : [1: after succees payement - ok] * -* [ ] etat virement ('etat_virement') : -* - 'en attente' -> ko 0/1 : [1: after form validation $ virement checked - ok] +* [/] etat virement ('etat_virement') : +* - 'en attente' -> ko 0/1 : [1: after form validation $ transfert choose - ok] * - 'reçu' -> ko 0/1 : [1: after admin change it from front - ko] * * [ ] activation du compte ('compte-actif') : @@ -46,8 +44,8 @@ if (!defined('ABSPATH')) { -function get_field_init_CIPF($acf_field, $acf_id) { - $acf_state = get_field($acf_field['_name'], $acf_id); +function get_field_init_CIPF($acf_field_name, $acf_id) { + $acf_state = get_field($acf_field_name, $acf_id); if ($acf_state !== null) { return $acf_state; } @@ -59,15 +57,15 @@ function get_field_init_CIPF($acf_field, $acf_id) { * - if no default value, update with first value * */ - update_field($acf_field['_name'], 'temps', $acf_id); - $acf_object = get_field_object($acf_field['_name'], $acf_id); + update_field($acf_field_name, 'temp', $acf_id); + $acf_object = get_field_object($acf_field_name, $acf_id); $default = $acf_object['default_value']; if (empty($default)) { $choices = $acf_object['choices']; $default = reset($choices); } - update_field($acf_field['_name'], $default, $acf_id); - $acf_state = get_field($acf_field['_name'], $acf_id); + update_field($acf_field_name, $default, $acf_id); + $acf_state = get_field($acf_field_name, $acf_id); return $acf_state; } @@ -99,7 +97,7 @@ function is_acf_state_CIPF($user_id = null, $acf_field, $state_name) { * $acf_state = get_field($acf_field['_key'], $acf_id); */ - $acf_state = get_field_init_CIPF($acf_field, $acf_id);; + $acf_state = get_field_init_CIPF($acf_field['_name'], $acf_id);; if ($acf_state === $acf_field[$state_name]) { return true; @@ -114,7 +112,7 @@ function set_acf_state_CIPF($user_id = null, $acf_field, $state_name) { } $acf_id = 'user_'.$user_id; - update_field($acf_field['_key'], $acf_field[$state_name], $acf_id); + update_field($acf_field['_name'], $acf_field[$state_name], $acf_id); } @@ -254,6 +252,8 @@ function is_payment_method_transfert_CIPF($user_id = null) { + + /* * etat paiement ('etat_paiement') : * - 'en_cours' @@ -313,6 +313,38 @@ function set_payment_nothing_CIPF($user_id = null) { + +/* +* etat virement ('etat_virement') : +* - 'en attente' +* - 'reçu' +* +*/ +function is_transfert_waiting_CIPF($user_id = null) { + PLGNTLS_class::debug_infos(); + $acf_transfert_state = PLGNTLS_class::ACF_TRANSFERT_STATE; + return is_acf_state_CIPF($user_id, $acf_transfert_state, 'waiting'); +} +function is_transfert_done_CIPF($user_id = null) { + PLGNTLS_class::debug_infos(); + $acf_transfert_state = PLGNTLS_class::ACF_TRANSFERT_STATE; + return is_acf_state_CIPF($user_id, $acf_transfert_state, 'done'); +} +function set_transfert_waiting_CIPF($user_id = null) { + PLGNTLS_class::debug_infos(); + $acf_transfert_state = PLGNTLS_class::ACF_TRANSFERT_STATE; + set_acf_state_CIPF($user_id, $acf_transfert_state, 'waiting'); +} +function set_transfert_done_CIPF($user_id = null) { + PLGNTLS_class::debug_infos(); + $acf_transfert_state = PLGNTLS_class::ACF_TRANSFERT_STATE; + set_acf_state_CIPF($user_id, $acf_transfert_state, 'done'); +} + + + + + /* * */ @@ -326,7 +358,7 @@ function set_card_number_CIPF($user_id = null) { $date_now = date_create('today'); $card_id = $date_now->format('Ymd') . $user_id; - update_field($acf_card_number['_key'], $card_id, $acf_id); + update_field($acf_card_number['_name'], $card_id, $acf_id); } diff --git a/plugins/cipf_plugin/utils/plgntls_class.php b/plugins/cipf_plugin/utils/plgntls_class.php index 47fecbe..625d15a 100644 --- a/plugins/cipf_plugin/utils/plgntls_class.php +++ b/plugins/cipf_plugin/utils/plgntls_class.php @@ -60,17 +60,18 @@ class PLGNTLS_class { * */ // ACF - const ACF_CARD_STATE = ['_name'=>'etat_carte', 'new'=>'Commande', 'renew'=>'Renouvellement', '_key'=>'field_65d85d72c4265']; // radio button - const ACF_CARD_PAYMENT_METHOD = ['_name'=>'paiement', 'paypal'=>'Paypal', 'transfert'=>'Virement', '_key'=>'field_65d243b9cc89d']; // radio button - const ACF_CARD_PRICE_CHOICE = ['_name'=>'tarif', 'low'=>'10', 'high'=>'15', '_key'=>'field_65d24447cc89f']; // radio button - const ACF_CARD_PRICE_DELIVERY = ['_name'=>'livraison', 'pdf'=>'PDF', 'post'=>'Fabrication', '_key'=>'field_65d36f6e02a9a']; // radio button - const ACF_PROF_IS_ACTIV = ['_name'=>'compte-actif', 'activ'=>'Actif', 'inactiv'=>'Inactif', '_key'=>'field_65e8acd5c2065']; // radio button - const ACF_PROF_CGV = ['_name'=>'cgv', 'cgv'=>'cgv', '_key'=>'field_65d2441fcc89e']; // checkbox - const ACF_CARD_PRICE_TOTAL = ['_name'=>'somme_a_regler', '_key'=>'field_65d396876fe57']; // number - const ACF_CARD_NUMBER = ['_name'=>'numero_de_la_carte', '_key'=>'field_65e48a0201107']; // number - const ACF_CARD_EXPIRATION = ['_name'=>'fin_de_validite', '_key'=>'field_65d66b26ebf59']; // date picker - const ACF_CARD_PAYMENT_STATE = ['_name'=>'etat_paiement', 'started'=>'en_cours', 'success'=>'reussi', 'failure'=>'echec', 'nothing'=>'aucun', '_key'=>'field_65eedb65227cb']; // radio button - const ACF_ACCOUNT_STATE = ['_name'=>'etat_compte', 'new'=>'nouveau prof', 'to_pay'=>'doit payer', 'valid'=>'carte valide', 'waiting_invalid'=>'en attente invalide', 'waiting_valid'=>'en attente valide', 'expired'=>'carte expiree', '_key'=>'field_65f89fb6de318']; + const ACF_CARD_STATE = ['_name'=>'etat_carte', 'new'=>'Commande', 'renew'=>'Renouvellement']; // radio button + const ACF_CARD_PAYMENT_METHOD = ['_name'=>'paiement', 'paypal'=>'Paypal', 'transfert'=>'Virement']; // radio button + const ACF_CARD_PRICE_CHOICE = ['_name'=>'tarif', 'low'=>'10', 'high'=>'15']; // radio button + const ACF_CARD_PRICE_DELIVERY = ['_name'=>'livraison', 'pdf'=>'PDF', 'post'=>'Fabrication']; // radio button + const ACF_PROF_IS_ACTIV = ['_name'=>'compte-actif', 'activ'=>'Actif', 'inactiv'=>'Inactif']; // radio button + const ACF_PROF_CGV = ['_name'=>'cgv', 'cgv'=>'cgv']; // checkbox + const ACF_CARD_PRICE_TOTAL = ['_name'=>'somme_a_regler']; // number + const ACF_CARD_NUMBER = ['_name'=>'numero_de_la_carte']; // number + const ACF_CARD_EXPIRATION = ['_name'=>'fin_de_validite']; // date picker + const ACF_CARD_PAYMENT_STATE = ['_name'=>'etat_paiement', 'started'=>'en_cours', 'success'=>'reussi', 'failure'=>'echec', 'nothing'=>'aucun']; // radio button + const ACF_ACCOUNT_STATE = ['_name'=>'etat_compte', 'new'=>'nouveau prof', 'to_pay'=>'doit payer', 'valid'=>'carte valide', 'waiting_invalid'=>'en attente invalide', 'waiting_valid'=>'en attente valide', 'expired'=>'carte expiree']; + const ACF_TRANSFERT_STATE = ['_name'=>'etat_virement', 'waiting'=>'en attente', 'done'=>'reçu']; // META const META_PAYEMENT_STATUS = 'cipf_payement_status';