commit
41e300626b
@ -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;
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -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 '<td align="right" width="120">'.$langs->trans("AmountTTC").'</td>';
|
||||
print '<td align="right" width="200">'.$langs->trans("Status").'</td>';
|
||||
print '</tr>';
|
||||
$elementarray = $project->get_element_list($key);
|
||||
$elementarray = $project->get_element_list($key, $tablename);
|
||||
if (count($elementarray)>0 && is_array($elementarray))
|
||||
{
|
||||
$var=true;
|
||||
@ -334,6 +337,74 @@ foreach ($listofreferent as $key => $value)
|
||||
}
|
||||
}
|
||||
|
||||
// Margin display of the project
|
||||
print_titre("Margin");
|
||||
print '<table class="noborder">';
|
||||
print '<tr class="liste_titre">';
|
||||
print '<td align="left" width="200">'.$langs->trans("Element").'</td>';
|
||||
print '<td align="right" width="100">'.$langs->trans("Number").'</td>';
|
||||
print '<td align="right" width="100">'.$langs->trans("AmountHT").'</td>';
|
||||
print '<td align="right" width="100">'.$langs->trans("AmountTTC").'</td>';
|
||||
print '</tr>';
|
||||
|
||||
|
||||
foreach ($listofreferent as $key => $value)
|
||||
{
|
||||
$title=$value['title'];
|
||||
$classname=$value['class'];
|
||||
$tablename=$value['table'];
|
||||
$qualified=$value['test'];
|
||||
$margin = $value['margin'];
|
||||
if (isset($margin))
|
||||
{
|
||||
$elementarray = $project->get_element_list($key, $tablename);
|
||||
if (count($elementarray)>0 && is_array($elementarray))
|
||||
{
|
||||
$var=true;
|
||||
$total_ht = 0;
|
||||
$total_ttc = 0;
|
||||
$num=count($elementarray);
|
||||
for ($i = 0; $i < $num; $i++)
|
||||
{
|
||||
$element = new $classname($db);
|
||||
$element->fetch($elementarray[$i]);
|
||||
$element->fetch_thirdparty();
|
||||
//print $classname;
|
||||
|
||||
$total_ht = $total_ht + $element->total_ht;
|
||||
$total_ttc = $total_ttc + $element->total_ttc;
|
||||
}
|
||||
|
||||
print '<tr >';
|
||||
print '<td align="left" >'.$classname.'</td>';
|
||||
print '<td align="right">'.$i.'</td>';
|
||||
print '<td align="right">'.price($total_ht).'</td>';
|
||||
print '<td align="right">'.price($total_ttc).'</td>';
|
||||
print '</tr>';
|
||||
if ($margin=="add")
|
||||
{
|
||||
$margin_ht+= $total_ht;
|
||||
$margin_ttc+= $total_ttc;
|
||||
}
|
||||
else
|
||||
{
|
||||
$margin_ht-= $total_ht;
|
||||
$margin_ttc-= $total_ttc;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
// and the margin amount total
|
||||
print '<tr class="liste_total">';
|
||||
print '<td align="right" colspan=2 >'.$langs->trans("Total").'</td>';
|
||||
print '<td align="right" >'.price($margin_ht).'</td>';
|
||||
print '<td align="right" >'.price($margin_ttc).'</td>';
|
||||
print '</tr>';
|
||||
|
||||
print "</table>";
|
||||
|
||||
|
||||
llxFooter();
|
||||
|
||||
$db->close();
|
||||
|
||||
Loading…
Reference in New Issue
Block a user