<?php
header('Access-Control-Allow-Origin: *');
header('Access-Control-Allow-Methods: POST, GET, OPTIONS');
header('Access-Control-Max-Age: 1000');
header('Access-Control-Allow-Headers: Content-Type');
require_once('../lib/dbclass.php');

extract($_POST);
$data = $_REQUEST;


if ($data['Assembly'] == 0 && $data['District'] == 0 && $data['Panchayat'] > 0) {
    $Panchayat = $data['Panchayat'];

    $showdistrictandassembly = 0;

    $datachlng = findQuery("select * from  `tbl_challenge` where '$challenge_startdate'  between `challenge_startdate` and `challenge_enddate` and status=0");

    if ($datachlng) {
        $showdistrictandassembly = $datachlng[0]['showdistrictandassembly'];
    }

    if ($showdistrictandassembly == 0) {
        $dataassem        = findQuery("select * from tbl_panchayat where status=0 and id=$Panchayat");
        $data['Assembly'] = $dataassem[0]['assembly_id'];
        $assembly         = $data['Assembly'];

        $datadis          = findQuery("select * from tbl_assembly where status=0 and id=$assembly");
        $data['District'] = $datadis[0]['district'];
    }
}


$id = saveArray('tbl_customer', $data, 0);


if ($id > 0) {
    $message = 'True';
    $data2   = $id;
} else {
    $message = 'False';
    $data2   = 0;
}

echo json_encode(['Status' => $message, 'data' => $data2]);








return;
?>	   


