This commit is contained in:
eldy 2011-09-29 22:32:28 +02:00
parent 8ff32f8ada
commit 0a9364c5e9
4 changed files with 170 additions and 137 deletions

View File

@ -74,7 +74,9 @@ class Expedition extends CommonObject
var $date_valid; var $date_valid;
/** /**
* Initialisation * Constructor
*
* @param DoliDB $DB Database handler
*/ */
function Expedition($DB) function Expedition($DB)
{ {
@ -88,10 +90,11 @@ class Expedition extends CommonObject
$this->statuts[1] = 'StatusSendingValidated'; $this->statuts[1] = 'StatusSendingValidated';
} }
/** /**
* Return next contract ref * Return next contract ref
* @param soc objet society *
* @return string free reference for contract * @param Societe $soc Objet society
* @return string Free reference for contract
*/ */
function getNextNumRef($soc) function getNextNumRef($soc)
{ {
@ -135,9 +138,10 @@ class Expedition extends CommonObject
} }
/** /**
* \brief Cree expedition en base * Create expedition en base
* \param user Objet du user qui cree *
* \return int <0 si erreur, id expedition creee si ok * @param User $user Objet du user qui cree
* @return int <0 si erreur, id expedition creee si ok
*/ */
function create($user) function create($user)
{ {
@ -301,11 +305,12 @@ class Expedition extends CommonObject
/** /**
* Get object and lines from database * Get object and lines from database
* @param id Id of object to load *
* @param ref Ref of object * @param int $id Id of object to load
* @param ref_ext External reference of object * @param string $ref Ref of object
* @param ref_int Internal reference of other object * @param string $ref_ext External reference of object
* @return int >0 if OK, <0 if KO * @param string $ref_int Internal reference of other object
* @return int >0 if OK, <0 if KO
*/ */
function fetch($id, $ref='', $ref_ext='', $ref_int='') function fetch($id, $ref='', $ref_ext='', $ref_int='')
{ {
@ -408,8 +413,9 @@ class Expedition extends CommonObject
/** /**
* Validate object and update stock if option enabled * Validate object and update stock if option enabled
* @param user Object user that validate *
* @return int * @param User $user Object user that validate
* @return int <0 if OK, >0 if KO
*/ */
function valid($user) function valid($user)
{ {
@ -579,9 +585,10 @@ class Expedition extends CommonObject
/** /**
* \brief Cree un bon de livraison a partir de l'expedition * Cree un bon de livraison a partir de l'expedition
* \param user Utilisateur *
* \return int <0 si ko, >=0 si ok * @param User $user Utilisateur
* @return int <0 if KO, >=0 if OK
*/ */
function create_delivery($user) function create_delivery($user)
{ {
@ -651,10 +658,11 @@ class Expedition extends CommonObject
} }
/** /**
* \brief Update database * Update database
* \param user User that modify *
* \param notrigger 0=launch triggers after, 1=disable triggers * @param User $user User that modify
* \return int <0 if KO, >0 if OK * @param int $notrigger 0=launch triggers after, 1=disable triggers
* @return int <0 if KO, >0 if OK
*/ */
function update($user=0, $notrigger=0) function update($user=0, $notrigger=0)
{ {
@ -755,6 +763,8 @@ class Expedition extends CommonObject
/** /**
* Delete shipping * Delete shipping
*
* @return void
*/ */
function delete() function delete()
{ {
@ -838,8 +848,9 @@ class Expedition extends CommonObject
} }
/** /**
* Load lines
* *
* * @return void
*/ */
function fetch_lines() function fetch_lines()
{ {
@ -898,9 +909,10 @@ class Expedition extends CommonObject
} }
/** /**
* \brief Renvoie nom clicable (avec eventuellement le picto) * Renvoie nom clicable (avec eventuellement le picto)
* \param withpicto 0=Pas de picto, 1=Inclut le picto dans le lien, 2=Picto seul *
* \return string Chaine avec URL * @param int $withpicto 0=Pas de picto, 1=Inclut le picto dans le lien, 2=Picto seul
* @return string Chaine avec URL
*/ */
function getNomUrl($withpicto=0,$option=0,$max=0,$short=0) function getNomUrl($withpicto=0,$option=0,$max=0,$short=0)
{ {
@ -925,8 +937,9 @@ class Expedition extends CommonObject
} }
/** /**
* \brief Retourne le libelle du statut d'une expedition * Retourne le libelle du statut d'une expedition
* \return string Libelle *
* @return string Libelle
*/ */
function getLibStatut($mode=0) function getLibStatut($mode=0)
{ {
@ -934,10 +947,11 @@ class Expedition extends CommonObject
} }
/** /**
* \brief Return label of a status * Return label of a status
* \param statut Id statut *
* \param mode 0=Long label, 1=Short label, 2=Picto + Short label, 3=Picto, 4=Picto + Long label, 5=Short label + Picto * @param int $statut Id statut
* \return string Label of status * @param int $mode 0=Long label, 1=Short label, 2=Picto + Short label, 3=Picto, 4=Picto + Long label, 5=Short label + Picto
* @return string Label of status
*/ */
function LibStatut($statut,$mode) function LibStatut($statut,$mode)
{ {
@ -1047,10 +1061,11 @@ class Expedition extends CommonObject
} }
/** /**
* \brief Set the planned delivery date * Set the planned delivery date
* \param user Objet utilisateur qui modifie *
* \param date_livraison Date de livraison * @param user Objet utilisateur qui modifie
* \return int <0 si ko, >0 si ok * @param date_livraison Date de livraison
* @return int <0 si ko, >0 si ok
*/ */
function set_date_livraison($user, $date_livraison) function set_date_livraison($user, $date_livraison)
{ {
@ -1081,7 +1096,9 @@ class Expedition extends CommonObject
} }
/** /**
* \brief Fetch deliveries method and return an array. Load array this->meths(rowid=>label). * Fetch deliveries method and return an array. Load array this->meths(rowid=>label).
*
* @return void
*/ */
function fetch_delivery_methods() function fetch_delivery_methods()
{ {
@ -1106,6 +1123,8 @@ class Expedition extends CommonObject
/** /**
* Get tracking url status * Get tracking url status
*
* @return void
*/ */
function GetUrlTrackingStatus($value='') function GetUrlTrackingStatus($value='')
{ {
@ -1157,8 +1176,7 @@ class Expedition extends CommonObject
/** /**
* \class ExpeditionLigne * Classe de gestion des lignes de bons d'expedition
* \brief Classe de gestion des lignes de bons d'expedition
*/ */
class ExpeditionLigne class ExpeditionLigne
{ {

View File

@ -28,104 +28,119 @@
*/ */
class ExpeditionStats class ExpeditionStats
{ {
var $db; var $db;
function ExpeditionStats($DB) /**
{ * Constructor
$this->db = $DB; *
} * @param DoliDB $DB Database handler
/** */
* Renvoie le nombre de expedition par annee function ExpeditionStats($DB)
*
*/
function getNbExpeditionByYear()
{
global $conf;
$result = array();
$sql = "SELECT count(*), date_format(date_expedition,'%Y') as dm";
$sql.= " FROM ".MAIN_DB_PREFIX."expedition";
$sql.= " WHERE fk_statut > 0";
$sql.= " AND entity = ".$conf->entity;
$sql.= " GROUP BY dm DESC";
$resql=$this->db->query($sql);
if ($resql)
{ {
$num = $this->db->num_rows($resql); $this->db = $DB;
$i = 0;
while ($i < $num)
{
$row = $this->db->fetch_row($resql);
$result[$i] = $row;
$i++;
}
$this->db->free($resql);
}
return $result;
}
/**
* Renvoie le nombre de expedition par mois pour une annee donnee
*
*/
function getNbExpeditionByMonth($year)
{
global $conf;
$result = array();
$sql = "SELECT count(*), date_format(date_expedition,'%m') as dm";
$sql.= " FROM ".MAIN_DB_PREFIX."expedition";
$sql.= " WHERE date_format(date_expedition,'%Y') = '".$year."'";
$sql.= " AND fk_statut > 0";
$sql.= " AND entity = ".$conf->entity;
$sql.= " GROUP BY dm DESC";
$resql=$this->db->query($sql);
if ($resql)
{
$num = $this->db->num_rows($resql);
$i = 0;
while ($i < $num)
{
$row = $this->db->fetch_row($resql);
$j = $row[0] * 1;
$result[$j] = $row[1];
$i++;
}
$this->db->free($resql);
}
for ($i = 1 ; $i < 13 ; $i++)
{
$res[$i] = $result[$i] + 0;
} }
$data = array(); /**
* Renvoie le nombre de expedition par annee
for ($i = 1 ; $i < 13 ; $i++) *
* @return void
*/
function getNbExpeditionByYear()
{ {
$data[$i-1] = array(dol_print_date(dol_mktime(12,0,0,$i,1,$year),"%b"), $res[$i]); global $conf;
$result = array();
$sql = "SELECT count(*), date_format(date_expedition,'%Y') as dm";
$sql.= " FROM ".MAIN_DB_PREFIX."expedition";
$sql.= " WHERE fk_statut > 0";
$sql.= " AND entity = ".$conf->entity;
$sql.= " GROUP BY dm DESC";
$resql=$this->db->query($sql);
if ($resql)
{
$num = $this->db->num_rows($resql);
$i = 0;
while ($i < $num)
{
$row = $this->db->fetch_row($resql);
$result[$i] = $row;
$i++;
}
$this->db->free($resql);
}
return $result;
} }
return $data; /**
} * Renvoie le nombre de expedition par mois pour une annee donnee
*
* @param int $year Year
function getNbExpeditionByMonthWithPrevYear($year) * @return int
{ */
$data1 = $this->getNbExpeditionByMonth($year); function getNbExpeditionByMonth($year)
$data2 = $this->getNbExpeditionByMonth($year - 1);
$data = array();
for ($i = 1 ; $i < 13 ; $i++)
{ {
$data[$i-1] = array(dol_print_date(dol_mktime(12,0,0,$i,1,$year),"%b"), global $conf;
$data1[$i][1],
$data2[$i][1]); $result = array();
$sql = "SELECT count(*), date_format(date_expedition,'%m') as dm";
$sql.= " FROM ".MAIN_DB_PREFIX."expedition";
$sql.= " WHERE date_format(date_expedition,'%Y') = '".$year."'";
$sql.= " AND fk_statut > 0";
$sql.= " AND entity = ".$conf->entity;
$sql.= " GROUP BY dm DESC";
$resql=$this->db->query($sql);
if ($resql)
{
$num = $this->db->num_rows($resql);
$i = 0;
while ($i < $num)
{
$row = $this->db->fetch_row($resql);
$j = $row[0] * 1;
$result[$j] = $row[1];
$i++;
}
$this->db->free($resql);
}
for ($i = 1 ; $i < 13 ; $i++)
{
$res[$i] = $result[$i] + 0;
}
$data = array();
for ($i = 1 ; $i < 13 ; $i++)
{
$data[$i-1] = array(dol_print_date(dol_mktime(12,0,0,$i,1,$year),"%b"), $res[$i]);
}
return $data;
}
/**
*
* @param int $year Year
* @return int
*/
function getNbExpeditionByMonthWithPrevYear($year)
{
$data1 = $this->getNbExpeditionByMonth($year);
$data2 = $this->getNbExpeditionByMonth($year - 1);
$data = array();
for ($i = 1 ; $i < 13 ; $i++)
{
$data[$i-1] = array(dol_print_date(dol_mktime(12,0,0,$i,1,$year),"%b"),
$data1[$i][1],
$data2[$i][1]);
}
return $data;
} }
return $data;
}
} }

View File

@ -783,7 +783,7 @@ if ($action == 'create')
// Show subproducts of product // Show subproducts of product
if (! empty($conf->global->PRODUIT_SOUSPRODUITS) && $line->fk_product > 0) if (! empty($conf->global->PRODUIT_SOUSPRODUITS) && $line->fk_product > 0)
{ {
$product->get_sousproduits_arbo (); $product->get_sousproduits_arbo();
$prods_arbo = $product->get_arbo_each_prod($qtyProdCom); $prods_arbo = $product->get_arbo_each_prod($qtyProdCom);
if(count($prods_arbo) > 0) if(count($prods_arbo) > 0)
{ {

View File

@ -46,16 +46,16 @@ $sql.= " GROUP BY dm DESC ";
$resql=$db->query($sql); $resql=$db->query($sql);
if ($resql) if ($resql)
{ {
$num = $db->num_rows($resql); $num = $db->num_rows($resql);
$i = 0; $i = 0;
while ($i < $num) while ($i < $num)
{ {
$row = $db->fetch_row($resql); $row = $db->fetch_row($resql);
$nbproduct = $row[0]; $nbproduct = $row[0];
$year = $row[1]; $year = $row[1];
print "<tr>"; print "<tr>";
print '<td align="center"><a href="month.php?year='.$year.'">'.$year.'</a></td><td align="center">'.$nbproduct.'</td></tr>'; print '<td align="center"><a href="month.php?year='.$year.'">'.$year.'</a></td><td align="center">'.$nbproduct.'</td></tr>';
$i++; $i++;
} }
} }
$db->free(); $db->free();