public function receiveTicketMachine($message, $phone)
 {
     $dbOps = new DBOperations();
     $con = new mysqli($dbOps->servername, $dbOps->username, $dbOps->password, $dbOps->dbname);
     //create the db connection
     $query = "";
     if ($con->connect_error) {
         die("connection failed: " . $con->connect_error);
     } else {
         //Get the suitable serial_number for phone_number from ticket_machine table
         $queryGetEditer = "SELECT * FROM ticket_machine WHERE phone_number = {$phone}";
         $result = $con->query($queryGetEditer);
         $editer = "";
         while ($row = mysqli_fetch_array($result)) {
             $editer = $row['serial_number'];
         }
         //set the time zone to Colombo time
         date_default_timezone_set('Asia/Colombo');
         $dt = new DateTime();
         //create DateTime object
         $prepare = explode(" ", $message);
         // split the ticket machine into array
         //Example Code: supCode approvedKGs units suppliedKGs
         if (count($prepare) == 4) {
             if (is_numeric($prepare[1]) && is_numeric($prepare[2]) && is_numeric($prepare[3])) {
                 //check the approvedKGs units suppliedKGs are integers
                 if (!supplierCodeExists($prepare[0])) {
                     //Example Code: supCode approvedKGs units suppliedKGs
                     if (DBOperations::isSupCodeValid($prepare[0])) {
                         //Check the supplier code valid or invalid
                         $query = "INSERT INTO today_supply(supplier_code, date, approved_kgs, units, supplied_kgs, editer) VALUES ('" . $prepare[0] . "', '" . $dt->format('y-m-d') . "', '" . $prepare[1] . "', '" . $prepare[2] . "', '" . $prepare[3] . "', '" . $editer . "')";
                         $con->query($query);
                     } else {
                         //If the supplier code invalid then send error message
                         Communication::sendMessage("Supplier code is invalid !", $phone);
                     }
                 } else {
                     //If the supplier code exists then send error message
                     Communication::sendMessage("Supplier code is already exists the system !", $phone);
                 }
             } else {
                 //reply again to the ticket machine
                 Communication::sendMessage("Sent message is invalid.", $phone);
             }
             //Example Code: supCode approvedKGs suppliedKGs
             //Example Code: supCode approvedKGs units
         } else {
             if (count($prepare) == 3) {
                 if (is_numeric($prepare[1]) && is_numeric($prepare[2])) {
                     //check the integers as above
                     if (!supplierCodeExists($prepare[0])) {
                         if ($prepare[1] <= $prepare[2]) {
                             //Example Code: supCode approvedKGs suppliedKGs
                             if (DBOperations::isSupCodeValid($prepare[0])) {
                                 //Check the supplier code valid or invalid
                                 $query = "INSERT INTO today_supply(supplier_code, date, approved_kgs, supplied_kgs, editer) VALUES ('" . $prepare[0] . "', '" . $dt->format('y-m-d') . "', '" . $prepare[1] . "', '" . $prepare[2] . "', '" . $editer . "')";
                                 $con->query($query);
                             } else {
                                 //If the supplier code invalid then send error message
                                 Communication::sendMessage("Supplier code is invalid !", $phone);
                             }
                         } else {
                             //Example Code: supCode approvedKGs units
                             if (DBOperations::isSupCodeValid($prepare[0])) {
                                 //Check the supplier code valid or invalid
                                 $query = "INSERT INTO today_supply(supplier_code, date, approved_kgs, units, editer) VALUES ('" . $prepare[0] . "', '" . $dt->format('y-m-d') . "', '" . $prepare[1] . "', '" . $prepare[2] . "', '" . $editer . "')";
                                 $con->query($query);
                             } else {
                                 //If the supplier code invalid then send error message
                                 Communication::sendMessage("Supplier code is invalid !", $phone);
                             }
                         }
                     } else {
                         //If the supplier code exists then send error message
                         Communication::sendMessage("Supplier code is already exists the system !", $phone);
                     }
                 } else {
                     //reply again to the ticket machine
                     Communication::sendMessage("Sent message is invalid.", $phone);
                 }
                 //Example Code: supCode approvedKGs
             } else {
                 if (count($prepare) == 2) {
                     if (is_numeric($prepare[1])) {
                         if (!DBOperations::supplierCodeExists($prepare[0])) {
                             //Example Code: supCode approvedKGs
                             if (DBOperations::isSupCodeValid($prepare[0])) {
                                 //Check the supplier code valid or invalid
                                 $query = "INSERT INTO today_supply(supplier_code, date, approved_kgs, editer) VALUES ('" . $prepare[0] . "', '" . $dt->format('y-m-d') . "', '" . $prepare[1] . "', '" . $editer . "')";
                                 $con->query($query);
                             } else {
                                 //If the supplier code invalid then send error message
                                 Communication::sendMessage("Supplier code is invalid !", $phone);
                             }
                         } else {
                             //If the supplier code exists then send error message
                             Communication::sendMessage("Supplier code is already exists the system !", $phone);
                         }
                     } else {
                         //reply again to the ticket machine
                         Communication::sendMessage("Sent message is invalid.", $phone);
                     }
                     //Example Code: without above codes
                 } else {
                     //reply again to the ticket machine
                     Communication::sendMessage("Sent message is invalid.", $phone);
                 }
             }
         }
     }
 }
		<label id="received_message">Received Message: </label>
		<textarea name="received_message" rows="4" cols="15"></textarea>
		<input type="submit" name="dbOps" value="read message">
		<br/><br/>

		<label id="to">to: </label>
		<input type="text" name="number" maxlength="10"></input><br/>
		<label id="write_message">Write Message: </label>
		<textarea name="send_message" rows="4" cols="15"></textarea>
		<input type="submit" name="send" value="send message">
		<br/><br/>

		<input type="submit" name="receive" value="Read Receive Messages">
	</form><br/>
</body>
</html>

<?php 
include_once 'messageDB.php';
include_once 'communication.php';
if (!empty($_POST['received_message']) && $_POST['dbOps'] == "read message") {
    $filterMessage = DBOperations::filterMessageDetails($_POST['received_message']);
    DBOperations::sendMessageDetails($filterMessage);
}
if (!empty($_POST['number']) && !empty($_POST['send_message']) && $_POST['send'] == "send message") {
    $mobileNumber = Communication::prepareNumber($_POST['number']);
    Communication::sendMessage($_POST['send_message'], $mobileNumber);
}
//DBOperations::receiveMessages("hgsr hjk", "94713535362"); //Supplier request message
DBOperations::displayMessageTable();
//DBOperations::receiveTicketMachine("0001 20", "94713535362"); //ticket machine message