Merge pull request #9246 from atm-florian/6.0

fix : ODT project substitution
This commit is contained in:
Laurent Destailleur 2018-08-16 00:33:04 +02:00 committed by GitHub
commit e88b68f131
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 153 additions and 56 deletions

View File

@ -160,6 +160,7 @@ class doc_generic_project_odt extends ModelePDFProjects
'task_description'=>$task->description, 'task_description'=>$task->description,
'task_fk_parent'=>$task->fk_parent, 'task_fk_parent'=>$task->fk_parent,
'task_duration'=>$task->duration, 'task_duration'=>$task->duration,
'task_duration_hour'=>convertSecondToTime($task->duration,'all'),
'task_progress'=>$task->progress, 'task_progress'=>$task->progress,
'task_public'=>$task->public, 'task_public'=>$task->public,
'task_date_start'=>dol_print_date($task->date_start,'day'), 'task_date_start'=>dol_print_date($task->date_start,'day'),
@ -317,7 +318,10 @@ class doc_generic_project_odt extends ModelePDFProjects
'tasktime_fk_user'=>$tasktime['fk_user'], 'tasktime_fk_user'=>$tasktime['fk_user'],
'tasktime_user_name'=>$tasktime['name'], 'tasktime_user_name'=>$tasktime['name'],
'tasktime_user_first'=>$tasktime['firstname'], 'tasktime_user_first'=>$tasktime['firstname'],
'tasktime_fullcivname'=>$tasktime['fullcivname'] 'tasktime_fullcivname'=>$tasktime['fullcivname'],
'tasktime_amountht'=>$tasktime['amountht'],
'tasktime_amountttc'=>$tasktime['amountttc'],
'tasktime_thm'=>$tasktime['thm'],
); );
} }
@ -698,7 +702,7 @@ class doc_generic_project_odt extends ModelePDFProjects
//Time ressources //Time ressources
$sql = "SELECT t.rowid, t.task_date, t.task_duration, t.fk_user, t.note"; $sql = "SELECT t.rowid, t.task_date, t.task_duration, t.fk_user, t.note";
$sql.= ", u.lastname, u.firstname"; $sql.= ", u.lastname, u.firstname, t.thm";
$sql .= " FROM ".MAIN_DB_PREFIX."projet_task_time as t"; $sql .= " FROM ".MAIN_DB_PREFIX."projet_task_time as t";
$sql .= " , ".MAIN_DB_PREFIX."user as u"; $sql .= " , ".MAIN_DB_PREFIX."user as u";
$sql .= " WHERE t.fk_task =".$task->id; $sql .= " WHERE t.fk_task =".$task->id;
@ -712,6 +716,35 @@ class doc_generic_project_odt extends ModelePDFProjects
$i = 0; $i = 0;
$tasks = array(); $tasks = array();
$listlinestasktime = $listlines->__get('taskstimes'); $listlinestasktime = $listlines->__get('taskstimes');
if (empty($num)) {
$row['rowid']='';
$row['task_date']='';
$row['task_duration']='';
$row['$tasktime']='';
$row['note']='';
$row['fk_user']='';
$row['name']='';
$row['firstname']='';
$row['fullcivname']='';
$row['amountht']='';
$row['amountttc']='';
$row['thm']='';
$tmparray=$this->get_substitutionarray_taskstime($row,$outputlangs);
foreach($tmparray as $key => $val)
{
try
{
$listlinestasktime->setVars($key, $val, true, 'UTF-8');
}
catch(OdfException $e)
{
}
catch(SegmentException $e)
{
}
}
$listlinestasktime->merge();
}
while ($i < $num) while ($i < $num)
{ {
$row = $this->db->fetch_array($resql); $row = $this->db->fetch_array($resql);
@ -723,6 +756,16 @@ class doc_generic_project_odt extends ModelePDFProjects
$row['fullcivname']=''; $row['fullcivname']='';
} }
if (!empty($row['thm'])) {
$row['amountht']=($row['task_duration'] / 3600) * $row['thm'];
$defaultvat = get_default_tva($mysoc, $mysoc);
$row['amountttc']=price2num($row['amountht'] * (1 + ($defaultvat / 100)),'MT');;
} else {
$row['amountht']=0;
$row['amountttc']=0;
$row['thm']=0;
}
$tmparray=$this->get_substitutionarray_taskstime($row,$outputlangs); $tmparray=$this->get_substitutionarray_taskstime($row,$outputlangs);
foreach($tmparray as $key => $val) foreach($tmparray as $key => $val)
@ -889,55 +932,109 @@ class doc_generic_project_odt extends ModelePDFProjects
'title' => "ListProposalsAssociatedProject", 'title' => "ListProposalsAssociatedProject",
'class' => 'Propal', 'class' => 'Propal',
'table' => 'propal', 'table' => 'propal',
'test'=>$conf->propal->enabled && $user->rights->propale->lire), 'test' => $conf->propal->enabled && $user->rights->propale->lire
),
'order' => array( 'order' => array(
'title' => "ListOrdersAssociatedProject", 'title' => "ListOrdersAssociatedProject",
'class' => 'Commande', 'class' => 'Commande',
'table' => 'commande', 'table' => 'commande',
'test'=>$conf->commande->enabled && $user->rights->commande->lire), 'test' => $conf->commande->enabled && $user->rights->commande->lire
),
'invoice' => array( 'invoice' => array(
'title' => "ListInvoicesAssociatedProject", 'title' => "ListInvoicesAssociatedProject",
'class' => 'Facture', 'class' => 'Facture',
'table' => 'facture', 'table' => 'facture',
'test'=>$conf->facture->enabled && $user->rights->facture->lire), 'test' => $conf->facture->enabled && $user->rights->facture->lire
),
'invoice_predefined' => array( 'invoice_predefined' => array(
'title' => "ListPredefinedInvoicesAssociatedProject", 'title' => "ListPredefinedInvoicesAssociatedProject",
'class' => 'FactureRec', 'class' => 'FactureRec',
'table' => 'facture_rec', 'table' => 'facture_rec',
'test'=>$conf->facture->enabled && $user->rights->facture->lire), 'test' => $conf->facture->enabled && $user->rights->facture->lire
),
'proposal_supplier' => array(
'title' => "ListSupplierProposalsAssociatedProject",
'class' => 'SupplierProposal',
'table' => 'supplier_proposal',
'test' => $conf->supplier_proposal->enabled && $user->rights->supplier_proposal->lire
),
'order_supplier' => array( 'order_supplier' => array(
'title' => "ListSupplierOrdersAssociatedProject", 'title' => "ListSupplierOrdersAssociatedProject",
'table' => 'commande_fournisseur', 'table' => 'commande_fournisseur',
'class' => 'CommandeFournisseur', 'class' => 'CommandeFournisseur',
'test'=>$conf->fournisseur->enabled && $user->rights->fournisseur->commande->lire), 'test' => $conf->fournisseur->enabled && $user->rights->fournisseur->commande->lire
),
'invoice_supplier' => array( 'invoice_supplier' => array(
'title' => "ListSupplierInvoicesAssociatedProject", 'title' => "ListSupplierInvoicesAssociatedProject",
'table' => 'facture_fourn', 'table' => 'facture_fourn',
'class' => 'FactureFournisseur', 'class' => 'FactureFournisseur',
'test'=>$conf->fournisseur->enabled && $user->rights->fournisseur->facture->lire), 'test' => $conf->fournisseur->enabled && $user->rights->fournisseur->facture->lire
),
'contract' => array( 'contract' => array(
'title' => "ListContractAssociatedProject", 'title' => "ListContractAssociatedProject",
'class' => 'Contrat', 'class' => 'Contrat',
'table' => 'contrat', 'table' => 'contrat',
'test'=>$conf->contrat->enabled && $user->rights->contrat->lire), 'test' => $conf->contrat->enabled && $user->rights->contrat->lire
),
'intervention' => array( 'intervention' => array(
'title' => "ListFichinterAssociatedProject", 'title' => "ListFichinterAssociatedProject",
'class' => 'Fichinter', 'class' => 'Fichinter',
'table' => 'fichinter', 'table' => 'fichinter',
'disableamount' => 1, 'disableamount' => 1,
'test'=>$conf->ficheinter->enabled && $user->rights->ficheinter->lire), 'test' => $conf->ficheinter->enabled && $user->rights->ficheinter->lire
),
'shipping' => array(
'title' => "ListShippingAssociatedProject",
'class' => 'Expedition',
'table' => 'expedition',
'disableamount' => 1,
'test' => $conf->expedition->enabled && $user->rights->expedition->lire
),
'trip' => array( 'trip' => array(
'title' => "ListTripAssociatedProject", 'title' => "ListTripAssociatedProject",
'class' => 'Deplacement', 'class' => 'Deplacement',
'table' => 'deplacement', 'table' => 'deplacement',
'disableamount' => 1, 'disableamount' => 1,
'test'=>$conf->deplacement->enabled && $user->rights->deplacement->lire), 'test' => $conf->deplacement->enabled && $user->rights->deplacement->lire
),
'expensereport' => array(
'title' => "ListExpenseReportsAssociatedProject",
'class' => 'ExpenseReportLine',
'table' => 'expensereport_det',
'test' => $conf->expensereport->enabled && $user->rights->expensereport->lire
),
'donation' => array(
'title' => "ListDonationsAssociatedProject",
'class' => 'Don',
'table' => 'don',
'test' => $conf->don->enabled && $user->rights->don->lire
),
'loan' => array(
'title' => "ListLoanAssociatedProject",
'class' => 'Loan',
'table' => 'loan',
'test' => $conf->loan->enabled && $user->rights->loan->read
),
'chargesociales' => array(
'title' => "ListSocialContributionAssociatedProject",
'class' => 'ChargeSociales',
'table' => 'chargesociales',
'urlnew' => DOL_URL_ROOT . '/compta/sociales/card.php?action=create&projectid=' . $id,
'test' => $conf->tax->enabled && $user->rights->tax->charges->lire
),
'stock_mouvement' => array(
'title' => "ListMouvementStockProject",
'class' => 'MouvementStock',
'table' => 'stock_mouvement',
'test' => ($conf->stock->enabled && $user->rights->stock->mouvement->lire && ! empty($conf->global->STOCK_MOVEMENT_INTO_PROJECT_OVERVIEW))
),
'agenda' => array( 'agenda' => array(
'title' => "ListActionsAssociatedProject", 'title' => "ListActionsAssociatedProject",
'class' => 'ActionComm', 'class' => 'ActionComm',
'table' => 'actioncomm', 'table' => 'actioncomm',
'disableamount' => 1, 'disableamount' => 1,
'test'=>$conf->agenda->enabled && $user->rights->agenda->allactions->lire) 'test' => $conf->agenda->enabled && $user->rights->agenda->allactions->lire
)
); );
//Insert reference //Insert reference