<?php

$campo1 = "c_id";
$campo2 = "c_descripcion";
$campo3 = "c_contacto";
$campo4 = "c_nom_comercial";
$campo5 = "c_direccion";
$campo6 = "c_telefono";
$campo7 = "c_fax";
$campo8 = "c_correo";
$campo9 = "c_web";
$campo10 = "c_idfiscal";
$campo11 = "c_dias_credito";
$campo12 = "c_limite_credito";
$campo13 = "c_termino";
$campo14 = "c_activo";
$campo15 = "c_notas";
$campo16 = "c_vendedor";
$campo17 = "pa_id";
$campo18 = "ciu_id";
$campo19 = "nom_fiscal_id";
$campo20 = "id_contribuyente";
$campo21 = "c_creacion";
$campo22 = "c_modificacion";
$campo23 = "c_u_id_crea";
$campo24 = "c_u_id_mod";
$campo25 = "c_envia_email";
$campo26 = "c_credito";
$campo27 = "c_desc";
$campo28 = "suc_id";
$campo29 = "c_precio";
$campo30 = "cat_id";
$campo31 = "c_apart";
$campo32 = "user";
$campo33 = "pass";
$campo34 = "c_observ";
$campo35 = "c_pagcxc";
$campo36 = "c_pagacxc";
$campo37 = "c_nccxc";
$campo38 = "c_ndcxc";
$campo39 = "c_factcxc";
$campo40 = "c_usuar_trans";
//$campo41="id_autoinc";
$campo42 = "c_contacto2";
$campo43 = "c_contacto3";
$campo44 = "c_contacto4";
$campo45 = "c_exclusiv_cont";
$campo46 = "c_contacto5";
$campo47 = "c_contacto6";
$campo48 = "c_contacto7";
$campo49 = "c_contacto8";
$campo50 = "c_contacto9";
$campo51 = "c_contacto10";
$campo52 = "c_ced1";
$campo53 = "c_ced2";
$campo54 = "c_ced3";
$campo55 = "c_ced4";
$campo56 = "c_ced5";
$campo57 = "c_ced6";
$campo58 = "c_ced7";
$campo59 = "c_ced8";
$campo60 = "c_ced9";
$campo61 = "c_ced10";
$campo62 = "c_telef1";
$campo63 = "c_telef2";
$campo64 = "c_telef3";
$campo65 = "c_telef4";
$campo66 = "c_telef5";
$campo67 = "c_telef6";
$campo68 = "c_telef7";
$campo69 = "c_telef8";
$campo70 = "c_telef9";
$campo71 = "c_telef10";
$campo72 = "c_web1";
$campo73 = "c_web2";
$campo74 = "c_web3";
$campo75 = "c_web4";
$campo76 = "c_web5";
$campo77 = "c_web6";
$campo78 = "c_web7";
$campo79 = "c_web8";
$campo80 = "c_web9";
$campo81 = "c_web10";
$campo82 = "c_ul_compra";
$campo83 = "c_recarg_mora";
$campo84 = "w_prod";
$campo85 = "w_prom";
$campo86 = "w_est_c";
$campo87 = "w_opc";
$campo88 = "w_fisc";
$campo89 = "cor_inf";
$campo90 = "otros";
$campo91 = "c_prospect";
$campo92 = "wadmin";
$campo93 = "c_contacto_fech_cumple1";
$campo94 = "c_contacto_fech_cumple2";
$campo95 = "c_contacto_fech_cumple3";
$campo96 = "c_contacto_fech_cumple4";
$campo97 = "c_contacto_fech_cumple5";
$campo98 = "c_contacto_fech_cumple6";
$campo99 = "c_contacto_fech_cumple7";
$campo100 = "c_contacto_fech_cumple8";
$campo101 = "c_contacto_fech_cumple9";
$campo102 = "c_contacto_fech_cumple10";
$campo103 = "c_contacto_img1";
$campo104 = "c_contacto_img2";
$campo105 = "c_contacto_img3";
$campo106 = "c_contacto_img4";
$campo107 = "c_contacto_img5";
$campo108 = "c_contacto_img6";
$campo109 = "c_contacto_img7";
$campo110 = "c_contacto_img8";
$campo111 = "c_contacto_img9";
$campo112 = "c_contacto_img10";
$campo113 = "c_hist_vta_cont";
$campo114 = "SyncProcesing";
$campo115 = "UserModify";
$campo116 = "UserOption";
$campo117 = "pa_descripcion";
$campo118 = "pa_activo";
$campo119 = "etiq_id";
$campo120 = "cod_pais";
$campo121 = "des_ciudad";
$campo122 = "ciu_activo";
$campo123 = "det_ciudad";
$campo124 = "pr_ubicacion";
$campo125 = "id_pack";

