Skip to content

Instantly share code, notes, and snippets.

@taleeb35
Created January 6, 2015 12:05
Show Gist options
  • Save taleeb35/980176c27c329abda8c4 to your computer and use it in GitHub Desktop.
Save taleeb35/980176c27c329abda8c4 to your computer and use it in GitHub Desktop.
Web Service
<?php
session_start();
$xmlStr = file_get_contents("test.txt");
$modified_time = filemtime("test.txt");
$twenty_minutes = strtotime("+1 minutes", $modified_time); // Add 20 minutes to the modified time
$current_time = time();
if (file_exists("test.txt") && $current_time < $twenty_minutes) { ?>
<html>
<head>
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
<h3 align="center">Previously Purchased Items:</h3>
<div class="leftPanel">
<ul>
<button id="test">TEST</button>
<p id="out"></p>
<li><a href="webservice.php">Previous Sales</a></li>
<li><a href="listing.php" id="cart">Shopping Cart</a></li>
</ul>
</div>
<div class="rightPanel">
<table border="1" class="tablemain" id="record">
<tr>
<th>Part#</th>
<th>Date</th>
<th>Unit$</th>
<th>Current$</th>
<th>Qty</th>
<th>Reorder?</th>
</tr>
<?php //foreach($data as $obj){
$xml = simplexml_load_string($xmlStr);
foreach($xml as $datarow) { ?>
<tr class="tr">
<td> <?php echo $datarow->cihs_item ."<br><br>"; ?>
<?php echo $datarow->cihs_description ; ?>
</td>
<td> <?php echo Date("Y-m-d",strtotime($datarow->cihs_date )); ?> </td>
<td> <?php echo $datarow->cihs_unitcost; ?> </td>
<td> <?php echo $datarow->cihs_price; ?> </td>
<td> <?php echo $datarow->cihs_quantity ; ?> </td>
<td><input type="checkbox" name="reorder" id="reorder" class="checkbox"> </td>
</tr>
<?php } ?>
</table>
</div>
<?php } else {
$params = array (
'IWSLogin' => 'inxsql',
'IWSPassword' => 'inxsql4u',
'customer' => 324968,
'resultsPerPage' => 10,
'pageNumber' => 1,
'listOrder' => '',
'listOrderKey' => ''
);
$response = new SoapClient('http://shop.imperialpaper.com/webservice/inxsqlwebdata.asmx?wsdl',array('trace'=>1));
$data = $response->GetPSListing($params);
$xmlStr = $data->GetPSListingResult->any;
$myfile = fopen("test.txt", "w") or die("Unable to open file!");
fwrite($myfile, $xmlStr);
fclose($myfile); ?>
<html>
<body>
<h3 align="center">Previously Purchased Items:</h3>
<div class="leftPanel">
<ul>
<button id="test">TEST</button>
<p id="out"></p>
<li><a href="webservice.php">Previous Sales</a></li>
<li><a href="listing.php" id="cart">Shopping Cart</a></li>
</ul>
</div>
<div class="rightPanel">
<table border="1" class="tablemain" id="record">
<tr>
<th>Part#</th>
<th>Date</th>
<th>Unit$</th>
<th>Current$</th>
<th>Qty</th>
<th>Reorder?</th>
</tr>
<?php //foreach($data as $obj){
$xml = simplexml_load_string($xmlStr);
foreach($xml as $datarow) { ?>
<tr id="id">
<td> <?php echo $datarow->cihs_item ."<br><br>"; ?>
<?php echo $datarow->cihs_description ; ?>
</td>
<td> <?php echo Date("Y-m-d",strtotime($datarow->cihs_date )); ?> </td>
<td> <?php echo $datarow->cihs_unitcost; ?> </td>
<td> <?php echo $datarow->cihs_price; ?> </td>
<td> <?php echo $datarow->cihs_quantity ; ?> </td>
<td><input type="checkbox" name="reorder" id="reorder" class="checkbox"> </td>
</tr>
<?php } ?>
</table>
<button id="test">TEST</button>
<p id="out"></p>
<?php } ?>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
var count = 0;
var value = $('#cart').text();
//console.log(value);
$(".checkbox").click(function(){
var counts = $("[type='checkbox']:checked").length;
if(counts > 0){
$('#cart').html(value + '(' + counts +')');
$('#test').click(function() {
$('#test').text('');
$('#record tr').has(':checkbox:checked').find('td:eq(0),td:eq(1),td:eq(2),td:eq(3),td:eq(4)')
.each(function(){
$('#test').append($(this).text());
});
});
} else {
$('#cart').html(value);
}
});
});
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment