Complete use of dol_banner

This commit is contained in:
Laurent Destailleur 2016-12-09 15:59:31 +01:00
parent fb45c72cc3
commit 10c00d37b5
7 changed files with 526 additions and 323 deletions

View File

@ -72,8 +72,22 @@ function fichinter_prepare_head($object)
// Tab to link resources // Tab to link resources
if ($conf->resource->enabled) if ($conf->resource->enabled)
{ {
$head[$h][0] = DOL_URL_ROOT.'/resource/element_resource.php?element=fichinter&element_id='.$object->id; require_once DOL_DOCUMENT_ROOT.'/resource/class/dolresource.class.php';
$nbResource = 0;
$objectres=new Dolresource($db);
foreach ($objectres->available_resources as $modresources => $resources)
{
$resources=(array) $resources; // To be sure $resources is an array
foreach($resources as $resource_obj)
{
$linked_resources = $object->getElementResources('fichinter',$object->id,$resource_obj);
}
}
$head[$h][0] = DOL_URL_ROOT.'/resource/element_resource.php?element=fichinter&element_id='.$object->id;
$head[$h][1] = $langs->trans("Resources"); $head[$h][1] = $langs->trans("Resources");
if ($nbResource > 0) $head[$h][1].= ' <span class="badge">'.$nbResource.'</span>';
$head[$h][2] = 'resource'; $head[$h][2] = 'resource';
$h++; $h++;
} }

View File

@ -1194,10 +1194,10 @@ else if ($id > 0 || ! empty($ref))
$morehtmlref='<div class="refidno">'; $morehtmlref='<div class="refidno">';
// Ref customer // Ref customer
//$morehtmlref.=$form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, $user->rights->commande->creer, 'string', '', 0, 1); //$morehtmlref.=$form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, $user->rights->fichinter->creer, 'string', '', 0, 1);
//$morehtmlref.=$form->editfieldval("RefCustomer", 'ref_client', $object->ref_client, $object, $user->rights->commande->creer, 'string', '', null, null, '', 1); //$morehtmlref.=$form->editfieldval("RefCustomer", 'ref_client', $object->ref_client, $object, $user->rights->fichinter->creer, 'string', '', null, null, '', 1);
// Thirdparty // Thirdparty
$morehtmlref.=$langs->trans('ThirdParty') . ' : ' . $soc->getNomUrl(1); $morehtmlref.=$langs->trans('ThirdParty') . ' : ' . $object->thirdparty->getNomUrl(1);
// Project // Project
if (! empty($conf->projet->enabled)) if (! empty($conf->projet->enabled))
{ {

View File

@ -112,43 +112,74 @@ llxHeader('',$langs->trans("Intervention"));
if ($id > 0 || ! empty($ref)) if ($id > 0 || ! empty($ref))
{ {
$soc = new Societe($db); $object->fetch_thirdparty();
$soc->fetch($object->socid);
$head = fichinter_prepare_head($object); $head = fichinter_prepare_head($object);
dol_fiche_head($head, 'contact', $langs->trans("InterventionCard"), 0, 'intervention'); dol_fiche_head($head, 'contact', $langs->trans("InterventionCard"), 0, 'intervention');
/* // Intervention card
* Fiche intervention synthese pour rappel
*/
print '<table class="border" width="100%">';
$linkback = '<a href="'.DOL_URL_ROOT.'/fichinter/list.php'.(! empty($socid)?'?socid='.$socid:'').'">'.$langs->trans("BackToList").'</a>'; $linkback = '<a href="'.DOL_URL_ROOT.'/fichinter/list.php'.(! empty($socid)?'?socid='.$socid:'').'">'.$langs->trans("BackToList").'</a>';
// Ref
print '<tr><td class="titlefield">'.$langs->trans("Ref").'</td><td colspan="3">'; $morehtmlref='<div class="refidno">';
print $form->showrefnav($object, 'ref', $linkback, 1, 'ref', 'ref'); // Ref customer
print "</td></tr>"; //$morehtmlref.=$form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', 0, 1);
//$morehtmlref.=$form->editfieldval("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', null, null, '', 1);
// Customer // Thirdparty
if ( is_null($object->thirdparty) ) $morehtmlref.=$langs->trans('ThirdParty') . ' : ' . $object->thirdparty->getNomUrl(1);
$object->fetch_thirdparty(); // Project
if (! empty($conf->projet->enabled))
print "<tr><td>".$langs->trans("Company")."</td>"; {
print '<td colspan="3">'.$object->thirdparty->getNomUrl(1).'</td></tr>'; $langs->load("projects");
print "</table>"; $morehtmlref.='<br>'.$langs->trans('Project') . ' ';
if ($user->rights->commande->creer)
print '</div>'; {
if ($action != 'classify')
//$morehtmlref.='<a href="' . $_SERVER['PHP_SELF'] . '?action=classify&amp;id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a> : ';
$morehtmlref.=' : ';
if ($action == 'classify') {
//$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1);
$morehtmlref.='<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">';
$morehtmlref.='<input type="hidden" name="action" value="classin">';
$morehtmlref.='<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
$morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1);
$morehtmlref.='<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">';
$morehtmlref.='</form>';
} else {
$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1);
}
} else {
if (! empty($object->fk_project)) {
$proj = new Project($db);
$proj->fetch($object->fk_project);
$morehtmlref.='<a href="'.DOL_URL_ROOT.'/projet/card.php?id=' . $object->fk_project . '" title="' . $langs->trans('ShowProject') . '">';
$morehtmlref.=$proj->ref;
$morehtmlref.='</a>';
} else {
$morehtmlref.='';
}
}
}
$morehtmlref.='</div>';
dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref);
dol_fiche_end();
print '<br>'; print '<br>';
if (! empty($conf->global->FICHINTER_HIDE_ADD_CONTACT_USER)) $hideaddcontactforuser=1; if (! empty($conf->global->FICHINTER_HIDE_ADD_CONTACT_USER)) $hideaddcontactforuser=1;
if (! empty($conf->global->FICHINTER_HIDE_ADD_CONTACT_THIPARTY)) $hideaddcontactforthirdparty=1; if (! empty($conf->global->FICHINTER_HIDE_ADD_CONTACT_THIPARTY)) $hideaddcontactforthirdparty=1;
// Contacts lines // Contacts lines (modules that overwrite templates must declare this into descriptor)
include DOL_DOCUMENT_ROOT.'/core/tpl/contacts.tpl.php'; $dirtpls=array_merge($conf->modules_parts['tpl'],array('/core/tpl'));
foreach($dirtpls as $reldir)
{
$res=@include dol_buildpath($reldir.'/contacts.tpl.php');
if ($res) break;
}
} }

