Ajout méthode pour futur "Tableau de bord Dolibarr".
This commit is contained in:
parent
175bd12e0f
commit
d26b283d18
@ -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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
|||||||
@ -160,6 +160,7 @@ class Commande
|
|||||||
}
|
}
|
||||||
return $result ;
|
return $result ;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Cloture la commande
|
* 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)
|
if ($this->statut == 0)
|
||||||
{
|
{
|
||||||
$sql = "DELETE FROM ".MAIN_DB_PREFIX."commandedet WHERE rowid = $idligne";
|
$sql = "DELETE FROM ".MAIN_DB_PREFIX."commandedet WHERE rowid = $idligne";
|
||||||
|
|
||||||
if ($this->db->query($sql) )
|
if ($this->db->query($sql) )
|
||||||
{
|
{
|
||||||
$this->update_price();
|
$this->update_price();
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return 0;
|
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 = "UPDATE ".MAIN_DB_PREFIX."commande SET facture = 1";
|
||||||
$sql .= " WHERE rowid = ".$this->id." AND fk_statut > 0 ;";
|
$sql .= " WHERE rowid = ".$this->id." AND fk_statut > 0 ;";
|
||||||
|
|
||||||
if ($this->db->query($sql) )
|
|
||||||
{
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
dolibarr_print_error($this->db);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
if ($this->db->query($sql) )
|
||||||
|
{
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
dolibarr_print_error($this->db);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Mettre à jour le prix
|
* 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)
|
function classin($cat_id)
|
||||||
{
|
{
|
||||||
$sql = "UPDATE ".MAIN_DB_PREFIX."commande SET fk_projet = $cat_id";
|
$sql = "UPDATE ".MAIN_DB_PREFIX."commande SET fk_projet = $cat_id";
|
||||||
$sql .= " WHERE rowid = $this->id;";
|
$sql .= " WHERE rowid = $this->id;";
|
||||||
|
|
||||||
if ($this->db->query($sql) )
|
if ($this->db->query($sql) )
|
||||||
{
|
{
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
dolibarr_print_error($this->db);
|
$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
|
\brief Classe de gestion des lignes de commande
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|||||||
@ -160,13 +160,6 @@ if ($_GET["action"] == 'deleteline' && $user->rights->commande->creer)
|
|||||||
Header("Location: fiche.php?id=".$_GET["id"]);
|
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)
|
if ($_POST["action"] == 'confirm_valid' && $_POST["confirm"] == 'yes' && $user->rights->commande->valider)
|
||||||
{
|
{
|
||||||
$commande = new Commande($db);
|
$commande = new Commande($db);
|
||||||
@ -176,6 +169,13 @@ if ($_POST["action"] == 'confirm_valid' && $_POST["confirm"] == 'yes' && $user->
|
|||||||
$result = $commande->valid($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)
|
if ($_POST["action"] == 'confirm_cancel' && $_POST["confirm"] == 'yes' && $user->rights->commande->valider)
|
||||||
{
|
{
|
||||||
$commande = new Commande($db);
|
$commande = new Commande($db);
|
||||||
@ -461,7 +461,6 @@ else
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* Confirmation de la suppression de la commande
|
* Confirmation de la suppression de la commande
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
if ($_GET["action"] == 'delete')
|
if ($_GET["action"] == 'delete')
|
||||||
{
|
{
|
||||||
@ -471,7 +470,6 @@ else
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* Confirmation de la validation
|
* Confirmation de la validation
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
if ($_GET["action"] == 'valid')
|
if ($_GET["action"] == 'valid')
|
||||||
{
|
{
|
||||||
@ -479,9 +477,19 @@ else
|
|||||||
$html->form_confirm("fiche.php?id=$id",$langs->trans("ValidateOrder"),$langs->trans("ConfirmValidateOrder"),"confirm_valid");
|
$html->form_confirm("fiche.php?id=$id",$langs->trans("ValidateOrder"),$langs->trans("ConfirmValidateOrder"),"confirm_valid");
|
||||||
print "<br />\n";
|
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
|
* Confirmation de l'annulation
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
if ($_GET["action"] == 'annuler')
|
if ($_GET["action"] == 'annuler')
|
||||||
{
|
{
|
||||||
@ -512,7 +520,7 @@ else
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
print $langs->trans("Project").' : ';
|
print $langs->trans("Project").' : ';
|
||||||
print '<a href="fiche.php?id='.$id.'&action=classer">Classer la commande</a>';
|
print '<a href="fiche.php?id='.$id.'&action=classer">'.$langs->trans("ClassifyOrder").'</a>';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
print ' </td></tr>';
|
print ' </td></tr>';
|
||||||
@ -768,6 +776,14 @@ else
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($commande->statut == 1 || $commande->statut == 2)
|
||||||
|
{
|
||||||
|
if ($user->rights->commande->creer)
|
||||||
|
{
|
||||||
|
print '<a class="butAction" href="fiche.php?id='.$id.'&action=cloture">'.$langs->trans("Close").'</a>';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if ($commande->statut == 0 && $user->rights->commande->supprimer)
|
if ($commande->statut == 0 && $user->rights->commande->supprimer)
|
||||||
{
|
{
|
||||||
print '<a class="butActionDelete" href="fiche.php?id='.$id.'&action=delete">'.$langs->trans("Delete").'</a>';
|
print '<a class="butActionDelete" href="fiche.php?id='.$id.'&action=delete">'.$langs->trans("Delete").'</a>';
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user