<?php
/**
 * Part of southprojects Grid communications with server example.
 *
 * Copyright (c) 2006 by SouthProjects
 * http://www.southprojects.com
 * Santiago, Chile,
 * Version 1.2 Dec 2006.
 * All rights reserved.
 */

/* $Id: editable_json.php 4960 2006-10-30 19:22:36Z alex $ */

require_once 'JSON.php';
$objJsonConverter = new Services_JSON();

// Get arguments in JSON format
$objArgs = array();
if (!empty($_POST['changes'])) {
  $objChanges = $objJsonConverter->decode(stripslashes($_POST['changes']));
}

if (!isset($objChanges) || !count($objChanges)) {
  echo "Changes were not found.";
  exit;
}

$arrColumns = array(
  'Item',
  'Date',
  'Time',
  'Rate Period',
  'Phone Number',
  'Minutes',
  'Total Charges',
  'Local'
);

echo "Following changes were done:\n";

for ($iChange = 0; $iChange < count($objChanges); $iChange++) {
  echo 'Item #' . $objChanges[$iChange]->{'item'} . ': new value of "' .
   $arrColumns[$objChanges[$iChange]->{'column'}] . '" is "' .
   $objChanges[$iChange]->{'value'} . "\"\n";
}

?>
