ALTER TABLE `clients` ADD `autorisation_cadeaux` VARCHAR(1) NOT NULL DEFAULT '0' AFTER `autorisation_paiement_instance`;
ALTER TABLE `clients` ADD `categorie_statistique` ENUM('A','B','C','D','E','F') NULL AFTER `categoriecommercial_code`;
ALTER TABLE `familles` ADD `ordre` INT(11) NOT NULL DEFAULT '1' AFTER `libelle`;
ALTER TABLE `gammes` ADD `ordre` INT(11) NOT NULL DEFAULT '1' AFTER `libelle`;

ALTER TABLE `stocks` ADD `dlc` INT(11) NOT NULL DEFAULT '0' AFTER `quantite`, ADD `casse` INT(11) NOT NULL DEFAULT '0' AFTER `dlc`;
ALTER TABLE `parametrages` ADD `commentaire_commande` INT(1) NOT NULL DEFAULT '0' AFTER `plafond_dc`;
ALTER TABLE `depots` ADD `site_expedition` VARCHAR(255) NOT NULL DEFAULT 'D23' AFTER `adresse`, 
                    ADD `site_vente` VARCHAR(255) NOT NULL DEFAULT 'D01' AFTER `site_expedition`, 
                   ADD `depot_code_sage` VARCHAR(255) NULL DEFAULT NULL AFTER `site_vente`, 
                  ADD `adresse_livraison_depot` VARCHAR(255) NOT NULL DEFAULT 'A01' AFTER `depot_code_sage`;
                  update depots set depot_code_sage=code;

ALTER TABLE `caisses` ADD `date_cloture` DATETIME NULL DEFAULT NULL AFTER `date`;

ALTER TABLE `parametrages` ADD `nbr_decimal` INT(3) NOT NULL DEFAULT '3' ,ADD `paiement_android` INT(1) NOT NULL DEFAULT '1' AFTER `nbr_decimal`;
ALTER TABLE `lignecommercials` ADD `num_lot` VARCHAR(50) NULL AFTER `num_config`;

ALTER TABLE `produits` ADD `ordre_mobile` INT NULL DEFAULT '0' AFTER `ordre`;
update produits set ordre_mobile=ordre;



ALTER TABLE `familles` ADD `hors_lait` BOOLEAN NOT NULL DEFAULT TRUE AFTER `hors_box`, 
                       ADD `hors_beurre` BOOLEAN NOT NULL DEFAULT TRUE AFTER `hors_lait`, 
                       ADD `hors_lait_beurre` BOOLEAN NOT NULL DEFAULT TRUE AFTER `hors_beurre`;
ALTER TABLE `commissions_camion` ADD `type` ENUM('journalier','mensuel') NOT NULL DEFAULT 'journalier' AFTER `montant_mensuel`;


ALTER TABLE `entetecommercials` CHANGE `type` `type` ENUM('avoir','commande','bl','bl_annule','facture','cadeaux','blf','demandeAvoir','Plan de charge','demandeCadeaux','devis') CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL;

ALTER TABLE `clients` ADD `date_changement_prospect_client` TIMESTAMP NULL DEFAULT NULL AFTER `date_creation`;

ALTER TABLE `parametrages` ADD `validInventaireWithPassword` BOOLEAN NOT NULL DEFAULT FALSE AFTER `recherche`;

ALTER TABLE `augmentations` ADD `cree_par` VARCHAR(255) NULL AFTER `groupe_code`;

 --     MAJ nomadis

 ALTER TABLE `tournees` ADD `rs_client_code` VARCHAR(191) NULL AFTER `client_code`;
ALTER TABLE `tournees` CHANGE `type_layer` `type_layer` ENUM('gouvernorat','delegation','localite','region','zone','secteur','tournee','route') CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL DEFAULT 'tournee' AFTER `coordinates`;
ALTER TABLE `tournees` CHANGE `code_layer` `code_layer` VARCHAR(255) CHARACTER SET utf8 COLLATE utf8_unicode_ci NULL DEFAULT NULL AFTER `type_layer`;

ALTER TABLE `tournees` ADD `latitude` VARCHAR(255) NULL AFTER `rs_client_code`, 
                       ADD `longitude` VARCHAR(255) NULL AFTER `latitude`, 
                       ADD `adresse` VARCHAR(255) NULL AFTER `longitude`, 
                       ADD `type_client` VARCHAR(255) NULL AFTER `adresse`;
ALTER TABLE `tournees` ADD `couleur` VARCHAR(255) NULL DEFAULT '#3388ff' AFTER `adresse`;

ALTER TABLE `tournees` ADD `activite` VARCHAR(255) NULL AFTER `type_client`, 
                        ADD `image` VARCHAR(255) NULL AFTER `activite`, 
                        ADD `client` VARCHAR(255) NULL AFTER `image`;
ALTER TABLE `tournees` ADD `icon` VARCHAR(255) NULL AFTER `client`, 
                        ADD `couleur_icon` VARCHAR(255) NULL AFTER `icon`;