View File

@ -101,24 +101,66 @@ if ($object->id)
} }
// Intervention card
$linkback = '<a href="'.DOL_URL_ROOT.'/fichinter/list.php'.(! empty($socid)?'?socid='.$socid:'').'">'.$langs->trans("BackToList").'</a>';
$morehtmlref='<div class="refidno">';
// Ref customer
//$morehtmlref.=$form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', 0, 1);
//$morehtmlref.=$form->editfieldval("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', null, null, '', 1);
// Thirdparty
$morehtmlref.=$langs->trans('ThirdParty') . ' : ' . $object->thirdparty->getNomUrl(1);
// Project
if (! empty($conf->projet->enabled))
{
$langs->load("projects");
$morehtmlref.='<br>'.$langs->trans('Project') . ' ';
if ($user->rights->commande->creer)
{
if ($action != 'classify')
//$morehtmlref.='<a href="' . $_SERVER['PHP_SELF'] . '?action=classify&amp;id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a> : ';
$morehtmlref.=' : ';
if ($action == 'classify') {
//$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1);
$morehtmlref.='<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">';
$morehtmlref.='<input type="hidden" name="action" value="classin">';
$morehtmlref.='<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
$morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1);
$morehtmlref.='<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">';
$morehtmlref.='</form>';
} else {
$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1);
}
} else {
if (! empty($object->fk_project)) {
$proj = new Project($db);
$proj->fetch($object->fk_project);
$morehtmlref.='<a href="'.DOL_URL_ROOT.'/projet/card.php?id=' . $object->fk_project . '" title="' . $langs->trans('ShowProject') . '">';
$morehtmlref.=$proj->ref;
$morehtmlref.='</a>';
} else {
$morehtmlref.='';
}
}
}
$morehtmlref.='</div>';
dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref);
print '<div class="fichecenter">';
print '<div class="underbanner clearboth"></div>';
print '<table class="border" width="100%">'; print '<table class="border" width="100%">';
print '<tr><td class="titlefield">'.$langs->trans("NbOfAttachedFiles").'</td><td colspan="3">'.count($filearray).'</td></tr>';
$linkback = '<a href="'.DOL_URL_ROOT.'/fichinter/list.php'.(! empty($socid)?'?socid='.$socid:'').'">'.$langs->trans("BackToList").'</a>';
// Ref
print '<tr><td class="titlefield">'.$langs->trans("Ref").'</td><td>';
print $form->showrefnav($object, 'ref', $linkback, 1, 'ref', 'ref');
print '</td></tr>';
// Societe
print "<tr><td>".$langs->trans("Company")."</td><td>".$object->thirdparty->getNomUrl(1)."</td></tr>";
print '<tr><td>'.$langs->trans("NbOfAttachedFiles").'</td><td colspan="3">'.count($filearray).'</td></tr>';
print '<tr><td>'.$langs->trans("TotalSizeOfAttachedFiles").'</td><td colspan="3">'.$totalsize.' '.$langs->trans("bytes").'</td></tr>'; print '<tr><td>'.$langs->trans("TotalSizeOfAttachedFiles").'</td><td colspan="3">'.$totalsize.' '.$langs->trans("bytes").'</td></tr>';
print '</table>'; print '</table>';
print '</div>'; print '</div>';
dol_fiche_end();
$modulepart = 'ficheinter'; $modulepart = 'ficheinter';
$permission = $user->rights->ficheinter->creer; $permission = $user->rights->ficheinter->creer;
$permtoedit = $user->rights->ficheinter->creer; $permtoedit = $user->rights->ficheinter->creer;

View File

