public function updateProspectDataAction()
    {
    	$response = array();
    	$this->getEventManager()->trigger('meliscmsprospects_toolprospects_save_start', $this, $response);
    	$id = null;
        $success = 0;
        $errors  = array();
        $textTitle = 'tr_melistoolprospects_tool_prospects';
        $textMessage = '';
        // for event logging
        $translator = $this->getServiceLocator()->get('translator');
        $prospectTable = $this->getServiceLocator()->get('MelisProspects');
        $melisTool = $this->getServiceLocator()->get('MelisCoreTool');
        $melisTool->setMelisToolKey('melistoolprospects', 'melistoolprospects_tool_prospects');
        $prospectForm = $melisTool->getForm('melistoolprospects_tool_prospects_update');
        
        if($this->getRequest()->isPost())
        {
            $postValues = get_object_vars($this->getRequest()->getPost());
            $postValues = $melisTool->sanitizePost($postValues, array('pros_message'));
            $id = $this->getRequest()->getPost('pros_id');
            $prospectForm->setData($postValues);
            
            if($prospectForm->isValid())
            {
                $data = $prospectForm->getData();
                // get the current data
                
                $curData = $prospectTable->getEntryById($id);
                $curData = $curData->current();
                
                $data['pros_contact_date'] = $curData->pros_contact_date;
                $data['pros_type'] = $curData->pros_type;
                
                $prospectTable->save($data, $id);
                
                // add event to Flash messenger
                $textMessage = $translator->translate('tr_prospect_manager_fm_update_data_content');
                $success = 1;
            }
            else {
                $textMessage = $translator->translate('tr_prospect_manager_fm_update_data_content_error');
                $errors = $prospectForm->getMessages();
            }
            
            $melisMelisCoreConfig = $this->serviceLocator->get('MelisCoreConfig');
            $appConfigForm = $melisMelisCoreConfig->getItem('melistoolprospects/tools/melistoolprospects_tool_prospects/forms/melistoolprospects_tool_prospects_update');
            $appConfigForm = $appConfigForm['elements'];
            
            foreach ($errors as $keyError => $valueError)
            {
                foreach ($appConfigForm as $keyForm => $valueForm)
                {
                    if ($valueForm['spec']['name'] == $keyError &&
                        !empty($valueForm['spec']['options']['label']))
                        $errors[$keyError]['label'] = $valueForm['spec']['options']['label'];
                }
            }
        }

        $response = array(
            'success' => $success,
            'textTitle' => $textTitle,
            'textMessage' => $textMessage,
            'errors' => $errors
        );
        
        $this->getEventManager()->trigger('meliscmsprospects_toolprospects_save_end', $this, array_merge($response, array('typeCode' => 'CMS_PROSPECTS_UPDATE', 'itemId' => $id)));
         
        return new JsonModel($response);
        
    }
public function updateProspectDataAction()
    {
    	$response = array();
    	$this->getEventManager()->trigger('meliscmsprospects_toolprospects_save_start', $this, $response);
    	$id = null;
        $success = 0;
        $errors  = array();
        $textTitle = 'tr_melistoolprospects_tool_prospects';
        $textMessage = '';
        // for event logging
        $translator = $this->getServiceLocator()->get('translator');
        $prospectTable = $this->getServiceLocator()->get('MelisProspects');
        $melisTool = $this->getServiceLocator()->get('MelisCoreTool');
        $melisTool->setMelisToolKey('melistoolprospects', 'melistoolprospects_tool_prospects');
        $prospectForm = $melisTool->getForm('melistoolprospects_tool_prospects_update');
        
        if($this->getRequest()->isPost())
        {
            $postValues = get_object_vars($this->getRequest()->getPost());
            $postValues = $melisTool->sanitizePost($postValues, array('pros_message'));
            $id = $this->getRequest()->getPost('pros_id');
            $prospectForm->setData($postValues);
            
            if($prospectForm->isValid())
            {
                $data = $prospectForm->getData();
                // get the current data
                
                $curData = $prospectTable->getEntryById($id);
                $curData = $curData->current();
                
                $data['pros_contact_date'] = $curData->pros_contact_date;
                $data['pros_type'] = $curData->pros_type;
                
                $prospectTable->save($data, $id);
                
                // add event to Flash messenger
                $textMessage = $translator->translate('tr_prospect_manager_fm_update_data_content');
                $success = 1;
            }
            else {
                $textMessage = $translator->translate('tr_prospect_manager_fm_update_data_content_error');
                $errors = $prospectForm->getMessages();
            }
            
            $melisMelisCoreConfig = $this->serviceLocator->get('MelisCoreConfig');
            $appConfigForm = $melisMelisCoreConfig->getItem('melistoolprospects/tools/melistoolprospects_tool_prospects/forms/melistoolprospects_tool_prospects_update');
            $appConfigForm = $appConfigForm['elements'];
            
            foreach ($errors as $keyError => $valueError)
            {
                foreach ($appConfigForm as $keyForm => $valueForm)
                {
                    if ($valueForm['spec']['name'] == $keyError &&
                        !empty($valueForm['spec']['options']['label']))
                        $errors[$keyError]['label'] = $valueForm['spec']['options']['label'];
                }
            }
        }

        $response = array(
            'success' => $success,
            'textTitle' => $textTitle,
            'textMessage' => $textMessage,
            'errors' => $errors
        );
        
        $this->getEventManager()->trigger('meliscmsprospects_toolprospects_save_end', $this, array_merge($response, array('typeCode' => 'CMS_PROSPECTS_UPDATE', 'itemId' => $id)));
         
        return new JsonModel($response);
        
    }
