/**
     *  Load data into info_box_contents array to show array later.
     *
     *  @param	int		$max        Maximum number of records to load
     *  @return	void
     */
    function loadBox($max = 5)
    {
        global $conf, $user, $langs, $db;
        $this->max = $max;
        $refreshaction = 'refresh_' . $this->boxcode;
        include_once DOL_DOCUMENT_ROOT . '/fourn/class/fournisseur.facture.class.php';
        $text = $langs->trans("BoxSuppliersInvoicesPerMonth", $max);
        $this->info_box_head = array('text' => $text, 'limit' => dol_strlen($text), 'graph' => 1, 'sublink' => '', 'subtext' => $langs->trans("Filter"), 'subpicto' => 'filter.png', 'subclass' => 'linkobject', 'target' => 'none');
        $dir = '';
        // We don't need a path because image file will not be saved into disk
        $prefix = '';
        $socid = 0;
        if ($user->societe_id) {
            $socid = $user->societe_id;
        }
        if (!$user->rights->societe->client->voir || $socid) {
            $prefix .= 'private-' . $user->id . '-';
        }
        // If user has no permission to see all, output dir is specific to user
        if ($user->rights->fournisseur->facture->lire) {
            $param_year = 'DOLUSERCOOKIE_box_' . $this->boxcode . '_year';
            $param_shownb = 'DOLUSERCOOKIE_box_' . $this->boxcode . '_shownb';
            $param_showtot = 'DOLUSERCOOKIE_box_' . $this->boxcode . '_showtot';
            include_once DOL_DOCUMENT_ROOT . '/core/class/dolgraph.class.php';
            include_once DOL_DOCUMENT_ROOT . '/compta/facture/class/facturestats.class.php';
            $autosetarray = preg_split("/[,;:]+/", GETPOST('DOL_AUTOSET_COOKIE'));
            if (in_array('DOLUSERCOOKIE_box_' . $this->boxcode, $autosetarray)) {
                $endyear = GETPOST($param_year, 'int');
                $shownb = GETPOST($param_shownb, 'alpha');
                $showtot = GETPOST($param_showtot, 'alpha');
            } else {
                $tmparray = json_decode($_COOKIE['DOLUSERCOOKIE_box_' . $this->boxcode], true);
                $endyear = $tmparray['year'];
                $shownb = $tmparray['shownb'];
                $showtot = $tmparray['showtot'];
            }
            if (empty($shownb) && empty($showtot)) {
                $showtot = 1;
            }
            $nowarray = dol_getdate(dol_now(), true);
            if (empty($endyear)) {
                $endyear = $nowarray['year'];
            }
            $startyear = $endyear - 1;
            $mode = 'supplier';
            $WIDTH = $shownb && $showtot || !empty($conf->dol_optimize_smallscreen) ? '256' : '320';
            $HEIGHT = '192';
            $stats = new FactureStats($this->db, $socid, $mode, 0);
            // Build graphic number of object. $data = array(array('Lib',val1,val2,val3),...)
            if ($shownb) {
                $data1 = $stats->getNbByMonthWithPrevYear($endyear, $startyear, GETPOST('action') == $refreshaction ? -1 : 3600 * 24);
                $filenamenb = $dir . "/" . $prefix . "invoicessuppliernbinyear-" . $year . ".png";
                if ($mode == 'customer') {
                    $fileurlnb = DOL_URL_ROOT . '/viewimage.php?modulepart=billstats&file=invoicesnbinyear-' . $year . '.png';
                }
                if ($mode == 'supplier') {
                    $fileurlnb = DOL_URL_ROOT . '/viewimage.php?modulepart=billstatssupplier&file=invoicessuppliernbinyear-' . $year . '.png';
                }
                $px1 = new DolGraph();
                $mesg = $px1->isGraphKo();
                if (!$mesg) {
                    $px1->SetData($data1);
                    unset($data1);
                    $px1->SetPrecisionY(0);
                    $i = $startyear;
                    $legend = array();
                    while ($i <= $endyear) {
                        $legend[] = $i;
                        $i++;
                    }
                    $px1->SetLegend($legend);
                    $px1->SetMaxValue($px1->GetCeilMaxValue());
                    $px1->SetWidth($WIDTH);
                    $px1->SetHeight($HEIGHT);
                    $px1->SetYLabel($langs->trans("NumberOfBills"));
                    $px1->SetShading(3);
                    $px1->SetHorizTickIncrement(1);
                    $px1->SetPrecisionY(0);
                    $px1->SetCssPrefix("cssboxes");
                    $px1->mode = 'depth';
                    $px1->SetTitle($langs->trans("NumberOfBillsByMonth"));
                    $px1->draw($filenamenb, $fileurlnb);
                }
            }
            // Build graphic number of object. $data = array(array('Lib',val1,val2,val3),...)
            if ($showtot) {
                $data2 = $stats->getAmountByMonthWithPrevYear($endyear, $startyear, GETPOST('action') == $refreshaction ? -1 : 3600 * 24);
                $filenamenb = $dir . "/" . $prefix . "invoicessupplieramountinyear-" . $year . ".png";
                if ($mode == 'customer') {
                    $fileurlnb = DOL_URL_ROOT . '/viewimage.php?modulepart=billstats&amp;file=invoicesamountinyear-' . $year . '.png';
                }
                if ($mode == 'supplier') {
                    $fileurlnb = DOL_URL_ROOT . '/viewimage.php?modulepart=billstatssupplier&amp;file=invoicessupplieramountinyear-' . $year . '.png';
                }
                $px2 = new DolGraph();
                $mesg = $px2->isGraphKo();
                if (!$mesg) {
                    $px2->SetData($data2);
                    unset($data2);
                    $px2->SetPrecisionY(0);
                    $i = $startyear;
                    $legend = array();
                    while ($i <= $endyear) {
                        $legend[] = $i;
                        $i++;
                    }
                    $px2->SetLegend($legend);
                    $px2->SetMaxValue($px2->GetCeilMaxValue());
                    $px2->SetWidth($WIDTH);
                    $px2->SetHeight($HEIGHT);
                    $px2->SetYLabel($langs->trans("AmountOfBillsHT"));
                    $px2->SetShading(3);
                    $px2->SetHorizTickIncrement(1);
                    $px2->SetPrecisionY(0);
                    $px2->SetCssPrefix("cssboxes");
                    $px2->mode = 'depth';
                    $px2->SetTitle($langs->trans("AmountOfBillsByMonthHT"));
                    $px2->draw($filenamenb, $fileurlnb);
                }
            }
            if (empty($conf->use_javascript_ajax)) {
                $langs->load("errors");
                $mesg = $langs->trans("WarningFeatureDisabledWithDisplayOptimizedForBlindNoJs");
            }
            if (!$mesg) {
                $stringtoshow = '';
                $stringtoshow .= '<script type="text/javascript" language="javascript">
					jQuery(document).ready(function() {
						jQuery("#idsubimg' . $this->boxcode . '").click(function() {
							jQuery("#idfilter' . $this->boxcode . '").toggle();
						});
					});
					</script>';
                $stringtoshow .= '<div class="center hideobject" id="idfilter' . $this->boxcode . '">';
                // hideobject is to start hidden
                $stringtoshow .= '<form class="flat formboxfilter" method="POST" action="' . $_SERVER["PHP_SELF"] . '">';
                $stringtoshow .= '<input type="hidden" name="action" value="' . $refreshaction . '">';
                $stringtoshow .= '<input type="hidden" name="DOL_AUTOSET_COOKIE" value="DOLUSERCOOKIE_box_' . $this->boxcode . ':year,shownb,showtot">';
                $stringtoshow .= '<input type="checkbox" name="' . $param_shownb . '"' . ($shownb ? ' checked' : '') . '> ' . $langs->trans("NumberOfBillsByMonth");
                $stringtoshow .= ' &nbsp; ';
                $stringtoshow .= '<input type="checkbox" name="' . $param_showtot . '"' . ($showtot ? ' checked' : '') . '> ' . $langs->trans("AmountOfBillsByMonthHT");
                $stringtoshow .= '<br>';
                $stringtoshow .= $langs->trans("Year") . ' <input class="flat" size="4" type="text" name="' . $param_year . '" value="' . $endyear . '">';
                $stringtoshow .= '<input type="image" alt="' . $langs->trans("Refresh") . '" src="' . img_picto($langs->trans("Refresh"), 'refresh.png', '', '', 1) . '">';
                $stringtoshow .= '</form>';
                $stringtoshow .= '</div>';
                if ($shownb && $showtot) {
                    $stringtoshow .= '<div class="fichecenter">';
                    $stringtoshow .= '<div class="fichehalfleft">';
                }
                if ($shownb) {
                    $stringtoshow .= $px1->show();
                }
                if ($shownb && $showtot) {
                    $stringtoshow .= '</div>';
                    $stringtoshow .= '<div class="fichehalfright">';
                }
                if ($showtot) {
                    $stringtoshow .= $px2->show();
                }
                if ($shownb && $showtot) {
                    $stringtoshow .= '</div>';
                    $stringtoshow .= '</div>';
                }
                $this->info_box_contents[0][0] = array('td' => 'align="center" class="nohover"', 'textnoformat' => $stringtoshow);
            } else {
                $this->info_box_contents[0][0] = array('td' => 'align="left" class="nohover"', 'maxlength' => 500, 'text' => $mesg);
            }
        } else {
            $this->info_box_contents[0][0] = array('td' => 'align="left"', 'text' => $langs->trans("ReadPermissionNotAllowed"));
        }
    }
