Jump to content
Jluis

Module Helper List colonne status

Recommended Posts

Posted (edited)

Salut , 
j'ai fait un module avec 2 helper list pour la configuration ;  j'ai mis , pour chacune , un champ status comme suit :
 

 'active' => array(
                'title' => $this->trans('Displayed', array(), 'Admin.Global'),
                'type' => 'bool',
                'active' => 'status', 'class' => 'fixed-width-xs',
                'align' => 'center',
                'ajax' => true,
            ),
'activated' => array(
                'title' => $this->trans('Displayed', array(), 'Admin.Global'),
                'type' => 'bool',
                'active' => 'status',
                'class' => 'fixed-width-xs',
                'align' => 'center',
                'ajax' => true,
            ),

Une deux fonctions pour changer leurs états au niveau base de donnée :


1er fonction pour  modifier l'état du champ "activated"

   public function changeTestimonialsStatus()
    {
        if (!$id_eg_partners_testimonials = (int)Tools::getValue('id_eg_partners_testimonials')) {
            die(Tools::jsonEncode(array('success' => false, 'error' => true, 'text' => $this->trans('Failed to update the status', array(), 'Admin.Global'))));
        } else {
            $reassurancetestimonials = new TestimonyBloc($id_eg_partners_testimonials);
            if (Validate::isLoadedObject($reassurancetestimonials)) {
                $reassurancetestimonials->activated = $reassurancetestimonials->activated == 1 ? 0 : 1;
                $reassurancetestimonials->save() ?
                    die(Tools::jsonEncode(array('success' => true, 'text' => $this->trans('The status has been updated successfully', array(), 'Admin.Global')))) :
                    die(Tools::jsonEncode(array('success' => false, 'error' => true, 'text' => $this->trans('Failed to update the status', array(), 'Admin.Global'))));
            }
        }
    }

 

2ème  fonction pour  modifier l'état du champ "active" :

 

public function changeStatus()
    {
        if (!$id_eg_partners_infos = (int)Tools::getValue('id_eg_partners_infos')) {
            die(Tools::jsonEncode(array('success' => false, 'error' => true, 'text' => $this->trans('Failed to update the status', array(), 'Admin.Global'))));
        } else {
            $reassurance = new PartnerBloc($id_eg_partners_infos);
       
            if (Validate::isLoadedObject($reassurance)) {
                $reassurance->active = $reassurance->active == 1 ? 0 : 1;
                $reassurance->save() ?
                    die(Tools::jsonEncode(array('success' => true, 'text' => $this->trans('The status has been updated successfully', array(), 'Admin.Global')))) :
                    die(Tools::jsonEncode(array('success' => false, 'error' => true, 'text' => $this->trans('Failed to update the status', array(), 'Admin.Global'))));
            }
        }
    }

EN  testant une par une , le changement de l'état de fait , le porblème que pour les 2 ensembles , il ne fonctionnent pas  comme si un double appel  ajax niveau  network console se fait 

 

Edited by Jluis (see edit history)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...

Important Information

Cookies ensure the smooth running of our services. Using these, you accept the use of cookies. Learn More