26 require
'../main.inc.php';
27 require_once DOL_DOCUMENT_ROOT.
'/projet/class/project.class.php';
28 require_once DOL_DOCUMENT_ROOT.
'/projet/class/task.class.php';
29 require_once DOL_DOCUMENT_ROOT.
'/core/lib/project.lib.php';
30 require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
31 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formprojet.class.php';
32 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
33 require_once DOL_DOCUMENT_ROOT.
'/core/modules/project/modules_project.php';
34 require_once DOL_DOCUMENT_ROOT.
'/core/class/extrafields.class.php';
35 require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
38 $langsLoad=array(
'projects',
'companies');
39 if (!empty($conf->eventorganization->enabled)) {
40 $langsLoad[]=
'eventorganization';
43 $langs->loadLangs($langsLoad);
47 $action =
GETPOST(
'action',
'aZ09');
48 $backtopage =
GETPOST(
'backtopage',
'alpha');
49 $backtopageforcancel =
GETPOST(
'backtopageforcancel',
'alpha');
50 $backtopagejsfields =
GETPOST(
'backtopagejsfields',
'alpha');
51 $cancel =
GETPOST(
'cancel',
'alpha');
52 $confirm =
GETPOST(
'confirm',
'aZ09');
53 $dol_openinpopup =
GETPOST(
'dol_openinpopup',
'aZ09');
55 $status =
GETPOST(
'status',
'int');
56 $opp_status =
GETPOST(
'opp_status',
'int');
58 $objcanvas =
GETPOST(
"objcanvas",
"alpha");
59 $comefromclone =
GETPOST(
"comefromclone",
"alpha");
61 if ($id ==
'' && $ref ==
'' && ($action !=
"create" && $action !=
"add" && $action !=
"update" && !
GETPOST(
"cancel"))) {
65 $mine =
GETPOST(
'mode') ==
'mine' ? 1 : 0;
69 $hookmanager->initHooks(array(
'projectcard',
'globalcard'));
76 if ($id > 0 || !empty($ref)) {
77 $ret = $object->fetch($id, $ref);
79 $object->fetch_thirdparty();
80 if (!empty($conf->global->PROJECT_ALLOW_COMMENT_ON_PROJECT) && method_exists($object,
'fetchComments') && empty($object->comments)) {
81 $object->fetchComments();
88 $extrafields->fetch_name_optionals_label($object->table_element);
94 $socid =
GETPOST(
'socid',
'int');
98 $permissiondellink = $user->rights->projet->creer;
105 $parameters = array(
'id'=>$socid,
'objcanvas'=>$objcanvas);
106 $reshook = $hookmanager->executeHooks(
'doActions',
$parameters, $object, $action);
111 if (empty($reshook)) {
112 $backurlforlist = DOL_URL_ROOT.
'/projet/list.php';
116 if (
GETPOST(
"comefromclone") == 1) {
117 $result = $object->delete($user);
119 header(
"Location: index.php");
123 setEventMessages($langs->trans(
"CantRemoveProject", $langs->transnoentitiesnoconv(
"ProjectOverview")),
null,
'errors');
128 if (empty($backtopage) || ($cancel && empty($id))) {
129 if (empty($backtopage) || ($cancel && strpos($backtopage,
'__ID__'))) {
130 if (empty($id) && (($action !=
'add' && $action !=
'create') || $cancel)) {
131 $backtopage = $backurlforlist;
133 $backtopage = DOL_URL_ROOT.
'/projet/card.php?id='.((!empty($id) && $id > 0) ? $id :
'__ID__');
139 if (!empty($backtopageforcancel)) {
140 header(
"Location: ".$backtopageforcancel);
142 } elseif (!empty($backtopage)) {
143 header(
"Location: ".$backtopage);
149 include DOL_DOCUMENT_ROOT.
'/core/actions_dellink.inc.php';
151 if ($action ==
'add' && $user->rights->projet->creer) {
154 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"Ref")),
null,
'errors');
158 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"ProjectLabel")),
null,
'errors');
162 if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES)) {
163 if (
GETPOST(
'opp_amount') !=
'' && !(
GETPOST(
'opp_status') > 0)) {
165 setEventMessages($langs->trans(
"ErrorOppStatusRequiredIfAmount"),
null,
'errors');
170 if (!empty($conf->global->PROJECT_CREATE_NO_DRAFT)) {
179 $object->ref =
GETPOST(
'ref',
'alphanohtml');
180 $object->title =
GETPOST(
'title',
'alphanohtml');
181 $object->socid =
GETPOST(
'socid',
'int');
182 $object->description =
GETPOST(
'description',
'restricthtml');
183 $object->public =
GETPOST(
'public',
'alphanohtml');
185 $object->budget_amount =
price2num(
GETPOST(
'budget_amount',
'alphanohtml'));
187 $object->date_start = $date_start;
188 $object->date_end = $date_end;
189 $object->statut = $status;
190 $object->opp_status = $opp_status;
191 $object->opp_percent = $opp_percent;
192 $object->usage_opportunity = (
GETPOST(
'usage_opportunity',
'alpha') ==
'on' ? 1 : 0);
193 $object->usage_task = (
GETPOST(
'usage_task',
'alpha') ==
'on' ? 1 : 0);
194 $object->usage_bill_time = (
GETPOST(
'usage_bill_time',
'alpha') ==
'on' ? 1 : 0);
195 $object->usage_organize_event = (
GETPOST(
'usage_organize_event',
'alpha') ==
'on' ? 1 : 0);
198 $ret = $extrafields->setOptionalsFromPost(
null, $object);
203 $result = $object->create($user);
204 if (!$error && $result > 0) {
206 $typeofcontact =
'PROJECTLEADER';
207 $result = $object->add_contact($user->id, $typeofcontact,
'internal');
213 } elseif ($result < 0) {
214 $langs->load(
"errors");
219 $langs->load(
"errors");
223 if (!$error && !empty($object->id) > 0) {
225 $categories =
GETPOST(
'categories',
'array');
226 $result = $object->setCategories($categories);
228 $langs->load(
"errors");
237 if (!empty($backtopage)) {
238 $backtopage = preg_replace(
'/--IDFORBACKTOPAGE--|__ID__/', $object->id, $backtopage);
239 $backtopage = $backtopage.
'&projectid='.$object->id;
240 header(
"Location: ".$backtopage);
243 header(
"Location:card.php?id=".$object->id);
248 unset($_POST[
"ref"]);
256 if ($action ==
'update' && empty(
GETPOST(
'cancel')) && $user->rights->projet->creer) {
261 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"Ref")),
null,
'errors');
265 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"ProjectLabel")),
null,
'errors');
271 $object->oldcopy = clone $object;
273 $old_start_date = $object->date_start;
275 $object->ref =
GETPOST(
'ref',
'alpha');
276 $object->title =
GETPOST(
'title',
'alphanohtml');
277 $object->statut =
GETPOST(
'status',
'int');
278 $object->socid =
GETPOST(
'socid',
'int');
279 $object->description =
GETPOST(
'description',
'restricthtml');
280 $object->public =
GETPOST(
'public',
'alpha');
281 $object->date_start = (!
GETPOST(
'projectstart')) ?
'' : $date_start;
282 $object->date_end = (!
GETPOST(
'projectend')) ?
'' : $date_end;
290 $object->opp_status = $opp_status;
293 $object->opp_percent = $opp_percent;
295 $object->usage_opportunity = (
GETPOST(
'usage_opportunity',
'alpha') ==
'on' ? 1 : 0);
296 $object->usage_task = (
GETPOST(
'usage_task',
'alpha') ==
'on' ? 1 : 0);
297 $object->usage_bill_time = (
GETPOST(
'usage_bill_time',
'alpha') ==
'on' ? 1 : 0);
298 $object->usage_organize_event = (
GETPOST(
'usage_organize_event',
'alpha') ==
'on' ? 1 : 0);
301 $ret = $extrafields->setOptionalsFromPost(
null, $object,
'@GETPOSTISSET');
307 if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES)) {
308 if ($object->opp_amount && ($object->opp_status <= 0)) {
310 setEventMessages($langs->trans(
"ErrorOppStatusRequiredIfAmount"),
null,
'errors');
315 $result = $object->update($user);
325 $categories =
GETPOST(
'categories',
'array');
326 $result = $object->setCategories($categories);
335 if (
GETPOST(
"reportdate") && ($object->date_start != $old_start_date)) {
336 $result = $object->shiftTaskDate($old_start_date);
339 setEventMessages($langs->trans(
"ErrorShiftTaskDate").
':'.$object->error, $object->errors,
'errors');
346 $resclose = $object->setClose($user);
349 setEventMessages($langs->trans(
"FailedToCloseProject").
':'.$object->error, $object->errors,
'errors');
360 if (
GETPOST(
'socid',
'int') > 0) {
361 $object->fetch_thirdparty(
GETPOST(
'socid',
'int'));
363 unset($object->thirdparty);
369 if ($action ==
'builddoc' && $user->rights->projet->creer) {
372 $object->setDocModel($user,
GETPOST(
'model',
'alpha'));
375 $outputlangs = $langs;
376 if (
GETPOST(
'lang_id',
'aZ09')) {
378 $outputlangs->setDefaultLang(
GETPOST(
'lang_id',
'aZ09'));
380 $result = $object->generateDocument($object->model_pdf, $outputlangs);
388 if ($action ==
'remove_file' && $user->rights->projet->creer) {
389 if ($object->id > 0) {
390 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
392 $langs->load(
"other");
393 $upload_dir = $conf->project->multidir_output[$object->entity];
394 $file = $upload_dir.
'/'.
GETPOST(
'file');
406 if ($action ==
'confirm_validate' && $confirm ==
'yes') {
407 $result = $object->setValid($user);
413 if ($action ==
'confirm_close' && $confirm ==
'yes') {
414 $result = $object->setClose($user);
420 if ($action ==
'confirm_reopen' && $confirm ==
'yes') {
421 $result = $object->setValid($user);
427 if ($action ==
'confirm_delete' &&
GETPOST(
"confirm") ==
"yes" && $user->rights->projet->supprimer) {
429 $result = $object->delete($user);
432 header(
"Location: list.php?restore_lastsearch_values=1");
440 if ($action ==
'confirm_clone' && $user->rights->projet->creer && $confirm ==
'yes') {
441 $clone_contacts =
GETPOST(
'clone_contacts') ? 1 : 0;
442 $clone_tasks =
GETPOST(
'clone_tasks') ? 1 : 0;
443 $clone_project_files =
GETPOST(
'clone_project_files') ? 1 : 0;
444 $clone_task_files =
GETPOST(
'clone_task_files') ? 1 : 0;
445 $clone_notes =
GETPOST(
'clone_notes') ? 1 : 0;
446 $move_date =
GETPOST(
'move_date') ? 1 : 0;
447 $clone_thirdparty =
GETPOST(
'socid',
'int') ?
GETPOST(
'socid',
'int') : 0;
449 $result = $object->createFromClone($user, $object->id, $clone_contacts, $clone_tasks, $clone_project_files, $clone_task_files, $clone_notes, $move_date, 0, $clone_thirdparty);
455 $newobject->fetch($result);
456 $newobject->fetch_optionals();
457 $newobject->fetch_thirdparty();
458 $object = $newobject;
460 $comefromclone =
true;
465 $triggersendname =
'PROJECT_SENTBYMAIL';
467 $autocopy =
'MAIN_MAIL_AUTOCOPY_PROJECT_TO';
468 $trackid =
'proj'.$object->id;
469 include DOL_DOCUMENT_ROOT.
'/core/actions_sendmails.inc.php';
480 $userstatic =
new User($db);
482 $title = $langs->trans(
"Project").
' - '.$object->ref.(!empty($object->thirdparty->name) ?
' - '.$object->thirdparty->name :
'').(!empty($object->title) ?
' - '.$object->title :
'');
483 if (!empty($conf->global->MAIN_HTML_TITLE) && preg_match(
'/projectnameonly/', $conf->global->MAIN_HTML_TITLE)) {
484 $title = $object->ref.(!empty($object->thirdparty->name) ?
' - '.$object->thirdparty->name :
'').(!empty($object->title) ?
' - '.$object->title :
'');
486 $help_url =
"EN:Module_Projects|FR:Module_Projets|ES:Módulo_Proyectos|DE:Modul_Projekte";
490 $titleboth = $langs->trans(
"LeadsOrProjects");
491 $titlenew = $langs->trans(
"NewLeadOrProject");
493 $titleboth = $langs->trans(
"Projects");
494 $titlenew = $langs->trans(
"NewProject");
497 $titleboth = $langs->trans(
"Leads");
498 $titlenew = $langs->trans(
"NewLead");
501 if ($action ==
'create' && $user->rights->projet->creer) {
506 $thirdparty =
new Societe($db);
508 $thirdparty->fetch($socid);
513 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
514 print
'<input type="hidden" name="action" value="add">';
515 print
'<input type="hidden" name="token" value="'.newToken().
'">';
516 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
517 print
'<input type="hidden" name="backtopageforcancel" value="'.$backtopageforcancel.
'">';
518 print
'<input type="hidden" name="backtopagejsfields" value="'.$backtopagejsfields.
'">';
522 print
'<table class="border centpercent tableforfieldcreate">';
525 $modele = empty($conf->global->PROJECT_ADDON) ?
'mod_project_simple' : $conf->global->PROJECT_ADDON;
528 $file =
''; $classname =
''; $filefound = 0;
529 $dirmodels = array_merge(array(
'/'), (array) $conf->modules_parts[
'models']);
530 foreach ($dirmodels as $reldir) {
531 $file =
dol_buildpath($reldir.
"core/modules/project/".$modele.
'.php', 0);
532 if (file_exists($file)) {
534 $classname = $modele;
541 $modProject =
new $classname;
543 $defaultref = $modProject->getNextValue($thirdparty, $object);
546 if (is_numeric($defaultref) && $defaultref <= 0) {
552 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).
'">';
553 print
' '.$form->textwithpicto(
'', $langs->trans(
"YouCanCompleteRef", $suggestedref));
557 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>';
560 if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES) || empty($conf->global->PROJECT_HIDE_TASKS) || !empty($conf->eventorganization->enabled)) {
561 print
'<tr><td class="tdtop">';
562 print $langs->trans(
"Usage");
565 if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES)) {
566 print
'<input type="checkbox" id="usage_opportunity" name="usage_opportunity"'.(GETPOSTISSET(
'usage_opportunity') ? (
GETPOST(
'usage_opportunity',
'alpha') ?
' checked="checked"' :
'') :
' checked="checked"').
'"> ';
567 $htmltext = $langs->trans(
"ProjectFollowOpportunity");
568 print
'<label for="usage_opportunity">'.$form->textwithpicto($langs->trans(
"ProjectFollowOpportunity"), $htmltext).
'</label>';
570 print
'$( document ).ready(function() {
571 jQuery("#usage_opportunity").change(function() {
572 if (jQuery("#usage_opportunity").prop("checked")) {
573 console.log("Show opportunities fields");
574 jQuery(".classuseopportunity").show();
576 console.log("Hide opportunities fields "+jQuery("#usage_opportunity").prop("checked"));
577 jQuery(".classuseopportunity").hide();
582 print
'jQuery(".classuseopportunity").hide();';
588 if (empty($conf->global->PROJECT_HIDE_TASKS)) {
589 print
'<input type="checkbox" id="usage_task" name="usage_task"'.(GETPOSTISSET(
'usage_task') ? (
GETPOST(
'usage_task',
'alpha') ?
' checked="checked"' :
'') :
' checked="checked"').
'"> ';
590 $htmltext = $langs->trans(
"ProjectFollowTasks");
591 print
'<label for="usage_task">'.$form->textwithpicto($langs->trans(
"ProjectFollowTasks"), $htmltext).
'</label>';
594 if (empty($conf->global->PROJECT_HIDE_TASKS) && !empty($conf->global->PROJECT_BILL_TIME_SPENT)) {
595 print
'<input type="checkbox" id="usage_bill_time" name="usage_bill_time"'.(GETPOSTISSET(
'usage_bill_time') ? (
GETPOST(
'usage_bill_time',
'alpha') ?
' checked="checked"' :
'') :
'').
'"> ';
596 $htmltext = $langs->trans(
"ProjectBillTimeDescription");
597 print
'<label for="usage_bill_time">'.$form->textwithpicto($langs->trans(
"BillTime"), $htmltext).
'</label>';
600 if (!empty($conf->eventorganization->enabled)) {
601 print
'<input type="checkbox" id="usage_organize_event" name="usage_organize_event"'.(GETPOSTISSET(
'usage_organize_event') ? (
GETPOST(
'usage_organize_event',
'alpha') ?
' checked="checked"' :
'') :
'').
'"> ';
602 $htmltext = $langs->trans(
"EventOrganizationDescriptionLong");
603 print
'<label for="usage_organize_event">'.$form->textwithpicto($langs->trans(
"ManageOrganizeEvent"), $htmltext).
'</label>';
612 print (empty($conf->global->PROJECT_THIRDPARTY_REQUIRED) ?
'' :
'<span class="fieldrequired">');
613 print $langs->trans(
"ThirdParty");
614 print (empty($conf->global->PROJECT_THIRDPARTY_REQUIRED) ?
'' :
'</span>');
615 print
'</td><td class="maxwidthonsmartphone">';
617 if (!empty($conf->global->PROJECT_FILTER_FOR_THIRDPARTY_LIST)) {
618 $filteronlist = $conf->global->PROJECT_FILTER_FOR_THIRDPARTY_LIST;
620 $text =
img_picto(
'',
'company').$form->select_company(
GETPOST(
'socid',
'int'),
'socid', $filteronlist,
'SelectThirdParty', 1, 0, array(), 0,
'minwidth300 widthcentpercentminusxx maxwidth500');
621 if (empty($conf->global->PROJECT_CAN_ALWAYS_LINK_TO_ALL_SUPPLIERS) && empty($conf->dol_use_jmobile)) {
622 $texthelp = $langs->trans(
"IfNeedToUseOtherObjectKeepEmpty");
623 print
$form->textwithtooltip($text.
' '.
img_help(), $texthelp, 1);
628 $url =
'/societe/card.php?action=create&client=3&fournisseur=0&backtopage='.urlencode($_SERVER[
"PHP_SELF"].
'?action=create');
629 $newbutton =
'<span class="fa fa-plus-circle valignmiddle paddingleft" title="'.$langs->trans(
"AddThirdParty").
'"></span>';
632 $tmpbacktopagejsfields =
'addthirdparty:socid,search_socid';
633 print
dolButtonToOpenUrlInDialogPopup(
'addthirdparty', $langs->transnoentitiesnoconv(
'AddThirdParty'), $newbutton, $url,
'',
'', $tmpbacktopagejsfields);
635 print
' <a href="'.DOL_URL_ROOT.$url.
'">'.$newbutton.
'</a>';
643 print
'<tr><td>'.$langs->trans(
"Status").
'</td><td>';
644 print
'<input type="hidden" name="status" value="'.$status.
'">';
645 print $object->LibStatut($status, 4);
650 print
'<tr><td>'.$langs->trans(
"Visibility").
'</td><td class="maxwidthonsmartphone">';
652 if (empty($conf->global->PROJECT_DISABLE_PRIVATE_PROJECT)) {
653 $array[0] = $langs->trans(
"PrivateProject");
655 if (empty($conf->global->PROJECT_DISABLE_PUBLIC_PROJECT)) {
656 $array[1] = $langs->trans(
"SharedProject");
659 if (count($array) > 0) {
660 print
$form->selectarray(
'public', $array,
GETPOST(
'public'), 0, 0, 0,
'', 0, 0, 0,
'',
'', 1);
662 print
'<input type="hidden" name="public" id="public" value="'.GETPOST(
'public').
'">';
665 print
img_picto($langs->trans(
'PrivateProject'),
'private',
'class="paddingrightonly"');
666 print $langs->trans(
"PrivateProject");
668 print
img_picto($langs->trans(
'SharedProject'),
'world',
'class="paddingrightonly"');
669 print $langs->trans(
"SharedProject");
675 print
'<tr><td>'.$langs->trans(
"DateStart").
'</td><td>';
676 print
$form->selectDate(($date_start ? $date_start :
''),
'projectstart', 0, 0, 0,
'', 1, 0);
680 print
'<tr><td>'.$langs->trans(
"DateEnd").
'</td><td>';
681 print
$form->selectDate(($date_end ? $date_end : -1),
'projectend', 0, 0, 0,
'', 1, 0);
684 if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES)) {
686 print
'<tr class="classuseopportunity"><td>'.$langs->trans(
"OpportunityStatus").
'</td>';
687 print
'<td class="maxwidthonsmartphone">';
688 print $formproject->selectOpportunityStatus(
'opp_status',
GETPOSTISSET(
'opp_status') ?
GETPOST(
'opp_status') : $object->opp_status, 1, 0, 0, 0,
'', 0, 1);
692 print
'<tr class="classuseopportunity"><td>'.$langs->trans(
"OpportunityProbability").
'</td>';
693 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>';
694 print
'<input type="hidden" name="opp_percent_not_set" id="opp_percent_not_set" value="'.dol_escape_htmltag(
GETPOSTISSET(
'opp_percent') ?
'0' :
'1').
'">';
699 print
'<tr class="classuseopportunity"><td>'.$langs->trans(
"OpportunityAmount").
'</td>';
700 print
'<td><input size="5" type="text" name="opp_amount" value="'.dol_escape_htmltag(
GETPOSTISSET(
'opp_amount') ?
GETPOST(
'opp_amount') :
'').
'"></td>';
705 print
'<tr><td>'.$langs->trans(
"Budget").
'</td>';
706 print
'<td><input size="5" type="text" name="budget_amount" value="'.dol_escape_htmltag(
GETPOSTISSET(
'budget_amount') ?
GETPOST(
'budget_amount') :
'').
'"></td>';
710 print
'<tr><td class="tdtop">'.$langs->trans(
"Description").
'</td>';
712 $doleditor =
new DolEditor(
'description',
GETPOST(
"description",
'restricthtml'),
'', 90,
'dolibarr_notes',
'',
false,
true,
getDolGlobalString(
'FCKEDITOR_ENABLE_SOCIETE'), ROWS_3,
'90%');
713 $doleditor->Create();
716 if (!empty($conf->categorie->enabled)) {
718 print
'<tr><td>'.$langs->trans(
"Categories").
'</td><td colspan="3">';
719 $cate_arbo =
$form->select_all_categories(Categorie::TYPE_PROJECT,
'',
'parent', 64, 0, 1);
720 $arrayselected =
GETPOST(
'categories',
'array');
721 print
img_picto(
'',
'category').$form->multiselectarray(
'categories', $cate_arbo, $arrayselected,
'', 0,
'quatrevingtpercent widthcentpercentminusx', 0, 0);
727 $reshook = $hookmanager->executeHooks(
'formObjectOptions',
$parameters, $object, $action);
728 print $hookmanager->resPrint;
729 if (empty($reshook)) {
730 print $object->showOptionals($extrafields,
'create');
737 print
$form->buttonsSaveCancel(
'CreateDraft');
742 print
'<script type="text/javascript">
743 jQuery(document).ready(function() {
744 function change_percent()
746 var element = jQuery("#opp_status option:selected");
747 var defaultpercent = element.attr("defaultpercent");
748 /*if (jQuery("#opp_percent_not_set").val() == "") */
749 jQuery("#opp_percent").val(defaultpercent);
753 jQuery("#opp_status").change(function() {
757 jQuery("#usage_task").change(function() {
758 console.log("We click on usage task "+jQuery("#usage_task").is(":checked"));
759 if (! jQuery("#usage_task").is(":checked")) {
760 jQuery("#usage_bill_time").prop("checked", false);
764 jQuery("#usage_bill_time").change(function() {
765 console.log("We click on usage to bill time");
766 if (jQuery("#usage_bill_time").is(":checked")) {
767 jQuery("#usage_task").prop("checked", true);
772 } elseif ($object->id > 0) {
777 $res = $object->fetch_optionals();
780 $userAccess = $object->restrictedProjectArea($user,
'read');
781 $userWrite = $object->restrictedProjectArea($user,
'write');
782 $userDelete = $object->restrictedProjectArea($user,
'delete');
787 if ($action ==
'validate') {
788 print
$form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.$object->id, $langs->trans(
'ValidateProject'), $langs->trans(
'ConfirmValidateProject'),
'confirm_validate',
'', 0, 1);
791 if ($action ==
'close') {
792 print
$form->formconfirm($_SERVER[
"PHP_SELF"].
"?id=".$object->id, $langs->trans(
"CloseAProject"), $langs->trans(
"ConfirmCloseAProject"),
"confirm_close",
'',
'', 1);
795 if ($action ==
'reopen') {
796 print
$form->formconfirm($_SERVER[
"PHP_SELF"].
"?id=".$object->id, $langs->trans(
"ReOpenAProject"), $langs->trans(
"ConfirmReOpenAProject"),
"confirm_reopen",
'',
'', 1);
799 if ($action ==
'delete') {
800 $text = $langs->trans(
"ConfirmDeleteAProject");
801 $task =
new Task($db);
802 $taskarray = $task->getTasksArray(0, 0, $object->id, 0, 0);
803 $nboftask = count($taskarray);
805 $text .=
'<br>'.img_warning().
' '.$langs->trans(
"ThisWillAlsoRemoveTasks", $nboftask);
807 print
$form->formconfirm($_SERVER[
"PHP_SELF"].
"?id=".$object->id, $langs->trans(
"DeleteAProject"), $text,
"confirm_delete",
'',
'', 1);
811 if ($action ==
'clone') {
812 $formquestion = array(
813 'text' => $langs->trans(
"ConfirmClone"),
814 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')),
815 array(
'type' =>
'checkbox',
'name' =>
'clone_contacts',
'label' => $langs->trans(
"CloneContacts"),
'value' =>
true),
816 array(
'type' =>
'checkbox',
'name' =>
'clone_tasks',
'label' => $langs->trans(
"CloneTasks"),
'value' =>
true),
817 array(
'type' =>
'checkbox',
'name' =>
'move_date',
'label' => $langs->trans(
"CloneMoveDate"),
'value' =>
true),
818 array(
'type' =>
'checkbox',
'name' =>
'clone_notes',
'label' => $langs->trans(
"CloneNotes"),
'value' =>
true),
819 array(
'type' =>
'checkbox',
'name' =>
'clone_project_files',
'label' => $langs->trans(
"CloneProjectFiles"),
'value' =>
false),
820 array(
'type' =>
'checkbox',
'name' =>
'clone_task_files',
'label' => $langs->trans(
"CloneTaskFiles"),
'value' =>
false)
823 print
$form->formconfirm($_SERVER[
"PHP_SELF"].
"?id=".$object->id, $langs->trans(
"ToClone"), $langs->trans(
"ConfirmCloneProject"),
"confirm_clone", $formquestion,
'', 1, 400, 590);
827 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
828 print
'<input type="hidden" name="token" value="'.newToken().
'">';
829 print
'<input type="hidden" name="action" value="update">';
830 print
'<input type="hidden" name="id" value="'.$object->id.
'">';
831 print
'<input type="hidden" name="comefromclone" value="'.$comefromclone.
'">';
835 if ($action ==
'edit' && $userWrite > 0) {
836 print
dol_get_fiche_head($head,
'project', $langs->trans(
"Project"), 0, ($object->public ?
'projectpub' :
'project'));
838 print
'<table class="border centpercent">';
841 $suggestedref = $object->ref;
842 print
'<tr><td class="titlefield fieldrequired">'.$langs->trans(
"Ref").
'</td>';
843 print
'<td><input size="25" name="ref" value="'.$suggestedref.
'">';
844 print
' '.$form->textwithpicto(
'', $langs->trans(
"YouCanCompleteRef", $suggestedref));
848 print
'<tr><td class="fieldrequired">'.$langs->trans(
"ProjectLabel").
'</td>';
849 print
'<td><input class="quatrevingtpercent" name="title" value="'.dol_escape_htmltag($object->title).
'"></td></tr>';
852 print
'<tr><td class="fieldrequired">'.$langs->trans(
"Status").
'</td><td>';
853 print
'<select class="flat" name="status">';
854 foreach ($object->statuts_short as $key => $val) {
855 print
'<option value="'.$key.
'"'.((
GETPOSTISSET(
'status') ?
GETPOST(
'status') : $object->statut) == $key ?
' selected="selected"' :
'').
'>'.$langs->trans($val).
'</option>';
861 if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES) || empty($conf->global->PROJECT_HIDE_TASKS) || !empty($conf->eventorganization->enabled)) {
862 print
'<tr><td class="tdtop">';
863 print $langs->trans(
"Usage");
866 if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES)) {
867 print
'<input type="checkbox" id="usage_opportunity" name="usage_opportunity"'.(GETPOSTISSET(
'usage_opportunity') ? (
GETPOST(
'usage_opportunity',
'alpha') !=
'' ?
' checked="checked"' :
'') : ($object->usage_opportunity ?
' checked="checked"' :
'')).
'"> ';
868 $htmltext = $langs->trans(
"ProjectFollowOpportunity");
869 print
'<label for="usage_opportunity">'.$form->textwithpicto($langs->trans(
"ProjectFollowOpportunity"), $htmltext).
'</label>';
871 print
'$( document ).ready(function() {
872 jQuery("#usage_opportunity").change(function() {
873 if (jQuery("#usage_opportunity").prop("checked")) {
874 console.log("Show opportunities fields");
875 jQuery(".classuseopportunity").show();
877 console.log("Hide opportunities fields "+jQuery("#usage_opportunity").prop("checked"));
878 jQuery(".classuseopportunity").hide();
887 if (empty($conf->global->PROJECT_HIDE_TASKS)) {
888 print
'<input type="checkbox" id="usage_task" name="usage_task"' . (
GETPOSTISSET(
'usage_task') ? (
GETPOST(
'usage_task',
'alpha') !=
'' ?
' checked="checked"' :
'') : ($object->usage_task ?
' checked="checked"' :
'')) .
'"> ';
889 $htmltext = $langs->trans(
"ProjectFollowTasks");
890 print
'<label for="usage_task">'.$form->textwithpicto($langs->trans(
"ProjectFollowTasks"), $htmltext).
'</label>';
893 if (empty($conf->global->PROJECT_HIDE_TASKS) && !empty($conf->global->PROJECT_BILL_TIME_SPENT)) {
894 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"' :
'')) .
'"> ';
895 $htmltext = $langs->trans(
"ProjectBillTimeDescription");
896 print
'<label for="usage_bill_time">'.$form->textwithpicto($langs->trans(
"BillTime"), $htmltext).
'</label>';
899 if (!empty($conf->eventorganization->enabled)) {
900 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"' :
'')) .
'"> ';
901 $htmltext = $langs->trans(
"EventOrganizationDescriptionLong");
902 print
'<label for="usage_organize_event">'.$form->textwithpicto($langs->trans(
"ManageOrganizeEvent"), $htmltext).
'</label>';
911 print (empty($conf->global->PROJECT_THIRDPARTY_REQUIRED) ?
'' :
'<span class="fieldrequired">');
912 print $langs->trans(
"ThirdParty");
913 print (empty($conf->global->PROJECT_THIRDPARTY_REQUIRED) ?
'' :
'</span>');
916 if (!empty($conf->global->PROJECT_FILTER_FOR_THIRDPARTY_LIST)) {
917 $filteronlist = $conf->global->PROJECT_FILTER_FOR_THIRDPARTY_LIST;
919 $text =
$form->select_company($object->thirdparty->id,
'socid', $filteronlist,
'None', 1, 0, array(), 0,
'minwidth300');
920 if (empty($conf->global->PROJECT_CAN_ALWAYS_LINK_TO_ALL_SUPPLIERS) && empty($conf->dol_use_jmobile)) {
921 $texthelp = $langs->trans(
"IfNeedToUseOtherObjectKeepEmpty");
922 print
$form->textwithtooltip($text.
' '.
img_help(), $texthelp, 1, 0,
'',
'', 2);
930 print
'<tr><td>'.$langs->trans(
"Visibility").
'</td><td>';
932 if (empty($conf->global->PROJECT_DISABLE_PRIVATE_PROJECT)) {
933 $array[0] = $langs->trans(
"PrivateProject");
935 if (empty($conf->global->PROJECT_DISABLE_PUBLIC_PROJECT)) {
936 $array[1] = $langs->trans(
"SharedProject");
939 if (count($array) > 0) {
940 print
$form->selectarray(
'public', $array, $object->public, 0, 0, 0,
'', 0, 0, 0,
'',
'', 1);
942 print
'<input type="hidden" id="public" name="public" value="'.$object->public.
'">';
944 if ($object->public == 0) {
945 print
img_picto($langs->trans(
'PrivateProject'),
'private',
'class="paddingrightonly"');
946 print $langs->trans(
"PrivateProject");
948 print
img_picto($langs->trans(
'SharedProject'),
'world',
'class="paddingrightonly"');
949 print $langs->trans(
"SharedProject");
954 if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES)) {
955 $classfortr = ($object->usage_opportunity ?
'' :
' hideobject');
957 print
'<tr class="classuseopportunity'.$classfortr.
'"><td>'.$langs->trans(
"OpportunityStatus").
'</td>';
959 print $formproject->selectOpportunityStatus(
'opp_status', $object->opp_status, 1, 0, 0, 0,
'inline-block valignmiddle', 0, 1);
960 print
'<div id="divtocloseproject" class="inline-block valign" style="display: none;"> ';
961 print
'<input type="checkbox" id="inputcloseproject" name="closeproject" />';
962 print
'<label for="inputcloseproject">'.$langs->trans(
"AlsoCloseAProject").
'</label>';
968 print
'<tr class="classuseopportunity'.$classfortr.
'"><td>'.$langs->trans(
"OpportunityProbability").
'</td>';
969 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) :
'')).
'"> %';
970 print
'<span id="oldopppercent"></span>';
975 print
'<tr class="classuseopportunity'.$classfortr.
'"><td>'.$langs->trans(
"OpportunityAmount").
'</td>';
976 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) :
'')).
'">';
977 print $langs->getCurrencySymbol($conf->currency);
983 print
'<tr><td>'.$langs->trans(
"DateStart").
'</td><td>';
984 print
$form->selectDate($object->date_start ? $object->date_start : -1,
'projectstart', 0, 0, 0,
'', 1, 0);
985 print
' <input type="checkbox" class="valignmiddle" id="reportdate" name="reportdate" value="yes" ';
986 if ($comefromclone) {
989 print
'/><label for="reportdate" class="opacitymedium">'.$langs->trans(
"ProjectReportDate").
'</label>';
993 print
'<tr><td>'.$langs->trans(
"DateEnd").
'</td><td>';
994 print
$form->selectDate($object->date_end ? $object->date_end : -1,
'projectend', 0, 0, 0,
'', 1, 0);
998 print
'<tr><td>'.$langs->trans(
"Budget").
'</td>';
999 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) :
'')).
'">';
1000 print $langs->getCurrencySymbol($conf->currency);
1005 print
'<tr><td class="tdtop">'.$langs->trans(
"Description").
'</td>';
1007 $doleditor =
new DolEditor(
'description', $object->description,
'', 90,
'dolibarr_notes',
'',
false,
true,
getDolGlobalInt(
'FCKEDITOR_ENABLE_SOCIETE'), ROWS_3,
'90%');
1008 $doleditor->Create();
1013 print
'<tr><td>'.$langs->trans(
"Categories").
'</td><td>';
1014 $cate_arbo =
$form->select_all_categories(Categorie::TYPE_PROJECT,
'',
'parent', 64, 0, 1);
1016 $cats = $c->containing($object->id, Categorie::TYPE_PROJECT);
1017 foreach ($cats as $cat) {
1018 $arrayselected[] = $cat->id;
1020 print
img_picto(
'',
'category').$form->multiselectarray(
'categories', $cate_arbo, $arrayselected, 0, 0,
'quatrevingtpercent widthcentpercentminusx', 0,
'0');
1026 $reshook = $hookmanager->executeHooks(
'formObjectOptions',
$parameters, $object, $action);
1027 print $hookmanager->resPrint;
1028 if (empty($reshook)) {
1029 print $object->showOptionals($extrafields,
'edit');
1034 print
dol_get_fiche_head($head,
'project', $langs->trans(
"Project"), -1, ($object->public ?
'projectpub' :
'project'));
1038 $linkback =
'<a href="'.DOL_URL_ROOT.
'/projet/list.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
1040 $morehtmlref =
'<div class="refidno">';
1044 $morehtmlref .=
'<br>'.$langs->trans(
'ThirdParty').
' : ';
1045 if (!empty($object->thirdparty->id) && $object->thirdparty->id > 0) {
1046 $morehtmlref .= $object->thirdparty->getNomUrl(1,
'project');
1048 $morehtmlref .=
'</div>';
1051 if (empty($user->rights->projet->all->lire)) {
1052 $objectsListId = $object->getProjectsAuthorizedForUser($user, 0, 0);
1053 $object->next_prev_filter =
" rowid IN (".$db->sanitize(count($objectsListId) ? join(
',', array_keys($objectsListId)) :
'0').
")";
1056 dol_banner_tab($object,
'ref', $linkback, 1,
'ref',
'ref', $morehtmlref);
1058 print
'<div class="fichecenter">';
1059 print
'<div class="fichehalfleft">';
1060 print
'<div class="underbanner clearboth"></div>';
1062 print
'<table class="border tableforfield" width="100%">';
1065 if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES) || empty($conf->global->PROJECT_HIDE_TASKS) || !empty($conf->eventorganization->enabled)) {
1066 print
'<tr><td class="tdtop">';
1067 print $langs->trans(
"Usage");
1070 if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES)) {
1071 print
'<input type="checkbox" disabled name="usage_opportunity"'.(GETPOSTISSET(
'usage_opportunity') ? (
GETPOST(
'usage_opportunity',
'alpha') !=
'' ?
' checked="checked"' :
'') : ($object->usage_opportunity ?
' checked="checked"' :
'')).
'"> ';
1072 $htmltext = $langs->trans(
"ProjectFollowOpportunity");
1073 print
$form->textwithpicto($langs->trans(
"ProjectFollowOpportunity"), $htmltext);
1076 if (empty($conf->global->PROJECT_HIDE_TASKS)) {
1077 print
'<input type="checkbox" disabled name="usage_task"'.(GETPOSTISSET(
'usage_task') ? (
GETPOST(
'usage_task',
'alpha') !=
'' ?
' checked="checked"' :
'') : ($object->usage_task ?
' checked="checked"' :
'')).
'"> ';
1078 $htmltext = $langs->trans(
"ProjectFollowTasks");
1079 print
$form->textwithpicto($langs->trans(
"ProjectFollowTasks"), $htmltext);
1082 if (empty($conf->global->PROJECT_HIDE_TASKS) && !empty($conf->global->PROJECT_BILL_TIME_SPENT)) {
1083 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"' :
'')).
'"> ';
1084 $htmltext = $langs->trans(
"ProjectBillTimeDescription");
1085 print
$form->textwithpicto($langs->trans(
"BillTime"), $htmltext);
1089 if (!empty($conf->eventorganization->enabled)) {
1090 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"' :
'')).
'"> ';
1091 $htmltext = $langs->trans(
"EventOrganizationDescriptionLong");
1092 print
$form->textwithpicto($langs->trans(
"ManageOrganizeEvent"), $htmltext);
1098 print
'<tr><td class="titlefield">'.$langs->trans(
"Visibility").
'</td><td>';
1099 if ($object->public) {
1100 print
img_picto($langs->trans(
'SharedProject'),
'world',
'class="paddingrightonly"');
1101 print $langs->trans(
'SharedProject');
1103 print
img_picto($langs->trans(
'PrivateProject'),
'private',
'class="paddingrightonly"');
1104 print $langs->trans(
'PrivateProject');
1108 if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES) && !empty($object->usage_opportunity)) {
1110 print
'<tr><td>'.$langs->trans(
"OpportunityStatus").
'</td><td>';
1111 $code =
dol_getIdFromCode($db, $object->opp_status,
'c_lead_status',
'rowid',
'code');
1113 print $langs->trans(
"OppStatus".$code);
1118 print
'<tr><td>'.$langs->trans(
"OpportunityProbability").
'</td><td>';
1119 if (strcmp($object->opp_percent,
'')) {
1120 print
price($object->opp_percent, 0, $langs, 1, 0).
' %';
1125 print
'<tr><td>'.$langs->trans(
"OpportunityAmount").
'</td><td>';
1126 if (strcmp($object->opp_amount,
'')) {
1127 print
'<span class="amount">'.price($object->opp_amount, 0, $langs, 1, 0, -1, $conf->currency).
'</span>';
1128 if (strcmp($object->opp_percent,
'')) {
1129 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>';
1145 print
'<tr><td>'.$langs->trans(
"DateStart").
' - '.$langs->trans(
"DateEnd").
'</td><td>';
1147 print ($start ? $start :
'?');
1150 print ($end ? $end :
'?');
1151 if ($object->hasDelay()) {
1157 print
'<tr><td>'.$langs->trans(
"Budget").
'</td><td>';
1158 if (strcmp($object->budget_amount,
'')) {
1159 print
'<span class="amount">'.price($object->budget_amount, 0, $langs, 1, 0, 0, $conf->currency).
'</span>';
1165 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_view.tpl.php';
1170 print
'<div class="fichehalfright">';
1171 print
'<div class="underbanner clearboth"></div>';
1173 print
'<table class="border tableforfield centpercent">';
1176 print
'<td class="titlefield tdtop">'.$langs->trans(
"Description").
'</td><td>';
1182 print
'<tr><td class="valignmiddle">'.$langs->trans(
"Categories").
'</td><td>';
1183 print
$form->showCategories($object->id, Categorie::TYPE_PROJECT, 1);
1192 print
'<div class="clearboth"></div>';
1197 if ($action ==
'edit' && $userWrite > 0) {
1198 print
$form->buttonsSaveCancel();
1204 if (!empty($conf->use_javascript_ajax) && !empty($conf->global->PROJECT_USE_OPPORTUNITIES)) {
1206 $defaultcheckedwhenoppclose = 1;
1207 if (empty($conf->global->PROJECT_HIDE_TASKS)) {
1208 $defaultcheckedwhenoppclose = 0;
1211 print
'<!-- Javascript to manage opportunity status change -->';
1212 print
'<script type="text/javascript">
1213 jQuery(document).ready(function() {
1214 function change_percent()
1216 var element = jQuery("#opp_status option:selected");
1217 var defaultpercent = element.attr("defaultpercent");
1218 var defaultcloseproject = '.((int) $defaultcheckedwhenoppclose).
';
1219 var elemcode = element.attr("elemcode");
1220 var oldpercent = \''.
dol_escape_js($object->opp_percent).
'\';
1222 console.log(
"We select "+elemcode);
1225 var closeproject = 0;
1226 if (elemcode == \
'LOST\') closeproject = 1;
1227 if (elemcode == \'WON\') closeproject = defaultcloseproject;
1228 if (closeproject) jQuery("#inputcloseproject").prop("checked", true);
1229 else jQuery("#inputcloseproject").prop("checked", false);
1231 /* Make the close project checkbox visible or not */
1232 console.log("closeproject="+closeproject);
1233 if (elemcode == \'WON\' || elemcode == \'LOST\')
1235 jQuery("#divtocloseproject").show();
1239 jQuery("#divtocloseproject").hide();
1242 /* Change percent with default percent (defaultpercent) if new status (defaultpercent) is higher than current (jQuery("#opp_percent").val()) */
1243 console.log("oldpercent="+oldpercent);
1244 if (oldpercent != \'\' && (parseFloat(defaultpercent) < parseFloat(oldpercent)))
1246 if (jQuery("#opp_percent").val() != \'\' && oldpercent != \'\') jQuery("#oldopppercent").text(\' - '.
dol_escape_js($langs->transnoentities(
"PreviousValue")).
': \'+oldpercent+\' %\');
1247 if (parseFloat(oldpercent) != 100) { jQuery("#opp_percent").val(oldpercent); }
1248 else { jQuery("#opp_percent").val(defaultpercent); }
1252 if ((parseFloat(jQuery("#opp_percent").val()) < parseFloat(defaultpercent)));
1254 if (jQuery("#opp_percent").val() != \'\' && oldpercent != \'\') jQuery("#oldopppercent").text(\' - '.
dol_escape_js($langs->transnoentities(
"PreviousValue")).
': \'+oldpercent+\' %\');
1255 jQuery("#opp_percent").val(defaultpercent);
1260 jQuery("#opp_status").change(function() {
1270 print
'<div class="tabsAction">';
1272 $reshook = $hookmanager->executeHooks(
'addMoreActionsButtons',
$parameters, $object, $action);
1274 if (empty($reshook)) {
1275 if ($action !=
"edit" && $action !=
'presend') {
1285 if (empty($user->socid)) {
1287 print
dolGetButtonAction(
'', $langs->trans(
'SendMail'),
'default', $_SERVER[
"PHP_SELF"].
'?action=presend&token='.
newToken().
'&id='.$object->id.
'&mode=init#formmailbeforetitle',
'');
1293 if ($userWrite > 0) {
1294 print
dolGetButtonAction(
'', $langs->trans(
'Modify'),
'default', $_SERVER[
"PHP_SELF"].
'?action=edit&token='.
newToken().
'&id='.$object->id,
'');
1296 print
dolGetButtonAction($langs->trans(
'NotOwnerOfProject'), $langs->trans(
'Modify'),
'default', $_SERVER[
'PHP_SELF'].
'#',
'',
false);
1302 if ($userWrite > 0) {
1303 print
dolGetButtonAction(
'', $langs->trans(
'Validate'),
'default', $_SERVER[
"PHP_SELF"].
'?action=validate&token='.
newToken().
'&id='.$object->id,
'');
1305 print
dolGetButtonAction($langs->trans(
'NotOwnerOfProject'), $langs->trans(
'Validate'),
'default', $_SERVER[
'PHP_SELF'].
'#',
'',
false);
1311 if ($userWrite > 0) {
1312 print
dolGetButtonAction(
'', $langs->trans(
'Close'),
'default', $_SERVER[
"PHP_SELF"].
'?action=close&token='.
newToken().
'&id='.$object->id,
'');
1314 print
dolGetButtonAction($langs->trans(
'NotOwnerOfProject'), $langs->trans(
'Close'),
'default', $_SERVER[
'PHP_SELF'].
'#',
'',
false);
1320 if ($userWrite > 0) {
1321 print
dolGetButtonAction(
'', $langs->trans(
'ReOpen'),
'default', $_SERVER[
"PHP_SELF"].
'?action=reopen&token='.
newToken().
'&id='.$object->id,
'');
1323 print
dolGetButtonAction($langs->trans(
'NotOwnerOfProject'), $langs->trans(
'ReOpen'),
'default', $_SERVER[
'PHP_SELF'].
'#',
'',
false);
1328 if (!empty($conf->global->PROJECT_SHOW_CREATE_OBJECT_BUTTON)) {
1329 if (!empty($conf->propal->enabled) && $user->rights->propal->creer) {
1330 $langs->load(
"propal");
1331 print
dolGetButtonAction(
'', $langs->trans(
'AddProp'),
'default', DOL_URL_ROOT.
'/comm/propal/card.php?action=create&projectid='.$object->id.
'&socid='.$object->socid,
'');
1333 if (!empty($conf->commande->enabled) && $user->rights->commande->creer) {
1334 $langs->load(
"orders");
1335 print
dolGetButtonAction(
'', $langs->trans(
'CreateOrder'),
'default', DOL_URL_ROOT.
'/commande/card.php?action=create&projectid='.$object->id.
'&socid='.$object->socid,
'');
1337 if (
isModEnabled(
'facture') && $user->rights->facture->creer) {
1338 $langs->load(
"bills");
1339 print
dolGetButtonAction(
'', $langs->trans(
'CreateBill'),
'default', DOL_URL_ROOT.
'/compta/facture/card.php?action=create&projectid='.$object->id.
'&socid='.$object->socid,
'');
1341 if (!empty($conf->supplier_proposal->enabled) && $user->rights->supplier_proposal->creer) {
1342 $langs->load(
"supplier_proposal");
1343 print
dolGetButtonAction(
'', $langs->trans(
'AddSupplierProposal'),
'default', DOL_URL_ROOT.
'/supplier_proposal/card.php?action=create&projectid='.$object->id.
'&socid='.$object->socid,
'');
1345 if (!empty($conf->supplier_order->enabled) && ($user->rights->fournisseur->commande->creer || $user->rights->supplier_order->creer)) {
1346 $langs->load(
"suppliers");
1347 print
dolGetButtonAction(
'', $langs->trans(
'AddSupplierOrder'),
'default', DOL_URL_ROOT.
'/fourn/commande/card.php?action=create&projectid='.$object->id.
'&socid='.$object->socid,
'');
1349 if (!empty($conf->supplier_invoice->enabled) && ($user->rights->fournisseur->facture->creer || $user->rights->supplier_invoice->creer)) {
1350 $langs->load(
"suppliers");
1351 print
dolGetButtonAction(
'', $langs->trans(
'AddSupplierInvoice'),
'default', DOL_URL_ROOT.
'/fourn/facture/card.php?action=create&projectid='.$object->id.
'&socid='.$object->socid,
'');
1353 if (!empty($conf->ficheinter->enabled) && $user->rights->ficheinter->creer) {
1354 $langs->load(
"interventions");
1355 print
dolGetButtonAction(
'', $langs->trans(
'AddIntervention'),
'default', DOL_URL_ROOT.
'/fichinter/card.php?action=create&projectid='.$object->id.
'&socid='.$object->socid,
'');
1357 if (!empty($conf->contrat->enabled) && $user->rights->contrat->creer) {
1358 $langs->load(
"contracts");
1359 print
dolGetButtonAction(
'', $langs->trans(
'AddContract'),
'default', DOL_URL_ROOT.
'/contrat/card.php?action=create&projectid='.$object->id.
'&socid='.$object->socid,
'');
1361 if (!empty($conf->expensereport->enabled) && $user->rights->expensereport->creer) {
1362 $langs->load(
"trips");
1363 print
dolGetButtonAction(
'', $langs->trans(
'AddTrip'),
'default', DOL_URL_ROOT.
'/expensereport/card.php?action=create&projectid='.$object->id.
'&socid='.$object->socid,
'');
1365 if (!empty($conf->don->enabled) && $user->rights->don->creer) {
1366 $langs->load(
"donations");
1367 print
dolGetButtonAction(
'', $langs->trans(
'AddDonation'),
'default', DOL_URL_ROOT.
'/don/card.php?action=create&projectid='.$object->id.
'&socid='.$object->socid,
'');
1372 if ($user->rights->projet->creer) {
1373 if ($userWrite > 0) {
1374 print
dolGetButtonAction(
'', $langs->trans(
'ToClone'),
'default', $_SERVER[
"PHP_SELF"].
'?action=clone&token='.
newToken().
'&id='.$object->id,
'');
1376 print
dolGetButtonAction($langs->trans(
'NotOwnerOfProject'), $langs->trans(
'ToClone'),
'default', $_SERVER[
'PHP_SELF'].
'#',
'',
false);
1381 if ($user->rights->projet->supprimer || ($object->statut ==
Project::STATUS_DRAFT && $user->rights->projet->creer)) {
1382 if ($userDelete > 0 || ($object->statut ==
Project::STATUS_DRAFT && $user->rights->projet->creer)) {
1383 print
dolGetButtonAction(
'', $langs->trans(
'Delete'),
'delete', $_SERVER[
"PHP_SELF"].
'?action=delete&token='.
newToken().
'&id='.$object->id,
'');
1385 print
dolGetButtonAction($langs->trans(
'NotOwnerOfProject'), $langs->trans(
'Delete'),
'default', $_SERVER[
'PHP_SELF'].
'#',
'',
false);
1393 if (
GETPOST(
'modelselected')) {
1394 $action =
'presend';
1397 if ($action !=
'presend') {
1398 print
'<div class="fichecenter"><div class="fichehalfleft">';
1399 print
'<a name="builddoc"></a>';
1405 $filedir = $conf->project->multidir_output[$object->entity].
"/".
dol_sanitizeFileName($object->ref);
1406 $urlsource = $_SERVER[
"PHP_SELF"].
"?id=".$object->id;
1407 $genallowed = ($user->rights->projet->lire && $userAccess > 0);
1408 $delallowed = ($user->rights->projet->creer && $userWrite > 0);
1410 print $formfile->showdocuments(
'project', $filename, $filedir, $urlsource, $genallowed, $delallowed, $object->model_pdf, 1, 0, 0, 0, 0,
'',
'',
'',
'',
'', $object);
1412 print
'</div><div class="fichehalfright">';
1416 $morehtmlcenter =
dolGetButtonTitle($langs->trans(
'SeeAll'),
'',
'fa fa-bars imgforviewmode', DOL_URL_ROOT.
'/projet/info.php?id='.$object->id);
1419 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formactions.class.php';
1421 $somethingshown =
$formactions->showactions($object,
'project', 0, 1,
'', $MAXEVENT,
'', $morehtmlcenter);
1423 print
'</div></div>';
1427 $modelmail =
'project';
1428 $defaulttopic =
'SendProjectRef';
1429 $diroutput = $conf->project->multidir_output[$object->entity];
1430 $autocopy =
'MAIN_MAIL_AUTOCOPY_PROJECT_TO';
1431 $trackid =
'proj'.$object->id;
1433 include DOL_DOCUMENT_ROOT.
'/core/tpl/card_presend.tpl.php';
1437 $reshook = $hookmanager->executeHooks(
'mainCardTabAddMore',
$parameters, $object, $action);
1439 print $langs->trans(
"RecordNotFound");