<?
set_time_limit (3600 );


date_default_timezone_set ( "America/Lima" ); 

define('SF_ROOT_DIR', "/home/invergladi/public_html/gladis");
//define('SF_ROOT_DIR', "C://wamp/www/credisur");
define('SF_APP',      'sys');
require_once(SF_ROOT_DIR.DIRECTORY_SEPARATOR."lib".DIRECTORY_SEPARATOR."functions".DIRECTORY_SEPARATOR."HelperHelper.php");
require_once(SF_ROOT_DIR.DIRECTORY_SEPARATOR.'config'.DIRECTORY_SEPARATOR.'config.php');
require_once(SF_ROOT_DIR.DIRECTORY_SEPARATOR.'config'.DIRECTORY_SEPARATOR.'config_core_compile.php');
require_once(SF_ROOT_DIR.DIRECTORY_SEPARATOR.'cache'.DIRECTORY_SEPARATOR.'config_autoload.php');


$con= Conexion::getConexion();
$a_param = Conexion::getParamDbByAlias($apps);

$dia = date('N');

if($dia == 7) exit;


if (!mysql_select_db($a_param['db'], $con)) {
    echo 'Could not select database';
    exit;
}



$periodo = date('Y-m');

$sql = "SELECT Periodo
		FROM cr_planilla_periodo 
		WHERE Periodo = '".$periodo."'";

$result = mysql_query($sql,$con);


if(mysql_num_rows($result)==0){
	
		$sql = "INSERT INTO  `cr_planilla_periodo`
				(`Periodo` ,
				`Estado` ,
				`Activo` 
				)
				VALUES (
				'".$periodo."',
				'A',
				'1')";
		
		
		$result2 = mysql_query($sql,$con);
	
}
