20 if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES))
22 $sql =
"SELECT p.fk_opp_status as opp_status, cls.code, COUNT(p.rowid) as nb, SUM(p.opp_amount) as opp_amount, SUM(p.opp_amount * p.opp_percent) as ponderated_opp_amount";
23 $sql .=
" FROM ".MAIN_DB_PREFIX.
"projet as p LEFT JOIN ".MAIN_DB_PREFIX.
"c_lead_status as cls ON p.fk_opp_status = cls.rowid";
24 $sql .=
" WHERE p.entity IN (".getEntity(
'project').
")";
25 $sql .=
" AND p.fk_statut = 1";
26 if ($mine || empty($user->rights->projet->all->lire)) $sql .=
" AND p.rowid IN (".$projectsListId.
")";
27 if ($socid) $sql .=
" AND (p.fk_soc IS NULL OR p.fk_soc = 0 OR p.fk_soc = ".$socid.
")";
28 $sql .=
" GROUP BY p.fk_opp_status, cls.code";
33 $num = $db->num_rows(
$resql);
39 $ponderated_opp_amount = 0;
41 $valsamount = array();
42 $dataseries = array();
46 $obj = $db->fetch_object(
$resql);
49 $valsnb[$obj->opp_status] = $obj->nb;
50 $valsamount[$obj->opp_status] = $obj->opp_amount;
52 if ($obj->opp_status) $totaloppnb += $obj->nb;
53 if (!in_array($obj->code, array(
'WON',
'LOST'))) {
54 $totalamount += $obj->opp_amount;
55 $ponderated_opp_amount += $obj->ponderated_opp_amount;
63 $ponderated_opp_amount = $ponderated_opp_amount / 100;
65 print '<div class="div-table-responsive-no-min">';
66 print '<table class="noborder nohover centpercent">';
67 print '<tr class="liste_titre"><th colspan="2">'.$langs->trans(
"Statistics").
' - '.$langs->trans(
"OpportunitiesStatusForOpenedProjects").
'</th></tr>'.
"\n";
69 $listofstatus = array_keys($listofoppstatus);
71 foreach ($valsamount as $key => $val) {
72 if (!in_array($key, $listofstatus) && $key) {
73 $listofstatus[] = $key;
77 foreach ($listofstatus as $status)
82 if ($code) $labelStatus = $langs->transnoentitiesnoconv(
"OppStatus".$code);
83 if (empty($labelStatus)) $labelStatus = $listofopplabel[$status];
84 if (empty($labelStatus)) $labelStatus = $langs->transnoentitiesnoconv(
'OldValue', $status);
89 $dataseries[] = array($labelStatus, (isset($valsamount[$status]) ? (
float) $valsamount[$status] : 0));
90 if (!$conf->use_javascript_ajax)
92 print '<tr class="oddeven">';
93 print '<td>'.$labelStatus.
'</td>';
94 print '<td class="right"><a href="list.php?statut='.$status.
'">'.
price((isset($valsamount[$status]) ? (
float) $valsamount[$status] : 0), 0,
'', 1, -1, -1, $conf->currency).
'</a></td>';
98 if ($conf->use_javascript_ajax)
100 print '<tr><td class="center nopaddingleftimp nopaddingrightimp" colspan="2">';
102 include_once DOL_DOCUMENT_ROOT.
'/core/class/dolgraph.class.php';
104 $dolgraph->SetData($dataseries);
105 $dolgraph->SetDataColor(array_values($colorseries));
106 $dolgraph->setShowLegend(2);
107 $dolgraph->setShowPercent(1);
108 $dolgraph->SetType(array(
'pie'));
110 $dolgraph->SetHeight(
'200');
111 $dolgraph->draw(
'idgraphstatus');
112 print $dolgraph->show($totaloppnb ? 0 : 1);
118 print '<tr class="liste_total"><td class="maxwidth200 tdoverflow">'.$langs->trans(
"OpportunityTotalAmount").
' ('.$langs->trans(
"WonLostExcluded").
')</td><td class="right">'.
price($totalamount, 0,
'', 1, -1, -1, $conf->currency).
'</td></tr>';
119 print '<tr class="liste_total"><td class="minwidth200 tdoverflow">';
121 print $form->textwithpicto($langs->trans(
"OpportunityPonderatedAmount").
' ('.$langs->trans(
"WonLostExcluded").
')', $langs->trans(
"OpportunityPonderatedAmountDesc"), 1);
122 print '</td><td class="right">'.price(
price2num($ponderated_opp_amount,
'MT'), 0,
'', 1, -1, -1, $conf->currency).
'</td></tr>';
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...
price2num($amount, $rounding= '', $option=0)
Function that return a number with universal decimal format (decimal separator is '...
dol_getIdFromCode($db, $key, $tablename, $fieldkey= 'code', $fieldid= 'id', $entityfilter=0)
Return an id or code from a code or id.
print
Draft customers invoices.
if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) if(!empty($conf->don->enabled)&&$user->rights->don->lire) if(!empty($conf->tax->enabled)&&$user->rights->tax->charges->lire) if(!empty($conf->facture->enabled)&&!empty($conf->commande->enabled)&&$user->rights->commande->lire &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) $resql
Social contributions to pay.
dol_print_error($db= '', $error= '', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...