ALTER TABLE `produits` ADD `type_unite` VARCHAR(50) NOT NULL DEFAULT 'UN' AFTER `unite`;

ALTER TABLE `stock_depot_info` ADD `date` DATETIME NULL AFTER `longitude`;

ALTER TABLE `entete_inventaire` ADD `date_cloture` DATETIME NULL DEFAULT NULL AFTER `validation`;
ALTER TABLE `mouvements` ADD `stk_before_inventaire` INT NULL AFTER `qte_demande`;
ALTER TABLE `mouvements` ADD `stk_after_inventaire` INT NULL AFTER `stk_before_inventaire`;
ALTER TABLE `ligne_inventaire` ADD `stk_before_inventaire` INT NULL AFTER `quantite`;
ALTER TABLE `ligne_inventaire` ADD `stk_after_inventaire` INT NULL AFTER `stk_before_inventaire`;
ALTER TABLE `stock_depot_info` ADD `diff_quantite` INT NULL AFTER `old_quantite`;
ALTER TABLE `stock_depot_info` ADD `commercial_code` VARCHAR(255) CHARACTER SET utf8 COLLATE utf8_unicode_ci NULL AFTER `user_code`;
ALTER TABLE `stock_depot_info` ADD `module_nomadis` ENUM('Achat','Mouvement','Inventaire','Correction') NULL AFTER `new_quantite`;
ALTER TABLE `stock_depot_info` ADD `type_mouvement` VARCHAR(255) NULL AFTER `module_nomadis`;
alter table stock_depot_info add FOREIGN key (commercial_code) references users(code);
ALTER TABLE `stock_depot_info` ADD `soussociete_code` VARCHAR(255) CHARACTER SET utf8 COLLATE utf8_unicode_ci NULL AFTER `commercial_code`;
alter table stock_depot_info add FOREIGN key (soussociete_code) references soussocietes(code);
ALTER TABLE `stock_depot_info` ADD `code` VARCHAR(255) NULL AFTER `soussociete_code`;
ALTER TABLE `stock_depot_info` ADD `etat` VARCHAR(100) NULL AFTER `type_mouvement`;
ALTER TABLE `depots` ADD `code_caisse_camion` VARCHAR(255) NULL AFTER `adresse`;
ALTER TABLE `mouvements` ADD `from_stock` BOOLEAN NOT NULL DEFAULT TRUE AFTER `type`;
ALTER TABLE `mouvements` DROP INDEX `produit_code`, ADD UNIQUE `produit_code` (`produit_code`, `num_serie`, `numero`, `configuration`, `from_stock`) USING BTREE;
ALTER TABLE `mouvements` DROP INDEX `commercial_code`, ADD UNIQUE `commercial_code` (`commercial_code`, `produit_code`, `quantite`, `type`, `numero`, `from_stock`) USING BTREE;
-- ##################################  2023-02-24 ################################################# --
ALTER TABLE `parametrages` ADD `modification_chargement` BOOLEAN NOT NULL DEFAULT FALSE AFTER `modification_mobile`;



ALTER TABLE `tournees` ADD `libelle` VARCHAR(255) NULL DEFAULT NULL AFTER `code`;
update tournees set libelle=code;
ALTER TABLE `parametrages` ADD `affichage_produit_hors_stock` INT(1) NOT NULL DEFAULT '0' AFTER `paiement_android`
ALTER TABLE `caisses` ADD `echange_gms` DOUBLE NULL DEFAULT '0' AFTER `creditgms`;
ALTER TABLE `depots` ADD `prefix_facture` VARCHAR(50)  NULL AFTER `type`, ADD `prefix_bl` VARCHAR(50)  NULL AFTER `prefix_facture`, ADD `prefix_cmd` VARCHAR(50)  NULL AFTER `prefix_bl`, ADD `prefix_avoir` VARCHAR(50)  NULL AFTER `prefix_cmd`, ADD `max_facture` INT(11)  NULL DEFAULT '0' AFTER `prefix_avoir`;
ALTER TABLE `depots` ADD `prefix_client` VARCHAR(50)  NULL AFTER `prefix_avoir`;
ALTER TABLE `equipement_pdvs` ADD `proprio` VARCHAR(50) NOT NULL AFTER `code`;



ALTER TABLE `produits` ADD `division_unite` DOUBLE NULL DEFAULT '1' AFTER `unite`;
ALTER TABLE `parametrages` ADD `validation_cadeaux` BOOLEAN NOT NULL DEFAULT FALSE AFTER `affichage_list_produit`;
ALTER TABLE `entetecommercials` ADD `cadeaux_valide` BOOLEAN NOT NULL DEFAULT TRUE AFTER `type`;
ALTER TABLE `entetecommercials` ADD `type_cadeaux` VARCHAR(255) NULL DEFAULT NULL AFTER `cadeaux_valide`;
ALTER TABLE `entetecommercials` ADD `code_avoir` VARCHAR(255) NULL AFTER `annule`, 
                                ADD `export_facture_cl` DATETIME NULL DEFAULT NULL AFTER `code_avoir`;
