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");
46 public $info_box_head = array();
47 public $info_box_contents = array();
57 global $user, $langs, $conf;
60 $langs->loadLangs(array(
'boxes',
'projects'));
64 $this->enabled = ($conf->global->MAIN_FEATURES_LEVEL >= 1 ? 1 : 0);
66 $this->hidden = empty($user->rights->projet->lire);
80 $badgeStatus0 =
'#cbd3d3';
81 $badgeStatus1 =
'#bc9526';
82 $badgeStatus1b =
'#bc9526';
83 $badgeStatus2 =
'#9c9c26';
84 $badgeStatus3 =
'#bca52b';
85 $badgeStatus4 =
'#25a580';
86 $badgeStatus4b =
'#25a580';
87 $badgeStatus5 =
'#cad2d2';
88 $badgeStatus6 =
'#cad2d2';
89 $badgeStatus7 =
'#baa32b';
90 $badgeStatus8 =
'#993013';
91 $badgeStatus9 =
'#e7f0f0';
92 if (file_exists(DOL_DOCUMENT_ROOT .
'/theme/' . $conf->theme .
'/theme_vars.inc.php')) {
93 include DOL_DOCUMENT_ROOT .
'/theme/' . $conf->theme .
'/theme_vars.inc.php';
95 $listofoppstatus = array();
96 $listofopplabel = array();
97 $listofoppcode = array();
98 $colorseriesstat = array();
99 $sql =
"SELECT cls.rowid, cls.code, cls.percent, cls.label";
100 $sql .=
" FROM " . MAIN_DB_PREFIX .
"c_lead_status as cls";
101 $sql .=
" WHERE active=1";
102 $sql .=
" AND cls.code <> 'LOST'";
103 $sql .= $this->
db->order(
'cls.rowid',
'ASC');
110 $objp = $this->
db->fetch_object(
$resql);
111 $listofoppstatus[$objp->rowid] = $objp->percent;
112 $listofopplabel[$objp->rowid] = $objp->label;
113 $listofoppcode[$objp->rowid] = $objp->code;
114 switch ($objp->code) {
116 $colorseriesstat[$objp->rowid] =
"-" . $badgeStatus0;
119 $colorseriesstat[$objp->rowid] =
"-" . $badgeStatus1;
122 $colorseriesstat[$objp->rowid] = $badgeStatus1;
125 $colorseriesstat[$objp->rowid] = $badgeStatus4;
128 $colorseriesstat[$objp->rowid] = $badgeStatus6;
139 global $conf, $user, $langs;
142 $this->info_box_head = array(
143 'text' => $langs->trans(
"Statistics") .
' - ' . $langs->trans(
"BoxTitleFunnelOfProspection"),
147 if ($user->rights->projet->lire || !empty($conf->global->PROJECT_USE_OPPORTUNITIES)) {
148 $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";
149 $sql .=
" FROM " . MAIN_DB_PREFIX .
"projet as p, " . MAIN_DB_PREFIX .
"c_lead_status as cls";
150 $sql .=
" WHERE p.entity IN (" .
getEntity(
'project') .
")";
151 $sql .=
" AND p.fk_opp_status = cls.rowid";
152 $sql .=
" AND p.fk_statut = 1";
153 $sql .=
" AND cls.code NOT IN ('LOST')";
154 $sql .=
" GROUP BY p.fk_opp_status, cls.code";
157 $form =
new Form($this->
db);
165 $ponderated_opp_amount = 0;
167 $valsamount = array();
168 $dataseries = array();
171 $obj = $this->
db->fetch_object(
$resql);
173 $valsnb[$obj->opp_status] = $obj->nb;
174 $valsamount[$obj->opp_status] = $obj->opp_amount;
175 $totalnb += $obj->nb;
176 if ($obj->opp_status) {
177 $totaloppnb += $obj->nb;
179 if (!in_array($obj->code, array(
'WON',
'LOST'))) {
180 $totalamount += $obj->opp_amount;
181 $ponderated_opp_amount += $obj->ponderated_opp_amount;
187 $ponderated_opp_amount = $ponderated_opp_amount / 100;
190 $stringtoprint .=
'<div class="div-table-responsive-no-min ">';
191 $listofstatus = array_keys($listofoppstatus);
192 $liststatus = array();
194 foreach ($listofstatus as $status) {
199 $labelStatus = $langs->transnoentitiesnoconv(
"OppStatus" . $code);
201 if (empty($labelStatus)) {
202 $labelStatus = $listofopplabel[$status];
205 $data[] = (isset($valsamount[$status]) ? (
float) $valsamount[$status] : 0);
206 $liststatus[] = $labelStatus;
207 if (!$conf->use_javascript_ajax) {
208 $stringtoprint .=
'<tr class="oddeven">';
209 $stringtoprint .=
'<td>' . $labelStatus .
'</td>';
210 $stringtoprint .=
'<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>';
211 $stringtoprint .=
"</tr>\n";
215 $dataseries[] = $data;
216 if ($conf->use_javascript_ajax) {
217 include_once DOL_DOCUMENT_ROOT .
'/core/class/dolgraph.class.php';
219 $dolgraph->SetMinValue(0);
220 $dolgraph->SetData($dataseries);
221 $dolgraph->SetLegend($liststatus);
222 $dolgraph->SetDataColor(array_values($colorseriesstat));
223 $dolgraph->setShowLegend(2);
224 $dolgraph->setShowPercent(1);
225 $dolgraph->setTitle(
'');
226 $dolgraph->SetType(array(
'horizontalbars'));
227 $dolgraph->SetHeight(
'200');
228 $dolgraph->SetWidth(
'600');
229 $dolgraph->mode =
'depth';
230 $dolgraph->draw(
'idgraphleadfunnel');
231 $stringtoprint .= $dolgraph->show($totaloppnb ? 0 : 1);
233 $stringtoprint .=
'</div>';
236 $this->info_box_contents[$line][] = array(
237 'tr' =>
'class="nohover left "',
240 $this->info_box_contents[$line][] = array(
241 'tr' =>
'class="nohover left "',
245 $this->info_box_contents[$line][] = array(
247 'td' =>
'class="center nopaddingleftimp nopaddingrightimp" colspan="2"',
248 'text' => $stringtoprint
251 $this->info_box_contents[$line][] = array(
252 'tr' =>
'class="oddeven"',
253 'td' =>
'class="left "',
255 'text' => $langs->trans(
"OpportunityTotalAmount") .
' (' . $langs->trans(
"WonLostExcluded") .
')'
257 $this->info_box_contents[$line][] = array(
258 'tr' =>
'class="oddeven"',
259 'td' =>
'class="right "',
261 'text' =>
price($totalamount, 0,
'', 1, -1, -1, $conf->currency)
264 $this->info_box_contents[$line][] = array(
265 'tr' =>
'class="oddeven"',
266 'td' =>
'class="left "',
268 'text' => $form->textwithpicto($langs->trans(
"OpportunityPonderatedAmount") .
' (' . $langs->trans(
"WonLostExcluded") .
')', $langs->trans(
"OpportunityPonderatedAmountDesc"), 1)
271 $this->info_box_contents[$line][] = array(
272 'td' =>
'class="right "',
274 'text' =>
price(
price2num($ponderated_opp_amount,
'MT'), 0,
'', 1, -1, -1, $conf->currency)
277 $this->info_box_contents[0][0] = array(
278 'td' =>
'class="center opacitymedium"',
279 'text' => $langs->trans(
"NoRecordedCustomers")
283 $this->info_box_contents[0][0] = array(
285 'text' => $langs->trans(
"ReadPermissionNotAllowed")
298 public function showBox($head = null, $contents = null, $nooutput = 0)
300 return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput);
showBox($head=null, $contents=null, $nooutput=0)
Method to show box.
loadBox($max=5)
Load data for box to show them later.
$conf db
API class for accounts.
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...
getEntity($element, $shared=1, $currentobject=null)
Get list of entity id to use.
price2num($amount, $rounding= '', $option=0)
Function that return a number with universal decimal format (decimal separator is '...
__construct($db, $param= '')
Constructor.
dol_getIdFromCode($db, $key, $tablename, $fieldkey= 'code', $fieldid= 'id', $entityfilter=0)
Return an id or code from a code or id.
div float
Buy price without taxes.
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...
Class to manage the box to show last projet.