Changeset 2387291
- Timestamp:
- 09/23/2020 08:27:29 PM (5 years ago)
- Location:
- perseo-software
- Files:
-
- 13 added
- 5 edited
-
tags/7.0 (added)
-
tags/7.0/LICENSE.txt (added)
-
tags/7.0/PluginPerseo.php (added)
-
tags/7.0/PluginPerseoClientes.php (added)
-
tags/7.0/README.md (added)
-
tags/7.0/includes (added)
-
tags/7.0/includes/PluginPerseo_cargador.php (added)
-
tags/7.0/includes/PluginPerseo_cron.php (added)
-
tags/7.0/includes/PluginPerseo_master.php (added)
-
tags/7.0/js (added)
-
tags/7.0/js/PluginPerseo_combo.js (added)
-
tags/7.0/uninstall.php (added)
-
trunk/PluginPerseo.php (modified) (14 diffs)
-
trunk/PluginPerseoClientes.php (modified) (2 diffs)
-
trunk/README.md (modified) (2 diffs)
-
trunk/includes/PluginPerseo_cron.php (modified) (21 diffs)
-
trunk/includes/PluginPerseo_master.php (modified) (2 diffs)
-
trunk/js/PluginPerseo_cedulas.js (added)
Legend:
- Unmodified
- Added
- Removed
-
perseo-software/trunk/PluginPerseo.php
r2381349 r2387291 4 4 Plugin URI: http://perseo.ec/ 5 5 Description: Este Plugins integra el Sistema Contable Perseo Web y PC con la tienda Woocommerce 6 Version: 6.06 Version: 7.0 7 7 Author: Pegasus Soft S.A. - Ecuador 8 8 Author URI: https://perseo.ec … … 160 160 add_settings_section( 161 161 'sperseo_seccionconfiguracion', 162 ' ConfiguracionPerseo Software',162 'Perseo Software', 163 163 'sperseo_seccionencabezado', 164 164 'pluginperseo_menu' … … 166 166 add_settings_section( 167 167 'sperseo_seccionconfiguracion', 168 'Parametrizacion Producto',168 'Parametrizacion ', 169 169 'sperseo_seccionencabezado1', 170 170 'pluginperseo_submenu' … … 229 229 //Campo seccion 2 parametrizacion 230 230 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( 231 243 'fperseo_campoproductos', 232 244 'Sincronizar Productos', … … 253 265 ); 254 266 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( 255 279 'fperseo_campoclientes', 256 280 'Sincronizar Clientes', … … 264 288 ] 265 289 ); 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 ); 266 304 add_settings_field( 267 305 'fperseo_campopedidos', 268 ' Sincronizar Pedidos',306 'Enviar Pedidos a Perseo', 269 307 'fperseo_pedidos', 270 308 'pluginperseo_submenu', … … 276 314 ] 277 315 ); 316 278 317 add_settings_field( 279 318 'fperseo_campocategorias', … … 288 327 ] 289 328 ); 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 );302 329 303 330 add_settings_field( … … 327 354 add_settings_field( 328 355 'fperseo_campotarifaventa', 329 ' Tarifa de Venta',356 'Precio Normal', 330 357 'fperseo_tarifaventa', 331 358 'pluginperseo_submenu', … … 339 366 add_settings_field( 340 367 'fperseo_campotarifaAumento', 341 ' Tarifa de Aumento',368 'Precio Rebajado', 342 369 'fperseo_tarifaAumento', 343 370 'pluginperseo_submenu', … … 355 382 356 383 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>"; 358 389 359 390 } 360 391 function 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 362 401 } 363 402 … … 423 462 //Campo seccion 2 PRODUCTOS SINCRONIZACION 424 463 464 function 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 } 425 479 function fperseo_productos($args){ 426 480 $perseo_parametros =PERSEOCONFIGPARAMETROS;// parametrizacion … … 453 507 </select >"; 454 508 echo $perseo_html; 509 } 510 function 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; 455 524 } 456 525 function fperseo_clientes($args){ … … 507 576 } 508 577 509 function fperseo_stock($args){ 578 579 580 function fperseo_enviarclientes($args){ 510 581 $perseo_parametros =PERSEOCONFIGPARAMETROS;// parametrizacion 511 582 //condcion si existe valiable los dos puntos caso de sino es valor2=10 ? true : false -
perseo-software/trunk/PluginPerseoClientes.php
r2324476 r2387291 1 1 <?php 2 //Añadimos los campos en una nueva sección de person 2 $version_Plugin ='1.0'; 3 4 define('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 20 function 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' ); ?> <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' ); ?> <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 43 add_action('woocommerce_register_form', 'campos_adicionales_registro_usuario', 10,3); 44 45 46 /////////////////////////////////////////////////////////// 47 ///////////////Validar Campos antes de guardarlos///////// 48 ///////////////////////////////////////////////////////// 49 function 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 70 add_filter( 'woocommerce_registration_errors', 'validar_datos_usuario',10,3 ); 71 72 73 /////////////////////////////////////////////////////////// 74 ////////////////guardar datos //////////////////////////// 75 ///////////////////////////////////////////////////////// 76 77 function 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///////// 3 90 add_action( 'show_user_profile', 'fperseo_agregarcamposseccion' ); 4 91 add_action( 'edit_user_profile', 'fperseo_agregarcamposseccion' ); … … 65 152 } 66 153 154 67 155 ?> -
perseo-software/trunk/README.md
r2374121 r2387291 31 31 == Installation == 32 32 33 1. Upload `PluginPerseo.php` to the `/wp-content/plugins/` directory34 2. Activate the plugin through the 'Plugins' menu in WordPress35 3. Place PluginPerseo in your templates.36 33 37 34 Contact your Perseo Software support. … … 52 49 53 50 == Changelog == 51 52 = 7.0 = 53 * Actualizacion . 54 55 = 6.0 = 56 * Actualizacion . 54 57 55 58 = 5.0 = -
perseo-software/trunk/includes/PluginPerseo_cron.php
r2381459 r2387291 46 46 $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."'"); 47 47 //var_dump( $perseo_arraydetalles); 48 //echo "<br>"; 49 //echo "<br>"; 48 50 foreach($perseo_arraydetalles as $detalPedido) 49 51 { … … 52 54 //codigo del producto de perseo 53 55 $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 56 57 $perseo_CodProdP= unserialize($perseo_DatoCodPro); 57 58 $perseo_DatoIva = $wpdb->get_var("SELECT meta_value FROM {$table_prefix}postmeta where meta_key='PERSEOPORCIVA' and post_id='".$detalPedido->varprod."'"); … … 65 66 //echo $perseo_valor; 66 67 //echo '<br>'; 67 68 $perseo_pedidoiva= ($perseo_DatoIva/100)+1; 69 $perseo_tarifaventapedido=round($perseo_precio * $perseo_pedidoiva); 70 68 71 $perseo_DetalleP = array( 69 72 'pedidosid'=>'', … … 78 81 'preciovisible'=>number_format($detalPedido->product_gross_revenue,3), 79 82 'iva'=>$perseo_DatoIva, 80 'precioiva'=> number_format($detalPedido->product_net_revenue,3),83 'precioiva'=>$perseo_tarifaventapedido, 81 84 'descuento'=>0 82 85 ); … … 96 99 97 100 } 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>'; 98 106 /////////////////////////////////////////////////// 99 107 //cabecera de pedido … … 114 122 'vendedoresid'=>1, 115 123 'tarifasid'=>1, 116 'concepto'=>'PEDIDO WOOCOMMERCE, IMPORTE TOTAL '.$DatPedido->total_sales,124 'concepto'=>'PEDIDO #'.$detalPedido->order_id.' WOOCOMMERCE, IMPORTE TOTAL '.$DatPedido->total_sales, 117 125 'origen'=>'0', 118 126 'documentosid'=>0, 119 'observacion'=>'Pedido Woocomerce ',127 'observacion'=>'Pedido Woocomerce #'.$detalPedido->order_id.', METODO DE PAGO '.$perseo_TipoMetodoPago.' , IMPORTE TOTAL '.$DatPedido->total_sales, 120 128 'subtotalsiniva'=>$perseosubtotalsiniva, 121 129 'subtotalconiva'=>$perseosubtotalconiva, … … 144 152 $perseo_bodypedido = json_encode($perseo_InsertarPedido,true); 145 153 146 //print_r($perseo_bodypedido);154 print_r($perseo_bodypedido); 147 155 148 156 /////////////////////////////////////////// … … 294 302 )) 295 303 ); 304 305 296 306 if (! empty( $perseo_responsecategoria)){ 297 307 $perseo_datosCategoria = json_decode($perseo_responsecategoria['body'],true); //devuelve 298 308 //var_dump($perseo_datosCategoria); 309 //echo "<br>"; 310 $Perseocate=""; 299 311 if(isset($perseo_datosCategoria['categorias'])){ 300 312 $perseo_ConsultaCat=$perseo_datosCategoria['categorias']; 313 $Perseocate='categorias'; 301 314 }; 302 315 if(isset($perseo_datosCategoria['lineas'])){ 303 316 $perseo_ConsultaCat=$perseo_datosCategoria['lineas']; 317 $Perseocate='lineas'; 304 318 }; 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 305 328 ///consulta sin categorizar 306 329 $perseo_Consultaidsincate = $wpdb->get_var("SELECT term.term_id as id FROM {$table_prefix}terms as term where term.name='Sin categorizar'"); … … 325 348 //Consultamos id ultimo 326 349 $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'; 329 352 330 353 if(isset($categoria['productos_lineasid'])){ 331 354 $perseo_idC=$categoria['productos_lineasid']; 332 }else{ 355 }; 356 if(isset($categoria['productos_categoriasid'])){ 333 357 $perseo_idC=$categoria['productos_categoriasid']; 334 358 }; 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 335 366 336 367 $wpdb->insert($table_prefix.'term_taxonomy', … … 338 369 'term_id'=> $perseo_rescate, 339 370 'taxonomy' => 'product_cat', 340 'description'=> $perseo_idC.'-Perseo ',371 'description'=> $perseo_idC.'-Perseo-'.$Perseocate, 341 372 'parent'=> '0', 342 373 'count'=> '0' … … 348 379 } 349 380 } 350 351 public function fperseo_producto(){ 352 381 public function fperseo_impuestos(){ 353 382 global $wpdb; 354 383 global $table_prefix; … … 356 385 $perseo_parametros =get_option('pluginperseo_parametros'); 357 386 358 if ($perseo_parametros['perseo productos']=='SI'){387 if ($perseo_parametros['perseoimpuestos']=='SI'){ 359 388 ///////////////////////////////////// 360 389 //subir tipos de ivas … … 381 410 if (! empty($perseo_responseiva)){ 382 411 $perseo_datosivas = json_decode($perseo_responseiva['body'],true); 383 // print_r($perseo_datosivas);412 //print_r($perseo_datosivas); 384 413 //verificar si existe el producto iva 385 414 foreach($perseo_datosivas['iva'] as $datoiva) { … … 401 430 'tax_rate_priority' => 1, 402 431 'tax_rate_compound' => 0, 403 'tax_rate_shipping' => 1,432 'tax_rate_shipping' => 0, 404 433 'tax_rate_order' => 0, 405 434 'tax_rate_class'=> 'tasa-cero' … … 414 443 'tax_rate_priority' => 1, 415 444 'tax_rate_compound' => 0, 416 'tax_rate_shipping' => 1,445 'tax_rate_shipping' => 0, 417 446 'tax_rate_order' => 0, 418 447 'tax_rate_class'=> '' … … 423 452 } 424 453 }; 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 427 466 ///////////////////////////////////// 428 467 //Verificar pc o web … … 515 554 $wpdb->insert($table_prefix.'postmeta', array('post_id'=> $idPost, 'meta_key' => '_edit_last', 'meta_value'=> '1') ); 516 555 $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 { 517 560 $wpdb->insert($table_prefix.'postmeta', array('post_id'=> $idPost, 'meta_key' => '_tax_status', 'meta_value'=> 'none') ); 561 }; 518 562 $wpdb->insert($table_prefix.'postmeta', array('post_id'=> $idPost, 'meta_key' => '_tax_class', 'meta_value'=> '') ); 519 563 $wpdb->insert($table_prefix.'postmeta', array('post_id'=> $idPost, 'meta_key' => '_manage_stock', 'meta_value'=> 'yes') ); … … 568 612 if($perseo_parametros['perseocategorias']=='productos_lineas_consulta'){ 569 613 //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' "; 571 615 $resProdCat = $wpdb->get_var($sql); 572 616 }; 573 617 574 618 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' "; 576 620 $resProdCat = $wpdb->get_var($sql); 577 621 }; 578 622 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 579 632 $wpdb->insert($table_prefix.'term_relationships',array('object_id' => $idPost,'term_taxonomy_id' => $resProdCat,'term_order'=> '0') ); 580 633 … … 757 810 { 758 811 $perseo_iva= ($producto['porcentajeiva']/100)+1; 759 812 760 813 if($perseo_parametros['perseotarifaVenta']==$tarifa['tarifasid']) 761 814 { 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); 763 817 }; 764 818 //precio 2 765 819 if($perseo_parametros['perseotarifaAumento']==$tarifa['tarifasid']) 766 820 { 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); 768 823 } 769 824 $wpdb->insert($table_prefix.'postmeta', array('post_id'=> $idPost, 'meta_key' => '_price', 'meta_value'=> $perseo_tarifaventa )); //nose … … 1053 1108 if($perseo_parametros['perseotarifaVenta']==$tarifa['tarifasid']) 1054 1109 { 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); 1056 1112 }; 1057 1113 //precio 2 1058 1114 if($perseo_parametros['perseotarifaAumento']==$tarifa['tarifasid']) 1059 1115 { 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); 1061 1118 } 1062 1119 // var_dump($tarifa); … … 1175 1232 } 1176 1233 } 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 } 1177 1404 1178 1405 -
perseo-software/trunk/includes/PluginPerseo_master.php
r2365053 r2387291 34 34 ///Cron 35 35 $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'); 36 37 $this->perseo_cargador->add_action( 'perseo_cron', $this->perseo_cron, 'fperseo_pedidos'); 37 38 $this->perseo_cargador->add_action( 'perseo_cron', $this->perseo_cron, 'fperseo_cliente'); … … 39 40 $this->perseo_cargador->add_action( 'perseo_cron', $this->perseo_cron, 'fperseo_producto'); 40 41 $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 42 44 $this->perseo_cargador->add_action( 'init', $this->perseo_cron, 'fperseo_inicializador'); 43 45 }
Note: See TracChangeset
for help on using the changeset viewer.