@ -1,6 +1,6 @@
<?php <?php
/* Copyright (C) 2005-2009 Regis Houssin <regis.houssin@capnetworks.com> /* Copyright (C) 2005-2009 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2009-2013 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2009-2016 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2011 Juanjo Menent <jmenent@2byte.es> * Copyright (C) 2011 Juanjo Menent <jmenent@2byte.es>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
@ -31,7 +31,9 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/fichinter.lib.php';
$langs->load('companies'); $langs->load('companies');
$langs->load("interventions"); $langs->load("interventions");
$socid=0;
$id = GETPOST('id','int'); $id = GETPOST('id','int');
$ref=GETPOST('ref','alpha');
// Security check // Security check
if ($user->societe_id) $socid=$user->societe_id; if ($user->societe_id) $socid=$user->societe_id;
@ -39,9 +41,10 @@ $result = restrictedArea($user, 'ficheinter', $id, 'fichinter');
$object = new Fichinter($db); $object = new Fichinter($db);
if ($id > 0) if (! $object->fetch($id, $ref) > 0)
{ {
$object->fetch($id); dol_print_error($db);
exit;
} }
@ -51,13 +54,63 @@ if ($id > 0)
llxHeader('',$langs->trans("Intervention")); llxHeader('',$langs->trans("Intervention"));
$societe = new Societe($db); $object->fetch_thirdparty();
$societe->fetch($object->socid); $object->info($object->id);
$head = fichinter_prepare_head($object); $head = fichinter_prepare_head($object);
dol_fiche_head($head, 'info', $langs->trans('InterventionCard'), 0, 'intervention'); dol_fiche_head($head, 'info', $langs->trans('InterventionCard'), 0, 'intervention');
$object->info($object->id); // Intervention card
$linkback = '<a href="'.DOL_URL_ROOT.'/fichinter/list.php'.(! empty($socid)?'?socid='.$socid:'').'">'.$langs->trans("BackToList").'</a>';
$morehtmlref='<div class="refidno">';
// Ref customer
//$morehtmlref.=$form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', 0, 1);
//$morehtmlref.=$form->editfieldval("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', null, null, '', 1);
// Thirdparty
$morehtmlref.=$langs->trans('ThirdParty') . ' : ' . $object->thirdparty->getNomUrl(1);
// Project
if (! empty($conf->projet->enabled))
{
$langs->load("projects");
$morehtmlref.='<br>'.$langs->trans('Project') . ' ';
if ($user->rights->commande->creer)
{
if ($action != 'classify')
//$morehtmlref.='<a href="' . $_SERVER['PHP_SELF'] . '?action=classify&amp;id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a> : ';
$morehtmlref.=' : ';
if ($action == 'classify') {
//$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1);
$morehtmlref.='<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">';
$morehtmlref.='<input type="hidden" name="action" value="classin">';
$morehtmlref.='<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
$morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1);
$morehtmlref.='<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">';
$morehtmlref.='</form>';
} else {
$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1);
}
} else {
if (! empty($object->fk_project)) {
$proj = new Project($db);
$proj->fetch($object->fk_project);
$morehtmlref.='<a href="'.DOL_URL_ROOT.'/projet/card.php?id=' . $object->fk_project . '" title="' . $langs->trans('ShowProject') . '">';
$morehtmlref.=$proj->ref;
$morehtmlref.='</a>';
} else {
$morehtmlref.='';
}
}
}
$morehtmlref.='</div>';
dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref);
print '<div class="fichecenter">';
print '<div class="underbanner clearboth"></div>';
print '<br>';
print '<table width="100%"><tr><td>'; print '<table width="100%"><tr><td>';
dol_print_object_info($object); dol_print_object_info($object);
@ -65,5 +118,7 @@ print '</td></tr></table>';
print '</div>'; print '</div>';
dol_fiche_end();
llxFooter(); llxFooter();
$db->close(); $db->close();

View File

@ -60,31 +60,67 @@ $form = new Form($db);
if ($id > 0 || ! empty($ref)) if ($id > 0 || ! empty($ref))
{ {
$societe = new Societe($db); $object->fetch_thirdparty();
if ($societe->fetch($object->socid))
$head = fichinter_prepare_head($object);
dol_fiche_head($head, 'note', $langs->trans('InterventionCard'), 0, 'intervention');
// Intervention card
$linkback = '<a href="'.DOL_URL_ROOT.'/fichinter/list.php'.(! empty($socid)?'?socid='.$socid:'').'">'.$langs->trans("BackToList").'</a>';
$morehtmlref='<div class="refidno">';
// Ref customer
//$morehtmlref.=$form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', 0, 1);
//$morehtmlref.=$form->editfieldval("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', null, null, '', 1);
// Thirdparty
$morehtmlref.=$langs->trans('ThirdParty') . ' : ' . $object->thirdparty->getNomUrl(1);
// Project
if (! empty($conf->projet->enabled))
{ {
$head = fichinter_prepare_head($object); $langs->load("projects");
dol_fiche_head($head, 'note', $langs->trans('InterventionCard'), 0, 'intervention'); $morehtmlref.='<br>'.$langs->trans('Project') . ' ';
if ($user->rights->commande->creer)
print '<table class="border" width="100%">'; {
if ($action != 'classify')
$linkback = '<a href="'.DOL_URL_ROOT.'/fichinter/list.php'.(! empty($socid)?'?socid='.$socid:'').'">'.$langs->trans("BackToList").'</a>'; //$morehtmlref.='<a href="' . $_SERVER['PHP_SELF'] . '?action=classify&amp;id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a> : ';
$morehtmlref.=' : ';
print '<tr><td class="titlefield">'.$langs->trans('Ref').'</td><td>'; if ($action == 'classify') {
print $form->showrefnav($object, 'ref', $linkback, 1, 'ref', 'ref'); //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1);
print '</td></tr>'; $morehtmlref.='<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">';
$morehtmlref.='<input type="hidden" name="action" value="classin">';
// Company $morehtmlref.='<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<tr><td>'.$langs->trans('Company').'</td><td>'.$societe->getNomUrl(1).'</td></tr>'; $morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1);
$morehtmlref.='<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">';
print "</table>"; $morehtmlref.='</form>';
} else {
print '<br>'; $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1);
}
include DOL_DOCUMENT_ROOT.'/core/tpl/notes.tpl.php'; } else {
if (! empty($object->fk_project)) {
dol_fiche_end(); $proj = new Project($db);
$proj->fetch($object->fk_project);
$morehtmlref.='<a href="'.DOL_URL_ROOT.'/projet/card.php?id=' . $object->fk_project . '" title="' . $langs->trans('ShowProject') . '">';
$morehtmlref.=$proj->ref;
$morehtmlref.='</a>';
} else {
$morehtmlref.='';
}
}
} }
$morehtmlref.='</div>';
dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref);
print '<div class="fichecenter">';
print '<div class="underbanner clearboth"></div>';
$cssclass="titlefield";
include DOL_DOCUMENT_ROOT.'/core/tpl/notes.tpl.php';
print '</div>';
dol_fiche_end();
} }
llxFooter(); llxFooter();

View File

@ -28,7 +28,7 @@ $res=@include("../main.inc.php"); // For root dire
if (! $res) $res=@include("../../main.inc.php"); // For "custom" directory if (! $res) $res=@include("../../main.inc.php"); // For "custom" directory
if (! $res) die("Include of main fails"); if (! $res) die("Include of main fails");
require 'class/dolresource.class.php'; require_once DOL_DOCUMENT_ROOT.'/resource/class/dolresource.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
require_once DOL_DOCUMENT_ROOT.'/fichinter/class/fichinter.class.php'; require_once DOL_DOCUMENT_ROOT.'/fichinter/class/fichinter.class.php';
@ -52,6 +52,7 @@ $object->available_resources = array('dolresource');
// Get parameters // Get parameters
$id = GETPOST('id','int'); $id = GETPOST('id','int');
$ref = GETPOST('ref','alpha');
$action = GETPOST('action','alpha'); $action = GETPOST('action','alpha');
$mode = GETPOST('mode','alpha'); $mode = GETPOST('mode','alpha');
$lineid = GETPOST('lineid','int'); $lineid = GETPOST('lineid','int');
@ -79,50 +80,50 @@ if ($socid > 0)
if ($action == 'add_element_resource' && ! $cancel) if ($action == 'add_element_resource' && ! $cancel)
{ {
$error++; $error++;
$res = 0; $res = 0;
if (! ($resource_id > 0)) if (! ($resource_id > 0))
{ {
$error++; $error++;
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Resource")), null, 'errors'); setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Resource")), null, 'errors');
$action=''; $action='';
} }
else else
{ {
$objstat = fetchObjectByElement($element_id, $element); $objstat = fetchObjectByElement($element_id, $element);
$res = $objstat->add_element_resource($resource_id, $resource_type, $busy, $mandatory); $res = $objstat->add_element_resource($resource_id, $resource_type, $busy, $mandatory);
} }
if (! $error && $res > 0) if (! $error && $res > 0)
{ {
setEventMessages($langs->trans('ResourceLinkedWithSuccess'), null, 'mesgs'); setEventMessages($langs->trans('ResourceLinkedWithSuccess'), null, 'mesgs');
header("Location: ".$_SERVER['PHP_SELF'].'?element='.$element.'&element_id='.$element_id); header("Location: ".$_SERVER['PHP_SELF'].'?element='.$element.'&element_id='.$element_id);
exit; exit;
} }
} }
// Update ressource // Update ressource
if ($action == 'update_linked_resource' && $user->rights->resource->write && !GETPOST('cancel') ) if ($action == 'update_linked_resource' && $user->rights->resource->write && !GETPOST('cancel') )
{ {
$res = $object->fetch_element_resource($lineid); $res = $object->fetch_element_resource($lineid);
if($res) if($res)
{ {
$object->busy = $busy; $object->busy = $busy;
$object->mandatory = $mandatory; $object->mandatory = $mandatory;
$result = $object->update_element_resource($user); $result = $object->update_element_resource($user);
if ($result >= 0) if ($result >= 0)
{ {
setEventMessages($langs->trans('RessourceLineSuccessfullyUpdated'), null, 'mesgs'); setEventMessages($langs->trans('RessourceLineSuccessfullyUpdated'), null, 'mesgs');
header("Location: ".$_SERVER['PHP_SELF']."?element=".$element."&element_id=".$element_id); header("Location: ".$_SERVER['PHP_SELF']."?element=".$element."&element_id=".$element_id);
exit; exit;
} }
else else
{ {
setEventMessages($object->error, $object->errors, 'errors'); setEventMessages($object->error, $object->errors, 'errors');
} }
} }
} }
// Delete a resource linked to an element // Delete a resource linked to an element
@ -166,212 +167,236 @@ llxHeader('',$pagetitle,'');
// Load available resource, declared by modules // Load available resource, declared by modules
$ret = count($object->available_resources); $ret = count($object->available_resources);
if($ret == -1) { if($ret == -1) {
dol_print_error($db,$object->error); dol_print_error($db,$object->error);
exit; exit;
} }
if (!$ret) { if (!$ret) {
print '<div class="warning">'.$langs->trans('NoResourceInDatabase').'</div>'; print '<div class="warning">'.$langs->trans('NoResourceInDatabase').'</div>';
} }
else else
{ {
// Confirmation suppression resource line // Confirmation suppression resource line
if ($action == 'delete_resource') if ($action == 'delete_resource')
{ {
print $form->formconfirm("element_resource.php?element=".$element."&element_id=".$element_id."&id=".$id."&lineid=".$lineid,$langs->trans("DeleteResource"),$langs->trans("ConfirmDeleteResourceElement"),"confirm_delete_linked_resource",'','',1); print $form->formconfirm("element_resource.php?element=".$element."&element_id=".$element_id."&id=".$id."&lineid=".$lineid,$langs->trans("DeleteResource"),$langs->trans("ConfirmDeleteResourceElement"),"confirm_delete_linked_resource",'','',1);
} }
/* // Specific to agenda module
* Specific to agenda module if ($element_id && $element == 'action')
*/ {
if ($element_id && $element == 'action') require_once DOL_DOCUMENT_ROOT.'/core/lib/agenda.lib.php';
{
require_once DOL_DOCUMENT_ROOT.'/core/lib/agenda.lib.php';
$act = fetchObjectByElement($element_id,$element); $act = fetchObjectByElement($element_id,$element);
if (is_object($act)) if (is_object($act))
{ {
$head=actions_prepare_head($act); $head=actions_prepare_head($act);
dol_fiche_head($head, 'resources', $langs->trans("Action"),0,'action'); dol_fiche_head($head, 'resources', $langs->trans("Action"),0,'action');
$linkback =img_picto($langs->trans("BackToList"),'object_list','class="hideonsmartphone pictoactionview"'); $linkback =img_picto($langs->trans("BackToList"),'object_list','class="hideonsmartphone pictoactionview"');
$linkback.= '<a href="'.DOL_URL_ROOT.'/comm/action/listactions.php">'.$langs->trans("BackToList").'</a>'; $linkback.= '<a href="'.DOL_URL_ROOT.'/comm/action/listactions.php">'.$langs->trans("BackToList").'</a>';
// Link to other agenda views // Link to other agenda views
$out=''; $out='';
$out.=img_picto($langs->trans("ViewPerUser"),'object_calendarperuser','class="hideonsmartphone pictoactionview"'); $out.=img_picto($langs->trans("ViewPerUser"),'object_calendarperuser','class="hideonsmartphone pictoactionview"');
$out.='<a href="'.DOL_URL_ROOT.'/comm/action/peruser.php?action=show_peruser&year='.dol_print_date($act->datep,'%Y').'&month='.dol_print_date($act->datep,'%m').'&day='.dol_print_date($act->datep,'%d').'">'.$langs->trans("ViewPerUser").'</a>'; $out.='<a href="'.DOL_URL_ROOT.'/comm/action/peruser.php?action=show_peruser&year='.dol_print_date($act->datep,'%Y').'&month='.dol_print_date($act->datep,'%m').'&day='.dol_print_date($act->datep,'%d').'">'.$langs->trans("ViewPerUser").'</a>';
$out.='<br>'; $out.='<br>';
$out.=img_picto($langs->trans("ViewCal"),'object_calendar','class="hideonsmartphone pictoactionview"'); $out.=img_picto($langs->trans("ViewCal"),'object_calendar','class="hideonsmartphone pictoactionview"');
$out.='<a href="'.DOL_URL_ROOT.'/comm/action/index.php?action=show_month&year='.dol_print_date($act->datep,'%Y').'&month='.dol_print_date($act->datep,'%m').'&day='.dol_print_date($act->datep,'%d').'">'.$langs->trans("ViewCal").'</a>'; $out.='<a href="'.DOL_URL_ROOT.'/comm/action/index.php?action=show_month&year='.dol_print_date($act->datep,'%Y').'&month='.dol_print_date($act->datep,'%m').'&day='.dol_print_date($act->datep,'%d').'">'.$langs->trans("ViewCal").'</a>';
$out.=img_picto($langs->trans("ViewWeek"),'object_calendarweek','class="hideonsmartphone pictoactionview"'); $out.=img_picto($langs->trans("ViewWeek"),'object_calendarweek','class="hideonsmartphone pictoactionview"');
$out.='<a href="'.DOL_URL_ROOT.'/comm/action/index.php?action=show_day&year='.dol_print_date($act->datep,'%Y').'&month='.dol_print_date($act->datep,'%m').'&day='.dol_print_date($act->datep,'%d').'">'.$langs->trans("ViewWeek").'</a>'; $out.='<a href="'.DOL_URL_ROOT.'/comm/action/index.php?action=show_day&year='.dol_print_date($act->datep,'%Y').'&month='.dol_print_date($act->datep,'%m').'&day='.dol_print_date($act->datep,'%d').'">'.$langs->trans("ViewWeek").'</a>';
$out.=img_picto($langs->trans("ViewDay"),'object_calendarday','class="hideonsmartphone pictoactionview"'); $out.=img_picto($langs->trans("ViewDay"),'object_calendarday','class="hideonsmartphone pictoactionview"');
$out.='<a href="'.DOL_URL_ROOT.'/comm/action/index.php?action=show_day&year='.dol_print_date($act->datep,'%Y').'&month='.dol_print_date($act->datep,'%m').'&day='.dol_print_date($act->datep,'%d').'">'.$langs->trans("ViewDay").'</a>'; $out.='<a href="'.DOL_URL_ROOT.'/comm/action/index.php?action=show_day&year='.dol_print_date($act->datep,'%Y').'&month='.dol_print_date($act->datep,'%m').'&day='.dol_print_date($act->datep,'%d').'">'.$langs->trans("ViewDay").'</a>';
$linkback.=$out;
dol_banner_tab($act, 'element_id', $linkback, ($user->societe_id?0:1), 'id', 'ref', '', "&element=".$element);
print '<div class="underbanner clearboth"></div>';
// Ref
/*print '<tr><td width="30%">'.$langs->trans("Ref").'</td><td colspan="3">';
print $form->showrefnav($act, 'id', $linkback, ($user->societe_id?0:1), 'id', 'ref', '');
print '</td></tr>';*/
// Affichage fiche action en mode visu $linkback.=$out;
print '<table class="border" width="100%">';
// Type dol_banner_tab($act, 'element_id', $linkback, ($user->societe_id?0:1), 'id', 'ref', '', "&element=".$element);
if (! empty($conf->global->AGENDA_USE_EVENT_TYPE))
{
print '<tr><td class="titlefield">'.$langs->trans("Type").'</td><td colspan="3">'.$act->type.'</td></tr>';
}
// Full day event print '<div class="underbanner clearboth"></div>';
print '<tr><td class="titlefield">'.$langs->trans("EventOnFullDay").'</td><td colspan="3">'.yn($act->fulldayevent, 3).'</td></tr>';
// Date start
print '<tr><td>'.$langs->trans("DateActionStart").'</td><td colspan="3">';
if (! $act->fulldayevent) print dol_print_date($act->datep,'dayhour');
else print dol_print_date($act->datep,'day');
if ($act->percentage == 0 && $act->datep && $act->datep < ($now - $delay_warning)) print img_warning($langs->trans("Late"));
print '</td>';
print '</tr>';
// Date end
print '<tr><td>'.$langs->trans("DateActionEnd").'</td><td colspan="3">';
if (! $act->fulldayevent) print dol_print_date($act->datef,'dayhour');
else print dol_print_date($act->datef,'day');
if ($act->percentage > 0 && $act->percentage < 100 && $act->datef && $act->datef < ($now- $delay_warning)) print img_warning($langs->trans("Late"));
print '</td></tr>';
// Status
/*print '<tr><td class="nowrap">'.$langs->trans("Status").' / '.$langs->trans("Percentage").'</td><td colspan="2">';
print $act->getLibStatut(4);
print '</td></tr>';*/
// Location
if (empty($conf->global->AGENDA_DISABLE_LOCATION))
{
print '<tr><td>'.$langs->trans("Location").'</td><td colspan="3">'.$act->location.'</td></tr>';
}
// Assigned to
print '<tr><td class="nowrap">'.$langs->trans("ActionAffectedTo").'</td><td colspan="3">';
$listofuserid=array();
if (empty($donotclearsession))
{
if ($act->userownerid > 0) $listofuserid[$act->userownerid]=array('id'=>$act->userownerid,'transparency'=>$act->transparency); // Owner first
if (! empty($act->userassigned)) // Now concat assigned users
{
// Restore array with key with same value than param 'id'
$tmplist1=$act->userassigned; $tmplist2=array();
foreach($tmplist1 as $key => $val)
{
if ($val['id'] && $val['id'] != $act->userownerid) $listofuserid[$val['id']]=$val;
}
}
$_SESSION['assignedtouser']=json_encode($listofuserid);
}
else
{
if (!empty($_SESSION['assignedtouser']))
{
$listofuserid=json_decode($_SESSION['assignedtouser'], true);
}
}
print '<div class="assignedtouser">';
print $form->select_dolusers_forevent('view', 'assignedtouser', 1, '', 0, '', '', 0, 0, 0, '', 0, '', 'maxwidth300');
print '</div>';
if (in_array($user->id,array_keys($listofuserid)))
{
print '<div class="myavailability">';
print $langs->trans("MyAvailability").': '.(($act->userassigned[$user->id]['transparency'] > 0)?$langs->trans("Busy"):$langs->trans("Available")); // We show nothing if event is assigned to nobody
print '</div>';
}
print ' </td></tr>';
print '</table>';
dol_fiche_end(); // Ref
} /*print '<tr><td width="30%">'.$langs->trans("Ref").'</td><td colspan="3">';
} print $form->showrefnav($act, 'id', $linkback, ($user->societe_id?0:1), 'id', 'ref', '');
print '</td></tr>';*/
/* // Affichage fiche action en mode visu
* Specific to thirdparty module print '<table class="border" width="100%">';
*/
if ($element_id && $element == 'societe')
{
$socstatic = fetchObjectByElement($element_id, $element);
if (is_object($socstatic)) {
$savobject = $object;
$object = $socstatic;
require_once DOL_DOCUMENT_ROOT . '/core/lib/company.lib.php';
$head = societe_prepare_head($socstatic);
dol_fiche_head($head, 'resources', $langs->trans("ThirdParty"), 0, 'company');
dol_banner_tab($socstatic, 'socid', '', ($user->societe_id ? 0 : 1), 'rowid', 'nom');
print '<div class="fichecenter">';
print '<div class="underbanner clearboth"></div>';
print '<table class="border" width="100%">';
// Alias name (commercial, trademark or alias name)
print '<tr><td class="titlefield">' . $langs->trans('AliasNames') . '</td><td colspan="3">';
print $socstatic->name_alias;
print "</td></tr>";
print '</table>';
print '</div>';
dol_fiche_end();
$object = $savobject;
}
}
/* // Type
* Specific to fichinter module if (! empty($conf->global->AGENDA_USE_EVENT_TYPE))
*/ {
print '<tr><td class="titlefield">'.$langs->trans("Type").'</td><td colspan="3">'.$act->type.'</td></tr>';
}
// Full day event
print '<tr><td class="titlefield">'.$langs->trans("EventOnFullDay").'</td><td colspan="3">'.yn($act->fulldayevent, 3).'</td></tr>';
// Date start
print '<tr><td>'.$langs->trans("DateActionStart").'</td><td colspan="3">';
if (! $act->fulldayevent) print dol_print_date($act->datep,'dayhour');
else print dol_print_date($act->datep,'day');
if ($act->percentage == 0 && $act->datep && $act->datep < ($now - $delay_warning)) print img_warning($langs->trans("Late"));
print '</td>';
print '</tr>';
// Date end
print '<tr><td>'.$langs->trans("DateActionEnd").'</td><td colspan="3">';
if (! $act->fulldayevent) print dol_print_date($act->datef,'dayhour');
else print dol_print_date($act->datef,'day');
if ($act->percentage > 0 && $act->percentage < 100 && $act->datef && $act->datef < ($now- $delay_warning)) print img_warning($langs->trans("Late"));
print '</td></tr>';
// Status
/*print '<tr><td class="nowrap">'.$langs->trans("Status").' / '.$langs->trans("Percentage").'</td><td colspan="2">';
print $act->getLibStatut(4);
print '</td></tr>';*/
// Location
if (empty($conf->global->AGENDA_DISABLE_LOCATION))
{
print '<tr><td>'.$langs->trans("Location").'</td><td colspan="3">'.$act->location.'</td></tr>';
}
// Assigned to
print '<tr><td class="nowrap">'.$langs->trans("ActionAffectedTo").'</td><td colspan="3">';
$listofuserid=array();
if (empty($donotclearsession))
{
if ($act->userownerid > 0) $listofuserid[$act->userownerid]=array('id'=>$act->userownerid,'transparency'=>$act->transparency); // Owner first
if (! empty($act->userassigned)) // Now concat assigned users
{
// Restore array with key with same value than param 'id'
$tmplist1=$act->userassigned; $tmplist2=array();
foreach($tmplist1 as $key => $val)
{
if ($val['id'] && $val['id'] != $act->userownerid) $listofuserid[$val['id']]=$val;
}
}
$_SESSION['assignedtouser']=json_encode($listofuserid);
}
else
{
if (!empty($_SESSION['assignedtouser']))
{
$listofuserid=json_decode($_SESSION['assignedtouser'], true);
}
}
print '<div class="assignedtouser">';
print $form->select_dolusers_forevent('view', 'assignedtouser', 1, '', 0, '', '', 0, 0, 0, '', 0, '', 'maxwidth300');
print '</div>';
if (in_array($user->id,array_keys($listofuserid)))
{
print '<div class="myavailability">';
print $langs->trans("MyAvailability").': '.(($act->userassigned[$user->id]['transparency'] > 0)?$langs->trans("Busy"):$langs->trans("Available")); // We show nothing if event is assigned to nobody
print '</div>';
}
print ' </td></tr>';
print '</table>';
dol_fiche_end();
}
}
// Specific to thirdparty module
if ($element_id && $element == 'societe')
{
$socstatic = fetchObjectByElement($element_id, $element);
if (is_object($socstatic)) {
$savobject = $object;
$object = $socstatic;
require_once DOL_DOCUMENT_ROOT . '/core/lib/company.lib.php';
$head = societe_prepare_head($socstatic);
dol_fiche_head($head, 'resources', $langs->trans("ThirdParty"), 0, 'company');
dol_banner_tab($socstatic, 'socid', '', ($user->societe_id ? 0 : 1), 'rowid', 'nom');
print '<div class="fichecenter">';
print '<div class="underbanner clearboth"></div>';
print '<table class="border" width="100%">';
// Alias name (commercial, trademark or alias name)
print '<tr><td class="titlefield">' . $langs->trans('AliasNames') . '</td><td colspan="3">';
print $socstatic->name_alias;
print "</td></tr>";
print '</table>';
print '</div>';
dol_fiche_end();
$object = $savobject;
}
}
// Specific to fichinter module
if ($element_id && $element == 'fichinter') if ($element_id && $element == 'fichinter')
{ {
require_once DOL_DOCUMENT_ROOT.'/core/lib/fichinter.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/fichinter.lib.php';
$fichinter = new Fichinter($db); $fichinter = new Fichinter($db);
$fichinter->fetch($element_id); $fichinter->fetch($element_id);
$fichinter->fetch_thirdparty();
if (is_object($fichinter)) if (is_object($fichinter))
{ {
$head=fichinter_prepare_head($fichinter); $head=fichinter_prepare_head($fichinter);
dol_fiche_head($head, 'resource', $langs->trans("InterventionCard"),0,'intervention'); dol_fiche_head($head, 'resource', $langs->trans("InterventionCard"),0,'intervention');
// Affichage fiche action en mode visu // Intervention card
print '<table class="border" width="100%">';
$linkback = '<a href="'.DOL_URL_ROOT.'/fichinter/list.php'.(! empty($socid)?'?socid='.$socid:'').'">'.$langs->trans("BackToList").'</a>'; $linkback = '<a href="'.DOL_URL_ROOT.'/fichinter/list.php'.(! empty($socid)?'?socid='.$socid:'').'">'.$langs->trans("BackToList").'</a>';
// Ref
print '<tr><td width="30%">'.$langs->trans("Ref").'</td><td colspan="3">'; $morehtmlref='<div class="refidno">';
print $form->showrefnav($fichinter, 'id', $linkback, ($user->societe_id?0:1), 'ref', 'ref', ''); // Ref customer
print '</td></tr>'; //$morehtmlref.=$form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', 0, 1);
//$morehtmlref.=$form->editfieldval("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', null, null, '', 1);
// Thirdparty
// Customer $morehtmlref.=$langs->trans('ThirdParty') . ' : ' . $fichinter->thirdparty->getNomUrl(1);
if ( is_null($fichinter->thirdparty) ) // Project
$fichinter->fetch_thirdparty(); if (! empty($conf->projet->enabled))
{
print "<tr><td>".$langs->trans("Company")."</td>"; $langs->load("projects");
print '<td colspan="3">'.$fichinter->thirdparty->getNomUrl(1).'</td></tr>'; $morehtmlref.='<br>'.$langs->trans('Project') . ' ';
print "</table>"; if ($user->rights->commande->creer)
{
if ($action != 'classify')
//$morehtmlref.='<a href="' . $_SERVER['PHP_SELF'] . '?action=classify&amp;id=' . $fichinter->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a> : ';
$morehtmlref.=' : ';
if ($action == 'classify') {
//$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $fichinter->id, $fichinter->socid, $fichinter->fk_project, 'projectid', 0, 0, 1, 1);
$morehtmlref.='<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$fichinter->id.'">';
$morehtmlref.='<input type="hidden" name="action" value="classin">';
$morehtmlref.='<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
$morehtmlref.=$formproject->select_projects($fichinter->socid, $fichinter->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1);
$morehtmlref.='<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">';
$morehtmlref.='</form>';
} else {
$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $fichinter->id, $fichinter->socid, $fichinter->fk_project, 'none', 0, 0, 0, 1);
}
} else {
if (! empty($fichinter->fk_project)) {
$proj = new Project($db);
$proj->fetch($fichinter->fk_project);
$morehtmlref.='<a href="'.DOL_URL_ROOT.'/projet/card.php?id=' . $fichinter->fk_project . '" title="' . $langs->trans('ShowProject') . '">';
$morehtmlref.=$proj->ref;
$morehtmlref.='</a>';
} else {
$morehtmlref.='';
}
}
}
$morehtmlref.='</div>';
dol_banner_tab($fichinter, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref);
dol_fiche_end(); dol_fiche_end();
} }
} }
@ -383,54 +408,54 @@ else
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
//print load_fiche_titre($langs->trans('ResourcesLinkedToElement'),'',''); //print load_fiche_titre($langs->trans('ResourcesLinkedToElement'),'','');
print '<br>'; print '<br>';
// Show list of resource links // Show list of resource links
foreach ($object->available_resources as $modresources => $resources) foreach ($object->available_resources as $modresources => $resources)
{ {
$resources=(array) $resources; // To be sure $resources is an array $resources=(array) $resources; // To be sure $resources is an array
foreach($resources as $resource_obj) foreach($resources as $resource_obj)
{ {
$element_prop = getElementProperties($resource_obj); $element_prop = getElementProperties($resource_obj);
//print '/'.$modresources.'/class/'.$resource_obj.'.class.php<br />'; //print '/'.$modresources.'/class/'.$resource_obj.'.class.php<br />';
$path = ''; $path = '';
if(strpos($resource_obj,'@')) if(strpos($resource_obj,'@'))
$path .= '/'.$element_prop['module']; $path .= '/'.$element_prop['module'];
$linked_resources = $object->getElementResources($element,$element_id,$resource_obj); $linked_resources = $object->getElementResources($element,$element_id,$resource_obj);
// If we have a specific template we use it // If we have a specific template we use it
if(file_exists(dol_buildpath($path.'/core/tpl/resource_'.$element_prop['element'].'_add.tpl.php'))) if(file_exists(dol_buildpath($path.'/core/tpl/resource_'.$element_prop['element'].'_add.tpl.php')))
{ {
$res=include dol_buildpath($path.'/core/tpl/resource_'.$element_prop['element'].'_add.tpl.php'); $res=include dol_buildpath($path.'/core/tpl/resource_'.$element_prop['element'].'_add.tpl.php');
} }
else else
{ {
$res=include DOL_DOCUMENT_ROOT . '/core/tpl/resource_add.tpl.php'; $res=include DOL_DOCUMENT_ROOT . '/core/tpl/resource_add.tpl.php';
} }
if ($mode != 'add' || $resource_obj != $resource_type) if ($mode != 'add' || $resource_obj != $resource_type)
{ {
//print load_fiche_titre($langs->trans(ucfirst($element_prop['element']).'Singular')); //print load_fiche_titre($langs->trans(ucfirst($element_prop['element']).'Singular'));
// If we have a specific template we use it // If we have a specific template we use it
if(file_exists(dol_buildpath($path.'/core/tpl/resource_'.$element_prop['element'].'_view.tpl.php'))) if(file_exists(dol_buildpath($path.'/core/tpl/resource_'.$element_prop['element'].'_view.tpl.php')))
{ {
$res=@include dol_buildpath($path.'/core/tpl/resource_'.$element_prop['element'].'_view.tpl.php'); $res=@include dol_buildpath($path.'/core/tpl/resource_'.$element_prop['element'].'_view.tpl.php');
} }
else else
{ {
$res=include DOL_DOCUMENT_ROOT . '/core/tpl/resource_view.tpl.php'; $res=include DOL_DOCUMENT_ROOT . '/core/tpl/resource_view.tpl.php';
} }
} }
} }
} }
} }
llxFooter(); llxFooter();