I’m trying to update a table with data that is inserted from a grid and I can’t seem to get it to save. And if I do it only does one row from the datagrid.
Code from main page (Client Side):
<script>
// Initialize Variables
var studentID1 = '<?php echo $_GET['id'];?>';
var seclevel = '<?php echo $seclevel?>';
var jsonCodex = <?php echo $jsonObject;?>;
function getCodeInfo(codexCodeCell) {
idCodex = '';
codexType = '';
codexDescription = '';
codexCost = '';
for(var i in jsonCodex.codex) {
if(jsonCodex.codex[i].codexCode==codexCodeCell) {
idCodex = jsonCodex.codex[i].idcodex;
codexType = jsonCodex.codex[i].codexType;
codexDescription = jsonCodex.codex[i].codexDescription;
codexCost = jsonCodex.codex[i].codexCost;
}
}
var jsonReturn = {"codexInfo": [{"idcodex": idCodex,"codexCode": codexCodeCell,"codexType": codexType,"codexDescription": codexDescription,"codexCost": codexCost}]};
return jsonReturn;
}
// Initialize Layout
var layCharge = new dhtmlXLayoutObject("layCharge","1C","dhx_skyblue");
layCharge.cells("a").setText("Cobro a Alumno: "+studentID1);
layCharge.cells("a").setWidth(910);
// Initialize Grid
gridCharge = layCharge.cells("a").attachGrid();
gridCharge.setHeader("Clave de Cobro,Tipo de Cobro,Descripción,Cantidad,Precio Unitario,Sub-Total");
gridCharge.attachHeader("#text_filter,#text_filter,#text_filter,#numeric_filter,#numeric_filter,#numeric_filter")
gridCharge.setInitWidths("*,*,*,*,*,*");
gridCharge.setColAlign("center,center,center,center,center,center");
gridCharge.setColTypes("ed,ed,ro,ed,price,price");
gridCharge.setColSorting("str,str,str,int,int,int");
gridCharge.init();
function sendDataCharge() {
dpfCharge.sendData();
alert("Los datos han sido enviados.");
}
shortcut.add("Ctrl+M",function() {
if(document.frmCobro.folio.value!="") {
var newId = (new Date()).valueOf();
gridCharge.addRow(newId,"",gridCharge.getRowsNum());
gridCharge.selectRow(gridCharge.getRowIndex(newId),false,false,true);
}
else {alert("Ingrese un folio nuevo.");}
});
shortcut.add("Ctrl+Delete",function() {
var selId = gridCharge.getSelectedId()
gridCharge.deleteRow(selId);
});
gridCharge.attachEvent("onEditCell",function(stage,rId,cInd,nValue,oValue){
if((stage==2)&&(cInd==0)) {
var jsonObjCodex = getCodeInfo(gridCharge.cells(rId,cInd).getValue());
gridCharge.cells(rId,cInd+2).setValue(jsonObjCodex.codexInfo[0].codexDescription);
gridCharge.cells(rId,cInd+4).setValue(jsonObjCodex.codexInfo[0].codexCost);
return true;
}
if((stage==2)&&(cInd==3)) {
var jsonObjCodex = getCodeInfo(gridCharge.cells(rId,0).getValue());
var intOne = parseInt(jsonObjCodex.codexInfo[0].codexCost);
var intTwo = parseInt(gridCharge.cells(rId,3).getValue());
var valSubTot = intOne * intTwo;
gridCharge.cells(rId,5).setValue(valSubTot);
dpfCharge = new dataProcessor("cnndb_gridChargeInsert.php?idpay="+document.frmCobro.folio.value+"&studentID1="+studentID1);
dpfCharge.init(gridCharge);
return true;
}
if((stage==2)&&(cInd==1)){
return true;
}
});
</script>
Server Side:
<?php
require("../../codebase/grid_connector.php");
$res=mysql_connect("localhost","root","inpa2010");
mysql_select_db("inpa");
$idpaymentperson = $_GET["idpay"];
$studentID1 = $_GET["studentID1"];
$sqlPerson = "SELECT studentID FROM person WHERE studentID1=$studentID1";
$resPerson = mysql_query($sqlPerson);
$datPerson = mysql_fetch_row($resPerson);
$studentID = $datPerson[0];
$frmConn = new GridConnector($res,"MySQL");
$frmConn->enable_log("gridCatInsert.log",true);
$frmConn->sql->attach("Insert","INSERT INTO paymentperson VALUES('$idpaymentperson','$studentID','{codexCode}','{paymentType}','{codexDescription}','{amount}','{price}','{subtotal}')");
$frmConn->render_table("paymentperson","codexCode","codexCode,paymentType,codexDescription,amount,price,subtotal");
?>
Any ideas on what could be wrong. I still can’t grasp dataprocessor.