32 require
'../main.inc.php';
33 require_once DOL_DOCUMENT_ROOT.
'/projet/class/project.class.php';
34 require_once DOL_DOCUMENT_ROOT.
'/projet/class/task.class.php';
35 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formprojet.class.php';
36 require_once DOL_DOCUMENT_ROOT.
'/core/lib/project.lib.php';
37 require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
38 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
39 if (!empty($conf->stock->enabled)) {
40 require_once DOL_DOCUMENT_ROOT.
'/product/stock/class/entrepot.class.php';
42 if (!empty($conf->propal->enabled)) {
43 require_once DOL_DOCUMENT_ROOT.
'/comm/propal/class/propal.class.php';
46 require_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facture.class.php';
47 require_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facture-rec.class.php';
49 if (!empty($conf->commande->enabled)) {
50 require_once DOL_DOCUMENT_ROOT.
'/commande/class/commande.class.php';
52 if (!empty($conf->supplier_proposal->enabled)) {
53 require_once DOL_DOCUMENT_ROOT.
'/supplier_proposal/class/supplier_proposal.class.php';
55 if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || !empty($conf->supplier_invoice->enabled)) {
56 require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.facture.class.php';
58 if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || !empty($conf->supplier_order->enabled)) {
59 require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.commande.class.php';
61 if (!empty($conf->contrat->enabled)) {
62 require_once DOL_DOCUMENT_ROOT.
'/contrat/class/contrat.class.php';
64 if (!empty($conf->ficheinter->enabled)) {
65 require_once DOL_DOCUMENT_ROOT.
'/fichinter/class/fichinter.class.php';
67 if (!empty($conf->expedition->enabled)) {
68 require_once DOL_DOCUMENT_ROOT.
'/expedition/class/expedition.class.php';
70 if (!empty($conf->deplacement->enabled)) {
71 require_once DOL_DOCUMENT_ROOT.
'/compta/deplacement/class/deplacement.class.php';
73 if (!empty($conf->expensereport->enabled)) {
74 require_once DOL_DOCUMENT_ROOT.
'/expensereport/class/expensereport.class.php';
77 require_once DOL_DOCUMENT_ROOT.
'/comm/action/class/actioncomm.class.php';
79 if (!empty($conf->don->enabled)) {
80 require_once DOL_DOCUMENT_ROOT.
'/don/class/don.class.php';
82 if (!empty($conf->loan->enabled)) {
83 require_once DOL_DOCUMENT_ROOT.
'/loan/class/loan.class.php';
84 require_once DOL_DOCUMENT_ROOT.
'/loan/class/loanschedule.class.php';
86 if (!empty($conf->stock->enabled)) {
87 require_once DOL_DOCUMENT_ROOT.
'/product/stock/class/mouvementstock.class.php';
89 if (!empty($conf->tax->enabled)) {
90 require_once DOL_DOCUMENT_ROOT.
'/compta/sociales/class/chargesociales.class.php';
92 if (!empty($conf->banque->enabled)) {
93 require_once DOL_DOCUMENT_ROOT.
'/compta/bank/class/paymentvarious.class.php';
95 if (!empty($conf->salaries->enabled)) {
96 require_once DOL_DOCUMENT_ROOT.
'/salaries/class/salary.class.php';
98 if (!empty($conf->categorie->enabled)) {
99 require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
101 if (!empty($conf->mrp->enabled)) {
102 require_once DOL_DOCUMENT_ROOT.
'/mrp/class/mo.class.php';
106 $langs->loadLangs(array(
'projects',
'companies',
'suppliers',
'compta'));
108 $langs->load(
"bills");
110 if (!empty($conf->commande->enabled)) {
111 $langs->load(
"orders");
113 if (!empty($conf->propal->enabled)) {
114 $langs->load(
"propal");
116 if (!empty($conf->ficheinter->enabled)) {
117 $langs->load(
"interventions");
119 if (!empty($conf->deplacement->enabled)) {
120 $langs->load(
"trips");
122 if (!empty($conf->expensereport->enabled)) {
123 $langs->load(
"trips");
125 if (!empty($conf->don->enabled)) {
126 $langs->load(
"donations");
128 if (!empty($conf->loan->enabled)) {
129 $langs->load(
"loan");
131 if (!empty($conf->salaries->enabled)) {
132 $langs->load(
"salaries");
134 if (!empty($conf->mrp->enabled)) {
137 if (!empty($conf->eventorganization->enabled)) {
138 $langs->load(
"eventorganization");
142 $ref =
GETPOST(
'ref',
'alpha');
143 $action =
GETPOST(
'action',
'aZ09');
144 $datesrfc =
GETPOST(
'datesrfc');
145 $dateerfc =
GETPOST(
'dateerfc');
148 if (empty($dates) && !empty($datesrfc)) {
151 if (empty($datee) && !empty($dateerfc)) {
154 if (!
GETPOSTISSET(
'datesrfc') && !
GETPOSTISSET(
'datesday') && !empty($conf->global->PROJECT_LINKED_ELEMENT_DEFAULT_FILTER_YEAR)) {
161 if ($id ==
'' && $ref ==
'') {
163 header(
'Location: list.php');
167 $mine =
GETPOST(
'mode') ==
'mine' ? 1 : 0;
172 include DOL_DOCUMENT_ROOT.
'/core/actions_fetchobject.inc.php';
173 if (!empty($conf->global->PROJECT_ALLOW_COMMENT_ON_PROJECT) && method_exists($object,
'fetchComments') && empty($object->comments)) {
174 $object->fetchComments();
178 $socid = $object->socid;
180 $result =
restrictedArea($user,
'projet', $object->id,
'projet&project');
182 $hookmanager->initHooks(array(
'projectOverview'));
189 $title = $langs->trans(
'ProjectReferers').
' - '.$object->ref.
' '.$object->name;
190 if (!empty($conf->global->MAIN_HTML_TITLE) && preg_match(
'/projectnameonly/', $conf->global->MAIN_HTML_TITLE) && $object->name) {
191 $title = $object->ref.
' '.$object->name.
' - '.$langs->trans(
'ProjectReferers');
194 $help_url =
'EN:Module_Projects|FR:Module_Projets|ES:Módulo_Proyectos|DE:Modul_Projekte';
202 $userstatic =
new User($db);
205 $userAccess = $object->restrictedProjectArea($user);
208 print
dol_get_fiche_head($head,
'element', $langs->trans(
"Project"), -1, ($object->public ?
'projectpub' :
'project'));
213 $linkback =
'<a href="'.DOL_URL_ROOT.
'/projet/list.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
215 $morehtmlref =
'<div class="refidno">';
217 $morehtmlref .= $object->title;
219 if (!empty($object->thirdparty->id) && $object->thirdparty->id > 0) {
220 $morehtmlref .=
'<br>'.$langs->trans(
'ThirdParty').
' : '.$object->thirdparty->getNomUrl(1,
'project');
222 $morehtmlref .=
'</div>';
225 if (empty($user->rights->projet->all->lire)) {
226 $objectsListId = $object->getProjectsAuthorizedForUser($user, 0, 0);
227 $object->next_prev_filter =
" te.rowid IN (".$db->sanitize(count($objectsListId) ?join(
',', array_keys($objectsListId)) :
'0').
")";
230 dol_banner_tab($object,
'ref', $linkback, 1,
'ref',
'ref', $morehtmlref);
233 print
'<div class="fichecenter">';
234 print
'<div class="fichehalfleft">';
235 print
'<div class="underbanner clearboth"></div>';
237 print
'<table class="border tableforfield centpercent">';
240 if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES) || empty($conf->global->PROJECT_HIDE_TASKS) || !empty($conf->eventorganization->enabled)) {
241 print
'<tr><td class="tdtop">';
242 print $langs->trans(
"Usage");
245 if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES)) {
246 print
'<input type="checkbox" disabled name="usage_opportunity"'.(GETPOSTISSET(
'usage_opportunity') ? (
GETPOST(
'usage_opportunity',
'alpha') !=
'' ?
' checked="checked"' :
'') : ($object->usage_opportunity ?
' checked="checked"' :
'')).
'"> ';
247 $htmltext = $langs->trans(
"ProjectFollowOpportunity");
248 print
$form->textwithpicto($langs->trans(
"ProjectFollowOpportunity"), $htmltext);
251 if (empty($conf->global->PROJECT_HIDE_TASKS)) {
252 print
'<input type="checkbox" disabled name="usage_task"'.(GETPOSTISSET(
'usage_task') ? (
GETPOST(
'usage_task',
'alpha') !=
'' ?
' checked="checked"' :
'') : ($object->usage_task ?
' checked="checked"' :
'')).
'"> ';
253 $htmltext = $langs->trans(
"ProjectFollowTasks");
254 print
$form->textwithpicto($langs->trans(
"ProjectFollowTasks"), $htmltext);
257 if (empty($conf->global->PROJECT_HIDE_TASKS) && !empty($conf->global->PROJECT_BILL_TIME_SPENT)) {
258 print
'<input type="checkbox" disabled name="usage_bill_time"'.(GETPOSTISSET(
'usage_bill_time') ? (
GETPOST(
'usage_bill_time',
'alpha') !=
'' ?
' checked="checked"' :
'') : ($object->usage_bill_time ?
' checked="checked"' :
'')).
'"> ';
259 $htmltext = $langs->trans(
"ProjectBillTimeDescription");
260 print
$form->textwithpicto($langs->trans(
"BillTime"), $htmltext);
263 if (!empty($conf->eventorganization->enabled)) {
264 print
'<input type="checkbox" disabled name="usage_organize_event"'.(GETPOSTISSET(
'usage_organize_event') ? (
GETPOST(
'usage_organize_event',
'alpha') !=
'' ?
' checked="checked"' :
'') : ($object->usage_organize_event ?
' checked="checked"' :
'')).
'"> ';
265 $htmltext = $langs->trans(
"EventOrganizationDescriptionLong");
266 print
$form->textwithpicto($langs->trans(
"ManageOrganizeEvent"), $htmltext);
272 print
'<tr><td class="titlefield">'.$langs->trans(
"Visibility").
'</td><td>';
273 if ($object->public) {
274 print
img_picto($langs->trans(
'SharedProject'),
'world',
'class="paddingrightonly"');
275 print $langs->trans(
'SharedProject');
277 print
img_picto($langs->trans(
'PrivateProject'),
'private',
'class="paddingrightonly"');
278 print $langs->trans(
'PrivateProject');
282 if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES)) {
284 print
'<tr><td>'.$langs->trans(
"OpportunityStatus").
'</td><td>';
285 $code =
dol_getIdFromCode($db, $object->opp_status,
'c_lead_status',
'rowid',
'code');
287 print $langs->trans(
"OppStatus".$code);
292 print
'<tr><td>'.$langs->trans(
"OpportunityProbability").
'</td><td>';
293 if (strcmp($object->opp_percent,
'')) {
294 print
price($object->opp_percent,
'', $langs, 1, 0).
' %';
299 print
'<tr><td>'.$langs->trans(
"OpportunityAmount").
'</td><td>';
300 if (strcmp($object->opp_amount,
'')) {
301 print
'<span class="amount">'.price($object->opp_amount,
'', $langs, 1, 0, 0, $conf->currency).
'</span>';
302 if (strcmp($object->opp_percent,
'')) {
303 print
' <span title="'.dol_escape_htmltag($langs->trans(
'OpportunityWeightedAmount')).
'"><span class="opacitymedium">'.$langs->trans(
"Weighted").
'</span>: <span class="amount">'.
price($object->opp_amount * $object->opp_percent / 100, 0, $langs, 1, 0, -1, $conf->currency).
'</span></span>';
310 print
'<tr><td>'.$langs->trans(
"DateStart").
' - '.$langs->trans(
"DateEnd").
'</td><td>';
312 print ($start ? $start :
'?');
315 print ($end ? $end :
'?');
316 if ($object->hasDelay()) {
322 print
'<tr><td>'.$langs->trans(
"Budget").
'</td><td>';
323 if (strcmp($object->budget_amount,
'')) {
324 print
'<span class="amount">'.price($object->budget_amount,
'', $langs, 1, 0, 0, $conf->currency).
'</span>';
330 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_view.tpl.php';
335 print
'<div class="fichehalfright">';
336 print
'<div class="underbanner clearboth"></div>';
338 print
'<table class="border tableforfield centpercent">';
341 print
'<td class="titlefield tdtop">'.$langs->trans(
"Description").
'</td><td>';
342 print nl2br($object->description);
347 print
'<tr><td class="valignmiddle">'.$langs->trans(
"Categories").
'</td><td>';
348 print
$form->showCategories($object->id, Categorie::TYPE_PROJECT, 1);
357 print
'<div class="clearboth"></div>';
367 $listofreferent = array(
370 'title'=>
"ListWarehouseAssociatedProject",
373 'datefieldname'=>
'date_entrepot',
374 'urlnew'=>DOL_URL_ROOT.
'/product/stock/card.php?action=create&projectid='.$id.
'&backtopage='.urlencode($_SERVER[
'PHP_SELF'].
'?id='.$id),
376 'buttonnew'=>
'AddWarehouse',
377 'project_field'=>
'fk_project',
378 'testnew'=>$user->rights->stock->creer,
379 'test'=>$conf->stock->enabled && $user->rights->stock->lire && !empty($conf->global->WAREHOUSE_ASK_WAREHOUSE_DURING_PROJECT)),
382 'title'=>
"ListProposalsAssociatedProject",
385 'datefieldname'=>
'datep',
386 'urlnew'=>DOL_URL_ROOT.
'/comm/propal/card.php?action=create&origin=project&originid='.$id.
'&socid='.$socid.
'&backtopage='.urlencode($_SERVER[
'PHP_SELF'].
'?id='.$id),
388 'buttonnew'=>
'AddProp',
389 'testnew'=>$user->rights->propal->creer,
390 'test'=>$conf->propal->enabled && $user->rights->propale->lire),
392 'name'=>
"CustomersOrders",
393 'title'=>
"ListOrdersAssociatedProject",
396 'datefieldname'=>
'date_commande',
397 'urlnew'=>DOL_URL_ROOT.
'/commande/card.php?action=create&projectid='.$id.
'&socid='.$socid.
'&backtopage='.urlencode($_SERVER[
'PHP_SELF'].
'?id='.$id),
399 'buttonnew'=>
'CreateOrder',
400 'testnew'=>$user->rights->commande->creer,
401 'test'=>$conf->commande->enabled && $user->rights->commande->lire),
403 'name'=>
"CustomersInvoices",
404 'title'=>
"ListInvoicesAssociatedProject",
408 'datefieldname'=>
'datef',
409 'urlnew'=>DOL_URL_ROOT.
'/compta/facture/card.php?action=create&projectid='.$id.
'&socid='.$socid.
'&backtopage='.urlencode($_SERVER[
'PHP_SELF'].
'?id='.$id),
411 'buttonnew'=>
'CreateBill',
412 'testnew'=>$user->rights->facture->creer,
413 'test'=>$conf->facture->enabled && $user->rights->facture->lire),
414 'invoice_predefined'=>array(
415 'name'=>
"PredefinedInvoices",
416 'title'=>
"ListPredefinedInvoicesAssociatedProject",
417 'class'=>
'FactureRec',
418 'table'=>
'facture_rec',
419 'datefieldname'=>
'datec',
420 'urlnew'=>DOL_URL_ROOT.
'/compta/facture/card.php?action=create&projectid='.$id.
'&socid='.$socid.
'&backtopage='.urlencode($_SERVER[
'PHP_SELF'].
'?id='.$id),
422 'buttonnew'=>
'CreateBill',
423 'testnew'=>$user->rights->facture->creer,
424 'test'=>$conf->facture->enabled && $user->rights->facture->lire),
425 'proposal_supplier'=>array(
426 'name'=>
"SuppliersProposals",
427 'title'=>
"ListSupplierProposalsAssociatedProject",
428 'class'=>
'SupplierProposal',
429 'table'=>
'supplier_proposal',
430 'datefieldname'=>
'date_valid',
431 'urlnew'=>DOL_URL_ROOT.
'/supplier_proposal/card.php?action=create&projectid='.$id.
'&backtopage='.urlencode($_SERVER[
'PHP_SELF'].
'?id='.$id),
432 'lang'=>
'supplier_proposal',
433 'buttonnew'=>
'AddSupplierProposal',
434 'testnew'=>$user->rights->supplier_proposal->creer,
435 'test'=>$conf->supplier_proposal->enabled && $user->rights->supplier_proposal->lire),
436 'order_supplier'=>array(
437 'name'=>
"SuppliersOrders",
438 'title'=>
"ListSupplierOrdersAssociatedProject",
439 'class'=>
'CommandeFournisseur',
440 'table'=>
'commande_fournisseur',
441 'datefieldname'=>
'date_commande',
442 'urlnew'=>DOL_URL_ROOT.
'/fourn/commande/card.php?action=create&projectid='.$id.
'&backtopage='.urlencode($_SERVER[
'PHP_SELF'].
'?id='.$id),
444 'buttonnew'=>
'AddSupplierOrder',
445 'testnew'=>($user->rights->fournisseur->commande->creer || $user->rights->supplier_order->creer),
446 'test'=>$conf->supplier_order->enabled && ($user->rights->fournisseur->commande->lire || $user->rights->supplier_order->lire)),
447 'invoice_supplier'=>array(
448 'name'=>
"BillsSuppliers",
449 'title'=>
"ListSupplierInvoicesAssociatedProject",
450 'class'=>
'FactureFournisseur',
452 'table'=>
'facture_fourn',
453 'datefieldname'=>
'datef',
454 'urlnew'=>DOL_URL_ROOT.
'/fourn/facture/card.php?action=create&projectid='.$id.
'&backtopage='.urlencode($_SERVER[
'PHP_SELF'].
'?id='.$id),
456 'buttonnew'=>
'AddSupplierInvoice',
457 'testnew'=>($user->rights->fournisseur->facture->creer || $user->rights->supplier_invoice->creer),
458 'test'=>$conf->supplier_invoice->enabled && ($user->rights->fournisseur->facture->lire || $user->rights->supplier_invoice->lire)),
461 'title'=>
"ListContractAssociatedProject",
464 'datefieldname'=>
'date_contrat',
465 'urlnew'=>DOL_URL_ROOT.
'/contrat/card.php?action=create&projectid='.$id.
'&socid='.$socid.
'&backtopage='.urlencode($_SERVER[
'PHP_SELF'].
'?id='.$id),
467 'buttonnew'=>
'AddContract',
468 'testnew'=>$user->rights->contrat->creer,
469 'test'=>$conf->contrat->enabled && $user->rights->contrat->lire),
470 'intervention'=>array(
471 'name'=>
"Interventions",
472 'title'=>
"ListFichinterAssociatedProject",
473 'class'=>
'Fichinter',
474 'table'=>
'fichinter',
475 'datefieldname'=>
'date_valid',
478 'urlnew'=>DOL_URL_ROOT.
'/fichinter/card.php?action=create&origin=project&originid='.$id.
'&socid='.$socid.
'&backtopage='.urlencode($_SERVER[
'PHP_SELF'].
'?id='.$id),
479 'lang'=>
'interventions',
480 'buttonnew'=>
'AddIntervention',
481 'testnew'=>$user->rights->ficheinter->creer,
482 'test'=>$conf->ficheinter->enabled && $user->rights->ficheinter->lire),
485 'title'=>
"ListShippingAssociatedProject",
486 'class'=>
'Expedition',
487 'table'=>
'expedition',
488 'datefieldname'=>
'date_valid',
489 'urlnew'=>DOL_URL_ROOT.
'/expedition/card.php?action=create&origin=project&originid='.$id.
'&socid='.$socid.
'&backtopage='.urlencode($_SERVER[
'PHP_SELF'].
'?id='.$id),
491 'buttonnew'=>
'CreateShipment',
493 'test'=>$conf->expedition->enabled && $user->rights->expedition->lire),
496 'title'=>
"ListMOAssociatedProject",
499 'datefieldname'=>
'date_valid',
500 'urlnew'=>DOL_URL_ROOT.
'/mrp/mo_card.php?action=create&origin=project&originid='.$id.
'&socid='.$socid.
'&backtopage='.urlencode($_SERVER[
'PHP_SELF'].
'?id='.$id),
502 'buttonnew'=>
'CreateMO',
503 'testnew'=>
'$user->rights->mrp->write',
504 'project_field'=>
'fk_project',
505 'test'=>$conf->mrp->enabled && $user->rights->mrp->read),
507 'name'=>
"TripsAndExpenses",
508 'title'=>
"ListExpenseReportsAssociatedProject",
509 'class'=>
'Deplacement',
510 'table'=>
'deplacement',
511 'datefieldname'=>
'dated',
514 'urlnew'=>DOL_URL_ROOT.
'/deplacement/card.php?action=create&projectid='.$id.
'&socid='.$socid.
'&backtopage='.urlencode($_SERVER[
'PHP_SELF'].
'?id='.$id),
516 'buttonnew'=>
'AddTrip',
517 'testnew'=>$user->rights->deplacement->creer,
518 'test'=>$conf->deplacement->enabled && $user->rights->deplacement->lire),
519 'expensereport'=>array(
520 'name'=>
"ExpenseReports",
521 'title'=>
"ListExpenseReportsAssociatedProject",
522 'class'=>
'ExpenseReportLine',
523 'table'=>
'expensereport_det',
524 'datefieldname'=>
'date',
527 'urlnew'=>DOL_URL_ROOT.
'/expensereport/card.php?action=create&projectid='.$id.
'&socid='.$socid.
'&backtopage='.urlencode($_SERVER[
'PHP_SELF'].
'?id='.$id),
529 'buttonnew'=>
'AddTrip',
530 'testnew'=>$user->rights->expensereport->creer,
531 'test'=>$conf->expensereport->enabled && $user->rights->expensereport->lire),
534 'title'=>
"ListDonationsAssociatedProject",
538 'datefieldname'=>
'datedon',
540 'urlnew'=>DOL_URL_ROOT.
'/don/card.php?action=create&projectid='.$id.
'&socid='.$socid.
'&backtopage='.urlencode($_SERVER[
'PHP_SELF'].
'?id='.$id),
542 'buttonnew'=>
'AddDonation',
543 'testnew'=>$user->rights->don->creer,
544 'test'=>$conf->don->enabled && $user->rights->don->lire),
547 'title'=>
"ListLoanAssociatedProject",
551 'datefieldname'=>
'datestart',
553 'urlnew'=>DOL_URL_ROOT.
'/loan/card.php?action=create&projectid='.$id.
'&socid='.$socid.
'&backtopage='.urlencode($_SERVER[
'PHP_SELF'].
'?id='.$id),
555 'buttonnew'=>
'AddLoan',
556 'testnew'=>$user->rights->loan->write,
557 'test'=>$conf->loan->enabled && $user->rights->loan->read),
558 'chargesociales'=>array(
559 'name'=>
"SocialContribution",
560 'title'=>
"ListSocialContributionAssociatedProject",
561 'class'=>
'ChargeSociales',
563 'table'=>
'chargesociales',
564 'datefieldname'=>
'date_ech',
566 'urlnew'=>DOL_URL_ROOT.
'/compta/sociales/card.php?action=create&projectid='.$id.
'&backtopage='.urlencode($_SERVER[
'PHP_SELF'].
'?id='.$id),
568 'buttonnew'=>
'AddSocialContribution',
569 'testnew'=>$user->rights->tax->charges->lire,
570 'test'=>$conf->tax->enabled && $user->rights->tax->charges->lire),
571 'project_task'=>array(
572 'name'=>
"TaskTimeSpent",
573 'title'=>
"ListTaskTimeUserProject",
576 'table'=>
'projet_task',
577 'datefieldname'=>
'task_date',
579 'urlnew'=>DOL_URL_ROOT.
'/projet/tasks/time.php?withproject=1&action=createtime&projectid='.$id.
'&backtopage='.urlencode($_SERVER[
'PHP_SELF'].
'?id='.$id),
580 'buttonnew'=>
'AddTimeSpent',
581 'testnew'=>$user->rights->projet->creer,
582 'test'=>($conf->project->enabled && $user->rights->projet->lire && empty($conf->global->PROJECT_HIDE_TASKS))),
583 'stock_mouvement'=>array(
584 'name'=>
"MouvementStockAssociated",
585 'title'=>
"ListMouvementStockProject",
586 'class'=>
'MouvementStock',
587 'table'=>
'stock_mouvement',
588 'datefieldname'=>
'datem',
591 'test'=>($conf->stock->enabled && $user->rights->stock->mouvement->lire && !empty($conf->global->STOCK_MOVEMENT_INTO_PROJECT_OVERVIEW))),
594 'title'=>
"ListSalariesAssociatedProject",
597 'datefieldname'=>
'datesp',
600 'urlnew'=>DOL_URL_ROOT.
'/salaries/card.php?action=create&projectid='.$id.
'&backtopage='.urlencode($_SERVER[
'PHP_SELF'].
'?id='.$id),
602 'buttonnew'=>
'AddSalary',
603 'testnew'=>$user->rights->salaries->write,
604 'test'=>$conf->salaries->enabled && $user->rights->salaries->read),
605 'variouspayment'=>array(
606 'name'=>
"VariousPayments",
607 'title'=>
"ListVariousPaymentsAssociatedProject",
608 'class'=>
'PaymentVarious',
609 'table'=>
'payment_various',
610 'datefieldname'=>
'datev',
613 'urlnew'=>DOL_URL_ROOT.
'/compta/bank/various_payment/card.php?action=create&projectid='.$id.
'&backtopage='.urlencode($_SERVER[
'PHP_SELF'].
'?id='.$id),
615 'buttonnew'=>
'AddVariousPayment',
616 'testnew'=>$user->rights->banque->modifier,
617 'test'=>$conf->banque->enabled && $user->rights->banque->lire && empty($conf->global->BANK_USE_OLD_VARIOUS_PAYMENT)),
635 if (!empty($conf->global->PROJECT_ELEMENTS_FOR_PLUS_MARGIN)) {
636 foreach ($listofreferent as $key => $element) {
637 if ($listofreferent[$key][
'margin'] ==
'add') {
638 unset($listofreferent[$key][
'margin']);
641 $newelementforplusmargin = explode(
',', $conf->global->PROJECT_ELEMENTS_FOR_PLUS_MARGIN);
642 foreach ($newelementforplusmargin as $value) {
643 $listofreferent[trim($value)][
'margin'] =
'add';
646 if (!empty($conf->global->PROJECT_ELEMENTS_FOR_MINUS_MARGIN)) {
647 foreach ($listofreferent as $key => $element) {
648 if ($listofreferent[$key][
'margin'] ==
'minus') {
649 unset($listofreferent[$key][
'margin']);
652 $newelementforminusmargin = explode(
',', $conf->global->PROJECT_ELEMENTS_FOR_MINUS_MARGIN);
653 foreach ($newelementforminusmargin as $value) {
654 $listofreferent[trim($value)][
'margin'] =
'minus';
660 $parameters = array(
'listofreferent'=>$listofreferent);
661 $resHook = $hookmanager->executeHooks(
'completeListOfReferent', $parameters, $object, $action);
663 if (!empty($hookmanager->resArray)) {
664 $listofreferent = array_merge($listofreferent, $hookmanager->resArray);
667 if ($action ==
"addelement") {
668 $tablename =
GETPOST(
"tablename");
669 $elementselectid =
GETPOST(
"elementselect");
670 $result = $object->update_element($tablename, $elementselectid);
674 } elseif ($action ==
"unlink") {
675 $tablename =
GETPOST(
"tablename",
"aZ09");
676 $projectField =
GETPOSTISSET(
'projectfield') ?
GETPOST(
'projectfield',
'aZ09') :
'fk_projet';
677 $elementselectid =
GETPOST(
"elementselect",
"int");
679 $result = $object->remove_element($tablename, $elementselectid, $projectField);
685 $elementuser =
new User($db);
691 if (!$showdatefilter) {
692 print
'<div class="center centpercent">';
693 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'" method="POST">';
694 print
'<input type="hidden" name="token" value="'.newToken().
'">';
695 print
'<input type="hidden" name="tablename" value="'.$tablename.
'">';
696 print
'<input type="hidden" name="action" value="view">';
697 print
'<div class="inline-block">';
698 print
$form->selectDate($dates,
'dates', 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
"From"));
700 print
'<div class="inline-block">';
701 print
$form->selectDate($datee,
'datee', 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
"to"));
703 print
'<div class="inline-block">';
704 print
'<input type="submit" name="refresh" value="'.$langs->trans(
"Refresh").
'" class="button small">';
716 $langs->loadLangs(array(
"suppliers",
"bills",
"orders",
"proposals",
"margins"));
718 if (!empty($conf->stock->enabled)) {
719 $langs->load(
'stocks');
724 print
'<table class="noborder centpercent">';
725 print
'<tr class="liste_titre">';
726 print
'<td class="left" width="200">';
727 $tooltiponprofit = $langs->trans(
"ProfitIsCalculatedWith").
"<br>\n";
728 $tooltiponprofitplus = $tooltiponprofitminus =
'';
729 foreach ($listofreferent as $key => $value) {
730 $name = $langs->trans($value[
'name']);
731 $qualified = $value[
'test'];
732 $margin = $value[
'margin'];
733 if ($qualified && isset($margin)) {
734 if ($margin ==
'add') {
735 $tooltiponprofitplus .=
' > '.$name.
" (+)<br>\n";
737 if ($margin ==
'minus') {
738 $tooltiponprofitminus .=
' > '.$name.
" (-)<br>\n";
742 $tooltiponprofit .= $tooltiponprofitplus;
743 $tooltiponprofit .= $tooltiponprofitminus;
744 print
$form->textwithpicto($langs->trans(
"Element"), $tooltiponprofit);
746 print
'<td class="right" width="100">'.$langs->trans(
"Number").
'</td>';
747 print
'<td class="right" width="100">'.$langs->trans(
"AmountHT").
'</td>';
748 print
'<td class="right" width="100">'.$langs->trans(
"AmountTTC").
'</td>';
751 $total_revenue_ht = 0;
756 foreach ($listofreferent as $key => $value) {
758 'total_revenue_ht' =>& $total_revenue_ht,
759 'balance_ht' =>& $balance_ht,
760 'balance_ttc' =>& $balance_ttc,
766 $reshook = $hookmanager->executeHooks(
'printOverviewProfit', $parameters, $object, $action);
769 } elseif ($reshook > 0) {
770 print $hookmanager->resPrint;
774 $name = $langs->trans($value[
'name']);
775 $title = $value[
'title'];
776 $classname = $value[
'class'];
777 $tablename = $value[
'table'];
778 $datefieldname = $value[
'datefieldname'];
779 $qualified = $value[
'test'];
780 $margin = $value[
'margin'];
781 $project_field = $value[
'project_field'];
782 if ($qualified && isset($margin)) {
783 $element =
new $classname($db);
785 $elementarray = $object->get_element_list($key, $tablename, $datefieldname, $dates, $datee, !empty($project_field) ? $project_field :
'fk_projet');
787 if (is_array($elementarray) && count($elementarray) > 0) {
792 $num = count($elementarray);
793 for ($i = 0; $i < $num; $i++) {
794 $tmp = explode(
'_', $elementarray[$i]);
795 $idofelement = $tmp[0];
796 $idofelementuser = $tmp[1];
798 $element->fetch($idofelement);
799 if ($idofelementuser) {
800 $elementuser->fetch($idofelementuser);
804 $qualifiedfortotal =
true;
805 if ($key ==
'invoice') {
806 if (!empty($element->close_code) && $element->close_code ==
'replaced') {
807 $qualifiedfortotal =
false;
809 if (!empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS) && $element->type ==
Facture::TYPE_DEPOSIT) {
810 $qualifiedfortotal =
false;
813 if ($key ==
'propal') {
815 $qualifiedfortotal =
false;
819 if ($tablename !=
'expensereport_det' && method_exists($element,
'fetch_thirdparty')) {
820 $element->fetch_thirdparty();
824 if ($tablename ==
'don' || $tablename ==
'chargesociales' || $tablename ==
'payment_various' || $tablename ==
'salary') {
825 $total_ht_by_line = $element->amount;
826 } elseif ($tablename ==
'fichinter') {
827 $total_ht_by_line = $element->getAmount();
828 } elseif ($tablename ==
'stock_mouvement') {
829 $total_ht_by_line = $element->price * abs($element->qty);
830 } elseif ($tablename ==
'projet_task') {
831 if ($idofelementuser) {
832 $tmp = $element->getSumOfAmount($elementuser, $dates, $datee);
833 $total_ht_by_line =
price2num($tmp[
'amount'],
'MT');
835 $tmp = $element->getSumOfAmount(
'', $dates, $datee);
836 $total_ht_by_line =
price2num($tmp[
'amount'],
'MT');
838 } elseif ($key ==
'loan') {
839 if ((empty($dates) && empty($datee)) || (intval($dates) <= $element->datestart && intval($datee) >= $element->dateend)) {
841 $total_ht_by_line = -$element->capital;
844 $total_ht_by_line = 0;
846 $loanScheduleStatic->fetchAll($element->id);
847 if (!empty($loanScheduleStatic->lines)) {
848 foreach ($loanScheduleStatic->lines as $loanSchedule) {
852 if (($loanSchedule->datep >= $dates && $loanSchedule->datep <= $datee)
853 || !empty($dates) && empty($datee) && $loanSchedule->datep >= $dates && $loanSchedule->datep <=
dol_now()
854 || empty($dates) && !empty($datee) && $loanSchedule->datep <= $datee
856 $total_ht_by_line -= $loanSchedule->amount_capital;
862 $total_ht_by_line = $element->total_ht;
866 if ($tablename ==
'don' || $tablename ==
'chargesociales' || $tablename ==
'payment_various' || $tablename ==
'salary') {
867 $total_ttc_by_line = $element->amount;
868 } elseif ($tablename ==
'fichinter') {
869 $total_ttc_by_line = $element->getAmount();
870 } elseif ($tablename ==
'stock_mouvement') {
871 $total_ttc_by_line = $element->price * abs($element->qty);
872 } elseif ($tablename ==
'projet_task') {
874 $total_ttc_by_line =
price2num($total_ht_by_line * (1 + ($defaultvat / 100)),
'MT');
875 } elseif ($key ==
'loan') {
876 $total_ttc_by_line = $total_ht_by_line;
878 $total_ttc_by_line = $element->total_ttc;
882 if ($tablename ==
'payment_various') {
883 if ($element->sens == 1) {
884 $total_ht_by_line = -$total_ht_by_line;
885 $total_ttc_by_line = -$total_ttc_by_line;
890 if ($qualifiedfortotal) {
891 $total_ht = $total_ht + $total_ht_by_line;
892 $total_ttc = $total_ttc + $total_ttc_by_line;
900 if ($margin ===
'add') {
901 $total_revenue_ht += $total_ht;
904 if ($margin ===
"minus") {
905 $total_ht = -$total_ht;
906 $total_ttc = -$total_ttc;
909 $balance_ht += $total_ht;
910 $balance_ttc += $total_ttc;
913 print
'<tr class="oddeven">';
915 print
'<td class="left">'.$name.
'</td>';
917 print
'<td class="right">'.$i.
'</td>';
919 print
'<td class="right">';
920 if ($key ==
'intervention' && !$margin) {
921 print
'<span class="opacitymedium">'.$form->textwithpicto($langs->trans(
"NA"), $langs->trans(
"AmountOfInteventionNotIncludedByDefault")).
'</span>';
923 if ($key ==
'propal') {
924 print
'<span class="opacitymedium">'.$form->textwithpicto(
'', $langs->trans(
"SignedOnly")).
'</span>';
926 print
price($total_ht);
930 print
'<td class="right">';
931 if ($key ==
'intervention' && !$margin) {
932 print
'<span class="opacitymedium">'.$form->textwithpicto($langs->trans(
"NA"), $langs->trans(
"AmountOfInteventionNotIncludedByDefault")).
'</span>';
934 if ($key ==
'propal') {
935 print
'<span class="opacitymedium">'.$form->textwithpicto(
'', $langs->trans(
"SignedOnly")).
'</span>';
937 print
price($total_ttc);
945 print
'<tr class="liste_total">';
946 print
'<td class="right" colspan="2">'.$langs->trans(
"Profit").
'</td>';
947 print
'<td class="right">'.price(
price2num($balance_ht,
'MT')).
'</td>';
948 print
'<td class="right">'.price(
price2num($balance_ttc,
'MT')).
'</td>';
952 if ($total_revenue_ht) {
953 print
'<tr class="liste_total">';
954 print
'<td class="right" colspan="2">'.$langs->trans(
"Margin").
'</td>';
955 print
'<td class="right">'.round(100 * $balance_ht / $total_revenue_ht, 1).
'%</td>';
956 print
'<td class="right"></td>';
969 foreach ($listofreferent as $key => $value) {
976 $reshook = $hookmanager->executeHooks(
'printOverviewDetail', $parameters, $object, $action);
979 } elseif ($reshook > 0) {
980 print $hookmanager->resPrint;
984 $title = $value[
'title'];
985 $classname = $value[
'class'];
986 $tablename = $value[
'table'];
987 $datefieldname = $value[
'datefieldname'];
988 $qualified = $value[
'test'];
989 $langtoload = $value[
'lang'];
990 $urlnew = $value[
'urlnew'];
991 $buttonnew = $value[
'buttonnew'];
992 $testnew = $value[
'testnew'];
993 $project_field = $value[
'project_field'];
995 $exclude_select_element = array(
'payment_various');
996 if (!empty($value[
'exclude_select_element'])) {
997 $exclude_select_element[] = $value[
'exclude_select_element'];
1005 $langs->load($langtoload);
1008 $element =
new $classname($db);
1012 $idtofilterthirdparty = 0;
1013 $array_of_element_linkable_with_different_thirdparty = array(
'facture_fourn',
'commande_fournisseur');
1014 if (!in_array($tablename, $array_of_element_linkable_with_different_thirdparty)) {
1015 $idtofilterthirdparty = $object->thirdparty->id;
1016 if (!empty($conf->global->PROJECT_OTHER_THIRDPARTY_ID_TO_ADD_ELEMENTS)) {
1017 $idtofilterthirdparty .=
','.$conf->global->PROJECT_OTHER_THIRDPARTY_ID_TO_ADD_ELEMENTS;
1021 $elementarray = $object->get_element_list($key, $tablename, $datefieldname, $dates, $datee, !empty($project_field) ? $project_field :
'fk_projet');
1024 if (empty($conf->global->PROJECT_LINK_ON_OVERWIEW_DISABLED) && $idtofilterthirdparty && !in_array($tablename, $exclude_select_element)) {
1025 $selectList = $formproject->select_element($tablename, $idtofilterthirdparty,
'minwidth300 minwidth75imp', -2, empty($project_field) ?
'fk_projet' : $project_field, $langs->trans(
"SelectElement"));
1026 if ($selectList < 0) {
1028 } elseif ($selectList) {
1030 $addform .=
'<div class="inline-block valignmiddle">';
1031 $addform .=
'<form action="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'" method="post">';
1032 $addform .=
'<input type="hidden" name="token" value="'.newToken().
'">';
1033 $addform .=
'<input type="hidden" name="tablename" value="'.$tablename.
'">';
1034 $addform .=
'<input type="hidden" name="action" value="addelement">';
1035 $addform .=
'<input type="hidden" name="datesrfc" value="'.dol_print_date($dates,
'dayhourrfc').
'">';
1036 $addform .=
'<input type="hidden" name="dateerfc" value="'.dol_print_date($datee,
'dayhourrfc').
'">';
1037 $addform .=
'<table><tr>';
1039 $addform .=
'<td>'.$selectList.
'</td>';
1040 $addform .=
'<td><input type="submit" class="button button-linkto smallpaddingimp" value="'.dol_escape_htmltag($langs->trans(
"LinkToElementShort")).
'"></td>';
1041 $addform .=
'</tr></table>';
1042 $addform .=
'</form>';
1043 $addform .=
'</div>';
1046 if (empty($conf->global->PROJECT_CREATE_ON_OVERVIEW_DISABLED) && $urlnew) {
1047 $addform .=
'<div class="inline-block valignmiddle">';
1049 $addform .=
'<a class="buttonxxx marginleftonly" href="'.$urlnew.
'" title="'.
dol_escape_htmltag($langs->trans($buttonnew)).
'"><span class="fa fa-plus-circle valignmiddle paddingleft"></span></a>';
1050 } elseif (empty($conf->global->MAIN_BUTTON_HIDE_UNAUTHORIZED)) {
1051 $addform .=
'<span title="'.dol_escape_htmltag($langs->trans($buttonnew)).
'"><a class="buttonxxx marginleftonly buttonRefused" disabled="disabled" href="#"><span class="fa fa-plus-circle valignmiddle paddingleft"></span></a></span>';
1053 $addform .=
'<div>';
1056 if (is_array($elementarray) && count($elementarray) > 0 && $key ==
"order_supplier") {
1057 $addform =
'<div class="inline-block valignmiddle"><a id="btnShow" class="buttonxxx marginleftonly" href="#" onClick="return false;">
1058 <span id="textBtnShow" class="valignmiddle text-plus-circle hideonsmartphone">'.$langs->trans(
"CanceledShown").
'</span><span id="minus-circle" class="fa fa-eye valignmiddle paddingleft"></span>
1061 $("#btnShow").on("click", function () {
1062 console.log("We click to show or hide the canceled lines");
1063 var attr = $(this).attr("data-canceledarehidden");
1064 if (typeof attr !== "undefined" && attr !== false) {
1065 console.log("Show canceled");
1066 $(".tr_canceled").show();
1067 $("#textBtnShow").text("'.
dol_escape_js($langs->transnoentitiesnoconv(
"CanceledShown")).
'");
1068 $("#btnShow").removeAttr("data-canceledarehidden");
1069 $("#minus-circle").removeClass("fa-eye-slash").addClass("fa-eye");
1071 console.log("Hide canceled");
1072 $(".tr_canceled").hide();
1073 $("#textBtnShow").text("'.
dol_escape_js($langs->transnoentitiesnoconv(
"CanceledHidden")).
'");
1074 $("#btnShow").attr("data-canceledarehidden", 1);
1075 $("#minus-circle").removeClass("fa-eye").addClass("fa-eye-slash");
1078 </script></div> '.$addform;
1083 print
"\n".
'<!-- Table for tablename = '.$tablename.
' -->'.
"\n";
1084 print
'<div class="div-table-responsive">';
1085 print
'<table class="noborder centpercent">';
1087 print
'<tr class="liste_titre">';
1089 print
'<td style="width: 24px"></td>';
1091 print
'<td'.(($tablename !=
'actioncomm' && $tablename !=
'projet_task') ?
' style="width: 200px"' :
'').
'>'.$langs->trans(
"Ref").
'</td>';
1093 print
'<td'.(($tablename !=
'actioncomm' && $tablename !=
'projet_task') ?
' style="width: 200px"' :
'').
' class="center">';
1094 if (in_array($tablename, array(
'projet_task'))) {
1095 print $langs->trans(
"TimeSpent");
1097 if (!in_array($tablename, array(
'projet_task'))) {
1098 print $langs->trans(
"Date");
1103 if (in_array($tablename, array(
'projet_task')) && $key ==
'project_task') {
1105 } elseif (in_array($tablename, array(
'payment_various'))) {
1107 } elseif (in_array($tablename, array(
'expensereport_det',
'don',
'projet_task',
'stock_mouvement',
'salary'))) {
1108 print $langs->trans(
"User");
1110 print $langs->trans(
"ThirdParty");
1114 if ($tablename ==
'fichinter') {
1116 print $langs->trans(
"TotalDuration");
1117 $total_duration = 0;
1123 if ($key ==
'loan') {
1124 print
'<td class="right" width="120">'.$langs->trans(
"LoanCapital").
'</td>';
1125 } elseif (empty($value[
'disableamount'])) {
1126 print
'<td class="right" width="120">'.$langs->trans(
"AmountHT").
'</td>';
1128 print
'<td width="120"></td>';
1132 if ($key ==
'loan') {
1133 print
'<td class="right" width="120">'.$langs->trans(
"RemainderToPay").
'</td>';
1134 } elseif (empty($value[
'disableamount'])) {
1135 print
'<td class="right" width="120">'.$langs->trans(
"AmountTTC").
'</td>';
1137 print
'<td width="120"></td>';
1140 if (in_array($tablename, array(
'projet_task'))) {
1141 print
'<td class="right" width="200">'.$langs->trans(
"ProgressDeclared").
'</td>';
1143 print
'<td class="right" width="200">'.$langs->trans(
"Status").
'</td>';
1147 if (is_array($elementarray) && count($elementarray) > 0) {
1151 $total_ht_by_third = 0;
1152 $total_ttc_by_third = 0;
1154 $saved_third_id = 0;
1162 $num = count($elementarray);
1163 for ($i = 0; $i < $num; $i++) {
1164 $tmp = explode(
'_', $elementarray[$i]);
1165 $idofelement = $tmp[0];
1166 $idofelementuser = $tmp[1];
1168 $element->fetch($idofelement);
1169 if ($idofelementuser) {
1170 $elementuser->fetch($idofelementuser);
1174 if ($tablename !=
'expensereport_det') {
1175 if (method_exists($element,
'fetch_thirdparty')) {
1176 $element->fetch_thirdparty();
1180 $expensereport->fetch($element->fk_expensereport);
1185 if ($breakline && $saved_third_id != $element->thirdparty->id) {
1188 $saved_third_id = $element->thirdparty->id;
1191 $total_ht_by_third = 0;
1192 $total_ttc_by_third = 0;
1194 $saved_third_id = $element->thirdparty->id;
1196 $qualifiedfortotal =
true;
1197 if ($key ==
'invoice') {
1198 if (!empty($element->close_code) && $element->close_code ==
'replaced') {
1199 $qualifiedfortotal =
false;
1201 } elseif ($key ==
'order_supplier' && $element->status == 7) {
1202 $qualifiedfortotal =
false;
1205 if ($key ==
"order_supplier" && $element->status == 7) {
1206 print
'<tr class="oddeven tr_canceled" style=display:none>';
1208 print
'<tr class="oddeven" >';
1213 print
'<td style="width: 24px">';
1214 if ($tablename !=
'projet_task' && $tablename !=
'stock_mouvement') {
1215 if (empty($conf->global->PROJECT_DISABLE_UNLINK_FROM_OVERVIEW) || $user->admin) {
1216 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&action=unlink&tablename='.$tablename.
'&elementselect='.$element->id.($project_field ?
'&projectfield='.$project_field :
'').
'" class="reposition">';
1217 print
img_picto($langs->trans(
'Unlink'),
'unlink');
1224 print
'<td class="left nowraponall">';
1225 if ($tablename ==
'expensereport_det') {
1226 print $expensereport->getNomUrl(1);
1229 if ($element instanceof
Task) {
1230 print $element->getNomUrl(1,
'withproject',
'time');
1231 print
' - '.dol_trunc($element->label, 48);
1232 } elseif ($key ==
'loan') {
1233 print $element->getNomUrl(1);
1234 print
' - '.dol_trunc($element->label, 48);
1236 print $element->getNomUrl(1);
1239 $element_doc = $element->element;
1241 $filedir = $conf->{$element_doc}->multidir_output[$element->entity].
'/'.
dol_sanitizeFileName($element->ref);
1243 if ($element_doc ===
'order_supplier') {
1244 $element_doc =
'commande_fournisseur';
1245 $filedir = $conf->fournisseur->commande->multidir_output[$element->entity].
'/'.
dol_sanitizeFileName($element->ref);
1246 } elseif ($element_doc ===
'invoice_supplier') {
1247 $element_doc =
'facture_fournisseur';
1248 $filename =
get_exdir($element->id, 2, 0, 0, $element,
'product').dol_sanitizeFileName($element->ref);
1249 $filedir = $conf->fournisseur->facture->multidir_output[$element->entity].
'/'.
get_exdir($element->id, 2, 0, 0, $element,
'invoice_supplier').dol_sanitizeFileName($element->ref);
1252 print
'<div class="inline-block valignmiddle">'.$formfile->getDocumentsLink($element_doc, $filename, $filedir).
'</div>';
1255 if (!empty($element->ref_supplier)) {
1256 print
' - '.$element->ref_supplier;
1259 if (!empty($element->ref_customer)) {
1260 print
' - '.$element->ref_customer;
1266 $date =
''; $total_time_by_line =
null;
1267 if ($tablename ==
'expensereport_det') {
1268 $date = $element->date;
1269 } elseif ($tablename ==
'stock_mouvement') {
1270 $date = $element->datem;
1271 } elseif ($tablename ==
'salary') {
1272 $date = $element->datesp;
1273 } elseif ($tablename ==
'payment_various') {
1274 $date = $element->datev;
1275 } elseif ($tablename ==
'chargesociales') {
1276 $date = $element->date_ech;
1277 } elseif (!empty($element->status) || !empty($element->statut) || !empty($element->fk_status)) {
1278 if ($tablename ==
'don') {
1279 $date = $element->datedon;
1281 if ($tablename ==
'commande_fournisseur' || $tablename ==
'supplier_order') {
1282 $date = ($element->date_commande ? $element->date_commande : $element->date_valid);
1283 } elseif ($tablename ==
'supplier_proposal') {
1284 $date = $element->date_validation;
1285 } elseif ($tablename ==
'fichinter') {
1286 $date = $element->datev;
1287 } elseif ($tablename ==
'projet_task') {
1290 $date = $element->date;
1292 $date = $element->date_contrat;
1295 $date = $element->datev;
1297 if (empty($date) && !empty($datefieldname)) {
1298 $date = $element->$datefieldname;
1301 } elseif ($key ==
'loan') {
1302 $date = $element->datestart;
1305 print
'<td class="center">';
1306 if ($tablename ==
'actioncomm') {
1308 if ($element->datef && $element->datef > $element->datep) {
1309 print
" - ".dol_print_date($element->datef,
'dayhour');
1311 } elseif (in_array($tablename, array(
'projet_task'))) {
1312 $tmpprojtime = $element->getSumOfAmount($elementuser, $dates, $datee);
1313 print
'<a href="'.DOL_URL_ROOT.
'/projet/tasks/time.php?id='.$idofelement.
'&withproject=1">';
1316 $total_time_by_line = $tmpprojtime[
'nbseconds'];
1323 print
'<td class="left">';
1324 if (is_object($element->thirdparty)) {
1325 print $element->thirdparty->getNomUrl(1,
'', 48);
1326 } elseif ($tablename ==
'expensereport_det') {
1327 $tmpuser =
new User($db);
1328 $tmpuser->fetch($expensereport->fk_user_author);
1329 print $tmpuser->getNomUrl(1,
'', 48);
1330 } elseif ($tablename ==
'salary') {
1331 $tmpuser =
new User($db);
1332 $tmpuser->fetch($element->fk_user);
1333 print $tmpuser->getNomUrl(1,
'', 48);
1334 } elseif ($tablename ==
'don' || $tablename ==
'stock_mouvement') {
1335 if ($element->fk_user_author > 0) {
1336 $tmpuser2 =
new User($db);
1337 $tmpuser2->fetch($element->fk_user_author);
1338 print $tmpuser2->getNomUrl(1,
'', 48);
1340 } elseif ($tablename ==
'projet_task' && $key ==
'project_task_time') {
1341 print $elementuser->getNomUrl(1);
1346 if ($tablename ==
'fichinter') {
1348 print
convertSecondToTime($element->duration,
'all', $conf->global->MAIN_DURATION_OF_WORKDAY);
1349 $total_duration += $element->duration;
1355 if (empty($value[
'disableamount'])) {
1356 $total_ht_by_line =
null;
1358 if ($tablename ==
'don' || $tablename ==
'chargesociales' || $tablename ==
'payment_various' || $tablename ==
'salary') {
1359 $total_ht_by_line = $element->amount;
1360 } elseif ($tablename ==
'fichinter') {
1361 $total_ht_by_line = $element->getAmount();
1362 } elseif ($tablename ==
'stock_mouvement') {
1363 $total_ht_by_line = $element->price * abs($element->qty);
1364 } elseif (in_array($tablename, array(
'projet_task'))) {
1365 if (!empty($conf->salaries->enabled)) {
1367 $total_ht_by_line =
price2num($tmpprojtime[
'amount'],
'MT');
1368 if ($tmpprojtime[
'nblinesnull'] > 0) {
1369 $langs->load(
"errors");
1370 $warning = $langs->trans(
"WarningSomeLinesWithNullHourlyRate", $conf->currency);
1373 $othermessage =
$form->textwithpicto($langs->trans(
"NotAvailable"), $langs->trans(
"ModuleSalaryToDefineHourlyRateMustBeEnabled"));
1375 } elseif ($key ==
'loan') {
1376 $total_ht_by_line = $element->capital;
1378 $total_ht_by_line = $element->total_ht;
1382 if ($tablename ==
'payment_various') {
1383 if ($element->sens == 0) {
1384 $total_ht_by_line = -$total_ht_by_line;
1388 print
'<td class="right">';
1389 if ($othermessage) {
1390 print $othermessage;
1392 if (isset($total_ht_by_line)) {
1393 if (!$qualifiedfortotal) {
1396 print
'<span class="amount">'.price($total_ht_by_line).
'</span>';
1397 if (!$qualifiedfortotal) {
1402 print
' '.img_warning($warning);
1410 if (empty($value[
'disableamount'])) {
1411 $total_ttc_by_line =
null;
1412 if ($tablename ==
'don' || $tablename ==
'chargesociales' || $tablename ==
'payment_various' || $tablename ==
'salary') {
1413 $total_ttc_by_line = $element->amount;
1414 } elseif ($tablename ==
'fichinter') {
1415 $total_ttc_by_line = $element->getAmount();
1416 } elseif ($tablename ==
'stock_mouvement') {
1417 $total_ttc_by_line = $element->price * abs($element->qty);
1418 } elseif ($tablename ==
'projet_task') {
1419 if (!empty($conf->salaries->enabled)) {
1422 $total_ttc_by_line =
price2num($total_ht_by_line * (1 + ($defaultvat / 100)),
'MT');
1424 $othermessage =
$form->textwithpicto($langs->trans(
"NotAvailable"), $langs->trans(
"ModuleSalaryToDefineHourlyRateMustBeEnabled"));
1426 } elseif ($key ==
'loan') {
1427 $total_ttc_by_line = $element->capital - $element->getSumPayment();
1429 $total_ttc_by_line = $element->total_ttc;
1433 if ($tablename ==
'payment_various') {
1434 if ($element->sens == 0) {
1435 $total_ttc_by_line = -$total_ttc_by_line;
1439 print
'<td class="right">';
1440 if ($othermessage) {
1441 print $othermessage;
1443 if (isset($total_ttc_by_line)) {
1444 if (!$qualifiedfortotal) {
1447 print
'<span class="amount">'.price($total_ttc_by_line).
'</span>';
1448 if (!$qualifiedfortotal) {
1453 print
' '.img_warning($warning);
1461 print
'<td class="right">';
1462 if ($tablename ==
'expensereport_det') {
1463 print $expensereport->getLibStatut(5);
1466 print $element->getLibStatut(5, $element->getSommePaiement());
1467 } elseif ($element instanceof
Task) {
1468 if ($element->progress !=
'') {
1469 print $element->progress.
' %';
1471 } elseif ($tablename ==
'stock_mouvement') {
1472 print $element->getLibStatut(3);
1474 print $element->getLibStatut(5);
1480 if ($qualifiedfortotal) {
1481 $total_ht = $total_ht + $total_ht_by_line;
1482 $total_ttc = $total_ttc + $total_ttc_by_line;
1484 $total_ht_by_third += $total_ht_by_line;
1485 $total_ttc_by_third += $total_ttc_by_line;
1487 $total_time = $total_time + $total_time_by_line;
1491 $breakline =
'<tr class="liste_total liste_sub_total">';
1492 $breakline .=
'<td colspan="2">';
1493 $breakline .=
'</td>';
1494 $breakline .=
'<td>';
1495 $breakline .=
'</td>';
1496 $breakline .=
'<td class="right">';
1497 $breakline .= $langs->trans(
'SubTotal').
' : ';
1498 if (is_object($element->thirdparty)) {
1499 $breakline .= $element->thirdparty->getNomUrl(0,
'', 48);
1501 $breakline .=
'</td>';
1502 $breakline .=
'<td class="right">'.price($total_ht_by_third).
'</td>';
1503 $breakline .=
'<td class="right">'.price($total_ttc_by_third).
'</td>';
1504 $breakline .=
'<td></td>';
1505 $breakline .=
'</tr>';
1517 if (in_array($tablename, array(
'projet_task'))) {
1521 print
'<tr class="liste_total"><td colspan="'.$colspan.
'">'.$langs->trans(
"Number").
': '.$i.
'</td>';
1522 if (in_array($tablename, array(
'projet_task'))) {
1523 print
'<td class="center">';
1532 if ($tablename ==
'fichinter') {
1533 print
'<td class="left">'.convertSecondToTime($total_duration,
'all', $conf->global->MAIN_DURATION_OF_WORKDAY).
'</td>';
1535 print
'<td class="right">';
1536 if (empty($value[
'disableamount'])) {
1537 if ($key ==
'loan') {
1538 print $langs->trans(
"Total").
' '.$langs->trans(
"LoanCapital").
' : '.
price($total_ttc);
1539 } elseif ($tablename !=
'projet_task' || !empty($conf->salaries->enabled)) {
1540 print
''.$langs->trans(
"TotalHT").
' : '.
price($total_ht);
1546 print
'<td class="right">';
1547 if (empty($value[
'disableamount'])) {
1548 if ($key ==
'loan') {
1549 print $langs->trans(
"Total").
' '.$langs->trans(
"RemainderToPay").
' : '.
price($total_ttc);
1550 } elseif ($tablename !=
'projet_task' || !empty($conf->salaries->enabled)) {
1551 print $langs->trans(
"TotalTTC").
' : '.
price($total_ttc);
1555 print
'<td> </td>';
1558 if (!is_array($elementarray)) {
1559 print
'<tr><td>'.$elementarray.
'</td></tr>';
1562 if (in_array($tablename, array(
'projet_task'))) {
1565 if ($tablename ==
'fichinter') {
1568 print
'<tr><td colspan="'.$colspan.
'"><span class="opacitymedium">'.$langs->trans(
"None").
'</td></tr>';
1578 if ($conf->use_javascript_ajax) {
1579 include_once DOL_DOCUMENT_ROOT.
'/core/lib/ajax.lib.php';
1582 print $comboenhancement;
1601 if (empty($conf->global->PROJECT_ADD_SUBTOTAL_LINES)) {
1604 return in_array($tablename, array(
'facture_fourn',
'commande_fournisseur'));
1615 global $db, $classname;
1617 $element =
new $classname($db);
1619 $clientname = array();
1620 foreach ($elementarray as $key => $id) {
1621 if (empty($clientname[$id])) {
1622 $element->fetch($id);
1623 $element->fetch_thirdparty();
1625 $clientname[$id] = $element->thirdparty->name;
1632 $elementarray = array();
1633 foreach ($clientname as $id => $name) {
1634 $elementarray[] = $id;
1637 return $elementarray;