/**
     * @service campaigns_categories read
     * @param $fields
     */
    public function loadTree(Gpf_Rpc_Params $params) {
        $data = new Gpf_Rpc_Data($params);

        $tree = new Pap_Features_CampaignsCategories_Tree(false, array('Y'));
        $tree->laod();
        $data->setValue(Pap_Features_CampaignsCategories_TreePanel::CAMPAIGNS_CATEGORIES_TREE, $tree->toJSON());
        $data->setValue(Pap_Features_CampaignsCategories_TreePanel::CAMPAIGNS_CATEGORIES_TREE_MAXITEMCODE, '0');

        return $data;
    }
 /**
  *
  * @service campaigns_categories write
  * @param $fields
  * @return Gpf_Rpc_Action
  */
 public function saveTree(Gpf_Rpc_Params $params) {
     $action = new Gpf_Rpc_Action($params);
     $action->setInfoMessage($this->_("Campaign categories structure was saved"));
     
     try {
         $tree = new Pap_Features_CampaignsCategories_Tree(false);
         $tree->save($action->getParam(self::CAMPAIGNS_CATEGORIES_TREE));
         $action->addOk();
     } catch (Gpf_Exception $e) {
         $action->setErrorMessage($e);
         $action->addError();
         return $action;
     }
     return $action;
 }
 protected function afterExecute(Gpf_Data_RecordSet $inputResult) {
     $outputResult = new Gpf_Data_RecordSet();
     $outputResult->setHeader($inputResult->getHeader());
     
     $tree = new Pap_Features_CampaignsCategories_Tree(false);
     foreach ($inputResult as $record) {
         if ($record->get('code')=='0' || $record->get('selected')=='N') {
             continue;
         }
         
         $newRecord = new Gpf_Data_Record($inputResult->getHeader());
         $newRecord->add('name', $this->_localize($tree->getBreadcrumb($record->get('id'), ' > ')));
         $newRecord->add('id', $record->get('id'));
         
         $outputResult->add($newRecord);
     }
     return $outputResult;
 }