HEX
Server: Apache
System: Linux clpupre 5.4.0-90-generic #101-Ubuntu SMP Fri Oct 15 20:00:55 UTC 2021 x86_64
User: undanet (1000)
PHP: 7.4.3
Disabled: pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
Upload Files
File: /home/undanet/www//PortalEmpleo/src/Views/FormularioInscripcionConvocatoriaView.php
<form method="post" name="frmInscripcionConvocatoria" id="frmInscripcionConvocatoria" action="" enctype="multipart/form-data">

<?php
    const SEPARADOR_PUESTOS_TRABAJO=';';

    if(isset($data))
    {
        $_SERVER['HTTPS'] = $_SERVER['HTTPS'] == 'off' ? '' : $_SERVER['HTTPS'];
        $root = (!empty($_SERVER['HTTPS']) ? 'https' : 'http') . '://' . $_SERVER['HTTP_HOST'] . '/';
        $rootwp = "";
        $actual_link = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ? "https" : "http") . "://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";

        if( pll_current_language() == 'en')
            $lang = 'en_GB';
        else 
            $lang = 'es_ES';

        //if(isset($data['candidato']) && is_object($data['candidato']))
        if(!isset($data['candidato']) || !is_object($data['candidato']))
        {
            if($lang=='en' || $lang=='en_GB')
            {
				echo '<div class="fondo_color">To sign up for any call you must complete your candidate profile. You can do it in the <a href="' . $root . $rootwp . 'en/candidate-profile/" target="_self" class="underline bold">following link</a>. Once it is completed, you can sign up for the job offer you want.</div>';
            }
            else
            {				
                echo '<div class="fondo_color">Para inscribirse en alguna convocatoria debes completar primero tu perfil de candidatura. Puedes hacerlo en el <a href="' . $root . $rootwp . 'es/perfil-del-candidato/?c=' . $_GET['id'] . '" target="_self" class="underline bold">siguiente enlace</a>. Una vez completado ya puedes inscribirte en la oferta de trabajo deseada. </div>';
            }
        }
        else
        {
            if(isset($data['convocatoria']) && is_object($data['convocatoria']))
            {
				$user_obj = get_user_by('id', ($data['candidato']->getCodigousuariowp())->getId());
				echo '<input type="hidden" id="candidatoDisplayName" name="candidatoDisplayName" value="' . $user_obj->first_name . ' ' . $user_obj->last_name . '" hidden>';
				echo '<input type="hidden" id="convReferencia" name="convReferencia" value="' . $data['convocatoria']->getReferencia() . '" hidden>';
				echo '<input type="hidden" id="convNombre" name="convNombre" value="' . $data['convocatoria']->getDescripcion() . '" hidden>';
				
                echo '<section id="infoconvocatoria">';
                if($lang=='en' || $lang=='en_GB')
                {
                    echo '<span class="underline bold">Info about the call</span>:';
                    echo '<br><br><ul class="lista_none"><li><span class="bold">Reference:</span> ' . $data['convocatoria']->getReferencia() . '</li><li><span class="bold">Description:</span> ' . $data['convocatoria']->getDescripcion() . '</li><li><span class="bold">Job:</span> ' . $data['convocatoria']->getPuestoTrabajo() . '</li><li><span class="bold">Center:</span> ' . $data['convocatoria']->getCentro() . '</li>';
                }
                else
                {
                    echo '<span class="underline bold">Resumen de la convocatoria</span>:';
                    echo '<br><br><ul class="lista_none"><li><span class="bold">Referencia:</span> ' . $data['convocatoria']->getReferencia() . '</li><li><span class="bold">Descripci&oacute;n:</span> ' . $data['convocatoria']->getDescripcion() . '</li><li><span class="bold">Puesto Trabajo:</span> ' . $data['convocatoria']->getPuestoTrabajo() . '</li><li><span class="bold">Centro:</span> ' . $data['convocatoria']->getCentro() . '</li>';
                }
                echo '</p></div></section>';

				if (!isset($_POST['isEdit'])) { 					
					if($lang=='en' || $lang=='en_GB')
					{
						echo '<div class="">When you register for this call, your personal data from your profile will be used. If you wish, you can check and update them at <a href="' . $root . $rootwp . 'en/candidate-profile/?c=' . $_GET['id'] . '" target="_self" class=""><u>this link</u></a>.</div>';
					}
					else
					{
						echo '<div class="">Al inscribirte en esta convocatoria se emplear&aacute;n tus datos personales de tu perfil. Si lo deseas puedes consultarlos y/o actualizarlos en el <a href="' . $root . $rootwp . 'es/perfil-del-candidato/?c=' . $_GET['id'] . '" target="_self" class=""><u>siguiente enlace</u></a>.</div>';
					}
				

					echo '<div style="padding: 1em 2em 1em 2em;"><table class="borde_color_suave_2"><tbody><tr>';
					if($lang=='en' || $lang=='en_GB')
					{
						echo '<td class="borde"><label for="slctPuestoTrabajo">Job:</label><label class="red nomargin">*</label></td>';
					}
					else
					{
						echo '<td class="borde"><label for="slctPuestoTrabajo">Puesto Trabajo:</label><label class="red nomargin">*</label></td>';
					}
					$lpuestos = explode(SEPARADOR_PUESTOS_TRABAJO, $data['convocatoria']->getPuestoTrabajo());
					echo '<td>' . generarHTML('PuestoTrabajo', $lpuestos) . '</td></tr>';
					echo '<tr><td>';
					if($lang=='en' || $lang=='en_GB')
					{
						echo '<label for="flCV">Curriculum Vitae <small>(Max. 10MB)</small>:</label><label class="red nomargin">*</label></td>';
					}
					else
					{
						echo '<label for="flCV">Curriculum Vitae <small>(Max. 10MB)</small>:</label><label class="red nomargin">*</label></td>';
					}
					echo '</td><td><table class="nomargin"><tbody><tr>';
					if(isset($data['candidato']) && is_object($data['candidato']) && strlen(trim($data['candidato']->getRutacv()))>0)
					{
						echo '<td class="noborde nofondo"><input type="text" id="txtflCV" name="txtflCV" value="' . $data['candidato']->getRutacv() . '" hidden></td></tr><tr>';
						//echo '<td><a href="../../portalempleo/src/Utils/download.php?id=' . $data['candidato']->getIdcandidato() . '&file=' . basename($data['candidato']->getRutacv()) . '" target="_blank">' . basename($data['candidato']->getRutacv())  . '</a></td></tr><tr>';
						echo '<td class="noborde nofondo"><a id="linkCV" name="linkCV" href="' . $root . 'descarga/?id=' . ($data['candidato']->getCodigousuariowp())->getId() . '&file=' . basename($data['candidato']->getRutacv()) . '" target="_blank" hidden>' . basename($data['candidato']->getRutacv())  . '</a></td></tr><tr>';
						echo '<td class="noborde nofondo"><input type="file" name="flCV" id="flCV" accept=".doc,.docx,application/msword,.pdf,application/pdf" value="' . $data['candidato']->getRutacv() . '"></td>';
					}
					else
					{
						echo '<td class="noborde nofondo"><input type="file" name="flCV" id="flCV" accept=".doc,.docx,application/msword,.pdf,application/pdf" required></td>';
					}

					if($lang=='en' || $lang=='en_GB')
					{
						echo '<td class="noborde nofondo"><div name="flCVError" id ="flCVError" hidden="true" class="red">Admitted files .doc, .docx y .pdf</div></td>';
					}
					else
					{
						echo '<td class="noborde nofondo"><div name="flCVError" id ="flCVError" hidden="true" class="red">Admite .doc, .docx y .pdf</div></td>';
					}
					echo '</tr></tbody></table>';
					if($lang=='en' || $lang=='en_GB')
					{
						echo '</tr><tr><td style="padding-left: 5%;" class="borde"><input type="checkbox" id="chkCVPerfil" name="chkCVPerfil" value="false"><label for="chkCVPerfil" style="font-size:small;">Use CV from my profile</label></td>';
					}
					else
					{
						echo '</tr><tr><td style="padding-left: 5%;" class="borde"><input type="checkbox" id="chkCVPerfil" name="chkCVPerfil" value="false"><label for="chkCVPerfil" style="font-size:small;">Utilizar el CV de mi perfil</label></td>';
					}
					echo '</td><tr><td>';
					if($lang=='en' || $lang=='en_GB')
					{
						echo '<label for="flCartaPresentacion">Cover Letter <small>(Max. 10MB)</small>:</label></td>';
					}
					else
					{
						echo '<label for="flCartaPresentacion">Carta de Presentaci&oacute;n <small>(Max. 10MB)</small>:</label></td>';
					}
					echo '</td><td><table class="nomargin"><tbody><tr>';
					if(isset($data['candidato']) && is_object($data['candidato']) && strlen(trim($data['candidato']->getRutacp()))>0)
					{
						echo '<td class="noborde nofondo"><input type="text" id="txtflCartaPresentacion" name="txtflCartaPresentacion" value="' . $data['candidato']->getRutacp() . '" hidden></td></tr><tr>';
						//echo '<td><a href="../../portalempleo/src/Utils/download.php?id=' . $data['candidato']->getIdcandidato() . '&file=' . basename($data['candidato']->getRutacp()) . '" target="_blank">' . basename($data['candidato']->getRutacp())  . '</a></td></tr><tr>';
						echo '<td class="noborde nofondo"><a id="linkCP" name="linkCP" href="' . $root . 'descarga/?id=' . ($data['candidato']->getCodigousuariowp())->getId() . '&file=' . basename($data['candidato']->getRutacp()) . '" target="_blank" hidden>' . basename($data['candidato']->getRutacp())  . '</a></td></tr><tr>';
						echo '<td class="noborde nofondo"><input type="file" name="flCartaPresentacion" id="flCartaPresentacion" accept=".doc,.docx,application/msword,.pdf,application/pdf" value="' . $data['candidato']->getRutacp() . '"></td>';
					}
					else
					{
						echo '<td class="noborde nofondo"><input type="file" name="flCartaPresentacion" id="flCartaPresentacion" accept=".doc,.docx,application/msword,.pdf,application/pdf" required></td>';
					}

					if($lang=='en' || $lang=='en_GB')
					{
						echo '<td class="noborde nofondo"><div name="flCartaPresentacionError" id ="flCartaPresentacionError" hidden="true" class="red">Admitted files .doc, .docx y .pdf</div></td>';
					}
					else
					{
						echo '<td class="noborde nofondo"><div name="flCartaPresentacionError" id ="flCartaPresentacionError" hidden="true" class="red">Admite .doc, .docx y .pdf</div></td>';
					}
					echo '</tr></tbody></table>';

					if(isset($data['candidato']) && is_object($data['candidato']) && strlen(trim($data['candidato']->getRutacp()))>0)
					{
						if($lang=='en' || $lang=='en_GB')
						{
							echo '</tr><tr><td style="padding-left: 5%;"><input type="checkbox" id="chkCPPerfil" name="chkCPPerfil" value="false"><label for="chkCVPerfil" style="font-size:small;">Use the cover letter from my profile</label></td>';
						}
						else
						{
							echo '</tr><tr><td style="padding-left: 5%;"><input type="checkbox" id="chkCPPerfil" name="chkCPPerfil" value="false"><label for="chkCVPerfil" style="font-size:small;">Utilizar la carta de presentaci&oacute;n de mi perfil</label></td>';
						}
					}
					echo '</td></tr></tbody></table></div>';
				
				
					echo'<script language="javascript">
						var filesA = [];
						var filesR = [];
						var spanA1 = [];
						var spanR1 = [];
						var spanA = [];
						var spanR = [];
						
						var file = document.getElementById("flCV");
						file.onchange = function(e) {
							var fileError = document.getElementById("flCVError");
							var ext = this.value.match(/\.([^\.]+)$/)[1];
							switch (ext) {
								case "doc":
								case "docx":
								case "pdf":
									//alert("Allowed");
									fileError.hidden = true;
									this.style.fontWeight="bold";
								break;
								default:
									//alert("Not allowed");
									this.value = "";
									fileError.hidden = false;
									this.style.fontWeight="unset";
								break;
							}
						};

						var file2 = document.getElementById("flCartaPresentacion");
						file2.onchange = function(e) {
							var fileError2 = document.getElementById("flCartaPresentacionError");
							var ext = this.value.match(/\.([^\.]+)$/)[1];
							switch (ext) {
								case "doc":
								case "docx":
								case "pdf":
									//alert("Allowed");
									fileError2.hidden = true;
									this.style.fontWeight="bold";
								break;
								default:
									//alert("Not allowed");
									fileError2.hidden = false;
									this.value = "";
									this.style.fontWeight="unset";
								break;
							}
						};
						
						var chkCV = document.getElementById("chkCVPerfil");
						chkCV.onchange = function(e) {
							var aCV = document.getElementById("linkCV");
							var fileCV = document.getElementById("flCV");
							if(chkCV.checked)
							{
								aCV.hidden = false;
								fileCV.hidden = true;
							}
							else
							{
								aCV.hidden = true;
								fileCV.hidden = false;
							}
						};
						
						/*var chkCP = document.getElementById("chkCPPerfil");
						chkCP.onchange = function(e) {
							var aCP = document.getElementById("linkCP");
							var fileCP = document.getElementById("flCartaPresentacion");
							if(chkCP.checked)
							{
								aCP.hidden = false;
								fileCP.hidden = true;
							}
							else
							{
								aCP.hidden = true;
								fileCP.hidden = false;
							}
						};*/
					</script>';
				}
				if (!isset($_POST['isEdit'])) { 
					if(isset($data['requisitos']) && $data['requisitos']!= null)
					{
						echo '<hr><section id="inforequisitos"><div class="fondo_color header-image">';
						if($lang=='en' || $lang=='en_GB')
						{
							echo '<span class="underline bold">Requirements</span>:';
							echo '<br><br><ul class="lista_none">';
							$i=1;
							foreach ($data['requisitos'] as $req) {
								echo '<li>';
								if($req->getObligatorio())
								{
									echo '<span class="red">*</span>';
								}
								echo '<span class="bold">Requirement '. $i . ': ' . $req->getRequisito() . '</span></li><li>' . $req->getDescripcion() . '</li>';
								if($req != $data['requisitos'][count($data['requisitos'])-1])
								{
									echo '<br>';
								}
								$i++;
							}
							echo '</ul>';
						}
						else
						{
							echo '<span class="underline bold">Requisitos</span>:';
							echo '<br><br><ul class="lista_none">';
							$i = 1;
							foreach ($data['requisitos'] as $req) {
								echo '<li>';
								if($req->getObligatorio())
								{
									echo '<span class="red">*</span>';
								}
								echo '<span class="bold">Requisito '. $i . ': ' . $req->getRequisito() . '</span></li><li>' . $req->getDescripcion() . '</li>';
								if($req != $data['requisitos'][count($data['requisitos'])-1])
								{
									echo '<br>';
								}
								$i++;
							}
							echo '</ul>';
						}
						echo '</div>';

						if($lang=='en' || $lang=='en_GB')
						{
							echo '<br>Do not forget to attach the necessary files to evidence that you meet the requirements of the call';
							echo '<br><div style="font-size: small;">Admitted Files: pdf, microsoft word, images, compress (jpg,png,gif,bmp,zip) until 10MB</div>';
						}
						else
						{
							echo '<br>No olvides adjuntar los archivos necesarios para demostrar que cumples con los requisitos de la convocatoria';
							echo '<br><div style="font-size: small;">Ficheros Admitidos: pdf, microsoft word, imagenes, comprimidos (jpg,png,gif,bmp,zip) hasta 10MB</div>';
						}

						echo '<input type="text" name="txtRequisitos" id="txtRequisitos" value="' . count($data['requisitos']) . '" hidden>';
						echo '<div style="padding: 1em 2em 1em 2em;"><table class="borde_color_suave"><tbody><tr>';
						for ($i=1; $i<=count($data['requisitos']); $i++) {
							if($lang=='en' || $lang=='en_GB')
							{
								echo '<td>';
								if($data['requisitos'][$i-1]->getObligatorio())
								{
									echo '<span class="red">*</span>';
								}
								echo 'Requirement ' . $i . '</td>';
							}
							else
							{
								echo '<td>';
								if($data['requisitos'][$i-1]->getObligatorio())
								{
									echo '<span class="red">*</span>';
								}
								echo 'Requisito ' . $i . '</td>';
							}
							echo '<td><input type="file" name="R' . $i . '_A" id="flReq' . $i . 'A" accept=".doc,.docx,application/msword,.pdf,application/pdf,.jpg,.jpeg,image/jpg,.png,image/png,.bmp,image/bmp,.gif,image/gif,.zip" class="small_padding"';
							if($data['requisitos'][$i-1]->getObligatorio())
							{
								echo ' required ';
							}
							echo '><span class="remove-cursor" name="SR' . $i . '_A" id="SRrt' . $i . 'A" hidden><svg fill="#1A1A1A" xmlns="http://www.w3.org/2000/svg"  viewBox="0 0 50 50" width="25px" height="25px"><path d="M 21.857422 7 C 20.282422 7 19 8.2824219 19 9.8574219 L 19 13 L 10.5 13 C 10.224 13 10 13.224 10 13.5 C 10 13.776 10.224 14 10.5 14 L 12.925781 14 L 14.292969 38.607422 C 14.399969 40.509422 15.974906 42 17.878906 42 L 32.121094 42 C 34.025094 42 35.601031 40.510375 35.707031 38.609375 L 37.074219 14 L 39.5 14 C 39.776 14 40 13.776 40 13.5 C 40 13.224 39.776 13 39.5 13 L 31 13 L 31 9.8574219 C 31 8.2824219 29.717578 7 28.142578 7 L 21.857422 7 z M 21.857422 8 L 28.142578 8 C 29.166578 8 30 8.8334219 30 9.8574219 L 30 13 L 20 13 L 20 9.8574219 C 20 8.8334219 20.832422 8 21.857422 8 z M 13.927734 14 L 36.072266 14 L 34.708984 38.552734 C 34.631984 39.924734 33.495094 41 32.121094 41 L 17.878906 41 C 16.504906 41 15.368016 39.925734 15.291016 38.552734 L 13.927734 14 z M 19.169922 19 C 18.894922 19.009 18.6775 19.241578 18.6875 19.517578 L 19.242188 35.517578 C 19.252187 35.787578 19.473188 35.998047 19.742188 35.998047 L 19.761719 35.998047 C 20.036719 35.989047 20.252188 35.758422 20.242188 35.482422 L 19.6875 19.482422 C 19.6785 19.206422 19.436922 18.962 19.169922 19 z M 25 19 C 24.724 19 24.5 19.224 24.5 19.5 L 24.5 35.431641 C 24.5 35.707641 24.724 35.931641 25 35.931641 C 25.276 35.931641 25.5 35.707641 25.5 35.431641 L 25.5 19.5 C 25.5 19.224 25.276 19 25 19 z M 30.830078 19 C 30.545078 18.98 30.3225 19.207422 30.3125 19.482422 L 29.755859 35.482422 C 29.745859 35.758422 29.963281 35.989047 30.238281 35.998047 L 30.255859 35.998047 C 30.524859 35.998047 30.745859 35.787578 30.755859 35.517578 L 31.3125 19.517578 C 31.3225 19.241578 31.105078 19.009 30.830078 19 z"/></svg></span><p class="nomargin"></p>';
							echo '<input type="file" name="R' . $i . '_R" id="flReq' . $i . 'R" accept=".doc,.docx,application/msword,.pdf,application/pdf,.jpg,.jpeg,image/jpg,.png,image/png,.bmp,image/bmp,.gif,image/gif,.zip" class="small_padding" hidden><span class="remove-cursor" name="SR' . $i . '_R" id="SRrt' . $i . 'R" hidden><svg fill="#1A1A1A" xmlns="http://www.w3.org/2000/svg"  viewBox="0 0 50 50" width="25px" height="25px"><path d="M 21.857422 7 C 20.282422 7 19 8.2824219 19 9.8574219 L 19 13 L 10.5 13 C 10.224 13 10 13.224 10 13.5 C 10 13.776 10.224 14 10.5 14 L 12.925781 14 L 14.292969 38.607422 C 14.399969 40.509422 15.974906 42 17.878906 42 L 32.121094 42 C 34.025094 42 35.601031 40.510375 35.707031 38.609375 L 37.074219 14 L 39.5 14 C 39.776 14 40 13.776 40 13.5 C 40 13.224 39.776 13 39.5 13 L 31 13 L 31 9.8574219 C 31 8.2824219 29.717578 7 28.142578 7 L 21.857422 7 z M 21.857422 8 L 28.142578 8 C 29.166578 8 30 8.8334219 30 9.8574219 L 30 13 L 20 13 L 20 9.8574219 C 20 8.8334219 20.832422 8 21.857422 8 z M 13.927734 14 L 36.072266 14 L 34.708984 38.552734 C 34.631984 39.924734 33.495094 41 32.121094 41 L 17.878906 41 C 16.504906 41 15.368016 39.925734 15.291016 38.552734 L 13.927734 14 z M 19.169922 19 C 18.894922 19.009 18.6775 19.241578 18.6875 19.517578 L 19.242188 35.517578 C 19.252187 35.787578 19.473188 35.998047 19.742188 35.998047 L 19.761719 35.998047 C 20.036719 35.989047 20.252188 35.758422 20.242188 35.482422 L 19.6875 19.482422 C 19.6785 19.206422 19.436922 18.962 19.169922 19 z M 25 19 C 24.724 19 24.5 19.224 24.5 19.5 L 24.5 35.431641 C 24.5 35.707641 24.724 35.931641 25 35.931641 C 25.276 35.931641 25.5 35.707641 25.5 35.431641 L 25.5 19.5 C 25.5 19.224 25.276 19 25 19 z M 30.830078 19 C 30.545078 18.98 30.3225 19.207422 30.3125 19.482422 L 29.755859 35.482422 C 29.745859 35.758422 29.963281 35.989047 30.238281 35.998047 L 30.255859 35.998047 C 30.524859 35.998047 30.745859 35.787578 30.755859 35.517578 L 31.3125 19.517578 C 31.3225 19.241578 31.105078 19.009 30.830078 19 z"/></svg></span></td>';
							echo '</tr>';

							echo'<script language="javascript">
							var x = ' . $i .';
							filesA[x-1]= document.getElementById("flReq' . $i . 'A");

							filesA[x-1].onchange = function(e) {
								var flR = document.getElementById("flReq' . $i . 'R");
								var SMrt = document.getElementById("SRrt' . $i . 'A");
								var ext = this.value.match(/\.([^\.]+)$/)[1];
								switch (ext) {
									case "doc":
									case "docx":
									case "pdf":
									case "jpg":
									case "jpeg":
									case "png":
									case "bmp":
									case "gif":
									case "zip":
										//alert("Allowed");
										this.style.fontWeight="bold";
										flR.hidden = false;
										SMrt.hidden = false;
									break;
									default:
										//alert("Not allowed");
										this.value = "";
										this.style.fontWeight="unset";
										flR.hidden = true;
									break;
								}
							};

							spanA1[x-1] = document.getElementById("SRrt' . $i . 'A");
							spanA1[x-1].onclick = function(e) {							
								var flR = document.getElementById("flReq' . $i . 'R");
								document.getElementById("flReq' . $i . 'A").value = null;
								document.getElementById("flReq' . $i . 'A").style.fontWeight="normal"
								flR.hidden = true;
								this.hidden = true;
							}

							
							filesR[x-1]= document.getElementById("flReq' . $i . 'R");
							filesR[x-1].onchange = function(e) {
								var SMrt = document.getElementById("SRrt' . $i . 'R");
								var ext = this.value.match(/\.([^\.]+)$/)[1];
								switch (ext) {
									case "doc":
									case "docx":
									case "pdf":
									case "jpg":
									case "jpeg":
									case "png":
									case "bmp":
									case "gif":
									case "zip":
										//alert("Allowed");
										this.style.fontWeight="bold";
										SMrt.hidden = false;
									break;
									default:
										//alert("Not allowed");
										this.value = "";
										this.style.fontWeight="unset";
										//this.hidden = true;
									break;
								}
							};
							
							spanR1[x-1] = document.getElementById("SRrt' . $i . 'R");
							spanR1[x-1].onclick = function(e) {							
								var flR = document.getElementById("flReq' . $i . 'R");
								document.getElementById("flReq' . $i . 'R").value = null;
								flR.style.fontWeight="unset";
								this.hidden = true;
							}
							</script>';
						}
						echo '</tbody></table></div>';
						echo '</section>';
					}
				} else {
					echo '
						<script>
						var filesA = [];
						var filesR = [];
						var spanA1 = [];
						var spanR1 = [];
						var spanA = [];
						var spanR = [];
						</script>
					';

                    echo '<h1 class="nomargin">' . __('Uploaded Files', 'panoramic_child') . '</h1>';
                    echo'
			<table border=0>
				<tbody>
					<tr>
						<td colspan=3>
							<br>
							<table class="border_2">
								<thead></thead>
								<tbody>';
                    try
                    {
                        //Cargamos las variables de entorno
                        $load = new PortalEmpleo\Utils\Load();
                        if($load->loadEnv() == null || !isset($_ENV))
                        {
                            throw $this->createNotFoundException(
                                'No se han podido cargar las variables de entorno.'
                            );
                            return;
                        }

                        //Accedemos a la carpeta del candidato y despues a la de la candidatura
                        $rutaCandidato = $_SERVER["DOCUMENT_ROOT"].$_ENV['FILES_DIR'].$_ENV['CANDIDATE_FILES_DIR'];
                        $rutaConvocatoria = '/' .($data['candidato']->getCodigousuariowp())->getId().'//C'. $_POST['convocatoriaId'] .'//';
                        $rutaCandidatoConvocatoria = $rutaCandidato . $rutaConvocatoria;

                        if (file_exists($rutaCandidatoConvocatoria))
                        {
                            //Recogemos todos los archivos que hay
                            $files = scandir($rutaCandidatoConvocatoria);
                            $files = array_diff(scandir($rutaCandidatoConvocatoria), array('.', '..'));

                            if(count($files) > 0)
                            {
                                foreach ($files as $key => $value) {
                                    echo '<tr class="cebra link subrayado"><td class="colornormal"><a href="' . $root . 'descarga/?id=' . ($data['candidato']->getCodigousuariowp())->getId() . '&file=' . basename($value) . '&cvt=' . $data['convocatoria']->getIdconvocatoria() . '" target="_blank">' . basename($value)  . '</a></td></tr>';
                                }
                            }
                            else
                            {
                                echo '<tr><td><label class="margenes_laterales_4 color_original_reducido">' . __('There are not files uploaded for this call by the candidate', 'panoramic_child') . '</label></td></tr>';


                            }
                        }
                        else
                        {
                            if($lang=='en' || $lang=='en_GB')
                            {
                                echo '<tr><td><label class="margenes_laterales_4 color_original_reducido">There are not files uploaded for this call by the candidate</label></td></tr>';
                            }
                            else
                            {
                                echo '<tr><td><label class="margenes_laterales_4 color_original_reducido">No hay archivos subidos por parte del candidato para esta convocatoria</label></td></tr>';
                            }
                        }
                    }
                    catch (Exception $exception)
                    {
                        if($lang=='en' || $lang=='en_GB')
                        {
                            echo 'Candidate\'s uploaded files for this call cannot be loaded';
                        }
                        else
                        {
                            echo 'No se han podido cargar los archivos de este candidato para esta candidatura';
                        }
                    }
                    echo '	
								</tbody>
							</table>';







                    if(isset($data['requisitos']) && $data['requisitos']!= null)
					{
						echo '<hr><section id="inforequisitos">';

						echo '<input type="text" name="txtRequisitos" id="txtRequisitos" value="' . count($data['requisitos']) . '" hidden>';
						echo '<div style="padding: 1em 2em 1em 2em;"><table class="borde_color_suave"><tbody><tr>';
						for ($i=1; $i<=1; $i++) {
							if($lang=='en' || $lang=='en_GB')
							{
								echo '<td>Requirements</td>';
							}
							else
							{
								echo '<td>Requisitos</td>';
							}

							echo '<td><input type="file" name="R' . $i . '_A" id="flReq' . $i . 'A" accept=".doc,.docx,application/msword,.pdf,application/pdf,.jpg,.jpeg,image/jpg,.png,image/png,.bmp,image/bmp,.gif,image/gif,.zip" class="small_padding"';
							echo '><span class="remove-cursor" name="SR' . $i . '_A" id="SRrt' . $i . 'A" hidden><svg fill="#1A1A1A" xmlns="http://www.w3.org/2000/svg"  viewBox="0 0 50 50" width="25px" height="25px"><path d="M 21.857422 7 C 20.282422 7 19 8.2824219 19 9.8574219 L 19 13 L 10.5 13 C 10.224 13 10 13.224 10 13.5 C 10 13.776 10.224 14 10.5 14 L 12.925781 14 L 14.292969 38.607422 C 14.399969 40.509422 15.974906 42 17.878906 42 L 32.121094 42 C 34.025094 42 35.601031 40.510375 35.707031 38.609375 L 37.074219 14 L 39.5 14 C 39.776 14 40 13.776 40 13.5 C 40 13.224 39.776 13 39.5 13 L 31 13 L 31 9.8574219 C 31 8.2824219 29.717578 7 28.142578 7 L 21.857422 7 z M 21.857422 8 L 28.142578 8 C 29.166578 8 30 8.8334219 30 9.8574219 L 30 13 L 20 13 L 20 9.8574219 C 20 8.8334219 20.832422 8 21.857422 8 z M 13.927734 14 L 36.072266 14 L 34.708984 38.552734 C 34.631984 39.924734 33.495094 41 32.121094 41 L 17.878906 41 C 16.504906 41 15.368016 39.925734 15.291016 38.552734 L 13.927734 14 z M 19.169922 19 C 18.894922 19.009 18.6775 19.241578 18.6875 19.517578 L 19.242188 35.517578 C 19.252187 35.787578 19.473188 35.998047 19.742188 35.998047 L 19.761719 35.998047 C 20.036719 35.989047 20.252188 35.758422 20.242188 35.482422 L 19.6875 19.482422 C 19.6785 19.206422 19.436922 18.962 19.169922 19 z M 25 19 C 24.724 19 24.5 19.224 24.5 19.5 L 24.5 35.431641 C 24.5 35.707641 24.724 35.931641 25 35.931641 C 25.276 35.931641 25.5 35.707641 25.5 35.431641 L 25.5 19.5 C 25.5 19.224 25.276 19 25 19 z M 30.830078 19 C 30.545078 18.98 30.3225 19.207422 30.3125 19.482422 L 29.755859 35.482422 C 29.745859 35.758422 29.963281 35.989047 30.238281 35.998047 L 30.255859 35.998047 C 30.524859 35.998047 30.745859 35.787578 30.755859 35.517578 L 31.3125 19.517578 C 31.3225 19.241578 31.105078 19.009 30.830078 19 z"/></svg></span><p class="nomargin"></p>';
							echo '<input type="file" name="R' . $i . '_R" id="flReq' . $i . 'R" accept=".doc,.docx,application/msword,.pdf,application/pdf,.jpg,.jpeg,image/jpg,.png,image/png,.bmp,image/bmp,.gif,image/gif,.zip" class="small_padding" hidden><span class="remove-cursor" name="SR' . $i . '_R" id="SRrt' . $i . 'R" hidden><svg fill="#1A1A1A" xmlns="http://www.w3.org/2000/svg"  viewBox="0 0 50 50" width="25px" height="25px"><path d="M 21.857422 7 C 20.282422 7 19 8.2824219 19 9.8574219 L 19 13 L 10.5 13 C 10.224 13 10 13.224 10 13.5 C 10 13.776 10.224 14 10.5 14 L 12.925781 14 L 14.292969 38.607422 C 14.399969 40.509422 15.974906 42 17.878906 42 L 32.121094 42 C 34.025094 42 35.601031 40.510375 35.707031 38.609375 L 37.074219 14 L 39.5 14 C 39.776 14 40 13.776 40 13.5 C 40 13.224 39.776 13 39.5 13 L 31 13 L 31 9.8574219 C 31 8.2824219 29.717578 7 28.142578 7 L 21.857422 7 z M 21.857422 8 L 28.142578 8 C 29.166578 8 30 8.8334219 30 9.8574219 L 30 13 L 20 13 L 20 9.8574219 C 20 8.8334219 20.832422 8 21.857422 8 z M 13.927734 14 L 36.072266 14 L 34.708984 38.552734 C 34.631984 39.924734 33.495094 41 32.121094 41 L 17.878906 41 C 16.504906 41 15.368016 39.925734 15.291016 38.552734 L 13.927734 14 z M 19.169922 19 C 18.894922 19.009 18.6775 19.241578 18.6875 19.517578 L 19.242188 35.517578 C 19.252187 35.787578 19.473188 35.998047 19.742188 35.998047 L 19.761719 35.998047 C 20.036719 35.989047 20.252188 35.758422 20.242188 35.482422 L 19.6875 19.482422 C 19.6785 19.206422 19.436922 18.962 19.169922 19 z M 25 19 C 24.724 19 24.5 19.224 24.5 19.5 L 24.5 35.431641 C 24.5 35.707641 24.724 35.931641 25 35.931641 C 25.276 35.931641 25.5 35.707641 25.5 35.431641 L 25.5 19.5 C 25.5 19.224 25.276 19 25 19 z M 30.830078 19 C 30.545078 18.98 30.3225 19.207422 30.3125 19.482422 L 29.755859 35.482422 C 29.745859 35.758422 29.963281 35.989047 30.238281 35.998047 L 30.255859 35.998047 C 30.524859 35.998047 30.745859 35.787578 30.755859 35.517578 L 31.3125 19.517578 C 31.3225 19.241578 31.105078 19.009 30.830078 19 z"/></svg></span></td>';
							echo '</tr>';

							echo'<script language="javascript">
							var x = ' . $i .';
							filesA[x-1]= document.getElementById("flReq' . $i . 'A");

							filesA[x-1].onchange = function(e) {
								var flR = document.getElementById("flReq' . $i . 'R");
								var SMrt = document.getElementById("SRrt' . $i . 'A");
								var ext = this.value.match(/\.([^\.]+)$/)[1];
								switch (ext) {
									case "doc":
									case "docx":
									case "pdf":
									case "jpg":
									case "jpeg":
									case "png":
									case "bmp":
									case "gif":
									case "zip":
										//alert("Allowed");
										this.style.fontWeight="bold";
										flR.hidden = false;
										SMrt.hidden = false;
									break;
									default:
										//alert("Not allowed");
										this.value = "";
										this.style.fontWeight="unset";
										flR.hidden = true;
									break;
								}
							};

							spanA1[x-1] = document.getElementById("SRrt' . $i . 'A");
							spanA1[x-1].onclick = function(e) {							
								var flR = document.getElementById("flReq' . $i . 'R");
								document.getElementById("flReq' . $i . 'A").value = null;
								document.getElementById("flReq' . $i . 'A").style.fontWeight="normal"
								flR.hidden = true;
								this.hidden = true;
							}

							
							filesR[x-1]= document.getElementById("flReq' . $i . 'R");
							filesR[x-1].onchange = function(e) {
								var SMrt = document.getElementById("SRrt' . $i . 'R");
								var ext = this.value.match(/\.([^\.]+)$/)[1];
								switch (ext) {
									case "doc":
									case "docx":
									case "pdf":
									case "jpg":
									case "jpeg":
									case "png":
									case "bmp":
									case "gif":
									case "zip":
										//alert("Allowed");
										this.style.fontWeight="bold";
										SMrt.hidden = false;
									break;
									default:
										//alert("Not allowed");
										this.value = "";
										this.style.fontWeight="unset";
										//this.hidden = true;
									break;
								}
							};
							
							spanR1[x-1] = document.getElementById("SRrt' . $i . 'R");
							spanR1[x-1].onclick = function(e) {							
								var flR = document.getElementById("flReq' . $i . 'R");
								document.getElementById("flReq' . $i . 'R").value = null;
								flR.style.fontWeight="unset";
								this.hidden = true;
							}
							</script>';
						}
						echo '</tbody></table></div>';
						echo '</section>';
					}					
				}
				if (!isset($_POST['isEdit'])) {

                   	if(isset($data['meritos']) && $data['meritos']!= null)
					{
						echo '<hr><section id="infomeritos"><div class="fondo_color header-image">';
						if($lang=='en' || $lang=='en_GB')
						{
							echo '<span class="underline bold">Merits</span>:';
							echo '<br><br><ul class="lista_none">';
							$i = 1;
							foreach ($data['meritos'] as $mrt) {
								echo '<li><span class="bold">Merit '. $i . ': ' . $mrt->getMerito() . '</span></li><li>' . $mrt->getDescripcion() . '</li>';
								if($mrt != $data['meritos'][count($data['meritos'])-1])
								{
									echo '<br>';
								}
								$i++;
							}
							echo '</ul>';
						}
						else
						{
							echo '<span class="underline bold">M&eacute;ritos</span>:';
							echo '<br><br><ul class="lista_none">';
							$i = 1;
							foreach ($data['meritos'] as $mrt) {
								echo '<li><span class="bold">M&eacute;rito '. $i . ': ' . $mrt->getMerito() . '</span></li><li>' . $mrt->getDescripcion() . '</li>';
								if($mrt != $data['meritos'][count($data['meritos'])-1])
								{
									echo '<br>';
								}
								$i++;
							}
							echo '</ul>';
						}
						echo '</div>';

						if($lang=='en' || $lang=='en_GB')
						{
							echo '<br>If you meet any merit of the call, please attach the necessary documentary evidence';
							echo '<br><div style="font-size: small;">Admitted Files: pdf, microsoft word, images, compress (jpg,png,gif,bmp,zip) until 10MB</div>';
						}
						else
						{
							echo '<br>Si cumples con alg&uacute;n m&eacute;rito, adjunta los archivos necesarios';
							echo '<br><div style="font-size: small;">Ficheros Admitidos: pdf, microsoft word, imagenes, comprimidos (jpg,png,gif,bmp,zip) hasta 10MB</div>';
						}

						echo '<input type="text" name="txtMeritos" id="txtMeritos" value="' . count($data['meritos']) . '" hidden>';
						echo '<div style="padding: 1em 2em 1em 2em;"><table class="borde_color_suave"><tbody><tr>';
						for ($i=1; $i<=count($data['meritos']); $i++) {
							if($lang=='en' || $lang=='en_GB')
							{
								echo '<td>Merit ' . $i . '</td>';
							}
							else
							{
								echo '<td>M&eacute;rito ' . $i . '</td>';
							}
							echo '<td><input type="file" name="M' . $i . '_A" id="flMrt' . $i . 'A" accept=".doc,.docx,application/msword,.pdf,application/pdf,.jpg,.jpeg,image/jpg,.png,image/png,.bmp,image/bmp,.gif,image/gif,.zip" class="small_padding"><span class="remove-cursor" name="S' . $i . '_A" id="SMrt' . $i . 'A" hidden><svg fill="#1A1A1A" xmlns="http://www.w3.org/2000/svg"  viewBox="0 0 50 50" width="25px" height="25px"><path d="M 21.857422 7 C 20.282422 7 19 8.2824219 19 9.8574219 L 19 13 L 10.5 13 C 10.224 13 10 13.224 10 13.5 C 10 13.776 10.224 14 10.5 14 L 12.925781 14 L 14.292969 38.607422 C 14.399969 40.509422 15.974906 42 17.878906 42 L 32.121094 42 C 34.025094 42 35.601031 40.510375 35.707031 38.609375 L 37.074219 14 L 39.5 14 C 39.776 14 40 13.776 40 13.5 C 40 13.224 39.776 13 39.5 13 L 31 13 L 31 9.8574219 C 31 8.2824219 29.717578 7 28.142578 7 L 21.857422 7 z M 21.857422 8 L 28.142578 8 C 29.166578 8 30 8.8334219 30 9.8574219 L 30 13 L 20 13 L 20 9.8574219 C 20 8.8334219 20.832422 8 21.857422 8 z M 13.927734 14 L 36.072266 14 L 34.708984 38.552734 C 34.631984 39.924734 33.495094 41 32.121094 41 L 17.878906 41 C 16.504906 41 15.368016 39.925734 15.291016 38.552734 L 13.927734 14 z M 19.169922 19 C 18.894922 19.009 18.6775 19.241578 18.6875 19.517578 L 19.242188 35.517578 C 19.252187 35.787578 19.473188 35.998047 19.742188 35.998047 L 19.761719 35.998047 C 20.036719 35.989047 20.252188 35.758422 20.242188 35.482422 L 19.6875 19.482422 C 19.6785 19.206422 19.436922 18.962 19.169922 19 z M 25 19 C 24.724 19 24.5 19.224 24.5 19.5 L 24.5 35.431641 C 24.5 35.707641 24.724 35.931641 25 35.931641 C 25.276 35.931641 25.5 35.707641 25.5 35.431641 L 25.5 19.5 C 25.5 19.224 25.276 19 25 19 z M 30.830078 19 C 30.545078 18.98 30.3225 19.207422 30.3125 19.482422 L 29.755859 35.482422 C 29.745859 35.758422 29.963281 35.989047 30.238281 35.998047 L 30.255859 35.998047 C 30.524859 35.998047 30.745859 35.787578 30.755859 35.517578 L 31.3125 19.517578 C 31.3225 19.241578 31.105078 19.009 30.830078 19 z"/></svg></span><p class="nomargin"></p>';
							echo '<input type="file" name="M' . $i . '_R" id="flMrt' . $i . 'R" accept=".doc,.docx,application/msword,.pdf,application/pdf,.jpg,.jpeg,image/jpg,.png,image/png,.bmp,image/bmp,.gif,image/gif,.zip" class="small_padding" hidden><span class="remove-cursor" name="S' . $i . '_R" id="SMrt' . $i . 'R" hidden><svg fill="#1A1A1A" xmlns="http://www.w3.org/2000/svg"  viewBox="0 0 50 50" width="25px" height="25px"><path d="M 21.857422 7 C 20.282422 7 19 8.2824219 19 9.8574219 L 19 13 L 10.5 13 C 10.224 13 10 13.224 10 13.5 C 10 13.776 10.224 14 10.5 14 L 12.925781 14 L 14.292969 38.607422 C 14.399969 40.509422 15.974906 42 17.878906 42 L 32.121094 42 C 34.025094 42 35.601031 40.510375 35.707031 38.609375 L 37.074219 14 L 39.5 14 C 39.776 14 40 13.776 40 13.5 C 40 13.224 39.776 13 39.5 13 L 31 13 L 31 9.8574219 C 31 8.2824219 29.717578 7 28.142578 7 L 21.857422 7 z M 21.857422 8 L 28.142578 8 C 29.166578 8 30 8.8334219 30 9.8574219 L 30 13 L 20 13 L 20 9.8574219 C 20 8.8334219 20.832422 8 21.857422 8 z M 13.927734 14 L 36.072266 14 L 34.708984 38.552734 C 34.631984 39.924734 33.495094 41 32.121094 41 L 17.878906 41 C 16.504906 41 15.368016 39.925734 15.291016 38.552734 L 13.927734 14 z M 19.169922 19 C 18.894922 19.009 18.6775 19.241578 18.6875 19.517578 L 19.242188 35.517578 C 19.252187 35.787578 19.473188 35.998047 19.742188 35.998047 L 19.761719 35.998047 C 20.036719 35.989047 20.252188 35.758422 20.242188 35.482422 L 19.6875 19.482422 C 19.6785 19.206422 19.436922 18.962 19.169922 19 z M 25 19 C 24.724 19 24.5 19.224 24.5 19.5 L 24.5 35.431641 C 24.5 35.707641 24.724 35.931641 25 35.931641 C 25.276 35.931641 25.5 35.707641 25.5 35.431641 L 25.5 19.5 C 25.5 19.224 25.276 19 25 19 z M 30.830078 19 C 30.545078 18.98 30.3225 19.207422 30.3125 19.482422 L 29.755859 35.482422 C 29.745859 35.758422 29.963281 35.989047 30.238281 35.998047 L 30.255859 35.998047 C 30.524859 35.998047 30.745859 35.787578 30.755859 35.517578 L 31.3125 19.517578 C 31.3225 19.241578 31.105078 19.009 30.830078 19 z"/></svg></span></td>';
							echo '</tr>';

							echo'<script language="javascript">
							var x = ' . $i .';
							filesA[x-1]= document.getElementById("flMrt' . $i . 'A");
							filesA[x-1].onchange = function(e) {
								var flR = document.getElementById("flMrt' . $i . 'R");
								var SMrt = document.getElementById("SMrt' . $i . 'A");
								var ext = this.value.match(/\.([^\.]+)$/)[1];
								switch (ext) {
									case "doc":
									case "docx":
									case "pdf":
									case "jpg":
									case "jpeg":
									case "png":
									case "bmp":
									case "gif":
									case "zip":
										//alert("Allowed");
										this.style.fontWeight="bold";
										flR.hidden = false;
										SMrt.hidden = false;
									break;
									default:
										//alert("Not allowed");
										this.value = "";
										this.style.fontWeight="unset";
										flR.hidden = true;
									break;
								}
							};
							
							spanA[x-1] = document.getElementById("SMrt' . $i . 'A");
							spanA[x-1].onclick = function(e) {							
								var flR = document.getElementById("flMrt' . $i . 'R");
								document.getElementById("flMrt' . $i . 'A").value = null;
								document.getElementById("flMrt' . $i . 'A").style.fontWeight="normal"
								flR.hidden = true;
								this.hidden = true;
							}
							
							
							filesR[x-1]= document.getElementById("flMrt' . $i . 'R");
							filesR[x-1].onchange = function(e) {
								var SMrt = document.getElementById("SMrt' . $i . 'R");
								var ext = this.value.match(/\.([^\.]+)$/)[1];
								switch (ext) {
									case "doc":
									case "docx":
									case "pdf":
									case "jpg":
									case "jpeg":
									case "png":
									case "bmp":
									case "gif":
									case "zip":
										//alert("Allowed");
										this.style.fontWeight="bold";
										SMrt.hidden = false;
									break;
									default:
										//alert("Not allowed");
										this.value = "";
										this.style.fontWeight="unset";
									break;
								}
							};
							
							spanR[x-1] = document.getElementById("SMrt' . $i . 'R");
							spanR[x-1].onclick = function(e) {							
								document.getElementById("flMrt' . $i . 'R").value = null;
								document.getElementById("flMrt' . $i . 'R").style.fontWeight="normal"
								this.hidden = true;
							}
							</script>';
						}
						echo '</tbody></table></div>';
						echo '</section>';
					}
				} else {
					if(isset($data['meritos']) && $data['meritos']!= null)
					{
						echo '<hr><section id="infomeritos">';

						echo '<input type="text" name="txtMeritos" id="txtMeritos" value="' . count($data['meritos']) . '" hidden>';
						echo '<div style="padding: 1em 2em 1em 2em;"><table class="borde_color_suave"><tbody><tr>';
						for ($i=1; $i<=1; $i++) {
							if($lang=='en' || $lang=='en_GB')
							{
								echo '<td>Merits</td>';
							}
							else
							{
								echo '<td>M&eacute;ritos</td>';
							}
							echo '<td><input type="file" name="M' . $i . '_A" id="flMrt' . $i . 'A" accept=".doc,.docx,application/msword,.pdf,application/pdf,.jpg,.jpeg,image/jpg,.png,image/png,.bmp,image/bmp,.gif,image/gif,.zip" class="small_padding"><span class="remove-cursor" name="S' . $i . '_A" id="SMrt' . $i . 'A" hidden><svg fill="#1A1A1A" xmlns="http://www.w3.org/2000/svg"  viewBox="0 0 50 50" width="25px" height="25px"><path d="M 21.857422 7 C 20.282422 7 19 8.2824219 19 9.8574219 L 19 13 L 10.5 13 C 10.224 13 10 13.224 10 13.5 C 10 13.776 10.224 14 10.5 14 L 12.925781 14 L 14.292969 38.607422 C 14.399969 40.509422 15.974906 42 17.878906 42 L 32.121094 42 C 34.025094 42 35.601031 40.510375 35.707031 38.609375 L 37.074219 14 L 39.5 14 C 39.776 14 40 13.776 40 13.5 C 40 13.224 39.776 13 39.5 13 L 31 13 L 31 9.8574219 C 31 8.2824219 29.717578 7 28.142578 7 L 21.857422 7 z M 21.857422 8 L 28.142578 8 C 29.166578 8 30 8.8334219 30 9.8574219 L 30 13 L 20 13 L 20 9.8574219 C 20 8.8334219 20.832422 8 21.857422 8 z M 13.927734 14 L 36.072266 14 L 34.708984 38.552734 C 34.631984 39.924734 33.495094 41 32.121094 41 L 17.878906 41 C 16.504906 41 15.368016 39.925734 15.291016 38.552734 L 13.927734 14 z M 19.169922 19 C 18.894922 19.009 18.6775 19.241578 18.6875 19.517578 L 19.242188 35.517578 C 19.252187 35.787578 19.473188 35.998047 19.742188 35.998047 L 19.761719 35.998047 C 20.036719 35.989047 20.252188 35.758422 20.242188 35.482422 L 19.6875 19.482422 C 19.6785 19.206422 19.436922 18.962 19.169922 19 z M 25 19 C 24.724 19 24.5 19.224 24.5 19.5 L 24.5 35.431641 C 24.5 35.707641 24.724 35.931641 25 35.931641 C 25.276 35.931641 25.5 35.707641 25.5 35.431641 L 25.5 19.5 C 25.5 19.224 25.276 19 25 19 z M 30.830078 19 C 30.545078 18.98 30.3225 19.207422 30.3125 19.482422 L 29.755859 35.482422 C 29.745859 35.758422 29.963281 35.989047 30.238281 35.998047 L 30.255859 35.998047 C 30.524859 35.998047 30.745859 35.787578 30.755859 35.517578 L 31.3125 19.517578 C 31.3225 19.241578 31.105078 19.009 30.830078 19 z"/></svg></span><p class="nomargin"></p>';
							echo '<input type="file" name="M' . $i . '_R" id="flMrt' . $i . 'R" accept=".doc,.docx,application/msword,.pdf,application/pdf,.jpg,.jpeg,image/jpg,.png,image/png,.bmp,image/bmp,.gif,image/gif,.zip" class="small_padding" hidden><span class="remove-cursor" name="S' . $i . '_R" id="SMrt' . $i . 'R" hidden><svg fill="#1A1A1A" xmlns="http://www.w3.org/2000/svg"  viewBox="0 0 50 50" width="25px" height="25px"><path d="M 21.857422 7 C 20.282422 7 19 8.2824219 19 9.8574219 L 19 13 L 10.5 13 C 10.224 13 10 13.224 10 13.5 C 10 13.776 10.224 14 10.5 14 L 12.925781 14 L 14.292969 38.607422 C 14.399969 40.509422 15.974906 42 17.878906 42 L 32.121094 42 C 34.025094 42 35.601031 40.510375 35.707031 38.609375 L 37.074219 14 L 39.5 14 C 39.776 14 40 13.776 40 13.5 C 40 13.224 39.776 13 39.5 13 L 31 13 L 31 9.8574219 C 31 8.2824219 29.717578 7 28.142578 7 L 21.857422 7 z M 21.857422 8 L 28.142578 8 C 29.166578 8 30 8.8334219 30 9.8574219 L 30 13 L 20 13 L 20 9.8574219 C 20 8.8334219 20.832422 8 21.857422 8 z M 13.927734 14 L 36.072266 14 L 34.708984 38.552734 C 34.631984 39.924734 33.495094 41 32.121094 41 L 17.878906 41 C 16.504906 41 15.368016 39.925734 15.291016 38.552734 L 13.927734 14 z M 19.169922 19 C 18.894922 19.009 18.6775 19.241578 18.6875 19.517578 L 19.242188 35.517578 C 19.252187 35.787578 19.473188 35.998047 19.742188 35.998047 L 19.761719 35.998047 C 20.036719 35.989047 20.252188 35.758422 20.242188 35.482422 L 19.6875 19.482422 C 19.6785 19.206422 19.436922 18.962 19.169922 19 z M 25 19 C 24.724 19 24.5 19.224 24.5 19.5 L 24.5 35.431641 C 24.5 35.707641 24.724 35.931641 25 35.931641 C 25.276 35.931641 25.5 35.707641 25.5 35.431641 L 25.5 19.5 C 25.5 19.224 25.276 19 25 19 z M 30.830078 19 C 30.545078 18.98 30.3225 19.207422 30.3125 19.482422 L 29.755859 35.482422 C 29.745859 35.758422 29.963281 35.989047 30.238281 35.998047 L 30.255859 35.998047 C 30.524859 35.998047 30.745859 35.787578 30.755859 35.517578 L 31.3125 19.517578 C 31.3225 19.241578 31.105078 19.009 30.830078 19 z"/></svg></span></td>';
							echo '</tr>';

							echo'<script language="javascript">
							var x = ' . $i .';
							filesA[x-1]= document.getElementById("flMrt' . $i . 'A");
							filesA[x-1].onchange = function(e) {
								var flR = document.getElementById("flMrt' . $i . 'R");
								var SMrt = document.getElementById("SMrt' . $i . 'A");
								var ext = this.value.match(/\.([^\.]+)$/)[1];
								switch (ext) {
									case "doc":
									case "docx":
									case "pdf":
									case "jpg":
									case "jpeg":
									case "png":
									case "bmp":
									case "gif":
									case "zip":
										//alert("Allowed");
										this.style.fontWeight="bold";
										flR.hidden = false;
										SMrt.hidden = false;
									break;
									default:
										//alert("Not allowed");
										this.value = "";
										this.style.fontWeight="unset";
										flR.hidden = true;
									break;
								}
							};
							
							spanA[x-1] = document.getElementById("SMrt' . $i . 'A");
							spanA[x-1].onclick = function(e) {							
								var flR = document.getElementById("flMrt' . $i . 'R");
								document.getElementById("flMrt' . $i . 'A").value = null;
								document.getElementById("flMrt' . $i . 'A").style.fontWeight="normal"
								flR.hidden = true;
								this.hidden = true;
							}
							
							
							filesR[x-1]= document.getElementById("flMrt' . $i . 'R");
							filesR[x-1].onchange = function(e) {
								var SMrt = document.getElementById("SMrt' . $i . 'R");
								var ext = this.value.match(/\.([^\.]+)$/)[1];
								switch (ext) {
									case "doc":
									case "docx":
									case "pdf":
									case "jpg":
									case "jpeg":
									case "png":
									case "bmp":
									case "gif":
									case "zip":
										//alert("Allowed");
										this.style.fontWeight="bold";
										SMrt.hidden = false;
									break;
									default:
										//alert("Not allowed");
										this.value = "";
										this.style.fontWeight="unset";
									break;
								}
							};
							
							spanR[x-1] = document.getElementById("SMrt' . $i . 'R");
							spanR[x-1].onclick = function(e) {							
								document.getElementById("flMrt' . $i . 'R").value = null;
								document.getElementById("flMrt' . $i . 'R").style.fontWeight="normal"
								this.hidden = true;
							}
							</script>';
						}
						echo '</tbody></table></div>';
						echo '</section>';
					}
				}
            }
        }
    }
    else
    {
        echo '<script language="javascript">history.back();</script>';
    }

    function generarHTML($nombrecombo, $lvalorescombo)
    {
        //generar el codigo html del combo y devolverlo
        $htmlcombo = '<select name="slct' . $nombrecombo . '" id="slct' . $nombrecombo . '" >';
            foreach ($lvalorescombo as $val) {
                $htmlcombo = $htmlcombo . '<option value="' . trim($val) . '" >' . trim($val) . '</option>';
            }
        $htmlcombo = $htmlcombo . '</select>';

        return $htmlcombo;
    }
