<?php
session_start();
require_once "../../../config.php";
require_once "../../../validation.php";
require_once "../../../Helper.php";

require_once '../../database1.php';
require_once "../../check_admin.php";

require_once '../check_edit_page_ajax.php';

class EditAjax extends database{
	public function index($data, $id)
	{
		$where['cl_id'] = $id;
		return $this->update('tb_checkout_item', $data,$where);
	}
}

if(!isset($_POST['code']) || trim($_POST['code']) == '')
{
	http_response_code(400);
	echo json_encode(['error_text' => 'Code Not found']);
	exit;
}

$code = $_POST['code'];

$helper = new Helper();
$validation = new validation();

$data['cl_code'] = $code;


$obj = new EditAjax();
$res = $obj->index($data, $id);
if(!$res)
{
	http_response_code(500);
	echo json_encode(array('error_text' => 'Something Went Wrong'));
	exit;
}

session_start();
$_SESSION['error_message'] = 'Code Updated Successfully';
$_SESSION['error_type'] = 'success';

http_response_code(200);
echo json_encode(array('message' => 'Code Updated Successfully'));
exit;