diff --git a/metadata/dbms/DBMSRecords.java b/metadata/dbms/DBMSRecords.java index caeffd4..ac9f578 100644 --- a/metadata/dbms/DBMSRecords.java +++ b/metadata/dbms/DBMSRecords.java @@ -2163,7 +2163,7 @@ public class DBMSRecords implements ServletContextAware { Statement st = null; try { st = conn.createStatement(); - String sql = "select t.translation from main._translations t where t.identifier='"+key+"' and t.language_id='"+user.language_id+"';"; + String sql = "select case when '"+user.language_id+"'='666' then t.translation||'''\"' alse t.translation end as translation from main._translations t where t.identifier='"+key+"' and (t.language_id='"+user.language_id+"' or ('"+user.language_id+"'='666' and t.language_id=1));"; rs = st.executeQuery(sql); if(rs != null) { if (rs.next()) { diff --git a/metadata/dbms/editrecord.js b/metadata/dbms/editrecord.js index 087c0be..35baf04 100644 --- a/metadata/dbms/editrecord.js +++ b/metadata/dbms/editrecord.js @@ -1,4 +1,4 @@ -//Copyright (C) 2008 Ivanov I.M. irigm@mail.ru +77051809750 +//Copyright (C) Ivanov I.M. irigm@mail.ru +77051809750 file created in 2008 //For find non english chars: [^\x00-\x7F]+ //Заглушки @@ -20,7 +20,7 @@ class EdtRec this.win.setContent('
'); let eDiv=document.getElementById('eDiv'+this.uid); - eDiv.innerHTML = '
' + eDiv.innerHTML = '
' if(caption!='') this.win.setCaption(document.createTextNode(caption)); @@ -50,7 +50,7 @@ class EdtRec { this.pBarDiv=document.createElement('div'); this.pBarDiv.style.cssText='position: absolute; left: 0px; top: 0px; z-index: 1; background-color: rgba(0,0,0,0.5); width:100%; height: 100%;'; - this.pBarDiv.innerHTML='
'; + this.pBarDiv.innerHTML='
'; let eDiv=document.getElementById('eDiv'+this.uid); if(eDiv==null) return; @@ -100,6 +100,16 @@ class EdtRec nodeProp=nodeProp.nextSibling; } } + //Задать новое значение GUI полю (не XML, XML выше) + setValue(propName,value){ + let field=document.getElementById("prop_"+this.uid+"_"+propName); + if(field!=null) + { + field.value=value; + }else{ + console.error('Field "'+propName+'" not found!'); + } + } //Apply the settings to the current node "type-> n" must match. setXMLSettings(xml) @@ -140,8 +150,8 @@ class EdtRec str+=' '; str+=' '; str+=' '; - str+=' '+trt('Name')+''; - str+=' '+trt('Value')+''; + str+=' '+trt('Name')+''; + str+=' '+trt('Value')+''; str+=' '; str+=' '; str+=' '; @@ -150,16 +160,16 @@ class EdtRec //this.win.setContent(str); //document.getElementById('menu').parentNode.appendChild( this.win.div ) - var eTable=document.getElementById('eTable'+this.uid); + let eTable=document.getElementById('eTable'+this.uid); - var type_name=nodeType.getAttribute("n"); + let type_name=nodeType.getAttribute("n"); //document.getElementById('caption'+this.uid).appendChild(document.createTextNode(nodeType.getAttribute("d"))); this.win.setCaption(document.createTextNode(nodeType.getAttribute("d"))); - var nodeProperties=findNodeOnPath(this.nodeMetadata, 'type/properties'); + let nodeProperties=findNodeOnPath(this.nodeMetadata, 'type/properties'); this.win.setWidth(nodeProperties.getAttribute("width")); - - var nodeFilters=findNodeOnPath(Node,'type/objects-list/filter'); - var nodeProp=null; + + let nodeFilters=findNodeOnPath(Node,'type/objects-list/filter'); + let nodeProp=null; //For convenience, when adding a new record, we rewrite the values from the parent filter in the edit field. if(nodeFilters!=null) @@ -176,10 +186,10 @@ class EdtRec { if (nodeFilter.getAttribute("n")==nodeProp.getAttribute("n")) { - var cdata1=findFirstNode(nodeFilter,'#cdata-section'); + let cdata1=findFirstNode(nodeFilter,'#cdata-section'); if((cdata1!=null)&&(cdata1.nodeValue!="")) { - var cdata2=findFirstNode(nodeProp,'#cdata-section'); + let cdata2=findFirstNode(nodeProp,'#cdata-section'); if (cdata2==null) { cdata2 = nodeProp.ownerDocument.createCDATASection(""); @@ -290,7 +300,7 @@ class EdtRec //td2.style.width=row+"px"; } - if(vt=="html"){ + if(vt==="html"){ td1.innerHTML=nodeProp.getAttribute("d")+'
'; }else{ td1.innerHTML=nodeProp.getAttribute("d"); @@ -302,7 +312,7 @@ class EdtRec let value=getCdata(nodeProp).nodeValue; - if(vt=="string" || vt=="str") + if(vt==="string" || vt==="str") { let table=document.createElement('table'); table.style.cssText="width:100%;border-spacing:0;border-collapse:collapse;border:0px;"; @@ -360,7 +370,7 @@ class EdtRec td2.appendChild( table ); }else - if(vt=="password") + if(vt==="password") { let input = document.createElement('input'); input.classList.add('DBMS'); @@ -371,7 +381,7 @@ class EdtRec input.setAttribute("id","prop_"+this.uid+"_"+nodeProp.getAttribute("n")); td2.appendChild( input ); }else - if(vt=="b") + if(vt==="b") { let select = document.createElement('select'); select.classList.add('DBMS'); @@ -411,7 +421,7 @@ class EdtRec select.setAttribute("id","prop_"+this.uid+"_"+nodeProp.getAttribute("n")); td2.appendChild( select ); }else - if(vt=="i4") + if(vt==="i4") { //If there is a node "list" with the elements "CheckBox" then create them. let opt=findNode(nodeProp, "options"); @@ -477,7 +487,7 @@ class EdtRec td2.appendChild( table ); } }else - if(vt=="f4") + if(vt==="f4") { let input = document.createElement('input'); input.classList.add('DBMS'); @@ -488,7 +498,7 @@ class EdtRec input.setAttribute("id","prop_"+this.uid+"_"+nodeProp.getAttribute("n")); td2.appendChild( input ); }else - if(vt=="object") + if(vt==="object") { let input=null; if(nodeProp.getAttribute("selector")=="combo") @@ -530,20 +540,20 @@ class EdtRec td2.appendChild( table ); //send a request for data (Only if creating a new record (if editing then requesting data only needs to come from the data itself because the data in the hung lists will receive data 2 times)) - /*var nTypeF = findFirstNode(nodeProp, "type"); + /*let nTypeF = findFirstNode(nodeProp, "type"); if(nTypeF != null) //Запрос с параметрами не можем отправить без подгрузки данных { //Add parameters to request nTypeF.setAttribute("c",nodeProp.getAttribute("FieldCaption")); nTypeF.setAttribute("pn",nodeProp.getAttribute("n")); - var strXMLF = getXMLNodeSerialisation(nTypeF); - var nColF=nodeProperties.firstChild; + let strXMLF = getXMLNodeSerialisation(nTypeF); + let nColF=nodeProperties.firstChild; while(nColF != null) { if(nColF.nodeName==="prop") { - var valF=getCdataValue(nColF); + let valF=getCdataValue(nColF); strXMLF=strXMLF.replace('${'+nColF.getAttribute('n')+'}', valF); } nColF = nColF.nextSibling; @@ -555,7 +565,7 @@ class EdtRec } }else { - var xml=''; + let xml=''; if(this.request.callServer(ScriptName,xml,true)); { this.showProgressBar(); @@ -599,7 +609,7 @@ class EdtRec //We request the field title by the field id (if it is filled). /*if ((value!="")&&(value!=-1)) { - var xml=''; + let xml=''; xml+=''; xml+=''; if(this.request.callServer(ScriptName,xml,true)) @@ -609,7 +619,7 @@ class EdtRec }*/ } }else - if(vt=="text") { + if(vt==="text") { let ta = document.createElement('textarea') ta.classList.add('DBMS'); ta.setAttribute("id", "prop_" + this.uid + "_" + nodeProp.getAttribute("n")); @@ -620,7 +630,7 @@ class EdtRec td2.appendChild(ta); }else - if(vt=="html"){ + if(vt==="html"){ let ta = document.createElement('textarea') ta.classList.add('DBMS'); ta.setAttribute("id", "prop_" + this.uid + "_" + nodeProp.getAttribute("n")); @@ -630,12 +640,12 @@ class EdtRec ta.setAttribute("value", value); td2.appendChild(ta); - /*var cdv=document.createElement('div'); + /*let cdv=document.createElement('div'); cdv.innerHTML+='[Show]'; cdv.innerHTML+=' [Hide]'; td2.appendChild( cdv );*/ }else - if(vt=="blob" || vt=="file") + if(vt==="blob" || vt==="file") { let ifr=createIFrame("prop_"+this.uid+"_"+nodeProp.getAttribute("n")+'_frm', ScriptUName+"?fn=9", td2, false); //IFrame to send the file to the server. document.body.appendChild(ifr); @@ -699,7 +709,7 @@ class EdtRec if(BeforeFirst(doc.body.innerHTML,'=')=='ok') { - var fName=BeforeFirst(AfterFirst(doc.body.innerHTML,'='),"\n"); + let fName=BeforeFirst(AfterFirst(doc.body.innerHTML,'='),"\n"); inp.value=fName;//BeforeLast(inp.value,'.')+'_'+fName; if(inp.value!='') { obj.sendData(); @@ -709,7 +719,7 @@ class EdtRec }(btnSel,input,this); }else - if(vt=="date" || vt=="dateTime") + if(vt==="date" || vt==="dateTime") { let table=document.createElement('table'); table.style.cssText="width:100%;border-spacing:0;border-collapse:collapse;border:0px;"; @@ -728,14 +738,14 @@ class EdtRec input.setAttribute("id","prop_"+this.uid+"_"+nodeProp.getAttribute("n")); newCell1.appendChild( input ); - var img = document.createElement('img'); + let img = document.createElement('img'); img.src='../resources/metadata/dbms/images/datepicker.jpg'; img.style.cssText="cursor: pointer;"; newCell2.appendChild(img); td2.appendChild( table ); - if(vt=="date") + if(vt==="date") new Calendar({ inputField: input, dateFormat: "%Y-%m-%d", @@ -747,7 +757,7 @@ class EdtRec this.hide(); } }); - if(vt=="dateTime") + if(vt==="dateTime") new Calendar({ inputField: input, dateFormat: "%Y-%m-%d %H:%M:%S", @@ -784,7 +794,7 @@ class EdtRec td.setAttribute("colspan", "2"); if (this.record_id==-1) td.innerHTML=''; tr.appendChild(td); - //var td = document.createElement('td'); + //let td = document.createElement('td'); td.setAttribute("align","right"); let button = document.createElement('input'); button.classList.add('button-secondary'); @@ -839,8 +849,8 @@ class EdtRec onComboObjectChangeHandler(node) { //I go through the fields and if there is a configurable query, I re-query the data - var nodeType=findFirstNode(this.nodeMetadata, "type"); - var nodeProperties=findNodeOnPath(this.nodeMetadata, 'type/properties'); + let nodeType=findFirstNode(this.nodeMetadata, "type"); + let nodeProperties=findNodeOnPath(this.nodeMetadata, 'type/properties'); if(nodeProperties!=null) //Creating HTML elements by XML filter { let nodeProp=nodeProperties.firstChild; @@ -848,25 +858,25 @@ class EdtRec { if (nodeProp.nodeName==="prop") { - var nTypeF = findFirstNode(nodeProp, "type"); + let nTypeF = findFirstNode(nodeProp, "type"); if(nTypeF != null) { //Add parameters to request nTypeF.setAttribute("c",nodeProp.getAttribute("FieldCaption")); nTypeF.setAttribute("pn",nodeProp.getAttribute("n")); - var strXMLF = getXMLNodeSerialisation(nTypeF); + let strXMLF = getXMLNodeSerialisation(nTypeF); if(strXMLF.indexOf('${'+node.getAttribute('n')+'}')!=-1) //If it does not participate then it does not react to the change { - var nColF=nodeProperties.firstChild; + let nColF=nodeProperties.firstChild; while(nColF != null) { if(nColF.nodeName==="prop") - { - var elm=document.getElementById('prop_'+this.uid+'_'+nColF.getAttribute("n")); + { + let elm=document.getElementById('prop_'+this.uid+'_'+nColF.getAttribute("n")); if(elm!=null) { - var valF=elm.value; + let valF=elm.value; strXMLF=strXMLF.replace('${'+nColF.getAttribute('n')+'}', valF); } } @@ -982,20 +992,20 @@ class EdtRec { if(nodeProp.getAttribute("selector")=="combo") { - var nTypeF = findFirstNode(nodeProp, "type"); + let nTypeF = findFirstNode(nodeProp, "type"); if(nTypeF != null) //Запрос с параметрами не можем отправить без подгрузки данных { //Add parameters to request nTypeF.setAttribute("c",nodeProp.getAttribute("FieldCaption")); nTypeF.setAttribute("pn",nodeProp.getAttribute("n")); - var strXMLF = getXMLNodeSerialisation(nTypeF); - var nColF=nodeProperties.firstChild; + let strXMLF = getXMLNodeSerialisation(nTypeF); + let nColF=nodeProperties.firstChild; while(nColF != null) { if(nColF.nodeName==="prop") { - var valF=getCdataValue(nColF); + let valF=getCdataValue(nColF); strXMLF=strXMLF.replace('${'+nColF.getAttribute('n')+'}', valF); } nColF = nColF.nextSibling; @@ -1006,8 +1016,8 @@ class EdtRec this.showProgressBar(); } }else - { - var xml=''; + { + let xml=''; if(this.request.callServer(ScriptName,xml,true)); { this.showProgressBar(); @@ -1018,7 +1028,7 @@ class EdtRec //We request the field title by the field id (if it is filled). /*if ((value!="")&&(value!=-1)) { - var xml=''; + let xml=''; xml+=''; xml+=''; if(this.request.callServer(ScriptName,xml,true)) @@ -1117,7 +1127,7 @@ class EdtRec }else //if the field with the button { //count the number of values - var count=0; + let count=0; nodeProp=nodeType.firstChild; while (nodeProp!=null) { @@ -1133,20 +1143,20 @@ class EdtRec id=nodeProp.getAttribute("id"); value=findNode(nodeProp, '#cdata-section').nodeValue; prop.value=id; - var propvis=document.getElementById("prop_"+this.uid+"_"+prop_name+"_visible"); + let propvis=document.getElementById("prop_"+this.uid+"_"+prop_name+"_visible"); propvis.value=value; propvis.select(); }else if(count>1) //Display the item selection window. { - var htmlString=''; + let htmlString='
'; nodeProp=nodeType.firstChild; - var i=0; + let i=0; while (nodeProp!=null) { if (nodeProp.nodeName=="record") { - var bgColor='whitesmoke'; + let bgColor='whitesmoke'; if (i%2==0) bgColor='white'; id=nodeProp.getAttribute("id"); value=findNode(nodeProp, '#cdata-section').nodeValue; @@ -1160,7 +1170,7 @@ class EdtRec } htmlString+='
'; - var win=new TWin(); + let win=new TWin(); win.BuildGUI(pageX-280,pageY-7); win.setContent(htmlString); win.setCaption(document.createTextNode(trt("Selection"))); @@ -1222,16 +1232,16 @@ class EdtRec //Request data to fill in the field with the button setFilterObject(TypeName,prop_id,id) { - var node=findFirstNodeOnAttribute(this.nodeMetadata,'prop','n',prop_id); + let node=findFirstNodeOnAttribute(this.nodeMetadata,'prop','n',prop_id); if(node!==null) { - var name=node.getAttribute("FieldCaption"); + let name=node.getAttribute("FieldCaption"); findNode(node,'#cdata-section').nodeValue=id; //We request data from the server to fill in the comments on the id of the record. - var prop=document.getElementById("filter_"+prop_id); + let prop=document.getElementById("filter_"+prop_id); if(prop!==null) prop.value=id; //Request a comment on the record id from the server - var xml=''; + let xml=''; xml+=''; xml+=''; if(this.request.callServer(ScriptName,xml,true)) @@ -1255,7 +1265,7 @@ class EdtRec //alert2(trt('Alert')," typeName="+typeName+" name="+name+" value="+value+" htmlid="+htmlid); if(value!="") { - var xml=''; + let xml=''; xml+=''; xml+=''; if(this.request.callServer(ScriptName,xml,true)) @@ -1267,7 +1277,7 @@ class EdtRec onCallFV(typeName,name,value,htmlid,filterName) { - var win=this + let win=this return function(e){ if(e==null) e=window.event; if(e.keyCode==13){ @@ -1282,16 +1292,16 @@ class EdtRec { if(typeof(node) != "undefined" && node!=null) { - var nProps1=findFirstNode(node, 'properties') - var nProps2=findFirstNode(this.nodeMetadata, 'properties') //Since the values came in abbreviated XML + let nProps1=findFirstNode(node, 'properties') + let nProps2=findFirstNode(this.nodeMetadata, 'properties') //Since the values came in abbreviated XML if(nProps1==null){ alert2(trt('Alert'),'Error, node='+getXMLNodeSerialisation(node)); return; } if(nProps2==null){ alert2(trt('Alert'),'Error, nodeMetadata='+getXMLNodeSerialisation(this.nodeMetadata)); return; } - var nProp1=nProps1.firstChild + let nProp1=nProps1.firstChild while(nProp1!=null) { if (nProp1.nodeName=="prop") { - var nProp2=findNodeOnAttribute(nProps2,"prop","n",nProp1.getAttribute("n")) + let nProp2=findNodeOnAttribute(nProps2,"prop","n",nProp1.getAttribute("n")) if(nProp2!=null) getCdata(nProp2).nodeValue=getCdata(nProp1).nodeValue } nProp1=nProp1.nextSibling; @@ -1305,13 +1315,13 @@ class EdtRec //I rewrite values from XML to GIU fields fillGUIFromXML() { - var nodeProperties=findFirstNode(this.nodeMetadata, 'properties'); - var nodeProp=nodeProperties.firstChild; + let nodeProperties=findFirstNode(this.nodeMetadata, 'properties'); + let nodeProp=nodeProperties.firstChild; while (nodeProp!=null) { if (nodeProp.nodeName=="prop") { - var value=getCdata(nodeProp).nodeValue; + let value=getCdata(nodeProp).nodeValue; //console.log("name = "+nodeProp.getAttribute("n")+" value= "+value); if ((value=="true")||(value=="t")) value=1; @@ -1319,7 +1329,7 @@ class EdtRec if(typeof nodeProp.field == "undefined") //Если не специализированное поле а обычные HTML поля { - var field=document.getElementById("prop_"+this.uid+"_"+nodeProp.getAttribute("n")); + let field=document.getElementById("prop_"+this.uid+"_"+nodeProp.getAttribute("n")); if(field!=null) { field.value=value; @@ -1332,7 +1342,7 @@ class EdtRec //console.log("++++++++++field.options.length = "+field.options.length); //We sort out the elements of the list (options) and set it to the desired value (the snake is not automatically exposed by the automaton). - for(var i=0;i'; + let xml=''; xml+=''; xml+=''; if(this.request.callServer(ScriptName,xml,true)) @@ -1365,16 +1375,18 @@ class EdtRec //Move data from html fields to an XML string and send to edit or update sendData() { + let nodeProperties; + let nodeProp; //Send binary data sequentially for each field - var nodeProperties=findFirstNode(this.nodeMetadata, 'properties'); - var nodeProp=nodeProperties.firstChild; - var sending=false; + nodeProperties=findFirstNode(this.nodeMetadata, 'properties'); + nodeProp=nodeProperties.firstChild; + let sending=false; while (nodeProp!=null) { if (nodeProp.nodeName=="prop" && (nodeProp.getAttribute("vt")=="blob" || nodeProp.getAttribute("vt")=="file")) { - var frm=document.getElementById('prop_'+this.uid+'_'+nodeProp.getAttribute("n")+'_frm'); - var doc=getIframeDocument(frm); + let frm=document.getElementById('prop_'+this.uid+'_'+nodeProp.getAttribute("n")+'_frm'); + let doc=getIframeDocument(frm); if(doc.forms["form"].elements["file"].value!='') { doc.forms["form"].submit(); sending=true; @@ -1385,20 +1397,20 @@ class EdtRec if(sending) return; //Sending text data - var nodeType=findFirstNode(this.nodeMetadata, 'type') - var nodename=nodeType.getAttribute("n") - var s=""; + let nodeType=findFirstNode(this.nodeMetadata, 'type') + let nodename=nodeType.getAttribute("n") + let s=""; s+='\n'; if (this.record_id!=-1) s+='\n'; else s+='\n'; s+='\n'; s+=' \n'; - var nodeProperties=findFirstNode(this.nodeMetadata, 'properties') - var nodeProp=nodeProperties.firstChild + nodeProperties=findFirstNode(this.nodeMetadata, 'properties') + nodeProp=nodeProperties.firstChild while (nodeProp!=null) { if (nodeProp.nodeName=="prop") { - var value=""; + let value=""; if(typeof nodeProp.field == "undefined") { value=document.getElementById("prop_"+this.uid+"_"+nodeProp.getAttribute("n")).value; @@ -1462,8 +1474,8 @@ class EdtRec setPropVal(id,caption,prop_id) { //alert2(trt('Alert'),"id="+id+" caption="+caption+" prop_id="+prop_id) - var prop=document.getElementById("prop_"+this.uid+"_"+prop_id); - var propvis=document.getElementById("prop_"+this.uid+"_"+prop_id+"_visible"); + let prop=document.getElementById("prop_"+this.uid+"_"+prop_id); + let propvis=document.getElementById("prop_"+this.uid+"_"+prop_id+"_visible"); if ((prop!=null)&&(propvis!=null)) { prop.value=id; @@ -1509,6 +1521,8 @@ class EdtRec } this.win.Close(); }; + + } //Поле с галочкой (или галочками) @@ -1539,8 +1553,8 @@ class TCheckboxListField }; // Return checked values divide ";" getValue() { - var result = ""; - for(var i=0;iexec("SET timezone TO 'UTC';"); //Пользователь должен сам передавать свою зону или она должна быть в настройках } $db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); } catch (Exception $e) @@ -427,7 +428,11 @@ $result = $stmt->fetch(PDO::FETCH_NUM); if($result[0]=='') { - $result[0]=$db->lastInsertId(); //Для SQLite + if(strpos($db_connection, 'sqlite')!==false) { + $result[0] = $db->lastInsertId(); //Для SQLite + }else{ + sendError(trt('Failed_to_insert_record').'!'); + } } $xmlstring='';