diff --git a/htdocs/core/lib/fichinter.lib.php b/htdocs/core/lib/fichinter.lib.php index 25f8c2c98aaa46080fdbc7298e54a2d1ba40fa70..de7fc01d0ff7ede2f733b207aa68a4bc45f4f71b 100644 --- a/htdocs/core/lib/fichinter.lib.php +++ b/htdocs/core/lib/fichinter.lib.php @@ -72,8 +72,22 @@ function fichinter_prepare_head($object) // Tab to link resources 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"); + if ($nbResource > 0) $head[$h][1].= ' <span class="badge">'.$nbResource.'</span>'; $head[$h][2] = 'resource'; $h++; } diff --git a/htdocs/fichinter/card.php b/htdocs/fichinter/card.php index f943fa4784bc0458d647bba5d21312f865c95b16..d2eb83a720fb5d9211299af0f74e88933f5a691a 100644 --- a/htdocs/fichinter/card.php +++ b/htdocs/fichinter/card.php @@ -1194,10 +1194,10 @@ else if ($id > 0 || ! empty($ref)) $morehtmlref='<div class="refidno">'; // Ref customer - //$morehtmlref.=$form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, $user->rights->commande->creer, 'string', '', 0, 1); - //$morehtmlref.=$form->editfieldval("RefCustomer", 'ref_client', $object->ref_client, $object, $user->rights->commande->creer, 'string', '', null, null, '', 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->fichinter->creer, 'string', '', null, null, '', 1); // Thirdparty - $morehtmlref.=$langs->trans('ThirdParty') . ' : ' . $soc->getNomUrl(1); + $morehtmlref.=$langs->trans('ThirdParty') . ' : ' . $object->thirdparty->getNomUrl(1); // Project if (! empty($conf->projet->enabled)) { diff --git a/htdocs/fichinter/contact.php b/htdocs/fichinter/contact.php index 473445049f7dabbe15d3652169d5c62050ac0be8..ab9b15da6668b65d55e80a385e6aebdc12a23069 100644 --- a/htdocs/fichinter/contact.php +++ b/htdocs/fichinter/contact.php @@ -112,43 +112,74 @@ llxHeader('',$langs->trans("Intervention")); if ($id > 0 || ! empty($ref)) { - $soc = new Societe($db); - $soc->fetch($object->socid); - + $object->fetch_thirdparty(); $head = fichinter_prepare_head($object); dol_fiche_head($head, 'contact', $langs->trans("InterventionCard"), 0, 'intervention'); - /* - * Fiche intervention synthese pour rappel - */ - print '<table class="border" width="100%">'; - + // Intervention card $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">'; - print $form->showrefnav($object, 'ref', $linkback, 1, 'ref', 'ref'); - print "</td></tr>"; - - // Customer - if ( is_null($object->thirdparty) ) - $object->fetch_thirdparty(); - - print "<tr><td>".$langs->trans("Company")."</td>"; - print '<td colspan="3">'.$object->thirdparty->getNomUrl(1).'</td></tr>'; - print "</table>"; - - print '</div>'; - + + + $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&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>'; - + if (! empty($conf->global->FICHINTER_HIDE_ADD_CONTACT_USER)) $hideaddcontactforuser=1; if (! empty($conf->global->FICHINTER_HIDE_ADD_CONTACT_THIPARTY)) $hideaddcontactforthirdparty=1; - // Contacts lines - include DOL_DOCUMENT_ROOT.'/core/tpl/contacts.tpl.php'; + // Contacts lines (modules that overwrite templates must declare this into descriptor) + $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; + } + } diff --git a/htdocs/fichinter/document.php b/htdocs/fichinter/document.php index a0bc97a17afa5072e7fc28129fe6643547fe03dc..2e53d6ebc629b377870f0df062ec084427d64162 100644 --- a/htdocs/fichinter/document.php +++ b/htdocs/fichinter/document.php @@ -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&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%">'; - - $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 class="titlefield">'.$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 '</table>'; print '</div>'; + dol_fiche_end(); + $modulepart = 'ficheinter'; $permission = $user->rights->ficheinter->creer; $permtoedit = $user->rights->ficheinter->creer; diff --git a/htdocs/fichinter/info.php b/htdocs/fichinter/info.php index 9f951dfe2d3b2ab9bf7673ee094cf14672787cb8..de2317eeccab3345b2fd68e050b5c8456fb7f6c6 100644 --- a/htdocs/fichinter/info.php +++ b/htdocs/fichinter/info.php @@ -1,6 +1,6 @@ <?php /* 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> * * 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("interventions"); +$socid=0; $id = GETPOST('id','int'); +$ref=GETPOST('ref','alpha'); // Security check if ($user->societe_id) $socid=$user->societe_id; @@ -39,9 +41,10 @@ $result = restrictedArea($user, 'ficheinter', $id, 'fichinter'); $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")); -$societe = new Societe($db); -$societe->fetch($object->socid); +$object->fetch_thirdparty(); +$object->info($object->id); $head = fichinter_prepare_head($object); 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&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>'; dol_print_object_info($object); @@ -65,5 +118,7 @@ print '</td></tr></table>'; print '</div>'; +dol_fiche_end(); + llxFooter(); $db->close(); diff --git a/htdocs/fichinter/note.php b/htdocs/fichinter/note.php index c672d48cb71641e690e0a85c647721779f3ca021..1da0b0c425ccb8a6d5f7031cbff336898b953016 100644 --- a/htdocs/fichinter/note.php +++ b/htdocs/fichinter/note.php @@ -60,31 +60,67 @@ $form = new Form($db); if ($id > 0 || ! empty($ref)) { - $societe = new Societe($db); - if ($societe->fetch($object->socid)) + $object->fetch_thirdparty(); + + $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); - dol_fiche_head($head, 'note', $langs->trans('InterventionCard'), 0, 'intervention'); - - print '<table class="border" width="100%">'; - - $linkback = '<a href="'.DOL_URL_ROOT.'/fichinter/list.php'.(! empty($socid)?'?socid='.$socid:'').'">'.$langs->trans("BackToList").'</a>'; - - print '<tr><td class="titlefield">'.$langs->trans('Ref').'</td><td>'; - print $form->showrefnav($object, 'ref', $linkback, 1, 'ref', 'ref'); - print '</td></tr>'; - - // Company - print '<tr><td>'.$langs->trans('Company').'</td><td>'.$societe->getNomUrl(1).'</td></tr>'; - - print "</table>"; - - print '<br>'; - - include DOL_DOCUMENT_ROOT.'/core/tpl/notes.tpl.php'; - - dol_fiche_end(); + $langs->load("projects"); + $morehtmlref.='<br>'.$langs->trans('Project') . ' '; + if ($user->rights->commande->creer) + { + if ($action != 'classify') + //$morehtmlref.='<a href="' . $_SERVER['PHP_SELF'] . '?action=classify&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>'; + + $cssclass="titlefield"; + include DOL_DOCUMENT_ROOT.'/core/tpl/notes.tpl.php'; + + print '</div>'; + + dol_fiche_end(); } llxFooter(); diff --git a/htdocs/resource/element_resource.php b/htdocs/resource/element_resource.php index 27451b079732a1bfc9596d3d417fa6ccbd5147ec..87354c6fd9d5280d7c163e854dc9725717c22696 100644 --- a/htdocs/resource/element_resource.php +++ b/htdocs/resource/element_resource.php @@ -28,7 +28,7 @@ $res=@include("../main.inc.php"); // For root dire if (! $res) $res=@include("../../main.inc.php"); // For "custom" directory 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.'/fichinter/class/fichinter.class.php'; @@ -52,6 +52,7 @@ $object->available_resources = array('dolresource'); // Get parameters $id = GETPOST('id','int'); +$ref = GETPOST('ref','alpha'); $action = GETPOST('action','alpha'); $mode = GETPOST('mode','alpha'); $lineid = GETPOST('lineid','int'); @@ -79,50 +80,50 @@ if ($socid > 0) if ($action == 'add_element_resource' && ! $cancel) { - $error++; - $res = 0; - if (! ($resource_id > 0)) - { - $error++; - setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Resource")), null, 'errors'); - $action=''; - } - else - { - $objstat = fetchObjectByElement($element_id, $element); - - $res = $objstat->add_element_resource($resource_id, $resource_type, $busy, $mandatory); - } - if (! $error && $res > 0) - { - setEventMessages($langs->trans('ResourceLinkedWithSuccess'), null, 'mesgs'); - header("Location: ".$_SERVER['PHP_SELF'].'?element='.$element.'&element_id='.$element_id); - exit; - } + $error++; + $res = 0; + if (! ($resource_id > 0)) + { + $error++; + setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Resource")), null, 'errors'); + $action=''; + } + else + { + $objstat = fetchObjectByElement($element_id, $element); + + $res = $objstat->add_element_resource($resource_id, $resource_type, $busy, $mandatory); + } + if (! $error && $res > 0) + { + setEventMessages($langs->trans('ResourceLinkedWithSuccess'), null, 'mesgs'); + header("Location: ".$_SERVER['PHP_SELF'].'?element='.$element.'&element_id='.$element_id); + exit; + } } // Update ressource if ($action == 'update_linked_resource' && $user->rights->resource->write && !GETPOST('cancel') ) { - $res = $object->fetch_element_resource($lineid); - if($res) - { - $object->busy = $busy; - $object->mandatory = $mandatory; - - $result = $object->update_element_resource($user); - - if ($result >= 0) - { - setEventMessages($langs->trans('RessourceLineSuccessfullyUpdated'), null, 'mesgs'); - header("Location: ".$_SERVER['PHP_SELF']."?element=".$element."&element_id=".$element_id); - exit; - } - else - { - setEventMessages($object->error, $object->errors, 'errors'); - } - } + $res = $object->fetch_element_resource($lineid); + if($res) + { + $object->busy = $busy; + $object->mandatory = $mandatory; + + $result = $object->update_element_resource($user); + + if ($result >= 0) + { + setEventMessages($langs->trans('RessourceLineSuccessfullyUpdated'), null, 'mesgs'); + header("Location: ".$_SERVER['PHP_SELF']."?element=".$element."&element_id=".$element_id); + exit; + } + else + { + setEventMessages($object->error, $object->errors, 'errors'); + } + } } // Delete a resource linked to an element @@ -166,212 +167,236 @@ llxHeader('',$pagetitle,''); // Load available resource, declared by modules $ret = count($object->available_resources); if($ret == -1) { - dol_print_error($db,$object->error); - exit; + dol_print_error($db,$object->error); + exit; } if (!$ret) { - print '<div class="warning">'.$langs->trans('NoResourceInDatabase').'</div>'; + print '<div class="warning">'.$langs->trans('NoResourceInDatabase').'</div>'; } else { - // Confirmation suppression resource line - 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); - } - - - /* - * Specific to agenda module - */ - if ($element_id && $element == 'action') - { - require_once DOL_DOCUMENT_ROOT.'/core/lib/agenda.lib.php'; - - $act = fetchObjectByElement($element_id,$element); - if (is_object($act)) - { - - $head=actions_prepare_head($act); - - dol_fiche_head($head, 'resources', $langs->trans("Action"),0,'action'); - - $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>'; - - // Link to other agenda views - $out=''; - $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.='<br>'; - $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.=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.=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>'; - - $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 - print '<table class="border" width="100%">'; - - // Type - 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 - */ + // Confirmation suppression resource line + 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); + } + + + // Specific to agenda module + if ($element_id && $element == 'action') + { + require_once DOL_DOCUMENT_ROOT.'/core/lib/agenda.lib.php'; + + $act = fetchObjectByElement($element_id,$element); + if (is_object($act)) + { + + $head=actions_prepare_head($act); + + dol_fiche_head($head, 'resources', $langs->trans("Action"),0,'action'); + + $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>'; + + // Link to other agenda views + $out=''; + $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.='<br>'; + $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.=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.=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>'; + + $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 + print '<table class="border" width="100%">'; + + // Type + 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') { require_once DOL_DOCUMENT_ROOT.'/core/lib/fichinter.lib.php'; $fichinter = new Fichinter($db); $fichinter->fetch($element_id); + $fichinter->fetch_thirdparty(); + if (is_object($fichinter)) { $head=fichinter_prepare_head($fichinter); dol_fiche_head($head, 'resource', $langs->trans("InterventionCard"),0,'intervention'); - // Affichage fiche action en mode visu - print '<table class="border" width="100%">'; - + // Intervention card $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">'; - print $form->showrefnav($fichinter, 'id', $linkback, ($user->societe_id?0:1), 'ref', 'ref', ''); - print '</td></tr>'; - - - // Customer - if ( is_null($fichinter->thirdparty) ) - $fichinter->fetch_thirdparty(); - - print "<tr><td>".$langs->trans("Company")."</td>"; - print '<td colspan="3">'.$fichinter->thirdparty->getNomUrl(1).'</td></tr>'; - print "</table>"; - + + + $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') . ' : ' . $fichinter->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&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(); } } @@ -383,54 +408,54 @@ else if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); - //print load_fiche_titre($langs->trans('ResourcesLinkedToElement'),'',''); - print '<br>'; - + //print load_fiche_titre($langs->trans('ResourcesLinkedToElement'),'',''); + print '<br>'; + // Show list of resource links - foreach ($object->available_resources as $modresources => $resources) - { - $resources=(array) $resources; // To be sure $resources is an array - foreach($resources as $resource_obj) - { - $element_prop = getElementProperties($resource_obj); - - //print '/'.$modresources.'/class/'.$resource_obj.'.class.php<br />'; - - $path = ''; - if(strpos($resource_obj,'@')) - $path .= '/'.$element_prop['module']; - - $linked_resources = $object->getElementResources($element,$element_id,$resource_obj); - - - // If we have a specific template we use it - 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'); - } - else - { - $res=include DOL_DOCUMENT_ROOT . '/core/tpl/resource_add.tpl.php'; - } - - if ($mode != 'add' || $resource_obj != $resource_type) - { - //print load_fiche_titre($langs->trans(ucfirst($element_prop['element']).'Singular')); - - // If we have a specific template we use it - 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'); - - } - else - { - $res=include DOL_DOCUMENT_ROOT . '/core/tpl/resource_view.tpl.php'; - } - } - } - } + foreach ($object->available_resources as $modresources => $resources) + { + $resources=(array) $resources; // To be sure $resources is an array + foreach($resources as $resource_obj) + { + $element_prop = getElementProperties($resource_obj); + + //print '/'.$modresources.'/class/'.$resource_obj.'.class.php<br />'; + + $path = ''; + if(strpos($resource_obj,'@')) + $path .= '/'.$element_prop['module']; + + $linked_resources = $object->getElementResources($element,$element_id,$resource_obj); + + + // If we have a specific template we use it + 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'); + } + else + { + $res=include DOL_DOCUMENT_ROOT . '/core/tpl/resource_add.tpl.php'; + } + + if ($mode != 'add' || $resource_obj != $resource_type) + { + //print load_fiche_titre($langs->trans(ucfirst($element_prop['element']).'Singular')); + + // If we have a specific template we use it + 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'); + + } + else + { + $res=include DOL_DOCUMENT_ROOT . '/core/tpl/resource_view.tpl.php'; + } + } + } + } } llxFooter();