ALTER TABLE `entetecommercials` ADD `export_facture_cl_avoirs` DATETIME NULL DEFAULT NULL AFTER `export_facture_cl`;

ALTER TABLE `objectifs` ADD `poids` DOUBLE NULL DEFAULT 0 AFTER `qte`;
ALTER TABLE `objectifs` CHANGE `type` `type` ENUM('journalier','qte','chiffre','poids') CHARACTER SET utf8 COLLATE utf8_unicode_ci NULL DEFAULT NULL;
ALTER TABLE `objectifs` ADD `realise_poids` DOUBLE NOT NULL DEFAULT '0' AFTER `realise_qte`;
ALTER TABLE `parametrages` ADD `proposition_commande_bl` INT(1) NOT NULL DEFAULT '0' AFTER `affichage_produit_hors_stock`;
ALTER TABLE `produits` ADD `prime_cache` DOUBLE NULL AFTER `type_unite`;
ALTER TABLE `produits` ADD `prime_terme` DOUBLE NULL AFTER `prime_cache`;
ALTER TABLE `equipements` CHANGE `marque` `marque` ENUM('Intermec','Honeywell','Thermal','Smart','Honeywell_new','SPRT By Nomadis') CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL DEFAULT 'Honeywell';
ALTER TABLE `parametrages` ADD `reenvoyer_chargement` BOOLEAN NOT NULL DEFAULT FALSE AFTER `modification_chargement`;
ALTER TABLE `objectifs` ADD `client_code` VARCHAR(255) NULL AFTER `marque_code`;

ALTER TABLE `mouvements` ADD `from_dash` BOOLEAN NOT NULL DEFAULT FALSE AFTER `type`;
ALTER TABLE `parametrages` ADD `ajout_gratuite_commercial` INT(1) NOT NULL DEFAULT '0' AFTER `proposition_commande_bl`;
ALTER TABLE `parametrages` ADD `type_remise` ENUM('ht','ttc') NOT NULL DEFAULT 'ttc' AFTER `ajout_gratuite_commercial`;



ALTER TABLE `produits` CHANGE `type_unite` `type_unite` VARCHAR(50) CHARACTER SET utf8 COLLATE utf8_unicode_ci NULL DEFAULT 'UN';
ALTER TABLE `produits` CHANGE `ordre_mobile` `ordre_mobile` INT(5) NULL DEFAULT '0';

-- ######################## Integration merbiss nomadis ##############################
ALTER TABLE `mouvements` ADD `group_cmd_code` VARCHAR(255) NULL DEFAULT NULL AFTER `numero`;
ALTER TABLE `mouvements_deleted` ADD `group_cmd_code` VARCHAR(255) NULL DEFAULT NULL AFTER `numero`;
ALTER TABLE `caisses` ADD `date_cloture` DATETIME NULL DEFAULT NULL AFTER `date`;


ALTER TABLE `mouvements` ADD `enseigne_code` VARCHAR(255) NULL DEFAULT NULL AFTER `group_cmd_code`;
ALTER TABLE `mouvements_deleted` ADD `enseigne_code` VARCHAR(255) NULL DEFAULT NULL AFTER `group_cmd_code`;
ALTER TABLE `caisses_collectivites` ADD `enseigne_code` VARCHAR(255) NULL AFTER `groupe_code`;
sudo php artisan migrate --path=database/migrations/caisses_collectivites
sudo php artisan migrate --path=database/migrations/caisses_collectivites_produits

ALTER TABLE `specialites` ADD `cacheTerme` ENUM('cache','terme') NOT NULL DEFAULT 'cache' AFTER `libelle`;
ALTER TABLE `parametrages` ADD `num_lot` INT NOT NULL DEFAULT '0' AFTER `type_remise`;
ALTER TABLE `parametrages` ADD `impression_edition_uniq_bl_avoir` INT NOT NULL DEFAULT '0' AFTER `num_lot`;

ALTER TABLE `mouvements` ADD `num_lot` VARCHAR(50) NULL AFTER `wavesoft`;
ALTER TABLE `mouvements` ADD `date_dlc` DATE NULL DEFAULT NULL AFTER `date_accept`;

ALTER TABLE `lignecommercials` ADD `remise_client` DOUBLE NULL DEFAULT NULL;
ALTER TABLE `entete_achat` CHANGE `remise` `remise` DOUBLE NULL DEFAULT NULL;


ALTER TABLE `entetecommercials` ADD `user_cadeaux_valide` VARCHAR(255) CHARACTER SET utf8 COLLATE utf8_unicode_ci NULL DEFAULT NULL AFTER `cadeaux_valide`;
alter table entetecommercials add FOREIGN key (user_cadeaux_valide) references users(code);

