public function editCategoriesAction() { if ($this->view->aclIsAllowed($this->view->current_module, 'edit')) { $id = $this->_getParam('ID'); $categoriesObject = new CategoriesObject(); $options = array('moduleID' => Cible_FunctionsModules::getModuleIDByName($this->view->current_module), 'cancelUrl' => "{$this->view->baseUrl()}/{$this->view->current_module}/index/list-categories/"); $form = new FormCategory($options); $this->view->assign('form', $form); if ($this->_request->isPost()) { $formData = $this->_request->getPost(); if ($form->isValid($formData)) { // save $categoriesObject->save($id, $formData, $this->_currentEditLanguage); $allViews = Cible_FunctionsCategories::getCategoryViews($this->_moduleID); $views = Cible_FunctionsCategories::getCategoryViews($this->_moduleID, $id); $reference_views = array(); foreach ($views as $view) { $reference_views[$view['MV_ID']] = $view; } $views = $reference_views; $this->view->dump($views); foreach ($allViews as $view) { $this->view->dump($view); $data = array('MCVP_ModuleID' => $this->_moduleID, 'MCVP_CategoryID' => $id, 'MCVP_ViewID' => $view['MV_ID'], 'MCVP_PageID' => $formData["{$view['MV_Name']}_pageID"]); if (!empty($formData["{$view['MV_Name']}_pageID"])) { if (isset($views[$view['MV_ID']]) && isset($views[$view['MV_ID']]['MCVP_ID'])) { $this->_db->update('ModuleCategoryViewPage', $data, "MCVP_ID = '{$views[$view['MV_ID']]['MCVP_ID']}'"); } else { $this->_db->insert('ModuleCategoryViewPage', $data); } } } $this->_redirect("{$this->view->current_module}/index/list-categories/"); } else { $formData = $this->_request->getPost(); $form->populate($formData); } } else { $data = $categoriesObject->populate($id, $this->_currentEditLanguage); $views = Cible_FunctionsCategories::getCategoryViews($this->_moduleID, $id); if ($views) { foreach ($views as $view) { if (!empty($view['MCVP_PageID'])) { $data["{$view['MV_Name']}_pageID"] = $view['MCVP_PageID']; $data["{$view['MV_Name']}_controllerName"] = $view['PI_PageIndex']; } } } $form->populate($data); } } }
/** * Set the module id. * * @return int */ public function setModuleId() { $this->_moduleID = Cible_FunctionsModules::getModuleIDByName($this->_request->getModuleName()); }
public function categoriesToExcelAction() { if ($this->view->aclIsAllowed($this->view->current_module, 'edit')) { $this->filename = 'Categories.xlsx'; $this->tables = array('Categories' => array('C_ID'), 'CategoriesIndex' => array('CI_Title', 'CI_WordingShowAllRecords')); $this->fields = array('CI_Title' => array('label' => $this->view->getCibleText("list_column_{$this->_moduleID}_CI_Title")), 'CI_WordingShowAllRecords' => array()); $this->filters = array(); $this->select = $this->_db->select()->from('Categories', $this->tables['Categories'])->joinInner('CategoriesIndex', 'Categories.C_ID = CategoriesIndex.CI_CategoryID', $this->tables['CategoriesIndex'])->where('Categories.C_ModuleID = ?', Cible_FunctionsModules::getModuleIDByName($this->view->current_module))->where('CategoriesIndex.CI_LanguageID = ?', $this->_currentInterfaceLanguage); parent::toExcelAction(); } }