public function updateProspectDataAction ( ) { $ response = array ( ) ; $ this -> getEventManager ( ) -> trigger ( 'meliscmsprospects_toolprospects_save_start' , $ this , $ response ) ; $ id = null ; $ success = 0 ; $ errors = array ( ) ; $ textTitle = 'tr_melistoolprospects_tool_prospects' ; $ textMessage = '' ; // for event logging $ translator = $ this -> getServiceLocator ( ) -> get ( 'translator' ) ; $ prospectTable = $ this -> getServiceLocator ( ) -> get ( 'MelisProspects' ) ; $ melisTool = $ this -> getServiceLocator ( ) -> get ( 'MelisCoreTool' ) ; $ melisTool -> setMelisToolKey ( 'melistoolprospects' , 'melistoolprospects_tool_prospects' ) ; $ prospectForm = $ melisTool -> getForm ( 'melistoolprospects_tool_prospects_update' ) ; if ( $ this -> getRequest ( ) -> isPost ( ) ) { $ postValues = get_object_vars ( $ this -> getRequest ( ) -> getPost ( ) ) ; $ postValues = $ melisTool -> sanitizePost ( $ postValues , array ( 'pros_message' ) ) ; $ id = $ this -> getRequest ( ) -> getPost ( 'pros_id' ) ; $ prospectForm -> setData ( $ postValues ) ; if ( $ prospectForm -> isValid ( ) ) { $ data = $ prospectForm -> getData ( ) ; // get the current data $ curData = $ prospectTable -> getEntryById ( $ id ) ; $ curData = $ curData -> current ( ) ; $ data [ 'pros_contact_date' ] = $ curData -> pros_contact_date ; $ data [ 'pros_type' ] = $ curData -> pros_type ; $ prospectTable -> save ( $ data , $ id ) ; // add event to Flash messenger $ textMessage = $ translator -> translate ( 'tr_prospect_manager_fm_update_data_content' ) ; $ success = 1 ; } else { $ textMessage = $ translator -> translate ( 'tr_prospect_manager_fm_update_data_content_error' ) ; $ errors = $ prospectForm -> getMessages ( ) ; } $ melisMelisCoreConfig = $ this -> serviceLocator -> get ( 'MelisCoreConfig' ) ; $ appConfigForm = $ melisMelisCoreConfig -> getItem ( 'melistoolprospects/tools/melistoolprospects_tool_prospects/forms/melistoolprospects_tool_prospects_update' ) ; $ appConfigForm = $ appConfigForm [ 'elements' ] ; foreach ( $ errors as $ keyError => $ valueError ) { foreach ( $ appConfigForm as $ keyForm => $ valueForm ) { if ( $ valueForm [ 'spec' ] [ 'name' ] == $ keyError && ! empty ( $ valueForm [ 'spec' ] [ 'options' ] [ 'label' ] ) ) $ errors [ $ keyError ] [ 'label' ] = $ valueForm [ 'spec' ] [ 'options' ] [ 'label' ] ; } } } $ response = array ( 'success' => $ success , 'textTitle' => $ textTitle , 'textMessage' => $ textMessage , 'errors' => $ errors ) ; $ this -> getEventManager ( ) -> trigger ( 'meliscmsprospects_toolprospects_save_end' , $ this , array_merge ( $ response , array ( 'typeCode' => 'CMS_PROSPECTS_UPDATE' , 'itemId' => $ id ) ) ) ; return new JsonModel ( $ response ) ; }
Updates an specific information of Prospect Data
@return \Zend\View\Model\JsonModel
Updates an specific information of Prospect Data