ALTER TABLE `produits` ADD `code_fournisseur` VARCHAR(255) NULL AFTER `code_erp`;
ALTER TABLE `produits` ADD `caisse_code` VARCHAR(255) NULL AFTER `code_erp`;
ALTER TABLE `users` ADD `ordre` INT NOT NULL DEFAULT '1' AFTER `date_delivrance`;
ALTER TABLE `entetecommercials` CHANGE `type` `type` ENUM('avoir','commande','bl','bl_annule','facture','cadeaux','blf','demandeAvoir','Plan de charge','demandeCadeaux','devis','commande_annule') CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci NOT NULL;
ALTER TABLE `equipements` CHANGE `marque` `marque` ENUM('Intermec','Honeywell','Thermal','Smart','Honeywell_new','SPRT By Nomadis','SPRT') CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL DEFAULT 'Honeywell';

ALTER TABLE `parametrages` ADD `impression_prix_ticket` ENUM('ttc','ht') NOT NULL DEFAULT 'ttc' AFTER `impression_edition_uniq_bl_avoir`;

ALTER TABLE `parametrages` ADD `gestion_prospect` INT(1) NOT NULL DEFAULT '0' AFTER `impression_prix_ticket`;

ALTER TABLE `clients` ADD `avance_sur_impot` DOUBLE NOT NULL DEFAULT '0' AFTER `regime_fiscale`;
ALTER TABLE `entetecommercials` ADD `impot` DOUBLE NOT NULL DEFAULT '0' AFTER `export`;
ALTER TABLE `conditions_gratuites` ADD `chiffre_max` DOUBLE NULL AFTER `chiffre`;


ALTER TABLE `lignecommercials` ADD `enpromotion` BOOLEAN NULL DEFAULT FALSE AFTER `updated_at`;
ALTER TABLE `lignecommercials` ADD `echantillon` BOOLEAN NULL DEFAULT FALSE AFTER `updated_at`;

-- ################################# 12/12/2023 ################################ --
ALTER TABLE `entetecommercials` ADD `facture` BOOLEAN NOT NULL DEFAULT FALSE AFTER `code_a_barre`;
ALTER TABLE `entetecommercials` ADD `status_facture` ENUM('Non facturé','Mixte','Facturé') NOT NULL DEFAULT 'Non facturé' AFTER `facture`;
ALTER TABLE `lignecommercials` ADD `facture` BOOLEAN NOT NULL DEFAULT FALSE AFTER `entetecommercial_code`;
ALTER TABLE `lignecommercials` ADD `status_facture` ENUM('Non facturé','Mixte','Facturé') NOT NULL DEFAULT 'Non facturé' AFTER `facture`;
ALTER TABLE `lignecommercials` ADD `quantite_facture` INT NOT NULL DEFAULT '0' AFTER `quantite`;
ALTER TABLE `lignecommercials` CHANGE `quantite_facture` `quantite_facture` DOUBLE NOT NULL DEFAULT '0';
ALTER TABLE `lignecommercials` ADD `bl_code` VARCHAR(255) NULL AFTER `status_facture`;
ALTER TABLE `clients` ADD `groupe_bls_facture` BOOLEAN NOT NULL DEFAULT TRUE AFTER `prenom`;
ALTER TABLE `parametrages` ADD `vente_decimal` INT NOT NULL DEFAULT '0' AFTER `gestion_prospect`;

ALTER TABLE `parametrages` ADD `module_chargement` INT NOT NULL DEFAULT '0' AFTER `vente_decimal`;

ALTER TABLE `lignecommercials` ADD `commercial_code` VARCHAR(255) NULL AFTER `entetecommercial_code`, ADD `depot_code` VARCHAR(255) NULL AFTER `commercial_code`;
ALTER TABLE `lignecommercials` ADD `commentaire` VARCHAR(255) NULL AFTER `status_facture`;
ALTER TABLE `societes` ADD `prefix_facture` VARCHAR(255) NULL AFTER `prefix_commande`;


-- sudo php artisan migrate  --path=database/migrations/type_negoces
ALTER TABLE `clients` ADD `code_type_negoce` VARCHAR(255) CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci NULL DEFAULT NULL AFTER `statut`;



ALTER TABLE `produits` ADD `marge_gms` DOUBLE NOT NULL DEFAULT '0' AFTER `marge`;
UPDATE produits SET marge_gms = marge;
ALTER TABLE `parametrages` ADD `envoi_bl_to_merbiss` BOOLEAN NOT NULL DEFAULT TRUE COMMENT 'Envoi BL to merbiss' AFTER `impression_recette`;
ALTER TABLE `entetecommercials` ADD `envoi_merbiss` BOOLEAN NOT NULL DEFAULT FALSE  AFTER `envoi_cmd`;

ALTER TABLE `produits` ADD `prix_impression` DOUBLE NOT NULL DEFAULT 0 AFTER `id`;
ALTER TABLE `parametrages` ADD `prix_impression` INT NOT NULL DEFAULT '0' AFTER `module_chargement`;
ALTER TABLE `parametrages` ADD `db_name_merbiss` VARCHAR(255) NULL AFTER `envoi_bl_to_merbiss`;

