';
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='';