From 4a270bc28c56c030393b948dc76ba19c26eca56b Mon Sep 17 00:00:00 2001 From: igor Date: Fri, 19 Nov 2021 17:26:07 +0600 Subject: [PATCH 1/2] =?UTF-8?q?=D0=AF=D0=B7=D1=8B=D0=BA=20666=20=D1=81=20?= =?UTF-8?q?=D0=B0=D0=BF=D0=BE=D1=81=D1=82=D1=80=D0=BE=D1=84=D0=B0=D0=BC?= =?UTF-8?q?=D0=B8=20=D0=B8=20=D0=BA=D0=B0=D0=B2=D1=8B=D1=87=D0=BA=D0=B0?= =?UTF-8?q?=D0=BC=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- metadata/dbms/DBMSRecords.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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()) { From 6258a39b1278c00c090dbd4ce11a6ac13c05a7b0 Mon Sep 17 00:00:00 2001 From: igor Date: Fri, 26 Nov 2021 17:11:34 +0600 Subject: [PATCH 2/2] =?UTF-8?q?var=20=D0=BD=D0=B0=20let?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- metadata/dbms/editrecord.js | 192 +++++++++++++++++++----------------- metadata/dbms/records.php | 7 +- 2 files changed, 109 insertions(+), 90 deletions(-) diff --git a/metadata/dbms/editrecord.js b/metadata/dbms/editrecord.js index 4ada59d..b8d4d2d 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); eDiv.appendChild(this.pBarDiv); @@ -99,6 +99,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) @@ -139,8 +149,8 @@ class EdtRec str+=' '; str+=' '; str+=' '; - str+=' '+trt('Name')+''; - str+=' '+trt('Value')+''; + str+=' '+trt('Name')+''; + str+=' '+trt('Value')+''; str+=' '; str+=' '; str+=' '; @@ -149,16 +159,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) @@ -175,10 +185,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(""); @@ -289,7 +299,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"); @@ -301,7 +311,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;"; @@ -359,7 +369,7 @@ class EdtRec td2.appendChild( table ); }else - if(vt=="password") + if(vt==="password") { let input = document.createElement('input'); input.classList.add('DBMS'); @@ -370,7 +380,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'); @@ -399,7 +409,7 @@ class EdtRec { if(opt.nodeName=="option") { - option = document.createElement("option"); + let option = document.createElement("option"); option.setAttribute("value",opt.getAttribute("val")); option.appendChild(document.createTextNode(opt.getAttribute("d"))); select.appendChild( option ); @@ -410,7 +420,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"); @@ -476,7 +486,7 @@ class EdtRec td2.appendChild( table ); } }else - if(vt=="f4") + if(vt==="f4") { let input = document.createElement('input'); input.classList.add('DBMS'); @@ -487,7 +497,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") @@ -529,20 +539,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; @@ -554,7 +564,7 @@ class EdtRec } }else { - var xml=''; + let xml=''; if(this.request.callServer(ScriptName,xml,true)); { this.showProgressBar(); @@ -598,7 +608,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)) @@ -608,7 +618,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")); @@ -619,7 +629,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")); @@ -629,12 +639,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); @@ -698,7 +708,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(); @@ -708,7 +718,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;"; @@ -727,14 +737,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", @@ -746,7 +756,7 @@ class EdtRec this.hide(); } }); - if(vt=="dateTime") + if(vt==="dateTime") new Calendar({ inputField: input, dateFormat: "%Y-%m-%d %H:%M:%S", @@ -783,7 +793,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'); @@ -838,8 +848,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; @@ -847,25 +857,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); } } @@ -981,20 +991,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; @@ -1005,8 +1015,8 @@ class EdtRec this.showProgressBar(); } }else - { - var xml=''; + { + let xml=''; if(this.request.callServer(ScriptName,xml,true)); { this.showProgressBar(); @@ -1017,7 +1027,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)) @@ -1115,7 +1125,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) { @@ -1131,20 +1141,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; @@ -1158,7 +1168,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"))); @@ -1220,16 +1230,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)) @@ -1253,7 +1263,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)) @@ -1265,7 +1275,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){ @@ -1280,16 +1290,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; @@ -1303,13 +1313,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; @@ -1317,7 +1327,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; @@ -1330,7 +1340,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)) @@ -1363,16 +1373,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; @@ -1383,20 +1395,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; @@ -1460,8 +1472,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; @@ -1507,6 +1519,8 @@ class EdtRec } this.win.Close(); }; + + } //Поле с галочкой (или галочками) @@ -1537,8 +1551,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='';