-- #################### 07/02/2024 ####################
ALTER TABLE `clients` ADD `pdv_code_merbiss` VARCHAR(255)  CHARACTER SET utf8 COLLATE utf8_unicode_ci NULL DEFAULT NULL AFTER `code`;
ALTER TABLE `entetecommercials` ADD `pdv_code_merbiss` VARCHAR(255) NULL AFTER `client_code`;
ALTER TABLE `clients` CHANGE `pdv_code_merbiss` `pdv_code_merbiss` VARCHAR(255) CHARACTER SET utf8 COLLATE utf8_unicode_ci NULL DEFAULT NULL;
ALTER TABLE `clients` CHANGE `pdv_code_merbiss` `pdv_code_merbiss` VARCHAR(191) CHARACTER SET utf8 COLLATE utf8_unicode_ci NULL DEFAULT NULL;
ALTER TABLE `entetecommercials` CHANGE `pdv_code_merbiss` `pdv_code_merbiss` VARCHAR(191) CHARACTER SET utf8 COLLATE utf8_unicode_ci NULL DEFAULT NULL;
ALTER TABLE entetecommercials add FOREIGN key (`pdv_code_merbiss`) references clients(`pdv_code_merbiss`);
ALTER TABLE `parametrages` ADD `details_bl` INT NOT NULL DEFAULT '1' AFTER `prix_impression`;
ALTER TABLE `routings` ADD `visibilite` INT NOT NULL DEFAULT '0' AFTER `user_code`;


-- #################### 16/02/2024 ####################
ALTER TABLE `users` ADD `user_code_merbiss` VARCHAR(255) NULL AFTER `code`;
ALTER TABLE `clients` ADD `code_nomashop` VARCHAR(255) NULL AFTER `code_a_barre`;
ALTER TABLE `visites` ADD `machine_code` VARCHAR(255) NULL AFTER `ascensseur_code`;
ALTER TABLE `visites` CHANGE `type` `type` ENUM('avoir','commande','bl','recouvrement','visite','merchandising','cadeaux','ascensseur','machine') CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci NOT NULL;
ALTER TABLE `produits` ADD `code_nomashop` VARCHAR(255) NULL AFTER `code_erp`;


-- #################### 11/03/2024 ####################
ALTER TABLE `entetecommercials` ADD `quantite_achete` INT NULL DEFAULT NULL COMMENT 'Condition Cadeaux' AFTER `id`, 
                                ADD `quantite_gratuite` INT NULL DEFAULT NULL COMMENT 'Condition Cadeaux' AFTER `quantite_achete`;

ALTER TABLE `clients` ADD `classement` ENUM('COLLECTIVITE','GMS','PROXY') NULL AFTER `soussociete_code`;
ALTER TABLE `clients` ADD `client_merbiss` BOOLEAN NULL AFTER `classement`;
ALTER TABLE `entetecommercials` ADD `nomashop` BOOLEAN NULL DEFAULT FALSE AFTER `updated_at`;


ALTER TABLE `users` ADD `token` TEXT NULL AFTER `remember_token`;
ALTER TABLE `grossistes` ADD `adresse` VARCHAR(191) NULL AFTER `libelle`;



-- champs en commentaire dans entetecommercialsController.php 
--  'c.classement',
--  'e.quantite_gratuite', 
--  'e.quantite_achete',
--  'e.status_facture',
--  'e.facture',

-- lignes en commentaire dans clientController.php 
--  $c->client_merbiss = request('client_merbiss', $c->client_merbiss);
--  $c->client_merbiss = request('client_merbiss', 0);

ALTER TABLE `produits` ADD `marge_percent` DOUBLE NOT NULL DEFAULT '0' AFTER `marge`;
ALTER TABLE `produits` ADD `marge_gms_percent` DOUBLE NOT NULL DEFAULT '0' AFTER `marge_gms`;
ALTER TABLE `produits` ADD `marge_type` ENUM('Prix', 'Percent') NULL AFTER `marge_gms_percent`;
ALTER TABLE `sousfamilles` ADD `marge_type` ENUM('Prix', 'Percent') NULL AFTER `libelle`;
ALTER TABLE `clients` ADD `client_gms` BOOLEAN NULL DEFAULT FALSE AFTER `magasin`;


--  COMMISSION NATILAIT 2024-05-09 --------------------------------------
ALTER TABLE `commissions_camion` ADD `nbr_jours` INT NOT NULL AFTER `date_fin`, 
                                  ADD `cloture` BOOLEAN NOT NULL DEFAULT FALSE AFTER `nbr_jours`;

ALTER TABLE `depots` ADD `commission_dlc` DOUBLE NOT NULL DEFAULT '2' AFTER `type`;

ALTER TABLE `commissions_historique` ADD `code` VARCHAR(255) NULL AFTER `id`;
ALTER TABLE `commissions_camion` ADD `commission_historique_code` VARCHAR(255) NULL AFTER `id`;

