diff --git a/htdocs/core/modules/project/pdf/doc_generic_project_odt.modules.php b/htdocs/core/modules/project/pdf/doc_generic_project_odt.modules.php index 0e7ec535ac6..c8cf919742b 100644 --- a/htdocs/core/modules/project/pdf/doc_generic_project_odt.modules.php +++ b/htdocs/core/modules/project/pdf/doc_generic_project_odt.modules.php @@ -841,46 +841,56 @@ class doc_generic_project_odt extends ModelePDFProjects 'propal'=>array( 'title'=>"ListProposalsAssociatedProject", 'class'=>'Propal', - 'test'=>$conf->propal->enabled), + 'table'=>'propal', + 'test'=>$conf->propal->enabled && $user->rights->propale->lire), 'order'=>array( 'title'=>"ListOrdersAssociatedProject", 'class'=>'Commande', - 'test'=>$conf->commande->enabled), + 'table'=>'commande', + 'test'=>$conf->commande->enabled && $user->rights->commande->lire), 'invoice'=>array( 'title'=>"ListInvoicesAssociatedProject", 'class'=>'Facture', - 'test'=>$conf->facture->enabled), + 'table'=>'facture', + 'test'=>$conf->facture->enabled && $user->rights->facture->lire), 'invoice_predefined'=>array( 'title'=>"ListPredefinedInvoicesAssociatedProject", 'class'=>'FactureRec', - 'test'=>$conf->facture->enabled), + 'table'=>'facture_rec', + 'test'=>$conf->facture->enabled && $user->rights->facture->lire), 'order_supplier'=>array( 'title'=>"ListSupplierOrdersAssociatedProject", + 'table'=>'commande_fournisseur', 'class'=>'CommandeFournisseur', - 'test'=>$conf->fournisseur->enabled), + 'test'=>$conf->fournisseur->enabled && $user->rights->fournisseur->commande->lire), 'invoice_supplier'=>array( 'title'=>"ListSupplierInvoicesAssociatedProject", + 'table'=>'facture_fourn', 'class'=>'FactureFournisseur', - 'test'=>$conf->fournisseur->enabled), + 'test'=>$conf->fournisseur->enabled && $user->rights->fournisseur->facture->lire), 'contract'=>array( 'title'=>"ListContractAssociatedProject", 'class'=>'Contrat', - 'test'=>$conf->contrat->enabled), + 'table'=>'contrat', + 'test'=>$conf->contrat->enabled && $user->rights->contrat->lire), 'intervention'=>array( 'title'=>"ListFichinterAssociatedProject", 'class'=>'Fichinter', + 'table'=>'fichinter', 'disableamount'=>1, - 'test'=>$conf->ficheinter->enabled), + 'test'=>$conf->ficheinter->enabled && $user->rights->ficheinter->lire), 'trip'=>array( 'title'=>"ListTripAssociatedProject", 'class'=>'Deplacement', + 'table'=>'deplacement', 'disableamount'=>1, - 'test'=>$conf->deplacement->enabled), + 'test'=>$conf->deplacement->enabled && $user->rights->deplacement->lire), 'agenda'=>array( 'title'=>"ListActionsAssociatedProject", 'class'=>'ActionComm', + 'table'=>'actioncomm', 'disableamount'=>1, - 'test'=>$conf->agenda->enabled) + 'test'=>$conf->agenda->enabled && $user->rights->agenda->allactions->lire) ); //Insert reference @@ -891,11 +901,12 @@ class doc_generic_project_odt extends ModelePDFProjects foreach ($listofreferent as $keyref => $valueref) { $title=$valueref['title']; + $tablename=$valueref['table']; $classname=$valueref['class']; $qualified=$valueref['test']; if ($qualified) { - $elementarray = $object->get_element_list($keyref); + $elementarray = $object->get_element_list($keyref, $tablename); if (count($elementarray)>0 && is_array($elementarray)) { $var=true; diff --git a/htdocs/projet/class/project.class.php b/htdocs/projet/class/project.class.php index 46f70c7ca89..719c7c5f034 100644 --- a/htdocs/projet/class/project.class.php +++ b/htdocs/projet/class/project.class.php @@ -389,33 +389,17 @@ class Project extends CommonObject * Return list of elements for type linked to project * * @param string $type 'propal','order','invoice','order_supplier','invoice_supplier' + * @param string $tablename name of table associated of the type * @return array List of orders linked to project, <0 if error */ - function get_element_list($type) + function get_element_list($type, $tablename) { $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 == 'invoice_predefined') - $sql = "SELECT rowid FROM " . MAIN_DB_PREFIX . "facture_rec 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 ($type == 'contract') - $sql = "SELECT rowid FROM " . MAIN_DB_PREFIX . "contrat WHERE fk_projet=" . $this->id; - if ($type == 'intervention') - $sql = "SELECT rowid FROM " . MAIN_DB_PREFIX . "fichinter WHERE fk_projet=" . $this->id; - if ($type == 'trip') - $sql = "SELECT rowid FROM " . MAIN_DB_PREFIX . "deplacement WHERE fk_projet=" . $this->id; if ($type == 'agenda') $sql = "SELECT id as rowid FROM " . MAIN_DB_PREFIX . "actioncomm WHERE fk_project=" . $this->id; + else + $sql = "SELECT rowid FROM " . MAIN_DB_PREFIX . $tablename." WHERE fk_projet=" . $this->id; if (! $sql) return -1; //print $sql; diff --git a/htdocs/projet/element.php b/htdocs/projet/element.php index 4266d0f745e..fd36808ccdd 100644 --- a/htdocs/projet/element.php +++ b/htdocs/projet/element.php @@ -151,6 +151,7 @@ $listofreferent=array( 'invoice'=>array( 'title'=>"ListInvoicesAssociatedProject", 'class'=>'Facture', + 'margin'=>'add', 'table'=>'facture', 'test'=>$conf->facture->enabled && $user->rights->facture->lire), 'invoice_predefined'=>array( @@ -166,6 +167,7 @@ $listofreferent=array( 'invoice_supplier'=>array( 'title'=>"ListSupplierInvoicesAssociatedProject", 'class'=>'FactureFournisseur', + 'margin'=>'minus', 'table'=>'facture_fourn', 'test'=>$conf->fournisseur->enabled && $user->rights->fournisseur->facture->lire), 'contract'=>array( @@ -183,6 +185,7 @@ $listofreferent=array( 'title'=>"ListTripAssociatedProject", 'class'=>'Deplacement', 'table'=>'deplacement', + 'margin'=>'minus', 'disableamount'=>1, 'test'=>$conf->deplacement->enabled && $user->rights->deplacement->lire), 'agenda'=>array( @@ -237,7 +240,7 @@ foreach ($listofreferent as $key => $value) if (empty($value['disableamount'])) print '
| '.$langs->trans("Element").' | '; +print ''.$langs->trans("Number").' | '; +print ''.$langs->trans("AmountHT").' | '; +print ''.$langs->trans("AmountTTC").' | '; +print '
| '.$classname.' | '; + print ''.$i.' | '; + print ''.price($total_ht).' | '; + print ''.price($total_ttc).' | '; + print '
| '.$langs->trans("Total").' | '; +print ''.price($margin_ht).' | '; +print ''.price($margin_ttc).' | '; +print '|