?>

<?php
    echo '<table class="nomargin"><tbody><tr><td><input type="text" id="accionConvocatoria" name="accionConvocatoria" value="" hidden></td></tr></tbody></table>';
    if(isset($data['candidato']) && is_object($data['candidato']))
    {
        echo '<input type="text" name="txtCdt" id="txtCdt" value="' . $data['candidato']->getIdcandidato() . '" hidden>';
        echo '<input type="text" name="codigoUsuarioWP" id="codigoUsuarioWP" value="' . ($data['candidato']->getCodigousuariowp())->getId() . '" hidden>';
        echo '<input type="text" name="txtCvt" id="txtCvt" value="' . $data['convocatoria']->getIdconvocatoria() . '" hidden>';
    }
	if(!isset($_POST['isEdit'])) {
		if($lang=='en' || $lang=='en_GB')
		{
			if(isset($data['candidato']) && is_object($data['candidato'])) {
				echo '<input type="button" name="btnaccionConvocatoria" value="Register" onClick="fnccandidatoconvocatoriasubmit(this,\'' . trim($lang) . '\');">';
			}
		}
		else
		{
			if(isset($data['candidato']) && is_object($data['candidato'])) {
				echo '<input type="button" name="btnaccionConvocatoria" value="Inscribirse" onClick="fnccandidatoconvocatoriasubmit(this,\'' . trim($lang) . '\');">';
			}
		}
	} else {
		if($lang=='en' || $lang=='en_GB')
		{
			if(isset($data['candidato']) && is_object($data['candidato'])) {
				echo '<input type="button" name="btnaccionConvocatoria" value="Insert" onClick="fnccandidatoconvocatoriasubmit(this,\'' . trim($lang) . '\');">';
			}
		}
		else
		{
			if(isset($data['candidato']) && is_object($data['candidato'])) {
				echo '<input type="button" name="btnaccionConvocatoria" value="Insertar" onClick="fnccandidatoconvocatoriasubmit(this,\'' . trim($lang) . '\');">';
			}
		}	
	}
	
    echo '<script language="javascript">
    function validar() {
        if(document.getElementById("chkCVPerfil").checked ||  document.getElementById("flCV").value.trim().length>0)
        {
            return true;
        }
        
        return false;
    }';
        echo 'function validar_requisitos() {';
                            
            echo'var x = 0;';

            if ( isset($data['requisitos']) )
                echo 'x = ' . count($data['requisitos']) .';
           
                for(i=1 ; i<=x ; i++)
                {
                    var id= "flReq" + i + "A";

                    //alert(id);
                    if(document.getElementById(id).required == true && ( document.getElementById(id).value == null || document.getElementById(id).value.trim().length<=0))
                    {
                        return false;
                    }
                }
                return true;
            ';
        echo '}';
		
		if(!isset($_POST['isEdit'])) {
			echo 'function fnccandidatoconvocatoriasubmit(object,lang) {            
				var hasrequisitos = false;';
				if ( isset($data['requisitos']) ) {  
					echo 'hasrequisitos = true;';
				}
				echo 'if( validar() && validar_requisitos() && hasrequisitos )
				{
					if(lang=="en" || lang=="en_GB")
					{
						var msg = "Do you want to register at this call?";
					}
					else
					{
						var msg = "¿Quieres inscribirte en esta convocatoria?";
					}
					if(confirm(msg))
					{
						document.getElementById("accionConvocatoria").value = "InscribirCandidato";
						document.getElementById("frmInscripcionConvocatoria").submit();
					}
				}
				else
				{
					if(!validar())
					{
						if(lang=="en" || lang=="en_GB")
						{
							alert("You must attach a curriculum file or mark the check if you want to use your profile\'s one");
						}
						else 
						{
							alert("Debe adjuntar un curriculum o indicar que desea utilizar el de su perfil");
						}
					}
					else if(!hasrequisitos)
					{
						if(lang=="en" || lang=="en_GB")
						{
							alert("This Call not have requiriments yet");
						}
						else 
						{
							alert("Esta convocatoria no tiene requisitos aún");
						}
					}               
					else if(!validar_requisitos())
					{
						if(lang=="en" || lang=="en_GB")
						{
							alert("There are mandatory requirements, You must attach file(s) to certify that they are met");
						}
						else 
						{
							alert("Existen requisitos obligatorios, debe adjuntar algún archivo para demostrar que los cumple");
						}
					}

				}
			}';
		} else {
			echo 'function fnccandidatoconvocatoriasubmit(object,lang) {';
				echo '
				if(lang=="en" || lang=="en_GB")
				{
					var msg = "Do you want to register at this call?";
				}
				else
				{
					var msg = "¿Quieres inscribirte en esta convocatoria?";
				}
				if(confirm(msg))
				{
					document.getElementById("accionConvocatoria").value = "SubirDocCandidatoConv";
					document.getElementById("frmInscripcionConvocatoria").submit();
				}				
			}';		
		}
    
    echo '</script>';
?>