Exemple #2
0
llxHeader();
$WIDTH = 500;
$HEIGHT = 200;
$mesg = '';
print_fiche_titre($langs->trans("StatisticsOfSendings") . ' ' . $_GET["year"], $mesg);
$stats = new ExpeditionStats($db);
$data = $stats->getNbExpeditionByMonth($_GET["year"]);
dol_mkdir($conf->expedition->dir_temp);
$filename = $conf->expedition->dir_temp . "/expedition" . $year . ".png";
$fileurl = DOL_URL_ROOT . '/viewimage.php?modulepart=expeditionstats&file=expedition' . $year . '.png';
$px = new DolGraph();
$mesg = $px->isGraphKo();
if (!$mesg) {
    $px->SetData($data);
    $px->SetMaxValue($px->GetCeilMaxValue());
    $px->SetWidth($WIDTH);
    $px->SetHeight($HEIGHT);
    $px->SetYLabel($langs->trans("NbOfOrders"));
    $px->SetShading(3);
    $px->SetHorizTickIncrement(1);
    $px->SetPrecisionY(0);
    $px->draw($filename, $fileurl);
}
print '<table class="border" width="100%">';
print '<tr><td align="center">Nombre d expedition par mois</td>';
print '<td align="center">';
print $px->show();
print '</td></tr>';
print '</table>';
llxFooter();
$db->close();
Exemple #3
0
    if ($mode == 'supplier') {
        $fileurl_avg = DOL_URL_ROOT . '/viewimage.php?modulepart=orderstatssupplier&file=ordersaverage-' . $year . '.png';
    }
}
$px3 = new DolGraph();
$mesg = $px3->isGraphKo();
if (!$mesg) {
    $px3->SetData($data);
    $i = $startyear;
    $legend = array();
    while ($i <= $endyear) {
        $legend[] = $i;
        $i++;
    }
    $px3->SetLegend($legend);
    $px3->SetYLabel($langs->trans("AmountAverage"));
    $px3->SetMaxValue($px3->GetCeilMaxValue());
    $px3->SetMinValue($px3->GetFloorMinValue());
    $px3->SetWidth($WIDTH);
    $px3->SetHeight($HEIGHT);
    $px3->SetShading(3);
    $px3->SetHorizTickIncrement(1);
    $px3->SetPrecisionY(0);
    $px3->mode = 'depth';
    $px3->SetTitle($langs->trans("AmountAverage"));
    $px3->draw($filename_avg, $fileurl_avg);
}
// Show array
$data = $stats->getAllByYear();
$arrayyears = array();
foreach ($data as $val) {
Exemple #4
0
             $graph_data = $object->get_nb_order($socid, $mode, (string) $type != '' ? $type : -1);
         }
         if ($key == 'invoices') {
             $graph_data = $object->get_nb_vente($socid, $mode, (string) $type != '' ? $type : -1);
         }
         if ($key == 'invoicessuppliers') {
             $graph_data = $object->get_nb_achat($socid, $mode, (string) $type != '' ? $type : -1);
         }
         if ($key == 'orderssuppliers') {
             $graph_data = $object->get_nb_ordersupplier($socid, $mode, (string) $type != '' ? $type : -1);
         }
         // TODO Save cachefile $graphfiles[$key]['file']
     }
     if (is_array($graph_data)) {
         $px->SetData($graph_data);
         $px->SetYLabel($graphfiles[$key]['label']);
         $px->SetMaxValue($px->GetCeilMaxValue() < 0 ? 0 : $px->GetCeilMaxValue());
         $px->SetMinValue($px->GetFloorMinValue() > 0 ? 0 : $px->GetFloorMinValue());
         $px->SetWidth($WIDTH);
         $px->SetHeight($HEIGHT);
         $px->SetHorizTickIncrement(1);
         $px->SetPrecisionY(0);
         $px->SetShading(3);
         //print 'x '.$key.' '.$graphfiles[$key]['file'];
         $url = DOL_URL_ROOT . '/viewimage.php?modulepart=' . $graphfiles[$key]['modulepart'] . '&entity=' . $object->entity . '&file=' . urlencode($graphfiles[$key]['file']);
         $px->draw($dir . "/" . $graphfiles[$key]['file'], $url);
         $graphfiles[$key]['output'] = $px->show();
     } else {
         dol_print_error($db, 'Error for calculating graph on key=' . $key . ' - ' . $object->error);
     }
 }