alter table commissions_camion add FOREIGN key (commission_historique_code) references commissions_historique(code);
ALTER TABLE `commissions_historique` ADD `commission_dlc_max` DOUBLE NOT NULL DEFAULT '0' AFTER `vente_nette`;


ALTER TABLE `depots` ADD `affichage_clients_visible`  VARCHAR(1) NOT NULL DEFAULT '0' AFTER `obligation_gps`;
ALTER TABLE `depots` ADD `obligtaion_matricule_fiscale`  VARCHAR(1) NOT NULL DEFAULT '0' AFTER `obligation_gps`;
ALTER TABLE `depots` ADD `choix_categorie_client`  VARCHAR(1) NOT NULL DEFAULT '0' AFTER `affichage_clients_visible`;
ALTER TABLE `depots` ADD `choix_activite_client` VARCHAR(1) NOT NULL DEFAULT '0' AFTER `choix_categorie_client`;
ALTER TABLE `clients` ADD `societe_facturation` VARCHAR(50) NULL DEFAULT NULL AFTER `soussociete_code`;
ALTER TABLE `clients` ADD `autorisation_paiement_virement` VARCHAR(1) NOT NULL DEFAULT '0' AFTER `autorisation_paiement_instance`;
ALTER TABLE `parametrages` ADD `use_chargement_web` INT NOT NULL DEFAULT '1' AFTER `details_bl`;

ALTER TABLE `mouvements` ADD `date_peremption` DATE NULL DEFAULT NULL AFTER `date_accept`;
ALTER TABLE `lignecommercials` ADD `date_peremption` DATE NULL DEFAULT NULL AFTER `date_modification`;

-- #################### 27/06/2024 ####################

ALTER TABLE `mouvements` ADD `type_chargement` ENUM('chargement','retour_hier','retourI_hier', 'DC') NULL AFTER `type`;
ALTER TABLE `parametrages` ADD `separer_quantite_chargement` BOOLEAN NULL DEFAULT FALSE AFTER `modification_chargement`;
ALTER TABLE `caisses` ADD `ancien_ecart` DOUBLE NULL DEFAULT NULL AFTER `ecart`;

ALTER TABLE `stock_depots` ADD `soussociete_code` VARCHAR(255) NULL DEFAULT NULL AFTER `quantite`;
ALTER TABLE stock_depots ADD FOREIGN KEY (soussociete_code) REFERENCES soussocietes(code)
ALTER TABLE `stock_depots` ADD `retour` INT NULL DEFAULT '0' AFTER `quantite`;

ALTER TABLE `mouvements` CHANGE `type` `type` ENUM('dc','chargement','dechargement','bl','casse','retour','garantie','venteC','retourC','casseC','cadeauxC','gratuiteC','inventaire','demande_avoir','dlc','achat','casse_usine','dlc_usine','inventaire_stock','inventaire_dlc','inventaire_casse','inventaire_reservation','inventaire_securite','dlcC','Rgratuite','Cgratuite','Dgratuite','retourI') CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci NOT NULL;

ALTER TABLE `mouvements` ADD `from_stock_ri` BOOLEAN NOT NULL DEFAULT FALSE AFTER `from_stock`;
ALTER TABLE `mouvements` DROP INDEX `commercial_code`, ADD UNIQUE `commercial_code` (`commercial_code`, `produit_code`, `quantite`, `type`, `numero`, `from_stock`, `type_chargement`) USING BTREE;
ALTER TABLE `stock_depot_info` CHANGE `module_nomadis` `module_nomadis` ENUM('Achat','Mouvement','Inventaire','Correction','TransfertStock') CHARACTER SET utf8 COLLATE utf8_unicode_ci NULL DEFAULT NULL;
ALTER TABLE `stock_depot_info` ADD `emplacement_stock` VARCHAR(255) NULL DEFAULT NULL AFTER `module_nomadis`;

ALTER TABLE `parametrages` ADD `langue` ENUM('ar','fr','en') NULL AFTER `id`;

ALTER TABLE `parametrages` ADD `update_caisse_avoir` BOOLEAN NOT NULL DEFAULT FALSE AFTER `id`;
ALTER TABLE `commissions_historique` ADD `save_details` BOOLEAN NOT NULL DEFAULT FALSE AFTER `cloture`;
ALTER TABLE commissions_historique_details ADD FOREIGN KEY (commissions_historique_code) REFERENCES commissions_historique(code)

ALTER TABLE `depots` ADD `affichage_clients_visible`  VARCHAR(1) NOT NULL DEFAULT '0' AFTER `obligation_gps`;
ALTER TABLE `depots` ADD `obligtaion_matricule_fiscale`  VARCHAR(1) NOT NULL DEFAULT '0' AFTER `obligation_gps`;
ALTER TABLE `depots` ADD `choix_categorie_client`  VARCHAR(1) NOT NULL DEFAULT '0' AFTER `affichage_clients_visible`;
ALTER TABLE `depots` ADD `choix_activite_client` VARCHAR(1) NOT NULL DEFAULT '0' AFTER `choix_categorie_client`;
ALTER TABLE `depots` ADD `visibilite` INT NOT NULL DEFAULT '0' AFTER `choix_activite_client`;
ALTER TABLE `depots` ADD `diametre_recherche` VARCHAR(1) NOT NULL DEFAULT '0' AFTER `visibilite`, 
ADD `motif_non_vente` INT NOT NULL DEFAULT '0' AFTER `diametre_recherche`;

