codebang
Posts: 74
|
| Posted: 01/07/2009, 12:37 PM |
|
Hello Folks...
Well below is the .php of my xml file that i need to upload into my system.
The whole scenario.....
Im working for a Petroleum company...in which i track all their tools using the software that i developed. I have created two systems, that r integrated. I send an xml file to the rig with all the tools that they will be using in a particular job-main tool as well as backup tool.
This xml file is then uploaded in to their RIG system, they fill out the data, and then send me the export files of their job...also xml.
Now. this is my problem....
sometimes the guys on the rig dont use the backup tools... but what im getting passed are all the tools, the main tools that were used as well as the backup tools with everything same. i dont want the backup tools, i only want the tools that were used and my xml file shows what tools were used..
so here u go. the xml file........
<?php
global $rec_execute;
$data = array();
function add_person(
$job_number,
$tool_type,
$sub_type,
$serial_no,
$well_name,
$rig_name,
$max_shock,
$circ_temp,
$max_shock_dur,
$flow_rate_max,
$tot_pump_hrs,
$tss_id,
$tss_tsd_id,
$rec_execute)
{
global $data;
$data []= array(
'job_number'=> $job_number,
'tool_type' => $tool_type,
'sub_type' => $sub_type,
'serial_no' => $serial_no,
'well_name' => $well_name,
'rig_name' =>$rig_name,
'max_shock' =>$max_shock,
'circ_temp' =>$circ_temp,
'max_shock_dur' =>$max_shock_dur,
'flow_rate_max' =>$flow_rate_max,
'tot_pump_hrs' =>$tot_pump_hrs,
'Tss Id' =>$tss_id,
'Tss Tsd Id' =>$tss_tsd_id,
'rec_execute' =>$rec_execute);
// Add to the Mysql Database
$db="cruzer";
$user="root";
$pass="";
$host="localhost";
$myCon = mysql_pconnect($host,$user,$pass) or die("Failed to Connect");
mysql_select_db($db,$myCon);
// Add the Record
$qry = "Insert into tbl_rig_tools(rt_id,job_number,tool_type,sub_type,serial_no,well_name,rig_name,
max_shock,circ_temp,max_shock_dur,flow_rate_max,tot_pump_hrs,tss_is,tss_tsd_id) values('"
.$rt_id."','"
.$job_number."','"
.$tool_type."','"
.$sub_type."','"
.$serial_no."','"
.$well_name."','"
.$rig_name."','"
.$max_shock."','"
.$circ_temp."','"
.$max_shock_dur."','"
.$flow_rate_max."','"
.$tot_pump_hrs."','"
.$tss_id."','"
.$tss_tsd_id."')";
echo "Qry:".$qry;
$res=mysql_query($qry,$myCon);
echo "execute = ".$rec_execute;
if($rec_execute==0) {
// Get the Base Configured Tool List
$req_qry="SELECT TBL_TOOL_SHIPMENT_DTL.tsd_id,
TBL_TOOL_SHIPMENT_DTL.tsd_tool_type,
TBL_TOOL_SHIPMENT_DTL.tsd_tsm_id,
TBL_TOOL_SHIPMENT_MST.tsm_id,
Tbl_tool_shipment_mst.tsm_job_no,
TBL_TOOL_SHIPMENT_SUB.tss_tsd_id,
TBL_TOOL_SHIPMENT_SUB.tss_tool_sub_type,
TBL_TOOL_SHIPMENT_SUB.tss_serial_no
FROM TBL_TOOL_SHIPMENT_DTL,TBL_TOOL_SHIPMENT_MST,TBL_TOOL_SHIPMENT_SUB
WHERE
TBL_TOOL_SHIPMENT_DTL.tsd_tsm_id=TBL_TOOL_SHIPMENT_MST.tsm_id
AND
TBL_TOOL_SHIPMENT_SUB.tss_tsd_id=TBL_TOOL_SHIPMENT_DTL.tsd_id
AND
TBL_TOOL_SHIPMENT_MST.tsm_job_no='".$job_number."'";
echo "MyQry :".$req_qry;
$res_qry = mysql_query($req_qry,$myCon);
while ($row = mysql_fetch_array($res_qry,MYSQL_NUM)){
$tool_ty = $row[1];
$sub_ty = $row[6];
$ser_no = $row[7];
// Storing the value
$str = "select max(cum_pump_hours) as cum_pump_hours,abs(service_level) as ser_level,batt_chnge_dt
as batt_change,batt_exp_Dt as expiry_date
from tbl_work_sheet where
serial_no='".$ser_no."' and sub_type = '".$sub_ty."' group by serial_no,sub_type,service_level";
$result=mysql_query($str);
$row2=mysql_fetch_array($result,MYSQL_ASSOC);
$cum_pump_hours=$row2['cum_pump_hours'];
$service_level=$row2['ser_level'];
$batt_chnge_dt=$row2['batt_change'];
$batt_exp_Dt=$row2['expiry_date'];
echo "Hours:".$cum_pump_hours;
$cum_pump_hours=$tot_pump_hrs+$cum_pump_hours;
// Add the Record
$qry2 = "Insert into tbl_work_sheet (job_number,tool_type,sub_type,serial_no,rig_name,well_name,
max_shock,max_temp,shock_duration,max_flow_rate,pumping_hours,last_service_level,batt_chnge_dt,
batt_exp_Dt,status_type,wo_stat,asset_code,cum_pump_hours) values('"
.$job_number."','"
.$tool_ty."','"
.$sub_ty."','"
.$ser_no."','"
.$rig_name."','"
.$well_name."','"
.$max_shock."','"
.$circ_temp."','"
.$max_shock_dur."','"
.$flow_rate_max."','"
.$tot_pump_hrs."','"
.$service_level."','"
.$batt_chnge_dt."','"
.$batt_exp_Dt."','"
.Rong."','"
.OPEN."','"
.$sub_ty."','"
.$cum_pump_hours."')";
echo "Qry:".$qry2;
$res2=mysql_query($qry2,$myCon);
}
$rec_execute = $rec_execute+1;
}
}
if ( $_FILES['file']['tmp_name'] )
{
$dom = DOMDocument::load( $_FILES['file']['tmp_name'] );
$rows = $dom->getElementsByTagName( 'Row' );
$first_row = true;
$rec_execute=0;
foreach ($rows as $row)
{
if ( !$first_row )
{
$job_number ="";
$tool_type="";
$sub_type="";
$serial_no="";
$well_name="";
$rig_name="";
$max_shock="";
$circ_temp="";
$max_shock_dur="";
$flow_rate_max="";
$tot_pump_hrs="";
$tss_id="";
$tss_tsd_id="";
$index = 1;
$cells = $row->getElementsByTagName( 'Cell' );
foreach( $cells as $cell )
{
$ind = $cell->getAttribute( 'Index' );
if ( $ind != null ) $index = $ind;
if ( $index == 1 ) $job_number =$cell->nodeValue;
if ( $index == 2 ) $tool_type=$cell->nodeValue;
if ( $index == 3 ) $sub_type=$cell->nodeValue;
if ( $index == 4 ) $serial_no=$cell->nodeValue;
if ( $index == 5 ) $well_name=$cell->nodeValue;
if ( $index == 6 ) $rig_name=$cell->nodeValue;
if ( $index == 7 ) $max_shock=$cell->nodeValue;
if ( $index == 8 ) $circ_temp=$cell->nodeValue;
if ( $index == 9 ) $max_shock_dur=$cell->nodeValue;
if ( $index == 10 ) $flow_rate_max=$cell->nodeValue;
if ( $index == 11 ) $tot_pump_hrs=$cell->nodeValue;
if ( $index == 12 ) $tss_id=$cell->nodeValue;
if ( $index == 13 ) $tss_tsd_id=$cell->nodeValue;
$index += 1;
}
add_person(
$job_number ,
$tool_type,
$sub_type,
$serial_no,
$well_name,
$rig_name,
$max_shock,
$circ_temp,
$max_shock_dur,
$flow_rate_max,
$tot_pump_hrs,
$tss_id,
$tss_tsd_id,
$rec_execute);
$rec_execute+=1;
}
$first_row = false;
}
}
?>
<html>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta http-equiv="Content-Language" content="en-us"><title>TRRACKIT
</title>
<meta http-equiv="refresh" content="0;url=http://localhost/trrackit/tbl_work_sheet_list.php">
<body>
<table>
<tr>
</tr>
<?php foreach( $data as $row ) { ?>
<tr>
</tr>
<?php } ?>
</table>
<font face="arial, helvetica, sans-serif" size="2">
<BR>
<a href="http://localhost/trrackit/tbl_work_sheet_list.php"></a>
</font>
</body>
</html>
Please Anybody out there...HELP!!!!... I've been working over a week on this ....please help.
Thank you...
Salah Hafiz.
|
 |
 |
