33require
'../main.inc.php';
42require_once DOL_DOCUMENT_ROOT.
'/projet/class/project.class.php';
43require_once DOL_DOCUMENT_ROOT.
'/projet/class/task.class.php';
44require_once DOL_DOCUMENT_ROOT.
'/core/lib/project.lib.php';
45require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
46require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formprojet.class.php';
47require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
48require_once DOL_DOCUMENT_ROOT.
'/core/modules/project/modules_project.php';
49require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
52$langsLoad = array(
'projects',
'companies');
54 $langsLoad[] =
'eventorganization';
57$langs->loadLangs($langsLoad);
61$action =
GETPOST(
'action',
'aZ09');
62$backtopage =
GETPOST(
'backtopage',
'alpha');
63$backtopageforcancel =
GETPOST(
'backtopageforcancel',
'alpha');
64$cancel =
GETPOST(
'cancel',
'alpha');
65$confirm =
GETPOST(
'confirm',
'aZ09');
72$objcanvas =
GETPOST(
"objcanvas",
"alphanohtml");
73$comefromclone =
GETPOST(
"comefromclone",
"alphanohtml");
78$location =
GETPOST(
'location',
'alphanohtml');
81$mine =
GETPOST(
'mode') ==
'mine' ? 1 : 0;
84$hookmanager->initHooks(array(
'projectcard',
'globalcard'));
90if ($id > 0 || !empty($ref)) {
91 $ret =
$object->fetch($id, $ref);
94 if (
getDolGlobalString(
'PROJECT_ALLOW_COMMENT_ON_PROJECT') && method_exists($object,
'fetchComments') && empty(
$object->comments)) {
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');
116$permissiontoeditextra = $permissiontoadd;
118if (
GETPOST(
'attribute',
'aZ09') && isset($extrafields->attributes[
$object->table_element][
'perms'][
GETPOST(
'attribute',
'aZ09')])) {
120 $permissiontoeditextra =
dol_eval((
string) $extrafields->attributes[
$object->table_element][
'perms'][
GETPOST(
'attribute',
'aZ09')]);
130$parameters = array(
'id' => $socid,
'objcanvas' => $objcanvas);
131$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
136if (empty($reshook)) {
137 $backurlforlist = DOL_URL_ROOT.
'/projet/list.php';
141 if (
GETPOST(
"comefromclone") == 1) {
142 $result =
$object->delete($user);
144 header(
"Location: index.php");
148 setEventMessages($langs->trans(
"CantRemoveProject", $langs->transnoentitiesnoconv(
"ProjectOverview")),
null,
'errors');
153 if (empty($backtopage) || ($cancel && empty($id))) {
154 if (empty($backtopage) || ($cancel && strpos($backtopage,
'__ID__'))) {
155 if (empty($id) && (($action !=
'add' && $action !=
'create') || $cancel)) {
156 $backtopage = $backurlforlist;
158 $backtopage = DOL_URL_ROOT.
'/projet/card.php?id='.((!empty($id) &&
$id > 0) ? $id :
'__ID__');
164 if (!empty($backtopageforcancel)) {
165 header(
"Location: ".$backtopageforcancel);
167 } elseif (!empty($backtopage)) {
168 header(
"Location: ".$backtopage);
174 include DOL_DOCUMENT_ROOT.
'/core/actions_dellink.inc.php';
177 if ($action ==
'confirm_setdraft' && $confirm ==
'yes' && $permissiontoadd) {
178 $result =
$object->setStatut($object::STATUS_DRAFT,
null,
'',
'PROJECT_MODIFY');
188 $object->statut = $object::STATUS_DRAFT;
192 if ($action ==
'add' && $permissiontoadd) {
195 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"Ref")),
null,
'errors');
199 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"ProjectLabel")),
null,
'errors');
204 if (
GETPOST(
'usage_opportunity') !=
'' && !(
GETPOST(
'opp_status') > 0)) {
206 setEventMessages($langs->trans(
"ErrorOppStatusRequiredIfUsage"),
null,
'errors');
208 if (
GETPOST(
'opp_amount') !=
'' && !(
GETPOST(
'opp_status') > 0)) {
210 setEventMessages($langs->trans(
"ErrorOppStatusRequiredIfAmount"),
null,
'errors');
235 $object->date_start_event = $date_start_event;
236 $object->date_end_event = $date_end_event;
239 $object->opp_status = $opp_status;
240 $object->opp_percent = $opp_percent;
241 $object->usage_opportunity = (
GETPOST(
'usage_opportunity',
'alpha') ==
'on' ? 1 : 0);
242 $object->usage_task = (
GETPOST(
'usage_task',
'alpha') ==
'on' ? 1 : 0);
243 $object->usage_bill_time = (
GETPOST(
'usage_bill_time',
'alpha') ==
'on' ? 1 : 0);
244 $object->usage_organize_event = (
GETPOST(
'usage_organize_event',
'alpha') ==
'on' ? 1 : 0);
247 $ret = $extrafields->setOptionalsFromPost(
null, $object);
253 $result =
$object->create($user);
256 $typeofcontact =
GETPOST(
'typeofcontact');
257 $result =
$object->add_contact($user->id, $typeofcontact,
'internal');
263 } elseif ($result < 0) {
264 $langs->load(
"errors");
269 $langs->load(
"errors");
274 if (!$error && !empty(
$object->id) > 0) {
276 $categories =
GETPOST(
'categories',
'array:int');
277 $result =
$object->setCategories($categories);
279 $langs->load(
"errors");
288 if (!empty($backtopage)) {
289 $backtopage = preg_replace(
'/--IDFORBACKTOPAGE--|__ID__/', (
string)
$object->id, $backtopage);
290 $backtopage = $backtopage.
'&projectid='.
$object->id;
291 header(
"Location: ".$backtopage);
294 header(
"Location:card.php?id=".
$object->id);
299 unset($_POST[
"ref"]);
307 if ($action ==
'update' && empty(
GETPOST(
'cancel')) && $permissiontoadd) {
310 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"Ref")),
null,
'errors');
314 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"ProjectLabel")),
null,
'errors');
322 $old_start_date =
$object->date_start;
333 $object->date_start_event = (!
GETPOST(
'date_start_event')) ?
'' : $date_start_event;
334 $object->date_end_event = (!
GETPOST(
'date_end_event')) ?
'' : $date_end_event;
343 $object->opp_status = $opp_status;
346 $object->opp_percent = $opp_percent;
348 $object->usage_opportunity = (
GETPOST(
'usage_opportunity',
'alpha') ==
'on' ? 1 : 0);
349 $object->usage_task = (
GETPOST(
'usage_task',
'alpha') ==
'on' ? 1 : 0);
350 $object->usage_bill_time = (
GETPOST(
'usage_bill_time',
'alpha') ==
'on' ? 1 : 0);
351 $object->usage_organize_event = (
GETPOST(
'usage_organize_event',
'alpha') ==
'on' ? 1 : 0);
354 $ret = $extrafields->setOptionalsFromPost(
null, $object,
'@GETPOSTISSET');
364 setEventMessages($langs->trans(
"ErrorOppStatusRequiredIfAmount"),
null,
'errors');
367 if (!$error && !is_null(
$object->thirdparty) && ((
int)
$object->thirdparty->client == 0 || (
int)
$object->thirdparty->client == 2)) {
371 if (
$object->opp_status == $idoppstatuswon) {
373 if (!empty(
$object->thirdparty) && !empty(
$object->thirdparty->id)) {
374 $object->thirdparty->setAsCustomer();
381 $result =
$object->update($user);
391 $categories =
GETPOST(
'categories',
'array:int');
392 $result =
$object->setCategories($categories);
401 if (
GETPOST(
"reportdate") && (
$object->date_start != $old_start_date)) {
402 $result =
$object->shiftTaskDate((
int) $old_start_date);
412 $resclose =
$object->setClose($user);
435 if ($action ==
'set_opp_status' && $user->hasRight(
'projet',
'creer')) {
437 $object->opp_status = $opp_status;
440 $object->opp_percent = $opp_percent;
446 setEventMessages($langs->trans(
"ErrorOppStatusRequiredIfAmount"),
null,
'errors');
453 $result =
$object->update($user);
465 if ((
int)
$object->thirdparty->client == 0 || (
int)
$object->thirdparty->client == 2) {
469 if (!$error &&
$object->opp_status == $idoppstatuswon) {
471 if (!empty(
$object->thirdparty) && !empty(
$object->thirdparty->id)) {
472 $object->thirdparty->setAsCustomer();
490 if ($action ==
'builddoc' && $permissiontoadd) {
496 $outputlangs = $langs;
497 if (
GETPOST(
'lang_id',
'aZ09')) {
499 $outputlangs->setDefaultLang(
GETPOST(
'lang_id',
'aZ09'));
501 $result =
$object->generateDocument(
$object->model_pdf, $outputlangs);
511 if ($action ==
'remove_file' && $permissiontoadd) {
513 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
515 $langs->load(
"other");
517 $file = $upload_dir.
'/'.
GETPOST(
'file');
529 if ($action ==
'confirm_validate' && $confirm ==
'yes' && $permissiontoadd) {
530 $result =
$object->setValid($user);
536 if ($action ==
'confirm_close' && $confirm ==
'yes' && $permissiontoadd) {
537 $result =
$object->setClose($user);
543 if ($action ==
'confirm_reopen' && $confirm ==
'yes' && $permissiontoadd) {
544 $result =
$object->setValid($user);
550 if ($action ==
'confirm_delete' && $confirm ==
'yes' && $permissiontodelete) {
552 $result =
$object->delete($user);
556 if (!empty($_SESSION[
'pageforbacktolist']) && !empty($_SESSION[
'pageforbacktolist'][
'project'])) {
557 $tmpurl = $_SESSION[
'pageforbacktolist'][
'project'];
558 $tmpurl = preg_replace(
'/__SOCID__/', (
string)
$object->socid, $tmpurl);
559 $urlback = $tmpurl.(preg_match(
'/\?/', $tmpurl) ?
'&' :
'?').
'restore_lastsearch_values=1';
561 $urlback = DOL_URL_ROOT.
'/projet/list.php?restore_lastsearch_values=1';
564 header(
"Location: ".$urlback);
572 if ($action ==
'confirm_clone' && $permissiontoadd && $confirm ==
'yes') {
573 $clone_contacts =
GETPOST(
'clone_contacts') ? 1 : 0;
574 $clone_tasks =
GETPOST(
'clone_tasks') ? 1 : 0;
575 $clone_project_files =
GETPOST(
'clone_project_files') ? 1 : 0;
576 $clone_task_files =
GETPOST(
'clone_task_files') ? 1 : 0;
577 $clone_notes =
GETPOST(
'clone_notes') ? 1 : 0;
578 $move_date =
GETPOST(
'move_date') ? 1 : 0;
581 $result =
$object->createFromClone($user,
$object->id, $clone_contacts, $clone_tasks, $clone_project_files, $clone_task_files, $clone_notes, $move_date, 0, $clone_thirdparty);
587 $newobject->fetch($result);
589 setEventMessages($langs->trans(
"ProjectCreatedInDolibarr", $newobject->ref),
null,
'mesgs');
591 header(
'Location: '.$_SERVER[
'PHP_SELF'].
'?id='.$result.
'&action=edit&comefromclone=1');
597 if ($action ==
'update_extras' && $permissiontoeditextra) {
600 $attribute_name =
GETPOST(
'attribute',
'aZ09');
603 $ret = $extrafields->setOptionalsFromPost(
null, $object, $attribute_name);
609 $result =
$object->updateExtraField($attribute_name,
'PROJECT_MODIFY');
617 $action =
'edit_extras';
622 include DOL_DOCUMENT_ROOT.
'/core/actions_printing.inc.php';
625 $triggersendname =
'PROJECT_SENTBYMAIL';
627 $autocopy =
'MAIN_MAIL_AUTOCOPY_PROJECT_TO';
628 $trackid =
'proj'.$object->id;
629 include DOL_DOCUMENT_ROOT.
'/core/actions_sendmails.inc.php';
642$title = $langs->trans(
"Project").
' - '.
$object->ref.(!empty(
$object->thirdparty->name) ?
' - '.$object->thirdparty->name :
'').(!empty(
$object->title) ?
' - '.$object->title :
'');
644 $title =
$object->ref.(!empty(
$object->thirdparty->name) ?
' - '.$object->thirdparty->name :
'').(!empty(
$object->title) ?
' - '.$object->title :
'');
647$help_url =
"EN:Module_Projects|FR:Module_Projets|ES:Módulo_Proyectos|DE:Modul_Projekte";
649llxHeader(
"", $title, $help_url,
'', 0, 0,
'',
'',
'',
'mod-project page-card');
651$titleboth = $langs->trans(
"LeadsOrProjects");
652$titlenew = $langs->trans(
"NewLeadOrProject");
654 $titleboth = $langs->trans(
"Projects");
655 $titlenew = $langs->trans(
"NewProject");
658 $titleboth = $langs->trans(
"Leads");
659 $titlenew = $langs->trans(
"NewLead");
662if ($action ==
'create' && $user->hasRight(
'projet',
'creer')) {
669 $thirdparty->fetch($socid);
674 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
675 print
'<input type="hidden" name="action" value="add">';
676 print
'<input type="hidden" name="token" value="'.newToken().
'">';
677 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
678 print
'<input type="hidden" name="backtopageforcancel" value="'.$backtopageforcancel.
'">';
679 print
'<input type="hidden" name="dol_openinpopup" value="'.$dol_openinpopup.
'">';
683 print
'<table class="border centpercent tableforfieldcreate">';
693 $dirmodels = array_merge(array(
'/'), (array)
$conf->modules_parts[
'models']);
694 foreach ($dirmodels as $reldir) {
695 $file =
dol_buildpath($reldir.
"core/modules/project/".$modele.
'.php', 0);
696 if (file_exists($file)) {
698 $classname = $modele;
703 if ($filefound && !empty($classname)) {
705 if (class_exists($classname)) {
706 $modProject =
new $classname();
707 '@phan-var-force ModeleNumRefProjects $modProject';
708 $defaultref = $modProject->getNextValue($thirdparty, $object);
712 if (is_numeric($defaultref) && $defaultref <= 0) {
718 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).
'">';
720 print
' '.$form->textwithpicto(
'', $langs->trans(
"YouCanCompleteRef", $suggestedref));
725 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>';
729 print
'<tr><td>'.$langs->trans(
"Parent").
'</td><td class="maxwidthonsmartphone">';
730 print
img_picto(
'',
'project',
'class="pictofixedwidth"');
731 $formproject->select_projects(-1,
'',
'fk_project', 64, 0, 1, 1, 0, 0, 0,
'', 0, 0,
'',
'',
'');
737 print
'<tr><td class="tdtop">';
738 print $langs->trans(
"Usage");
742 print
'<input type="checkbox" id="usage_opportunity" name="usage_opportunity"'.(GETPOSTISSET(
'usage_opportunity') ? (
GETPOST(
'usage_opportunity',
'alpha') ?
' checked="checked"' :
'') :
' checked="checked"').
'> ';
743 $htmltext = $langs->trans(
"ProjectFollowOpportunity");
744 print
'<label for="usage_opportunity">'.$form->textwithpicto($langs->trans(
"ProjectFollowOpportunity"), $htmltext).
'</label>';
746 print
'$( document ).ready(function() {
747 jQuery("#usage_opportunity").change(function() {
748 if (jQuery("#usage_opportunity").prop("checked")) {
749 console.log("Show opportunities fields");
750 jQuery(".classuseopportunity").show();
752 console.log("Hide opportunities fields "+jQuery("#usage_opportunity").prop("checked"));
753 jQuery(".classuseopportunity").hide();
758 print
'jQuery(".classuseopportunity").hide();';
765 print
'<input type="checkbox" id="usage_task" name="usage_task"'.(GETPOSTISSET(
'usage_task') ? (
GETPOST(
'usage_task',
'alpha') ?
' checked="checked"' :
'') :
' checked="checked"').
'> ';
766 $htmltext = $langs->trans(
"ProjectFollowTasks");
767 print
'<label for="usage_task">'.$form->textwithpicto($langs->trans(
"ProjectFollowTasks"), $htmltext).
'</label>';
769 print
'$( document ).ready(function() {
770 jQuery("#usage_task").change(function() {
771 if (jQuery("#usage_task").prop("checked")) {
772 console.log("Show task fields");
773 jQuery(".classusetask").show();
775 console.log("Hide tasks fields "+jQuery("#usage_task").prop("checked"));
776 jQuery(".classusetask").hide();
781 print
'jQuery(".classusetask").hide();';
788 print
'<input type="checkbox" id="usage_bill_time" name="usage_bill_time"'.(GETPOSTISSET(
'usage_bill_time') ? (
GETPOST(
'usage_bill_time',
'alpha') ?
' checked="checked"' :
'') :
'').
'> ';
789 $htmltext = $langs->trans(
"ProjectBillTimeDescription");
790 print
'<label for="usage_bill_time">'.$form->textwithpicto($langs->trans(
"BillTime"), $htmltext).
'</label>';
792 print
'$( document ).ready(function() {
793 jQuery("#usage_bill_time").change(function() {
794 if (jQuery("#usage_bill_time").prop("checked")) {
795 console.log("Show bill time fields");
796 jQuery(".classusebilltime").show();
798 console.log("Hide bill time fields "+jQuery("#usage_bill_time").prop("checked"));
799 jQuery(".classusebilltime").hide();
804 print
'jQuery(".classusebilltime").hide();';
811 print
'<input type="checkbox" id="usage_organize_event" name="usage_organize_event"'.(GETPOSTISSET(
'usage_organize_event') ? (
GETPOST(
'usage_organize_event',
'alpha') ?
' checked="checked"' :
'') :
'').
'"> ';
812 $htmltext = $langs->trans(
"EventOrganizationDescriptionLong");
813 print
'<label for="usage_organize_event">'.$form->textwithpicto($langs->trans(
"ManageOrganizeEvent"), $htmltext).
'</label>';
815 print
'$( document ).ready(function() {
816 jQuery("#usage_organize_event").change(function() {
817 if (jQuery("#usage_organize_event").prop("checked")) {
818 console.log("Show organize event fields");
819 jQuery(".classuseorganizeevent").show();
821 console.log("Hide organize event fields "+jQuery("#usage_organize_event").prop("checked"));
822 jQuery(".classuseorganizeevent").hide();
826 if (!
GETPOST(
'usage_organize_event')) {
827 print
'jQuery(".classuseorganizeevent").hide();';
839 print(!
getDolGlobalString(
'PROJECT_THIRDPARTY_REQUIRED') ?
'' :
'<span class="fieldrequired">');
840 print $langs->trans(
"ThirdParty");
842 print
'</td><td class="maxwidthonsmartphone">';
847 $text =
img_picto(
'',
'company',
'class="pictofixedwidth"').$form->select_company(
GETPOSTINT(
'socid'),
'socid', $filter,
'SelectThirdParty', 1, 0, array(), 0,
'minwidth300 widthcentpercentminusxx maxwidth500');
849 $texthelp = $langs->trans(
"IfNeedToUseOtherObjectKeepEmpty");
850 print $form->textwithtooltip($text.
' '.
img_help(), $texthelp, 1);
855 $url =
'/societe/card.php?action=create&customer=3&fournisseur=0&backtopage='.urlencode($_SERVER[
"PHP_SELF"].
'?action=create');
856 $newbutton =
'<span class="fa fa-plus-circle valignmiddle paddingleft" title="'.$langs->trans(
"AddThirdParty").
'"></span>';
859 $jsonclose =
'TODO Not yet implemented';
862 print
' <a href="'.DOL_URL_ROOT.$url.
'">'.$newbutton.
'</a>';
870 print
'<tr><td>'.$langs->trans(
"Status").
'</td><td>';
871 print
'<input type="hidden" name="status" value="'.$status.
'">';
872 print
$object->LibStatut($status, 4);
878 print
'<tr class="classuseopportunity"><td><span class="fieldrequired">'.$langs->trans(
"OpportunityStatus").
'</span></td>';
879 print
'<td class="maxwidthonsmartphone">';
880 print $formproject->selectOpportunityStatus(
'opp_status',
GETPOSTISSET(
'opp_status') ?
GETPOST(
'opp_status') :
$object->opp_status, 1, 0, 0, 0,
'', 0, 1);
883 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>';
884 print
'<input type="hidden" name="opp_percent_not_set" id="opp_percent_not_set" value="'.dol_escape_htmltag(
GETPOSTISSET(
'opp_percent') ?
'0' :
'1').
'">';
889 print
'<tr class="classuseopportunity"><td>'.$langs->trans(
"OpportunityAmount").
'</td>';
890 print
'<td><input class="width75 right" type="text" name="opp_amount" value="'.dol_escape_htmltag(
GETPOSTISSET(
'opp_amount') ?
GETPOST(
'opp_amount') :
'').
'">';
891 print
' '.$langs->getCurrencySymbol(
$conf->currency);
897 print
'<tr><td>'.$langs->trans(
"Budget").
'</td>';
898 print
'<td><input class="width75 right" type="text" name="budget_amount" value="'.dol_escape_htmltag(
GETPOSTISSET(
'budget_amount') ?
GETPOST(
'budget_amount') :
'').
'">';
899 print
' '.$langs->getCurrencySymbol(
$conf->currency);
904 print
'<tr><td>'.$langs->trans(
"Date").(isModEnabled(
'eventorganization') ?
' <span class="classuseorganizeevent">('.$langs->trans(
"Project").
')</span>' :
'').
'</td><td>';
906 print
' <span class="opacitymedium"> '.$langs->trans(
"to").
' </span> ';
907 print $form->selectDate(($date_end ? $date_end : -1),
'projectend', 0, 0, 0,
'', 1, 0);
912 print
'<tr class="classuseorganizeevent"><td>'.$langs->trans(
"Date").
' ('.$langs->trans(
"Event").
')</td><td>';
913 print $form->selectDate(($date_start_event ? $date_start_event : -1),
'date_start_event', 1, 1, 1,
'', 1, 0);
914 print
' <span class="opacitymedium"> '.$langs->trans(
"to").
' </span> ';
915 print $form->selectDate(($date_end_event ? $date_end_event : -1),
'date_end_event', 1, 1, 1,
'', 1, 0);
919 print
'<tr class="classuseorganizeevent"><td>'.$langs->trans(
"Location").
'</td>';
920 print
'<td><input class="minwidth300 maxwidth500" type="text" name="location" value="'.dol_escape_htmltag($location).
'"></td>';
925 print
'<tr><td class="tdtop">'.$langs->trans(
"Description").
'</td>';
927 $doleditor =
new DolEditor(
'description',
GETPOST(
"description",
'restricthtml'),
'', 90,
'dolibarr_notes',
'',
false,
true,
isModEnabled(
'fckeditor') &&
getDolGlobalString(
'FCKEDITOR_ENABLE_SOCIETE'), ROWS_3,
'90%');
928 $doleditor->Create();
933 print
'<tr><td>'.$langs->trans(
"Categories").
'</td><td colspan="3">';
934 print $form->selectCategories(Categorie::TYPE_PROJECT,
'categories', $object);
939 print
'<tr><td>'.$langs->trans(
"Visibility").
'</td><td class="maxwidthonsmartphone">';
942 $array[0] = $langs->trans(
"PrivateProject");
945 $array[1] = $langs->trans(
"SharedProject");
948 if (count($array) > 0) {
949 print $form->selectarray(
'public', $array,
GETPOSTINT(
'public') ? 1 : 0, 0, 0, 0,
'', 0, 0, 0,
'',
'minwidth200', 1);
951 print
'<input type="hidden" name="public" id="public" value="'.(GETPOSTINT(
'public') ? 1 : 0).
'">';
954 print
img_picto($langs->trans(
'PrivateProject'),
'private',
'class="paddingrightonly"');
955 print $langs->trans(
"PrivateProject");
957 print
img_picto($langs->trans(
'SharedProject'),
'world',
'class="paddingrightonly"');
958 print $langs->trans(
"SharedProject");
964 print
'<tr><td class="tdtop">'.$langs->trans(
"ProjectContactTypeManager").
'</td>';
966 $contactList =
$object->liste_type_contact(
'internal',
'position', 1);
967 $typeofcontact =
GETPOST(
'typeofcontact') ?
GETPOST(
'typeofcontact') :
'PROJECTLEADER';
968 print $form->selectarray(
'typeofcontact', $contactList, $typeofcontact, 0, 0, 0,
'', 0, 0, 0,
'',
'minwidth200', 1);
972 $parameters = array();
973 $reshook = $hookmanager->executeHooks(
'formObjectOptions', $parameters, $object, $action);
974 print $hookmanager->resPrint;
975 if (empty($reshook)) {
976 print
$object->showOptionals($extrafields,
'create');
983 print $form->buttonsSaveCancel(
'CreateDraft');
989 print
'<script type="text/javascript">
990 jQuery(document).ready(function() {
991 function change_percent()
993 var element = jQuery("#opp_status option:selected");
994 var defaultpercent = element.attr("defaultpercent");
995 /*if (jQuery("#opp_percent_not_set").val() == "") */
996 /* defaultpercent is the raw DB value (double(5,2), ie "100.00"), so normalize it */
997 jQuery("#opp_percent").val(parseFloat(defaultpercent));
1001 jQuery("#opp_status").change(function() {
1005 jQuery("#usage_task").change(function() {
1006 console.log("We click on usage task "+jQuery("#usage_task").is(":checked"));
1007 if (! jQuery("#usage_task").is(":checked")) {
1008 jQuery("#usage_bill_time").prop("checked", false);
1012 jQuery("#usage_bill_time").change(function() {
1013 console.log("We click on usage to bill time");
1014 if (jQuery("#usage_bill_time").is(":checked")) {
1015 jQuery("#usage_task").prop("checked", true);
1025 $res =
$object->fetch_optionals();
1028 $userAccess =
$object->restrictedProjectArea($user,
'read');
1029 $userWrite =
$object->restrictedProjectArea($user,
'write');
1030 $userDelete =
$object->restrictedProjectArea($user,
'delete');
1036 if ($action ==
'validate') {
1037 $text = $langs->trans(
'ConfirmValidateProject');
1038 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'ValidateProject'), $text,
'confirm_validate',
'', 0, 1);
1041 if ($action ==
'close') {
1042 $text = $langs->trans(
"ConfirmCloseAProject");
1043 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
"?id=".
$object->id, $langs->trans(
"CloseAProject"), $text,
"confirm_close",
'',
'', 1);
1046 if ($action ==
'reopen') {
1047 $text = $langs->trans(
"ConfirmReOpenAProject");
1048 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
"?id=".
$object->id, $langs->trans(
"ReOpenAProject"), $text,
"confirm_reopen",
'',
'', 1);
1051 if ($action ==
'delete') {
1052 $text = $langs->trans(
"ConfirmDeleteAProject");
1054 $taskarray = $task->getTasksArray(
null,
null,
$object->id, 0, 0);
1055 $nboftask = count($taskarray);
1057 $text .=
'<br>'.img_warning().
' '.$langs->trans(
"ThisWillAlsoRemoveTasks", $nboftask);
1059 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
"?id=".
$object->id, $langs->trans(
"DeleteAProject"), $text,
"confirm_delete",
'',
'', 1);
1063 if ($action ==
'clone') {
1064 $text = $langs->trans(
"ConfirmCloneProject");
1065 $formquestion = array(
1066 'text' => $langs->trans(
"ConfirmClone"),
1067 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, array(), 0,
'minwidth200 maxwidth250')),
1068 1 => array(
'type' =>
'checkbox',
'name' =>
'clone_contacts',
'label' => $langs->trans(
"CloneContacts"),
'value' => true),
1069 2 => array(
'type' =>
'checkbox',
'name' =>
'clone_tasks',
'label' => $langs->trans(
"CloneTasks"),
'value' => true),
1070 3 => array(
'type' =>
'checkbox',
'name' =>
'move_date',
'label' => $langs->trans(
"CloneMoveDate"),
'value' => true),
1071 4 => array(
'type' =>
'checkbox',
'name' =>
'clone_notes',
'label' => $langs->trans(
"CloneNotes"),
'value' => true),
1072 5 => array(
'type' =>
'checkbox',
'name' =>
'clone_project_files',
'label' => $langs->trans(
"CloneProjectFiles"),
'value' => false),
1073 6 => array(
'type' =>
'checkbox',
'name' =>
'clone_task_files',
'label' => $langs->trans(
"CloneTaskFiles"),
'value' => false)
1076 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
"?id=".
$object->id, $langs->trans(
"ToClone"), $text,
"confirm_clone", $formquestion,
'', 1, 400, 590);
1080 $parameters = array(
'formConfirm' => $formconfirm);
1081 $reshook = $hookmanager->executeHooks(
'formConfirm', $parameters, $object, $action);
1082 if (empty($reshook)) {
1083 $formconfirm .= $hookmanager->resPrint;
1084 } elseif ($reshook > 0) {
1085 $formconfirm = $hookmanager->resPrint;
1092 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
1093 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1094 print
'<input type="hidden" name="action" value="update">';
1095 print
'<input type="hidden" name="id" value="'.$object->id.
'">';
1096 print
'<input type="hidden" name="comefromclone" value="'.$comefromclone.
'">';
1100 if ($action ==
'edit' && $userWrite > 0) {
1103 print
'<table class="border centpercent">';
1107 print
'<tr><td class="titlefield fieldrequired">'.$langs->trans(
"Ref").
'</td>';
1108 print
'<td><input class="width200" name="ref" value="'.$suggestedref.
'">';
1109 print
' '.$form->textwithpicto(
'', $langs->trans(
"YouCanCompleteRef", $suggestedref));
1113 print
'<tr><td class="fieldrequired">'.$langs->trans(
"Label").
'</td>';
1114 print
'<td><input class="quatrevingtpercent" name="title" value="'.dol_escape_htmltag(
$object->title).
'"></td></tr>';
1117 print
'<tr><td class="fieldrequired">'.$langs->trans(
"Status").
'</td><td>';
1118 print
'<select class="flat" name="status" id="status">';
1119 $statuses =
$object->labelStatusShort;
1121 unset($statuses[$object::STATUS_DRAFT]);
1123 foreach ($statuses as $key => $val) {
1124 print
'<option value="'.$key.
'"'.((
GETPOSTISSET(
'status') ?
GETPOST(
'status') :
$object->
status) == $key ?
' selected="selected"' :
'').
'>'.$langs->trans($val).
'</option>';
1132 print
'<tr><td>'.$langs->trans(
"Parent").
'</td><td class="maxwidthonsmartphone">';
1133 print
img_picto(
'',
'project',
'class="pictofixedwidth"');
1134 $formproject->select_projects(-1, (
string)
$object->fk_project,
'fk_project', 64, 0, 1, 1, 0, 0, 0,
'', 0, 0,
'',
'',
'');
1140 print
'<tr><td class="tdtop">';
1141 print $langs->trans(
"Usage");
1145 print
'<input type="checkbox" id="usage_opportunity" name="usage_opportunity"'.(GETPOSTISSET(
'usage_opportunity') ? (
GETPOST(
'usage_opportunity',
'alpha') !=
'' ?
' checked="checked"' :
'') : (
$object->usage_opportunity ?
' checked="checked"' :
'')).
'> ';
1146 $htmltext = $langs->trans(
"ProjectFollowOpportunity");
1147 print
'<label for="usage_opportunity">'.$form->textwithpicto($langs->trans(
"ProjectFollowOpportunity"), $htmltext).
'</label>';
1149 print
'$( document ).ready(function() {
1150 jQuery("#usage_opportunity").change(function() {
1151 set_usage_opportunity();
1154 set_usage_opportunity();
1156 function set_usage_opportunity() {
1157 console.log("set_usage_opportunity");
1158 if (jQuery("#usage_opportunity").prop("checked")) {
1159 console.log("Show opportunities fields");
1160 jQuery(".classuseopportunity").show();
1162 console.log("Hide opportunities fields "+jQuery("#usage_opportunity").prop("checked"));
1163 jQuery(".classuseopportunity").hide();
1171 print
'<input type="checkbox" id="usage_task" name="usage_task"' . (
GETPOSTISSET(
'usage_task') ? (
GETPOST(
'usage_task',
'alpha') !=
'' ?
' checked="checked"' :
'') : (
$object->usage_task ?
' checked="checked"' :
'')) .
'> ';
1172 $htmltext = $langs->trans(
"ProjectFollowTasks");
1173 print
'<label for="usage_task">'.$form->textwithpicto($langs->trans(
"ProjectFollowTasks"), $htmltext).
'</label>';
1175 print
'$( document ).ready(function() {
1176 jQuery("#usage_task").change(function() {
1182 function set_usage_task() {
1183 console.log("set_usage_task");
1184 if (jQuery("#usage_task").prop("checked")) {
1185 console.log("Show task fields");
1186 jQuery(".classusetask").show();
1188 console.log("Hide task fields "+jQuery("#usage_task").prop("checked"));
1189 jQuery(".classusetask").hide();
1197 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"' :
'')) .
'> ';
1198 $htmltext = $langs->trans(
"ProjectBillTimeDescription");
1199 print
'<label for="usage_bill_time">'.$form->textwithpicto($langs->trans(
"BillTime"), $htmltext).
'</label>';
1201 print
'$( document ).ready(function() {
1202 jQuery("#usage_bill_time").change(function() {
1203 set_usage_bill_time();
1206 set_usage_bill_time();
1208 function set_usage_bill_time() {
1209 console.log("set_usage_bill_time");
1210 if (jQuery("#usage_bill_time").prop("checked")) {
1211 console.log("Show bill time fields");
1212 jQuery(".classusebilltime").show();
1214 console.log("Hide bill time fields "+jQuery("#usage_bill_time").prop("checked"));
1215 jQuery(".classusebilltime").hide();
1223 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"' :
'')) .
'> ';
1224 $htmltext = $langs->trans(
"EventOrganizationDescriptionLong");
1225 print
'<label for="usage_organize_event">'.$form->textwithpicto($langs->trans(
"ManageOrganizeEvent"), $htmltext).
'</label>';
1227 print
'$( document ).ready(function() {
1228 jQuery("#usage_organize_event").change(function() {
1234 function set_usage_event() {
1235 console.log("set_usage_event");
1236 if (jQuery("#usage_organize_event").prop("checked")) {
1237 console.log("Show organize event fields");
1238 jQuery(".classuseorganizeevent").show();
1240 console.log("Hide organize event fields "+jQuery("#usage_organize_event").prop("checked"));
1241 jQuery(".classuseorganizeevent").hide();
1254 print(!
getDolGlobalString(
'PROJECT_THIRDPARTY_REQUIRED') ?
'' :
'<span class="fieldrequired">');
1255 print $langs->trans(
"ThirdParty");
1262 $text =
img_picto(
'',
'company',
'class="pictofixedwidth"');
1263 $text .= $form->select_company(!empty(
$object->thirdparty->id) ?
$object->thirdparty->id :
"",
'socid', $filter,
'None', 1, 0, array(), 0,
'minwidth300');
1265 $texthelp = $langs->trans(
"IfNeedToUseOtherObjectKeepEmpty");
1266 print $form->textwithtooltip($text.
' '.
img_help(), $texthelp, 1, 0,
'',
'', 2);
1274 $classfortr = (
$object->usage_opportunity ?
'' :
' hideobject');
1276 print
'<tr class="classuseopportunity'.$classfortr.
'"><td>'.$langs->trans(
"OpportunityStatus").
'</td>';
1279 print $formproject->selectOpportunityStatus(
'opp_status', (
string)
$object->opp_status, 1, 0, 0, 0,
'minwidth150 inline-block valignmiddle', 1, 1);
1282 print
' <input class="width50 right valignmiddle" 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) :
'')).
'"> %';
1283 print
'<span id="oldopppercent" class="opacitymedium"></span>';
1286 print
'<div id="divtocloseproject" class="inline-block valign clearboth paddingtop" style="display: none;">';
1287 print
'<input type="checkbox" id="inputcloseproject" name="closeproject" class="valignmiddle" />';
1288 print
'<label for="inputcloseproject" class="opacitymedium valignmiddle">';
1289 print $form->textwithpicto($langs->trans(
"AlsoCloseAProject"), $langs->trans(
"AlsoCloseAProjectTooltip"));
1297 print
'<tr class="classuseopportunity'.$classfortr.
'"><td>'.$langs->trans(
"OpportunityAmount").
'</td>';
1298 print
'<td><input class="width75 right marginright2" type="text" name="opp_amount" value="'.(GETPOSTISSET(
'opp_amount') ?
GETPOST(
'opp_amount') : (strcmp(
$object->opp_amount,
'') ?
price2num(
$object->opp_amount) :
'')).
'">';
1299 print
'<span class="opacitymedium">'.$langs->getCurrencySymbol(
$conf->currency).
'</span>';
1305 print
'<tr><td>'.$langs->trans(
"Budget").
'</td>';
1306 print
'<td><input class="width75 right marginright2" type="text" name="budget_amount" value="'.(GETPOSTISSET(
'budget_amount') ?
GETPOST(
'budget_amount') : (strcmp(
$object->budget_amount,
'') ?
price2num(
$object->budget_amount) :
'')).
'">';
1307 print
'<span class="opacitymedium">'.$langs->getCurrencySymbol(
$conf->currency).
'</span>';
1312 print
'<tr><td>'.$langs->trans(
"Date").(isModEnabled(
'eventorganization') ?
' <span class="classuseorganizeevent">('.$langs->trans(
"Project").
')</span>' :
'').
'</td><td>';
1313 print $form->selectDate(
$object->date_start ?
$object->date_start : -1,
'projectstart', 0, 0, 0,
'', 1, 0);
1314 print
' <span class="opacitymedium"> '.$langs->trans(
"to").
' </span> ';
1315 print $form->selectDate(
$object->date_end ?
$object->date_end : -1,
'projectend', 0, 0, 0,
'', 1, 0);
1316 $object->getLinesArray(
null, 0);
1318 print
' <span id="divreportdate" class="hidden"> <input type="checkbox" class="valignmiddle" id="reportdate" name="reportdate" value="yes" ';
1319 if ($comefromclone) {
1322 print
'/><label for="reportdate" class="valignmiddle opacitymedium">'.$langs->trans(
"ProjectReportDate").
'</label></span>';
1328 print
'<tr class="classuseorganizeevent"><td>'.$langs->trans(
"Date").
' ('.$langs->trans(
"Event").
')</td><td>';
1329 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);
1330 print
' <span class="opacitymedium"> '.$langs->trans(
"to").
' </span> ';
1331 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);
1335 print
'<tr class="classuseorganizeevent"><td>'.$langs->trans(
"Location").
'</td>';
1336 print
'<td><input class="minwidth300 maxwidth500" type="text" name="location" value="'.dol_escape_htmltag(
GETPOSTISSET(
'location') ?
GETPOST(
'location') :
$object->location).
'"></td>';
1341 print
'<tr><td class="tdtop">'.$langs->trans(
"Description").
'</td>';
1343 $doleditor =
new DolEditor(
'description',
$object->description,
'', 90,
'dolibarr_notes',
'',
false,
true,
isModEnabled(
'fckeditor') &&
getDolGlobalInt(
'FCKEDITOR_ENABLE_SOCIETE'), ROWS_3,
'90%');
1344 $doleditor->Create();
1349 print
'<tr><td>'.$langs->trans(
"Categories").
'</td><td>';
1350 print $form->selectCategories(Categorie::TYPE_PROJECT,
'categories', $object);
1355 print
'<tr><td>'.$langs->trans(
"Visibility").
'</td><td>';
1358 $array[0] = $langs->trans(
"PrivateProject");
1361 $array[1] = $langs->trans(
"SharedProject");
1364 if (count($array) > 0) {
1365 print $form->selectarray(
'public', $array,
$object->public, 0, 0, 0,
'', 0, 0, 0,
'',
'', 1);
1367 print
'<input type="hidden" id="public" name="public" value="'.$object->public.
'">';
1370 print
img_picto($langs->trans(
'PrivateProject'),
'private',
'class="paddingrightonly"');
1371 print $langs->trans(
"PrivateProject");
1373 print
img_picto($langs->trans(
'SharedProject'),
'world',
'class="paddingrightonly"');
1374 print $langs->trans(
"SharedProject");
1380 $parameters = array();
1381 $reshook = $hookmanager->executeHooks(
'formObjectOptions', $parameters, $object, $action);
1382 print $hookmanager->resPrint;
1383 if (empty($reshook)) {
1384 print
$object->showOptionals($extrafields,
'edit');
1389 print
dol_get_fiche_head($head,
'project', $langs->trans(
"Project"), -1, (
$object->public ?
'projectpub' :
'project'), 0,
'',
'', 0,
'', 1);
1393 if (!empty($_SESSION[
'pageforbacktolist']) && !empty($_SESSION[
'pageforbacktolist'][
'project'])) {
1394 $tmpurl = $_SESSION[
'pageforbacktolist'][
'project'];
1395 $tmpurl = preg_replace(
'/__SOCID__/', (
string)
$object->socid, $tmpurl);
1396 $linkback =
'<a href="'.$tmpurl.(preg_match(
'/\?/', $tmpurl) ?
'&' :
'?').
'restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
1398 $linkback =
'<a href="'.DOL_URL_ROOT.
'/projet/list.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
1401 $morehtmlref =
'<div class="refidno">';
1404 $morehtmlref .=
'<br>';
1406 if (!empty(
$object->thirdparty->id) &&
$object->thirdparty->id > 0) {
1407 $morehtmlref .=
$object->thirdparty->getNomUrl(1,
'project');
1413 $parent->fetch(
$object->fk_project);
1414 $morehtmlref .= $langs->trans(
"Child of").
' '.$parent->getNomUrl(1,
'project').
' '.$parent->title;
1417 $morehtmlref .=
'</div>';
1420 if (!$user->hasRight(
'projet',
'all',
'lire')) {
1421 $objectsListId =
$object->getProjectsAuthorizedForUser($user, 0, 0);
1422 $object->next_prev_filter =
"rowid:IN:".$db->sanitize(count($objectsListId) ? implode(
',', array_keys($objectsListId)) :
'0');
1425 dol_banner_tab($object,
'ref', $linkback, 1,
'ref',
'ref', $morehtmlref);
1427 print
'<div class="fichecenter">';
1428 print
'<div class="fichehalfleft">';
1429 print
'<div class="underbanner clearboth"></div>';
1431 print
'<table class="border tableforfield centpercent">';
1435 print
'<tr><td class="tdtop">';
1436 print $langs->trans(
"Usage");
1440 print
'<input type="checkbox" disabled name="usage_opportunity"'.(GETPOSTISSET(
'usage_opportunity') ? (
GETPOST(
'usage_opportunity',
'alpha') !=
'' ?
' checked="checked"' :
'') : (
$object->usage_opportunity ?
' checked="checked"' :
'')).
'> ';
1441 $htmltext = $langs->trans(
"ProjectFollowOpportunity");
1442 print $form->textwithpicto($langs->trans(
"ProjectFollowOpportunity"), $htmltext);
1446 print
'<input type="checkbox" disabled name="usage_task"'.(GETPOSTISSET(
'usage_task') ? (
GETPOST(
'usage_task',
'alpha') !=
'' ?
' checked="checked"' :
'') : (
$object->usage_task ?
' checked="checked"' :
'')).
'> ';
1447 $htmltext = $langs->trans(
"ProjectFollowTasks");
1448 print $form->textwithpicto($langs->trans(
"ProjectFollowTasks"), $htmltext);
1452 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"' :
'')).
'> ';
1453 $htmltext = $langs->trans(
"ProjectBillTimeDescription");
1454 print $form->textwithpicto($langs->trans(
"BillTime"), $htmltext);
1459 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"' :
'')).
'> ';
1460 $htmltext = $langs->trans(
"EventOrganizationDescriptionLong");
1461 print $form->textwithpicto($langs->trans(
"ManageOrganizeEvent"), $htmltext);
1468 print
'<tr><td>'.$langs->trans(
"OpportunityStatus");
1469 if ($action !=
'edit_opp_status' && $user->hasRight(
'projet',
'creer')) {
1470 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>';
1473 $html_name_status = ($action ==
'edit_opp_status') ?
'opp_status' :
'none';
1474 $html_name_percent = ($action ==
'edit_opp_status') ?
'opp_percent' :
'none';
1476 $formproject->formOpportunityStatus($_SERVER[
'PHP_SELF'].
'?socid='.
$object->id, (
string)
$object->opp_status, $percent_value, $html_name_status, $html_name_percent);
1480 print
'<tr><td>'.$langs->trans(
"OpportunityAmount").
'</td><td>';
1481 if (strcmp(
$object->opp_amount,
'')) {
1482 print
'<span class="amount">'.price(
$object->opp_amount, 0, $langs, 1, 0, -1,
$conf->currency).
'</span>';
1483 if (strcmp(
$object->opp_percent,
'')) {
1484 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>';
1491 print
'<tr><td>'.$langs->trans(
"Budget").
'</td><td>';
1492 if (!is_null(
$object->budget_amount) && strcmp(
$object->budget_amount,
'')) {
1493 print
'<span class="amount">'.price(
$object->budget_amount, 0, $langs, 1, 0, 0,
$conf->currency).
'</span>';
1498 print
'<tr><td>'.$langs->trans(
"Dates").
'</td><td>';
1500 print($start ? $start :
'?');
1502 print
' <span class="opacitymedium">-</span> ';
1503 print($end ? $end :
'?');
1510 print
'<tr><td class="titlefield">'.$langs->trans(
"Visibility").
'</td><td>';
1512 print
img_picto($langs->trans(
'SharedProject'),
'world',
'class="paddingrightonly"');
1513 print $langs->trans(
'SharedProject');
1515 print
img_picto($langs->trans(
'PrivateProject'),
'private',
'class="paddingrightonly"');
1516 print $langs->trans(
'PrivateProject');
1522 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_view.tpl.php';
1527 print
'<div class="fichehalfright">';
1528 print
'<div class="underbanner clearboth"></div>';
1530 print
'<table class="border tableforfield centpercent">';
1534 print
'<tr><td class="valignmiddle">'.$langs->trans(
"Categories").
'</td><td>';
1535 print $form->showCategories(
$object->id, Categorie::TYPE_PROJECT, 1);
1540 print
'<tr><td class="titlefield'.($object->description ?
' noborderbottom' :
'').
'" colspan="2">'.$langs->trans(
"Description").
'</td></tr>';
1542 print
'<tr><td class="nottitleforfield" colspan="2">';
1543 print
'<div class="longmessagecut">';
1554 print
'<div class="clearboth"></div>';
1559 if ($action ==
'edit' && $userWrite > 0) {
1560 print $form->buttonsSaveCancel();
1566 print
'<script type="text/javascript">
1567 jQuery(document).ready(function() {
1568 jQuery("#usage_task").change(function() {
1569 console.log("We click on usage task "+jQuery("#usage_task").is(":checked"));
1570 if (! jQuery("#usage_task").is(":checked")) {
1571 jQuery("#usage_bill_time").prop("checked", false);
1575 jQuery("#usage_bill_time").change(function() {
1576 console.log("We click on usage to bill time");
1577 if (jQuery("#usage_bill_time").is(":checked")) {
1578 jQuery("#usage_task").prop("checked", true);
1582 jQuery("#projectstart").change(function() {
1583 console.log("We modify the start date");
1584 jQuery("#divreportdate").show();
1592 $defaultcheckedwhenoppclose = 1;
1594 $defaultcheckedwhenoppclose = 0;
1597 print
'<!-- Javascript to manage opportunity status change -->';
1598 print
'<script type="text/javascript">
1599 jQuery(document).ready(function() {
1600 function change_percent()
1602 var element = jQuery("#opp_status option:selected");
1603 var defaultpercent = element.attr("defaultpercent");
1604 var defaultcloseproject = '.((int) $defaultcheckedwhenoppclose).
';
1605 var elemcode = element.attr("elemcode");
1608 console.log(
"We select "+elemcode);
1611 var closeproject = 0;
1612 if (elemcode == \
'LOST\') closeproject = 1;
1613 if (elemcode == \'WON\') closeproject = defaultcloseproject;
1614 if (closeproject) jQuery("#inputcloseproject").prop("checked", true);
1615 else jQuery("#inputcloseproject").prop("checked", false);
1617 /* Make the close project checkbox visible or not */
1618 console.log("closeproject="+closeproject);
1619 if (elemcode == \'WON\' || elemcode == \'LOST\')
1621 jQuery("#divtocloseproject").show();
1625 jQuery("#divtocloseproject").hide();
1628 /* Note: defaultpercent and oldpercent hold raw DB values (double(5,2), ie "100.00"),
1629 so they are already in universal numeric format and must not go through price2numjs(),
1630 which would strip the "." as a thousand separator in languages like de_DE. */
1631 /* Change percent with default percent (defaultpercent) if new status (defaultpercent) is higher than current (jQuery("#opp_percent").val()) */
1632 if (oldpercent != \'\' && (parseFloat(defaultpercent) < parseFloat(oldpercent)))
1634 console.log("oldpercent="+oldpercent+" defaultpercent="+defaultpercent+" def < old");
1635 if (jQuery("#opp_percent").val() != \'\' && oldpercent != \'\') {
1636 jQuery("#oldopppercent").text(\' - '.
dol_escape_js($langs->transnoentities(
"PreviousValue")).
': \'+parseFloat(oldpercent)+\' %\');
1639 if (parseFloat(oldpercent) != 100 && elemcode != \'LOST\') { jQuery("#opp_percent").val(parseFloat(oldpercent)); }
1640 else { jQuery("#opp_percent").val(parseFloat(defaultpercent)); }
1642 console.log("oldpercent="+oldpercent+" defaultpercent="+defaultpercent);
1643 if (jQuery("#opp_percent").val() == \'\' || (parseFloat(jQuery("#opp_percent").val()) < parseFloat(defaultpercent))) {
1644 if (jQuery("#opp_percent").val() != \'\' && oldpercent != \'\') {
1645 jQuery("#oldopppercent").text(\' - '.
dol_escape_js($langs->transnoentities(
"PreviousValue")).
': \'+parseFloat(oldpercent)+\' %\');
1647 jQuery("#opp_percent").val(parseFloat(defaultpercent));
1652 jQuery("#opp_status").change(function() {
1664 print
'<div class="tabsAction">';
1665 $parameters = array();
1666 $reshook = $hookmanager->executeHooks(
'addMoreActionsButtons', $parameters, $object, $action);
1668 if (empty($reshook)) {
1669 if ($action !=
"edit" && $action !=
'presend') {
1679 if (empty($user->socid)) {
1681 print
dolGetButtonAction(
'', $langs->trans(
'SendMail'),
'email', $_SERVER[
"PHP_SELF"].
'?action=presend&token='.
newToken().
'&id='.
$object->id.
'&mode=init#formmailbeforetitle',
'');
1701 if ($userWrite > 0) {
1702 print
dolGetButtonAction(
'', $langs->trans(
'SetToDraft'),
'default', $_SERVER[
"PHP_SELF"].
'?action=confirm_setdraft&confirm=yes&token='.
newToken().
'&id='.
$object->id,
'');
1704 print
dolGetButtonAction($langs->trans(
'NotOwnerOfProject'), $langs->trans(
'SetToDraft'),
'default', $_SERVER[
'PHP_SELF'].
'#',
'',
false);
1711 if ($userWrite > 0) {
1714 print
dolGetButtonAction($langs->trans(
'NotOwnerOfProject'), $langs->trans(
'Modify'),
'default', $_SERVER[
'PHP_SELF'].
'#',
'',
false);
1720 if ($userWrite > 0) {
1722 print
dolGetButtonAction(
'', $langs->trans(
'Validate'),
'default', $_SERVER[
"PHP_SELF"].
'?action=confirm_validate&confirm=yes&token='.
newToken().
'&id='.
$object->id,
'');
1724 print
dolGetButtonAction($langs->trans(
'NotOwnerOfProject'), $langs->trans(
'Validate'),
'default', $_SERVER[
'PHP_SELF'].
'#',
'',
false);
1730 if ($userWrite > 0) {
1732 print
dolGetButtonAction(
'', $langs->trans(
'Close'),
'default', $_SERVER[
"PHP_SELF"].
'?action=confirm_close&confirm=yes&token='.
newToken().
'&id='.
$object->id,
'');
1734 print
dolGetButtonAction($langs->trans(
'NotOwnerOfProject'), $langs->trans(
'Close'),
'default', $_SERVER[
'PHP_SELF'].
'#',
'',
false);
1740 if ($userWrite > 0) {
1743 print
dolGetButtonAction($langs->trans(
'NotOwnerOfProject'), $langs->trans(
'ReOpen'),
'default', $_SERVER[
'PHP_SELF'].
'#',
'',
false);
1751 $is_customer_or_prospect = (!empty(
$object->thirdparty->prospect) || !empty(
$object->thirdparty->client));
1752 $is_supplier_only= (!empty(
$object->thirdparty->fournisseur) && !$is_customer_or_prospect);
1754 $arrayforbutaction = array(
1755 10 => array(
'lang'=>
'propal',
'enabled' => (
isModEnabled(
"propal") && $is_customer_or_prospect),
'perm' => $user->hasRight(
'propal',
'creer') ?
true : false,
'label' =>
'AddProp',
'url'=>
'/comm/propal/card.php?action=create&projectid='.
$object->id.
'&socid='.
$object->socid),
1756 20 => array(
'lang'=>
'orders',
'enabled' => (
isModEnabled(
"order") && $is_customer_or_prospect),
'perm' => $user->hasRight(
'commande',
'creer') ? true : false,
'label' =>
'CreateOrder',
'url'=>
'/commande/card.php?action=create&projectid='.
$object->id.
'&socid='.
$object->socid),
1757 30 => array(
'lang'=>
'bills',
'enabled' => (
isModEnabled(
"invoice") && $is_customer_or_prospect),
'perm' => $user->hasRight(
'facture',
'creer') ? true : false,
'label' =>
'CreateBill',
'url'=>
'/compta/facture/card.php?action=create&projectid='.
$object->id.
'&socid='.
$object->socid),
1758 40 => array(
'lang'=>
'supplier_proposal',
'enabled' =>
isModEnabled(
"supplier_proposal"),
'perm' => $user->hasRight(
'supplier_proposal',
'creer') ? true : false,
'label' =>
'AddSupplierProposal',
'url'=>
'/supplier_proposal/card.php?action=create&projectid='.
$object->id.($is_supplier_only ?
'&socid='.
$object->socid :
'')),
1759 50 => array(
'lang'=>
'suppliers',
'enabled' =>
isModEnabled(
"supplier_order"),
'perm' => $user->hasRight(
'fournisseur',
'commande',
'creer') ? true : false,
'label' =>
'AddSupplierOrder',
'url'=>
'/fourn/commande/card.php?action=create&projectid='.
$object->id.($is_supplier_only ?
'&socid='.
$object->socid :
'')),
1760 60 => array(
'lang'=>
'suppliers',
'enabled' =>
isModEnabled(
"supplier_invoice"),
'perm' => $user->hasRight(
'fournisseur',
'facture',
'creer') ? true : false,
'label' =>
'AddSupplierInvoice',
'url'=>
'/fourn/facture/card.php?action=create&projectid='.
$object->id.($is_supplier_only ?
'&socid='.
$object->socid :
'')),
1761 70 => array(
'lang'=>
'interventions',
'enabled' =>
isModEnabled(
"intervention"),
'perm' => $user->hasRight(
'fichinter',
'creer') ? true : false,
'label' =>
'AddIntervention',
'url'=>
'/fichinter/card.php?action=create&projectid='.
$object->id.
'&socid='.
$object->socid),
1762 80 => array(
'lang'=>
'contracts',
'enabled' =>
isModEnabled(
"contract"),
'perm' => $user->hasRight(
'contrat',
'creer') ? true : false,
'label' =>
'AddContract',
'url'=>
'/contrat/card.php?action=create&projectid='.
$object->id.
'&socid='.
$object->socid),
1763 90 => array(
'lang'=>
'trips',
'enabled' =>
isModEnabled(
"expensereport"),
'perm' => $user->hasRight(
'expensereport',
'creer') ? true : false,
'label' =>
'AddTrip',
'url'=>
'/expensereport/card.php?action=create&projectid='.
$object->id.
'&socid='.
$object->socid),
1764 100 => array(
'lang'=>
'donations',
'enabled' =>
isModEnabled(
"don"),
'perm' => $user->hasRight(
'don',
'creer') ? true : false,
'label' =>
'AddDonation',
'url'=>
'/don/card.php?action=create&projectid='.
$object->id.
'&socid='.
$object->socid),
1767 $params = array(
'backtopage' => $_SERVER[
"PHP_SELF"].
'?id='.
$object->id);
1770 print
dolGetButtonAction(
'', $langs->trans(
"Create"),
'default', $arrayforbutaction,
'', 1, $params);
1774 if ($user->hasRight(
'projet',
'creer')) {
1775 if ($userWrite > 0) {
1778 print
dolGetButtonAction($langs->trans(
'NotOwnerOfProject'), $langs->trans(
'ToClone'),
'clone', $_SERVER[
'PHP_SELF'].
'#',
'',
false);
1787 print
dolGetButtonAction($langs->trans(
'NotOwnerOfProject'), $langs->trans(
'Delete'),
'delete', $_SERVER[
'PHP_SELF'].
'#',
'',
false);
1795 if (
GETPOST(
'modelselected')) {
1796 $action =
'presend';
1799 if ($action !=
'presend') {
1800 print
'<div class="fichecenter"><div class="fichehalfleft">';
1801 print
'<a name="builddoc"></a>';
1807 $children =
$object->getChildren();
1809 print
'<table class="centpercent notopnoleftnoright table-fiche-title">';
1810 print
'<tr class="titre"><td class="nobordernopadding valignmiddle col-title">';
1811 print
'<div class="titre inline-block">'.$langs->trans(
'Sub-projects').
'</div>';
1812 print
'</td></tr></table>';
1814 print
'<div class="div-table-responsive-no-min">';
1815 print
'<table class="centpercent noborder'.(!empty($morecss) ?
' '.$morecss :
'').
'">';
1816 print
'<tr class="liste_titre">';
1817 print
getTitleFieldOfList(
'Ref', 0, $_SERVER[
"PHP_SELF"],
'',
'',
'',
'',
'',
'',
'', 1);
1818 print
getTitleFieldOfList(
'Title', 0, $_SERVER[
"PHP_SELF"],
'',
'',
'',
'',
'',
'',
'', 1);
1819 print
getTitleFieldOfList(
'Status', 0, $_SERVER[
"PHP_SELF"],
'',
'',
'',
'',
'',
'',
'', 1);
1824 foreach ($children as $child) {
1825 $subproject->fetch($child->rowid);
1826 print
'<tr class="oddeven">';
1827 print
'<td class="nowraponall">'.$subproject->getNomUrl(1,
'project').
'</td>';
1828 print
'<td class="nowraponall tdoverflowmax125">'.$child->title.
'</td>';
1829 print
'<td class="nowraponall">'.$subproject->getLibStatut(5).
'</td>';
1843 $urlsource = $_SERVER[
"PHP_SELF"].
"?id=".
$object->id;
1844 $genallowed = ($user->hasRight(
'projet',
'lire') && $userAccess > 0);
1845 $delallowed = ($user->hasRight(
'projet',
'creer') && $userWrite > 0);
1847 print $formfile->showdocuments(
'project', $filename, $filedir, $urlsource, (
int) $genallowed, (int) $delallowed,
$object->model_pdf, 1, 0, 0, 0, 0,
'',
'',
'',
'',
'', $object);
1849 print
'</div><div class="fichehalfright">';
1853 $morehtmlcenter =
'<div class="nowraponall">';
1854 $morehtmlcenter .=
dolGetButtonTitle($langs->trans(
'FullConversation'),
'',
'fa fa-comments imgforviewmode', DOL_URL_ROOT.
'/projet/messaging.php?id='.
$object->id);
1855 $morehtmlcenter .=
dolGetButtonTitle($langs->trans(
'FullList'),
'',
'fa fa-bars imgforviewmode', DOL_URL_ROOT.
'/projet/agenda.php?id='.
$object->id);
1856 $morehtmlcenter .=
'</div>';
1859 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formactions.class.php';
1861 $somethingshown = $formactions->showactions($object,
'project', 0, 1,
'', $MAXEVENT,
'', $morehtmlcenter);
1863 print
'</div></div>';
1867 $modelmail =
'project';
1868 $defaulttopic =
'SendProjectRef';
1869 $defaulttopiclang =
'projects';
1871 $autocopy =
'MAIN_MAIL_AUTOCOPY_PROJECT_TO';
1872 $trackid =
'proj'.$object->id;
1874 include DOL_DOCUMENT_ROOT.
'/core/tpl/card_presend.tpl.php';
1877 $parameters = array();
1878 $reshook = $hookmanager->executeHooks(
'mainCardTabAddMore', $parameters, $object, $action);
$id
Support class for third parties, contacts, members, users or resources.
if(! $sortfield) if(! $sortorder) $object
ajax_combobox($htmlname, $events=array(), $minLengthToAutocomplete=0, $forcefocus=0, $widthTypeOfAutocomplete='resolve', $idforemptyvalue='-1', $morecss='')
Convert a html select field into an ajax combobox.
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
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.
print $langs trans("Ref").' m titre as m m statut as status
Or an array listing all the potential status of the object: array: int of the status => translated la...
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.
$date_start
Variables from include:
dol_now($mode='gmt')
Return date for now.
recordNotFound($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Displays an error page when a record is not found.
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...
dol_getIdFromCode($db, $key, $tablename, $fieldkey='code', $fieldid='id', $entityfilter=0, $filters='', $useCache=true)
Return an id or code from a code or id.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
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_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2, $allowothertags=array())
Show picto whatever it's its name (generic function)
img_warning($titlealt='default', $moreatt='', $morecss='pictowarning')
Show warning logo.
dolPrintHTML($s, $allowiframe=0, $moreallowedtags=array())
Return a string (that can be on several lines) ready to be output on a HTML page.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0, $morecssdiv='')
Show tabs of a record.
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
dolButtonToOpenUrlInDialogPopup($name, $label, $buttonstring, $url, $disabled='', $morecss='classlink button bordertransp', $jsonopen='', $jsonclose='', $accesskey='')
Return HTML code to output a button to open a dialog popup box.
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.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
dol_eval($s, $returnvalue=1, $hideerrors=1, $onlysimplestring='1')
Replace eval function to add more security.
setEventMessage($mesgs, $style='mesgs', $noduplicate=0, $attop=0)
Set event message in dol_events session object.
dol_sanitizeFileName($str, $newstr='_', $unaccent=1, $includequotes=0, $allowdash=0)
Clean a string to use it as a file name.
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.
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.
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'.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0, $nodefault=0)
Return value of a param into GET or POST supervariable.
GETPOSTFLOAT($paramname, $rounding='', $option=2)
Return the value of a $_GET or $_POST supervariable, converted into float.
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.
GETPOSTINT($paramname, $method=0, $nodefault=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
dol_clone($srcobject, $native=2)
Create a clone of instance of object (new instance with same value for each properties) With native =...
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false, $decorate=0)
Output date in a string format according to outputlangs (or langs if not defined).
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='', $morecssonpicto='widthpictotitle')
Load a title with picto.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
isModEnabled($module)
Is Dolibarr module enabled.
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, $nodie=0, $mode='')
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.