<?php
include("../../db.php");
header('Content-Type: application/json');

$status = 0;
$msg = 'Unable to save data. Please try again later..!';

$jsonData  = $_POST['json'];
$arrayData = json_decode($jsonData, true);

$school_name       = $arrayData['school_name'];
$principle_contact = $arrayData['principle_contact'];
$director_contact  = $arrayData['director_contact'];
$school_mail       = $arrayData['school_mail'];
$visited_date      = $arrayData['visited_date'];
$demo_done         = $arrayData['demo_done'];
$total_student     = $arrayData['total_student'];
$amount_quoted     = $arrayData['amount_quoted'];
$status            = $arrayData['status'];
$location          = $arrayData['location'];
$state             = $arrayData['state'];
$reminder_date     = $arrayData['reminder_date'];
$address           = $arrayData['address'];
$feedback          = $arrayData['feedback'];

$sale_person_id    = $arrayData['sale_uid'];

$dbArray = array("school_name" => $school_name, "principal_contact" => $principle_contact, "director_contact" => $director_contact, "email" => $school_mail, "status" => $status,
                 "sales_person" => $sale_person_id, "visit_date" => $visited_date, "address" => $address, "feedback" => $feedback, "school_id" => 1, "added_by" => 0,
                 "demo_done" => $demo_done, "total_student" => $total_student, "amount_quoted" => $amount_quoted, "location" => $location, "state" => $state, "reminder_date" => $reminder_date);

$sqlResponse = $db->insertAry("school_data", $dbArray);

if ($sqlResponse > 0) {
    $status = 1;
    $msg = "Record inserted successfully";
}

echo json_encode(array('status' => $status, 'msg' => $msg));
