File: /home/undanet/www/PortalEmpleo/src/Views/FormularioConvocatoriaTribunalView.php
<form method="post" name="frmTribunalConvocatoria" id="frmTribunalConvocatoria" action="" enctype="multipart/form-data">
<?php
$root = get_site_url() . '/';
$rootwp = "";
if(isset($data['lusuariosWP']))
{
$_SESSION["data"] = $data;
echo '<script language="JavaScript">
var lEvaluadores = [];';
foreach ($data['lusuariosWP'] as $usuarioWP) {
echo 'lEvaluadores.push("' . $usuarioWP->getDisplayName() .'");';
}
echo '</script>';
}
if(isset($data['lconvocatoria']))
{
echo '<script language="JavaScript">
titulo = document.getElementsByClassName("entry-title");
titulo[0].innerHTML = "' . __('Evaluation Committee for the call', 'panoramic_child') . ' ' . $data['lconvocatoria']->getReferencia() . '";';
echo '</script>';
}
?>
<table border="0" style="margin-top: 1em;" class="azul nomargin">
<thead>
<?php
echo '<tr><th>' . __('Role', 'panoramic_child') . '</th><th>' . __('Evaluator', 'panoramic_child') . '</th><th class="centrado">' . __('Assumes Main Role', 'panoramic_child') . '</th></tr>';
?>
</thead>
<tbody>
<?php
if(isset($data['lusuariosWP']))
{
$disabled = ( ($data['lconvocatoria']->getCodigoestadoconvocatoria())->getIdestadoconvocatoria() > 1 ) ? 'readonly' : '';
echo '<tr class="cebra">
<td>' . __('President', 'panoramic_child') . '<label class="red nomargin">*</label></td>
<td><input list="users" id="txtPresidente" name="txtPresidente"
onmouseover="focus();old = value;"
onmousedown = "value = "";"
onmouseup="value = old;"
onClick="this.setSelectionRange(0, this.value.length);"
placeholder = "' . __('Select user...', 'panoramic_child') . '" required ' . $disabled . '/>
<datalist id="users">';
foreach ($data['lusuariosWP'] as $usuarioWP) {
$user_meta = get_userdata($usuarioWP->getId());
$user_roles = $user_meta->roles;
if ( in_array( 'um_evaluador', $user_roles, true ) ) {
echo '<option value="' . $usuarioWP->getDisplayName() .'">';
}
}
echo '</datalist></td><td></td></tr>';
echo '<tr class="cebra">
<td>' . __('Substitute for the President', 'panoramic_child') . '<label class="red nomargin">*</label></td>
<td><input list="users" id="txtPresidenteSubs" name="txtPresidenteSubs"
onmouseover="focus();old = value;"
onmousedown = "value = "";"
onmouseup="value = old;"
onClick="this.setSelectionRange(0, this.value.length);"
placeholder = "' . __('' . __('Select user...', 'panoramic_child') . '', 'panoramic_child') . '" required ' . $disabled . ' />
<datalist id="users">';
foreach ($data['lusuariosWP'] as $usuarioWP) {
$user_meta = get_userdata($usuarioWP->getId());
$user_roles = $user_meta->roles;
if ( in_array( 'um_evaluador', $user_roles, true ) ) {
echo '<option value="' . $usuarioWP->getDisplayName() .'">';
}
}
echo '</datalist>
</td>
<td>
<input type="checkbox" id="chkPresidenteSubs" name="chkPresidenteSubs" value="chkPresidenteSubs">
</td>
</tr>';
echo '<tr class="cebra">
<td>' . __('Secretary', 'panoramic_child') . '<label class="red nomargin">*</label></td>
<td><input list="users" id="txtSecretario" name="txtSecretario"
onmouseover="focus();old = value;"
onmousedown = "value = "";"
onmouseup="value = old;"
onClick="this.setSelectionRange(0, this.value.length);"
placeholder = "' . __('Select user...', 'panoramic_child') . '" required ' . $disabled . ' />
<datalist id="users">';
foreach ($data['lusuariosWP'] as $usuarioWP) {
$user_meta = get_userdata($usuarioWP->getId());
$user_roles = $user_meta->roles;
if ( in_array( 'um_evaluador', $user_roles, true ) ) {
echo '<option value="' . $usuarioWP->getDisplayName() .'">';
}
}
echo '</datalist></td><td></td></tr>';
echo '<tr class="cebra">
<td>' . __('Substitute for the Secretary', 'panoramic_child') . '<label class="red nomargin">*</label></td>
<td><input list="users" id="txtSecretarioSubs" name="txtSecretarioSubs"
onmouseover="focus();old = value;"
onmousedown = "value = "";"
onmouseup="value = old;"
onClick="this.setSelectionRange(0, this.value.length);"
placeholder = "' . __('Select user...', 'panoramic_child') . '" required ' . $disabled . '/>
<datalist id="users">';
foreach ($data['lusuariosWP'] as $usuarioWP) {
$user_meta = get_userdata($usuarioWP->getId());
$user_roles = $user_meta->roles;
if ( in_array( 'um_evaluador', $user_roles, true ) ) {
echo '<option value="' . $usuarioWP->getDisplayName() .'">';
}
}
echo '</datalist>
</td>
<td>
<input type="checkbox" id="chkSecretarioSubs" name="chkSecretarioSubs" value="chkSecretarioSubs">
</td>
</tr>';
echo '<tr class="cebra">
<td>' . __('Officer', 'panoramic_child') . '<label class="red nomargin">*</label></td>
<td><input list="users" id="txtVocal1" name="txtVocal1"
onmouseover="focus();old = value;"
onmousedown = "value = "";"
onmouseup="value = old;"
onClick="this.setSelectionRange(0, this.value.length);"
placeholder = "' . __('Select user...', 'panoramic_child') . '" required ' . $disabled . ' />
<datalist id="users">';
foreach ($data['lusuariosWP'] as $usuarioWP) {
$user_meta = get_userdata($usuarioWP->getId());
$user_roles = $user_meta->roles;
if ( in_array( 'um_evaluador', $user_roles, true ) ) {
echo '<option value="' . $usuarioWP->getDisplayName() .'">';
}
}
echo '</datalist></td><td></td></tr>';
echo '<tr class="cebra">
<td>' . __('Substitute for the Officer', 'panoramic_child') . '<label class="red nomargin">*</label></td>
<td><input list="users" id="txtVocal1Subs" name="txtVocal1Subs"
onmouseover="focus();old = value;"
onmousedown = "value = "";"
onmouseup="value = old;"
onClick="this.setSelectionRange(0, this.value.length);"
placeholder = "' . __('Select user...', 'panoramic_child') . '" required ' . $disabled . ' />
<datalist id="users">';
foreach ($data['lusuariosWP'] as $usuarioWP) {
$user_meta = get_userdata($usuarioWP->getId());
$user_roles = $user_meta->roles;
if ( in_array( 'um_evaluador', $user_roles, true ) ) {
echo '<option value="' . $usuarioWP->getDisplayName() .'">';
}
}
echo '</datalist>
</td>
<td>
<input type="checkbox" id="chkVocal1Subs" name="chkVocal1Subs" value="chkVocal1Subs">
</td>
</tr>';
echo '<tr class="cebra" id="trVocal2" hidden>
<td>' . __('Officer 2', 'panoramic_child') . '</td>
<td><input list="users" id="txtVocal2" name="txtVocal2"
onmouseover="focus();old = value;"
onmousedown = "value = "";"
onmouseup="value = old;"
onClick="this.setSelectionRange(0, this.value.length);"
placeholder = "' . __('Select user...', 'panoramic_child') . '" ' . $disabled . '/>
<datalist id="users">';
foreach ($data['lusuariosWP'] as $usuarioWP) {
$user_meta = get_userdata($usuarioWP->getId());
$user_roles = $user_meta->roles;
if ( in_array( 'um_evaluador', $user_roles, true ) ) {
echo '<option value="' . $usuarioWP->getDisplayName() .'">';
}
}
echo '</datalist></td><td></td></tr>';
echo '<tr class="cebra" id="trVocal2Subs" hidden>
<td>' . __('Substitute for the Officer 2', 'panoramic_child') . '</td>
<td><input list="users" id="txtVocal2Subs" name="txtVocal2Subs"
onmouseover="focus();old = value;"
onmousedown = "value = "";"
onmouseup="value = old;"
onClick="this.setSelectionRange(0, this.value.length);"
placeholder = "' . __('Select user...', 'panoramic_child') . '" ' . $disabled . '/>
<datalist id="users">';
foreach ($data['lusuariosWP'] as $usuarioWP) {
$user_meta = get_userdata($usuarioWP->getId());
$user_roles = $user_meta->roles;
if ( in_array( 'um_evaluador', $user_roles, true ) ) {
echo '<option value="' . $usuarioWP->getDisplayName() .'">';
}
}
echo '</datalist>
</td>
<td>
<input type="checkbox" id="chkVocal2Subs" name="chkVocal2Subs" value="chkVocal2Subs">
</td>
</tr>';
}
else {
echo '<tr><td><div class="fondo_color">' . __('There are no users enabled to be selected', 'panoramic_child') . '</div></td></tr>';
}
?>
</tbody>
</table>
<script language="JavaScript">
function validar(){
var txtP = document.getElementById('txtPresidente');
var txtPSub = document.getElementById('txtPresidenteSubs');
var txtS = document.getElementById('txtSecretario');
var txtSSub = document.getElementById('txtSecretarioSubs');
var txtV1 = document.getElementById('txtVocal1');
var txtV1Sub = document.getElementById('txtVocal1Subs');
var txtV2 = document.getElementById('txtVocal2');
var txtV2Sub = document.getElementById('txtVocal2Subs');
var allinone = [];
var alreadySeen = [];
if((txtV2.value !== "" && txtV2.value !== undefined) && (txtV2Sub.value !== "" && txtV2Sub.value !== undefined))
{
allinone.push(txtP.value, txtPSub.value, txtS.value, txtSSub.value, txtV1.value, txtV1Sub.value, txtV2.value, txtV2Sub.value);
}
else
{
allinone.push(txtP.value, txtPSub.value, txtS.value, txtSSub.value, txtV1.value, txtV1Sub.value);
}
//allinone.push(txtP.value, txtPSub.value, txtS.value, txtSSub.value, txtV1.value, txtV1Sub.value, txtV2.value, txtV2Sub.value);
// allinone = allinone.split(' ').join('');
var repeated = false;
allinone.forEach(function(str) {
if (alreadySeen[str])
repeated = true;
else
alreadySeen[str] = true;
});
//console.log(allinone);
if(txtP.value === "" || txtP.value === undefined || !lEvaluadores.includes(txtP.value))
{
txtP.value = "";
return false;
}
if(txtPSub.value === "" || txtPSub.value === undefined || !lEvaluadores.includes(txtPSub.value))
{
txtPSub.value = "";
return false;
}
if(txtS.value === "" || txtS.value === undefined || !lEvaluadores.includes(txtS.value))
{
txtS.value = "";
return false;
}
if(txtSSub.value === "" || txtSSub.value === undefined || !lEvaluadores.includes(txtSSub.value))
{
txtSSub.value = "";
return false;
}
if(txtV1.value === "" || txtV1.value === undefined || !lEvaluadores.includes(txtV1.value))
{
txtV1.value = "";
return false;
}
if(txtV1Sub.value === "" || txtV1Sub.value === undefined || !lEvaluadores.includes(txtV1Sub.value))
{
txtV1Sub.value = "";
return false;
}
if(txtV2.value !== "" && txtV2.value !== undefined)
{
if(!lEvaluadores.includes(txtV2.value))
{
txtV2.value = "";
return false;
}
}
if(txtV2Sub.value !== "" && txtV2Sub.value !== undefined)
{
if(!lEvaluadores.includes(txtV2Sub.value))
{
txtV2Sub.value = "";
return false;
}
}
else
{
if(txtV2.value !== "" && txtV2.value !== undefined)
{
alert("<?php echo __('You must select a substitute for the Officer 2', 'panoramic_child') ?>");
return false;
}
}
if(repeated)
{
alert("<?php echo __('Cann\'t use the same user for diferents roles', 'panoramic_child') ?>");
return false;
}
return true;
}
function fncconvocatoriasubmit( object ) {
if( validar() )
{
var msg = "<?php echo __('Do you want to save this committee?', 'panoramic_child') ?>";
if(confirm(msg))
{
document.getElementById("accionConvocatoria").value = "GuardarTribunal";
document.getElementById("frmTribunalConvocatoria").submit();
}
}
else
{
alert("<?php echo __('You must select a valid evaluator for each role. Please, check evaluators name values', 'panoramic_child') ?>");
}
}
function fncconvocatoriacancel() {
document.getElementById("accionConvocatoria").value = "Cancelar";
document.getElementById("frmTribunalConvocatoria").submit();
}
</script>
<script language="JavaScript">
var txtVocal1 = document.getElementById('txtVocal1');
var txtVocal1Subs = document.getElementById('txtVocal1Subs');
mostrarVocal2 = function(){
var trVocal2 = document.getElementById('trVocal2');
var trVocal2Subs = document.getElementById('trVocal2Subs');
var txtVocal2 = document.getElementById('txtVocal2');
var txtVocal2Subs = document.getElementById('txtVocal2Subs');
if(txtVocal1.value !== "" && txtVocal1Subs.value !== "")
{
trVocal2.hidden = false;
trVocal2Subs.hidden = false;
}
else
{
txtVocal2.value = "";
txtVocal2Subs.value = "";
trVocal2.hidden = true;
trVocal2Subs.hidden = true;
}
}
txtVocal1.addEventListener('change', mostrarVocal2);
txtVocal1Subs.addEventListener('change', mostrarVocal2);
</script>
<?php
if(isset($data['ltribunal'][0]))
{
echo '<script language="JavaScript">
document.getElementById("txtPresidente").value = "'. ($data['ltribunal'][0]->getCodigousuariowp())->getDisplayName() .'";
</script>';
}
if(isset($data['ltribunal'][1]))
{
echo '<script language="JavaScript">
document.getElementById("txtPresidenteSubs").value = "'. ($data['ltribunal'][1]->getCodigousuariowp())->getDisplayName() .'";';
if($data['ltribunal'][1]->getAsumerolprincipal())
{
echo 'document.getElementById("chkPresidenteSubs").checked = true;';
}
echo '</script>';
}
if(isset($data['ltribunal'][2]))
{
echo '<script language="JavaScript">
document.getElementById("txtSecretario").value = "'. ($data['ltribunal'][2]->getCodigousuariowp())->getDisplayName() .'";
</script>';
}
if(isset($data['ltribunal'][3]))
{
echo '<script language="JavaScript">
document.getElementById("txtSecretarioSubs").value = "'. ($data['ltribunal'][3]->getCodigousuariowp())->getDisplayName() .'";';
if($data['ltribunal'][3]->getAsumerolprincipal())
{
echo 'document.getElementById("chkSecretarioSubs").checked = true;';
}
echo '</script>';
}
if(isset($data['ltribunal'][4]))
{
echo '<script language="JavaScript">
document.getElementById("txtVocal1").value = "'. ($data['ltribunal'][4]->getCodigousuariowp())->getDisplayName() .'";
</script>';
}
if(isset($data['ltribunal'][5]))
{
echo '<script language="JavaScript">
document.getElementById("txtVocal1Subs").value = "'. ($data['ltribunal'][5]->getCodigousuariowp())->getDisplayName() .'";
document.getElementById("txtVocal1Subs").dispatchEvent(new Event("change"));';
if($data['ltribunal'][5]->getAsumerolprincipal())
{
echo 'document.getElementById("chkVocal1Subs").checked = true;';
}
echo '</script>';
}
if(isset($data['ltribunal'][6]) && !user_can( ($data['ltribunal'][6]->getCodigousuariowp())->getId(), 'administrator' ) )
{
echo '<script language="JavaScript">
document.getElementById("txtVocal2").value = "'. ($data['ltribunal'][6]->getCodigousuariowp())->getDisplayName() .'";
</script>';
}
if(isset($data['ltribunal'][7]))
{
echo '<script language="JavaScript">
document.getElementById("txtVocal2Subs").value = "'. ($data['ltribunal'][7]->getCodigousuariowp())->getDisplayName() .'";';
if($data['ltribunal'][7]->getAsumerolprincipal())
{
echo 'document.getElementById("chkVocal2Subs").checked = true;';
}
echo '</script>';
}
?>
<?php
echo '<br>';
echo '<table><tbody><tr><td><input type="text" id="accionConvocatoria" name="accionConvocatoria" value="" hidden></td></tr></tbody></table>';
if(isset($data['lconvocatoria']) && is_object($data['lconvocatoria']))
{
echo '<input type="text" id="txtConvocatoria" name="txtConvocatoria" value="' . ($data['lconvocatoria'])->getIdconvocatoria() . '" hidden>';
echo '<input type="text" id="txtConvocatoriaRef" name="txtConvocatoriaRef" value="' . ($data['lconvocatoria'])->getReferencia() . ' ' . ($data['lconvocatoria'])->getDescripcion() . '" hidden>';
echo '<input type="text" id="txtConvocatoriaFechaInicio" name="txtConvocatoriaFechaInicio" value="' . $data['lconvocatoria']->getFechainicio()->format("d") . ' de '. getMes($data['lconvocatoria']->getFechainicio()->format('n')-1) . ' del ' . $data['lconvocatoria']->getFechainicio()->format("Y") . '" hidden>';
}
$isnew = (isset($data['ltribunal'])) ? 'notisnew' : 'isnew';
echo '<input type="text" id="isnew" name="isnew" value="' . $isnew . '" hidden>';
echo '<input type="button" name="btnaccionConvocatoria" value="' . __('Save', 'panoramic_child') . '" onClick="fncconvocatoriasubmit(this);">';
echo '<input type="button" name="btnaccionConvocatoria" value="' . __('Cancel', 'panoramic_child') . '" class="margenes_laterales_4" onClick="fncconvocatoriacancel();">';
?>