From 581ea0f36b3bd90b3c9f271136c2f353ce8339ab Mon Sep 17 00:00:00 2001 From: PeartreeG Date: Sun, 31 Jan 2016 12:17:45 +0100 Subject: [PATCH 01/21] adding resource in contact type list --- htdocs/admin/dict.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/admin/dict.php b/htdocs/admin/dict.php index 17033845f8c..f52a29249ea 100644 --- a/htdocs/admin/dict.php +++ b/htdocs/admin/dict.php @@ -466,6 +466,7 @@ if ($id == 11) 'propal' => $langs->trans('Proposal'), 'commande' => $langs->trans('Order'), 'facture' => $langs->trans('Bill'), + 'resource' => $langs->trans('Resource'), // 'facture_fourn' => $langs->trans('SupplierBill'), 'fichinter' => $langs->trans('InterventionCard') ); From 4c025d432316ac7958faf3605b29625500b1c1c9 Mon Sep 17 00:00:00 2001 From: PeartreeG Date: Sun, 31 Jan 2016 12:23:05 +0100 Subject: [PATCH 02/21] Adding additional tabs --- htdocs/core/lib/resource.lib.php | 40 ++++++++++++++++++++++++++++++-- 1 file changed, 38 insertions(+), 2 deletions(-) diff --git a/htdocs/core/lib/resource.lib.php b/htdocs/core/lib/resource.lib.php index e92d59dcac7..b56f361110a 100644 --- a/htdocs/core/lib/resource.lib.php +++ b/htdocs/core/lib/resource.lib.php @@ -1,6 +1,7 @@ + * Copyright (C) 2016 Gilles Poirier * * 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 @@ -28,7 +29,7 @@ * @param Object $object Object * @return array Array of head entries */ -function resourcePrepareHead($object) +function resource_prepare_head($object) { global $langs, $conf, $user; $h = 0; @@ -36,15 +37,50 @@ function resourcePrepareHead($object) $head[$h][0] = dol_buildpath('/resource/card.php',1).'?id='.$object->id; $head[$h][1] = $langs->trans("ResourceCard"); - $head[$h][2] = 'resource'; + $head[$h][2] = 'resource'; $h++; + if (empty($conf->global->MAIN_DISABLE_CONTACTS_TAB)) + { + $head[$h][0] = DOL_URL_ROOT.'/resource/contact.php?id='.$object->id; + $head[$h][1] = $langs->trans('Contact'); + $head[$h][2] = 'contact'; + $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 // $this->tabs = array('entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to remove a tab complete_head_from_modules($conf,$langs,$object,$head,$h,'resource'); + if (empty($conf->global->MAIN_DISABLE_NOTES_TAB)) + { + $nbNote = 0; + if(!empty($object->note_private)) $nbNote++; + if(!empty($object->note_public)) $nbNote++; + $head[$h][0] = DOL_URL_ROOT.'/fichinter/note.php?id='.$object->id; + $head[$h][1] = $langs->trans('Notes'); + if ($nbNote > 0) $head[$h][1].= ' '.$nbNote.''; + $head[$h][2] = 'note'; + $h++; + } + + require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; + $upload_dir = $conf->ficheinter->dir_output . "/" . dol_sanitizeFileName($object->ref); + $nbFiles = count(dol_dir_list($upload_dir,'files',0,'','(\.meta|_preview\.png)$')); + $head[$h][0] = DOL_URL_ROOT.'/fichinter/document.php?id='.$object->id; + $head[$h][1] = $langs->trans("Documents"); + if($nbFiles > 0) $head[$h][1].= ' '.$nbFiles.''; + $head[$h][2] = 'documents'; + $h++; + + $head[$h][0] = DOL_URL_ROOT.'/fichinter/info.php?id='.$object->id; + $head[$h][1] = $langs->trans('Info'); + $head[$h][2] = 'info'; + $h++; + + complete_head_from_modules($conf,$langs,$object,$head,$h,'intervention','remove'); return $head; } From d1018760dfdd3e233707e09cb2aa461f56e54e7f Mon Sep 17 00:00:00 2001 From: PeartreeG Date: Sun, 31 Jan 2016 12:24:19 +0100 Subject: [PATCH 03/21] Update resource.lib.php --- htdocs/core/lib/resource.lib.php | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/htdocs/core/lib/resource.lib.php b/htdocs/core/lib/resource.lib.php index b56f361110a..dd7b7ef699f 100644 --- a/htdocs/core/lib/resource.lib.php +++ b/htdocs/core/lib/resource.lib.php @@ -57,30 +57,30 @@ function resource_prepare_head($object) if (empty($conf->global->MAIN_DISABLE_NOTES_TAB)) { $nbNote = 0; - if(!empty($object->note_private)) $nbNote++; + if(!empty($object->note_private)) $nbNote++; if(!empty($object->note_public)) $nbNote++; - $head[$h][0] = DOL_URL_ROOT.'/fichinter/note.php?id='.$object->id; + $head[$h][0] = DOL_URL_ROOT.'/resource/note.php?id='.$object->id; $head[$h][1] = $langs->trans('Notes'); if ($nbNote > 0) $head[$h][1].= ' '.$nbNote.''; $head[$h][2] = 'note'; $h++; } - + require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; - $upload_dir = $conf->ficheinter->dir_output . "/" . dol_sanitizeFileName($object->ref); + $upload_dir = $conf->resource->dir_output . "/" . dol_sanitizeFileName($object->ref); $nbFiles = count(dol_dir_list($upload_dir,'files',0,'','(\.meta|_preview\.png)$')); - $head[$h][0] = DOL_URL_ROOT.'/fichinter/document.php?id='.$object->id; + $head[$h][0] = DOL_URL_ROOT.'/resource/document.php?id='.$object->id; $head[$h][1] = $langs->trans("Documents"); if($nbFiles > 0) $head[$h][1].= ' '.$nbFiles.''; $head[$h][2] = 'documents'; $h++; - - $head[$h][0] = DOL_URL_ROOT.'/fichinter/info.php?id='.$object->id; + + $head[$h][0] = DOL_URL_ROOT.'/resource/info.php?id='.$object->id; $head[$h][1] = $langs->trans('Info'); $head[$h][2] = 'info'; $h++; - complete_head_from_modules($conf,$langs,$object,$head,$h,'intervention','remove'); + complete_head_from_modules($conf,$langs,$object,$head,$h,'resource', 'remove'); return $head; } From c34fd7b354c2b21227beadcabcc884c16c152564 Mon Sep 17 00:00:00 2001 From: PeartreeG Date: Sun, 31 Jan 2016 12:26:12 +0100 Subject: [PATCH 04/21] add contact tabs on resource --- htdocs/resource/contact.php | 159 ++++++++++++++++++++++++++++++++++++ 1 file changed, 159 insertions(+) create mode 100644 htdocs/resource/contact.php diff --git a/htdocs/resource/contact.php b/htdocs/resource/contact.php new file mode 100644 index 00000000000..70c64568bf6 --- /dev/null +++ b/htdocs/resource/contact.php @@ -0,0 +1,159 @@ + + * Copyright (C) 2007-2009 Laurent Destailleur + * Copyright (C) 2012 Juanjo Menent + * Copyright (C) 2016 Gilles Poirier + + * + * 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 + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** + * \file htdocs/resource/contact.php + * \ingroup resource + * \brief Onglet de gestion des contacts des resources + */ + +require '../main.inc.php'; +require_once DOL_DOCUMENT_ROOT.'/resource/class/resource.class.php'; +require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/resource.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; + +$langs->load("resource"); +$langs->load("sendings"); +$langs->load("companies"); + +$id = GETPOST('id','int'); +$ref = GETPOST('ref', 'alpha'); +$action = GETPOST('action','alpha'); + +// Security check +if ($user->societe_id) $socid=$user->societe_id; +$result = restrictedArea($user, 'resource', $id, 'resource'); + +$object = new Resource($db); +$result = $object->fetch($id,$ref); + + +/* + * Ajout d'un nouveau contact + */ + +if ($action == 'addcontact' && $user->rights->resource->write) +{ + if ($result > 0 && $id > 0) + { + $contactid = (GETPOST('userid','int') ? GETPOST('userid','int') : GETPOST('contactid','int')); + $result = $object->add_contact($contactid, GETPOST('type','int'), GETPOST('source','alpha')); + } + + if ($result >= 0) + { + header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); + exit; + } + else + { + if ($object->error == 'DB_ERROR_RECORD_ALREADY_EXISTS') { + $langs->load("errors"); + $mesg = $langs->trans("ErrorThisContactIsAlreadyDefinedAsThisType"); + } else { + $mesg = $object->error; + } + + setEventMessage($mesg, 'errors'); + } +} + +// bascule du statut d'un contact +else if ($action == 'swapstatut' && $user->rights->resource->write) +{ + $result=$object->swapContactStatus(GETPOST('ligne','int')); +} + +// Efface un contact +else if ($action == 'deletecontact' && $user->rights->resource->write) +{ + $result = $object->delete_contact(GETPOST('lineid','int')); + + if ($result >= 0) + { + header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); + exit; + } + else { + dol_print_error($db); + } +} + + +/* + * View + */ + +$form = new Form($db); +$formcompany = new FormCompany($db); +$contactstatic=new Contact($db); +$userstatic=new User($db); + +llxHeader('',$langs->trans("Resource")); + +// Mode vue et edition + +if ($id > 0 || ! empty($ref)) +{ + $soc = new Societe($db); + $soc->fetch($object->socid); + + + $head = resource_prepare_head($object); + dol_fiche_head($head, 'contact', $langs->trans("ResourceSingular"), 0, 'resource@resource'); + + + /* + * Resource synthese pour rappel + */ + print ''; + + print ''; + print ''; + + // Resource type + print ''; + print ''; + print ''; + print ''; + + print '
'.$langs->trans("ResourceFormLabel_ref").''; + $linkback = $objet->ref.' '.$langs->trans("BackToList").''; + print $form->showrefnav($object, 'id', $linkback,1,"rowid"); + print '
' . $langs->trans("ResourceType") . ''; + print $object->type_label; + print '
'; + print ''; + + print '
'; + + if (! empty($conf->global->RESOURCE_HIDE_ADD_CONTACT_USER)) $hideaddcontactforuser=1; + if (! empty($conf->global->RESOURCE_HIDE_ADD_CONTACT_THIPARTY)) $hideaddcontactforthirdparty=1; + + $permission=1; + // Contacts lines + include DOL_DOCUMENT_ROOT.'/core/tpl/contacts.tpl.php'; +} + + +llxFooter(); +$db->close(); From 265f01806cdcd6eb61b38f3d7ff1d81363e973f4 Mon Sep 17 00:00:00 2001 From: PeartreeG Date: Sun, 31 Jan 2016 12:27:46 +0100 Subject: [PATCH 05/21] add document feature on resource modules --- htdocs/resource/document.php | 141 +++++++++++++++++++++++++++++++++++ 1 file changed, 141 insertions(+) create mode 100644 htdocs/resource/document.php diff --git a/htdocs/resource/document.php b/htdocs/resource/document.php new file mode 100644 index 00000000000..cbe53be0ad1 --- /dev/null +++ b/htdocs/resource/document.php @@ -0,0 +1,141 @@ + + * Copyright (C) 2004-2010 Laurent Destailleur + * Copyright (C) 2005 Marc Barilley / Ocebo + * Copyright (C) 2005-2009 Regis Houssin + * Copyright (C) 2005 Simon TOSSER + * Copyright (C) 2011-2012 Juanjo Menent + * Copyright (C) 2013 Cédric Salvador + * Copyright (C) 2016 Gilles Poirier + * + * 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 + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** + * \file htdocs/resource/document.php + * \ingroup resource + * \brief Page des documents joints sur les resources + */ + +require '../main.inc.php'; +require_once DOL_DOCUMENT_ROOT.'/resource/class/resource.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/resource.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; + +$langs->load("other"); +$langs->load("resource"); +$langs->load("companies"); + +$id = GETPOST('id','int'); +$ref = GETPOST('ref', 'alpha'); +$action = GETPOST('action','alpha'); +$confirm = GETPOST('confirm','alpha'); + +// Security check +if ($user->societe_id) $socid=$user->societe_id; +$result = restrictedArea($user, 'resource', $id, 'resource'); + + +// Get parameters +$sortfield = GETPOST('sortfield','alpha'); +$sortorder = GETPOST('sortorder','alpha'); +$page = GETPOST('page','int'); +if ($page == -1) { $page = 0; } +$offset = $conf->liste_limit * $page; +$pageprev = $page - 1; +$pagenext = $page + 1; +if (! $sortorder) $sortorder="ASC"; +if (! $sortfield) $sortfield="name"; + + +$object = new Resource($db); +$object->fetch($id, $ref); + +$upload_dir = $conf->resource->dir_output.'/'.dol_sanitizeFileName($object->ref); +$modulepart='fichinter'; + + +/* + * Actions + */ + +include_once DOL_DOCUMENT_ROOT . '/core/tpl/document_actions_pre_headers.tpl.php'; + + +/* + * View + */ + +$form = new Form($db); + +llxHeader('',$langs->trans("Resource")); + +if ($object->id) +{ + $object->fetch_thirdparty(); + + $head=resource_prepare_head($object); + + dol_fiche_head($head, 'documents', $langs->trans("ResourceSingular"), 0, 'resource'); + + + // Construit liste des fichiers + $filearray=dol_dir_list($upload_dir,"files",0,'','(\.meta|_preview\.png)$',$sortfield,(strtolower($sortorder)=='desc'?SORT_DESC:SORT_ASC),1); + $totalsize=0; + foreach($filearray as $key => $file) + { + $totalsize+=$file['size']; + } + + + print ''; + + + print ''; + print ''; + + // Resource type + print ''; + print ''; + print ''; + print ''; + + print ''; + print ''; + print '
'.$langs->trans("ResourceFormLabel_ref").''; + $linkback = $objet->ref.' '.$langs->trans("BackToList").''; + print $form->showrefnav($object, 'id', $linkback,1,"rowid"); + print '
' . $langs->trans("ResourceType") . ''; + print $object->type_label; + print '
'.$langs->trans("NbOfAttachedFiles").''.count($filearray).'
'.$langs->trans("TotalSizeOfAttachedFiles").''.$totalsize.' '.$langs->trans("bytes").'
'; + + print ''; + + $modulepart = 'ficheinter'; + $permission = $user->rights->ficheinter->creer; + $param = '&id=' . $object->id; + include_once DOL_DOCUMENT_ROOT . '/core/tpl/document_actions_post_headers.tpl.php'; + +} +else +{ + print $langs->trans("ErrorUnknown"); +} + + +llxFooter(); + +$db->close(); From f4a6945aa099b8c2de8358503cfe10c968e0d3d0 Mon Sep 17 00:00:00 2001 From: PeartreeG Date: Sun, 31 Jan 2016 12:30:15 +0100 Subject: [PATCH 06/21] add note feature on resource module --- htdocs/resource/note.php | 90 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 90 insertions(+) create mode 100644 htdocs/resource/note.php diff --git a/htdocs/resource/note.php b/htdocs/resource/note.php new file mode 100644 index 00000000000..f3da12c0b49 --- /dev/null +++ b/htdocs/resource/note.php @@ -0,0 +1,90 @@ + + * Copyright (C) 2011-2012 Juanjo Menent + * Copyright (C) 2013 Florian Henry + * Copyright (C) 2016 Gilles Poirier + * + * 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 + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** + * \file htdocs/resource/note.php + * \ingroup fichinter + * \brief Fiche d'information sur une resource + */ + +require '../main.inc.php'; +require_once DOL_DOCUMENT_ROOT.'/resource/class/resource.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/resource.lib.php'; + +$langs->load('companies'); +$langs->load("interventions"); + +$id = GETPOST('id','int'); +$ref = GETPOST('ref', 'alpha'); +$action=GETPOST('action','alpha'); + +// Security check +if ($user->societe_id) $socid=$user->societe_id; +$result = restrictedArea($user, 'resource', $id, 'resource'); + +$object = new Resource($db); +$object->fetch($id,$ref); + +$permissionnote=$user->rights->resource->write; // Used by the include of actions_setnotes.inc.php + +/* + * Actions + */ + +include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include, not includ_once + + +/* + * View + */ + +llxHeader(); + +$form = new Form($db); + +if ($id > 0 || ! empty($ref)) +{ + $head = resource_prepare_head($object); + dol_fiche_head($head, 'note', $langs->trans('ResourceSingular'), 0, 'resource@resource'); + + print ''; + print ''; + print ''; + + // Resource type + print ''; + print ''; + print ''; + print ''; print "
'.$langs->trans("ResourceFormLabel_ref").''; + $linkback = $objet->ref.' '.$langs->trans("BackToList").''; + print $form->showrefnav($object, 'id', $linkback,1,"rowid"); + print '
' . $langs->trans("ResourceType") . ''; + print $object->type_label; + print '
"; + + print '
'; + $permission=$user->rights->resource->write; + include DOL_DOCUMENT_ROOT.'/core/tpl/notes.tpl.php'; + + dol_fiche_end(); +} + +llxFooter(); +$db->close(); From 91e46b1d35385a4b2722a5a13bd56a8fa664cf1c Mon Sep 17 00:00:00 2001 From: PeartreeG Date: Sun, 31 Jan 2016 12:37:03 +0100 Subject: [PATCH 07/21] add somes fields on resource --- htdocs/install/mysql/tables/llx_resource.sql | 25 +++++++++++++------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/htdocs/install/mysql/tables/llx_resource.sql b/htdocs/install/mysql/tables/llx_resource.sql index 0d67075f1ea..37e0fbc7494 100755 --- a/htdocs/install/mysql/tables/llx_resource.sql +++ b/htdocs/install/mysql/tables/llx_resource.sql @@ -16,12 +16,21 @@ CREATE TABLE llx_resource ( - rowid integer AUTO_INCREMENT PRIMARY KEY, - entity integer DEFAULT 1 NOT NULL, - ref varchar(255), - description text, + rowid integer AUTO_INCREMENT PRIMARY KEY, + entity integer DEFAULT 1 NOT NULL, + ref varchar(255), + asset_number varchar(255), + description text, fk_code_type_resource varchar(32), - note_public text, - note_private text, - tms timestamp -)ENGINE=innodb; \ No newline at end of file + datec datetime DEFAULT NULL, + date_valid datetime DEFAULT NULL, + fk_user_author integer DEFAULT NULL, + fk_user_modif integer DEFAULT NULL, + fk_user_valid integer DEFAULT NULL, + fk_statut smallint NOT NULL DEFAULT '0', + note_public text, + note_private text, + import_key varchar(14), + extraparams varchar(255), -- for stock other parameters with json format + tms timestamp +)ENGINE=innodb; From b47065862a3f0f125f3ec457dc43832219aaab94 Mon Sep 17 00:00:00 2001 From: PeartreeG Date: Sun, 31 Jan 2016 12:38:05 +0100 Subject: [PATCH 08/21] Update llx_resource.sql --- htdocs/install/mysql/tables/llx_resource.sql | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/install/mysql/tables/llx_resource.sql b/htdocs/install/mysql/tables/llx_resource.sql index 37e0fbc7494..afb73e9fd5f 100755 --- a/htdocs/install/mysql/tables/llx_resource.sql +++ b/htdocs/install/mysql/tables/llx_resource.sql @@ -1,5 +1,6 @@ -- Module to manage resources into Dolibarr ERP/CRM --- Copyright (C) 2013 Jean-François Ferry +-- Copyright (C) 2013 Jean-François Ferry +-- Copyright (C) 2016 Gilles Poirier -- -- 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 From 1fbfdbfefd33a979bf5250c28ed730cf814fedad Mon Sep 17 00:00:00 2001 From: PeartreeG Date: Sun, 31 Jan 2016 12:47:18 +0100 Subject: [PATCH 09/21] add new ressources fields --- htdocs/install/mysql/migration/3.9.0-4.0.0.sql | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/htdocs/install/mysql/migration/3.9.0-4.0.0.sql b/htdocs/install/mysql/migration/3.9.0-4.0.0.sql index f2b3ff181cc..e2cad614d91 100644 --- a/htdocs/install/mysql/migration/3.9.0-4.0.0.sql +++ b/htdocs/install/mysql/migration/3.9.0-4.0.0.sql @@ -39,4 +39,14 @@ ALTER TABLE llx_cronjob MODIFY COLUMN unitfrequency varchar(255) NOT NULL DEFAUL ALTER TABLE llx_facture ADD INDEX idx_facture_fk_statut (fk_statut); UPDATE llx_projet as p set p.opp_percent = (SELECT percent FROM llx_c_lead_status as cls WHERE cls.rowid = p.fk_opp_status) WHERE p.opp_percent IS NULL AND p.fk_opp_status IS NOT NULL; - \ No newline at end of file + +ALTER TABLE llx_resource ADD COLUMN asset_number varchar(255) after ref; +ALTER TABLE llx_resource ADD COLUMN datec datetime DEFAULT NULL; +ALTER TABLE llx_resource ADD COLUMN date_valid datetime DEFAULT NULL; +ALTER TABLE llx_resource ADD COLUMN fk_user_author integer DEFAULT NULL; +ALTER TABLE llx_resource ADD COLUMN fk_user_modif integer DEFAULT NULL; +ALTER TABLE llx_resource ADD COLUMN fk_user_valid integer DEFAULT NULL; +ALTER TABLE llx_resource ADD COLUMN fk_statut smallint NOT NULL DEFAULT '0'; +ALTER TABLE llx_resource ADD COLUMN import_key varchar(14); +ALTER TABLE llx_resource ADD COLUMN extraparams varchar(255); + From f6dc4757d0f4115aead107a1cd13cf457293190e Mon Sep 17 00:00:00 2001 From: PeartreeG Date: Sun, 31 Jan 2016 18:13:14 +0100 Subject: [PATCH 10/21] add fields for resource tracking --- htdocs/install/mysql/tables/llx_element_resources.sql | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/htdocs/install/mysql/tables/llx_element_resources.sql b/htdocs/install/mysql/tables/llx_element_resources.sql index 9c67a0d52af..4fac28de4b1 100644 --- a/htdocs/install/mysql/tables/llx_element_resources.sql +++ b/htdocs/install/mysql/tables/llx_element_resources.sql @@ -26,6 +26,10 @@ CREATE TABLE llx_element_resources resource_type varchar(64), -- resource or user busy integer, mandatory integer, + dateo date, -- date start of using ressource + datee date, -- date end of using ressource + datet date, -- date terminaison of using ressource + duree real, -- total duration of using ressource fk_user_create integer, tms timestamp )ENGINE=innodb; From e2404b57b3d78bbe17b4ed2e6f15ec2d568a2c1b Mon Sep 17 00:00:00 2001 From: PeartreeG Date: Sun, 31 Jan 2016 18:15:11 +0100 Subject: [PATCH 11/21] adding additionnal fields for tracking resource use --- htdocs/install/mysql/migration/3.9.0-4.0.0.sql | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/htdocs/install/mysql/migration/3.9.0-4.0.0.sql b/htdocs/install/mysql/migration/3.9.0-4.0.0.sql index e2cad614d91..b7e5ab28c76 100644 --- a/htdocs/install/mysql/migration/3.9.0-4.0.0.sql +++ b/htdocs/install/mysql/migration/3.9.0-4.0.0.sql @@ -50,3 +50,7 @@ ALTER TABLE llx_resource ADD COLUMN fk_statut smallint NOT NULL DEFAULT '0 ALTER TABLE llx_resource ADD COLUMN import_key varchar(14); ALTER TABLE llx_resource ADD COLUMN extraparams varchar(255); +ALTER TABLE llx_element_resources ADD COLUMN dateo date, -- date start of using ressource +ALTER TABLE llx_element_resources ADD COLUMN datee date, -- date end of using ressource +ALTER TABLE llx_element_resources ADD COLUMN datet date, -- date terminaison of using ressource +ALTER TABLE llx_element_resources ADD COLUMN duree real, -- total duration of using ressource From ceb1cd57984f77be68ab736b9839a6a2172b48d4 Mon Sep 17 00:00:00 2001 From: PeartreeG Date: Sun, 31 Jan 2016 18:16:53 +0100 Subject: [PATCH 12/21] Update 3.9.0-4.0.0.sql --- htdocs/install/mysql/migration/3.9.0-4.0.0.sql | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/install/mysql/migration/3.9.0-4.0.0.sql b/htdocs/install/mysql/migration/3.9.0-4.0.0.sql index b7e5ab28c76..352d950ef02 100644 --- a/htdocs/install/mysql/migration/3.9.0-4.0.0.sql +++ b/htdocs/install/mysql/migration/3.9.0-4.0.0.sql @@ -50,7 +50,7 @@ ALTER TABLE llx_resource ADD COLUMN fk_statut smallint NOT NULL DEFAULT '0 ALTER TABLE llx_resource ADD COLUMN import_key varchar(14); ALTER TABLE llx_resource ADD COLUMN extraparams varchar(255); -ALTER TABLE llx_element_resources ADD COLUMN dateo date, -- date start of using ressource -ALTER TABLE llx_element_resources ADD COLUMN datee date, -- date end of using ressource -ALTER TABLE llx_element_resources ADD COLUMN datet date, -- date terminaison of using ressource -ALTER TABLE llx_element_resources ADD COLUMN duree real, -- total duration of using ressource +ALTER TABLE llx_element_resources ADD COLUMN dateo date; -- date start of using ressource +ALTER TABLE llx_element_resources ADD COLUMN datee date; -- date end of using ressource +ALTER TABLE llx_element_resources ADD COLUMN datet date; -- date terminaison of using ressource +ALTER TABLE llx_element_resources ADD COLUMN duree real; -- total duration of using ressource From 4e83abba30d11a3c7ce99f8949cbaed2219fda2b Mon Sep 17 00:00:00 2001 From: PeartreeG Date: Mon, 1 Feb 2016 15:40:16 +0100 Subject: [PATCH 13/21] Update element_resource.php --- htdocs/resource/element_resource.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/htdocs/resource/element_resource.php b/htdocs/resource/element_resource.php index e4477e1674a..4193ee44749 100644 --- a/htdocs/resource/element_resource.php +++ b/htdocs/resource/element_resource.php @@ -257,6 +257,10 @@ else } } + // hook for other elements linked + $parameters=array('element'=>$element, 'element_id'=>$element_id ); + $reshook=$hookmanager->executeHooks('printElementTab',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks + if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); //print load_fiche_titre($langs->trans('ResourcesLinkedToElement'),'',''); From c1ff21c30a860bcf9431f0a537bacb7b140d89fc Mon Sep 17 00:00:00 2001 From: PeartreeG Date: Mon, 1 Feb 2016 16:09:58 +0100 Subject: [PATCH 14/21] add fichinter link to resources --- htdocs/core/lib/fichinter.lib.php | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/htdocs/core/lib/fichinter.lib.php b/htdocs/core/lib/fichinter.lib.php index a6f68800dc4..ff67de88132 100644 --- a/htdocs/core/lib/fichinter.lib.php +++ b/htdocs/core/lib/fichinter.lib.php @@ -2,6 +2,8 @@ /* Copyright (C) 2006-2007 Laurent Destailleur * Copyright (C) 2007 Rodolphe Quiedeville * Copyright (C) 2012 Regis Houssin + * Copyright (C) 2016 Gilles Poirier + * * 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 @@ -65,6 +67,15 @@ function fichinter_prepare_head($object) // $this->tabs = array('entity:-tabname); to remove a tab complete_head_from_modules($conf,$langs,$object,$head,$h,'intervention'); + // Tab to link resources + if ($conf->resource->enabled) + { + $head[$h][0] = DOL_URL_ROOT.'/resource/element_resource.php?element=ficheinter&element_id='.$object->id; + $head[$h][1] = $langs->trans("Resources"); + $head[$h][2] = 'resource'; + $h++; + } + if (empty($conf->global->MAIN_DISABLE_NOTES_TAB)) { $nbNote = 0; From 62b35ffa455acbf9e80a26172d3f076b92b490cc Mon Sep 17 00:00:00 2001 From: PeartreeG Date: Mon, 1 Feb 2016 16:15:30 +0100 Subject: [PATCH 15/21] add fichinter tabs on resource element link --- htdocs/resource/element_resource.php | 40 +++++++++++++++++++++++++++- 1 file changed, 39 insertions(+), 1 deletion(-) diff --git a/htdocs/resource/element_resource.php b/htdocs/resource/element_resource.php index 4193ee44749..80c9f1f97a7 100644 --- a/htdocs/resource/element_resource.php +++ b/htdocs/resource/element_resource.php @@ -1,5 +1,6 @@ +/* Copyright (C) 2013 Jean-François Ferry + * Copyright (C) 2016 Gilles Poirier * * 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 @@ -257,6 +258,43 @@ else } } + /* + * Specific to agenda module + */ + if ($element_id && $element == 'ficheinter') + { + require_once DOL_DOCUMENT_ROOT.'/core/lib/fichinter.lib.php'; + + $fichinter = fetchObjectByElement($element_id, $element); + if (is_object($fichinter)) + { + $head=fichinter_prepare_head($fichinter); + dol_fiche_head($head, 'resources', $langs->trans("InterventionCard"),0,'intervention'); + + // Affichage fiche action en mode visu + print ''; + + $linkback = ''.$langs->trans("BackToList").''; + + // Ref + print ''; + + + // Customer + if ( is_null($fichinter->client) ) + $fichinter->fetch_thirdparty(); + + print ""; + print ''; + print "
'.$langs->trans("Ref").''; + print $form->showrefnav($fichinter, 'id', $linkback, ($user->societe_id?0:1), 'ref', 'ref', ''); + print '
".$langs->trans("Company")."'.$fichinter->client->getNomUrl(1).'
"; + + dol_fiche_end(); + } + } + + // hook for other elements linked $parameters=array('element'=>$element, 'element_id'=>$element_id ); $reshook=$hookmanager->executeHooks('printElementTab',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks From 6bb6e66e134efb3cf53a5e332db25da4482250bb Mon Sep 17 00:00:00 2001 From: PeartreeG Date: Tue, 2 Feb 2016 14:05:35 +0100 Subject: [PATCH 16/21] element name used to create the clas... --- htdocs/resource/element_resource.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/resource/element_resource.php b/htdocs/resource/element_resource.php index 80c9f1f97a7..6ac787bc359 100644 --- a/htdocs/resource/element_resource.php +++ b/htdocs/resource/element_resource.php @@ -259,9 +259,9 @@ else } /* - * Specific to agenda module + * Specific to fichinter module */ - if ($element_id && $element == 'ficheinter') + if ($element_id && $element == 'fichinter') { require_once DOL_DOCUMENT_ROOT.'/core/lib/fichinter.lib.php'; From 4c0f29d23460d27b1b4824d1fdb04af3d64e846f Mon Sep 17 00:00:00 2001 From: PeartreeG Date: Tue, 2 Feb 2016 14:05:58 +0100 Subject: [PATCH 17/21] Update fichinter.lib.php --- htdocs/core/lib/fichinter.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/lib/fichinter.lib.php b/htdocs/core/lib/fichinter.lib.php index ff67de88132..390a7e14435 100644 --- a/htdocs/core/lib/fichinter.lib.php +++ b/htdocs/core/lib/fichinter.lib.php @@ -70,7 +70,7 @@ function fichinter_prepare_head($object) // Tab to link resources if ($conf->resource->enabled) { - $head[$h][0] = DOL_URL_ROOT.'/resource/element_resource.php?element=ficheinter&element_id='.$object->id; + $head[$h][0] = DOL_URL_ROOT.'/resource/element_resource.php?element=fichinter&element_id='.$object->id; $head[$h][1] = $langs->trans("Resources"); $head[$h][2] = 'resource'; $h++; From 835c2725c517527cd09031cca6cb0181f2156896 Mon Sep 17 00:00:00 2001 From: PeartreeG Date: Tue, 2 Feb 2016 14:14:01 +0100 Subject: [PATCH 18/21] Update element_resource.php --- htdocs/resource/element_resource.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/resource/element_resource.php b/htdocs/resource/element_resource.php index 6ac787bc359..7dbcd3a5522 100644 --- a/htdocs/resource/element_resource.php +++ b/htdocs/resource/element_resource.php @@ -269,7 +269,7 @@ else if (is_object($fichinter)) { $head=fichinter_prepare_head($fichinter); - dol_fiche_head($head, 'resources', $langs->trans("InterventionCard"),0,'intervention'); + dol_fiche_head($head, 'resource', $langs->trans("InterventionCard"),0,'intervention'); // Affichage fiche action en mode visu print ''; From b0579cc39b8a8b1574e867c6a5ccb2c43e08867d Mon Sep 17 00:00:00 2001 From: PeartreeG Date: Tue, 2 Feb 2016 18:05:00 +0100 Subject: [PATCH 19/21] Update 3.9.0-4.0.0.sql --- htdocs/install/mysql/migration/3.9.0-4.0.0.sql | 3 --- 1 file changed, 3 deletions(-) diff --git a/htdocs/install/mysql/migration/3.9.0-4.0.0.sql b/htdocs/install/mysql/migration/3.9.0-4.0.0.sql index 352d950ef02..d8e42cff15f 100644 --- a/htdocs/install/mysql/migration/3.9.0-4.0.0.sql +++ b/htdocs/install/mysql/migration/3.9.0-4.0.0.sql @@ -50,7 +50,4 @@ ALTER TABLE llx_resource ADD COLUMN fk_statut smallint NOT NULL DEFAULT '0 ALTER TABLE llx_resource ADD COLUMN import_key varchar(14); ALTER TABLE llx_resource ADD COLUMN extraparams varchar(255); -ALTER TABLE llx_element_resources ADD COLUMN dateo date; -- date start of using ressource -ALTER TABLE llx_element_resources ADD COLUMN datee date; -- date end of using ressource -ALTER TABLE llx_element_resources ADD COLUMN datet date; -- date terminaison of using ressource ALTER TABLE llx_element_resources ADD COLUMN duree real; -- total duration of using ressource From cc8af4fba118481eb86eac8e840da86cc791a7ca Mon Sep 17 00:00:00 2001 From: PeartreeG Date: Tue, 2 Feb 2016 18:05:24 +0100 Subject: [PATCH 20/21] Update llx_element_resources.sql --- htdocs/install/mysql/tables/llx_element_resources.sql | 3 --- 1 file changed, 3 deletions(-) diff --git a/htdocs/install/mysql/tables/llx_element_resources.sql b/htdocs/install/mysql/tables/llx_element_resources.sql index 4fac28de4b1..d619626d3d7 100644 --- a/htdocs/install/mysql/tables/llx_element_resources.sql +++ b/htdocs/install/mysql/tables/llx_element_resources.sql @@ -26,9 +26,6 @@ CREATE TABLE llx_element_resources resource_type varchar(64), -- resource or user busy integer, mandatory integer, - dateo date, -- date start of using ressource - datee date, -- date end of using ressource - datet date, -- date terminaison of using ressource duree real, -- total duration of using ressource fk_user_create integer, tms timestamp From ea5b8a409c243ce45159792bcee21bbd80d0791e Mon Sep 17 00:00:00 2001 From: PeartreeG Date: Tue, 2 Feb 2016 18:37:54 +0100 Subject: [PATCH 21/21] little forget... --- htdocs/resource/card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/resource/card.php b/htdocs/resource/card.php index 31fb6a955b1..59862a811ba 100644 --- a/htdocs/resource/card.php +++ b/htdocs/resource/card.php @@ -152,7 +152,7 @@ $formresource = new FormResource($db); if ( $object->fetch($id) > 0 ) { - $head=resourcePrepareHead($object); + $head=resource_prepare_head($object); if ($action == 'edit' )