<?php
$xempr=$_GET['empr'];
$tipo=$_GET['tipo'];
$user_codigo='CJ_clave';

echo '*** CJ Genera DB';
include('php_gene1.php');
include('php_data1.php'); 
include('reset0.php'); 


if(empty($tipo)){$tipo=9;}


if($xempr==''){$empr_array=explode('.',$cias);}
if($xempr!=''){$empr_array=array($xempr);}
echo var_dump($empr_array); 

for($iempr=0; $iempr<count($empr_array); $iempr++)
{
  $link_vcrx='';
  $_SESSION['link_vcrx']='' ;   
  $empr_codi=substr(trim($empr_array[$iempr]),0,4);
	chdir('../'.$empr_codi.'/_lib');
	include('../_cfg/config.php');
  
	echo '***********';
	echo '<br>';
	echo 'EMPR: '.$empr_codi;
	echo '==>';

  $colafter='';
	echo '<br>';

     
     
/// regulariza liquidaion de compra a FP03
{
msql_query('update docu0 set docu_status="X" where docu_codigo="FP11"',$link_vcrx);   
     
msql_query('update comp1 set docu="FP03" where docu="FP11"',$link_vcrx);   
msql_query('update cont1 set docu="FP03" where docu="FP11"',$link_vcrx);  
     
msql_query('update caja2 set docum="FP03" where docum="FP11"',$link_vcrx);   
msql_query('update bcos2 set docum="FP03" where docum="FP11"',$link_vcrx);   
msql_query('update retp2 set docum="FP03" where docum="FP11"',$link_vcrx);   
msql_query('update cont2 set docum="FP03" where docum="FP11"',$link_vcrx);   
}
     
   
msql_query('update cair0 set cair_porc=1.75 where cair_codigo="312"',$link_vcrx);   
msql_query('insert into modu0(modu_codigo,modu_descri)value("SRI1","S.R.I.")',$link_vcrx);   
//    get_rime($cfg_ruc);
//    get_agret($cfg_ruc);
//    set_cair("351",0,"REGIMEN MICROEMPRESARIAL");
set_cair("351",1.75,"REGIMEN MICROEMPRESARIAL");   
		set_docu("ATRZ","PARA","atrz","AUTORIZACIONES");
		set_docu("MRCA","MAES","mrca","MARCAS");
		set_docu("PAYT","MAES","payt","PAGOS TARJETA");

     
// vrsettab0('ppho',16);
vrsettab0('payt',16);
     
  $tabla='payt';
  $tabla0=$tabla.'0';
			$colafter=vrsetcolu($tabla0,$tabla.'_transaction','varchar(10)',$colafter,'');
			$colafter=vrsetcolu($tabla0,$tabla.'_authorization','varchar(10)',$colafter,'');
			$colafter=vrsetcolu($tabla0,$tabla.'_cardtype','varchar(6)',$colafter,'');
			$colafter=vrsetcolu($tabla0,$tabla.'_cardbrand','varchar(15)',$colafter,'');
			$colafter=vrsetcolu($tabla0,$tabla.'_amount','decimal(9,2)',$colafter,'');
			$colafter=vrsetcolu($tabla0,$tabla.'_response','text',$colafter,'');
			$colafter=vrsetcolu($tabla0,$tabla.'_response','text',$colafter,'');

  $tabla='enti';
  $tabla0=$tabla.'0';
			$colafter=vrsetcolu($tabla0,$tabla.'_rimpe','varchar(1)',$colafter,'');
  
  $tabla='user';
  $tabla0=$tabla.'0';
			$colafter=vrsetcolu($tabla0,$tabla.'_enti','varchar(10)','','');
  			$colafter=vrsetcolu($tabla0,$tabla.'_referx','varchar(10)',$colafter,'');
     
  $tabla='usrt';
  $tabla0=$tabla.'0';
  			$colafter=vrsetcolu($tabla0,$tabla.'_referx','varchar(10)',$colafter,'');
     
     
  $tabla='empr';
  $tabla0=$tabla.'0';
			$colafter=vrsetcolu($tabla0,$tabla.'_enti','varchar(13)','','');
			$colafter=vrsetcolu($tabla0,$tabla.'_rinve','datetime','','');
			$colafter=vrsetcolu($tabla0,$tabla.'_rnomi','datetime','','');
			$colafter=vrsetcolu($tabla0,$tabla.'_ratvd','datetime','','');
			$colafter=vrsetcolu($tabla0,$tabla.'_cele','varchar(1)','','0');
			$colafter=vrsetcolu($tabla0,$tabla.'_rete','varchar(1)','','0');
			$colafter=vrsetcolu($tabla0,$tabla.'_comi','varchar(1)','','0');
			$colafter=vrsetcolu($tabla0,$tabla.'_payphoneidapp','varchar(21)',$colafter,'');
			$colafter=vrsetcolu($tabla0,$tabla.'_payphonetoken','text',$colafter,'');
			$colafter=vrsetcolu($tabla0,$tabla.'_paypaltoken','text',$colafter,'');
  
  
  $tabla='ptov';
  $tabla0=$tabla.'0';
     $colafter=vrsetcolu($tabla0,$tabla.'_autocon', 'varchar(1)',$colafter,'');  
     
  $tabla='item';
  $tabla0=$tabla.'0';
   $colafter=vrsetcolu($tabla0,$tabla.'_puni4', 'decimal(15,6)','','');   
   $colafter=vrsetcolu($tabla0,$tabla.'_puni5', 'decimal(15,6)','','');   
   $colafter=vrsetcolu($tabla0,$tabla.'_dcto4', 'decimal(15,6)','','');   
   $colafter=vrsetcolu($tabla0,$tabla.'_dcto5', 'decimal(15,6)','','');   
   $colafter=vrsetcolu($tabla0,$tabla.'_pvp4', 'decimal(15,6)','','');   
   $colafter=vrsetcolu($tabla0,$tabla.'_pvp5', 'decimal(15,6)','','');   
   
  $tabla='zsub';
  $tabla0=$tabla.'0';
   $colafter=vrsetcolu($tabla0,$tabla.'_ctaacli', 'varchar(12)','','');   

  
  vrsetview0();
  
  
  $tabla='prod';
  $tabla1=$tabla.'1';
  $tabla2=$tabla.'2';
			$colafter=vrsetcolu($tabla1,'claveacc','varchar(49)','','');
			$colafter=vrsetcolu($tabla1,'emailto','varchar(50)','','');
  vrsetview1($tabla);

  
  $tabla='clie';
  $tabla1=$tabla.'1';
  $tabla2=$tabla.'2';
			$colafter=vrsetcolu($tabla1,'paypal_res','text',$colafter,'');
			$colafter=vrsetcolu($tabla1,'payphone_res','text',$colafter,'');
  vrsetview1($tabla);

  $tabla='vtas';
  $tabla1=$tabla.'1';
  $tabla2=$tabla.'2';
			$colafter=vrsetcolu($tabla1,'paypal_res','text',$colafter,'');
			$colafter=vrsetcolu($tabla1,'payphone_res','text',$colafter,'');
  vrsetview1($tabla);

  $tabla='carr';
  $tabla1=$tabla.'1';
  $tabla2=$tabla.'2';
	$colafter=vrsetcolu($tabla1,'udate','datetime','','');
  vrsetview1($tabla);

  
  $tabla='comp';
  $tabla1=$tabla.'1';
  $tabla2=$tabla.'2';
	  $colafter=vrsetcolu($tabla1,'efectivo','decimal(9,2)','','');
      $colafter=vrsetcolu($tabla2,'uxpre','decimal(7,2)','','');
      $colafter=vrsetcolu($tabla2,'facon','decimal(15,6)','','');
			$colafter=vrsetcolu($tabla2,'umdd','varchar(4)','','');
  
  vrsetview1($tabla);
  
  $tabla='prov';
  $tabla1=$tabla.'1';
  $tabla2=$tabla.'2';
      $colafter=vrsetcolu($tabla2,'uxpre','decimal(7,2)','','');
      $colafter=vrsetcolu($tabla2,'facon','decimal(15,6)','','');
  vrsetview1($tabla);
  
  
  msql_query('update docu0 set docu_tice="93" where docu_codigo like "OP%"',$link_vcrx);
  msql_query('update docu0 set docu_tcel="93" where docu_codigo like "OP%"',$link_vcrx);
  
  
	echo '<br>';
	echo '<br>';
//   $tipo=4;
//   include('set_data.php'); 
  
  
  
	chdir('../');
}	

// echo '</resultado>';

?>