--
-- Script run to make a migration of module version 1.0.8 to module version 1.0.9
--
 
UPDATE `llx_extrafields` SET `enabled`='isModEnabled("bb2a") && getDolGlobalInt("BB2A_THIRDPARTY_CENTRALE")' WHERE  `name`='centrale' and `elementtype`='societe';

-- Add same fields on product
UPDATE `llx_extrafields` SET `enabled`='isModEnabled("bb2a") && getDolGlobalInt("BB2A_PDF_OPTION")' WHERE  `name`='pdf_product' and `elementtype`='product';
-- Add same fields on propal
UPDATE `llx_extrafields` SET `enabled`='isModEnabled("bb2a") && getDolGlobalInt("BB2A_PDF_PROPAL_DETAIL_PRICE")' WHERE  `name`='detaille' and `elementtype`='propal';
UPDATE `llx_extrafields` SET `enabled`='isModEnabled("bb2a")' WHERE  `name`='propalsend' and `elementtype`='propal';
UPDATE `llx_extrafields` SET `enabled`='isModEnabled("bb2a") && getDolGlobalInt("BB2A_RECEIPT_DEPOSIT")' WHERE  `name`='acompte' and `elementtype`='propal';
UPDATE `llx_extrafields` SET `enabled`='isModEnabled("bb2a") && getDolGlobalInt("BB2A_RECEIPT_DEPOSIT")' WHERE  `name`='receiptdeposit' and `elementtype`='propal';
UPDATE `llx_extrafields` SET `enabled`='isModEnabled("bb2a") && getDolGlobalInt("BB2A_ORDER_DATE_PREPA_DELIVRY")' WHERE  `name`='turnover' and `elementtype`='propal';


-- Add same fields on order
UPDATE `llx_extrafields` SET `enabled`='isModEnabled("bb2a") && getDolGlobalInt("BB2A_ORDER_DATE_PREPA_DELIVRY")' WHERE  `name`='date_prepadelivery' and `elementtype`='commande';
UPDATE `llx_extrafields` SET `enabled`='isModEnabled("bb2a") && getDolGlobalInt("BB2A_ORDER_DATE_PREPA_DELIVRY")' WHERE  `name`='datedeliveryconfirmed' and `elementtype`='commande';
UPDATE `llx_extrafields` SET `enabled`='isModEnabled("bb2a") && getDolGlobalInt("BB2A_ORDER_STATUS_PROGRESS")' WHERE  `name`='status_progress' and `elementtype`='commande';
UPDATE `llx_extrafields` SET `enabled`='isModEnabled("bb2a") && getDolGlobalInt("BB2A_ORDER_ADD_ACTIONBTN_SENDORDER")' WHERE  `name`='sendorder' and `elementtype`='commande';
UPDATE `llx_extrafields` SET `enabled`='isModEnabled("bb2a") && getDolGlobalInt("BB2A_ORDER_ADD_ACTIONBTN_SENDINVOICE")' WHERE  `name`='sendforinvoice' and `elementtype`='commande';
UPDATE `llx_extrafields` SET `enabled`='isModEnabled("bb2a") && getDolGlobalInt("BB2A_RECEIPT_DEPOSIT")' WHERE  `name`='acompte' and `elementtype`='commande';
UPDATE `llx_extrafields` SET `enabled`='isModEnabled("bb2a") && getDolGlobalInt("BB2A_RECEIPT_DEPOSIT")' WHERE  `name`='receiptdeposit' and `elementtype`='commande';
UPDATE `llx_extrafields` SET `enabled`='isModEnabled("bb2a") && getDolGlobalInt("BB2A_ORDER_DATE_PREPA_DELIVRY")' WHERE  `name`='turnover' and `elementtype`='commande';
UPDATE `llx_extrafields` SET `enabled`='isModEnabled("bb2a")' WHERE  `name`='date_facture' and `elementtype`='commande';

-- Add same fields on Resource
UPDATE `llx_extrafields` SET `enabled`='isModEnabled("bb2a") && isModEnabled("stock")' WHERE  `name`='fk_warehouse' and `elementtype`='resource';
UPDATE `llx_extrafields` SET `enabled`='isModEnabled("bb2a")' WHERE  `name`='vehicleinfo' and `elementtype`='resource';
UPDATE `llx_extrafields` SET `enabled`='isModEnabled("bb2a")' WHERE  `name`='licenseplate' and `elementtype`='resource';
UPDATE `llx_extrafields` SET `enabled`='isModEnabled("bb2a")' WHERE  `name`='make' and `elementtype`='resource';
UPDATE `llx_extrafields` SET `enabled`='isModEnabled("bb2a")' WHERE  `name`='model' and `elementtype`='resource';
UPDATE `llx_extrafields` SET `enabled`='isModEnabled("bb2a")' WHERE  `name`='pneumaticsize' and `elementtype`='resource';
UPDATE `llx_extrafields` SET `enabled`='isModEnabled("bb2a")' WHERE  `name`='odometervalue' and `elementtype`='resource';
UPDATE `llx_extrafields` SET `enabled`='isModEnabled("bb2a")' WHERE  `name`='vehicleinspection' and `elementtype`='resource';
UPDATE `llx_extrafields` SET `enabled`='isModEnabled("bb2a")' WHERE  `name`='fk_driver' and `elementtype`='resource';