maxhugen
Posts: 272
|
| Posted: 01/11/2009, 5:15 PM |
|
Not sure if I'm clear here...
1. You send x records (of tools) to the rig.
2. They update some records (but not all)
3. They return x records back to you, some of which are updated.
Is that right?
_________________
Max
www.gardenloco.com | www.eipdna.com | www.chrisarminson.com |
 |
 |
codebang
Posts: 74
|
| Posted: 01/11/2009, 9:29 PM |
|
.....
That is completely right....
Hoping that you really have a solution..
Thank you very much..for reading this post.
Salah Hafiz Midhat.
|
 |
 |
damian
Posts: 838
|
| Posted: 01/11/2009, 9:58 PM |
|
but what is it you are wanting to do with the data they send back?
_________________
if you found this post useful take the time to help someone else.... :)
|
 |
 |
codebang
Posts: 74
|
| Posted: 01/12/2009, 12:34 AM |
|
......
"but what is it you are wanting to do with the data they send back?"
First of all..the data that i get back has values....these values have to be inserted into the system, in the form of worksheets, that are opened automatically, once the xml files are uploaded.
The XML file that i get from the giys on the rig has information an=bout the tool..the pumping hours, the shocks, the temperature etc..i take this data..
hope i made myself clear...
Listen to make it more clear here is my email addy:
midhatsalah@hotmail.com
|
 |
 |
