33require
'../main.inc.php';
34require_once DOL_DOCUMENT_ROOT.
'/projet/class/project.class.php';
35require_once DOL_DOCUMENT_ROOT.
'/projet/class/task.class.php';
36require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formprojet.class.php';
37require_once DOL_DOCUMENT_ROOT.
'/core/lib/project.lib.php';
38require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
39require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
40if (isModEnabled(
'stock')) {
41 require_once DOL_DOCUMENT_ROOT.
'/product/stock/class/entrepot.class.php';
43if (isModEnabled(
"propal")) {
44 require_once DOL_DOCUMENT_ROOT.
'/comm/propal/class/propal.class.php';
46if (isModEnabled(
'facture')) {
47 require_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facture.class.php';
48 require_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facture-rec.class.php';
50if (isModEnabled(
'commande')) {
51 require_once DOL_DOCUMENT_ROOT.
'/commande/class/commande.class.php';
53if (isModEnabled(
'supplier_proposal')) {
54 require_once DOL_DOCUMENT_ROOT.
'/supplier_proposal/class/supplier_proposal.class.php';
56if (isModEnabled(
"supplier_invoice")) {
57 require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.facture.class.php';
59if (isModEnabled(
"supplier_order")) {
60 require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.commande.class.php';
62if (isModEnabled(
'contrat')) {
63 require_once DOL_DOCUMENT_ROOT.
'/contrat/class/contrat.class.php';
65if (isModEnabled(
'ficheinter')) {
66 require_once DOL_DOCUMENT_ROOT.
'/fichinter/class/fichinter.class.php';
68if (isModEnabled(
"expedition")) {
69 require_once DOL_DOCUMENT_ROOT.
'/expedition/class/expedition.class.php';
71if (isModEnabled(
'deplacement')) {
72 require_once DOL_DOCUMENT_ROOT.
'/compta/deplacement/class/deplacement.class.php';
74if (isModEnabled(
'expensereport')) {
75 require_once DOL_DOCUMENT_ROOT.
'/expensereport/class/expensereport.class.php';
77if (isModEnabled(
'agenda')) {
78 require_once DOL_DOCUMENT_ROOT.
'/comm/action/class/actioncomm.class.php';
80if (isModEnabled(
'don')) {
81 require_once DOL_DOCUMENT_ROOT.
'/don/class/don.class.php';
83if (isModEnabled(
'loan')) {
84 require_once DOL_DOCUMENT_ROOT.
'/loan/class/loan.class.php';
85 require_once DOL_DOCUMENT_ROOT.
'/loan/class/loanschedule.class.php';
87if (isModEnabled(
'stock')) {
88 require_once DOL_DOCUMENT_ROOT.
'/product/stock/class/mouvementstock.class.php';
90if (isModEnabled(
'tax')) {
91 require_once DOL_DOCUMENT_ROOT.
'/compta/sociales/class/chargesociales.class.php';
93if (isModEnabled(
"banque")) {
94 require_once DOL_DOCUMENT_ROOT.
'/compta/bank/class/paymentvarious.class.php';
96if (isModEnabled(
'salaries')) {
97 require_once DOL_DOCUMENT_ROOT.
'/salaries/class/salary.class.php';
99if (isModEnabled(
'categorie')) {
100 require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
102if (isModEnabled(
'mrp')) {
103 require_once DOL_DOCUMENT_ROOT.
'/mrp/class/mo.class.php';
107$langs->loadLangs(array(
'projects',
'companies',
'suppliers',
'compta'));
108if (isModEnabled(
'facture')) {
109 $langs->load(
"bills");
111if (isModEnabled(
'commande')) {
112 $langs->load(
"orders");
114if (isModEnabled(
"propal")) {
115 $langs->load(
"propal");
117if (isModEnabled(
'ficheinter')) {
118 $langs->load(
"interventions");
120if (isModEnabled(
'deplacement')) {
121 $langs->load(
"trips");
123if (isModEnabled(
'expensereport')) {
124 $langs->load(
"trips");
126if (isModEnabled(
'don')) {
127 $langs->load(
"donations");
129if (isModEnabled(
'loan')) {
130 $langs->load(
"loan");
132if (isModEnabled(
'salaries')) {
133 $langs->load(
"salaries");
135if (isModEnabled(
'mrp')) {
138if (isModEnabled(
'eventorganization')) {
139 $langs->load(
"eventorganization");
144$action =
GETPOST(
'action',
'aZ09');
145$datesrfc =
GETPOST(
'datesrfc');
146$dateerfc =
GETPOST(
'dateerfc');
149if (empty($dates) && !empty($datesrfc)) {
152if (empty($datee) && !empty($dateerfc)) {
155if (!GETPOSTISSET(
'datesrfc') && !GETPOSTISSET(
'datesday') && !empty($conf->global->PROJECT_LINKED_ELEMENT_DEFAULT_FILTER_YEAR)) {
162if ($id ==
'' && $ref ==
'') {
164 header(
'Location: list.php');
168$mine =
GETPOST(
'mode') ==
'mine' ? 1 : 0;
173include DOL_DOCUMENT_ROOT.
'/core/actions_fetchobject.inc.php';
174if (!empty($conf->global->PROJECT_ALLOW_COMMENT_ON_PROJECT) && method_exists($object,
'fetchComments') && empty($object->comments)) {
175 $object->fetchComments();
179$socid = $object->socid;
181$result =
restrictedArea($user,
'projet', $object->id,
'projet&project');
183$hookmanager->initHooks(array(
'projectOverview'));
190$title = $langs->trans(
'ProjectReferers').
' - '.$object->ref.
' '.$object->name;
191if (!empty($conf->global->MAIN_HTML_TITLE) && preg_match(
'/projectnameonly/', $conf->global->MAIN_HTML_TITLE) && $object->name) {
192 $title = $object->ref.
' '.$object->name.
' - '.$langs->trans(
'ProjectReferers');
195$help_url =
'EN:Module_Projects|FR:Module_Projets|ES:Módulo_Proyectos|DE:Modul_Projekte';
199$form =
new Form($db);
203$userstatic =
new User($db);
206$userAccess = $object->restrictedProjectArea($user);
209print
dol_get_fiche_head($head,
'element', $langs->trans(
"Project"), -1, ($object->public ?
'projectpub' :
'project'));
214if (!empty($_SESSION[
'pageforbacktolist']) && !empty($_SESSION[
'pageforbacktolist'][
'project'])) {
215 $tmpurl = $_SESSION[
'pageforbacktolist'][
'project'];
216 $tmpurl = preg_replace(
'/__SOCID__/', $object->socid, $tmpurl);
217 $linkback =
'<a href="'.$tmpurl.(preg_match(
'/\?/', $tmpurl) ?
'&' :
'?').
'restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
219 $linkback =
'<a href="'.DOL_URL_ROOT.
'/projet/list.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
222$morehtmlref =
'<div class="refidno">';
224$morehtmlref .= $object->title;
226if (!empty($object->thirdparty->id) && $object->thirdparty->id > 0) {
227 $morehtmlref .=
'<br>'.$object->thirdparty->getNomUrl(1,
'project');
229$morehtmlref .=
'</div>';
232if (empty($user->rights->projet->all->lire)) {
233 $objectsListId = $object->getProjectsAuthorizedForUser($user, 0, 0);
234 $object->next_prev_filter =
"te.rowid IN (".$db->sanitize(count($objectsListId) ?join(
',', array_keys($objectsListId)) :
'0').
")";
237dol_banner_tab($object,
'ref', $linkback, 1,
'ref',
'ref', $morehtmlref);
240print
'<div class="fichecenter">';
241print
'<div class="fichehalfleft">';
242print
'<div class="underbanner clearboth"></div>';
244print
'<table class="border tableforfield centpercent">';
247if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES) || empty($conf->global->PROJECT_HIDE_TASKS) || isModEnabled(
'eventorganization')) {
248 print
'<tr><td class="tdtop">';
249 print $langs->trans(
"Usage");
252 if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES)) {
253 print
'<input type="checkbox" disabled name="usage_opportunity"'.(GETPOSTISSET(
'usage_opportunity') ? (
GETPOST(
'usage_opportunity',
'alpha') !=
'' ?
' checked="checked"' :
'') : ($object->usage_opportunity ?
' checked="checked"' :
'')).
'"> ';
254 $htmltext = $langs->trans(
"ProjectFollowOpportunity");
255 print $form->textwithpicto($langs->trans(
"ProjectFollowOpportunity"), $htmltext);
258 if (empty($conf->global->PROJECT_HIDE_TASKS)) {
259 print
'<input type="checkbox" disabled name="usage_task"'.(GETPOSTISSET(
'usage_task') ? (
GETPOST(
'usage_task',
'alpha') !=
'' ?
' checked="checked"' :
'') : ($object->usage_task ?
' checked="checked"' :
'')).
'"> ';
260 $htmltext = $langs->trans(
"ProjectFollowTasks");
261 print $form->textwithpicto($langs->trans(
"ProjectFollowTasks"), $htmltext);
264 if (empty($conf->global->PROJECT_HIDE_TASKS) && !empty($conf->global->PROJECT_BILL_TIME_SPENT)) {
265 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"' :
'')).
'"> ';
266 $htmltext = $langs->trans(
"ProjectBillTimeDescription");
267 print $form->textwithpicto($langs->trans(
"BillTime"), $htmltext);
270 if (isModEnabled(
'eventorganization')) {
271 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"' :
'')).
'"> ';
272 $htmltext = $langs->trans(
"EventOrganizationDescriptionLong");
273 print $form->textwithpicto($langs->trans(
"ManageOrganizeEvent"), $htmltext);
279print
'<tr><td class="titlefield">'.$langs->trans(
"Visibility").
'</td><td>';
280if ($object->public) {
281 print
img_picto($langs->trans(
'SharedProject'),
'world',
'class="paddingrightonly"');
282 print $langs->trans(
'SharedProject');
284 print
img_picto($langs->trans(
'PrivateProject'),
'private',
'class="paddingrightonly"');
285 print $langs->trans(
'PrivateProject');
289if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES)) {
291 print
'<tr><td>'.$langs->trans(
"OpportunityStatus").
'</td><td>';
292 $code =
dol_getIdFromCode($db, $object->opp_status,
'c_lead_status',
'rowid',
'code');
294 print $langs->trans(
"OppStatus".$code);
299 print
'<tr><td>'.$langs->trans(
"OpportunityProbability").
'</td><td>';
300 if (!is_null($object->opp_percent) && strcmp($object->opp_percent,
'')) {
301 print
price($object->opp_percent,
'', $langs, 1, 0).
' %';
306 print
'<tr><td>'.$langs->trans(
"OpportunityAmount").
'</td><td>';
307 if (!is_null($object->opp_amount) && strcmp($object->opp_amount,
'')) {
308 print
'<span class="amount">'.price($object->opp_amount,
'', $langs, 1, 0, 0, $conf->currency).
'</span>';
309 if (strcmp($object->opp_percent,
'')) {
310 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>';
317print
'<tr><td>'.$langs->trans(
"Budget").
'</td><td>';
318if (!is_null($object->budget_amount) && strcmp($object->budget_amount,
'')) {
319 print
'<span class="amount">'.price($object->budget_amount,
'', $langs, 1, 0, 0, $conf->currency).
'</span>';
324print
'<tr><td>'.$langs->trans(
"Dates").
'</td><td>';
326print ($start ? $start :
'?');
329print ($end ? $end :
'?');
330if ($object->hasDelay()) {
337include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_view.tpl.php';
342print
'<div class="fichehalfright">';
343print
'<div class="underbanner clearboth"></div>';
345print
'<table class="border tableforfield centpercent">';
348print
'<td class="titlefield tdtop">'.$langs->trans(
"Description").
'</td><td>';
353if (isModEnabled(
'categorie')) {
354 print
'<tr><td class="valignmiddle">'.$langs->trans(
"Categories").
'</td><td>';
355 print $form->showCategories($object->id, Categorie::TYPE_PROJECT, 1);
364print
'<div class="clearboth"></div>';
374$listofreferent = array(
377 'title'=>
"ListWarehouseAssociatedProject",
380 'datefieldname'=>
'date_entrepot',
381 'urlnew'=>DOL_URL_ROOT.
'/product/stock/card.php?action=create&projectid='.$id.
'&backtopage='.urlencode($_SERVER[
'PHP_SELF'].
'?id='.$id),
383 'buttonnew'=>
'AddWarehouse',
384 'project_field'=>
'fk_project',
385 'testnew'=>$user->hasRight(
'stock',
'creer'),
386 'test'=>isModEnabled(
'stock') && $user->hasRight(
'stock',
'lire') && !empty($conf->global->WAREHOUSE_ASK_WAREHOUSE_DURING_PROJECT)
390 'title'=>
"ListProposalsAssociatedProject",
393 'datefieldname'=>
'datep',
394 'urlnew'=>DOL_URL_ROOT.
'/comm/propal/card.php?action=create&origin=project&originid='.$id.
'&socid='.$socid.
'&backtopage='.urlencode($_SERVER[
'PHP_SELF'].
'?id='.$id),
396 'buttonnew'=>
'AddProp',
397 'testnew'=>$user->hasRight(
'propal',
'creer'),
398 'test'=>isModEnabled(
'propal') && $user->hasRight(
'propal',
'lire')
401 'name'=>
"CustomersOrders",
402 'title'=>
"ListOrdersAssociatedProject",
405 'datefieldname'=>
'date_commande',
406 'urlnew'=>DOL_URL_ROOT.
'/commande/card.php?action=create&projectid='.$id.
'&socid='.$socid.
'&backtopage='.urlencode($_SERVER[
'PHP_SELF'].
'?id='.$id),
408 'buttonnew'=>
'CreateOrder',
409 'testnew'=>$user->hasRight(
'commande',
'creer'),
410 'test'=>isModEnabled(
'commande') && $user->hasRight(
'commande',
'lire')
413 'name'=>
"CustomersInvoices",
414 'title'=>
"ListInvoicesAssociatedProject",
418 'datefieldname'=>
'datef',
419 'urlnew'=>DOL_URL_ROOT.
'/compta/facture/card.php?action=create&projectid='.$id.
'&socid='.$socid.
'&backtopage='.urlencode($_SERVER[
'PHP_SELF'].
'?id='.$id),
421 'buttonnew'=>
'CreateBill',
422 'testnew'=>$user->hasRight(
'facture',
'creer'),
423 'test'=>isModEnabled(
'facture') && $user->hasRight(
'facture',
'lire')
425 'invoice_predefined'=>array(
426 'name'=>
"PredefinedInvoices",
427 'title'=>
"ListPredefinedInvoicesAssociatedProject",
428 'class'=>
'FactureRec',
429 'table'=>
'facture_rec',
430 'datefieldname'=>
'datec',
431 'urlnew'=>DOL_URL_ROOT.
'/compta/facture/card.php?action=create&projectid='.$id.
'&socid='.$socid.
'&backtopage='.urlencode($_SERVER[
'PHP_SELF'].
'?id='.$id),
433 'buttonnew'=>
'CreateBill',
434 'testnew'=>$user->hasRight(
'facture',
'creer'),
435 'test'=>isModEnabled(
'facture') && $user->hasRight(
'facture',
'lire')
437 'proposal_supplier'=>array(
438 'name'=>
"SupplierProposals",
439 'title'=>
"ListSupplierProposalsAssociatedProject",
440 'class'=>
'SupplierProposal',
441 'table'=>
'supplier_proposal',
442 'datefieldname'=>
'date_valid',
443 'urlnew'=>DOL_URL_ROOT.
'/supplier_proposal/card.php?action=create&projectid='.$id.
'&backtopage='.urlencode($_SERVER[
'PHP_SELF'].
'?id='.$id),
444 'lang'=>
'supplier_proposal',
445 'buttonnew'=>
'AddSupplierProposal',
446 'testnew'=>$user->hasRight(
'supplier_proposal',
'creer'),
447 'test'=>isModEnabled(
'supplier_proposal') && $user->hasRight(
'supplier_proposal',
'lire')
449 'order_supplier'=>array(
450 'name'=>
"SuppliersOrders",
451 'title'=>
"ListSupplierOrdersAssociatedProject",
452 'class'=>
'CommandeFournisseur',
453 'table'=>
'commande_fournisseur',
454 'datefieldname'=>
'date_commande',
455 'urlnew'=>DOL_URL_ROOT.
'/fourn/commande/card.php?action=create&projectid='.$id.
'&backtopage='.urlencode($_SERVER[
'PHP_SELF'].
'?id='.$id),
457 'buttonnew'=>
'AddSupplierOrder',
458 'testnew'=>$user->hasRight(
'fournisseur',
'commande',
'creer') || $user->hasRight(
'supplier_order',
'creer'),
459 'test'=>isModEnabled(
'supplier_order') && $user->hasRight(
'fournisseur',
'commande',
'lire') || $user->hasRight(
'supplier_order',
'lire')
461 'invoice_supplier'=>array(
462 'name'=>
"BillsSuppliers",
463 'title'=>
"ListSupplierInvoicesAssociatedProject",
464 'class'=>
'FactureFournisseur',
466 'table'=>
'facture_fourn',
467 'datefieldname'=>
'datef',
468 'urlnew'=>DOL_URL_ROOT.
'/fourn/facture/card.php?action=create&projectid='.$id.
'&backtopage='.urlencode($_SERVER[
'PHP_SELF'].
'?id='.$id),
470 'buttonnew'=>
'AddSupplierInvoice',
471 'testnew'=>$user->hasRight(
'fournisseur',
'facture',
'creer') || $user->hasRight(
'supplier_invoice',
'creer'),
472 'test'=>isModEnabled(
'supplier_invoice') && $user->hasRight(
'fournisseur',
'facture',
'lire') || $user->hasRight(
'supplier_invoice',
'lire')
476 'title'=>
"ListContractAssociatedProject",
479 'datefieldname'=>
'date_contrat',
480 'urlnew'=>DOL_URL_ROOT.
'/contrat/card.php?action=create&projectid='.$id.
'&socid='.$socid.
'&backtopage='.urlencode($_SERVER[
'PHP_SELF'].
'?id='.$id),
482 'buttonnew'=>
'AddContract',
483 'testnew'=>$user->hasRight(
'contrat',
'creer'),
484 'test'=>isModEnabled(
'contrat') && $user->hasRight(
'contrat',
'lire')
486 'intervention'=>array(
487 'name'=>
"Interventions",
488 'title'=>
"ListFichinterAssociatedProject",
489 'class'=>
'Fichinter',
490 'table'=>
'fichinter',
491 'datefieldname'=>
'date_valid',
494 'urlnew'=>DOL_URL_ROOT.
'/fichinter/card.php?action=create&origin=project&originid='.$id.
'&socid='.$socid.
'&backtopage='.urlencode($_SERVER[
'PHP_SELF'].
'?id='.$id),
495 'lang'=>
'interventions',
496 'buttonnew'=>
'AddIntervention',
497 'testnew'=>$user->hasRight(
'ficheinter',
'creer'),
498 'test'=>isModEnabled(
'ficheinter') && $user->hasRight(
'ficheinter',
'lire')
502 'title'=>
"ListShippingAssociatedProject",
503 'class'=>
'Expedition',
504 'table'=>
'expedition',
505 'datefieldname'=>
'date_valid',
506 'urlnew'=>DOL_URL_ROOT.
'/expedition/card.php?action=create&origin=project&originid='.$id.
'&socid='.$socid.
'&backtopage='.urlencode($_SERVER[
'PHP_SELF'].
'?id='.$id),
508 'buttonnew'=>
'CreateShipment',
510 'test'=>isModEnabled(
'expedition') && $user->hasRight(
'expedition',
'lire')
514 'title'=>
"ListMOAssociatedProject",
517 'datefieldname'=>
'date_valid',
518 'urlnew'=>DOL_URL_ROOT.
'/mrp/mo_card.php?action=create&origin=project&originid='.$id.
'&socid='.$socid.
'&backtopage='.urlencode($_SERVER[
'PHP_SELF'].
'?id='.$id),
520 'buttonnew'=>
'CreateMO',
521 'testnew'=>$user->hasRight(
'mrp',
'write'),
522 'project_field'=>
'fk_project',
524 'test'=>isModEnabled(
'mrp') && $user->hasRight(
'mrp',
'read')
527 'name'=>
"TripsAndExpenses",
528 'title'=>
"ListExpenseReportsAssociatedProject",
529 'class'=>
'Deplacement',
530 'table'=>
'deplacement',
531 'datefieldname'=>
'dated',
534 'urlnew'=>DOL_URL_ROOT.
'/deplacement/card.php?action=create&projectid='.$id.
'&socid='.$socid.
'&backtopage='.urlencode($_SERVER[
'PHP_SELF'].
'?id='.$id),
536 'buttonnew'=>
'AddTrip',
537 'testnew'=>$user->hasRight(
'deplacement',
'creer'),
538 'test'=>isModEnabled(
'deplacement') && $user->hasRight(
'deplacement',
'lire')
540 'expensereport'=>array(
541 'name'=>
"ExpenseReports",
542 'title'=>
"ListExpenseReportsAssociatedProject",
543 'class'=>
'ExpenseReportLine',
544 'table'=>
'expensereport_det',
545 'datefieldname'=>
'date',
548 'urlnew'=>DOL_URL_ROOT.
'/expensereport/card.php?action=create&projectid='.$id.
'&socid='.$socid.
'&backtopage='.urlencode($_SERVER[
'PHP_SELF'].
'?id='.$id),
550 'buttonnew'=>
'AddTrip',
551 'testnew'=>$user->hasRight(
'expensereport',
'creer'),
552 'test'=>isModEnabled(
'expensereport') && $user->hasRight(
'expensereport',
'lire')
556 'title'=>
"ListDonationsAssociatedProject",
560 'datefieldname'=>
'datedon',
562 'urlnew'=>DOL_URL_ROOT.
'/don/card.php?action=create&projectid='.$id.
'&socid='.$socid.
'&backtopage='.urlencode($_SERVER[
'PHP_SELF'].
'?id='.$id),
564 'buttonnew'=>
'AddDonation',
565 'testnew'=>$user->hasRight(
'don',
'creer'),
566 'test'=>isModEnabled(
'don') && $user->hasRight(
'don',
'lire')
570 'title'=>
"ListLoanAssociatedProject",
574 'datefieldname'=>
'datestart',
576 'urlnew'=>DOL_URL_ROOT.
'/loan/card.php?action=create&projectid='.$id.
'&socid='.$socid.
'&backtopage='.urlencode($_SERVER[
'PHP_SELF'].
'?id='.$id),
578 'buttonnew'=>
'AddLoan',
579 'testnew'=>$user->hasRight(
'loan',
'write'),
580 'test'=>isModEnabled(
'loan') && $user->hasRight(
'loan',
'read')
582 'chargesociales'=>array(
583 'name'=>
"SocialContribution",
584 'title'=>
"ListSocialContributionAssociatedProject",
585 'class'=>
'ChargeSociales',
587 'table'=>
'chargesociales',
588 'datefieldname'=>
'date_ech',
590 'urlnew'=>DOL_URL_ROOT.
'/compta/sociales/card.php?action=create&projectid='.$id.
'&backtopage='.urlencode($_SERVER[
'PHP_SELF'].
'?id='.$id),
592 'buttonnew'=>
'AddSocialContribution',
593 'testnew'=>$user->hasRight(
'tax',
'charges',
'lire'),
594 'test'=>isModEnabled(
'tax') && $user->hasRight(
'tax',
'charges',
'lire')
596 'project_task'=>array(
597 'name'=>
"TaskTimeSpent",
598 'title'=>
"ListTaskTimeUserProject",
601 'table'=>
'projet_task',
602 'datefieldname'=>
'element_date',
604 'urlnew'=>DOL_URL_ROOT.
'/projet/tasks/time.php?withproject=1&action=createtime&projectid='.$id.
'&backtopage='.urlencode($_SERVER[
'PHP_SELF'].
'?id='.$id),
605 'buttonnew'=>
'AddTimeSpent',
606 'testnew'=>$user->hasRight(
'project',
'creer'),
607 'test'=>isModEnabled(
'project') && $user->hasRight(
'projet',
'lire') && empty($conf->global->PROJECT_HIDE_TASKS)
609 'stock_mouvement'=>array(
610 'name'=>
"MouvementStockAssociated",
611 'title'=>
"ListMouvementStockProject",
612 'class'=>
'MouvementStock',
613 'table'=>
'stock_mouvement',
614 'datefieldname'=>
'datem',
617 'test'=>isModEnabled(
'stock') && $user->hasRight(
'stock',
'mouvement',
'lire') && !empty($conf->global->STOCK_MOVEMENT_INTO_PROJECT_OVERVIEW)
621 'title'=>
"ListSalariesAssociatedProject",
624 'datefieldname'=>
'datesp',
627 'urlnew'=>DOL_URL_ROOT.
'/salaries/card.php?action=create&projectid='.$id.
'&backtopage='.urlencode($_SERVER[
'PHP_SELF'].
'?id='.$id),
629 'buttonnew'=>
'AddSalary',
630 'testnew'=>$user->hasRight(
'salaries',
'write'),
631 'test'=>isModEnabled(
'salaries') && $user->hasRight(
'salaries',
'read')
633 'variouspayment'=>array(
634 'name'=>
"VariousPayments",
635 'title'=>
"ListVariousPaymentsAssociatedProject",
636 'class'=>
'PaymentVarious',
637 'table'=>
'payment_various',
638 'datefieldname'=>
'datev',
641 'urlnew'=>DOL_URL_ROOT.
'/compta/bank/various_payment/card.php?action=create&projectid='.$id.
'&backtopage='.urlencode($_SERVER[
'PHP_SELF'].
'?id='.$id),
643 'buttonnew'=>
'AddVariousPayment',
644 'testnew'=>$user->hasRight(
'banque',
'modifier'),
645 'test'=>isModEnabled(
"banque") && $user->hasRight(
'banque',
'lire') && empty($conf->global->BANK_USE_OLD_VARIOUS_PAYMENT)
664if (!empty($conf->global->PROJECT_ELEMENTS_FOR_PLUS_MARGIN)) {
665 foreach ($listofreferent as $key => $element) {
666 if ($listofreferent[$key][
'margin'] ==
'add') {
667 unset($listofreferent[$key][
'margin']);
670 $newelementforplusmargin = explode(
',', $conf->global->PROJECT_ELEMENTS_FOR_PLUS_MARGIN);
671 foreach ($newelementforplusmargin as $value) {
672 $listofreferent[trim($value)][
'margin'] =
'add';
675if (!empty($conf->global->PROJECT_ELEMENTS_FOR_MINUS_MARGIN)) {
676 foreach ($listofreferent as $key => $element) {
677 if ($listofreferent[$key][
'margin'] ==
'minus') {
678 unset($listofreferent[$key][
'margin']);
681 $newelementforminusmargin = explode(
',', $conf->global->PROJECT_ELEMENTS_FOR_MINUS_MARGIN);
682 foreach ($newelementforminusmargin as $value) {
683 $listofreferent[trim($value)][
'margin'] =
'minus';
688$parameters = array(
'listofreferent'=>$listofreferent);
689$resHook = $hookmanager->executeHooks(
'completeListOfReferent', $parameters, $object, $action);
691if (!empty($hookmanager->resArray)) {
692 $listofreferent = array_merge($listofreferent, $hookmanager->resArray);
695if ($action ==
"addelement") {
696 $tablename =
GETPOST(
"tablename");
697 $elementselectid =
GETPOST(
"elementselect");
698 $result = $object->update_element($tablename, $elementselectid);
702} elseif ($action ==
"unlink") {
703 $tablename =
GETPOST(
"tablename",
"aZ09");
704 $projectField = GETPOSTISSET(
'projectfield') ?
GETPOST(
'projectfield',
'aZ09') :
'fk_projet';
705 $elementselectid =
GETPOST(
"elementselect",
"int");
707 $result = $object->remove_element($tablename, $elementselectid, $projectField);
713$elementuser =
new User($db);
719if (!$showdatefilter) {
720 print
'<div class="center centpercent">';
721 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'" method="POST">';
722 print
'<input type="hidden" name="token" value="'.newToken().
'">';
723 print
'<input type="hidden" name="tablename" value="'.(empty($tablename) ?
'' : $tablename).
'">';
724 print
'<input type="hidden" name="action" value="view">';
725 print
'<div class="inline-block">';
726 print $form->selectDate($dates,
'dates', 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
"From"));
728 print
'<div class="inline-block">';
729 print $form->selectDate($datee,
'datee', 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
"to"));
731 print
'<div class="inline-block">';
732 print
'<input type="submit" name="refresh" value="'.$langs->trans(
"Refresh").
'" class="button small">';
744$langs->loadLangs(array(
"suppliers",
"bills",
"orders",
"proposals",
"margins"));
746if (isModEnabled(
'stock')) {
747 $langs->load(
'stocks');
752print
'<table class="noborder centpercent">';
753print
'<tr class="liste_titre">';
754print
'<td class="left" width="200">';
755$tooltiponprofit = $langs->trans(
"ProfitIsCalculatedWith").
"<br>\n";
756$tooltiponprofitplus = $tooltiponprofitminus =
'';
757foreach ($listofreferent as $key => $value) {
758 if (!empty($value[
'lang'])) {
759 $langs->load($value[
'lang']);
761 $name = $langs->trans($value[
'name']);
762 $qualified = $value[
'test'];
763 $margin = empty($value[
'margin']) ?
'' : $value[
'margin'];
764 if ($qualified && isset($margin)) {
765 if ($margin ===
'add') {
766 $tooltiponprofitplus .=
' > '.$name.
" (+)<br>\n";
768 if ($margin ===
'minus') {
769 $tooltiponprofitminus .=
' > '.$name.
" (-)<br>\n";
773$tooltiponprofit .= $tooltiponprofitplus;
774$tooltiponprofit .= $tooltiponprofitminus;
775print $form->textwithpicto($langs->trans(
"Element"), $tooltiponprofit);
777print
'<td class="right" width="100">'.$langs->trans(
"Number").
'</td>';
778print
'<td class="right" width="100">'.$langs->trans(
"AmountHT").
'</td>';
779print
'<td class="right" width="100">'.$langs->trans(
"AmountTTC").
'</td>';
782$total_revenue_ht = 0;
787foreach ($listofreferent as $key => $value) {
789 'total_revenue_ht' =>& $total_revenue_ht,
790 'balance_ht' =>& $balance_ht,
791 'balance_ttc' =>& $balance_ttc,
797 $reshook = $hookmanager->executeHooks(
'printOverviewProfit', $parameters, $object, $action);
800 } elseif ($reshook > 0) {
801 print $hookmanager->resPrint;
805 $name = $langs->trans($value[
'name']);
806 $title = $value[
'title'];
807 $classname = $value[
'class'];
808 $tablename = $value[
'table'];
809 $datefieldname = $value[
'datefieldname'];
810 $qualified = $value[
'test'];
811 $margin = empty($value[
'margin']) ? 0 : $value[
'margin'];
812 $project_field = empty($value[
'project_field']) ?
'' : $value[
'project_field'];
813 if ($qualified && isset($margin)) {
814 $element =
new $classname($db);
816 $elementarray = $object->get_element_list($key, $tablename, $datefieldname, $dates, $datee, !empty($project_field) ? $project_field :
'fk_projet');
818 if (is_array($elementarray) && count($elementarray) > 0) {
823 $num = count($elementarray);
824 for ($i = 0; $i < $num; $i++) {
825 $tmp = explode(
'_', $elementarray[$i]);
826 $idofelement = $tmp[0];
827 $idofelementuser = !empty($tmp[1]) ? $tmp[1] :
"";
829 $element->fetch($idofelement);
830 if ($idofelementuser) {
831 $elementuser->fetch($idofelementuser);
835 $qualifiedfortotal =
true;
836 if ($key ==
'invoice') {
837 if (!empty($element->close_code) && $element->close_code ==
'replaced') {
838 $qualifiedfortotal =
false;
840 if (!empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS) && $element->type ==
Facture::TYPE_DEPOSIT) {
841 $qualifiedfortotal =
false;
844 if ($key ==
'propal') {
846 $qualifiedfortotal =
false;
850 if ($tablename !=
'expensereport_det' && method_exists($element,
'fetch_thirdparty')) {
851 $element->fetch_thirdparty();
855 if ($tablename ==
'don' || $tablename ==
'chargesociales' || $tablename ==
'payment_various' || $tablename ==
'salary') {
856 $total_ht_by_line = $element->amount;
857 } elseif ($tablename ==
'fichinter') {
858 $total_ht_by_line = $element->getAmount();
859 } elseif ($tablename ==
'stock_mouvement') {
860 $total_ht_by_line = $element->price * abs($element->qty);
861 } elseif ($tablename ==
'projet_task') {
862 if ($idofelementuser) {
863 $tmp = $element->getSumOfAmount($elementuser, $dates, $datee);
864 $total_ht_by_line =
price2num($tmp[
'amount'],
'MT');
866 $tmp = $element->getSumOfAmount(
'', $dates, $datee);
867 $total_ht_by_line =
price2num($tmp[
'amount'],
'MT');
869 } elseif ($key ==
'loan') {
870 if ((empty($dates) && empty($datee)) || (intval($dates) <= $element->datestart && intval($datee) >= $element->dateend)) {
872 $total_ht_by_line = -$element->capital;
875 $total_ht_by_line = 0;
877 $loanScheduleStatic->fetchAll($element->id);
878 if (!empty($loanScheduleStatic->lines)) {
879 foreach ($loanScheduleStatic->lines as $loanSchedule) {
883 if (($loanSchedule->datep >= $dates && $loanSchedule->datep <= $datee)
884 || !empty($dates) && empty($datee) && $loanSchedule->datep >= $dates && $loanSchedule->datep <=
dol_now()
885 || empty($dates) && !empty($datee) && $loanSchedule->datep <= $datee
887 $total_ht_by_line -= $loanSchedule->amount_capital;
893 $total_ht_by_line = $element->total_ht;
897 if ($tablename ==
'don' || $tablename ==
'chargesociales' || $tablename ==
'payment_various' || $tablename ==
'salary') {
898 $total_ttc_by_line = $element->amount;
899 } elseif ($tablename ==
'fichinter') {
900 $total_ttc_by_line = $element->getAmount();
901 } elseif ($tablename ==
'stock_mouvement') {
902 $total_ttc_by_line = $element->price * abs($element->qty);
903 } elseif ($tablename ==
'projet_task') {
905 $total_ttc_by_line =
price2num($total_ht_by_line * (1 + ($defaultvat / 100)),
'MT');
906 } elseif ($key ==
'loan') {
907 $total_ttc_by_line = $total_ht_by_line;
909 $total_ttc_by_line = $element->total_ttc;
913 if ($tablename ==
'payment_various') {
914 if ($element->sens == 1) {
915 $total_ht_by_line = -$total_ht_by_line;
916 $total_ttc_by_line = -$total_ttc_by_line;
921 if ($tablename ==
'commande_fournisseur' || $tablename ==
'supplier_proposal') {
922 $total_ht_by_line = -$total_ht_by_line;
923 $total_ttc_by_line = -$total_ttc_by_line;
927 if ($qualifiedfortotal) {
928 $total_ht = $total_ht + $total_ht_by_line;
929 $total_ttc = $total_ttc + $total_ttc_by_line;
937 if ($margin ===
'add') {
938 $total_revenue_ht += $total_ht;
941 if ($margin ===
"minus") {
942 $total_ht = -$total_ht;
943 $total_ttc = -$total_ttc;
946 $balance_ht += $total_ht;
947 $balance_ttc += $total_ttc;
950 print
'<tr class="oddeven">';
952 print
'<td class="left">'.$name.
'</td>';
954 print
'<td class="right">'.$i.
'</td>';
956 print
'<td class="right">';
957 if ($key ==
'intervention' && !$margin) {
958 print
'<span class="opacitymedium">'.$form->textwithpicto($langs->trans(
"NA"), $langs->trans(
"AmountOfInteventionNotIncludedByDefault")).
'</span>';
960 if ($key ==
'propal') {
961 print
'<span class="opacitymedium">'.$form->textwithpicto(
'', $langs->trans(
"SignedOnly")).
'</span>';
963 print
price($total_ht);
967 print
'<td class="right">';
968 if ($key ==
'intervention' && !$margin) {
969 print
'<span class="opacitymedium">'.$form->textwithpicto($langs->trans(
"NA"), $langs->trans(
"AmountOfInteventionNotIncludedByDefault")).
'</span>';
971 if ($key ==
'propal') {
972 print
'<span class="opacitymedium">'.$form->textwithpicto(
'', $langs->trans(
"SignedOnly")).
'</span>';
974 print
price($total_ttc);
982print
'<tr class="liste_total">';
983print
'<td class="right" colspan="2">'.$langs->trans(
"Profit").
'</td>';
984print
'<td class="right">'.price(
price2num($balance_ht,
'MT')).
'</td>';
985print
'<td class="right">'.price(
price2num($balance_ttc,
'MT')).
'</td>';
989if ($total_revenue_ht) {
990 print
'<tr class="liste_total">';
991 print
'<td class="right" colspan="2">'.$langs->trans(
"Margin").
'</td>';
992 print
'<td class="right">'.round(100 * $balance_ht / $total_revenue_ht, 1).
'%</td>';
993 print
'<td class="right"></td>';
1006foreach ($listofreferent as $key => $value) {
1007 $parameters = array(
1013 $reshook = $hookmanager->executeHooks(
'printOverviewDetail', $parameters, $object, $action);
1016 } elseif ($reshook > 0) {
1017 print $hookmanager->resPrint;
1021 $title = $value[
'title'];
1022 $classname = $value[
'class'];
1023 $tablename = $value[
'table'];
1024 $datefieldname = $value[
'datefieldname'];
1025 $qualified = $value[
'test'];
1026 $urlnew = empty($value[
'urlnew']) ?
'' : $value[
'urlnew'];
1027 $buttonnew = empty($value[
'buttonnew']) ?
'' : $value[
'buttonnew'];
1028 $testnew = empty($value[
'testnew']) ?
'' : $value[
'testnew'];
1029 $project_field = empty($value[
'project_field']) ?
'' : $value[
'project_field'];
1030 $nototal = empty($value[
'nototal']) ? 0 : 1;
1032 $exclude_select_element = array(
'payment_various');
1033 if (!empty($value[
'exclude_select_element'])) {
1034 $exclude_select_element[] = $value[
'exclude_select_element'];
1041 $element =
new $classname($db);
1045 $idtofilterthirdparty = 0;
1046 $array_of_element_linkable_with_different_thirdparty = array(
'facture_fourn',
'commande_fournisseur');
1047 if (!in_array($tablename, $array_of_element_linkable_with_different_thirdparty)) {
1048 $idtofilterthirdparty = empty($object->thirdparty->id) ? 0 : $object->thirdparty->id;
1049 if (!empty($conf->global->PROJECT_OTHER_THIRDPARTY_ID_TO_ADD_ELEMENTS)) {
1050 $idtofilterthirdparty .=
','.$conf->global->PROJECT_OTHER_THIRDPARTY_ID_TO_ADD_ELEMENTS;
1054 $elementarray = $object->get_element_list($key, $tablename, $datefieldname, $dates, $datee, !empty($project_field) ? $project_field :
'fk_projet');
1057 if (empty($conf->global->PROJECT_LINK_ON_OVERWIEW_DISABLED) && $idtofilterthirdparty && !in_array($tablename, $exclude_select_element)) {
1058 $selectList = $formproject->select_element($tablename, $idtofilterthirdparty,
'minwidth300 minwidth75imp', -2, empty($project_field) ?
'fk_projet' : $project_field, $langs->trans(
"SelectElement"));
1059 if ($selectList < 0) {
1061 } elseif ($selectList) {
1063 $addform .=
'<div class="inline-block valignmiddle">';
1064 $addform .=
'<form action="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'" method="post">';
1065 $addform .=
'<input type="hidden" name="token" value="'.newToken().
'">';
1066 $addform .=
'<input type="hidden" name="tablename" value="'.$tablename.
'">';
1067 $addform .=
'<input type="hidden" name="action" value="addelement">';
1068 $addform .=
'<input type="hidden" name="datesrfc" value="'.dol_print_date($dates,
'dayhourrfc').
'">';
1069 $addform .=
'<input type="hidden" name="dateerfc" value="'.dol_print_date($datee,
'dayhourrfc').
'">';
1070 $addform .=
'<table><tr>';
1072 $addform .=
'<td>'.$selectList.
'</td>';
1073 $addform .=
'<td><input type="submit" class="button button-linkto smallpaddingimp" value="'.dol_escape_htmltag($langs->trans(
"LinkToElementShort")).
'"></td>';
1074 $addform .=
'</tr></table>';
1075 $addform .=
'</form>';
1076 $addform .=
'</div>';
1079 if (empty($conf->global->PROJECT_CREATE_ON_OVERVIEW_DISABLED) && $urlnew) {
1080 $addform .=
'<div class="inline-block valignmiddle">';
1082 $addform .=
'<a class="buttonxxx marginleftonly" href="'.$urlnew.
'" title="'.
dol_escape_htmltag($langs->trans($buttonnew)).
'"><span class="fa fa-plus-circle valignmiddle paddingleft"></span></a>';
1083 } elseif (empty($conf->global->MAIN_BUTTON_HIDE_UNAUTHORIZED)) {
1084 $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>';
1086 $addform .=
'<div>';
1089 if (is_array($elementarray) && count($elementarray) > 0 && $key ==
"order_supplier") {
1090 $addform =
'<div class="inline-block valignmiddle"><a id="btnShow" class="buttonxxx marginleftonly" href="#" onClick="return false;">
1091 <span id="textBtnShow" class="valignmiddle text-plus-circle hideonsmartphone">'.$langs->trans(
"CanceledShown").
'</span><span id="minus-circle" class="fa fa-eye valignmiddle paddingleft"></span>
1094 $("#btnShow").on("click", function () {
1095 console.log("We click to show or hide the canceled lines");
1096 var attr = $(this).attr("data-canceledarehidden");
1097 if (typeof attr !== "undefined" && attr !== false) {
1098 console.log("Show canceled");
1099 $(".tr_canceled").show();
1100 $("#textBtnShow").text("'.
dol_escape_js($langs->transnoentitiesnoconv(
"CanceledShown")).
'");
1101 $("#btnShow").removeAttr("data-canceledarehidden");
1102 $("#minus-circle").removeClass("fa-eye-slash").addClass("fa-eye");
1104 console.log("Hide canceled");
1105 $(".tr_canceled").hide();
1106 $("#textBtnShow").text("'.
dol_escape_js($langs->transnoentitiesnoconv(
"CanceledHidden")).
'");
1107 $("#btnShow").attr("data-canceledarehidden", 1);
1108 $("#minus-circle").removeClass("fa-eye").addClass("fa-eye-slash");
1111 </script></div> '.$addform;
1116 print
"\n".
'<!-- Table for tablename = '.$tablename.
' -->'.
"\n";
1117 print
'<div class="div-table-responsive">';
1118 print
'<table class="noborder centpercent">';
1120 print
'<tr class="liste_titre">';
1122 print
'<td style="width: 24px"></td>';
1124 print
'<td'.(($tablename !=
'actioncomm' && $tablename !=
'projet_task') ?
' style="width: 200px"' :
'').
'>'.$langs->trans(
"Ref").
'</td>';
1126 print
'<td'.(($tablename !=
'actioncomm' && $tablename !=
'projet_task') ?
' style="width: 200px"' :
'').
' class="center">';
1127 if (in_array($tablename, array(
'projet_task'))) {
1128 print $langs->trans(
"TimeSpent");
1130 if (!in_array($tablename, array(
'projet_task'))) {
1131 print $langs->trans(
"Date");
1136 if (in_array($tablename, array(
'projet_task')) && $key ==
'project_task') {
1138 } elseif (in_array($tablename, array(
'payment_various'))) {
1140 } elseif (in_array($tablename, array(
'expensereport_det',
'don',
'projet_task',
'stock_mouvement',
'salary'))) {
1141 print $langs->trans(
"User");
1143 print $langs->trans(
"ThirdParty");
1147 if ($tablename ==
'fichinter') {
1149 print $langs->trans(
"TotalDuration");
1150 $total_duration = 0;
1156 if ($key ==
'loan') {
1157 print
'<td class="right" width="120">'.$langs->trans(
"LoanCapital").
'</td>';
1158 } elseif (empty($value[
'disableamount'])) {
1159 print
'<td class="right" width="120">'.$langs->trans(
"AmountHT").
'</td>';
1161 print
'<td width="120"></td>';
1165 if ($key ==
'loan') {
1166 print
'<td class="right" width="120">'.$langs->trans(
"RemainderToPay").
'</td>';
1167 } elseif (empty($value[
'disableamount'])) {
1168 print
'<td class="right" width="120">'.$langs->trans(
"AmountTTC").
'</td>';
1170 print
'<td width="120"></td>';
1173 if (in_array($tablename, array(
'projet_task'))) {
1174 print
'<td class="right" width="200">'.$langs->trans(
"ProgressDeclared").
'</td>';
1176 print
'<td class="right" width="200">'.$langs->trans(
"Status").
'</td>';
1180 if (is_array($elementarray) && count($elementarray) > 0) {
1184 $total_ht_by_third = 0;
1185 $total_ttc_by_third = 0;
1187 $saved_third_id = 0;
1195 $num = count($elementarray);
1197 for ($i = 0; $i < $num; $i++) {
1198 $tmp = explode(
'_', $elementarray[$i]);
1199 $idofelement = $tmp[0];
1200 $idofelementuser = isset($tmp[1]) ? $tmp[1] :
"";
1202 $element->fetch($idofelement);
1203 if ($idofelementuser) {
1204 $elementuser->fetch($idofelementuser);
1208 if ($tablename !=
'expensereport_det') {
1209 if (method_exists($element,
'fetch_thirdparty')) {
1210 $element->fetch_thirdparty();
1214 $expensereport->fetch($element->fk_expensereport);
1219 if ($breakline && $saved_third_id != $element->thirdparty->id) {
1222 $saved_third_id = $element->thirdparty->id;
1225 $total_ht_by_third = 0;
1226 $total_ttc_by_third = 0;
1229 $saved_third_id = empty($element->thirdparty->id) ? 0 : $element->thirdparty->id;
1231 $qualifiedfortotal =
true;
1232 if ($key ==
'invoice') {
1233 if (!empty($element->close_code) && $element->close_code ==
'replaced') {
1234 $qualifiedfortotal =
false;
1236 } elseif ($key ==
'order_supplier' && $element->status == 7) {
1237 $qualifiedfortotal =
false;
1240 if ($key ==
"order_supplier" && $element->status == 7) {
1241 print
'<tr class="oddeven tr_canceled" style=display:none>';
1243 print
'<tr class="oddeven" >';
1248 print
'<td style="width: 24px">';
1249 if ($tablename !=
'projet_task' && $tablename !=
'stock_mouvement') {
1250 if (empty($conf->global->PROJECT_DISABLE_UNLINK_FROM_OVERVIEW) || $user->admin) {
1251 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&action=unlink&tablename='.$tablename.
'&elementselect='.$element->id.($project_field ?
'&projectfield='.$project_field :
'').
'" class="reposition">';
1252 print
img_picto($langs->trans(
'Unlink'),
'unlink');
1259 print
'<td class="left nowraponall">';
1260 if ($tablename ==
'expensereport_det') {
1261 print $expensereport->getNomUrl(1);
1264 if ($element instanceof
Task) {
1265 print $element->getNomUrl(1,
'withproject',
'time');
1266 print
' - '.dol_trunc($element->label, 48);
1267 } elseif ($key ==
'loan') {
1268 print $element->getNomUrl(1);
1269 print
' - '.dol_trunc($element->label, 48);
1271 print $element->getNomUrl(1);
1274 $element_doc = $element->element;
1276 if (!empty($conf->$element_doc)) {
1277 $confelementdoc = $conf->$element_doc;
1278 $filedir = $confelementdoc->multidir_output[$element->entity].
'/'.
dol_sanitizeFileName($element->ref);
1283 if ($element_doc ===
'order_supplier') {
1284 $element_doc =
'commande_fournisseur';
1285 $filedir = $conf->fournisseur->commande->multidir_output[$element->entity].
'/'.
dol_sanitizeFileName($element->ref);
1286 } elseif ($element_doc ===
'invoice_supplier') {
1287 $element_doc =
'facture_fournisseur';
1288 $filename =
get_exdir($element->id, 2, 0, 0, $element,
'invoice_supplier').dol_sanitizeFileName($element->ref);
1289 $filedir = $conf->fournisseur->facture->multidir_output[$element->entity].
'/'.$filename;
1292 print
'<div class="inline-block valignmiddle">';
1294 print $formfile->getDocumentsLink($element_doc, $filename, $filedir);
1299 if (!empty($element->ref_supplier)) {
1300 print
' - '.$element->ref_supplier;
1303 if (!empty($element->ref_customer)) {
1304 print
' - '.$element->ref_customer;
1307 if (empty($element->ref_customer) && !empty($element->ref_client)) {
1308 print
' - '.$element->ref_client;
1314 $date =
''; $total_time_by_line =
null;
1315 if ($tablename ==
'expensereport_det') {
1316 $date = $element->date;
1317 } elseif ($tablename ==
'stock_mouvement') {
1318 $date = $element->datem;
1319 } elseif ($tablename ==
'salary') {
1320 $date = $element->datesp;
1321 } elseif ($tablename ==
'payment_various') {
1322 $date = $element->datev;
1323 } elseif ($tablename ==
'chargesociales') {
1324 $date = $element->date_ech;
1325 } elseif (!empty($element->status) || !empty($element->statut) || !empty($element->fk_status)) {
1326 if ($tablename ==
'don') {
1327 $date = $element->datedon;
1329 if ($tablename ==
'commande_fournisseur' || $tablename ==
'supplier_order') {
1330 $date = ($element->date_commande ? $element->date_commande : $element->date_valid);
1331 } elseif ($tablename ==
'supplier_proposal') {
1332 $date = $element->date_validation;
1333 } elseif ($tablename ==
'fichinter') {
1334 $date = $element->datev;
1335 } elseif ($tablename ==
'projet_task') {
1338 $date = $element->date;
1340 $date = $element->date_contrat;
1343 $date = $element->datev;
1345 if (empty($date) && !empty($datefieldname)) {
1346 $date = $element->$datefieldname;
1349 } elseif ($key ==
'loan') {
1350 $date = $element->datestart;
1353 print
'<td class="center">';
1354 if ($tablename ==
'actioncomm') {
1356 if ($element->datef && $element->datef > $element->datep) {
1357 print
" - ".dol_print_date($element->datef,
'dayhour');
1359 } elseif (in_array($tablename, array(
'projet_task'))) {
1360 $tmpprojtime = $element->getSumOfAmount($elementuser, $dates, $datee);
1361 print
'<a href="'.DOL_URL_ROOT.
'/projet/tasks/time.php?id='.$idofelement.
'&withproject=1">';
1364 $total_time_by_line = $tmpprojtime[
'nbseconds'];
1371 print
'<td class="left">';
1372 if (is_object($element->thirdparty)) {
1373 print $element->thirdparty->getNomUrl(1,
'', 48);
1374 } elseif ($tablename ==
'expensereport_det') {
1375 $tmpuser =
new User($db);
1376 $tmpuser->fetch($expensereport->fk_user_author);
1377 print $tmpuser->getNomUrl(1,
'', 48);
1378 } elseif ($tablename ==
'salary') {
1379 $tmpuser =
new User($db);
1380 $tmpuser->fetch($element->fk_user);
1381 print $tmpuser->getNomUrl(1,
'', 48);
1382 } elseif ($tablename ==
'don' || $tablename ==
'stock_mouvement') {
1383 if ($element->fk_user_author > 0) {
1384 $tmpuser2 =
new User($db);
1385 $tmpuser2->fetch($element->fk_user_author);
1386 print $tmpuser2->getNomUrl(1,
'', 48);
1388 } elseif ($tablename ==
'projet_task' && $key ==
'element_time') {
1389 print $elementuser->getNomUrl(1);
1394 if ($tablename ==
'fichinter') {
1396 print
convertSecondToTime($element->duration,
'all', $conf->global->MAIN_DURATION_OF_WORKDAY);
1397 $total_duration += $element->duration;
1403 if (empty($value[
'disableamount'])) {
1404 $total_ht_by_line =
null;
1406 if ($tablename ==
'don' || $tablename ==
'chargesociales' || $tablename ==
'payment_various' || $tablename ==
'salary') {
1407 $total_ht_by_line = $element->amount;
1408 } elseif ($tablename ==
'fichinter') {
1409 $total_ht_by_line = $element->getAmount();
1410 } elseif ($tablename ==
'stock_mouvement') {
1411 $total_ht_by_line = $element->price * abs($element->qty);
1412 } elseif (in_array($tablename, array(
'projet_task'))) {
1413 if (isModEnabled(
'salaries')) {
1415 $total_ht_by_line =
price2num($tmpprojtime[
'amount'],
'MT');
1416 if ($tmpprojtime[
'nblinesnull'] > 0) {
1417 $langs->load(
"errors");
1418 $warning = $langs->trans(
"WarningSomeLinesWithNullHourlyRate", $conf->currency);
1421 $othermessage = $form->textwithpicto($langs->trans(
"NotAvailable"), $langs->trans(
"ModuleSalaryToDefineHourlyRateMustBeEnabled"));
1423 } elseif ($key ==
'loan') {
1424 $total_ht_by_line = $element->capital;
1426 $total_ht_by_line = $element->total_ht;
1430 if ($tablename ==
'payment_various') {
1431 if ($element->sens == 0) {
1432 $total_ht_by_line = -$total_ht_by_line;
1436 print
'<td class="right">';
1437 if ($othermessage) {
1438 print $othermessage;
1440 if (isset($total_ht_by_line)) {
1441 if (!$qualifiedfortotal) {
1444 print
'<span class="amount">'.price($total_ht_by_line).
'</span>';
1445 if (!$qualifiedfortotal) {
1450 print
' '.img_warning($warning);
1458 if (empty($value[
'disableamount'])) {
1459 $total_ttc_by_line =
null;
1460 if ($tablename ==
'don' || $tablename ==
'chargesociales' || $tablename ==
'payment_various' || $tablename ==
'salary') {
1461 $total_ttc_by_line = $element->amount;
1462 } elseif ($tablename ==
'fichinter') {
1463 $total_ttc_by_line = $element->getAmount();
1464 } elseif ($tablename ==
'stock_mouvement') {
1465 $total_ttc_by_line = $element->price * abs($element->qty);
1466 } elseif ($tablename ==
'projet_task') {
1467 if (isModEnabled(
'salaries')) {
1470 $total_ttc_by_line =
price2num($total_ht_by_line * (1 + ($defaultvat / 100)),
'MT');
1472 $othermessage = $form->textwithpicto($langs->trans(
"NotAvailable"), $langs->trans(
"ModuleSalaryToDefineHourlyRateMustBeEnabled"));
1474 } elseif ($key ==
'loan') {
1475 $total_ttc_by_line = $element->capital - $element->getSumPayment();
1477 $total_ttc_by_line = $element->total_ttc;
1481 if ($tablename ==
'payment_various') {
1482 if ($element->sens == 0) {
1483 $total_ttc_by_line = -$total_ttc_by_line;
1487 print
'<td class="right">';
1488 if ($othermessage) {
1489 print $othermessage;
1491 if (isset($total_ttc_by_line)) {
1492 if (!$qualifiedfortotal) {
1495 print
'<span class="amount">'.price($total_ttc_by_line).
'</span>';
1496 if (!$qualifiedfortotal) {
1501 print
' '.img_warning($warning);
1509 print
'<td class="right">';
1510 if ($tablename ==
'expensereport_det') {
1511 print $expensereport->getLibStatut(5);
1514 print $element->getLibStatut(5, $element->getSommePaiement());
1515 } elseif ($element instanceof
Task) {
1516 if ($element->progress !=
'') {
1517 print $element->progress.
' %';
1519 } elseif ($tablename ==
'stock_mouvement') {
1520 print $element->getLibStatut(3);
1522 print $element->getLibStatut(5);
1528 if ($qualifiedfortotal) {
1529 $total_ht = $total_ht + $total_ht_by_line;
1530 $total_ttc = $total_ttc + $total_ttc_by_line;
1532 $total_ht_by_third += $total_ht_by_line;
1533 $total_ttc_by_third += $total_ttc_by_line;
1535 if (!isset($total_time)) $total_time = $total_time_by_line;
1536 else $total_time += $total_time_by_line;
1540 $breakline =
'<tr class="liste_total liste_sub_total">';
1541 $breakline .=
'<td colspan="2">';
1542 $breakline .=
'</td>';
1543 $breakline .=
'<td>';
1544 $breakline .=
'</td>';
1545 $breakline .=
'<td class="right">';
1546 $breakline .= $langs->trans(
'SubTotal').
' : ';
1547 if (is_object($element->thirdparty)) {
1548 $breakline .= $element->thirdparty->getNomUrl(0,
'', 48);
1550 $breakline .=
'</td>';
1551 $breakline .=
'<td class="right">'.price($total_ht_by_third).
'</td>';
1552 $breakline .=
'<td class="right">'.price($total_ttc_by_third).
'</td>';
1553 $breakline .=
'<td></td>';
1554 $breakline .=
'</tr>';
1565 if (empty($nototal)) {
1567 if (in_array($tablename, array(
'projet_task'))) {
1571 print
'<tr class="liste_total"><td colspan="'.$colspan.
'">'.$langs->trans(
"Number").
': '.$i.
'</td>';
1572 if (in_array($tablename, array(
'projet_task'))) {
1573 print
'<td class="center">';
1582 if ($tablename ==
'fichinter') {
1583 print
'<td class="left">'.convertSecondToTime($total_duration,
'all', $conf->global->MAIN_DURATION_OF_WORKDAY).
'</td>';
1585 print
'<td class="right">';
1586 if (empty($value[
'disableamount'])) {
1587 if ($key ==
'loan') {
1588 print $langs->trans(
"Total").
' '.$langs->trans(
"LoanCapital").
' : '.
price($total_ttc);
1589 } elseif ($tablename !=
'projet_task' || isModEnabled(
'salaries')) {
1590 print
''.$langs->trans(
"TotalHT").
' : '.
price($total_ht);
1596 print
'<td class="right">';
1597 if (empty($value[
'disableamount'])) {
1598 if ($key ==
'loan') {
1599 print $langs->trans(
"Total").
' '.$langs->trans(
"RemainderToPay").
' : '.
price($total_ttc);
1600 } elseif ($tablename !=
'projet_task' || isModEnabled(
'salaries')) {
1601 print $langs->trans(
"TotalTTC").
' : '.
price($total_ttc);
1605 print
'<td> </td>';
1609 if (!is_array($elementarray)) {
1610 print
'<tr><td>'.$elementarray.
'</td></tr>';
1613 if (in_array($tablename, array(
'projet_task'))) {
1616 if ($tablename ==
'fichinter') {
1619 print
'<tr><td colspan="'.$colspan.
'"><span class="opacitymedium">'.$langs->trans(
"None").
'</td></tr>';
1629if ($conf->use_javascript_ajax) {
1630 include_once DOL_DOCUMENT_ROOT.
'/core/lib/ajax.lib.php';
1633 print $comboenhancement;
1652 if (empty($conf->global->PROJECT_ADD_SUBTOTAL_LINES)) {
1655 return in_array($tablename, array(
'facture_fourn',
'commande_fournisseur'));
1666 global $db, $classname;
1668 $element =
new $classname($db);
1670 $clientname = array();
1671 foreach ($elementarray as $key => $id) {
1672 if (empty($clientname[$id])) {
1673 $element->fetch($id);
1674 $element->fetch_thirdparty();
1676 $clientname[$id] = $element->thirdparty->name;
1683 $elementarray = array();
1684 foreach ($clientname as $id => $name) {
1685 $elementarray[] = $id;
1688 return $elementarray;
ajax_combobox($htmlname, $events=array(), $minLengthToAutocomplete=0, $forcefocus=0, $widthTypeOfAutocomplete='resolve', $idforemptyvalue='-1', $morecss='')
Convert a html select field into an ajax combobox.
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader()
Empty header.
Superclass for invoices classes.
Class to manage Trips and Expenses.
const TYPE_DEPOSIT
Deposit invoice.
Class to manage Schedule of loans.
Class to manage projects.
const STATUS_SIGNED
Signed quote.
const STATUS_BILLED
Billed or processed quote.
Class to manage Dolibarr users.
dol_get_first_day($year, $month=1, $gm=false)
Return GMT time for first day of a month or year.
convertSecondToTime($iSecond, $format='all', $lengthOfDay=86400, $lengthOfWeek=7)
Return, in clear text, value of a number of seconds in days, hours and minutes.
dol_stringtotime($string, $gm=1)
Convert a string date into a GM Timestamps date Warning: YYYY-MM-DDTHH:MM:SS+02:00 (RFC3339) is not s...
sortElementsByClientName($elementarray)
sortElementsByClientName
canApplySubtotalOn($tablename)
Return if we should do a group by customer with sub-total.
dol_banner_tab($object, $paramid, $morehtml='', $shownav=1, $fieldid='rowid', $fieldref='ref', $morehtmlref='', $moreparam='', $nodbprefix=0, $morehtmlleft='', $morehtmlstatus='', $onlybanner=0, $morehtmlright='')
Show tab footer of a card.
dol_mktime($hour, $minute, $second, $month, $day, $year, $gm='auto', $check=1)
Return a timestamp date built from detailed informations (by default a local PHP server timestamp) Re...
load_fiche_titre($titre, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
img_warning($titlealt='default', $moreatt='', $morecss='pictowarning')
Show warning logo.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0)
Show tabs of a record.
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
setEventMessage($mesgs, $style='mesgs', $noduplicate=0)
Set event message in dol_events session object.
price($amount, $form=0, $outlangs='', $trunc=1, $rounding=-1, $forcerounding=-1, $currency_code='')
Function to format a value into an amount for visual output Function used into PDF and HTML pages.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs='', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
dol_now($mode='auto')
Return date for now.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
dol_escape_js($stringtoescape, $mode=0, $noescapebackslashn=0)
Returns text escaped for inclusion into javascript code.
dol_getIdFromCode($db, $key, $tablename, $fieldkey='code', $fieldid='id', $entityfilter=0, $filters='')
Return an id or code from a code or id.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0)
Set event messages in dol_events session object.
dol_sanitizeFileName($str, $newstr='_', $unaccent=1)
Clean a string to use it as a file name.
dol_htmlentitiesbr($stringtoencode, $nl2brmode=0, $pagecodefrom='UTF-8', $removelasteolbr=1)
This function is called to encode a string into a HTML string but differs from htmlentities because a...
get_default_tva(Societe $thirdparty_seller, Societe $thirdparty_buyer, $idprod=0, $idprodfournprice=0)
Function that return vat rate of a product line (according to seller, buyer and product vat rate) VAT...
get_exdir($num, $level, $alpha, $withoutslash, $object, $modulepart='')
Return a path to have a the directory according to object where files are stored.
dol_getdate($timestamp, $fast=false, $forcetimezone='')
Return an array with locale date info.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
Returns text escaped for inclusion in HTML alt or title or value tags, or into values of HTML input f...
project_prepare_head(Project $project, $moreparam='')
Prepare array with list of tabs.
restrictedArea(User $user, $features, $object=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $isdraft=0, $mode=0)
Check permissions of a user to show a page and an object.