$campo126 = "c_ref2";
$campo127 = "c_ref3";
$campo128 = "c_club";
$campo129 = "cliente_pre_pago";
$campo130 = "c_acumpuntos";
$campo131 = "c_afiliado";


$valor = $campo1 . "," .
$campo2 . "," .
$campo3 . "," .
$campo4 . "," .
$campo5 . "," .
$campo6 . "," .
$campo7 . "," .
$campo8 . "," .
$campo9 . "," .
$campo10 . "," .
$campo11 . "," .
$campo12 . "," .
$campo13 . "," .
$campo14 . "," .
$campo15 . "," .
$campo16 . "," .
$campo17 . "," .
$campo18 . "," .
$campo19 . "," .
$campo20 . "," .
$campo21 . "," .
$campo22 . "," .
$campo23 . "," .
$campo24 . "," .
$campo25 . "," .
$campo26 . "," .
$campo27 . "," .
$campo28 . "," .
$campo29 . "," .
$campo30 . "," .
$campo31 . "," .
$campo32 . "," .
$campo33 . "," .
$campo34 . "," .
$campo35 . "," .
$campo36 . "," .
$campo37 . "," .
$campo38 . "," .
$campo39 . "," .
$campo40 . "," .
//$campo41    . "," .
$campo42 . "," .
    $campo43 . "," .
    $campo44 . "," .
    $campo45 . "," .
    $campo46 . "," .
    $campo47 . "," .
    $campo48 . "," .
    $campo49 . "," .
    $campo50 . "," .
    $campo51 . "," .
    $campo52 . "," .
    $campo53 . "," .
    $campo54 . "," .
    $campo55 . "," .
    $campo56 . "," .
    $campo57 . "," .
    $campo58 . "," .
    $campo59 . "," .
    $campo60 . "," .
    $campo61 . "," .
    $campo62 . "," .
    $campo63 . "," .
    $campo64 . "," .
    $campo65 . "," .
    $campo66 . "," .
    $campo67 . "," .
    $campo68 . "," .
    $campo69 . "," .
    $campo70 . "," .
    $campo71 . "," .
    $campo72 . "," .
    $campo73 . "," .
    $campo74 . "," .
    $campo75 . "," .
    $campo76 . "," .
    $campo77 . "," .
    $campo78 . "," .
    $campo79 . "," .
    $campo80 . "," .
    $campo81 . "," .
    $campo82 . "," .
    $campo83 . "," .
    $campo84 . "," .
    $campo85 . "," .
    $campo86 . "," .
    $campo87 . "," .
    $campo88 . "," .
    $campo89 . "," .
    $campo90 . "," .
    $campo91 . "," .
    $campo92 . "," .
    $campo93 . "," .
    $campo94 . "," .
    $campo95 . "," .
    $campo96 . "," .
    $campo97 . "," .
    $campo98 . "," .
    $campo99 . ","
    . $campo100 . ","
    . $campo101 . ","
    . $campo102 . ","
    . $campo103 . ","
    . $campo104 . ","
    . $campo105 . ","
    . $campo106 . ","
    . $campo107 . ","
    . $campo108 . ","
    . $campo109 . ","
    . $campo110 . ","
    . $campo111 . ","
    . $campo112 . ","
    . $campo113 . ","
    . $campo114 . ","
    . $campo115 . ","
    . $campo116 . ","
    . $campo126 . ","
    . $campo127 . ","
    . $campo128 . ","
    . $campo129 . ","
    . $campo130 . ","
    . $campo131;

$db_destino = $database;
$tabla_dest = "clientes";
$db_tmp = "tmp";

$llave = "c_id";

$sqlop1 = "update  " . $db_destino . "." . $tabla_dest . ", ( select "
. $valor . " from " . $db_tmp . "." . $_SESSION['unico'] . " "
. " where " . $db_tmp . "." . $_SESSION['unico'] . "." . $llave
. "  in (select " . $db_destino . "." . $tabla_dest . "."
. $llave . " from " . $db_destino . "." . $tabla_dest
. "  where " . $llave . " is not null  ) )b " . " set "

