Fix: Statut facture d'une propale non gr

This commit is contained in:
Laurent Destailleur 2005-07-10 15:09:55 +00:00
parent 0732193013
commit 004290a232
8 changed files with 165 additions and 94 deletions

View File

@ -125,8 +125,8 @@ if ($_GET["propalid"])
*
*/
$sql = 'SELECT s.nom, s.idp, p.price, p.fk_projet,p.remise, p.tva, p.total, p.ref,'.$db->pdate('p.datep').' as dp, c.id as statut, c.label as lst, p.note, x.firstname, x.name, x.fax, x.phone, x.email, p.fk_user_author, p.fk_user_valid, p.fk_user_cloture, p.datec, p.date_valid, p.date_cloture';
$sql .= ' FROM '.MAIN_DB_PREFIX.'societe as s, '.MAIN_DB_PREFIX.'propal as p, '.MAIN_DB_PREFIX.'c_propalst as c, '.MAIN_DB_PREFIX.'socpeople as x';
$sql .= ' WHERE p.fk_soc = s.idp AND p.fk_statut = c.id AND x.idp = p.fk_soc_contact AND p.rowid = '.$propal->id;
$sql.= ' FROM '.MAIN_DB_PREFIX.'societe as s, '.MAIN_DB_PREFIX.'propal as p, '.MAIN_DB_PREFIX.'c_propalst as c, '.MAIN_DB_PREFIX.'socpeople as x';
$sql.= ' WHERE p.fk_soc = s.idp AND p.fk_statut = c.id AND x.idp = p.fk_soc_contact AND p.rowid = '.$propal->id;
if ($socidp) $sql .= ' AND s.idp = '.$socidp;
$result = $db->query($sql);
@ -431,7 +431,7 @@ if ($_GET["propalid"])
print '<a class="butAction" href="facture.php?propalid='.$propal->id."&action=create\">".$langs->trans("BuildBill")."</a>";
}
if ($obj->statut == 2 && $num_fac_asso)
if ($obj->statut == 2 && sizeof($propal->facture_liste_array()))
{
print '<a class="butAction" href="propal.php?propalid='.$propal->id."&action=setstatut&statut=4\">".$langs->trans("ClassifyBilled")."</a>";
}

View File

@ -1,5 +1,6 @@
# Dolibarr language file - en_US - compta
Accountancy=Accountancy
AccountancyCard=Accountancy card
Treasury=Treasury
OptionMode=Option for accountancy
OptionModeTrue=Option Recettes-Dépenses

View File

@ -9,3 +9,4 @@ ConfirmDeleteAProject=Are you sure you want to delete this project ?
LastProjects=Last %s projects
AllProjects=All projects
ShowProject=Show project
NoProject=No project defined

View File

@ -27,6 +27,15 @@ PropalsOpened=Opened
PropalStatusDraft=Draft (need to be validated)
PropalStatusValidated=Validated (proposal is opened)
PropalStatusClosed=Closed
PropalStatusSigned=Signed (need to be billed)
PropalStatusNotSigned=Not signed (closed)
PropalStatusBilled=Billed
PropalStatusDraftShort=Draft
PropalStatusValidatedShort=Validated
PropalStatusClosedShort=Closed
PropalStatusSignedShort=Signed
PropalStatusClosedShort=Not signed
PropalStatusBilledShort=Billed
ListOfProposals=List of commercial proposals
ActionsOnPropal=Tasks on proposal
NoOpenedPropals=No opened commercial proposals
@ -38,5 +47,11 @@ FileNotUploaded=The file was not uploaded
FileUploaded=The file was successfully uploaded
AssociatedDocuments=Documents associated with the proposal:
ErrorCantOpenDir=Can't open directory
DateEndPropal=Date fin validité
DateEndPropalShort=Date fin
DateEndPropal=Date end validity
DateEndPropalShort=Date end
ValidityDuration=Validity duration
CloseAs=Close with status
ClassifyBilled=Classify billed
BuildBill=Build bill
RelatedBill=Related bill
RelatedBills=Related bills