ALTER TABLE `depots` ADD `vente_avec_casse` VARCHAR(1) NOT NULL DEFAULT '0' AFTER `motif_non_vente`;
ALTER TABLE `depots` ADD `modele_produit_vente` VARCHAR(1) NOT NULL DEFAULT '1' AFTER `vente_avec_casse`;

ALTER TABLE `parametrages` ADD `postion_automatique` VARCHAR(1) NOT NULL DEFAULT '0';
ALTER TABLE `tournees` CHANGE `actif` `actif` BOOLEAN NOT NULL DEFAULT FALSE;

ALTER TABLE `lignecommercials` ADD `bl_date` DATETIME NULL AFTER `bl_code`;
ALTER TABLE `depots` ADD `nombre_impression` INT NOT NULL DEFAULT '1' AFTER `modele_produit_vente`;

ALTER TABLE `users` ADD `matricule_fiscale` VARCHAR(50) NULL AFTER `code_a_barre`, ADD `num_responsable1` VARCHAR(50) NULL AFTER `matricule_fiscale`, ADD `num_responsable2` VARCHAR(50) NULL AFTER `num_responsable1`;
ALTER TABLE `depots` ADD `modele_client` VARCHAR(1) NOT NULL DEFAULT '1' AFTER `modele_produit_vente`;

ALTER TABLE `grossistes` ADD `email` VARCHAR(255) NULL AFTER `adresse`;
ALTER TABLE `grossistes` ADD `mobile` VARCHAR(255) NULL AFTER `email`;

ALTER TABLE `pgfidelites` ADD `objectif` INT NOT NULL DEFAULT '0' AFTER `equivalance`;
ALTER TABLE `affectation_clients` ADD `categorie_statistique` VARCHAR(2) NULL AFTER `type`;
ALTER TABLE `affectation_clients` ADD `type_client` VARCHAR(255) NULL AFTER `categorie_statistique`;

ALTER TABLE `mouvements` CHANGE `type_chargement` `type_chargement` ENUM('chargement','retour_hier','retourI_hier','DC','chargement_box') CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci NULL DEFAULT NULL;
ALTER TABLE `tournees` ADD `actif_client` VARCHAR(1) NOT NULL DEFAULT '1' AFTER `actif`;
ALTER TABLE `tournees` CHANGE `actif_client` `actif_client` BOOLEAN NOT NULL DEFAULT FALSE;

update tournees set actif_client=actif;



-- ######################################## 05/ 11 / 2024 ##################################
Alter table affectation_synchronisation ADD region_code VARCHAR(255) NULL AFTER zone_code
alter table affectation_synchronisation add FOREIGN key (region_code) references regions(code);

Alter table affectation_synchronisation ADD secteur_code VARCHAR(255) NULL AFTER zone_code;
alter table affectation_synchronisation add FOREIGN key (secteur_code) references secteurs(code);

Alter table affectation_synchronisation ADD gouvernorat_code VARCHAR(255) NULL AFTER zone_code;
alter table affectation_synchronisation add FOREIGN key (gouvernorat_code) references gouvernorats(code);
Alter table affectation_synchronisation ADD delegation_code VARCHAR(255) NULL AFTER zone_code;
alter table affectation_synchronisation add FOREIGN key (delegation_code) references delegations(code);
Alter table affectation_synchronisation ADD localite_code VARCHAR(255) NULL AFTER zone_code;
alter table affectation_synchronisation add FOREIGN key (localite_code) references localites(code);


ALTER TABLE `marques` ADD `superviseur` INT NOT NULL DEFAULT '1' AFTER `image`;
ALTER TABLE `depots` ADD `max_avoir` INT NOT NULL DEFAULT '0' AFTER `max_devis`;
ALTER TABLE `depots` ADD `prefix_devis` VARCHAR(50) NOT NULL DEFAULT 'DV' AFTER `prefix_client`;

ALTER TABLE `parametrages` ADD `bloquerDcSiencours` INT NOT NULL DEFAULT '0' AFTER `postion_automatique`;
ALTER TABLE `parametrages` ADD `min_max_client` INT(20) NOT NULL DEFAULT '0' AFTER `bloquerDcSiencours`;

ALTER TABLE `parametrages` ADD `pin_maps_tournee` ENUM('visites','categories') NOT NULL DEFAULT 'visites' AFTER `min_max_client`;
ALTER TABLE `equipements` CHANGE `marque` `marque` ENUM('Intermec','Honeywell','Thermal','Smart','Honeywell_new','SPRT By Nomadis','SPRT','Delice','Sans remise et ttc') CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci NOT NULL DEFAULT 'Honeywell';
ALTER TABLE `categoriecommercials` ADD `format` ENUM('circle','star','triangle','fleche') NOT NULL DEFAULT 'circle' AFTER `remise_max`;
ALTER TABLE `categoriecommercials` ADD `couleur` VARCHAR(50) NULL AFTER `format`;