. $tabla_dest . "." . $campo2 . "=b." . $campo2 . ",  "
. $tabla_dest . "." . $campo3 . "=b." . $campo3 . ",  "
. $tabla_dest . "." . $campo4 . "=b." . $campo4 . ",  "
. $tabla_dest . "." . $campo5 . "=b." . $campo5 . ",  "
. $tabla_dest . "." . $campo6 . "=b." . $campo6 . ",  "
. $tabla_dest . "." . $campo7 . "=b." . $campo7 . ",  "
. $tabla_dest . "." . $campo8 . "=b." . $campo8 . ",  "
. $tabla_dest . "." . $campo9 . "=b." . $campo9 . ",  "
. $tabla_dest . "." . $campo10 . "=b." . $campo10 . ",  "
. $tabla_dest . "." . $campo11 . "=b." . $campo11 . ",  "
. $tabla_dest . "." . $campo12 . "=b." . $campo12 . ",  "
. $tabla_dest . "." . $campo13 . "=b." . $campo13 . ",  "
. $tabla_dest . "." . $campo14 . "=b." . $campo14 . ",  "
. $tabla_dest . "." . $campo15 . "=b." . $campo15 . ",  "
. $tabla_dest . "." . $campo16 . "=b." . $campo16 . ",  "
. $tabla_dest . "." . $campo17 . "=b." . $campo17 . ",  "
. $tabla_dest . "." . $campo18 . "=b." . $campo18 . ",  "
. $tabla_dest . "." . $campo19 . "=b." . $campo19 . ",  "
. $tabla_dest . "." . $campo20 . "=b." . $campo20 . ",  "
. $tabla_dest . "." . $campo21 . "=b." . $campo21 . ",  "
. $tabla_dest . "." . $campo22 . "=b." . $campo22 . ",  "
. $tabla_dest . "." . $campo23 . "=b." . $campo23 . ",  "
. $tabla_dest . "." . $campo24 . "=b." . $campo24 . ",  "
. $tabla_dest . "." . $campo25 . "=b." . $campo25 . ",  "
. $tabla_dest . "." . $campo26 . "=b." . $campo26 . ",  "
. $tabla_dest . "." . $campo27 . "=b." . $campo27 . " ,"

