1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
| SET @propal_ref='eee';
SET @fk_soc=2;
SET @fk_projet=0;
SET @fk_propal=num_fk_propale; :*/parametre de la procedure/*
set @id=(select max(rowid)+1 from llx_commande); /* rowid de la ligne commande*/
/* a inserer dans llx_commande*/
start transaction;
INSERT INTO llx_commande
(ref,entity,ref_ext,ref_int,ref_client,
fk_soc,fk_projet,tms,date_creation,date_commande,fk_user_author,fk_statut,
remise_percent,remise_absolue,remise,tva,localtax1,localtax2,
total_ht,total_ttc,note,note_public,
model_pdf,facture,fk_account,fk_currency,fk_cond_reglement,fk_mode_reglement,date_livraison,
fk_availability,fk_demand_reason,fk_adresse_livraison,fk_propale)
SELECT
concat('(Prov', @id ,')'),entity,ref_ext,ref_int,concat(ref_client,' ',@propal_ref),
fk_soc,fk_projet,now(),now(),now(),1,0,
remise_percent,remise_absolue,remise,tva,localtax1,localtax2,
total_ht,total,concat(note,' ref propal :',@propal_ref),note_public,
'einstein',0,fk_account,fk_currency,fk_cond_reglement,fk_mode_reglement,date_livraison,
fk_availability,fk_demand_reason,fk_adresse_livraison,@fk_propal
FROM `llx_propal` WHERE rowid=@fk_propal;
commit;
/* a inserer dans llx_commandedet */
start transaction;
INSERT INTO llx_commandedet
(fk_commande,fk_product,description,tva_tx,localtax1_tx,localtax2_tx,qty ,
remise_percent, remise ,fk_remise_except,price,subprice,
total_ht,total_tva,total_localtax1,total_localtax2,total_ttc,product_type, info_bits,special_code, rang)
SELECT
@id , fk_product,description,tva_tx,localtax1_tx,localtax2_tx,qty ,
remise_percent, remise ,fk_remise_except,price,subprice,
total_ht,total_tva,total_localtax1,total_localtax2,total_ttc,product_type, info_bits,special_code, rang
FROM llx_propaldet WHERE fk_propal= @fk_propal ;
commit; |
Partager