public function locationAction() { if ($this->getRequest()->isXmlHttpRequest()) { $danexml = '<?xml version="1.0"?><items>'; $danexml .= '<item type="fieldset" name="loc" className="formstyle" label="Locations" width="200"> <item type="settings" position="label-right" inputWidth="50" labelWidth="100" labelAlign="left"/>'; $aLocation = \My\Tools\Lista::Lista('location'); if (!empty($aLocation)) { foreach ($aLocation as $val) { $danexml .= '<item type="checkbox" value="' . $val["id"] . '" name="' . $val["short"] . '" label="' . $val["name"] . '" />'; } } $danexml .= '</item>'; $danexml .= '</items>'; $this->getResponse()->getHeaders()->addHeaders(array('Content-type' => 'text/xml')); return $this->getResponse()->setContent($danexml); } }
private function setItem($vector, $dane, $def_widthpola = 200, $def_widthlabel = 150) { if (isset($dane[$vector["nazwa_pola"]]) && $dane[$vector["nazwa_pola"]] == '') { $dane[$vector["nazwa_pola"]] = trim($vector["wartosc_domyslna"]); } if ($vector["szerokosc_pola"] == 0) { $width_pola = $def_widthpola; } else { $width_pola = $vector["szerokosc_pola"]; } if ($vector["szerokosc_etykiety"] == 0) { $width_label = $def_widthlabel; } else { $width_label = $vector["szerokosc_etykiety"]; } $styl = $this->styldoedycji; $itemXml = $this->oDom->createElement('item'); if ($vector["margin_gora"] > 0) { $vector["margin_gora"] = $vector["margin_gora"] + 7; } $labelleft = $vector["margin_lewy"] - $width_label - 5; $labeltop = $vector["margin_gora"] + 5; switch ($vector["typ_pola"]) { case 1: //input $itemXml->setAttribute('type', 'input'); $itemXml->setAttribute('required', $vector["czy_wymagane"]); $itemXml->setAttribute('name', $vector["nazwa_pola"]); if (isset($dane[$vector["nazwa_pola"]])) { $itemXml->setAttribute('value', htmlspecialchars($dane[$vector["nazwa_pola"]])); } $itemXml->setAttribute('label', $vector["etykieta"]); $itemXml->setAttribute('labelWidth', $width_label); $itemXml->setAttribute('inputWidth', $width_pola); $itemXml->setAttribute('validate', $vector["walidacja"]); $itemXml->setAttribute('style', $styl); $itemXml->setAttribute('className', $vector["class_css"]); if ($vector["margin_lewy"] > 0 && $vector["margin_gora"] > 0) { $itemXml->setAttribute('position', 'absolute'); $itemXml->setAttribute('inputTop', $vector["margin_gora"]); $itemXml->setAttribute('inputLeft', $vector["margin_lewy"]); $itemXml->setAttribute('labelLeft', $labelleft); $itemXml->setAttribute('labelTop', $labeltop); } break; case 2: if ($vector["czy_wymagane"] == 1) { $itemXml->setAttribute('required', 'true'); $itemXml->setAttribute('validate', $vector["walidacja"]); } $itemXml->setAttribute('type', 'select'); $itemXml->setAttribute('required', $vector["czy_wymagane"]); $itemXml->setAttribute('name', $vector["nazwa_pola"]); // $itemXml->setAttribute('value',htmlspecialchars($dane[$vector["nazwa_pola"]])); $itemXml->setAttribute('label', $vector["etykieta"]); $itemXml->setAttribute('labelWidth', $width_label); $itemXml->setAttribute('inputWidth', $width_pola); $itemXml->setAttribute('style', $styl); $itemXml->setAttribute('className', $vector["class_css"]); if ($vector["margin_lewy"] > 0 && $vector["margin_gora"] > 0) { $itemXml->setAttribute('position', 'absolute'); $itemXml->setAttribute('inputTop', $vector["margin_gora"]); $itemXml->setAttribute('inputLeft', $vector["margin_lewy"]); $itemXml->setAttribute('labelLeft', $labelleft); $itemXml->setAttribute('labelTop', $labeltop); } $select_data = array(); if (trim($vector["tabela_slownikowa"]) != '' && !is_array($vector["tabela_slownikowa"])) { $select_data = \My\Tools\Lista::Lista($vector["tabela_slownikowa"]); } $select_data_insert = ''; if (is_array($vector["tabela_slownikowa"])) { $select_data_insert = $vector["tabela_slownikowa"]; } /* * dodaje arraya do wstrzykniecia * */ $option = $this->oDom->createElement('option'); $option->setAttribute('text', 'Select'); $option->setAttribute('value', ''); $itemXml->appendChild($option); if (is_array($select_data_insert) && count($select_data_insert) > 0) { foreach ($select_data_insert as $key => $val) { $option = $this->oDom->createElement('option'); $option->setAttribute('value', $val["id"]); //$option->setAttribute('text', htmlspecialchars($val["nazwa"])); $option->setAttribute('text', $val["nazwa"]); if (isset($dane[$vector['column']]) && $dane[$vector['column']] == $val["id"]) { $option->setAttribute('selected', 'true'); } $itemXml->appendChild($option); } } $itemXml->appendChild($option); if (is_array($select_data) && count($select_data) > 0) { foreach ($select_data as $val) { $option = $this->oDom->createElement('option'); $option->setAttribute('value', $val["id"]); //$option->setAttribute('text', htmlspecialchars($val["name"])); $option->setAttribute('text', $val["name"]); if (isset($dane[$vector["nazwa_pola"]]) && $val["id"] == $dane[$vector["nazwa_pola"]]) { $option->setAttribute('selected', 'true'); } $itemXml->appendChild($option); } } break; case 3: $itemXml->setAttribute('type', 'calendar'); $itemXml->setAttribute('required', $vector["czy_wymagane"]); $itemXml->setAttribute('className', $vector["class_css"]); $itemXml->setAttribute('dateFormat', '%Y-%m-%d'); $itemXml->setAttribute('name', $vector["nazwa_pola"]); if (isset($dane[$vector["nazwa_pola"]]) && $dane[$vector["nazwa_pola"]] != 0) { $itemXml->setAttribute('value', htmlspecialchars($dane[$vector["nazwa_pola"]])); } $itemXml->setAttribute('label', $vector["etykieta"]); $itemXml->setAttribute('labelWidth', $width_label); $itemXml->setAttribute('inputWidth', $width_pola); $itemXml->setAttribute('validate', $vector["walidacja"]); $itemXml->setAttribute('style', $styl); if ($vector["margin_lewy"] > 0 && $vector["margin_gora"] > 0) { $itemXml->setAttribute('position', 'absolute'); $itemXml->setAttribute('inputTop', $vector["margin_gora"]); $itemXml->setAttribute('inputLeft', $vector["margin_lewy"]); $itemXml->setAttribute('labelLeft', $labelleft); $itemXml->setAttribute('labelTop', $labeltop); } break; case 4: //textarea $itemXml->setAttribute('type', 'input'); $itemXml->setAttribute('rows', '3'); $itemXml->setAttribute('required', $vector["czy_wymagane"]); $itemXml->setAttribute('className', $vector["class_css"]); $itemXml->setAttribute('name', $vector["nazwa_pola"]); $itemXml->setAttribute('value', htmlspecialchars($dane[$vector["nazwa_pola"]])); $itemXml->setAttribute('label', $vector["etykieta"]); $itemXml->setAttribute('labelWidth', $width_label); $itemXml->setAttribute('inputWidth', $width_pola); $itemXml->setAttribute('validate', $vector["walidacja"]); $styl = $this->styldoedycji_txbox; $itemXml->setAttribute('style', $styl); if ($vector["margin_lewy"] > 0 && $vector["margin_gora"] > 0) { $itemXml->setAttribute('position', 'absolute'); $itemXml->setAttribute('inputTop', $vector["margin_gora"]); $itemXml->setAttribute('inputLeft', $vector["margin_lewy"]); $itemXml->setAttribute('labelLeft', $labelleft); $itemXml->setAttribute('labelTop', $labeltop); } // $styl = $this->styldoedycji_txbox; // $danexml.='<item type="input" rows="3" name="'.$vector["nazwa_pola"].'" required="'.$vector["czy_wymagane"].'" value="'.$dane[$vector["nazwa_pola"]].'" label="'.$vector["etykieta"].':" inputWidth="'.$width_pola.'" labelWidth="'.$width_label.'" validate="'.$vector["walidacja"].'" style="'.$styl.'"/>'; break; case 5: $styl = $this->styldoodczytu; $itemXml->setAttribute('type', 'input'); $itemXml->setAttribute('readonly', 'true'); $itemXml->setAttribute('required', $vector["czy_wymagane"]); $itemXml->setAttribute('className', $vector["class_css"]); $itemXml->setAttribute('name', $vector["nazwa_pola"]); $itemXml->setAttribute('value', htmlspecialchars($dane[$vector["nazwa_pola"]])); $itemXml->setAttribute('label', $vector["etykieta"]); $itemXml->setAttribute('labelWidth', $width_label); $itemXml->setAttribute('inputWidth', $width_pola); $itemXml->setAttribute('validate', $vector["walidacja"]); $itemXml->setAttribute('style', $styl); if ($vector["margin_lewy"] > 0 && $vector["margin_gora"] > 0) { $itemXml->setAttribute('position', 'absolute'); $itemXml->setAttribute('inputTop', $vector["margin_gora"]); $itemXml->setAttribute('inputLeft', $vector["margin_lewy"]); $itemXml->setAttribute('labelLeft', $labelleft); $itemXml->setAttribute('labelTop', $labeltop); } break; case 6: $command = ""; $itemXml->setAttribute('type', 'button'); //$itemXml->setAttribute('offsetLeft', $vector["margin_lewy"]); $itemXml->setAttribute('name', $vector["nazwa_pola"]); $itemXml->setAttribute('value', $vector["etykieta"]); $itemXml->setAttribute('label', $vector["etykieta"]); $itemXml->setAttribute('labelWidth', $width_label); $itemXml->setAttribute('inputWidth', $width_pola); $itemXml->setAttribute('validate', $vector["walidacja"]); $itemXml->setAttribute('style', $styl); $itemXml->setAttribute('className', $vector["class_css"]); if ($vector["margin_lewy"] > 0) { $itemXml->setAttribute('position', 'absolute'); $itemXml->setAttribute('inputTop', $vector["margin_gora"]); $itemXml->setAttribute('inputLeft', $vector["margin_lewy"]); $itemXml->setAttribute('labelLeft', $labelleft); $itemXml->setAttribute('labelTop', $labeltop); } break; case 7: $itemXml->setAttribute('type', 'checkbox'); $itemXml->setAttribute('required', $vector["czy_wymagane"]); $itemXml->setAttribute('name', $vector["nazwa_pola"]); $itemXml->setAttribute('value', 1); $itemXml->setAttribute('label', $vector["etykieta"]); if ($dane['wartosc_domyslna'] != '') { $vector["wartosc_domyslna"] = $dane['wartosc_domyslna']; } $itemXml->setAttribute('checked', \My\Tools\Lista::Logiczna($vector["wartosc_domyslna"])); $itemXml->setAttribute('labelWidth', $width_label); $itemXml->setAttribute('inputWidth', $width_pola); $itemXml->setAttribute('validate', $vector["walidacja"]); $itemXml->setAttribute('style', $styl); $itemXml->setAttribute('className', $vector["class_css"]); if ($vector["margin_lewy"] > 0 && $vector["margin_gora"] > 0) { $itemXml->setAttribute('position', 'absolute'); $itemXml->setAttribute('inputTop', $vector["margin_gora"]); $itemXml->setAttribute('inputLeft', $vector["margin_lewy"]); $itemXml->setAttribute('labelLeft', $labelleft); $itemXml->setAttribute('labelTop', $labeltop); } break; case 8: $itemXml->setAttribute('type', 'hidden'); $itemXml->setAttribute('name', $vector["nazwa_pola"]); $itemXml->setAttribute('value', htmlspecialchars($dane[$vector["nazwa_pola"]])); $itemXml->setAttribute('label', $vector["etykieta"]); $itemXml->setAttribute('labelWidth', $width_label); $itemXml->setAttribute('inputWidth', $width_pola); $itemXml->setAttribute('validate', $vector["walidacja"]); $itemXml->setAttribute('style', $styl); $itemXml->setAttribute('className', $vector["class_css"]); if ($vector["margin_lewy"] > 0 && $vector["margin_gora"] > 0) { $itemXml->setAttribute('position', 'absolute'); $itemXml->setAttribute('inputTop', $vector["margin_gora"]); $itemXml->setAttribute('inputLeft', $vector["margin_lewy"]); $itemXml->setAttribute('labelLeft', $labelleft); $itemXml->setAttribute('labelTop', $labeltop); } $command = ''; // $danexml.='<item type="hidden" offsetLeft="'.$vector["margin_lewy"].'" name="'.$vector["nazwa_pola"].'" value="'.$vector["etykieta"].'" width="'.$width_pola.'" '.$command.' style="'.$styl.'"/>'; break; case 9: $itemXml->setAttribute('type', 'file'); $itemXml->setAttribute('name', $vector["nazwa_pola"]); $itemXml->setAttribute('value', htmlspecialchars($dane[$vector["nazwa_pola"]])); $itemXml->setAttribute('label', $vector["etykieta"]); $itemXml->setAttribute('labelWidth', $width_label); $itemXml->setAttribute('inputWidth', $width_pola); $itemXml->setAttribute('validate', $vector["walidacja"]); $itemXml->setAttribute('style', $styl); $itemXml->setAttribute('className', $vector["class_css"]); if ($vector["margin_lewy"] > 0 && $vector["margin_gora"] > 0) { $itemXml->setAttribute('position', 'absolute'); $itemXml->setAttribute('inputTop', $vector["margin_gora"]); $itemXml->setAttribute('inputLeft', $vector["margin_lewy"]); $itemXml->setAttribute('labelLeft', $labelleft); $itemXml->setAttribute('labelTop', $labeltop); } $command = ''; // $danexml.='<item type="hidden" offsetLeft="'.$vector["margin_lewy"].'" name="'.$vector["nazwa_pola"].'" value="'.$vector["etykieta"].'" width="'.$width_pola.'" '.$command.' style="'.$styl.'"/>'; break; case 10: $itemXml->setAttribute('type', 'template'); $itemXml->setAttribute('name', htmlspecialchars($vector["nazwa_pola"])); //$itemXml->setAttribute('value', htmlspecialchars($dane[$vector["nazwa_pola"]])); if (isset($dane[$vector["nazwa_pola"]])) { $itemXml->setAttribute('value', $dane[$vector["nazwa_pola"]]); } $itemXml->setAttribute('label', $vector["etykieta"]); $itemXml->setAttribute('labelWidth', $width_label); $itemXml->setAttribute('inputWidth', $width_pola); $itemXml->setAttribute('className', $vector["class_css"]); //inputHeight $itemXml->setAttribute('style', $this->styldoedycji_template); if ($vector["margin_lewy"] > 0 && $vector["margin_gora"] > 0) { $itemXml->setAttribute('position', 'absolute'); $itemXml->setAttribute('inputTop', $vector["margin_gora"]); $itemXml->setAttribute('inputLeft', $vector["margin_lewy"]); $itemXml->setAttribute('labelLeft', $labelleft); $itemXml->setAttribute('labelTop', $labeltop); } $command = ''; // $danexml.='<item type="hidden" offsetLeft="'.$vector["margin_lewy"].'" name="'.$vector["nazwa_pola"].'" value="'.$vector["etykieta"].'" width="'.$width_pola.'" '.$command.' style="'.$styl.'"/>'; break; case 12: $itemXml->setAttribute('type', 'block'); $itemXml->setAttribute('name', $vector["nazwa_pola"]); $itemXml->setAttribute('width', $width_pola); // $itemXml->setAttribute('validate', $vector["walidacja"]); $itemXml->setAttribute('className', $vector["class_css"]); if ($vector["margin_lewy"] > 0 && $vector["margin_gora"] > 0) { $itemXml->setAttribute('position', 'absolute'); $itemXml->setAttribute('inputTop', $vector["margin_gora"]); $itemXml->setAttribute('inputLeft', $vector["margin_lewy"]); $itemXml->setAttribute('labelLeft', $labelleft); $itemXml->setAttribute('labelTop', $labeltop); } break; case 13: $itemXml->setAttribute('type', 'newcolumn'); $itemXml->setAttribute('name', $vector["nazwa_pola"]); if ($vector["margin_lewy"] > 0 && $vector["margin_gora"] > 0) { $itemXml->setAttribute('position', 'absolute'); $itemXml->setAttribute('inputTop', $vector["margin_gora"]); $itemXml->setAttribute('inputLeft', $vector["margin_lewy"]); $itemXml->setAttribute('labelLeft', $labelleft); $itemXml->setAttribute('labelTop', $labeltop); } $command = ''; // $danexml.='<item type="hidden" offsetLeft="'.$vector["margin_lewy"].'" name="'.$vector["nazwa_pola"].'" value="'.$vector["etykieta"].'" width="'.$width_pola.'" '.$command.' style="'.$styl.'"/>'; break; case 14: unset($itemXml); $aItem = array(); $select_data = array(); if (trim($vector["tabela_slownikowa"]) != '' && !is_array($vector["tabela_slownikowa"])) { if (!isset($vector["tabela_slownikowa_baza"])) { $vector["tabela_slownikowa_baza"] = $this->iDbDefault; } $select_data = \My\Tools\Lista::Lista($vector["tabela_slownikowa"]); } $select_data_insert = ''; if (is_array($vector["tabela_slownikowa"])) { $select_data_insert = $vector["tabela_slownikowa"]; } $count = count($select_data_insert); $iIloscKolumn = $vector["ilosc_kolumn"]; $ile = ceil($count / $iIloscKolumn); /* * wstrzykiwanie danych * */ if (is_array($select_data_insert) && count($select_data_insert) > 0) { $i = 0; foreach ($select_data_insert as $key => $val) { $i++; $itemXml = $this->oDom->createElement('item'); $itemXml->setAttribute('className', $vector["class_css"]); if ($vector["czy_wymagane"] == 1) { $itemXml->setAttribute('required', 'true'); } else { $itemXml->setAttribute('required', 'false'); } if ($vector["walidacja"] != '') { $itemXml->setAttribute('validate', $vector["walidacja"]); } $itemXml->setAttribute('type', 'radio'); $itemXml->setAttribute('name', $vector["nazwa_pola"]); $itemXml->setAttribute('label', $vector["etykieta"]); $itemXml->setAttribute('labelWidth', $width_label); $itemXml->setAttribute('labelAlign', 'left'); $itemXml->setAttribute('position', 'label-right'); $itemXml->setAttribute('inputWidth', $width_pola); $itemXml->setAttribute('style', $styl); if ($vector["margin_lewy"] > 0 && $vector["margin_gora"] > 0) { $itemXml->setAttribute('position', 'absolute'); $itemXml->setAttribute('inputTop', $vector["margin_gora"]); $itemXml->setAttribute('inputLeft', $vector["margin_lewy"]); $itemXml->setAttribute('labelLeft', $labelleft); $itemXml->setAttribute('labelTop', $labeltop); } $itemXml->setAttribute('value', $val["id"]); $itemXml->setAttribute('label', htmlspecialchars($val["name"])); if (isset($dane[$vector['column']]) && $dane[$vector['column']] == $val["id"]) { $itemXml->setAttribute('checked', 'true'); } $aItem[] = $itemXml; if ($i == $ile) { $itemXml2 = $this->oDom->createElement('item'); $itemXml2->setAttribute('type', 'newcolumn'); $aItem[] = $itemXml2; $i = 0; } } } $count = count($select_data); $iIloscKolumn = $vector["ilosc_kolumn"]; $ile = ceil($count / $iIloscKolumn); if (is_array($select_data) && count($select_data) > 0) { $i = 0; foreach ($select_data as $val) { $i++; $itemXml = $this->oDom->createElement('item'); $itemXml->setAttribute('type', 'radio'); $itemXml->setAttribute('className', $vector["class_css"]); if ($vector["czy_wymagane"] == 1) { $itemXml->setAttribute('required', 'true'); } else { $itemXml->setAttribute('required', 'false'); } if ($vector["walidacja"] != '') { $itemXml->setAttribute('validate', $vector["walidacja"]); } else { $itemXml->setAttribute('validate', ""); } $itemXml->setAttribute('name', $vector["nazwa_pola"]); $itemXml->setAttribute('label', $vector["etykieta"]); $itemXml->setAttribute('labelWidth', $width_label); $itemXml->setAttribute('inputWidth', $width_pola); $itemXml->setAttribute('labelAlign', 'left'); $itemXml->setAttribute('position', 'label-right'); $itemXml->setAttribute('style', $styl); if ($vector["margin_lewy"] > 0 && $vector["margin_gora"] > 0) { $itemXml->setAttribute('position', 'absolute'); $itemXml->setAttribute('inputTop', $vector["margin_gora"]); $itemXml->setAttribute('inputLeft', $vector["margin_lewy"]); $itemXml->setAttribute('labelLeft', $labelleft); $itemXml->setAttribute('labelTop', $labeltop); } $itemXml->setAttribute('value', $val["id"]); $itemXml->setAttribute('label', htmlspecialchars($val["name"])); if (isset($dane[$vector["nazwa_pola"]]) && $val["id"] == $dane[$vector["nazwa_pola"]]) { $itemXml->setAttribute('checked', 'true'); } $aItem[] = $itemXml; if ($i == $ile) { $itemXml2 = $this->oDom->createElement('item'); $itemXml2->setAttribute('type', 'newcolumn'); $aItem[] = $itemXml2; $i = 0; } } } $itemXml = $aItem; break; case 15: $itemXml->setAttribute('type', 'label'); $itemXml->setAttribute('name', $vector["nazwa_pola"]); $itemXml->setAttribute('width', $width_pola); $itemXml->setAttribute('validate', $vector["walidacja"]); $itemXml->setAttribute('label', $vector["etykieta"]); $itemXml->setAttribute('style', $styl); $itemXml->setAttribute('className', $vector["class_css"]); if ($vector["margin_lewy"] > 0 && $vector["margin_gora"] > 0) { $itemXml->setAttribute('position', 'absolute'); $itemXml->setAttribute('inputTop', $vector["margin_gora"]); $itemXml->setAttribute('inputLeft', $vector["margin_lewy"]); $itemXml->setAttribute('labelLeft', $labelleft); $itemXml->setAttribute('labelTop', $labeltop); } $command = ''; // $danexml.='<item type="hidden" offsetLeft="'.$vector["margin_lewy"].'" name="'.$vector["nazwa_pola"].'" value="'.$vector["etykieta"].'" width="'.$width_pola.'" '.$command.' style="'.$styl.'"/>'; break; case 16: $itemXml->setAttribute('type', 'container'); $itemXml->setAttribute('name', $vector["nazwa_pola"]); $itemXml->setAttribute('width', $width_pola); $itemXml->setAttribute('validate', $vector["walidacja"]); $itemXml->setAttribute('style', $styl); $itemXml->setAttribute('className', $vector["class_css"]); if ($vector["margin_lewy"] > 0 && $vector["margin_gora"] > 0) { $itemXml->setAttribute('position', 'absolute'); $itemXml->setAttribute('inputTop', $vector["margin_gora"]); $itemXml->setAttribute('inputLeft', $vector["margin_lewy"]); $itemXml->setAttribute('labelLeft', $labelleft); $itemXml->setAttribute('labelTop', $labeltop); } $command = ''; // $danexml.='<item type="hidden" offsetLeft="'.$vector["margin_lewy"].'" name="'.$vector["nazwa_pola"].'" value="'.$vector["etykieta"].'" width="'.$width_pola.'" '.$command.' style="'.$styl.'"/>'; break; case 17: $itemXml->setAttribute('type', 'upload'); $itemXml->setAttribute('name', $vector["nazwa_pola"]); $itemXml->setAttribute('width', $width_pola); $itemXml->setAttribute('validate', $vector["walidacja"]); $itemXml->setAttribute('style', $styl); $itemXml->setAttribute('className', $vector["class_css"]); $itemXml->setAttribute('autoStart', $vector["autostartupload"]); //$itemXml->setAttribute('url', ""); if ($vector["margin_lewy"] > 0 && $vector["margin_gora"] > 0) { $itemXml->setAttribute('position', 'absolute'); $itemXml->setAttribute('inputTop', $vector["margin_gora"]); $itemXml->setAttribute('inputLeft', $vector["margin_lewy"]); $itemXml->setAttribute('labelLeft', $labelleft); $itemXml->setAttribute('labelTop', $labeltop); } $command = ''; // $danexml.='<item type="hidden" offsetLeft="'.$vector["margin_lewy"].'" name="'.$vector["nazwa_pola"].'" value="'.$vector["etykieta"].'" width="'.$width_pola.'" '.$command.' style="'.$styl.'"/>'; break; case 18: $itemXml->setAttribute('type', 'fieldset'); $itemXml->setAttribute('name', $vector["nazwa_pola"]); $itemXml->setAttribute('label', $vector["etykieta"]); $itemXml->setAttribute('width', $width_pola); $itemXml->setAttribute('style', $styl); $itemXml->setAttribute('className', $vector["class_css"]); if ($vector["margin_lewy"] > 0 && $vector["margin_gora"] > 0) { $itemXml->setAttribute('position', 'absolute'); $itemXml->setAttribute('inputTop', $vector["margin_gora"]); $itemXml->setAttribute('inputLeft', $vector["margin_lewy"]); $itemXml->setAttribute('labelLeft', $labelleft); $itemXml->setAttribute('labelTop', $labeltop); } break; case 19: //input with checkbox window $itemXml->setAttribute('type', 'input'); $itemXml->setAttribute('required', $vector["czy_wymagane"]); $itemXml->setAttribute('name', $vector["nazwa_pola"]); if (isset($dane[$vector["nazwa_pola"]])) { $itemXml->setAttribute('value', htmlspecialchars($dane[$vector["nazwa_pola"]])); } $itemXml->setAttribute('label', $vector["etykieta"]); $itemXml->setAttribute('labelWidth', $width_label); $itemXml->setAttribute('inputWidth', $width_pola); $itemXml->setAttribute('validate', $vector["walidacja"]); $itemXml->setAttribute('style', $styl); $itemXml->setAttribute('className', $vector["class_css"]); if ($vector["margin_lewy"] > 0 && $vector["margin_gora"] > 0) { $itemXml->setAttribute('position', 'absolute'); $itemXml->setAttribute('inputTop', $vector["margin_gora"]); $itemXml->setAttribute('inputLeft', $vector["margin_lewy"]); $itemXml->setAttribute('labelLeft', $labelleft); $itemXml->setAttribute('labelTop', $labeltop); } break; case 20: //combo if ($vector["czy_wymagane"] == 1) { $itemXml->setAttribute('required', 'true'); $itemXml->setAttribute('validate', $vector["walidacja"]); } $itemXml->setAttribute('type', 'combo'); $itemXml->setAttribute('required', $vector["czy_wymagane"]); $itemXml->setAttribute('name', $vector["nazwa_pola"]); $itemXml->setAttribute('label', $vector["etykieta"]); $itemXml->setAttribute('labelWidth', $width_label); $itemXml->setAttribute('inputWidth', $width_pola); $itemXml->setAttribute('style', $styl); $itemXml->setAttribute('autocomplete', 'on'); $itemXml->setAttribute('className', $vector["class_css"]); if ($vector["margin_lewy"] > 0 && $vector["margin_gora"] > 0) { $itemXml->setAttribute('position', 'absolute'); $itemXml->setAttribute('inputTop', $vector["margin_gora"]); $itemXml->setAttribute('inputLeft', $vector["margin_lewy"]); $itemXml->setAttribute('labelLeft', $labelleft); $itemXml->setAttribute('labelTop', $labeltop); } $select_data = array(); if (trim($vector["tabela_slownikowa"]) != '' && !is_array($vector["tabela_slownikowa"])) { $select_data = \My\Tools\Lista::Lista($vector["tabela_slownikowa"]); } $select_data_insert = ''; if (is_array($vector["tabela_slownikowa"])) { $select_data_insert = $vector["tabela_slownikowa"]; } /* * dodaje arraya do wstrzykniecia * */ $option = $this->oDom->createElement('option'); $option->setAttribute('text', ''); $option->setAttribute('value', ''); $itemXml->appendChild($option); if (is_array($select_data_insert) && count($select_data_insert) > 0) { foreach ($select_data_insert as $key => $val) { $option = $this->oDom->createElement('option'); $option->setAttribute('value', $val["id"]); $option->setAttribute('text', htmlspecialchars($val["nazwa"])); if (isset($dane[$vector['column']]) && $dane[$vector['column']] == $val["id"]) { $option->setAttribute('selected', 'true'); } $itemXml->appendChild($option); } } $itemXml->appendChild($option); if (is_array($select_data) && count($select_data) > 0) { foreach ($select_data as $val) { $option = $this->oDom->createElement('option'); $option->setAttribute('value', $val["id"]); $option->setAttribute('text', htmlspecialchars($val["nazwa"])); if (isset($dane[$vector["nazwa_pola"]]) && $val["id"] == $dane[$vector["nazwa_pola"]]) { $option->setAttribute('selected', 'true'); } $itemXml->appendChild($option); } } break; } if (!is_array($itemXml) && $this->czy_podpowiedzi && $vector["podpowiedz"] != '') { $note = $this->oDom->createElement('note', $vector["podpowiedz"]); $itemXml->appendChild($note); } return $itemXml; }
public static function ListaWszystkieKolumnyLimit($nazwaSlownika, $limit = null, $offset = null) { $aKolumny = \My\Tools\Lista::KolumnyNazwy($nazwaSlownika); $select = new \Zend\Db\Sql\Select(); $select->from($nazwaSlownika); if (in_array('deleted', $aKolumny)) { $select->where('deleted=0'); } if (in_array('is_active', $aKolumny)) { $select->where('is_active=1'); } if (!is_null($limit) && $limit > 0) { $select->limit((int) $limit); } if (!is_null($offset) && $offset >= 0) { $select->offset((int) $offset); } $projectTable = new TableGateway($nazwaSlownika, \Zend\Db\TableGateway\Feature\GlobalAdapterFeature::getStaticAdapter()); $rowset = $projectTable->selectWith($select); if ($rowset) { return $rowset->toArray(); } return array(); }
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); } }
public function deleteAction() { if ($this->getRequest()->isXmlHttpRequest()) { $id_slownika = $this->getEvent()->getRouteMatch()->getParam('id_slownika'); $id = $this->getEvent()->getRouteMatch()->getParam('id'); $aSlownik = \My\Tools\Lista::ListaWhere('import_slo', 'id', $id_slownika); if ($aSlownik) { $aWartosci = \My\Tools\Lista::ListaWhere($aSlownik['nazwa'], 'id', $id); if ($aWartosci) { $bUpdate = \My\Tools\Lista::Update($aSlownik['nazwa'], array('deleted' => 1), $id); if ($bUpdate) { $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.')); } } } $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); } } } } }
public static function polaczFromularzZPelnymDanymiDoGrida($aFrom, $aDane) { $aDaneOut = array(); foreach ($aFrom as $keyForm => $pole) { foreach ($aDane as $keyDane => $dane) { if ($pole['nazwa_pola'] == $keyDane) { $aDaneOut[$keyForm]['id'] = $keyForm; $aDaneOut[$keyForm][$keyDane] = array('type' => 'ro', 'class' => 'form_cell', 'value' => $pole['etykieta']); if ($pole['tabela_slownikowa'] != '') { $aData = \My\Tools\Lista::Lista($pole["tabela_slownikowa"]); $aDataSlownik = \My\Tools\Lista::Slownik($aData, 'id'); $dane = isset($aDataSlownik[$dane]) ? $aDataSlownik[$dane]['name'] : $dane; } $aDaneOut[$keyForm][$keyForm] = array('type' => 'ro', 'class' => '', 'value' => $dane); } } } return $aDaneOut; }