CREATE TABLE `f_orders`
(
    `id`                           int(7) NOT NULL,
    `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,
    `parts_order`                  int(11) NOT NULL DEFAULT 0 COMMENT '1-its parts order, 0- normal order',
    `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(11) NOT NULL DEFAULT 0 COMMENT '1 - reclamation, 2 - correction',
    `confirm_production_user`      int(11) NOT NULL DEFAULT 0,
    `confirmed_pgroups`            text         NOT NULL,
    `order_type`                   int(11) NOT NULL DEFAULT 0 COMMENT '0 - sales, 1 - reclamation',
    `4_digit_order_type`           varchar(255) NOT NULL DEFAULT '',
    `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,
    `samples_production`           int(11) NOT NULL DEFAULT 0,
    `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) NOT NULL DEFAULT 1,
    `carrier`                      varchar(50)  NOT NULL,
    `send_through_terminal`        int(11) NOT NULL DEFAULT 0,
    `send_through_terminal_note`   varchar(100) NOT NULL DEFAULT '',
    `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)           DEFAULT NULL,
    `c_name`                       text                  DEFAULT NULL,
    `c_address`                    text                  DEFAULT NULL,
    `c_postcode`                   varchar(100)          DEFAULT NULL,
    `c_tel`                        varchar(200)          DEFAULT NULL,
    `c_contact_email`              varchar(250) NOT NULL DEFAULT '',
    `c_email`                      varchar(200)          DEFAULT NULL,
    `c_ean_nr`                     varchar(200) NOT NULL,
    `c_address_invoice`            text         NOT NULL,
    `c_contact_id`                 int(11) NOT NULL DEFAULT 0,
    `c_contact_person`             varchar(200)          DEFAULT NULL,
    `c_sales_contact_person`       varchar(200) NOT NULL,
    `c_sales_contact_id`           int(11) NOT NULL DEFAULT 0,
    `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) NOT NULL DEFAULT '',
    `del_address`                  varchar(100) NOT NULL DEFAULT '',
    `del_address2`                 varchar(100) NOT NULL DEFAULT '',
    `del_postcode`                 varchar(15)  NOT NULL DEFAULT '',
    `del_city`                     varchar(50)  NOT NULL DEFAULT '',
    `del_country`                  int(11) NOT NULL DEFAULT 0,
    `del_contact_name`             varchar(50)  NOT NULL DEFAULT '',
    `del_contact_phone`            varchar(50)  NOT NULL DEFAULT '',
    `del_contact_email`            varchar(250) NOT NULL DEFAULT '',
    `email_del_info`               int(11) NOT NULL DEFAULT 0,
    `del_terminal_kvint`           int(11) NOT NULL DEFAULT 0,
    `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)  NOT NULL DEFAULT '',
    `date_changed_delivery`        varchar(10)  NOT NULL DEFAULT '',
    `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) NOT NULL DEFAULT 0,
    `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)  NOT NULL DEFAULT '',
    `printed`                      int(1) NOT NULL,
    `tripletex_saved`              int(1) NOT NULL,
    `tripletex_saved_sandnes`      int(11) NOT NULL DEFAULT 0,
    `tripletex_id_user`            int(11) NOT NULL DEFAULT 0,
    `tripletex_id_dealer`          int(11) NOT NULL DEFAULT 0,
    `quotation`                    int(1) NOT NULL,
    `quotation_convert_date`       varchar(255) NOT NULL,
    `alternative`                  int(11) NOT NULL,
    `dimensions`                   int(1) NOT NULL,
    `products`                     int(5) NOT NULL,
    `components`                   int(5) NOT NULL,
    `extra_lines`                  int(11) NOT NULL DEFAULT 0,
    `product_images`               int(1) NOT NULL,
    `fabrics_images`               int(1) NOT NULL,
    `component_images`             int(1) NOT NULL,
    `pdf_orientation`              varchar(1)   NOT NULL DEFAULT 'L',
    `dealer_vat`                   int(2) NOT NULL,
    `discount`                     int(2) NOT NULL,
    `sum`                          int(11) NOT NULL,
    `discount_sum`                 int(11) NOT NULL,
    `subtotal`                     int(11) NOT NULL,
    `total`                        int(11) NOT NULL,
    `curr`                         varchar(20)  NOT NULL,
    `curr_rate`                    float        NOT NULL,
    `vat`                          int(1) NOT NULL,
    `reversed_vat`                 tinyint(4) NOT NULL DEFAULT 0,
    `provision`                    int(3) NOT NULL,
    `provision_sum`                varchar(20)  NOT NULL,
    `d_sum`                        int(11) NOT NULL,
    `d_discount`                   int(11) NOT NULL,
    `d_discount_sum`               int(11) NOT NULL,
    `d_installation`               int(11) NOT NULL,
    `d_subtotal`                   int(11) NOT NULL,
    `d_total`                      int(11) NOT NULL,
    `d_manual_withoutvat`          int(11) NOT NULL,
    `d_manual_total`               int(11) NOT NULL,
    `currency_fee_status`          int(11) NOT NULL DEFAULT 0 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,
    `prices_pdf_language`          varchar(10)  NOT NULL DEFAULT 'en' COMMENT 'Language for prices pdf',
    `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(11) NOT NULL DEFAULT 0,
    `checked_in_vies`              int(11) NOT NULL DEFAULT -1,
    `checked_vies_date`            timestamp NULL DEFAULT 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(11) NOT NULL DEFAULT 0,
    `recalculate_by_new_pricelist` int(11) NOT NULL DEFAULT 0,
    `curtain_view`                 int(11) DEFAULT 0,
    `curtains_list`                int(11) NOT NULL DEFAULT 0,
    `fortnox_id`                   int(10) NOT NULL,
    `fortnox_customer_id`          int(10) NOT NULL,
    `home_delivery`                int(11) NOT NULL,
    `create_date`                  timestamp    NOT NULL DEFAULT current_timestamp(),
    `update_date`                  timestamp    NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp ()
) CHARSET=utf8mb3;
