create table f_orders
(
    id int(7) auto_increment
        primary key,
    old_id int(10) not null,
    org_id int(10) not null,
    original_id int(10) not null,
    copied_from int(10) not null,
    parts_id int(10) not null,
    calculation_id int(7) not null,
    status int(3) not null comment '0 - new, 8 - dealer quotation, 9 - user quotation, 10 - submited to Fischer, 20 - submited to production, 30 - in production, 40 - produced',
    production_type int default 0 not null comment '1 - reclamation, 2 - correction',
    confirm_production_user int default 0 not null,
    confirmed_pgroups text not null,
    order_type int default 0 not null comment '0 - sales, 1 - reclamation',
    `4_digit_order_type` varchar(255) default '' not null,
    deleted int(1) not null,
    cancelled int(1) not null,
    onhold int(1) not null,
    private int(1) not null,
    archive int(1) not null,
    production int(1) not null,
    not_final_measurements int(1) not null,
    not_for_shipments int(1) not null,
    cnc tinyint(1) not null,
    stock_deduction int(1) not null,
    sales_contact_person int(6) not null,
    user int(5) not null,
    dealer int(6) not null,
    dealer_company int(7) not null,
    community int(5) not null,
    name varchar(250) not null,
    pgroups text not null,
    pgroups_finished text not null,
    deducted text not null,
    finished int(1) not null,
    prepared text not null,
    change_pdf_company int(10) not null,
    dealer_nr varchar(50) not null,
    dealer_name varchar(200) not null,
    phone varchar(250) not null,
    address varchar(200) not null,
    location varchar(200) not null,
    city varchar(50) not null,
    postcode varchar(100) not null,
    country int(5) default 1 not null,
    carrier varchar(50) not null,
    send_through_terminal int default 0 not null,
    send_through_terminal_note varchar(100) default '' not null,
    marking varchar(200) not null,
    project_nr varchar(50) not null,
    search_name varchar(250) not null,
    rekv_nr varchar(250) not null,
    change_shipping_address int(1) not null,
    c_id int(7) not null,
    c_nr varchar(20) null,
    c_name text null,
    c_address text null,
    c_postcode varchar(100) null,
    c_tel varchar(200) null,
    c_contact_email varchar(250) default '' not null,
    c_email varchar(200) null,
    c_ean_nr varchar(200) not null,
    c_address_invoice text not null,
    c_contact_id int default 0 not null,
    c_contact_person varchar(200) null,
    c_sales_contact_person varchar(200) not null,
    c_sales_contact_id int default 0 not null,
    c_sales_tel varchar(200) not null,
    c_address_id varchar(10) not null,
    c_city varchar(50) not null,
    c_country varchar(50) not null,
    c_type int(1) not null,
    c_code varchar(50) not null,
    del_name varchar(100) default '' not null,
    del_address varchar(100) default '' not null,
    del_address2 varchar(100) default '' not null,
    del_postcode varchar(15) default '' not null,
    del_city varchar(50) default '' not null,
    del_country int default 0 not null,
    del_contact_name varchar(50) default '' not null,
    del_contact_phone varchar(50) default '' not null,
    del_contact_email varchar(250) default '' not null,
    email_del_info int default 0 not null,
    del_terminal_kvint int default 0 not null,
    client_number varchar(50) not null,
    date_create varchar(10) not null,
    date_submit varchar(10) not null,
    date_produce varchar(10) not null,
    date_delivery varchar(10) not null,
    date_confirmed_delivery varchar(10) default '' not null,
    date_changed_delivery varchar(10) default '' not null,
    date_measure varchar(10) not null,
    date_receive varchar(10) not null,
    date_installation varchar(20) not null,
    installation_time varchar(50) not null,
    production_in_24h int(2) not null,
    installation_start_check int(3) not null,
    installation_start_week int(3) not null,
    curtains_reparation_time varchar(50) not null,
    height_installation text not null,
    date_customer varchar(10) not null,
    date_follow_up varchar(10) not null,
    followup_type int(1) default 0 not null,
    date_valid_until varchar(10) not null,
    date_to_archive varchar(10) not null,
    customer_delivery varchar(10) not null,
    installers_note text not null,
    surface text not null,
    equipment text not null,
    extra_order_note text not null,
    project_specifications text not null,
    quotation_text text not null,
    quotation_text2 text not null,
    remarks_customer text not null,
    only_total_price int(1) not null,
    d_price_zero int(1) not null,
    agreed_price_text varchar(50) default '' not null,
    printed int(1) not null,
    tripletex_saved int(1) not null,
    tripletex_saved_sandnes int default 0 not null,
    tripletex_id_user int default 0 not null,
    tripletex_id_dealer int default 0 not null,
    quotation int(1) not null,
    quotation_convert_date varchar(255) not null,
    alternative int not null,
    dimensions int(1) not null,
    products int(5) not null,
    components int(5) not null,
    extra_lines int default 0 not null,
    product_images int(1) not null,
    fabrics_images int(1) not null,
    component_images int(1) not null,
    pdf_orientation varchar(1) default 'L' not null,
    dealer_vat int(2) not null,
    discount int(2) not null,
    sum int not null,
    discount_sum int not null,
    subtotal int not null,
    total int not null,
    curr varchar(20) not null,
    curr_rate float not null,
    vat int(1) not null,
    reversed_vat tinyint default 0 not null,
    provision int(3) not null,
    provision_sum varchar(20) not null,
    d_sum int not null,
    d_discount int not null,
    d_discount_sum int not null,
    d_installation int not null,
    d_subtotal int not null,
    d_total int not null,
    d_manual_withoutvat int not null,
    d_manual_total int not null,
    currency_fee_status int default 0 not null comment '0 - not deleted, 1 - deleted for user, 2 - deleted for dealer, 3 - deleted for both',
    labels_printed int(1) not null,
    save_pdf text not null,
    by_room int(1) not null,
    invoiced int(2) not null,
    acoustic_sequence text not null,
    special_parts int(1) not null,
    sent_to_c5 int default 0 not null,
    checked_in_vies int default -1 not null,
    checked_vies_date timestamp null,
    recalculate int(1) not null,
    copy_warning int(10) not null,
    email_for_auto_followup varchar(200) not null,
    quot_builder_text text not null,
    internal_note_edit int(10) not null,
    internal_note_date varchar(255) not null,
    invoicing_status int default 0 not null,
    recalculate_by_new_pricelist int default 0 not null,
    curtain_view int default 0 null,
    curtains_list int default 0 not null,
    fortnox_id int(10) not null,
    fortnox_customer_id int(10) not null,
    home_delivery int not null,
    create_date timestamp default CURRENT_TIMESTAMP not null,
    update_date timestamp default CURRENT_TIMESTAMP not null on update CURRENT_TIMESTAMP
)
    charset=utf8;