Exemple #5
0
$mesg = $px1->isGraphKo();
if (!$mesg) {
    $px1->SetData($data);
    $px1->SetPrecisionY(0);
    $i = $startyear;
    $legend = array();
    while ($i <= $endyear) {
        $legend[] = $i;
        $i++;
    }
    $px1->SetLegend($legend);
    $px1->SetMaxValue($px1->GetCeilMaxValue());
    $px1->SetMinValue(min(0, $px1->GetFloorMinValue()));
    $px1->SetWidth($WIDTH);
    $px1->SetHeight($HEIGHT);
    $px1->SetYLabel($langs->trans("NbOfSendings"));
    $px1->SetShading(3);
    $px1->SetHorizTickIncrement(1);
    $px1->SetPrecisionY(0);
    $px1->mode = 'depth';
    $px1->SetTitle($langs->trans("NumberOfShipmentsByMonth"));
    $px1->draw($filenamenb, $fileurlnb);
}
// Build graphic amount of object
/*
$data = $stats->getAmountByMonthWithPrevYear($endyear,$startyear);
//var_dump($data);
// $data = array(array('Lib',val1,val2,val3),...)

if (!$user->rights->societe->client->voir || $user->societe_id)
{
Exemple #6
0
    $px3 = new DolGraph();
    $mesg = $px3->isGraphKo();
    if (!$mesg) {
        $px3->SetData($data);
        $i = $startyear;
        $legend = array();
        while ($i <= $endyear) {
            $legend[] = $i;
            $i++;
        }
        $px3->SetLegend($legend);
        $px3->SetMaxValue($px3->GetCeilMaxValue());
        $px3->SetMinValue(min(0, $px3->GetFloorMinValue()));
        $px3->SetWidth($WIDTH);
        $px3->SetHeight($HEIGHT);
        $px3->SetYLabel($langs->trans("ProjectWeightedOppAmountOfProjectsByMonth"));
        $px3->SetShading(3);
        $px3->SetHorizTickIncrement(1);
        $px3->SetPrecisionY(0);
        $px3->mode = 'depth';
        $px3->SetTitle($langs->trans("ProjectWeightedOppAmountOfProjectsByMonth"));
        $px3->draw($filenamenb, $fileurlnb);
    }
}
// Show array
$stats_project->year = 0;
$data_all_year = $stats_project->getAllByYear();
if (!empty($year)) {
    $stats_project->year = $year;
}
$arrayyears = array();
Exemple #7
0
$px3 = new DolGraph();
$mesg = $px3->isGraphKo();
if (!$mesg) {
    $px3->SetData($data);
    $i = $startyear;
    $legend = array();
    while ($i <= $endyear) {
        $legend[] = $i;
        $i++;
    }
    $px3->SetLegend($legend);
    $px3->SetMaxValue($px3->GetCeilMaxValue());
    $px3->SetMinValue(min(0, $px3->GetFloorMinValue()));
    $px3->SetWidth($WIDTH);
    $px3->SetHeight($HEIGHT);
    $px3->SetYLabel($langs->trans("LeadTransRateOfLead"));
    $px3->SetShading(3);
    $px3->SetHorizTickIncrement(1);
    $px3->SetPrecisionY(0);
    $px3->mode = 'depth';
    $px3->SetTitle($langs->trans("LeadTransRateOfLeadsByMonth"));
    $px3->draw($filenamenb, $fileurlnb);
}
$stringtoshow .= '<table class="border" width="100%"><tr valign="top"><td align="center">';
if ($mesg) {
    print $mesg;
} else {
    $stringtoshow .= $px1->show();
    $stringtoshow .= "<br>\n";
    $stringtoshow .= $px2->show();
    $stringtoshow .= "<br>\n";
Exemple #8
0
if (! $mesg)
{
    $px->SetData($data);
    $px->SetPrecisionY(0);
    $i=$startyear;
    while ($i <= $endyear)
    {
        $legend[]=$i;
        $i++;
    }
    $px->SetLegend($legend);
    $px->SetMaxValue($px->GetCeilMaxValue());
    $px->SetMinValue(min(0,$px->GetFloorMinValue()));
    $px->SetWidth($WIDTH);
    $px->SetHeight($HEIGHT);
    $px->SetYLabel($langs->trans("AmountOfProposals"));
    $px->SetShading(3);
    $px->SetHorizTickIncrement(1);
    $px->SetPrecisionY(0);
    $px->mode='depth';
    $px->SetTitle($langs->trans("AmountOfProposalsByMonthHT"));

    $px->draw($filenameamount);
}

print '<table class="notopnoleftnopadd" width="100%"><tr>';
print '<td align="center" valign="top">';

// Show filter box
print '<form name="stats" method="POST" action="'.$_SERVER["PHP_SELF"].'">';
print '<table class="border" width="100%">';
$px2 = new DolGraph();
$mesg = $px2->isGraphKo();
if (!$mesg) {
    $px2->SetData($data);
    $px2->SetPrecisionY(0);
    $i = $startyear;
    while ($i <= $endyear) {
        $legend[] = $i;
        $i++;
    }
    $px2->SetLegend($legend);
    $px2->SetMaxValue($px2->GetCeilMaxValue());
    $px2->SetMinValue(min(0, $px2->GetFloorMinValue()));
    $px2->SetWidth($WIDTH);
    $px2->SetHeight($HEIGHT);
    $px2->SetYLabel($langs->trans("AmountOfSubscriptions"));
    $px2->SetShading(3);
    $px2->SetHorizTickIncrement(1);
    $px2->SetPrecisionY(0);
    $px2->mode = 'depth';
    $px2->SetTitle($langs->trans("AmountOfSubscriptions"));
    $px2->draw($filenameamount, $fileurlamount);
}
$head = member_stats_prepare_head($adh);
dol_fiche_head($head, 'statssubscription', $langs->trans("Statistics"), 0, 'user');
print '<div class="fichecenter"><div class="fichethirdleft">';
// Show filter box
/*print '<form name="stats" method="POST" action="'.$_SERVER["PHP_SELF"].'">';
print '<table class="border" width="100%">';
print '<tr class="liste_titre"><td class="liste_titre" colspan="2">'.$langs->trans("Filter").'</td></tr>';
print '<tr><td>'.$langs->trans("Member").'</td><td>';
Exemple #10
0
$mesg = $px->isGraphKo();
if (! $mesg)
{
	$px->SetData($data);
	$i=$startyear;
	while ($i <= $endyear)
	{
		$legend[]=$i;
		$i++;
	}
	$px->SetLegend($legend);
	$px->SetMaxValue($px->GetCeilMaxValue());
	$px->SetMinValue(min(0,$px->GetFloorMinValue()));
	$px->SetWidth($WIDTH);
	$px->SetHeight($HEIGHT);
	$px->SetYLabel($langs->trans("AmountOfBills"));
	$px->SetShading(3);
	$px->SetHorizTickIncrement(1);
	$px->SetPrecisionY(0);
	$px->mode='depth';
	$px->SetTitle($langs->trans("AmountOfBillsByMonthHT"));

	$px->draw($filenameamount);
}



print '<table class="notopnoleftnopadd" width="100%"><tr>';
print '<td align="center" valign="top">';

// Show filter box
Exemple #11
0
$mesg = $px->isGraphKo();
if (! $mesg)
{
    $px->SetData($data);
    $i=$startyear;
    while ($i <= $endyear)
    {
        $legend[]=$i;
        $i++;
    }
    $px->SetLegend($legend);
    $px->SetMaxValue($px->GetCeilMaxValue());
    $px->SetMinValue(min(0,$px->GetFloorMinValue()));
    $px->SetWidth($WIDTH);
    $px->SetHeight($HEIGHT);
    $px->SetYLabel($langs->trans("AmountOfOrders"));
    $px->SetShading(3);
    $px->SetHorizTickIncrement(1);
    $px->SetPrecisionY(0);
    $px->mode='depth';
    $px->SetTitle($langs->trans("AmountOfOrdersByMonthHT"));

    $px->draw($filenameamount);
}

print '<table class="notopnoleftnopadd" width="100%"><tr>';
print '<td align="center" valign="top">';

// Show filter box
print '<form name="stats" method="POST" action="'.$_SERVER["PHP_SELF"].'">';
print '<table class="border" width="100%">';
Exemple #12
0
$mesg = $px->isGraphKo();
if (! $mesg)
{
	$px->SetData($data);
	$i=$startyear;
	while ($i <= $endyear)
	{
		$legend[]=$i;
		$i++;
	}
	$px->SetLegend($legend);
	$px->SetMaxValue($px->GetCeilMaxValue());
	$px->SetMinValue(min(0,$px->GetFloorMinValue()));
	$px->SetWidth($WIDTH);
	$px->SetHeight($HEIGHT);
	$px->SetYLabel($langs->trans("Amount"));
	$px->SetShading(3);
	$px->SetHorizTickIncrement(1);
	$px->SetPrecisionY(0);
	$px->mode='depth';
	$px->SetTitle($langs->trans("AmountTotal"));

	$px->draw($filenameamount);
}



print '<table class="notopnoleftnopadd" width="100%"><tr>';
print '<td align="center" valign="top">';

// Show filter box