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

if(!empty($id) && $_POST['code'] != "0"){
                
                $editor_data = $_POST[ 'condition_plus' ];
                $data['programe_img'] = $_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_airline'] = $_POST['airline'];
                $data['programe_month'] = $_POST['month'];
                $data['food'] = $_POST['card'];
                $data['programe_hilight'] = $_POST['hilight'];
                $data['condition_plus'] = $editor_data;
                $data['condition_no'] = $_POST['condition_no'];
                $data['programe_file'] = $_POST['series_field'];
                $data['programe_status'] = $_POST['status'];
                $data['programe_food'] = $_POST['programe_food'];
                $data['programe_wholesale'] = $_POST['programe_wholesale'];
                $data['programe_datego'] = $_POST['programe_datego'];
                $data['programe_dateback'] = $_POST['programe_dateback'];
                $data['programe_route_img'] = $_POST['programe_route_img'];
                
		$rs = $db->update('tb_programe',$data,'programe_id',$id);
           if($rs){
            echo "0";
           } else {
            echo "00";
           }

     } else {

      if($_POST['time'] != "0" && $_POST['code'] != "0" && $_POST['airline'] != "0" && $_POST['country'] != "0") {
           
      $rs = $db->insert('tb_programe',array(
       'programe_img' => $_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_airline' => $_POST['airline'],
       'programe_month' => $_POST['month'],
       'food' => $_POST['card'],
       'programe_hilight' => $_POST['hilight'],
       'condition_plus' => $_POST['condition_plus'],
       'condition_no' => $_POST['condition_no'],
       'programe_file' => $_POST['series_field'],
       'programe_status' => $_POST['status'],
       'programe_wholesale' => $_POST['programe_wholesale'],
       'programe_food' => $_POST['programe_food']
            ));

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

