This commit is contained in:
Laurent Destailleur 2017-06-03 00:58:51 +02:00
parent 976c8e0752
commit af584bc9c0

View File

@ -134,7 +134,7 @@ if (empty($reshook))
$error++; $error++;
setEventMessages($langs->trans("ErrorOppStatusRequiredIfAmount"), null, 'errors'); setEventMessages($langs->trans("ErrorOppStatusRequiredIfAmount"), null, 'errors');
} }
if (! $error) if (! $error)
{ {
$error=0; $error=0;
@ -308,8 +308,8 @@ if (empty($reshook))
setEventMessages($langs->trans("FailedToCloseProject").':'.$object->error, $object->errors, 'errors'); setEventMessages($langs->trans("FailedToCloseProject").':'.$object->error, $object->errors, 'errors');
} }
} }
if ($error) if ($error)
{ {
$db->rollback(); $db->rollback();
@ -322,7 +322,7 @@ if (empty($reshook))
if (GETPOST('socid','int') > 0) $object->fetch_thirdparty(GETPOST('socid','int')); if (GETPOST('socid','int') > 0) $object->fetch_thirdparty(GETPOST('socid','int'));
else unset($object->thirdparty); else unset($object->thirdparty);
} }
} }
// Build doc // Build doc
@ -619,7 +619,7 @@ if ($action == 'create' && $user->rights->projet->creer)
{ {
print '     '; print '     ';
print '<input type="button" class="button" value="' . $langs->trans("Cancel") . '" onClick="javascript:history.go(-1)">'; print '<input type="button" class="button" value="' . $langs->trans("Cancel") . '" onClick="javascript:history.go(-1)">';
} }
print '</div>'; print '</div>';
print '</form>'; print '</form>';
@ -641,12 +641,12 @@ if ($action == 'create' && $user->rights->projet->creer)
}); });
</script>'; </script>';
} }
elseif ($object->id > 0) elseif ($object->id > 0)
{ {
/* /*
* Show or edit * Show or edit
*/ */
$res=$object->fetch_optionals($object->id,$extralabels); $res=$object->fetch_optionals($object->id,$extralabels);
// To verify role of users // To verify role of users
@ -828,26 +828,26 @@ elseif ($object->id > 0)
else else
{ {
// Project card // Project card
$linkback = '<a href="'.DOL_URL_ROOT.'/projet/list.php">'.$langs->trans("BackToList").'</a>'; $linkback = '<a href="'.DOL_URL_ROOT.'/projet/list.php">'.$langs->trans("BackToList").'</a>';
$morehtmlref='<div class="refidno">'; $morehtmlref='<div class="refidno">';
// Title // Title
$morehtmlref.=$object->title; $morehtmlref.=$object->title;
// Thirdparty // Thirdparty
if ($object->thirdparty->id > 0) if ($object->thirdparty->id > 0)
{ {
$morehtmlref.='<br>'.$langs->trans('ThirdParty') . ' : ' . $object->thirdparty->getNomUrl(1, 'project'); $morehtmlref.='<br>'.$langs->trans('ThirdParty') . ' : ' . $object->thirdparty->getNomUrl(1, 'project');
} }
$morehtmlref.='</div>'; $morehtmlref.='</div>';
// Define a complementary filter for search of next/prev ref. // Define a complementary filter for search of next/prev ref.
if (! $user->rights->projet->all->lire) if (! $user->rights->projet->all->lire)
{ {
$objectsListId = $object->getProjectsAuthorizedForUser($user,0,0); $objectsListId = $object->getProjectsAuthorizedForUser($user,0,0);
$object->next_prev_filter=" rowid in (".(count($objectsListId)?join(',',array_keys($objectsListId)):'0').")"; $object->next_prev_filter=" rowid in (".(count($objectsListId)?join(',',array_keys($objectsListId)):'0').")";
} }
dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref); dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref);
@ -881,18 +881,18 @@ elseif ($object->id > 0)
if (strcmp($object->opp_amount,'')) print price($object->opp_amount,0,$langs,1,0,0,$conf->currency); if (strcmp($object->opp_amount,'')) print price($object->opp_amount,0,$langs,1,0,0,$conf->currency);
print '</td></tr>'; print '</td></tr>';
} }
// Date start - end // Date start - end
print '<tr><td>'.$langs->trans("DateStart").' - '.$langs->trans("DateEnd").'</td><td>'; print '<tr><td>'.$langs->trans("DateStart").' - '.$langs->trans("DateEnd").'</td><td>';
print dol_print_date($object->date_start,'day'); print dol_print_date($object->date_start,'day');
$end=dol_print_date($object->date_end,'day'); $end=dol_print_date($object->date_end,'day');
if ($end) if ($end)
{ {
print ' - '.$end; print ' - '.$end;
if ($object->hasDelay()) print img_warning($langs->trans('Late')); if ($object->hasDelay()) print img_warning($langs->trans('Late'));
} }
print '</td></tr>'; print '</td></tr>';
// Budget // Budget
print '<tr><td>'.$langs->trans("Budget").'</td><td>'; print '<tr><td>'.$langs->trans("Budget").'</td><td>';
if (strcmp($object->budget_amount, '')) print price($object->budget_amount,0,$langs,1,0,0,$conf->currency); if (strcmp($object->budget_amount, '')) print price($object->budget_amount,0,$langs,1,0,0,$conf->currency);
@ -901,16 +901,16 @@ elseif ($object->id > 0)
// Other attributes // Other attributes
$cols = 2; $cols = 2;
include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php'; include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php';
print '</table>'; print '</table>';
print '</div>'; print '</div>';
print '<div class="fichehalfright">'; print '<div class="fichehalfright">';
print '<div class="ficheaddleft">'; print '<div class="ficheaddleft">';
print '<div class="underbanner clearboth"></div>'; print '<div class="underbanner clearboth"></div>';
print '<table class="border" width="100%">'; print '<table class="border" width="100%">';
// Description // Description
print '<td class="titlefield tdtop">'.$langs->trans("Description").'</td><td>'; print '<td class="titlefield tdtop">'.$langs->trans("Description").'</td><td>';
print nl2br($object->description); print nl2br($object->description);
@ -922,13 +922,13 @@ elseif ($object->id > 0)
print $form->showCategories($object->id,'project',1); print $form->showCategories($object->id,'project',1);
print "</td></tr>"; print "</td></tr>";
} }
print '</table>'; print '</table>';
print '</div>'; print '</div>';
print '</div>'; print '</div>';
print '</div>'; print '</div>';
print '<div class="clearboth"></div>'; print '<div class="clearboth"></div>';
} }
@ -947,9 +947,10 @@ elseif ($object->id > 0)
// Change probability from status // Change probability from status
if (! empty($conf->use_javascript_ajax) && ! empty($conf->global->PROJECT_USE_OPPORTUNITIES)) if (! empty($conf->use_javascript_ajax) && ! empty($conf->global->PROJECT_USE_OPPORTUNITIES))
{ {
// Default value to close or not when we set opp to 'WON'.
$defaultcheckedwhenoppclose=1; $defaultcheckedwhenoppclose=1;
if (empty($conf->global->PROJECT_HIDE_TASKS)) $defaultcheckedwhenoppclose=0; if (empty($conf->global->PROJECT_HIDE_TASKS)) $defaultcheckedwhenoppclose=0;
print '<!-- Javascript to manage opportunity status change -->'; print '<!-- Javascript to manage opportunity status change -->';
print '<script type="text/javascript" language="javascript"> print '<script type="text/javascript" language="javascript">
jQuery(document).ready(function() { jQuery(document).ready(function() {
@ -962,13 +963,17 @@ elseif ($object->id > 0)
var oldpercent = \''.dol_escape_js($object->opp_percent).'\'; var oldpercent = \''.dol_escape_js($object->opp_percent).'\';
console.log("We select "+elemcode); console.log("We select "+elemcode);
if (elemcode == \'LOST\') defaultcloseproject = 1;
jQuery("#divtocloseproject").show(); /* Define if checkbox to close is checked or not */
if (defaultcloseproject) jQuery("#inputcloseproject").prop("checked", true); closeproject = 0;
if (elemcode == \'LOST\') closeproject = 1;
if (elemcode == \'WON\') closeproject = defaultcloseproject;
if (closeproject) jQuery("#inputcloseproject").prop("checked", true);
else jQuery("#inputcloseproject").prop("checked", false); else jQuery("#inputcloseproject").prop("checked", false);
console.log("closeproject="+closeproject);
/* Make close project visible or not */
if (elemcode == \'WON\' || elemcode == \'LOST\') /* Make the close project checkbox visible or not */
if (elemcode == \'WON\' || elemcode == \'LOST\')
{ {
jQuery("#divtocloseproject").show(); jQuery("#divtocloseproject").show();
} }
@ -976,7 +981,7 @@ elseif ($object->id > 0)
{ {
jQuery("#divtocloseproject").hide(); jQuery("#divtocloseproject").hide();
} }
/* Change percent of default percent of new status is higher */ /* Change percent of default percent of new status is higher */
if (parseFloat(jQuery("#opp_percent").val()) != parseFloat(defaultpercent)) if (parseFloat(jQuery("#opp_percent").val()) != parseFloat(defaultpercent))
{ {
@ -1003,7 +1008,7 @@ elseif ($object->id > 0)
{ {
if ($action != "edit" ) if ($action != "edit" )
{ {
// Create event // Create event
if ($conf->agenda->enabled && ! empty($conf->global->MAIN_ADD_EVENT_ON_ELEMENT_CARD)) // Add hidden condition because this is not a if ($conf->agenda->enabled && ! empty($conf->global->MAIN_ADD_EVENT_ON_ELEMENT_CARD)) // Add hidden condition because this is not a
// "workflow" action so should appears somewhere else on // "workflow" action so should appears somewhere else on