echo "The Average salary for the " . $searchstring . " position based on Total Earnings is Grand Total Salary: " . money_format('%i', $sum) . " divided by total number of records " . $totalrows . " = " . money_format('%i', $average) . "<br>";
            return 1;
        } else {
            // no data found, the program will return to the start page, but inform the user. The message may be visible on a slower system.
            echo "Sorry no data found for: " . $searchstring . "<br>";
            return 0;
        }
    }
}
//end of controller
// cleans and tests input for correctness
function test_input($data)
{
    $data = trim($data);
    $data = stripslashes($data);
    $data = htmlspecialchars($data);
    return $data;
}
//if (isset($_GET['name']))
if (isset($name)) {
    //instantiate the CalculateEarnings controller class
    $workhorse = new ModelClass();
    //then call the method
    $ret = $workhorse->getAverageSalary();
    //return final status
    if ($ret === 0) {
        echo "{module:model, message:No data found, the program, success: false}";
    } else {
        echo "{module:model, success: true}";
    }
}
 /**
  * Test that index is deleted afer deleting a model
  * @return [type] [description]
  */
 public function testDeleteIndexAfterDelete()
 {
     $ModelClass = new ModelClass();
     $ModelClass->Behaviors->Indexable->settings['ModelClass']['request']['uri']['host'] = ELASTIC_HOST;
     $ModelClass->Behaviors->Indexable->settings['ModelClass']['request']['uri']['port'] = ELASTIC_PORT;
     $id = rand(0, 1000);
     $ModelClass->query("INSERT INTO model_classes (id, title) VALUES(" . $id . ", 'test')");
     $this->HttpSocket->request(array('method' => 'PUT', 'uri' => array('host' => ELASTIC_HOST, 'port' => ELASTIC_PORT, 'path' => 'test_song/model_class/' . $id), 'body' => json_encode(array('id' => $id))));
     $this->HttpSocket->request(array('method' => 'PUT', 'uri' => array('host' => ELASTIC_HOST, 'port' => ELASTIC_PORT, 'path' => 'test_song/model_class/25'), 'body' => json_encode(array('id' => 25))));
     $response = $this->HttpSocket->request(array('method' => 'GET', 'uri' => array('host' => ELASTIC_HOST, 'port' => ELASTIC_PORT, 'path' => 'test_song/model_class/' . $id)));
     $response = json_decode($response, true);
     $this->assertTrue($response['exists']);
     $this->assertEquals(array('id' => $id), $response['_source']);
     $ModelClass->id = $id;
     $ModelClass->delete($id);
     $response = $this->HttpSocket->request(array('method' => 'GET', 'uri' => array('host' => ELASTIC_HOST, 'port' => ELASTIC_PORT, 'path' => 'test_song/model_class/' . $id)));
     $response = json_decode($response, true);
     // Deleting the index
     $this->assertFalse($response['exists']);
     // Don't delete other index
     $response = $this->HttpSocket->request(array('method' => 'GET', 'uri' => array('host' => ELASTIC_HOST, 'port' => ELASTIC_PORT, 'path' => 'test_song/model_class/25')));
     $response = json_decode($response, true);
     $this->assertTrue($response['exists']);
 }