27 include_once DOL_DOCUMENT_ROOT.
"/core/boxes/modules_boxes.php";
34 public $boxcode =
"FunnelOfProspection";
35 public $boximg =
"object_projectpub";
36 public $boxlabel =
"BoxTitleFunnelOfProspection";
37 public $depends = array(
"projet");
39 public $version =
'development';
48 public $info_box_head = array();
49 public $info_box_contents = array();
59 global $user, $langs, $conf;
62 $langs->loadLangs(array(
'boxes',
'projects'));
66 $this->enabled = ($conf->global->MAIN_FEATURES_LEVEL >= 1 ? 1 : 0);
68 $this->hidden = empty($user->rights->projet->lire);
82 $badgeStatus0 =
'#cbd3d3';
83 $badgeStatus1 =
'#bc9526';
84 $badgeStatus1b =
'#bc9526';
85 $badgeStatus2 =
'#9c9c26';
86 $badgeStatus3 =
'#bca52b';
87 $badgeStatus4 =
'#25a580';
88 $badgeStatus4b =
'#25a580';
89 $badgeStatus5 =
'#cad2d2';
90 $badgeStatus6 =
'#cad2d2';
91 $badgeStatus7 =
'#baa32b';
92 $badgeStatus8 =
'#993013';
93 $badgeStatus9 =
'#e7f0f0';
94 if (file_exists(DOL_DOCUMENT_ROOT.
'/theme/'.$conf->theme.
'/theme_vars.inc.php')) {
95 include DOL_DOCUMENT_ROOT.
'/theme/'.$conf->theme.
'/theme_vars.inc.php';
97 $listofoppstatus = array();
98 $listofopplabel = array();
99 $listofoppcode = array();
100 $colorseriesstat = array();
101 $bordercolorseries = array();
102 $sql =
"SELECT cls.rowid, cls.code, cls.percent, cls.label";
103 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_lead_status as cls";
104 $sql .=
" WHERE active=1";
105 $sql .=
" AND cls.code <> 'LOST'";
106 $sql .= $this->
db->order(
'cls.rowid',
'ASC');
113 $objp = $this->
db->fetch_object(
$resql);
114 $listofoppstatus[$objp->rowid] = $objp->percent;
115 $listofopplabel[$objp->rowid] = $objp->label;
116 $listofoppcode[$objp->rowid] = $objp->code;
117 switch ($objp->code) {
119 $colorseriesstat[$objp->rowid] =
'#FFFFFF';
120 $bordercolorseries[$objp->rowid] = $badgeStatus0;
123 $colorseriesstat[$objp->rowid] =
'#FFFFFF';
124 $bordercolorseries[$objp->rowid] = $badgeStatus1;
127 $colorseriesstat[$objp->rowid] = $badgeStatus1;
128 $bordercolorseries[$objp->rowid] = $badgeStatus1;
131 $colorseriesstat[$objp->rowid] = $badgeStatus4;
132 $bordercolorseries[$objp->rowid] = $badgeStatus4;
135 $colorseriesstat[$objp->rowid] = $badgeStatus6;
136 $bordercolorseries[$objp->rowid] = $badgeStatus6;
147 global $conf, $user, $langs;
150 $this->info_box_head = array(
151 'text' => $langs->trans(
"Statistics").
' - '.$langs->trans(
"BoxTitleFunnelOfProspection"),
155 if ($user->rights->projet->lire || !empty($conf->global->PROJECT_USE_OPPORTUNITIES)) {
156 $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";
157 $sql .=
" FROM ".MAIN_DB_PREFIX.
"projet as p, ".MAIN_DB_PREFIX.
"c_lead_status as cls";
158 $sql .=
" WHERE p.entity IN (".getEntity(
'project').
")";
159 $sql .=
" AND p.fk_opp_status = cls.rowid";
160 $sql .=
" AND p.fk_statut = 1";
161 $sql .=
" AND cls.code NOT IN ('LOST')";
162 $sql .=
" GROUP BY p.fk_opp_status, cls.code";
173 $ponderated_opp_amount = 0;
175 $valsamount = array();
176 $dataseries = array();
179 $obj = $this->
db->fetch_object(
$resql);
181 $valsnb[$obj->opp_status] = $obj->nb;
182 $valsamount[$obj->opp_status] = $obj->opp_amount;
183 $totalnb += $obj->nb;
184 if ($obj->opp_status) {
185 $totaloppnb += $obj->nb;
187 if (!in_array($obj->code, array(
'WON',
'LOST'))) {
188 $totalamount += $obj->opp_amount;
189 $ponderated_opp_amount += $obj->ponderated_opp_amount;
195 $ponderated_opp_amount = $ponderated_opp_amount / 100;
198 $stringtoprint .=
'<div class="div-table-responsive-no-min ">';
199 $listofstatus = array_keys($listofoppstatus);
200 $liststatus = array();
202 $customlabels = array();
204 foreach ($listofstatus as $status) {
210 $labelStatus = $langs->transnoentitiesnoconv(
"OppStatus".$code);
212 if (empty($labelStatus)) {
213 $labelStatus = $listofopplabel[$status];
215 $amount = (isset($valsamount[$status]) ? (
float) $valsamount[$status] : 0);
217 $customlabel = $amount;
218 $liststatus[] = $labelStatus;
219 if (!$conf->use_javascript_ajax) {
220 $stringtoprint .=
'<tr class="oddeven">';
221 $stringtoprint .=
'<td>'.$labelStatus.
'</td>';
222 $stringtoprint .=
'<td class="nowraponall right amount"><a href="list.php?statut='.$status.
'">'.
price((isset($valsamount[$status]) ? (
float) $valsamount[$status] : 0), 0,
'', 1, -1, -1, $conf->currency).
'</a></td>';
223 $stringtoprint .=
"</tr>\n";
226 $customlabels[] = $customlabel;
228 $dataseries[] = $data;
229 if ($conf->use_javascript_ajax) {
230 include_once DOL_DOCUMENT_ROOT.
'/core/class/dolgraph.class.php';
232 $dolgraph->SetMinValue(0);
233 $dolgraph->SetData($dataseries);
234 $dolgraph->SetLegend($liststatus);
235 $dolgraph->setHideXValues(
true);
236 $dolgraph->SetDataColor(array_values($colorseriesstat));
237 $dolgraph->setBorderColor(array_values($bordercolorseries));
238 $dolgraph->setShowLegend(2);
239 if (!empty($conf->dol_optimize_smallscreen)) {
240 $dolgraph->SetWidth(320);
242 $dolgraph->setShowPercent(1);
243 $dolgraph->setMirrorGraphValues(
true);
244 $dolgraph->setBorderWidth(2);
245 $dolgraph->SetType(array(
'horizontalbars'));
246 $dolgraph->SetHeight(
'200');
247 $dolgraph->SetWidth(
'600');
248 $dolgraph->setTooltipsTitles($liststatus);
249 $dolgraph->setTooltipsLabels($customlabels);
250 $dolgraph->mode =
'depth';
251 $dolgraph->draw(
'idgraphleadfunnel');
252 $stringtoprint .= $dolgraph->show($totaloppnb ? 0 : 1);
254 $stringtoprint .=
'</div>';
257 $this->info_box_contents[$line][] = array(
258 'tr' =>
'class="nohover left "',
261 $this->info_box_contents[$line][] = array(
262 'tr' =>
'class="nohover left "',
266 $this->info_box_contents[$line][] = array(
268 'td' =>
'class="center nopaddingleftimp nopaddingrightimp" colspan="2"',
269 'text' => $stringtoprint
272 $this->info_box_contents[$line][] = array(
273 'tr' =>
'class="oddeven"',
274 'td' =>
'class="left "',
276 'text' => $langs->trans(
"OpportunityTotalAmount").
' ('.$langs->trans(
"WonLostExcluded").
')'
278 $this->info_box_contents[$line][] = array(
279 'tr' =>
'class="oddeven"',
280 'td' =>
'class="nowraponall right amount"',
282 'text' =>
price($totalamount, 0,
'', 1, -1, -1, $conf->currency)
285 $this->info_box_contents[$line][] = array(
286 'tr' =>
'class="oddeven"',
287 'td' =>
'class="left "',
289 'text' =>
$form->textwithpicto($langs->trans(
"OpportunityPonderatedAmount").
' ('.$langs->trans(
"WonLostExcluded").
')', $langs->trans(
"OpportunityPonderatedAmountDesc"), 1)
292 $this->info_box_contents[$line][] = array(
293 'td' =>
'class="nowraponall right amount"',
295 'text' =>
price(
price2num($ponderated_opp_amount,
'MT'), 0,
'', 1, -1, -1, $conf->currency)
298 $this->info_box_contents[0][0] = array(
299 'td' =>
'class="center opacitymedium"',
300 'text' => $langs->trans(
"NoRecordedCustomers")
304 $this->info_box_contents[0][0] = array(
306 'text' => $langs->trans(
"ReadPermissionNotAllowed")
319 public function showBox($head =
null, $contents =
null, $nooutput = 0)
321 return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput);
Class to manage the box to show last projet.
showBox($head=null, $contents=null, $nooutput=0)
Method to show box.
__construct($db, $param='')
Constructor.
loadBox($max=5)
Load data for box to show them later.
if(isModEnabled('facture') &&!empty($user->rights->facture->lire)) if((isModEnabled('fournisseur') &&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->hasRight("fournisseur", "facture", "lire"))||(isModEnabled('supplier_invoice') && $user->hasRight("supplier_invoice", "lire"))) if(isModEnabled('don') &&!empty($user->rights->don->lire)) if(isModEnabled('tax') &&!empty($user->rights->tax->charges->lire)) if(isModEnabled('facture') &&isModEnabled('commande') && $user->hasRight("commande", "lire") &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) $resql
Social contributions to pay.
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
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_getIdFromCode($db, $key, $tablename, $fieldkey='code', $fieldid='id', $entityfilter=0, $filters='')
Return an id or code from a code or id.
div float
Buy price without taxes.
$conf db
API class for accounts.