View File

@ -1,5 +1,6 @@
# Dolibarr language file - fr_FR - compta
Accountancy=Compta
AccountancyCard=Fiche Compta
Treasury=Tréso
OptionMode=Option de tenue de comptabilité
OptionModeTrue=Option Recettes-Dépenses

View File

@ -9,3 +9,4 @@ ConfirmDeleteAProject=
LastProjects=Les %s derniers projets
AllProjects=Tous les projets
ShowProject=Afficher projet
NoProject=Aucun projet défini

View File

@ -26,7 +26,16 @@ PropalsDraft=Brouillons
PropalsOpened=Ouvertes
PropalStatusDraft=Brouillon (à valider)
PropalStatusValidated=Validée (propale ouverte)
PropalStatusClosed=Fermé
PropalStatusClosed=Fermée
PropalStatusSigned=Signée (à facturer)
PropalStatusNotSigned=Non signée (fermée)
PropalStatusBilled=Facturée
PropalStatusDraftShort=Brouillon
PropalStatusValidatedShort=Validée
PropalStatusClosedShort=Fermée
PropalStatusSignedShort=Signée
PropalStatusClosedShort=Non signée
PropalStatusBilledShort=Facturée
ListOfProposals=Liste des devis/propositions commerciales
ActionsOnPropal=Actions sur la proposition
NoOpenedPropals=Pas de proposition ouverte
@ -40,3 +49,9 @@ AssociatedDocuments=Documents associ
ErrorCantOpenDir=Impossible d'ouvrir le répertoire
DateEndPropal=Date fin validité
DateEndPropalShort=Date fin
ValidityDuration=Durée de validité
CloseAs=Clôturer au statut
ClassifyBilled=Classer facturée
BuildBill=Créer facture
RelatedBill=Facture associée
RelatedBills=Factures associées

View File

