Fix status of opportunity is required if an amount is defined

This commit is contained in:
Laurent Destailleur 2017-03-02 12:51:43 +01:00
parent 29618890f4
commit 57b532cdd0
2 changed files with 11 additions and 4 deletions

View File

@ -232,6 +232,7 @@ UPDATE llx_actioncomm set fk_user_action = fk_user_author where fk_user_author >
UPDATE llx_projet_task_time set task_datehour = task_date where task_datehour IS NULL and task_date IS NOT NULL;
UPDATE llx_projet set fk_opp_status = NULL where fk_opp_status = -1;
UPDATE llx_projet set fk_opp_status = (SELECT rowid FROM llx_c_lead_status WHERE code='PROSP') where fk_opp_status IS NULL and opp_amount > 0;
UPDATE llx_c_lead_status set code = 'WON' where code = 'WIN';
-- Requests to clean old tables or external modules tables

View File

@ -129,6 +129,12 @@ if (empty($reshook))
$error++;
}
if (GETPOST('opp_amount') != '' && ! (GETPOST('opp_status') > 0))
{
$error++;
setEventMessages($langs->trans("ErrorOppStatusRequiredIfAmount"), null, 'errors');
}
if (! $error)
{
$error=0;
@ -558,26 +564,26 @@ if ($action == 'create' && $user->rights->projet->creer)
// Opportunity probability
print '<tr><td>'.$langs->trans("OpportunityProbability").'</td>';
print '<td><input size="5" type="text" id="opp_percent" name="opp_percent" value="'.(GETPOST('opp_percent')!=''?price(GETPOST('opp_percent')):'').'"><span class="hideonsmartphone"> %</span>';
print '<td><input size="5" type="text" id="opp_percent" name="opp_percent" value="'.(GETPOST('opp_percent')!=''?GETPOST('opp_percent'):'').'"><span class="hideonsmartphone"> %</span>';
print '<input type="hidden" name="opp_percent_not_set" id="opp_percent_not_set" value="'.(GETPOST('opp_percent')!=''?'0':'1').'">';
print '</td>';
print '</tr>';
// Opportunity amount
print '<tr><td>'.$langs->trans("OpportunityAmount").'</td>';
print '<td><input size="5" type="text" name="opp_amount" value="'.(GETPOST('opp_amount')!=''?price(GETPOST('opp_amount')):'').'"></td>';
print '<td><input size="5" type="text" name="opp_amount" value="'.(GETPOST('opp_amount')!=''?GETPOST('opp_amount'):'').'"></td>';
print '</tr>';
}
// Budget
print '<tr><td>'.$langs->trans("Budget").'</td>';
print '<td><input size="5" type="text" name="budget_amount" value="'.(GETPOST('budget_amount')!=''?price(GETPOST('budget_amount')):'').'"></td>';
print '<td><input size="5" type="text" name="budget_amount" value="'.(GETPOST('budget_amount')!=''?GETPOST('budget_amount'):'').'"></td>';
print '</tr>';
// Description
print '<tr><td class="tdtop">'.$langs->trans("Description").'</td>';
print '<td>';
print '<textarea name="description" wrap="soft" class="centpercent" rows="'.ROWS_3.'">'.$_POST["description"].'</textarea>';
print '<textarea name="description" wrap="soft" class="centpercent" rows="'.ROWS_3.'">'.GETPOST("description").'</textarea>';
print '</td></tr>';
if ($conf->categorie->enabled) {