mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2025-02-20 13:46:52 +01:00
New: Add graph for supplier invoices.
Fix: Error management into supplier invoice validation.
This commit is contained in:
parent
efd855b186
commit
f564d1912e
|
|
@ -24,7 +24,7 @@ For users:
|
|||
- New: [ task #928 ] Add extrafield feature on invoice lines.
|
||||
- New: Add option ADHERENT_LOGIN_NOT_REQUIRED.
|
||||
- New: Add a cron module to define scheduled jobs.
|
||||
- New: Add new graphical boxes (customer invoices and orders per month).
|
||||
- New: Add new graphical boxes (customer and supplier invoices and orders per month).
|
||||
- New: [ task #286 ] Enhance rounding function of prices to allow round of sum instead of sum of rounding.
|
||||
- New: Can add an event automatically when a projet is create.
|
||||
- New: Add option MAIN_GENERATE_DOCUMENT_WITH_PICTURE.
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ class FactureStats extends Stats
|
|||
var $from;
|
||||
var $field;
|
||||
var $where;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
|
|
@ -57,7 +57,8 @@ class FactureStats extends Stats
|
|||
$this->db = $db;
|
||||
$this->socid = ($socid > 0 ? $socid : 0);
|
||||
$this->userid = $userid;
|
||||
|
||||
$this->cachefilesuffix = $mode;
|
||||
|
||||
if ($mode == 'customer')
|
||||
{
|
||||
$object=new Facture($this->db);
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@
|
|||
*/
|
||||
|
||||
/**
|
||||
* \file htdocs/core/boxes/box_invoice_permonth.php
|
||||
* \file htdocs/core/boxes/box_graph_invoices_permonth.php
|
||||
* \ingroup factures
|
||||
* \brief Box to show graph of invoices per month
|
||||
*/
|
||||
|
|
@ -104,7 +104,7 @@ class box_graph_invoices_permonth extends ModeleBoxes
|
|||
|
||||
$filenamenb = $dir."/invoicesnbinyear-".$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=invoicesnbinyear-'.$year.'.png';
|
||||
if ($mode == 'supplier') $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=billstatssupplier&file=invoicessuppliernbinyear-'.$year.'.png';
|
||||
|
||||
$px1 = new DolGraph();
|
||||
$mesg = $px1->isGraphKo();
|
||||
|
|
@ -142,7 +142,7 @@ class box_graph_invoices_permonth extends ModeleBoxes
|
|||
|
||||
$filenamenb = $dir."/invoicesamountinyear-".$year.".png";
|
||||
if ($mode == 'customer') $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=billstats&file=invoicesamountinyear-'.$year.'.png';
|
||||
if ($mode == 'supplier') $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=billstatssupplier&file=invoicesamountinyear-'.$year.'.png';
|
||||
if ($mode == 'supplier') $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=billstatssupplier&file=invoicessupplieramountinyear-'.$year.'.png';
|
||||
|
||||
$px2 = new DolGraph();
|
||||
$mesg = $px2->isGraphKo();
|
||||
|
|
|
|||
225
htdocs/core/boxes/box_graph_invoices_supplier_permonth.php
Normal file
225
htdocs/core/boxes/box_graph_invoices_supplier_permonth.php
Normal file
|
|
@ -0,0 +1,225 @@
|
|||
<?php
|
||||
/* Copyright (C) 2013 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file htdocs/core/boxes/box_graph_invoices_supplier_permonth.php
|
||||
* \ingroup fournisseur
|
||||
* \brief Box to show graph of invoices per month
|
||||
*/
|
||||
include_once DOL_DOCUMENT_ROOT.'/core/boxes/modules_boxes.php';
|
||||
|
||||
|
||||
/**
|
||||
* Class to manage the box to show last invoices
|
||||
*/
|
||||
class box_graph_invoices_supplier_permonth extends ModeleBoxes
|
||||
{
|
||||
var $boxcode="invoicessupplierpermonth";
|
||||
var $boximg="object_bill";
|
||||
var $boxlabel="BoxSuppliersInvoicesPerMonth";
|
||||
var $depends = array("fournisseur");
|
||||
|
||||
var $db;
|
||||
|
||||
var $info_box_head = array();
|
||||
var $info_box_contents = array();
|
||||
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param DoliDB $db Database handler
|
||||
* @param string $param More parameters
|
||||
*/
|
||||
function __construct($db,$param)
|
||||
{
|
||||
global $conf;
|
||||
|
||||
$this->db=$db;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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';
|
||||
$facturestatic=new Facture($db);
|
||||
|
||||
$text = $langs->trans("BoxSuppliersInvoicesPerMonth",$max);
|
||||
$this->info_box_head = array(
|
||||
'text' => $text,
|
||||
'limit'=> dol_strlen($text),
|
||||
'graph'=> 1,
|
||||
'sublink'=>$_SERVER["PHP_SELF"].'?action='.$refreshaction,
|
||||
'subtext'=>$langs->trans("Refresh"),
|
||||
'subpicto'=>'refresh.png',
|
||||
'target'=>'none'
|
||||
);
|
||||
|
||||
if ($user->rights->fournisseur->facture->lire)
|
||||
{
|
||||
include_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php';
|
||||
include_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facturestats.class.php';
|
||||
|
||||
$shownb=(! empty($conf->global->FACTURE_BOX_GRAPH_SHOW_NB));
|
||||
$showtot=(! isset($conf->global->FACTURE_BOX_GRAPH_SHOW_TOT) || ! empty($conf->global->FACTURE_BOX_GRAPH_SHOW_TOT));
|
||||
$nowarray=dol_getdate(dol_now(),true);
|
||||
$endyear=$nowarray['year'];
|
||||
$startyear=$endyear-1;
|
||||
$mode='supplier';
|
||||
$userid=0;
|
||||
$WIDTH='256';
|
||||
$HEIGHT='192';
|
||||
|
||||
$stats = new FactureStats($this->db, 0, $mode, ($userid>0?$userid: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."/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."/invoicessupplieramountinyear-".$year.".png";
|
||||
if ($mode == 'customer') $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=billstats&file=invoicesamountinyear-'.$year.'.png';
|
||||
if ($mode == 'supplier') $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=billstatssupplier&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 (! $mesg)
|
||||
{
|
||||
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"','textnoformat'=>$stringtoshow);
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->info_box_contents[0][0] = array( 'td' => 'align="left"',
|
||||
'maxlength'=>500,
|
||||
'text' => $mesg);
|
||||
}
|
||||
|
||||
}
|
||||
else {
|
||||
$this->info_box_contents[0][0] = array('td' => 'align="left"',
|
||||
'text' => $langs->trans("ReadPermissionNotAllowed"));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to show box
|
||||
*
|
||||
* @param array $head Array with properties of box title
|
||||
* @param array $contents Array with properties of box lines
|
||||
* @return void
|
||||
*/
|
||||
function showBox($head = null, $contents = null)
|
||||
{
|
||||
parent::showBox($this->info_box_head, $this->info_box_contents);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
@ -16,7 +16,7 @@
|
|||
*/
|
||||
|
||||
/**
|
||||
* \file htdocs/core/boxes/box_order_permonth.php
|
||||
* \file htdocs/core/boxes/box_graph_orders_permonth.php
|
||||
* \ingroup commandes
|
||||
* \brief Box to show graph of orders per month
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
/* Copyright (C) 2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||
* Copyright (c) 2008-2012 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (c) 2008-2013 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2012 Regis Houssin <regis.houssin@capnetworks.com>
|
||||
* Copyright (C) 2012 Marcos García <marcosgdf@gmail.com>
|
||||
*
|
||||
|
|
@ -31,7 +31,7 @@ abstract class Stats
|
|||
{
|
||||
protected $db;
|
||||
var $_lastfetchdate=array(); // Dates of cache file read by methods
|
||||
|
||||
var $cachefilesuffix=''; // Suffix to add to name of cache file (to avoid file name conflicts)
|
||||
|
||||
/**
|
||||
* Return nb of elements by month for several years
|
||||
|
|
@ -56,7 +56,7 @@ abstract class Stats
|
|||
include_once DOL_DOCUMENT_ROOT.'/core/lib/json.lib.php';
|
||||
}
|
||||
|
||||
$newpathofdestfile=$conf->user->dir_temp.'/'.get_class($this).'_'.__FUNCTION__.'_'.$langs->defaultlang.'_user'.$user->id.'.cache';
|
||||
$newpathofdestfile=$conf->user->dir_temp.'/'.get_class($this).'_'.__FUNCTION__.'_'.(empty($this->cachefilesuffix)?'':$this->cachefilesuffix.'_').$langs->defaultlang.'_user'.$user->id.'.cache';
|
||||
$newmask='0644';
|
||||
|
||||
$nowgmt = dol_now();
|
||||
|
|
@ -147,7 +147,7 @@ abstract class Stats
|
|||
include_once DOL_DOCUMENT_ROOT.'/core/lib/json.lib.php';
|
||||
}
|
||||
|
||||
$newpathofdestfile=$conf->user->dir_temp.'/'.get_class($this).'_'.__FUNCTION__.'_'.$langs->defaultlang.'_user'.$user->id.'.cache';
|
||||
$newpathofdestfile=$conf->user->dir_temp.'/'.get_class($this).'_'.__FUNCTION__.'_'.(empty($this->cachefilesuffix)?'':$this->cachefilesuffix.'_').$langs->defaultlang.'_user'.$user->id.'.cache';
|
||||
$newmask='0644';
|
||||
|
||||
$nowgmt = dol_now();
|
||||
|
|
|
|||
|
|
@ -98,7 +98,11 @@ class modFacture extends DolibarrModules
|
|||
|
||||
// Boxes
|
||||
//$this->boxes = array(0=>array(1=>'box_factures_imp.php'),1=>array(1=>'box_factures.php'));
|
||||
$this->boxes = array(0=>array('file'=>'box_factures_imp.php','enabledbydefaulton'=>'Home'),1=>array('file'=>'box_factures.php','enabledbydefaulton'=>'Home'),2=>array('file'=>'box_graph_invoices_permonth.php','enabledbydefaulton'=>'Home'));
|
||||
$this->boxes = array(
|
||||
0=>array('file'=>'box_factures_imp.php','enabledbydefaulton'=>'Home'),
|
||||
1=>array('file'=>'box_factures.php','enabledbydefaulton'=>'Home'),
|
||||
2=>array('file'=>'box_graph_invoices_permonth.php','enabledbydefaulton'=>'Home')
|
||||
);
|
||||
|
||||
// Permissions
|
||||
$this->rights = array();
|
||||
|
|
|
|||
|
|
@ -108,20 +108,13 @@ class modFournisseur extends DolibarrModules
|
|||
$r++;
|
||||
|
||||
// Boxes
|
||||
$this->boxes = array();
|
||||
$r=0;
|
||||
|
||||
$this->boxes[$r][1] = "box_fournisseurs.php";
|
||||
$r++;
|
||||
|
||||
$this->boxes[$r][1] = "box_factures_fourn_imp.php";
|
||||
$r++;
|
||||
|
||||
$this->boxes[$r][1] = "box_factures_fourn.php";
|
||||
$r++;
|
||||
|
||||
$this->boxes[$r][1] = "box_supplier_orders.php";
|
||||
$r++;
|
||||
$this->boxes = array(
|
||||
0=>array('file'=>'box_graph_invoices_supplier_permonth.php','enabledbydefaulton'=>'Home'),
|
||||
1=>array('file'=>'box_fournisseurs.php','enabledbydefaulton'=>'Home'),
|
||||
2=>array('file'=>'box_factures_fourn_imp.php','enabledbydefaulton'=>'Home'),
|
||||
3=>array('file'=>'box_factures_fourn.php','enabledbydefaulton'=>'Home'),
|
||||
4=>array('file'=>'box_supplier_orders.php','enabledbydefaulton'=>'Home'),
|
||||
);
|
||||
|
||||
// Permissions
|
||||
$this->rights = array();
|
||||
|
|
|
|||
|
|
@ -622,9 +622,10 @@ class InterfaceActionsAuto
|
|||
}
|
||||
else
|
||||
{
|
||||
$error ="Failed to insert : ".$actioncomm->error." ";
|
||||
$error ="Failed to insert event : ".$actioncomm->error." ".join(',',$actioncomm->errors);
|
||||
$this->error=$error;
|
||||
|
||||
$this->errors=$actioncomm->errors;
|
||||
|
||||
dol_syslog("interface_modAgenda_ActionsAuto.class.php: ".$this->error, LOG_ERR);
|
||||
return -1;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -142,7 +142,8 @@ elseif ($action == 'confirm_valid' && $confirm == 'yes' && $user->rights->fourni
|
|||
$result = $object->validate($user,'',$idwarehouse);
|
||||
if ($result < 0)
|
||||
{
|
||||
$mesg='<div class="error">'.$object->error.'</div>';
|
||||
setEventMessage($object->error,'errors');
|
||||
setEventMessage($object->errors,'errors');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user