public function indexAction() { if ($this->getRequest()->isXmlHttpRequest()) { $sm = $this->getServiceLocator(); $oFormModel = $sm->get('FormsElementTable'); $aFormModel = $oFormModel->getPolaFormularza(1); $oForm = new \My\Dhtmlx\Form(); $xml = $oForm->getXMLForm($aFormModel); $this->getResponse()->getHeaders()->addHeaders(array('Content-type' => 'text/xml')); return $this->getResponse()->setContent($xml); } }
public function addAction() { if ($this->getRequest()->isXmlHttpRequest()) { $sm = $this->getServiceLocator(); $oFormModel = $sm->get('FormsElementTable'); $oForm = new \My\Dhtmlx\Form(); $request = $this->getRequest(); $id_slownika = $this->getEvent()->getRouteMatch()->getParam('id_slownika'); $aSlownik = \My\Tools\Lista::ListaWhere('import_slo', 'id', $id_slownika); if ($request->isPost()) { $oPost = $request->getPost(); try { $bInsert = \My\Tools\Lista::Insert($aSlownik['nazwa'], $oPost->toArray()); if ($bInsert) { $danexml = \My\Dhtmlx\Info::setXMLInfo(array('status' => 1, 'error' => '')); } else { $danexml = \My\Dhtmlx\Info::setXMLInfo(array('status' => 0, 'error' => 'Błąd podczas dodania danych do słownika.')); } } catch (Exception $e) { $danexml = \My\Dhtmlx\Info::setXMLInfo(array('status' => 0, 'error' => 'Błąd danych. Błąd ' . $e->getMessage())); } } else { $danexml = '<?xml version="1.0"?><items>'; $label = "Add"; $danexml .= '<item type="fieldset" name="krok1" className="formstyle" label="' . $label . '" width="500"> <item type="settings" position="label-left" labelAlign="right"/>'; $aKolumny = \My\Tools\Lista::Kolumny($aSlownik['nazwa']); $aSlownikListAvailable = explode(',', $aSlownik['column_list']); $width_pola = 250; $width_label = 150; $styl = $oForm->getStyle(); $aColumnNameSlo = explode(',', $aSlownik['column_mapping_list']); $i = 0; foreach ($aKolumny as $sKey => $column) { $sKolumna = $sKey; if ($sKolumna != 'id' && in_array($column->getName(), $aSlownikListAvailable)) { $danexml .= '<item type="input" required="1" name="' . $column->getName() . '" value="" label="' . $aColumnNameSlo[$i] . ':" inputWidth="' . $width_pola . '" labelWidth="' . $width_label . '" tolltip="tre" style="' . $styl . '">'; $danexml .= '<note>' . $column->getDataType() . ' ' . $column->getCharacterMaximumLength() . '</note>'; $danexml .= '</item>'; $i++; } } $danexml .= '</item>'; $danexml .= '<item type="button" name="save" offsetLeft="350" width="150" value="Save"/>'; $danexml .= '</items>'; } $this->getResponse()->getHeaders()->addHeaders(array('Content-type' => 'text/xml')); return $this->getResponse()->setContent($danexml); } }