File: /home/asjudine/public_html/generar_pago_comision_dir_reg.php
<?php
require_once("mainfile.php");
include ("config.php");
global $dbi;
require_once("Conectarse.php");
$total_comi=0;
//$query_sql4 = "SELECT * FROM director_ventas where estado = '1' and (tipo = 'R' || tipo = 'M') order by nombre";
//$sql4 = mysql_query($query_sql4, $dbi) or die(mysql_error());
$sql4 = mysql_query('SELECT * FROM director_ventas WHERE estado = "1" and (tipo = "R" || tipo = "M") order by nombre ');
if (!$sql4) {
die('Invalid query: ' . mysql_error());
}
$row_sql4 = mysql_fetch_assoc($sql4);
$totalRows_sql4 = mysql_num_rows($sql4);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Generador Pagos Director Regional</title>
<style type="text/css">
<!--
.recaudo {font-family: "Courier New", Courier, monospace;
font-size: 12px;
font-style: normal;
font-weight: bold;
font-variant: normal;
color: #000000;
background-color: #B6CBDC;
margin: 4px;
padding: 8px;
width: auto;
border: medium outset #339966;
}
.est_cont1 {
font-family: "Times New Roman", Times, serif;
font-size: 12px;
font-style: normal;
font-weight: normal;
color: #4068F4;
background-color: #E6FFF1;
margin: 1px;
padding: 1px;
height: auto;
width: auto;
border: thin double #33CC66;
}
.est_cont2 {
font-family: Geneva, Arial, Helvetica, sans-serif;
font-size: 12px;
font-style: normal;
font-weight: normal;
color: #418BAF;
background-color: #F0F5CF;
height: 15px;
width: auto;
border: thin solid #FABF85;
}
.est_cont3 {
font-family: "Courier New", Courier, monospace;
font-size: 12px;
font-style: normal;
font-weight: normal;
color: #EA261C;
background-color: #DEDDE8;
height: auto;
width: auto;
border: thin outset #FC9F67;
}
.est_cont5 {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 12px;
font-style: normal;
font-weight: normal;
background-color: #D6ECFE;
margin: 2px;
padding: 2px;
height: auto;
width: auto;
border: thin groove #E9AAF0;
color: #C72350;
}
.Estilo50 {color: #CC3333;
font-family: "Arial Narrow";
font-weight: bold;
}
.fecha {font-size: 12px; font-family: Arial; color:#990000; display: block; }
.titulos {font: 16px; color: red; font-family:Arial; font-weight:bold}
.Estilo51 {
font-size: 14px;
font-weight: bold;
}
.col_cre2 { font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 12px;
font-style: normal;
font-weight: bold;
color: #F92F0B;
background-color: #B3D9F0;
height: auto;
width: auto;
border: medium groove #FC9227;
}
.est_cont21 { font-family: Geneva, Arial, Helvetica, sans-serif;
font-size: 12px;
font-style: normal;
font-weight: normal;
color: #2B39EC;
background-color: #F0F5CF;
height: 18px;
width: auto;
border: thin solid #FABF85;
}
-->
</style>
</head>
<body>
<form id="form1" name="form1" method="post" action="">
<div align="center">
<table width="669" border="0" align="center" cellpadding="2" cellspacing="2">
<tr bgcolor="#FFFFCC">
<td colspan="2" class="titulos"><div align="center">GENERAR PAGO COMISION - DIRECTOR REGIONAL</div></td>
</tr>
<tr bgcolor="#ECE9D8">
<td width="327" height="22" class="fecha">
<div align="right">
<script languaje="JavaScript">Mostrar_Fecha()</script>
<span class="Estilo51">DIRECTOR :</span></div></td>
<td width="328" class="fecha"><div align="left">
<select name="ase" id="ase">
<option value="0">-SELECCIONE DIRECTOR-</option>
<?php
do {
?>
<option value="<?php echo $row_sql4['codigo'];?>"><?php echo $row_sql4['nombre']?></option>
<?php
} while ($row_sql4 = mysql_fetch_assoc($sql4));
$rows4 = mysql_num_rows($sql4);
if($rows4 > 0) {
mysql_data_seek($sql4, 0);
$row_sql4 = mysql_fetch_assoc($sql4);
}
?>
</select>
</div></td>
</tr>
<tr bgcolor="#FFCC99">
<td colspan="2"><div align="center">
<input name="consultar" type="submit" class="col_cre2" id="consultar" value="Consultar" />
</div></td>
</tr>
<tr bgcolor="#FFCC99">
<td colspan="2"><div align="center">
<input name="menu2" type="button" class="Estilo50" id="menu2" onclick="window.location.href='menu_comisiones.php'" value="IR AL MENU" />
<label></label>
</div></td>
</tr>
<tr bgcolor="#FFCC99">
<td colspan="2" bgcolor="#CEFBE6"><?php
//$sqlnom4 = "select nombre from director_ventas where codigo = '$ase'";
//$control4 = mysql_query($sqlnom4, $dbi) or die(mysql_error());
$control4 = mysql_query('SELECT nombre FROM director_ventas WHERE codigo = "' ."$ase". '" ');
if (!$control4) {
die('Invalid query: ' . mysql_error());
}
list($nombre_ase) = mysql_fetch_row($control4);
$casr=$ase;
echo 'DIRECTOR : '.$nombre_ase;?>
<label></label></td>
</tr>
<tr bgcolor="#FFCC99">
<td colspan="2" bgcolor="#CCCCCC"><div align="center">
<input name="generarp" type="submit" class="col_cre2" id="generarp" value="Generar Pago" />
</div></td>
</tr>
</table>
<p> </p>
<div align="left"></div>
<div align="left"></div>
<div align="right"></div>
</div>
</form>
</body>
</html>
<?php
if(isset($_POST["consultar"]))
{
echo "<form id='form2' name='form2' method='post' action=''>";
require_once("mainfile.php");
include ("config.php");
global $dbi;
//$mssql = mysql_query("select * from comisiones_ventas",$dbi);
$mssql = mysql_query('SELECT * FROM comisiones_ventas');
if (!$mssql) {
die('Invalid query: ' . mysql_error());
}
if($mssql)
{
$filas = mysql_num_rows($mssql);
if ($filas > 0)
{
// $sql = "select id, cedula, valor_comision from comisiones_ventas where estado = '1' and codigo_asesor = '$ase'";
// $control = mysql_query($sql, $dbi) or die(mysql_error());
$control = mysql_query('SELECT id, cedula, valor_comision FROM comisiones_ventas WHERE estado = "1" and codigo_asesor = "' . $_POST[ase] . '" ');
if (!$control) {
die('Invalid query: ' . mysql_error());
}
if ((mysql_num_rows($control)!=0))
{
echo "<table width='400' border='2' align='center' cellpadding='1' cellspacing='1' class='est_cont5'>
<tr>
<td width='70'><div align='center'><strong>CEDULA</strong></div></td>
<td width='140'><div align='center'><strong>NOMBRE</strong></div></td>
<td width='50'><div align='center'><strong>CONTRATO No</strong></div></td>
<td width='70'><div align='center'><strong>TIPO</strong></div></td>
<td width='70'><div align='center'><strong>VALOR COMISION</strong></div></td>
</tr>";
while(list($id, $ced, $valcom) = mysql_fetch_row($control))
{
$total_comi=$total_comi+$valcom;
// $sqlnom2 = "select contrato, tipo_contrato from info_asjudinet where cedula = '$ced'";
//$control2 = mysql_query($sqlnom2, $dbi) or die(mysql_error());
$control2 = mysql_query('SELECT contrato, tipo_contrato FROM info_asjudinet WHERE cedula = "' ."$ced". '" ');
if (!$control2) {
die('Invalid query: ' . mysql_error());
}
list($contrato, $tipoc) = mysql_fetch_row($control2);
//$sqlnom3 = "select apellidos_noms from datos_basicos_rc where cedula = '$ced'";
//$control3 = mysql_query($sqlnom3, $dbi) or die(mysql_error());
$control3 = mysql_query('SELECT apellidos_noms FROM datos_basicos_rc WHERE cedula = "' ."$ced". '" ');
if (!$control3) {
die('Invalid query: ' . mysql_error());
}
list($nombre) = mysql_fetch_row($control3);
printf("<TR>
<TD bgcolor='#ECE9D8'><div align='center' class='lista'><input type='button' value=$ced name='cedu' class=est_cont1 onClick =window.open('.php?id2=$id&ced2=$ced','','top=50,left=100,toolbar=yes,scrollbars=yes,width=800,height=300,status=yes')></a></span></div></TD>
<TD bgcolor='#C5D6FC'><div align='center' class='lista'>".$nombre."</span></div></TD>
<TD bgcolor='#C5D6FC'><div align='center' class='lista'>".$contrato."</span></div></TD>
<TD bgcolor='#C5D6FC'><div align='center' class='lista'>".$tipoc."</span></div></TD>
<TD bgcolor='#C5D6FC'><div align='center' class='lista'>".$valcom."</span></div></TD> </TR>");
}
echo "</table>";
}
echo "<TD bgcolor='#FFFFCC'><div align='center'><span class='est_cont2'>TOTAL COMISION</span></div></TD>";
echo "<td bgcolor='#FFFFCC'><div align='center' class='est_cont5'>".$total_comi."</span></div></td>";
}
}
echo "</form>";
}
if(isset($_POST["generarp"]))
{
$fecha_pag = date ( "Y-n-j" );
if($ase!=0)
{
//$mssqlsol = "update comisiones_ventas set fecha_pago = '$fecha_pag' ,estado='2' where estado = '1' and codigo_asesor = '$ase' ";
// mysql_query($mssqlsol, $dbi) or die(mysql_error());
$mssqlsol = mysql_query("UPDATE comisiones_ventas set fecha_pago= '" . $_POST[fecha_pag] . "', estado='2' WHERE estado = '1' and codigo_asesor= '" . $_POST[ase] . "'");
if (!$mssqlsol) {
die('Invalid query SEGUNDO UPDATE: ' . mysql_error());
}
echo "<script>alert('Se ha generado pago de comision');</script>";
}else{
echo "<script>alert('Debe seleccionar director para generar pago');</script>";
}
}
?>