35require
'../main.inc.php';
36require_once DOL_DOCUMENT_ROOT.
'/projet/class/project.class.php';
37require_once DOL_DOCUMENT_ROOT.
'/projet/class/task.class.php';
38require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formprojet.class.php';
39require_once DOL_DOCUMENT_ROOT.
'/core/lib/project.lib.php';
40require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
41require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
43if (isModEnabled(
'agenda')) {
44 require_once DOL_DOCUMENT_ROOT.
'/comm/action/class/actioncomm.class.php';
46if (isModEnabled(
'bank')) {
47 require_once DOL_DOCUMENT_ROOT.
'/compta/bank/class/paymentvarious.class.php';
49if (isModEnabled(
'category')) {
50 require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
52if (isModEnabled(
'order')) {
53 require_once DOL_DOCUMENT_ROOT.
'/commande/class/commande.class.php';
55if (isModEnabled(
'contract')) {
56 require_once DOL_DOCUMENT_ROOT.
'/contrat/class/contrat.class.php';
58if (isModEnabled(
'deplacement')) {
59 require_once DOL_DOCUMENT_ROOT.
'/compta/deplacement/class/deplacement.class.php';
61if (isModEnabled(
'don')) {
62 require_once DOL_DOCUMENT_ROOT.
'/don/class/don.class.php';
64if (isModEnabled(
'shipping')) {
65 require_once DOL_DOCUMENT_ROOT.
'/expedition/class/expedition.class.php';
67if (isModEnabled(
'expensereport')) {
68 require_once DOL_DOCUMENT_ROOT.
'/expensereport/class/expensereport.class.php';
70if (isModEnabled(
'invoice')) {
71 require_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facture.class.php';
72 require_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facture-rec.class.php';
74if (isModEnabled(
'intervention')) {
75 require_once DOL_DOCUMENT_ROOT.
'/fichinter/class/fichinter.class.php';
77if (isModEnabled(
'loan')) {
78 require_once DOL_DOCUMENT_ROOT.
'/loan/class/loan.class.php';
79 require_once DOL_DOCUMENT_ROOT.
'/loan/class/loanschedule.class.php';
81if (isModEnabled(
'mrp')) {
82 require_once DOL_DOCUMENT_ROOT.
'/mrp/class/mo.class.php';
84if (isModEnabled(
'propal')) {
85 require_once DOL_DOCUMENT_ROOT.
'/comm/propal/class/propal.class.php';
87if (isModEnabled(
'salaries')) {
88 require_once DOL_DOCUMENT_ROOT.
'/salaries/class/salary.class.php';
90if (isModEnabled(
'stock')) {
91 require_once DOL_DOCUMENT_ROOT.
'/product/stock/class/entrepot.class.php';
92 require_once DOL_DOCUMENT_ROOT.
'/product/stock/class/mouvementstock.class.php';
94if (isModEnabled(
'supplier_invoice')) {
95 require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.facture.class.php';
97if (isModEnabled(
'supplier_order')) {
98 require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.commande.class.php';
100if (isModEnabled(
'supplier_proposal')) {
101 require_once DOL_DOCUMENT_ROOT.
'/supplier_proposal/class/supplier_proposal.class.php';
103if (isModEnabled(
'tax')) {
104 require_once DOL_DOCUMENT_ROOT.
'/compta/sociales/class/chargesociales.class.php';
106if (isModEnabled(
'stocktransfer')) {
107 require_once DOL_DOCUMENT_ROOT.
'/product/stock/stocktransfer/class/stocktransfer.class.php';
108 require_once DOL_DOCUMENT_ROOT.
'/product/stock/stocktransfer/class/stocktransferline.class.php';
114$langs->loadLangs(array(
'projects',
'companies',
'suppliers',
'compta'));
115if (isModEnabled(
'invoice')) {
116 $langs->load(
"bills");
118if (isModEnabled(
'order')) {
119 $langs->load(
"orders");
121if (isModEnabled(
"propal")) {
122 $langs->load(
"propal");
124if (isModEnabled(
'intervention')) {
125 $langs->load(
"interventions");
127if (isModEnabled(
'deplacement')) {
128 $langs->load(
"trips");
130if (isModEnabled(
'expensereport')) {
131 $langs->load(
"trips");
133if (isModEnabled(
'don')) {
134 $langs->load(
"donations");
136if (isModEnabled(
'loan')) {
137 $langs->load(
"loan");
139if (isModEnabled(
'salaries')) {
140 $langs->load(
"salaries");
142if (isModEnabled(
'mrp')) {
145if (isModEnabled(
'eventorganization')) {
146 $langs->load(
"eventorganization");
151$action =
GETPOST(
'action',
'aZ09');
152$datesrfc =
GETPOST(
'datesrfc');
153$dateerfc =
GETPOST(
'dateerfc');
156if (empty($dates) && !empty($datesrfc)) {
159if (empty($datee) && !empty($dateerfc)) {
162if (!GETPOSTISSET(
'datesrfc') && !GETPOSTISSET(
'datesday') &&
getDolGlobalString(
'PROJECT_LINKED_ELEMENT_DEFAULT_FILTER_YEAR')) {
169if ($id ==
'' && $ref ==
'') {
171 header(
'Location: list.php');
182$mine =
GETPOST(
'mode') ==
'mine' ? 1 : 0;
187include DOL_DOCUMENT_ROOT.
'/core/actions_fetchobject.inc.php';
188if (
getDolGlobalString(
'PROJECT_ALLOW_COMMENT_ON_PROJECT') && method_exists($object,
'fetchComments') && empty(
$object->comments)) {
195$hookmanager->initHooks(array(
'projectOverview'));
201$total_ttc_by_line = 0;
202$total_ht_by_line = 0;
203$expensereport =
null;
205$tmpprojtime = array();
219$title = $langs->trans(
'ProjectReferers').
' - '.
$object->ref.
' '.
$object->name;
221 $title =
$object->ref.
' '.
$object->name.
' - '.$langs->trans(
'ProjectReferers');
224$help_url =
'EN:Module_Projects|FR:Module_Projets|ES:Módulo_Proyectos|DE:Modul_Projekte';
226llxHeader(
'', $title, $help_url,
'', 0, 0,
'',
'',
'',
'mod-project page-card_element');
228$form =
new Form($db);
232$userstatic =
new User($db);
235$userAccess =
$object->restrictedProjectArea($user);
243if (!empty($_SESSION[
'pageforbacktolist']) && !empty($_SESSION[
'pageforbacktolist'][
'project'])) {
244 $tmpurl = $_SESSION[
'pageforbacktolist'][
'project'];
245 $tmpurl = preg_replace(
'/__SOCID__/', (
string)
$object->socid, $tmpurl);
246 $linkback =
'<a href="'.$tmpurl.(preg_match(
'/\?/', $tmpurl) ?
'&' :
'?').
'restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
248 $linkback =
'<a href="'.DOL_URL_ROOT.
'/projet/list.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
251$morehtmlref =
'<div class="refidno">';
255if (!empty(
$object->thirdparty->id) &&
$object->thirdparty->id > 0) {
256 $morehtmlref .=
'<br>'.$object->thirdparty->getNomUrl(1,
'project');
258$morehtmlref .=
'</div>';
261if (!$user->hasRight(
'projet',
'all',
'lire')) {
262 $objectsListId =
$object->getProjectsAuthorizedForUser($user, 0, 0);
263 $object->next_prev_filter =
"te.rowid IN (".$db->sanitize(count($objectsListId) ? implode(
',', array_keys($objectsListId)) :
'0').
")";
266dol_banner_tab($object,
'ref', $linkback, 1,
'ref',
'ref', $morehtmlref);
269print
'<div class="fichecenter">';
270print
'<div class="fichehalfleft">';
271print
'<div class="underbanner clearboth"></div>';
273print
'<table class="border tableforfield centpercent">';
277 print
'<tr><td class="tdtop">';
278 print $langs->trans(
"Usage");
282 print
'<input type="checkbox" disabled name="usage_opportunity"'.(GETPOSTISSET(
'usage_opportunity') ? (
GETPOST(
'usage_opportunity',
'alpha') !=
'' ?
' checked="checked"' :
'') : (
$object->usage_opportunity ?
' checked="checked"' :
'')).
'"> ';
283 $htmltext = $langs->trans(
"ProjectFollowOpportunity");
284 print $form->textwithpicto($langs->trans(
"ProjectFollowOpportunity"), $htmltext);
288 print
'<input type="checkbox" disabled name="usage_task"'.(GETPOSTISSET(
'usage_task') ? (
GETPOST(
'usage_task',
'alpha') !=
'' ?
' checked="checked"' :
'') : (
$object->usage_task ?
' checked="checked"' :
'')).
'"> ';
289 $htmltext = $langs->trans(
"ProjectFollowTasks");
290 print $form->textwithpicto($langs->trans(
"ProjectFollowTasks"), $htmltext);
294 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"' :
'')).
'"> ';
295 $htmltext = $langs->trans(
"ProjectBillTimeDescription");
296 print $form->textwithpicto($langs->trans(
"BillTime"), $htmltext);
299 if (isModEnabled(
'eventorganization')) {
300 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"' :
'')).
'"> ';
301 $htmltext = $langs->trans(
"EventOrganizationDescriptionLong");
302 print $form->textwithpicto($langs->trans(
"ManageOrganizeEvent"), $htmltext);
308print
'<tr><td class="titlefield">'.$langs->trans(
"Visibility").
'</td><td>';
310 print
img_picto($langs->trans(
'SharedProject'),
'world',
'class="paddingrightonly"');
311 print $langs->trans(
'SharedProject');
313 print
img_picto($langs->trans(
'PrivateProject'),
'private',
'class="paddingrightonly"');
314 print $langs->trans(
'PrivateProject');
320 print
'<tr><td>'.$langs->trans(
"OpportunityStatus").
'</td><td>';
323 print $langs->trans(
"OppStatus".$code);
328 print
'<tr><td>'.$langs->trans(
"OpportunityProbability").
'</td><td>';
329 if (!is_null(
$object->opp_percent) && strcmp(
$object->opp_percent,
'')) {
330 print
price(
$object->opp_percent, 0, $langs, 1, 0).
' %';
335 print
'<tr><td>'.$langs->trans(
"OpportunityAmount").
'</td><td>';
336 if (!is_null(
$object->opp_amount) && strcmp(
$object->opp_amount,
'')) {
337 print
'<span class="amount">'.price(
$object->opp_amount, 0, $langs, 1, 0, 0, $conf->currency).
'</span>';
338 if (strcmp(
$object->opp_percent,
'')) {
339 print
' <span title="'.dol_escape_htmltag($langs->trans(
'OpportunityWeightedAmount')).
'"><span class="opacitymedium">'.$langs->trans(
"OpportunityWeightedAmountShort").
'</span>: <span class="amount">'.
price(
$object->opp_amount *
$object->opp_percent / 100, 0, $langs, 1, 0, -1, $conf->currency).
'</span></span>';
346print
'<tr><td>'.$langs->trans(
"Budget").
'</td><td>';
347if (!is_null(
$object->budget_amount) && strcmp(
$object->budget_amount,
'')) {
348 print
'<span class="amount">'.price(
$object->budget_amount, 0, $langs, 1, 0, 0, $conf->currency).
'</span>';
353print
'<tr><td>'.$langs->trans(
"Dates").
'</td><td>';
355print($start ? $start :
'?');
358print($end ? $end :
'?');
366include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_view.tpl.php';
371print
'<div class="fichehalfright">';
372print
'<div class="underbanner clearboth"></div>';
374print
'<table class="border tableforfield centpercent">';
377print
'<td class="titlefield tdtop">'.$langs->trans(
"Description").
'</td><td>';
382if (isModEnabled(
'category')) {
383 print
'<tr><td class="valignmiddle">'.$langs->trans(
"Categories").
'</td><td>';
384 print $form->showCategories(
$object->id, Categorie::TYPE_PROJECT, 1);
393print
'<div class="clearboth"></div>';
403$listofreferent = array(
405 'name' =>
"Warehouse",
406 'title' =>
"ListWarehouseAssociatedProject",
407 'class' =>
'Entrepot',
408 'table' =>
'entrepot',
409 'datefieldname' =>
'date_entrepot',
410 'urlnew' => DOL_URL_ROOT.
'/product/stock/card.php?action=create&projectid='.
$id.
'&backtopage='.urlencode($_SERVER[
'PHP_SELF'].
'?id='.$id),
411 'lang' =>
'entrepot',
412 'buttonnew' =>
'AddWarehouse',
413 'project_field' =>
'fk_project',
414 'testnew' => $user->hasRight(
'stock',
'creer'),
415 'test' => isModEnabled(
'stock') && $user->hasRight(
'stock',
'lire') &&
getDolGlobalString(
'WAREHOUSE_ASK_WAREHOUSE_DURING_PROJECT')
418 'name' =>
"Proposals",
419 'title' =>
"ListProposalsAssociatedProject",
422 'datefieldname' =>
'datep',
423 'urlnew' => DOL_URL_ROOT.
'/comm/propal/card.php?action=create&origin=project&originid='.
$id.
'&socid='.$socid.
'&backtopage='.urlencode($_SERVER[
'PHP_SELF'].
'?id='.$id),
425 'buttonnew' =>
'AddProp',
426 'testnew' => $user->hasRight(
'propal',
'creer'),
427 'test' => isModEnabled(
'propal') && $user->hasRight(
'propal',
'lire')
430 'name' =>
"CustomersOrders",
431 'title' =>
"ListOrdersAssociatedProject",
432 'class' =>
'Commande',
433 'table' =>
'commande',
434 'datefieldname' =>
'date_commande',
435 'urlnew' => DOL_URL_ROOT.
'/commande/card.php?action=create&projectid='.
$id.
'&socid='.$socid.
'&backtopage='.urlencode($_SERVER[
'PHP_SELF'].
'?id='.$id),
437 'buttonnew' =>
'CreateOrder',
438 'testnew' => $user->hasRight(
'commande',
'creer'),
439 'test' => isModEnabled(
'order') && $user->hasRight(
'commande',
'lire')
442 'name' =>
"CustomersInvoices",
443 'title' =>
"ListInvoicesAssociatedProject",
444 'class' =>
'Facture',
446 'table' =>
'facture',
447 'datefieldname' =>
'datef',
448 'urlnew' => DOL_URL_ROOT.
'/compta/facture/card.php?action=create&projectid='.
$id.
'&socid='.$socid.
'&backtopage='.urlencode($_SERVER[
'PHP_SELF'].
'?id='.$id),
450 'buttonnew' =>
'CreateBill',
451 'testnew' => $user->hasRight(
'facture',
'creer'),
452 'test' => isModEnabled(
'invoice') && $user->hasRight(
'facture',
'lire')
454 'invoice_predefined' => array(
455 'name' =>
"PredefinedInvoices",
456 'title' =>
"ListPredefinedInvoicesAssociatedProject",
457 'class' =>
'FactureRec',
458 'table' =>
'facture_rec',
459 'datefieldname' =>
'datec',
460 'urlnew' => DOL_URL_ROOT.
'/compta/facture/card.php?action=create&projectid='.
$id.
'&socid='.$socid.
'&backtopage='.urlencode($_SERVER[
'PHP_SELF'].
'?id='.$id),
462 'buttonnew' =>
'CreateBill',
463 'testnew' => $user->hasRight(
'facture',
'creer'),
464 'test' => isModEnabled(
'invoice') && $user->hasRight(
'facture',
'lire')
466 'proposal_supplier' => array(
467 'name' =>
"SupplierProposals",
468 'title' =>
"ListSupplierProposalsAssociatedProject",
469 'class' =>
'SupplierProposal',
470 'table' =>
'supplier_proposal',
471 'datefieldname' =>
'date_valid',
472 'urlnew' => DOL_URL_ROOT.
'/supplier_proposal/card.php?action=create&projectid='.
$id.
'&backtopage='.urlencode($_SERVER[
'PHP_SELF'].
'?id='.$id),
473 'lang' =>
'supplier_proposal',
474 'buttonnew' =>
'AddSupplierProposal',
475 'testnew' => $user->hasRight(
'supplier_proposal',
'creer'),
476 'test' => isModEnabled(
'supplier_proposal') && $user->hasRight(
'supplier_proposal',
'lire')
478 'order_supplier' => array(
479 'name' =>
"SuppliersOrders",
480 'title' =>
"ListSupplierOrdersAssociatedProject",
481 'class' =>
'CommandeFournisseur',
482 'table' =>
'commande_fournisseur',
483 'datefieldname' =>
'date_commande',
484 'urlnew' => DOL_URL_ROOT.
'/fourn/commande/card.php?action=create&projectid='.
$id.
'&backtopage='.urlencode($_SERVER[
'PHP_SELF'].
'?id='.$id),
485 'lang' =>
'suppliers',
486 'buttonnew' =>
'AddSupplierOrder',
487 'testnew' => $user->hasRight(
'fournisseur',
'commande',
'creer') || $user->hasRight(
'supplier_order',
'creer'),
488 'test' => isModEnabled(
'supplier_order') && $user->hasRight(
'fournisseur',
'commande',
'lire') || $user->hasRight(
'supplier_order',
'lire')
490 'invoice_supplier' => array(
491 'name' =>
"BillsSuppliers",
492 'title' =>
"ListSupplierInvoicesAssociatedProject",
493 'class' =>
'FactureFournisseur',
495 'table' =>
'facture_fourn',
496 'datefieldname' =>
'datef',
497 'urlnew' => DOL_URL_ROOT.
'/fourn/facture/card.php?action=create&projectid='.
$id.
'&backtopage='.urlencode($_SERVER[
'PHP_SELF'].
'?id='.$id),
498 'lang' =>
'suppliers',
499 'buttonnew' =>
'AddSupplierInvoice',
500 'testnew' => $user->hasRight(
'fournisseur',
'facture',
'creer') || $user->hasRight(
'supplier_invoice',
'creer'),
501 'test' => isModEnabled(
'supplier_invoice') && $user->hasRight(
'fournisseur',
'facture',
'lire') || $user->hasRight(
'supplier_invoice',
'lire')
504 'name' =>
"Contracts",
505 'title' =>
"ListContractAssociatedProject",
506 'class' =>
'Contrat',
507 'table' =>
'contrat',
508 'datefieldname' =>
'date_contrat',
509 'urlnew' => DOL_URL_ROOT.
'/contrat/card.php?action=create&projectid='.
$id.
'&socid='.$socid.
'&backtopage='.urlencode($_SERVER[
'PHP_SELF'].
'?id='.$id),
510 'lang' =>
'contracts',
511 'buttonnew' =>
'AddContract',
512 'testnew' => $user->hasRight(
'contrat',
'creer'),
513 'test' => isModEnabled(
'contract') && $user->hasRight(
'contrat',
'lire')
515 'intervention' => array(
516 'name' =>
"Interventions",
517 'title' =>
"ListFichinterAssociatedProject",
518 'class' =>
'Fichinter',
519 'table' =>
'fichinter',
520 'datefieldname' =>
'date_valid',
521 'disableamount' => 0,
523 'urlnew' => DOL_URL_ROOT.
'/fichinter/card.php?action=create&origin=project&originid='.
$id.
'&socid='.$socid.
'&backtopage='.urlencode($_SERVER[
'PHP_SELF'].
'?id='.$id),
524 'lang' =>
'interventions',
525 'buttonnew' =>
'AddIntervention',
526 'testnew' => $user->hasRight(
'ficheinter',
'creer'),
527 'test' => isModEnabled(
'intervention') && $user->hasRight(
'ficheinter',
'lire')
530 'name' =>
"Shippings",
531 'title' =>
"ListShippingAssociatedProject",
532 'class' =>
'Expedition',
533 'table' =>
'expedition',
534 'datefieldname' =>
'date_valid',
535 'urlnew' => DOL_URL_ROOT.
'/expedition/card.php?action=create&origin=project&originid='.
$id.
'&socid='.$socid.
'&backtopage='.urlencode($_SERVER[
'PHP_SELF'].
'?id='.$id),
536 'lang' =>
'sendings',
537 'buttonnew' =>
'CreateShipment',
539 'test' => isModEnabled(
'shipping') && $user->hasRight(
'expedition',
'lire')
543 'title' =>
"ListMOAssociatedProject",
546 'datefieldname' =>
'date_valid',
547 'urlnew' => DOL_URL_ROOT.
'/mrp/mo_card.php?action=create&origin=project&originid='.
$id.
'&socid='.$socid.
'&backtopage='.urlencode($_SERVER[
'PHP_SELF'].
'?id='.$id),
549 'buttonnew' =>
'CreateMO',
550 'testnew' => $user->hasRight(
'mrp',
'write'),
551 'project_field' =>
'fk_project',
553 'test' => isModEnabled(
'mrp') && $user->hasRight(
'mrp',
'read')
556 'name' =>
"TripsAndExpenses",
557 'title' =>
"ListExpenseReportsAssociatedProject",
558 'class' =>
'Deplacement',
559 'table' =>
'deplacement',
560 'datefieldname' =>
'dated',
562 'disableamount' => 1,
563 'urlnew' => DOL_URL_ROOT.
'/deplacement/card.php?action=create&projectid='.
$id.
'&socid='.$socid.
'&backtopage='.urlencode($_SERVER[
'PHP_SELF'].
'?id='.$id),
565 'buttonnew' =>
'AddTrip',
566 'testnew' => $user->hasRight(
'deplacement',
'creer'),
567 'test' => isModEnabled(
'deplacement') && $user->hasRight(
'deplacement',
'lire')
569 'expensereport' => array(
570 'name' =>
"ExpenseReports",
571 'title' =>
"ListExpenseReportsAssociatedProject",
572 'class' =>
'ExpenseReportLine',
573 'table' =>
'expensereport_det',
574 'datefieldname' =>
'date',
576 'disableamount' => 0,
577 'urlnew' => DOL_URL_ROOT.
'/expensereport/card.php?action=create&projectid='.
$id.
'&socid='.$socid.
'&backtopage='.urlencode($_SERVER[
'PHP_SELF'].
'?id='.$id),
579 'buttonnew' =>
'AddTrip',
580 'testnew' => $user->hasRight(
'expensereport',
'creer'),
581 'test' => isModEnabled(
'expensereport') && $user->hasRight(
'expensereport',
'lire')
584 'name' =>
"Donation",
585 'title' =>
"ListDonationsAssociatedProject",
589 'datefieldname' =>
'datedon',
590 'disableamount' => 0,
591 'urlnew' => DOL_URL_ROOT.
'/don/card.php?action=create&projectid='.
$id.
'&socid='.$socid.
'&backtopage='.urlencode($_SERVER[
'PHP_SELF'].
'?id='.$id),
592 'lang' =>
'donations',
593 'buttonnew' =>
'AddDonation',
594 'testnew' => $user->hasRight(
'don',
'creer'),
595 'test' => isModEnabled(
'don') && $user->hasRight(
'don',
'lire')
599 'title' =>
"ListLoanAssociatedProject",
603 'datefieldname' =>
'datestart',
604 'disableamount' => 0,
605 'urlnew' => DOL_URL_ROOT.
'/loan/card.php?action=create&projectid='.
$id.
'&socid='.$socid.
'&backtopage='.urlencode($_SERVER[
'PHP_SELF'].
'?id='.$id),
607 'buttonnew' =>
'AddLoan',
608 'testnew' => $user->hasRight(
'loan',
'write'),
609 'test' => isModEnabled(
'loan') && $user->hasRight(
'loan',
'read')
611 'chargesociales' => array(
612 'name' =>
"SocialContribution",
613 'title' =>
"ListSocialContributionAssociatedProject",
614 'class' =>
'ChargeSociales',
616 'table' =>
'chargesociales',
617 'datefieldname' =>
'date_ech',
618 'disableamount' => 0,
619 'urlnew' => DOL_URL_ROOT.
'/compta/sociales/card.php?action=create&projectid='.
$id.
'&backtopage='.urlencode($_SERVER[
'PHP_SELF'].
'?id='.$id),
621 'buttonnew' =>
'AddSocialContribution',
622 'testnew' => $user->hasRight(
'tax',
'charges',
'lire'),
623 'test' => isModEnabled(
'tax') && $user->hasRight(
'tax',
'charges',
'lire')
625 'project_task' => array(
626 'name' =>
"TaskTimeSpent",
627 'title' =>
"ListTaskTimeUserProject",
630 'table' =>
'projet_task',
631 'datefieldname' =>
'element_date',
632 'disableamount' => 0,
633 'urlnew' => DOL_URL_ROOT.
'/projet/tasks/time.php?withproject=1&action=createtime&projectid='.
$id.
'&backtopage='.urlencode($_SERVER[
'PHP_SELF'].
'?id='.$id),
634 'buttonnew' =>
'AddTimeSpent',
635 'testnew' => $user->hasRight(
'project',
'creer'),
636 'test' => isModEnabled(
'project') && $user->hasRight(
'projet',
'lire') && !
getDolGlobalString(
'PROJECT_HIDE_TASKS')
638 'stock_mouvement' => array(
639 'name' =>
"MouvementStockAssociated",
640 'title' =>
"ListMouvementStockProject",
641 'class' =>
'StockTransfer',
642 'table' =>
'stocktransfer_stocktransfer',
643 'datefieldname' =>
'datem',
645 'project_field' =>
'fk_project',
646 'disableamount' => 0,
647 'test' => isModEnabled(
'stock') && $user->hasRight(
'stock',
'mouvement',
'lire') &&
getDolGlobalString(
'STOCK_MOVEMENT_INTO_PROJECT_OVERVIEW')
650 'name' =>
"Salaries",
651 'title' =>
"ListSalariesAssociatedProject",
654 'datefieldname' =>
'datesp',
656 'disableamount' => 0,
657 'urlnew' => DOL_URL_ROOT.
'/salaries/card.php?action=create&projectid='.
$id.
'&backtopage='.urlencode($_SERVER[
'PHP_SELF'].
'?id='.$id),
658 'lang' =>
'salaries',
659 'buttonnew' =>
'AddSalary',
660 'testnew' => $user->hasRight(
'salaries',
'write'),
661 'test' => isModEnabled(
'salaries') && $user->hasRight(
'salaries',
'read')
663 'variouspayment' => array(
664 'name' =>
"VariousPayments",
665 'title' =>
"ListVariousPaymentsAssociatedProject",
666 'class' =>
'PaymentVarious',
667 'table' =>
'payment_various',
668 'datefieldname' =>
'datev',
670 'disableamount' => 0,
671 'urlnew' => DOL_URL_ROOT.
'/compta/bank/various_payment/card.php?action=create&projectid='.
$id.
'&backtopage='.urlencode($_SERVER[
'PHP_SELF'].
'?id='.$id),
673 'buttonnew' =>
'AddVariousPayment',
674 'testnew' => $user->hasRight(
'banque',
'modifier'),
675 'test' => isModEnabled(
"bank") && $user->hasRight(
'banque',
'lire') && !
getDolGlobalString(
'BANK_USE_OLD_VARIOUS_PAYMENT')
695 foreach ($listofreferent as $key => $element) {
696 if ($listofreferent[$key][
'margin'] ==
'add') {
697 unset($listofreferent[$key][
'margin']);
700 $newelementforplusmargin = explode(
',',
getDolGlobalString(
'PROJECT_ELEMENTS_FOR_PLUS_MARGIN'));
701 foreach ($newelementforplusmargin as $value) {
702 $listofreferent[trim($value)][
'margin'] =
'add';
706 foreach ($listofreferent as $key => $element) {
707 if ($listofreferent[$key][
'margin'] ==
'minus') {
708 unset($listofreferent[$key][
'margin']);
711 $newelementforminusmargin = explode(
',',
getDolGlobalString(
'PROJECT_ELEMENTS_FOR_MINUS_MARGIN'));
712 foreach ($newelementforminusmargin as $value) {
713 $listofreferent[trim($value)][
'margin'] =
'minus';
718$parameters = array(
'listofreferent' => $listofreferent);
719$resHook = $hookmanager->executeHooks(
'completeListOfReferent', $parameters, $object, $action);
721if (!empty($hookmanager->resArray)) {
722 $listofreferent = array_merge($listofreferent, $hookmanager->resArray);
723} elseif ($resHook > 0 && !empty($hookmanager->resPrint)) {
724 $listofreferent = $hookmanager->resPrint;
727if ($action ==
"addelement") {
728 $tablename =
GETPOST(
"tablename");
729 $elementselectid =
GETPOST(
"elementselect");
730 $result =
$object->update_element($tablename, $elementselectid);
734} elseif ($action ==
"unlink") {
735 $tablename =
GETPOST(
"tablename",
"aZ09");
736 $projectField = GETPOSTISSET(
'projectfield') ?
GETPOST(
'projectfield',
'aZ09') :
'fk_projet';
737 $elementselectid =
GETPOSTINT(
"elementselect");
739 $result =
$object->remove_element($tablename, $elementselectid, $projectField);
745$elementuser =
new User($db);
751if (!$showdatefilter) {
752 print
'<div class="center centpercent">';
753 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'" method="POST">';
754 print
'<input type="hidden" name="token" value="'.newToken().
'">';
755 print
'<input type="hidden" name="tablename" value="'.(empty($tablename) ?
'' : $tablename).
'">';
756 print
'<input type="hidden" name="action" value="view">';
757 print
'<div class="inline-block">';
758 print $form->selectDate($dates,
'dates', 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
"From"));
760 print
'<div class="inline-block">';
761 print $form->selectDate($datee,
'datee', 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
"to"));
763 print
'<div class="inline-block">';
764 print
'<input type="submit" name="refresh" value="'.$langs->trans(
"Refresh").
'" class="button small">';
776$langs->loadLangs(array(
"suppliers",
"bills",
"orders",
"proposals",
"margins"));
778if (isModEnabled(
'stock')) {
779 $langs->load(
'stocks');
784print
'<table class="noborder centpercent">';
785print
'<tr class="liste_titre">';
786print
'<td class="left" width="200">';
787$tooltiponprofit = $langs->trans(
"ProfitIsCalculatedWith").
"<br>\n";
788$tooltiponprofitplus = $tooltiponprofitminus =
'';
789foreach ($listofreferent as $key => $value) {
790 if (!empty($value[
'lang'])) {
791 $langs->load($value[
'lang']);
793 $name = $langs->trans($value[
'name']);
794 $qualified = $value[
'test'];
795 $margin = empty($value[
'margin']) ?
'' : $value[
'margin'];
796 if ($qualified && isset($margin)) {
797 if ($margin ===
'add') {
798 $tooltiponprofitplus .=
' > '.$name.
" (+)<br>\n";
800 if ($margin ===
'minus') {
801 $tooltiponprofitminus .=
' > '.$name.
" (-)<br>\n";
805$tooltiponprofit .= $tooltiponprofitplus;
806$tooltiponprofit .= $tooltiponprofitminus;
807print $form->textwithpicto($langs->trans(
"Element"), $tooltiponprofit);
809print
'<td class="right" width="100">'.$langs->trans(
"Number").
'</td>';
810print
'<td class="right" width="100">'.$langs->trans(
"AmountHT").
'</td>';
811print
'<td class="right" width="100">'.$langs->trans(
"AmountTTC").
'</td>';
814$total_revenue_ht = 0;
819foreach ($listofreferent as $key => $value) {
821 'total_revenue_ht' => & $total_revenue_ht,
822 'balance_ht' => & $balance_ht,
823 'balance_ttc' => & $balance_ttc,
829 $reshook = $hookmanager->executeHooks(
'printOverviewProfit', $parameters, $object, $action);
832 } elseif ($reshook > 0) {
833 print $hookmanager->resPrint;
837 $name = $langs->trans($value[
'name']);
838 $title = $value[
'title'];
839 $classname = $value[
'class'];
840 $tablename = $value[
'table'];
841 $datefieldname = $value[
'datefieldname'];
842 $qualified = $value[
'test'];
843 $margin = empty($value[
'margin']) ? 0 : $value[
'margin'];
844 $project_field = empty($value[
'project_field']) ?
'' : $value[
'project_field'];
845 if ($qualified && isset($margin)) {
846 $element =
new $classname($db);
848 $elementarray =
$object->get_element_list($key, $tablename, $datefieldname, $dates, $datee, !empty($project_field) ? $project_field :
'fk_projet');
850 if (is_array($elementarray) && count($elementarray) > 0) {
855 $num = count($elementarray);
856 for ($i = 0; $i < $num; $i++) {
857 $tmp = explode(
'_', $elementarray[$i]);
858 $idofelement = $tmp[0];
859 $idofelementuser = !empty($tmp[1]) ? $tmp[1] :
"";
861 $element->fetch($idofelement);
862 if ($idofelementuser) {
863 $elementuser->fetch($idofelementuser);
867 $qualifiedfortotal =
true;
868 if ($key ==
'invoice') {
869 if (!empty($element->close_code) && $element->close_code ==
'replaced') {
870 $qualifiedfortotal =
false;
873 $qualifiedfortotal =
false;
876 if ($key ==
'propal') {
878 $qualifiedfortotal =
false;
882 if ($tablename !=
'expensereport_det' && method_exists($element,
'fetch_thirdparty')) {
883 $element->fetch_thirdparty();
887 if ($tablename ==
'don' || $tablename ==
'chargesociales' || $tablename ==
'payment_various' || $tablename ==
'salary') {
888 $total_ht_by_line = $element->amount;
889 } elseif ($tablename ==
'fichinter') {
890 $total_ht_by_line = $element->getAmount();
891 } elseif ($tablename ==
'stock_mouvement') {
892 $total_ht_by_line = $element->price * abs($element->qty);
893 } elseif ($tablename ==
'projet_task') {
894 $tmp = $element->getSumOfAmount($idofelementuser ? $elementuser :
'', $dates, $datee);
895 $total_ht_by_line =
price2num($tmp[
'amount'],
'MT');
896 } elseif ($key ==
'loan') {
897 if ((empty($dates) && empty($datee)) || (intval($dates) <= $element->datestart && intval($datee) >= $element->dateend)) {
899 $total_ht_by_line = -$element->capital;
902 $total_ht_by_line = 0;
904 $loanScheduleStatic->fetchAll($element->id);
905 if (!empty($loanScheduleStatic->lines)) {
906 foreach ($loanScheduleStatic->lines as $loanSchedule) {
910 if (($loanSchedule->datep >= $dates && $loanSchedule->datep <= $datee)
911 || !empty($dates) && empty($datee) && $loanSchedule->datep >= $dates && $loanSchedule->datep <=
dol_now()
912 || empty($dates) && !empty($datee) && $loanSchedule->datep <= $datee
914 $total_ht_by_line -= $loanSchedule->amount_capital;
920 $total_ht_by_line = $element->total_ht;
924 if ($tablename ==
'don' || $tablename ==
'chargesociales' || $tablename ==
'payment_various' || $tablename ==
'salary') {
925 $total_ttc_by_line = $element->amount;
926 } elseif ($tablename ==
'fichinter') {
927 $total_ttc_by_line = $element->getAmount();
928 } elseif ($tablename ==
'stock_mouvement') {
929 $total_ttc_by_line = $element->price * abs($element->qty);
930 } elseif ($tablename ==
'projet_task') {
933 if (preg_replace(
'/^(\d+\.)\s\(.*\)/', $defaultvat, $reg)) {
935 $defaultvat = $reg[1];
937 $total_ttc_by_line =
price2num($total_ht_by_line * (1 + ((
float) $defaultvat / 100)),
'MT');
938 } elseif ($key ==
'loan') {
939 $total_ttc_by_line = $total_ht_by_line;
941 $total_ttc_by_line = $element->total_ttc;
945 if ($tablename ==
'payment_various') {
946 if ($element->sens == 1) {
947 $total_ht_by_line = -$total_ht_by_line;
948 $total_ttc_by_line = -$total_ttc_by_line;
953 if ($qualifiedfortotal) {
954 $total_ht += $total_ht_by_line;
955 $total_ttc += $total_ttc_by_line;
963 if ($margin ===
'add') {
964 $total_revenue_ht += $total_ht;
967 if ($margin ===
"minus") {
968 $total_ht = -$total_ht;
969 $total_ttc = -$total_ttc;
972 $balance_ht += $total_ht;
973 $balance_ttc += $total_ttc;
976 print
'<tr class="oddeven">';
978 print
'<td class="left">'.$name.
'</td>';
980 print
'<td class="right">'.$i.
'</td>';
982 print
'<td class="right">';
983 if ($key ==
'intervention' && !$margin) {
984 print
'<span class="opacitymedium">'.$form->textwithpicto($langs->trans(
"NA"), $langs->trans(
"AmountOfInteventionNotIncludedByDefault")).
'</span>';
986 if ($key ==
'propal') {
987 print
'<span class="opacitymedium">'.$form->textwithpicto(
'', $langs->trans(
"SignedOnly")).
'</span>';
989 print
price($total_ht);
993 print
'<td class="right">';
994 if ($key ==
'intervention' && !$margin) {
995 print
'<span class="opacitymedium">'.$form->textwithpicto($langs->trans(
"NA"), $langs->trans(
"AmountOfInteventionNotIncludedByDefault")).
'</span>';
997 if ($key ==
'propal') {
998 print
'<span class="opacitymedium">'.$form->textwithpicto(
'', $langs->trans(
"SignedOnly")).
'</span>';
1000 print
price($total_ttc);
1008print
'<tr class="liste_total">';
1009print
'<td class="right" colspan="2">'.$langs->trans(
"Profit").
'</td>';
1010print
'<td class="right">'.price(
price2num($balance_ht,
'MT')).
'</td>';
1011print
'<td class="right">'.price(
price2num($balance_ttc,
'MT')).
'</td>';
1015if (
$object->usage_organize_event) {
1016 require_once DOL_DOCUMENT_ROOT.
'/eventorganization/class/conferenceorboothattendee.class.php';
1018 $result = $conforboothattendee->fetchAll(
'',
'', 0, 0,
'(t.fk_project:=:'.((
int)
$object->id).
') AND (t.status:=:'.ConferenceOrBoothAttendee::STATUS_VALIDATED.
')');
1020 if (!is_array($result) && $result < 0) {
1021 setEventMessages($conforboothattendee->error, $conforboothattendee->errors,
'errors');
1023 $nbAttendees = count($result);
1026 if ($nbAttendees >= 2) {
1027 $costperattendee_ht = $balance_ht / $nbAttendees;
1028 $costperattendee_ttc = $balance_ttc / $nbAttendees;
1029 print
'<tr class="liste_total">';
1030 print
'<td class="right" colspan="2">'.$langs->trans(
"ProfitPerValidatedAttendee").
'</td>';
1031 print
'<td class="right">'.price(
price2num($costperattendee_ht,
'MT')).
'</td>';
1032 print
'<td class="right">'.price(
price2num($costperattendee_ttc,
'MT')).
'</td>';
1038if ($total_revenue_ht) {
1039 print
'<tr class="liste_total">';
1040 print
'<td class="right" colspan="2">'.$langs->trans(
"Margin").
'</td>';
1041 print
'<td class="right">'.round(100 * $balance_ht / $total_revenue_ht, 1).
'%</td>';
1042 print
'<td class="right"></td>';
1056foreach ($listofreferent as $key => $value) {
1057 $parameters = array(
1059 'value' => & $value,
1063 $reshook = $hookmanager->executeHooks(
'printOverviewDetail', $parameters, $object, $action);
1066 } elseif ($reshook > 0) {
1067 print $hookmanager->resPrint;
1071 $title = $value[
'title'];
1072 $classname = $value[
'class'];
1073 $tablename = $value[
'table'];
1074 $datefieldname = $value[
'datefieldname'];
1075 $qualified = $value[
'test'];
1076 $urlnew = empty($value[
'urlnew']) ?
'' : $value[
'urlnew'];
1077 $buttonnew = empty($value[
'buttonnew']) ?
'' : $value[
'buttonnew'];
1078 $testnew = empty($value[
'testnew']) ?
'' : $value[
'testnew'];
1079 $project_field = empty($value[
'project_field']) ?
'' : $value[
'project_field'];
1080 $nototal = empty($value[
'nototal']) ? 0 : 1;
1082 $exclude_select_element = array(
'payment_various');
1083 if (!empty($value[
'exclude_select_element'])) {
1084 $exclude_select_element[] = $value[
'exclude_select_element'];
1091 $element =
new $classname($db);
1095 $idtofilterthirdparty = 0;
1096 $array_of_element_linkable_with_different_thirdparty = array(
'facture_fourn',
'commande_fournisseur');
1097 if (!in_array($tablename, $array_of_element_linkable_with_different_thirdparty)) {
1098 $idtofilterthirdparty = empty(
$object->thirdparty->id) ? 0 :
$object->thirdparty->id;
1100 $idtofilterthirdparty .=
',' .
getDolGlobalString(
'PROJECT_OTHER_THIRDPARTY_ID_TO_ADD_ELEMENTS');
1104 $elementarray =
$object->get_element_list($key, $tablename, $datefieldname, $dates, $datee, !empty($project_field) ? $project_field :
'fk_projet');
1107 if (!
getDolGlobalString(
'PROJECT_LINK_ON_OVERWIEW_DISABLED') && $idtofilterthirdparty && !in_array($tablename, $exclude_select_element)) {
1108 $selectList = $formproject->select_element($tablename, $idtofilterthirdparty,
'minwidth300 minwidth75imp', -2, empty($project_field) ?
'fk_projet' : $project_field, $langs->trans(
"SelectElement"));
1109 if ((
int) $selectList < 0) {
1111 } elseif ($selectList) {
1113 $addform .=
'<div class="inline-block valignmiddle">';
1114 $addform .=
'<form action="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'" method="post">';
1115 $addform .=
'<input type="hidden" name="token" value="'.newToken().
'">';
1116 $addform .=
'<input type="hidden" name="tablename" value="'.$tablename.
'">';
1117 $addform .=
'<input type="hidden" name="action" value="addelement">';
1118 $addform .=
'<input type="hidden" name="datesrfc" value="'.dol_print_date($dates,
'dayhourrfc').
'">';
1119 $addform .=
'<input type="hidden" name="dateerfc" value="'.dol_print_date($datee,
'dayhourrfc').
'">';
1120 $addform .=
'<table><tr>';
1122 $addform .=
'<td>'.$selectList.
'</td>';
1123 $addform .=
'<td><input type="submit" class="button button-linkto smallpaddingimp" value="'.dol_escape_htmltag($langs->trans(
"LinkToElementShort")).
'"></td>';
1124 $addform .=
'</tr></table>';
1125 $addform .=
'</form>';
1126 $addform .=
'</div>';
1130 $addform .=
'<div class="inline-block valignmiddle">';
1132 $addform .=
'<a class="buttonxxx marginleftonly" href="'.$urlnew.
'" title="'.
dol_escape_htmltag($langs->trans($buttonnew)).
'"><span class="fa fa-plus-circle valignmiddle paddingleft"></span></a>';
1134 $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>';
1136 $addform .=
'<div>';
1139 if (is_array($elementarray) && count($elementarray) > 0 && $key ==
"order_supplier") {
1140 $addform =
'<div class="inline-block valignmiddle"><a id="btnShow" class="buttonxxx marginleftonly" href="#" onClick="return false;">
1141 <span id="textBtnShow" class="valignmiddle text-plus-circle hideonsmartphone">'.$langs->trans(
"CanceledShown").
'</span><span id="minus-circle" class="fa fa-eye valignmiddle paddingleft"></span>
1144 $("#btnShow").on("click", function () {
1145 console.log("We click to show or hide the canceled lines");
1146 var attr = $(this).attr("data-canceledarehidden");
1147 if (typeof attr !== "undefined" && attr !== false) {
1148 console.log("Show canceled");
1149 $(".tr_canceled").show();
1150 $("#textBtnShow").text("'.
dol_escape_js($langs->transnoentitiesnoconv(
"CanceledShown")).
'");
1151 $("#btnShow").removeAttr("data-canceledarehidden");
1152 $("#minus-circle").removeClass("fa-eye-slash").addClass("fa-eye");
1154 console.log("Hide canceled");
1155 $(".tr_canceled").hide();
1156 $("#textBtnShow").text("'.
dol_escape_js($langs->transnoentitiesnoconv(
"CanceledHidden")).
'");
1157 $("#btnShow").attr("data-canceledarehidden", 1);
1158 $("#minus-circle").removeClass("fa-eye").addClass("fa-eye-slash");
1161 </script></div> '.$addform;
1166 print
"\n".
'<!-- Table for tablename = '.$tablename.
' -->'.
"\n";
1167 print
'<div class="div-table-responsive">';
1168 print
'<table class="noborder centpercent">';
1170 print
'<tr class="liste_titre">';
1172 print
'<td style="width: 24px"></td>';
1174 print
'<td'.(($tablename !=
'actioncomm' && $tablename !=
'projet_task') ?
' style="width: 200px"' :
'').
'>'.$langs->trans(
"Ref").
'</td>';
1176 if (
'MouvementStock' == $classname) {
1177 print
'<td style="width: 200px">'.$langs->trans(
"Product").
'</td>';
1178 print
'<td style="width: 50px">'.$langs->trans(
"Qty").
'</td>';
1181 print
'<td'.(($tablename !=
'actioncomm' && $tablename !=
'projet_task') ?
' style="width: 200px"' :
'').
' class="center">';
1182 if (in_array($tablename, array(
'projet_task'))) {
1183 print $langs->trans(
"TimeSpent");
1185 if (!in_array($tablename, array(
'projet_task'))) {
1186 print $langs->trans(
"Date");
1191 if (in_array($tablename, array(
'projet_task')) && $key ==
'project_task') {
1193 } elseif (in_array($tablename, array(
'payment_various'))) {
1194 print $langs->trans(
"Label");
1195 } elseif (in_array($tablename, array(
'expensereport_det',
'don',
'projet_task',
'stock_mouvement',
'salary'))) {
1196 print $langs->trans(
"User");
1198 print $langs->trans(
"ThirdParty");
1202 if ($tablename ==
'fichinter') {
1204 print $langs->trans(
"TotalDuration");
1205 $total_duration = 0;
1211 if ($key ==
'loan') {
1212 print
'<td class="right" width="120">'.$langs->trans(
"LoanCapital").
'</td>';
1213 } elseif (empty($value[
'disableamount'])) {
1214 print
'<td class="right" width="120">'.$langs->trans(
"AmountHT").
'</td>';
1216 print
'<td width="120"></td>';
1220 if ($key ==
'loan') {
1221 print
'<td class="right" width="120">'.$langs->trans(
"RemainderToPay").
'</td>';
1222 } elseif (empty($value[
'disableamount'])) {
1223 print
'<td class="right" width="120">'.$langs->trans(
"AmountTTC").
'</td>';
1225 print
'<td width="120"></td>';
1228 if (in_array($tablename, array(
'projet_task'))) {
1229 print
'<td class="right" width="200">'.$langs->trans(
"ProgressDeclared").
'</td>';
1231 print
'<td class="right" width="200">'.$langs->trans(
"Status").
'</td>';
1235 if (is_array($elementarray) && count($elementarray) > 0) {
1239 $total_ht_by_third = 0;
1240 $total_ttc_by_third = 0;
1242 $saved_third_id = 0;
1250 $num = count($elementarray);
1251 for ($i = 0; $i < $num; $i++) {
1252 $tmp = explode(
'_', $elementarray[$i]);
1253 $idofelement = $tmp[0];
1254 $idofelementuser = isset($tmp[1]) ? $tmp[1] :
"";
1256 $element->fetch($idofelement);
1257 if ($idofelementuser) {
1258 $elementuser->fetch($idofelementuser);
1262 if ($tablename !=
'expensereport_det') {
1263 if (method_exists($element,
'fetch_thirdparty')) {
1264 $element->fetch_thirdparty();
1268 $expensereport->fetch($element->fk_expensereport);
1273 if ($breakline && $saved_third_id != $element->thirdparty->id) {
1276 $saved_third_id = $element->thirdparty->id;
1279 $total_ht_by_third = 0;
1280 $total_ttc_by_third = 0;
1283 $saved_third_id = empty($element->thirdparty->id) ? 0 : $element->thirdparty->id;
1285 $qualifiedfortotal =
true;
1286 if ($key ==
'invoice') {
1287 if (!empty($element->close_code) && $element->close_code ==
'replaced') {
1288 $qualifiedfortotal =
false;
1290 } elseif ($key ==
'order_supplier' && $element->status == 7) {
1291 $qualifiedfortotal =
false;
1294 if ($key ==
"order_supplier" && $element->status == 7) {
1295 print
'<tr class="oddeven tr_canceled" style=display:none>';
1297 print
'<tr class="oddeven" >';
1302 print
'<td style="width: 24px">';
1303 if ($tablename !=
'projet_task' && $tablename !=
'stock_mouvement') {
1305 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=unlink&tablename='.$tablename.
'&elementselect='.$element->id.($project_field ?
'&projectfield='.$project_field :
'').
'" class="reposition">';
1306 print
img_picto($langs->trans(
'Unlink'),
'unlink');
1313 print
'<td class="left nowraponall tdoverflowmax250">';
1314 if ($tablename ==
'expensereport_det') {
1315 print $expensereport->getNomUrl(1);
1318 if ($element instanceof
Task) {
1319 print $element->getNomUrl(1,
'withproject',
'time');
1320 print
' - '.dol_trunc($element->label, 48);
1321 } elseif ($key ==
'loan') {
1322 print $element->getNomUrl(1);
1323 print
' - '.dol_trunc($element->label, 48);
1325 print $element->getNomUrl(1);
1328 $element_doc = $element->element;
1330 if (!empty($conf->$element_doc)) {
1331 $confelementdoc = $conf->$element_doc;
1332 $filedir = $confelementdoc->multidir_output[$element->entity].
'/'.
dol_sanitizeFileName($element->ref);
1337 if ($element_doc ===
'order_supplier') {
1338 $element_doc =
'commande_fournisseur';
1339 $filedir = $conf->fournisseur->commande->multidir_output[$element->entity].
'/'.
dol_sanitizeFileName($element->ref);
1340 } elseif ($element_doc ===
'invoice_supplier') {
1341 $element_doc =
'facture_fournisseur';
1342 $filename =
get_exdir($element->id, 2, 0, 0, $element,
'invoice_supplier').dol_sanitizeFileName($element->ref);
1343 $filedir = $conf->fournisseur->facture->multidir_output[$element->entity].
'/'.$filename;
1346 print
'<div class="inline-block valignmiddle">';
1348 print $formfile->getDocumentsLink($element_doc, $filename, $filedir);
1353 if (!empty($element->ref_supplier)) {
1354 print
' - '.$element->ref_supplier;
1357 if (!empty($element->ref_customer)) {
1358 print
' - '.$element->ref_customer;
1361 if (empty($element->ref_customer) && !empty($element->ref_client)) {
1362 print
' - '.$element->ref_client;
1367 if (
'MouvementStock' == $classname) {
1368 $mvsProd =
new Product($element->db);
1369 $mvsProd->fetch($element->product_id);
1370 print
'<td>'.$mvsProd->getNomUrl(1).
'</td>';
1371 print
'<td>'.$element->qty.
'</td>';
1375 $total_time_by_line =
null;
1376 if ($tablename ==
'expensereport_det') {
1377 $date = $element->date;
1378 } elseif ($tablename ==
'stock_mouvement') {
1379 $date = $element->datem;
1380 } elseif ($tablename ==
'salary') {
1381 $date = $element->datesp;
1382 } elseif ($tablename ==
'payment_various') {
1383 $date = $element->datev;
1384 } elseif ($tablename ==
'chargesociales') {
1385 $date = $element->date_ech;
1386 } elseif (!empty($element->status) || !empty($element->statut) || !empty($element->fk_status)) {
1387 if ($tablename ==
'don') {
1388 $date = $element->datedon;
1390 if ($tablename ==
'commande_fournisseur' || $tablename ==
'supplier_order') {
1391 $date = ($element->date_commande ? $element->date_commande : $element->date_valid);
1392 } elseif ($tablename ==
'supplier_proposal') {
1393 $date = $element->date_validation;
1394 } elseif ($tablename ==
'fichinter') {
1395 $date = $element->datev;
1396 } elseif ($tablename ==
'projet_task') {
1399 $date = $element->date;
1401 $date = $element->date_contrat;
1404 $date = $element->datev;
1406 if (empty($date) && !empty($datefieldname)) {
1407 $date = $element->$datefieldname;
1410 } elseif ($key ==
'loan') {
1411 $date = $element->datestart;
1414 print
'<td class="center">';
1415 if ($tablename ==
'actioncomm') {
1417 if ($element->datef && $element->datef > $element->datep) {
1418 print
" - ".dol_print_date($element->datef,
'dayhour');
1420 } elseif (in_array($tablename, array(
'projet_task'))) {
1421 $tmpprojtime = $element->getSumOfAmount($idofelementuser ? $elementuser :
'', $dates, $datee);
1422 print
'<a href="'.DOL_URL_ROOT.
'/projet/tasks/time.php?id='.$idofelement.
'&withproject=1">';
1425 $total_time_by_line = $tmpprojtime[
'nbseconds'];
1432 print
'<td class="tdoverflowmax150">';
1433 if (is_object($element->thirdparty)) {
1434 print $element->thirdparty->getNomUrl(1,
'', 48);
1435 } elseif ($tablename ==
'expensereport_det') {
1436 $tmpuser =
new User($db);
1437 $tmpuser->fetch($expensereport->fk_user_author);
1438 print $tmpuser->getNomUrl(1,
'', 48);
1439 } elseif ($tablename ==
'salary') {
1440 $tmpuser =
new User($db);
1441 $tmpuser->fetch($element->fk_user);
1442 print $tmpuser->getNomUrl(1,
'', 48);
1443 } elseif ($tablename ==
'don' || $tablename ==
'stock_mouvement') {
1444 if ($element->fk_user_author > 0) {
1445 $tmpuser2 =
new User($db);
1446 $tmpuser2->fetch($element->fk_user_author);
1447 print $tmpuser2->getNomUrl(1,
'', 48);
1449 } elseif ($tablename ==
'projet_task' && $key ==
'element_time') {
1450 print $elementuser->getNomUrl(1);
1451 } elseif ($tablename ==
'payment_various') {
1452 print $element->label;
1457 if ($tablename ==
'fichinter') {
1459 print
convertSecondToTime($element->duration,
'all', $conf->global->MAIN_DURATION_OF_WORKDAY);
1460 $total_duration += $element->duration;
1466 if (empty($value[
'disableamount'])) {
1467 $total_ht_by_line =
null;
1469 if ($tablename ==
'don' || $tablename ==
'chargesociales' || $tablename ==
'payment_various' || $tablename ==
'salary') {
1470 $total_ht_by_line = $element->amount;
1471 } elseif ($tablename ==
'fichinter') {
1472 $total_ht_by_line = $element->getAmount();
1473 } elseif ($tablename ==
'stock_mouvement') {
1474 $total_ht_by_line = $element->price * abs($element->qty);
1475 } elseif (in_array($tablename, array(
'projet_task'))) {
1476 if (isModEnabled(
'salaries')) {
1478 $total_ht_by_line =
price2num($tmpprojtime[
'amount'],
'MT');
1479 if ($tmpprojtime[
'nblinesnull'] > 0) {
1480 $langs->load(
"errors");
1481 $warning = $langs->trans(
"WarningSomeLinesWithNullHourlyRate", $conf->currency);
1484 $othermessage = $form->textwithpicto($langs->trans(
"NotAvailable"), $langs->trans(
"ModuleSalaryToDefineHourlyRateMustBeEnabled"));
1486 } elseif ($key ==
'loan') {
1487 $total_ht_by_line = $element->capital;
1489 $total_ht_by_line = $element->total_ht;
1493 if ($tablename ==
'payment_various') {
1494 if ($element->sens == 0) {
1495 $total_ht_by_line = -$total_ht_by_line;
1499 print
'<td class="right">';
1500 if ($othermessage) {
1501 print
'<span class="opacitymedium">'.$othermessage.
'</span>';
1503 if (isset($total_ht_by_line)) {
1504 if (!$qualifiedfortotal) {
1507 print
'<span class="amount">'.price($total_ht_by_line).
'</span>';
1508 if (!$qualifiedfortotal) {
1513 print
' '.img_warning($warning);
1521 if (empty($value[
'disableamount'])) {
1522 $total_ttc_by_line =
null;
1523 if ($tablename ==
'don' || $tablename ==
'chargesociales' || $tablename ==
'payment_various' || $tablename ==
'salary') {
1524 $total_ttc_by_line = $element->amount;
1525 } elseif ($tablename ==
'fichinter') {
1526 $total_ttc_by_line = $element->getAmount();
1527 } elseif ($tablename ==
'stock_mouvement') {
1528 $total_ttc_by_line = $element->price * abs($element->qty);
1529 } elseif ($tablename ==
'projet_task') {
1530 if (isModEnabled(
'salaries')) {
1533 $total_ttc_by_line =
price2num($total_ht_by_line * (1 + ($defaultvat / 100)),
'MT');
1535 $othermessage = $form->textwithpicto($langs->trans(
"NotAvailable"), $langs->trans(
"ModuleSalaryToDefineHourlyRateMustBeEnabled"));
1537 } elseif ($key ==
'loan') {
1538 $total_ttc_by_line = $element->capital - $element->getSumPayment();
1540 $total_ttc_by_line = $element->total_ttc;
1544 if ($tablename ==
'payment_various') {
1545 if ($element->sens == 0) {
1546 $total_ttc_by_line = -$total_ttc_by_line;
1550 print
'<td class="right">';
1551 if ($othermessage) {
1552 print $othermessage;
1554 if (isset($total_ttc_by_line)) {
1555 if (!$qualifiedfortotal) {
1558 print
'<span class="amount">'.price($total_ttc_by_line).
'</span>';
1559 if (!$qualifiedfortotal) {
1564 print
' '.img_warning($warning);
1572 print
'<td class="right">';
1573 if ($tablename ==
'expensereport_det') {
1574 print $expensereport->getLibStatut(5);
1577 print $element->getLibStatut(5, $element->getSommePaiement());
1578 } elseif ($element instanceof
Task) {
1579 if ($element->progress !=
'') {
1580 print $element->progress.
' %';
1582 } elseif ($tablename ==
'stock_mouvement') {
1583 print $element->getLibStatut(3);
1585 print $element->getLibStatut(5);
1591 if ($qualifiedfortotal) {
1592 $total_ht += $total_ht_by_line;
1593 $total_ttc += $total_ttc_by_line;
1595 $total_ht_by_third += $total_ht_by_line;
1596 $total_ttc_by_third += $total_ttc_by_line;
1598 if (!isset($total_time)) {
1599 $total_time = $total_time_by_line;
1601 $total_time += $total_time_by_line;
1606 $breakline =
'<tr class="liste_total liste_sub_total">';
1607 $breakline .=
'<td colspan="2">';
1608 $breakline .=
'</td>';
1609 $breakline .=
'<td>';
1610 $breakline .=
'</td>';
1611 $breakline .=
'<td class="right">';
1612 $breakline .= $langs->trans(
'SubTotal').
' : ';
1613 if (is_object($element->thirdparty)) {
1614 $breakline .= $element->thirdparty->getNomUrl(0,
'', 48);
1616 $breakline .=
'</td>';
1617 $breakline .=
'<td class="right">'.price($total_ht_by_third).
'</td>';
1618 $breakline .=
'<td class="right">'.price($total_ttc_by_third).
'</td>';
1619 $breakline .=
'<td></td>';
1620 $breakline .=
'</tr>';
1631 if (empty($nototal)) {
1633 if (in_array($tablename, array(
'projet_task'))) {
1637 print
'<tr class="liste_total"><td colspan="'.$colspan.
'">'.$langs->trans(
"Number").
': '.$i.
'</td>';
1638 if (in_array($tablename, array(
'projet_task'))) {
1639 print
'<td class="center">';
1648 if ($tablename ==
'fichinter') {
1649 print
'<td class="left">'.convertSecondToTime($total_duration,
'all', $conf->global->MAIN_DURATION_OF_WORKDAY).
'</td>';
1651 print
'<td class="right">';
1652 if (empty($value[
'disableamount'])) {
1653 if ($key ==
'loan') {
1654 print $langs->trans(
"Total").
' '.$langs->trans(
"LoanCapital").
' : '.
price($total_ttc);
1655 } elseif ($tablename !=
'projet_task' || isModEnabled(
'salaries')) {
1656 print
''.$langs->trans(
"TotalHT").
' : '.
price($total_ht);
1662 print
'<td class="right">';
1663 if (empty($value[
'disableamount'])) {
1664 if ($key ==
'loan') {
1665 print $langs->trans(
"Total").
' '.$langs->trans(
"RemainderToPay").
' : '.
price($total_ttc);
1666 } elseif ($tablename !=
'projet_task' || isModEnabled(
'salaries')) {
1667 print $langs->trans(
"TotalTTC").
' : '.
price($total_ttc);
1671 print
'<td> </td>';
1675 if (!is_array($elementarray)) {
1676 print
'<tr><td>'.$elementarray.
'</td></tr>';
1679 if ($tablename ==
'fichinter') {
1682 print
'<tr><td colspan="'.$colspan.
'"><span class="opacitymedium">'.$langs->trans(
"None").
'</td></tr>';
1692if ($conf->use_javascript_ajax) {
1693 include_once DOL_DOCUMENT_ROOT.
'/core/lib/ajax.lib.php';
1696 print $comboenhancement;
1718 return in_array($tablename, array(
'facture_fourn',
'commande_fournisseur'));
1729 global $db, $classname;
1730 '@phan-var-force string $classname';
1732 $element =
new $classname($db);
1733 '@phan-var-force CommonObject $element';
1735 $clientname = array();
1736 foreach ($elementarray as $key =>
$id) {
1737 if (empty($clientname[
$id])) {
1738 $element->fetch(
$id);
1739 $element->fetch_thirdparty();
1741 $clientname[
$id] = $element->thirdparty->name;
1748 $elementarray = array();
1749 foreach ($clientname as
$id => $name) {
1750 $elementarray[] =
$id;
1753 return $elementarray;
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
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($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
Superclass for invoice classes.
Class for ConferenceOrBoothAttendee.
Class to manage Trips and Expenses.
const TYPE_DEPOSIT
Deposit invoice.
Class to manage Schedule of loans.
Class to manage products or services.
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_mktime($hour, $minute, $second, $month, $day, $year, $gm='auto', $check=1)
Return a timestamp date built from detailed information (by default a local PHP server timestamp) Rep...
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
img_warning($titlealt='default', $moreatt='', $morecss='pictowarning')
Show warning logo.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
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, $attop=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_now($mode='auto')
Return date for now.
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.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
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...
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
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.