PageRenderTime 52ms CodeModel.GetById 15ms RepoModel.GetById 0ms app.codeStats 0ms

/htdocs/agenda/fiche.php

https://bitbucket.org/speedealing/speedealing
PHP | 1362 lines | 894 code | 181 blank | 287 comment | 224 complexity | b6caced5f4f47c3e6739b8e3900fd2cb MD5 | raw file
Possible License(s): LGPL-3.0, LGPL-2.1, GPL-3.0, MIT

Large files files are truncated, but you can click here to view the full file

  1. <?php
  2. /* Copyright (C) 2001-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
  3. * Copyright (C) 2004-2012 Laurent Destailleur <eldy@users.sourceforge.net>
  4. * Copyright (C) 2005 Simon TOSSER <simon@kornog-computing.com>
  5. * Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com>
  6. * Copyright (C) 2010 Juanjo Menent <jmenent@2byte.es>
  7. * Copyright (C) 2010-2012 Herve Prot <herve.prot@symeos.com>
  8. *
  9. * This program is free software; you can redistribute it and/or modify
  10. * it under the terms of the GNU General Public License as published by
  11. * the Free Software Foundation; either version 3 of the License, or
  12. * (at your option) any later version.
  13. *
  14. * This program is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. * GNU General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU General Public License
  20. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  21. */
  22. require '../main.inc.php';
  23. // For best performance, it's preferred to use "class_exists + require" instead "require_once"
  24. require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php';
  25. require_once DOL_DOCUMENT_ROOT . '/agenda/lib/agenda.lib.php';
  26. if (!class_exists('Agenda'))
  27. require DOL_DOCUMENT_ROOT . '/agenda/class/agenda.class.php';
  28. if (!class_exists('Contact'))
  29. require DOL_DOCUMENT_ROOT . '/contact/class/contact.class.php';
  30. if (!class_exists('User'))
  31. require DOL_DOCUMENT_ROOT . '/user/class/user.class.php';
  32. if (!class_exists('FormActions'))
  33. require DOL_DOCUMENT_ROOT . '/core/class/html.formactions.class.php';
  34. if (!empty($conf->propal->enabled) && !class_exists('Propal'))
  35. require DOL_DOCUMENT_ROOT . '/propal/class/propal.class.php';
  36. if (!empty($conf->project->enabled)) {
  37. require_once DOL_DOCUMENT_ROOT . '/core/lib/project.lib.php';
  38. if (!class_exists('User'))
  39. require DOL_DOCUMENT_ROOT . '/projet/class/project.class.php';
  40. }
  41. if (!empty($conf->lead->enabled)) {
  42. dol_include_once("/lead/class/lead.class.php");
  43. dol_include_once("/lead/lib/lead.lib.php");
  44. }
  45. $langs->load("companies");
  46. $langs->load("commercial");
  47. $langs->load("other");
  48. $langs->load("bills");
  49. $langs->load("orders");
  50. $langs->load("agenda");
  51. $action = GETPOST('action', 'alpha');
  52. $cancel = GETPOST('cancel', 'alpha');
  53. $backtopage = GETPOST('backtopage', 'alpha');
  54. $contactid = GETPOST('contactid', 'alpha');
  55. // Security check
  56. $socid = GETPOST('socid', 'alpha');
  57. $id = GETPOST('id', 'alpha');
  58. if ($user->societe_id)
  59. $socid = $user->societe_id;
  60. $result = restrictedArea($user, 'agenda', $id, 'actioncomm', 'myactions', '', 'id');
  61. $error = GETPOST("error");
  62. $mesg = '';
  63. $object = new Agenda($db);
  64. $contact = new Contact($db);
  65. //var_dump($_POST);
  66. /*
  67. * Action creation de l'action
  68. */
  69. if ($action == 'add_action') {
  70. $error = 0;
  71. if (empty($backtopage)) {
  72. $backtopage = DOL_URL_ROOT . '/agenda/index.php';
  73. }
  74. if ($contactid) {
  75. $result = $contact->fetch($contactid);
  76. }
  77. if ($cancel) {
  78. header("Location: " . $backtopage);
  79. exit;
  80. }
  81. $fulldayevent = $_POST["fullday"];
  82. // Clean parameters
  83. //$datep = dol_mktime($fulldayevent ? '00' : $_POST["aphour"], $fulldayevent ? '00' : $_POST["apmin"], 0, $_POST["apmonth"], $_POST["apday"], $_POST["apyear"]);
  84. //$datef = dol_mktime($fulldayevent ? '23' : $_POST["p2hour"], $fulldayevent ? '59' : $_POST["p2min"], $fulldayevent ? '59' : '0', $_POST["p2month"], $_POST["p2day"], $_POST["p2year"]);
  85. $datep = date("c", strtotime($_POST["datep"])); // iso format
  86. $datef = date("c", strtotime($_POST["datef"])); // iso format
  87. /*
  88. echo '<pre>'.print_r($datep, true).'</pre>';
  89. echo '<pre>'.print_r($datef, true).'</pre>';
  90. die();
  91. */
  92. // Check parameters
  93. if (!$datef && $_POST["percentage"] == 100) {
  94. $error++;
  95. $action = 'create';
  96. $mesg = '<div class="error">' . $langs->trans("ErrorFieldRequired", $langs->trans("DateEnd")) . '</div>';
  97. }
  98. // Initialisation objet cactioncomm
  99. if (!$_POST["actioncode"]) {
  100. $error++;
  101. $action = 'create';
  102. $mesg = '<div class="error">' . $langs->trans("ErrorFieldRequired", $langs->trans("Type")) . '</div>';
  103. } else {
  104. //$result = $cactioncomm->fetch($_POST["actioncode"]);
  105. $object->type_code = $_POST["actioncode"];
  106. }
  107. /*
  108. if ($cactioncomm->type == 2) { //ACTION
  109. if ($_POST["percentage"] == 100)
  110. $datef = dol_now();
  111. else
  112. $datef = '';
  113. } */
  114. // Check parameters
  115. if (!$datef && $_POST["percentage"] == 100) {
  116. $error = 1;
  117. $action = 'create';
  118. $mesg = '<div class="error">' . $langs->trans("ErrorFieldRequired", $langs->trans("DateEnd")) . '</div>';
  119. }
  120. // Initialisation objet actioncomm
  121. $object->type_id = null;
  122. $object->type_code = $_POST["actioncode"];
  123. $object->fulldayevent = $_POST["fullday"] ? 1 : 0;
  124. $object->location = isset($_POST["location"]) ? $_POST["location"] : '';
  125. $object->label = trim($_POST["label"]);
  126. if (!$_POST["label"]) {
  127. if ($_POST["actioncode"] == 'AC_RDV' && $contact->getFullName($langs)) {
  128. $object->label = $langs->transnoentitiesnoconv("TaskRDVWith", $contact->getFullName($langs));
  129. } else {
  130. if ($langs->trans("Action" . $object->type_code) != "Action" . $object->type_code) {
  131. $object->label = $langs->transnoentitiesnoconv("Action" . $object->type_code) . "\n";
  132. }
  133. else
  134. $object->label = $cactioncomm->libelle;
  135. }
  136. }
  137. $object->fk_project = isset($_POST["projectid"]) ? $_POST["projectid"] : 0;
  138. $object->fk_lead = isset($_POST["leadid"]) ? $_POST["leadid"] : 0;
  139. $object->propalrowid = isset($_POST["propalid"]) ? $_POST["propalid"] : 0;
  140. $object->type = $cactioncomm->type;
  141. $object->fk_task = isset($_POST["fk_task"]) ? $_POST["fk_task"] : 0;
  142. $object->datep = $datep;
  143. $object->datef = $datef;
  144. $object->Status = GETPOST('status');
  145. if ($object->type_code == "AC_RDV") //ACTION
  146. $object->durationp = $object->datef - $object->datep;
  147. else {
  148. $object->durationp = $_POST["durationhour"] * 3600 + $_POST["durationmin"] * 60;
  149. $object->datef = $object->datep + $object->durationp;
  150. }
  151. /*
  152. if ($cactioncomm->type == 1) { //RDV
  153. // RDV
  154. if ($object->datef && $object->datef < dol_now('tzref')) {
  155. $object->percentage = 100;
  156. } else {
  157. $object->percentage = 0;
  158. }
  159. } else {
  160. $object->percentage = isset($_POST["percentage"]) ? $_POST["percentage"] : 0;
  161. }
  162. $object->duree = (($_POST["dureehour"] * 60) + $_POST["dureemin"]) * 60;
  163. */
  164. $object->author->id = $user->id;
  165. $object->author->name = $user->login;
  166. $object->usermod = null;
  167. if (strlen($_POST["affectedto"]) > 0)
  168. $object->usertodo->id = GETPOST("affectedto");
  169. /*
  170. $userdone = new User($db);
  171. if ($_POST["doneby"] > 0) {
  172. $userdone->fetch($_POST["doneby"]);
  173. }
  174. $object->userdone = $userdone;
  175. *
  176. */
  177. if (strlen($_POST["doneby"]) > 0)
  178. $object->userdone->id = GETPOST("doneby");
  179. $object->notes = trim($_POST["note"]);
  180. if (isset($_POST["contactid"])) {
  181. $object->contact->id = $contact->id;
  182. $object->contact->name = $contact->name;
  183. }
  184. if (!empty($socid)) {
  185. $societe = new Societe($db);
  186. $societe->fetch($socid);
  187. $object->societe->id = $societe->id;
  188. $object->societe->name = $societe->name;
  189. }
  190. // Check parameters
  191. if ($cactioncomm->type == 1 && ($datef == '')) { //RDV
  192. $error++;
  193. $action = 'create';
  194. $mesg = '<div class="error">' . $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("DateEnd")) . '</div>';
  195. }
  196. /*
  197. if ($datea && $_POST["percentage"] == 0) {
  198. $error++;
  199. $action = 'create';
  200. $mesg = '<div class="error">' . $langs->trans("ErrorStatusCantBeZeroIfStarted") . '</div>';
  201. }
  202. */
  203. if (!$_POST["datep"] && !$_POST["datef"]) {
  204. $error++;
  205. $action = 'create';
  206. $mesg = '<div class="error">' . $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Date")) . '</div>';
  207. }
  208. //echo '<pre>'.print_r($_POST, true).'</pre>';
  209. //echo '<pre>'.print_r($object, true).'</pre>';
  210. //die();
  211. if (!$error) {
  212. // On cree l'action
  213. $idaction = $object->add($user);
  214. if ($idaction > 0) {
  215. if (!$object->error) {
  216. if (!empty($backtopage)) {
  217. dol_syslog("Back to " . $backtopage);
  218. Header("Location: " . $backtopage);
  219. } elseif ($idaction) {
  220. Header("Location: " . DOL_URL_ROOT . '/agenda/fiche.php?id=' . $idaction);
  221. } else {
  222. Header("Location: " . DOL_URL_ROOT . '/agenda/index.php');
  223. }
  224. exit;
  225. } else {
  226. // Si erreur
  227. $id = $idaction;
  228. $langs->load("errors");
  229. $error = $langs->trans($object->error);
  230. }
  231. } else {
  232. $id = $idaction;
  233. $langs->load("errors");
  234. $error = $langs->trans($object->error);
  235. }
  236. }
  237. }
  238. /*
  239. * Action cloturer l'action
  240. */
  241. if (GETPOST("action") == 'close') {
  242. $object->load($id);
  243. if ($user->rights->agenda->myactions->write || $user->rights->agenda->allactions->write) {
  244. $object->Status = "DONE";
  245. $object->percentage = 100;
  246. $object->update($user);
  247. Header("Location: " . DOL_URL_ROOT . '/agenda/fiche.php?id=' . $id);
  248. exit;
  249. }
  250. }
  251. /*
  252. * Action suppression de l'action
  253. */
  254. if ($action == 'confirm_delete' && GETPOST("confirm") == 'yes') {
  255. $object->fetch($id);
  256. if ($user->rights->agenda->myactions->delete
  257. || $user->rights->agenda->allactions->delete) {
  258. $result = $object->delete();
  259. if ($result >= 0) {
  260. Header("Location: /agenda/listactions.php");
  261. exit;
  262. } else {
  263. $mesg = $object->error;
  264. }
  265. }
  266. }
  267. /*
  268. * Action mise a jour de l'action
  269. */
  270. if ($action == 'update') {
  271. if (!$_POST["cancel"]) {
  272. $fulldayevent = $_POST["fullday"];
  273. // Clean parameters
  274. if ($_POST["aphour"] == -1)
  275. $_POST["aphour"] = '0';
  276. if ($_POST["apmin"] == -1)
  277. $_POST["apmin"] = '0';
  278. if ($_POST["p2hour"] == -1)
  279. $_POST["p2hour"] = '0';
  280. if ($_POST["p2min"] == -1)
  281. $_POST["p2min"] = '0';
  282. //if ($_POST["adhour"] == -1) $_POST["adhour"]='0';
  283. //if ($_POST["admin"] == -1) $_POST["admin"]='0';
  284. $object->fetch($id);
  285. //$datep = dol_mktime($fulldayevent ? '00' : $_POST["aphour"], $fulldayevent ? '00' : $_POST["apmin"], 0, $_POST["apmonth"], $_POST["apday"], $_POST["apyear"]);
  286. //$datef = dol_mktime($fulldayevent ? '23' : $_POST["p2hour"], $fulldayevent ? '59' : $_POST["p2min"], $fulldayevent ? '59' : '0', $_POST["p2month"], $_POST["p2day"], $_POST["p2year"]);
  287. $object->label = $_POST["label"];
  288. $object->datep = date("c", strtotime($_POST["datep"]));
  289. $object->datef = date("c", strtotime($_POST["datef"]));
  290. //$object->date = $datea;
  291. //$object->dateend = $datea2;
  292. $object->percentage = $_POST["percentage"];
  293. $object->fulldayevent = $_POST["fullday"] ? 1 : 0;
  294. $object->location = isset($_POST["location"]) ? $_POST["location"] : '';
  295. $object->contact->id = $_POST["contactid"];
  296. $object->fk_project = $_POST["projectid"];
  297. $object->fk_lead = $_POST["leadid"];
  298. $object->propalrowid = $_POST["propalid"];
  299. $object->notes = $_POST["note"];
  300. $object->fk_task = $_POST["fk_task"];
  301. //$object->type = $cactioncomm->type;
  302. $object->Status = $_POST["status"];
  303. if ($object->type_code == "AC_RDV") //ACTION
  304. $object->durationp = $object->datef - $object->datep;
  305. else {
  306. $object->durationp = $_POST["durationhour"] * 3600 + $_POST["durationmin"] * 60;
  307. $object->datef = date("c", strtotime($object->datep) + $object->durationp);
  308. }
  309. /*
  310. if ($object->type == 2) //ACTION
  311. $object->durationp = !empty($_POST["duration"]) ? $_POST["duration"] * 3600 : 3600;
  312. if ($object->type == 1 && !$datef && $object->percentage == 100) {
  313. $error = $langs->trans("ErrorFieldRequired", $langs->trans("DateEnd"));
  314. $action = 'edit';
  315. }
  316. */
  317. // Users
  318. $object->usertodo->id = $_POST["affectedto"];
  319. $object->userdone->id = $_POST["doneby"];
  320. if (GETPOST("socid", "alpha")) {
  321. $societe = new Societe($db);
  322. $societe->fetch($_POST["socid"]);
  323. $object->societe->id = $_POST["socid"];
  324. $object->societe->name = $societe->ThirdPartyName;
  325. } else
  326. $object->societe = new stdClass();
  327. //debug($object);
  328. //die();
  329. if (!$error) {
  330. $result = $object->update($user);
  331. if ($result < 0) {
  332. $langs->load("errors");
  333. $error = $langs->trans($object->error);
  334. $action = 'edit';
  335. }
  336. }
  337. }
  338. if ($result < 0) {
  339. $langs->load("errors");
  340. $mesg = '<div class="error">' . $langs->trans($object->error) . '</div>';
  341. } else {
  342. if (!empty($backtopage)) {
  343. header("Location: " . $backtopage);
  344. exit;
  345. }
  346. }
  347. }
  348. /*
  349. * View
  350. */
  351. llxHeader('', $langs->trans("Agenda"));
  352. $form = new Form($db);
  353. $htmlactions = new FormActions($db);
  354. if ($action == 'create') {
  355. $contact = new Contact($db);
  356. if (GETPOST("contactid")) {
  357. $result = $contact->fetch(GETPOST("contactid"));
  358. if ($result < 0)
  359. dol_print_error($db, $contact->error);
  360. }
  361. $object->fk_task = GETPOST("fk_task") ? GETPOST("fk_task") : 0;
  362. if (GETPOST("actioncode") == 'AC_RDV')
  363. $title = $langs->trans("AddActionRendezVous");
  364. else
  365. $title = $langs->trans("AddAnAction");
  366. print_fiche_titre($title);
  367. print '<div class="with-padding">';
  368. print '<div class="columns">';
  369. print column_start();
  370. //print start_box($title, "twelve", $object->fk_extrafields->ico, false);
  371. print "\n" . '<script type="text/javascript" language="javascript">';
  372. print 'jQuery(document).ready(function () {
  373. function setdatefields()
  374. {
  375. if (jQuery("#fullday:checked").val() == null)
  376. {
  377. jQuery(".fulldaystarthour").attr(\'disabled\', false);
  378. jQuery(".fulldaystartmin").attr(\'disabled\', false);
  379. jQuery(".fulldayendhour").attr(\'disabled\', false);
  380. jQuery(".fulldayendmin").attr(\'disabled\', false);
  381. }
  382. else
  383. {
  384. jQuery(".fulldaystarthour").attr(\'disabled\', true);
  385. jQuery(".fulldaystartmin").attr(\'disabled\', true);
  386. jQuery(".fulldayendhour").attr(\'disabled\', true);
  387. jQuery(".fulldayendmin").attr(\'disabled\', true);
  388. jQuery(".fulldaystarthour").val("00");
  389. jQuery(".fulldaystartmin").val("00");
  390. //jQuery(".fulldayendhour").val("00");
  391. //jQuery(".fulldayendmin").val("00");
  392. jQuery(".fulldayendhour").val("23");
  393. jQuery(".fulldayendmin").val("59");
  394. }
  395. }
  396. setdatefields();
  397. jQuery("#fullday").change(function() {
  398. setdatefields();
  399. });
  400. jQuery("#selectcomplete").change(function() {
  401. if (jQuery("#selectcomplete").val() == 100)
  402. {
  403. if (jQuery("#doneby").val() <= 0) jQuery("#doneby").val(\'' . $user->id . '\');
  404. }
  405. if (jQuery("#selectcomplete").val() == 0)
  406. {
  407. jQuery("#doneby").val(-1);
  408. }
  409. });
  410. jQuery("#actioncode").change(function() {
  411. if (jQuery("#actioncode").val() == \'AC_RDV\') jQuery("#dateend").addClass("fieldrequired");
  412. else jQuery("#dateend").removeClass("fieldrequired");
  413. });
  414. })';
  415. print '</script>' . "\n";
  416. print "\n" . '<script type="text/javascript" language="javascript">';
  417. print 'jQuery(document).ready(function () {
  418. function settype()
  419. {
  420. var typeselected=jQuery("#actioncode option:selected").val();
  421. var type=typeselected.split("_");
  422. if (type[1] == "RDV")
  423. {
  424. $("#jqfullday").css("display","table-row");
  425. $("#jqech").hide();
  426. $("#jqstart").show();
  427. $("#jqend").css("display","table-row");
  428. $("#jqloc").css("display","table-row");
  429. $(".fulldaystarthour").show();
  430. $(".fulldaystartmin").show();
  431. $(".fulldayendhour").show();
  432. $(".fulldayendmin").show();
  433. jQuery(".fulldaystartmin").val("00");
  434. jQuery(".fulldayendmin").val("00");
  435. $("#jqduration").hide();
  436. }
  437. else
  438. {
  439. $("#jqfullday").css("display","none");
  440. $("#jqech").show();
  441. $("#jqstart").hide();
  442. $("#jqend").css("display","none");
  443. $("#jqloc").css("display","none");
  444. $(".fulldayendhour").hide();
  445. $(".fulldayendmin").hide();
  446. jQuery(".fulldaystartmin").val("00");
  447. $("#jqduration").show();
  448. }
  449. }
  450. settype();
  451. jQuery("#actioncode").change(function() {
  452. settype();
  453. });
  454. })';
  455. print '</script>' . "\n";
  456. /* print "\n".'<script type="text/javascript" language="javascript">';
  457. print 'jQuery(document).ready(function () {
  458. function setday()
  459. {
  460. if ($("#ap").val()!="")
  461. {
  462. $("#p2").val($("#ap").val());
  463. }
  464. }
  465. setday();
  466. jQuery("#p2").click(function() {
  467. setday();
  468. });
  469. })';
  470. print '</script>'."\n";
  471. print "\n".'<script type="text/javascript" language="javascript">';
  472. print 'jQuery(document).ready(function () {
  473. function sethour()
  474. {
  475. var hour=parseInt($(".fulldaystarthour option:selected").val());
  476. hour=hour+1;
  477. var strhour=hour.toString(10)
  478. if(strhour.length==1)
  479. $(".fulldayendhour").val(0+strhour);
  480. else
  481. $(".fulldayendhour").val(strhour);
  482. }
  483. sethour();
  484. jQuery(".fulldaystarthour").click(function() {
  485. sethour();
  486. });
  487. })';
  488. print '</script>'."\n"; */
  489. print '<form name="formaction" action="' . $_SERVER["PHP_SELF"] . '" method="POST">';
  490. print '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">';
  491. print '<input type="hidden" name="action" value="add_action">';
  492. if ($backtopage)
  493. print '<input type="hidden" name="backtopage" value="' . ($backtopage != '1' ? $backtopage : $_SERVER["HTTP_REFERER"]) . '">';
  494. dol_htmloutput_mesg($mesg);
  495. print '<div class="tabBar">';
  496. print '<table class="border" width="100%">';
  497. // Type d'action actifs
  498. print '<tr><td width="30%"><span class="fieldrequired">' . $langs->trans("Type") . '</span></b></td><td>';
  499. /* if (GETPOST("actioncode"))
  500. {
  501. print '<input type="hidden" name="actioncode" value="'.GETPOST("actioncode").'">'."\n";
  502. $cactioncomm->fetch(GETPOST("actioncode"));
  503. print $cactioncomm->getNomUrl();
  504. $object->type=split("_",$cactioncomm->code);
  505. }
  506. else
  507. { */
  508. //$htmlactions->select_type_actions($object->type_code, "actioncode");
  509. print $object->select_fk_extrafields("type_code", "actioncode");
  510. //}
  511. print '</td></tr>';
  512. // Title
  513. print '<tr id="jqtitle"><td>' . $langs->trans("Title") . '</td><td><input type="text" name="label" size="60" value="' . GETPOST('label') . '"></td></tr>';
  514. // Full day
  515. print '<tr id="jqfullday"><td>' . $langs->trans("EventOnFullDay") . '</td><td><input type="checkbox" id="fullday" name="fullday" ' . (GETPOST('fullday') ? ' checked="checked"' : '') . '></td></tr>';
  516. // Date start
  517. $datep = $object->datep;
  518. if (GETPOST('datep', 'alpha'))
  519. $datep = GETPOST('datep', 'alpha');
  520. print '<tr><td width="30%" nowrap="nowrap"><span class="fieldrequired" id="jqech">' . $langs->trans("DateEchAction") . '</span><span class="fieldrequired" id="jqstart">' . $langs->trans("DateActionStart") . '</span></td><td>';
  521. if (GETPOST("afaire") == 1)
  522. $form->select_date($datep, 'datep', 1, 1, 0, "action", 1, 1, 0, 0, 'fulldayend', array('stepMinutes' => 30));
  523. else if (GETPOST("afaire") == 2)
  524. $form->select_date($datep, 'datep', 1, 1, 1, "action", 1, 1, 0, 0, 'fulldayend', array('stepMinutes' => 30));
  525. // $html->select_date($datep,'datep',0,0,1,"action",1,1,0,0,'fulldaystart');
  526. $form->select_date($datep, 'datep', 1, 1, 0, "action", 1, 1, 0, 0, 'fulldaystart', array('stepMinutes' => 30));
  527. print '</td></tr>';
  528. // Date end
  529. $datef = $object->datef;
  530. if (GETPOST('datef', 'alpha'))
  531. $datef = GETPOST('datef', 'alpha');
  532. print '<tr id="jqend"><td>' . $langs->trans("DateActionEnd") . '</td><td>';
  533. if (GETPOST("afaire") == 1)
  534. $form->select_date($datef, 'datef', 1, 1, 1, "action", 1, 1, 0, 0, 'fulldayend', array('stepMinutes' => 30));
  535. else if (GETPOST("afaire") == 2)
  536. $form->select_date($datef, 'datef', 1, 1, 1, "action", 1, 1, 0, 0, 'fulldayend', array('stepMinutes' => 30));
  537. else
  538. $form->select_date($datef, 'datef', 1, 1, 0, "action", 1, 1, 0, 0, 'fulldayend', array('stepMinutes' => 30));
  539. print '</td></tr>';
  540. // duration task
  541. print '<tr id="jqduration"><td>' . $langs->trans("Duration") . '</td><td colspan="3">';
  542. //<input type="text" name="duration" size="3" value="' . (empty($object->durationp) ? 1 : $object->durationp / 3600) . '">
  543. $form->select_duration('duration', '', 0, array('stepMinutes' => 30));
  544. print '</td></tr>';
  545. // Status
  546. print '<tr><td width="10%">' . $langs->trans("Status") . ' / ' . $langs->trans("Percentage") . '</td>';
  547. print '<td>';
  548. //$percent=-1;
  549. $percent = 0;
  550. if (isset($_GET['percentage']) || isset($_POST['percentage'])) {
  551. $percent = GETPOST('percentage');
  552. } else {
  553. if (GETPOST("afaire") == 1)
  554. $percent = 0;
  555. if (GETPOST("afaire") == 2)
  556. $percent = 100;
  557. }
  558. print $object->select_fk_extrafields("Status", "status");
  559. print '</td></tr>';
  560. // Location
  561. print '<tr id="jqloc"><td>' . $langs->trans("Location") . '</td><td colspan="3"><input type="text" name="location" size="50" value="' . $object->location . '"></td></tr>';
  562. print '</table>';
  563. print '<br><br>';
  564. print '<table class="border" width="100%">';
  565. // Affected by
  566. $var = false;
  567. print '<tr><td width="30%" nowrap="nowrap">' . $langs->trans("ActionAffectedTo") . '</td><td>';
  568. print $object->select_fk_extrafields("usertodo", 'affectedto');
  569. //$form->select_users(GETPOST("affectedto") ? GETPOST("affectedto") : ($object->usertodo->id > 0 ? $object->usertodo : $user), 'affectedto', 1);
  570. print '</td></tr>';
  571. // Realised by
  572. print '<tr><td nowrap>' . $langs->trans("ActionDoneBy") . '</td><td>';
  573. print $object->select_fk_extrafields("userdone", 'doneby');
  574. //$form->select_users(GETPOST("doneby") ? GETPOST("doneby") : (!empty($object->userdone->id) && $percent == 100 ? $object->userdone->id : 0), 'doneby', 1);
  575. print '</td></tr>';
  576. print '</table>';
  577. print '<br><br>';
  578. print '<table class="border" width="100%">';
  579. // Societe, contact
  580. print '<tr><td width="30%" nowrap="nowrap">' . $langs->trans("ActionOnCompany") . '</td><td>';
  581. if (!empty($socid)) {
  582. $societe = new Societe($db);
  583. $societe->load($socid);
  584. if ($societe->class == "Societe")
  585. print $societe->getNomUrl(1);
  586. else { // Is a contact
  587. $object->contact->id = $socid;
  588. $socid = $societe->societe->id;
  589. $societe->load($socid);
  590. print $societe->getNomUrl(1);
  591. }
  592. print '<input type="hidden" name="socid" value="' . $socid . '">';
  593. } else {
  594. print $object->select_fk_extrafields("societe", 'socid');
  595. }
  596. print '</td></tr>';
  597. // If company is forced, we propose contacts (may be contact is also forced)
  598. if (!empty($socid)) {
  599. $object->societe->id = $socid;
  600. print '<tr><td nowrap>' . $langs->trans("ActionOnContact") . '</td><td>';
  601. print $object->select_fk_extrafields("contact", 'contactid');
  602. //$form->select_contacts(GETPOST('socid', 'int'), GETPOST('contactid'), 'contactid', 1);
  603. print '</td></tr>';
  604. }
  605. // Lead
  606. if ($conf->lead->enabled && GETPOST("leadid")) {
  607. // Affaire associe
  608. $langs->load("lead");
  609. print '<tr><td valign="top">' . $langs->trans("Lead") . '</td><td>';
  610. $numlead = select_leads($societe->id, GETPOST("leadid") ? GETPOST("leadid") : $leadid, 'leadid');
  611. if ($numlead == 0) {
  612. print ' &nbsp; <a href="../../lead/fiche.php?socid=' . $societe->id . '&action=create">' . $langs->trans("AddLead") . '</a>';
  613. }
  614. print '</td></tr>';
  615. }
  616. // Project
  617. if (!empty($conf->projet->enabled)) {
  618. // Projet associe
  619. $langs->load("project");
  620. print '<tr><td valign="top">' . $langs->trans("Project") . '</td><td>';
  621. $numproject = select_projects((!empty($societe->id) ? $societe->id : 0), GETPOST("projectid") ? GETPOST("projectid") : '', 'projectid');
  622. if ($numproject == 0) {
  623. print ' &nbsp; <a href="' . DOL_DOCUMENT_ROOT . '/projet/fiche.php?socid=' . $societe->id . '&action=create">' . $langs->trans("AddProject") . '</a>';
  624. }
  625. print '</td></tr>';
  626. }
  627. // PropalID
  628. if (GETPOST("propalid")) {
  629. // Object linked
  630. $propal = new Propal($db);
  631. $propal->fetch(GETPOST("propalid"));
  632. print '<tr><td valign="top">' . $langs->trans("LinkedObject") . '</td><td>';
  633. print '<input type="hidden" name="propalid" value="' . $propal->id . '">';
  634. print $propal->getNomUrl(1);
  635. print '</td></tr>';
  636. }
  637. if (GETPOST("datep") && preg_match('/^([0-9][0-9][0-9][0-9])([0-9][0-9])([0-9][0-9])$/', GETPOST("datep"), $reg)) {
  638. $object->datep = dol_mktime(0, 0, 0, $reg[2], $reg[3], $reg[1]);
  639. }
  640. add_row_for_calendar_link();
  641. // Description
  642. print '<tr><td valign="top">' . $langs->trans("Description") . '</td><td>';
  643. require_once(DOL_DOCUMENT_ROOT . "/core/class/doleditor.class.php");
  644. $doleditor = new DolEditor('note', (GETPOST('note') ? GETPOST('note') : $object->notes), '', 280, 'dolibarr_notes', 'In', true, true, $conf->fckeditor->enabled, ROWS_7, 90);
  645. $doleditor->Create();
  646. print '</td></tr>';
  647. print '</table>';
  648. print '<br><center>';
  649. print '<input type="submit" class="button" value="' . $langs->trans("Add") . '">';
  650. print ' &nbsp; &nbsp; ';
  651. print '<input type="submit" class="button" name="cancel" value="' . $langs->trans("Cancel") . '">';
  652. print "</center>";
  653. print "</form>";
  654. print "</div>";
  655. print column_end();
  656. }
  657. // View or edit
  658. if ($id) {
  659. if ($error) {
  660. dol_htmloutput_errors($error);
  661. }
  662. if ($mesg) {
  663. dol_htmloutput_mesg($mesg);
  664. }
  665. $result = $object->fetch($id);
  666. if ($result < 0) {
  667. dol_print_error($db, $object->error);
  668. exit;
  669. }
  670. $societe = new Societe($db);
  671. /* if ($object->societe->id) {
  672. $result = $societe->fetch($object->societe->id);
  673. }
  674. $object->societe = $societe;
  675. if ($object->author->id > 0) {
  676. $tmpuser = new User($db);
  677. $res = $tmpuser->fetch($object->author->id);
  678. $object->author = $tmpuser;
  679. }
  680. if ($object->usermod->id > 0) {
  681. $tmpuser = new User($db);
  682. $res = $tmpuser->fetch($object->usermod->id);
  683. $object->usermod = $tmpuser;
  684. }
  685. if ($object->usertodo->id > 0) {
  686. $tmpuser = new User($db);
  687. $res = $tmpuser->fetch($object->usertodo->id);
  688. $object->usertodo = $tmpuser;
  689. }
  690. if ($object->userdone->id > 0) {
  691. $tmpuser = new User($db);
  692. $res = $tmpuser->fetch($object->userdone->id);
  693. $object->userdone = $tmpuser;
  694. }
  695. */
  696. $contact = new Contact($db);
  697. if ($object->contact->id) {
  698. $result = $contact->fetch($object->contact->id, $user);
  699. }
  700. $object->contact = $contact;
  701. print_fiche_titre($langs->trans("Event") . " " . $object->label);
  702. print '<div class="with-padding">';
  703. print '<div class="columns">';
  704. print column_start();
  705. /*
  706. * Affichage onglets
  707. */
  708. dol_fiche_head($head, 'card', $langs->trans("Action"), 0, 'action');
  709. $now = dol_now();
  710. $delay_warning = $conf->global->MAIN_DELAY_ACTIONS_TODO * 24 * 60 * 60;
  711. // Confirmation suppression action
  712. if ($action == 'delete') {
  713. $ret = $form->form_confirm("/agenda/fiche.php?id=" . $id, $langs->trans("DeleteAction"), $langs->trans("ConfirmDeleteAction"), "confirm_delete", '', '', 1);
  714. if ($ret == 'html')
  715. print '<br>';
  716. }
  717. if ($action == 'edit') {
  718. print "\n" . '<script type="text/javascript" language="javascript">';
  719. print 'jQuery(document).ready(function () {
  720. function setdatefields()
  721. {
  722. if (jQuery("#fullday:checked").val() == null)
  723. {
  724. jQuery(".fulldaystarthour").attr(\'disabled\', false);
  725. jQuery(".fulldaystartmin").attr(\'disabled\', false);
  726. jQuery(".fulldayendhour").attr(\'disabled\', false);
  727. jQuery(".fulldayendmin").attr(\'disabled\', false);
  728. }
  729. else
  730. {
  731. jQuery(".fulldaystarthour").attr(\'disabled\', true);
  732. jQuery(".fulldaystartmin").attr(\'disabled\', true);
  733. jQuery(".fulldayendhour").attr(\'disabled\', true);
  734. jQuery(".fulldayendmin").attr(\'disabled\', true);
  735. jQuery(".fulldaystarthour").val("00");
  736. jQuery(".fulldaystartmin").val("00");
  737. //jQuery(".fulldayendhour").val("00");
  738. //jQuery(".fulldayendmin").val("00");
  739. jQuery(".fulldayendhour").val("23");
  740. jQuery(".fulldayendmin").val("59");
  741. }
  742. }
  743. setdatefields();
  744. jQuery("#fullday").change(function() {
  745. setdatefields();
  746. });
  747. })';
  748. print '</script>' . "\n";
  749. print "\n" . '<script type="text/javascript" language="javascript">';
  750. print 'jQuery(document).ready(function () {
  751. function settype()
  752. {
  753. var typeselected=jQuery("#actioncode").val();
  754. var type=typeselected.split("_");
  755. if (type[1] == "RDV")
  756. {
  757. $("#jqfullday").css("display","table-row");
  758. $("#jqech").hide();
  759. $("#jqstart").show();
  760. $("#jqend").css("display","table-row");
  761. $("#jqloc").css("display","table-row");
  762. $(".fulldaystarthour").show();
  763. $(".fulldaystartmin").show();
  764. $(".fulldayendhour").show();
  765. $(".fulldayendmin").show();
  766. jQuery(".fulldaystartmin").val("00");
  767. jQuery(".fulldayendmin").val("00");
  768. $("#jqduration").hide();
  769. }
  770. else
  771. {
  772. $("#jqfullday").css("display","none");
  773. $("#jqech").show();
  774. $("#jqstart").hide();
  775. $("#jqend").css("display","none");
  776. $("#jqloc").css("display","none");
  777. $(".fulldayendhour").hide();
  778. $(".fulldayendmin").hide();
  779. jQuery(".fulldaystartmin").val("00");
  780. $("#jqduration").show();
  781. }
  782. }
  783. settype();
  784. jQuery("#actioncode").change(function() {
  785. settype();
  786. });
  787. })';
  788. print '</script>' . "\n";
  789. // Fiche action en mode edition
  790. print '<form name="formaction" action="' . $_SERVER["PHP_SELF"] . '" method="post">';
  791. print '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">';
  792. print '<input type="hidden" name="action" value="update">';
  793. print '<input type="hidden" name="id" value="' . $id . '">';
  794. print '<input type="hidden" name="ref_ext" value="' . $object->ref_ext . '">';
  795. print '<input type="hidden" id="actioncode" name="actioncode" value="' . $object->type_code . '">';
  796. if ($backtopage)
  797. print '<input type="hidden" name="backtopage" value="' . ($backtopage != '1' ? $backtopage : $_SERVER["HTTP_REFERER"]) . '">';
  798. print '<table class="border" width="100%">';
  799. // Ref
  800. print '<tr><td width="30%">' . $langs->trans("Ref") . '</td><td colspan="3">' . $object->id . '</td></tr>';
  801. // Type
  802. print '<tr><td class="fieldrequired">' . ($object->type == 2 ? $langs->trans("Action") : $langs->trans("Event")) . '</td><td colspan="3">' . $object->print_fk_extrafields("type_code") . '</td></tr>';
  803. // Title
  804. print '<tr><td>' . $langs->trans("Title") . '</td><td colspan="3"><input type="text" name="label" size="50" value="' . $object->label . '"></td></tr>';
  805. // Full day
  806. print '<tr id="jqfullday"><td>' . $langs->trans("EventOnFullDay") . '</td><td><input type="checkbox" id="fullday" name="fullday" ' . (GETPOST('fullday') ? ' checked="checked"' : '') . '></td></tr>';
  807. // Date start
  808. $datep = $object->datep;
  809. if (GETPOST('datep', 'alpha'))
  810. $datep = GETPOST('datep', 'alpha');
  811. print '<tr><td width="30%" nowrap="nowrap"><span class="fieldrequired" id="jqech">' . $langs->trans("DateEchAction") . '</span><span class="fieldrequired" id="jqstart">' . $langs->trans("DateActionStart") . '</span></td><td>';
  812. if (GETPOST("afaire") == 1)
  813. $form->select_date($datep, 'datep', 1, 1, 0, "action", 1, 1, 0, 0, 'fulldayend', array('stepMinutes' => 30));
  814. else if (GETPOST("afaire") == 2)
  815. $form->select_date($datep, 'datep', 1, 1, 1, "action", 1, 1, 0, 0, 'fulldayend', array('stepMinutes' => 30));
  816. // $html->select_date($datep,'datep',0,0,1,"action",1,1,0,0,'fulldaystart');
  817. $form->select_date($datep, 'datep', 1, 1, 0, "action", 1, 1, 0, 0, 'fulldaystart', array('stepMinutes' => 30));
  818. print '</td></tr>';
  819. // Date end
  820. $datef = $object->datef;
  821. if (GETPOST('datef', 'alpha'))
  822. $datef = GETPOST('datef', 'alpha');
  823. print '<tr id="jqend"><td>' . $langs->trans("DateActionEnd") . '</td><td>';
  824. if (GETPOST("afaire") == 1)
  825. $form->select_date($datef, 'datef', 1, 1, 1, "action", 1, 1, 0, 0, 'fulldayend', array('stepMinutes' => 30));
  826. else if (GETPOST("afaire") == 2)
  827. $form->select_date($datef, 'datef', 1, 1, 1, "action", 1, 1, 0, 0, 'fulldayend', array('stepMinutes' => 30));
  828. else
  829. $form->select_date($datef, 'datef', 1, 1, 0, "action", 1, 1, 0, 0, 'fulldayend', array('stepMinutes' => 30));
  830. print '</td></tr>';
  831. /* print '<tr id="jqend"><td>' . $langs->trans("DateActionEnd") . '</td><td>';
  832. print $object->select_fk_extrafields('datef', 'datef');
  833. print '</td></tr>'; */
  834. // duration task
  835. print '<tr id="jqduration"><td>' . $langs->trans("Duration") . '</td><td colspan="3">';
  836. //<input type="text" name="duration" size="3" value="' . (empty($object->durationp) ? 1 : $object->durationp / 3600) . '">
  837. $form->select_duration('duration', $object->durationp, 0, array('stepMinutes' => 30));
  838. print '</td></tr>';
  839. // Status
  840. print '<tr><td nowrap>' . $langs->trans("Status") . '</td><td colspan="3">';
  841. print $object->select_fk_extrafields('Status', 'status');
  842. print '</td></tr>';
  843. // Percentage
  844. if ($object->type_code != 'AC_RDV') {
  845. // Status
  846. print '<tr><td nowrap>' . $langs->trans("Percentage") . '</td><td colspan="3" style="height: 60px">';
  847. $percent = GETPOST("percentage") ? GETPOST("percentage") : $object->percentage;
  848. //print $htmlactions->form_select_status_action('formaction', $percent, 1);
  849. print '<p class="inline-medium-label button-height" style="padding-left: 0px; margin-top:10px">';
  850. print '<input type="text" size="2" class="input demo-slider mid-margin-right" value="' . $percent . '" id="demo-slider1" name="percentage">';
  851. print '</p>';
  852. print '</td></tr>';
  853. print '<script type="text/javascript" >
  854. jQuery(document).ready(function(){
  855. jQuery(".demo-slider").slider({
  856. "hideInput": false
  857. });
  858. });
  859. </script>';
  860. }
  861. if ($object->type_code == "AC_RDV") { //RDV
  862. // Location
  863. print '<tr><td>' . $langs->trans("Location") . '</td><td colspan="3"><input type="text" name="location" size="50" value="' . $object->location . '"></td></tr>';
  864. }
  865. print '</table><br><br><table class="border" width="100%">';
  866. // Input by
  867. $var = false;
  868. print '<tr><td width="30%" nowrap="nowrap">' . $langs->trans("ActionAskedBy") . '</td><td colspan="3">';
  869. print $object->print_fk_extrafields("author");
  870. print '</td></tr>';
  871. // Affected to
  872. print '<tr><td nowrap="nowrap">' . $langs->trans("ActionAffectedTo") . '</td><td colspan="3">';
  873. print $object->select_fk_extrafields("usertodo", 'affectedto');
  874. print '</td></tr>';
  875. // Realised by
  876. print '<tr><td nowrap="nowrap">' . $langs->trans("ActionDoneBy") . '</td><td colspan="3">';
  877. print $object->select_fk_extrafields("userdone", 'doneby');
  878. print '</td></tr>';
  879. print '</table><br><br>';
  880. print '<table class="border" width="100%">';
  881. // Company
  882. print '<tr><td width="30%">' . $langs->trans("ActionOnCompany") . '</td>';
  883. print '<td>';
  884. print $object->select_fk_extrafields('societe', 'socid');
  885. print '</td>';
  886. // Contact
  887. print '<td>' . $langs->trans("Contact") . '</td><td width="30%">';
  888. print $object->select_fk_extrafields('contact', 'contactid');
  889. //print $form->selectarray("contactid", (empty($object->societe->id) ? array() : $object->societe->contact_array()), $object->contact->id, 1);
  890. print '</td></tr>';
  891. // Lead
  892. if ($conf->lead->enabled) {
  893. // Lead associe
  894. $langs->load("lead");
  895. print '<tr><td valign="top">' . $langs->trans("Lead") . '</td><td colspan="3">';
  896. $numlead = select_leads($object->societe->id, $object->fk_lead, 'leadid');
  897. if ($numlead == 0) {
  898. print ' &nbsp; <a href="../../lead/fiche.php?socid=' . $object->societe->id . '&action=create">' . $langs->trans("AddLead") . '</a>';
  899. }
  900. print '</td></tr>';
  901. }
  902. // Project
  903. if ($conf->projet->enabled) {
  904. // Projet associe
  905. $langs->load("project");
  906. print '<tr><td valign="top">' . $langs->trans("Project") . '</td><td colspan="3">';
  907. $numprojet = select_projects($object->societe->id, $object->fk_project, 'projectid');
  908. if ($numprojet == 0) {
  909. print ' &nbsp; <a href="../../projet/fiche.php?socid=' . $object->societe->id . '&action=create">' . $langs->trans("AddProject") . '</a>';
  910. }
  911. print '</td></tr>';
  912. }
  913. // Object linked
  914. if (!empty($object->fk_element) && !empty($object->elementtype)) {
  915. print '<tr><td>' . $langs->trans("LinkedObject") . '</td>';
  916. print '<td colspan="3">' . $object->getElementUrl($object->fk_element, $object->elementtype, 1) . '</td></tr>';
  917. }
  918. // Description
  919. print '<tr><td valign="top">' . $langs->trans("Description") . '</td><td colspan="3">';
  920. // Editeur wysiwyg
  921. require_once(DOL_DOCUMENT_ROOT . "/core/class/doleditor.class.php");
  922. $doleditor = new DolEditor('note', $object->notes, '', 240, 'dolibarr_notes', 'In', true, true, $conf->fckeditor->enabled, ROWS_5, 90);
  923. $doleditor->Create();
  924. print '</td></tr>';
  925. print '</table><br>';
  926. print '<center><input type="submit" class="button" name="edit" value="' . $langs->trans("Save") . '">';
  927. print ' &nbsp; &nbsp; <input type="submit" class="button" name="cancel" value="' . $langs->trans("Cancel") . '">';
  928. print '</center>';
  929. print '</form>';
  930. print '</div>';
  931. print column_end();
  932. } else {
  933. /**
  934. * Mode View
  935. */
  936. print '<table class="border" width="100%">';
  937. // Ref
  938. print '<tr><td width="30%">' . $langs->trans("Ref") . '</td><td colspan="3">';
  939. print $form->showrefnav($object, 'id', '', ($user->societe_id ? 0 : 1), 'id', 'ref', '');
  940. print '</td></tr>';
  941. // Type
  942. print '<tr><td>' . $langs->trans("Type") . '</td><td colspan="3">' . $object->print_fk_extrafields("type_code") . '</td></tr>';
  943. // Title
  944. print '<tr><td>' . $langs->trans("Title") . '</td><td colspan="3">' . $object->label . '</td></tr>';
  945. // Full day event
  946. print '<tr><td>' . $langs->trans("EventOnFullDay") . '</td><td colspan="3">' . yn($object->fulldayevent) . '</td></tr>';
  947. // Date start
  948. print '<tr><td width="30%">' . $langs->trans("DateActionStart") . '</td><td colspan="2">';
  949. if (!$object->fulldayevent)
  950. print dol_print_date($object->datep, 'dayhour');
  951. else
  952. print dol_print_date($object->datep, 'day');
  953. if ($object->percentage == 0 && $object->datep && $object->datep < ($now - $delay_warning))
  954. print img_warning($langs->trans("Late"));
  955. print '</td>';
  956. //if($object->type==1) //RDV
  957. //{
  958. print '<td rowspan="4" align="center" valign="middle" width="180">' . "\n";
  959. print '<form name="listactionsfiltermonth" action="' . DOL_URL_ROOT . '/comm/action/index.php" method="POST">';
  960. print '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">';
  961. print '<input type="hidden" name="action" value="show_month">';
  962. print '<input type="hidden" name="year" value="' . dol_print_date($object->datep, '%Y') . '">';
  963. print '<input type="hidden" name="month" value="' . dol_print_date($object->datep, '%m') . '">';
  964. print '<input type="hidden" name="day" value="' . dol_print_date($object->datep, '%d') . '">';
  965. //print '<input type="hidden" name="day" value="'.dol_print_date($object->datep,'%d').'">';
  966. print img_picto($langs->trans("ViewCal"), 'object_calendar') . ' <input type="submit" style="width: 120px" class="button" name="viewcal" value="' . $langs->trans("ViewCal") . '">';
  967. print '</form>' . "\n";
  968. print '<form name="listactionsfilterweek" action="' . DOL_URL_ROOT . '/comm/action/index.php" method="POST">';
  969. print '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">';
  970. print '<input type="hidden" name="action" value="show_week">';
  971. print '<input type="hidden" name="year" value="' . dol_print_date($object->datep, '%Y') . '">';
  972. print '<input type="hidden" name="month" value="' . dol_print_date($object->datep, '%m') . '">';
  973. print '<input type="hidden" name="day" value="' . dol_print_date($object->datep, '%d') . '">';
  974. //print '<input type="hidden" name="day" value="'.dol_print_date($object->datep,'%d').'">';
  975. print img_picto($langs->trans("ViewCal"), 'object_calendarweek') . ' <input type="submit" style="width: 120px" class="button" name="viewweek" value="' . $langs->trans("ViewWeek") . '">';
  976. print '</form>' . "\n";
  977. print '<form name="listactionsfilterday" action="' . DOL_URL_ROOT . '/comm/action/index.php" method="POST">';
  978. print '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">';
  979. print '<input type="hidden" name="action" value="show_day">';
  980. print '<input type="hidden" name="year" value="' . dol_print_date($object->datep, '%Y') . '">';
  981. print '<input type="hidden" name="month" value="' . dol_print_date($object->datep, '%m') . '">';
  982. print '<input type="hidden" name="day" value="' . dol_print_date($object->datep, '%d') . '">';
  983. //print '<input type="hidden" name="day" value="'.dol_print_date($object->datep,'%d').'">';
  984. print img_picto($langs->trans("ViewCal"), 'object_calendarday') . ' <input type="submit" style="width: 120px" class="button" name="viewday" value="' . $langs->trans("ViewDay") . '">';
  985. print '</form>' . "\n";
  986. print '</td>';
  987. print '</tr>';
  988. $var = !$var;
  989. // Date end
  990. print '<tr><td>' . $langs->trans("DateActionEnd") . '</td><td colspan="2">';
  991. if (!$object->fulldayevent)
  992. print dol_print_date($object->datef, 'dayhour');
  993. else
  994. print dol_print_date($object->datef, 'day');
  995. if ($object->percentage > 0 && $object->percentage < 100 && $object->datef && $object->datef < ($now - $delay_warning))
  996. print img_warning($langs->trans("Late"));
  997. print '</td></tr>';
  998. // Status
  999. print '<tr><td nowrap>' . $langs->trans("Status") . ' / ' . $langs->trans("Percentage") . '</td><td colspan="2">';
  1000. print $object->getLibStatus();
  1001. print '</td></tr>';
  1002. // Percentage
  1003. if ($object->type_code != 'AC_RDV') {
  1004. print '<tr><td nowrap>' . $langs->trans("Percentage") . '</td><td colspan="2">';
  1005. print '<span style="width: 100px" class="progress anthracite thin">';
  1006. print '<span style="width: ' . $object->percentage . '%" class="progress-bar"></span>';
  1007. print '</span>';
  1008. print '</td></tr>';
  1009. }
  1010. $var = !$var;
  1011. // Location
  1012. print '<tr><td>' . $langs->trans("Location") . '</td><td colspan="2">' . $object->location . '</td></tr>';
  1013. print '</table><br><br><table class="border" width="100%">';
  1014. // Input by
  1015. $var = false;
  1016. print '<tr><td width="30%" nowrap="nowrap">' . $langs->trans("ActionAskedBy") . '</td><td colspan="3">';
  1017. print $object->print_fk_extrafields('author');
  1018. print '</td></tr>';
  1019. // Affecte a
  1020. print '<tr><td nowrap="nowrap">' . $langs->trans("ActionAffectedTo") . '</td><td colspan="3">';
  1021. print $object->print_fk_extrafields('usertodo');
  1022. print '</td></tr>';
  1023. // Done by
  1024. print '<tr><td nowrap="nowrap">' . $langs->trans("ActionDoneBy") . '</td><td colspan="3">';
  1025. print $object->print_fk_extrafields('userdone');
  1026. print '</td></tr>';
  1027. print '</table><br><br><table class="border" width="100%">';
  1028. // Third party - Contact
  1029. print '<tr><td width="30%">' . $langs->trans("ActionOnCompany") . '</td><td>' . /* ($object->societe->id ? $object->societe->getNomUrl(1) : $langs->trans("None")) */ "";
  1030. /*
  1031. if ($object->societe->id && $object->type_code == 'AC_TEL') {
  1032. if ($object->societe->fetch($object->societe->id)) {
  1033. print "<br>" . dol_print_phone($object->societe->tel);
  1034. }
  1035. } */
  1036. if (!empty($object->societe->id)) {
  1037. $societe->id = $object->societe->id;
  1038. $societe->name = $object->societe->name;
  1039. print $societe->getNomUrl(1);
  1040. } else {
  1041. print $langs->trans("None");
  1042. }
  1043. print '</td>';
  1044. print '<td>' . $langs->trans("Contact") . '</td>';
  1045. print '<td>';
  1046. if (!empty($object->contact->id)) {
  1047. $contact->id = $object->contact->id;
  1048. $contact->name = $object->contact->name;
  1049. print $contact->getNomUrl(1);
  1050. } else {
  1051. print $langs->trans("None");
  1052. }
  1053. print '</td></tr>';
  1054. $var = !$var;
  1055. // Lead
  1056. if ($conf->lead->enabled && $object->fk_lead) {
  1057. print '<tr ' . $bc[$var] . '><td valign="top" id="label">' . $langs->trans("Lead") . '</td><td colspan="1" id="value">';
  1058. if ($object->fk_lead) {
  1059. $lead = new Lead($db);
  1060. $lead->fetch($object->fk_lead);
  1061. print $lead->getNomUrl(1);
  1062. }
  1063. print '</td></tr>';
  1064. $var = !$var;
  1065. }
  1066. // Project
  1067. if ($conf->projet->enabled) {
  1068. print '<tr><td valign="top">' . $langs->trans("Project") . '</td><td colspan="3">';
  1069. if ($object->fk_project) {
  1070. $project = new Project($db);
  1071. $project->fetch($object->fk_project);
  1072. print $project->getNomUrl(1);
  1073. }
  1074. print '</td></tr>';
  1075. $var = !$var;
  1076. }
  1077. // Object linked
  1078. if (!empty($object->fk_element) && !empty($object->elementtype)) {
  1079. print '<tr><td>' . $langs->trans("LinkedObject") . '</td>';
  1080. print '<td colspan="3">' . $object->getElementUrl($object->fk_element, $object->elementtype, 1) . '</td></tr>';
  1081. }
  1082. print '</table>';
  1083. }
  1084. print "</div>\n";
  1085. /*
  1086. * Barre d'actions
  1087. *
  1088. */
  1089. if ($action != 'edit') {
  1090. print '<div class="tabsAction">';
  1091. print '<div class="button-height">';
  1092. print '<span class="button-group">';
  1093. if ($user->rights->agenda->allactions->write ||
  1094. (($object->author->id == $user->id || $object->usertodo->id == $user->id) && $user->rights->agenda->myactions->write)) {
  1095. //print '<a class="butAction" href="' . $_SERVER['PHP_SELF'] . '?action=create&fk_task=' . $object->id . ($object->socid ? "&socid=" . $object->socid : "") . ($object->contact->id ? "&contactid=" . $object->contact->id : "") . ($object->fk_lead ? "&leadid=" . $object->fk_lead : "") . ($object->fk_project ? "&projectid=" . $object->fk_project : "") . "&backtopage=" . DOL_URL_ROOT . '/agenda/fiche.php?id=' . $object->id . '">' . $langs->trans("AddAction") . '</a>';
  1096. print '<a class="button icon-pencil" href="' . $_SERVER['PHP_SELF'] . '?action=edit&id=' . $object->id . '">' . $langs->trans("Modify") . '</a>';
  1097. if ($object->percentage < 100)
  1098. print '<a class="button icon-tick" href="' . $_SERVER['PHP_SELF'] . '?action=close&id=' . $object->id . '">' . $langs->trans("Close") . '</a>';
  1099. else
  1100. print '<a class="button icon-tick disabled" href="#" title="' . $langs->trans("NotAllowed") . '">' . $langs->trans("Close") . '</a>';
  1101. }
  1102. else {
  1103. print '<a class="button icon-pencil disabled" href="#" title="' . $langs->trans("NotAllowed") . '">' . $langs->trans("Modify") . '</a>';
  1104. print '<a class="button icon-tick disabled" href="#" title="' . $langs->trans("NotAllowed") . '">' . $langs->trans("Close") . '</a>';
  1105. }
  1106. if ($user->rights->agenda->allactions->delete ||
  1107. (($object->author->id == $user->id || $object->usertodo->id == $user->id) && $user->rights->agenda->myactions->delete)) {
  1108. print '<a class="button icon-trash red-gradient" href="' . $_SERVER['PHP_SELF'] . '?action=delete&id=' . $object->id . '">' . $langs->trans("Delete") . '</a>';
  1109. } else {
  1110. print '<a class="button icon-trash red-gradient disabled" href="#" title="' . $langs->trans("NotAllowed") . '">' . $langs->trans("Delete") . '</a>';
  1111. }
  1112. print '</span>';
  1113. print '</div>';
  1114. print '</div>';
  1115. print column_end();
  1116. print column_start("six");
  1117. print $object->show_notes(true);
  1118. print column_end();
  1119. }
  1120. }
  1121. print "</div>";
  1122. print "</div>";
  1123. llxFooter();
  1124. /**
  1125. * Ajoute une ligne de tableau a 2 colonnes pour avoir l'option synch…

Large files files are truncated, but you can click here to view the full file