diff --git a/htdocs/commande/fiche.php b/htdocs/commande/fiche.php index 3f22559fffb..1f0f9d1c948 100644 --- a/htdocs/commande/fiche.php +++ b/htdocs/commande/fiche.php @@ -1850,7 +1850,7 @@ else $var=!$var; print ''; print ''.img_object($langs->trans('ShowBill'),'bill').' '.$objp->facnumber.''; - print ''.dolibarr_print_date($objp->df).''; + print ''.dolibarr_print_date($objp->df,'day').''; print ''.$objp->total_ttc.''; $i++; } @@ -1894,7 +1894,7 @@ else $var=!$var; print ''; print ''.img_object($langs->trans('ShowTask'),'task').' '.$objp->id.''; - print ''.dolibarr_print_date($objp->da)."\n"; + print ''.dolibarr_print_date($objp->da,'day')."\n"; print ''.stripslashes($objp->label).''; $authoract = new User($db); $authoract->id = $objp->fk_user_author; diff --git a/htdocs/fourn/commande/fiche.php b/htdocs/fourn/commande/fiche.php index 7685059aa2b..6913ba61b00 100644 --- a/htdocs/fourn/commande/fiche.php +++ b/htdocs/fourn/commande/fiche.php @@ -398,27 +398,31 @@ if ($action=='remove_file') */ if ($_GET["action"] == 'create') { + $fourn = new Fournisseur($db); + $fourn->fetch($_GET["socid"]); - $fourn = new Fournisseur($db); - $fourn->fetch($_GET["socid"]); - $commande->modelpdf = 'muscadet'; //test - - if ($fourn->create_commande($user) > 0) - { - $idc = $fourn->single_open_commande; - - if ($comclientid != '') + $db->begin(); + + $orderid=$fourn->create_commande($user); + if ($orderid > 0) { - $fourn->updateFromCommandeClient($user,$idc,$comclientid); - } + $idc = $fourn->single_open_commande; - Header("Location:fiche.php?id=".$idc); - exit; - } - else - { - $mesg=$fourn->error; - } + if ($comclientid != '') + { + $fourn->updateFromCommandeClient($user,$idc,$comclientid); + + } + + $_GET['id']=$orderid; + $_GET['action']='edit'; + $db->commit(); + } + else + { + $db->rollback(); + $mesg=$fourn->error; + } } diff --git a/htdocs/fourn/facture/fiche.php b/htdocs/fourn/facture/fiche.php index 0ff94262eca..816ca880cb1 100644 --- a/htdocs/fourn/facture/fiche.php +++ b/htdocs/fourn/facture/fiche.php @@ -31,6 +31,7 @@ require_once('./pre.inc.php'); require_once(DOL_DOCUMENT_ROOT.'/fourn/facture/paiementfourn.class.php'); require_once(DOL_DOCUMENT_ROOT.'/lib/fourn.lib.php'); require_once(DOL_DOCUMENT_ROOT.'/product.class.php'); +if ($conf->projet->enabled) require_once(DOL_DOCUMENT_ROOT.'/project.class.php'); if (!$user->rights->fournisseur->facture->lire) @@ -298,7 +299,12 @@ if ($_GET['action'] == 'add_ligne') $_GET['action'] = ''; } - +if ($_POST['action'] == 'classin') +{ + $facture = new FactureFournisseur($db,'',$_GET['facid']); + $facture->fetch($_GET['facid']); + $facture->setProject($_POST['projetid']); +} /* * Affichage page @@ -602,6 +608,37 @@ else print ''.$langs->trans('AmountVAT').''.price($fac->total_tva).''.$langs->trans('Currency'.$conf->monnaie).''; print ''.$langs->trans('AmountTTC').''.price($fac->total_ttc).''.$langs->trans('Currency'.$conf->monnaie).''; + // Project + if ($conf->projet->enabled) + { + $langs->load('projects'); + print ''; + print ''; + + print ''; + if ($_GET['action'] != 'classer') + { + print ''; + } + print '
'; + print $langs->trans('Project'); + print 'id.'">'; + print img_edit($langs->trans('SetProject'),1); + print '
'; + + print ''; + if ($_GET['action'] == 'classer') + { + $html->form_project($_SERVER['PHP_SELF'].'?facid='.$fac->id,$fac->socid,$fac->fk_project,'projetid'); + } + else + { + $html->form_project($_SERVER['PHP_SELF'].'?facid='.$fac->id,$fac->socid,$fac->fk_project,'none'); + } + print ''; + print ''; + } + print ''; print ''; diff --git a/htdocs/fourn/fournisseur.commande.class.php b/htdocs/fourn/fournisseur.commande.class.php index 1a49b9299f7..ddebf8cccbf 100644 --- a/htdocs/fourn/fournisseur.commande.class.php +++ b/htdocs/fourn/fournisseur.commande.class.php @@ -75,7 +75,7 @@ class CommandeFournisseur extends Commande function fetch($id) { $sql = "SELECT c.rowid, c.date_creation, c.ref, c.fk_soc, c.fk_user_author, c.fk_statut, c.amount_ht, c.total_ht, c.total_ttc, c.tva,"; - $sql .= " ".$this->db->pdate("c.date_commande")." as date_commande, c.fk_projet, c.remise_percent, c.source, c.fk_methode_commande,"; + $sql .= " ".$this->db->pdate("c.date_commande")." as date_commande, c.fk_projet as fk_project, c.remise_percent, c.source, c.fk_methode_commande,"; $sql .= " c.note, c.note_public, c.model_pdf,"; $sql .= " cm.libelle as methode_commande"; $sql .= " FROM ".MAIN_DB_PREFIX."commande_fournisseur as c"; @@ -104,7 +104,8 @@ class CommandeFournisseur extends Commande $this->source = $obj->source; $this->facturee = $obj->facture; - $this->projet_id = $obj->fk_projet; + $this->fk_project = $obj->fk_project; + $this->projet_id = $obj->fk_project; // For compatibility with old code $this->note = $obj->note; $this->note_public = $obj->note_public; $this->modelpdf = $obj->model_pdf; @@ -600,64 +601,64 @@ class CommandeFournisseur extends Commande return $result ; } - /** - * \brief Créé la commande au statut brouillon - * \param user Utilisateur qui crée - * \return int <0 si ko, >0 si ok - */ - function create($user) - { - global $langs,$conf; - - dolibarr_syslog("CommandeFournisseur::Create soc id=".$this->socid); + /** + * \brief Créé la commande au statut brouillon + * \param user Utilisateur qui crée + * \return int <0 si ko, >0 si ok + */ + function create($user) + { + global $langs,$conf; + + dolibarr_syslog("CommandeFournisseur::Create soc id=".$this->socid); - $this->db->begin(); - - /* On positionne en mode brouillon la commande */ - $this->brouillon = 1; - - $sql = "INSERT INTO ".MAIN_DB_PREFIX."commande_fournisseur (fk_soc, date_creation, fk_user_author, fk_statut) "; - $sql .= " VALUES (".$this->socid.", now(), ".$user->id.",0)"; - - if ( $this->db->query($sql) ) - { - $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."commande_fournisseur"); - - $sql = "UPDATE ".MAIN_DB_PREFIX."commande_fournisseur"; - $sql.= " SET ref='(PROV".$this->id.")'"; - $sql.= " WHERE rowid=".$this->id; - if ($this->db->query($sql)) - { - // On logue creation pour historique - $this->log($user, 0, time()); - - // Appel des triggers - include_once(DOL_DOCUMENT_ROOT . "/interfaces.class.php"); - $interface=new Interfaces($this->db); - $result=$interface->run_triggers('ORDER_SUPPLIER_CREATE',$this,$user,$langs,$conf); - if ($result < 0) { $error++; $this->errors=$interface->errors; } - // Fin appel triggers + $this->db->begin(); + + /* On positionne en mode brouillon la commande */ + $this->brouillon = 1; + + $sql = "INSERT INTO ".MAIN_DB_PREFIX."commande_fournisseur (ref, fk_soc, date_creation, fk_user_author, fk_statut, source) "; + $sql .= " VALUES ('',".$this->socid.", now(), ".$user->id.",0,0)"; + + if ( $this->db->query($sql) ) + { + $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."commande_fournisseur"); + + $sql = "UPDATE ".MAIN_DB_PREFIX."commande_fournisseur"; + $sql.= " SET ref='(PROV".$this->id.")'"; + $sql.= " WHERE rowid=".$this->id; + if ($this->db->query($sql)) + { + // On logue creation pour historique + $this->log($user, 0, time()); + + // Appel des triggers + include_once(DOL_DOCUMENT_ROOT . "/interfaces.class.php"); + $interface=new Interfaces($this->db); + $result=$interface->run_triggers('ORDER_SUPPLIER_CREATE',$this,$user,$langs,$conf); + if ($result < 0) { $error++; $this->errors=$interface->errors; } + // Fin appel triggers - dolibarr_syslog("CommandeFournisseur::Create : Success"); - $this->db->commit(); - return 1; - } - else - { - $this->error=$this->db->error()." - ".$sql; - dolibarr_syslog("CommandeFournisseur::Create: Failed -2 - ".$this->error); - $this->db->rollback(); - return -2; - } - } - else - { - $this->error=$this->db->error()." - ".$sql; - dolibarr_syslog("CommandeFournisseur::Create: Failed -1 - ".$this->error); - $this->db->rollback(); - return -1; - } - } + dolibarr_syslog("CommandeFournisseur::Create : Success"); + $this->db->commit(); + return 1; + } + else + { + $this->error=$this->db->error()." - ".$sql; + dolibarr_syslog("CommandeFournisseur::Create: Failed -2 - ".$this->error); + $this->db->rollback(); + return -2; + } + } + else + { + $this->error=$this->db->error()." - ".$sql; + dolibarr_syslog("CommandeFournisseur::Create: Failed -1 - ".$this->error); + $this->db->rollback(); + return -1; + } + } /** * \brief Ajoute une ligne de commande diff --git a/htdocs/fourn/fournisseur.facture.class.php b/htdocs/fourn/fournisseur.facture.class.php index 1e3b601e63e..36826a06cf7 100644 --- a/htdocs/fourn/fournisseur.facture.class.php +++ b/htdocs/fourn/fournisseur.facture.class.php @@ -176,7 +176,7 @@ class FactureFournisseur extends Facture { $sql = 'SELECT libelle, facnumber, amount, remise, '.$this->db->pdate(datef).'as df,'; $sql.= ' total_ht, total_tva, total_ttc, fk_user_author,'; - $sql.= ' fk_statut, paye, f.note, f.note_public,'; + $sql.= ' fk_statut, fk_projet as fk_project, paye, f.note, f.note_public,'; $sql.= ' '.$this->db->pdate('date_lim_reglement').'as de,'; $sql.= ' s.nom as socnom, s.rowid as socid'; $sql.= ' FROM '.MAIN_DB_PREFIX.'facture_fourn as f,'.MAIN_DB_PREFIX.'societe as s'; @@ -211,6 +211,8 @@ class FactureFournisseur extends Facture $this->statut = $obj->fk_statut; $this->paye = $obj->paye; + $this->fk_project = $obj->fk_project; + $this->socnom = $obj->socnom; $this->note = $obj->note; $this->note_public = $obj->note_public; diff --git a/htdocs/langs/en_US/suppliers.lang b/htdocs/langs/en_US/suppliers.lang index ac46f820cc7..3338db30a00 100644 --- a/htdocs/langs/en_US/suppliers.lang +++ b/htdocs/langs/en_US/suppliers.lang @@ -26,4 +26,8 @@ ApproveThisOrder=Approve this order ConfirmApproveThisOrder=Are you sure you want to approve this order ? DenyingThisOrder=Denying this order ConfirmDenyingThisOrder=Are you sure you want to deny this order ? -ConfirmCancelThisOrder=Are you sure you want to cancel this order ? \ No newline at end of file +ConfirmCancelThisOrder=Are you sure you want to cancel this order ? +AddCustomerOrder=Create customer order +AddCustomerInvoice=Create customer invoice +AddSupplierOrder=Create supplier order +AddSupplierInvoice=Create supplier invoice \ No newline at end of file diff --git a/htdocs/langs/fr_FR/projects.lang b/htdocs/langs/fr_FR/projects.lang index cff69b56b60..08c87980da2 100755 --- a/htdocs/langs/fr_FR/projects.lang +++ b/htdocs/langs/fr_FR/projects.lang @@ -22,6 +22,8 @@ AddDuration=Ajouter la dur Activity=Activité MyActivity=Mon activité DurationEffective=Durée effective -ListProposalsAssociatedProject=Listes des propositions commerciales associées au projet -ListOrdersAssociatedProject=Listes des commandes associées au projet -ListInvoicesAssociatedProject=Listes des factures associées au projet \ No newline at end of file +ListProposalsAssociatedProject=Liste des propositions commerciales associées au projet +ListOrdersAssociatedProject=Liste des commandes associées au projet +ListInvoicesAssociatedProject=Liste des factures associées au projet +ListSupplierOrdersAssociatedProject=Liste des commandes fournisseurs associées au projet +ListSupplierInvoicesAssociatedProject=Liste des factures fournisseur associées au projet \ No newline at end of file diff --git a/htdocs/langs/fr_FR/suppliers.lang b/htdocs/langs/fr_FR/suppliers.lang index bb08b294f90..2e92269e4e8 100644 --- a/htdocs/langs/fr_FR/suppliers.lang +++ b/htdocs/langs/fr_FR/suppliers.lang @@ -26,4 +26,8 @@ ApproveThisOrder=Approuver la commande ConfirmApproveThisOrder=Etes-vous sûr de vouloir approuver cette commande ? DenyingThisOrder=Refuser la commande ConfirmDenyingThisOrder=Etes-vous sûr de vouloir refuser cette commande ? -ConfirmCancelThisOrder=Etes-vous sûr de vouloir annuler cette commande ? \ No newline at end of file +ConfirmCancelThisOrder=Etes-vous sûr de vouloir annuler cette commande ? +AddCustomerOrder=Créer commande client +AddCustomerInvoice=Créer facture/avoir client +AddSupplierOrder=Créer commande fournisseur +AddSupplierInvoice=Créer facture fournisseur \ No newline at end of file diff --git a/htdocs/lib/product.lib.php b/htdocs/lib/product.lib.php index e99fb4c599b..c9f82ee1974 100644 --- a/htdocs/lib/product.lib.php +++ b/htdocs/lib/product.lib.php @@ -16,14 +16,12 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * or see http://www.gnu.org/ - * - * $Id$ */ /** \file htdocs/lib/product.lib.php \brief Ensemble de fonctions de base pour le module produit et service - \version $Revision$ + \version $Id$ */ function product_prepare_head($product, $user) diff --git a/htdocs/lib/project.lib.php b/htdocs/lib/project.lib.php index c8bcd6c1318..d0b806ab619 100644 --- a/htdocs/lib/project.lib.php +++ b/htdocs/lib/project.lib.php @@ -15,15 +15,13 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * or see http://www.gnu.org/ - * - * $Id$ */ /** \file htdocs/lib/project.lib.php \brief Ensemble de fonctions de base pour le module projet \ingroup societe - \version $Revision$ + \version $Id$ */ function project_prepare_head($objsoc) @@ -42,30 +40,11 @@ function project_prepare_head($objsoc) $head[$h][2] = 'tasks'; $h++; - if ($conf->propal->enabled) + if ($conf->propal->enabled || $conf->commande->enabled || $conf->facture->enabled) { - $langs->load("propal"); - $head[$h][0] = DOL_URL_ROOT.'/projet/propal.php?id='.$objsoc->id; - $head[$h][1] = $langs->trans("Proposals"); - $head[$h][2] = 'propal'; - $h++; - } - - if ($conf->commande->enabled) - { - $langs->load("orders"); - $head[$h][0] = DOL_URL_ROOT.'/projet/commandes.php?id='.$objsoc->id; - $head[$h][1] = $langs->trans("Orders"); - $head[$h][2] = 'order'; - $h++; - } - - if ($conf->facture->enabled) - { - $langs->load("bills"); - $head[$h][0] = DOL_URL_ROOT.'/projet/facture.php?id='.$objsoc->id; - $head[$h][1] = $langs->trans("Invoices"); - $head[$h][2] = 'invoice'; + $head[$h][0] = DOL_URL_ROOT.'/projet/element.php?id='.$objsoc->id; + $head[$h][1] = $langs->trans("Referers"); + $head[$h][2] = 'element'; $h++; } diff --git a/htdocs/project.class.php b/htdocs/project.class.php index ca08058eb55..24220c2a3a0 100644 --- a/htdocs/project.class.php +++ b/htdocs/project.class.php @@ -121,7 +121,7 @@ class Project extends CommonObject /* * \brief Charge objet projet depuis la base - * \param rowid id du projet � charger + * \param rowid id du projet a charger */ function fetch($rowid) { @@ -163,45 +163,6 @@ class Project extends CommonObject } } - - /* - * - * - * - */ - function get_propal_list() - { - $propales = array(); - $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."propal WHERE fk_projet=$this->id;"; - - if ($this->db->query($sql) ) - { - $nump = $this->db->num_rows(); - if ($nump) - { - $i = 0; - while ($i < $nump) - { - $obj = $this->db->fetch_object(); - - $propales[$i] = $obj->rowid; - - $i++; - } - $this->db->free(); - /* - * Retourne un tableau contenant la liste des propales associees - */ - return $propales; - } - } - else - { - print $this->db->error() . '
' .$sql; - } - } - - /* * * @@ -241,53 +202,25 @@ class Project extends CommonObject } } - /* - * - * - * - */ - function get_facture_list() - { - $factures = array(); - $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."facture WHERE fk_projet=$this->id;"; - - $result=$this->db->query($sql); - if ($result) - { - $nump = $this->db->num_rows($result); - if ($nump) - { - $i = 0; - while ($i < $nump) - { - $obj = $this->db->fetch_object($result); - - $factures[$i] = $obj->rowid; - - $i++; - } - $this->db->free($result); - /* - * Retourne un tableau contenant la liste des factures associees - */ - return $factures; - } - } - else - { - dolibarr_print_error($this->db); - } - } + /** - * Renvoie la liste des commande associ�es au projet - * - * + * \brief Return list of elements for type linked to project + * \param type 'propal','order','invoice','order_supplier','invoice_supplier' + * \return array List of orders linked to project, <0 if error */ - function get_commande_list() + function get_element_list($type) { - $commandes = array(); - $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."commande WHERE fk_projet=$this->id;"; + $elements = array(); + $sql=''; + if ($type == 'propal') $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."propal WHERE fk_projet=".$this->id; + if ($type == 'order') $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."commande WHERE fk_projet=".$this->id; + if ($type == 'invoice') $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."facture WHERE fk_projet=".$this->id; + if ($type == 'order_supplier') $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."commande_fournisseur WHERE fk_projet=".$this->id; + if ($type == 'invoice_supplier') $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."facture_fourn WHERE fk_projet=".$this->id; + if (! $sql) return -1; + + dolibarr_syslog("Project::get_element_list sql=".$sql); $result=$this->db->query($sql); if ($result) { @@ -299,15 +232,14 @@ class Project extends CommonObject { $obj = $this->db->fetch_object($result); - $commandes[$i] = $obj->rowid; + $elements[$i] = $obj->rowid; $i++; } $this->db->free($result); - /* - * Retourne un tableau contenant la liste des commandes associees - */ - return $commandes; + + /* Return array */ + return $elements; } } else @@ -316,11 +248,10 @@ class Project extends CommonObject } } - /* + /** * \brief Supprime le projet dans la base * \param Utilisateur */ - function delete($user) { @@ -338,7 +269,7 @@ class Project extends CommonObject } } - /* + /** * \brief Cr�e une tache dans le projet * \param user Id utilisateur qui cr�e * \param title titre de la t�che @@ -395,8 +326,8 @@ class Project extends CommonObject } - /* - * \brief Cr�e une tache dans le projet + /** + * \brief Cree une tache dans le projet * \param user Id utilisateur qui cr�e * \param title titre de la t�che * \param parent tache parente @@ -477,7 +408,7 @@ class Project extends CommonObject { $tasks = array(); - /* Liste des t�ches dans $tasks */ + /* Liste des taches dans $tasks */ $sql = "SELECT t.rowid, t.title, t.fk_task_parent, t.duration_effective"; $sql .= " FROM ".MAIN_DB_PREFIX."projet_task as t"; diff --git a/htdocs/projet/commandes.php b/htdocs/projet/commandes.php deleted file mode 100644 index d1391d72a07..00000000000 --- a/htdocs/projet/commandes.php +++ /dev/null @@ -1,128 +0,0 @@ - - * Copyright (C) 2004-2006 Laurent Destailleur - * Copyright (C) 2005-2007 Regis Houssin - * - * 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 2 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, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -/** - \file htdocs/projet/commandes.php - \ingroup projet commande - \brief Page des commandes par projet - \version $Id$ -*/ - -require("./pre.inc.php"); -require_once(DOL_DOCUMENT_ROOT."/propal.class.php"); -require_once(DOL_DOCUMENT_ROOT."/facture.class.php"); -require_once(DOL_DOCUMENT_ROOT."/commande/commande.class.php"); -require_once(DOL_DOCUMENT_ROOT."/lib/project.lib.php"); - -$langs->load("projects"); -$langs->load("companies"); -$langs->load("orders"); - -// Sécurité accés client -$projetid=''; -if ($_GET["id"]) { $projetid=$_GET["id"]; } - -if ($projetid == '') accessforbidden(); - -// Security check -if ($user->societe_id) $socid=$user->societe_id; -$result = restrictedArea($user, 'projet', $projetid); - - -llxHeader("","../"); - -$projet = new Project($db); -$projet->fetch($_GET["id"]); -$projet->societe->fetch($projet->societe->id); - -$head=project_prepare_head($projet); -dolibarr_fiche_head($head, 'order', $langs->trans("Project")); - - - -print ''; - -print ''; -print ''; - -print ''; - -print '
'.$langs->trans("Ref").''.$projet->ref.'
'.$langs->trans("Label").''.$projet->title.'
'.$langs->trans("Company").''.$projet->societe->getNomUrl(1).'
'; - -print ''; - -/* - * Barre d'action - * - */ - print '
'; - - if ($conf->commande->enabled && $user->rights->commande->creer) - { - $langs->load("orders"); - print ''.$langs->trans("AddOrder").''; - } - print '
'; - -/* - * Commandes - * - */ -$commandes = $projet->get_commande_list(); -$total = 0 ; -if (sizeof($commandes)>0 && is_array($commandes)) -{ - print '
'; - - print_titre($langs->trans("ListProposalsAssociatedProject")); - print ''; - - print ''; - print ''; - - for ($i = 0; $ifetch($commandes[$i]); - - $var=!$var; - print ""; - print "\n"; - print ''; - print ''; - - $total = $total + $commande->total_ht; - } - - print ''; - print ''; - print ''; - print "
'.$langs->trans("Ref").'Date'.$langs->trans("Amount").' 
id\">$commande->ref'.dolibarr_print_date($commande->date,'day').''.price($commande->total_ht).' 
'.$i.' '.$langs->trans("Orders").''.$langs->trans("TotalHT").': '.price($total).''.$langs->trans("Currency".$conf->monnaie).'
"; -} - - -// Juste pour éviter bug IE qui réorganise mal div précédents si celui-ci absent -print '
'; -print '
'; - -$db->close(); - -llxFooter('$Date$ - $Revision$'); -?> diff --git a/htdocs/projet/element.php b/htdocs/projet/element.php new file mode 100644 index 00000000000..3289b88eb68 --- /dev/null +++ b/htdocs/projet/element.php @@ -0,0 +1,191 @@ + + * Copyright (C) 2004-2008 Laurent Destailleur + * Copyright (C) 2005-2007 Regis Houssin + * + * 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 2 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, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +/** + \file htdocs/projet/element.php + \ingroup projet facture + \brief Page des elements par projet + \version $Id$ +*/ + +require("./pre.inc.php"); +require_once(DOL_DOCUMENT_ROOT."/propal.class.php"); +require_once(DOL_DOCUMENT_ROOT."/facture.class.php"); +require_once(DOL_DOCUMENT_ROOT."/commande/commande.class.php"); +require_once(DOL_DOCUMENT_ROOT."/fourn/fournisseur.facture.class.php"); +require_once(DOL_DOCUMENT_ROOT."/fourn/fournisseur.commande.class.php"); +require_once(DOL_DOCUMENT_ROOT."/lib/project.lib.php"); + +$langs->load("projects"); +$langs->load("companies"); +$langs->load("suppliers"); +if ($conf->facture->enabled) $langs->load("bills"); +if ($conf->commande->enabled) $langs->load("orders"); +if ($conf->propal->enabled) $langs->load("propal"); + +// Sécurité accés client +$projetid=''; +if ($_GET["id"]) { $projetid=$_GET["id"]; } + +if ($projetid == '') accessforbidden(); + +// Security check +if ($user->societe_id) $socid=$user->societe_id; +$result = restrictedArea($user, 'projet', $projetid); + + +/* +* View +*/ + +llxHeader("","../"); + +$projet = new Project($db); +$projet->fetch($_GET["id"]); +$projet->societe->fetch($projet->societe->id); + +$head=project_prepare_head($projet); +dolibarr_fiche_head($head, 'element', $langs->trans("Project")); + + +print ''; + +print ''; +print ''; + +print ''; + +print '
'.$langs->trans("Ref").''.$projet->ref.'
'.$langs->trans("Label").''.$projet->title.'
'.$langs->trans("Company").''.$projet->societe->getNomUrl(1,'compta').'
'; + +print ''; + + +/* + * Factures + */ +$listofreferent=array( +'propal'=>array( + 'title'=>"ListProposalsAssociatedProject", + 'class'=>'Propal', + 'test'=>$conf->propal->enabled), +'order'=>array( + 'title'=>"ListOrdersAssociatedProject", + 'class'=>'Commande', + 'test'=>$conf->commande->enabled), +'invoice'=>array( + 'title'=>"ListInvoicesAssociatedProject", + 'class'=>'Facture', + 'test'=>$conf->facture->enabled), +'order_supplier'=>array( + 'title'=>"ListSupplierOrdersAssociatedProject", + 'class'=>'CommandeFournisseur', + 'test'=>$conf->fournisseur->enabled), +'invoice_supplier'=>array( + 'title'=>"ListSupplierInvoicesAssociatedProject", + 'class'=>'FactureFournisseur', + 'test'=>$conf->fournisseur->enabled) +); + +foreach ($listofreferent as $key => $value) +{ + $title=$value['title']; + $class=$value['class']; + $qualified=$value['test']; + if ($qualified) + { + print '
'; + + print_titre($langs->trans($title)); + print ''; + + print ''; + print ''; + $elementarray = $projet->get_element_list($key); + if (sizeof($elementarray)>0 && is_array($elementarray)) + { + $var=true; + $total = 0; + for ($i = 0; $ifetch($elementarray[$i]); + + $var=!$var; + print ""; + print "\n"; + $date=$element->date; + if (empty($date)) $date=$element->datep; + print ''; + print ''; + + $total = $total + $element->total_ht; + } + + print ''; + print ''; + print ''; + } + print "
'.$langs->trans("Ref").''.$langs->trans("Date").''.$langs->trans("Amount").' 
"; + print $element->getNomUrl(1); + print "'.dolibarr_print_date($date,'day').''.price($element->total_ht).' 
'.$i.' '.$langs->trans("Bills").''.$langs->trans("TotalHT").' : '.price($total).''.$langs->trans("Currency".$conf->monnaie).'
"; + + /* + * Barre d'action + */ + print '
'; + + if ($projet->societe->prospect || $projet->societe->client) + { + if ($key == 'propal' && $conf->propal->enabled && $user->rights->propale->creer) + { + print ''.$langs->trans("AddProp").''; + } + if ($key == 'order' && $conf->commande->enabled && $user->rights->commande->creer) + { + print ''.$langs->trans("AddCustomerOrder").''; + } + if ($key == 'invoice' && $conf->facture->enabled && $user->rights->facture->creer) + { + print ''.$langs->trans("AddCustomerInvoice").''; + } + } + if ($projet->societe->fournisseur) + { + if ($key == 'order_supplier' && $conf->fournisseur->enabled && $user->rights->fournisseur->commande->creer) + { + print ''.$langs->trans("AddSupplierInvoice").''; + } + if ($key == 'invoice_supplier' && $conf->fournisseur->enabled && $user->rights->fournisseur->facture->creer) + { + print ''.$langs->trans("AddSupplierOrder").''; + } + } + print '
'; + } +} + +// Juste pour éviter bug IE qui réorganise mal div précédents si celui-ci absent +print '
'; +print '
'; + +$db->close(); + +llxFooter('$Date$ - $Revision$'); +?> diff --git a/htdocs/projet/facture.php b/htdocs/projet/facture.php deleted file mode 100644 index d400ace1af4..00000000000 --- a/htdocs/projet/facture.php +++ /dev/null @@ -1,126 +0,0 @@ - - * Copyright (C) 2004-2006 Laurent Destailleur - * Copyright (C) 2005-2007 Regis Houssin - * - * 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 2 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, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -/** - \file htdocs/projet/facture.php - \ingroup projet facture - \brief Page des factures par projet - \version $Id$ -*/ - -require("./pre.inc.php"); -require_once(DOL_DOCUMENT_ROOT."/propal.class.php"); -require_once(DOL_DOCUMENT_ROOT."/facture.class.php"); -require_once(DOL_DOCUMENT_ROOT."/commande/commande.class.php"); -require_once(DOL_DOCUMENT_ROOT."/lib/project.lib.php"); - -$langs->load("projects"); -$langs->load("companies"); -$langs->load("bills"); - -// Sécurité accés client -$projetid=''; -if ($_GET["id"]) { $projetid=$_GET["id"]; } - -if ($projetid == '') accessforbidden(); - -// Security check -if ($user->societe_id) $socid=$user->societe_id; -$result = restrictedArea($user, 'projet', $projetid); - - - -llxHeader("","../"); - -$projet = new Project($db); -$projet->fetch($_GET["id"]); -$projet->societe->fetch($projet->societe->id); - -$head=project_prepare_head($projet); -dolibarr_fiche_head($head, 'invoice', $langs->trans("Project")); - - -print ''; - -print ''; -print ''; - -print ''; - -print '
'.$langs->trans("Ref").''.$projet->ref.'
'.$langs->trans("Label").''.$projet->title.'
'.$langs->trans("Company").''.$projet->societe->getNomUrl(1,'compta').'
'; - -print ''; - -/* - * Barre d'action - * - */ - print '
'; - - if ($conf->facture->enabled && $user->rights->facture->creer) - { - print ''.$langs->trans("AddBill").''; - } - print '
'; - -/* - * Factures - */ -$factures = $projet->get_facture_list(); -$total = 0; -if (sizeof($factures)>0 && is_array($factures)) -{ - print '
'; - - print_titre($langs->trans("ListInvoicesAssociatedProject")); - print ''; - - print ''; - print ''; - - for ($i = 0; $ifetch($factures[$i]); - - $var=!$var; - print ""; - print "\n"; - print ''; - print ''; - - $total = $total + $facture->total_ht; - } - - print ''; - print ''; - print ''; - print "
'.$langs->trans("Ref").''.$langs->trans("Date").''.$langs->trans("Amount").' 
id\">$facture->ref'.dolibarr_print_date($facture->date,'day').''.price($facture->total_ht).' 
'.$i.' '.$langs->trans("Bills").''.$langs->trans("TotalHT").' : '.price($total).''.$langs->trans("Currency".$conf->monnaie).'
"; -} - - -// Juste pour éviter bug IE qui réorganise mal div précédents si celui-ci absent -print '
'; -print '
'; - -$db->close(); - -llxFooter('$Date$ - $Revision$'); -?> diff --git a/htdocs/projet/propal.php b/htdocs/projet/propal.php deleted file mode 100644 index fe9829f1388..00000000000 --- a/htdocs/projet/propal.php +++ /dev/null @@ -1,120 +0,0 @@ - - * Copyright (C) 2004-2006 Laurent Destailleur - * Copyright (C) 2005-2007 Regis Houssin - * - * 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 2 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, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -/** - \file htdocs/projet/propal.php - \ingroup projet propale - \brief Page des propositions commerciales par projet - \version $Id$ -*/ - -require("./pre.inc.php"); -require_once(DOL_DOCUMENT_ROOT."/propal.class.php"); -require_once(DOL_DOCUMENT_ROOT."/facture.class.php"); -require_once(DOL_DOCUMENT_ROOT."/commande/commande.class.php"); -require_once(DOL_DOCUMENT_ROOT."/lib/project.lib.php"); - -$langs->load("projects"); -$langs->load("companies"); -$langs->load("propal"); - -// Sécurité accés client -$projetid=''; -if ($_GET["id"]) { $projetid=$_GET["id"]; } - -if ($projetid == '') accessforbidden(); - -// Security check -if ($user->societe_id) $socid=$user->societe_id; -$result = restrictedArea($user, 'projet', $projetid); - - - -llxHeader("","../"); - -$projet = new Project($db); -$projet->fetch($_GET["id"]); -$projet->societe->fetch($projet->societe->id); - - -$head=project_prepare_head($projet); -dolibarr_fiche_head($head, 'propal', $langs->trans("Project")); - - -$propales = array(); - -print ''; -print ''; -print ''; -print ''; -print '
'.$langs->trans("Ref").''.$projet->ref.'
'.$langs->trans("Label").''.$projet->title.'
'.$langs->trans("Company").''.$projet->societe->getNomUrl(1).'
'; - -print ''; - -/* - * Barre d'action - * - */ - print '
'; - - if ($conf->propal->enabled && $user->rights->propale->creer) - { - $langs->load("propal"); - print ''.$langs->trans("AddProp").''; - } - print '
'; - -$propales = $projet->get_propal_list(); - -if (sizeof($propales)>0 && is_array($propales)) -{ - print '
'; - - print_titre($langs->trans("ListProposalsAssociatedProject")); - print ''; - - print ''; - print ''; - - for ($i = 0; $ifetch($propales[$i]); - - $var=!$var; - print ""; - print "\n"; - - print ''; - - print ''; - $total = $total + $propale->total_ht; - } - - print ''; - print ''; - print '
'.$langs->trans("Ref").''.$langs->trans("Date").''.$langs->trans("Amount").' 
id\">$propale->ref'.dolibarr_print_date($propale->datep).''.price($propale->total_ht).' 
'.$i.' '.$langs->trans("Proposal").''.$langs->trans("TotalHT").': '.price($total).''.$langs->trans("Currency".$conf->monnaie).'
'; -} - - -$db->close(); - -llxFooter('$Date$ - $Revision$'); -?>