31require
'../main.inc.php';
32require_once DOL_DOCUMENT_ROOT.
'/projet/class/project.class.php';
33require_once DOL_DOCUMENT_ROOT.
'/projet/class/task.class.php';
34require_once DOL_DOCUMENT_ROOT.
'/core/lib/project.lib.php';
35require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
36require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formprojet.class.php';
37require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
38require_once DOL_DOCUMENT_ROOT.
'/core/modules/project/modules_project.php';
39require_once DOL_DOCUMENT_ROOT.
'/core/class/extrafields.class.php';
40require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
43$langsLoad = array(
'projects',
'companies');
44if (isModEnabled(
'eventorganization')) {
45 $langsLoad[] =
'eventorganization';
48$langs->loadLangs($langsLoad);
52$action =
GETPOST(
'action',
'aZ09');
53$backtopage =
GETPOST(
'backtopage',
'alpha');
54$backtopageforcancel =
GETPOST(
'backtopageforcancel',
'alpha');
55$backtopagejsfields =
GETPOST(
'backtopagejsfields',
'alpha');
56$cancel =
GETPOST(
'cancel',
'alpha');
57$confirm =
GETPOST(
'confirm',
'aZ09');
60if (!empty($backtopagejsfields)) {
61 $tmpbacktopagejsfields = explode(
':', $backtopagejsfields);
62 $dol_openinpopup = preg_replace(
'/[^a-z0-9_]/i',
'', $tmpbacktopagejsfields[0]);
68$objcanvas =
GETPOST(
"objcanvas",
"alphanohtml");
69$comefromclone =
GETPOST(
"comefromclone",
"alphanohtml");
74$location =
GETPOST(
'location',
'alphanohtml');
78$mine =
GETPOST(
'mode') ==
'mine' ? 1 : 0;
82$hookmanager->initHooks(array(
'projectcard',
'globalcard'));
89if ($id > 0 || !empty($ref)) {
90 $ret =
$object->fetch($id, $ref);
101$extrafields->fetch_name_optionals_label(
$object->table_element);
108if ($id ==
'' && $ref ==
'' && ($action !=
"create" && $action !=
"add" && $action !=
"update" && !
GETPOST(
"cancel"))) {
112$permissiontoadd = $user->hasRight(
'projet',
'creer');
113$permissiontodelete = $user->hasRight(
'projet',
'supprimer');
114$permissiondellink = $user->hasRight(
'projet',
'creer');
121$parameters = array(
'id' => $socid,
'objcanvas' => $objcanvas);
122$reshook = $hookmanager->executeHooks(
'doActions', $parameters,
$object, $action);
127if (empty($reshook)) {
128 $backurlforlist = DOL_URL_ROOT.
'/projet/list.php';
132 if (
GETPOST(
"comefromclone") == 1) {
133 $result =
$object->delete($user);
135 header(
"Location: index.php");
139 setEventMessages($langs->trans(
"CantRemoveProject", $langs->transnoentitiesnoconv(
"ProjectOverview")),
null,
'errors');
144 if (empty($backtopage) || ($cancel && empty($id))) {
145 if (empty($backtopage) || ($cancel && strpos($backtopage,
'__ID__'))) {
146 if (empty($id) && (($action !=
'add' && $action !=
'create') || $cancel)) {
147 $backtopage = $backurlforlist;
149 $backtopage = DOL_URL_ROOT.
'/projet/card.php?id='.((!empty($id) && $id > 0) ? $id :
'__ID__');
155 if (!empty($backtopageforcancel)) {
156 header(
"Location: ".$backtopageforcancel);
158 } elseif (!empty($backtopage)) {
159 header(
"Location: ".$backtopage);
165 include DOL_DOCUMENT_ROOT.
'/core/actions_dellink.inc.php';
168 if ($action ==
'confirm_setdraft' && $confirm ==
'yes' && $permissiontoadd) {
169 $result =
$object->setStatut($object::STATUS_DRAFT,
null,
'',
'PROJECT_MODIFY');
179 $object->statut = $object::STATUS_DRAFT;
183 if ($action ==
'add' && $permissiontoadd) {
186 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"Ref")),
null,
'errors');
190 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"ProjectLabel")),
null,
'errors');
195 if (
GETPOST(
'usage_opportunity') !=
'' && !(
GETPOST(
'opp_status') > 0)) {
197 setEventMessages($langs->trans(
"ErrorOppStatusRequiredIfUsage"),
null,
'errors');
199 if (
GETPOST(
'opp_amount') !=
'' && !(
GETPOST(
'opp_status') > 0)) {
201 setEventMessages($langs->trans(
"ErrorOppStatusRequiredIfAmount"),
null,
'errors');
224 $object->date_start = $date_start;
226 $object->date_start_event = $date_start_event;
227 $object->date_end_event = $date_end_event;
230 $object->opp_status = $opp_status;
231 $object->opp_percent = $opp_percent;
232 $object->usage_opportunity = (
GETPOST(
'usage_opportunity',
'alpha') ==
'on' ? 1 : 0);
233 $object->usage_task = (
GETPOST(
'usage_task',
'alpha') ==
'on' ? 1 : 0);
234 $object->usage_bill_time = (
GETPOST(
'usage_bill_time',
'alpha') ==
'on' ? 1 : 0);
235 $object->usage_organize_event = (
GETPOST(
'usage_organize_event',
'alpha') ==
'on' ? 1 : 0);
238 $ret = $extrafields->setOptionalsFromPost(
null,
$object);
243 $result =
$object->create($user);
244 if (!$error && $result > 0) {
246 $typeofcontact =
'PROJECTLEADER';
247 $result =
$object->add_contact($user->id, $typeofcontact,
'internal');
253 } elseif ($result < 0) {
254 $langs->load(
"errors");
259 $langs->load(
"errors");
263 if (!$error && !empty(
$object->id) > 0) {
265 $categories =
GETPOST(
'categories',
'array');
266 $result =
$object->setCategories($categories);
268 $langs->load(
"errors");
277 if (!empty($backtopage)) {
278 $backtopage = preg_replace(
'/--IDFORBACKTOPAGE--|__ID__/', (
string)
$object->id, $backtopage);
279 $backtopage = $backtopage.
'&projectid='.
$object->id;
280 header(
"Location: ".$backtopage);
283 header(
"Location:card.php?id=".
$object->id);
288 unset($_POST[
"ref"]);
296 if ($action ==
'update' && empty(
GETPOST(
'cancel')) && $permissiontoadd) {
301 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"Ref")),
null,
'errors');
305 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"ProjectLabel")),
null,
'errors');
313 $old_start_date =
$object->date_start;
322 $object->date_start = (!
GETPOST(
'projectstart')) ?
'' : $date_start;
324 $object->date_start_event = (!
GETPOST(
'date_start_event')) ?
'' : $date_start_event;
325 $object->date_end_event = (!
GETPOST(
'date_end_event')) ?
'' : $date_end_event;
327 if (GETPOSTISSET(
'opp_amount')) {
330 if (GETPOSTISSET(
'budget_amount')) {
333 if (GETPOSTISSET(
'opp_status')) {
334 $object->opp_status = $opp_status;
336 if (GETPOSTISSET(
'opp_percent')) {
337 $object->opp_percent = $opp_percent;
339 $object->usage_opportunity = (
GETPOST(
'usage_opportunity',
'alpha') ==
'on' ? 1 : 0);
340 $object->usage_task = (
GETPOST(
'usage_task',
'alpha') ==
'on' ? 1 : 0);
341 $object->usage_bill_time = (
GETPOST(
'usage_bill_time',
'alpha') ==
'on' ? 1 : 0);
342 $object->usage_organize_event = (
GETPOST(
'usage_organize_event',
'alpha') ==
'on' ? 1 : 0);
345 $ret = $extrafields->setOptionalsFromPost(
null,
$object,
'@GETPOSTISSET');
354 setEventMessages($langs->trans(
"ErrorOppStatusRequiredIfAmount"),
null,
'errors');
359 $result =
$object->update($user);
369 $categories =
GETPOST(
'categories',
'array');
370 $result =
$object->setCategories($categories);
379 if (
GETPOST(
"reportdate") && (
$object->date_start != $old_start_date)) {
380 $result =
$object->shiftTaskDate($old_start_date);
390 $resclose =
$object->setClose($user);
412 if ($action ==
'set_opp_status' && $user->hasRight(
'projet',
'creer')) {
414 if (GETPOSTISSET(
'opp_status')) {
415 $object->opp_status = $opp_status;
417 if (GETPOSTISSET(
'opp_percent')) {
418 $object->opp_percent = $opp_percent;
424 setEventMessages($langs->trans(
"ErrorOppStatusRequiredIfAmount"),
null,
'errors');
429 $result =
$object->update($user);
449 if ($action ==
'builddoc' && $permissiontoadd) {
455 $outputlangs = $langs;
456 if (
GETPOST(
'lang_id',
'aZ09')) {
458 $outputlangs->setDefaultLang(
GETPOST(
'lang_id',
'aZ09'));
460 $result =
$object->generateDocument(
$object->model_pdf, $outputlangs);
468 if ($action ==
'remove_file' && $permissiontoadd) {
470 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
472 $langs->load(
"other");
473 $upload_dir = $conf->project->multidir_output[
$object->entity];
474 $file = $upload_dir.
'/'.
GETPOST(
'file');
486 if ($action ==
'confirm_validate' && $confirm ==
'yes' && $permissiontoadd) {
487 $result =
$object->setValid($user);
493 if ($action ==
'confirm_close' && $confirm ==
'yes' && $permissiontoadd) {
494 $result =
$object->setClose($user);
500 if ($action ==
'confirm_reopen' && $confirm ==
'yes' && $permissiontoadd) {
501 $result =
$object->setValid($user);
507 if ($action ==
'confirm_delete' && $confirm ==
'yes' && $permissiontodelete) {
509 $result =
$object->delete($user);
513 if (!empty($_SESSION[
'pageforbacktolist']) && !empty($_SESSION[
'pageforbacktolist'][
'project'])) {
514 $tmpurl = $_SESSION[
'pageforbacktolist'][
'project'];
515 $tmpurl = preg_replace(
'/__SOCID__/', (
string)
$object->socid, $tmpurl);
516 $urlback = $tmpurl.(preg_match(
'/\?/', $tmpurl) ?
'&' :
'?').
'restore_lastsearch_values=1';
518 $urlback = DOL_URL_ROOT.
'/projet/list.php?restore_lastsearch_values=1';
521 header(
"Location: ".$urlback);
529 if ($action ==
'confirm_clone' && $permissiontoadd && $confirm ==
'yes') {
530 $clone_contacts =
GETPOST(
'clone_contacts') ? 1 : 0;
531 $clone_tasks =
GETPOST(
'clone_tasks') ? 1 : 0;
532 $clone_project_files =
GETPOST(
'clone_project_files') ? 1 : 0;
533 $clone_task_files =
GETPOST(
'clone_task_files') ? 1 : 0;
534 $clone_notes =
GETPOST(
'clone_notes') ? 1 : 0;
535 $move_date =
GETPOST(
'move_date') ? 1 : 0;
538 $result =
$object->createFromClone($user,
$object->id, $clone_contacts, $clone_tasks, $clone_project_files, $clone_task_files, $clone_notes, $move_date, 0, $clone_thirdparty);
544 $newobject->fetch($result);
545 $newobject->fetch_optionals();
546 $newobject->fetch_thirdparty();
549 $comefromclone =
true;
551 setEventMessages($langs->trans(
"ProjectCreatedInDolibarr", $newobject->ref),
"",
'mesgs');
557 $triggersendname =
'PROJECT_SENTBYMAIL';
559 $autocopy =
'MAIN_MAIL_AUTOCOPY_PROJECT_TO';
560 $trackid =
'proj'.$object->id;
561 include DOL_DOCUMENT_ROOT.
'/core/actions_sendmails.inc.php';
569$form =
new Form($db);
572$userstatic =
new User($db);
574$title = $langs->trans(
"Project").
' - '.
$object->ref.(!empty(
$object->thirdparty->name) ?
' - '.$object->thirdparty->name :
'').(!empty(
$object->title) ?
' - '.$object->title :
'');
576 $title =
$object->ref.(!empty(
$object->thirdparty->name) ?
' - '.$object->thirdparty->name :
'').(!empty(
$object->title) ?
' - '.$object->title :
'');
579$help_url =
"EN:Module_Projects|FR:Module_Projets|ES:Módulo_Proyectos|DE:Modul_Projekte";
583$titleboth = $langs->trans(
"LeadsOrProjects");
584$titlenew = $langs->trans(
"NewLeadOrProject");
586 $titleboth = $langs->trans(
"Projects");
587 $titlenew = $langs->trans(
"NewProject");
590 $titleboth = $langs->trans(
"Leads");
591 $titlenew = $langs->trans(
"NewLead");
594if ($action ==
'create' && $user->hasRight(
'projet',
'creer')) {
599 $thirdparty =
new Societe($db);
601 $thirdparty->fetch($socid);
606 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
607 print
'<input type="hidden" name="action" value="add">';
608 print
'<input type="hidden" name="token" value="'.newToken().
'">';
609 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
610 print
'<input type="hidden" name="backtopageforcancel" value="'.$backtopageforcancel.
'">';
611 print
'<input type="hidden" name="backtopagejsfields" value="'.$backtopagejsfields.
'">';
612 print
'<input type="hidden" name="dol_openinpopup" value="'.$dol_openinpopup.
'">';
616 print
'<table class="border centpercent tableforfieldcreate">';
619 $modele = !
getDolGlobalString(
'PROJECT_ADDON') ?
'mod_project_simple' : $conf->global->PROJECT_ADDON;
625 $dirmodels = array_merge(array(
'/'), (array) $conf->modules_parts[
'models']);
626 foreach ($dirmodels as $reldir) {
627 $file =
dol_buildpath($reldir.
"core/modules/project/".$modele.
'.php', 0);
628 if (file_exists($file)) {
630 $classname = $modele;
637 $modProject =
new $classname();
639 $defaultref = $modProject->getNextValue($thirdparty,
$object);
642 if (is_numeric($defaultref) && $defaultref <= 0) {
648 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).
'">';
650 print
' '.$form->textwithpicto(
'', $langs->trans(
"YouCanCompleteRef", $suggestedref));
655 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>';
659 print
'<tr><td>'.$langs->trans(
"Parent").
'</td><td class="maxwidthonsmartphone">';
660 print
img_picto(
'',
'project',
'class="pictofixedwidth"');
661 $formproject->select_projects(-1,
'',
'fk_project', 64, 0, 1, 1, 0, 0, 0,
'', 0, 0,
'',
'',
'');
667 print
'<tr><td class="tdtop">';
668 print $langs->trans(
"Usage");
672 print
'<input type="checkbox" id="usage_opportunity" name="usage_opportunity"'.(GETPOSTISSET(
'usage_opportunity') ? (
GETPOST(
'usage_opportunity',
'alpha') ?
' checked="checked"' :
'') :
' checked="checked"').
'"> ';
673 $htmltext = $langs->trans(
"ProjectFollowOpportunity");
674 print
'<label for="usage_opportunity">'.$form->textwithpicto($langs->trans(
"ProjectFollowOpportunity"), $htmltext).
'</label>';
676 print
'$( document ).ready(function() {
677 jQuery("#usage_opportunity").change(function() {
678 if (jQuery("#usage_opportunity").prop("checked")) {
679 console.log("Show opportunities fields");
680 jQuery(".classuseopportunity").show();
682 console.log("Hide opportunities fields "+jQuery("#usage_opportunity").prop("checked"));
683 jQuery(".classuseopportunity").hide();
687 if (GETPOSTISSET(
'usage_opportunity') && !
GETPOST(
'usage_opportunity')) {
688 print
'jQuery(".classuseopportunity").hide();';
695 print
'<input type="checkbox" id="usage_task" name="usage_task"'.(GETPOSTISSET(
'usage_task') ? (
GETPOST(
'usage_task',
'alpha') ?
' checked="checked"' :
'') :
' checked="checked"').
'"> ';
696 $htmltext = $langs->trans(
"ProjectFollowTasks");
697 print
'<label for="usage_task">'.$form->textwithpicto($langs->trans(
"ProjectFollowTasks"), $htmltext).
'</label>';
699 print
'$( document ).ready(function() {
700 jQuery("#usage_task").change(function() {
701 if (jQuery("#usage_task").prop("checked")) {
702 console.log("Show task fields");
703 jQuery(".classusetask").show();
705 console.log("Hide tasks fields "+jQuery("#usage_task").prop("checked"));
706 jQuery(".classusetask").hide();
710 if (GETPOSTISSET(
'usage_task') && !
GETPOST(
'usage_task')) {
711 print
'jQuery(".classusetask").hide();';
718 print
'<input type="checkbox" id="usage_bill_time" name="usage_bill_time"'.(GETPOSTISSET(
'usage_bill_time') ? (
GETPOST(
'usage_bill_time',
'alpha') ?
' checked="checked"' :
'') :
'').
'"> ';
719 $htmltext = $langs->trans(
"ProjectBillTimeDescription");
720 print
'<label for="usage_bill_time">'.$form->textwithpicto($langs->trans(
"BillTime"), $htmltext).
'</label>';
722 print
'$( document ).ready(function() {
723 jQuery("#usage_bill_time").change(function() {
724 if (jQuery("#usage_bill_time").prop("checked")) {
725 console.log("Show bill time fields");
726 jQuery(".classusebilltime").show();
728 console.log("Hide bill time fields "+jQuery("#usage_bill_time").prop("checked"));
729 jQuery(".classusebilltime").hide();
733 if (GETPOSTISSET(
'usage_bill_time') && !
GETPOST(
'usage_bill_time')) {
734 print
'jQuery(".classusebilltime").hide();';
740 if (isModEnabled(
'eventorganization')) {
741 print
'<input type="checkbox" id="usage_organize_event" name="usage_organize_event"'.(GETPOSTISSET(
'usage_organize_event') ? (
GETPOST(
'usage_organize_event',
'alpha') ?
' checked="checked"' :
'') :
'').
'"> ';
742 $htmltext = $langs->trans(
"EventOrganizationDescriptionLong");
743 print
'<label for="usage_organize_event">'.$form->textwithpicto($langs->trans(
"ManageOrganizeEvent"), $htmltext).
'</label>';
745 print
'$( document ).ready(function() {
746 jQuery("#usage_organize_event").change(function() {
747 if (jQuery("#usage_organize_event").prop("checked")) {
748 console.log("Show organize event fields");
749 jQuery(".classuseorganizeevent").show();
751 console.log("Hide organize event fields "+jQuery("#usage_organize_event").prop("checked"));
752 jQuery(".classuseorganizeevent").hide();
756 if (!
GETPOST(
'usage_organize_event')) {
757 print
'jQuery(".classuseorganizeevent").hide();';
767 if (isModEnabled(
'societe')) {
769 print(!
getDolGlobalString(
'PROJECT_THIRDPARTY_REQUIRED') ?
'' :
'<span class="fieldrequired">');
770 print $langs->trans(
"ThirdParty");
772 print
'</td><td class="maxwidthonsmartphone">';
777 $text =
img_picto(
'',
'company',
'class="pictofixedwidth"').$form->select_company(
GETPOSTINT(
'socid'),
'socid', $filter,
'SelectThirdParty', 1, 0, array(), 0,
'minwidth300 widthcentpercentminusxx maxwidth500');
778 if (!
getDolGlobalString(
'PROJECT_CAN_ALWAYS_LINK_TO_ALL_SUPPLIERS') && empty($conf->dol_use_jmobile)) {
779 $texthelp = $langs->trans(
"IfNeedToUseOtherObjectKeepEmpty");
780 print $form->textwithtooltip($text.
' '.
img_help(), $texthelp, 1);
784 if (!GETPOSTISSET(
'backtopage')) {
785 $url =
'/societe/card.php?action=create&client=3&fournisseur=0&backtopage='.urlencode($_SERVER[
"PHP_SELF"].
'?action=create');
786 $newbutton =
'<span class="fa fa-plus-circle valignmiddle paddingleft" title="'.$langs->trans(
"AddThirdParty").
'"></span>';
789 $tmpbacktopagejsfields =
'addthirdparty:socid,search_socid';
790 print
dolButtonToOpenUrlInDialogPopup(
'addthirdparty', $langs->transnoentitiesnoconv(
'AddThirdParty'), $newbutton, $url,
'',
'',
'', $tmpbacktopagejsfields);
792 print
' <a href="'.DOL_URL_ROOT.$url.
'">'.$newbutton.
'</a>';
800 print
'<tr><td>'.$langs->trans(
"Status").
'</td><td>';
801 print
'<input type="hidden" name="status" value="'.$status.
'">';
802 print
$object->LibStatut($status, 4);
807 print
'<tr><td>'.$langs->trans(
"Visibility").
'</td><td class="maxwidthonsmartphone">';
810 $array[0] = $langs->trans(
"PrivateProject");
813 $array[1] = $langs->trans(
"SharedProject");
816 if (count($array) > 0) {
817 print $form->selectarray(
'public', $array,
GETPOST(
'public'), 0, 0, 0,
'', 0, 0, 0,
'',
'', 1);
819 print
'<input type="hidden" name="public" id="public" value="'.GETPOST(
'public').
'">';
822 print
img_picto($langs->trans(
'PrivateProject'),
'private',
'class="paddingrightonly"');
823 print $langs->trans(
"PrivateProject");
825 print
img_picto($langs->trans(
'SharedProject'),
'world',
'class="paddingrightonly"');
826 print $langs->trans(
"SharedProject");
833 print
'<tr class="classuseopportunity"><td><span class="fieldrequired">'.$langs->trans(
"OpportunityStatus").
'</span></td>';
834 print
'<td class="maxwidthonsmartphone">';
835 print $formproject->selectOpportunityStatus(
'opp_status', GETPOSTISSET(
'opp_status') ?
GETPOST(
'opp_status') :
$object->opp_status, 1, 0, 0, 0,
'', 0, 1);
838 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>';
839 print
'<input type="hidden" name="opp_percent_not_set" id="opp_percent_not_set" value="'.dol_escape_htmltag(GETPOSTISSET(
'opp_percent') ?
'0' :
'1').
'">';
844 print
'<tr class="classuseopportunity"><td>'.$langs->trans(
"OpportunityAmount").
'</td>';
845 print
'<td><input class="width75 right" type="text" name="opp_amount" value="'.dol_escape_htmltag(GETPOSTISSET(
'opp_amount') ?
GETPOST(
'opp_amount') :
'').
'">';
846 print
' '.$langs->getCurrencySymbol($conf->currency);
852 print
'<tr><td>'.$langs->trans(
"Budget").
'</td>';
853 print
'<td><input class="width75 right" type="text" name="budget_amount" value="'.dol_escape_htmltag(GETPOSTISSET(
'budget_amount') ?
GETPOST(
'budget_amount') :
'').
'">';
854 print
' '.$langs->getCurrencySymbol($conf->currency);
859 print
'<tr><td>'.$langs->trans(
"Date").(isModEnabled(
'eventorganization') ?
' <span class="classuseorganizeevent">('.$langs->trans(
"Project").
')</span>' :
'').
'</td><td>';
860 print $form->selectDate(($date_start ? $date_start :
''),
'projectstart', 0, 0, 0,
'', 1, 0);
861 print
' <span class="opacitymedium"> '.$langs->trans(
"to").
' </span> ';
862 print $form->selectDate(($date_end ? $date_end : -1),
'projectend', 0, 0, 0,
'', 1, 0);
865 if (isModEnabled(
'eventorganization')) {
867 print
'<tr class="classuseorganizeevent"><td>'.$langs->trans(
"Date").
' ('.$langs->trans(
"Event").
')</td><td>';
868 print $form->selectDate(($date_start_event ? $date_start_event : -1),
'date_start_event', 1, 1, 1,
'', 1, 0);
869 print
' <span class="opacitymedium"> '.$langs->trans(
"to").
' </span> ';
870 print $form->selectDate(($date_end_event ? $date_end_event : -1),
'date_end_event', 1, 1, 1,
'', 1, 0);
874 print
'<tr class="classuseorganizeevent"><td>'.$langs->trans(
"Location").
'</td>';
875 print
'<td><input class="minwidth300 maxwidth500" type="text" name="location" value="'.dol_escape_htmltag($location).
'"></td>';
880 print
'<tr><td class="tdtop">'.$langs->trans(
"Description").
'</td>';
882 $doleditor =
new DolEditor(
'description',
GETPOST(
"description",
'restricthtml'),
'', 90,
'dolibarr_notes',
'',
false,
true, isModEnabled(
'fckeditor') &&
getDolGlobalString(
'FCKEDITOR_ENABLE_SOCIETE'), ROWS_3,
'90%');
883 $doleditor->Create();
886 if (isModEnabled(
'category')) {
888 print
'<tr><td>'.$langs->trans(
"Categories").
'</td><td colspan="3">';
889 $cate_arbo = $form->select_all_categories(Categorie::TYPE_PROJECT,
'',
'parent', 64, 0, 3);
890 $arrayselected =
GETPOST(
'categories',
'array');
891 print
img_picto(
'',
'category',
'class="pictofixedwidth"').$form->multiselectarray(
'categories', $cate_arbo, $arrayselected,
'', 0,
'quatrevingtpercent widthcentpercentminusx', 0, 0);
896 $parameters = array();
897 $reshook = $hookmanager->executeHooks(
'formObjectOptions', $parameters,
$object, $action);
898 print $hookmanager->resPrint;
899 if (empty($reshook)) {
900 print
$object->showOptionals($extrafields,
'create');
907 print $form->buttonsSaveCancel(
'CreateDraft');
913 print
'<script type="text/javascript">
914 jQuery(document).ready(function() {
915 function change_percent()
917 var element = jQuery("#opp_status option:selected");
918 var defaultpercent = element.attr("defaultpercent");
919 /*if (jQuery("#opp_percent_not_set").val() == "") */
920 jQuery("#opp_percent").val(defaultpercent);
924 jQuery("#opp_status").change(function() {
928 jQuery("#usage_task").change(function() {
929 console.log("We click on usage task "+jQuery("#usage_task").is(":checked"));
930 if (! jQuery("#usage_task").is(":checked")) {
931 jQuery("#usage_bill_time").prop("checked", false);
935 jQuery("#usage_bill_time").change(function() {
936 console.log("We click on usage to bill time");
937 if (jQuery("#usage_bill_time").is(":checked")) {
938 jQuery("#usage_task").prop("checked", true);
948 $res =
$object->fetch_optionals();
951 $userAccess =
$object->restrictedProjectArea($user,
'read');
952 $userWrite =
$object->restrictedProjectArea($user,
'write');
953 $userDelete =
$object->restrictedProjectArea($user,
'delete');
958 if ($action ==
'validate') {
959 print $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'ValidateProject'), $langs->trans(
'ConfirmValidateProject'),
'confirm_validate',
'', 0, 1);
962 if ($action ==
'close') {
963 print $form->formconfirm($_SERVER[
"PHP_SELF"].
"?id=".
$object->id, $langs->trans(
"CloseAProject"), $langs->trans(
"ConfirmCloseAProject"),
"confirm_close",
'',
'', 1);
966 if ($action ==
'reopen') {
967 print $form->formconfirm($_SERVER[
"PHP_SELF"].
"?id=".
$object->id, $langs->trans(
"ReOpenAProject"), $langs->trans(
"ConfirmReOpenAProject"),
"confirm_reopen",
'',
'', 1);
970 if ($action ==
'delete') {
971 $text = $langs->trans(
"ConfirmDeleteAProject");
972 $task =
new Task($db);
973 $taskarray = $task->getTasksArray(0, 0,
$object->id, 0, 0);
974 $nboftask = count($taskarray);
976 $text .=
'<br>'.img_warning().
' '.$langs->trans(
"ThisWillAlsoRemoveTasks", $nboftask);
978 print $form->formconfirm($_SERVER[
"PHP_SELF"].
"?id=".
$object->id, $langs->trans(
"DeleteAProject"), $text,
"confirm_delete",
'',
'', 1);
982 if ($action ==
'clone') {
983 $formquestion = array(
984 'text' => $langs->trans(
"ConfirmClone"),
985 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')),
986 1 => array(
'type' =>
'checkbox',
'name' =>
'clone_contacts',
'label' => $langs->trans(
"CloneContacts"),
'value' => true),
987 2 => array(
'type' =>
'checkbox',
'name' =>
'clone_tasks',
'label' => $langs->trans(
"CloneTasks"),
'value' => true),
988 3 => array(
'type' =>
'checkbox',
'name' =>
'move_date',
'label' => $langs->trans(
"CloneMoveDate"),
'value' => true),
989 4 => array(
'type' =>
'checkbox',
'name' =>
'clone_notes',
'label' => $langs->trans(
"CloneNotes"),
'value' => true),
990 5 => array(
'type' =>
'checkbox',
'name' =>
'clone_project_files',
'label' => $langs->trans(
"CloneProjectFiles"),
'value' => false),
991 6 => array(
'type' =>
'checkbox',
'name' =>
'clone_task_files',
'label' => $langs->trans(
"CloneTaskFiles"),
'value' => false)
994 print $form->formconfirm($_SERVER[
"PHP_SELF"].
"?id=".
$object->id, $langs->trans(
"ToClone"), $langs->trans(
"ConfirmCloneProject"),
"confirm_clone", $formquestion,
'', 1, 400, 590);
998 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
999 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1000 print
'<input type="hidden" name="action" value="update">';
1001 print
'<input type="hidden" name="id" value="'.$object->id.
'">';
1002 print
'<input type="hidden" name="comefromclone" value="'.$comefromclone.
'">';
1006 if ($action ==
'edit' && $userWrite > 0) {
1009 print
'<table class="border centpercent">';
1013 print
'<tr><td class="titlefield fieldrequired">'.$langs->trans(
"Ref").
'</td>';
1014 print
'<td><input class="width200" name="ref" value="'.$suggestedref.
'">';
1015 print
' '.$form->textwithpicto(
'', $langs->trans(
"YouCanCompleteRef", $suggestedref));
1019 print
'<tr><td class="fieldrequired">'.$langs->trans(
"Label").
'</td>';
1020 print
'<td><input class="quatrevingtpercent" name="title" value="'.dol_escape_htmltag(
$object->title).
'"></td></tr>';
1023 print
'<tr><td class="fieldrequired">'.$langs->trans(
"Status").
'</td><td>';
1024 print
'<select class="flat" name="status" id="status">';
1025 $statuses =
$object->labelStatusShort;
1027 unset($statuses[$object::STATUS_DRAFT]);
1029 foreach ($statuses as $key => $val) {
1030 print
'<option value="'.$key.
'"'.((GETPOSTISSET(
'status') ?
GETPOST(
'status') :
$object->
statut) == $key ?
' selected="selected"' :
'').
'>'.$langs->trans($val).
'</option>';
1038 print
'<tr><td>'.$langs->trans(
"Parent").
'</td><td class="maxwidthonsmartphone">';
1039 print
img_picto(
'',
'project',
'class="pictofixedwidth"');
1040 $formproject->select_projects(-1,
$object->fk_project,
'fk_project', 64, 0, 1, 1, 0, 0, 0,
'', 0, 0,
'',
'',
'');
1046 print
'<tr><td class="tdtop">';
1047 print $langs->trans(
"Usage");
1051 print
'<input type="checkbox" id="usage_opportunity" name="usage_opportunity"'.(GETPOSTISSET(
'usage_opportunity') ? (
GETPOST(
'usage_opportunity',
'alpha') !=
'' ?
' checked="checked"' :
'') : (
$object->usage_opportunity ?
' checked="checked"' :
'')).
'> ';
1052 $htmltext = $langs->trans(
"ProjectFollowOpportunity");
1053 print
'<label for="usage_opportunity">'.$form->textwithpicto($langs->trans(
"ProjectFollowOpportunity"), $htmltext).
'</label>';
1055 print
'$( document ).ready(function() {
1056 jQuery("#usage_opportunity").change(function() {
1057 set_usage_opportunity();
1060 set_usage_opportunity();
1062 function set_usage_opportunity() {
1063 console.log("set_usage_opportunity");
1064 if (jQuery("#usage_opportunity").prop("checked")) {
1065 console.log("Show opportunities fields");
1066 jQuery(".classuseopportunity").show();
1068 console.log("Hide opportunities fields "+jQuery("#usage_opportunity").prop("checked"));
1069 jQuery(".classuseopportunity").hide();
1077 print
'<input type="checkbox" id="usage_task" name="usage_task"' . (GETPOSTISSET(
'usage_task') ? (
GETPOST(
'usage_task',
'alpha') !=
'' ?
' checked="checked"' :
'') : (
$object->usage_task ?
' checked="checked"' :
'')) .
'> ';
1078 $htmltext = $langs->trans(
"ProjectFollowTasks");
1079 print
'<label for="usage_task">'.$form->textwithpicto($langs->trans(
"ProjectFollowTasks"), $htmltext).
'</label>';
1081 print
'$( document ).ready(function() {
1082 jQuery("#usage_task").change(function() {
1088 function set_usage_task() {
1089 console.log("set_usage_task");
1090 if (jQuery("#usage_task").prop("checked")) {
1091 console.log("Show task fields");
1092 jQuery(".classusetask").show();
1094 console.log("Hide task fields "+jQuery("#usage_task").prop("checked"));
1095 jQuery(".classusetask").hide();
1103 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"' :
'')) .
'> ';
1104 $htmltext = $langs->trans(
"ProjectBillTimeDescription");
1105 print
'<label for="usage_bill_time">'.$form->textwithpicto($langs->trans(
"BillTime"), $htmltext).
'</label>';
1107 print
'$( document ).ready(function() {
1108 jQuery("#usage_bill_time").change(function() {
1109 set_usage_bill_time();
1112 set_usage_bill_time();
1114 function set_usage_bill_time() {
1115 console.log("set_usage_bill_time");
1116 if (jQuery("#usage_bill_time").prop("checked")) {
1117 console.log("Show bill time fields");
1118 jQuery(".classusebilltime").show();
1120 console.log("Hide bill time fields "+jQuery("#usage_bill_time").prop("checked"));
1121 jQuery(".classusebilltime").hide();
1128 if (isModEnabled(
'eventorganization')) {
1129 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"' :
'')) .
'> ';
1130 $htmltext = $langs->trans(
"EventOrganizationDescriptionLong");
1131 print
'<label for="usage_organize_event">'.$form->textwithpicto($langs->trans(
"ManageOrganizeEvent"), $htmltext).
'</label>';
1133 print
'$( document ).ready(function() {
1134 jQuery("#usage_organize_event").change(function() {
1140 function set_usage_event() {
1141 console.log("set_usage_event");
1142 if (jQuery("#usage_organize_event").prop("checked")) {
1143 console.log("Show organize event fields");
1144 jQuery(".classuseorganizeevent").show();
1146 console.log("Hide organize event fields "+jQuery("#usage_organize_event").prop("checked"));
1147 jQuery(".classuseorganizeevent").hide();
1158 if (isModEnabled(
'societe')) {
1160 print(!
getDolGlobalString(
'PROJECT_THIRDPARTY_REQUIRED') ?
'' :
'<span class="fieldrequired">');
1161 print $langs->trans(
"ThirdParty");
1168 $text =
img_picto(
'',
'company',
'class="pictofixedwidth"');
1169 $text .= $form->select_company(!empty(
$object->thirdparty->id) ?
$object->thirdparty->id :
"",
'socid', $filter,
'None', 1, 0, array(), 0,
'minwidth300');
1170 if (!
getDolGlobalString(
'PROJECT_CAN_ALWAYS_LINK_TO_ALL_SUPPLIERS') && empty($conf->dol_use_jmobile)) {
1171 $texthelp = $langs->trans(
"IfNeedToUseOtherObjectKeepEmpty");
1172 print $form->textwithtooltip($text.
' '.
img_help(), $texthelp, 1, 0,
'',
'', 2);
1180 print
'<tr><td>'.$langs->trans(
"Visibility").
'</td><td>';
1183 $array[0] = $langs->trans(
"PrivateProject");
1186 $array[1] = $langs->trans(
"SharedProject");
1189 if (count($array) > 0) {
1190 print $form->selectarray(
'public', $array,
$object->public, 0, 0, 0,
'', 0, 0, 0,
'',
'', 1);
1192 print
'<input type="hidden" id="public" name="public" value="'.$object->public.
'">';
1195 print
img_picto($langs->trans(
'PrivateProject'),
'private',
'class="paddingrightonly"');
1196 print $langs->trans(
"PrivateProject");
1198 print
img_picto($langs->trans(
'SharedProject'),
'world',
'class="paddingrightonly"');
1199 print $langs->trans(
"SharedProject");
1205 $classfortr = (
$object->usage_opportunity ?
'' :
' hideobject');
1207 print
'<tr class="classuseopportunity'.$classfortr.
'"><td>'.$langs->trans(
"OpportunityStatus").
'</td>';
1210 print $formproject->selectOpportunityStatus(
'opp_status',
$object->opp_status, 1, 0, 0, 0,
'minwidth150 inline-block valignmiddle', 1, 1);
1213 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) :
'')).
'"> %';
1214 print
'<span id="oldopppercent" class="opacitymedium"></span>';
1217 print
'<div id="divtocloseproject" class="inline-block valign clearboth paddingtop" style="display: none;">';
1218 print
'<input type="checkbox" id="inputcloseproject" name="closeproject" />';
1219 print
'<label for="inputcloseproject">';
1220 print $form->textwithpicto($langs->trans(
"AlsoCloseAProject"), $langs->trans(
"AlsoCloseAProjectTooltip")).
'</label>';
1227 print
'<tr class="classuseopportunity'.$classfortr.
'"><td>'.$langs->trans(
"OpportunityAmount").
'</td>';
1228 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) :
'')).
'">';
1229 print $langs->getCurrencySymbol($conf->currency);
1235 print
'<tr><td>'.$langs->trans(
"Budget").
'</td>';
1236 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) :
'')).
'">';
1237 print $langs->getCurrencySymbol($conf->currency);
1242 print
'<tr><td>'.$langs->trans(
"Date").(isModEnabled(
'eventorganization') ?
' <span class="classuseorganizeevent">('.$langs->trans(
"Project").
')</span>' :
'').
'</td><td>';
1243 print $form->selectDate(
$object->date_start ?
$object->date_start : -1,
'projectstart', 0, 0, 0,
'', 1, 0);
1244 print
' <span class="opacitymedium"> '.$langs->trans(
"to").
' </span> ';
1245 print $form->selectDate(
$object->date_end ?
$object->date_end : -1,
'projectend', 0, 0, 0,
'', 1, 0);
1246 $object->getLinesArray(
null, 0);
1248 print
' <span id="divreportdate" class="hidden"> <input type="checkbox" class="valignmiddle" id="reportdate" name="reportdate" value="yes" ';
1249 if ($comefromclone) {
1252 print
'/><label for="reportdate" class="valignmiddle opacitymedium">'.$langs->trans(
"ProjectReportDate").
'</label></span>';
1256 if (isModEnabled(
'eventorganization')) {
1258 print
'<tr class="classuseorganizeevent"><td>'.$langs->trans(
"Date").
' ('.$langs->trans(
"Event").
')</td><td>';
1259 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);
1260 print
' <span class="opacitymedium"> '.$langs->trans(
"to").
' </span> ';
1261 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);
1265 print
'<tr class="classuseorganizeevent"><td>'.$langs->trans(
"Location").
'</td>';
1266 print
'<td><input class="minwidth300 maxwidth500" type="text" name="location" value="'.dol_escape_htmltag(GETPOSTISSET(
'location') ?
GETPOST(
'location') :
$object->location).
'"></td>';
1271 print
'<tr><td class="tdtop">'.$langs->trans(
"Description").
'</td>';
1273 $doleditor =
new DolEditor(
'description',
$object->description,
'', 90,
'dolibarr_notes',
'',
false,
true, isModEnabled(
'fckeditor') &&
getDolGlobalInt(
'FCKEDITOR_ENABLE_SOCIETE'), ROWS_3,
'90%');
1274 $doleditor->Create();
1278 if (isModEnabled(
'category')) {
1279 $arrayselected = array();
1280 print
'<tr><td>'.$langs->trans(
"Categories").
'</td><td>';
1281 $cate_arbo = $form->select_all_categories(Categorie::TYPE_PROJECT,
'',
'parent', 64, 0, 3);
1283 $cats = $c->containing(
$object->id, Categorie::TYPE_PROJECT);
1284 foreach ($cats as $cat) {
1285 $arrayselected[] = $cat->id;
1287 print
img_picto(
'',
'category',
'class="pictofixedwidth"').$form->multiselectarray(
'categories', $cate_arbo, $arrayselected, 0, 0,
'quatrevingtpercent widthcentpercentminusx', 0,
'0');
1292 $parameters = array();
1293 $reshook = $hookmanager->executeHooks(
'formObjectOptions', $parameters,
$object, $action);
1294 print $hookmanager->resPrint;
1295 if (empty($reshook)) {
1296 print
$object->showOptionals($extrafields,
'edit');
1305 if (!empty($_SESSION[
'pageforbacktolist']) && !empty($_SESSION[
'pageforbacktolist'][
'project'])) {
1306 $tmpurl = $_SESSION[
'pageforbacktolist'][
'project'];
1307 $tmpurl = preg_replace(
'/__SOCID__/', (
string)
$object->socid, $tmpurl);
1308 $linkback =
'<a href="'.$tmpurl.(preg_match(
'/\?/', $tmpurl) ?
'&' :
'?').
'restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
1310 $linkback =
'<a href="'.DOL_URL_ROOT.
'/projet/list.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
1313 $morehtmlref =
'<div class="refidno">';
1316 $morehtmlref .=
'<br>';
1318 if (!empty(
$object->thirdparty->id) &&
$object->thirdparty->id > 0) {
1319 $morehtmlref .=
$object->thirdparty->getNomUrl(1,
'project');
1325 $parent->fetch(
$object->fk_project);
1326 $morehtmlref .= $langs->trans(
"Child of").
' '.$parent->getNomUrl(1,
'project').
' '.$parent->title;
1329 $morehtmlref .=
'</div>';
1332 if (!$user->hasRight(
'projet',
'all',
'lire')) {
1333 $objectsListId =
$object->getProjectsAuthorizedForUser($user, 0, 0);
1334 $object->next_prev_filter =
"rowid IN (".$db->sanitize(count($objectsListId) ? implode(
',', array_keys($objectsListId)) :
'0').
")";
1337 dol_banner_tab(
$object,
'ref', $linkback, 1,
'ref',
'ref', $morehtmlref);
1339 print
'<div class="fichecenter">';
1340 print
'<div class="fichehalfleft">';
1341 print
'<div class="underbanner clearboth"></div>';
1343 print
'<table class="border tableforfield centpercent">';
1347 print
'<tr><td class="tdtop">';
1348 print $langs->trans(
"Usage");
1352 print
'<input type="checkbox" disabled name="usage_opportunity"'.(GETPOSTISSET(
'usage_opportunity') ? (
GETPOST(
'usage_opportunity',
'alpha') !=
'' ?
' checked="checked"' :
'') : (
$object->usage_opportunity ?
' checked="checked"' :
'')).
'> ';
1353 $htmltext = $langs->trans(
"ProjectFollowOpportunity");
1354 print $form->textwithpicto($langs->trans(
"ProjectFollowOpportunity"), $htmltext);
1358 print
'<input type="checkbox" disabled name="usage_task"'.(GETPOSTISSET(
'usage_task') ? (
GETPOST(
'usage_task',
'alpha') !=
'' ?
' checked="checked"' :
'') : (
$object->usage_task ?
' checked="checked"' :
'')).
'> ';
1359 $htmltext = $langs->trans(
"ProjectFollowTasks");
1360 print $form->textwithpicto($langs->trans(
"ProjectFollowTasks"), $htmltext);
1364 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"' :
'')).
'> ';
1365 $htmltext = $langs->trans(
"ProjectBillTimeDescription");
1366 print $form->textwithpicto($langs->trans(
"BillTime"), $htmltext);
1370 if (isModEnabled(
'eventorganization')) {
1371 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"' :
'')).
'> ';
1372 $htmltext = $langs->trans(
"EventOrganizationDescriptionLong");
1373 print $form->textwithpicto($langs->trans(
"ManageOrganizeEvent"), $htmltext);
1379 print
'<tr><td class="titlefield">'.$langs->trans(
"Visibility").
'</td><td>';
1381 print
img_picto($langs->trans(
'SharedProject'),
'world',
'class="paddingrightonly"');
1382 print $langs->trans(
'SharedProject');
1384 print
img_picto($langs->trans(
'PrivateProject'),
'private',
'class="paddingrightonly"');
1385 print $langs->trans(
'PrivateProject');
1391 print
'<tr><td>'.$langs->trans(
"OpportunityStatus");
1392 if ($action !=
'edit_opp_status' && $user->hasRight(
'projet',
'creer')) {
1393 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>';
1396 $html_name_status = ($action ==
'edit_opp_status') ?
'opp_status' :
'none';
1397 $html_name_percent = ($action ==
'edit_opp_status') ?
'opp_percent' :
'none';
1398 $percent_value = (GETPOSTISSET(
'opp_percent') ?
GETPOST(
'opp_percent') : (strcmp(
$object->opp_percent,
'') ?
vatrate(
$object->opp_percent) :
''));
1399 $formproject->formOpportunityStatus($_SERVER[
'PHP_SELF'].
'?socid='.
$object->id,
$object->opp_status, $percent_value, $html_name_status, $html_name_percent);
1403 print
'<tr><td>'.$langs->trans(
"OpportunityAmount").
'</td><td>';
1404 if (strcmp(
$object->opp_amount,
'')) {
1405 print
'<span class="amount">'.price(
$object->opp_amount, 0, $langs, 1, 0, -1, $conf->currency).
'</span>';
1406 if (strcmp(
$object->opp_percent,
'')) {
1407 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>';
1414 print
'<tr><td>'.$langs->trans(
"Budget").
'</td><td>';
1415 if (!is_null(
$object->budget_amount) && strcmp(
$object->budget_amount,
'')) {
1416 print
'<span class="amount">'.price(
$object->budget_amount, 0, $langs, 1, 0, 0, $conf->currency).
'</span>';
1421 print
'<tr><td>'.$langs->trans(
"Dates").
'</td><td>';
1423 print($start ? $start :
'?');
1425 print
' <span class="opacitymedium">-</span> ';
1426 print($end ? $end :
'?');
1434 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_view.tpl.php';
1439 print
'<div class="fichehalfright">';
1440 print
'<div class="underbanner clearboth"></div>';
1442 print
'<table class="border tableforfield centpercent">';
1445 print
'<td class="titlefield tdtop">'.$langs->trans(
"Description").
'</td><td>';
1446 print
'<div class="longmessagecut">';
1452 if (isModEnabled(
'category')) {
1453 print
'<tr><td class="valignmiddle">'.$langs->trans(
"Categories").
'</td><td>';
1454 print $form->showCategories(
$object->id, Categorie::TYPE_PROJECT, 1);
1463 print
'<div class="clearboth"></div>';
1468 if ($action ==
'edit' && $userWrite > 0) {
1469 print $form->buttonsSaveCancel();
1475 print
'<script type="text/javascript">
1476 jQuery(document).ready(function() {
1477 jQuery("#usage_task").change(function() {
1478 console.log("We click on usage task "+jQuery("#usage_task").is(":checked"));
1479 if (! jQuery("#usage_task").is(":checked")) {
1480 jQuery("#usage_bill_time").prop("checked", false);
1484 jQuery("#usage_bill_time").change(function() {
1485 console.log("We click on usage to bill time");
1486 if (jQuery("#usage_bill_time").is(":checked")) {
1487 jQuery("#usage_task").prop("checked", true);
1491 jQuery("#projectstart").change(function() {
1492 console.log("We modify the start date");
1493 jQuery("#divreportdate").show();
1499 if (!empty($conf->use_javascript_ajax) &&
getDolGlobalString(
'PROJECT_USE_OPPORTUNITIES')) {
1501 $defaultcheckedwhenoppclose = 1;
1503 $defaultcheckedwhenoppclose = 0;
1506 print
'<!-- Javascript to manage opportunity status change -->';
1507 print
'<script type="text/javascript">
1508 jQuery(document).ready(function() {
1509 function change_percent()
1511 var element = jQuery("#opp_status option:selected");
1512 var defaultpercent = element.attr("defaultpercent");
1513 var defaultcloseproject = '.((int) $defaultcheckedwhenoppclose).
';
1514 var elemcode = element.attr("elemcode");
1517 console.log(
"We select "+elemcode);
1520 var closeproject = 0;
1521 if (elemcode == \
'LOST\') closeproject = 1;
1522 if (elemcode == \'WON\') closeproject = defaultcloseproject;
1523 if (closeproject) jQuery("#inputcloseproject").prop("checked", true);
1524 else jQuery("#inputcloseproject").prop("checked", false);
1526 /* Make the close project checkbox visible or not */
1527 console.log("closeproject="+closeproject);
1528 if (elemcode == \'WON\' || elemcode == \'LOST\')
1530 jQuery("#divtocloseproject").show();
1534 jQuery("#divtocloseproject").hide();
1537 /* Change percent with default percent (defaultpercent) if new status (defaultpercent) is higher than current (jQuery("#opp_percent").val()) */
1538 if (oldpercent != \'\' && (parseFloat(defaultpercent) < parseFloat(oldpercent)))
1540 console.log("oldpercent="+oldpercent+" defaultpercent="+defaultpercent+" def < old");
1541 if (jQuery("#opp_percent").val() != \'\' && oldpercent != \'\') {
1542 jQuery("#oldopppercent").text(\' - '.
dol_escape_js($langs->transnoentities(
"PreviousValue")).
': \'+price2numjs(oldpercent)+\' %\');
1545 if (parseFloat(oldpercent) != 100 && elemcode != \'LOST\') { jQuery("#opp_percent").val(oldpercent); }
1546 else { jQuery("#opp_percent").val(price2numjs(defaultpercent)); }
1548 console.log("oldpercent="+oldpercent+" defaultpercent="+defaultpercent);
1549 if (jQuery("#opp_percent").val() == \'\' || (parseFloat(jQuery("#opp_percent").val()) < parseFloat(defaultpercent))) {
1550 if (jQuery("#opp_percent").val() != \'\' && oldpercent != \'\') {
1551 jQuery("#oldopppercent").text(\' - '.
dol_escape_js($langs->transnoentities(
"PreviousValue")).
': \'+price2numjs(oldpercent)+\' %\');
1553 jQuery("#opp_percent").val(price2numjs(defaultpercent));
1558 jQuery("#opp_status").change(function() {
1570 print
'<div class="tabsAction">';
1571 $parameters = array();
1572 $reshook = $hookmanager->executeHooks(
'addMoreActionsButtons', $parameters,
$object, $action);
1574 if (empty($reshook)) {
1575 if ($action !=
"edit" && $action !=
'presend') {
1585 if (empty($user->socid)) {
1587 print
dolGetButtonAction(
'', $langs->trans(
'SendMail'),
'default', $_SERVER[
"PHP_SELF"].
'?action=presend&token='.
newToken().
'&id='.
$object->id.
'&mode=init#formmailbeforetitle',
'');
1607 if ($userWrite > 0) {
1608 print
dolGetButtonAction(
'', $langs->trans(
'SetToDraft'),
'default', $_SERVER[
"PHP_SELF"].
'?action=confirm_setdraft&confirm=yes&token='.
newToken().
'&id='.
$object->id,
'');
1610 print
dolGetButtonAction($langs->trans(
'NotOwnerOfProject'), $langs->trans(
'SetToDraft'),
'default', $_SERVER[
'PHP_SELF'].
'#',
'',
false);
1617 if ($userWrite > 0) {
1620 print
dolGetButtonAction($langs->trans(
'NotOwnerOfProject'), $langs->trans(
'Modify'),
'default', $_SERVER[
'PHP_SELF'].
'#',
'',
false);
1626 if ($userWrite > 0) {
1629 print
dolGetButtonAction($langs->trans(
'NotOwnerOfProject'), $langs->trans(
'Validate'),
'default', $_SERVER[
'PHP_SELF'].
'#',
'',
false);
1635 if ($userWrite > 0) {
1638 print
dolGetButtonAction($langs->trans(
'NotOwnerOfProject'), $langs->trans(
'Close'),
'default', $_SERVER[
'PHP_SELF'].
'#',
'',
false);
1644 if ($userWrite > 0) {
1647 print
dolGetButtonAction($langs->trans(
'NotOwnerOfProject'), $langs->trans(
'ReOpen'),
'default', $_SERVER[
'PHP_SELF'].
'#',
'',
false);
1654 $arrayforbutaction = array(
1656 10 => array(
'lang' =>
'propal',
'enabled' => isModEnabled(
"propal"),
'perm' => $user->hasRight(
'propal',
'creer'),
'label' =>
'AddProp',
'url' =>
'/comm/propal/card.php?action=create&projectid='.$object->id.
'&socid='.
$object->socid),
1657 20 => array(
'lang' =>
'orders',
'enabled' => isModEnabled(
"order"),
'perm' => $user->hasRight(
'commande',
'creer'),
'label' =>
'CreateOrder',
'url' =>
'/commande/card.php?action=create&projectid='.$object->id.
'&socid='.
$object->socid),
1658 30 => array(
'lang' =>
'bills',
'enabled' => isModEnabled(
"invoice"),
'perm' => $user->hasRight(
'facture',
'creer'),
'label' =>
'CreateBill',
'url' =>
'/compta/facture/card.php?action=create&projectid='.$object->id.
'&socid='.
$object->socid),
1659 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.
'&socid='.
$object->socid),
1660 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.
'&socid='.
$object->socid),
1661 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.
'&socid='.
$object->socid),
1662 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),
1663 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),
1664 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),
1665 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),
1668 $params = array(
'backtopage' => $_SERVER[
"PHP_SELF"].
'?id='.
$object->id);
1671 print
dolGetButtonAction(
'', $langs->trans(
"Create"),
'default', $arrayforbutaction,
'', 1, $params);
1675 if ($user->hasRight(
'projet',
'creer')) {
1676 if ($userWrite > 0) {
1679 print
dolGetButtonAction($langs->trans(
'NotOwnerOfProject'), $langs->trans(
'ToClone'),
'default', $_SERVER[
'PHP_SELF'].
'#',
'',
false);
1688 print
dolGetButtonAction($langs->trans(
'NotOwnerOfProject'), $langs->trans(
'Delete'),
'default', $_SERVER[
'PHP_SELF'].
'#',
'',
false);
1696 if (
GETPOST(
'modelselected')) {
1697 $action =
'presend';
1700 if ($action !=
'presend') {
1701 print
'<div class="fichecenter"><div class="fichehalfleft">';
1702 print
'<a name="builddoc"></a>';
1708 $children =
$object->getChildren();
1710 print
'<table class="centpercent notopnoleftnoright table-fiche-title">';
1711 print
'<tr class="titre"><td class="nobordernopadding valignmiddle col-title">';
1712 print
'<div class="titre inline-block">'.$langs->trans(
'Sub-projects').
'</div>';
1713 print
'</td></tr></table>';
1715 print
'<div class="div-table-responsive-no-min">';
1716 print
'<table class="centpercent noborder'.($morecss ?
' '.$morecss :
'').
'">';
1717 print
'<tr class="liste_titre">';
1718 print
getTitleFieldOfList(
'Ref', 0, $_SERVER[
"PHP_SELF"],
'',
'',
'',
'',
'',
'',
'', 1);
1719 print
getTitleFieldOfList(
'Title', 0, $_SERVER[
"PHP_SELF"],
'',
'',
'',
'',
'',
'',
'', 1);
1720 print
getTitleFieldOfList(
'Status', 0, $_SERVER[
"PHP_SELF"],
'',
'',
'',
'',
'',
'',
'', 1);
1724 $subproject =
new Project($db);
1725 foreach ($children as $child) {
1726 $subproject->fetch($child->rowid);
1727 print
'<tr class="oddeven">';
1728 print
'<td class="nowraponall">'.$subproject->getNomUrl(1,
'project').
'</td>';
1729 print
'<td class="nowraponall tdoverflowmax125">'.$child->title.
'</td>';
1730 print
'<td class="nowraponall">'.$subproject->getLibStatut(5).
'</td>';
1744 $urlsource = $_SERVER[
"PHP_SELF"].
"?id=".
$object->id;
1745 $genallowed = ($user->hasRight(
'projet',
'lire') && $userAccess > 0);
1746 $delallowed = ($user->hasRight(
'projet',
'creer') && $userWrite > 0);
1748 print $formfile->showdocuments(
'project', $filename, $filedir, $urlsource, $genallowed, $delallowed,
$object->model_pdf, 1, 0, 0, 0, 0,
'',
'',
'',
'',
'',
$object);
1750 print
'</div><div class="fichehalfright">';
1754 $morehtmlcenter =
'<div class="nowraponall">';
1755 $morehtmlcenter .=
dolGetButtonTitle($langs->trans(
'FullConversation'),
'',
'fa fa-comments imgforviewmode', DOL_URL_ROOT.
'/projet/messaging.php?id='.
$object->id);
1756 $morehtmlcenter .=
dolGetButtonTitle($langs->trans(
'FullList'),
'',
'fa fa-bars imgforviewmode', DOL_URL_ROOT.
'/projet/agenda.php?id='.
$object->id);
1757 $morehtmlcenter .=
'</div>';
1760 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formactions.class.php';
1762 $somethingshown = $formactions->showactions(
$object,
'project', 0, 1,
'', $MAXEVENT,
'', $morehtmlcenter);
1764 print
'</div></div>';
1768 $modelmail =
'project';
1769 $defaulttopic =
'SendProjectRef';
1770 $defaulttopiclang =
'projects';
1771 $diroutput = $conf->project->multidir_output[
$object->entity];
1772 $autocopy =
'MAIN_MAIL_AUTOCOPY_PROJECT_TO';
1773 $trackid =
'proj'.$object->id;
1775 include DOL_DOCUMENT_ROOT.
'/core/tpl/card_presend.tpl.php';
1778 $parameters = array();
1779 $reshook = $hookmanager->executeHooks(
'mainCardTabAddMore', $parameters,
$object, $action);
1781 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'.
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