-- -----------------------------------------------------------------------------------
-- estructura de archivo para importar pedidos a QFACWIN desde Magento utilizando la extension orders2csv
-- 1. A menos que el prefijo de las tablas en su tienda Magento sea mg_ 
--    debe cambiar este archivo antes de ejecutarlo: buscar: mg_ y reemplazar por suprefijo_
-- 2. Compruebe que en su tabla orders2csv_file no hay ningun registro con el file_id = 99
--    Si ya existe un registro 99 debe cambiar este archivo antes de ejecutarlo: buscar: 99 y reemplazar por un numero que no exista
-- 3. Ejecute este archivo desde phpmyadmin o su gestor de mysql para insertar el formato en su base de datos
-- -----------------------------------------------------------------------------------


-- -------------------
-- Tabla: mg_orders2csv_file
-- -------------------
insert into mg_orders2csv_file  (file_id,title,is_active,num_formatting,creation_time,update_time) values (99,'Pedidos QFACWIN',1,0,now(),now() ); 


-- -------------------
-- Tabla: mg_orders2csv_column
-- -------------------
insert into mg_orders2csv_column  (column_id,file_id,title,sort_order,value,creation_time,update_time) values (NULL,99,'Pedido_Num',10,'order_data_increment_id',now(),now() ); 
insert into mg_orders2csv_column  (column_id,file_id,title,sort_order,value,creation_time,update_time) values (NULL,99,'Fecha',20,'order_data_created_at',now(),now() ); 
insert into mg_orders2csv_column  (column_id,file_id,title,sort_order,value,creation_time,update_time) values (NULL,99,'Codigo',30,'item_data_sku',now(),now() ); 
insert into mg_orders2csv_column  (column_id,file_id,title,sort_order,value,creation_time,update_time) values (NULL,99,'Cant',35,'item_data_qty_ordered',now(),now() ); 
insert into mg_orders2csv_column  (column_id,file_id,title,sort_order,value,creation_time,update_time) values (NULL,99,'Articulo',40,'item_data_name',now(),now() ); 
insert into mg_orders2csv_column  (column_id,file_id,title,sort_order,value,creation_time,update_time) values (NULL,99,'Precio',50,'item_data_price',now(),now() ); 
insert into mg_orders2csv_column  (column_id,file_id,title,sort_order,value,creation_time,update_time) values (NULL,99,'%Iva',70,'item_data_tax_percent',now(),now() ); 
insert into mg_orders2csv_column  (column_id,file_id,title,sort_order,value,creation_time,update_time) values (NULL,99,'Nombre_Cliente',80,'order_data_customer_firstname',now(),now() ); 
insert into mg_orders2csv_column  (column_id,file_id,title,sort_order,value,creation_time,update_time) values (NULL,99,'Apellidos_Cliente',90,'order_data_customer_lastname',now(),now() ); 
insert into mg_orders2csv_column  (column_id,file_id,title,sort_order,value,creation_time,update_time) values (NULL,99,'Direccion_Cliente',100,'order_billing_data_street',now(),now() ); 
insert into mg_orders2csv_column  (column_id,file_id,title,sort_order,value,creation_time,update_time) values (NULL,99,'CP_Cliente',110,'order_billing_data_postcode',now(),now() ); 
insert into mg_orders2csv_column  (column_id,file_id,title,sort_order,value,creation_time,update_time) values (NULL,99,'Telf_Cliente',120,'order_billing_data_telephone',now(),now() ); 
insert into mg_orders2csv_column  (column_id,file_id,title,sort_order,value,creation_time,update_time) values (NULL,99,'Mail_Cliente',130,'order_data_customer_email',now(),now() ); 
insert into mg_orders2csv_column  (column_id,file_id,title,sort_order,value,creation_time,update_time) values (NULL,99,'Empresa',95,'order_billing_data_company',now(),now() ); 
insert into mg_orders2csv_column  (column_id,file_id,title,sort_order,value,creation_time,update_time) values (NULL,99,'Fax_Cliente',119,'order_billing_data_fax',now(),now() ); 
insert into mg_orders2csv_column  (column_id,file_id,title,sort_order,value,creation_time,update_time) values (NULL,99,'Pais_Cliente',118,'order_billing_country_name',now(),now() ); 
insert into mg_orders2csv_column  (column_id,file_id,title,sort_order,value,creation_time,update_time) values (NULL,99,'Prov_Cliente',116,'order_billing_data_region',now(),now() ); 
insert into mg_orders2csv_column  (column_id,file_id,title,sort_order,value,creation_time,update_time) values (NULL,99,'Ciudad_Cliente',115,'order_billing_data_city',now(),now() ); 
insert into mg_orders2csv_column  (column_id,file_id,title,sort_order,value,creation_time,update_time) values (NULL,99,'Env_Pais',210,'order_shipping_country_name',now(),now() ); 
insert into mg_orders2csv_column  (column_id,file_id,title,sort_order,value,creation_time,update_time) values (NULL,99,'Env_Prov',200,'order_shipping_data_region',now(),now() ); 
insert into mg_orders2csv_column  (column_id,file_id,title,sort_order,value,creation_time,update_time) values (NULL,99,'Env_Ciudad',190,'order_shipping_data_city',now(),now() ); 
insert into mg_orders2csv_column  (column_id,file_id,title,sort_order,value,creation_time,update_time) values (NULL,99,'Env_CP',180,'order_shipping_data_postcode',now(),now() ); 
insert into mg_orders2csv_column  (column_id,file_id,title,sort_order,value,creation_time,update_time) values (NULL,99,'Env_Direccion',170,'order_shipping_data_street',now(),now() ); 
insert into mg_orders2csv_column  (column_id,file_id,title,sort_order,value,creation_time,update_time) values (NULL,99,'Env_Empresa',160,'order_shipping_data_company',now(),now() ); 
insert into mg_orders2csv_column  (column_id,file_id,title,sort_order,value,creation_time,update_time) values (NULL,99,'Env_Apellidos',150,'order_shipping_data_lastname',now(),now() ); 
insert into mg_orders2csv_column  (column_id,file_id,title,sort_order,value,creation_time,update_time) values (NULL,99,'Env_Nombre',140,'order_shipping_data_firstname',now(),now() ); 
insert into mg_orders2csv_column  (column_id,file_id,title,sort_order,value,creation_time,update_time) values (NULL,99,'NIF',96,'order_data_customer_taxvat',now(),now() ); 
insert into mg_orders2csv_column  (column_id,file_id,title,sort_order,value,creation_time,update_time) values (NULL,99,'Gtos_Envio',71,'order_data_shipping_amount',now(),now() ); 
insert into mg_orders2csv_column  (column_id,file_id,title,sort_order,value,creation_time,update_time) values (NULL,99,'Total',220,'order_data_grand_total',now(),now() ); 
