2020-07-26 22:03:40 +02:00
< ? php
2020-07-30 03:50:27 +02:00
/* Copyright ( C ) 2020 Laurent Destailleur < eldy @ users . sourceforge . net >
2020-07-26 22:03:40 +02:00
*
* This program is free software ; you can redistribute it and / or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation ; either version 3 of the License , or
* ( at your option ) any later version .
*
* This program is distributed in the hope that it will be useful ,
* but WITHOUT ANY WARRANTY ; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
* GNU General Public License for more details .
*
* You should have received a copy of the GNU General Public License
* along with this program . If not , see < https :// www . gnu . org / licenses />.
*/
/**
* \file htdocs / public / recruitment / view . php
* \ingroup recruitment
* \brief Public file to show on job
*/
2021-02-26 18:58:34 +01:00
if ( ! defined ( 'NOLOGIN' )) {
define ( " NOLOGIN " , 1 ); // This means this output page does not require to be logged.
}
if ( ! defined ( 'NOCSRFCHECK' )) {
define ( " NOCSRFCHECK " , 1 ); // We accept to go on this page from external web site.
}
if ( ! defined ( 'NOIPCHECK' )) {
define ( 'NOIPCHECK' , '1' ); // Do not check IP defined into conf $dolibarr_main_restrict_ip
}
if ( ! defined ( 'NOBROWSERNOTIF' )) {
define ( 'NOBROWSERNOTIF' , '1' );
}
2020-07-26 22:03:40 +02:00
require '../../main.inc.php' ;
require_once DOL_DOCUMENT_ROOT . '/recruitment/class/recruitmentjobposition.class.php' ;
require_once DOL_DOCUMENT_ROOT . '/core/class/CMailFile.class.php' ;
require_once DOL_DOCUMENT_ROOT . '/core/lib/security.lib.php' ;
require_once DOL_DOCUMENT_ROOT . '/core/lib/company.lib.php' ;
2021-06-15 16:11:25 +02:00
require_once DOL_DOCUMENT_ROOT . '/core/lib/payments.lib.php' ;
2020-07-26 22:03:40 +02:00
// Load translation files required by the page
$langs -> loadLangs ( array ( " companies " , " other " , " recruitment " ));
// Get parameters
$action = GETPOST ( 'action' , 'aZ09' );
2020-07-30 03:50:27 +02:00
$cancel = GETPOST ( 'cancel' , 'alpha' );
2020-07-26 22:03:40 +02:00
$email = GETPOST ( 'email' , 'alpha' );
2020-07-30 03:50:27 +02:00
$backtopage = '' ;
2020-07-26 22:03:40 +02:00
$ref = GETPOST ( 'ref' , 'alpha' );
if ( GETPOST ( 'btn_view' )) {
unset ( $_SESSION [ 'email_customer' ]);
}
if ( isset ( $_SESSION [ 'email_customer' ])) {
$email = $_SESSION [ 'email_customer' ];
}
$object = new RecruitmentJobPosition ( $db );
2021-02-26 18:58:34 +01:00
if ( ! $action ) {
if ( ! $ref ) {
2020-07-30 03:50:27 +02:00
print $langs -> trans ( 'ErrorBadParameters' ) . " - ref missing " ;
exit ;
} else {
$object -> fetch ( '' , $ref );
}
}
// Define $urlwithroot
//$urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT,'/').'$/i','',trim($dolibarr_main_url_root));
//$urlwithroot=$urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file
$urlwithroot = DOL_MAIN_URL_ROOT ; // This is to use same domain name than current. For Paypal payment, we can use internal URL like localhost.
2021-06-13 20:37:53 +02:00
// Security check
2021-06-15 16:11:25 +02:00
if ( empty ( $conf -> recruitment -> enabled )) {
2021-06-13 20:37:53 +02:00
accessforbidden ( '' , 0 , 0 , 1 );
}
2020-07-26 22:03:40 +02:00
/*
* Actions
*/
2021-02-26 18:58:34 +01:00
if ( $cancel ) {
if ( ! empty ( $backtopage )) {
2020-07-26 22:03:40 +02:00
header ( " Location: " . $backtopage );
exit ;
}
$action = 'view' ;
}
if ( $action == " view " || $action == " presend " || $action == " close " || $action == " confirm_public_close " || $action == " add_message " ) {
$error = 0 ;
$display_ticket = false ;
if ( ! strlen ( $ref )) {
$error ++ ;
array_push ( $object -> errors , $langs -> trans ( " ErrorFieldRequired " , $langs -> transnoentities ( " Ref " )));
$action = '' ;
}
if ( ! strlen ( $email )) {
$error ++ ;
array_push ( $object -> errors , $langs -> trans ( " ErrorFieldRequired " , $langs -> transnoentities ( " Email " )));
$action = '' ;
} else {
if ( ! isValidEmail ( $email )) {
$error ++ ;
array_push ( $object -> errors , $langs -> trans ( " ErrorEmailInvalid " ));
$action = '' ;
}
}
if ( ! $error ) {
$ret = $object -> fetch ( '' , $ref );
}
/*
if ( ! $error && $action == " add_message " && $display_ticket && GETPOSTISSET ( 'btn_add_message' ))
{
// TODO Add message...
2022-05-18 12:40:44 +02:00
$ret = $object -> newMessage ( $user , $action , 0 , 1 );
2020-07-26 22:03:40 +02:00
if ( ! $error )
{
$action = 'view' ;
}
}
*/
if ( $error || $errors ) {
setEventMessages ( $object -> error , $object -> errors , 'errors' );
2021-02-26 18:58:34 +01:00
if ( $action == " add_message " ) {
2020-07-26 22:03:40 +02:00
$action = 'presend' ;
} else {
$action = '' ;
}
}
}
//var_dump($action);
//$object->doActions($action);
// Actions to send emails (for ticket, we need to manage the addfile and removefile only)
$triggersendname = 'CANDIDATURE_SENTBYMAIL' ;
$paramname = 'id' ;
$autocopy = 'MAIN_MAIL_AUTOCOPY_CANDIDATURE_TO' ; // used to know the automatic BCC to add
2020-11-08 14:39:20 +01:00
$trackid = 'recruitmentcandidature' . $object -> id ;
2020-07-26 22:03:40 +02:00
include DOL_DOCUMENT_ROOT . '/core/actions_sendmails.inc.php' ;
/*
* View
*/
2020-07-30 03:50:27 +02:00
$head = '' ;
2021-02-26 18:58:34 +01:00
if ( ! empty ( $conf -> global -> MAIN_RECRUITMENT_CSS_URL )) {
$head = '<link rel="stylesheet" type="text/css" href="' . $conf -> global -> MAIN_RECRUITMENT_CSS_URL . '?lang=' . $langs -> defaultlang . '">' . " \n " ;
}
2020-07-30 03:50:27 +02:00
$conf -> dol_hide_topmenu = 1 ;
$conf -> dol_hide_leftmenu = 1 ;
2020-07-26 22:03:40 +02:00
if ( ! $conf -> global -> RECRUITMENT_ENABLE_PUBLIC_INTERFACE ) {
2020-12-10 16:01:06 +01:00
$langs -> load ( " errors " );
print '<div class="error">' . $langs -> trans ( 'ErrorPublicInterfaceNotEnabled' ) . '</div>' ;
2020-07-26 22:03:40 +02:00
$db -> close ();
exit ();
}
$arrayofjs = array ();
2020-07-30 03:50:27 +02:00
$arrayofcss = array ();
$replacemainarea = ( empty ( $conf -> dol_hide_leftmenu ) ? '<div>' : '' ) . '<div>' ;
2022-05-01 11:48:11 +02:00
llxHeader ( $head , $langs -> trans ( " PositionToBeFilled " ), '' , '' , 0 , 0 , '' , '' , '' , 'onlinepaymentbody' , $replacemainarea , 1 , 1 );
2020-07-30 03:50:27 +02:00
print '<span id="dolpaymentspan"></span>' . " \n " ;
print '<div class="center">' . " \n " ;
print '<form id="dolpaymentform" class="center" name="paymentform" action="' . $_SERVER [ " PHP_SELF " ] . '" method="POST">' . " \n " ;
print '<input type="hidden" name="token" value="' . newToken () . '">' . " \n " ;
print '<input type="hidden" name="action" value="dosign">' . " \n " ;
print '<input type="hidden" name="tag" value="' . GETPOST ( " tag " , 'alpha' ) . '">' . " \n " ;
print '<input type="hidden" name="suffix" value="' . GETPOST ( " suffix " , 'alpha' ) . '">' . " \n " ;
print '<input type="hidden" name="securekey" value="' . $SECUREKEY . '">' . " \n " ;
print '<input type="hidden" name="entity" value="' . $entity . '" />' ;
print " \n " ;
2021-06-19 20:05:25 +02:00
print '<!-- Form to view job -->' . " \n " ;
2020-07-30 03:50:27 +02:00
// Show logo (search order: logo defined by ONLINE_SIGN_LOGO_suffix, then ONLINE_SIGN_LOGO_, then small company logo, large company logo, theme logo, common logo)
// Define logo and logosmall
$logosmall = $mysoc -> logo_small ;
$logo = $mysoc -> logo ;
$paramlogo = 'ONLINE_RECRUITMENT_LOGO_' . $suffix ;
2021-02-26 18:58:34 +01:00
if ( ! empty ( $conf -> global -> $paramlogo )) {
$logosmall = $conf -> global -> $paramlogo ;
} elseif ( ! empty ( $conf -> global -> ONLINE_RECRUITMENT_LOGO )) {
$logosmall = $conf -> global -> ONLINE_RECRUITMENT_LOGO_ ;
}
2020-07-30 03:50:27 +02:00
//print '<!-- Show logo (logosmall='.$logosmall.' logo='.$logo.') -->'."\n";
// Define urllogo
$urllogo = '' ;
$urllogofull = '' ;
2021-02-26 18:58:34 +01:00
if ( ! empty ( $logosmall ) && is_readable ( $conf -> mycompany -> dir_output . '/logos/thumbs/' . $logosmall )) {
2020-07-30 03:50:27 +02:00
$urllogo = DOL_URL_ROOT . '/viewimage.php?modulepart=mycompany&entity=' . $conf -> entity . '&file=' . urlencode ( 'logos/thumbs/' . $logosmall );
$urllogofull = $dolibarr_main_url_root . '/viewimage.php?modulepart=mycompany&entity=' . $conf -> entity . '&file=' . urlencode ( 'logos/thumbs/' . $logosmall );
2021-02-26 18:58:34 +01:00
} elseif ( ! empty ( $logo ) && is_readable ( $conf -> mycompany -> dir_output . '/logos/' . $logo )) {
2020-07-30 03:50:27 +02:00
$urllogo = DOL_URL_ROOT . '/viewimage.php?modulepart=mycompany&entity=' . $conf -> entity . '&file=' . urlencode ( 'logos/' . $logo );
$urllogofull = $dolibarr_main_url_root . '/viewimage.php?modulepart=mycompany&entity=' . $conf -> entity . '&file=' . urlencode ( 'logos/' . $logo );
}
// Output html code for logo
2021-02-26 18:58:34 +01:00
if ( $urllogo ) {
2020-07-30 03:50:27 +02:00
print '<div class="backgreypublicpayment">' ;
print '<div class="logopublicpayment">' ;
2022-09-01 15:38:31 +02:00
if ( ! empty ( $mysoc -> url )) {
print '<a href="' . $mysoc -> url . '" target="_blank" rel="noopener">' ;
}
2022-05-01 11:48:11 +02:00
print '<img id="dolpaymentlogo" src="' . $urllogo . '">' ;
2022-09-01 15:38:31 +02:00
if ( ! empty ( $mysoc -> url )) {
print '</a>' ;
}
2020-07-30 03:50:27 +02:00
print '</div>' ;
if ( empty ( $conf -> global -> MAIN_HIDE_POWERED_BY )) {
2020-11-14 18:11:46 +01:00
print '<div class="poweredbypublicpayment opacitymedium right"><a class="poweredbyhref" href="https://www.dolibarr.org?utm_medium=website&utm_source=poweredby" target="dolibarr" rel="noopener">' . $langs -> trans ( " PoweredBy " ) . '<br><img class="poweredbyimg" src="' . DOL_URL_ROOT . '/theme/dolibarr_logo.svg" width="80px"></a></div>' ;
2020-07-30 03:50:27 +02:00
}
print '</div>' ;
}
2020-07-26 22:03:40 +02:00
2021-06-19 20:05:25 +02:00
if ( ! empty ( $conf -> global -> RECRUITMENT_IMAGE_PUBLIC_INTERFACE )) {
2021-06-19 19:45:13 +02:00
print '<div class="backimagepublicrecruitment">' ;
2021-06-19 20:05:25 +02:00
print '<img id="idPROJECT_IMAGE_PUBLIC_SUGGEST_BOOTH" src="' . $conf -> global -> RECRUITMENT_IMAGE_PUBLIC_INTERFACE . '">' ;
2021-06-19 19:45:13 +02:00
print '</div>' ;
}
2020-07-26 22:03:40 +02:00
2021-10-18 15:57:33 +02:00
2022-05-01 12:12:44 +02:00
print '<table id="dolpaymenttable" summary="Job position offer" class="center">' . " \n " ;
2021-10-18 15:57:33 +02:00
2020-07-30 03:50:27 +02:00
// Output introduction text
$text = '' ;
2021-02-26 18:58:34 +01:00
if ( ! empty ( $conf -> global -> RECRUITMENT_NEWFORM_TEXT )) {
2022-05-01 12:12:44 +02:00
$reg = array ();
2021-02-26 18:58:34 +01:00
if ( preg_match ( '/^\((.*)\)$/' , $conf -> global -> RECRUITMENT_NEWFORM_TEXT , $reg )) {
$text .= $langs -> trans ( $reg [ 1 ]) . " <br> \n " ;
} else {
$text .= $conf -> global -> RECRUITMENT_NEWFORM_TEXT . " <br> \n " ;
}
2020-07-30 03:50:27 +02:00
$text = '<tr><td align="center"><br>' . $text . '<br></td></tr>' . " \n " ;
}
2021-02-26 18:58:34 +01:00
if ( empty ( $text )) {
2020-08-02 18:50:08 +02:00
$text .= '<tr><td class="textpublicpayment"><br>' . $langs -> trans ( " JobOfferToBeFilled " , $mysoc -> name );
$text .= ' - <strong>' . $mysoc -> name . '</strong>' ;
2022-05-01 11:48:11 +02:00
$text .= ' - <span class="nowraponall"><span class="fa fa-calendar secondary"></span> ' . dol_print_date ( $object -> date_creation ) . '</span>' ;
2020-07-30 03:50:27 +02:00
$text .= '</td></tr>' . " \n " ;
2022-05-02 16:47:28 +02:00
$text .= '<tr><td class="textpublicpayment"><h1 class="paddingleft paddingright">' . $object -> label . '</h1><br></td></tr>' . " \n " ;
2020-07-30 03:50:27 +02:00
}
print $text ;
2020-07-26 22:03:40 +02:00
2020-07-30 03:50:27 +02:00
// Output payment summary form
2020-07-30 04:17:05 +02:00
print '<tr><td class="left">' ;
print '<div with="100%" id="tablepublicpayment">' ;
print '<div class="opacitymedium">' . $langs -> trans ( " ThisIsInformationOnJobPosition " ) . ' :</div>' . " \n " ;
2020-07-26 22:03:40 +02:00
2020-07-30 03:50:27 +02:00
$error = 0 ;
2020-07-30 04:17:05 +02:00
$found = true ;
print '<br>' ;
2020-07-26 22:03:40 +02:00
2020-07-30 03:50:27 +02:00
// Label
2020-07-30 04:23:23 +02:00
print $langs -> trans ( " Label " ) . ' : ' ;
2020-09-26 12:19:08 +02:00
print '<b>' . dol_escape_htmltag ( $object -> label ) . '</b><br>' ;
2020-07-26 22:03:40 +02:00
2020-07-30 03:50:27 +02:00
// Date
2020-07-30 04:23:23 +02:00
print $langs -> trans ( " DateExpected " ) . ' : ' ;
2020-07-30 04:17:05 +02:00
print '<b>' ;
2020-07-30 03:50:27 +02:00
if ( $object -> date_planned > $now ) {
2020-07-30 04:17:05 +02:00
print dol_print_date ( $object -> date_planned , 'day' );
2020-07-30 03:50:27 +02:00
} else {
print $langs -> trans ( " ASAP " );
}
2020-07-30 04:17:05 +02:00
print '</b><br>' ;
2020-08-06 15:55:04 +02:00
// Remuneration
print $langs -> trans ( " Remuneration " ) . ' : ' ;
print '<b>' ;
2020-09-26 12:19:08 +02:00
print dol_escape_htmltag ( $object -> remuneration_suggested );
2020-08-06 15:55:04 +02:00
print '</b><br>' ;
2020-08-02 18:09:53 +02:00
// Contact
$tmpuser = new User ( $db );
$tmpuser -> fetch ( $object -> fk_user_recruiter );
2020-08-02 18:45:42 +02:00
print $langs -> trans ( " ContactForRecruitment " ) . ' : ' ;
$emailforcontact = $object -> email_recruiter ;
2020-08-02 18:09:53 +02:00
if ( empty ( $emailforcontact )) {
2020-08-02 18:45:42 +02:00
$emailforcontact = $tmpuser -> email ;
if ( empty ( $emailforcontact )) {
$emailforcontact = $mysoc -> email ;
}
2020-08-02 18:09:53 +02:00
}
2020-11-14 18:11:46 +01:00
print '<b class="wordbreak">' ;
2020-08-02 18:45:42 +02:00
print $tmpuser -> getFullName ( - 1 );
2022-05-01 11:48:11 +02:00
print ' ' . dol_print_email ( $emailforcontact , 0 , 0 , 1 , 0 , 0 , 'envelope' );
2020-08-02 18:09:53 +02:00
print '</b>' ;
print '</b><br>' ;
2020-09-06 20:48:13 +02:00
if ( $object -> status == RecruitmentJobPosition :: STATUS_RECRUITED ) {
print info_admin ( $langs -> trans ( " JobClosedTextCandidateFound " ), 0 , 0 , 0 , 'warning' );
}
if ( $object -> status == RecruitmentJobPosition :: STATUS_CANCELED ) {
print info_admin ( $langs -> trans ( " JobClosedTextCanceled " ), 0 , 0 , 0 , 'warning' );
}
2020-08-02 18:09:53 +02:00
2020-07-30 04:17:05 +02:00
print '<br>' ;
2020-07-26 22:03:40 +02:00
2020-07-30 03:50:27 +02:00
// Description
2020-07-26 22:03:40 +02:00
2020-07-30 03:50:27 +02:00
$text = $object -> description ;
2020-07-30 04:17:05 +02:00
print $text ;
2020-09-06 20:48:13 +02:00
print '<input type="hidden" name="ref" value="' . $object -> ref . '">' ;
2020-07-26 22:03:40 +02:00
2020-07-30 04:17:05 +02:00
print '</div>' . " \n " ;
2020-07-30 03:50:27 +02:00
print " \n " ;
2020-07-26 22:03:40 +02:00
2020-07-30 04:17:05 +02:00
2021-02-26 18:58:34 +01:00
if ( $action != 'dosubmit' ) {
2022-08-14 15:25:06 +02:00
if ( $found && ! $error ) {
// We are in a management option and no error
2020-07-26 22:03:40 +02:00
} else {
2022-08-14 15:25:06 +02:00
dol_print_error_email ( 'ERRORSUBMITAPPLICATION' );
2020-07-26 22:03:40 +02:00
}
2020-07-30 03:50:27 +02:00
} else {
// Print
2020-07-26 22:03:40 +02:00
}
2020-07-30 03:50:27 +02:00
print '</td></tr>' . " \n " ;
2020-07-26 22:03:40 +02:00
2020-07-30 03:50:27 +02:00
print '</table>' . " \n " ;
2022-05-01 12:12:44 +02:00
2020-07-30 03:50:27 +02:00
print '</form>' . " \n " ;
print '</div>' . " \n " ;
print '<br>' ;
htmlPrintOnlinePaymentFooter ( $mysoc , $langs );
2020-07-26 22:03:40 +02:00
llxFooter ( '' , 'public' );
$db -> close ();