From 49f2157f2da876d88ffa71d87a8c2444da6d4371 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 31 May 2015 02:05:39 +0200 Subject: [PATCH] Little debug of module resource --- htdocs/comm/action/card.php | 8 +-- htdocs/comm/action/document.php | 16 +++--- htdocs/core/lib/agenda.lib.php | 9 ++++ htdocs/core/lib/company.lib.php | 9 ++++ htdocs/core/modules/modResource.class.php | 8 +-- htdocs/core/tpl/resource_add.tpl.php | 15 ++---- htdocs/core/tpl/resource_view.tpl.php | 32 +++++------- htdocs/resource/element_resource.php | 64 +++++++++++------------ htdocs/theme/eldy/style.css.php | 12 ++++- 9 files changed, 94 insertions(+), 79 deletions(-) diff --git a/htdocs/comm/action/card.php b/htdocs/comm/action/card.php index 27841434f5a..8a80408fe49 100644 --- a/htdocs/comm/action/card.php +++ b/htdocs/comm/action/card.php @@ -1267,7 +1267,7 @@ if ($id > 0) print ''; print ''; //print ''; - print img_picto($langs->trans("ViewCal"),'object_calendar','class="hideonsmartphone"').' '; + print img_picto($langs->trans("ViewCal"),'object_calendar','class="hideonsmartphone pictoactionview"').' '; print ''."\n"; print '
'; print ''; @@ -1276,7 +1276,7 @@ if ($id > 0) print ''; print ''; //print ''; - print img_picto($langs->trans("ViewCal"),'object_calendarweek','class="hideonsmartphone"').' '; + print img_picto($langs->trans("ViewCal"),'object_calendarweek','class="hideonsmartphone pictoactionview"').' '; print '
'."\n"; print '
'; print ''; @@ -1285,7 +1285,7 @@ if ($id > 0) print ''; print ''; //print ''; - print img_picto($langs->trans("ViewCal"),'object_calendarday','class="hideonsmartphone"').' '; + print img_picto($langs->trans("ViewCal"),'object_calendarday','class="hideonsmartphone pictoactionview"').' '; print '
'."\n"; print '
'; print ''; @@ -1294,7 +1294,7 @@ if ($id > 0) print ''; print ''; //print ''; - print img_picto($langs->trans("ViewCal"),'object_calendarperuser','class="hideonsmartphone"').' '; + print img_picto($langs->trans("ViewCal"),'object_calendarperuser','class="hideonsmartphone pictoactionview"').' '; print '
'."\n"; print ''; diff --git a/htdocs/comm/action/document.php b/htdocs/comm/action/document.php index 82d88089684..598b02ef0b8 100644 --- a/htdocs/comm/action/document.php +++ b/htdocs/comm/action/document.php @@ -1,6 +1,6 @@ - * Copyright (C) 2004-2012 Laurent Destailleur + * Copyright (C) 2004-2015 Laurent Destailleur * Copyright (C) 2005 Marc Barilley / Ocebo * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2005 Simon TOSSER @@ -143,7 +143,7 @@ if ($object->id > 0) print ''.$langs->trans("Title").''.$object->label.''; // Full day event - print ''.$langs->trans("EventOnFullDay").''.yn($object->fulldayevent).''; + print ''.$langs->trans("EventOnFullDay").''.yn($object->fulldayevent, 3).''; // Date start print ''.$langs->trans("DateActionStart").''; @@ -235,7 +235,7 @@ if ($object->id > 0) // Project if (! empty($conf->projet->enabled)) { - print ''.$langs->trans("Project").''; + print ''.$langs->trans("Project").''; if ($object->fk_project) { $project=new Project($db); @@ -274,7 +274,7 @@ if ($object->id > 0) } - print ''.$langs->trans("NbOfAttachedFiles").''.count($filearray).''; + print ''.$langs->trans("NbOfAttachedFiles").''.count($filearray).''; print ''.$langs->trans("TotalSizeOfAttachedFiles").''.$totalsize.' '.$langs->trans("bytes").''; print ''; @@ -294,7 +294,7 @@ if ($object->id > 0) print ''; print ''; //print ''; - print img_picto($langs->trans("ViewCal"),'object_calendar','class="hideonsmartphone"').' '; + print img_picto($langs->trans("ViewCal"),'object_calendar','class="hideonsmartphone pictoactionview"').' '; print ''."\n"; print '
'; print ''; @@ -303,7 +303,7 @@ if ($object->id > 0) print ''; print ''; //print ''; - print img_picto($langs->trans("ViewCal"),'object_calendarweek','class="hideonsmartphone"').' '; + print img_picto($langs->trans("ViewCal"),'object_calendarweek','class="hideonsmartphone pictoactionview"').' '; print '
'."\n"; print '
'; print ''; @@ -312,7 +312,7 @@ if ($object->id > 0) print ''; print ''; //print ''; - print img_picto($langs->trans("ViewCal"),'object_calendarday','class="hideonsmartphone"').' '; + print img_picto($langs->trans("ViewCal"),'object_calendarday','class="hideonsmartphone pictoactionview"').' '; print '
'."\n"; print '
'; print ''; @@ -321,7 +321,7 @@ if ($object->id > 0) print ''; print ''; //print ''; - print img_picto($langs->trans("ViewCal"),'object_calendarperuser','class="hideonsmartphone"').' '; + print img_picto($langs->trans("ViewCal"),'object_calendarperuser','class="hideonsmartphone pictoactionview"').' '; print '
'."\n"; print ''; diff --git a/htdocs/core/lib/agenda.lib.php b/htdocs/core/lib/agenda.lib.php index 8013896d7bd..8ebdc547cc8 100644 --- a/htdocs/core/lib/agenda.lib.php +++ b/htdocs/core/lib/agenda.lib.php @@ -421,6 +421,15 @@ function actions_prepare_head($object) $head[$h][2] = 'card'; $h++; + // Tab to link resources + if ($conf->resource->enabled) + { + $head[$h][0] = DOL_URL_ROOT.'/resource/element_resource.php?element=action&element_id='.$object->id; + $head[$h][1] = $langs->trans("Resources"); + $head[$h][2] = 'resources'; + $h++; + } + // Attached files require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; $upload_dir = $conf->agenda->dir_output . "/" . $object->id; diff --git a/htdocs/core/lib/company.lib.php b/htdocs/core/lib/company.lib.php index 4eb33852836..efee824c092 100644 --- a/htdocs/core/lib/company.lib.php +++ b/htdocs/core/lib/company.lib.php @@ -93,6 +93,15 @@ function societe_prepare_head(Societe $object) $h++; } + // Tab to link resources + if ($conf->resource->enabled && ! empty($conf->global->RESOURCE_ON_THIRDPARTIES)) + { + $head[$h][0] = DOL_URL_ROOT.'/resource/element_resource.php?element=societe&element_id='.$object->id; + $head[$h][1] = $langs->trans("Resources"); + $head[$h][2] = 'resources'; + $h++; + } + // Show more tabs from modules // Entries must be declared in modules descriptor with line // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab diff --git a/htdocs/core/modules/modResource.class.php b/htdocs/core/modules/modResource.class.php index aa97f5608df..ae646cf6a3f 100644 --- a/htdocs/core/modules/modResource.class.php +++ b/htdocs/core/modules/modResource.class.php @@ -1,6 +1,5 @@ +/* Copyright (C) 2013-2014 Jean-François Ferry * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -14,6 +13,8 @@ * * You should have received a copy of the GNU General Public License * along with this program. If not, see . + * + * Module to manage resources into Dolibarr ERP/CRM */ /** @@ -151,8 +152,7 @@ class modResource extends DolibarrModules // (reresource 'x' by type of category (0=product, 1=supplier, 2=customer, 3=member) $this->tabs = array( - 'action:+resources:Resources:resource:$user->rights->resource->read:/resource/element_resource.php?element=action&element_id=__ID__', - 'thirdparty:+resources:Resources:resource:$user->rights->resource->read:/resource/element_resource.php?element=societe&element_id=__ID__' +// 'thirdparty:+resources:Resources:resource:$user->rights->resource->read:/resource/element_resource.php?element=societe&element_id=__ID__' ); // Boxes diff --git a/htdocs/core/tpl/resource_add.tpl.php b/htdocs/core/tpl/resource_add.tpl.php index f9cd20b5dc3..d16b8b629f8 100644 --- a/htdocs/core/tpl/resource_add.tpl.php +++ b/htdocs/core/tpl/resource_add.tpl.php @@ -1,14 +1,13 @@ load($resource_type); +require_once(DOL_DOCUMENT_ROOT.'/resource/class/html.formresource.class.php'); $form = new Form($db); -if(!class_exists('FormResource')) - require_once(DOL_DOCUMENT_ROOT.'/resource/class/html.formresource.class.php'); $formresources = new FormResource($db); -$out .= '
'; +$out .= '
'; $out .= '
'; $out .= ''; @@ -27,10 +26,8 @@ $out .= '
'; $out .= '
'.$form->selectyesno('busy',$linked_resource['busy']?1:0,1).'
'; $out .= '
'.$form->selectyesno('mandatory',$linked_resource['mandatory']?1:0,1).'
'; -$out .= '
'; -$out .='trans("Cancel").'" />'; +$out .= '
'; +$out .=''; $out .= '
'; $out .=''; @@ -40,6 +37,4 @@ $out .= '
'; print $out; - - // FIN DU TPL diff --git a/htdocs/core/tpl/resource_view.tpl.php b/htdocs/core/tpl/resource_view.tpl.php index 75a69996603..3b846e9314c 100644 --- a/htdocs/core/tpl/resource_view.tpl.php +++ b/htdocs/core/tpl/resource_view.tpl.php @@ -6,36 +6,32 @@ $form= new Form($db); if( (array) $linked_resources && count($linked_resources) > 0) { - $var=false; + $var=true; // TODO: DEBUT DU TPL if($mode == 'edit' ) { - print '
'; print '
'; print '
'.$langs->trans('Type').'
'; print '
'.$langs->trans('Resource').'
'; - print '
'.$langs->trans('Busy').'
'; - print '
'.$langs->trans('Mandatory').'
'; - print '
'.$langs->trans('Edit').'
'; + print '
'.$langs->trans('Busy').'
'; + print '
'.$langs->trans('Mandatory').'
'; + print '
'; print '
'; //print '
'; - } else { - print '
'; print '
'; print '
'.$langs->trans('Type').'
'; print '
'.$langs->trans('Resource').'
'; - print '
'.$langs->trans('Busy').'
'; - print '
'.$langs->trans('Mandatory').'
'; - print '
'.$langs->trans('Action').'
'; + print '
'.$langs->trans('Busy').'
'; + print '
'.$langs->trans('Mandatory').'
'; + print '
'; print '
'; //print '
'; - } @@ -55,7 +51,7 @@ if( (array) $linked_resources && count($linked_resources) > 0) print '
'.$object_resource->type_label.'
'; print '
'.$object_resource->getNomUrl(1).'
'; - print '
'.$form->selectyesno('busy',$linked_resource['busy']?1:0,1).'
'; + print '
'.$form->selectyesno('busy',$linked_resource['busy']?1:0,1).'
'; print '
'.$form->selectyesno('mandatory',$linked_resource['mandatory']?1:0,1).'
'; print '
'; print ''; @@ -77,20 +73,20 @@ if( (array) $linked_resources && count($linked_resources) > 0) print $object_resource->getNomUrl(1); print '
'; - print '
'; - print $linked_resource['busy']?1:0; + print '
'; + print yn($linked_resource['busy']); print '
'; - print '
'; - print $linked_resource['mandatory']?1:0; + print '
'; + print yn($linked_resource['mandatory']); print '
'; - print '
'; + print ''; diff --git a/htdocs/resource/element_resource.php b/htdocs/resource/element_resource.php index 6b6b5553d72..123673654c9 100644 --- a/htdocs/resource/element_resource.php +++ b/htdocs/resource/element_resource.php @@ -72,6 +72,11 @@ $mandatory = GETPOST('mandatory','int'); $cancel = GETPOST('cancel','alpha'); $confirm = GETPOST('confirm','alpha'); + +/* + * Actions + */ + if($action == 'add_element_resource' && ! $cancel) { $objstat = fetchObjectByElement($element_id,$element); @@ -147,19 +152,17 @@ $reshook=$hookmanager->executeHooks('getElementResources',$parameters,$object,$a if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); -/*************************************************** - * VIEW -* -* Put here all code to build page -****************************************************/ + +/* + * View + */ + +$form=new Form($db); $pagetitle=$langs->trans('ResourceElementPage'); llxHeader('',$pagetitle,''); -$form=new Form($db); - - // Load available resource, declared by modules $ret = count($object->available_resources); if($ret == -1) { @@ -212,16 +215,17 @@ else print ''.$langs->trans("Title").''.$act->label.''; print ''; - print '
'; + dol_fiche_end(); } } + /* * Specific to thirdparty module */ - if($element_id && $element == 'societe') + if ($element_id && $element == 'societe') { $socstatic = fetchObjectByElement($element_id,$element); - if(is_object($socstatic)) { + if (is_object($socstatic)) { require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; $head = societe_prepare_head($socstatic); @@ -240,13 +244,13 @@ else print ''; print ''; - print '
'; + dol_fiche_end(); } } - print_fiche_titre($langs->trans('ResourcesLinkedToElement'),'','resource.png@resource'); + //print_fiche_titre($langs->trans('ResourcesLinkedToElement'),'',''); @@ -257,7 +261,8 @@ else { $element_prop = getElementProperties($resource_obj); - print_titre($langs->trans(ucfirst($element_prop['element']).'Singular')); + + //print '/'.$modresources.'/class/'.$resource_obj.'.class.php
'; @@ -267,21 +272,21 @@ else $linked_resources = $object->getElementResources($element,$element_id,$resource_obj); - if ( $mode == 'add' && $resource_obj == $resource_type) + + // 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 we have a specific template we use it - if(file_exists(dol_buildpath($path.'/core/tpl/resource_'.$element_prop['element'].'_'.$mode.'.tpl.php'))) - { - $res=include dol_buildpath($path.'/core/tpl/resource_'.$element_prop['element'].'_'.$mode.'.tpl.php'); - } - else - { - $res=include DOL_DOCUMENT_ROOT . '/core/tpl/resource_add.tpl.php'; - } + $res=include dol_buildpath($path.'/core/tpl/resource_'.$element_prop['element'].'_add.tpl.php'); } else { - //print '/'.$element_prop['module'].'/core/tpl/resource_'.$element_prop['element'].'_view.tpl.php'; + $res=include DOL_DOCUMENT_ROOT . '/core/tpl/resource_add.tpl.php'; + } + + + if ($mode != 'add' || $resource_obj != $resource_type) + { + //print_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'))) @@ -294,15 +299,6 @@ else $res=include DOL_DOCUMENT_ROOT . '/core/tpl/resource_view.tpl.php'; } } - - if($resource_obj!=$resource_type ) - { - print '
'; - print '
'; - print ''.$langs->trans('AddResource').''; - print '
'; - print '
'; - } } } } diff --git a/htdocs/theme/eldy/style.css.php b/htdocs/theme/eldy/style.css.php index dd304dae7c1..6a7de1143bf 100644 --- a/htdocs/theme/eldy/style.css.php +++ b/htdocs/theme/eldy/style.css.php @@ -448,7 +448,17 @@ textarea.centpercent { #formuserfile_link { margin-left: 1px; } - +/* Style to move picto into left of button */ +/* +.buttonactionview { + padding-left: 15px; +} +.pictoactionview { + padding-left: 10px; + margin-right: -24px; + z-index: 999999; +} +*/ /* ============================================================================== */ /* Styles to hide objects */