<?php
include 'include/db.php';
include 'include/connect.php';
$id = $_POST['id'];

if(!empty($id) && $_POST['code'] != "0"){

                $data['programe_banner'] = $_POST['image_field'];
                $data['programe_name'] = $_POST['name'];
                $data['programe_code'] = $_POST['code'];
                $data['programe_price'] = $_POST['price'];
                $data['programe_discount'] = $_POST['price_dis'];
                $data['programe_time'] = $_POST['time'];
                // $data['programe_country'] = $_POST['country'];
                $data['programe_bus'] = $_POST['airline'];
                $data['programe_momth'] = $_POST['month'];
                $data['programe_card'] = $_POST['card'];
                $data['programe_hilight'] = $_POST['hilight'];
                $data['programe_cus1'] = $_POST['condition_plus'];
                $data['programe_cus2'] = $_POST['condition_no'];
                $data['programe_file'] = $_POST['series_field'];
                $data['programe_status'] = $_POST['status'];
                $data['programe_category'] = $_POST['category'];
                $data['programe_area'] = $_POST['area'];
                $data['programe_wholesale'] = $_POST['programe_wholesale'];
                
		$rs = $db->update('tbprograme_TH',$data,'programe_id',$id);
           if($rs){
            echo "0";
           } else {
            echo "00";
           }

     } else {

      if($_POST['time'] != "0" && $_POST['code'] != "0" && $_POST['airline'] != "0") {
           
      $rs = $db->insert('tbprograme_TH',array(
       'programe_banner' => $_POST['image_field'],
       'programe_name' => $_POST['name'],
       'programe_code' => $_POST['code'],
       'programe_price' => $_POST['price'],
       'programe_discount' => $_POST['price_dis'],
       'programe_time' => $_POST['time'],
       // 'programe_country' => $_POST['country'],
       'programe_bus' => $_POST['airline'],
       'programe_momth' => $_POST['month'],
       'programe_card' => $_POST['card'],
       'programe_hilight' => $_POST['hilight'],
       'programe_cus1' => $_POST['condition_plus'],
       'programe_cus2' => $_POST['condition_no'],
       'programe_file' => $_POST['series_field'],
       'programe_category' => $_POST['category'],
       'programe_area' => $_POST['area'],
       'programe_wholesale' => $_POST['programe_wholesale'],
       'programe_status' => $_POST['status']
            ));

           if($rs){
            echo "2";
           } else {
            echo "0";
           }
         } else {
            echo "3";
        }
}
?>

