32require
'../main.inc.php';
33require_once DOL_DOCUMENT_ROOT.
'/projet/class/project.class.php';
34require_once DOL_DOCUMENT_ROOT.
'/projet/class/task.class.php';
35require_once DOL_DOCUMENT_ROOT.
'/core/lib/project.lib.php';
36require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
37require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formprojet.class.php';
38require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
39require_once DOL_DOCUMENT_ROOT.
'/core/modules/project/modules_project.php';
40require_once DOL_DOCUMENT_ROOT.
'/core/class/extrafields.class.php';
41require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
44$langsLoad = array(
'projects',
'companies');
45if (isModEnabled(
'eventorganization')) {
46 $langsLoad[] =
'eventorganization';
49$langs->loadLangs($langsLoad);
53$action =
GETPOST(
'action',
'aZ09');
54$backtopage =
GETPOST(
'backtopage',
'alpha');
55$backtopageforcancel =
GETPOST(
'backtopageforcancel',
'alpha');
56$backtopagejsfields =
GETPOST(
'backtopagejsfields',
'alpha');
57$cancel =
GETPOST(
'cancel',
'alpha');
58$confirm =
GETPOST(
'confirm',
'aZ09');
61if (!empty($backtopagejsfields)) {
62 $tmpbacktopagejsfields = explode(
':', $backtopagejsfields);
63 $dol_openinpopup = preg_replace(
'/[^a-z0-9_]/i',
'', $tmpbacktopagejsfields[0]);
69$objcanvas =
GETPOST(
"objcanvas",
"alphanohtml");
70$comefromclone =
GETPOST(
"comefromclone",
"alphanohtml");
75$location =
GETPOST(
'location',
'alphanohtml');
79$mine =
GETPOST(
'mode') ==
'mine' ? 1 : 0;
83$hookmanager->initHooks(array(
'projectcard',
'globalcard'));
90if ($id > 0 || !empty($ref)) {
91 $ret =
$object->fetch($id, $ref);
102$extrafields->fetch_name_optionals_label(
$object->table_element);
109if ($id ==
'' && $ref ==
'' && ($action !=
"create" && $action !=
"add" && $action !=
"update" && !
GETPOST(
"cancel"))) {
113$permissiontoadd = $user->hasRight(
'projet',
'creer');
114$permissiontodelete = $user->hasRight(
'projet',
'supprimer');
115$permissiondellink = $user->hasRight(
'projet',
'creer');
116$permissiontoeditextra = $permissiontoadd;
125$parameters = array(
'id' => $socid,
'objcanvas' => $objcanvas);
126$reshook = $hookmanager->executeHooks(
'doActions', $parameters,
$object, $action);
131if (empty($reshook)) {
132 $backurlforlist = DOL_URL_ROOT.
'/projet/list.php';
136 if (
GETPOST(
"comefromclone") == 1) {
137 $result =
$object->delete($user);
139 header(
"Location: index.php");
143 setEventMessages($langs->trans(
"CantRemoveProject", $langs->transnoentitiesnoconv(
"ProjectOverview")),
null,
'errors');
148 if (empty($backtopage) || ($cancel && empty($id))) {
149 if (empty($backtopage) || ($cancel && strpos($backtopage,
'__ID__'))) {
150 if (empty($id) && (($action !=
'add' && $action !=
'create') || $cancel)) {
151 $backtopage = $backurlforlist;
153 $backtopage = DOL_URL_ROOT.
'/projet/card.php?id='.((!empty($id) && $id > 0) ? $id :
'__ID__');
159 if (!empty($backtopageforcancel)) {
160 header(
"Location: ".$backtopageforcancel);
162 } elseif (!empty($backtopage)) {
163 header(
"Location: ".$backtopage);
169 include DOL_DOCUMENT_ROOT.
'/core/actions_dellink.inc.php';
172 if ($action ==
'confirm_setdraft' && $confirm ==
'yes' && $permissiontoadd) {
173 $result =
$object->setStatut($object::STATUS_DRAFT,
null,
'',
'PROJECT_MODIFY');
183 $object->statut = $object::STATUS_DRAFT;
187 if ($action ==
'add' && $permissiontoadd) {
190 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"Ref")),
null,
'errors');
194 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"ProjectLabel")),
null,
'errors');
199 if (
GETPOST(
'usage_opportunity') !=
'' && !(
GETPOST(
'opp_status') > 0)) {
201 setEventMessages($langs->trans(
"ErrorOppStatusRequiredIfUsage"),
null,
'errors');
203 if (
GETPOST(
'opp_amount') !=
'' && !(
GETPOST(
'opp_status') > 0)) {
205 setEventMessages($langs->trans(
"ErrorOppStatusRequiredIfAmount"),
null,
'errors');
228 $object->date_start = $date_start;
230 $object->date_start_event = $date_start_event;
231 $object->date_end_event = $date_end_event;
234 $object->opp_status = $opp_status;
235 $object->opp_percent = $opp_percent;
236 $object->usage_opportunity = (
GETPOST(
'usage_opportunity',
'alpha') ==
'on' ? 1 : 0);
237 $object->usage_task = (
GETPOST(
'usage_task',
'alpha') ==
'on' ? 1 : 0);
238 $object->usage_bill_time = (
GETPOST(
'usage_bill_time',
'alpha') ==
'on' ? 1 : 0);
239 $object->usage_organize_event = (
GETPOST(
'usage_organize_event',
'alpha') ==
'on' ? 1 : 0);
242 $ret = $extrafields->setOptionalsFromPost(
null,
$object);
247 $result =
$object->create($user);
248 if (!$error && $result > 0) {
250 $typeofcontact =
'PROJECTLEADER';
251 $result =
$object->add_contact($user->id, $typeofcontact,
'internal');
257 } elseif ($result < 0) {
258 $langs->load(
"errors");
263 $langs->load(
"errors");
267 if (!$error && !empty(
$object->id) > 0) {
269 $categories =
GETPOST(
'categories',
'array');
270 $result =
$object->setCategories($categories);
272 $langs->load(
"errors");
281 if (!empty($backtopage)) {
282 $backtopage = preg_replace(
'/--IDFORBACKTOPAGE--|__ID__/', (
string)
$object->id, $backtopage);
283 $backtopage = $backtopage.
'&projectid='.
$object->id;
284 header(
"Location: ".$backtopage);
287 header(
"Location:card.php?id=".
$object->id);
292 unset($_POST[
"ref"]);
300 if ($action ==
'update' && empty(
GETPOST(
'cancel')) && $permissiontoadd) {
305 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"Ref")),
null,
'errors');
309 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"ProjectLabel")),
null,
'errors');
317 $old_start_date =
$object->date_start;
326 $object->date_start = (!
GETPOST(
'projectstart')) ?
'' : $date_start;
328 $object->date_start_event = (!
GETPOST(
'date_start_event')) ?
'' : $date_start_event;
329 $object->date_end_event = (!
GETPOST(
'date_end_event')) ?
'' : $date_end_event;
331 if (GETPOSTISSET(
'opp_amount')) {
334 if (GETPOSTISSET(
'budget_amount')) {
337 if (GETPOSTISSET(
'opp_status')) {
338 $object->opp_status = $opp_status;
340 if (GETPOSTISSET(
'opp_percent')) {
341 $object->opp_percent = $opp_percent;
343 $object->usage_opportunity = (
GETPOST(
'usage_opportunity',
'alpha') ==
'on' ? 1 : 0);
344 $object->usage_task = (
GETPOST(
'usage_task',
'alpha') ==
'on' ? 1 : 0);
345 $object->usage_bill_time = (
GETPOST(
'usage_bill_time',
'alpha') ==
'on' ? 1 : 0);
346 $object->usage_organize_event = (
GETPOST(
'usage_organize_event',
'alpha') ==
'on' ? 1 : 0);
349 $ret = $extrafields->setOptionalsFromPost(
null,
$object,
'@GETPOSTISSET');
358 setEventMessages($langs->trans(
"ErrorOppStatusRequiredIfAmount"),
null,
'errors');
363 $result =
$object->update($user);
373 $categories =
GETPOST(
'categories',
'array');
374 $result =
$object->setCategories($categories);
383 if (
GETPOST(
"reportdate") && (
$object->date_start != $old_start_date)) {
384 $result =
$object->shiftTaskDate($old_start_date);
394 $resclose =
$object->setClose($user);
416 if ($action ==
'set_opp_status' && $user->hasRight(
'projet',
'creer')) {
418 if (GETPOSTISSET(
'opp_status')) {
419 $object->opp_status = $opp_status;
421 if (GETPOSTISSET(
'opp_percent')) {
422 $object->opp_percent = $opp_percent;
428 setEventMessages($langs->trans(
"ErrorOppStatusRequiredIfAmount"),
null,
'errors');
433 $result =
$object->update($user);
453 if ($action ==
'builddoc' && $permissiontoadd) {
459 $outputlangs = $langs;
460 if (
GETPOST(
'lang_id',
'aZ09')) {
462 $outputlangs->setDefaultLang(
GETPOST(
'lang_id',
'aZ09'));
464 $result =
$object->generateDocument(
$object->model_pdf, $outputlangs);
472 if ($action ==
'remove_file' && $permissiontoadd) {
474 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
476 $langs->load(
"other");
477 $upload_dir = $conf->project->multidir_output[
$object->entity];
478 $file = $upload_dir.
'/'.
GETPOST(
'file');
490 if ($action ==
'confirm_validate' && $confirm ==
'yes' && $permissiontoadd) {
491 $result =
$object->setValid($user);
497 if ($action ==
'confirm_close' && $confirm ==
'yes' && $permissiontoadd) {
498 $result =
$object->setClose($user);
504 if ($action ==
'confirm_reopen' && $confirm ==
'yes' && $permissiontoadd) {
505 $result =
$object->setValid($user);
511 if ($action ==
'confirm_delete' && $confirm ==
'yes' && $permissiontodelete) {
513 $result =
$object->delete($user);
517 if (!empty($_SESSION[
'pageforbacktolist']) && !empty($_SESSION[
'pageforbacktolist'][
'project'])) {
518 $tmpurl = $_SESSION[
'pageforbacktolist'][
'project'];
519 $tmpurl = preg_replace(
'/__SOCID__/', (
string)
$object->socid, $tmpurl);
520 $urlback = $tmpurl.(preg_match(
'/\?/', $tmpurl) ?
'&' :
'?').
'restore_lastsearch_values=1';
522 $urlback = DOL_URL_ROOT.
'/projet/list.php?restore_lastsearch_values=1';
525 header(
"Location: ".$urlback);
533 if ($action ==
'confirm_clone' && $permissiontoadd && $confirm ==
'yes') {
534 $clone_contacts =
GETPOST(
'clone_contacts') ? 1 : 0;
535 $clone_tasks =
GETPOST(
'clone_tasks') ? 1 : 0;
536 $clone_project_files =
GETPOST(
'clone_project_files') ? 1 : 0;
537 $clone_task_files =
GETPOST(
'clone_task_files') ? 1 : 0;
538 $clone_notes =
GETPOST(
'clone_notes') ? 1 : 0;
539 $move_date =
GETPOST(
'move_date') ? 1 : 0;
542 $result =
$object->createFromClone($user,
$object->id, $clone_contacts, $clone_tasks, $clone_project_files, $clone_task_files, $clone_notes, $move_date, 0, $clone_thirdparty);
548 $newobject->fetch($result);
550 setEventMessages($langs->trans(
"ProjectCreatedInDolibarr", $newobject->ref),
"",
'mesgs');
552 header(
'Location: '.$_SERVER[
'PHP_SELF'].
'?id='.$result.
'&action=edit&comefromclone=1');
558 if ($action ==
'update_extras' && $permissiontoeditextra) {
561 $attribute_name =
GETPOST(
'attribute',
'aZ09');
564 $ret = $extrafields->setOptionalsFromPost(
null,
$object, $attribute_name);
570 $result =
$object->updateExtraField($attribute_name,
'PROJECT_MODIFY');
578 $action =
'edit_extras';
583 $triggersendname =
'PROJECT_SENTBYMAIL';
585 $autocopy =
'MAIN_MAIL_AUTOCOPY_PROJECT_TO';
586 $trackid =
'proj'.$object->id;
587 include DOL_DOCUMENT_ROOT.
'/core/actions_sendmails.inc.php';
595$form =
new Form($db);
598$userstatic =
new User($db);
600$title = $langs->trans(
"Project").
' - '.
$object->ref.(!empty(
$object->thirdparty->name) ?
' - '.$object->thirdparty->name :
'').(!empty(
$object->title) ?
' - '.$object->title :
'');
602 $title =
$object->ref.(!empty(
$object->thirdparty->name) ?
' - '.$object->thirdparty->name :
'').(!empty(
$object->title) ?
' - '.$object->title :
'');
605$help_url =
"EN:Module_Projects|FR:Module_Projets|ES:Módulo_Proyectos|DE:Modul_Projekte";
609$titleboth = $langs->trans(
"LeadsOrProjects");
610$titlenew = $langs->trans(
"NewLeadOrProject");
612 $titleboth = $langs->trans(
"Projects");
613 $titlenew = $langs->trans(
"NewProject");
616 $titleboth = $langs->trans(
"Leads");
617 $titlenew = $langs->trans(
"NewLead");
620if ($action ==
'create' && $user->hasRight(
'projet',
'creer')) {
625 $thirdparty =
new Societe($db);
627 $thirdparty->fetch($socid);
632 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
633 print
'<input type="hidden" name="action" value="add">';
634 print
'<input type="hidden" name="token" value="'.newToken().
'">';
635 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
636 print
'<input type="hidden" name="backtopageforcancel" value="'.$backtopageforcancel.
'">';
637 print
'<input type="hidden" name="backtopagejsfields" value="'.$backtopagejsfields.
'">';
638 print
'<input type="hidden" name="dol_openinpopup" value="'.$dol_openinpopup.
'">';
642 print
'<table class="border centpercent tableforfieldcreate">';
645 $modele = !
getDolGlobalString(
'PROJECT_ADDON') ?
'mod_project_simple' : $conf->global->PROJECT_ADDON;
651 $dirmodels = array_merge(array(
'/'), (array) $conf->modules_parts[
'models']);
652 foreach ($dirmodels as $reldir) {
653 $file =
dol_buildpath($reldir.
"core/modules/project/".$modele.
'.php', 0);
654 if (file_exists($file)) {
656 $classname = $modele;
663 $modProject =
new $classname();
665 $defaultref = $modProject->getNextValue($thirdparty,
$object);
668 if (is_numeric($defaultref) && $defaultref <= 0) {
674 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).
'">';
676 print
' '.$form->textwithpicto(
'', $langs->trans(
"YouCanCompleteRef", $suggestedref));
681 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>';
685 print
'<tr><td>'.$langs->trans(
"Parent").
'</td><td class="maxwidthonsmartphone">';
686 print
img_picto(
'',
'project',
'class="pictofixedwidth"');
687 $formproject->select_projects(-1,
'',
'fk_project', 64, 0, 1, 1, 0, 0, 0,
'', 0, 0,
'',
'',
'');
693 print
'<tr><td class="tdtop">';
694 print $langs->trans(
"Usage");
698 print
'<input type="checkbox" id="usage_opportunity" name="usage_opportunity"'.(GETPOSTISSET(
'usage_opportunity') ? (
GETPOST(
'usage_opportunity',
'alpha') ?
' checked="checked"' :
'') :
' checked="checked"').
'"> ';
699 $htmltext = $langs->trans(
"ProjectFollowOpportunity");
700 print
'<label for="usage_opportunity">'.$form->textwithpicto($langs->trans(
"ProjectFollowOpportunity"), $htmltext).
'</label>';
702 print
'$( document ).ready(function() {
703 jQuery("#usage_opportunity").change(function() {
704 if (jQuery("#usage_opportunity").prop("checked")) {
705 console.log("Show opportunities fields");
706 jQuery(".classuseopportunity").show();
708 console.log("Hide opportunities fields "+jQuery("#usage_opportunity").prop("checked"));
709 jQuery(".classuseopportunity").hide();
713 if (GETPOSTISSET(
'usage_opportunity') && !
GETPOST(
'usage_opportunity')) {
714 print
'jQuery(".classuseopportunity").hide();';
721 print
'<input type="checkbox" id="usage_task" name="usage_task"'.(GETPOSTISSET(
'usage_task') ? (
GETPOST(
'usage_task',
'alpha') ?
' checked="checked"' :
'') :
' checked="checked"').
'"> ';
722 $htmltext = $langs->trans(
"ProjectFollowTasks");
723 print
'<label for="usage_task">'.$form->textwithpicto($langs->trans(
"ProjectFollowTasks"), $htmltext).
'</label>';
725 print
'$( document ).ready(function() {
726 jQuery("#usage_task").change(function() {
727 if (jQuery("#usage_task").prop("checked")) {
728 console.log("Show task fields");
729 jQuery(".classusetask").show();
731 console.log("Hide tasks fields "+jQuery("#usage_task").prop("checked"));
732 jQuery(".classusetask").hide();
736 if (GETPOSTISSET(
'usage_task') && !
GETPOST(
'usage_task')) {
737 print
'jQuery(".classusetask").hide();';
744 print
'<input type="checkbox" id="usage_bill_time" name="usage_bill_time"'.(GETPOSTISSET(
'usage_bill_time') ? (
GETPOST(
'usage_bill_time',
'alpha') ?
' checked="checked"' :
'') :
'').
'"> ';
745 $htmltext = $langs->trans(
"ProjectBillTimeDescription");
746 print
'<label for="usage_bill_time">'.$form->textwithpicto($langs->trans(
"BillTime"), $htmltext).
'</label>';
748 print
'$( document ).ready(function() {
749 jQuery("#usage_bill_time").change(function() {
750 if (jQuery("#usage_bill_time").prop("checked")) {
751 console.log("Show bill time fields");
752 jQuery(".classusebilltime").show();
754 console.log("Hide bill time fields "+jQuery("#usage_bill_time").prop("checked"));
755 jQuery(".classusebilltime").hide();
759 if (GETPOSTISSET(
'usage_bill_time') && !
GETPOST(
'usage_bill_time')) {
760 print
'jQuery(".classusebilltime").hide();';
766 if (isModEnabled(
'eventorganization')) {
767 print
'<input type="checkbox" id="usage_organize_event" name="usage_organize_event"'.(GETPOSTISSET(
'usage_organize_event') ? (
GETPOST(
'usage_organize_event',
'alpha') ?
' checked="checked"' :
'') :
'').
'"> ';
768 $htmltext = $langs->trans(
"EventOrganizationDescriptionLong");
769 print
'<label for="usage_organize_event">'.$form->textwithpicto($langs->trans(
"ManageOrganizeEvent"), $htmltext).
'</label>';
771 print
'$( document ).ready(function() {
772 jQuery("#usage_organize_event").change(function() {
773 if (jQuery("#usage_organize_event").prop("checked")) {
774 console.log("Show organize event fields");
775 jQuery(".classuseorganizeevent").show();
777 console.log("Hide organize event fields "+jQuery("#usage_organize_event").prop("checked"));
778 jQuery(".classuseorganizeevent").hide();
782 if (!
GETPOST(
'usage_organize_event')) {
783 print
'jQuery(".classuseorganizeevent").hide();';
793 if (isModEnabled(
'societe')) {
795 print(!
getDolGlobalString(
'PROJECT_THIRDPARTY_REQUIRED') ?
'' :
'<span class="fieldrequired">');
796 print $langs->trans(
"ThirdParty");
798 print
'</td><td class="maxwidthonsmartphone">';
803 $text =
img_picto(
'',
'company',
'class="pictofixedwidth"').$form->select_company(
GETPOSTINT(
'socid'),
'socid', $filter,
'SelectThirdParty', 1, 0, array(), 0,
'minwidth300 widthcentpercentminusxx maxwidth500');
804 if (!
getDolGlobalString(
'PROJECT_CAN_ALWAYS_LINK_TO_ALL_SUPPLIERS') && empty($conf->dol_use_jmobile)) {
805 $texthelp = $langs->trans(
"IfNeedToUseOtherObjectKeepEmpty");
806 print $form->textwithtooltip($text.
' '.
img_help(), $texthelp, 1);
810 if (!GETPOSTISSET(
'backtopage')) {
811 $url =
'/societe/card.php?action=create&client=3&fournisseur=0&backtopage='.urlencode($_SERVER[
"PHP_SELF"].
'?action=create');
812 $newbutton =
'<span class="fa fa-plus-circle valignmiddle paddingleft" title="'.$langs->trans(
"AddThirdParty").
'"></span>';
815 $tmpbacktopagejsfields =
'addthirdparty:socid,search_socid';
816 print
dolButtonToOpenUrlInDialogPopup(
'addthirdparty', $langs->transnoentitiesnoconv(
'AddThirdParty'), $newbutton, $url,
'',
'',
'', $tmpbacktopagejsfields);
818 print
' <a href="'.DOL_URL_ROOT.$url.
'">'.$newbutton.
'</a>';
826 print
'<tr><td>'.$langs->trans(
"Status").
'</td><td>';
827 print
'<input type="hidden" name="status" value="'.$status.
'">';
828 print
$object->LibStatut($status, 4);
833 print
'<tr><td>'.$langs->trans(
"Visibility").
'</td><td class="maxwidthonsmartphone">';
836 $array[0] = $langs->trans(
"PrivateProject");
839 $array[1] = $langs->trans(
"SharedProject");
842 if (count($array) > 0) {
843 print $form->selectarray(
'public', $array,
GETPOST(
'public'), 0, 0, 0,
'', 0, 0, 0,
'',
'', 1);
845 print
'<input type="hidden" name="public" id="public" value="'.GETPOST(
'public').
'">';
848 print
img_picto($langs->trans(
'PrivateProject'),
'private',
'class="paddingrightonly"');
849 print $langs->trans(
"PrivateProject");
851 print
img_picto($langs->trans(
'SharedProject'),
'world',
'class="paddingrightonly"');
852 print $langs->trans(
"SharedProject");
859 print
'<tr class="classuseopportunity"><td><span class="fieldrequired">'.$langs->trans(
"OpportunityStatus").
'</span></td>';
860 print
'<td class="maxwidthonsmartphone">';
861 print $formproject->selectOpportunityStatus(
'opp_status', GETPOSTISSET(
'opp_status') ?
GETPOST(
'opp_status') :
$object->opp_status, 1, 0, 0, 0,
'', 0, 1);
864 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>';
865 print
'<input type="hidden" name="opp_percent_not_set" id="opp_percent_not_set" value="'.dol_escape_htmltag(GETPOSTISSET(
'opp_percent') ?
'0' :
'1').
'">';
870 print
'<tr class="classuseopportunity"><td>'.$langs->trans(
"OpportunityAmount").
'</td>';
871 print
'<td><input class="width75 right" type="text" name="opp_amount" value="'.dol_escape_htmltag(GETPOSTISSET(
'opp_amount') ?
GETPOST(
'opp_amount') :
'').
'">';
872 print
' '.$langs->getCurrencySymbol($conf->currency);
878 print
'<tr><td>'.$langs->trans(
"Budget").
'</td>';
879 print
'<td><input class="width75 right" type="text" name="budget_amount" value="'.dol_escape_htmltag(GETPOSTISSET(
'budget_amount') ?
GETPOST(
'budget_amount') :
'').
'">';
880 print
' '.$langs->getCurrencySymbol($conf->currency);
885 print
'<tr><td>'.$langs->trans(
"Date").(isModEnabled(
'eventorganization') ?
' <span class="classuseorganizeevent">('.$langs->trans(
"Project").
')</span>' :
'').
'</td><td>';
886 print $form->selectDate(($date_start ? $date_start :
''),
'projectstart', 0, 0, 0,
'', 1, 0);
887 print
' <span class="opacitymedium"> '.$langs->trans(
"to").
' </span> ';
888 print $form->selectDate(($date_end ? $date_end : -1),
'projectend', 0, 0, 0,
'', 1, 0);
891 if (isModEnabled(
'eventorganization')) {
893 print
'<tr class="classuseorganizeevent"><td>'.$langs->trans(
"Date").
' ('.$langs->trans(
"Event").
')</td><td>';
894 print $form->selectDate(($date_start_event ? $date_start_event : -1),
'date_start_event', 1, 1, 1,
'', 1, 0);
895 print
' <span class="opacitymedium"> '.$langs->trans(
"to").
' </span> ';
896 print $form->selectDate(($date_end_event ? $date_end_event : -1),
'date_end_event', 1, 1, 1,
'', 1, 0);
900 print
'<tr class="classuseorganizeevent"><td>'.$langs->trans(
"Location").
'</td>';
901 print
'<td><input class="minwidth300 maxwidth500" type="text" name="location" value="'.dol_escape_htmltag($location).
'"></td>';
906 print
'<tr><td class="tdtop">'.$langs->trans(
"Description").
'</td>';
908 $doleditor =
new DolEditor(
'description',
GETPOST(
"description",
'restricthtml'),
'', 90,
'dolibarr_notes',
'',
false,
true, isModEnabled(
'fckeditor') &&
getDolGlobalString(
'FCKEDITOR_ENABLE_SOCIETE'), ROWS_3,
'90%');
909 $doleditor->Create();
912 if (isModEnabled(
'category')) {
914 print
'<tr><td>'.$langs->trans(
"Categories").
'</td><td colspan="3">';
915 $cate_arbo = $form->select_all_categories(Categorie::TYPE_PROJECT,
'',
'parent', 64, 0, 3);
916 $arrayselected =
GETPOST(
'categories',
'array');
917 print
img_picto(
'',
'category',
'class="pictofixedwidth"').$form->multiselectarray(
'categories', $cate_arbo, $arrayselected,
'', 0,
'quatrevingtpercent widthcentpercentminusx', 0, 0);
922 $parameters = array();
923 $reshook = $hookmanager->executeHooks(
'formObjectOptions', $parameters,
$object, $action);
924 print $hookmanager->resPrint;
925 if (empty($reshook)) {
926 print
$object->showOptionals($extrafields,
'create');
933 print $form->buttonsSaveCancel(
'CreateDraft');
939 print
'<script type="text/javascript">
940 jQuery(document).ready(function() {
941 function change_percent()
943 var element = jQuery("#opp_status option:selected");
944 var defaultpercent = element.attr("defaultpercent");
945 /*if (jQuery("#opp_percent_not_set").val() == "") */
946 jQuery("#opp_percent").val(defaultpercent);
950 jQuery("#opp_status").change(function() {
954 jQuery("#usage_task").change(function() {
955 console.log("We click on usage task "+jQuery("#usage_task").is(":checked"));
956 if (! jQuery("#usage_task").is(":checked")) {
957 jQuery("#usage_bill_time").prop("checked", false);
961 jQuery("#usage_bill_time").change(function() {
962 console.log("We click on usage to bill time");
963 if (jQuery("#usage_bill_time").is(":checked")) {
964 jQuery("#usage_task").prop("checked", true);
974 $res =
$object->fetch_optionals();
977 $userAccess =
$object->restrictedProjectArea($user,
'read');
978 $userWrite =
$object->restrictedProjectArea($user,
'write');
979 $userDelete =
$object->restrictedProjectArea($user,
'delete');
984 if ($action ==
'validate') {
985 print $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'ValidateProject'), $langs->trans(
'ConfirmValidateProject'),
'confirm_validate',
'', 0, 1);
988 if ($action ==
'close') {
989 print $form->formconfirm($_SERVER[
"PHP_SELF"].
"?id=".
$object->id, $langs->trans(
"CloseAProject"), $langs->trans(
"ConfirmCloseAProject"),
"confirm_close",
'',
'', 1);
992 if ($action ==
'reopen') {
993 print $form->formconfirm($_SERVER[
"PHP_SELF"].
"?id=".
$object->id, $langs->trans(
"ReOpenAProject"), $langs->trans(
"ConfirmReOpenAProject"),
"confirm_reopen",
'',
'', 1);
996 if ($action ==
'delete') {
997 $text = $langs->trans(
"ConfirmDeleteAProject");
998 $task =
new Task($db);
999 $taskarray = $task->getTasksArray(0, 0,
$object->id, 0, 0);
1000 $nboftask = count($taskarray);
1002 $text .=
'<br>'.img_warning().
' '.$langs->trans(
"ThisWillAlsoRemoveTasks", $nboftask);
1004 print $form->formconfirm($_SERVER[
"PHP_SELF"].
"?id=".
$object->id, $langs->trans(
"DeleteAProject"), $text,
"confirm_delete",
'',
'', 1);
1008 if ($action ==
'clone') {
1009 $formquestion = array(
1010 'text' => $langs->trans(
"ConfirmClone"),
1011 0 => array(
'type' =>
'other',
'name' =>
'socid',
'label' => $langs->trans(
"SelectThirdParty"),
'value' => $form->select_company(
GETPOSTINT(
'socid') > 0 ?
GETPOSTINT(
'socid') :
$object->socid,
'socid',
'',
"None", 0, 0, null, 0,
'minwidth200 maxwidth250')),
1012 1 => array(
'type' =>
'checkbox',
'name' =>
'clone_contacts',
'label' => $langs->trans(
"CloneContacts"),
'value' => true),
1013 2 => array(
'type' =>
'checkbox',
'name' =>
'clone_tasks',
'label' => $langs->trans(
"CloneTasks"),
'value' => true),
1014 3 => array(
'type' =>
'checkbox',
'name' =>
'move_date',
'label' => $langs->trans(
"CloneMoveDate"),
'value' => true),
1015 4 => array(
'type' =>
'checkbox',
'name' =>
'clone_notes',
'label' => $langs->trans(
"CloneNotes"),
'value' => true),
1016 5 => array(
'type' =>
'checkbox',
'name' =>
'clone_project_files',
'label' => $langs->trans(
"CloneProjectFiles"),
'value' => false),
1017 6 => array(
'type' =>
'checkbox',
'name' =>
'clone_task_files',
'label' => $langs->trans(
"CloneTaskFiles"),
'value' => false)
1020 print $form->formconfirm($_SERVER[
"PHP_SELF"].
"?id=".
$object->id, $langs->trans(
"ToClone"), $langs->trans(
"ConfirmCloneProject"),
"confirm_clone", $formquestion,
'', 1, 400, 590);
1024 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
1025 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1026 print
'<input type="hidden" name="action" value="update">';
1027 print
'<input type="hidden" name="id" value="'.$object->id.
'">';
1028 print
'<input type="hidden" name="comefromclone" value="'.$comefromclone.
'">';
1032 if ($action ==
'edit' && $userWrite > 0) {
1035 print
'<table class="border centpercent">';
1039 print
'<tr><td class="titlefield fieldrequired">'.$langs->trans(
"Ref").
'</td>';
1040 print
'<td><input class="width200" name="ref" value="'.$suggestedref.
'">';
1041 print
' '.$form->textwithpicto(
'', $langs->trans(
"YouCanCompleteRef", $suggestedref));
1045 print
'<tr><td class="fieldrequired">'.$langs->trans(
"Label").
'</td>';
1046 print
'<td><input class="quatrevingtpercent" name="title" value="'.dol_escape_htmltag(
$object->title).
'"></td></tr>';
1049 print
'<tr><td class="fieldrequired">'.$langs->trans(
"Status").
'</td><td>';
1050 print
'<select class="flat" name="status" id="status">';
1051 $statuses =
$object->labelStatusShort;
1053 unset($statuses[$object::STATUS_DRAFT]);
1055 foreach ($statuses as $key => $val) {
1056 print
'<option value="'.$key.
'"'.((GETPOSTISSET(
'status') ?
GETPOST(
'status') :
$object->
statut) == $key ?
' selected="selected"' :
'').
'>'.$langs->trans($val).
'</option>';
1064 print
'<tr><td>'.$langs->trans(
"Parent").
'</td><td class="maxwidthonsmartphone">';
1065 print
img_picto(
'',
'project',
'class="pictofixedwidth"');
1066 $formproject->select_projects(-1,
$object->fk_project,
'fk_project', 64, 0, 1, 1, 0, 0, 0,
'', 0, 0,
'',
'',
'');
1072 print
'<tr><td class="tdtop">';
1073 print $langs->trans(
"Usage");
1077 print
'<input type="checkbox" id="usage_opportunity" name="usage_opportunity"'.(GETPOSTISSET(
'usage_opportunity') ? (
GETPOST(
'usage_opportunity',
'alpha') !=
'' ?
' checked="checked"' :
'') : (
$object->usage_opportunity ?
' checked="checked"' :
'')).
'> ';
1078 $htmltext = $langs->trans(
"ProjectFollowOpportunity");
1079 print
'<label for="usage_opportunity">'.$form->textwithpicto($langs->trans(
"ProjectFollowOpportunity"), $htmltext).
'</label>';
1081 print
'$( document ).ready(function() {
1082 jQuery("#usage_opportunity").change(function() {
1083 set_usage_opportunity();
1086 set_usage_opportunity();
1088 function set_usage_opportunity() {
1089 console.log("set_usage_opportunity");
1090 if (jQuery("#usage_opportunity").prop("checked")) {
1091 console.log("Show opportunities fields");
1092 jQuery(".classuseopportunity").show();
1094 console.log("Hide opportunities fields "+jQuery("#usage_opportunity").prop("checked"));
1095 jQuery(".classuseopportunity").hide();
1103 print
'<input type="checkbox" id="usage_task" name="usage_task"' . (GETPOSTISSET(
'usage_task') ? (
GETPOST(
'usage_task',
'alpha') !=
'' ?
' checked="checked"' :
'') : (
$object->usage_task ?
' checked="checked"' :
'')) .
'> ';
1104 $htmltext = $langs->trans(
"ProjectFollowTasks");
1105 print
'<label for="usage_task">'.$form->textwithpicto($langs->trans(
"ProjectFollowTasks"), $htmltext).
'</label>';
1107 print
'$( document ).ready(function() {
1108 jQuery("#usage_task").change(function() {
1114 function set_usage_task() {
1115 console.log("set_usage_task");
1116 if (jQuery("#usage_task").prop("checked")) {
1117 console.log("Show task fields");
1118 jQuery(".classusetask").show();
1120 console.log("Hide task fields "+jQuery("#usage_task").prop("checked"));
1121 jQuery(".classusetask").hide();
1129 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"' :
'')) .
'> ';
1130 $htmltext = $langs->trans(
"ProjectBillTimeDescription");
1131 print
'<label for="usage_bill_time">'.$form->textwithpicto($langs->trans(
"BillTime"), $htmltext).
'</label>';
1133 print
'$( document ).ready(function() {
1134 jQuery("#usage_bill_time").change(function() {
1135 set_usage_bill_time();
1138 set_usage_bill_time();
1140 function set_usage_bill_time() {
1141 console.log("set_usage_bill_time");
1142 if (jQuery("#usage_bill_time").prop("checked")) {
1143 console.log("Show bill time fields");
1144 jQuery(".classusebilltime").show();
1146 console.log("Hide bill time fields "+jQuery("#usage_bill_time").prop("checked"));
1147 jQuery(".classusebilltime").hide();
1154 if (isModEnabled(
'eventorganization')) {
1155 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"' :
'')) .
'> ';
1156 $htmltext = $langs->trans(
"EventOrganizationDescriptionLong");
1157 print
'<label for="usage_organize_event">'.$form->textwithpicto($langs->trans(
"ManageOrganizeEvent"), $htmltext).
'</label>';
1159 print
'$( document ).ready(function() {
1160 jQuery("#usage_organize_event").change(function() {
1166 function set_usage_event() {
1167 console.log("set_usage_event");
1168 if (jQuery("#usage_organize_event").prop("checked")) {
1169 console.log("Show organize event fields");
1170 jQuery(".classuseorganizeevent").show();
1172 console.log("Hide organize event fields "+jQuery("#usage_organize_event").prop("checked"));
1173 jQuery(".classuseorganizeevent").hide();
1184 if (isModEnabled(
'societe')) {
1186 print(!
getDolGlobalString(
'PROJECT_THIRDPARTY_REQUIRED') ?
'' :
'<span class="fieldrequired">');
1187 print $langs->trans(
"ThirdParty");
1194 $text =
img_picto(
'',
'company',
'class="pictofixedwidth"');
1195 $text .= $form->select_company(!empty(
$object->thirdparty->id) ?
$object->thirdparty->id :
"",
'socid', $filter,
'None', 1, 0, array(), 0,
'minwidth300');
1196 if (!
getDolGlobalString(
'PROJECT_CAN_ALWAYS_LINK_TO_ALL_SUPPLIERS') && empty($conf->dol_use_jmobile)) {
1197 $texthelp = $langs->trans(
"IfNeedToUseOtherObjectKeepEmpty");
1198 print $form->textwithtooltip($text.
' '.
img_help(), $texthelp, 1, 0,
'',
'', 2);
1206 print
'<tr><td>'.$langs->trans(
"Visibility").
'</td><td>';
1209 $array[0] = $langs->trans(
"PrivateProject");
1212 $array[1] = $langs->trans(
"SharedProject");
1215 if (count($array) > 0) {
1216 print $form->selectarray(
'public', $array,
$object->public, 0, 0, 0,
'', 0, 0, 0,
'',
'', 1);
1218 print
'<input type="hidden" id="public" name="public" value="'.$object->public.
'">';
1221 print
img_picto($langs->trans(
'PrivateProject'),
'private',
'class="paddingrightonly"');
1222 print $langs->trans(
"PrivateProject");
1224 print
img_picto($langs->trans(
'SharedProject'),
'world',
'class="paddingrightonly"');
1225 print $langs->trans(
"SharedProject");
1231 $classfortr = (
$object->usage_opportunity ?
'' :
' hideobject');
1233 print
'<tr class="classuseopportunity'.$classfortr.
'"><td>'.$langs->trans(
"OpportunityStatus").
'</td>';
1236 print $formproject->selectOpportunityStatus(
'opp_status',
$object->opp_status, 1, 0, 0, 0,
'minwidth150 inline-block valignmiddle', 1, 1);
1239 print
' <input class="width50 right" type="text" id="opp_percent" name="opp_percent" title="'.dol_escape_htmltag($langs->trans(
"OpportunityProbability")).
'" value="'.(GETPOSTISSET(
'opp_percent') ?
GETPOST(
'opp_percent') : (strcmp(
$object->opp_percent,
'') ?
vatrate(
$object->opp_percent) :
'')).
'"> %';
1240 print
'<span id="oldopppercent" class="opacitymedium"></span>';
1243 print
'<div id="divtocloseproject" class="inline-block valign clearboth paddingtop" style="display: none;">';
1244 print
'<input type="checkbox" id="inputcloseproject" name="closeproject" />';
1245 print
'<label for="inputcloseproject">';
1246 print $form->textwithpicto($langs->trans(
"AlsoCloseAProject"), $langs->trans(
"AlsoCloseAProjectTooltip")).
'</label>';
1253 print
'<tr class="classuseopportunity'.$classfortr.
'"><td>'.$langs->trans(
"OpportunityAmount").
'</td>';
1254 print
'<td><input class="width75 right" type="text" name="opp_amount" value="'.(GETPOSTISSET(
'opp_amount') ?
GETPOST(
'opp_amount') : (strcmp(
$object->opp_amount,
'') ?
price2num(
$object->opp_amount) :
'')).
'">';
1255 print $langs->getCurrencySymbol($conf->currency);
1261 print
'<tr><td>'.$langs->trans(
"Budget").
'</td>';
1262 print
'<td><input class="width75 right" type="text" name="budget_amount" value="'.(GETPOSTISSET(
'budget_amount') ?
GETPOST(
'budget_amount') : (strcmp(
$object->budget_amount,
'') ?
price2num(
$object->budget_amount) :
'')).
'">';
1263 print $langs->getCurrencySymbol($conf->currency);
1268 print
'<tr><td>'.$langs->trans(
"Date").(isModEnabled(
'eventorganization') ?
' <span class="classuseorganizeevent">('.$langs->trans(
"Project").
')</span>' :
'').
'</td><td>';
1269 print $form->selectDate(
$object->date_start ?
$object->date_start : -1,
'projectstart', 0, 0, 0,
'', 1, 0);
1270 print
' <span class="opacitymedium"> '.$langs->trans(
"to").
' </span> ';
1271 print $form->selectDate(
$object->date_end ?
$object->date_end : -1,
'projectend', 0, 0, 0,
'', 1, 0);
1272 $object->getLinesArray(
null, 0);
1274 print
' <span id="divreportdate" class="hidden"> <input type="checkbox" class="valignmiddle" id="reportdate" name="reportdate" value="yes" ';
1275 if ($comefromclone) {
1278 print
'/><label for="reportdate" class="valignmiddle opacitymedium">'.$langs->trans(
"ProjectReportDate").
'</label></span>';
1282 if (isModEnabled(
'eventorganization')) {
1284 print
'<tr class="classuseorganizeevent"><td>'.$langs->trans(
"Date").
' ('.$langs->trans(
"Event").
')</td><td>';
1285 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);
1286 print
' <span class="opacitymedium"> '.$langs->trans(
"to").
' </span> ';
1287 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);
1291 print
'<tr class="classuseorganizeevent"><td>'.$langs->trans(
"Location").
'</td>';
1292 print
'<td><input class="minwidth300 maxwidth500" type="text" name="location" value="'.dol_escape_htmltag(GETPOSTISSET(
'location') ?
GETPOST(
'location') :
$object->location).
'"></td>';
1297 print
'<tr><td class="tdtop">'.$langs->trans(
"Description").
'</td>';
1299 $doleditor =
new DolEditor(
'description',
$object->description,
'', 90,
'dolibarr_notes',
'',
false,
true, isModEnabled(
'fckeditor') &&
getDolGlobalInt(
'FCKEDITOR_ENABLE_SOCIETE'), ROWS_3,
'90%');
1300 $doleditor->Create();
1304 if (isModEnabled(
'category')) {
1305 $arrayselected = array();
1306 print
'<tr><td>'.$langs->trans(
"Categories").
'</td><td>';
1307 $cate_arbo = $form->select_all_categories(Categorie::TYPE_PROJECT,
'',
'parent', 64, 0, 3);
1309 $cats = $c->containing(
$object->id, Categorie::TYPE_PROJECT);
1310 foreach ($cats as $cat) {
1311 $arrayselected[] = $cat->id;
1313 print
img_picto(
'',
'category',
'class="pictofixedwidth"').$form->multiselectarray(
'categories', $cate_arbo, $arrayselected, 0, 0,
'quatrevingtpercent widthcentpercentminusx', 0,
'0');
1318 $parameters = array();
1319 $reshook = $hookmanager->executeHooks(
'formObjectOptions', $parameters,
$object, $action);
1320 print $hookmanager->resPrint;
1321 if (empty($reshook)) {
1322 print
$object->showOptionals($extrafields,
'edit');
1331 if (!empty($_SESSION[
'pageforbacktolist']) && !empty($_SESSION[
'pageforbacktolist'][
'project'])) {
1332 $tmpurl = $_SESSION[
'pageforbacktolist'][
'project'];
1333 $tmpurl = preg_replace(
'/__SOCID__/', (
string)
$object->socid, $tmpurl);
1334 $linkback =
'<a href="'.$tmpurl.(preg_match(
'/\?/', $tmpurl) ?
'&' :
'?').
'restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
1336 $linkback =
'<a href="'.DOL_URL_ROOT.
'/projet/list.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
1339 $morehtmlref =
'<div class="refidno">';
1342 $morehtmlref .=
'<br>';
1344 if (!empty(
$object->thirdparty->id) &&
$object->thirdparty->id > 0) {
1345 $morehtmlref .=
$object->thirdparty->getNomUrl(1,
'project');
1351 $parent->fetch(
$object->fk_project);
1352 $morehtmlref .= $langs->trans(
"Child of").
' '.$parent->getNomUrl(1,
'project').
' '.$parent->title;
1355 $morehtmlref .=
'</div>';
1358 if (!$user->hasRight(
'projet',
'all',
'lire')) {
1359 $objectsListId =
$object->getProjectsAuthorizedForUser($user, 0, 0);
1360 $object->next_prev_filter =
"rowid IN (".$db->sanitize(count($objectsListId) ? implode(
',', array_keys($objectsListId)) :
'0').
")";
1363 dol_banner_tab(
$object,
'ref', $linkback, 1,
'ref',
'ref', $morehtmlref);
1365 print
'<div class="fichecenter">';
1366 print
'<div class="fichehalfleft">';
1367 print
'<div class="underbanner clearboth"></div>';
1369 print
'<table class="border tableforfield centpercent">';
1373 print
'<tr><td class="tdtop">';
1374 print $langs->trans(
"Usage");
1378 print
'<input type="checkbox" disabled name="usage_opportunity"'.(GETPOSTISSET(
'usage_opportunity') ? (
GETPOST(
'usage_opportunity',
'alpha') !=
'' ?
' checked="checked"' :
'') : (
$object->usage_opportunity ?
' checked="checked"' :
'')).
'> ';
1379 $htmltext = $langs->trans(
"ProjectFollowOpportunity");
1380 print $form->textwithpicto($langs->trans(
"ProjectFollowOpportunity"), $htmltext);
1384 print
'<input type="checkbox" disabled name="usage_task"'.(GETPOSTISSET(
'usage_task') ? (
GETPOST(
'usage_task',
'alpha') !=
'' ?
' checked="checked"' :
'') : (
$object->usage_task ?
' checked="checked"' :
'')).
'> ';
1385 $htmltext = $langs->trans(
"ProjectFollowTasks");
1386 print $form->textwithpicto($langs->trans(
"ProjectFollowTasks"), $htmltext);
1390 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"' :
'')).
'> ';
1391 $htmltext = $langs->trans(
"ProjectBillTimeDescription");
1392 print $form->textwithpicto($langs->trans(
"BillTime"), $htmltext);
1396 if (isModEnabled(
'eventorganization')) {
1397 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"' :
'')).
'> ';
1398 $htmltext = $langs->trans(
"EventOrganizationDescriptionLong");
1399 print $form->textwithpicto($langs->trans(
"ManageOrganizeEvent"), $htmltext);
1405 print
'<tr><td class="titlefield">'.$langs->trans(
"Visibility").
'</td><td>';
1407 print
img_picto($langs->trans(
'SharedProject'),
'world',
'class="paddingrightonly"');
1408 print $langs->trans(
'SharedProject');
1410 print
img_picto($langs->trans(
'PrivateProject'),
'private',
'class="paddingrightonly"');
1411 print $langs->trans(
'PrivateProject');
1417 print
'<tr><td>'.$langs->trans(
"OpportunityStatus");
1418 if ($action !=
'edit_opp_status' && $user->hasRight(
'projet',
'creer')) {
1419 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>';
1422 $html_name_status = ($action ==
'edit_opp_status') ?
'opp_status' :
'none';
1423 $html_name_percent = ($action ==
'edit_opp_status') ?
'opp_percent' :
'none';
1424 $percent_value = (GETPOSTISSET(
'opp_percent') ?
GETPOST(
'opp_percent') : (strcmp(
$object->opp_percent,
'') ?
vatrate(
$object->opp_percent) :
''));
1425 $formproject->formOpportunityStatus($_SERVER[
'PHP_SELF'].
'?socid='.
$object->id,
$object->opp_status, $percent_value, $html_name_status, $html_name_percent);
1429 print
'<tr><td>'.$langs->trans(
"OpportunityAmount").
'</td><td>';
1430 if (strcmp(
$object->opp_amount,
'')) {
1431 print
'<span class="amount">'.price(
$object->opp_amount, 0, $langs, 1, 0, -1, $conf->currency).
'</span>';
1432 if (strcmp(
$object->opp_percent,
'')) {
1433 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>';
1440 print
'<tr><td>'.$langs->trans(
"Budget").
'</td><td>';
1441 if (!is_null(
$object->budget_amount) && strcmp(
$object->budget_amount,
'')) {
1442 print
'<span class="amount">'.price(
$object->budget_amount, 0, $langs, 1, 0, 0, $conf->currency).
'</span>';
1447 print
'<tr><td>'.$langs->trans(
"Dates").
'</td><td>';
1449 print($start ? $start :
'?');
1451 print
' <span class="opacitymedium">-</span> ';
1452 print($end ? $end :
'?');
1460 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_view.tpl.php';
1465 print
'<div class="fichehalfright">';
1466 print
'<div class="underbanner clearboth"></div>';
1468 print
'<table class="border tableforfield centpercent">';
1471 print
'<td class="titlefield tdtop">'.$langs->trans(
"Description").
'</td><td>';
1472 print
'<div class="longmessagecut">';
1478 if (isModEnabled(
'category')) {
1479 print
'<tr><td class="valignmiddle">'.$langs->trans(
"Categories").
'</td><td>';
1480 print $form->showCategories(
$object->id, Categorie::TYPE_PROJECT, 1);
1489 print
'<div class="clearboth"></div>';
1494 if ($action ==
'edit' && $userWrite > 0) {
1495 print $form->buttonsSaveCancel();
1501 print
'<script type="text/javascript">
1502 jQuery(document).ready(function() {
1503 jQuery("#usage_task").change(function() {
1504 console.log("We click on usage task "+jQuery("#usage_task").is(":checked"));
1505 if (! jQuery("#usage_task").is(":checked")) {
1506 jQuery("#usage_bill_time").prop("checked", false);
1510 jQuery("#usage_bill_time").change(function() {
1511 console.log("We click on usage to bill time");
1512 if (jQuery("#usage_bill_time").is(":checked")) {
1513 jQuery("#usage_task").prop("checked", true);
1517 jQuery("#projectstart").change(function() {
1518 console.log("We modify the start date");
1519 jQuery("#divreportdate").show();
1525 if (!empty($conf->use_javascript_ajax) &&
getDolGlobalString(
'PROJECT_USE_OPPORTUNITIES')) {
1527 $defaultcheckedwhenoppclose = 1;
1529 $defaultcheckedwhenoppclose = 0;
1532 print
'<!-- Javascript to manage opportunity status change -->';
1533 print
'<script type="text/javascript">
1534 jQuery(document).ready(function() {
1535 function change_percent()
1537 var element = jQuery("#opp_status option:selected");
1538 var defaultpercent = element.attr("defaultpercent");
1539 var defaultcloseproject = '.((int) $defaultcheckedwhenoppclose).
';
1540 var elemcode = element.attr("elemcode");
1543 console.log(
"We select "+elemcode);
1546 var closeproject = 0;
1547 if (elemcode == \
'LOST\') closeproject = 1;
1548 if (elemcode == \'WON\') closeproject = defaultcloseproject;
1549 if (closeproject) jQuery("#inputcloseproject").prop("checked", true);
1550 else jQuery("#inputcloseproject").prop("checked", false);
1552 /* Make the close project checkbox visible or not */
1553 console.log("closeproject="+closeproject);
1554 if (elemcode == \'WON\' || elemcode == \'LOST\')
1556 jQuery("#divtocloseproject").show();
1560 jQuery("#divtocloseproject").hide();
1563 /* Change percent with default percent (defaultpercent) if new status (defaultpercent) is higher than current (jQuery("#opp_percent").val()) */
1564 if (oldpercent != \'\' && (parseFloat(defaultpercent) < parseFloat(oldpercent)))
1566 console.log("oldpercent="+oldpercent+" defaultpercent="+defaultpercent+" def < old");
1567 if (jQuery("#opp_percent").val() != \'\' && oldpercent != \'\') {
1568 jQuery("#oldopppercent").text(\' - '.
dol_escape_js($langs->transnoentities(
"PreviousValue")).
': \'+price2numjs(oldpercent)+\' %\');
1571 if (parseFloat(oldpercent) != 100 && elemcode != \'LOST\') { jQuery("#opp_percent").val(oldpercent); }
1572 else { jQuery("#opp_percent").val(price2numjs(defaultpercent)); }
1574 console.log("oldpercent="+oldpercent+" defaultpercent="+defaultpercent);
1575 if (jQuery("#opp_percent").val() == \'\' || (parseFloat(jQuery("#opp_percent").val()) < parseFloat(defaultpercent))) {
1576 if (jQuery("#opp_percent").val() != \'\' && oldpercent != \'\') {
1577 jQuery("#oldopppercent").text(\' - '.
dol_escape_js($langs->transnoentities(
"PreviousValue")).
': \'+price2numjs(oldpercent)+\' %\');
1579 jQuery("#opp_percent").val(price2numjs(defaultpercent));
1584 jQuery("#opp_status").change(function() {
1596 print
'<div class="tabsAction">';
1597 $parameters = array();
1598 $reshook = $hookmanager->executeHooks(
'addMoreActionsButtons', $parameters,
$object, $action);
1600 if (empty($reshook)) {
1601 if ($action !=
"edit" && $action !=
'presend') {
1611 if (empty($user->socid)) {
1613 print
dolGetButtonAction(
'', $langs->trans(
'SendMail'),
'default', $_SERVER[
"PHP_SELF"].
'?action=presend&token='.
newToken().
'&id='.
$object->id.
'&mode=init#formmailbeforetitle',
'');
1633 if ($userWrite > 0) {
1634 print
dolGetButtonAction(
'', $langs->trans(
'SetToDraft'),
'default', $_SERVER[
"PHP_SELF"].
'?action=confirm_setdraft&confirm=yes&token='.
newToken().
'&id='.
$object->id,
'');
1636 print
dolGetButtonAction($langs->trans(
'NotOwnerOfProject'), $langs->trans(
'SetToDraft'),
'default', $_SERVER[
'PHP_SELF'].
'#',
'',
false);
1643 if ($userWrite > 0) {
1646 print
dolGetButtonAction($langs->trans(
'NotOwnerOfProject'), $langs->trans(
'Modify'),
'default', $_SERVER[
'PHP_SELF'].
'#',
'',
false);
1652 if ($userWrite > 0) {
1655 print
dolGetButtonAction($langs->trans(
'NotOwnerOfProject'), $langs->trans(
'Validate'),
'default', $_SERVER[
'PHP_SELF'].
'#',
'',
false);
1661 if ($userWrite > 0) {
1664 print
dolGetButtonAction($langs->trans(
'NotOwnerOfProject'), $langs->trans(
'Close'),
'default', $_SERVER[
'PHP_SELF'].
'#',
'',
false);
1670 if ($userWrite > 0) {
1673 print
dolGetButtonAction($langs->trans(
'NotOwnerOfProject'), $langs->trans(
'ReOpen'),
'default', $_SERVER[
'PHP_SELF'].
'#',
'',
false);
1681 $is_customer_or_prospect = (!empty(
$object->thirdparty->prospect) || !empty(
$object->thirdparty->client));
1682 $is_supplier_only= (!empty(
$object->thirdparty->fournisseur) && $is_customer_or_prospect ==
false);
1684 $arrayforbutaction = array(
1685 10 => array(
'lang'=>
'propal',
'enabled'=>(isModEnabled(
"propal") && $is_customer_or_prospect ==
true),
'perm'=>$user->hasRight(
'propal',
'creer'),
'label' =>
'AddProp',
'url'=>
'/comm/propal/card.php?action=create&projectid='.$object->id.
'&socid='.
$object->socid),
1686 20 => array(
'lang'=>
'orders',
'enabled'=>(isModEnabled(
"order") && $is_customer_or_prospect ==
true),
'perm'=>$user->hasRight(
'commande',
'creer'),
'label' =>
'CreateOrder',
'url'=>
'/commande/card.php?action=create&projectid='.$object->id.
'&socid='.
$object->socid),
1687 30 => array(
'lang'=>
'bills',
'enabled'=>(isModEnabled(
"invoice") && $is_customer_or_prospect ==
true),
'perm'=>$user->hasRight(
'facture',
'creer'),
'label' =>
'CreateBill',
'url'=>
'/compta/facture/card.php?action=create&projectid='.$object->id.
'&socid='.
$object->socid),
1688 40 => array(
'lang'=>
'supplier_proposal',
'enabled'=>isModEnabled(
"supplier_proposal"),
'perm'=>$user->hasRight(
'supplier_proposal',
'creer'),
'label' =>
'AddSupplierProposal',
'url'=>
'/supplier_proposal/card.php?action=create&projectid='.$object->id.($is_supplier_only ==
true ?
'&socid='.$object->socid :
'')),
1689 50 => array(
'lang'=>
'suppliers',
'enabled'=>isModEnabled(
"supplier_order"),
'perm'=>$user->hasRight(
'fournisseur',
'commande',
'creer'),
'label' =>
'AddSupplierOrder',
'url'=>
'/fourn/commande/card.php?action=create&projectid='.
$object->id.($is_supplier_only == true ?
'&socid='.
$object->socid :
'')),
1690 60 => array(
'lang'=>
'suppliers',
'enabled'=>isModEnabled(
"supplier_invoice"),
'perm'=>$user->hasRight(
'fournisseur',
'facture',
'creer'),
'label' =>
'AddSupplierInvoice',
'url'=>
'/fourn/facture/card.php?action=create&projectid='.
$object->id.($is_supplier_only == true ?
'&socid='.
$object->socid :
'')),
1691 70 => array(
'lang'=>
'interventions',
'enabled'=>isModEnabled(
"intervention"),
'perm'=>$user->hasRight(
'fichinter',
'creer'),
'label' =>
'AddIntervention',
'url'=>
'/fichinter/card.php?action=create&projectid='.
$object->id.
'&socid='.
$object->socid),
1692 80 => array(
'lang'=>
'contracts',
'enabled'=>isModEnabled(
"contract"),
'perm'=>$user->hasRight(
'contrat',
'creer'),
'label' =>
'AddContract',
'url'=>
'/contrat/card.php?action=create&projectid='.
$object->id.
'&socid='.
$object->socid),
1693 90 => array(
'lang'=>
'trips',
'enabled'=>isModEnabled(
"expensereport"),
'perm'=>$user->hasRight(
'expensereport',
'creer'),
'label' =>
'AddTrip',
'url'=>
'/expensereport/card.php?action=create&projectid='.
$object->id.
'&socid='.
$object->socid),
1694 100 => array(
'lang'=>
'donations',
'enabled'=>isModEnabled(
"don"),
'perm'=>$user->hasRight(
'don',
'creer'),
'label' =>
'AddDonation',
'url'=>
'/don/card.php?action=create&projectid='.
$object->id.
'&socid='.
$object->socid),
1697 $params = array(
'backtopage' => $_SERVER[
"PHP_SELF"].
'?id='.
$object->id);
1700 print
dolGetButtonAction(
'', $langs->trans(
"Create"),
'default', $arrayforbutaction,
'', 1, $params);
1704 if ($user->hasRight(
'projet',
'creer')) {
1705 if ($userWrite > 0) {
1708 print
dolGetButtonAction($langs->trans(
'NotOwnerOfProject'), $langs->trans(
'ToClone'),
'default', $_SERVER[
'PHP_SELF'].
'#',
'',
false);
1717 print
dolGetButtonAction($langs->trans(
'NotOwnerOfProject'), $langs->trans(
'Delete'),
'default', $_SERVER[
'PHP_SELF'].
'#',
'',
false);
1725 if (
GETPOST(
'modelselected')) {
1726 $action =
'presend';
1729 if ($action !=
'presend') {
1730 print
'<div class="fichecenter"><div class="fichehalfleft">';
1731 print
'<a name="builddoc"></a>';
1737 $children =
$object->getChildren();
1739 print
'<table class="centpercent notopnoleftnoright table-fiche-title">';
1740 print
'<tr class="titre"><td class="nobordernopadding valignmiddle col-title">';
1741 print
'<div class="titre inline-block">'.$langs->trans(
'Sub-projects').
'</div>';
1742 print
'</td></tr></table>';
1744 print
'<div class="div-table-responsive-no-min">';
1745 print
'<table class="centpercent noborder'.($morecss ?
' '.$morecss :
'').
'">';
1746 print
'<tr class="liste_titre">';
1747 print
getTitleFieldOfList(
'Ref', 0, $_SERVER[
"PHP_SELF"],
'',
'',
'',
'',
'',
'',
'', 1);
1748 print
getTitleFieldOfList(
'Title', 0, $_SERVER[
"PHP_SELF"],
'',
'',
'',
'',
'',
'',
'', 1);
1749 print
getTitleFieldOfList(
'Status', 0, $_SERVER[
"PHP_SELF"],
'',
'',
'',
'',
'',
'',
'', 1);
1753 $subproject =
new Project($db);
1754 foreach ($children as $child) {
1755 $subproject->fetch($child->rowid);
1756 print
'<tr class="oddeven">';
1757 print
'<td class="nowraponall">'.$subproject->getNomUrl(1,
'project').
'</td>';
1758 print
'<td class="nowraponall tdoverflowmax125">'.$child->title.
'</td>';
1759 print
'<td class="nowraponall">'.$subproject->getLibStatut(5).
'</td>';
1773 $urlsource = $_SERVER[
"PHP_SELF"].
"?id=".
$object->id;
1774 $genallowed = ($user->hasRight(
'projet',
'lire') && $userAccess > 0);
1775 $delallowed = ($user->hasRight(
'projet',
'creer') && $userWrite > 0);
1777 print $formfile->showdocuments(
'project', $filename, $filedir, $urlsource, $genallowed, $delallowed,
$object->model_pdf, 1, 0, 0, 0, 0,
'',
'',
'',
'',
'',
$object);
1779 print
'</div><div class="fichehalfright">';
1783 $morehtmlcenter =
'<div class="nowraponall">';
1784 $morehtmlcenter .=
dolGetButtonTitle($langs->trans(
'FullConversation'),
'',
'fa fa-comments imgforviewmode', DOL_URL_ROOT.
'/projet/messaging.php?id='.
$object->id);
1785 $morehtmlcenter .=
dolGetButtonTitle($langs->trans(
'FullList'),
'',
'fa fa-bars imgforviewmode', DOL_URL_ROOT.
'/projet/agenda.php?id='.
$object->id);
1786 $morehtmlcenter .=
'</div>';
1789 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formactions.class.php';
1791 $somethingshown = $formactions->showactions(
$object,
'project', 0, 1,
'', $MAXEVENT,
'', $morehtmlcenter);
1793 print
'</div></div>';
1797 $modelmail =
'project';
1798 $defaulttopic =
'SendProjectRef';
1799 $defaulttopiclang =
'projects';
1800 $diroutput = $conf->project->multidir_output[
$object->entity];
1801 $autocopy =
'MAIN_MAIL_AUTOCOPY_PROJECT_TO';
1802 $trackid =
'proj'.$object->id;
1804 include DOL_DOCUMENT_ROOT.
'/core/tpl/card_presend.tpl.php';
1807 $parameters = array();
1808 $reshook = $hookmanager->executeHooks(
'mainCardTabAddMore', $parameters,
$object, $action);
1810 print $langs->trans(
"RecordNotFound");
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
ajax_combobox($htmlname, $events=array(), $minLengthToAutocomplete=0, $forcefocus=0, $widthTypeOfAutocomplete='resolve', $idforemptyvalue='-1', $morecss='')
Convert a html select field into an ajax combobox.
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader()
Empty header.
Class to manage categories.
Class to manage a WYSIWYG editor.
Class to manage projects.
const STATUS_VALIDATED
Open/Validated status.
const STATUS_CLOSED
Closed status.
const STATUS_DRAFT
Draft status.
Class to manage third parties objects (customers, suppliers, prospects...)
Class to manage translations.
Class to manage Dolibarr users.
dol_delete_file($file, $disableglob=0, $nophperrors=0, $nohook=0, $object=null, $allowdotdot=false, $indexdatabase=1, $nolog=0)
Remove a file or several files with a mask.
dol_mktime($hour, $minute, $second, $month, $day, $year, $gm='auto', $check=1)
Return a timestamp date built from detailed information (by default a local PHP server timestamp) Rep...
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
vatrate($rate, $addpercent=false, $info_bits=0, $usestarfornpr=0, $html=0)
Return a string with VAT rate label formatted for view output Used into pdf and HTML pages.
img_help($usehelpcursor=1, $usealttitle=1)
Show help logo with cursor "?".
img_warning($titlealt='default', $moreatt='', $morecss='pictowarning')
Show warning logo.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0)
Show tabs of a record.
dolPrintHTML($s, $allowiframe=0)
Return a string (that can be on several lines) ready to be output on a HTML page.
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
dolGetButtonTitle($label, $helpText='', $iconClass='fa fa-file', $url='', $id='', $status=1, $params=array())
Function dolGetButtonTitle : this kind of buttons are used in title in list.
dolButtonToOpenUrlInDialogPopup($name, $label, $buttonstring, $url, $disabled='', $morecss='classlink button bordertransp', $jsonopen='', $backtopagejsfields='', $accesskey='')
Return HTML code to output a button to open a dialog popup box.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
setEventMessage($mesgs, $style='mesgs', $noduplicate=0)
Set event message in dol_events session object.
price($amount, $form=0, $outlangs='', $trunc=1, $rounding=-1, $forcerounding=-1, $currency_code='')
Function to format a value into an amount for visual output Function used into PDF and HTML pages.
dol_now($mode='auto')
Return date for now.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
dol_escape_js($stringtoescape, $mode=0, $noescapebackslashn=0)
Returns text escaped for inclusion into javascript code.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
if(!function_exists( 'dol_getprefix')) dol_include_once($relpath, $classname='')
Make an include_once using default root and alternate root if it fails.
newToken()
Return the value of token currently saved into session with name 'newtoken'.
dol_clone($object, $native=0)
Create a clone of instance of object (new instance with same value for each properties) With native =...
dolGetButtonAction($label, $text='', $actionType='default', $url='', $id='', $userRight=1, $params=array())
Function dolGetButtonAction.
getTitleFieldOfList($name, $thead=0, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $disablesortlink=0, $tooltip='', $forcenowrapcolumntitle=0)
Get title line of an array.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
GETPOSTFLOAT($paramname, $rounding='')
Return the value of a $_GET or $_POST supervariable, converted into float.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0)
Set event messages in dol_events session object.
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
dol_sanitizeFileName($str, $newstr='_', $unaccent=1)
Clean a string to use it as a file name.
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
img_edit($titlealt='default', $float=0, $other='')
Show logo edit/modify fiche.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
Returns text escaped for inclusion in HTML alt or title or value tags, or into values of HTML input f...
project_prepare_head(Project $project, $moreparam='')
Prepare array with list of tabs.
restrictedArea(User $user, $features, $object=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $isdraft=0, $mode=0)
Check permissions of a user to show a page and an object.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.
publicphonebutton2 phonegreen basiclayout basiclayout TotalHT VATCode TotalVAT TotalLT1 TotalLT2 TotalTTC TotalHT clearboth nowraponall TAKEPOS_SHOW_SUBPRICE right right right takeposterminal SELECT e e e e e statut