1<?php
2/* Copyright (C) 2007-2017 Laurent Destailleur  <eldy@users.sourceforge.net>
3 * Copyright (C) ---Put here your own copyright and developer email---
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <https://www.gnu.org/licenses/>.
17 */
18
19/**
20 *  \file       recruitmentcandidature_note.php
21 *  \ingroup    recruitment
22 *  \brief      Car with notes on RecruitmentCandidature
23 */
24
25// Load Dolibarr environment
26$res = 0;
27// Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined)
28if (!$res && !empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) {
29	$res = @include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php";
30}
31// Try main.inc.php into web root detected using web root calculated from SCRIPT_FILENAME
32$tmp = empty($_SERVER['SCRIPT_FILENAME']) ? '' : $_SERVER['SCRIPT_FILENAME']; $tmp2 = realpath(__FILE__); $i = strlen($tmp) - 1; $j = strlen($tmp2) - 1;
33while ($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) {
34	$i--; $j--;
35}
36if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1))."/main.inc.php")) {
37	$res = @include substr($tmp, 0, ($i + 1))."/main.inc.php";
38}
39if (!$res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php")) {
40	$res = @include dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php";
41}
42// Try main.inc.php using relative path
43if (!$res && file_exists("../main.inc.php")) {
44	$res = @include "../main.inc.php";
45}
46if (!$res && file_exists("../../main.inc.php")) {
47	$res = @include "../../main.inc.php";
48}
49if (!$res && file_exists("../../../main.inc.php")) {
50	$res = @include "../../../main.inc.php";
51}
52if (!$res) {
53	die("Include of main fails");
54}
55
56dol_include_once('/recruitment/class/recruitmentcandidature.class.php');
57dol_include_once('/recruitment/lib/recruitment_recruitmentcandidature.lib.php');
58
59// Load translation files required by the page
60$langs->loadLangs(array("recruitment", "companies"));
61
62// Get parameters
63$id = GETPOST('id', 'int');
64$ref        = GETPOST('ref', 'alpha');
65$action = GETPOST('action', 'aZ09');
66$cancel     = GETPOST('cancel', 'aZ09');
67$backtopage = GETPOST('backtopage', 'alpha');
68
69// Initialize technical objects
70$object = new RecruitmentCandidature($db);
71$extrafields = new ExtraFields($db);
72$diroutputmassaction = $conf->recruitment->dir_output.'/temp/massgeneration/'.$user->id;
73$hookmanager->initHooks(array('recruitmentjobpositionnote', 'globalcard')); // Note that conf->hooks_modules contains array
74// Fetch optionals attributes and labels
75$extrafields->fetch_name_optionals_label($object->table_element);
76
77// Load object
78include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once  // Must be include, not include_once. Include fetch and fetch_thirdparty but not fetch_optionals
79if ($id > 0 || !empty($ref)) {
80	$upload_dir = $conf->recruitment->multidir_output[$object->entity]."/".$object->id;
81}
82
83$permissionnote = $user->rights->recruitment->recruitmentjobposition->write; // Used by the include of actions_setnotes.inc.php
84$permissiontoadd = $user->rights->recruitment->recruitmentjobposition->write; // Used by the include of actions_addupdatedelete.inc.php
85
86// Security check - Protection if external user
87//if ($user->socid > 0) accessforbidden();
88//if ($user->socid > 0) $socid = $user->socid;
89$isdraft = (($object->status == $object::STATUS_DRAFT) ? 1 : 0);
90$result = restrictedArea($user, 'recruitment', $object->id, 'recruitment_recruitmentcandidature', 'recruitmentjobposition', '', 'rowid', $isdraft);
91
92
93/*
94 * Actions
95 */
96
97include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include, not include_once
98
99
100/*
101 * View
102 */
103
104$form = new Form($db);
105
106//$help_url='EN:Customers_Orders|FR:Commandes_Clients|ES:Pedidos de clientes';
107$help_url = '';
108llxHeader('', $langs->trans('RecruitmentCandidature'), $help_url);
109
110if ($id > 0 || !empty($ref)) {
111	$object->fetch_thirdparty();
112
113	$head = recruitmentCandidaturePrepareHead($object);
114
115	print dol_get_fiche_head($head, 'note', $langs->trans("RecruitmentCandidature"), -1, $object->picto);
116
117	// Object card
118	// ------------------------------------------------------------
119	$linkback = '<a href="'.dol_buildpath('/recruitment/recruitmentjobposition_list.php', 1).'?restore_lastsearch_values=1'.(!empty($socid) ? '&socid='.$socid : '').'">'.$langs->trans("BackToList").'</a>';
120
121	$morehtmlref = '<div class="refidno">';
122	/*
123	 // Ref customer
124	 $morehtmlref.=$form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', 0, 1);
125	 $morehtmlref.=$form->editfieldval("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', null, null, '', 1);
126	 // Thirdparty
127	 $morehtmlref.='<br>'.$langs->trans('ThirdParty') . ' : ' . (is_object($object->thirdparty) ? $object->thirdparty->getNomUrl(1) : '');
128	*/
129	// Project
130	/*if (! empty($conf->projet->enabled))
131	{
132		$langs->load("projects");
133		$morehtmlref .= $langs->trans('Project') . ' ';
134		if ($permissiontoadd)
135		{
136			if ($action != 'classify')
137				//$morehtmlref.='<a class="editfielda" href="' . $_SERVER['PHP_SELF'] . '?action=classify&amp;id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a> : ';
138			$morehtmlref .=' : ';
139			if ($action == 'classify') {
140				//$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1);
141				$morehtmlref .= '<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">';
142				$morehtmlref .= '<input type="hidden" name="action" value="classin">';
143				$morehtmlref .= '<input type="hidden" name="token" value="'.newToken().'">';
144				$morehtmlref .= $formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1);
145				$morehtmlref .= '<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">';
146				$morehtmlref .= '</form>';
147			} else {
148				$morehtmlref .= $form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1);
149			}
150		} else {
151			if (! empty($object->fk_project)) {
152				$proj = new Project($db);
153				$proj->fetch($object->fk_project);
154				$morehtmlref .= ': '.$proj->getNomUrl();
155			} else {
156				$morehtmlref .= '';
157			}
158		}
159	}*/
160	$morehtmlref .= '</div>';
161
162
163	dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref);
164
165
166	print '<div class="fichecenter">';
167	print '<div class="underbanner clearboth"></div>';
168
169
170	$cssclass = "titlefield";
171	include DOL_DOCUMENT_ROOT.'/core/tpl/notes.tpl.php';
172
173	print '</div>';
174
175	print dol_get_fiche_end();
176}
177
178// End of page
179llxFooter();
180$db->close();
181