index.php 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476
  1. <?php
  2. /* Copyright (C) 2001-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
  3. * Copyright (C) 2004-2015 Laurent Destailleur <eldy@users.sourceforge.net>
  4. * Copyright (C) 2005-2012 Regis Houssin <regis.houssin@inodbox.com>
  5. * Copyright (C) 2015 Jean-François Ferry <jfefe@aternatik.fr>
  6. *
  7. * This program is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License as published by
  9. * the Free Software Foundation; either version 3 of the License, or
  10. * (at your option) any later version.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program. If not, see <https://www.gnu.org/licenses/>.
  19. */
  20. /**
  21. * \file recruitment/index.php
  22. * \ingroup recruitment
  23. * \brief Home page of recruitment top menu
  24. */
  25. // Load Dolibarr environment
  26. require '../main.inc.php';
  27. require_once DOL_DOCUMENT_ROOT.'/recruitment/class/recruitmentjobposition.class.php';
  28. require_once DOL_DOCUMENT_ROOT.'/recruitment/class/recruitmentcandidature.class.php';
  29. require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
  30. // Load translation files required by the page
  31. $langs->loadLangs(array("recruitment", "boxes"));
  32. $action = GETPOST('action', 'aZ09');
  33. $max = 5;
  34. $now = dol_now();
  35. $socid = GETPOST('socid', 'int');
  36. if (isset($user->socid) && $user->socid > 0) {
  37. $action = '';
  38. $socid = $user->socid;
  39. }
  40. // Security check (enable the most restrictive one)
  41. //if ($user->socid > 0) accessforbidden();
  42. //if ($user->socid > 0) $socid = $user->socid;
  43. // if (! $user->hasRight('mymodule', 'myobject', 'read')) {
  44. // accessforbidden();
  45. // }
  46. restrictedArea($user, 'recruitment', 0, 'recruitment_recruitmentjobposition', 'recruitmentjobposition', '', 'rowid');
  47. /*
  48. * Actions
  49. */
  50. // None
  51. /*
  52. * View
  53. */
  54. $form = new Form($db);
  55. $formfile = new FormFile($db);
  56. $staticrecruitmentjobposition = new RecruitmentJobPosition($db);
  57. $staticrecruitmentcandidature = new RecruitmentCandidature($db);
  58. llxHeader("", $langs->trans("RecruitmentArea"));
  59. print load_fiche_titre($langs->trans("RecruitmentArea"), '', 'object_recruitmentjobposition');
  60. print '<div class="fichecenter"><div class="fichethirdleft">';
  61. /*
  62. * Statistics
  63. */
  64. if ($conf->use_javascript_ajax) {
  65. $sql = "SELECT COUNT(t.rowid) as nb, status";
  66. $sql .= " FROM ".MAIN_DB_PREFIX."recruitment_recruitmentjobposition as t";
  67. $sql .= " GROUP BY t.status";
  68. $sql .= " ORDER BY t.status ASC";
  69. $resql = $db->query($sql);
  70. if ($resql) {
  71. $num = $db->num_rows($resql);
  72. $i = 0;
  73. $totalnb = 0;
  74. $dataseries = array();
  75. $colorseries = array();
  76. $vals = array();
  77. include DOL_DOCUMENT_ROOT.'/theme/'.$conf->theme.'/theme_vars.inc.php';
  78. while ($i < $num) {
  79. $obj = $db->fetch_object($resql);
  80. if ($obj) {
  81. $vals[$obj->status] = $obj->nb;
  82. $totalnb += $obj->nb;
  83. }
  84. $i++;
  85. }
  86. $db->free($resql);
  87. print '<div class="div-table-responsive-no-min">';
  88. print '<table class="noborder nohover centpercent">';
  89. print '<tr class="liste_titre"><th colspan="2">'.$langs->trans("Statistics").' - '.$langs->trans("JobPositions").'</th></tr>'."\n";
  90. $listofstatus = array(0, 1, 3, 9);
  91. foreach ($listofstatus as $status) {
  92. $dataseries[] = array(dol_html_entity_decode($staticrecruitmentjobposition->LibStatut($status, 1), ENT_QUOTES | ENT_HTML5), (isset($vals[$status]) ? (int) $vals[$status] : 0));
  93. if ($status == RecruitmentJobPosition::STATUS_DRAFT) {
  94. $colorseries[$status] = '-'.$badgeStatus0;
  95. }
  96. if ($status == RecruitmentJobPosition::STATUS_VALIDATED) {
  97. $colorseries[$status] = $badgeStatus4;
  98. }
  99. if ($status == RecruitmentJobPosition::STATUS_RECRUITED) {
  100. $colorseries[$status] = $badgeStatus6;
  101. }
  102. if ($status == RecruitmentJobPosition::STATUS_CANCELED) {
  103. $colorseries[$status] = $badgeStatus9;
  104. }
  105. if (empty($conf->use_javascript_ajax)) {
  106. print '<tr class="oddeven">';
  107. print '<td>'.$staticrecruitmentjobposition->LibStatut($status, 0).'</td>';
  108. print '<td class="right"><a href="list.php?statut='.$status.'">'.(isset($vals[$status]) ? $vals[$status] : 0).'</a></td>';
  109. print "</tr>\n";
  110. }
  111. }
  112. if ($conf->use_javascript_ajax) {
  113. print '<tr><td class="center" colspan="2">';
  114. include_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php';
  115. $dolgraph = new DolGraph();
  116. $dolgraph->SetData($dataseries);
  117. $dolgraph->SetDataColor(array_values($colorseries));
  118. $dolgraph->setShowLegend(2);
  119. $dolgraph->setShowPercent(1);
  120. $dolgraph->SetType(array('pie'));
  121. $dolgraph->SetHeight('200');
  122. $dolgraph->draw('idgraphstatus');
  123. print $dolgraph->show($totalnb ? 0 : 1);
  124. print '</td></tr>';
  125. }
  126. print "</table>";
  127. print "</div>";
  128. print "<br>";
  129. } else {
  130. dol_print_error($db);
  131. }
  132. $sql = "SELECT COUNT(t.rowid) as nb, status";
  133. $sql .= " FROM ".MAIN_DB_PREFIX."recruitment_recruitmentcandidature as t";
  134. $sql .= " GROUP BY t.status";
  135. $sql .= " ORDER BY t.status ASC";
  136. $resql = $db->query($sql);
  137. if ($resql) {
  138. $num = $db->num_rows($resql);
  139. $i = 0;
  140. $totalnb = 0;
  141. $dataseries = array();
  142. $colorseries = array();
  143. $vals = array();
  144. include DOL_DOCUMENT_ROOT.'/theme/'.$conf->theme.'/theme_vars.inc.php';
  145. while ($i < $num) {
  146. $obj = $db->fetch_object($resql);
  147. if ($obj) {
  148. $vals[$obj->status] = $obj->nb;
  149. $totalnb += $obj->nb;
  150. }
  151. $i++;
  152. }
  153. $db->free($resql);
  154. print '<div class="div-table-responsive-no-min">';
  155. print '<table class="noborder nohover centpercent">';
  156. print '<tr class="liste_titre"><th colspan="2">'.$langs->trans("Statistics").' - '.$langs->trans("RecruitmentCandidatures").'</th></tr>'."\n";
  157. $listofstatus = array(0, 1, 3, 5, 8, 9);
  158. foreach ($listofstatus as $status) {
  159. $dataseries[] = array(dol_html_entity_decode($staticrecruitmentcandidature->LibStatut($status, 1), ENT_QUOTES | ENT_HTML5), (isset($vals[$status]) ? (int) $vals[$status] : 0));
  160. if ($status == RecruitmentCandidature::STATUS_DRAFT) {
  161. $colorseries[$status] = '-'.$badgeStatus0;
  162. }
  163. if ($status == RecruitmentCandidature::STATUS_VALIDATED) {
  164. $colorseries[$status] = $badgeStatus1;
  165. }
  166. if ($status == RecruitmentCandidature::STATUS_CONTRACT_PROPOSED) {
  167. $colorseries[$status] = $badgeStatus4;
  168. }
  169. if ($status == RecruitmentCandidature::STATUS_CONTRACT_SIGNED) {
  170. $colorseries[$status] = $badgeStatus5;
  171. }
  172. if ($status == RecruitmentCandidature::STATUS_REFUSED) {
  173. $colorseries[$status] = $badgeStatus9;
  174. }
  175. if ($status == RecruitmentCandidature::STATUS_CANCELED) {
  176. $colorseries[$status] = $badgeStatus9;
  177. }
  178. if (empty($conf->use_javascript_ajax)) {
  179. print '<tr class="oddeven">';
  180. print '<td>'.$staticrecruitmentcandidature->LibStatut($status, 0).'</td>';
  181. print '<td class="right"><a href="list.php?statut='.$status.'">'.(isset($vals[$status]) ? $vals[$status] : 0).'</a></td>';
  182. print "</tr>\n";
  183. }
  184. }
  185. if ($conf->use_javascript_ajax) {
  186. print '<tr><td class="center" colspan="2">';
  187. include_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php';
  188. $dolgraph = new DolGraph();
  189. $dolgraph->SetData($dataseries);
  190. $dolgraph->SetDataColor(array_values($colorseries));
  191. $dolgraph->setShowLegend(2);
  192. $dolgraph->setShowPercent(1);
  193. $dolgraph->SetType(array('pie'));
  194. $dolgraph->SetHeight('200');
  195. $dolgraph->draw('idgraphstatuscandidature');
  196. print $dolgraph->show($totalnb ? 0 : 1);
  197. print '</td></tr>';
  198. }
  199. print "</table>";
  200. print "</div>";
  201. print "<br>";
  202. } else {
  203. dol_print_error($db);
  204. }
  205. }
  206. print '<br>';
  207. /* BEGIN MODULEBUILDER DRAFT MYOBJECT
  208. // Draft MyObject
  209. if (isModEnabled('recruitment') && $user->rights->recruitment->read)
  210. {
  211. $langs->load("orders");
  212. $sql = "SELECT c.rowid, c.ref, c.ref_client, c.total_ht, c.total_tva, c.total_ttc, s.rowid as socid, s.nom as name, s.client, s.canvas";
  213. $sql.= ", s.code_client";
  214. $sql.= " FROM ".MAIN_DB_PREFIX."recruitment_recruitmentjobposition as c";
  215. $sql.= ", ".MAIN_DB_PREFIX."societe as s";
  216. if (! $user->rights->societe->client->voir && ! $socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
  217. $sql.= " WHERE c.fk_soc = s.rowid";
  218. $sql.= " AND c.fk_statut = 0";
  219. $sql.= " AND c.entity IN (".getEntity('commande').")";
  220. if (! $user->rights->societe->client->voir && ! $socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
  221. if ($socid) $sql.= " AND c.fk_soc = ".((int) $socid);
  222. $resql = $db->query($sql);
  223. if ($resql)
  224. {
  225. $total = 0;
  226. $num = $db->num_rows($resql);
  227. print '<table class="noborder centpercent">';
  228. print '<tr class="liste_titre">';
  229. print '<th colspan="3">'.$langs->trans("DraftOrders").($num?'<span class="badge marginleftonlyshort">'.$num.'</span>':'').'</th></tr>';
  230. $var = true;
  231. if ($num > 0)
  232. {
  233. $i = 0;
  234. while ($i < $num)
  235. {
  236. $obj = $db->fetch_object($resql);
  237. print '<tr class="oddeven"><td class="nowrap">';
  238. $orderstatic->id=$obj->rowid;
  239. $orderstatic->ref=$obj->ref;
  240. $orderstatic->ref_client=$obj->ref_client;
  241. $orderstatic->total_ht = $obj->total_ht;
  242. $orderstatic->total_tva = $obj->total_tva;
  243. $orderstatic->total_ttc = $obj->total_ttc;
  244. print $orderstatic->getNomUrl(1);
  245. print '</td>';
  246. print '<td class="nowrap">';
  247. $companystatic->id=$obj->socid;
  248. $companystatic->name=$obj->name;
  249. $companystatic->client=$obj->client;
  250. $companystatic->code_client = $obj->code_client;
  251. $companystatic->code_fournisseur = $obj->code_fournisseur;
  252. $companystatic->canvas=$obj->canvas;
  253. print $companystatic->getNomUrl(1,'customer',16);
  254. print '</td>';
  255. print '<td class="right" class="nowrap">'.price($obj->total_ttc).'</td></tr>';
  256. $i++;
  257. $total += $obj->total_ttc;
  258. }
  259. if ($total>0)
  260. {
  261. print '<tr class="liste_total"><td>'.$langs->trans("Total").'</td><td colspan="2" class="right">'.price($total)."</td></tr>";
  262. }
  263. }
  264. else
  265. {
  266. print '<tr class="oddeven"><td colspan="3" class="opacitymedium">'.$langs->trans("NoOrder").'</td></tr>';
  267. }
  268. print "</table><br>";
  269. $db->free($resql);
  270. }
  271. else
  272. {
  273. dol_print_error($db);
  274. }
  275. }
  276. END MODULEBUILDER DRAFT MYOBJECT */
  277. print '</div><div class="fichetwothirdright">';
  278. $NBMAX = $conf->global->MAIN_SIZE_SHORTLIST_LIMIT;
  279. $max = $conf->global->MAIN_SIZE_SHORTLIST_LIMIT;
  280. // Last modified job position
  281. if (isModEnabled('recruitment') && $user->hasRight('recruitment', 'recruitmentjobposition', 'read')) {
  282. $sql = "SELECT s.rowid, s.ref, s.label, s.date_creation, s.tms, s.status, COUNT(rc.rowid) as nbapplications";
  283. $sql .= " FROM ".MAIN_DB_PREFIX."recruitment_recruitmentjobposition as s";
  284. $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."recruitment_recruitmentcandidature as rc ON rc.fk_recruitmentjobposition = s.rowid";
  285. if (isModEnabled('societe') && empty($user->rights->societe->client->voir) && !$socid) {
  286. $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
  287. }
  288. $sql .= " WHERE s.entity IN (".getEntity($staticrecruitmentjobposition->element).")";
  289. if (isModEnabled('societe') && empty($user->rights->societe->client->voir) && !$socid) {
  290. $sql .= " AND s.fk_soc = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
  291. }
  292. if ($socid) {
  293. $sql .= " AND s.fk_soc = $socid";
  294. }
  295. $sql .= " GROUP BY s.rowid, s.ref, s.label, s.date_creation, s.tms, s.status";
  296. $sql .= $db->order('s.tms', 'DESC');
  297. $sql .= $db->plimit($max, 0);
  298. $resql = $db->query($sql);
  299. if ($resql) {
  300. $num = $db->num_rows($resql);
  301. $i = 0;
  302. print '<div class="div-table-responsive-no-min">';
  303. print '<table class="noborder centpercent">';
  304. print '<tr class="liste_titre">';
  305. print '<th colspan="2">';
  306. print $langs->trans("BoxTitleLatestModifiedJobPositions", $max);
  307. print '</th>';
  308. print '<th class="right">';
  309. print $langs->trans("Applications");
  310. print '</th>';
  311. print '<th class="right" colspan="2"><a href="'.DOL_URL_ROOT.'/recruitment/recruitmentjobposition_list.php?sortfield=t.tms&sortorder=DESC">'.$langs->trans("FullList").'</th>';
  312. print '</tr>';
  313. if ($num) {
  314. while ($i < $num) {
  315. $objp = $db->fetch_object($resql);
  316. $staticrecruitmentjobposition->id = $objp->rowid;
  317. $staticrecruitmentjobposition->ref = $objp->ref;
  318. $staticrecruitmentjobposition->label = $objp->label;
  319. $staticrecruitmentjobposition->status = $objp->status;
  320. $staticrecruitmentjobposition->date_creation = $objp->date_creation;
  321. print '<tr class="oddeven">';
  322. print '<td class="nowrap">'.$staticrecruitmentjobposition->getNomUrl(1, '').'</td>';
  323. print '<td class="right nowrap">';
  324. print "</td>";
  325. print '<td class="right">';
  326. print $objp->nbapplications;
  327. print '</td>';
  328. print '<td class="right nowrap">'.dol_print_date($db->jdate($objp->tms), 'day')."</td>";
  329. print '<td class="right nowrap" width="16">';
  330. print $staticrecruitmentjobposition->getLibStatut(3);
  331. print "</td>";
  332. print '</tr>';
  333. $i++;
  334. }
  335. $db->free($resql);
  336. } else {
  337. print '<tr class="oddeven"><td colspan="4" class="opacitymedium">'.$langs->trans("None").'</td></tr>';
  338. }
  339. print "</table>";
  340. print "</div>";
  341. print "<br>";
  342. } else {
  343. dol_print_error($db);
  344. }
  345. }
  346. // Last modified job position
  347. if (isModEnabled('recruitment') && $user->hasRight('recruitment', 'recruitmentjobposition', 'read')) {
  348. $sql = "SELECT rc.rowid, rc.ref, rc.email, rc.lastname, rc.firstname, rc.date_creation, rc.tms, rc.status";
  349. $sql .= " FROM ".MAIN_DB_PREFIX."recruitment_recruitmentcandidature as rc";
  350. $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."recruitment_recruitmentjobposition as s ON rc.fk_recruitmentjobposition = s.rowid";
  351. if (isModEnabled('societe') && empty($user->rights->societe->client->voir) && !$socid) {
  352. $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
  353. }
  354. $sql .= " WHERE rc.entity IN (".getEntity($staticrecruitmentjobposition->element).")";
  355. if (isModEnabled('societe') && empty($user->rights->societe->client->voir) && !$socid) {
  356. $sql .= " AND s.fk_soc = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
  357. }
  358. if ($socid) {
  359. $sql .= " AND s.fk_soc = $socid";
  360. }
  361. $sql .= $db->order('rc.tms', 'DESC');
  362. $sql .= $db->plimit($max, 0);
  363. $resql = $db->query($sql);
  364. if ($resql) {
  365. $num = $db->num_rows($resql);
  366. $i = 0;
  367. print '<div class="div-table-responsive-no-min">';
  368. print '<table class="noborder centpercent">';
  369. print '<tr class="liste_titre">';
  370. print '<th colspan="2">';
  371. print $langs->trans("BoxTitleLatestModifiedCandidatures", $max);
  372. print '</th>';
  373. print '<th class="right" colspan="2"><a href="'.DOL_URL_ROOT.'/recruitment/recruitmentcandidature_list.php?sortfield=t.tms&sortorder=DESC">'.$langs->trans("FullList").'</th>';
  374. print '</tr>';
  375. if ($num) {
  376. while ($i < $num) {
  377. $objp = $db->fetch_object($resql);
  378. $staticrecruitmentcandidature->id = $objp->rowid;
  379. $staticrecruitmentcandidature->ref = $objp->ref;
  380. $staticrecruitmentcandidature->email = $objp->email;
  381. $staticrecruitmentcandidature->status = $objp->status;
  382. $staticrecruitmentcandidature->date_creation = $objp->date_creation;
  383. $staticrecruitmentcandidature->firstname = $objp->firstname;
  384. $staticrecruitmentcandidature->lastname = $objp->lastname;
  385. print '<tr class="oddeven">';
  386. print '<td class="nowrap">'.$staticrecruitmentcandidature->getNomUrl(1, '').'</td>';
  387. print '<td class="right nowrap">';
  388. print "</td>";
  389. print '<td class="right nowrap">'.dol_print_date($db->jdate($objp->tms), 'day')."</td>";
  390. print '<td class="right nowrap" width="16">';
  391. print $staticrecruitmentcandidature->getLibStatut(3);
  392. print "</td>";
  393. print '</tr>';
  394. $i++;
  395. }
  396. $db->free($resql);
  397. } else {
  398. print '<tr class="oddeven"><td colspan="4" class="opacitymedium">'.$langs->trans("None").'</td></tr>';
  399. }
  400. print "</table>";
  401. print "</div>";
  402. print "<br>";
  403. } else {
  404. dol_print_error($db);
  405. }
  406. }
  407. print '</div></div>';
  408. // End of page
  409. llxFooter();
  410. $db->close();