33 require
'../main.inc.php';
34 require_once DOL_DOCUMENT_ROOT.
'/projet/class/project.class.php';
35 require_once DOL_DOCUMENT_ROOT.
'/projet/class/task.class.php';
36 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formprojet.class.php';
37 require_once DOL_DOCUMENT_ROOT.
'/core/lib/project.lib.php';
38 require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
39 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
41 require_once DOL_DOCUMENT_ROOT.
'/product/stock/class/entrepot.class.php';
44 require_once DOL_DOCUMENT_ROOT.
'/comm/propal/class/propal.class.php';
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';
51 require_once DOL_DOCUMENT_ROOT.
'/commande/class/commande.class.php';
54 require_once DOL_DOCUMENT_ROOT.
'/supplier_proposal/class/supplier_proposal.class.php';
57 require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.facture.class.php';
60 require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.commande.class.php';
63 require_once DOL_DOCUMENT_ROOT.
'/contrat/class/contrat.class.php';
66 require_once DOL_DOCUMENT_ROOT.
'/fichinter/class/fichinter.class.php';
69 require_once DOL_DOCUMENT_ROOT.
'/expedition/class/expedition.class.php';
72 require_once DOL_DOCUMENT_ROOT.
'/compta/deplacement/class/deplacement.class.php';
75 require_once DOL_DOCUMENT_ROOT.
'/expensereport/class/expensereport.class.php';
78 require_once DOL_DOCUMENT_ROOT.
'/comm/action/class/actioncomm.class.php';
81 require_once DOL_DOCUMENT_ROOT.
'/don/class/don.class.php';
84 require_once DOL_DOCUMENT_ROOT.
'/loan/class/loan.class.php';
85 require_once DOL_DOCUMENT_ROOT.
'/loan/class/loanschedule.class.php';
88 require_once DOL_DOCUMENT_ROOT.
'/product/stock/class/mouvementstock.class.php';
91 require_once DOL_DOCUMENT_ROOT.
'/compta/sociales/class/chargesociales.class.php';
94 require_once DOL_DOCUMENT_ROOT.
'/compta/bank/class/paymentvarious.class.php';
97 require_once DOL_DOCUMENT_ROOT.
'/salaries/class/salary.class.php';
100 require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
103 require_once DOL_DOCUMENT_ROOT.
'/mrp/class/mo.class.php';
107 $langs->loadLangs(array(
'projects',
'companies',
'suppliers',
'compta'));
109 $langs->load(
"bills");
112 $langs->load(
"orders");
115 $langs->load(
"propal");
118 $langs->load(
"interventions");
121 $langs->load(
"trips");
124 $langs->load(
"trips");
127 $langs->load(
"donations");
130 $langs->load(
"loan");
133 $langs->load(
"salaries");
139 $langs->load(
"eventorganization");
143 $ref =
GETPOST(
'ref',
'alpha');
144 $action =
GETPOST(
'action',
'aZ09');
145 $datesrfc =
GETPOST(
'datesrfc');
146 $dateerfc =
GETPOST(
'dateerfc');
149 if (empty($dates) && !empty($datesrfc)) {
152 if (empty($datee) && !empty($dateerfc)) {
155 if (!
GETPOSTISSET(
'datesrfc') && !
GETPOSTISSET(
'datesday') && !empty($conf->global->PROJECT_LINKED_ELEMENT_DEFAULT_FILTER_YEAR)) {
162 if ($id ==
'' && $ref ==
'') {
164 header(
'Location: list.php');
168 $mine =
GETPOST(
'mode') ==
'mine' ? 1 : 0;
173 include DOL_DOCUMENT_ROOT.
'/core/actions_fetchobject.inc.php';
174 if (!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;
191 if (!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';
203 $userstatic =
new User($db);
206 $userAccess = $object->restrictedProjectArea($user);
209 print
dol_get_fiche_head($head,
'element', $langs->trans(
"Project"), -1, ($object->public ?
'projectpub' :
'project'));
214 $linkback =
'<a href="'.DOL_URL_ROOT.
'/projet/list.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
216 $morehtmlref =
'<div class="refidno">';
218 $morehtmlref .= $object->title;
220 if (!empty($object->thirdparty->id) && $object->thirdparty->id > 0) {
221 $morehtmlref .=
'<br>'.$object->thirdparty->getNomUrl(1,
'project');
223 $morehtmlref .=
'</div>';
226 if (empty($user->rights->projet->all->lire)) {
227 $objectsListId = $object->getProjectsAuthorizedForUser($user, 0, 0);
228 $object->next_prev_filter =
" te.rowid IN (".$db->sanitize(count($objectsListId) ?join(
',', array_keys($objectsListId)) :
'0').
")";
231 dol_banner_tab($object,
'ref', $linkback, 1,
'ref',
'ref', $morehtmlref);
234 print
'<div class="fichecenter">';
235 print
'<div class="fichehalfleft">';
236 print
'<div class="underbanner clearboth"></div>';
238 print
'<table class="border tableforfield centpercent">';
241 if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES) || empty($conf->global->PROJECT_HIDE_TASKS) ||
isModEnabled(
'eventorganization')) {
242 print
'<tr><td class="tdtop">';
243 print $langs->trans(
"Usage");
246 if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES)) {
247 print
'<input type="checkbox" disabled name="usage_opportunity"'.(GETPOSTISSET(
'usage_opportunity') ? (
GETPOST(
'usage_opportunity',
'alpha') !=
'' ?
' checked="checked"' :
'') : ($object->usage_opportunity ?
' checked="checked"' :
'')).
'"> ';
248 $htmltext = $langs->trans(
"ProjectFollowOpportunity");
249 print
$form->textwithpicto($langs->trans(
"ProjectFollowOpportunity"), $htmltext);
252 if (empty($conf->global->PROJECT_HIDE_TASKS)) {
253 print
'<input type="checkbox" disabled name="usage_task"'.(GETPOSTISSET(
'usage_task') ? (
GETPOST(
'usage_task',
'alpha') !=
'' ?
' checked="checked"' :
'') : ($object->usage_task ?
' checked="checked"' :
'')).
'"> ';
254 $htmltext = $langs->trans(
"ProjectFollowTasks");
255 print
$form->textwithpicto($langs->trans(
"ProjectFollowTasks"), $htmltext);
258 if (empty($conf->global->PROJECT_HIDE_TASKS) && !empty($conf->global->PROJECT_BILL_TIME_SPENT)) {
259 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"' :
'')).
'"> ';
260 $htmltext = $langs->trans(
"ProjectBillTimeDescription");
261 print
$form->textwithpicto($langs->trans(
"BillTime"), $htmltext);
265 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"' :
'')).
'"> ';
266 $htmltext = $langs->trans(
"EventOrganizationDescriptionLong");
267 print
$form->textwithpicto($langs->trans(
"ManageOrganizeEvent"), $htmltext);
273 print
'<tr><td class="titlefield">'.$langs->trans(
"Visibility").
'</td><td>';
274 if ($object->public) {
275 print
img_picto($langs->trans(
'SharedProject'),
'world',
'class="paddingrightonly"');
276 print $langs->trans(
'SharedProject');
278 print
img_picto($langs->trans(
'PrivateProject'),
'private',
'class="paddingrightonly"');
279 print $langs->trans(
'PrivateProject');
283 if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES)) {
285 print
'<tr><td>'.$langs->trans(
"OpportunityStatus").
'</td><td>';
286 $code =
dol_getIdFromCode($db, $object->opp_status,
'c_lead_status',
'rowid',
'code');
288 print $langs->trans(
"OppStatus".$code);
293 print
'<tr><td>'.$langs->trans(
"OpportunityProbability").
'</td><td>';
294 if (!is_null($object->opp_percent) && strcmp($object->opp_percent,
'')) {
295 print
price($object->opp_percent,
'', $langs, 1, 0).
' %';
300 print
'<tr><td>'.$langs->trans(
"OpportunityAmount").
'</td><td>';
301 if (!is_null($object->opp_amount) && strcmp($object->opp_amount,
'')) {
302 print
'<span class="amount">'.price($object->opp_amount,
'', $langs, 1, 0, 0, $conf->currency).
'</span>';
303 if (strcmp($object->opp_percent,
'')) {
304 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>';
311 print
'<tr><td>'.$langs->trans(
"Budget").
'</td><td>';
312 if (!is_null($object->budget_amount) && strcmp($object->budget_amount,
'')) {
313 print
'<span class="amount">'.price($object->budget_amount,
'', $langs, 1, 0, 0, $conf->currency).
'</span>';
318 print
'<tr><td>'.$langs->trans(
"Dates").
'</td><td>';
320 print ($start ? $start :
'?');
323 print ($end ? $end :
'?');
324 if ($object->hasDelay()) {
331 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_view.tpl.php';
336 print
'<div class="fichehalfright">';
337 print
'<div class="underbanner clearboth"></div>';
339 print
'<table class="border tableforfield centpercent">';
342 print
'<td class="titlefield tdtop">'.$langs->trans(
"Description").
'</td><td>';
348 print
'<tr><td class="valignmiddle">'.$langs->trans(
"Categories").
'</td><td>';
349 print
$form->showCategories($object->id, Categorie::TYPE_PROJECT, 1);
358 print
'<div class="clearboth"></div>';
368 $listofreferent = array(
371 'title'=>
"ListWarehouseAssociatedProject",
374 'datefieldname'=>
'date_entrepot',
375 'urlnew'=>DOL_URL_ROOT.
'/product/stock/card.php?action=create&projectid='.$id.
'&backtopage='.urlencode($_SERVER[
'PHP_SELF'].
'?id='.$id),
377 'buttonnew'=>
'AddWarehouse',
378 'project_field'=>
'fk_project',
379 'testnew'=>$user->hasRight(
'stock',
'creer'),
380 'test'=>
isModEnabled(
'stock') && $user->hasRight(
'stock',
'lire') && !empty($conf->global->WAREHOUSE_ASK_WAREHOUSE_DURING_PROJECT)
384 'title'=>
"ListProposalsAssociatedProject",
387 'datefieldname'=>
'datep',
388 'urlnew'=>DOL_URL_ROOT.
'/comm/propal/card.php?action=create&origin=project&originid='.$id.
'&socid='.$socid.
'&backtopage='.urlencode($_SERVER[
'PHP_SELF'].
'?id='.$id),
390 'buttonnew'=>
'AddProp',
391 'testnew'=>$user->hasRight(
'propal',
'creer'),
392 'test'=>
isModEnabled(
'propal') && $user->hasRight(
'propal',
'lire')
395 'name'=>
"CustomersOrders",
396 'title'=>
"ListOrdersAssociatedProject",
399 'datefieldname'=>
'date_commande',
400 'urlnew'=>DOL_URL_ROOT.
'/commande/card.php?action=create&projectid='.$id.
'&socid='.$socid.
'&backtopage='.urlencode($_SERVER[
'PHP_SELF'].
'?id='.$id),
402 'buttonnew'=>
'CreateOrder',
403 'testnew'=>$user->hasRight(
'commande',
'creer'),
404 'test'=>
isModEnabled(
'commande') && $user->hasRight(
'commande',
'lire')
407 'name'=>
"CustomersInvoices",
408 'title'=>
"ListInvoicesAssociatedProject",
412 'datefieldname'=>
'datef',
413 'urlnew'=>DOL_URL_ROOT.
'/compta/facture/card.php?action=create&projectid='.$id.
'&socid='.$socid.
'&backtopage='.urlencode($_SERVER[
'PHP_SELF'].
'?id='.$id),
415 'buttonnew'=>
'CreateBill',
416 'testnew'=>$user->hasRight(
'facture',
'creer'),
417 'test'=>
isModEnabled(
'facture') && $user->hasRight(
'facture',
'lire')
419 'invoice_predefined'=>array(
420 'name'=>
"PredefinedInvoices",
421 'title'=>
"ListPredefinedInvoicesAssociatedProject",
422 'class'=>
'FactureRec',
423 'table'=>
'facture_rec',
424 'datefieldname'=>
'datec',
425 'urlnew'=>DOL_URL_ROOT.
'/compta/facture/card.php?action=create&projectid='.$id.
'&socid='.$socid.
'&backtopage='.urlencode($_SERVER[
'PHP_SELF'].
'?id='.$id),
427 'buttonnew'=>
'CreateBill',
428 'testnew'=>$user->hasRight(
'facture',
'creer'),
429 'test'=>
isModEnabled(
'facture') && $user->hasRight(
'facture',
'lire')
431 'proposal_supplier'=>array(
432 'name'=>
"SupplierProposals",
433 'title'=>
"ListSupplierProposalsAssociatedProject",
434 'class'=>
'SupplierProposal',
435 'table'=>
'supplier_proposal',
436 'datefieldname'=>
'date_valid',
437 'urlnew'=>DOL_URL_ROOT.
'/supplier_proposal/card.php?action=create&projectid='.$id.
'&backtopage='.urlencode($_SERVER[
'PHP_SELF'].
'?id='.$id),
438 'lang'=>
'supplier_proposal',
439 'buttonnew'=>
'AddSupplierProposal',
440 'testnew'=>$user->hasRight(
'supplier_proposal',
'creer'),
441 'test'=>
isModEnabled(
'supplier_proposal') && $user->hasRight(
'supplier_proposal',
'lire')
443 'order_supplier'=>array(
444 'name'=>
"SuppliersOrders",
445 'title'=>
"ListSupplierOrdersAssociatedProject",
446 'class'=>
'CommandeFournisseur',
447 'table'=>
'commande_fournisseur',
448 'datefieldname'=>
'date_commande',
449 'urlnew'=>DOL_URL_ROOT.
'/fourn/commande/card.php?action=create&projectid='.$id.
'&backtopage='.urlencode($_SERVER[
'PHP_SELF'].
'?id='.$id),
451 'buttonnew'=>
'AddSupplierOrder',
452 'testnew'=>$user->hasRight(
'fournisseur',
'commande',
'creer') || $user->hasRight(
'supplier_order',
'creer'),
453 'test'=>
isModEnabled(
'supplier_order') && $user->hasRight(
'fournisseur',
'commande',
'lire') || $user->hasRight(
'supplier_order',
'lire')
455 'invoice_supplier'=>array(
456 'name'=>
"BillsSuppliers",
457 'title'=>
"ListSupplierInvoicesAssociatedProject",
458 'class'=>
'FactureFournisseur',
460 'table'=>
'facture_fourn',
461 'datefieldname'=>
'datef',
462 'urlnew'=>DOL_URL_ROOT.
'/fourn/facture/card.php?action=create&projectid='.$id.
'&backtopage='.urlencode($_SERVER[
'PHP_SELF'].
'?id='.$id),
464 'buttonnew'=>
'AddSupplierInvoice',
465 'testnew'=>$user->hasRight(
'fournisseur',
'facture',
'creer') || $user->hasRight(
'supplier_invoice',
'creer'),
466 'test'=>
isModEnabled(
'supplier_invoice') && $user->hasRight(
'fournisseur',
'facture',
'lire') || $user->hasRight(
'supplier_invoice',
'lire')
470 'title'=>
"ListContractAssociatedProject",
473 'datefieldname'=>
'date_contrat',
474 'urlnew'=>DOL_URL_ROOT.
'/contrat/card.php?action=create&projectid='.$id.
'&socid='.$socid.
'&backtopage='.urlencode($_SERVER[
'PHP_SELF'].
'?id='.$id),
476 'buttonnew'=>
'AddContract',
477 'testnew'=>$user->hasRight(
'contrat',
'creer'),
478 'test'=>
isModEnabled(
'contrat') && $user->hasRight(
'contrat',
'lire')
480 'intervention'=>array(
481 'name'=>
"Interventions",
482 'title'=>
"ListFichinterAssociatedProject",
483 'class'=>
'Fichinter',
484 'table'=>
'fichinter',
485 'datefieldname'=>
'date_valid',
488 'urlnew'=>DOL_URL_ROOT.
'/fichinter/card.php?action=create&origin=project&originid='.$id.
'&socid='.$socid.
'&backtopage='.urlencode($_SERVER[
'PHP_SELF'].
'?id='.$id),
489 'lang'=>
'interventions',
490 'buttonnew'=>
'AddIntervention',
491 'testnew'=>$user->hasRight(
'ficheinter',
'creer'),
492 'test'=>
isModEnabled(
'ficheinter') && $user->hasRight(
'ficheinter',
'lire')
496 'title'=>
"ListShippingAssociatedProject",
497 'class'=>
'Expedition',
498 'table'=>
'expedition',
499 'datefieldname'=>
'date_valid',
500 'urlnew'=>DOL_URL_ROOT.
'/expedition/card.php?action=create&origin=project&originid='.$id.
'&socid='.$socid.
'&backtopage='.urlencode($_SERVER[
'PHP_SELF'].
'?id='.$id),
502 'buttonnew'=>
'CreateShipment',
504 'test'=>
isModEnabled(
'expedition') && $user->hasRight(
'expedition',
'lire')
508 'title'=>
"ListMOAssociatedProject",
511 'datefieldname'=>
'date_valid',
512 'urlnew'=>DOL_URL_ROOT.
'/mrp/mo_card.php?action=create&origin=project&originid='.$id.
'&socid='.$socid.
'&backtopage='.urlencode($_SERVER[
'PHP_SELF'].
'?id='.$id),
514 'buttonnew'=>
'CreateMO',
515 'testnew'=>$user->hasRight(
'mrp',
'write'),
516 'project_field'=>
'fk_project',
518 'test'=>
isModEnabled(
'mrp') && $user->hasRight(
'mrp',
'read')
521 'name'=>
"TripsAndExpenses",
522 'title'=>
"ListExpenseReportsAssociatedProject",
523 'class'=>
'Deplacement',
524 'table'=>
'deplacement',
525 'datefieldname'=>
'dated',
528 'urlnew'=>DOL_URL_ROOT.
'/deplacement/card.php?action=create&projectid='.$id.
'&socid='.$socid.
'&backtopage='.urlencode($_SERVER[
'PHP_SELF'].
'?id='.$id),
530 'buttonnew'=>
'AddTrip',
531 'testnew'=>$user->hasRight(
'deplacement',
'creer'),
532 'test'=>
isModEnabled(
'deplacement') && $user->hasRight(
'deplacement',
'lire')
534 'expensereport'=>array(
535 'name'=>
"ExpenseReports",
536 'title'=>
"ListExpenseReportsAssociatedProject",
537 'class'=>
'ExpenseReportLine',
538 'table'=>
'expensereport_det',
539 'datefieldname'=>
'date',
542 'urlnew'=>DOL_URL_ROOT.
'/expensereport/card.php?action=create&projectid='.$id.
'&socid='.$socid.
'&backtopage='.urlencode($_SERVER[
'PHP_SELF'].
'?id='.$id),
544 'buttonnew'=>
'AddTrip',
545 'testnew'=>$user->hasRight(
'expensereport',
'creer'),
546 'test'=>
isModEnabled(
'expensereport') && $user->hasRight(
'expensereport',
'lire')
550 'title'=>
"ListDonationsAssociatedProject",
554 'datefieldname'=>
'datedon',
556 'urlnew'=>DOL_URL_ROOT.
'/don/card.php?action=create&projectid='.$id.
'&socid='.$socid.
'&backtopage='.urlencode($_SERVER[
'PHP_SELF'].
'?id='.$id),
558 'buttonnew'=>
'AddDonation',
559 'testnew'=>$user->hasRight(
'don',
'creer'),
560 'test'=>
isModEnabled(
'don') && $user->hasRight(
'don',
'lire')
564 'title'=>
"ListLoanAssociatedProject",
568 'datefieldname'=>
'datestart',
570 'urlnew'=>DOL_URL_ROOT.
'/loan/card.php?action=create&projectid='.$id.
'&socid='.$socid.
'&backtopage='.urlencode($_SERVER[
'PHP_SELF'].
'?id='.$id),
572 'buttonnew'=>
'AddLoan',
573 'testnew'=>$user->hasRight(
'loan',
'write'),
574 'test'=>
isModEnabled(
'loan') && $user->hasRight(
'loan',
'read')
576 'chargesociales'=>array(
577 'name'=>
"SocialContribution",
578 'title'=>
"ListSocialContributionAssociatedProject",
579 'class'=>
'ChargeSociales',
581 'table'=>
'chargesociales',
582 'datefieldname'=>
'date_ech',
584 'urlnew'=>DOL_URL_ROOT.
'/compta/sociales/card.php?action=create&projectid='.$id.
'&backtopage='.urlencode($_SERVER[
'PHP_SELF'].
'?id='.$id),
586 'buttonnew'=>
'AddSocialContribution',
587 'testnew'=>$user->hasRight(
'tax',
'charges',
'lire'),
588 'test'=>
isModEnabled(
'tax') && $user->hasRight(
'tax',
'charges',
'lire')
590 'project_task'=>array(
591 'name'=>
"TaskTimeSpent",
592 'title'=>
"ListTaskTimeUserProject",
595 'table'=>
'projet_task',
596 'datefieldname'=>
'element_date',
598 'urlnew'=>DOL_URL_ROOT.
'/projet/tasks/time.php?withproject=1&action=createtime&projectid='.$id.
'&backtopage='.urlencode($_SERVER[
'PHP_SELF'].
'?id='.$id),
599 'buttonnew'=>
'AddTimeSpent',
600 'testnew'=>$user->hasRight(
'project',
'creer'),
601 'test'=>
isModEnabled(
'project') && $user->hasRight(
'projet',
'lire') && empty($conf->global->PROJECT_HIDE_TASKS)
603 'stock_mouvement'=>array(
604 'name'=>
"MouvementStockAssociated",
605 'title'=>
"ListMouvementStockProject",
606 'class'=>
'MouvementStock',
607 'table'=>
'stock_mouvement',
608 'datefieldname'=>
'datem',
611 'test'=>
isModEnabled(
'stock') && $user->hasRight(
'stock',
'mouvement',
'lire') && !empty($conf->global->STOCK_MOVEMENT_INTO_PROJECT_OVERVIEW)
615 'title'=>
"ListSalariesAssociatedProject",
618 'datefieldname'=>
'datesp',
621 'urlnew'=>DOL_URL_ROOT.
'/salaries/card.php?action=create&projectid='.$id.
'&backtopage='.urlencode($_SERVER[
'PHP_SELF'].
'?id='.$id),
623 'buttonnew'=>
'AddSalary',
624 'testnew'=>$user->hasRight(
'salaries',
'write'),
625 'test'=>
isModEnabled(
'salaries') && $user->hasRight(
'salaries',
'read')
627 'variouspayment'=>array(
628 'name'=>
"VariousPayments",
629 'title'=>
"ListVariousPaymentsAssociatedProject",
630 'class'=>
'PaymentVarious',
631 'table'=>
'payment_various',
632 'datefieldname'=>
'datev',
635 'urlnew'=>DOL_URL_ROOT.
'/compta/bank/various_payment/card.php?action=create&projectid='.$id.
'&backtopage='.urlencode($_SERVER[
'PHP_SELF'].
'?id='.$id),
637 'buttonnew'=>
'AddVariousPayment',
638 'testnew'=>$user->hasRight(
'banque',
'modifier'),
639 'test'=>
isModEnabled(
"banque") && $user->hasRight(
'banque',
'lire') && empty($conf->global->BANK_USE_OLD_VARIOUS_PAYMENT)
658 if (!empty($conf->global->PROJECT_ELEMENTS_FOR_PLUS_MARGIN)) {
659 foreach ($listofreferent as $key => $element) {
660 if ($listofreferent[$key][
'margin'] ==
'add') {
661 unset($listofreferent[$key][
'margin']);
664 $newelementforplusmargin = explode(
',', $conf->global->PROJECT_ELEMENTS_FOR_PLUS_MARGIN);
665 foreach ($newelementforplusmargin as $value) {
666 $listofreferent[trim($value)][
'margin'] =
'add';
669 if (!empty($conf->global->PROJECT_ELEMENTS_FOR_MINUS_MARGIN)) {
670 foreach ($listofreferent as $key => $element) {
671 if ($listofreferent[$key][
'margin'] ==
'minus') {
672 unset($listofreferent[$key][
'margin']);
675 $newelementforminusmargin = explode(
',', $conf->global->PROJECT_ELEMENTS_FOR_MINUS_MARGIN);
676 foreach ($newelementforminusmargin as $value) {
677 $listofreferent[trim($value)][
'margin'] =
'minus';
682 $parameters = array(
'listofreferent'=>$listofreferent);
683 $resHook = $hookmanager->executeHooks(
'completeListOfReferent', $parameters, $object, $action);
685 if (!empty($hookmanager->resArray)) {
686 $listofreferent = array_merge($listofreferent, $hookmanager->resArray);
689 if ($action ==
"addelement") {
690 $tablename =
GETPOST(
"tablename");
691 $elementselectid =
GETPOST(
"elementselect");
692 $result = $object->update_element($tablename, $elementselectid);
696 } elseif ($action ==
"unlink") {
697 $tablename =
GETPOST(
"tablename",
"aZ09");
698 $projectField =
GETPOSTISSET(
'projectfield') ?
GETPOST(
'projectfield',
'aZ09') :
'fk_projet';
699 $elementselectid =
GETPOST(
"elementselect",
"int");
701 $result = $object->remove_element($tablename, $elementselectid, $projectField);
707 $elementuser =
new User($db);
713 if (!$showdatefilter) {
714 print
'<div class="center centpercent">';
715 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'" method="POST">';
716 print
'<input type="hidden" name="token" value="'.newToken().
'">';
717 print
'<input type="hidden" name="tablename" value="'.(empty($tablename) ?
'' : $tablename).
'">';
718 print
'<input type="hidden" name="action" value="view">';
719 print
'<div class="inline-block">';
720 print
$form->selectDate($dates,
'dates', 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
"From"));
722 print
'<div class="inline-block">';
723 print
$form->selectDate($datee,
'datee', 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
"to"));
725 print
'<div class="inline-block">';
726 print
'<input type="submit" name="refresh" value="'.$langs->trans(
"Refresh").
'" class="button small">';
738 $langs->loadLangs(array(
"suppliers",
"bills",
"orders",
"proposals",
"margins"));
741 $langs->load(
'stocks');
746 print
'<table class="noborder centpercent">';
747 print
'<tr class="liste_titre">';
748 print
'<td class="left" width="200">';
749 $tooltiponprofit = $langs->trans(
"ProfitIsCalculatedWith").
"<br>\n";
750 $tooltiponprofitplus = $tooltiponprofitminus =
'';
751 foreach ($listofreferent as $key => $value) {
752 if (!empty($value[
'lang'])) {
753 $langs->load($value[
'lang']);
755 $name = $langs->trans($value[
'name']);
756 $qualified = $value[
'test'];
757 $margin = empty($value[
'margin']) ?
'' : $value[
'margin'];
758 if ($qualified && isset($margin)) {
759 if ($margin ===
'add') {
760 $tooltiponprofitplus .=
' > '.$name.
" (+)<br>\n";
762 if ($margin ===
'minus') {
763 $tooltiponprofitminus .=
' > '.$name.
" (-)<br>\n";
767 $tooltiponprofit .= $tooltiponprofitplus;
768 $tooltiponprofit .= $tooltiponprofitminus;
769 print
$form->textwithpicto($langs->trans(
"Element"), $tooltiponprofit);
771 print
'<td class="right" width="100">'.$langs->trans(
"Number").
'</td>';
772 print
'<td class="right" width="100">'.$langs->trans(
"AmountHT").
'</td>';
773 print
'<td class="right" width="100">'.$langs->trans(
"AmountTTC").
'</td>';
776 $total_revenue_ht = 0;
781 foreach ($listofreferent as $key => $value) {
783 'total_revenue_ht' =>& $total_revenue_ht,
784 'balance_ht' =>& $balance_ht,
785 'balance_ttc' =>& $balance_ttc,
791 $reshook = $hookmanager->executeHooks(
'printOverviewProfit', $parameters, $object, $action);
794 } elseif ($reshook > 0) {
795 print $hookmanager->resPrint;
799 $name = $langs->trans($value[
'name']);
800 $title = $value[
'title'];
801 $classname = $value[
'class'];
802 $tablename = $value[
'table'];
803 $datefieldname = $value[
'datefieldname'];
804 $qualified = $value[
'test'];
805 $margin = empty($value[
'margin']) ? 0 : $value[
'margin'];
806 $project_field = empty($value[
'project_field']) ?
'' : $value[
'project_field'];
807 if ($qualified && isset($margin)) {
808 $element =
new $classname($db);
810 $elementarray = $object->get_element_list($key, $tablename, $datefieldname, $dates, $datee, !empty($project_field) ? $project_field :
'fk_projet');
812 if (is_array($elementarray) && count($elementarray) > 0) {
817 $num = count($elementarray);
818 for ($i = 0; $i < $num; $i++) {
819 $tmp = explode(
'_', $elementarray[$i]);
820 $idofelement = $tmp[0];
821 $idofelementuser = !empty($tmp[1]) ? $tmp[1] :
"";
823 $element->fetch($idofelement);
824 if ($idofelementuser) {
825 $elementuser->fetch($idofelementuser);
829 $qualifiedfortotal =
true;
830 if ($key ==
'invoice') {
831 if (!empty($element->close_code) && $element->close_code ==
'replaced') {
832 $qualifiedfortotal =
false;
834 if (!empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS) && $element->type ==
Facture::TYPE_DEPOSIT) {
835 $qualifiedfortotal =
false;
838 if ($key ==
'propal') {
840 $qualifiedfortotal =
false;
844 if ($tablename !=
'expensereport_det' && method_exists($element,
'fetch_thirdparty')) {
845 $element->fetch_thirdparty();
849 if ($tablename ==
'don' || $tablename ==
'chargesociales' || $tablename ==
'payment_various' || $tablename ==
'salary') {
850 $total_ht_by_line = $element->amount;
851 } elseif ($tablename ==
'fichinter') {
852 $total_ht_by_line = $element->getAmount();
853 } elseif ($tablename ==
'stock_mouvement') {
854 $total_ht_by_line = $element->price * abs($element->qty);
855 } elseif ($tablename ==
'projet_task') {
856 $tmp = $element->getSumOfAmount($idofelementuser ? $elementuser :
'', $dates, $datee);
857 $total_ht_by_line =
price2num($tmp[
'amount'],
'MT');
858 } elseif ($key ==
'loan') {
859 if ((empty($dates) && empty($datee)) || (intval($dates) <= $element->datestart && intval($datee) >= $element->dateend)) {
861 $total_ht_by_line = -$element->capital;
864 $total_ht_by_line = 0;
866 $loanScheduleStatic->fetchAll($element->id);
867 if (!empty($loanScheduleStatic->lines)) {
868 foreach ($loanScheduleStatic->lines as $loanSchedule) {
872 if (($loanSchedule->datep >= $dates && $loanSchedule->datep <= $datee)
873 || !empty($dates) && empty($datee) && $loanSchedule->datep >= $dates && $loanSchedule->datep <=
dol_now()
874 || empty($dates) && !empty($datee) && $loanSchedule->datep <= $datee
876 $total_ht_by_line -= $loanSchedule->amount_capital;
882 $total_ht_by_line = $element->total_ht;
886 if ($tablename ==
'don' || $tablename ==
'chargesociales' || $tablename ==
'payment_various' || $tablename ==
'salary') {
887 $total_ttc_by_line = $element->amount;
888 } elseif ($tablename ==
'fichinter') {
889 $total_ttc_by_line = $element->getAmount();
890 } elseif ($tablename ==
'stock_mouvement') {
891 $total_ttc_by_line = $element->price * abs($element->qty);
892 } elseif ($tablename ==
'projet_task') {
894 $total_ttc_by_line =
price2num($total_ht_by_line * (1 + ($defaultvat / 100)),
'MT');
895 } elseif ($key ==
'loan') {
896 $total_ttc_by_line = $total_ht_by_line;
898 $total_ttc_by_line = $element->total_ttc;
902 if ($tablename ==
'payment_various') {
903 if ($element->sens == 1) {
904 $total_ht_by_line = -$total_ht_by_line;
905 $total_ttc_by_line = -$total_ttc_by_line;
910 if ($qualifiedfortotal) {
911 $total_ht = $total_ht + $total_ht_by_line;
912 $total_ttc = $total_ttc + $total_ttc_by_line;
920 if ($margin ===
'add') {
921 $total_revenue_ht += $total_ht;
924 if ($margin ===
"minus") {
925 $total_ht = -$total_ht;
926 $total_ttc = -$total_ttc;
929 $balance_ht += $total_ht;
930 $balance_ttc += $total_ttc;
933 print
'<tr class="oddeven">';
935 print
'<td class="left">'.$name.
'</td>';
937 print
'<td class="right">'.$i.
'</td>';
939 print
'<td class="right">';
940 if ($key ==
'intervention' && !$margin) {
941 print
'<span class="opacitymedium">'.$form->textwithpicto($langs->trans(
"NA"), $langs->trans(
"AmountOfInteventionNotIncludedByDefault")).
'</span>';
943 if ($key ==
'propal') {
944 print
'<span class="opacitymedium">'.$form->textwithpicto(
'', $langs->trans(
"SignedOnly")).
'</span>';
946 print
price($total_ht);
950 print
'<td class="right">';
951 if ($key ==
'intervention' && !$margin) {
952 print
'<span class="opacitymedium">'.$form->textwithpicto($langs->trans(
"NA"), $langs->trans(
"AmountOfInteventionNotIncludedByDefault")).
'</span>';
954 if ($key ==
'propal') {
955 print
'<span class="opacitymedium">'.$form->textwithpicto(
'', $langs->trans(
"SignedOnly")).
'</span>';
957 print
price($total_ttc);
965 print
'<tr class="liste_total">';
966 print
'<td class="right" colspan="2">'.$langs->trans(
"Profit").
'</td>';
967 print
'<td class="right">'.price(
price2num($balance_ht,
'MT')).
'</td>';
968 print
'<td class="right">'.price(
price2num($balance_ttc,
'MT')).
'</td>';
972 if ($total_revenue_ht) {
973 print
'<tr class="liste_total">';
974 print
'<td class="right" colspan="2">'.$langs->trans(
"Margin").
'</td>';
975 print
'<td class="right">'.round(100 * $balance_ht / $total_revenue_ht, 1).
'%</td>';
976 print
'<td class="right"></td>';
989 foreach ($listofreferent as $key => $value) {
996 $reshook = $hookmanager->executeHooks(
'printOverviewDetail', $parameters, $object, $action);
999 } elseif ($reshook > 0) {
1000 print $hookmanager->resPrint;
1004 $title = $value[
'title'];
1005 $classname = $value[
'class'];
1006 $tablename = $value[
'table'];
1007 $datefieldname = $value[
'datefieldname'];
1008 $qualified = $value[
'test'];
1009 $urlnew = empty($value[
'urlnew']) ?
'' : $value[
'urlnew'];
1010 $buttonnew = empty($value[
'buttonnew']) ?
'' : $value[
'buttonnew'];
1011 $testnew = empty($value[
'testnew']) ?
'' : $value[
'testnew'];
1012 $project_field = empty($value[
'project_field']) ?
'' : $value[
'project_field'];
1013 $nototal = empty($value[
'nototal']) ? 0 : 1;
1015 $exclude_select_element = array(
'payment_various');
1016 if (!empty($value[
'exclude_select_element'])) {
1017 $exclude_select_element[] = $value[
'exclude_select_element'];
1024 $element =
new $classname($db);
1028 $idtofilterthirdparty = 0;
1029 $array_of_element_linkable_with_different_thirdparty = array(
'facture_fourn',
'commande_fournisseur');
1030 if (!in_array($tablename, $array_of_element_linkable_with_different_thirdparty)) {
1031 $idtofilterthirdparty = empty($object->thirdparty->id) ? 0 : $object->thirdparty->id;
1032 if (!empty($conf->global->PROJECT_OTHER_THIRDPARTY_ID_TO_ADD_ELEMENTS)) {
1033 $idtofilterthirdparty .=
','.$conf->global->PROJECT_OTHER_THIRDPARTY_ID_TO_ADD_ELEMENTS;
1037 $elementarray = $object->get_element_list($key, $tablename, $datefieldname, $dates, $datee, !empty($project_field) ? $project_field :
'fk_projet');
1040 if (empty($conf->global->PROJECT_LINK_ON_OVERWIEW_DISABLED) && $idtofilterthirdparty && !in_array($tablename, $exclude_select_element)) {
1041 $selectList = $formproject->select_element($tablename, $idtofilterthirdparty,
'minwidth300 minwidth75imp', -2, empty($project_field) ?
'fk_projet' : $project_field, $langs->trans(
"SelectElement"));
1042 if ($selectList < 0) {
1044 } elseif ($selectList) {
1046 $addform .=
'<div class="inline-block valignmiddle">';
1047 $addform .=
'<form action="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'" method="post">';
1048 $addform .=
'<input type="hidden" name="token" value="'.newToken().
'">';
1049 $addform .=
'<input type="hidden" name="tablename" value="'.$tablename.
'">';
1050 $addform .=
'<input type="hidden" name="action" value="addelement">';
1051 $addform .=
'<input type="hidden" name="datesrfc" value="'.dol_print_date($dates,
'dayhourrfc').
'">';
1052 $addform .=
'<input type="hidden" name="dateerfc" value="'.dol_print_date($datee,
'dayhourrfc').
'">';
1053 $addform .=
'<table><tr>';
1055 $addform .=
'<td>'.$selectList.
'</td>';
1056 $addform .=
'<td><input type="submit" class="button button-linkto smallpaddingimp" value="'.dol_escape_htmltag($langs->trans(
"LinkToElementShort")).
'"></td>';
1057 $addform .=
'</tr></table>';
1058 $addform .=
'</form>';
1059 $addform .=
'</div>';
1062 if (empty($conf->global->PROJECT_CREATE_ON_OVERVIEW_DISABLED) && $urlnew) {
1063 $addform .=
'<div class="inline-block valignmiddle">';
1065 $addform .=
'<a class="buttonxxx marginleftonly" href="'.$urlnew.
'" title="'.
dol_escape_htmltag($langs->trans($buttonnew)).
'"><span class="fa fa-plus-circle valignmiddle paddingleft"></span></a>';
1066 } elseif (empty($conf->global->MAIN_BUTTON_HIDE_UNAUTHORIZED)) {
1067 $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>';
1069 $addform .=
'<div>';
1072 if (is_array($elementarray) && count($elementarray) > 0 && $key ==
"order_supplier") {
1073 $addform =
'<div class="inline-block valignmiddle"><a id="btnShow" class="buttonxxx marginleftonly" href="#" onClick="return false;">
1074 <span id="textBtnShow" class="valignmiddle text-plus-circle hideonsmartphone">'.$langs->trans(
"CanceledShown").
'</span><span id="minus-circle" class="fa fa-eye valignmiddle paddingleft"></span>
1077 $("#btnShow").on("click", function () {
1078 console.log("We click to show or hide the canceled lines");
1079 var attr = $(this).attr("data-canceledarehidden");
1080 if (typeof attr !== "undefined" && attr !== false) {
1081 console.log("Show canceled");
1082 $(".tr_canceled").show();
1083 $("#textBtnShow").text("'.
dol_escape_js($langs->transnoentitiesnoconv(
"CanceledShown")).
'");
1084 $("#btnShow").removeAttr("data-canceledarehidden");
1085 $("#minus-circle").removeClass("fa-eye-slash").addClass("fa-eye");
1087 console.log("Hide canceled");
1088 $(".tr_canceled").hide();
1089 $("#textBtnShow").text("'.
dol_escape_js($langs->transnoentitiesnoconv(
"CanceledHidden")).
'");
1090 $("#btnShow").attr("data-canceledarehidden", 1);
1091 $("#minus-circle").removeClass("fa-eye").addClass("fa-eye-slash");
1094 </script></div> '.$addform;
1099 print
"\n".
'<!-- Table for tablename = '.$tablename.
' -->'.
"\n";
1100 print
'<div class="div-table-responsive">';
1101 print
'<table class="noborder centpercent">';
1103 print
'<tr class="liste_titre">';
1105 print
'<td style="width: 24px"></td>';
1107 print
'<td'.(($tablename !=
'actioncomm' && $tablename !=
'projet_task') ?
' style="width: 200px"' :
'').
'>'.$langs->trans(
"Ref").
'</td>';
1109 print
'<td'.(($tablename !=
'actioncomm' && $tablename !=
'projet_task') ?
' style="width: 200px"' :
'').
' class="center">';
1110 if (in_array($tablename, array(
'projet_task'))) {
1111 print $langs->trans(
"TimeSpent");
1113 if (!in_array($tablename, array(
'projet_task'))) {
1114 print $langs->trans(
"Date");
1119 if (in_array($tablename, array(
'projet_task')) && $key ==
'project_task') {
1121 } elseif (in_array($tablename, array(
'payment_various'))) {
1123 } elseif (in_array($tablename, array(
'expensereport_det',
'don',
'projet_task',
'stock_mouvement',
'salary'))) {
1124 print $langs->trans(
"User");
1126 print $langs->trans(
"ThirdParty");
1130 if ($tablename ==
'fichinter') {
1132 print $langs->trans(
"TotalDuration");
1133 $total_duration = 0;
1139 if ($key ==
'loan') {
1140 print
'<td class="right" width="120">'.$langs->trans(
"LoanCapital").
'</td>';
1141 } elseif (empty($value[
'disableamount'])) {
1142 print
'<td class="right" width="120">'.$langs->trans(
"AmountHT").
'</td>';
1144 print
'<td width="120"></td>';
1148 if ($key ==
'loan') {
1149 print
'<td class="right" width="120">'.$langs->trans(
"RemainderToPay").
'</td>';
1150 } elseif (empty($value[
'disableamount'])) {
1151 print
'<td class="right" width="120">'.$langs->trans(
"AmountTTC").
'</td>';
1153 print
'<td width="120"></td>';
1156 if (in_array($tablename, array(
'projet_task'))) {
1157 print
'<td class="right" width="200">'.$langs->trans(
"ProgressDeclared").
'</td>';
1159 print
'<td class="right" width="200">'.$langs->trans(
"Status").
'</td>';
1163 if (is_array($elementarray) && count($elementarray) > 0) {
1167 $total_ht_by_third = 0;
1168 $total_ttc_by_third = 0;
1170 $saved_third_id = 0;
1178 $num = count($elementarray);
1179 for ($i = 0; $i < $num; $i++) {
1180 $tmp = explode(
'_', $elementarray[$i]);
1181 $idofelement = $tmp[0];
1182 $idofelementuser = isset($tmp[1]) ? $tmp[1] :
"";
1184 $element->fetch($idofelement);
1185 if ($idofelementuser) {
1186 $elementuser->fetch($idofelementuser);
1190 if ($tablename !=
'expensereport_det') {
1191 if (method_exists($element,
'fetch_thirdparty')) {
1192 $element->fetch_thirdparty();
1196 $expensereport->fetch($element->fk_expensereport);
1201 if ($breakline && $saved_third_id != $element->thirdparty->id) {
1204 $saved_third_id = $element->thirdparty->id;
1207 $total_ht_by_third = 0;
1208 $total_ttc_by_third = 0;
1211 $saved_third_id = empty($element->thirdparty->id) ? 0 : $element->thirdparty->id;
1213 $qualifiedfortotal =
true;
1214 if ($key ==
'invoice') {
1215 if (!empty($element->close_code) && $element->close_code ==
'replaced') {
1216 $qualifiedfortotal =
false;
1218 } elseif ($key ==
'order_supplier' && $element->status == 7) {
1219 $qualifiedfortotal =
false;
1222 if ($key ==
"order_supplier" && $element->status == 7) {
1223 print
'<tr class="oddeven tr_canceled" style=display:none>';
1225 print
'<tr class="oddeven" >';
1230 print
'<td style="width: 24px">';
1231 if ($tablename !=
'projet_task' && $tablename !=
'stock_mouvement') {
1232 if (empty($conf->global->PROJECT_DISABLE_UNLINK_FROM_OVERVIEW) || $user->admin) {
1233 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&action=unlink&tablename='.$tablename.
'&elementselect='.$element->id.($project_field ?
'&projectfield='.$project_field :
'').
'" class="reposition">';
1234 print
img_picto($langs->trans(
'Unlink'),
'unlink');
1241 print
'<td class="left nowraponall">';
1242 if ($tablename ==
'expensereport_det') {
1243 print $expensereport->getNomUrl(1);
1246 if ($element instanceof
Task) {
1247 print $element->getNomUrl(1,
'withproject',
'time');
1248 print
' - '.dol_trunc($element->label, 48);
1249 } elseif ($key ==
'loan') {
1250 print $element->getNomUrl(1);
1251 print
' - '.dol_trunc($element->label, 48);
1253 print $element->getNomUrl(1);
1256 $element_doc = $element->element;
1258 if (!empty($conf->$element_doc)) {
1259 $confelementdoc = $conf->$element_doc;
1260 $filedir = $confelementdoc->multidir_output[$element->entity].
'/'.
dol_sanitizeFileName($element->ref);
1265 if ($element_doc ===
'order_supplier') {
1266 $element_doc =
'commande_fournisseur';
1267 $filedir = $conf->fournisseur->commande->multidir_output[$element->entity].
'/'.
dol_sanitizeFileName($element->ref);
1268 } elseif ($element_doc ===
'invoice_supplier') {
1269 $element_doc =
'facture_fournisseur';
1270 $filename =
get_exdir($element->id, 2, 0, 0, $element,
'product').dol_sanitizeFileName($element->ref);
1271 $filedir = $conf->fournisseur->facture->multidir_output[$element->entity].
'/'.
get_exdir($element->id, 2, 0, 0, $element,
'invoice_supplier').dol_sanitizeFileName($element->ref);
1274 print
'<div class="inline-block valignmiddle">';
1276 print $formfile->getDocumentsLink($element_doc, $filename, $filedir);
1281 if (!empty($element->ref_supplier)) {
1282 print
' - '.$element->ref_supplier;
1285 if (!empty($element->ref_customer)) {
1286 print
' - '.$element->ref_customer;
1289 if (empty($element->ref_customer) && !empty($element->ref_client)) {
1290 print
' - '.$element->ref_client;
1296 $date =
''; $total_time_by_line =
null; $total_time = 0;
1297 if ($tablename ==
'expensereport_det') {
1298 $date = $element->date;
1299 } elseif ($tablename ==
'stock_mouvement') {
1300 $date = $element->datem;
1301 } elseif ($tablename ==
'salary') {
1302 $date = $element->datesp;
1303 } elseif ($tablename ==
'payment_various') {
1304 $date = $element->datev;
1305 } elseif ($tablename ==
'chargesociales') {
1306 $date = $element->date_ech;
1307 } elseif (!empty($element->status) || !empty($element->statut) || !empty($element->fk_status)) {
1308 if ($tablename ==
'don') {
1309 $date = $element->datedon;
1311 if ($tablename ==
'commande_fournisseur' || $tablename ==
'supplier_order') {
1312 $date = ($element->date_commande ? $element->date_commande : $element->date_valid);
1313 } elseif ($tablename ==
'supplier_proposal') {
1314 $date = $element->date_validation;
1315 } elseif ($tablename ==
'fichinter') {
1316 $date = $element->datev;
1317 } elseif ($tablename ==
'projet_task') {
1320 $date = $element->date;
1322 $date = $element->date_contrat;
1325 $date = $element->datev;
1327 if (empty($date) && !empty($datefieldname)) {
1328 $date = $element->$datefieldname;
1331 } elseif ($key ==
'loan') {
1332 $date = $element->datestart;
1335 print
'<td class="center">';
1336 if ($tablename ==
'actioncomm') {
1338 if ($element->datef && $element->datef > $element->datep) {
1339 print
" - ".dol_print_date($element->datef,
'dayhour');
1341 } elseif (in_array($tablename, array(
'projet_task'))) {
1342 $tmpprojtime = $element->getSumOfAmount($idofelementuser ? $elementuser :
'', $dates, $datee);
1343 print
'<a href="'.DOL_URL_ROOT.
'/projet/tasks/time.php?id='.$idofelement.
'&withproject=1">';
1346 $total_time_by_line = $tmpprojtime[
'nbseconds'];
1353 print
'<td class="left">';
1354 if (is_object($element->thirdparty)) {
1355 print $element->thirdparty->getNomUrl(1,
'', 48);
1356 } elseif ($tablename ==
'expensereport_det') {
1357 $tmpuser =
new User($db);
1358 $tmpuser->fetch($expensereport->fk_user_author);
1359 print $tmpuser->getNomUrl(1,
'', 48);
1360 } elseif ($tablename ==
'salary') {
1361 $tmpuser =
new User($db);
1362 $tmpuser->fetch($element->fk_user);
1363 print $tmpuser->getNomUrl(1,
'', 48);
1364 } elseif ($tablename ==
'don' || $tablename ==
'stock_mouvement') {
1365 if ($element->fk_user_author > 0) {
1366 $tmpuser2 =
new User($db);
1367 $tmpuser2->fetch($element->fk_user_author);
1368 print $tmpuser2->getNomUrl(1,
'', 48);
1370 } elseif ($tablename ==
'projet_task' && $key ==
'element_time') {
1371 print $elementuser->getNomUrl(1);
1376 if ($tablename ==
'fichinter') {
1378 print
convertSecondToTime($element->duration,
'all', $conf->global->MAIN_DURATION_OF_WORKDAY);
1379 $total_duration += $element->duration;
1385 if (empty($value[
'disableamount'])) {
1386 $total_ht_by_line =
null;
1388 if ($tablename ==
'don' || $tablename ==
'chargesociales' || $tablename ==
'payment_various' || $tablename ==
'salary') {
1389 $total_ht_by_line = $element->amount;
1390 } elseif ($tablename ==
'fichinter') {
1391 $total_ht_by_line = $element->getAmount();
1392 } elseif ($tablename ==
'stock_mouvement') {
1393 $total_ht_by_line = $element->price * abs($element->qty);
1394 } elseif (in_array($tablename, array(
'projet_task'))) {
1397 $total_ht_by_line =
price2num($tmpprojtime[
'amount'],
'MT');
1398 if ($tmpprojtime[
'nblinesnull'] > 0) {
1399 $langs->load(
"errors");
1400 $warning = $langs->trans(
"WarningSomeLinesWithNullHourlyRate", $conf->currency);
1403 $othermessage =
$form->textwithpicto($langs->trans(
"NotAvailable"), $langs->trans(
"ModuleSalaryToDefineHourlyRateMustBeEnabled"));
1405 } elseif ($key ==
'loan') {
1406 $total_ht_by_line = $element->capital;
1408 $total_ht_by_line = $element->total_ht;
1412 if ($tablename ==
'payment_various') {
1413 if ($element->sens == 0) {
1414 $total_ht_by_line = -$total_ht_by_line;
1418 print
'<td class="right">';
1419 if ($othermessage) {
1420 print $othermessage;
1422 if (isset($total_ht_by_line)) {
1423 if (!$qualifiedfortotal) {
1426 print
'<span class="amount">'.price($total_ht_by_line).
'</span>';
1427 if (!$qualifiedfortotal) {
1432 print
' '.img_warning($warning);
1440 if (empty($value[
'disableamount'])) {
1441 $total_ttc_by_line =
null;
1442 if ($tablename ==
'don' || $tablename ==
'chargesociales' || $tablename ==
'payment_various' || $tablename ==
'salary') {
1443 $total_ttc_by_line = $element->amount;
1444 } elseif ($tablename ==
'fichinter') {
1445 $total_ttc_by_line = $element->getAmount();
1446 } elseif ($tablename ==
'stock_mouvement') {
1447 $total_ttc_by_line = $element->price * abs($element->qty);
1448 } elseif ($tablename ==
'projet_task') {
1452 $total_ttc_by_line =
price2num($total_ht_by_line * (1 + ($defaultvat / 100)),
'MT');
1454 $othermessage =
$form->textwithpicto($langs->trans(
"NotAvailable"), $langs->trans(
"ModuleSalaryToDefineHourlyRateMustBeEnabled"));
1456 } elseif ($key ==
'loan') {
1457 $total_ttc_by_line = $element->capital - $element->getSumPayment();
1459 $total_ttc_by_line = $element->total_ttc;
1463 if ($tablename ==
'payment_various') {
1464 if ($element->sens == 0) {
1465 $total_ttc_by_line = -$total_ttc_by_line;
1469 print
'<td class="right">';
1470 if ($othermessage) {
1471 print $othermessage;
1473 if (isset($total_ttc_by_line)) {
1474 if (!$qualifiedfortotal) {
1477 print
'<span class="amount">'.price($total_ttc_by_line).
'</span>';
1478 if (!$qualifiedfortotal) {
1483 print
' '.img_warning($warning);
1491 print
'<td class="right">';
1492 if ($tablename ==
'expensereport_det') {
1493 print $expensereport->getLibStatut(5);
1496 print $element->getLibStatut(5, $element->getSommePaiement());
1497 } elseif ($element instanceof
Task) {
1498 if ($element->progress !=
'') {
1499 print $element->progress.
' %';
1501 } elseif ($tablename ==
'stock_mouvement') {
1502 print $element->getLibStatut(3);
1504 print $element->getLibStatut(5);
1510 if ($qualifiedfortotal) {
1511 $total_ht = $total_ht + $total_ht_by_line;
1512 $total_ttc = $total_ttc + $total_ttc_by_line;
1514 $total_ht_by_third += $total_ht_by_line;
1515 $total_ttc_by_third += $total_ttc_by_line;
1517 if (!isset($total_time)) $total_time = $total_time_by_line;
1518 else $total_time += $total_time_by_line;
1522 $breakline =
'<tr class="liste_total liste_sub_total">';
1523 $breakline .=
'<td colspan="2">';
1524 $breakline .=
'</td>';
1525 $breakline .=
'<td>';
1526 $breakline .=
'</td>';
1527 $breakline .=
'<td class="right">';
1528 $breakline .= $langs->trans(
'SubTotal').
' : ';
1529 if (is_object($element->thirdparty)) {
1530 $breakline .= $element->thirdparty->getNomUrl(0,
'', 48);
1532 $breakline .=
'</td>';
1533 $breakline .=
'<td class="right">'.price($total_ht_by_third).
'</td>';
1534 $breakline .=
'<td class="right">'.price($total_ttc_by_third).
'</td>';
1535 $breakline .=
'<td></td>';
1536 $breakline .=
'</tr>';
1547 if (empty($nototal)) {
1549 if (in_array($tablename, array(
'projet_task'))) {
1553 print
'<tr class="liste_total"><td colspan="'.$colspan.
'">'.$langs->trans(
"Number").
': '.$i.
'</td>';
1554 if (in_array($tablename, array(
'projet_task'))) {
1555 print
'<td class="center">';
1564 if ($tablename ==
'fichinter') {
1565 print
'<td class="left">'.convertSecondToTime($total_duration,
'all', $conf->global->MAIN_DURATION_OF_WORKDAY).
'</td>';
1567 print
'<td class="right">';
1568 if (empty($value[
'disableamount'])) {
1569 if ($key ==
'loan') {
1570 print $langs->trans(
"Total").
' '.$langs->trans(
"LoanCapital").
' : '.
price($total_ttc);
1571 } elseif ($tablename !=
'projet_task' ||
isModEnabled(
'salaries')) {
1572 print
''.$langs->trans(
"TotalHT").
' : '.
price($total_ht);
1578 print
'<td class="right">';
1579 if (empty($value[
'disableamount'])) {
1580 if ($key ==
'loan') {
1581 print $langs->trans(
"Total").
' '.$langs->trans(
"RemainderToPay").
' : '.
price($total_ttc);
1582 } elseif ($tablename !=
'projet_task' ||
isModEnabled(
'salaries')) {
1583 print $langs->trans(
"TotalTTC").
' : '.
price($total_ttc);
1587 print
'<td> </td>';
1591 if (!is_array($elementarray)) {
1592 print
'<tr><td>'.$elementarray.
'</td></tr>';
1595 if (in_array($tablename, array(
'projet_task'))) {
1598 if ($tablename ==
'fichinter') {
1601 print
'<tr><td colspan="'.$colspan.
'"><span class="opacitymedium">'.$langs->trans(
"None").
'</td></tr>';
1611 if ($conf->use_javascript_ajax) {
1612 include_once DOL_DOCUMENT_ROOT.
'/core/lib/ajax.lib.php';
1615 print $comboenhancement;
1634 if (empty($conf->global->PROJECT_ADD_SUBTOTAL_LINES)) {
1637 return in_array($tablename, array(
'facture_fourn',
'commande_fournisseur'));
1648 global $db, $classname;
1650 $element =
new $classname($db);
1652 $clientname = array();
1653 foreach ($elementarray as $key => $id) {
1654 if (empty($clientname[$id])) {
1655 $element->fetch($id);
1656 $element->fetch_thirdparty();
1658 $clientname[$id] = $element->thirdparty->name;
1665 $elementarray = array();
1666 foreach ($clientname as $id => $name) {
1667 $elementarray[] = $id;
1670 return $elementarray;
if(GETPOST('button_removefilter_x', 'alpha')||GETPOST('button_removefilter.x', 'alpha')||GETPOST('button_removefilter', 'alpha')) if(GETPOST('button_search_x', 'alpha')||GETPOST('button_search.x', 'alpha')||GETPOST('button_search', 'alpha')) if($action=="save" &&empty($cancel)) $help_url
View.
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.
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
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.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form.
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...
isModEnabled($module)
Is Dolibarr module enabled.
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.