2004-10-20 22:06:49 +02:00
< ? php
2005-04-05 13:46:55 +02:00
/* Copyright ( C ) 2001 - 2005 Rodolphe Quiedeville < rodolphe @ quiedeville . org >
2016-08-04 10:08:58 +02:00
* Copyright ( C ) 2004 - 2016 Laurent Destailleur < eldy @ users . sourceforge . net >
2018-10-27 14:43:12 +02:00
* Copyright ( C ) 2005 - 2012 Regis Houssin < regis . houssin @ inodbox . com >
2003-09-04 13:08:03 +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
2013-01-16 15:36:08 +01:00
* the Free Software Foundation ; either version 3 of the License , or
2003-09-04 13:08:03 +02:00
* ( 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
2019-09-23 21:55:30 +02:00
* along with this program . If not , see < https :// www . gnu . org / licenses />.
2003-09-04 13:08:03 +02:00
*/
2004-08-14 15:16:01 +02:00
2005-07-16 13:21:08 +02:00
/**
2014-09-18 21:18:25 +02:00
* \file htdocs / projet / card . php
2008-09-10 11:43:48 +02:00
* \ingroup projet
2010-02-15 01:57:27 +01:00
* \brief Project card
2008-09-10 11:43:48 +02:00
*/
2009-01-10 04:40:06 +01:00
2012-08-22 23:24:21 +02:00
require '../main.inc.php' ;
2012-08-22 23:11:24 +02:00
require_once DOL_DOCUMENT_ROOT . '/projet/class/project.class.php' ;
require_once DOL_DOCUMENT_ROOT . '/projet/class/task.class.php' ;
require_once DOL_DOCUMENT_ROOT . '/core/lib/project.lib.php' ;
2019-11-20 06:38:28 +01:00
require_once DOL_DOCUMENT_ROOT . '/core/class/doleditor.class.php' ;
2015-06-29 16:57:32 +02:00
require_once DOL_DOCUMENT_ROOT . '/core/class/html.formprojet.class.php' ;
2012-08-22 23:11:24 +02:00
require_once DOL_DOCUMENT_ROOT . '/core/class/html.formfile.class.php' ;
require_once DOL_DOCUMENT_ROOT . '/core/modules/project/modules_project.php' ;
2013-04-12 11:09:53 +02:00
require_once DOL_DOCUMENT_ROOT . '/core/class/extrafields.class.php' ;
2016-08-29 10:32:00 +02:00
require_once DOL_DOCUMENT_ROOT . '/categories/class/categorie.class.php' ;
2003-09-04 13:08:03 +02:00
2018-05-26 21:11:25 +02:00
// Load translation files required by the page
2021-02-15 12:18:08 +01:00
$langsLoad = array ( 'projects' , 'companies' );
if ( ! empty ( $conf -> eventorganization -> enabled )) {
$langsLoad [] = 'eventorganization' ;
}
$langs -> loadLangs ( $langsLoad );
2010-01-04 22:45:59 +01:00
2019-11-13 19:35:02 +01:00
$id = GETPOST ( 'id' , 'int' );
$ref = GETPOST ( 'ref' , 'alpha' );
2020-09-16 19:39:50 +02:00
$action = GETPOST ( 'action' , 'aZ09' );
2019-11-13 19:35:02 +01:00
$backtopage = GETPOST ( 'backtopage' , 'alpha' );
2022-05-19 21:32:17 +02:00
$backtopageforcancel = GETPOST ( 'backtopageforcancel' , 'alpha' );
2022-05-12 20:18:58 +02:00
$backtopagejsfields = GETPOST ( 'backtopagejsfields' , 'alpha' );
2019-11-13 19:35:02 +01:00
$cancel = GETPOST ( 'cancel' , 'alpha' );
$confirm = GETPOST ( 'confirm' , 'aZ09' );
2022-05-12 20:18:58 +02:00
$dol_openinpopup = GETPOST ( 'dol_openinpopup' , 'aZ09' );
2019-11-13 19:35:02 +01:00
$status = GETPOST ( 'status' , 'int' );
$opp_status = GETPOST ( 'opp_status' , 'int' );
$opp_percent = price2num ( GETPOST ( 'opp_percent' , 'alpha' ));
2022-05-21 18:47:01 +02:00
$objcanvas = GETPOST ( " objcanvas " , " alpha " );
$comefromclone = GETPOST ( " comefromclone " , " alpha " );
2019-11-13 19:35:02 +01:00
2021-03-24 19:06:44 +01:00
if ( $id == '' && $ref == '' && ( $action != " create " && $action != " add " && $action != " update " && ! GETPOST ( " cancel " ))) {
2021-02-26 18:49:22 +01:00
accessforbidden ();
}
2019-11-13 19:35:02 +01:00
$mine = GETPOST ( 'mode' ) == 'mine' ? 1 : 0 ;
2010-05-29 01:26:08 +02:00
//if (! $user->rights->projet->all->lire) $mine=1; // Special for projects
2010-05-30 14:21:32 +02:00
2017-06-10 12:56:28 +02:00
// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
2019-11-13 19:35:02 +01:00
$hookmanager -> initHooks ( array ( 'projectcard' , 'globalcard' ));
Add: hooks and triggers for a lot of core modules (action/calendrier, deplacement, dons, tva, contact/tiers, contrat, product lines, expedition, fournisseur commandes et factures, fiche intervention, projet et taches)
Signed-off-by: Stephen L. <lrq3000@gmail.com>
2012-08-14 15:50:45 +02:00
2012-07-02 19:30:37 +02:00
$object = new Project ( $db );
2013-04-12 11:09:53 +02:00
$extrafields = new ExtraFields ( $db );
2015-03-04 20:52:54 +01:00
2015-03-02 17:54:35 +01:00
// Load object
2015-10-01 16:50:18 +02:00
//include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Can't use generic include because when creating a project, ref is defined and we dont want error if fetch fails from ref.
2021-02-26 18:49:22 +01:00
if ( $id > 0 || ! empty ( $ref )) {
2019-11-13 19:35:02 +01:00
$ret = $object -> fetch ( $id , $ref ); // If we create project, ref may be defined into POST but record does not yet exists into database
2017-10-07 13:09:31 +02:00
if ( $ret > 0 ) {
$object -> fetch_thirdparty ();
2021-02-26 18:49:22 +01:00
if ( ! empty ( $conf -> global -> PROJECT_ALLOW_COMMENT_ON_PROJECT ) && method_exists ( $object , 'fetchComments' ) && empty ( $object -> comments )) {
$object -> fetchComments ();
}
2019-11-13 19:35:02 +01:00
$id = $object -> id ;
2017-10-07 13:09:31 +02:00
}
2012-06-09 18:37:54 +02:00
}
2010-05-23 22:01:10 +02:00
2013-04-12 11:09:53 +02:00
// fetch optionals attributes and labels
2019-10-06 14:41:52 +02:00
$extrafields -> fetch_name_optionals_label ( $object -> table_element );
2013-04-12 11:09:53 +02:00
2019-11-13 19:35:02 +01:00
$date_start = dol_mktime ( 0 , 0 , 0 , GETPOST ( 'projectstartmonth' , 'int' ), GETPOST ( 'projectstartday' , 'int' ), GETPOST ( 'projectstartyear' , 'int' ));
$date_end = dol_mktime ( 0 , 0 , 0 , GETPOST ( 'projectendmonth' , 'int' ), GETPOST ( 'projectendday' , 'int' ), GETPOST ( 'projectendyear' , 'int' ));
2012-08-31 14:31:36 +02:00
2021-03-29 21:35:19 +02:00
// Security check
$socid = GETPOST ( 'socid' , 'int' );
//if ($user->socid > 0) $socid = $user->socid; // For external user, no check is done on company because readability is managed by public status of project and assignement.
restrictedArea ( $user , 'projet' , $object -> id , 'projet&project' );
2021-07-28 12:05:46 +02:00
$permissiondellink = $user -> rights -> projet -> creer ; // Used by the include of actions_dellink.inc.php
2010-05-23 22:01:10 +02:00
2008-02-24 14:18:40 +01:00
/*
2008-09-10 11:43:48 +02:00
* Actions
*/
2007-11-29 22:19:21 +01:00
2019-11-13 19:35:02 +01:00
$parameters = array ( 'id' => $socid , 'objcanvas' => $objcanvas );
$reshook = $hookmanager -> executeHooks ( 'doActions' , $parameters , $object , $action ); // Note that $action and $object may have been modified by some hooks
2021-02-26 18:49:22 +01:00
if ( $reshook < 0 ) {
setEventMessages ( $hookmanager -> error , $hookmanager -> errors , 'errors' );
}
2014-05-08 20:02:34 +02:00
2021-02-26 18:49:22 +01:00
if ( empty ( $reshook )) {
2021-09-02 21:35:36 +02:00
$backurlforlist = DOL_URL_ROOT . '/projet/list.php' ;
2014-05-08 20:02:34 +02:00
// Cancel
2021-02-26 18:49:22 +01:00
if ( $cancel ) {
if ( GETPOST ( " comefromclone " ) == 1 ) {
2019-11-13 19:35:02 +01:00
$result = $object -> delete ( $user );
2021-02-26 18:49:22 +01:00
if ( $result > 0 ) {
2017-10-07 13:09:31 +02:00
header ( " Location: index.php " );
exit ;
2020-05-21 15:05:19 +02:00
} else {
2019-01-27 11:55:16 +01:00
dol_syslog ( $object -> error , LOG_DEBUG );
2020-05-19 21:38:42 +02:00
setEventMessages ( $langs -> trans ( " CantRemoveProject " , $langs -> transnoentitiesnoconv ( " ProjectOverview " )), null , 'errors' );
2017-10-07 13:09:31 +02:00
}
2014-05-08 20:02:34 +02:00
}
2021-09-02 21:35:36 +02:00
}
if ( empty ( $backtopage ) || ( $cancel && empty ( $id ))) {
if ( empty ( $backtopage ) || ( $cancel && strpos ( $backtopage , '__ID__' ))) {
if ( empty ( $id ) && (( $action != 'add' && $action != 'create' ) || $cancel )) {
$backtopage = $backurlforlist ;
} else {
$backtopage = DOL_URL_ROOT . '/projet/card.php?id=' . (( ! empty ( $id ) && $id > 0 ) ? $id : '__ID__' );
}
}
}
if ( $cancel ) {
if ( ! empty ( $backtopageforcancel )) {
header ( " Location: " . $backtopageforcancel );
exit ;
} elseif ( ! empty ( $backtopage )) {
2017-10-07 13:09:31 +02:00
header ( " Location: " . $backtopage );
exit ;
2015-03-04 18:56:57 +01:00
}
$action = '' ;
2012-04-27 11:03:01 +02:00
}
2010-11-11 13:16:55 +01:00
2021-07-28 12:05:46 +02:00
include DOL_DOCUMENT_ROOT . '/core/actions_dellink.inc.php' ; // Must be include, not include_once
2021-02-26 18:49:22 +01:00
if ( $action == 'add' && $user -> rights -> projet -> creer ) {
2019-11-13 19:35:02 +01:00
$error = 0 ;
2021-02-26 18:49:22 +01:00
if ( ! GETPOST ( 'ref' )) {
2017-10-07 13:09:31 +02:00
setEventMessages ( $langs -> trans ( " ErrorFieldRequired " , $langs -> transnoentities ( " Ref " )), null , 'errors' );
$error ++ ;
}
2021-02-26 18:49:22 +01:00
if ( ! GETPOST ( 'title' )) {
2020-11-24 21:12:44 +01:00
setEventMessages ( $langs -> trans ( " ErrorFieldRequired " , $langs -> transnoentities ( " ProjectLabel " )), null , 'errors' );
2017-10-07 13:09:31 +02:00
$error ++ ;
}
2021-07-28 16:14:38 +02:00
if ( ! empty ( $conf -> global -> PROJECT_USE_OPPORTUNITIES )) {
if ( GETPOST ( 'opp_amount' ) != '' && ! ( GETPOST ( 'opp_status' ) > 0 )) {
$error ++ ;
setEventMessages ( $langs -> trans ( " ErrorOppStatusRequiredIfAmount " ), null , 'errors' );
}
2017-10-07 13:09:31 +02:00
}
// Create with status validated immediatly
2021-02-26 18:49:22 +01:00
if ( ! empty ( $conf -> global -> PROJECT_CREATE_NO_DRAFT )) {
2019-11-13 19:35:02 +01:00
$status = Project :: STATUS_VALIDATED ;
2017-10-07 13:09:31 +02:00
}
2021-02-26 18:49:22 +01:00
if ( ! $error ) {
2019-11-13 19:35:02 +01:00
$error = 0 ;
2017-10-07 13:09:31 +02:00
$db -> begin ();
2020-09-17 19:01:01 +02:00
$object -> ref = GETPOST ( 'ref' , 'alphanohtml' );
$object -> title = GETPOST ( 'title' , 'alphanohtml' );
2019-01-27 11:55:16 +01:00
$object -> socid = GETPOST ( 'socid' , 'int' );
2020-09-17 12:30:14 +02:00
$object -> description = GETPOST ( 'description' , 'restricthtml' ); // Do not use 'alpha' here, we want field as it is
2020-09-17 19:01:01 +02:00
$object -> public = GETPOST ( 'public' , 'alphanohtml' );
$object -> opp_amount = price2num ( GETPOST ( 'opp_amount' , 'alphanohtml' ));
$object -> budget_amount = price2num ( GETPOST ( 'budget_amount' , 'alphanohtml' ));
2019-11-13 19:35:02 +01:00
$object -> date_c = dol_now ();
2017-10-07 13:09:31 +02:00
$object -> date_start = $date_start ;
$object -> date_end = $date_end ;
$object -> statut = $status ;
$object -> opp_status = $opp_status ;
$object -> opp_percent = $opp_percent ;
2019-11-13 19:35:02 +01:00
$object -> usage_opportunity = ( GETPOST ( 'usage_opportunity' , 'alpha' ) == 'on' ? 1 : 0 );
$object -> usage_task = ( GETPOST ( 'usage_task' , 'alpha' ) == 'on' ? 1 : 0 );
$object -> usage_bill_time = ( GETPOST ( 'usage_bill_time' , 'alpha' ) == 'on' ? 1 : 0 );
$object -> usage_organize_event = ( GETPOST ( 'usage_organize_event' , 'alpha' ) == 'on' ? 1 : 0 );
2017-10-07 13:09:31 +02:00
// Fill array 'array_options' with data from add form
2019-10-06 14:41:52 +02:00
$ret = $extrafields -> setOptionalsFromPost ( null , $object );
2021-02-26 18:49:22 +01:00
if ( $ret < 0 ) {
$error ++ ;
}
2014-05-08 20:02:34 +02:00
2017-10-07 13:09:31 +02:00
$result = $object -> create ( $user );
2021-02-26 18:49:22 +01:00
if ( ! $error && $result > 0 ) {
2017-10-07 13:09:31 +02:00
// Add myself as project leader
2022-03-03 12:19:47 +01:00
$typeofcontact = 'PROJECTLEADER' ;
2021-01-19 15:54:06 +01:00
$result = $object -> add_contact ( $user -> id , $typeofcontact , 'internal' );
2022-03-03 12:19:47 +01:00
// -3 means type not found (PROJECTLEADER renamed, de-activated or deleted), so don't prevent creation if it has been the case
2022-03-08 15:07:02 +01:00
if ( $result == - 3 ) {
2022-03-17 02:37:30 +01:00
setEventMessage ( 'ErrorPROJECTLEADERRoleMissingRestoreIt' , 'errors' );
2022-03-23 17:23:01 +01:00
$error ++ ;
2022-03-08 15:07:02 +01:00
} elseif ( $result < 0 ) {
2017-10-07 13:09:31 +02:00
$langs -> load ( " errors " );
2020-08-03 12:26:26 +02:00
setEventMessages ( $object -> error , $object -> errors , 'errors' );
2017-10-07 13:09:31 +02:00
$error ++ ;
}
2020-05-21 15:05:19 +02:00
} else {
2017-10-07 13:09:31 +02:00
$langs -> load ( " errors " );
2020-08-03 12:26:26 +02:00
setEventMessages ( $object -> error , $object -> errors , 'errors' );
2017-10-07 13:09:31 +02:00
$error ++ ;
}
2021-02-26 18:49:22 +01:00
if ( ! $error && ! empty ( $object -> id ) > 0 ) {
2017-10-07 13:09:31 +02:00
// Category association
$categories = GETPOST ( 'categories' , 'array' );
2019-11-13 19:35:02 +01:00
$result = $object -> setCategories ( $categories );
if ( $result < 0 ) {
2017-10-07 13:09:31 +02:00
$langs -> load ( " errors " );
setEventMessages ( $object -> error , $object -> errors , 'errors' );
$error ++ ;
}
}
2014-05-08 20:02:34 +02:00
2021-02-26 18:49:22 +01:00
if ( ! $error ) {
2017-10-07 13:09:31 +02:00
$db -> commit ();
2021-02-26 18:49:22 +01:00
if ( ! empty ( $backtopage )) {
2021-10-11 15:02:53 +02:00
$backtopage = preg_replace ( '/--IDFORBACKTOPAGE--|__ID__/' , $object -> id , $backtopage ); // New method to autoselect project after a New on another form object creation
2019-11-13 19:35:02 +01:00
$backtopage = $backtopage . '&projectid=' . $object -> id ; // Old method
2019-10-21 14:44:39 +02:00
header ( " Location: " . $backtopage );
2017-10-07 13:09:31 +02:00
exit ;
2020-05-21 15:05:19 +02:00
} else {
2017-10-07 13:09:31 +02:00
header ( " Location:card.php?id= " . $object -> id );
exit ;
2015-06-03 11:55:39 +02:00
}
2020-05-21 15:05:19 +02:00
} else {
2017-10-07 13:09:31 +02:00
$db -> rollback ();
2021-03-12 16:48:43 +01:00
unset ( $_POST [ " ref " ]);
2017-10-07 13:09:31 +02:00
$action = 'create' ;
}
2020-05-21 15:05:19 +02:00
} else {
2017-10-07 13:09:31 +02:00
$action = 'create' ;
}
2014-05-08 20:02:34 +02:00
}
2009-07-28 20:12:47 +02:00
2021-02-26 18:49:22 +01:00
if ( $action == 'update' && empty ( GETPOST ( 'cancel' )) && $user -> rights -> projet -> creer ) {
2019-11-13 19:35:02 +01:00
$error = 0 ;
2017-10-07 13:09:31 +02:00
2021-02-26 18:49:22 +01:00
if ( empty ( $ref )) {
2017-10-07 13:09:31 +02:00
$error ++ ;
setEventMessages ( $langs -> trans ( " ErrorFieldRequired " , $langs -> transnoentities ( " Ref " )), null , 'errors' );
}
2021-03-24 19:53:31 +01:00
if ( ! GETPOST ( " title " )) {
2017-10-07 13:09:31 +02:00
$error ++ ;
2020-11-24 21:12:44 +01:00
setEventMessages ( $langs -> trans ( " ErrorFieldRequired " , $langs -> transnoentities ( " ProjectLabel " )), null , 'errors' );
2017-10-07 13:09:31 +02:00
}
$db -> begin ();
2021-02-26 18:49:22 +01:00
if ( ! $error ) {
2015-09-24 16:32:48 +02:00
$object -> oldcopy = clone $object ;
2014-05-08 20:02:34 +02:00
$old_start_date = $object -> date_start ;
2019-01-27 11:55:16 +01:00
$object -> ref = GETPOST ( 'ref' , 'alpha' );
2020-09-18 01:29:17 +02:00
$object -> title = GETPOST ( 'title' , 'alphanohtml' ); // Do not use 'alpha' here, we want field as it is
2019-01-27 11:55:16 +01:00
$object -> statut = GETPOST ( 'status' , 'int' );
$object -> socid = GETPOST ( 'socid' , 'int' );
2020-09-17 12:30:14 +02:00
$object -> description = GETPOST ( 'description' , 'restricthtml' ); // Do not use 'alpha' here, we want field as it is
2019-01-27 11:55:16 +01:00
$object -> public = GETPOST ( 'public' , 'alpha' );
2020-02-21 17:53:37 +01:00
$object -> date_start = ( ! GETPOST ( 'projectstart' )) ? '' : $date_start ;
$object -> date_end = ( ! GETPOST ( 'projectend' )) ? '' : $date_end ;
2021-02-26 18:49:22 +01:00
if ( GETPOSTISSET ( 'opp_amount' )) {
$object -> opp_amount = price2num ( GETPOST ( 'opp_amount' , 'alpha' ));
}
if ( GETPOSTISSET ( 'budget_amount' )) {
$object -> budget_amount = price2num ( GETPOST ( 'budget_amount' , 'alpha' ));
}
if ( GETPOSTISSET ( 'opp_status' )) {
$object -> opp_status = $opp_status ;
}
if ( GETPOSTISSET ( 'opp_percent' )) {
$object -> opp_percent = $opp_percent ;
}
2019-11-13 19:35:02 +01:00
$object -> usage_opportunity = ( GETPOST ( 'usage_opportunity' , 'alpha' ) == 'on' ? 1 : 0 );
$object -> usage_task = ( GETPOST ( 'usage_task' , 'alpha' ) == 'on' ? 1 : 0 );
$object -> usage_bill_time = ( GETPOST ( 'usage_bill_time' , 'alpha' ) == 'on' ? 1 : 0 );
$object -> usage_organize_event = ( GETPOST ( 'usage_organize_event' , 'alpha' ) == 'on' ? 1 : 0 );
2017-10-07 13:09:31 +02:00
// Fill array 'array_options' with data from add form
2021-12-06 11:19:12 +01:00
$ret = $extrafields -> setOptionalsFromPost ( null , $object , '@GETPOSTISSET' );
2021-02-26 18:49:22 +01:00
if ( $ret < 0 ) {
$error ++ ;
}
2017-10-07 13:09:31 +02:00
}
2010-11-11 13:16:55 +01:00
2021-07-28 16:14:38 +02:00
if ( ! empty ( $conf -> global -> PROJECT_USE_OPPORTUNITIES )) {
if ( $object -> opp_amount && ( $object -> opp_status <= 0 )) {
$error ++ ;
setEventMessages ( $langs -> trans ( " ErrorOppStatusRequiredIfAmount " ), null , 'errors' );
}
2017-10-07 13:09:31 +02:00
}
2021-02-26 18:49:22 +01:00
if ( ! $error ) {
2019-11-13 19:35:02 +01:00
$result = $object -> update ( $user );
2021-02-26 18:49:22 +01:00
if ( $result < 0 ) {
2017-10-07 13:09:31 +02:00
$error ++ ;
2021-02-26 18:49:22 +01:00
if ( $result == - 4 ) {
setEventMessages ( $langs -> trans ( " ErrorRefAlreadyExists " ), null , 'errors' );
} else {
setEventMessages ( $object -> error , $object -> errors , 'errors' );
}
2019-11-13 19:35:02 +01:00
} else {
2017-10-07 13:09:31 +02:00
// Category association
$categories = GETPOST ( 'categories' , 'array' );
2019-11-13 19:35:02 +01:00
$result = $object -> setCategories ( $categories );
2021-02-26 18:49:22 +01:00
if ( $result < 0 ) {
2017-10-07 13:09:31 +02:00
$error ++ ;
setEventMessages ( $object -> error , $object -> errors , 'errors' );
}
}
}
2021-02-26 18:49:22 +01:00
if ( ! $error ) {
if ( GETPOST ( " reportdate " ) && ( $object -> date_start != $old_start_date )) {
2019-11-13 19:35:02 +01:00
$result = $object -> shiftTaskDate ( $old_start_date );
2021-02-26 18:49:22 +01:00
if ( $result < 0 ) {
2017-10-07 13:09:31 +02:00
$error ++ ;
setEventMessages ( $langs -> trans ( " ErrorShiftTaskDate " ) . ':' . $object -> error , $object -> errors , 'errors' );
}
}
}
2013-04-30 18:23:44 +02:00
2017-02-01 13:25:16 +01:00
// Check if we must change status
2021-02-26 18:49:22 +01:00
if ( GETPOST ( 'closeproject' )) {
2017-10-07 13:09:31 +02:00
$resclose = $object -> setClose ( $user );
2021-02-26 18:49:22 +01:00
if ( $resclose < 0 ) {
2017-10-07 13:09:31 +02:00
$error ++ ;
setEventMessages ( $langs -> trans ( " FailedToCloseProject " ) . ':' . $object -> error , $object -> errors , 'errors' );
}
}
2017-06-02 12:27:46 +02:00
2021-02-26 18:49:22 +01:00
if ( $error ) {
2014-05-08 20:02:34 +02:00
$db -> rollback ();
2019-11-13 19:35:02 +01:00
$action = 'edit' ;
2020-05-21 15:05:19 +02:00
} else {
2017-10-07 13:09:31 +02:00
$db -> commit ();
2010-11-11 13:16:55 +01:00
2021-02-26 18:49:22 +01:00
if ( GETPOST ( 'socid' , 'int' ) > 0 ) {
$object -> fetch_thirdparty ( GETPOST ( 'socid' , 'int' ));
} else {
unset ( $object -> thirdparty );
}
2017-10-07 13:09:31 +02:00
}
2014-05-08 20:02:34 +02:00
}
2013-10-23 18:26:18 +02:00
2014-05-08 20:02:34 +02:00
// Build doc
2021-02-26 18:49:22 +01:00
if ( $action == 'builddoc' && $user -> rights -> projet -> creer ) {
2014-05-08 20:02:34 +02:00
// Save last template used to generate document
2021-02-26 18:49:22 +01:00
if ( GETPOST ( 'model' )) {
$object -> setDocModel ( $user , GETPOST ( 'model' , 'alpha' ));
}
2010-11-11 13:16:55 +01:00
2017-10-07 13:09:31 +02:00
$outputlangs = $langs ;
2021-02-26 18:49:22 +01:00
if ( GETPOST ( 'lang_id' , 'aZ09' )) {
2019-01-27 11:55:16 +01:00
$outputlangs = new Translate ( " " , $conf );
$outputlangs -> setDefaultLang ( GETPOST ( 'lang_id' , 'aZ09' ));
2017-10-07 13:09:31 +02:00
}
2020-09-10 01:49:09 +02:00
$result = $object -> generateDocument ( $object -> model_pdf , $outputlangs );
2021-02-26 18:49:22 +01:00
if ( $result <= 0 ) {
2017-10-07 13:09:31 +02:00
setEventMessages ( $object -> error , $object -> errors , 'errors' );
2019-11-13 19:35:02 +01:00
$action = '' ;
2017-10-07 13:09:31 +02:00
}
2014-05-08 20:02:34 +02:00
}
2010-01-13 19:20:21 +01:00
2014-05-08 20:02:34 +02:00
// Delete file in doc form
2021-02-26 18:49:22 +01:00
if ( $action == 'remove_file' && $user -> rights -> projet -> creer ) {
if ( $object -> id > 0 ) {
2019-11-13 19:35:02 +01:00
require_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php' ;
2016-08-29 10:32:00 +02:00
2016-07-01 17:49:13 +02:00
$langs -> load ( " other " );
2023-03-24 15:58:53 +01:00
$upload_dir = $conf -> project -> multidir_output [ $object -> entity ];
2019-11-13 19:35:02 +01:00
$file = $upload_dir . '/' . GETPOST ( 'file' );
2016-07-01 17:49:13 +02:00
$ret = dol_delete_file ( $file , 0 , 0 , 0 , $object );
2021-02-26 18:49:22 +01:00
if ( $ret ) {
2016-07-01 17:49:13 +02:00
setEventMessages ( $langs -> trans ( " FileWasRemoved " , GETPOST ( 'file' )), null , 'mesgs' );
2021-02-26 18:49:22 +01:00
} else {
setEventMessages ( $langs -> trans ( " ErrorFailToDeleteFile " , GETPOST ( 'file' )), null , 'errors' );
}
2016-07-01 17:49:13 +02:00
$action = '' ;
2017-10-07 13:09:31 +02:00
}
2014-05-08 20:02:34 +02:00
}
2012-05-29 23:50:13 +02:00
2012-04-27 10:32:01 +02:00
2021-02-26 18:49:22 +01:00
if ( $action == 'confirm_validate' && $confirm == 'yes' ) {
2017-10-07 13:09:31 +02:00
$result = $object -> setValid ( $user );
2021-02-26 18:49:22 +01:00
if ( $result <= 0 ) {
2017-10-07 13:09:31 +02:00
setEventMessages ( $object -> error , $object -> errors , 'errors' );
}
2014-05-08 20:02:34 +02:00
}
2010-01-04 23:04:04 +01:00
2021-02-26 18:49:22 +01:00
if ( $action == 'confirm_close' && $confirm == 'yes' ) {
2017-10-07 13:09:31 +02:00
$result = $object -> setClose ( $user );
2021-02-26 18:49:22 +01:00
if ( $result <= 0 ) {
2017-10-07 13:09:31 +02:00
setEventMessages ( $object -> error , $object -> errors , 'errors' );
}
2014-05-08 20:02:34 +02:00
}
2010-01-04 23:04:04 +01:00
2021-02-26 18:49:22 +01:00
if ( $action == 'confirm_reopen' && $confirm == 'yes' ) {
2017-10-07 13:09:31 +02:00
$result = $object -> setValid ( $user );
2021-02-26 18:49:22 +01:00
if ( $result <= 0 ) {
2017-10-07 13:09:31 +02:00
setEventMessages ( $object -> error , $object -> errors , 'errors' );
}
2014-05-08 20:02:34 +02:00
}
2010-01-04 22:45:59 +01:00
2021-02-26 18:49:22 +01:00
if ( $action == 'confirm_delete' && GETPOST ( " confirm " ) == " yes " && $user -> rights -> projet -> supprimer ) {
2017-10-07 13:09:31 +02:00
$object -> fetch ( $id );
2019-11-13 19:35:02 +01:00
$result = $object -> delete ( $user );
2021-02-26 18:49:22 +01:00
if ( $result > 0 ) {
2017-10-07 13:09:31 +02:00
setEventMessages ( $langs -> trans ( " RecordDeleted " ), null , 'mesgs' );
2018-02-26 21:16:40 +01:00
header ( " Location: list.php?restore_lastsearch_values=1 " );
2017-10-07 13:09:31 +02:00
exit ;
2020-05-21 15:05:19 +02:00
} else {
2019-01-27 11:55:16 +01:00
dol_syslog ( $object -> error , LOG_DEBUG );
2017-10-07 13:09:31 +02:00
setEventMessages ( $object -> error , $object -> errors , 'errors' );
}
2014-05-08 20:02:34 +02:00
}
2003-09-04 13:08:03 +02:00
2021-02-26 18:49:22 +01:00
if ( $action == 'confirm_clone' && $user -> rights -> projet -> creer && $confirm == 'yes' ) {
2019-11-13 19:35:02 +01:00
$clone_contacts = GETPOST ( 'clone_contacts' ) ? 1 : 0 ;
$clone_tasks = GETPOST ( 'clone_tasks' ) ? 1 : 0 ;
2014-05-08 20:02:34 +02:00
$clone_project_files = GETPOST ( 'clone_project_files' ) ? 1 : 0 ;
$clone_task_files = GETPOST ( 'clone_task_files' ) ? 1 : 0 ;
2019-11-13 19:35:02 +01:00
$clone_notes = GETPOST ( 'clone_notes' ) ? 1 : 0 ;
$move_date = GETPOST ( 'move_date' ) ? 1 : 0 ;
$clone_thirdparty = GETPOST ( 'socid' , 'int' ) ? GETPOST ( 'socid' , 'int' ) : 0 ;
2017-10-07 13:09:31 +02:00
2019-11-13 19:35:02 +01:00
$result = $object -> createFromClone ( $user , $object -> id , $clone_contacts , $clone_tasks , $clone_project_files , $clone_task_files , $clone_notes , $move_date , 0 , $clone_thirdparty );
2021-02-26 18:49:22 +01:00
if ( $result <= 0 ) {
2017-10-07 13:09:31 +02:00
setEventMessages ( $object -> error , $object -> errors , 'errors' );
2020-05-21 15:05:19 +02:00
} else {
2017-10-07 13:09:31 +02:00
// Load new object
2019-11-13 19:35:02 +01:00
$newobject = new Project ( $db );
2017-10-07 13:09:31 +02:00
$newobject -> fetch ( $result );
$newobject -> fetch_optionals ();
2019-11-13 19:35:02 +01:00
$newobject -> fetch_thirdparty (); // Load new object
$object = $newobject ;
$action = 'edit' ;
$comefromclone = true ;
2017-10-07 13:09:31 +02:00
}
2014-05-08 20:02:34 +02:00
}
2018-03-28 15:22:47 +02:00
// Actions to send emails
2019-12-02 09:38:16 +01:00
$triggersendname = 'PROJECT_SENTBYMAIL' ;
2019-11-13 19:35:02 +01:00
$paramname = 'id' ;
$autocopy = 'MAIN_MAIL_AUTOCOPY_PROJECT_TO' ; // used to know the automatic BCC to add
$trackid = 'proj' . $object -> id ;
2018-03-28 15:22:47 +02:00
include DOL_DOCUMENT_ROOT . '/core/actions_sendmails.inc.php' ;
2012-04-27 10:32:01 +02:00
}
2005-08-14 03:38:12 +02:00
2008-03-02 23:20:44 +01:00
/*
2008-09-10 11:43:48 +02:00
* View
*/
2008-03-02 23:20:44 +01:00
2011-11-08 10:18:45 +01:00
$form = new Form ( $db );
2010-01-13 18:58:34 +01:00
$formfile = new FormFile ( $db );
2015-06-29 16:57:32 +02:00
$formproject = new FormProjets ( $db );
2010-05-23 22:01:10 +02:00
$userstatic = new User ( $db );
2021-09-02 18:48:46 +02:00
$title = $langs -> trans ( " Project " ) . ' - ' . $object -> ref . ( ! empty ( $object -> thirdparty -> name ) ? ' - ' . $object -> thirdparty -> name : '' ) . ( ! empty ( $object -> title ) ? ' - ' . $object -> title : '' );
2021-02-26 18:49:22 +01:00
if ( ! empty ( $conf -> global -> MAIN_HTML_TITLE ) && preg_match ( '/projectnameonly/' , $conf -> global -> MAIN_HTML_TITLE )) {
2021-09-02 18:48:46 +02:00
$title = $object -> ref . ( ! empty ( $object -> thirdparty -> name ) ? ' - ' . $object -> thirdparty -> name : '' ) . ( ! empty ( $object -> title ) ? ' - ' . $object -> title : '' );
2021-02-26 18:49:22 +01:00
}
2021-03-13 15:19:09 +01:00
$help_url = " EN:Module_Projects|FR:Module_Projets|ES:Módulo_Proyectos|DE:Modul_Projekte " ;
2015-03-23 12:44:41 +01:00
2019-01-27 11:55:16 +01:00
llxHeader ( " " , $title , $help_url );
2004-08-07 03:25:00 +02:00
2019-11-13 19:35:02 +01:00
$titleboth = $langs -> trans ( " LeadsOrProjects " );
$titlenew = $langs -> trans ( " NewLeadOrProject " ); // Leads and opportunities by default
2022-12-20 10:13:47 +01:00
if ( ! getDolGlobalInt ( 'PROJECT_USE_OPPORTUNITIES' )) {
2019-11-13 19:35:02 +01:00
$titleboth = $langs -> trans ( " Projects " );
2018-10-01 18:56:47 +02:00
$titlenew = $langs -> trans ( " NewProject " );
}
2022-12-21 20:45:11 +01:00
if ( getDolGlobalInt ( 'PROJECT_USE_OPPORTUNITIES' ) == 2 ) { // 2 = leads only
2019-11-13 19:35:02 +01:00
$titleboth = $langs -> trans ( " Leads " );
2018-10-01 18:56:47 +02:00
$titlenew = $langs -> trans ( " NewLead " );
}
2010-01-28 12:08:11 +01:00
2021-02-26 18:49:22 +01:00
if ( $action == 'create' && $user -> rights -> projet -> creer ) {
2017-10-07 13:09:31 +02:00
/*
2021-02-26 18:49:22 +01:00
* Create
*/
2014-06-11 18:01:15 +02:00
2019-11-13 19:35:02 +01:00
$thirdparty = new Societe ( $db );
2021-02-26 18:49:22 +01:00
if ( $socid > 0 ) {
$thirdparty -> fetch ( $socid );
}
2014-06-11 18:01:15 +02:00
2019-10-02 18:14:41 +02:00
print load_fiche_titre ( $titlenew , '' , 'project' );
2017-10-07 13:09:31 +02:00
print '<form action="' . $_SERVER [ " PHP_SELF " ] . '" method="POST">' ;
print '<input type="hidden" name="action" value="add">' ;
2022-05-12 20:18:58 +02:00
print '<input type="hidden" name="token" value="' . newToken () . '">' ;
2017-10-07 13:09:31 +02:00
print '<input type="hidden" name="backtopage" value="' . $backtopage . '">' ;
2022-07-12 19:17:44 +02:00
print '<input type="hidden" name="backtopageforcancel" value="' . $backtopageforcancel . '">' ;
2022-05-12 20:18:58 +02:00
print '<input type="hidden" name="backtopagejsfields" value="' . $backtopagejsfields . '">' ;
2017-10-07 13:09:31 +02:00
2020-10-22 22:50:03 +02:00
print dol_get_fiche_head ();
2017-10-07 13:09:31 +02:00
2019-11-01 23:16:08 +01:00
print '<table class="border centpercent tableforfieldcreate">' ;
2017-10-07 13:09:31 +02:00
2019-11-13 19:35:02 +01:00
$defaultref = '' ;
$modele = empty ( $conf -> global -> PROJECT_ADDON ) ? 'mod_project_simple' : $conf -> global -> PROJECT_ADDON ;
2017-10-07 13:09:31 +02:00
// Search template files
2019-11-13 19:35:02 +01:00
$file = '' ; $classname = '' ; $filefound = 0 ;
$dirmodels = array_merge ( array ( '/' ), ( array ) $conf -> modules_parts [ 'models' ]);
2021-02-26 18:49:22 +01:00
foreach ( $dirmodels as $reldir ) {
2019-11-13 19:35:02 +01:00
$file = dol_buildpath ( $reldir . " core/modules/project/ " . $modele . '.php' , 0 );
2021-02-26 18:49:22 +01:00
if ( file_exists ( $file )) {
2019-11-13 19:35:02 +01:00
$filefound = 1 ;
2017-10-07 13:09:31 +02:00
$classname = $modele ;
break ;
}
}
2021-02-26 18:49:22 +01:00
if ( $filefound ) {
2019-11-13 19:35:02 +01:00
$result = dol_include_once ( $reldir . " core/modules/project/ " . $modele . '.php' );
2017-10-07 13:09:31 +02:00
$modProject = new $classname ;
2019-01-27 11:55:16 +01:00
$defaultref = $modProject -> getNextValue ( $thirdparty , $object );
2017-10-07 13:09:31 +02:00
}
2021-02-26 18:49:22 +01:00
if ( is_numeric ( $defaultref ) && $defaultref <= 0 ) {
$defaultref = '' ;
}
2017-10-07 13:09:31 +02:00
// Ref
2021-03-24 19:53:31 +01:00
$suggestedref = ( GETPOST ( " ref " ) ? GETPOST ( " ref " ) : $defaultref );
2021-10-12 23:50:23 +02:00
print '<tr><td class="titlefieldcreate"><span class="fieldrequired">' . $langs -> trans ( " Ref " ) . '</span></td><td class><input class="maxwidth150onsmartphone" type="text" name="ref" value="' . dol_escape_htmltag ( $suggestedref ) . '">' ;
2017-10-07 13:09:31 +02:00
print ' ' . $form -> textwithpicto ( '' , $langs -> trans ( " YouCanCompleteRef " , $suggestedref ));
print '</td></tr>' ;
// Label
2021-10-12 23:50:23 +02:00
print '<tr><td><span class="fieldrequired">' . $langs -> trans ( " ProjectLabel " ) . '</span></td><td><input class="width500 maxwidth150onsmartphone" type="text" name="title" value="' . dol_escape_htmltag ( GETPOST ( " title " , 'alphanohtml' )) . '" autofocus></td></tr>' ;
2017-10-07 13:09:31 +02:00
2019-09-01 01:40:51 +02:00
// Usage (opp, task, bill time, ...)
2021-03-20 12:42:46 +01:00
if ( ! empty ( $conf -> global -> PROJECT_USE_OPPORTUNITIES ) || empty ( $conf -> global -> PROJECT_HIDE_TASKS ) || ! empty ( $conf -> eventorganization -> enabled )) {
2021-03-18 11:07:48 +01:00
print '<tr><td class="tdtop">' ;
print $langs -> trans ( " Usage " );
print '</td>' ;
print '<td>' ;
2021-03-20 12:18:40 +01:00
if ( ! empty ( $conf -> global -> PROJECT_USE_OPPORTUNITIES )) {
2022-07-29 17:05:02 +02:00
print '<input type="checkbox" id="usage_opportunity" name="usage_opportunity"' . ( GETPOSTISSET ( 'usage_opportunity' ) ? ( GETPOST ( 'usage_opportunity' , 'alpha' ) ? ' checked="checked"' : '' ) : ' checked="checked"' ) . '"> ' ;
2021-03-18 11:07:48 +01:00
$htmltext = $langs -> trans ( " ProjectFollowOpportunity " );
2021-03-20 12:18:40 +01:00
print '<label for="usage_opportunity">' . $form -> textwithpicto ( $langs -> trans ( " ProjectFollowOpportunity " ), $htmltext ) . '</label>' ;
2021-03-18 11:07:48 +01:00
print '<script>' ;
print ' $ ( document ) . ready ( function () {
jQuery ( " #usage_opportunity " ) . change ( function () {
if ( jQuery ( " #usage_opportunity " ) . prop ( " checked " )) {
console . log ( " Show opportunities fields " );
jQuery ( " .classuseopportunity " ) . show ();
} else {
console . log ( " Hide opportunities fields " + jQuery ( " #usage_opportunity " ) . prop ( " checked " ));
jQuery ( " .classuseopportunity " ) . hide ();
}
});
2022-07-29 17:05:02 +02:00
' ;
if ( GETPOSTISSET ( 'usage_opportunity' ) && ! GETPOST ( 'usage_opportunity' )) {
print 'jQuery(".classuseopportunity").hide();' ;
}
print '});' ;
2021-03-18 11:07:48 +01:00
print '</script>' ;
print '<br>' ;
}
2021-03-20 12:42:46 +01:00
if ( empty ( $conf -> global -> PROJECT_HIDE_TASKS )) {
2022-07-29 17:05:02 +02:00
print '<input type="checkbox" id="usage_task" name="usage_task"' . ( GETPOSTISSET ( 'usage_task' ) ? ( GETPOST ( 'usage_task' , 'alpha' ) ? ' checked="checked"' : '' ) : ' checked="checked"' ) . '"> ' ;
2021-03-18 11:07:48 +01:00
$htmltext = $langs -> trans ( " ProjectFollowTasks " );
2021-03-20 12:18:40 +01:00
print '<label for="usage_task">' . $form -> textwithpicto ( $langs -> trans ( " ProjectFollowTasks " ), $htmltext ) . '</label>' ;
2021-03-18 11:07:48 +01:00
print '<br>' ;
}
2021-03-20 12:42:46 +01:00
if ( empty ( $conf -> global -> PROJECT_HIDE_TASKS ) && ! empty ( $conf -> global -> PROJECT_BILL_TIME_SPENT )) {
2022-07-29 17:05:02 +02:00
print '<input type="checkbox" id="usage_bill_time" name="usage_bill_time"' . ( GETPOSTISSET ( 'usage_bill_time' ) ? ( GETPOST ( 'usage_bill_time' , 'alpha' ) ? ' checked="checked"' : '' ) : '' ) . '"> ' ;
2021-03-18 11:07:48 +01:00
$htmltext = $langs -> trans ( " ProjectBillTimeDescription " );
2021-03-20 12:18:40 +01:00
print '<label for="usage_bill_time">' . $form -> textwithpicto ( $langs -> trans ( " BillTime " ), $htmltext ) . '</label>' ;
2021-03-18 11:07:48 +01:00
print '<br>' ;
}
2021-03-20 12:42:46 +01:00
if ( ! empty ( $conf -> eventorganization -> enabled )) {
2022-07-29 17:05:02 +02:00
print '<input type="checkbox" id="usage_organize_event" name="usage_organize_event"' . ( GETPOSTISSET ( 'usage_organize_event' ) ? ( GETPOST ( 'usage_organize_event' , 'alpha' ) ? ' checked="checked"' : '' ) : '' ) . '"> ' ;
2021-03-20 12:42:46 +01:00
$htmltext = $langs -> trans ( " EventOrganizationDescriptionLong " );
2021-08-31 23:51:45 +02:00
print '<label for="usage_organize_event">' . $form -> textwithpicto ( $langs -> trans ( " ManageOrganizeEvent " ), $htmltext ) . '</label>' ;
2021-03-20 12:42:46 +01:00
}
2021-03-18 11:07:48 +01:00
print '</td>' ;
print '</tr>' ;
2021-02-15 12:18:08 +01:00
}
2017-10-07 13:09:31 +02:00
// Thirdparty
2022-06-09 22:49:48 +02:00
if ( isModEnabled ( 'societe' )) {
2017-10-07 13:09:31 +02:00
print '<tr><td>' ;
2019-11-13 19:35:02 +01:00
print ( empty ( $conf -> global -> PROJECT_THIRDPARTY_REQUIRED ) ? '' : '<span class="fieldrequired">' );
2017-10-07 13:09:31 +02:00
print $langs -> trans ( " ThirdParty " );
2019-11-13 19:35:02 +01:00
print ( empty ( $conf -> global -> PROJECT_THIRDPARTY_REQUIRED ) ? '' : '</span>' );
2017-10-07 13:09:31 +02:00
print '</td><td class="maxwidthonsmartphone">' ;
2019-11-13 19:35:02 +01:00
$filteronlist = '' ;
2021-02-26 18:49:22 +01:00
if ( ! empty ( $conf -> global -> PROJECT_FILTER_FOR_THIRDPARTY_LIST )) {
$filteronlist = $conf -> global -> PROJECT_FILTER_FOR_THIRDPARTY_LIST ;
}
2022-05-12 20:18:58 +02:00
$text = img_picto ( '' , 'company' ) . $form -> select_company ( GETPOST ( 'socid' , 'int' ), 'socid' , $filteronlist , 'SelectThirdParty' , 1 , 0 , array (), 0 , 'minwidth300 widthcentpercentminusxx maxwidth500' );
2021-02-26 18:49:22 +01:00
if ( empty ( $conf -> global -> PROJECT_CAN_ALWAYS_LINK_TO_ALL_SUPPLIERS ) && empty ( $conf -> dol_use_jmobile )) {
2019-11-13 19:35:02 +01:00
$texthelp = $langs -> trans ( " IfNeedToUseOtherObjectKeepEmpty " );
2019-01-27 11:55:16 +01:00
print $form -> textwithtooltip ( $text . ' ' . img_help (), $texthelp , 1 );
2021-02-26 18:49:22 +01:00
} else {
print $text ;
}
if ( ! GETPOSTISSET ( 'backtopage' )) {
2022-05-12 20:18:58 +02:00
$url = '/societe/card.php?action=create&client=3&fournisseur=0&backtopage=' . urlencode ( $_SERVER [ " PHP_SELF " ] . '?action=create' );
$newbutton = '<span class="fa fa-plus-circle valignmiddle paddingleft" title="' . $langs -> trans ( " AddThirdParty " ) . '"></span>' ;
2022-05-18 00:51:20 +02:00
// TODO @LDR Implement this
2022-05-19 21:32:17 +02:00
if ( getDolGlobalInt ( 'MAIN_FEATURES_LEVEL' ) >= 2 ) {
$tmpbacktopagejsfields = 'addthirdparty:socid,search_socid' ;
print dolButtonToOpenUrlInDialogPopup ( 'addthirdparty' , $langs -> transnoentitiesnoconv ( 'AddThirdParty' ), $newbutton , $url , '' , '' , $tmpbacktopagejsfields );
} else {
print ' <a href="' . DOL_URL_ROOT . $url . '">' . $newbutton . '</a>' ;
}
2021-02-26 18:49:22 +01:00
}
2017-10-07 13:09:31 +02:00
print '</td></tr>' ;
}
// Status
2021-02-26 18:49:22 +01:00
if ( $status != '' ) {
2017-10-07 13:09:31 +02:00
print '<tr><td>' . $langs -> trans ( " Status " ) . '</td><td>' ;
print '<input type="hidden" name="status" value="' . $status . '">' ;
print $object -> LibStatut ( $status , 4 );
print '</td></tr>' ;
}
// Visibility
print '<tr><td>' . $langs -> trans ( " Visibility " ) . '</td><td class="maxwidthonsmartphone">' ;
2019-11-13 19:35:02 +01:00
$array = array ();
2021-02-26 18:49:22 +01:00
if ( empty ( $conf -> global -> PROJECT_DISABLE_PRIVATE_PROJECT )) {
$array [ 0 ] = $langs -> trans ( " PrivateProject " );
}
if ( empty ( $conf -> global -> PROJECT_DISABLE_PUBLIC_PROJECT )) {
$array [ 1 ] = $langs -> trans ( " SharedProject " );
}
2021-04-13 10:23:05 +02:00
2021-04-13 15:38:51 +02:00
if ( count ( $array ) > 0 ) {
2022-03-15 19:15:02 +01:00
print $form -> selectarray ( 'public' , $array , GETPOST ( 'public' ), 0 , 0 , 0 , '' , 0 , 0 , 0 , '' , '' , 1 );
2021-04-13 15:38:51 +02:00
} else {
2022-03-15 19:15:02 +01:00
print '<input type="hidden" name="public" id="public" value="' . GETPOST ( 'public' ) . '">' ;
2021-04-13 10:23:05 +02:00
2022-03-15 19:15:02 +01:00
if ( GETPOST ( 'public' ) == 0 ) {
2022-05-16 18:00:59 +02:00
print img_picto ( $langs -> trans ( 'PrivateProject' ), 'private' , 'class="paddingrightonly"' );
2021-04-13 15:38:51 +02:00
print $langs -> trans ( " PrivateProject " );
2021-04-13 20:00:36 +02:00
} else {
2022-05-16 18:00:59 +02:00
print img_picto ( $langs -> trans ( 'SharedProject' ), 'world' , 'class="paddingrightonly"' );
2021-04-13 15:38:51 +02:00
print $langs -> trans ( " SharedProject " );
}
2021-04-13 10:23:05 +02:00
}
2017-10-07 13:09:31 +02:00
print '</td></tr>' ;
// Date start
print '<tr><td>' . $langs -> trans ( " DateStart " ) . '</td><td>' ;
2019-11-13 19:35:02 +01:00
print $form -> selectDate (( $date_start ? $date_start : '' ), 'projectstart' , 0 , 0 , 0 , '' , 1 , 0 );
2017-10-07 13:09:31 +02:00
print '</td></tr>' ;
// Date end
print '<tr><td>' . $langs -> trans ( " DateEnd " ) . '</td><td>' ;
2019-11-13 19:35:02 +01:00
print $form -> selectDate (( $date_end ? $date_end : - 1 ), 'projectend' , 0 , 0 , 0 , '' , 1 , 0 );
2017-10-07 13:09:31 +02:00
print '</td></tr>' ;
2021-02-26 18:49:22 +01:00
if ( ! empty ( $conf -> global -> PROJECT_USE_OPPORTUNITIES )) {
2017-10-07 13:09:31 +02:00
// Opportunity status
2020-05-15 15:50:50 +02:00
print '<tr class="classuseopportunity"><td>' . $langs -> trans ( " OpportunityStatus " ) . '</td>' ;
2017-10-07 13:09:31 +02:00
print '<td class="maxwidthonsmartphone">' ;
2022-01-01 18:15:22 +01:00
print $formproject -> selectOpportunityStatus ( 'opp_status' , GETPOSTISSET ( 'opp_status' ) ? GETPOST ( 'opp_status' ) : $object -> opp_status , 1 , 0 , 0 , 0 , '' , 0 , 1 );
2017-10-07 13:09:31 +02:00
print '</tr>' ;
// Opportunity probability
2020-05-15 15:50:50 +02:00
print '<tr class="classuseopportunity"><td>' . $langs -> trans ( " OpportunityProbability " ) . '</td>' ;
2020-05-15 15:00:58 +02:00
print '<td><input size="5" type="text" id="opp_percent" name="opp_percent" value="' . dol_escape_htmltag ( GETPOSTISSET ( 'opp_percent' ) ? GETPOST ( 'opp_percent' ) : '' ) . '"><span class="hideonsmartphone"> %</span>' ;
print '<input type="hidden" name="opp_percent_not_set" id="opp_percent_not_set" value="' . dol_escape_htmltag ( GETPOSTISSET ( 'opp_percent' ) ? '0' : '1' ) . '">' ;
2017-10-07 13:09:31 +02:00
print '</td>' ;
print '</tr>' ;
// Opportunity amount
2020-05-15 15:50:50 +02:00
print '<tr class="classuseopportunity"><td>' . $langs -> trans ( " OpportunityAmount " ) . '</td>' ;
2020-05-15 15:00:58 +02:00
print '<td><input size="5" type="text" name="opp_amount" value="' . dol_escape_htmltag ( GETPOSTISSET ( 'opp_amount' ) ? GETPOST ( 'opp_amount' ) : '' ) . '"></td>' ;
2017-10-07 13:09:31 +02:00
print '</tr>' ;
}
2015-06-29 16:57:32 +02:00
2015-06-30 01:53:01 +02:00
// Budget
print '<tr><td>' . $langs -> trans ( " Budget " ) . '</td>' ;
2020-05-15 15:00:58 +02:00
print '<td><input size="5" type="text" name="budget_amount" value="' . dol_escape_htmltag ( GETPOSTISSET ( 'budget_amount' ) ? GETPOST ( 'budget_amount' ) : '' ) . '"></td>' ;
2015-06-30 01:53:01 +02:00
print '</tr>' ;
2015-02-16 10:58:05 +01:00
2017-10-07 13:09:31 +02:00
// Description
print '<tr><td class="tdtop">' . $langs -> trans ( " Description " ) . '</td>' ;
print '<td>' ;
2021-09-02 18:48:46 +02:00
$doleditor = new DolEditor ( 'description' , GETPOST ( " description " , 'restricthtml' ), '' , 90 , 'dolibarr_notes' , '' , false , true , getDolGlobalString ( 'FCKEDITOR_ENABLE_SOCIETE' ), ROWS_3 , '90%' );
2019-11-20 06:38:28 +01:00
$doleditor -> Create ();
2017-10-07 13:09:31 +02:00
print '</td></tr>' ;
2018-12-21 12:07:13 +01:00
2021-09-02 18:48:46 +02:00
if ( ! empty ( $conf -> categorie -> enabled )) {
2017-10-07 13:09:31 +02:00
// Categories
print '<tr><td>' . $langs -> trans ( " Categories " ) . '</td><td colspan="3">' ;
$cate_arbo = $form -> select_all_categories ( Categorie :: TYPE_PROJECT , '' , 'parent' , 64 , 0 , 1 );
2019-11-13 19:35:02 +01:00
$arrayselected = GETPOST ( 'categories' , 'array' );
2020-05-15 16:29:18 +02:00
print img_picto ( '' , 'category' ) . $form -> multiselectarray ( 'categories' , $cate_arbo , $arrayselected , '' , 0 , 'quatrevingtpercent widthcentpercentminusx' , 0 , 0 );
2017-10-07 13:09:31 +02:00
print " </td></tr> " ;
}
// Other options
2019-11-13 19:35:02 +01:00
$parameters = array ();
$reshook = $hookmanager -> executeHooks ( 'formObjectOptions' , $parameters , $object , $action ); // Note that $action and $object may have been modified by hook
2017-10-07 13:09:31 +02:00
print $hookmanager -> resPrint ;
2021-02-26 18:49:22 +01:00
if ( empty ( $reshook )) {
2020-12-02 19:13:32 +01:00
print $object -> showOptionals ( $extrafields , 'create' );
2017-10-07 13:09:31 +02:00
}
print '</table>' ;
2020-10-27 18:19:31 +01:00
print dol_get_fiche_end ();
2017-10-07 13:09:31 +02:00
2021-08-20 14:41:30 +02:00
print $form -> buttonsSaveCancel ( 'CreateDraft' );
2017-10-07 13:09:31 +02:00
print '</form>' ;
2022-07-29 17:05:02 +02:00
// Change probability from status or role of project
2021-11-29 15:09:18 +01:00
print ' < script type = " text/javascript " >
2016-01-28 20:04:02 +01:00
jQuery ( document ) . ready ( function () {
function change_percent ()
{
2016-08-29 10:32:00 +02:00
var element = jQuery ( " #opp_status option:selected " );
2016-01-28 20:04:02 +01:00
var defaultpercent = element . attr ( " defaultpercent " );
/*if (jQuery("#opp_percent_not_set").val() == "") */
jQuery ( " #opp_percent " ) . val ( defaultpercent );
}
2022-07-29 17:05:02 +02:00
/*init_myfunc();*/
2016-01-28 20:04:02 +01:00
jQuery ( " #opp_status " ) . change ( function () {
change_percent ();
});
2019-12-06 08:50:26 +01:00
jQuery ( " #usage_task " ) . change ( function () {
console . log ( " We click on usage task " + jQuery ( " #usage_task " ) . is ( " :checked " ));
if ( ! jQuery ( " #usage_task " ) . is ( " :checked " )) {
jQuery ( " #usage_bill_time " ) . prop ( " checked " , false );
}
});
jQuery ( " #usage_bill_time " ) . change ( function () {
console . log ( " We click on usage to bill time " );
if ( jQuery ( " #usage_bill_time " ) . is ( " :checked " )) {
jQuery ( " #usage_task " ) . prop ( " checked " , true );
}
});
2016-01-28 20:04:02 +01:00
});
</ script > ' ;
2021-02-26 18:49:22 +01:00
} elseif ( $object -> id > 0 ) {
2017-10-07 13:09:31 +02:00
/*
2021-02-26 18:49:22 +01:00
* Show or edit
*/
2017-06-02 12:27:46 +02:00
2019-11-13 19:35:02 +01:00
$res = $object -> fetch_optionals ();
2017-10-07 13:09:31 +02:00
// To verify role of users
2019-01-27 11:55:16 +01:00
$userAccess = $object -> restrictedProjectArea ( $user , 'read' );
$userWrite = $object -> restrictedProjectArea ( $user , 'write' );
$userDelete = $object -> restrictedProjectArea ( $user , 'delete' );
2017-10-07 13:09:31 +02:00
//print "userAccess=".$userAccess." userWrite=".$userWrite." userDelete=".$userDelete;
// Confirmation validation
2021-02-26 18:49:22 +01:00
if ( $action == 'validate' ) {
2019-01-27 11:55:16 +01:00
print $form -> formconfirm ( $_SERVER [ " PHP_SELF " ] . '?id=' . $object -> id , $langs -> trans ( 'ValidateProject' ), $langs -> trans ( 'ConfirmValidateProject' ), 'confirm_validate' , '' , 0 , 1 );
2017-10-07 13:09:31 +02:00
}
// Confirmation close
2021-02-26 18:49:22 +01:00
if ( $action == 'close' ) {
2019-01-27 11:55:16 +01:00
print $form -> formconfirm ( $_SERVER [ " PHP_SELF " ] . " ?id= " . $object -> id , $langs -> trans ( " CloseAProject " ), $langs -> trans ( " ConfirmCloseAProject " ), " confirm_close " , '' , '' , 1 );
2017-10-07 13:09:31 +02:00
}
// Confirmation reopen
2021-02-26 18:49:22 +01:00
if ( $action == 'reopen' ) {
2019-01-27 11:55:16 +01:00
print $form -> formconfirm ( $_SERVER [ " PHP_SELF " ] . " ?id= " . $object -> id , $langs -> trans ( " ReOpenAProject " ), $langs -> trans ( " ConfirmReOpenAProject " ), " confirm_reopen " , '' , '' , 1 );
2017-10-07 13:09:31 +02:00
}
// Confirmation delete
2021-02-26 18:49:22 +01:00
if ( $action == 'delete' ) {
2019-11-13 19:35:02 +01:00
$text = $langs -> trans ( " ConfirmDeleteAProject " );
$task = new Task ( $db );
$taskarray = $task -> getTasksArray ( 0 , 0 , $object -> id , 0 , 0 );
$nboftask = count ( $taskarray );
2021-02-26 18:49:22 +01:00
if ( $nboftask ) {
$text .= '<br>' . img_warning () . ' ' . $langs -> trans ( " ThisWillAlsoRemoveTasks " , $nboftask );
}
2019-01-27 11:55:16 +01:00
print $form -> formconfirm ( $_SERVER [ " PHP_SELF " ] . " ?id= " . $object -> id , $langs -> trans ( " DeleteAProject " ), $text , " confirm_delete " , '' , '' , 1 );
2017-10-07 13:09:31 +02:00
}
// Clone confirmation
2021-02-26 18:49:22 +01:00
if ( $action == 'clone' ) {
2019-11-13 19:35:02 +01:00
$formquestion = array (
2017-10-07 13:09:31 +02:00
'text' => $langs -> trans ( " ConfirmClone " ),
2022-07-07 21:42:32 +02:00
array ( 'type' => 'other' , 'name' => 'socid' , 'label' => $langs -> trans ( " SelectThirdParty " ), 'value' => $form -> select_company ( GETPOST ( 'socid' , 'int' ) > 0 ? GETPOST ( 'socid' , 'int' ) : $object -> socid , 'socid' , '' , " None " , 0 , 0 , null , 0 , 'minwidth200 maxwidth250' )),
2019-11-13 19:35:02 +01:00
array ( 'type' => 'checkbox' , 'name' => 'clone_contacts' , 'label' => $langs -> trans ( " CloneContacts " ), 'value' => true ),
array ( 'type' => 'checkbox' , 'name' => 'clone_tasks' , 'label' => $langs -> trans ( " CloneTasks " ), 'value' => true ),
array ( 'type' => 'checkbox' , 'name' => 'move_date' , 'label' => $langs -> trans ( " CloneMoveDate " ), 'value' => true ),
array ( 'type' => 'checkbox' , 'name' => 'clone_notes' , 'label' => $langs -> trans ( " CloneNotes " ), 'value' => true ),
array ( 'type' => 'checkbox' , 'name' => 'clone_project_files' , 'label' => $langs -> trans ( " CloneProjectFiles " ), 'value' => false ),
array ( 'type' => 'checkbox' , 'name' => 'clone_task_files' , 'label' => $langs -> trans ( " CloneTaskFiles " ), 'value' => false )
2017-10-07 13:09:31 +02:00
);
2022-07-07 21:42:32 +02:00
print $form -> formconfirm ( $_SERVER [ " PHP_SELF " ] . " ?id= " . $object -> id , $langs -> trans ( " ToClone " ), $langs -> trans ( " ConfirmCloneProject " ), " confirm_clone " , $formquestion , '' , 1 , 400 , 590 );
2017-10-07 13:09:31 +02:00
}
print '<form action="' . $_SERVER [ " PHP_SELF " ] . '" method="POST">' ;
2019-12-18 23:12:31 +01:00
print '<input type="hidden" name="token" value="' . newToken () . '">' ;
2017-10-07 13:09:31 +02:00
print '<input type="hidden" name="action" value="update">' ;
print '<input type="hidden" name="id" value="' . $object -> id . '">' ;
print '<input type="hidden" name="comefromclone" value="' . $comefromclone . '">' ;
2019-11-13 19:35:02 +01:00
$head = project_prepare_head ( $object );
2017-10-07 13:09:31 +02:00
2021-02-26 18:49:22 +01:00
if ( $action == 'edit' && $userWrite > 0 ) {
2020-10-22 22:50:03 +02:00
print dol_get_fiche_head ( $head , 'project' , $langs -> trans ( " Project " ), 0 , ( $object -> public ? 'projectpub' : 'project' ));
2017-10-07 13:09:31 +02:00
2019-11-05 21:24:41 +01:00
print '<table class="border centpercent">' ;
2017-10-07 13:09:31 +02:00
// Ref
2019-11-13 19:35:02 +01:00
$suggestedref = $object -> ref ;
2017-10-07 13:09:31 +02:00
print '<tr><td class="titlefield fieldrequired">' . $langs -> trans ( " Ref " ) . '</td>' ;
2021-07-28 11:01:38 +02:00
print '<td><input size="25" name="ref" value="' . $suggestedref . '">' ;
2017-10-07 13:09:31 +02:00
print ' ' . $form -> textwithpicto ( '' , $langs -> trans ( " YouCanCompleteRef " , $suggestedref ));
print '</td></tr>' ;
// Label
2020-11-24 21:12:44 +01:00
print '<tr><td class="fieldrequired">' . $langs -> trans ( " ProjectLabel " ) . '</td>' ;
2018-10-15 11:04:29 +02:00
print '<td><input class="quatrevingtpercent" name="title" value="' . dol_escape_htmltag ( $object -> title ) . '"></td></tr>' ;
2017-10-07 13:09:31 +02:00
2018-02-01 17:50:19 +01:00
// Status
print '<tr><td class="fieldrequired">' . $langs -> trans ( " Status " ) . '</td><td>' ;
print '<select class="flat" name="status">' ;
2021-02-26 18:49:22 +01:00
foreach ( $object -> statuts_short as $key => $val ) {
2019-11-13 19:35:02 +01:00
print '<option value="' . $key . '"' . (( GETPOSTISSET ( 'status' ) ? GETPOST ( 'status' ) : $object -> statut ) == $key ? ' selected="selected"' : '' ) . '>' . $langs -> trans ( $val ) . '</option>' ;
2018-02-01 17:50:19 +01:00
}
print '</select>' ;
print '</td></tr>' ;
2019-09-01 01:40:51 +02:00
// Usage
2021-03-20 12:42:46 +01:00
if ( ! empty ( $conf -> global -> PROJECT_USE_OPPORTUNITIES ) || empty ( $conf -> global -> PROJECT_HIDE_TASKS ) || ! empty ( $conf -> eventorganization -> enabled )) {
2021-03-18 11:07:48 +01:00
print '<tr><td class="tdtop">' ;
print $langs -> trans ( " Usage " );
print '</td>' ;
print '<td>' ;
2021-03-20 12:42:46 +01:00
if ( ! empty ( $conf -> global -> PROJECT_USE_OPPORTUNITIES )) {
print '<input type="checkbox" id="usage_opportunity" name="usage_opportunity"' . ( GETPOSTISSET ( 'usage_opportunity' ) ? ( GETPOST ( 'usage_opportunity' , 'alpha' ) != '' ? ' checked="checked"' : '' ) : ( $object -> usage_opportunity ? ' checked="checked"' : '' )) . '"> ' ;
2021-03-18 11:07:48 +01:00
$htmltext = $langs -> trans ( " ProjectFollowOpportunity " );
2021-08-31 23:51:45 +02:00
print '<label for="usage_opportunity">' . $form -> textwithpicto ( $langs -> trans ( " ProjectFollowOpportunity " ), $htmltext ) . '</label>' ;
2021-03-18 11:07:48 +01:00
print '<script>' ;
print ' $ ( document ) . ready ( function () {
2020-05-15 15:15:07 +02:00
jQuery ( " #usage_opportunity " ) . change ( function () {
2021-03-20 12:42:46 +01:00
if ( jQuery ( " #usage_opportunity " ) . prop ( " checked " )) {
console . log ( " Show opportunities fields " );
jQuery ( " .classuseopportunity " ) . show ();
} else {
console . log ( " Hide opportunities fields " + jQuery ( " #usage_opportunity " ) . prop ( " checked " ));
jQuery ( " .classuseopportunity " ) . hide ();
}
});
2022-07-29 17:05:02 +02:00
' ;
print '
2021-03-20 12:42:46 +01:00
}); ' ;
2021-03-18 11:07:48 +01:00
print '</script>' ;
print '<br>' ;
}
2021-03-20 12:42:46 +01:00
if ( empty ( $conf -> global -> PROJECT_HIDE_TASKS )) {
2021-08-31 23:51:45 +02:00
print '<input type="checkbox" id="usage_task" name="usage_task"' . ( GETPOSTISSET ( 'usage_task' ) ? ( GETPOST ( 'usage_task' , 'alpha' ) != '' ? ' checked="checked"' : '' ) : ( $object -> usage_task ? ' checked="checked"' : '' )) . '"> ' ;
2021-03-18 11:07:48 +01:00
$htmltext = $langs -> trans ( " ProjectFollowTasks " );
2021-08-31 23:51:45 +02:00
print '<label for="usage_task">' . $form -> textwithpicto ( $langs -> trans ( " ProjectFollowTasks " ), $htmltext ) . '</label>' ;
2021-03-18 11:07:48 +01:00
print '<br>' ;
}
2021-03-20 12:42:46 +01:00
if ( empty ( $conf -> global -> PROJECT_HIDE_TASKS ) && ! empty ( $conf -> global -> PROJECT_BILL_TIME_SPENT )) {
2021-08-31 23:51:45 +02:00
print '<input type="checkbox" id="usage_bill_time" name="usage_bill_time"' . ( GETPOSTISSET ( 'usage_bill_time' ) ? ( GETPOST ( 'usage_bill_time' , 'alpha' ) != '' ? ' checked="checked"' : '' ) : ( $object -> usage_bill_time ? ' checked="checked"' : '' )) . '"> ' ;
2021-03-18 11:07:48 +01:00
$htmltext = $langs -> trans ( " ProjectBillTimeDescription " );
2021-08-31 23:51:45 +02:00
print '<label for="usage_bill_time">' . $form -> textwithpicto ( $langs -> trans ( " BillTime " ), $htmltext ) . '</label>' ;
2021-03-18 11:07:48 +01:00
print '<br>' ;
}
2021-03-20 12:42:46 +01:00
if ( ! empty ( $conf -> eventorganization -> enabled )) {
2021-08-31 23:51:45 +02:00
print '<input type="checkbox" id="usage_organize_event" name="usage_organize_event"' . ( GETPOSTISSET ( 'usage_organize_event' ) ? ( GETPOST ( 'usage_organize_event' , 'alpha' ) != '' ? ' checked="checked"' : '' ) : ( $object -> usage_organize_event ? ' checked="checked"' : '' )) . '"> ' ;
2021-03-20 12:42:46 +01:00
$htmltext = $langs -> trans ( " EventOrganizationDescriptionLong " );
2021-08-31 23:51:45 +02:00
print '<label for="usage_organize_event">' . $form -> textwithpicto ( $langs -> trans ( " ManageOrganizeEvent " ), $htmltext ) . '</label>' ;
2021-03-20 12:42:46 +01:00
}
2021-03-18 11:07:48 +01:00
print '</td></tr>' ;
2021-02-15 12:18:08 +01:00
}
2019-09-01 01:40:51 +02:00
print '</td></tr>' ;
2017-10-07 13:09:31 +02:00
// Thirdparty
2022-06-09 22:49:48 +02:00
if ( isModEnabled ( 'societe' )) {
2017-10-07 13:09:31 +02:00
print '<tr><td>' ;
2019-11-13 19:35:02 +01:00
print ( empty ( $conf -> global -> PROJECT_THIRDPARTY_REQUIRED ) ? '' : '<span class="fieldrequired">' );
2017-10-07 13:09:31 +02:00
print $langs -> trans ( " ThirdParty " );
2019-11-13 19:35:02 +01:00
print ( empty ( $conf -> global -> PROJECT_THIRDPARTY_REQUIRED ) ? '' : '</span>' );
2017-10-07 13:09:31 +02:00
print '</td><td>' ;
2019-11-13 19:35:02 +01:00
$filteronlist = '' ;
2021-02-26 18:49:22 +01:00
if ( ! empty ( $conf -> global -> PROJECT_FILTER_FOR_THIRDPARTY_LIST )) {
$filteronlist = $conf -> global -> PROJECT_FILTER_FOR_THIRDPARTY_LIST ;
}
2019-11-13 19:35:02 +01:00
$text = $form -> select_company ( $object -> thirdparty -> id , 'socid' , $filteronlist , 'None' , 1 , 0 , array (), 0 , 'minwidth300' );
2021-02-26 18:49:22 +01:00
if ( empty ( $conf -> global -> PROJECT_CAN_ALWAYS_LINK_TO_ALL_SUPPLIERS ) && empty ( $conf -> dol_use_jmobile )) {
2019-11-13 19:35:02 +01:00
$texthelp = $langs -> trans ( " IfNeedToUseOtherObjectKeepEmpty " );
2017-10-07 13:09:31 +02:00
print $form -> textwithtooltip ( $text . ' ' . img_help (), $texthelp , 1 , 0 , '' , '' , 2 );
2021-02-26 18:49:22 +01:00
} else {
print $text ;
}
2017-10-07 13:09:31 +02:00
print '</td></tr>' ;
}
// Visibility
print '<tr><td>' . $langs -> trans ( " Visibility " ) . '</td><td>' ;
2019-11-13 19:35:02 +01:00
$array = array ();
2021-02-26 18:49:22 +01:00
if ( empty ( $conf -> global -> PROJECT_DISABLE_PRIVATE_PROJECT )) {
$array [ 0 ] = $langs -> trans ( " PrivateProject " );
}
if ( empty ( $conf -> global -> PROJECT_DISABLE_PUBLIC_PROJECT )) {
$array [ 1 ] = $langs -> trans ( " SharedProject " );
}
2021-04-13 10:23:05 +02:00
2021-04-13 15:39:34 +02:00
if ( count ( $array ) > 0 ) {
2021-04-13 10:23:05 +02:00
print $form -> selectarray ( 'public' , $array , $object -> public , 0 , 0 , 0 , '' , 0 , 0 , 0 , '' , '' , 1 );
2021-04-13 15:39:34 +02:00
} else {
2021-04-13 10:23:05 +02:00
print '<input type="hidden" id="public" name="public" value="' . $object -> public . '">' ;
2021-04-13 15:39:34 +02:00
if ( $object -> public == 0 ) {
2022-05-16 18:00:59 +02:00
print img_picto ( $langs -> trans ( 'PrivateProject' ), 'private' , 'class="paddingrightonly"' );
2021-04-13 15:39:34 +02:00
print $langs -> trans ( " PrivateProject " );
2021-04-13 20:00:36 +02:00
} else {
2022-05-16 18:00:59 +02:00
print img_picto ( $langs -> trans ( 'SharedProject' ), 'world' , 'class="paddingrightonly"' );
2021-04-13 15:39:34 +02:00
print $langs -> trans ( " SharedProject " );
}
2021-04-13 10:23:05 +02:00
}
2017-10-07 13:09:31 +02:00
print '</td></tr>' ;
2021-02-26 18:49:22 +01:00
if ( ! empty ( $conf -> global -> PROJECT_USE_OPPORTUNITIES )) {
2020-05-15 15:15:07 +02:00
$classfortr = ( $object -> usage_opportunity ? '' : ' hideobject' );
2017-10-07 13:09:31 +02:00
// Opportunity status
2020-05-15 15:15:07 +02:00
print '<tr class="classuseopportunity' . $classfortr . '"><td>' . $langs -> trans ( " OpportunityStatus " ) . '</td>' ;
2017-10-07 13:09:31 +02:00
print '<td>' ;
2020-12-11 01:20:40 +01:00
print $formproject -> selectOpportunityStatus ( 'opp_status' , $object -> opp_status , 1 , 0 , 0 , 0 , 'inline-block valignmiddle' , 0 , 1 );
2017-10-07 13:09:31 +02:00
print '<div id="divtocloseproject" class="inline-block valign" style="display: none;"> ' ;
2021-10-06 14:26:48 +02:00
print '<input type="checkbox" id="inputcloseproject" name="closeproject" />' ;
print '<label for="inputcloseproject">' . $langs -> trans ( " AlsoCloseAProject " ) . '</label>' ;
2017-10-07 13:09:31 +02:00
print '</div>' ;
print '</td>' ;
print '</tr>' ;
2020-10-31 14:32:18 +01:00
// Opportunity probability
print '<tr class="classuseopportunity' . $classfortr . '"><td>' . $langs -> trans ( " OpportunityProbability " ) . '</td>' ;
print '<td><input size="5" type="text" id="opp_percent" name="opp_percent" value="' . ( GETPOSTISSET ( 'opp_percent' ) ? GETPOST ( 'opp_percent' ) : ( strcmp ( $object -> opp_percent , '' ) ? vatrate ( $object -> opp_percent ) : '' )) . '"> %' ;
print '<span id="oldopppercent"></span>' ;
print '</td>' ;
print '</tr>' ;
2016-08-29 10:32:00 +02:00
2020-10-31 14:32:18 +01:00
// Opportunity amount
print '<tr class="classuseopportunity' . $classfortr . '"><td>' . $langs -> trans ( " OpportunityAmount " ) . '</td>' ;
2022-05-16 19:19:52 +02:00
print '<td><input size="5" type="text" name="opp_amount" value="' . ( GETPOSTISSET ( 'opp_amount' ) ? GETPOST ( 'opp_amount' ) : ( strcmp ( $object -> opp_amount , '' ) ? price2num ( $object -> opp_amount ) : '' )) . '">' ;
print $langs -> getCurrencySymbol ( $conf -> currency );
print '</td>' ;
2020-10-31 14:32:18 +01:00
print '</tr>' ;
}
2017-10-07 13:09:31 +02:00
// Date start
print '<tr><td>' . $langs -> trans ( " DateStart " ) . '</td><td>' ;
2019-11-13 19:35:02 +01:00
print $form -> selectDate ( $object -> date_start ? $object -> date_start : - 1 , 'projectstart' , 0 , 0 , 0 , '' , 1 , 0 );
2021-10-06 14:26:48 +02:00
print ' <input type="checkbox" class="valignmiddle" id="reportdate" name="reportdate" value="yes" ' ;
2021-02-26 18:49:22 +01:00
if ( $comefromclone ) {
print ' checked ' ;
}
2022-05-16 19:19:52 +02:00
print '/><label for="reportdate" class="opacitymedium">' . $langs -> trans ( " ProjectReportDate " ) . '</label>' ;
2017-10-07 13:09:31 +02:00
print '</td></tr>' ;
// Date end
print '<tr><td>' . $langs -> trans ( " DateEnd " ) . '</td><td>' ;
2019-11-13 19:35:02 +01:00
print $form -> selectDate ( $object -> date_end ? $object -> date_end : - 1 , 'projectend' , 0 , 0 , 0 , '' , 1 , 0 );
2017-10-07 13:09:31 +02:00
print '</td></tr>' ;
// Budget
print '<tr><td>' . $langs -> trans ( " Budget " ) . '</td>' ;
2022-05-16 19:19:52 +02:00
print '<td><input size="5" type="text" name="budget_amount" value="' . ( GETPOSTISSET ( 'budget_amount' ) ? GETPOST ( 'budget_amount' ) : ( strcmp ( $object -> budget_amount , '' ) ? price2num ( $object -> budget_amount ) : '' )) . '">' ;
print $langs -> getCurrencySymbol ( $conf -> currency );
print '</td>' ;
2017-10-07 13:09:31 +02:00
print '</tr>' ;
// Description
print '<tr><td class="tdtop">' . $langs -> trans ( " Description " ) . '</td>' ;
print '<td>' ;
2022-06-22 08:36:24 +02:00
$doleditor = new DolEditor ( 'description' , $object -> description , '' , 90 , 'dolibarr_notes' , '' , false , true , getDolGlobalInt ( 'FCKEDITOR_ENABLE_SOCIETE' ), ROWS_3 , '90%' );
2019-11-20 06:38:28 +01:00
$doleditor -> Create ();
2017-10-07 13:09:31 +02:00
print '</td></tr>' ;
// Tags-Categories
2022-06-09 22:41:59 +02:00
if ( isModEnabled ( 'categorie' )) {
2020-05-15 16:29:18 +02:00
print '<tr><td>' . $langs -> trans ( " Categories " ) . '</td><td>' ;
2017-10-07 13:09:31 +02:00
$cate_arbo = $form -> select_all_categories ( Categorie :: TYPE_PROJECT , '' , 'parent' , 64 , 0 , 1 );
$c = new Categorie ( $db );
2019-01-27 11:55:16 +01:00
$cats = $c -> containing ( $object -> id , Categorie :: TYPE_PROJECT );
2019-11-13 19:35:02 +01:00
foreach ( $cats as $cat ) {
2017-10-07 13:09:31 +02:00
$arrayselected [] = $cat -> id ;
}
2020-05-15 16:29:18 +02:00
print img_picto ( '' , 'category' ) . $form -> multiselectarray ( 'categories' , $cate_arbo , $arrayselected , 0 , 0 , 'quatrevingtpercent widthcentpercentminusx' , 0 , '0' );
2017-10-07 13:09:31 +02:00
print " </td></tr> " ;
}
// Other options
2019-11-13 19:35:02 +01:00
$parameters = array ();
$reshook = $hookmanager -> executeHooks ( 'formObjectOptions' , $parameters , $object , $action ); // Note that $action and $object may have been modified by hook
2017-10-07 13:09:31 +02:00
print $hookmanager -> resPrint ;
2021-02-26 18:49:22 +01:00
if ( empty ( $reshook )) {
2019-01-27 11:55:16 +01:00
print $object -> showOptionals ( $extrafields , 'edit' );
2017-10-07 13:09:31 +02:00
}
print '</table>' ;
2020-05-21 15:05:19 +02:00
} else {
2020-10-22 22:50:03 +02:00
print dol_get_fiche_head ( $head , 'project' , $langs -> trans ( " Project " ), - 1 , ( $object -> public ? 'projectpub' : 'project' ));
2017-10-07 13:09:31 +02:00
// Project card
$linkback = '<a href="' . DOL_URL_ROOT . '/projet/list.php?restore_lastsearch_values=1">' . $langs -> trans ( " BackToList " ) . '</a>' ;
2019-11-13 19:35:02 +01:00
$morehtmlref = '<div class="refidno">' ;
2017-10-07 13:09:31 +02:00
// Title
2020-09-18 01:39:32 +02:00
$morehtmlref .= dol_escape_htmltag ( $object -> title );
2017-10-07 13:09:31 +02:00
// Thirdparty
2019-11-13 19:35:02 +01:00
$morehtmlref .= '<br>' . $langs -> trans ( 'ThirdParty' ) . ' : ' ;
2021-10-24 09:59:30 +02:00
if ( ! empty ( $object -> thirdparty -> id ) && $object -> thirdparty -> id > 0 ) {
2017-10-07 13:09:31 +02:00
$morehtmlref .= $object -> thirdparty -> getNomUrl ( 1 , 'project' );
}
2019-11-13 19:35:02 +01:00
$morehtmlref .= '</div>' ;
2017-10-07 13:09:31 +02:00
// Define a complementary filter for search of next/prev ref.
2021-10-24 09:59:30 +02:00
if ( empty ( $user -> rights -> projet -> all -> lire )) {
2019-01-27 11:55:16 +01:00
$objectsListId = $object -> getProjectsAuthorizedForUser ( $user , 0 , 0 );
2021-03-22 12:47:23 +01:00
$object -> next_prev_filter = " rowid IN ( " . $db -> sanitize ( count ( $objectsListId ) ? join ( ',' , array_keys ( $objectsListId )) : '0' ) . " ) " ;
2017-10-07 13:09:31 +02:00
}
dol_banner_tab ( $object , 'ref' , $linkback , 1 , 'ref' , 'ref' , $morehtmlref );
print '<div class="fichecenter">' ;
print '<div class="fichehalfleft">' ;
print '<div class="underbanner clearboth"></div>' ;
2019-01-17 19:27:26 +01:00
print '<table class="border tableforfield" width="100%">' ;
2017-10-07 13:09:31 +02:00
2019-09-01 01:40:51 +02:00
// Usage
2021-03-20 12:42:46 +01:00
if ( ! empty ( $conf -> global -> PROJECT_USE_OPPORTUNITIES ) || empty ( $conf -> global -> PROJECT_HIDE_TASKS ) || ! empty ( $conf -> eventorganization -> enabled )) {
2021-03-18 11:07:48 +01:00
print '<tr><td class="tdtop">' ;
print $langs -> trans ( " Usage " );
print '</td>' ;
print '<td>' ;
2021-03-20 12:42:46 +01:00
if ( ! empty ( $conf -> global -> PROJECT_USE_OPPORTUNITIES )) {
print '<input type="checkbox" disabled name="usage_opportunity"' . ( GETPOSTISSET ( 'usage_opportunity' ) ? ( GETPOST ( 'usage_opportunity' , 'alpha' ) != '' ? ' checked="checked"' : '' ) : ( $object -> usage_opportunity ? ' checked="checked"' : '' )) . '"> ' ;
2021-03-18 11:07:48 +01:00
$htmltext = $langs -> trans ( " ProjectFollowOpportunity " );
print $form -> textwithpicto ( $langs -> trans ( " ProjectFollowOpportunity " ), $htmltext );
print '<br>' ;
}
2021-03-20 12:42:46 +01:00
if ( empty ( $conf -> global -> PROJECT_HIDE_TASKS )) {
print '<input type="checkbox" disabled name="usage_task"' . ( GETPOSTISSET ( 'usage_task' ) ? ( GETPOST ( 'usage_task' , 'alpha' ) != '' ? ' checked="checked"' : '' ) : ( $object -> usage_task ? ' checked="checked"' : '' )) . '"> ' ;
2021-03-18 11:07:48 +01:00
$htmltext = $langs -> trans ( " ProjectFollowTasks " );
print $form -> textwithpicto ( $langs -> trans ( " ProjectFollowTasks " ), $htmltext );
print '<br>' ;
}
2021-03-20 12:42:46 +01:00
if ( empty ( $conf -> global -> PROJECT_HIDE_TASKS ) && ! empty ( $conf -> global -> PROJECT_BILL_TIME_SPENT )) {
print '<input type="checkbox" disabled name="usage_bill_time"' . ( GETPOSTISSET ( 'usage_bill_time' ) ? ( GETPOST ( 'usage_bill_time' , 'alpha' ) != '' ? ' checked="checked"' : '' ) : ( $object -> usage_bill_time ? ' checked="checked"' : '' )) . '"> ' ;
2021-03-18 11:07:48 +01:00
$htmltext = $langs -> trans ( " ProjectBillTimeDescription " );
print $form -> textwithpicto ( $langs -> trans ( " BillTime " ), $htmltext );
print '<br>' ;
}
2021-02-15 12:18:08 +01:00
2021-03-20 12:42:46 +01:00
if ( ! empty ( $conf -> eventorganization -> enabled )) {
print '<input type="checkbox" disabled name="usage_organize_event"' . ( GETPOSTISSET ( 'usage_organize_event' ) ? ( GETPOST ( 'usage_organize_event' , 'alpha' ) != '' ? ' checked="checked"' : '' ) : ( $object -> usage_organize_event ? ' checked="checked"' : '' )) . '"> ' ;
$htmltext = $langs -> trans ( " EventOrganizationDescriptionLong " );
print $form -> textwithpicto ( $langs -> trans ( " ManageOrganizeEvent " ), $htmltext );
}
2021-03-18 11:07:48 +01:00
print '</td></tr>' ;
2021-02-15 12:18:08 +01:00
}
2019-09-01 01:40:51 +02:00
2017-10-07 13:09:31 +02:00
// Visibility
print '<tr><td class="titlefield">' . $langs -> trans ( " Visibility " ) . '</td><td>' ;
2021-02-26 18:49:22 +01:00
if ( $object -> public ) {
2022-05-16 18:00:59 +02:00
print img_picto ( $langs -> trans ( 'SharedProject' ), 'world' , 'class="paddingrightonly"' );
2021-02-26 18:49:22 +01:00
print $langs -> trans ( 'SharedProject' );
} else {
2022-05-23 00:57:02 +02:00
print img_picto ( $langs -> trans ( 'PrivateProject' ), 'private' , 'class="paddingrightonly"' );
2021-02-26 18:49:22 +01:00
print $langs -> trans ( 'PrivateProject' );
}
2017-10-07 13:09:31 +02:00
print '</td></tr>' ;
2021-02-26 18:49:22 +01:00
if ( ! empty ( $conf -> global -> PROJECT_USE_OPPORTUNITIES ) && ! empty ( $object -> usage_opportunity )) {
2017-10-07 13:09:31 +02:00
// Opportunity status
print '<tr><td>' . $langs -> trans ( " OpportunityStatus " ) . '</td><td>' ;
$code = dol_getIdFromCode ( $db , $object -> opp_status , 'c_lead_status' , 'rowid' , 'code' );
2021-02-26 18:49:22 +01:00
if ( $code ) {
print $langs -> trans ( " OppStatus " . $code );
}
2017-10-07 13:09:31 +02:00
print '</td></tr>' ;
// Opportunity percent
print '<tr><td>' . $langs -> trans ( " OpportunityProbability " ) . '</td><td>' ;
2021-02-26 18:49:22 +01:00
if ( strcmp ( $object -> opp_percent , '' )) {
print price ( $object -> opp_percent , 0 , $langs , 1 , 0 ) . ' %' ;
}
2017-10-07 13:09:31 +02:00
print '</td></tr>' ;
// Opportunity Amount
print '<tr><td>' . $langs -> trans ( " OpportunityAmount " ) . '</td><td>' ;
2021-02-26 18:49:22 +01:00
if ( strcmp ( $object -> opp_amount , '' )) {
2022-01-01 18:15:22 +01:00
print '<span class="amount">' . price ( $object -> opp_amount , 0 , $langs , 1 , 0 , - 1 , $conf -> currency ) . '</span>' ;
2022-05-16 18:54:50 +02:00
if ( strcmp ( $object -> opp_percent , '' )) {
print ' <span title="' . dol_escape_htmltag ( $langs -> trans ( 'OpportunityWeightedAmount' )) . '"><span class="opacitymedium">' . $langs -> trans ( " Weighted " ) . '</span>: <span class="amount">' . price ( $object -> opp_amount * $object -> opp_percent / 100 , 0 , $langs , 1 , 0 , - 1 , $conf -> currency ) . '</span></span>' ;
}
2021-02-26 18:49:22 +01:00
}
2017-10-07 13:09:31 +02:00
print '</td></tr>' ;
2019-12-10 09:32:37 +01:00
2020-10-31 14:32:18 +01:00
// Opportunity Weighted Amount
2022-05-16 18:54:50 +02:00
/*
2020-10-31 14:32:18 +01:00
print '<tr><td>' . $langs -> trans ( 'OpportunityWeightedAmount' ) . '</td><td>' ;
2021-02-26 18:49:22 +01:00
if ( strcmp ( $object -> opp_amount , '' ) && strcmp ( $object -> opp_percent , '' )) {
2022-01-01 18:15:22 +01:00
print '<span class="amount">' . price ( $object -> opp_amount * $object -> opp_percent / 100 , 0 , $langs , 1 , 0 , - 1 , $conf -> currency ) . '</span>' ;
2021-02-26 18:49:22 +01:00
}
2020-10-31 14:32:18 +01:00
print '</td></tr>' ;
2022-05-16 18:54:50 +02:00
*/
2017-10-07 13:09:31 +02:00
}
2017-06-02 12:27:46 +02:00
2017-10-07 13:09:31 +02:00
// Date start - end
print '<tr><td>' . $langs -> trans ( " DateStart " ) . ' - ' . $langs -> trans ( " DateEnd " ) . '</td><td>' ;
2019-01-27 11:55:16 +01:00
$start = dol_print_date ( $object -> date_start , 'day' );
2019-11-13 19:35:02 +01:00
print ( $start ? $start : '?' );
2019-01-27 11:55:16 +01:00
$end = dol_print_date ( $object -> date_end , 'day' );
2017-04-05 14:48:24 +02:00
print ' - ' ;
2019-11-13 19:35:02 +01:00
print ( $end ? $end : '?' );
2021-02-26 18:49:22 +01:00
if ( $object -> hasDelay ()) {
print img_warning ( " Late " );
}
2017-10-07 13:09:31 +02:00
print '</td></tr>' ;
2017-06-02 12:27:46 +02:00
2017-10-07 13:09:31 +02:00
// Budget
print '<tr><td>' . $langs -> trans ( " Budget " ) . '</td><td>' ;
2021-02-26 18:49:22 +01:00
if ( strcmp ( $object -> budget_amount , '' )) {
2022-01-01 18:15:22 +01:00
print '<span class="amount">' . price ( $object -> budget_amount , 0 , $langs , 1 , 0 , 0 , $conf -> currency ) . '</span>' ;
2021-02-26 18:49:22 +01:00
}
2017-10-07 13:09:31 +02:00
print '</td></tr>' ;
2015-02-16 10:58:05 +01:00
2017-10-07 13:09:31 +02:00
// Other attributes
$cols = 2 ;
2019-11-13 19:35:02 +01:00
include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php' ;
2017-06-02 12:27:46 +02:00
2017-10-07 13:09:31 +02:00
print '</table>' ;
2017-06-02 12:27:46 +02:00
2017-10-07 13:09:31 +02:00
print '</div>' ;
print '<div class="fichehalfright">' ;
print '<div class="underbanner clearboth"></div>' ;
2017-06-02 12:27:46 +02:00
2021-10-23 17:18:35 +02:00
print '<table class="border tableforfield centpercent">' ;
2017-06-02 12:27:46 +02:00
2017-10-07 13:09:31 +02:00
// Description
print '<td class="titlefield tdtop">' . $langs -> trans ( " Description " ) . '</td><td>' ;
2020-07-10 02:46:59 +02:00
print dol_htmlentitiesbr ( $object -> description );
2017-10-07 13:09:31 +02:00
print '</td></tr>' ;
2010-11-11 13:16:55 +01:00
2017-10-07 13:09:31 +02:00
// Categories
2022-06-09 22:41:59 +02:00
if ( isModEnabled ( 'categorie' )) {
2019-02-23 22:24:26 +01:00
print '<tr><td class="valignmiddle">' . $langs -> trans ( " Categories " ) . '</td><td>' ;
2019-11-14 08:15:39 +01:00
print $form -> showCategories ( $object -> id , Categorie :: TYPE_PROJECT , 1 );
2017-10-07 13:09:31 +02:00
print " </td></tr> " ;
}
2017-06-02 12:27:46 +02:00
2017-10-07 13:09:31 +02:00
print '</table>' ;
2017-06-02 12:27:46 +02:00
2017-10-07 13:09:31 +02:00
print '</div>' ;
print '</div>' ;
2017-06-02 12:27:46 +02:00
2017-10-07 13:09:31 +02:00
print '<div class="clearboth"></div>' ;
}
2010-11-11 13:16:55 +01:00
2020-10-27 18:19:31 +01:00
print dol_get_fiche_end ();
2010-11-11 13:16:55 +01:00
2021-02-26 18:49:22 +01:00
if ( $action == 'edit' && $userWrite > 0 ) {
2021-08-20 14:41:30 +02:00
print $form -> buttonsSaveCancel ();
2015-01-30 16:33:39 +01:00
}
2017-10-07 13:09:31 +02:00
print '</form>' ;
2015-01-30 16:33:39 +01:00
2017-10-07 13:09:31 +02:00
// Change probability from status
2021-02-26 18:49:22 +01:00
if ( ! empty ( $conf -> use_javascript_ajax ) && ! empty ( $conf -> global -> PROJECT_USE_OPPORTUNITIES )) {
2017-10-07 13:09:31 +02:00
// Default value to close or not when we set opp to 'WON'.
2019-11-13 19:35:02 +01:00
$defaultcheckedwhenoppclose = 1 ;
2021-02-26 18:49:22 +01:00
if ( empty ( $conf -> global -> PROJECT_HIDE_TASKS )) {
$defaultcheckedwhenoppclose = 0 ;
}
2017-06-02 12:27:46 +02:00
2017-10-07 13:09:31 +02:00
print '<!-- Javascript to manage opportunity status change -->' ;
2021-11-29 15:09:18 +01:00
print ' < script type = " text/javascript " >
2017-02-01 13:25:16 +01:00
jQuery ( document ) . ready ( function () {
function change_percent ()
{
var element = jQuery ( " #opp_status option:selected " );
var defaultpercent = element . attr ( " defaultpercent " );
2022-05-23 00:57:02 +02:00
var defaultcloseproject = '.((int) $defaultcheckedwhenoppclose).' ;
2017-02-01 13:25:16 +01:00
var elemcode = element . attr ( " elemcode " );
var oldpercent = \ '' . dol_escape_js ( $object -> opp_percent ) . ' \ ' ;
console . log ( " We select " + elemcode );
2017-06-03 00:58:51 +02:00
/* Define if checkbox to close is checked or not */
2017-06-03 01:55:05 +02:00
var closeproject = 0 ;
2017-06-03 00:58:51 +02:00
if ( elemcode == \ ' LOST\ ' ) closeproject = 1 ;
if ( elemcode == \ ' WON\ ' ) closeproject = defaultcloseproject ;
if ( closeproject ) jQuery ( " #inputcloseproject " ) . prop ( " checked " , true );
2017-02-01 13:25:16 +01:00
else jQuery ( " #inputcloseproject " ) . prop ( " checked " , false );
2017-06-02 12:27:46 +02:00
2017-06-03 00:58:51 +02:00
/* Make the close project checkbox visible or not */
2017-06-03 01:55:05 +02:00
console . log ( " closeproject= " + closeproject );
2017-06-02 12:27:46 +02:00
if ( elemcode == \ ' WON\ ' || elemcode == \ ' LOST\ ' )
2017-02-01 13:25:16 +01:00
{
jQuery ( " #divtocloseproject " ) . show ();
}
else
{
jQuery ( " #divtocloseproject " ) . hide ();
}
2017-06-02 12:27:46 +02:00
2018-04-06 00:01:24 +02:00
/* Change percent with default percent (defaultpercent) if new status (defaultpercent) is higher than current (jQuery("#opp_percent").val()) */
console . log ( " oldpercent= " + oldpercent );
if ( oldpercent != \ ' \ ' && ( parseFloat ( defaultpercent ) < parseFloat ( oldpercent )))
2017-02-01 13:25:16 +01:00
{
if ( jQuery ( " #opp_percent " ) . val () != \ '\' && oldpercent != \'\') jQuery("#oldopppercent").text(\' - ' . dol_escape_js ( $langs -> transnoentities ( " PreviousValue " )) . ' : \ ' + oldpercent + \ ' % \ ' );
2018-04-06 00:01:24 +02:00
if ( parseFloat ( oldpercent ) != 100 ) { jQuery ( " #opp_percent " ) . val ( oldpercent ); }
else { jQuery ( " #opp_percent " ) . val ( defaultpercent ); }
}
2018-04-13 13:28:48 +02:00
else
2018-04-06 00:01:24 +02:00
{
if (( parseFloat ( jQuery ( " #opp_percent " ) . val ()) < parseFloat ( defaultpercent )));
{
if ( jQuery ( " #opp_percent " ) . val () != \ '\' && oldpercent != \'\') jQuery("#oldopppercent").text(\' - ' . dol_escape_js ( $langs -> transnoentities ( " PreviousValue " )) . ' : \ ' + oldpercent + \ ' % \ ' );
jQuery ( " #opp_percent " ) . val ( defaultpercent );
}
2017-02-01 13:25:16 +01:00
}
}
jQuery ( " #opp_status " ) . change ( function () {
change_percent ();
});
2016-01-28 20:04:02 +01:00
});
</ script > ' ;
2017-10-07 13:09:31 +02:00
}
2016-08-29 10:32:00 +02:00
2017-10-07 13:09:31 +02:00
/*
2021-02-26 18:49:22 +01:00
* Actions Buttons
*/
2017-10-07 13:09:31 +02:00
print '<div class="tabsAction">' ;
$parameters = array ();
$reshook = $hookmanager -> executeHooks ( 'addMoreActionsButtons' , $parameters , $object , $action ); // Note that $action and $object may have been
// modified by hook
2021-02-26 18:49:22 +01:00
if ( empty ( $reshook )) {
if ( $action != " edit " && $action != 'presend' ) {
2017-10-07 13:09:31 +02:00
// Create event
2017-12-07 00:28:43 +01:00
/* if ( $conf -> agenda -> enabled && ! empty ( $conf -> global -> MAIN_ADD_EVENT_ON_ELEMENT_CARD )) // Add hidden condition because this is not a
2017-10-07 13:09:31 +02:00
// "workflow" action so should appears somewhere else on
// page.
{
2019-10-16 14:17:53 +02:00
print '<a class="butAction" href="' . DOL_URL_ROOT . '/comm/action/card.php?action=create&origin=' . $object -> element . '&originid=' . $object -> id . '&socid=' . $object -> socid . '&projectid=' . $object -> id . '">' . $langs -> trans ( " AddAction " ) . '</a>' ;
2017-12-07 00:28:43 +01:00
} */
2016-10-18 22:23:03 +02:00
2018-03-28 15:22:47 +02:00
// Send
2020-04-10 01:37:04 +02:00
if ( empty ( $user -> socid )) {
2021-02-26 18:49:22 +01:00
if ( $object -> statut != Project :: STATUS_CLOSED ) {
2022-05-19 17:55:13 +02:00
print dolGetButtonAction ( '' , $langs -> trans ( 'SendMail' ), 'default' , $_SERVER [ " PHP_SELF " ] . '?action=presend&token=' . newToken () . '&id=' . $object -> id . '&mode=init#formmailbeforetitle' , '' );
2020-04-10 01:37:04 +02:00
}
2018-03-28 16:07:02 +02:00
}
2018-03-28 15:22:47 +02:00
2019-09-01 01:40:51 +02:00
// Modify
2021-02-26 18:49:22 +01:00
if ( $object -> statut != Project :: STATUS_CLOSED && $user -> rights -> projet -> creer ) {
if ( $userWrite > 0 ) {
2022-05-19 17:55:13 +02:00
print dolGetButtonAction ( '' , $langs -> trans ( 'Modify' ), 'default' , $_SERVER [ " PHP_SELF " ] . '?action=edit&token=' . newToken () . '&id=' . $object -> id , '' );
2020-05-21 15:05:19 +02:00
} else {
2022-05-19 17:55:13 +02:00
print dolGetButtonAction ( $langs -> trans ( 'NotOwnerOfProject' ), $langs -> trans ( 'Modify' ), 'default' , $_SERVER [ 'PHP_SELF' ] . '#' , '' , false );
2017-10-07 13:09:31 +02:00
}
}
// Validate
2021-02-26 18:49:22 +01:00
if ( $object -> statut == Project :: STATUS_DRAFT && $user -> rights -> projet -> creer ) {
if ( $userWrite > 0 ) {
2022-05-19 17:55:13 +02:00
print dolGetButtonAction ( '' , $langs -> trans ( 'Validate' ), 'default' , $_SERVER [ " PHP_SELF " ] . '?action=validate&token=' . newToken () . '&id=' . $object -> id , '' );
2020-05-21 15:05:19 +02:00
} else {
2022-05-19 17:55:13 +02:00
print dolGetButtonAction ( $langs -> trans ( 'NotOwnerOfProject' ), $langs -> trans ( 'Validate' ), 'default' , $_SERVER [ 'PHP_SELF' ] . '#' , '' , false );
2017-10-07 13:09:31 +02:00
}
}
// Close
2021-02-26 18:49:22 +01:00
if ( $object -> statut == Project :: STATUS_VALIDATED && $user -> rights -> projet -> creer ) {
if ( $userWrite > 0 ) {
2022-05-19 17:55:13 +02:00
print dolGetButtonAction ( '' , $langs -> trans ( 'Close' ), 'default' , $_SERVER [ " PHP_SELF " ] . '?action=close&token=' . newToken () . '&id=' . $object -> id , '' );
2020-05-21 15:05:19 +02:00
} else {
2022-05-19 17:55:13 +02:00
print dolGetButtonAction ( $langs -> trans ( 'NotOwnerOfProject' ), $langs -> trans ( 'Close' ), 'default' , $_SERVER [ 'PHP_SELF' ] . '#' , '' , false );
2017-10-07 13:09:31 +02:00
}
}
// Reopen
2021-02-26 18:49:22 +01:00
if ( $object -> statut == Project :: STATUS_CLOSED && $user -> rights -> projet -> creer ) {
if ( $userWrite > 0 ) {
2022-05-19 17:55:13 +02:00
print dolGetButtonAction ( '' , $langs -> trans ( 'ReOpen' ), 'default' , $_SERVER [ " PHP_SELF " ] . '?action=reopen&token=' . newToken () . '&id=' . $object -> id , '' );
2020-05-21 15:05:19 +02:00
} else {
2022-05-19 17:55:13 +02:00
print dolGetButtonAction ( $langs -> trans ( 'NotOwnerOfProject' ), $langs -> trans ( 'ReOpen' ), 'default' , $_SERVER [ 'PHP_SELF' ] . '#' , '' , false );
2017-10-07 13:09:31 +02:00
}
}
// Add button to create objects from project
2021-02-26 18:49:22 +01:00
if ( ! empty ( $conf -> global -> PROJECT_SHOW_CREATE_OBJECT_BUTTON )) {
if ( ! empty ( $conf -> propal -> enabled ) && $user -> rights -> propal -> creer ) {
2017-10-07 13:09:31 +02:00
$langs -> load ( " propal " );
2022-05-19 17:55:13 +02:00
print dolGetButtonAction ( '' , $langs -> trans ( 'AddProp' ), 'default' , DOL_URL_ROOT . '/comm/propal/card.php?action=create&projectid=' . $object -> id . '&socid=' . $object -> socid , '' );
2017-10-07 13:09:31 +02:00
}
2021-02-26 18:49:22 +01:00
if ( ! empty ( $conf -> commande -> enabled ) && $user -> rights -> commande -> creer ) {
2017-10-07 13:09:31 +02:00
$langs -> load ( " orders " );
2022-05-19 17:55:13 +02:00
print dolGetButtonAction ( '' , $langs -> trans ( 'CreateOrder' ), 'default' , DOL_URL_ROOT . '/commande/card.php?action=create&projectid=' . $object -> id . '&socid=' . $object -> socid , '' );
2017-10-07 13:09:31 +02:00
}
2022-06-11 09:46:28 +02:00
if ( isModEnabled ( 'facture' ) && $user -> rights -> facture -> creer ) {
2017-10-07 13:09:31 +02:00
$langs -> load ( " bills " );
2022-05-19 17:55:13 +02:00
print dolGetButtonAction ( '' , $langs -> trans ( 'CreateBill' ), 'default' , DOL_URL_ROOT . '/compta/facture/card.php?action=create&projectid=' . $object -> id . '&socid=' . $object -> socid , '' );
2017-10-07 13:09:31 +02:00
}
2021-02-26 18:49:22 +01:00
if ( ! empty ( $conf -> supplier_proposal -> enabled ) && $user -> rights -> supplier_proposal -> creer ) {
2017-10-07 13:09:31 +02:00
$langs -> load ( " supplier_proposal " );
2022-05-19 17:55:13 +02:00
print dolGetButtonAction ( '' , $langs -> trans ( 'AddSupplierProposal' ), 'default' , DOL_URL_ROOT . '/supplier_proposal/card.php?action=create&projectid=' . $object -> id . '&socid=' . $object -> socid , '' );
2017-10-07 13:09:31 +02:00
}
2021-04-12 09:47:16 +02:00
if ( ! empty ( $conf -> supplier_order -> enabled ) && ( $user -> rights -> fournisseur -> commande -> creer || $user -> rights -> supplier_order -> creer )) {
2017-10-07 13:09:31 +02:00
$langs -> load ( " suppliers " );
2022-05-19 17:55:13 +02:00
print dolGetButtonAction ( '' , $langs -> trans ( 'AddSupplierOrder' ), 'default' , DOL_URL_ROOT . '/fourn/commande/card.php?action=create&projectid=' . $object -> id . '&socid=' . $object -> socid , '' );
2017-10-07 13:09:31 +02:00
}
2021-04-12 07:37:34 +02:00
if ( ! empty ( $conf -> supplier_invoice -> enabled ) && ( $user -> rights -> fournisseur -> facture -> creer || $user -> rights -> supplier_invoice -> creer )) {
2017-10-07 13:09:31 +02:00
$langs -> load ( " suppliers " );
2022-05-19 17:55:13 +02:00
print dolGetButtonAction ( '' , $langs -> trans ( 'AddSupplierInvoice' ), 'default' , DOL_URL_ROOT . '/fourn/facture/card.php?action=create&projectid=' . $object -> id . '&socid=' . $object -> socid , '' );
2017-10-07 13:09:31 +02:00
}
2021-02-26 18:49:22 +01:00
if ( ! empty ( $conf -> ficheinter -> enabled ) && $user -> rights -> ficheinter -> creer ) {
2017-10-07 13:09:31 +02:00
$langs -> load ( " interventions " );
2022-05-19 17:55:13 +02:00
print dolGetButtonAction ( '' , $langs -> trans ( 'AddIntervention' ), 'default' , DOL_URL_ROOT . '/fichinter/card.php?action=create&projectid=' . $object -> id . '&socid=' . $object -> socid , '' );
2017-10-07 13:09:31 +02:00
}
2021-02-26 18:49:22 +01:00
if ( ! empty ( $conf -> contrat -> enabled ) && $user -> rights -> contrat -> creer ) {
2017-10-07 13:09:31 +02:00
$langs -> load ( " contracts " );
2022-05-19 17:55:13 +02:00
print dolGetButtonAction ( '' , $langs -> trans ( 'AddContract' ), 'default' , DOL_URL_ROOT . '/contrat/card.php?action=create&projectid=' . $object -> id . '&socid=' . $object -> socid , '' );
2017-10-07 13:09:31 +02:00
}
2021-02-26 18:49:22 +01:00
if ( ! empty ( $conf -> expensereport -> enabled ) && $user -> rights -> expensereport -> creer ) {
2017-10-07 13:09:31 +02:00
$langs -> load ( " trips " );
2022-05-19 17:55:13 +02:00
print dolGetButtonAction ( '' , $langs -> trans ( 'AddTrip' ), 'default' , DOL_URL_ROOT . '/expensereport/card.php?action=create&projectid=' . $object -> id . '&socid=' . $object -> socid , '' );
2017-10-07 13:09:31 +02:00
}
2021-02-26 18:49:22 +01:00
if ( ! empty ( $conf -> don -> enabled ) && $user -> rights -> don -> creer ) {
2017-10-07 13:09:31 +02:00
$langs -> load ( " donations " );
2022-05-19 17:55:13 +02:00
print dolGetButtonAction ( '' , $langs -> trans ( 'AddDonation' ), 'default' , DOL_URL_ROOT . '/don/card.php?action=create&projectid=' . $object -> id . '&socid=' . $object -> socid , '' );
2017-10-07 13:09:31 +02:00
}
}
// Clone
2021-02-26 18:49:22 +01:00
if ( $user -> rights -> projet -> creer ) {
if ( $userWrite > 0 ) {
2022-05-19 17:55:13 +02:00
print dolGetButtonAction ( '' , $langs -> trans ( 'ToClone' ), 'default' , $_SERVER [ " PHP_SELF " ] . '?action=clone&token=' . newToken () . '&id=' . $object -> id , '' );
2020-05-21 15:05:19 +02:00
} else {
2022-05-19 17:55:13 +02:00
print dolGetButtonAction ( $langs -> trans ( 'NotOwnerOfProject' ), $langs -> trans ( 'ToClone' ), 'default' , $_SERVER [ 'PHP_SELF' ] . '#' , '' , false );
2017-10-07 13:09:31 +02:00
}
}
// Delete
2021-02-26 18:49:22 +01:00
if ( $user -> rights -> projet -> supprimer || ( $object -> statut == Project :: STATUS_DRAFT && $user -> rights -> projet -> creer )) {
if ( $userDelete > 0 || ( $object -> statut == Project :: STATUS_DRAFT && $user -> rights -> projet -> creer )) {
2022-05-19 17:55:13 +02:00
print dolGetButtonAction ( '' , $langs -> trans ( 'Delete' ), 'delete' , $_SERVER [ " PHP_SELF " ] . '?action=delete&token=' . newToken () . '&id=' . $object -> id , '' );
2020-05-21 15:05:19 +02:00
} else {
2022-05-19 17:55:13 +02:00
print dolGetButtonAction ( $langs -> trans ( 'NotOwnerOfProject' ), $langs -> trans ( 'Delete' ), 'default' , $_SERVER [ 'PHP_SELF' ] . '#' , '' , false );
2017-10-07 13:09:31 +02:00
}
}
2019-02-03 14:29:45 +01:00
}
2017-10-07 13:09:31 +02:00
}
print " </div> " ;
2018-03-28 17:10:12 +02:00
if ( GETPOST ( 'modelselected' )) {
$action = 'presend' ;
}
2021-02-26 18:49:22 +01:00
if ( $action != 'presend' ) {
2017-10-07 13:09:31 +02:00
print '<div class="fichecenter"><div class="fichehalfleft">' ;
print '<a name="builddoc"></a>' ; // ancre
/*
2021-03-16 04:04:33 +01:00
* Generated documents
2021-02-26 18:49:22 +01:00
*/
2019-11-13 19:35:02 +01:00
$filename = dol_sanitizeFileName ( $object -> ref );
2023-03-24 15:58:53 +01:00
$filedir = $conf -> project -> multidir_output [ $object -> entity ] . " / " . dol_sanitizeFileName ( $object -> ref );
2019-11-13 19:35:02 +01:00
$urlsource = $_SERVER [ " PHP_SELF " ] . " ?id= " . $object -> id ;
$genallowed = ( $user -> rights -> projet -> lire && $userAccess > 0 );
$delallowed = ( $user -> rights -> projet -> creer && $userWrite > 0 );
2010-11-11 13:16:55 +01:00
2023-03-24 15:58:53 +01:00
print $formfile -> showdocuments ( 'project' , $filename , $filedir , $urlsource , $genallowed , $delallowed , $object -> model_pdf , 1 , 0 , 0 , 0 , 0 , '' , '' , '' , '' , '' , $object );
2010-11-11 13:16:55 +01:00
2021-10-23 17:18:35 +02:00
print '</div><div class="fichehalfright">' ;
2010-11-11 13:16:55 +01:00
2017-11-21 12:28:34 +01:00
$MAXEVENT = 10 ;
2017-10-04 12:58:13 +02:00
2022-05-18 23:11:59 +02:00
$morehtmlcenter = dolGetButtonTitle ( $langs -> trans ( 'SeeAll' ), '' , 'fa fa-bars imgforviewmode' , DOL_URL_ROOT . '/projet/info.php?id=' . $object -> id );
2017-10-04 12:58:13 +02:00
2017-10-07 13:09:31 +02:00
// List of actions on element
2019-11-13 19:35:02 +01:00
include_once DOL_DOCUMENT_ROOT . '/core/class/html.formactions.class.php' ;
2017-10-07 13:09:31 +02:00
$formactions = new FormActions ( $db );
2021-10-18 15:25:56 +02:00
$somethingshown = $formactions -> showactions ( $object , 'project' , 0 , 1 , '' , $MAXEVENT , '' , $morehtmlcenter );
2010-11-11 13:16:55 +01:00
2021-10-23 17:18:35 +02:00
print '</div></div>' ;
2017-10-07 13:09:31 +02:00
}
2014-05-08 20:02:34 +02:00
2018-03-28 15:22:47 +02:00
// Presend form
2019-11-13 19:35:02 +01:00
$modelmail = 'project' ;
$defaulttopic = 'SendProjectRef' ;
2023-03-24 15:58:53 +01:00
$diroutput = $conf -> project -> multidir_output [ $object -> entity ];
2019-11-13 19:35:02 +01:00
$autocopy = 'MAIN_MAIL_AUTOCOPY_PROJECT_TO' ; // used to know the automatic BCC to add
2018-03-28 15:22:47 +02:00
$trackid = 'proj' . $object -> id ;
include DOL_DOCUMENT_ROOT . '/core/tpl/card_presend.tpl.php' ;
2017-10-07 13:09:31 +02:00
// Hook to add more things on page
2019-11-13 19:35:02 +01:00
$parameters = array ();
$reshook = $hookmanager -> executeHooks ( 'mainCardTabAddMore' , $parameters , $object , $action ); // Note that $action and $object may have been modified by hook
2020-05-21 15:05:19 +02:00
} else {
2017-10-07 13:09:31 +02:00
print $langs -> trans ( " RecordNotFound " );
2016-11-19 02:16:12 +01:00
}
2004-10-23 17:09:29 +02:00
2018-08-15 12:48:13 +02:00
// End of page
2011-08-27 16:24:16 +02:00
llxFooter ();
2012-02-04 18:34:52 +01:00
$db -> close ();