damian
Posts: 838
|
| Posted: 01/12/2009, 2:43 AM |
|
you want to import the returned XML data into your database?
from what I have read - a very complicated task...
http://www.google.com.au/search?hl=en&q=import+xml+data...mysql+php&meta=
_________________
if you found this post useful take the time to help someone else.... :)
|
 |
 |
codebang
Posts: 74
|
| Posted: 01/12/2009, 5:19 AM |
|
i am already importing the XML file, but im getting all the tools of the determined job, instead of only getting the tools that were used in the job/rig.
i am already importing/exporting my tools, but this one is a bit complicated.
I have roughly about more than 12 screens that work only on import and export.
Please... if i can have ur email..im sure that we will be able to reach to a solution.im sure that i might be able to explain to u the whole problem. take a close look at the code that i sent...above.
thank u again.
|
 |
 |
datadoit
|
| Posted: 01/12/2009, 5:24 AM |
|
codebang wrote:
> i am already importing the XML file, but im getting all the tools of the
> determined job, instead of only getting the tools that were used in the
> job/rig.
>
Import all into a temp table, then create another routine to retrieve
just the records you care about and export to your permanent table.
|
|
|
 |
codebang
Posts: 74
|
| Posted: 01/12/2009, 5:35 AM |
|
im already doing that....
but the tools have subcomponents, which have too be also tracked.. the only way through this is through one of my screens...called the tool set builder.
the engineers dont see the sub components. they only see a collar
so what they have is only the serial number of the collar...when actually the tool has many subcomponents with different serial numbers...also have to be tracked.
big problem...
|
 |
 |
datadoit
|
| Posted: 01/12/2009, 10:38 AM |
|
Salah, I've read through all of the posts on this topic and I'm still
trying to figure out what your -CodeCharge- question is.
Without a CodeCharge question you might as well just declare you like
double cheese on your pizza. ;)
|
|
|
 |
maxhugen
Posts: 272
|
| Posted: 01/12/2009, 1:38 PM |
|
Salah, it would seem to me that you need an extra field to flag a record... eg "tool_used". This 'flag' would have to be set by your software at the rig. For example, if users at the rig edit a record, and that represents "being used", automatically set the flag (or get the rig workers to set it manually?)
That way, once you've imported the data at your end, you'd know which records (tools) have been used, and take the appropriate action.
Would that help?
_________________
Max
www.gardenloco.com | www.eipdna.com | www.chrisarminson.com |
 |
 |
|