@ -79,10 +79,14 @@ class Propal
$langs->load("propals");
$this->labelstatut[0]=$langs->trans("PropalStatusDraft");
$this->labelstatut[1]=$langs->trans("PropalStatusValidated");
$this->labelstatut[2]=$langs->trans("PropalStatusClosed");
$this->labelstatut_short[0]=$langs->trans("PropalStatusDraft");
$this->labelstatut[2]=$langs->trans("PropalStatusSigned");
$this->labelstatut[3]=$langs->trans("PropalStatusNotSigned");
$this->labelstatut[4]=$langs->trans("PropalStatusBilled");
$this->labelstatut_short[0]=$langs->trans("PropalStatusDraftShort");
$this->labelstatut_short[1]=$langs->trans("Opened");
$this->labelstatut_short[2]=$langs->trans("PropalStatusClosed");
$this->labelstatut_short[2]=$langs->trans("PropalStatusSignedShort");
$this->labelstatut_short[3]=$langs->trans("PropalStatusNotSignedShort");
$this->labelstatut_short[4]=$langs->trans("PropalStatusBilledShort");
}
@ -786,45 +790,45 @@ class Propal
}
}
/**
* \brief Renvoie un tableau contenant les numéros de commandes associées
*
*/
function commande_liste_array ()
/**
* \brief Renvoie un tableau contenant les numéros de commandes associées
* \remarks Fonction plus light que associated_orders
* \seealso associated_orders
*/
function commande_liste_array ()
{
$ga = array();
$sql = "SELECT fk_commande FROM ".MAIN_DB_PREFIX."co_pr";
$sql .= " WHERE fk_propale = " . $this->id;
if ($this->db->query($sql) )
{
$nump = $this->db->num_rows();
if ($nump)
{
$i = 0;
while ($i < $nump)
{
$obj = $this->db->fetch_object();
$ga[$i] = $obj->fk_commande;
$i++;
}
}
return $ga;
}
else
{
dolibarr_print_error($this->db);
}
$ga = array();
$sql = "SELECT fk_commande FROM ".MAIN_DB_PREFIX."co_pr";
$sql .= " WHERE fk_propale = " . $this->id;
if ($this->db->query($sql) )
{
$nump = $this->db->num_rows();
if ($nump)
{
$i = 0;
while ($i < $nump)
{
$obj = $this->db->fetch_object();
$ga[$i] = $obj->fk_commande;
$i++;
}
}
return $ga;
}
else
{
dolibarr_print_error($this->db);
}
}
/**
* \brief Renvoie un tableau contenant les commandes associées
*
* \brief Renvoie un tableau contenant les commandes associées
* \remarks Fonction plus lourde que commande_liste_array
* \seealso commande_liste_array
*/
function associated_orders ()
{
$ga = array();
@ -855,11 +859,42 @@ class Propal
}
}
/*
*
*
/**
* \brief Renvoie un tableau contenant les numéros de factures associées
*/
function facture_liste_array ()
{
$ga = array();
$sql = "SELECT fk_facture FROM ".MAIN_DB_PREFIX."fa_pr as fp";
$sql .= " WHERE fk_propal = " . $this->id;
if ($this->db->query($sql) )
{
$nump = $this->db->num_rows();
if ($nump)
{
$i = 0;
while ($i < $nump)
{
$obj = $this->db->fetch_object();
$ga[$i] = $obj->fk_facture;
$i++;
}
}
return $ga;
}
else
{
dolibarr_print_error($this->db);
}
}
/**
* \brief Efface propal
* \param user Objet du user qui efface
*/
function delete($user)
{
$sql = "DELETE FROM ".MAIN_DB_PREFIX."propaldet WHERE fk_propal = $this->id ;";
@ -904,55 +939,57 @@ class Propal
}
/*
* \brief Information sur l'objet
*
*/
function info($id)
/**
* \brief Information sur l'objet propal
* \param id id de la propale
*/
function info($id)
{
$sql = "SELECT c.rowid, ".$this->db->pdate("datec")." as datec";
$sql .= ", fk_user_valid, fk_user_cloture, fk_user_author";
$sql .= " FROM ".MAIN_DB_PREFIX."propal as c";
$sql .= " WHERE c.rowid = $id";
if ($this->db->query($sql))
{
if ($this->db->num_rows())
{
$obj = $this->db->fetch_object();
$sql = "SELECT c.rowid, ";
$sql.= $this->db->pdate("datec")." as datec, ".$this->db->pdate("date_valid")." as datev, ".$this->db->pdate("date_cloture")." as dateo";
$sql.= ", fk_user_author, fk_user_valid, fk_user_cloture";
$sql.= " FROM ".MAIN_DB_PREFIX."propal as c";
$sql.= " WHERE c.rowid = $id";
if ($this->db->query($sql))
{
if ($this->db->num_rows())
{
$obj = $this->db->fetch_object();
$this->id = $obj->rowid;
$this->date_creation = $obj->datec;
$this->date_validation = $obj->datev;
$this->date_cloture = $obj->dateo;
$this->id = $obj->rowid;
$this->date_creation = $obj->datec;
$cuser = new User($this->db, $obj->fk_user_author);
$cuser->fetch();
$this->user_creation = $cuser;
if ($obj->fk_user_valid)
{
$vuser = new User($this->db, $obj->fk_user_valid);
$vuser->fetch();
$this->user_validation = $vuser;
}
if ($obj->fk_user_cloture)
{
$cluser = new User($this->db, $obj->fk_user_cloture);
$cluser->fetch();
$this->user_cloture = $cluser;
}
}
$this->db->free();
}
else
{
dolibarr_print_error($this->db);
}
$cuser = new User($this->db, $obj->fk_user_author);
$cuser->fetch();
$this->user_creation = $cuser;
if ($obj->fk_user_valid)
{
$vuser = new User($this->db, $obj->fk_user_valid);
$vuser->fetch();
$this->user_validation = $vuser;
}
if ($obj->fk_user_cloture)
{
$cluser = new User($this->db, $obj->fk_user_cloture);
$cluser->fetch();
$this->user_cloture = $cluser;
}
}
$this->db->free();
}
else
{
dolibarr_print_error($this->db);
}
}