<?php
include 'include/db.php';
include 'include/connect.php';

$id = $_POST['id'];


if(!empty($id)){
        

              $data['iv_wholesale'] = $_POST['iv_wholesale'];
              $data['iv_com'] = $_POST['iv_com'];
              $data['iv_com_sale'] = $_POST['iv_com_sale'];
              $data['iv_note'] = $_POST['iv_note'];
              $data['iv_land_total'] = $_POST['iv_land_total'];
        
    $rs = $db->update('tbiv',$data,'iv_id',$id);
                
                if($rs){
                    echo '0';
                }  else {
                    echo '00';
                } 
  } else {    
        if($_POST['cus_name'] != "" && $_POST['cus_tel'] != "" && $_POST['cus_mail'] != ""){
        $rs = $db->insert('tbiv',array(
      'cus_name' => $_POST['cus_name'],
        'cus_tel' => $_POST['cus_tel'],
        'cus_mail' => $_POST['cus_mail'],
        'iv_admin' => $_POST['iv_admin'],
        'iv_date' => $_POST['iv_date'],
        'iv_namepro' => $_POST['iv_namepro'],
        'iv_codepro' => $_POST['iv_codepro'],
        'pro_datego' => $_POST['pro_datego'],
        'pro_dateback' => $_POST['pro_dateback'],
        'adult_price' => $_POST['adult_price'],
        'adult_num' => $_POST['adult_num'],
        'c_price' => $_POST['c_price'],
        'c_num' => $_POST['c_num'],
        'nb_price' => $_POST['nb_price'],
        'nb_num' => $_POST['nb_num'],
        's_price' => $_POST['s_price'],
        's_num' => $_POST['s_num'],
        'custom1_name' => $_POST['custom1_name'],
        'custom1_price' => $_POST['custom1_price'],
        'custom1_num' => $_POST['custom1_num'],
        'custom2_name' => $_POST['custom2_name'],
        'custom2_price' => $_POST['custom2_price'],
        'custom2_num' => $_POST['custom2_num'],
        'discount_price' => $_POST['discount_price'],
        'discount_sum' => $_POST['discount_sum'],
        'cus_ads' => $_POST['cus_ads'],
        'mus_price' => $_POST['mus_price'],
        'mus_num' => $_POST['mus_num'],
        'mus_date' => $_POST['mus_date'],
        'date_line' => $_POST['date_line'],
        'tax' => $_POST['tax'],
        'cus_de_name' => $_POST['cus_de_name'],
        'cus_de_num' => $_POST['cus_de_num'],
        'cus_de_price' => $_POST['cus_de_price'],
        'cus_de_name2' => $_POST['cus_de_name2'],
        'cus_de_num2' => $_POST['cus_de_num2'],
        'cus_de_price2' => $_POST['cus_de_price2'],
        'iv_pay' => $_POST['iv_pay'],
    ));
        if($rs){

            echo '2';
           
            }else {
                
            echo '00';
            }           
        

  } else {
        echo "3";
    }    
}   
?>