. $tabla_dest . "." . $campo28 . "=b." . $campo28 . ",  "
. $tabla_dest . "." . $campo29 . "=b." . $campo29 . ",  "
. $tabla_dest . "." . $campo30 . "=b." . $campo30 . ",  "
. $tabla_dest . "." . $campo31 . "=b." . $campo31 . ",  "
. $tabla_dest . "." . $campo32 . "=b." . $campo32 . ",  "
. $tabla_dest . "." . $campo33 . "=b." . $campo33 . ",  "
. $tabla_dest . "." . $campo34 . "=b." . $campo34 . ",  "
. $tabla_dest . "." . $campo35 . "=b." . $campo35 . ",  "
. $tabla_dest . "." . $campo36 . "=b." . $campo36 . ",  "
. $tabla_dest . "." . $campo37 . "=b." . $campo37 . ",  "
. $tabla_dest . "." . $campo38 . "=b." . $campo38 . ",  "
. $tabla_dest . "." . $campo39 . "=b." . $campo39 . ",  "
. $tabla_dest . "." . $campo40 . "=b." . $campo40 . ",  "
//. $tabla_dest . "." .    $campo41    . "=b." .    $campo41    . ",  "
 . $tabla_dest . "." . $campo42 . "=b." . $campo42 . ",  "
    . $tabla_dest . "." . $campo43 . "=b." . $campo43 . ",  "
    . $tabla_dest . "." . $campo44 . "=b." . $campo44 . ",  "
    . $tabla_dest . "." . $campo45 . "=b." . $campo45 . ",  "
    . $tabla_dest . "." . $campo46 . "=b." . $campo46 . ",  "
    . $tabla_dest . "." . $campo47 . "=b." . $campo47 . ",  "
    . $tabla_dest . "." . $campo48 . "=b." . $campo48 . ",  "
    . $tabla_dest . "." . $campo49 . "=b." . $campo49 . ",  "
    . $tabla_dest . "." . $campo50 . "=b." . $campo50 . ",  "
    . $tabla_dest . "." . $campo51 . "=b." . $campo51 . ",  "
    . $tabla_dest . "." . $campo52 . "=b." . $campo52 . ",  "
    . $tabla_dest . "." . $campo53 . "=b." . $campo53 . ",  "
    . $tabla_dest . "." . $campo54 . "=b." . $campo54 . ",  "
    . $tabla_dest . "." . $campo55 . "=b." . $campo55 . ",  "
    . $tabla_dest . "." . $campo56 . "=b." . $campo56 . ",  "
    . $tabla_dest . "." . $campo57 . "=b." . $campo57 . ",  "
    . $tabla_dest . "." . $campo58 . "=b." . $campo58 . ",  "
    . $tabla_dest . "." . $campo59 . "=b." . $campo59 . ",  "
    . $tabla_dest . "." . $campo60 . "=b." . $campo60 . ",  "
    . $tabla_dest . "." . $campo61 . "=b." . $campo61 . ",  "
    . $tabla_dest . "." . $campo62 . "=b." . $campo62 . ",  "
    . $tabla_dest . "." . $campo63 . "=b." . $campo63 . ",  "
    . $tabla_dest . "." . $campo64 . "=b." . $campo64 . ",  "
    . $tabla_dest . "." . $campo65 . "=b." . $campo65 . ",  "
    . $tabla_dest . "." . $campo66 . "=b." . $campo66 . ",  "
    . $tabla_dest . "." . $campo67 . "=b." . $campo67 . ",  "
    . $tabla_dest . "." . $campo68 . "=b." . $campo68 . ",  "
    . $tabla_dest . "." . $campo69 . "=b." . $campo69 . ",  "
    . $tabla_dest . "." . $campo70 . "=b." . $campo70 . ",  "
    . $tabla_dest . "." . $campo71 . "=b." . $campo71 . ",  "
    . $tabla_dest . "." . $campo72 . "=b." . $campo72 . ",  "
    . $tabla_dest . "." . $campo73 . "=b." . $campo73 . ",  "
    . $tabla_dest . "." . $campo74 . "=b." . $campo74 . ",  "
    . $tabla_dest . "." . $campo75 . "=b." . $campo75 . ",  "
    . $tabla_dest . "." . $campo76 . "=b." . $campo76 . ",  "
    . $tabla_dest . "." . $campo77 . "=b." . $campo77 . ",  "
    . $tabla_dest . "." . $campo78 . "=b." . $campo78 . ",  "
    . $tabla_dest . "." . $campo79 . "=b." . $campo79 . ",  "
    . $tabla_dest . "." . $campo80 . "=b." . $campo80 . ",  "
    . $tabla_dest . "." . $campo81 . "=b." . $campo81 . ",  "
    . $tabla_dest . "." . $campo82 . "=b." . $campo82 . ",  "
    . $tabla_dest . "." . $campo83 . "=b." . $campo83 . ",  "
    . $tabla_dest . "." . $campo84 . "=b." . $campo84 . ",  "
    . $tabla_dest . "." . $campo85 . "=b." . $campo85 . ",  "
    . $tabla_dest . "." . $campo86 . "=b." . $campo86 . ",  "
    . $tabla_dest . "." . $campo87 . "=b." . $campo87 . ",  "
    . $tabla_dest . "." . $campo88 . "=b." . $campo88 . ",  "
    . $tabla_dest . "." . $campo89 . "=b." . $campo89 . ",  "
    . $tabla_dest . "." . $campo90 . "=b." . $campo90 . ",  "
    . $tabla_dest . "." . $campo91 . "=b." . $campo91 . ",  "
    . $tabla_dest . "." . $campo92 . "=b." . $campo92 . ",  "
    . $tabla_dest . "." . $campo93 . "=b." . $campo93 . ",  "
    . $tabla_dest . "." . $campo94 . "=b." . $campo94 . ",  "
    . $tabla_dest . "." . $campo95 . "=b." . $campo95 . ",  "
    . $tabla_dest . "." . $campo96 . "=b." . $campo96 . ",  "
    . $tabla_dest . "." . $campo97 . "=b." . $campo97 . ",  "
    . $tabla_dest . "." . $campo98 . "=b." . $campo98 . ",  "
    . $tabla_dest . "." . $campo99 . "=b." . $campo99 . ",  "
    . $tabla_dest . "." . $campo100 . "=b." . $campo100 . ",  "
    . $tabla_dest . "." . $campo101 . "=b." . $campo101 . ",  "
    . $tabla_dest . "." . $campo102 . "=b." . $campo102 . ",  "
    . $tabla_dest . "." . $campo103 . "=b." . $campo103 . ",  "
    . $tabla_dest . "." . $campo104 . "=b." . $campo104 . ",  "
    . $tabla_dest . "." . $campo105 . "=b." . $campo105 . ",  "
    . $tabla_dest . "." . $campo106 . "=b." . $campo106 . ",  "
    . $tabla_dest . "." . $campo107 . "=b." . $campo107 . ",  "
    . $tabla_dest . "." . $campo108 . "=b." . $campo108 . ",  "
    . $tabla_dest . "." . $campo109 . "=b." . $campo109 . ",  "
    . $tabla_dest . "." . $campo110 . "=b." . $campo110 . ",  "
    . $tabla_dest . "." . $campo111 . "=b." . $campo111 . ",  "
    . $tabla_dest . "." . $campo112 . "=b." . $campo112 . ",  "
    . $tabla_dest . "." . $campo113 . "=b." . $campo113 . ",  "
    . $tabla_dest . "." . $campo114 . "=b." . $campo114 . ",  "
    . $tabla_dest . "." . $campo115 . "=b." . $campo115 . ",  "

    . $tabla_dest . "." . $campo116 . "=b." . $campo116 . ",  "

    . $tabla_dest . "." . $campo126 . "=b." . $campo126 . ",  "
    . $tabla_dest . "." . $campo127 . "=b." . $campo127 . ",  "
    . $tabla_dest . "." . $campo128 . "=b." . $campo128 . ",  "
    . $tabla_dest . "." . $campo129 . "=b." . $campo129 . ",  "
    . $tabla_dest . "." . $campo130 . "=b." . $campo130 . ",  "

    . $tabla_dest . "." . $campo131 . "=b." . $campo131 .

    " where "
    . $tabla_dest . "." . $llave . "=b." . $llave;

