32require
'../main.inc.php';
33require_once DOL_DOCUMENT_ROOT.
'/projet/class/project.class.php';
34require_once DOL_DOCUMENT_ROOT.
'/projet/class/task.class.php';
35require_once DOL_DOCUMENT_ROOT.
'/core/lib/project.lib.php';
36require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
37require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formprojet.class.php';
38require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
39require_once DOL_DOCUMENT_ROOT.
'/core/modules/project/modules_project.php';
40require_once DOL_DOCUMENT_ROOT.
'/core/class/extrafields.class.php';
41require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
44$langsLoad = array(
'projects',
'companies');
45if (isModEnabled(
'eventorganization')) {
46 $langsLoad[] =
'eventorganization';
49$langs->loadLangs($langsLoad);
53$action =
GETPOST(
'action',
'aZ09');
54$backtopage =
GETPOST(
'backtopage',
'alpha');
55$backtopageforcancel =
GETPOST(
'backtopageforcancel',
'alpha');
56$backtopagejsfields =
GETPOST(
'backtopagejsfields',
'alpha');
57$cancel =
GETPOST(
'cancel',
'alpha');
58$confirm =
GETPOST(
'confirm',
'aZ09');
61if (!empty($backtopagejsfields)) {
62 $tmpbacktopagejsfields = explode(
':', $backtopagejsfields);
63 $dol_openinpopup = preg_replace(
'/[^a-z0-9_]/i',
'', $tmpbacktopagejsfields[0]);
69$objcanvas =
GETPOST(
"objcanvas",
"alphanohtml");
70$comefromclone =
GETPOST(
"comefromclone",
"alphanohtml");
75$location =
GETPOST(
'location',
'alphanohtml');
79$mine =
GETPOST(
'mode') ==
'mine' ? 1 : 0;
83$hookmanager->initHooks(array(
'projectcard',
'globalcard'));
90if ($id > 0 || !empty($ref)) {
91 $ret =
$object->fetch($id, $ref);
102$extrafields->fetch_name_optionals_label(
$object->table_element);
109if ($id ==
'' && $ref ==
'' && ($action !=
"create" && $action !=
"add" && $action !=
"update" && !
GETPOST(
"cancel"))) {
113$permissiontoadd = $user->hasRight(
'projet',
'creer');
114$permissiontodelete = $user->hasRight(
'projet',
'supprimer');
115$permissiondellink = $user->hasRight(
'projet',
'creer');
122$parameters = array(
'id' => $socid,
'objcanvas' => $objcanvas);
123$reshook = $hookmanager->executeHooks(
'doActions', $parameters,
$object, $action);
128if (empty($reshook)) {
129 $backurlforlist = DOL_URL_ROOT.
'/projet/list.php';
133 if (
GETPOST(
"comefromclone") == 1) {
134 $result =
$object->delete($user);
136 header(
"Location: index.php");
140 setEventMessages($langs->trans(
"CantRemoveProject", $langs->transnoentitiesnoconv(
"ProjectOverview")),
null,
'errors');
145 if (empty($backtopage) || ($cancel && empty($id))) {
146 if (empty($backtopage) || ($cancel && strpos($backtopage,
'__ID__'))) {
147 if (empty($id) && (($action !=
'add' && $action !=
'create') || $cancel)) {
148 $backtopage = $backurlforlist;
150 $backtopage = DOL_URL_ROOT.
'/projet/card.php?id='.((!empty($id) && $id > 0) ? $id :
'__ID__');
156 if (!empty($backtopageforcancel)) {
157 header(
"Location: ".$backtopageforcancel);
159 } elseif (!empty($backtopage)) {
160 header(
"Location: ".$backtopage);
166 include DOL_DOCUMENT_ROOT.
'/core/actions_dellink.inc.php';
169 if ($action ==
'confirm_setdraft' && $confirm ==
'yes' && $permissiontoadd) {
170 $result =
$object->setStatut($object::STATUS_DRAFT,
null,
'',
'PROJECT_MODIFY');
180 $object->statut = $object::STATUS_DRAFT;
184 if ($action ==
'add' && $permissiontoadd) {
187 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"Ref")),
null,
'errors');
191 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"ProjectLabel")),
null,
'errors');
196 if (
GETPOST(
'usage_opportunity') !=
'' && !(
GETPOST(
'opp_status') > 0)) {
198 setEventMessages($langs->trans(
"ErrorOppStatusRequiredIfUsage"),
null,
'errors');
200 if (
GETPOST(
'opp_amount') !=
'' && !(
GETPOST(
'opp_status') > 0)) {
202 setEventMessages($langs->trans(
"ErrorOppStatusRequiredIfAmount"),
null,
'errors');
225 $object->date_start = $date_start;
227 $object->date_start_event = $date_start_event;
228 $object->date_end_event = $date_end_event;
231 $object->opp_status = $opp_status;
232 $object->opp_percent = $opp_percent;
233 $object->usage_opportunity = (
GETPOST(
'usage_opportunity',
'alpha') ==
'on' ? 1 : 0);
234 $object->usage_task = (
GETPOST(
'usage_task',
'alpha') ==
'on' ? 1 : 0);
235 $object->usage_bill_time = (
GETPOST(
'usage_bill_time',
'alpha') ==
'on' ? 1 : 0);
236 $object->usage_organize_event = (
GETPOST(
'usage_organize_event',
'alpha') ==
'on' ? 1 : 0);
239 $ret = $extrafields->setOptionalsFromPost(
null,
$object);
244 $result =
$object->create($user);
245 if (!$error && $result > 0) {
247 $typeofcontact =
'PROJECTLEADER';
248 $result =
$object->add_contact($user->id, $typeofcontact,
'internal');
254 } elseif ($result < 0) {
255 $langs->load(
"errors");
260 $langs->load(
"errors");
264 if (!$error && !empty(
$object->id) > 0) {
266 $categories =
GETPOST(
'categories',
'array');
267 $result =
$object->setCategories($categories);
269 $langs->load(
"errors");
278 if (!empty($backtopage)) {
279 $backtopage = preg_replace(
'/--IDFORBACKTOPAGE--|__ID__/', (
string)
$object->id, $backtopage);
280 $backtopage = $backtopage.
'&projectid='.
$object->id;
281 header(
"Location: ".$backtopage);
284 header(
"Location:card.php?id=".
$object->id);
289 unset($_POST[
"ref"]);
297 if ($action ==
'update' && empty(
GETPOST(
'cancel')) && $permissiontoadd) {
302 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"Ref")),
null,
'errors');
306 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"ProjectLabel")),
null,
'errors');
314 $old_start_date =
$object->date_start;
323 $object->date_start = (!
GETPOST(
'projectstart')) ?
'' : $date_start;
325 $object->date_start_event = (!
GETPOST(
'date_start_event')) ?
'' : $date_start_event;
326 $object->date_end_event = (!
GETPOST(
'date_end_event')) ?
'' : $date_end_event;
328 if (GETPOSTISSET(
'opp_amount')) {
331 if (GETPOSTISSET(
'budget_amount')) {
334 if (GETPOSTISSET(
'opp_status')) {
335 $object->opp_status = $opp_status;
337 if (GETPOSTISSET(
'opp_percent')) {
338 $object->opp_percent = $opp_percent;
340 $object->usage_opportunity = (
GETPOST(
'usage_opportunity',
'alpha') ==
'on' ? 1 : 0);
341 $object->usage_task = (
GETPOST(
'usage_task',
'alpha') ==
'on' ? 1 : 0);
342 $object->usage_bill_time = (
GETPOST(
'usage_bill_time',
'alpha') ==
'on' ? 1 : 0);
343 $object->usage_organize_event = (
GETPOST(
'usage_organize_event',
'alpha') ==
'on' ? 1 : 0);
346 $ret = $extrafields->setOptionalsFromPost(
null,
$object,
'@GETPOSTISSET');
355 setEventMessages($langs->trans(
"ErrorOppStatusRequiredIfAmount"),
null,
'errors');
360 $result =
$object->update($user);
370 $categories =
GETPOST(
'categories',
'array');
371 $result =
$object->setCategories($categories);
380 if (
GETPOST(
"reportdate") && (
$object->date_start != $old_start_date)) {
381 $result =
$object->shiftTaskDate($old_start_date);
391 $resclose =
$object->setClose($user);
413 if ($action ==
'set_opp_status' && $user->hasRight(
'projet',
'creer')) {
415 if (GETPOSTISSET(
'opp_status')) {
416 $object->opp_status = $opp_status;
418 if (GETPOSTISSET(
'opp_percent')) {
419 $object->opp_percent = $opp_percent;
425 setEventMessages($langs->trans(
"ErrorOppStatusRequiredIfAmount"),
null,
'errors');
430 $result =
$object->update($user);
450 if ($action ==
'builddoc' && $permissiontoadd) {
456 $outputlangs = $langs;
457 if (
GETPOST(
'lang_id',
'aZ09')) {
459 $outputlangs->setDefaultLang(
GETPOST(
'lang_id',
'aZ09'));
461 $result =
$object->generateDocument(
$object->model_pdf, $outputlangs);
469 if ($action ==
'remove_file' && $permissiontoadd) {
471 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
473 $langs->load(
"other");
474 $upload_dir = $conf->project->multidir_output[
$object->entity];
475 $file = $upload_dir.
'/'.
GETPOST(
'file');
487 if ($action ==
'confirm_validate' && $confirm ==
'yes' && $permissiontoadd) {
488 $result =
$object->setValid($user);
494 if ($action ==
'confirm_close' && $confirm ==
'yes' && $permissiontoadd) {
495 $result =
$object->setClose($user);
501 if ($action ==
'confirm_reopen' && $confirm ==
'yes' && $permissiontoadd) {
502 $result =
$object->setValid($user);
508 if ($action ==
'confirm_delete' && $confirm ==
'yes' && $permissiontodelete) {
510 $result =
$object->delete($user);
514 if (!empty($_SESSION[
'pageforbacktolist']) && !empty($_SESSION[
'pageforbacktolist'][
'project'])) {
515 $tmpurl = $_SESSION[
'pageforbacktolist'][
'project'];
516 $tmpurl = preg_replace(
'/__SOCID__/', (
string)
$object->socid, $tmpurl);
517 $urlback = $tmpurl.(preg_match(
'/\?/', $tmpurl) ?
'&' :
'?').
'restore_lastsearch_values=1';
519 $urlback = DOL_URL_ROOT.
'/projet/list.php?restore_lastsearch_values=1';
522 header(
"Location: ".$urlback);
530 if ($action ==
'confirm_clone' && $permissiontoadd && $confirm ==
'yes') {
531 $clone_contacts =
GETPOST(
'clone_contacts') ? 1 : 0;
532 $clone_tasks =
GETPOST(
'clone_tasks') ? 1 : 0;
533 $clone_project_files =
GETPOST(
'clone_project_files') ? 1 : 0;
534 $clone_task_files =
GETPOST(
'clone_task_files') ? 1 : 0;
535 $clone_notes =
GETPOST(
'clone_notes') ? 1 : 0;
536 $move_date =
GETPOST(
'move_date') ? 1 : 0;
539 $result =
$object->createFromClone($user,
$object->id, $clone_contacts, $clone_tasks, $clone_project_files, $clone_task_files, $clone_notes, $move_date, 0, $clone_thirdparty);
545 $newobject->fetch($result);
547 setEventMessages($langs->trans(
"ProjectCreatedInDolibarr", $newobject->ref),
"",
'mesgs');
549 header(
'Location: '.$_SERVER[
'PHP_SELF'].
'?id='.$result.
'&action=edit&comefromclone=1');
555 if ($action ==
'update_extras' && $permissiontoadd) {
559 $ret = $extrafields->setOptionalsFromPost(
null,
$object,
GETPOST(
'attribute',
'restricthtml'));
566 $result =
$object->insertExtraFields(
'PROJECT_MODIFY');
574 $action =
'edit_extras';
579 $triggersendname =
'PROJECT_SENTBYMAIL';
581 $autocopy =
'MAIN_MAIL_AUTOCOPY_PROJECT_TO';
582 $trackid =
'proj'.$object->id;
583 include DOL_DOCUMENT_ROOT.
'/core/actions_sendmails.inc.php';
591$form =
new Form($db);
594$userstatic =
new User($db);
596$title = $langs->trans(
"Project").
' - '.
$object->ref.(!empty(
$object->thirdparty->name) ?
' - '.$object->thirdparty->name :
'').(!empty(
$object->title) ?
' - '.$object->title :
'');
598 $title =
$object->ref.(!empty(
$object->thirdparty->name) ?
' - '.$object->thirdparty->name :
'').(!empty(
$object->title) ?
' - '.$object->title :
'');
601$help_url =
"EN:Module_Projects|FR:Module_Projets|ES:Módulo_Proyectos|DE:Modul_Projekte";
605$titleboth = $langs->trans(
"LeadsOrProjects");
606$titlenew = $langs->trans(
"NewLeadOrProject");
608 $titleboth = $langs->trans(
"Projects");
609 $titlenew = $langs->trans(
"NewProject");
612 $titleboth = $langs->trans(
"Leads");
613 $titlenew = $langs->trans(
"NewLead");
616if ($action ==
'create' && $user->hasRight(
'projet',
'creer')) {
621 $thirdparty =
new Societe($db);
623 $thirdparty->fetch($socid);
628 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
629 print
'<input type="hidden" name="action" value="add">';
630 print
'<input type="hidden" name="token" value="'.newToken().
'">';
631 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
632 print
'<input type="hidden" name="backtopageforcancel" value="'.$backtopageforcancel.
'">';
633 print
'<input type="hidden" name="backtopagejsfields" value="'.$backtopagejsfields.
'">';
634 print
'<input type="hidden" name="dol_openinpopup" value="'.$dol_openinpopup.
'">';
638 print
'<table class="border centpercent tableforfieldcreate">';
641 $modele = !
getDolGlobalString(
'PROJECT_ADDON') ?
'mod_project_simple' : $conf->global->PROJECT_ADDON;
647 $dirmodels = array_merge(array(
'/'), (array) $conf->modules_parts[
'models']);
648 foreach ($dirmodels as $reldir) {
649 $file =
dol_buildpath($reldir.
"core/modules/project/".$modele.
'.php', 0);
650 if (file_exists($file)) {
652 $classname = $modele;
659 $modProject =
new $classname();
661 $defaultref = $modProject->getNextValue($thirdparty,
$object);
664 if (is_numeric($defaultref) && $defaultref <= 0) {
670 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).
'">';
672 print
' '.$form->textwithpicto(
'', $langs->trans(
"YouCanCompleteRef", $suggestedref));
677 print
'<tr><td><span class="fieldrequired">'.$langs->trans(
"Label").
'</span></td><td><input class="width500 maxwidth150onsmartphone" type="text" name="title" value="'.
dol_escape_htmltag(
GETPOST(
"title",
'alphanohtml')).
'" autofocus></td></tr>';
681 print
'<tr><td>'.$langs->trans(
"Parent").
'</td><td class="maxwidthonsmartphone">';
682 print
img_picto(
'',
'project',
'class="pictofixedwidth"');
683 $formproject->select_projects(-1,
'',
'fk_project', 64, 0, 1, 1, 0, 0, 0,
'', 0, 0,
'',
'',
'');
689 print
'<tr><td class="tdtop">';
690 print $langs->trans(
"Usage");
694 print
'<input type="checkbox" id="usage_opportunity" name="usage_opportunity"'.(GETPOSTISSET(
'usage_opportunity') ? (
GETPOST(
'usage_opportunity',
'alpha') ?
' checked="checked"' :
'') :
' checked="checked"').
'"> ';
695 $htmltext = $langs->trans(
"ProjectFollowOpportunity");
696 print
'<label for="usage_opportunity">'.$form->textwithpicto($langs->trans(
"ProjectFollowOpportunity"), $htmltext).
'</label>';
698 print
'$( document ).ready(function() {
699 jQuery("#usage_opportunity").change(function() {
700 if (jQuery("#usage_opportunity").prop("checked")) {
701 console.log("Show opportunities fields");
702 jQuery(".classuseopportunity").show();
704 console.log("Hide opportunities fields "+jQuery("#usage_opportunity").prop("checked"));
705 jQuery(".classuseopportunity").hide();
709 if (GETPOSTISSET(
'usage_opportunity') && !
GETPOST(
'usage_opportunity')) {
710 print
'jQuery(".classuseopportunity").hide();';
717 print
'<input type="checkbox" id="usage_task" name="usage_task"'.(GETPOSTISSET(
'usage_task') ? (
GETPOST(
'usage_task',
'alpha') ?
' checked="checked"' :
'') :
' checked="checked"').
'"> ';
718 $htmltext = $langs->trans(
"ProjectFollowTasks");
719 print
'<label for="usage_task">'.$form->textwithpicto($langs->trans(
"ProjectFollowTasks"), $htmltext).
'</label>';
721 print
'$( document ).ready(function() {
722 jQuery("#usage_task").change(function() {
723 if (jQuery("#usage_task").prop("checked")) {
724 console.log("Show task fields");
725 jQuery(".classusetask").show();
727 console.log("Hide tasks fields "+jQuery("#usage_task").prop("checked"));
728 jQuery(".classusetask").hide();
732 if (GETPOSTISSET(
'usage_task') && !
GETPOST(
'usage_task')) {
733 print
'jQuery(".classusetask").hide();';
740 print
'<input type="checkbox" id="usage_bill_time" name="usage_bill_time"'.(GETPOSTISSET(
'usage_bill_time') ? (
GETPOST(
'usage_bill_time',
'alpha') ?
' checked="checked"' :
'') :
'').
'"> ';
741 $htmltext = $langs->trans(
"ProjectBillTimeDescription");
742 print
'<label for="usage_bill_time">'.$form->textwithpicto($langs->trans(
"BillTime"), $htmltext).
'</label>';
744 print
'$( document ).ready(function() {
745 jQuery("#usage_bill_time").change(function() {
746 if (jQuery("#usage_bill_time").prop("checked")) {
747 console.log("Show bill time fields");
748 jQuery(".classusebilltime").show();
750 console.log("Hide bill time fields "+jQuery("#usage_bill_time").prop("checked"));
751 jQuery(".classusebilltime").hide();
755 if (GETPOSTISSET(
'usage_bill_time') && !
GETPOST(
'usage_bill_time')) {
756 print
'jQuery(".classusebilltime").hide();';
762 if (isModEnabled(
'eventorganization')) {
763 print
'<input type="checkbox" id="usage_organize_event" name="usage_organize_event"'.(GETPOSTISSET(
'usage_organize_event') ? (
GETPOST(
'usage_organize_event',
'alpha') ?
' checked="checked"' :
'') :
'').
'"> ';
764 $htmltext = $langs->trans(
"EventOrganizationDescriptionLong");
765 print
'<label for="usage_organize_event">'.$form->textwithpicto($langs->trans(
"ManageOrganizeEvent"), $htmltext).
'</label>';
767 print
'$( document ).ready(function() {
768 jQuery("#usage_organize_event").change(function() {
769 if (jQuery("#usage_organize_event").prop("checked")) {
770 console.log("Show organize event fields");
771 jQuery(".classuseorganizeevent").show();
773 console.log("Hide organize event fields "+jQuery("#usage_organize_event").prop("checked"));
774 jQuery(".classuseorganizeevent").hide();
778 if (!
GETPOST(
'usage_organize_event')) {
779 print
'jQuery(".classuseorganizeevent").hide();';
789 if (isModEnabled(
'societe')) {
791 print(!
getDolGlobalString(
'PROJECT_THIRDPARTY_REQUIRED') ?
'' :
'<span class="fieldrequired">');
792 print $langs->trans(
"ThirdParty");
794 print
'</td><td class="maxwidthonsmartphone">';
799 $text =
img_picto(
'',
'company',
'class="pictofixedwidth"').$form->select_company(
GETPOSTINT(
'socid'),
'socid', $filter,
'SelectThirdParty', 1, 0, array(), 0,
'minwidth300 widthcentpercentminusxx maxwidth500');
800 if (!
getDolGlobalString(
'PROJECT_CAN_ALWAYS_LINK_TO_ALL_SUPPLIERS') && empty($conf->dol_use_jmobile)) {
801 $texthelp = $langs->trans(
"IfNeedToUseOtherObjectKeepEmpty");
802 print $form->textwithtooltip($text.
' '.
img_help(), $texthelp, 1);
806 if (!GETPOSTISSET(
'backtopage')) {
807 $url =
'/societe/card.php?action=create&client=3&fournisseur=0&backtopage='.urlencode($_SERVER[
"PHP_SELF"].
'?action=create');
808 $newbutton =
'<span class="fa fa-plus-circle valignmiddle paddingleft" title="'.$langs->trans(
"AddThirdParty").
'"></span>';
811 $tmpbacktopagejsfields =
'addthirdparty:socid,search_socid';
812 print
dolButtonToOpenUrlInDialogPopup(
'addthirdparty', $langs->transnoentitiesnoconv(
'AddThirdParty'), $newbutton, $url,
'',
'',
'', $tmpbacktopagejsfields);
814 print
' <a href="'.DOL_URL_ROOT.$url.
'">'.$newbutton.
'</a>';
822 print
'<tr><td>'.$langs->trans(
"Status").
'</td><td>';
823 print
'<input type="hidden" name="status" value="'.$status.
'">';
824 print
$object->LibStatut($status, 4);
829 print
'<tr><td>'.$langs->trans(
"Visibility").
'</td><td class="maxwidthonsmartphone">';
832 $array[0] = $langs->trans(
"PrivateProject");
835 $array[1] = $langs->trans(
"SharedProject");
838 if (count($array) > 0) {
839 print $form->selectarray(
'public', $array,
GETPOST(
'public'), 0, 0, 0,
'', 0, 0, 0,
'',
'', 1);
841 print
'<input type="hidden" name="public" id="public" value="'.GETPOST(
'public').
'">';
844 print
img_picto($langs->trans(
'PrivateProject'),
'private',
'class="paddingrightonly"');
845 print $langs->trans(
"PrivateProject");
847 print
img_picto($langs->trans(
'SharedProject'),
'world',
'class="paddingrightonly"');
848 print $langs->trans(
"SharedProject");
855 print
'<tr class="classuseopportunity"><td><span class="fieldrequired">'.$langs->trans(
"OpportunityStatus").
'</span></td>';
856 print
'<td class="maxwidthonsmartphone">';
857 print $formproject->selectOpportunityStatus(
'opp_status', GETPOSTISSET(
'opp_status') ?
GETPOST(
'opp_status') :
$object->opp_status, 1, 0, 0, 0,
'', 0, 1);
860 print
' <input class="width50 right" type="text" id="opp_percent" name="opp_percent" title="'.dol_escape_htmltag($langs->trans(
"OpportunityProbability")).
'" value="'.
dol_escape_htmltag(GETPOSTISSET(
'opp_percent') ?
GETPOST(
'opp_percent') :
'').
'"><span class="hideonsmartphone"> %</span>';
861 print
'<input type="hidden" name="opp_percent_not_set" id="opp_percent_not_set" value="'.dol_escape_htmltag(GETPOSTISSET(
'opp_percent') ?
'0' :
'1').
'">';
866 print
'<tr class="classuseopportunity"><td>'.$langs->trans(
"OpportunityAmount").
'</td>';
867 print
'<td><input class="width75 right" type="text" name="opp_amount" value="'.dol_escape_htmltag(GETPOSTISSET(
'opp_amount') ?
GETPOST(
'opp_amount') :
'').
'">';
868 print
' '.$langs->getCurrencySymbol($conf->currency);
874 print
'<tr><td>'.$langs->trans(
"Budget").
'</td>';
875 print
'<td><input class="width75 right" type="text" name="budget_amount" value="'.dol_escape_htmltag(GETPOSTISSET(
'budget_amount') ?
GETPOST(
'budget_amount') :
'').
'">';
876 print
' '.$langs->getCurrencySymbol($conf->currency);
881 print
'<tr><td>'.$langs->trans(
"Date").(isModEnabled(
'eventorganization') ?
' <span class="classuseorganizeevent">('.$langs->trans(
"Project").
')</span>' :
'').
'</td><td>';
882 print $form->selectDate(($date_start ? $date_start :
''),
'projectstart', 0, 0, 0,
'', 1, 0);
883 print
' <span class="opacitymedium"> '.$langs->trans(
"to").
' </span> ';
884 print $form->selectDate(($date_end ? $date_end : -1),
'projectend', 0, 0, 0,
'', 1, 0);
887 if (isModEnabled(
'eventorganization')) {
889 print
'<tr class="classuseorganizeevent"><td>'.$langs->trans(
"Date").
' ('.$langs->trans(
"Event").
')</td><td>';
890 print $form->selectDate(($date_start_event ? $date_start_event : -1),
'date_start_event', 1, 1, 1,
'', 1, 0);
891 print
' <span class="opacitymedium"> '.$langs->trans(
"to").
' </span> ';
892 print $form->selectDate(($date_end_event ? $date_end_event : -1),
'date_end_event', 1, 1, 1,
'', 1, 0);
896 print
'<tr class="classuseorganizeevent"><td>'.$langs->trans(
"Location").
'</td>';
897 print
'<td><input class="minwidth300 maxwidth500" type="text" name="location" value="'.dol_escape_htmltag($location).
'"></td>';
902 print
'<tr><td class="tdtop">'.$langs->trans(
"Description").
'</td>';
904 $doleditor =
new DolEditor(
'description',
GETPOST(
"description",
'restricthtml'),
'', 90,
'dolibarr_notes',
'',
false,
true, isModEnabled(
'fckeditor') &&
getDolGlobalString(
'FCKEDITOR_ENABLE_SOCIETE'), ROWS_3,
'90%');
905 $doleditor->Create();
908 if (isModEnabled(
'category')) {
910 print
'<tr><td>'.$langs->trans(
"Categories").
'</td><td colspan="3">';
911 $cate_arbo = $form->select_all_categories(Categorie::TYPE_PROJECT,
'',
'parent', 64, 0, 3);
912 $arrayselected =
GETPOST(
'categories',
'array');
913 print
img_picto(
'',
'category',
'class="pictofixedwidth"').$form->multiselectarray(
'categories', $cate_arbo, $arrayselected,
'', 0,
'quatrevingtpercent widthcentpercentminusx', 0, 0);
918 $parameters = array();
919 $reshook = $hookmanager->executeHooks(
'formObjectOptions', $parameters,
$object, $action);
920 print $hookmanager->resPrint;
921 if (empty($reshook)) {
922 print
$object->showOptionals($extrafields,
'create');
929 print $form->buttonsSaveCancel(
'CreateDraft');
935 print
'<script type="text/javascript">
936 jQuery(document).ready(function() {
937 function change_percent()
939 var element = jQuery("#opp_status option:selected");
940 var defaultpercent = element.attr("defaultpercent");
941 /*if (jQuery("#opp_percent_not_set").val() == "") */
942 jQuery("#opp_percent").val(defaultpercent);
946 jQuery("#opp_status").change(function() {
950 jQuery("#usage_task").change(function() {
951 console.log("We click on usage task "+jQuery("#usage_task").is(":checked"));
952 if (! jQuery("#usage_task").is(":checked")) {
953 jQuery("#usage_bill_time").prop("checked", false);
957 jQuery("#usage_bill_time").change(function() {
958 console.log("We click on usage to bill time");
959 if (jQuery("#usage_bill_time").is(":checked")) {
960 jQuery("#usage_task").prop("checked", true);
970 $res =
$object->fetch_optionals();
973 $userAccess =
$object->restrictedProjectArea($user,
'read');
974 $userWrite =
$object->restrictedProjectArea($user,
'write');
975 $userDelete =
$object->restrictedProjectArea($user,
'delete');
980 if ($action ==
'validate') {
981 print $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'ValidateProject'), $langs->trans(
'ConfirmValidateProject'),
'confirm_validate',
'', 0, 1);
984 if ($action ==
'close') {
985 print $form->formconfirm($_SERVER[
"PHP_SELF"].
"?id=".
$object->id, $langs->trans(
"CloseAProject"), $langs->trans(
"ConfirmCloseAProject"),
"confirm_close",
'',
'', 1);
988 if ($action ==
'reopen') {
989 print $form->formconfirm($_SERVER[
"PHP_SELF"].
"?id=".
$object->id, $langs->trans(
"ReOpenAProject"), $langs->trans(
"ConfirmReOpenAProject"),
"confirm_reopen",
'',
'', 1);
992 if ($action ==
'delete') {
993 $text = $langs->trans(
"ConfirmDeleteAProject");
994 $task =
new Task($db);
995 $taskarray = $task->getTasksArray(0, 0,
$object->id, 0, 0);
996 $nboftask = count($taskarray);
998 $text .=
'<br>'.img_warning().
' '.$langs->trans(
"ThisWillAlsoRemoveTasks", $nboftask);
1000 print $form->formconfirm($_SERVER[
"PHP_SELF"].
"?id=".
$object->id, $langs->trans(
"DeleteAProject"), $text,
"confirm_delete",
'',
'', 1);
1004 if ($action ==
'clone') {
1005 $formquestion = array(
1006 'text' => $langs->trans(
"ConfirmClone"),
1007 0 => array(
'type' =>
'other',
'name' =>
'socid',
'label' => $langs->trans(
"SelectThirdParty"),
'value' => $form->select_company(
GETPOSTINT(
'socid') > 0 ?
GETPOSTINT(
'socid') :
$object->socid,
'socid',
'',
"None", 0, 0, null, 0,
'minwidth200 maxwidth250')),
1008 1 => array(
'type' =>
'checkbox',
'name' =>
'clone_contacts',
'label' => $langs->trans(
"CloneContacts"),
'value' => true),
1009 2 => array(
'type' =>
'checkbox',
'name' =>
'clone_tasks',
'label' => $langs->trans(
"CloneTasks"),
'value' => true),
1010 3 => array(
'type' =>
'checkbox',
'name' =>
'move_date',
'label' => $langs->trans(
"CloneMoveDate"),
'value' => true),
1011 4 => array(
'type' =>
'checkbox',
'name' =>
'clone_notes',
'label' => $langs->trans(
"CloneNotes"),
'value' => true),
1012 5 => array(
'type' =>
'checkbox',
'name' =>
'clone_project_files',
'label' => $langs->trans(
"CloneProjectFiles"),
'value' => false),
1013 6 => array(
'type' =>
'checkbox',
'name' =>
'clone_task_files',
'label' => $langs->trans(
"CloneTaskFiles"),
'value' => false)
1016 print $form->formconfirm($_SERVER[
"PHP_SELF"].
"?id=".
$object->id, $langs->trans(
"ToClone"), $langs->trans(
"ConfirmCloneProject"),
"confirm_clone", $formquestion,
'', 1, 400, 590);
1020 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
1021 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1022 print
'<input type="hidden" name="action" value="update">';
1023 print
'<input type="hidden" name="id" value="'.$object->id.
'">';
1024 print
'<input type="hidden" name="comefromclone" value="'.$comefromclone.
'">';
1028 if ($action ==
'edit' && $userWrite > 0) {
1031 print
'<table class="border centpercent">';
1035 print
'<tr><td class="titlefield fieldrequired">'.$langs->trans(
"Ref").
'</td>';
1036 print
'<td><input class="width200" name="ref" value="'.$suggestedref.
'">';
1037 print
' '.$form->textwithpicto(
'', $langs->trans(
"YouCanCompleteRef", $suggestedref));
1041 print
'<tr><td class="fieldrequired">'.$langs->trans(
"Label").
'</td>';
1042 print
'<td><input class="quatrevingtpercent" name="title" value="'.dol_escape_htmltag(
$object->title).
'"></td></tr>';
1045 print
'<tr><td class="fieldrequired">'.$langs->trans(
"Status").
'</td><td>';
1046 print
'<select class="flat" name="status" id="status">';
1047 $statuses =
$object->labelStatusShort;
1049 unset($statuses[$object::STATUS_DRAFT]);
1051 foreach ($statuses as $key => $val) {
1052 print
'<option value="'.$key.
'"'.((GETPOSTISSET(
'status') ?
GETPOST(
'status') :
$object->
statut) == $key ?
' selected="selected"' :
'').
'>'.$langs->trans($val).
'</option>';
1060 print
'<tr><td>'.$langs->trans(
"Parent").
'</td><td class="maxwidthonsmartphone">';
1061 print
img_picto(
'',
'project',
'class="pictofixedwidth"');
1062 $formproject->select_projects(-1,
$object->fk_project,
'fk_project', 64, 0, 1, 1, 0, 0, 0,
'', 0, 0,
'',
'',
'');
1068 print
'<tr><td class="tdtop">';
1069 print $langs->trans(
"Usage");
1073 print
'<input type="checkbox" id="usage_opportunity" name="usage_opportunity"'.(GETPOSTISSET(
'usage_opportunity') ? (
GETPOST(
'usage_opportunity',
'alpha') !=
'' ?
' checked="checked"' :
'') : (
$object->usage_opportunity ?
' checked="checked"' :
'')).
'> ';
1074 $htmltext = $langs->trans(
"ProjectFollowOpportunity");
1075 print
'<label for="usage_opportunity">'.$form->textwithpicto($langs->trans(
"ProjectFollowOpportunity"), $htmltext).
'</label>';
1077 print
'$( document ).ready(function() {
1078 jQuery("#usage_opportunity").change(function() {
1079 set_usage_opportunity();
1082 set_usage_opportunity();
1084 function set_usage_opportunity() {
1085 console.log("set_usage_opportunity");
1086 if (jQuery("#usage_opportunity").prop("checked")) {
1087 console.log("Show opportunities fields");
1088 jQuery(".classuseopportunity").show();
1090 console.log("Hide opportunities fields "+jQuery("#usage_opportunity").prop("checked"));
1091 jQuery(".classuseopportunity").hide();
1099 print
'<input type="checkbox" id="usage_task" name="usage_task"' . (GETPOSTISSET(
'usage_task') ? (
GETPOST(
'usage_task',
'alpha') !=
'' ?
' checked="checked"' :
'') : (
$object->usage_task ?
' checked="checked"' :
'')) .
'> ';
1100 $htmltext = $langs->trans(
"ProjectFollowTasks");
1101 print
'<label for="usage_task">'.$form->textwithpicto($langs->trans(
"ProjectFollowTasks"), $htmltext).
'</label>';
1103 print
'$( document ).ready(function() {
1104 jQuery("#usage_task").change(function() {
1110 function set_usage_task() {
1111 console.log("set_usage_task");
1112 if (jQuery("#usage_task").prop("checked")) {
1113 console.log("Show task fields");
1114 jQuery(".classusetask").show();
1116 console.log("Hide task fields "+jQuery("#usage_task").prop("checked"));
1117 jQuery(".classusetask").hide();
1125 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"' :
'')) .
'> ';
1126 $htmltext = $langs->trans(
"ProjectBillTimeDescription");
1127 print
'<label for="usage_bill_time">'.$form->textwithpicto($langs->trans(
"BillTime"), $htmltext).
'</label>';
1129 print
'$( document ).ready(function() {
1130 jQuery("#usage_bill_time").change(function() {
1131 set_usage_bill_time();
1134 set_usage_bill_time();
1136 function set_usage_bill_time() {
1137 console.log("set_usage_bill_time");
1138 if (jQuery("#usage_bill_time").prop("checked")) {
1139 console.log("Show bill time fields");
1140 jQuery(".classusebilltime").show();
1142 console.log("Hide bill time fields "+jQuery("#usage_bill_time").prop("checked"));
1143 jQuery(".classusebilltime").hide();
1150 if (isModEnabled(
'eventorganization')) {
1151 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"' :
'')) .
'> ';
1152 $htmltext = $langs->trans(
"EventOrganizationDescriptionLong");
1153 print
'<label for="usage_organize_event">'.$form->textwithpicto($langs->trans(
"ManageOrganizeEvent"), $htmltext).
'</label>';
1155 print
'$( document ).ready(function() {
1156 jQuery("#usage_organize_event").change(function() {
1162 function set_usage_event() {
1163 console.log("set_usage_event");
1164 if (jQuery("#usage_organize_event").prop("checked")) {
1165 console.log("Show organize event fields");
1166 jQuery(".classuseorganizeevent").show();
1168 console.log("Hide organize event fields "+jQuery("#usage_organize_event").prop("checked"));
1169 jQuery(".classuseorganizeevent").hide();
1180 if (isModEnabled(
'societe')) {
1182 print(!
getDolGlobalString(
'PROJECT_THIRDPARTY_REQUIRED') ?
'' :
'<span class="fieldrequired">');
1183 print $langs->trans(
"ThirdParty");
1190 $text =
img_picto(
'',
'company',
'class="pictofixedwidth"');
1191 $text .= $form->select_company(!empty(
$object->thirdparty->id) ?
$object->thirdparty->id :
"",
'socid', $filter,
'None', 1, 0, array(), 0,
'minwidth300');
1192 if (!
getDolGlobalString(
'PROJECT_CAN_ALWAYS_LINK_TO_ALL_SUPPLIERS') && empty($conf->dol_use_jmobile)) {
1193 $texthelp = $langs->trans(
"IfNeedToUseOtherObjectKeepEmpty");
1194 print $form->textwithtooltip($text.
' '.
img_help(), $texthelp, 1, 0,
'',
'', 2);
1202 print
'<tr><td>'.$langs->trans(
"Visibility").
'</td><td>';
1205 $array[0] = $langs->trans(
"PrivateProject");
1208 $array[1] = $langs->trans(
"SharedProject");
1211 if (count($array) > 0) {
1212 print $form->selectarray(
'public', $array,
$object->public, 0, 0, 0,
'', 0, 0, 0,
'',
'', 1);
1214 print
'<input type="hidden" id="public" name="public" value="'.$object->public.
'">';
1217 print
img_picto($langs->trans(
'PrivateProject'),
'private',
'class="paddingrightonly"');
1218 print $langs->trans(
"PrivateProject");
1220 print
img_picto($langs->trans(
'SharedProject'),
'world',
'class="paddingrightonly"');
1221 print $langs->trans(
"SharedProject");
1227 $classfortr = (
$object->usage_opportunity ?
'' :
' hideobject');
1229 print
'<tr class="classuseopportunity'.$classfortr.
'"><td>'.$langs->trans(
"OpportunityStatus").
'</td>';
1232 print $formproject->selectOpportunityStatus(
'opp_status',
$object->opp_status, 1, 0, 0, 0,
'minwidth150 inline-block valignmiddle', 1, 1);
1235 print
' <input class="width50 right" type="text" id="opp_percent" name="opp_percent" title="'.dol_escape_htmltag($langs->trans(
"OpportunityProbability")).
'" value="'.(GETPOSTISSET(
'opp_percent') ?
GETPOST(
'opp_percent') : (strcmp(
$object->opp_percent,
'') ?
vatrate(
$object->opp_percent) :
'')).
'"> %';
1236 print
'<span id="oldopppercent" class="opacitymedium"></span>';
1239 print
'<div id="divtocloseproject" class="inline-block valign clearboth paddingtop" style="display: none;">';
1240 print
'<input type="checkbox" id="inputcloseproject" name="closeproject" />';
1241 print
'<label for="inputcloseproject">';
1242 print $form->textwithpicto($langs->trans(
"AlsoCloseAProject"), $langs->trans(
"AlsoCloseAProjectTooltip")).
'</label>';
1249 print
'<tr class="classuseopportunity'.$classfortr.
'"><td>'.$langs->trans(
"OpportunityAmount").
'</td>';
1250 print
'<td><input class="width75 right" type="text" name="opp_amount" value="'.(GETPOSTISSET(
'opp_amount') ?
GETPOST(
'opp_amount') : (strcmp(
$object->opp_amount,
'') ?
price2num(
$object->opp_amount) :
'')).
'">';
1251 print $langs->getCurrencySymbol($conf->currency);
1257 print
'<tr><td>'.$langs->trans(
"Budget").
'</td>';
1258 print
'<td><input class="width75 right" type="text" name="budget_amount" value="'.(GETPOSTISSET(
'budget_amount') ?
GETPOST(
'budget_amount') : (strcmp(
$object->budget_amount,
'') ?
price2num(
$object->budget_amount) :
'')).
'">';
1259 print $langs->getCurrencySymbol($conf->currency);
1264 print
'<tr><td>'.$langs->trans(
"Date").(isModEnabled(
'eventorganization') ?
' <span class="classuseorganizeevent">('.$langs->trans(
"Project").
')</span>' :
'').
'</td><td>';
1265 print $form->selectDate(
$object->date_start ?
$object->date_start : -1,
'projectstart', 0, 0, 0,
'', 1, 0);
1266 print
' <span class="opacitymedium"> '.$langs->trans(
"to").
' </span> ';
1267 print $form->selectDate(
$object->date_end ?
$object->date_end : -1,
'projectend', 0, 0, 0,
'', 1, 0);
1268 $object->getLinesArray(
null, 0);
1270 print
' <span id="divreportdate" class="hidden"> <input type="checkbox" class="valignmiddle" id="reportdate" name="reportdate" value="yes" ';
1271 if ($comefromclone) {
1274 print
'/><label for="reportdate" class="valignmiddle opacitymedium">'.$langs->trans(
"ProjectReportDate").
'</label></span>';
1278 if (isModEnabled(
'eventorganization')) {
1280 print
'<tr class="classuseorganizeevent"><td>'.$langs->trans(
"Date").
' ('.$langs->trans(
"Event").
')</td><td>';
1281 print $form->selectDate(($date_start_event ? $date_start_event : (
$object->date_start_event ?
$object->date_start_event : -1)),
'date_start_event', 1, 1, 1,
'', 1, 0);
1282 print
' <span class="opacitymedium"> '.$langs->trans(
"to").
' </span> ';
1283 print $form->selectDate(($date_end_event ? $date_end_event : (
$object->date_end_event ?
$object->date_end_event : -1)),
'date_end_event', 1, 1, 1,
'', 1, 0);
1287 print
'<tr class="classuseorganizeevent"><td>'.$langs->trans(
"Location").
'</td>';
1288 print
'<td><input class="minwidth300 maxwidth500" type="text" name="location" value="'.dol_escape_htmltag(GETPOSTISSET(
'location') ?
GETPOST(
'location') :
$object->location).
'"></td>';
1293 print
'<tr><td class="tdtop">'.$langs->trans(
"Description").
'</td>';
1295 $doleditor =
new DolEditor(
'description',
$object->description,
'', 90,
'dolibarr_notes',
'',
false,
true, isModEnabled(
'fckeditor') &&
getDolGlobalInt(
'FCKEDITOR_ENABLE_SOCIETE'), ROWS_3,
'90%');
1296 $doleditor->Create();
1300 if (isModEnabled(
'category')) {
1301 $arrayselected = array();
1302 print
'<tr><td>'.$langs->trans(
"Categories").
'</td><td>';
1303 $cate_arbo = $form->select_all_categories(Categorie::TYPE_PROJECT,
'',
'parent', 64, 0, 3);
1305 $cats = $c->containing(
$object->id, Categorie::TYPE_PROJECT);
1306 foreach ($cats as $cat) {
1307 $arrayselected[] = $cat->id;
1309 print
img_picto(
'',
'category',
'class="pictofixedwidth"').$form->multiselectarray(
'categories', $cate_arbo, $arrayselected, 0, 0,
'quatrevingtpercent widthcentpercentminusx', 0,
'0');
1314 $parameters = array();
1315 $reshook = $hookmanager->executeHooks(
'formObjectOptions', $parameters,
$object, $action);
1316 print $hookmanager->resPrint;
1317 if (empty($reshook)) {
1318 print
$object->showOptionals($extrafields,
'edit');
1327 if (!empty($_SESSION[
'pageforbacktolist']) && !empty($_SESSION[
'pageforbacktolist'][
'project'])) {
1328 $tmpurl = $_SESSION[
'pageforbacktolist'][
'project'];
1329 $tmpurl = preg_replace(
'/__SOCID__/', (
string)
$object->socid, $tmpurl);
1330 $linkback =
'<a href="'.$tmpurl.(preg_match(
'/\?/', $tmpurl) ?
'&' :
'?').
'restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
1332 $linkback =
'<a href="'.DOL_URL_ROOT.
'/projet/list.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
1335 $morehtmlref =
'<div class="refidno">';
1338 $morehtmlref .=
'<br>';
1340 if (!empty(
$object->thirdparty->id) &&
$object->thirdparty->id > 0) {
1341 $morehtmlref .=
$object->thirdparty->getNomUrl(1,
'project');
1347 $parent->fetch(
$object->fk_project);
1348 $morehtmlref .= $langs->trans(
"Child of").
' '.$parent->getNomUrl(1,
'project').
' '.$parent->title;
1351 $morehtmlref .=
'</div>';
1354 if (!$user->hasRight(
'projet',
'all',
'lire')) {
1355 $objectsListId =
$object->getProjectsAuthorizedForUser($user, 0, 0);
1356 $object->next_prev_filter =
"rowid IN (".$db->sanitize(count($objectsListId) ? implode(
',', array_keys($objectsListId)) :
'0').
")";
1359 dol_banner_tab(
$object,
'ref', $linkback, 1,
'ref',
'ref', $morehtmlref);
1361 print
'<div class="fichecenter">';
1362 print
'<div class="fichehalfleft">';
1363 print
'<div class="underbanner clearboth"></div>';
1365 print
'<table class="border tableforfield centpercent">';
1369 print
'<tr><td class="tdtop">';
1370 print $langs->trans(
"Usage");
1374 print
'<input type="checkbox" disabled name="usage_opportunity"'.(GETPOSTISSET(
'usage_opportunity') ? (
GETPOST(
'usage_opportunity',
'alpha') !=
'' ?
' checked="checked"' :
'') : (
$object->usage_opportunity ?
' checked="checked"' :
'')).
'> ';
1375 $htmltext = $langs->trans(
"ProjectFollowOpportunity");
1376 print $form->textwithpicto($langs->trans(
"ProjectFollowOpportunity"), $htmltext);
1380 print
'<input type="checkbox" disabled name="usage_task"'.(GETPOSTISSET(
'usage_task') ? (
GETPOST(
'usage_task',
'alpha') !=
'' ?
' checked="checked"' :
'') : (
$object->usage_task ?
' checked="checked"' :
'')).
'> ';
1381 $htmltext = $langs->trans(
"ProjectFollowTasks");
1382 print $form->textwithpicto($langs->trans(
"ProjectFollowTasks"), $htmltext);
1386 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"' :
'')).
'> ';
1387 $htmltext = $langs->trans(
"ProjectBillTimeDescription");
1388 print $form->textwithpicto($langs->trans(
"BillTime"), $htmltext);
1392 if (isModEnabled(
'eventorganization')) {
1393 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"' :
'')).
'> ';
1394 $htmltext = $langs->trans(
"EventOrganizationDescriptionLong");
1395 print $form->textwithpicto($langs->trans(
"ManageOrganizeEvent"), $htmltext);
1401 print
'<tr><td class="titlefield">'.$langs->trans(
"Visibility").
'</td><td>';
1403 print
img_picto($langs->trans(
'SharedProject'),
'world',
'class="paddingrightonly"');
1404 print $langs->trans(
'SharedProject');
1406 print
img_picto($langs->trans(
'PrivateProject'),
'private',
'class="paddingrightonly"');
1407 print $langs->trans(
'PrivateProject');
1413 print
'<tr><td>'.$langs->trans(
"OpportunityStatus");
1414 if ($action !=
'edit_opp_status' && $user->hasRight(
'projet',
'creer')) {
1415 print
'<a class="editfielda paddingtop" href="'.$_SERVER[
"PHP_SELF"].
'?action=edit_opp_status&token='.
newToken().
'&id='.
$object->id.
'">'.
img_edit($langs->transnoentitiesnoconv(
'Edit'), 1).
'</a>';
1418 $html_name_status = ($action ==
'edit_opp_status') ?
'opp_status' :
'none';
1419 $html_name_percent = ($action ==
'edit_opp_status') ?
'opp_percent' :
'none';
1420 $percent_value = (GETPOSTISSET(
'opp_percent') ?
GETPOST(
'opp_percent') : (strcmp(
$object->opp_percent,
'') ?
vatrate(
$object->opp_percent) :
''));
1421 $formproject->formOpportunityStatus($_SERVER[
'PHP_SELF'].
'?socid='.
$object->id,
$object->opp_status, $percent_value, $html_name_status, $html_name_percent);
1425 print
'<tr><td>'.$langs->trans(
"OpportunityAmount").
'</td><td>';
1426 if (strcmp(
$object->opp_amount,
'')) {
1427 print
'<span class="amount">'.price(
$object->opp_amount, 0, $langs, 1, 0, -1, $conf->currency).
'</span>';
1428 if (strcmp(
$object->opp_percent,
'')) {
1429 print
' <span title="'.dol_escape_htmltag($langs->trans(
'OpportunityWeightedAmount')).
'"><span class="opacitymedium">'.$langs->trans(
"OpportunityWeightedAmountShort").
'</span>: <span class="amount">'.
price(
$object->opp_amount *
$object->opp_percent / 100, 0, $langs, 1, 0, -1, $conf->currency).
'</span></span>';
1436 print
'<tr><td>'.$langs->trans(
"Budget").
'</td><td>';
1437 if (!is_null(
$object->budget_amount) && strcmp(
$object->budget_amount,
'')) {
1438 print
'<span class="amount">'.price(
$object->budget_amount, 0, $langs, 1, 0, 0, $conf->currency).
'</span>';
1443 print
'<tr><td>'.$langs->trans(
"Dates").
'</td><td>';
1445 print($start ? $start :
'?');
1447 print
' <span class="opacitymedium">-</span> ';
1448 print($end ? $end :
'?');
1456 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_view.tpl.php';
1461 print
'<div class="fichehalfright">';
1462 print
'<div class="underbanner clearboth"></div>';
1464 print
'<table class="border tableforfield centpercent">';
1467 print
'<td class="titlefield tdtop">'.$langs->trans(
"Description").
'</td><td>';
1468 print
'<div class="longmessagecut">';
1474 if (isModEnabled(
'category')) {
1475 print
'<tr><td class="valignmiddle">'.$langs->trans(
"Categories").
'</td><td>';
1476 print $form->showCategories(
$object->id, Categorie::TYPE_PROJECT, 1);
1485 print
'<div class="clearboth"></div>';
1490 if ($action ==
'edit' && $userWrite > 0) {
1491 print $form->buttonsSaveCancel();
1497 print
'<script type="text/javascript">
1498 jQuery(document).ready(function() {
1499 jQuery("#usage_task").change(function() {
1500 console.log("We click on usage task "+jQuery("#usage_task").is(":checked"));
1501 if (! jQuery("#usage_task").is(":checked")) {
1502 jQuery("#usage_bill_time").prop("checked", false);
1506 jQuery("#usage_bill_time").change(function() {
1507 console.log("We click on usage to bill time");
1508 if (jQuery("#usage_bill_time").is(":checked")) {
1509 jQuery("#usage_task").prop("checked", true);
1513 jQuery("#projectstart").change(function() {
1514 console.log("We modify the start date");
1515 jQuery("#divreportdate").show();
1521 if (!empty($conf->use_javascript_ajax) &&
getDolGlobalString(
'PROJECT_USE_OPPORTUNITIES')) {
1523 $defaultcheckedwhenoppclose = 1;
1525 $defaultcheckedwhenoppclose = 0;
1528 print
'<!-- Javascript to manage opportunity status change -->';
1529 print
'<script type="text/javascript">
1530 jQuery(document).ready(function() {
1531 function change_percent()
1533 var element = jQuery("#opp_status option:selected");
1534 var defaultpercent = element.attr("defaultpercent");
1535 var defaultcloseproject = '.((int) $defaultcheckedwhenoppclose).
';
1536 var elemcode = element.attr("elemcode");
1539 console.log(
"We select "+elemcode);
1542 var closeproject = 0;
1543 if (elemcode == \
'LOST\') closeproject = 1;
1544 if (elemcode == \'WON\') closeproject = defaultcloseproject;
1545 if (closeproject) jQuery("#inputcloseproject").prop("checked", true);
1546 else jQuery("#inputcloseproject").prop("checked", false);
1548 /* Make the close project checkbox visible or not */
1549 console.log("closeproject="+closeproject);
1550 if (elemcode == \'WON\' || elemcode == \'LOST\')
1552 jQuery("#divtocloseproject").show();
1556 jQuery("#divtocloseproject").hide();
1559 /* Change percent with default percent (defaultpercent) if new status (defaultpercent) is higher than current (jQuery("#opp_percent").val()) */
1560 if (oldpercent != \'\' && (parseFloat(defaultpercent) < parseFloat(oldpercent)))
1562 console.log("oldpercent="+oldpercent+" defaultpercent="+defaultpercent+" def < old");
1563 if (jQuery("#opp_percent").val() != \'\' && oldpercent != \'\') {
1564 jQuery("#oldopppercent").text(\' - '.
dol_escape_js($langs->transnoentities(
"PreviousValue")).
': \'+price2numjs(oldpercent)+\' %\');
1567 if (parseFloat(oldpercent) != 100 && elemcode != \'LOST\') { jQuery("#opp_percent").val(oldpercent); }
1568 else { jQuery("#opp_percent").val(price2numjs(defaultpercent)); }
1570 console.log("oldpercent="+oldpercent+" defaultpercent="+defaultpercent);
1571 if (jQuery("#opp_percent").val() == \'\' || (parseFloat(jQuery("#opp_percent").val()) < parseFloat(defaultpercent))) {
1572 if (jQuery("#opp_percent").val() != \'\' && oldpercent != \'\') {
1573 jQuery("#oldopppercent").text(\' - '.
dol_escape_js($langs->transnoentities(
"PreviousValue")).
': \'+price2numjs(oldpercent)+\' %\');
1575 jQuery("#opp_percent").val(price2numjs(defaultpercent));
1580 jQuery("#opp_status").change(function() {
1592 print
'<div class="tabsAction">';
1593 $parameters = array();
1594 $reshook = $hookmanager->executeHooks(
'addMoreActionsButtons', $parameters,
$object, $action);
1596 if (empty($reshook)) {
1597 if ($action !=
"edit" && $action !=
'presend') {
1607 if (empty($user->socid)) {
1609 print
dolGetButtonAction(
'', $langs->trans(
'SendMail'),
'default', $_SERVER[
"PHP_SELF"].
'?action=presend&token='.
newToken().
'&id='.
$object->id.
'&mode=init#formmailbeforetitle',
'');
1629 if ($userWrite > 0) {
1630 print
dolGetButtonAction(
'', $langs->trans(
'SetToDraft'),
'default', $_SERVER[
"PHP_SELF"].
'?action=confirm_setdraft&confirm=yes&token='.
newToken().
'&id='.
$object->id,
'');
1632 print
dolGetButtonAction($langs->trans(
'NotOwnerOfProject'), $langs->trans(
'SetToDraft'),
'default', $_SERVER[
'PHP_SELF'].
'#',
'',
false);
1639 if ($userWrite > 0) {
1642 print
dolGetButtonAction($langs->trans(
'NotOwnerOfProject'), $langs->trans(
'Modify'),
'default', $_SERVER[
'PHP_SELF'].
'#',
'',
false);
1648 if ($userWrite > 0) {
1651 print
dolGetButtonAction($langs->trans(
'NotOwnerOfProject'), $langs->trans(
'Validate'),
'default', $_SERVER[
'PHP_SELF'].
'#',
'',
false);
1657 if ($userWrite > 0) {
1660 print
dolGetButtonAction($langs->trans(
'NotOwnerOfProject'), $langs->trans(
'Close'),
'default', $_SERVER[
'PHP_SELF'].
'#',
'',
false);
1666 if ($userWrite > 0) {
1669 print
dolGetButtonAction($langs->trans(
'NotOwnerOfProject'), $langs->trans(
'ReOpen'),
'default', $_SERVER[
'PHP_SELF'].
'#',
'',
false);
1677 $is_customer_or_prospect = (!empty(
$object->thirdparty->prospect) || !empty(
$object->thirdparty->client));
1678 $is_supplier_only= (!empty(
$object->thirdparty->fournisseur) && $is_customer_or_prospect ==
false);
1680 $arrayforbutaction = array(
1681 10 => array(
'lang'=>
'propal',
'enabled'=>(isModEnabled(
"propal") && $is_customer_or_prospect ==
true),
'perm'=>$user->hasRight(
'propal',
'creer'),
'label' =>
'AddProp',
'url'=>
'/comm/propal/card.php?action=create&projectid='.$object->id.
'&socid='.
$object->socid),
1682 20 => array(
'lang'=>
'orders',
'enabled'=>(isModEnabled(
"order") && $is_customer_or_prospect ==
true),
'perm'=>$user->hasRight(
'commande',
'creer'),
'label' =>
'CreateOrder',
'url'=>
'/commande/card.php?action=create&projectid='.$object->id.
'&socid='.
$object->socid),
1683 30 => array(
'lang'=>
'bills',
'enabled'=>(isModEnabled(
"invoice") && $is_customer_or_prospect ==
true),
'perm'=>$user->hasRight(
'facture',
'creer'),
'label' =>
'CreateBill',
'url'=>
'/compta/facture/card.php?action=create&projectid='.$object->id.
'&socid='.
$object->socid),
1684 40 => array(
'lang'=>
'supplier_proposal',
'enabled'=>isModEnabled(
"supplier_proposal"),
'perm'=>$user->hasRight(
'supplier_proposal',
'creer'),
'label' =>
'AddSupplierProposal',
'url'=>
'/supplier_proposal/card.php?action=create&projectid='.$object->id.($is_supplier_only ==
true ?
'&socid='.$object->socid :
'')),
1685 50 => array(
'lang'=>
'suppliers',
'enabled'=>isModEnabled(
"supplier_order"),
'perm'=>$user->hasRight(
'fournisseur',
'commande',
'creer'),
'label' =>
'AddSupplierOrder',
'url'=>
'/fourn/commande/card.php?action=create&projectid='.
$object->id.($is_supplier_only == true ?
'&socid='.
$object->socid :
'')),
1686 60 => array(
'lang'=>
'suppliers',
'enabled'=>isModEnabled(
"supplier_invoice"),
'perm'=>$user->hasRight(
'fournisseur',
'facture',
'creer'),
'label' =>
'AddSupplierInvoice',
'url'=>
'/fourn/facture/card.php?action=create&projectid='.
$object->id.($is_supplier_only == true ?
'&socid='.
$object->socid :
'')),
1687 70 => array(
'lang'=>
'interventions',
'enabled'=>isModEnabled(
"intervention"),
'perm'=>$user->hasRight(
'fichinter',
'creer'),
'label' =>
'AddIntervention',
'url'=>
'/fichinter/card.php?action=create&projectid='.
$object->id.
'&socid='.
$object->socid),
1688 80 => array(
'lang'=>
'contracts',
'enabled'=>isModEnabled(
"contract"),
'perm'=>$user->hasRight(
'contrat',
'creer'),
'label' =>
'AddContract',
'url'=>
'/contrat/card.php?action=create&projectid='.
$object->id.
'&socid='.
$object->socid),
1689 90 => array(
'lang'=>
'trips',
'enabled'=>isModEnabled(
"expensereport"),
'perm'=>$user->hasRight(
'expensereport',
'creer'),
'label' =>
'AddTrip',
'url'=>
'/expensereport/card.php?action=create&projectid='.
$object->id.
'&socid='.
$object->socid),
1690 100 => array(
'lang'=>
'donations',
'enabled'=>isModEnabled(
"don"),
'perm'=>$user->hasRight(
'don',
'creer'),
'label' =>
'AddDonation',
'url'=>
'/don/card.php?action=create&projectid='.
$object->id.
'&socid='.
$object->socid),
1693 $params = array(
'backtopage' => $_SERVER[
"PHP_SELF"].
'?id='.
$object->id);
1696 print
dolGetButtonAction(
'', $langs->trans(
"Create"),
'default', $arrayforbutaction,
'', 1, $params);
1700 if ($user->hasRight(
'projet',
'creer')) {
1701 if ($userWrite > 0) {
1704 print
dolGetButtonAction($langs->trans(
'NotOwnerOfProject'), $langs->trans(
'ToClone'),
'default', $_SERVER[
'PHP_SELF'].
'#',
'',
false);
1713 print
dolGetButtonAction($langs->trans(
'NotOwnerOfProject'), $langs->trans(
'Delete'),
'default', $_SERVER[
'PHP_SELF'].
'#',
'',
false);
1721 if (
GETPOST(
'modelselected')) {
1722 $action =
'presend';
1725 if ($action !=
'presend') {
1726 print
'<div class="fichecenter"><div class="fichehalfleft">';
1727 print
'<a name="builddoc"></a>';
1733 $children =
$object->getChildren();
1735 print
'<table class="centpercent notopnoleftnoright table-fiche-title">';
1736 print
'<tr class="titre"><td class="nobordernopadding valignmiddle col-title">';
1737 print
'<div class="titre inline-block">'.$langs->trans(
'Sub-projects').
'</div>';
1738 print
'</td></tr></table>';
1740 print
'<div class="div-table-responsive-no-min">';
1741 print
'<table class="centpercent noborder'.($morecss ?
' '.$morecss :
'').
'">';
1742 print
'<tr class="liste_titre">';
1743 print
getTitleFieldOfList(
'Ref', 0, $_SERVER[
"PHP_SELF"],
'',
'',
'',
'',
'',
'',
'', 1);
1744 print
getTitleFieldOfList(
'Title', 0, $_SERVER[
"PHP_SELF"],
'',
'',
'',
'',
'',
'',
'', 1);
1745 print
getTitleFieldOfList(
'Status', 0, $_SERVER[
"PHP_SELF"],
'',
'',
'',
'',
'',
'',
'', 1);
1749 $subproject =
new Project($db);
1750 foreach ($children as $child) {
1751 $subproject->fetch($child->rowid);
1752 print
'<tr class="oddeven">';
1753 print
'<td class="nowraponall">'.$subproject->getNomUrl(1,
'project').
'</td>';
1754 print
'<td class="nowraponall tdoverflowmax125">'.$child->title.
'</td>';
1755 print
'<td class="nowraponall">'.$subproject->getLibStatut(5).
'</td>';
1769 $urlsource = $_SERVER[
"PHP_SELF"].
"?id=".
$object->id;
1770 $genallowed = ($user->hasRight(
'projet',
'lire') && $userAccess > 0);
1771 $delallowed = ($user->hasRight(
'projet',
'creer') && $userWrite > 0);
1773 print $formfile->showdocuments(
'project', $filename, $filedir, $urlsource, $genallowed, $delallowed,
$object->model_pdf, 1, 0, 0, 0, 0,
'',
'',
'',
'',
'',
$object);
1775 print
'</div><div class="fichehalfright">';
1779 $morehtmlcenter =
'<div class="nowraponall">';
1780 $morehtmlcenter .=
dolGetButtonTitle($langs->trans(
'FullConversation'),
'',
'fa fa-comments imgforviewmode', DOL_URL_ROOT.
'/projet/messaging.php?id='.
$object->id);
1781 $morehtmlcenter .=
dolGetButtonTitle($langs->trans(
'FullList'),
'',
'fa fa-bars imgforviewmode', DOL_URL_ROOT.
'/projet/agenda.php?id='.
$object->id);
1782 $morehtmlcenter .=
'</div>';
1785 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formactions.class.php';
1787 $somethingshown = $formactions->showactions(
$object,
'project', 0, 1,
'', $MAXEVENT,
'', $morehtmlcenter);
1789 print
'</div></div>';
1793 $modelmail =
'project';
1794 $defaulttopic =
'SendProjectRef';
1795 $defaulttopiclang =
'projects';
1796 $diroutput = $conf->project->multidir_output[
$object->entity];
1797 $autocopy =
'MAIN_MAIL_AUTOCOPY_PROJECT_TO';
1798 $trackid =
'proj'.$object->id;
1800 include DOL_DOCUMENT_ROOT.
'/core/tpl/card_presend.tpl.php';
1803 $parameters = array();
1804 $reshook = $hookmanager->executeHooks(
'mainCardTabAddMore', $parameters,
$object, $action);
1806 print $langs->trans(
"RecordNotFound");
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
ajax_combobox($htmlname, $events=array(), $minLengthToAutocomplete=0, $forcefocus=0, $widthTypeOfAutocomplete='resolve', $idforemptyvalue='-1', $morecss='')
Convert a html select field into an ajax combobox.
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader()
Empty header.
Class to manage categories.
Class to manage a WYSIWYG editor.
Class to manage projects.
const STATUS_VALIDATED
Open/Validated status.
const STATUS_CLOSED
Closed status.
const STATUS_DRAFT
Draft status.
Class to manage third parties objects (customers, suppliers, prospects...)
Class to manage translations.
Class to manage Dolibarr users.
dol_delete_file($file, $disableglob=0, $nophperrors=0, $nohook=0, $object=null, $allowdotdot=false, $indexdatabase=1, $nolog=0)
Remove a file or several files with a mask.
dol_mktime($hour, $minute, $second, $month, $day, $year, $gm='auto', $check=1)
Return a timestamp date built from detailed information (by default a local PHP server timestamp) Rep...
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
vatrate($rate, $addpercent=false, $info_bits=0, $usestarfornpr=0, $html=0)
Return a string with VAT rate label formatted for view output Used into pdf and HTML pages.
img_help($usehelpcursor=1, $usealttitle=1)
Show help logo with cursor "?".
img_warning($titlealt='default', $moreatt='', $morecss='pictowarning')
Show warning logo.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0)
Show tabs of a record.
dolPrintHTML($s, $allowiframe=0)
Return a string (that can be on several lines) ready to be output on a HTML page.
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
dolGetButtonTitle($label, $helpText='', $iconClass='fa fa-file', $url='', $id='', $status=1, $params=array())
Function dolGetButtonTitle : this kind of buttons are used in title in list.
dolButtonToOpenUrlInDialogPopup($name, $label, $buttonstring, $url, $disabled='', $morecss='classlink button bordertransp', $jsonopen='', $backtopagejsfields='', $accesskey='')
Return HTML code to output a button to open a dialog popup box.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
setEventMessage($mesgs, $style='mesgs', $noduplicate=0)
Set event message in dol_events session object.
price($amount, $form=0, $outlangs='', $trunc=1, $rounding=-1, $forcerounding=-1, $currency_code='')
Function to format a value into an amount for visual output Function used into PDF and HTML pages.
dol_now($mode='auto')
Return date for now.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
dol_escape_js($stringtoescape, $mode=0, $noescapebackslashn=0)
Returns text escaped for inclusion into javascript code.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
if(!function_exists( 'dol_getprefix')) dol_include_once($relpath, $classname='')
Make an include_once using default root and alternate root if it fails.
newToken()
Return the value of token currently saved into session with name 'newtoken'.
dol_clone($object, $native=0)
Create a clone of instance of object (new instance with same value for each properties) With native =...
dolGetButtonAction($label, $text='', $actionType='default', $url='', $id='', $userRight=1, $params=array())
Function dolGetButtonAction.
getTitleFieldOfList($name, $thead=0, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $disablesortlink=0, $tooltip='', $forcenowrapcolumntitle=0)
Get title line of an array.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
GETPOSTFLOAT($paramname, $rounding='')
Return the value of a $_GET or $_POST supervariable, converted into float.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0)
Set event messages in dol_events session object.
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
dol_sanitizeFileName($str, $newstr='_', $unaccent=1)
Clean a string to use it as a file name.
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
img_edit($titlealt='default', $float=0, $other='')
Show logo edit/modify fiche.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
Returns text escaped for inclusion in HTML alt or title or value tags, or into values of HTML input f...
project_prepare_head(Project $project, $moreparam='')
Prepare array with list of tabs.
restrictedArea(User $user, $features, $object=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $isdraft=0, $mode=0)
Check permissions of a user to show a page and an object.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.
publicphonebutton2 phonegreen basiclayout basiclayout TotalHT VATCode TotalVAT TotalLT1 TotalLT2 TotalTTC TotalHT clearboth nowraponall TAKEPOS_SHOW_SUBPRICE right right right takeposterminal SELECT e e e e e statut