Plugin Directory

Changeset 2387291


Ignore:
Timestamp:
09/23/2020 08:27:29 PM (5 years ago)
Author:
perseosoftware
Message:

Actualizaciones Clientes Woocommerce a Perseo

Location:
perseo-software
Files:
13 added
5 edited

Legend:

Unmodified
Added
Removed
  • perseo-software/trunk/PluginPerseo.php

    r2381349 r2387291  
    44Plugin URI: http://perseo.ec/
    55Description: Este Plugins integra el Sistema Contable Perseo Web y PC con la tienda Woocommerce
    6 Version: 6.0
     6Version: 7.0
    77Author: Pegasus Soft S.A. - Ecuador
    88Author URI: https://perseo.ec
     
    160160    add_settings_section(
    161161      'sperseo_seccionconfiguracion',
    162       'Configuracion Perseo Software',
     162      'Perseo Software',
    163163      'sperseo_seccionencabezado',
    164164      'pluginperseo_menu'
     
    166166    add_settings_section(
    167167        'sperseo_seccionconfiguracion',
    168         'Parametrizacion Producto',
     168        'Parametrizacion ',
    169169        'sperseo_seccionencabezado1',
    170170        'pluginperseo_submenu'
     
    229229    //Campo seccion 2 parametrizacion
    230230    add_settings_field(
     231        'fperseo_campoimpuestos',
     232        'Sincronizar Impuestos',
     233        'fperseo_impuestos',
     234        'pluginperseo_submenu',
     235        'sperseo_seccionconfiguracion',
     236        [
     237        'label_for' => 'perseoimpuestos',
     238        'class' => 'clase_campo',
     239        'perseo_datopersonalizado' => 'Valor perseoimpuestos'
     240        ]
     241    );
     242    add_settings_field(
    231243        'fperseo_campoproductos',
    232244        'Sincronizar Productos',
     
    253265    );
    254266    add_settings_field(
     267        'fperseo_campostock',
     268        'Sincronizar Stock',
     269        'fperseo_stock',
     270        'pluginperseo_submenu',
     271        'sperseo_seccionconfiguracion',
     272        [
     273         'label_for' => 'perseostock',
     274         'class' => 'clase_campo',
     275         'perseo_datopersonalizado' => 'Valor perseostock'
     276        ]
     277    );
     278    add_settings_field(
    255279        'fperseo_campoclientes',
    256280        'Sincronizar Clientes',
     
    264288        ]
    265289    );
     290
     291
     292    add_settings_field(
     293        'fperseo_campoenviarclientes',
     294        'Enviar Clientes a Perseo',
     295        'fperseo_enviarclientes',
     296        'pluginperseo_submenu',
     297        'sperseo_seccionconfiguracion',
     298        [
     299         'label_for' => 'perseoenviarclientes',
     300         'class' => 'clase_campo',
     301         'perseo_datopersonalizado' => 'Valor perseoenviarclientes'
     302        ]
     303    );
    266304    add_settings_field(
    267305        'fperseo_campopedidos',
    268         'Sincronizar Pedidos',
     306        'Enviar Pedidos a Perseo',
    269307        'fperseo_pedidos',
    270308        'pluginperseo_submenu',
     
    276314        ]
    277315    );
     316   
    278317    add_settings_field(
    279318        'fperseo_campocategorias',
     
    288327        ]
    289328    );
    290     add_settings_field(
    291         'fperseo_campostock',
    292         'Stock',
    293         'fperseo_stock',
    294         'pluginperseo_submenu',
    295         'sperseo_seccionconfiguracion',
    296         [
    297          'label_for' => 'perseostock',
    298          'class' => 'clase_campo',
    299          'perseo_datopersonalizado' => 'Valor perseostock'
    300         ]
    301     );
    302329
    303330    add_settings_field(
     
    327354    add_settings_field(
    328355        'fperseo_campotarifaventa',
    329         'Tarifa de Venta',
     356        'Precio Normal',
    330357        'fperseo_tarifaventa',
    331358        'pluginperseo_submenu',
     
    339366    add_settings_field(
    340367        'fperseo_campotarifaAumento',
    341         'Tarifa de Aumento',
     368        'Precio Rebajado',
    342369        'fperseo_tarifaAumento',
    343370        'pluginperseo_submenu',
     
    355382
    356383 function sperseo_seccionencabezado(){
    357     echo "<p> Seccion conexion  Perseo Software </p>";
     384    echo "<p><b>Sincronizacion de Perseo Software a WordPress :</b><br> Clientes, Productos, Productos Categorias , Productos Imagenes y  Productos Stock. </p>";
     385    echo "<p><b>Sincronizacion de WordPress a Perseo Software : </b><br> Clientes, Pedidos.</p>";
     386    echo "<p><b>RECOMENDACIONES GENERALES</b> <br>Instalacion previa de WooCommerce en la tienda WordPress. <br> Creacion de Productos desde Perseo Software. <br>Envio de pedidos a Perseo software en estado del pedido en WooCommerce <b>PROCESANDO</b>. <br>Productos imagenes de Perseo Software deben ser fotos cuadradas. Ejemplo 1080x1080px.<br> Carga de Perseo Software el precio Normal sin IVA. </p>";
     387   
     388     echo "<h3> Conexion  Perseo Software </h3>";
    358389         
    359390}
    360391function sperseo_seccionencabezado1(){
    361     echo "<p> Seccion parametrizacion sincronizacion con Perseo Software </p>";
     392   
     393    echo "<p><b>IMPORTANTE </b>Primera vez guardar los datos en <b>NO</b> y minimo en 10 minutos el <b>tiempo de sincronizacion.</b> Una vez sincronizado se recomienda de 30 a 60 minutos.</p>";
     394    echo "<p> Parametrizaciones en el siguiente orden (Activar <b>SI</b>):<br></p>";
     395    echo "<p> 1.-<b>Importante</b> Cargar Impuestos y parametrizar el WooCommerce de acuerdo a como desee mostrar (precio tienda incluido o no impuesto) antes de sincronizar productos.<br></p>";
     396    echo "<p> 2.-Activar sincronizar Perseo productos y productos imagenes (Carga automaticamente <b>Origen de datos (solo se selecciona 1 origen de datos), Productos Existencias y Precios)</b>.<br></p>";
     397    echo "<p> 3.-Activar sincronizar Perseo clientes .<br></p>";
     398    echo "<p> 4.-Activar sincronizar Perseo stock .<br></p>";
     399    echo "<p> 5.-Activar envio de WooCommerce clientes y Pedidos .<br></p>";
     400
    362401}
    363402
     
    423462//Campo seccion 2 PRODUCTOS SINCRONIZACION
    424463
     464function fperseo_impuestos($args){
     465    $perseo_parametros  =PERSEOCONFIGPARAMETROS;// parametrizacion 
     466    //condcion si existe valiable los dos puntos caso de sino es valor2=10 ? true : false
     467    $perseo_selec='selected';
     468    $perseo_refr1= ($perseo_parametros[$args['label_for']] == 'SI' )? $perseo_selec :'' ;
     469    $perseo_refr2= ($perseo_parametros[$args['label_for']] == 'NO' )? $perseo_selec :'' ;
     470
     471    $perseo_parametros[$args['label_for']] = isset($perseo_parametros[$args['label_for']]) ? esc_attr($perseo_parametros[$args['label_for']]):'';
     472   
     473    $perseo_html = "<select  class='{$args['class']}'  data-custom='{$args['perseo_datopersonalizado']}' name='pluginperseo_parametros[{$args['label_for']}]' >
     474    <option value='SI' ".$perseo_refr1." >SI</option>
     475    <option value='NO' ".$perseo_refr2." >NO</option>
     476    </select >";
     477    echo $perseo_html;
     478}
    425479function fperseo_productos($args){
    426480    $perseo_parametros  =PERSEOCONFIGPARAMETROS;// parametrizacion 
     
    453507    </select >";
    454508    echo $perseo_html;
     509}
     510function fperseo_stock($args){
     511    $perseo_parametros  =PERSEOCONFIGPARAMETROS;// parametrizacion
     512    //condcion si existe valiable los dos puntos caso de sino es valor2=10 ? true : false
     513    $perseo_selec='selected';
     514    $perseo_refr1= ($perseo_parametros[$args['label_for']] == 'SI' )? $perseo_selec :'' ;
     515    $perseo_refr2= ($perseo_parametros[$args['label_for']] == 'NO' )? $perseo_selec :'' ;
     516
     517    $perseo_parametros[$args['label_for']] = isset($perseo_parametros[$args['label_for']]) ? esc_attr($perseo_parametros[$args['label_for']]):'';
     518   
     519    $perseo_html = "<select  class='{$args['class']}'  data-custom='{$args['perseo_datopersonalizado']}' name='pluginperseo_parametros[{$args['label_for']}]' >
     520    <option value='SI' ".$perseo_refr1." >SI</option>
     521    <option value='NO' ".$perseo_refr2." >NO</option>
     522    </select >";
     523    echo $perseo_html;
    455524}
    456525function fperseo_clientes($args){
     
    507576}
    508577
    509 function fperseo_stock($args){
     578
     579
     580function fperseo_enviarclientes($args){
    510581    $perseo_parametros  =PERSEOCONFIGPARAMETROS;// parametrizacion
    511582    //condcion si existe valiable los dos puntos caso de sino es valor2=10 ? true : false
  • perseo-software/trunk/PluginPerseoClientes.php

    r2324476 r2387291  
    11<?php
    2 //Añadimos los campos en una nueva sección de person
     2$version_Plugin ='1.0';
     3
     4define('PERSEO_DIR_PATH', plugin_dir_path(__FILE__));
     5////////////////////////////////////////////////////////////////
     6//////Anadir campos Cedula al registro mediante Woocommerce////
     7////// de cedula para guardar  y enviar a perseo       /////
     8/////////////////////////////////////////////////////////////
     9/*
     10<p class="woocommerce-form-row woocommerce-form-row--wide form-row form-row-wide" >
     11        <label for="tipoIdentificacion">Tipo</label>
     12        <select class="woocommerce-Input " id="tipoIdentificacion" name="tipoIdentificacion">
     13        <option  value="C">RUC</option>
     14        <option  value="R">Cedula</option>
     15        <option  value="P">Pasaporte</option>
     16        </select >
     17    </p>
     18*/
     19
     20function campos_adicionales_registro_usuario(){
     21   
     22    $PerseoIdentificacion = (isset($_POST['PerseoIdentificacion'])) ? $_POST['PerseoIdentificacion'] : '';
     23    $PerseoTelefono = (isset($_POST['billing_phone'])) ? $_POST['billing_phone'] : '';
     24    ?>
     25
     26   
     27
     28     <p  class="woocommerce-form-row woocommerce-form-row--wide form-row form-row-wide">
     29     <label ><?php esc_html_e( 'CI / RUC', 'woocommerce' ); ?>&nbsp;<span class="required">*</span></label>
     30        <input type="text" id="PerseoIdentificacion"  name="PerseoIdentificacion"   size="25" value="<?php echo ( ! empty( $_POST['PerseoIdentificacion'] ) ) ? esc_attr( wp_unslash( $_POST['PerseoIdentificacion'] ) ) : ''; ?>" onblur="var cedula = document.getElementById('PerseoIdentificacion').value; if(cedula.length == 13) { var ruc = cedula.substring(0,10); cedula=ruc; } if(cedula.length == 10){ var digito_region = cedula.substring(0,2); if( digito_region >= 1 && digito_region <=24 ){ var ultimo_digito   = cedula.substring(9,10); var pares = parseInt(cedula.substring(1,2)) + parseInt(cedula.substring(3,4)) + parseInt(cedula.substring(5,6)) + parseInt(cedula.substring(7,8));  var numero1 = cedula.substring(0,1);  var numero1 = (numero1 * 2); if( numero1 > 9 ){ var numero1 = (numero1 - 9); }  var numero3 = cedula.substring(2,3);  var numero3 = (numero3 * 2); if( numero3 > 9 ){ var numero3 = (numero3 - 9); } var numero5 = cedula.substring(4,5);  var numero5 = (numero5 * 2);  if( numero5 > 9 ){ var numero5 = (numero5 - 9); }  var numero7 = cedula.substring(6,7);  var numero7 = (numero7 * 2); if( numero7 > 9 ){ var numero7 = (numero7 - 9); } var numero9 = cedula.substring(8,9);  var numero9 = (numero9 * 2);  if( numero9 > 9 ){ var numero9 = (numero9 - 9); }  var impares = numero1 + numero3 + numero5 + numero7 + numero9;  var suma_total = (pares + impares); var primer_digito_suma = String(suma_total).substring(0,1);  var decena = (parseInt(primer_digito_suma) + 1)  * 10;  var digito_validador = decena - suma_total; if(digito_validador == 10) var digito_validador = 0; if(digito_validador == ultimo_digito){  }else{ alert('CI/RUC:' + cedula + ' es incorrecta');  document.getElementById('PerseoIdentificacion').focus();  } } else{  alert('CI/RUC:' + cedula + ' es incorrecta');  document.getElementById('PerseoIdentificacion').focus(); } };">
     31       
     32    </p>
     33
     34    <p class="woocommerce-form-row woocommerce-form-row--wide form-row form-row-wide">
     35    <label for="billing_phone"><?php esc_html_e( 'Telefono', 'woocommerce' ); ?>&nbsp;<span class="required">*</span></label>
     36        <input type="text" id="billing_phone" name="billing_phone" class="woocommerce-Input woocommerce-Input--text input-text" size="25"  value="<?php echo esc_attr($PerseoTelefono);?>">
     37    </p>
     38<?php
     39
     40}
     41//////////////////////////////////////////////////
     42//woocommerce_register_form//Registro en form de woocomerce
     43add_action('woocommerce_register_form', 'campos_adicionales_registro_usuario', 10,3);
     44
     45
     46///////////////////////////////////////////////////////////
     47///////////////Validar Campos antes de guardarlos/////////
     48/////////////////////////////////////////////////////////
     49function validar_datos_usuario($errors, $sanitized_user_login, $user_email){
     50 global $wpdb;
     51 global $table_prefix;
     52    if( empty($_POST['PerseoIdentificacion'])){
     53        $errors->add('PerseoIdentificacion_error', __(' Identificacion no puede estar vacia', 'textdomain'));
     54    } else {
     55        //verificar si ya existe esta cedula
     56        $perseo_IngresoIdent=$wpdb->get_var("SELECT user.user_id as id FROM {$table_prefix}usermeta as user where user.meta_key='PerseoIdentificacion' and user.meta_value like '%".$_POST['PerseoIdentificacion']."%'");
     57        //$errors->add('PerseoIdentificacion_error', __('<strong>Error</strong>: Identificacion ya existe-'.$perseo_IngresoIdent, 'textdomain'));
     58        if ($perseo_IngresoIdent<>""){
     59            $errors->add('PerseoIdentificacion_error', __(' Identificacion ya existe', 'textdomain'));           
     60        }
     61       
     62    }
     63    if( empty($_POST['billing_phone'])){
     64        $errors->add('billing_phone_error', __(' Telefono no puede estar vacia', 'textdomain'));
     65    }
     66    return $errors;
     67  }
     68
     69
     70add_filter( 'woocommerce_registration_errors', 'validar_datos_usuario',10,3 );
     71 
     72
     73///////////////////////////////////////////////////////////
     74////////////////guardar datos ////////////////////////////
     75/////////////////////////////////////////////////////////
     76
     77function guardar_campos_adicionales_usuario($user_id){
     78    if(isset($_POST['PerseoIdentificacion'])){
     79      update_user_meta($user_id, 'PerseoIdentificacion', sanitize_text_field($_POST['PerseoIdentificacion']));
     80    }
     81    if(isset($_POST['billing_phone'])){
     82        update_user_meta($user_id, 'billing_phone', sanitize_text_field($_POST['billing_phone']));
     83      }
     84  }
     85  add_action('user_register', 'guardar_campos_adicionales_usuario');
     86
     87 
     88/////////////////////////////////////////////////////////////
     89//Añadimos los campos en una nueva sección de person/////////
    390add_action( 'show_user_profile', 'fperseo_agregarcamposseccion' );
    491add_action( 'edit_user_profile', 'fperseo_agregarcamposseccion' );
     
    65152}
    66153
     154
    67155?>
  • perseo-software/trunk/README.md

    r2374121 r2387291  
    3131== Installation ==
    3232
    33 1. Upload `PluginPerseo.php` to the `/wp-content/plugins/` directory
    34 2. Activate the plugin through the 'Plugins' menu in WordPress
    35 3. Place PluginPerseo in your templates.
    3633
    3734Contact your Perseo Software support.
     
    5249
    5350== Changelog ==
     51
     52= 7.0 =
     53* Actualizacion .
     54
     55= 6.0 =
     56* Actualizacion .
    5457
    5558= 5.0 =
  • perseo-software/trunk/includes/PluginPerseo_cron.php

    r2381459 r2387291  
    4646                       $perseo_arraydetalles =$wpdb->get_results("SELECT producto.product_id as varprod ,ord.* , producto.* FROM {$table_prefix}wc_order_product_lookup ord , {$table_prefix}wc_product_meta_lookup producto where ord.product_id=producto.product_id and  order_id ='".$DatPedido->codigoPedido."'");
    4747                       //var_dump( $perseo_arraydetalles);
     48                       //echo "<br>";
     49                       //echo "<br>";
    4850                       foreach($perseo_arraydetalles as $detalPedido)
    4951                       {
     
    5254                            //codigo del producto de perseo
    5355                            $perseo_DatoCodPro= $wpdb->get_var("SELECT meta_value FROM {$table_prefix}postmeta where meta_key='_product_attributes' and post_id='".$detalPedido->varprod."'");
    54                             //var_dump($perseo_DatoCodPro);
    55                             //echo '<br>';
     56                           
    5657                            $perseo_CodProdP= unserialize($perseo_DatoCodPro);
    5758                            $perseo_DatoIva = $wpdb->get_var("SELECT meta_value FROM {$table_prefix}postmeta where meta_key='PERSEOPORCIVA' and post_id='".$detalPedido->varprod."'");
     
    6566                            //echo  $perseo_valor;
    6667                            //echo '<br>';
    67                            
     68                            $perseo_pedidoiva= ($perseo_DatoIva/100)+1;
     69                            $perseo_tarifaventapedido=round($perseo_precio * $perseo_pedidoiva);
     70
    6871                                $perseo_DetalleP  =   array(
    6972                                    'pedidosid'=>'',
     
    7881                                    'preciovisible'=>number_format($detalPedido->product_gross_revenue,3),
    7982                                    'iva'=>$perseo_DatoIva,
    80                                     'precioiva'=>number_format($detalPedido->product_net_revenue,3),
     83                                    'precioiva'=>$perseo_tarifaventapedido,
    8184                                    'descuento'=>0
    8285                                );
     
    9699                           
    97100                        }
     101                        //////////////////////////////////
     102                            //tipo de metodo de pago
     103                            $perseo_TipoMetodoPago= $wpdb->get_var("SELECT meta_value FROM {$table_prefix}postmeta where meta_key='_payment_method_title' and post_id='".$DatPedido->codigoPedido."'");
     104                            //echo $perseo_TipoMetodoPago;
     105                            //echo '<br>';
    98106                        ///////////////////////////////////////////////////
    99107                        //cabecera de pedido
     
    114122                                            'vendedoresid'=>1,
    115123                                            'tarifasid'=>1,
    116                                             'concepto'=>'PEDIDO WOOCOMMERCE, IMPORTE TOTAL '.$DatPedido->total_sales,
     124                                            'concepto'=>'PEDIDO #'.$detalPedido->order_id.' WOOCOMMERCE, IMPORTE TOTAL '.$DatPedido->total_sales,
    117125                                            'origen'=>'0',
    118126                                            'documentosid'=>0,
    119                                             'observacion'=>'Pedido Woocomerce',
     127                                            'observacion'=>'Pedido Woocomerce #'.$detalPedido->order_id.', METODO DE PAGO  '.$perseo_TipoMetodoPago.' , IMPORTE TOTAL '.$DatPedido->total_sales,
    120128                                            'subtotalsiniva'=>$perseosubtotalsiniva,
    121129                                            'subtotalconiva'=>$perseosubtotalconiva,
     
    144152                    $perseo_bodypedido = json_encode($perseo_InsertarPedido,true);
    145153
    146                    // print_r($perseo_bodypedido);
     154                   print_r($perseo_bodypedido);
    147155
    148156                    ///////////////////////////////////////////
     
    294302                ))
    295303             );
     304           
     305             
    296306            if (! empty( $perseo_responsecategoria)){   
    297307                $perseo_datosCategoria = json_decode($perseo_responsecategoria['body'],true); //devuelve
    298308                //var_dump($perseo_datosCategoria);
     309                //echo "<br>";
     310                $Perseocate="";
    299311                if(isset($perseo_datosCategoria['categorias'])){
    300312                    $perseo_ConsultaCat=$perseo_datosCategoria['categorias'];
     313                    $Perseocate='categorias';
    301314                };
    302315                if(isset($perseo_datosCategoria['lineas'])){
    303316                    $perseo_ConsultaCat=$perseo_datosCategoria['lineas'];
     317                    $Perseocate='lineas';
    304318                };
     319                if(isset($perseo_datosCategoria['subcategorias'])){
     320                    $perseo_ConsultaCat=$perseo_datosCategoria['subcategorias'];
     321                    $Perseocate='subcategorias';
     322                };
     323                if(isset($perseo_datosCategoria['subgrupo'])){
     324                    $perseo_ConsultaCat=$perseo_datosCategoria['subgrupo'];
     325                    $Perseocate='subgrupo';
     326                };
     327
    305328                ///consulta sin categorizar
    306329                $perseo_Consultaidsincate = $wpdb->get_var("SELECT term.term_id as id FROM {$table_prefix}terms as term where term.name='Sin categorizar'");
     
    325348                                    //Consultamos id ultimo
    326349                                    $perseo_rescate = $wpdb->get_var("SELECT MAX(term_id) FROM {$table_prefix}terms "); 
    327                                     echo  $perseo_rescate;
    328                                     echo '<br';
     350                                    //echo  $perseo_rescate;
     351                                    //echo '<br';
    329352                               
    330353                                    if(isset($categoria['productos_lineasid'])){
    331354                                        $perseo_idC=$categoria['productos_lineasid'];
    332                                     }else{
     355                                    };
     356                                    if(isset($categoria['productos_categoriasid'])){
    333357                                        $perseo_idC=$categoria['productos_categoriasid'];
    334358                                    };
     359                                    if(isset($categoria['productos_subcategoriasid'])){
     360                                      $perseo_idC=$categoria['productos_subcategoriasid'];
     361                                    };
     362                                    if(isset($categoria['productos_subgruposid'])){
     363                                        $perseo_idC=$categoria['productos_subgruposid'];
     364                                      };
     365                                   
    335366
    336367                            $wpdb->insert($table_prefix.'term_taxonomy',
     
    338369                                'term_id'=> $perseo_rescate,
    339370                                'taxonomy'  => 'product_cat',
    340                                 'description'=>  $perseo_idC.'-Perseo',
     371                                'description'=>  $perseo_idC.'-Perseo-'.$Perseocate,
    341372                                'parent'=>  '0',
    342373                                'count'=> '0'
     
    348379        }
    349380    }
    350 
    351     public function fperseo_producto(){
    352        
     381    public function fperseo_impuestos(){
    353382        global $wpdb;       
    354383        global $table_prefix;
     
    356385        $perseo_parametros  =get_option('pluginperseo_parametros');
    357386       
    358         if ($perseo_parametros['perseoproductos']=='SI'){
     387        if ($perseo_parametros['perseoimpuestos']=='SI'){
    359388            /////////////////////////////////////
    360389            //subir tipos de ivas
     
    381410                    if (! empty($perseo_responseiva)){ 
    382411                        $perseo_datosivas = json_decode($perseo_responseiva['body'],true);
    383                        // print_r($perseo_datosivas);
     412                       //print_r($perseo_datosivas);
    384413                        //verificar si existe el producto iva
    385414                        foreach($perseo_datosivas['iva'] as $datoiva) {
     
    401430                                                'tax_rate_priority'  => 1,
    402431                                                'tax_rate_compound'  => 0,
    403                                                 'tax_rate_shipping'  => 1,
     432                                                'tax_rate_shipping'  => 0,
    404433                                                'tax_rate_order'  => 0,
    405434                                                'tax_rate_class'=> 'tasa-cero'
     
    414443                                                'tax_rate_priority'  => 1,
    415444                                                'tax_rate_compound'  => 0,
    416                                                 'tax_rate_shipping'  => 1,
     445                                                'tax_rate_shipping'  => 0,
    417446                                                'tax_rate_order'  => 0,
    418447                                                'tax_rate_class'=> ''
     
    423452                         }
    424453                    };
    425 
    426 
     454        };
     455    }
     456
     457    public function fperseo_producto(){
     458       
     459        global $wpdb;       
     460        global $table_prefix;
     461        $perseo_config      =get_option('pluginperseo_configuracion');
     462        $perseo_parametros  =get_option('pluginperseo_parametros');
     463       
     464        if ($perseo_parametros['perseoproductos']=='SI'){
     465           
    427466            /////////////////////////////////////
    428467            //Verificar pc o web
     
    515554                                                $wpdb->insert($table_prefix.'postmeta', array('post_id'=> $idPost, 'meta_key'  => '_edit_last', 'meta_value'=> '1') );
    516555                                                $wpdb->insert($table_prefix.'postmeta', array('post_id'=> $idPost, 'meta_key'  => 'total_sales', 'meta_value'=> '0') );
     556                                                ///saber si tiene IVA 12 % o 0%
     557                                                if ($producto['porcentajeiva']=='12'){                                                   
     558                                                $wpdb->insert($table_prefix.'postmeta', array('post_id'=> $idPost, 'meta_key'  => '_tax_status', 'meta_value'=> 'taxable') );
     559                                                } else {                                                   
    517560                                                $wpdb->insert($table_prefix.'postmeta', array('post_id'=> $idPost, 'meta_key'  => '_tax_status', 'meta_value'=> 'none') );
     561                                                };
    518562                                                $wpdb->insert($table_prefix.'postmeta', array('post_id'=> $idPost, 'meta_key'  => '_tax_class', 'meta_value'=> '') );
    519563                                                $wpdb->insert($table_prefix.'postmeta', array('post_id'=> $idPost, 'meta_key'  => '_manage_stock', 'meta_value'=> 'yes') );
     
    568612                                                if($perseo_parametros['perseocategorias']=='productos_lineas_consulta'){
    569613                                                    //consultamos categoria x codigo wp_term_taxonomy
    570                                                     $sql= "SELECT term_taxonomy_id  FROM {$table_prefix}term_taxonomy where description = '".$producto['productos_lineasid']."-Perseo' ";
     614                                                    $sql= "SELECT term_taxonomy_id  FROM {$table_prefix}term_taxonomy where description = '".$producto['productos_lineasid']."-Perseo-lineas' ";
    571615                                                    $resProdCat = $wpdb->get_var($sql);
    572616                                                };
    573617
    574618                                                if($perseo_parametros['perseocategorias']=='productos_categorias_consulta') {
    575                                                     $sql= "SELECT term_taxonomy_id  FROM {$table_prefix}term_taxonomy where description = '".$producto['productos_categoriasid']."-Perseo' ";
     619                                                    $sql= "SELECT term_taxonomy_id  FROM {$table_prefix}term_taxonomy where description = '".$producto['productos_categoriasid']."-Perseo-categorias' ";
    576620                                                    $resProdCat = $wpdb->get_var($sql);
    577621                                                };
    578622                                               
     623                                                if($perseo_parametros['perseocategorias']=='productos_subcategorias_consulta') {
     624                                                    $sql= "SELECT term_taxonomy_id  FROM {$table_prefix}term_taxonomy where description = '".$producto['productos_subcategoriasid']."-Perseo-subcategorias' ";
     625                                                    $resProdCat = $wpdb->get_var($sql);
     626                                                };
     627                                                if($perseo_parametros['perseocategorias']=='productos_subgrupos_consulta') {
     628                                                    $sql= "SELECT term_taxonomy_id  FROM {$table_prefix}term_taxonomy where description = '".$producto['productos_subgruposid']."-Perseo-subgrupos' ";
     629                                                    $resProdCat = $wpdb->get_var($sql);
     630                                                };
     631
    579632                                    $wpdb->insert($table_prefix.'term_relationships',array('object_id'  => $idPost,'term_taxonomy_id'  => $resProdCat,'term_order'=> '0') );
    580633                                                   
     
    757810                                                {
    758811                                                    $perseo_iva= ($producto['porcentajeiva']/100)+1;
    759 
     812                                                   
    760813                                                        if($perseo_parametros['perseotarifaVenta']==$tarifa['tarifasid'])
    761814                                                        {
    762                                                             $perseo_tarifaventa=round($tarifa['precio'],2) * $perseo_iva;
     815                                                            //$perseo_tarifaventa=round($tarifa['precio'],2) * $perseo_iva;
     816                                                            $perseo_tarifaventa=round($tarifa['precio'],2);
    763817                                                        };
    764818                                                            //precio 2
    765819                                                        if($perseo_parametros['perseotarifaAumento']==$tarifa['tarifasid'])
    766820                                                        {
    767                                                             $perseo_tarifaaumento =round($tarifa['precio'],2)* $perseo_iva;
     821                                                            //$perseo_tarifaaumento =round($tarifa['precio'],2)* $perseo_iva;
     822                                                            $perseo_tarifaaumento =round($tarifa['precio'],2);
    768823                                                        }
    769824                                                $wpdb->insert($table_prefix.'postmeta', array('post_id'=> $idPost, 'meta_key'  => '_price', 'meta_value'=> $perseo_tarifaventa )); //nose
     
    10531108                                                        if($perseo_parametros['perseotarifaVenta']==$tarifa['tarifasid'])
    10541109                                                        {
    1055                                                             $perseo_tarifaventa=round($tarifa['precio'],2) * $perseo_iva;
     1110                                                            //$perseo_tarifaventa=round($tarifa['precio'],2) * $perseo_iva;
     1111                                                            $perseo_tarifaventa=round($tarifa['precio'],2);
    10561112                                                        };
    10571113                                                            //precio 2
    10581114                                                        if($perseo_parametros['perseotarifaAumento']==$tarifa['tarifasid'])
    10591115                                                        {
    1060                                                             $perseo_tarifaaumento =round($tarifa['precio'],2)* $perseo_iva;
     1116                                                            //$perseo_tarifaaumento =round($tarifa['precio'],2)* $perseo_iva;
     1117                                                            $perseo_tarifaaumento =round($tarifa['precio'],2);
    10611118                                                        }
    10621119                                          //  var_dump($tarifa);
     
    11751232        } 
    11761233    }
     1234
     1235    public function fperseo_enviarclientes(){
     1236
     1237        global $wpdb;       
     1238        global $table_prefix;
     1239        $perseo_config          =get_option('pluginperseo_configuracion');
     1240        $perseo_parametros      =get_option('pluginperseo_parametros');
     1241       
     1242        if ($perseo_parametros['perseoenviarclientes']=='SI'){
     1243
     1244           
     1245            //////////////////////////////////
     1246            //consultamos
     1247            //SELECT DISTINCT(usuario.ID), usuario.*, user.meta_value  FROM {$table_prefix}users as usuario ,  {$table_prefix}usermeta as user  where  usuario.ID=user.user_id and user.meta_key='PerseoIdentificacion'
     1248            $ConsultaclientesWordpress=$wpdb->get_results("SELECT DISTINCT(usuario.ID) as UserID, usuario.*, user.meta_value as identificacion FROM {$table_prefix}users as usuario ,  {$table_prefix}usermeta as user  where  usuario.ID=user.user_id and user.meta_key='PerseoIdentificacion'");
     1249            $Perseo_TipoIdentificacion="";         
     1250            if( ! empty($ConsultaclientesWordpress)){ 
     1251                foreach ($ConsultaclientesWordpress as $Clientes){
     1252                   // echo $Clientes -> identificacion;
     1253                   // echo "<br>";
     1254                   
     1255                    if ($perseo_config['perseotiposoftware']=='WEB'){
     1256                        $perseo_urlcliente ='https://www.perseo.app/api/clientes_consulta';
     1257                    }else{
     1258                        $perseo_urlcliente  =$perseo_config['perseocertificado'].'://'.$perseo_config['perseoip'].'/api/clientes_consulta';       
     1259                    };
     1260                    $perseo_bodycliente= '{"clientes":[ {"clientes":{ "identificacion":"'.$Clientes -> identificacion.'"}}]}';
     1261                   
     1262                    ///////////////////////////////////
     1263                    //ejecutamos y enviamos  el id del prodclienteucto
     1264                    $perseo_responseclient = wp_remote_post($perseo_urlcliente,
     1265                    array(
     1266                        'method'      => 'POST',
     1267                        'timeout'     => 10000,
     1268                        'redirection' => 5,
     1269                        'httpversion' => '1.0',
     1270                        'blocking'    => true,
     1271                        'headers'     => array(           
     1272                            'Usuario'    =>  'Perseo',
     1273                            'Clave'      =>  'Perseo1232*',
     1274                            'DBDatos'    =>  $perseo_config['perseotoken'],
     1275                            'Content-Type'=> 'application/json'
     1276                        ),
     1277                        'body'        => $perseo_bodycliente)
     1278                    );
     1279                    $datoclient = json_decode($perseo_responseclient['body'],true);
     1280                       
     1281                    if (isset($datoclient['fault'])){
     1282                        //echo "NO EXISTE";
     1283                        //echo "<br>";                       
     1284                        //contar caracteres de identificacion                       
     1285                        switch( strlen($Clientes -> identificacion)){
     1286                            case 10:
     1287                                $Perseo_TipoIdentificacion ="C";
     1288                            break;
     1289                            case 13:
     1290                                $Perseo_TipoIdentificacion ="R";
     1291                            break;
     1292                            default:
     1293                                $Perseo_TipoIdentificacion ="P";
     1294                        };
     1295                       
     1296                        //si es vacio realiza el registro en perseo
     1297                        $Perseo_EnviarClie=array(
     1298                            "clientes" => [array(
     1299                                "clientes" => array(
     1300                                    "clientesid"        =>"",
     1301                                    "clientescodigo"    =>"",
     1302                                    "clientes_gruposid" =>1,
     1303                                    "provinciasid"      =>"17",
     1304                                    "ciudadesid"        =>"1701",
     1305                                    "razonsocial"       =>$Clientes -> display_name,
     1306                                    "parroquiasid"      =>"170150",
     1307                                    "clientes_zonasid"  =>1,
     1308                                    "nombrecomercial"   =>"",
     1309                                    "direccion"         =>"",
     1310                                    "identificacion"    =>$Clientes -> identificacion,
     1311                                    "tipoidentificacion"=>$Perseo_TipoIdentificacion,
     1312                                    "email"             =>$Clientes -> user_email,
     1313                                    "telefono1"         =>"",
     1314                                    "telefono2"         =>"",
     1315                                    "telefono3"         =>"",
     1316                                    "tipodestino"       =>"1",
     1317                                    "vendedoresid"      =>3,
     1318                                    "cobradoresid"      =>3,
     1319                                    "creditocupo"       =>0,
     1320                                    "creditodias"       =>0,
     1321                                    "sri_codigo_impuestosiva"=>"",
     1322                                    "sri_codigo_impuestosrenta"=>"312",
     1323                                    "estado"            =>true,
     1324                                    "tarifasid"         =>-1,
     1325                                    "forma_pago_empresaid"=>-1,
     1326                                    "ordenvisita"       =>0,
     1327                                    "latitud"           =>"",
     1328                                    "longitud"          =>"",
     1329                                    "usuariocreacion"   =>"WORDPRESS"
     1330                               
     1331                                )
     1332                            )]
     1333                        );
     1334                        $Perseo_EnviarCli=json_encode($Perseo_EnviarClie,true);
     1335                        //print_r($Perseo_EnviarCli);
     1336                        //echo "<br>";
     1337                        //echo "<br>";
     1338
     1339                        if ($perseo_config['perseotiposoftware']=='WEB'){
     1340                            $perseo_urlclientecrear ='https://www.perseo.app/api/clientes_crear';
     1341                        }else{
     1342                            $perseo_urlclientecrear  =$perseo_config['perseocertificado'].'://'.$perseo_config['perseoip'].'/api/clientes_crear';       
     1343                        };
     1344                        ///////////////////////////////////
     1345                        //ejecutamos y enviamos 
     1346                        $perseo_responseclient = wp_remote_post($perseo_urlclientecrear,
     1347                        array(
     1348                            'method'      => 'POST',
     1349                            'timeout'     => 10000,
     1350                            'redirection' => 5,
     1351                            'httpversion' => '1.0',
     1352                            'blocking'    => true,
     1353                            'headers'     => array(           
     1354                                'Usuario'    =>  'Perseo',
     1355                                'Clave'      =>  'Perseo1232*',
     1356                                'DBDatos'    =>  $perseo_config['perseotoken'],
     1357                                'Content-Type'=> 'application/json'
     1358                            ),
     1359                            'body'        => $Perseo_EnviarCli)
     1360                        );
     1361
     1362                        ////////////////////////////////////
     1363                        //Actualizamos datos de perseo en cliente de worpress
     1364                       
     1365                        $perseo_bodyccliente= '{"clientes":[ {"clientes":{ "identificacion":"'.$Clientes -> identificacion.'"}}]}';
     1366                       
     1367                        ///////////////////////////////////
     1368                        //ejecutamos y enviamos  el id del prodclienteucto
     1369                        $perseo_dresponseclient = wp_remote_post($perseo_urlcliente,
     1370                        array(
     1371                            'method'      => 'POST',
     1372                            'timeout'     => 10000,
     1373                            'redirection' => 5,
     1374                            'httpversion' => '1.0',
     1375                            'blocking'    => true,
     1376                            'headers'     => array(           
     1377                                'Usuario'    =>  'Perseo',
     1378                                'Clave'      =>  'Perseo1232*',
     1379                                'DBDatos'    =>  $perseo_config['perseotoken'],
     1380                                'Content-Type'=> 'application/json'
     1381                            ),
     1382                            'body'        => $perseo_bodyccliente)
     1383                        );
     1384                       
     1385                        if (! empty($perseo_dresponseclient)){
     1386                            $perseo_datosCliente = json_decode($perseo_dresponseclient['body'],true); //devuelve
     1387                            var_dump($perseo_datosCliente);
     1388                            //Actualizamos datos
     1389                            $Perseo_IDUSU=$Clientes -> UserID;
     1390                            $Perseo_COUSU = $perseo_datosCliente['clientes'][0]['clientescodigo'];
     1391                            $Perseo_USU = $perseo_datosCliente['clientes'][0]['clientesid'];
     1392                           
     1393                            $wpdb->insert($table_prefix.'usermeta', array('user_id' => $Perseo_IDUSU,'meta_key'=>'PerseoCodigo','meta_value'=>$Perseo_COUSU));
     1394                            $wpdb->insert($table_prefix.'usermeta', array('user_id' => $Perseo_IDUSU,'meta_key'=>'PerseoID','meta_value'=>$Perseo_USU));
     1395                           
     1396                               
     1397                        }
     1398                    }
     1399                }
     1400            }
     1401        }
     1402           
     1403    }
    11771404   
    11781405   
  • perseo-software/trunk/includes/PluginPerseo_master.php

    r2365053 r2387291  
    3434        ///Cron
    3535        $this->perseo_cargador->add_action( 'cron_schedules', $this->perseo_cron, 'fperseo_intervalos'); 
     36        $this->perseo_cargador->add_action( 'perseo_cron', $this->perseo_cron, 'fperseo_impuestos');
    3637        $this->perseo_cargador->add_action( 'perseo_cron', $this->perseo_cron, 'fperseo_pedidos');
    3738        $this->perseo_cargador->add_action( 'perseo_cron', $this->perseo_cron, 'fperseo_cliente');
     
    3940        $this->perseo_cargador->add_action( 'perseo_cron', $this->perseo_cron, 'fperseo_producto');
    4041        $this->perseo_cargador->add_action( 'perseo_cron', $this->perseo_cron, 'fperseo_stockproducto');
    41        
     42        $this->perseo_cargador->add_action( 'perseo_cron', $this->perseo_cron, 'fperseo_enviarclientes');
     43
    4244        $this->perseo_cargador->add_action( 'init', $this->perseo_cron, 'fperseo_inicializador');
    4345    }
Note: See TracChangeset for help on using the changeset viewer.