$sqlop2 = "insert into " . $db_destino . "." . $tabla_dest . " ( "
    . $valor . ") select " . $valor . " from " . $db_tmp . "."
    . $_SESSION['unico'] . " on duplicate  key update 
    c_descripcion=values(c_descripcion),
   c_contacto=values(c_contacto),
   c_nom_comercial=values(c_nom_comercial),
   c_direccion=values(c_direccion),
   c_telefono=values(c_telefono),
   c_fax=values(c_fax),
   c_correo=values(c_correo),
   c_web=values(c_web),
   c_idfiscal=values(c_idfiscal),
   c_dias_credito=values(c_dias_credito),
   c_limite_credito=values(c_limite_credito),
   c_termino=values(c_termino),
   c_activo=values(c_activo),
   c_notas=values(c_notas),
   c_vendedor=values(c_vendedor),
   pa_id=values(pa_id),
   ciu_id=values(ciu_id),
   nom_fiscal_id=values(nom_fiscal_id),
   id_contribuyente=values(id_contribuyente),
   c_creacion=values(c_creacion),
   c_modificacion=values(c_modificacion),
   c_u_id_crea=values(c_u_id_crea),
   c_u_id_mod=values(c_u_id_mod),
   c_envia_email=values(c_envia_email),
   c_credito=values(c_credito),
   c_desc=values(c_desc),
   suc_id=values(suc_id),
   c_precio=values(c_precio),
   cat_id=values(cat_id),
   c_apart=values(c_apart),
   user=values(user),
   pass=values(pass),
   c_observ=values(c_observ),
   c_pagcxc=values(c_pagcxc),
   c_pagacxc=values(c_pagacxc),
   c_nccxc=values(c_nccxc),
   c_ndcxc=values(c_ndcxc),
   c_factcxc=values(c_factcxc),
   c_usuar_trans=values(c_usuar_trans),
   c_exclusiv_cont=values(c_exclusiv_cont),
   c_ced1=values(c_ced1),
   c_telef1=values(c_telef1),
   c_web1=values(c_web1),
   c_ul_compra=values(c_ul_compra),
   c_recarg_mora=values(c_recarg_mora),
   w_prod=values(w_prod),
   w_prom=values(w_prom),
   w_est_c=values(w_est_c),
   w_opc=values(w_opc),
   w_fisc=values(w_fisc),
   cor_inf=values(cor_inf),
   otros=values(otros),
   c_prospect=values(c_prospect),
   wadmin=values(wadmin),
   c_contacto_fech_cumple1=values(c_contacto_fech_cumple1),
   c_contacto_img1=values(c_contacto_img1),
   c_hist_vta_cont=values(c_hist_vta_cont),
   c_ref2=values(c_ref2),
   c_ref3=values(c_ref3),
   c_club=values(c_club),
   cliente_pre_pago=values(cliente_pre_pago),
   c_acumpuntos=values(c_acumpuntos),
   c_afiliado=values(c_afiliado)";

?>
