Ajout mthode pour futur "Tableau de bord Dolibarr".

This commit is contained in:
Laurent Destailleur 2005-07-14 22:29:49 +00:00
parent 175bd12e0f
commit d26b283d18
3 changed files with 142 additions and 58 deletions

View File

@ -216,5 +216,35 @@ class ActionComm
}
}
/**
* \brief Charge indicateurs this->nbtodo et this->nbtodolate de tableau de bord
* \return int <0 si ko, >0 si ok
*/
function load_board()
{
global $conf;
$this->nbtodo=$this->nbtodolate=0;
$sql = "SELECT a.id,".$this->db->pdate("a.datea")." as da";
$sql.= " FROM ".MAIN_DB_PREFIX."actioncomm as a";
$sql.= " WHERE a.percent < 100";
$resql=$this->db->query($sql);
if ($resql)
{
while ($obj=$this->db->fetch_object($resql))
{
$this->nbtodo++;
if ($obj->da < (time() - $conf->actions->warning_delay)) $this->nbtodolate++;
}
return 1;
}
else
{
$this->error=$this->db->error();
return -1;
}
}
}
?>

View File

@ -160,6 +160,7 @@ class Commande
}
return $result ;
}
/**
* Cloture la commande
*
@ -576,27 +577,29 @@ class Commande
}
/**
* Supprime une ligne de la commande
*
* \brief Supprime une ligne de la commande
* \param idligne Id de la ligne à supprimer
* \return int >0 si ok, <0 si ko
*/
function delete_line($idligne)
function delete_line($idligne)
{
if ($this->statut == 0)
{
$sql = "DELETE FROM ".MAIN_DB_PREFIX."commandedet WHERE rowid = $idligne";
if ($this->db->query($sql) )
{
$this->update_price();
return 1;
}
else
{
return 0;
}
}
if ($this->statut == 0)
{
$sql = "DELETE FROM ".MAIN_DB_PREFIX."commandedet WHERE rowid = $idligne";
if ($this->db->query($sql) )
{
$this->update_price();
return 1;
}
else
{
return -1;
}
}
}
/**
*
*
@ -651,24 +654,24 @@ class Commande
}
}
/**
* Classe la facture comme facturée
*
* \brief Classe la facture comme facturée
* \return int <0 si ko, >0 si ok
*/
function classer_facturee()
function classer_facturee()
{
$sql = "UPDATE ".MAIN_DB_PREFIX."commande SET facture = 1";
$sql .= " WHERE rowid = ".$this->id." AND fk_statut > 0 ;";
if ($this->db->query($sql) )
{
return 1;
}
else
{
dolibarr_print_error($this->db);
}
$sql = "UPDATE ".MAIN_DB_PREFIX."commande SET facture = 1";
$sql .= " WHERE rowid = ".$this->id." AND fk_statut > 0 ;";
if ($this->db->query($sql) )
{
return 1;
}
else
{
dolibarr_print_error($this->db);
}
}
/**
* Mettre à jour le prix
*
@ -804,27 +807,62 @@ class Commande
}
}
/**
* Classe la commande
*
* \brief Classer la commande dans un projet
* \param cat_id Id du projet
*/
function classin($cat_id)
{
$sql = "UPDATE ".MAIN_DB_PREFIX."commande SET fk_projet = $cat_id";
$sql .= " WHERE rowid = $this->id;";
if ($this->db->query($sql) )
{
return 1;
}
else
{
dolibarr_print_error($this->db);
}
$sql = "UPDATE ".MAIN_DB_PREFIX."commande SET fk_projet = $cat_id";
$sql .= " WHERE rowid = $this->id;";
if ($this->db->query($sql) )
{
return 1;
}
else
{
$this->error=$this->db->error();
return -1;
}
}
/**
* \brief Charge indicateurs this->nbtodo et this->nbtodolate de tableau de bord
* \return int <0 si ko, >0 si ok
*/
function load_board()
{
global $conf;
$this->nbtodo=$this->nbtodolate=0;
$sql = "SELECT c.rowid,".$this->db->pdate("c.date_creation")." as datec";
$sql.= " FROM ".MAIN_DB_PREFIX."commande as c";
$sql.= " WHERE c.fk_statut BETWEEN 1 AND 2";
$resql=$this->db->query($sql);
if ($resql)
{
while ($obj=$this->db->fetch_object($resql))
{
$this->nbtodo++;
if ($obj->da < (time() - $conf->commande->traitement->warning_delay)) $this->nbtodolate++;
}
return 1;
}
else
{
dolibarr_print_error($this->db);
$this->error=$this->db->error();
return -1;
}
}
}
/** \class CommandeLigne
/**
\class CommandeLigne
\brief Classe de gestion des lignes de commande
*/

View File

@ -160,13 +160,6 @@ if ($_GET["action"] == 'deleteline' && $user->rights->commande->creer)
Header("Location: fiche.php?id=".$_GET["id"]);
}
if ($_GET["action"] == 'facturee')
{
$commande = new Commande($db);
$commande->fetch($_GET["id"]);
$commande->classer_facturee();
}
if ($_POST["action"] == 'confirm_valid' && $_POST["confirm"] == 'yes' && $user->rights->commande->valider)
{
$commande = new Commande($db);
@ -176,6 +169,13 @@ if ($_POST["action"] == 'confirm_valid' && $_POST["confirm"] == 'yes' && $user->
$result = $commande->valid($user);
}
if ($_POST["action"] == 'confirm_close' && $_POST["confirm"] == 'yes' && $user->rights->commande->creer)
{
$commande = new Commande($db);
$commande->fetch($_GET["id"]);
$result = $commande->cloture($user);
}
if ($_POST["action"] == 'confirm_cancel' && $_POST["confirm"] == 'yes' && $user->rights->commande->valider)
{
$commande = new Commande($db);
@ -461,7 +461,6 @@ else
/*
* Confirmation de la suppression de la commande
*
*/
if ($_GET["action"] == 'delete')
{
@ -471,7 +470,6 @@ else
/*
* Confirmation de la validation
*
*/
if ($_GET["action"] == 'valid')
{
@ -479,9 +477,19 @@ else
$html->form_confirm("fiche.php?id=$id",$langs->trans("ValidateOrder"),$langs->trans("ConfirmValidateOrder"),"confirm_valid");
print "<br />\n";
}
/*
* Confirmation de la cloture
*/
if ($_GET["action"] == 'cloture')
{
//$numfa = commande_get_num($soc);
$html->form_confirm("fiche.php?id=$id",$langs->trans("CloseOrder"),$langs->trans("ConfirmCloseOrder"),"confirm_close");
print "<br />\n";
}
/*
* Confirmation de l'annulation
*
*/
if ($_GET["action"] == 'annuler')
{
@ -512,7 +520,7 @@ else
else
{
print $langs->trans("Project").' : ';
print '<a href="fiche.php?id='.$id.'&amp;action=classer">Classer la commande</a>';
print '<a href="fiche.php?id='.$id.'&amp;action=classer">'.$langs->trans("ClassifyOrder").'</a>';
}
}
print '&nbsp;</td></tr>';
@ -767,6 +775,14 @@ else
print '<a class="butAction" href="fiche.php?id='.$id.'&amp;action=valid">'.$langs->trans("Valid").'</a>';
}
}
if ($commande->statut == 1 || $commande->statut == 2)
{
if ($user->rights->commande->creer)
{
print '<a class="butAction" href="fiche.php?id='.$id.'&amp;action=cloture">'.$langs->trans("Close").'</a>';
}
}
if ($commande->statut == 0 && $user->rights->commande->supprimer)
{