NEW add weighted amount on project/opportunity
This commit is contained in:
parent
8190a68bba
commit
0396b348f7
@ -1836,14 +1836,14 @@ function print_projecttasks_array($db, $form, $socid, $projectsListId, $mytasks
|
||||
if (empty($arrayidofprojects)) $arrayidofprojects[0] = -1;
|
||||
|
||||
// Get list of project with calculation on tasks
|
||||
$sql2 = "SELECT p.rowid as projectid, p.ref, p.title, p.fk_soc, s.nom as socname, p.fk_user_creat, p.public, p.fk_statut as status, p.fk_opp_status as opp_status, p.opp_amount,";
|
||||
$sql2 = "SELECT p.rowid as projectid, p.ref, p.title, p.fk_soc, s.nom as socname, p.fk_user_creat, p.public, p.fk_statut as status, p.fk_opp_status as opp_status, p.opp_percent, p.opp_amount,";
|
||||
$sql2 .= " p.dateo, p.datee,";
|
||||
$sql2 .= " COUNT(t.rowid) as nb, SUM(t.planned_workload) as planned_workload, SUM(t.planned_workload * t.progress / 100) as declared_progess_workload";
|
||||
$sql2 .= " FROM ".MAIN_DB_PREFIX."projet as p";
|
||||
$sql2 .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = p.fk_soc";
|
||||
$sql2 .= " LEFT JOIN ".MAIN_DB_PREFIX."projet_task as t ON p.rowid = t.fk_projet";
|
||||
$sql2 .= " WHERE p.rowid IN (".join(',', $arrayidofprojects).")";
|
||||
$sql2 .= " GROUP BY p.rowid, p.ref, p.title, p.fk_soc, s.nom, p.fk_user_creat, p.public, p.fk_statut, p.fk_opp_status, p.opp_amount, p.dateo, p.datee";
|
||||
$sql2 .= " GROUP BY p.rowid, p.ref, p.title, p.fk_soc, s.nom, p.fk_user_creat, p.public, p.fk_statut, p.fk_opp_status, p.opp_percent, p.opp_amount, p.dateo, p.datee";
|
||||
$sql2 .= " ORDER BY p.title, p.ref";
|
||||
|
||||
$resql = $db->query($sql2);
|
||||
@ -1862,7 +1862,7 @@ function print_projecttasks_array($db, $form, $socid, $projectsListId, $mytasks
|
||||
if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES))
|
||||
{
|
||||
print_liste_field_titre("OpportunityAmount", "", "", "", "", 'align="right"', $sortfield, $sortorder);
|
||||
print_liste_field_titre("OpportunityStatus", "", "", "", "", 'align="right"', $sortfield, $sortorder);
|
||||
print_liste_field_titre('OpportunityWeightedAmount', '', '', '', '', 'align="right"', $sortfield, $sortorder);
|
||||
}
|
||||
if (empty($conf->global->PROJECT_HIDE_TASKS))
|
||||
{
|
||||
@ -1914,8 +1914,11 @@ function print_projecttasks_array($db, $form, $socid, $projectsListId, $mytasks
|
||||
if ($objp->opp_amount) print price($objp->opp_amount, 0, '', 1, -1, -1, $conf->currency);
|
||||
print '</td>';
|
||||
print '<td class="right">';
|
||||
$code = dol_getIdFromCode($db, $objp->opp_status, 'c_lead_status', 'rowid', 'code');
|
||||
if ($code) print $langs->trans("OppStatus".$code);
|
||||
if ($objp->opp_percent && $objp->opp_amount) {
|
||||
$opp_weighted_amount = $objp->opp_percent * $objp->opp_amount / 100;
|
||||
print price($opp_weighted_amount, 0, '', 1, -1, -1, $conf->currency);
|
||||
$ponderated_opp_amount += price2num($opp_weighted_amount);
|
||||
}
|
||||
print '</td>';
|
||||
}
|
||||
if (empty($conf->global->PROJECT_HIDE_TASKS))
|
||||
@ -1944,7 +1947,6 @@ function print_projecttasks_array($db, $form, $socid, $projectsListId, $mytasks
|
||||
|
||||
$total_task = $total_task + $objp->nb;
|
||||
$total_opp_amount = $total_opp_amount + $objp->opp_amount;
|
||||
$ponderated_opp_amount = $ponderated_opp_amount + price2num($listofoppstatus[$objp->opp_status] * $objp->opp_amount / 100);
|
||||
}
|
||||
|
||||
$i++;
|
||||
|
||||
@ -162,6 +162,8 @@ OpportunityProbability=Lead probability
|
||||
OpportunityProbabilityShort=Lead probab.
|
||||
OpportunityAmount=Lead amount
|
||||
OpportunityAmountShort=Lead amount
|
||||
OpportunityWeightedAmount=Opportunity weighted amount
|
||||
OpportunityWeightedAmountShort=Opp. weighted amount
|
||||
OpportunityAmountAverageShort=Average lead amount
|
||||
OpportunityAmountWeigthedShort=Weighted lead amount
|
||||
WonLostExcluded=Won/Lost excluded
|
||||
|
||||
@ -162,6 +162,8 @@ OpportunityProbability=Probabilité d'opportunité
|
||||
OpportunityProbabilityShort=Prob. opp.
|
||||
OpportunityAmount=Montant opportunité
|
||||
OpportunityAmountShort=Montant opportunité
|
||||
OpportunityWeightedAmount=Montant pondéré opportunité
|
||||
OpportunityWeightedAmountShort=Montant pondéré opp.
|
||||
OpportunityAmountAverageShort=montant moyen des opportunités
|
||||
OpportunityAmountWeigthedShort=Montant pondéré des opportunités
|
||||
WonLostExcluded=hors opportunités remportées/perdues
|
||||
|
||||
@ -1045,6 +1045,11 @@ elseif ($object->id > 0)
|
||||
}*/
|
||||
if (strcmp($object->opp_amount, '')) print price($object->opp_amount, 0, $langs, 1, 0, -1, $conf->currency);
|
||||
print '</td></tr>';
|
||||
|
||||
// Opportunity Weighted Amount
|
||||
print '<tr><td>'.$langs->trans('OpportunityWeightedAmount').'</td><td>';
|
||||
if (strcmp($object->opp_amount, '') && strcmp($object->opp_percent, '')) print price($object->opp_amount * $object->opp_percent / 100, 0, $langs, 1, 0, -1, $conf->currency);
|
||||
print '</td></tr>';
|
||||
}
|
||||
|
||||
// Date start - end
|
||||
|
||||
@ -165,8 +165,8 @@ if (!empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS)) // This is useles
|
||||
include DOL_DOCUMENT_ROOT.'/projet/graph_opportunities.inc.php';
|
||||
|
||||
|
||||
// List of draft projects
|
||||
print_projecttasks_array($db, $form, $socid, $projectsListId, 0, 0, $listofoppstatus, array('projectlabel', 'plannedworkload', 'declaredprogress'));
|
||||
// List of validated projects
|
||||
print_projecttasks_array($db, $form, $socid, $projectsListId, 0, 1, $listofoppstatus, array('projectlabel', 'plannedworkload', 'declaredprogress'));
|
||||
|
||||
|
||||
print '</div><div class="fichetwothirdright"><div class="ficheaddleft">';
|
||||
|
||||
@ -131,7 +131,8 @@ $arrayfields = array(
|
||||
'p.opp_amount'=>array('label'=>$langs->trans("OpportunityAmountShort"), 'checked'=>1, 'enabled'=>($conf->global->PROJECT_USE_OPPORTUNITIES ? 1 : 0), 'position'=>103),
|
||||
'p.fk_opp_status'=>array('label'=>$langs->trans("OpportunityStatusShort"), 'checked'=>1, 'enabled'=>($conf->global->PROJECT_USE_OPPORTUNITIES ? 1 : 0), 'position'=>104),
|
||||
'p.opp_percent'=>array('label'=>$langs->trans("OpportunityProbabilityShort"), 'checked'=>1, 'enabled'=>($conf->global->PROJECT_USE_OPPORTUNITIES ? 1 : 0), 'position'=>105),
|
||||
'p.budget_amount'=>array('label'=>$langs->trans("Budget"), 'checked'=>0, 'position'=>110),
|
||||
'opp_weighted_amount'=>array('label'=>$langs->trans('OpportunityWeightedAmountShort'), 'checked'=>0, 'enabled'=>($conf->global->PROJECT_USE_OPPORTUNITIES?1:0), 'position'=>106),
|
||||
'p.budget_amount'=>array('label'=>$langs->trans("Budget"), 'checked'=>0, 'position'=>110),
|
||||
'p.usage_opportunity'=>array('label'=>$langs->trans("UsageOpportunity"), 'checked'=>0, 'enabled'=>($conf->global->PROJECT_USE_OPPORTUNITIES ? 1 : 0), 'position'=>115),
|
||||
'p.usage_task'=>array('label'=>$langs->trans("UsageTasks"), 'checked'=>0, 'enabled'=>($conf->global->PROJECT_HIDE_TASKS ? 0 : 1), 'position'=>116),
|
||||
'p.usage_bill_time'=>array('label'=>$langs->trans("UsageBillTimeShort"), 'checked'=>0, 'enabled'=>($conf->global->PROJECT_HIDE_TASKS ? 0 : 1), 'position'=>117),
|
||||
@ -289,7 +290,7 @@ if (count($listofprojectcontacttype) == 0) $listofprojectcontacttype[0] = '0'; /
|
||||
|
||||
$distinct = 'DISTINCT'; // We add distinct until we are added a protection to be sure a contact of a project and task is only once.
|
||||
$sql = "SELECT ".$distinct." p.rowid as id, p.ref, p.title, p.fk_statut, p.fk_opp_status, p.public, p.fk_user_creat";
|
||||
$sql .= ", p.datec as date_creation, p.dateo as date_start, p.datee as date_end, p.opp_amount, p.opp_percent, p.tms as date_update, p.budget_amount, p.usage_opportunity, p.usage_task, p.usage_bill_time";
|
||||
$sql .= ", p.datec as date_creation, p.dateo as date_start, p.datee as date_end, p.opp_amount, p.opp_percent, (p.opp_amount*p.opp_percent/100) as opp_weighted_amount, p.tms as date_update, p.budget_amount, p.usage_opportunity, p.usage_task, p.usage_bill_time";
|
||||
$sql .= ", s.rowid as socid, s.nom as name, s.email";
|
||||
$sql .= ", cls.code as opp_status_code";
|
||||
// We'll need these fields in order to filter by categ
|
||||
@ -604,6 +605,11 @@ if (!empty($arrayfields['p.opp_percent']['checked']))
|
||||
print '<input type="text" class="flat" name="search_opp_percent" size="2" value="'.$search_opp_percent.'">';
|
||||
print '</td>';
|
||||
}
|
||||
if (!empty($arrayfields['opp_weighted_amount']['checked']))
|
||||
{
|
||||
print '<td class="liste_titre nowrap right">';
|
||||
print '</td>';
|
||||
}
|
||||
if (!empty($arrayfields['p.budget_amount']['checked']))
|
||||
{
|
||||
print '<td class="liste_titre nowrap right">';
|
||||
@ -676,7 +682,8 @@ if (!empty($arrayfields['p.datee']['checked'])) print_liste_field_titre(
|
||||
if (!empty($arrayfields['p.public']['checked'])) print_liste_field_titre($arrayfields['p.public']['label'], $_SERVER["PHP_SELF"], "p.public", "", $param, "", $sortfield, $sortorder);
|
||||
if (!empty($arrayfields['p.fk_opp_status']['checked'])) print_liste_field_titre($arrayfields['p.fk_opp_status']['label'], $_SERVER["PHP_SELF"], 'p.fk_opp_status', "", $param, '', $sortfield, $sortorder, 'center ');
|
||||
if (!empty($arrayfields['p.opp_amount']['checked'])) print_liste_field_titre($arrayfields['p.opp_amount']['label'], $_SERVER["PHP_SELF"], 'p.opp_amount', "", $param, '', $sortfield, $sortorder, 'right ');
|
||||
if (!empty($arrayfields['p.opp_percent']['checked'])) print_liste_field_titre($arrayfields['p.opp_percent']['label'], $_SERVER["PHP_SELF"], 'p.opp_percent', "", $param, '', $sortfield, $sortorder, 'right ');
|
||||
if (!empty($arrayfields['p.opp_percent']['checked'])) print_liste_field_titre($arrayfields['p.opp_percent']['label'], $_SERVER['PHP_SELF'], 'p.opp_percent', "", $param, '', $sortfield, $sortorder, 'right ');
|
||||
if (!empty($arrayfields['opp_weighted_amount']['checked'])) print_liste_field_titre($arrayfields['opp_weighted_amount']['label'], $_SERVER['PHP_SELF'], 'opp_weighted_amount', '', $param, '', $sortfield, $sortorder, 'right ');
|
||||
if (!empty($arrayfields['p.budget_amount']['checked'])) print_liste_field_titre($arrayfields['p.budget_amount']['label'], $_SERVER["PHP_SELF"], 'p.budget_amount', "", $param, '', $sortfield, $sortorder, 'right ');
|
||||
if (!empty($arrayfields['p.usage_opportunity']['checked'])) print_liste_field_titre($arrayfields['p.usage_opportunity']['label'], $_SERVER["PHP_SELF"], 'p.usage_opportunity', "", $param, '', $sortfield, $sortorder, 'right ');
|
||||
if (!empty($arrayfields['p.usage_task']['checked'])) print_liste_field_titre($arrayfields['p.usage_task']['label'], $_SERVER["PHP_SELF"], 'p.usage_task', "", $param, '', $sortfield, $sortorder, 'right ');
|
||||
@ -848,6 +855,16 @@ while ($i < min($num, $limit))
|
||||
print '</td>';
|
||||
if (! $i) $totalarray['nbfield']++;
|
||||
}
|
||||
// Opp weighted amount
|
||||
if (!empty($arrayfields['opp_weighted_amount']['checked']))
|
||||
{
|
||||
print '<td align="right">';
|
||||
if ($obj->opp_weighted_amount) {
|
||||
print price($obj->opp_weighted_amount, 1, $langs, 1, -1, -1, '');
|
||||
}
|
||||
print '</td>';
|
||||
if (! $i) $totalarray['nbfield']++;
|
||||
}
|
||||
// Budget
|
||||
if (! empty($arrayfields['p.budget_amount']['checked']))
|
||||
{
|
||||
|
||||
Loading…
Reference in New Issue
Block a user