ALTER TABLE `parametrages` ADD `affichage_stock_mobile` INT(1) NOT NULL DEFAULT '1' AFTER `pin_maps_tournee`;
ALTER TABLE `parametrages` ADD `choix_tarif` INT NOT NULL DEFAULT '0' AFTER `affichage_stock_mobile`;
ALTER TABLE `parametrages` ADD `choix_date_visite` INT NOT NULL DEFAULT '0' AFTER `choix_tarif`;
ALTER TABLE `parametrages` ADD `search_client` ENUM('like','debut_mot') NOT NULL DEFAULT 'like' AFTER `choix_date_visite`;
ALTER TABLE `parametrages` ADD `default_acces_metrage` INT NOT NULL DEFAULT '0' AFTER `obligation_gps`;

ALTER TABLE `parametrages` ADD `choix_ajouter_grauite_ou_non` INT NOT NULL DEFAULT '0' AFTER `search_client`;
ALTER TABLE `equipements` CHANGE `marque` `marque` ENUM('Intermec','Honeywell','Thermal','Smart','Honeywell_new','SPRT By Nomadis','SPRT','Delice','Sans remise et ttc','MP110') CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci NOT NULL DEFAULT 'Honeywell';

ALTER TABLE `categoriecommercials` ADD `acces_metrage` INT(20) NOT NULL DEFAULT '0' AFTER `couleur`;
ALTER TABLE `produits` ADD `concurrent` INT(1) NOT NULL DEFAULT '0' AFTER `vendable_web`;
update produits set concurrent = '0';
ALTER TABLE `tournees_result` ADD `nombre_clients` INT NOT NULL DEFAULT '0' AFTER `nombre_commande`;
ALTER TABLE `produits` ADD `prix_ht3` FLOAT NOT NULL DEFAULT '0' AFTER `prix_ht2`;
ALTER TABLE `produits` ADD `prix_ttc3` DOUBLE NOT NULL DEFAULT '0' AFTER `prix_ttc2`;
ALTER TABLE `parametrages` ADD `validation_mf_cin` INT NOT NULL DEFAULT '0' AFTER `choix_ajouter_grauite_ou_non`;
ALTER TABLE `parametrages` ADD `vente_seul_mf_cin` INT NOT NULL DEFAULT '0' AFTER `validation_mf_cin`;
ALTER TABLE `depots` ADD `creation_client_bloque` INT NOT NULL DEFAULT '0' AFTER `nombre_impression`;

ALTER TABLE `parametrages` ADD `vente_prospect` ENUM('espece','non','oui') NOT NULL DEFAULT 'oui' AFTER `vente_seul_mf_cin`;
ALTER TABLE `entetecommercials` ADD `cadeaux_annule` BOOLEAN NOT NULL DEFAULT TRUE AFTER `cadeaux_valide`;
ALTER TABLE `depots` ADD `prefix_recouvrement` VARCHAR(30) NULL AFTER `prefix_devis`;

ALTER TABLE `parametrages` ADD `erp` VARCHAR(191) NULL AFTER `langue`;


ALTER TABLE `entete_achat` CHANGE `type` `type` ENUM('bl','facture','commande') CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci NOT NULL DEFAULT 'facture', 
                           CHANGE `ru` `ru` ENUM('achat','casse','dlc','avoir','avoir_financier','retour_Stock','commande','retour','casse_stock','dlc_stock') CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci NOT NULL;

ALTER TABLE `clients` ADD `quartier` ENUM('Populaire','Chic','Moyen') NOT NULL DEFAULT 'Populaire' AFTER `cover`, ADD `superficier` ENUM('moins de 15m','de 15 a 40m','de 40 a 80m','superieure a 80m')  NULL DEFAULT 'de 15 a 40m' AFTER `quartier`;

ALTER TABLE `releve_prix` ADD `fournisseur_code` VARCHAR(255) NULL AFTER `type`;
ALTER TABLE `depots` ADD `liste_produit` ENUM('All','Assortiment') NOT NULL DEFAULT 'All' AFTER `creation_client_bloque`;


ALTER TABLE `entete_achat` ADD `synchronisation_elastic` DATETIME NULL AFTER `ru`;
ALTER TABLE `entete_achat` ADD `validation_admin_elastic` DATETIME NULL AFTER `synchronisation_elastic`;
ALTER TABLE `entete_achat` ADD `date_cloture` DATETIME NULL AFTER `cloture`;

ALTER TABLE `entete_achat` ADD `code_achat` VARCHAR(191) NULL AFTER `code_commande`;

ALTER TABLE `parametrages` ADD `param_commande_partiel` BOOLEAN NOT NULL DEFAULT FALSE AFTER `update_caisse_avoir`;

