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';
 
   56 if ((
isModEnabled(
"fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || 
isModEnabled(
"supplier_invoice")) {
 
   57   require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.facture.class.php';
 
   59 if ((
isModEnabled(
"fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || 
isModEnabled(
"supplier_order")) {
 
   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';
 
   83 if (!empty($conf->loan->enabled)) {
 
   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';
 
   96 if (!empty($conf->salaries->enabled)) {
 
   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");
 
  129 if (!empty($conf->loan->enabled)) {
 
  130   $langs->load(
"loan");
 
  132 if (!empty($conf->salaries->enabled)) {
 
  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 (strcmp($object->opp_percent, 
'')) {
 
  295     print 
price($object->opp_percent, 
'', $langs, 1, 0).
' %';
 
  300   print 
'<tr><td>'.$langs->trans(
"OpportunityAmount").
'</td><td>';
 
  301   if (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 (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>';
 
  343 print nl2br($object->description);
 
  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'=>!empty($conf->stock->enabled) && $user->hasRight(
'stock', 
'lire') && !empty($conf->global->WAREHOUSE_ASK_WAREHOUSE_DURING_PROJECT)),
 
  383   'title'=>
"ListProposalsAssociatedProject",
 
  386   'datefieldname'=>
'datep',
 
  387   'urlnew'=>DOL_URL_ROOT.
'/comm/propal/card.php?action=create&origin=project&originid='.$id.
'&socid='.$socid.
'&backtopage='.urlencode($_SERVER[
'PHP_SELF'].
'?id='.$id),
 
  389   'buttonnew'=>
'AddProp',
 
  390   'testnew'=>$user->hasRight(
'propal', 
'creer'),
 
  391   'test'=>!empty($conf->propal->enabled) && $user->hasRight(
'propal', 
'lire')),
 
  393   'name'=>
"CustomersOrders",
 
  394   'title'=>
"ListOrdersAssociatedProject",
 
  397   'datefieldname'=>
'date_commande',
 
  398   'urlnew'=>DOL_URL_ROOT.
'/commande/card.php?action=create&projectid='.$id.
'&socid='.$socid.
'&backtopage='.urlencode($_SERVER[
'PHP_SELF'].
'?id='.$id),
 
  400   'buttonnew'=>
'CreateOrder',
 
  401   'testnew'=>$user->hasRight(
'commande', 
'creer'),
 
  402   'test'=>!empty($conf->commande->enabled) && $user->hasRight(
'commande', 
'lire')),
 
  404   'name'=>
"CustomersInvoices",
 
  405   'title'=>
"ListInvoicesAssociatedProject",
 
  409   'datefieldname'=>
'datef',
 
  410   'urlnew'=>DOL_URL_ROOT.
'/compta/facture/card.php?action=create&projectid='.$id.
'&socid='.$socid.
'&backtopage='.urlencode($_SERVER[
'PHP_SELF'].
'?id='.$id),
 
  412   'buttonnew'=>
'CreateBill',
 
  413   'testnew'=>$user->hasRight(
'facture', 
'creer'),
 
  414   'test'=>!empty($conf->facture->enabled) && $user->hasRight(
'facture', 
'lire')),
 
  415 'invoice_predefined'=>array(
 
  416   'name'=>
"PredefinedInvoices",
 
  417   'title'=>
"ListPredefinedInvoicesAssociatedProject",
 
  418   'class'=>
'FactureRec',
 
  419   'table'=>
'facture_rec',
 
  420   'datefieldname'=>
'datec',
 
  421   'urlnew'=>DOL_URL_ROOT.
'/compta/facture/card.php?action=create&projectid='.$id.
'&socid='.$socid.
'&backtopage='.urlencode($_SERVER[
'PHP_SELF'].
'?id='.$id),
 
  423   'buttonnew'=>
'CreateBill',
 
  424   'testnew'=>$user->hasRight(
'facture', 
'creer'),
 
  425   'test'=>!empty($conf->facture->enabled) && $user->hasRight(
'facture', 
'lire')),
 
  426 'proposal_supplier'=>array(
 
  427   'name'=>
"SuppliersProposals",
 
  428   'title'=>
"ListSupplierProposalsAssociatedProject",
 
  429   'class'=>
'SupplierProposal',
 
  430   'table'=>
'supplier_proposal',
 
  431   'datefieldname'=>
'date_valid',
 
  432   'urlnew'=>DOL_URL_ROOT.
'/supplier_proposal/card.php?action=create&projectid='.$id.
'&backtopage='.urlencode($_SERVER[
'PHP_SELF'].
'?id='.$id), 
 
  433   'lang'=>
'supplier_proposal',
 
  434   'buttonnew'=>
'AddSupplierProposal',
 
  435   'testnew'=>$user->hasRight(
'supplier_proposal', 
'creer'),
 
  436   'test'=>!empty($conf->supplier_proposal->enabled) && $user->hasRight(
'supplier_proposal', 
'lire')),
 
  437 'order_supplier'=>array(
 
  438   'name'=>
"SuppliersOrders",
 
  439   'title'=>
"ListSupplierOrdersAssociatedProject",
 
  440   'class'=>
'CommandeFournisseur',
 
  441   'table'=>
'commande_fournisseur',
 
  442   'datefieldname'=>
'date_commande',
 
  443   'urlnew'=>DOL_URL_ROOT.
'/fourn/commande/card.php?action=create&projectid='.$id.
'&backtopage='.urlencode($_SERVER[
'PHP_SELF'].
'?id='.$id), 
 
  445   'buttonnew'=>
'AddSupplierOrder',
 
  446   'testnew'=>$user->hasRight(
'fournisseur', 
'commande', 
'creer') || $user->hasRight(
'supplier_order', 
'creer'),
 
  447   'test'=>!empty($conf->supplier_order->enabled) && $user->hasRight(
'fournisseur', 
'commande', 
'lire') || $user->hasRight(
'supplier_order', 
'lire')),
 
  448 'invoice_supplier'=>array(
 
  449   'name'=>
"BillsSuppliers",
 
  450   'title'=>
"ListSupplierInvoicesAssociatedProject",
 
  451   'class'=>
'FactureFournisseur',
 
  453   'table'=>
'facture_fourn',
 
  454   'datefieldname'=>
'datef',
 
  455   'urlnew'=>DOL_URL_ROOT.
'/fourn/facture/card.php?action=create&projectid='.$id.
'&backtopage='.urlencode($_SERVER[
'PHP_SELF'].
'?id='.$id), 
 
  457   'buttonnew'=>
'AddSupplierInvoice',
 
  458   'testnew'=>$user->hasRight(
'fournisseur', 
'facture', 
'creer') || $user->hasRight(
'supplier_invoice', 
'creer'),
 
  459   'test'=>!empty($conf->supplier_invoice->enabled) && $user->hasRight(
'fournisseur', 
'facture', 
'lire') || $user->hasRight(
'supplier_invoice', 
'lire')),
 
  462   'title'=>
"ListContractAssociatedProject",
 
  465   'datefieldname'=>
'date_contrat',
 
  466   'urlnew'=>DOL_URL_ROOT.
'/contrat/card.php?action=create&projectid='.$id.
'&socid='.$socid.
'&backtopage='.urlencode($_SERVER[
'PHP_SELF'].
'?id='.$id),
 
  468   'buttonnew'=>
'AddContract',
 
  469   'testnew'=>$user->hasRight(
'contrat', 
'creer'),
 
  470   'test'=>!empty($conf->contrat->enabled) && $user->hasRight(
'contrat', 
'lire')),
 
  471 'intervention'=>array(
 
  472   'name'=>
"Interventions",
 
  473   'title'=>
"ListFichinterAssociatedProject",
 
  474   'class'=>
'Fichinter',
 
  475   'table'=>
'fichinter',
 
  476   'datefieldname'=>
'date_valid',
 
  479   'urlnew'=>DOL_URL_ROOT.
'/fichinter/card.php?action=create&origin=project&originid='.$id.
'&socid='.$socid.
'&backtopage='.urlencode($_SERVER[
'PHP_SELF'].
'?id='.$id),
 
  480   'lang'=>
'interventions',
 
  481   'buttonnew'=>
'AddIntervention',
 
  482   'testnew'=>$user->hasRight(
'ficheinter', 
'creer'),
 
  483   'test'=>!empty($conf->ficheinter->enabled) && $user->hasRight(
'ficheinter', 
'lire')),
 
  486   'title'=>
"ListShippingAssociatedProject",
 
  487   'class'=>
'Expedition',
 
  488   'table'=>
'expedition',
 
  489   'datefieldname'=>
'date_valid',
 
  490   'urlnew'=>DOL_URL_ROOT.
'/expedition/card.php?action=create&origin=project&originid='.$id.
'&socid='.$socid.
'&backtopage='.urlencode($_SERVER[
'PHP_SELF'].
'?id='.$id),
 
  492   'buttonnew'=>
'CreateShipment',
 
  494   'test'=>$conf->expedition->enabled && $user->rights->expedition->lire),
 
  497   'title'=>
"ListMOAssociatedProject",
 
  500   'datefieldname'=>
'date_valid',
 
  501   'urlnew'=>DOL_URL_ROOT.
'/mrp/mo_card.php?action=create&origin=project&originid='.$id.
'&socid='.$socid.
'&backtopage='.urlencode($_SERVER[
'PHP_SELF'].
'?id='.$id),
 
  503   'buttonnew'=>
'CreateMO',
 
  504   'testnew'=>$user->hasRight(
'mrp', 
'write'),
 
  505   'project_field'=>
'fk_project',
 
  506   'test'=>!empty($conf->mrp->enabled) && $user->hasRight(
'mrp', 
'read')),
 
  508   'name'=>
"TripsAndExpenses",
 
  509   'title'=>
"ListExpenseReportsAssociatedProject",
 
  510   'class'=>
'Deplacement',
 
  511   'table'=>
'deplacement',
 
  512   'datefieldname'=>
'dated',
 
  515   'urlnew'=>DOL_URL_ROOT.
'/deplacement/card.php?action=create&projectid='.$id.
'&socid='.$socid.
'&backtopage='.urlencode($_SERVER[
'PHP_SELF'].
'?id='.$id),
 
  517   'buttonnew'=>
'AddTrip',
 
  518   'testnew'=>$user->hasRight(
'deplacement', 
'creer'),
 
  519   'test'=>!empty($conf->deplacement->enabled) && $user->hasRight(
'deplacement', 
'lire')),
 
  520 'expensereport'=>array(
 
  521   'name'=>
"ExpenseReports",
 
  522   'title'=>
"ListExpenseReportsAssociatedProject",
 
  523   'class'=>
'ExpenseReportLine',
 
  524   'table'=>
'expensereport_det',
 
  525   'datefieldname'=>
'date',
 
  528   'urlnew'=>DOL_URL_ROOT.
'/expensereport/card.php?action=create&projectid='.$id.
'&socid='.$socid.
'&backtopage='.urlencode($_SERVER[
'PHP_SELF'].
'?id='.$id),
 
  530   'buttonnew'=>
'AddTrip',
 
  531   'testnew'=>$user->hasRight(
'expensereport', 
'creer'),
 
  532   'test'=>!empty($conf->expensereport->enabled) && $user->hasRight(
'expensereport', 
'lire')),
 
  535   'title'=>
"ListDonationsAssociatedProject",
 
  539   'datefieldname'=>
'datedon',
 
  541   'urlnew'=>DOL_URL_ROOT.
'/don/card.php?action=create&projectid='.$id.
'&socid='.$socid.
'&backtopage='.urlencode($_SERVER[
'PHP_SELF'].
'?id='.$id),
 
  543   'buttonnew'=>
'AddDonation',
 
  544   'testnew'=>$user->hasRight(
'don', 
'creer'),
 
  545   'test'=>!empty($conf->don->enabled) && $user->hasRight(
'don', 
'lire')),
 
  548   'title'=>
"ListLoanAssociatedProject",
 
  552   'datefieldname'=>
'datestart',
 
  554   'urlnew'=>DOL_URL_ROOT.
'/loan/card.php?action=create&projectid='.$id.
'&socid='.$socid.
'&backtopage='.urlencode($_SERVER[
'PHP_SELF'].
'?id='.$id),
 
  556   'buttonnew'=>
'AddLoan',
 
  557   'testnew'=>$user->hasRight(
'loan', 
'write'),
 
  558   'test'=>!empty($conf->loan->enabled) && $user->hasRight(
'loan', 
'read')),
 
  559 'chargesociales'=>array(
 
  560   'name'=>
"SocialContribution",
 
  561   'title'=>
"ListSocialContributionAssociatedProject",
 
  562   'class'=>
'ChargeSociales',
 
  564   'table'=>
'chargesociales',
 
  565   'datefieldname'=>
'date_ech',
 
  567   'urlnew'=>DOL_URL_ROOT.
'/compta/sociales/card.php?action=create&projectid='.$id.
'&backtopage='.urlencode($_SERVER[
'PHP_SELF'].
'?id='.$id),
 
  569   'buttonnew'=>
'AddSocialContribution',
 
  570   'testnew'=>$user->hasRight(
'tax', 
'charges', 
'lire'),
 
  571   'test'=>!empty($conf->tax->enabled) && $user->hasRight(
'tax', 
'charges', 
'lire')),
 
  572 'project_task'=>array(
 
  573   'name'=>
"TaskTimeSpent",
 
  574   'title'=>
"ListTaskTimeUserProject",
 
  577   'table'=>
'projet_task',
 
  578   'datefieldname'=>
'task_date',
 
  580   'urlnew'=>DOL_URL_ROOT.
'/projet/tasks/time.php?withproject=1&action=createtime&projectid='.$id.
'&backtopage='.urlencode($_SERVER[
'PHP_SELF'].
'?id='.$id),
 
  581   'buttonnew'=>
'AddTimeSpent',
 
  582   'testnew'=>$user->hasRight(
'project', 
'creer'),
 
  583   'test'=>!empty($conf->project->enabled) && $user->hasRight(
'projet', 
'lire') && !empty($conf->global->PROJECT_HIDE_TASKS)),
 
  584 'stock_mouvement'=>array(
 
  585   'name'=>
"MouvementStockAssociated",
 
  586   'title'=>
"ListMouvementStockProject",
 
  587   'class'=>
'MouvementStock',
 
  589   'table'=>
'stock_mouvement',
 
  590   'datefieldname'=>
'datem',
 
  592   'test'=>!empty($conf->stock->enabled) && $user->hasRight(
'stock', 
'mouvement', 
'lire') && !empty($conf->global->STOCK_MOVEMENT_INTO_PROJECT_OVERVIEW)),
 
  595   'title'=>
"ListSalariesAssociatedProject",
 
  598   'datefieldname'=>
'datesp',
 
  601   'urlnew'=>DOL_URL_ROOT.
'/salaries/card.php?action=create&projectid='.$id.
'&backtopage='.urlencode($_SERVER[
'PHP_SELF'].
'?id='.$id),
 
  603   'buttonnew'=>
'AddSalary',
 
  604   'testnew'=>$user->hasRight(
'salaries', 
'write'),
 
  605   'test'=>!empty($conf->salaries->enabled) && $user->hasRight(
'salaries', 
'read')),
 
  606 'variouspayment'=>array(
 
  607   'name'=>
"VariousPayments",
 
  608   'title'=>
"ListVariousPaymentsAssociatedProject",
 
  609   'class'=>
'PaymentVarious',
 
  610   'table'=>
'payment_various',
 
  611   'datefieldname'=>
'datev',
 
  614   'urlnew'=>DOL_URL_ROOT.
'/compta/bank/various_payment/card.php?action=create&projectid='.$id.
'&backtopage='.urlencode($_SERVER[
'PHP_SELF'].
'?id='.$id),
 
  616   'buttonnew'=>
'AddVariousPayment',
 
  617   'testnew'=>$user->hasRight(
'banque', 
'modifier'),
 
  618   'test'=>!empty($conf->banque->enabled) && $user->hasRight(
'banque', 
'lire') && !empty($conf->global->BANK_USE_OLD_VARIOUS_PAYMENT)),
 
  636 if (!empty($conf->global->PROJECT_ELEMENTS_FOR_PLUS_MARGIN)) {
 
  637   foreach ($listofreferent as $key => $element) {
 
  638     if ($listofreferent[$key][
'margin'] == 
'add') {
 
  639       unset($listofreferent[$key][
'margin']);
 
  642   $newelementforplusmargin = explode(
',', $conf->global->PROJECT_ELEMENTS_FOR_PLUS_MARGIN);
 
  643   foreach ($newelementforplusmargin as $value) {
 
  644     $listofreferent[trim($value)][
'margin'] = 
'add';
 
  647 if (!empty($conf->global->PROJECT_ELEMENTS_FOR_MINUS_MARGIN)) {
 
  648   foreach ($listofreferent as $key => $element) {
 
  649     if ($listofreferent[$key][
'margin'] == 
'minus') {
 
  650       unset($listofreferent[$key][
'margin']);
 
  653   $newelementforminusmargin = explode(
',', $conf->global->PROJECT_ELEMENTS_FOR_MINUS_MARGIN);
 
  654   foreach ($newelementforminusmargin as $value) {
 
  655     $listofreferent[trim($value)][
'margin'] = 
'minus';
 
  661 $parameters = array(
'listofreferent'=>$listofreferent);
 
  662 $resHook = $hookmanager->executeHooks(
'completeListOfReferent', $parameters, $object, $action);
 
  664 if (!empty($hookmanager->resArray)) {
 
  665   $listofreferent = array_merge($listofreferent, $hookmanager->resArray);
 
  668 if ($action == 
"addelement") {
 
  669   $tablename = 
GETPOST(
"tablename");
 
  670   $elementselectid = 
GETPOST(
"elementselect");
 
  671   $result = $object->update_element($tablename, $elementselectid);
 
  675 } elseif ($action == 
"unlink") {
 
  676   $tablename = 
GETPOST(
"tablename", 
"aZ09");
 
  677   $projectField = 
GETPOSTISSET(
'projectfield') ? 
GETPOST(
'projectfield', 
'aZ09') : 
'fk_projet';
 
  678   $elementselectid = 
GETPOST(
"elementselect", 
"int");
 
  680   $result = $object->remove_element($tablename, $elementselectid, $projectField);
 
  686 $elementuser = 
new User($db);
 
  692 if (!$showdatefilter) {
 
  693   print 
'<div class="center centpercent">';
 
  694   print 
'<form action="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'" method="POST">';
 
  695   print 
'<input type="hidden" name="token" value="'.newToken().
'">';
 
  696   print 
'<input type="hidden" name="tablename" value="'.$tablename.
'">';
 
  697   print 
'<input type="hidden" name="action" value="view">';
 
  698   print 
'<div class="inline-block">';
 
  699   print 
$form->selectDate($dates, 
'dates', 0, 0, 1, 
'', 1, 0, 0, 
'', 
'', 
'', 
'', 1, 
'', $langs->trans(
"From"));
 
  701   print 
'<div class="inline-block">';
 
  702   print 
$form->selectDate($datee, 
'datee', 0, 0, 1, 
'', 1, 0, 0, 
'', 
'', 
'', 
'', 1, 
'', $langs->trans(
"to"));
 
  704   print 
'<div class="inline-block">';
 
  705   print 
'<input type="submit" name="refresh" value="'.$langs->trans(
"Refresh").
'" class="button small">';
 
  717 $langs->loadLangs(array(
"suppliers", 
"bills", 
"orders", 
"proposals", 
"margins"));
 
  720   $langs->load(
'stocks');
 
  725 print 
'<table class="noborder centpercent">';
 
  726 print 
'<tr class="liste_titre">';
 
  727 print 
'<td class="left" width="200">';
 
  728 $tooltiponprofit = $langs->trans(
"ProfitIsCalculatedWith").
"<br>\n";
 
  729 $tooltiponprofitplus = $tooltiponprofitminus = 
'';
 
  730 foreach ($listofreferent as $key => $value) {
 
  731   $name = $langs->trans($value[
'name']);
 
  732   $qualified = $value[
'test'];
 
  733   $margin = $value[
'margin'];
 
  734   if ($qualified && isset($margin)) {   
 
  735     if ($margin == 
'add') {
 
  736       $tooltiponprofitplus .= 
' > '.$name.
" (+)<br>\n";
 
  738     if ($margin == 
'minus') {
 
  739       $tooltiponprofitminus .= 
' > '.$name.
" (-)<br>\n";
 
  743 $tooltiponprofit .= $tooltiponprofitplus;
 
  744 $tooltiponprofit .= $tooltiponprofitminus;
 
  745 print 
$form->textwithpicto($langs->trans(
"Element"), $tooltiponprofit);
 
  747 print 
'<td class="right" width="100">'.$langs->trans(
"Number").
'</td>';
 
  748 print 
'<td class="right" width="100">'.$langs->trans(
"AmountHT").
'</td>';
 
  749 print 
'<td class="right" width="100">'.$langs->trans(
"AmountTTC").
'</td>';
 
  752 $total_revenue_ht = 0;
 
  756 foreach ($listofreferent as $key => $value) {
 
  758     'total_revenue_ht' =>& $total_revenue_ht,
 
  759     'balance_ht' =>& $balance_ht,
 
  760     'balance_ttc' =>& $balance_ttc,
 
  766   $reshook = $hookmanager->executeHooks(
'printOverviewProfit', $parameters, $object, $action); 
 
  769   } elseif ($reshook > 0) {
 
  770     print $hookmanager->resPrint;
 
  774   $name = $langs->trans($value[
'name']);
 
  775   $title = $value[
'title'];
 
  776   $classname = $value[
'class'];
 
  777   $tablename = $value[
'table'];
 
  778   $datefieldname = $value[
'datefieldname'];
 
  779   $qualified = $value[
'test'];
 
  780   $margin = $value[
'margin'];
 
  781   $project_field = $value[
'project_field'];
 
  782   if ($qualified && isset($margin)) {   
 
  783     $element = 
new $classname($db);
 
  785     $elementarray = $object->get_element_list($key, $tablename, $datefieldname, $dates, $datee, !empty($project_field) ? $project_field : 
'fk_projet');
 
  787     if (is_array($elementarray) && count($elementarray) > 0) {
 
  791       $num = count($elementarray);
 
  792       for ($i = 0; $i < $num; $i++) {
 
  793         $tmp = explode(
'_', $elementarray[$i]);
 
  794         $idofelement = $tmp[0];
 
  795         $idofelementuser = $tmp[1];
 
  797         $element->fetch($idofelement);
 
  798         if ($idofelementuser) {
 
  799           $elementuser->fetch($idofelementuser);
 
  803         $qualifiedfortotal = 
true;
 
  804         if ($key == 
'invoice') {
 
  805           if (!empty($element->close_code) && $element->close_code == 
'replaced') {
 
  806             $qualifiedfortotal = 
false; 
 
  808           if (!empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS) && $element->type == 
Facture::TYPE_DEPOSIT) {
 
  809             $qualifiedfortotal = 
false; 
 
  812         if ($key == 
'propal') {
 
  814             $qualifiedfortotal = 
false; 
 
  818         if ($tablename != 
'expensereport_det' && method_exists($element, 
'fetch_thirdparty')) {
 
  819           $element->fetch_thirdparty();
 
  823         if ($tablename == 
'don' || $tablename == 
'chargesociales' || $tablename == 
'payment_various' || $tablename == 
'salary') {
 
  824           $total_ht_by_line = $element->amount;
 
  825         } elseif ($tablename == 
'fichinter') {
 
  826           $total_ht_by_line = $element->getAmount();
 
  827         } elseif ($tablename == 
'stock_mouvement') {
 
  828           $total_ht_by_line = $element->price * abs($element->qty);
 
  829         } elseif ($tablename == 
'projet_task') {
 
  830           if ($idofelementuser) {
 
  831             $tmp = $element->getSumOfAmount($elementuser, $dates, $datee);
 
  832             $total_ht_by_line = 
price2num($tmp[
'amount'], 
'MT');
 
  834             $tmp = $element->getSumOfAmount(
'', $dates, $datee);
 
  835             $total_ht_by_line = 
price2num($tmp[
'amount'], 
'MT');
 
  837         } elseif ($key == 
'loan') {
 
  838           if ((empty($dates) && empty($datee)) || (intval($dates) <= $element->datestart && intval($datee) >= $element->dateend)) {
 
  840             $total_ht_by_line = -$element->capital;
 
  843             $total_ht_by_line = 0;
 
  845             $loanScheduleStatic->fetchAll($element->id);
 
  846             if (!empty($loanScheduleStatic->lines)) {
 
  847               foreach ($loanScheduleStatic->lines as $loanSchedule) {
 
  851                 if (($loanSchedule->datep >= $dates && $loanSchedule->datep <= $datee) 
 
  852                   || !empty($dates) && empty($datee) && $loanSchedule->datep >= $dates && $loanSchedule->datep <= 
dol_now()
 
  853                   || empty($dates) && !empty($datee) && $loanSchedule->datep <= $datee
 
  855                   $total_ht_by_line -= $loanSchedule->amount_capital;
 
  861           $total_ht_by_line = $element->total_ht;
 
  865         if ($tablename == 
'don' || $tablename == 
'chargesociales' || $tablename == 
'payment_various' || $tablename == 
'salary') {
 
  866           $total_ttc_by_line = $element->amount;
 
  867         } elseif ($tablename == 
'fichinter') {
 
  868           $total_ttc_by_line = $element->getAmount();
 
  869         } elseif ($tablename == 
'stock_mouvement') {
 
  870           $total_ttc_by_line = $element->price * abs($element->qty);
 
  871         } elseif ($tablename == 
'projet_task') {
 
  873           $total_ttc_by_line = 
price2num($total_ht_by_line * (1 + ($defaultvat / 100)), 
'MT');
 
  874         } elseif ($key == 
'loan') {
 
  875             $total_ttc_by_line = $total_ht_by_line; 
 
  877           $total_ttc_by_line = $element->total_ttc;
 
  881         if ($tablename == 
'payment_various') {
 
  882           if ($element->sens == 1) {
 
  883             $total_ht_by_line = -$total_ht_by_line;
 
  884             $total_ttc_by_line = -$total_ttc_by_line;
 
  889         if ($qualifiedfortotal) {
 
  890           $total_ht = $total_ht + $total_ht_by_line;
 
  891           $total_ttc = $total_ttc + $total_ttc_by_line;
 
  896       $qualifiedforfinalprofit = 
true;
 
  897       if ($key == 
'intervention' && empty($conf->global->PROJECT_INCLUDE_INTERVENTION_AMOUNT_IN_PROFIT)) {
 
  898         $qualifiedforfinalprofit = 
false;
 
  903       if ($qualifiedforfinalprofit) {
 
  904         if ($margin == 
'add') {
 
  905           $total_revenue_ht += $total_ht;
 
  908         if ($margin != 
"add") { 
 
  909           $total_ht = -$total_ht;
 
  910           $total_ttc = -$total_ttc;
 
  913         $balance_ht += $total_ht;
 
  914         $balance_ttc += $total_ttc;
 
  917       print 
'<tr class="oddeven">';
 
  919       print 
'<td class="left">'.$name.
'</td>';
 
  921       print 
'<td class="right">'.$i.
'</td>';
 
  923       print 
'<td class="right">';
 
  924       if ($key == 
'intervention' && !$qualifiedforfinalprofit) {
 
  925         print 
'<span class="opacitymedium">'.$form->textwithpicto($langs->trans(
"NA"), $langs->trans(
"AmountOfInteventionNotIncludedByDefault")).
'</span>';
 
  927         print 
price($total_ht);
 
  928         if ($key == 
'propal') {
 
  929           print 
'<span class="opacitymedium">'.$form->textwithpicto(
'', $langs->trans(
"SignedOnly")).
'</span>';
 
  934       print 
'<td class="right">';
 
  935       if ($key == 
'intervention' && !$qualifiedforfinalprofit) {
 
  936         print 
'<span class="opacitymedium">'.$form->textwithpicto($langs->trans(
"NA"), $langs->trans(
"AmountOfInteventionNotIncludedByDefault")).
'</span>';
 
  938         print 
price($total_ttc);
 
  939         if ($key == 
'propal') {
 
  940           print 
'<span class="opacitymedium">'.$form->textwithpicto(
'', $langs->trans(
"SignedOnly")).
'</span>';
 
  949 print 
'<tr class="liste_total">';
 
  950 print 
'<td class="right" colspan="2">'.$langs->trans(
"Profit").
'</td>';
 
  951 print 
'<td class="right">'.price(
price2num($balance_ht, 
'MT')).
'</td>';
 
  952 print 
'<td class="right">'.price(
price2num($balance_ttc, 
'MT')).
'</td>';
 
  956 if ($total_revenue_ht) {
 
  957   print 
'<tr class="liste_total">';
 
  958   print 
'<td class="right" colspan="2">'.$langs->trans(
"Margin").
'</td>';
 
  959   print 
'<td class="right">'.round(100 * $balance_ht / $total_revenue_ht, 1).
'%</td>';
 
  960   print 
'<td class="right"></td>';
 
  973 foreach ($listofreferent as $key => $value) {
 
  980   $reshook = $hookmanager->executeHooks(
'printOverviewDetail', $parameters, $object, $action); 
 
  983   } elseif ($reshook > 0) {
 
  984     print $hookmanager->resPrint;
 
  988   $title = $value[
'title'];
 
  989   $classname = $value[
'class'];
 
  990   $tablename = $value[
'table'];
 
  991   $datefieldname = $value[
'datefieldname'];
 
  992   $qualified = $value[
'test'];
 
  993   $langtoload = $value[
'lang'];
 
  994   $urlnew = $value[
'urlnew'];
 
  995   $buttonnew = $value[
'buttonnew'];
 
  996   $testnew = $value[
'testnew'];
 
  997   $project_field = $value[
'project_field'];
 
  999   $exclude_select_element = array(
'payment_various');
 
 1000   if (!empty($value[
'exclude_select_element'])) {
 
 1001     $exclude_select_element[] = $value[
'exclude_select_element'];
 
 1009       $langs->load($langtoload);
 
 1012     $element = 
new $classname($db);
 
 1016     $idtofilterthirdparty = 0;
 
 1017     $array_of_element_linkable_with_different_thirdparty = array(
'facture_fourn', 
'commande_fournisseur');
 
 1018     if (!in_array($tablename, $array_of_element_linkable_with_different_thirdparty)) {
 
 1019       $idtofilterthirdparty = $object->thirdparty->id;
 
 1020       if (!empty($conf->global->PROJECT_OTHER_THIRDPARTY_ID_TO_ADD_ELEMENTS)) {
 
 1021         $idtofilterthirdparty .= 
','.$conf->global->PROJECT_OTHER_THIRDPARTY_ID_TO_ADD_ELEMENTS;
 
 1025     $elementarray = $object->get_element_list($key, $tablename, $datefieldname, $dates, $datee, !empty($project_field) ? $project_field : 
'fk_projet');
 
 1028     if (empty($conf->global->PROJECT_LINK_ON_OVERWIEW_DISABLED) && $idtofilterthirdparty && !in_array($tablename, $exclude_select_element)) {
 
 1029       $selectList = $formproject->select_element($tablename, $idtofilterthirdparty, 
'minwidth300 minwidth75imp', -2, empty($project_field) ? 
'fk_projet' : $project_field, $langs->trans(
"SelectElement"));
 
 1030       if ($selectList < 0) {
 
 1032       } elseif ($selectList) {
 
 1034         $addform .= 
'<div class="inline-block valignmiddle">';
 
 1035         $addform .= 
'<form action="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'" method="post">';
 
 1036         $addform .= 
'<input type="hidden" name="token" value="'.newToken().
'">';
 
 1037         $addform .= 
'<input type="hidden" name="tablename" value="'.$tablename.
'">';
 
 1038         $addform .= 
'<input type="hidden" name="action" value="addelement">';
 
 1039         $addform .= 
'<input type="hidden" name="datesrfc" value="'.dol_print_date($dates, 
'dayhourrfc').
'">';
 
 1040         $addform .= 
'<input type="hidden" name="dateerfc" value="'.dol_print_date($datee, 
'dayhourrfc').
'">';
 
 1041         $addform .= 
'<table><tr>';
 
 1043         $addform .= 
'<td>'.$selectList.
'</td>';
 
 1044         $addform .= 
'<td><input type="submit" class="button button-linkto smallpaddingimp" value="'.dol_escape_htmltag($langs->trans(
"LinkToElementShort")).
'"></td>';
 
 1045         $addform .= 
'</tr></table>';
 
 1046         $addform .= 
'</form>';
 
 1047         $addform .= 
'</div>';
 
 1050     if (empty($conf->global->PROJECT_CREATE_ON_OVERVIEW_DISABLED) && $urlnew) {
 
 1051       $addform .= 
'<div class="inline-block valignmiddle">';
 
 1053         $addform .= 
'<a class="buttonxxx marginleftonly" href="'.$urlnew.
'" title="'.
dol_escape_htmltag($langs->trans($buttonnew)).
'"><span class="fa fa-plus-circle valignmiddle paddingleft"></span></a>';
 
 1054       } elseif (empty($conf->global->MAIN_BUTTON_HIDE_UNAUTHORIZED)) {
 
 1055         $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>';
 
 1057       $addform .= 
'<div>';
 
 1060     if (is_array($elementarray) && count($elementarray) > 0 && $key == 
"order_supplier") {
 
 1061       $addform = 
'<div class="inline-block valignmiddle"><a id="btnShow" class="buttonxxx marginleftonly" href="#" onClick="return false;"> 
 1062              <span id="textBtnShow" class="valignmiddle text-plus-circle hideonsmartphone">'.$langs->trans(
"CanceledShown").
'</span><span id="minus-circle" class="fa fa-eye valignmiddle paddingleft"></span> 
 1065              $("#btnShow").on("click", function () { 
 1066               console.log("We click to show or hide the canceled lines"); 
 1067               var attr = $(this).attr("data-canceledarehidden"); 
 1068               if (typeof attr !== "undefined" && attr !== false) { 
 1069                 console.log("Show canceled"); 
 1070                 $(".tr_canceled").show(); 
 1071                 $("#textBtnShow").text("'.
dol_escape_js($langs->transnoentitiesnoconv(
"CanceledShown")).
'"); 
 1072                 $("#btnShow").removeAttr("data-canceledarehidden"); 
 1073                 $("#minus-circle").removeClass("fa-eye-slash").addClass("fa-eye"); 
 1075                 console.log("Hide canceled"); 
 1076                 $(".tr_canceled").hide(); 
 1077                 $("#textBtnShow").text("'.
dol_escape_js($langs->transnoentitiesnoconv(
"CanceledHidden")).
'"); 
 1078                 $("#btnShow").attr("data-canceledarehidden", 1); 
 1079                 $("#minus-circle").removeClass("fa-eye").addClass("fa-eye-slash"); 
 1082              </script></div> '.$addform;
 
 1087     print 
"\n".
'<!-- Table for tablename = '.$tablename.
' -->'.
"\n";
 
 1088     print 
'<div class="div-table-responsive">';
 
 1089     print 
'<table class="noborder centpercent">';
 
 1091     print 
'<tr class="liste_titre">';
 
 1093     print 
'<td style="width: 24px"></td>';
 
 1095     print 
'<td'.(($tablename != 
'actioncomm' && $tablename != 
'projet_task') ? 
' style="width: 200px"' : 
'').
'>'.$langs->trans(
"Ref").
'</td>';
 
 1097     print 
'<td'.(($tablename != 
'actioncomm' && $tablename != 
'projet_task') ? 
' style="width: 200px"' : 
'').
' class="center">';
 
 1098     if (in_array($tablename, array(
'projet_task'))) {
 
 1099       print $langs->trans(
"TimeSpent");
 
 1101     if (!in_array($tablename, array(
'projet_task'))) {
 
 1102       print $langs->trans(
"Date");
 
 1107     if (in_array($tablename, array(
'projet_task')) && $key == 
'project_task') {
 
 1109     } elseif (in_array($tablename, array(
'payment_various'))) {
 
 1111     } elseif (in_array($tablename, array(
'expensereport_det', 
'don', 
'projet_task', 
'stock_mouvement', 
'salary'))) {
 
 1112       print $langs->trans(
"User");
 
 1114       print $langs->trans(
"ThirdParty");
 
 1118     if ($tablename == 
'fichinter') {
 
 1120       print $langs->trans(
"TotalDuration");
 
 1121       $total_duration = 0;
 
 1127     if ($key == 
'loan') {
 
 1128       print 
'<td class="right" width="120">'.$langs->trans(
"LoanCapital").
'</td>';
 
 1129     } elseif (empty($value[
'disableamount'])) {
 
 1130       print 
'<td class="right" width="120">'.$langs->trans(
"AmountHT").
'</td>';
 
 1132       print 
'<td width="120"></td>';
 
 1136     if ($key == 
'loan') {
 
 1137       print 
'<td class="right" width="120">'.$langs->trans(
"RemainderToPay").
'</td>';
 
 1138     } elseif (empty($value[
'disableamount'])) {
 
 1139       print 
'<td class="right" width="120">'.$langs->trans(
"AmountTTC").
'</td>';
 
 1141       print 
'<td width="120"></td>';
 
 1144     if (in_array($tablename, array(
'projet_task'))) {
 
 1145       print 
'<td class="right" width="200">'.$langs->trans(
"ProgressDeclared").
'</td>';
 
 1147       print 
'<td class="right" width="200">'.$langs->trans(
"Status").
'</td>';
 
 1151     if (is_array($elementarray) && count($elementarray) > 0) {
 
 1155       $total_ht_by_third = 0;
 
 1156       $total_ttc_by_third = 0;
 
 1158       $saved_third_id = 0;
 
 1166       $num = count($elementarray);
 
 1167       for ($i = 0; $i < $num; $i++) {
 
 1168         $tmp = explode(
'_', $elementarray[$i]);
 
 1169         $idofelement = $tmp[0];
 
 1170         $idofelementuser = $tmp[1];
 
 1172         $element->fetch($idofelement);
 
 1173         if ($idofelementuser) {
 
 1174           $elementuser->fetch($idofelementuser);
 
 1178         if ($tablename != 
'expensereport_det') {
 
 1179           if (method_exists($element, 
'fetch_thirdparty')) {
 
 1180             $element->fetch_thirdparty();
 
 1184           $expensereport->fetch($element->fk_expensereport);
 
 1189         if ($breakline && $saved_third_id != $element->thirdparty->id) {
 
 1192           $saved_third_id = $element->thirdparty->id;
 
 1195           $total_ht_by_third = 0;
 
 1196           $total_ttc_by_third = 0;
 
 1198         $saved_third_id = $element->thirdparty->id;
 
 1200         $qualifiedfortotal = 
true;
 
 1201         if ($key == 
'invoice') {
 
 1202           if (!empty($element->close_code) && $element->close_code == 
'replaced') {
 
 1203             $qualifiedfortotal = 
false; 
 
 1205         } elseif ($key == 
'order_supplier' && $element->status == 7) {
 
 1206           $qualifiedfortotal = 
false; 
 
 1209         if ($key == 
"order_supplier" && $element->status == 7) {
 
 1210           print 
'<tr class="oddeven tr_canceled" style=display:none>';
 
 1212           print 
'<tr class="oddeven" >';
 
 1217         print 
'<td style="width: 24px">';
 
 1218         if ($tablename != 
'projet_task' && $tablename != 
'stock_mouvement') {
 
 1219           if (empty($conf->global->PROJECT_DISABLE_UNLINK_FROM_OVERVIEW) || $user->admin) {   
 
 1220             print 
'<a href="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&action=unlink&tablename='.$tablename.
'&elementselect='.$element->id.($project_field ? 
'&projectfield='.$project_field : 
'').
'" class="reposition">';
 
 1221             print 
img_picto($langs->trans(
'Unlink'), 
'unlink');
 
 1228         print 
'<td class="left nowraponall">';
 
 1229         if ($tablename == 
'expensereport_det') {
 
 1230           print $expensereport->getNomUrl(1);
 
 1233           if ($element instanceof 
Task) {
 
 1234             print $element->getNomUrl(1, 
'withproject', 
'time');
 
 1235             print 
' - '.dol_trunc($element->label, 48);
 
 1236           } elseif ($key == 
'loan') {
 
 1237             print $element->getNomUrl(1);
 
 1238             print 
' - '.dol_trunc($element->label, 48);
 
 1240             print $element->getNomUrl(1);
 
 1243           $element_doc = $element->element;
 
 1245           $filedir = $conf->{$element_doc}->multidir_output[$element->entity].
'/'.
dol_sanitizeFileName($element->ref);
 
 1247           if ($element_doc === 
'order_supplier') {
 
 1248             $element_doc = 
'commande_fournisseur';
 
 1249             $filedir = $conf->fournisseur->commande->multidir_output[$element->entity].
'/'.
dol_sanitizeFileName($element->ref);
 
 1250           } elseif ($element_doc === 
'invoice_supplier') {
 
 1251             $element_doc = 
'facture_fournisseur';
 
 1252             $filename = 
get_exdir($element->id, 2, 0, 0, $element, 
'product').dol_sanitizeFileName($element->ref);
 
 1253             $filedir = $conf->fournisseur->facture->multidir_output[$element->entity].
'/'.
get_exdir($element->id, 2, 0, 0, $element, 
'invoice_supplier').dol_sanitizeFileName($element->ref);
 
 1256           print 
'<div class="inline-block valignmiddle">'.$formfile->getDocumentsLink($element_doc, $filename, $filedir).
'</div>';
 
 1259           if (!empty($element->ref_supplier)) {
 
 1260             print 
' - '.$element->ref_supplier;
 
 1263           if (!empty($element->ref_customer)) {
 
 1264             print 
' - '.$element->ref_customer;
 
 1270         $date = 
''; $total_time_by_line = 
null;
 
 1271         if ($tablename == 
'expensereport_det') {
 
 1272           $date = $element->date; 
 
 1273         } elseif ($tablename == 
'stock_mouvement') {
 
 1274           $date = $element->datem;
 
 1275         } elseif ($tablename == 
'salary') {
 
 1276           $date = $element->datesp;
 
 1277         } elseif ($tablename == 
'payment_various') {
 
 1278           $date = $element->datev;
 
 1279         } elseif ($tablename == 
'chargesociales') {
 
 1280           $date = $element->date_ech;
 
 1281         } elseif (!empty($element->status) || !empty($element->statut) || !empty($element->fk_status)) {
 
 1282           if ($tablename == 
'don') {
 
 1283             $date = $element->datedon;
 
 1285           if ($tablename == 
'commande_fournisseur' || $tablename == 
'supplier_order') {
 
 1286             $date = ($element->date_commande ? $element->date_commande : $element->date_valid);
 
 1287           } elseif ($tablename == 
'supplier_proposal') {
 
 1288             $date = $element->date_validation; 
 
 1289           } elseif ($tablename == 
'fichinter') {
 
 1290             $date = $element->datev; 
 
 1291           } elseif ($tablename == 
'projet_task') {
 
 1294             $date = $element->date; 
 
 1296               $date = $element->date_contrat;
 
 1299               $date = $element->datev;
 
 1301             if (empty($date) && !empty($datefieldname)) {
 
 1302               $date = $element->$datefieldname;
 
 1305         } elseif ($key == 
'loan') {
 
 1306           $date = $element->datestart;
 
 1309         print 
'<td class="center">';
 
 1310         if ($tablename == 
'actioncomm') {
 
 1312           if ($element->datef && $element->datef > $element->datep) {
 
 1313             print 
" - ".dol_print_date($element->datef, 
'dayhour');
 
 1315         } elseif (in_array($tablename, array(
'projet_task'))) {
 
 1316           $tmpprojtime = $element->getSumOfAmount($elementuser, $dates, $datee); 
 
 1317           print 
'<a href="'.DOL_URL_ROOT.
'/projet/tasks/time.php?id='.$idofelement.
'&withproject=1">';
 
 1320           $total_time_by_line = $tmpprojtime[
'nbseconds'];
 
 1327         print 
'<td class="left">';
 
 1328         if (is_object($element->thirdparty)) {
 
 1329           print $element->thirdparty->getNomUrl(1, 
'', 48);
 
 1330         } elseif ($tablename == 
'expensereport_det') {
 
 1331           $tmpuser = 
new User($db);
 
 1332           $tmpuser->fetch($expensereport->fk_user_author);
 
 1333           print $tmpuser->getNomUrl(1, 
'', 48);
 
 1334         } elseif ($tablename == 
'salary') {
 
 1335           $tmpuser = 
new User($db);
 
 1336           $tmpuser->fetch($element->fk_user);
 
 1337           print $tmpuser->getNomUrl(1, 
'', 48);
 
 1338         } elseif ($tablename == 
'don' || $tablename == 
'stock_mouvement') {
 
 1339           if ($element->fk_user_author > 0) {
 
 1340             $tmpuser2 = 
new User($db);
 
 1341             $tmpuser2->fetch($element->fk_user_author);
 
 1342             print $tmpuser2->getNomUrl(1, 
'', 48);
 
 1344         } elseif ($tablename == 
'projet_task' && $key == 
'project_task_time') { 
 
 1345           print $elementuser->getNomUrl(1);
 
 1350         if ($tablename == 
'fichinter') {
 
 1352           print 
convertSecondToTime($element->duration, 
'all', $conf->global->MAIN_DURATION_OF_WORKDAY);
 
 1353           $total_duration += $element->duration;
 
 1359         if (empty($value[
'disableamount'])) {
 
 1360           $total_ht_by_line = 
null;
 
 1362           if ($tablename == 
'don' || $tablename == 
'chargesociales' || $tablename == 
'payment_various' || $tablename == 
'salary') {
 
 1363             $total_ht_by_line = $element->amount;
 
 1364           } elseif ($tablename == 
'fichinter') {
 
 1365             $total_ht_by_line = $element->getAmount();
 
 1366           } elseif ($tablename == 
'stock_mouvement') {
 
 1367             $total_ht_by_line = $element->price * abs($element->qty);
 
 1368           } elseif (in_array($tablename, array(
'projet_task'))) {
 
 1369             if (!empty($conf->salaries->enabled)) {
 
 1371               $total_ht_by_line = 
price2num($tmpprojtime[
'amount'], 
'MT');
 
 1372               if ($tmpprojtime[
'nblinesnull'] > 0) {
 
 1373                 $langs->load(
"errors");
 
 1374                 $warning = $langs->trans(
"WarningSomeLinesWithNullHourlyRate", $conf->currency);
 
 1377               $othermessage = 
$form->textwithpicto($langs->trans(
"NotAvailable"), $langs->trans(
"ModuleSalaryToDefineHourlyRateMustBeEnabled"));
 
 1379           } elseif ($key == 
'loan') {
 
 1380             $total_ht_by_line = $element->capital;
 
 1382             $total_ht_by_line = $element->total_ht;
 
 1386           if ($tablename == 
'payment_various') {
 
 1387             if ($element->sens == 0) {
 
 1388               $total_ht_by_line = -$total_ht_by_line;
 
 1392           print 
'<td class="right">';
 
 1393           if ($othermessage) {
 
 1394             print $othermessage;
 
 1396           if (isset($total_ht_by_line)) {
 
 1397             if (!$qualifiedfortotal) {
 
 1400             print 
'<span class="amount">'.price($total_ht_by_line).
'</span>';
 
 1401             if (!$qualifiedfortotal) {
 
 1406             print 
' '.img_warning($warning);
 
 1414         if (empty($value[
'disableamount'])) {
 
 1415           $total_ttc_by_line = 
null;
 
 1416           if ($tablename == 
'don' || $tablename == 
'chargesociales' || $tablename == 
'payment_various' || $tablename == 
'salary') {
 
 1417             $total_ttc_by_line = $element->amount;
 
 1418           } elseif ($tablename == 
'fichinter') {
 
 1419             $total_ttc_by_line = $element->getAmount();
 
 1420           } elseif ($tablename == 
'stock_mouvement') {
 
 1421             $total_ttc_by_line = $element->price * abs($element->qty);
 
 1422           } elseif ($tablename == 
'projet_task') {
 
 1423             if (!empty($conf->salaries->enabled)) {
 
 1426               $total_ttc_by_line = 
price2num($total_ht_by_line * (1 + ($defaultvat / 100)), 
'MT');
 
 1428               $othermessage = 
$form->textwithpicto($langs->trans(
"NotAvailable"), $langs->trans(
"ModuleSalaryToDefineHourlyRateMustBeEnabled"));
 
 1430           } elseif ($key == 
'loan') {
 
 1431             $total_ttc_by_line = $element->capital - $element->getSumPayment();
 
 1433             $total_ttc_by_line = $element->total_ttc;
 
 1437           if ($tablename == 
'payment_various') {
 
 1438             if ($element->sens == 0) {
 
 1439               $total_ttc_by_line = -$total_ttc_by_line;
 
 1443           print 
'<td class="right">';
 
 1444           if ($othermessage) {
 
 1445             print $othermessage;
 
 1447           if (isset($total_ttc_by_line)) {
 
 1448             if (!$qualifiedfortotal) {
 
 1451             print 
'<span class="amount">'.price($total_ttc_by_line).
'</span>';
 
 1452             if (!$qualifiedfortotal) {
 
 1457             print 
' '.img_warning($warning);
 
 1465         print 
'<td class="right">';
 
 1466         if ($tablename == 
'expensereport_det') {
 
 1467           print $expensereport->getLibStatut(5);
 
 1470           print $element->getLibStatut(5, $element->getSommePaiement());
 
 1471         } elseif ($element instanceof 
Task) {
 
 1472           if ($element->progress != 
'') {
 
 1473             print $element->progress.
' %';
 
 1475         } elseif ($tablename == 
'stock_mouvement') {
 
 1476           print $element->getLibStatut(3);
 
 1478           print $element->getLibStatut(5);
 
 1484         if ($qualifiedfortotal) {
 
 1485           $total_ht = $total_ht + $total_ht_by_line;
 
 1486           $total_ttc = $total_ttc + $total_ttc_by_line;
 
 1488           $total_ht_by_third += $total_ht_by_line;
 
 1489           $total_ttc_by_third += $total_ttc_by_line;
 
 1491           $total_time = $total_time + $total_time_by_line;
 
 1495           $breakline = 
'<tr class="liste_total liste_sub_total">';
 
 1496           $breakline .= 
'<td colspan="2">';
 
 1497           $breakline .= 
'</td>';
 
 1498           $breakline .= 
'<td>';
 
 1499           $breakline .= 
'</td>';
 
 1500           $breakline .= 
'<td class="right">';
 
 1501           $breakline .= $langs->trans(
'SubTotal').
' : ';
 
 1502           if (is_object($element->thirdparty)) {
 
 1503             $breakline .= $element->thirdparty->getNomUrl(0, 
'', 48);
 
 1505           $breakline .= 
'</td>';
 
 1506           $breakline .= 
'<td class="right">'.price($total_ht_by_third).
'</td>';
 
 1507           $breakline .= 
'<td class="right">'.price($total_ttc_by_third).
'</td>';
 
 1508           $breakline .= 
'<td></td>';
 
 1509           $breakline .= 
'</tr>';
 
 1521       if (in_array($tablename, array(
'projet_task'))) {
 
 1525       print 
'<tr class="liste_total"><td colspan="'.$colspan.
'">'.$langs->trans(
"Number").
': '.$i.
'</td>';
 
 1526       if (in_array($tablename, array(
'projet_task'))) {
 
 1527         print 
'<td class="center">';
 
 1536       if ($tablename == 
'fichinter') {
 
 1537         print 
'<td class="left">'.convertSecondToTime($total_duration, 
'all', $conf->global->MAIN_DURATION_OF_WORKDAY).
'</td>';
 
 1539       print 
'<td class="right">';
 
 1540       if (empty($value[
'disableamount'])) {
 
 1541         if ($key == 
'loan') {
 
 1542           print $langs->trans(
"Total").
' '.$langs->trans(
"LoanCapital").
' : '.
price($total_ttc);
 
 1543         } elseif ($tablename != 
'projet_task' || !empty($conf->salaries->enabled)) {
 
 1544           print 
''.$langs->trans(
"TotalHT").
' : '.
price($total_ht);
 
 1550       print 
'<td class="right">';
 
 1551       if (empty($value[
'disableamount'])) {
 
 1552         if ($key == 
'loan') {
 
 1553           print $langs->trans(
"Total").
' '.$langs->trans(
"RemainderToPay").
' : '.
price($total_ttc);
 
 1554         } elseif ($tablename != 
'projet_task' || !empty($conf->salaries->enabled)) {
 
 1555           print $langs->trans(
"TotalTTC").
' : '.
price($total_ttc);
 
 1559       print 
'<td> </td>';
 
 1562       if (!is_array($elementarray)) { 
 
 1563         print 
'<tr><td>'.$elementarray.
'</td></tr>';
 
 1566         if (in_array($tablename, array(
'projet_task'))) {
 
 1569         if ($tablename == 
'fichinter') {
 
 1572         print 
'<tr><td colspan="'.$colspan.
'"><span class="opacitymedium">'.$langs->trans(
"None").
'</td></tr>';
 
 1582 if ($conf->use_javascript_ajax) {
 
 1583   include_once DOL_DOCUMENT_ROOT.
'/core/lib/ajax.lib.php';
 
 1586   print $comboenhancement;
 
 1605   if (empty($conf->global->PROJECT_ADD_SUBTOTAL_LINES)) {
 
 1608   return in_array($tablename, array(
'facture_fourn', 
'commande_fournisseur'));
 
 1619   global $db, $classname;
 
 1621   $element = 
new $classname($db);
 
 1623   $clientname = array();
 
 1624   foreach ($elementarray as $key => $id) {  
 
 1625     if (empty($clientname[$id])) {
 
 1626       $element->fetch($id);
 
 1627       $element->fetch_thirdparty();
 
 1629       $clientname[$id] = $element->thirdparty->name;
 
 1636   $elementarray = array();
 
 1637   foreach ($clientname as $id => $name) {
 
 1638     $elementarray[] = $id;
 
 1641   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.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='')
Show tabs of a record.
img_warning($titlealt='default', $moreatt='', $morecss='pictowarning')
Show warning logo.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0)
Returns text escaped for inclusion in HTML alt or title tags, or into values of HTML input fields.
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.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='')
Set event messages 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.
setEventMessage($mesgs, $style='mesgs')
Set event message 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.
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.
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.