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); } }
protected function saveHistory($aNewValues, $aOldValues, $iId) { $iIdUzytkownika = 1; $aPomijaneKolumny = array('cr_date', 'cr_user'); foreach ($aNewValues as $sNazwaKolumny => $sNowaWartosc) { if (!is_integer($sNazwaKolumny)) { if (!in_array($sNazwaKolumny, $aPomijaneKolumny)) { $sStaraWartosc = isset($aOldValues[$sNazwaKolumny]) ? $aOldValues[$sNazwaKolumny] : ''; if ($sNowaWartosc != $sStaraWartosc) { $aData = array(); if (empty($aStareDane)) { $aData['operation'] = 'I'; } else { $aData['operation'] = 'U'; } $aData['table_name'] = $this->getTable(); $aData['column_name'] = $sNazwaKolumny; $aData['new_value'] = $sNowaWartosc; $aData['old_value'] = $aOldValues[$sNazwaKolumny]; $aData['id_user'] = $iIdUzytkownika; $aData['row_id'] = $iId; $aData['cr_Date'] = new \Zend\Db\Sql\Expression("getdate()"); \My\Tools\Lista::Insert($this->sHistoryTableName, $aData); } } } } }