From f7aa08f3fdad623277172e4f48c55d1b6181f1b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Doursenaud?= Date: Wed, 24 Sep 2014 17:41:05 +0200 Subject: [PATCH 01/10] Fixed invoices webservice --- htdocs/webservices/server_invoice.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/htdocs/webservices/server_invoice.php b/htdocs/webservices/server_invoice.php index 8412ed6ab1b..3e5ec83afc9 100644 --- a/htdocs/webservices/server_invoice.php +++ b/htdocs/webservices/server_invoice.php @@ -136,7 +136,9 @@ $server->wsdl->addComplexType( 'minOccurs' => '0', 'maxOccurs' => 'unbounded' ) - ) + ), + null, + 'tns:line' ); @@ -197,7 +199,9 @@ $server->wsdl->addComplexType( 'minOccurs' => '0', 'maxOccurs' => 'unbounded' ) - ) + ), + null, + 'tns:invoice' ); From 6149994b4308455a9dbfb6daf6657c40eab3230e Mon Sep 17 00:00:00 2001 From: jean Date: Wed, 24 Sep 2014 22:05:53 +0200 Subject: [PATCH 02/10] Adding hook 'suppliercard' on supplier cartd --- htdocs/fourn/card.php | 112 +++++++++++++++++++++++------------------- 1 file changed, 61 insertions(+), 51 deletions(-) diff --git a/htdocs/fourn/card.php b/htdocs/fourn/card.php index 313f82547e7..07ede4329b6 100644 --- a/htdocs/fourn/card.php +++ b/htdocs/fourn/card.php @@ -4,6 +4,7 @@ * Copyright (C) 2004-2011 Laurent Destailleur * Copyright (C) 2005-2010 Regis Houssin * Copyright (C) 2010-2014 Juanjo Menent + * Copyright (C) 2014 Jean Heimburger * * 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 @@ -48,6 +49,9 @@ $result = restrictedArea($user, 'societe&fournisseur', $id, '&societe'); $object = new Fournisseur($db); +// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array +$hookmanager->initHooks(array('suppliercard')); + /* * Action */ @@ -425,60 +429,66 @@ if ($object->fetch($id)) /* * Barre d'actions */ + $parameters = array(); + $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been + // modified by hook + if (empty($reshook)) + { - print '
'; + print '
'; - if ($user->rights->fournisseur->commande->creer) - { - $langs->load("orders"); - print ''.$langs->trans("AddOrder").''; + if ($user->rights->fournisseur->commande->creer) + { + $langs->load("orders"); + print ''.$langs->trans("AddOrder").''; + } + + if ($user->rights->fournisseur->facture->creer) + { + $langs->load("bills"); + print ''.$langs->trans("AddBill").''; + } + + // Add action + if (! empty($conf->agenda->enabled) && ! empty($conf->global->MAIN_REPEATTASKONEACHTAB)) + { + if ($user->rights->agenda->myactions->create) + { + print ''.$langs->trans("AddAction").''; + } + else + { + print ''.$langs->trans("AddAction").''; + } + } + + print '
'; + print '
'; + + if (! empty($conf->global->MAIN_REPEATCONTACTONEACHTAB)) + { + print '
'; + // List of contacts + show_contacts($conf,$langs,$db,$object,$_SERVER["PHP_SELF"].'?socid='.$object->id); + } + + // Addresses list + if (! empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) && ! empty($conf->global->MAIN_REPEATADDRESSONEACHTAB)) + { + $result=show_addresses($conf,$langs,$db,$object,$_SERVER["PHP_SELF"].'?socid='.$object->id); + } + + if (! empty($conf->global->MAIN_REPEATTASKONEACHTAB)) + { + print load_fiche_titre($langs->trans("ActionsOnCompany"),'',''); + + // List of todo actions + show_actions_todo($conf,$langs,$db,$object); + + // List of done actions + show_actions_done($conf,$langs,$db,$object); + } } - - if ($user->rights->fournisseur->facture->creer) - { - $langs->load("bills"); - print ''.$langs->trans("AddBill").''; - } - - // Add action - if (! empty($conf->agenda->enabled) && ! empty($conf->global->MAIN_REPEATTASKONEACHTAB)) - { - if ($user->rights->agenda->myactions->create) - { - print ''.$langs->trans("AddAction").''; - } - else - { - print ''.$langs->trans("AddAction").''; - } - } - - print '
'; - print '
'; - - if (! empty($conf->global->MAIN_REPEATCONTACTONEACHTAB)) - { - print '
'; - // List of contacts - show_contacts($conf,$langs,$db,$object,$_SERVER["PHP_SELF"].'?socid='.$object->id); - } - - // Addresses list - if (! empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) && ! empty($conf->global->MAIN_REPEATADDRESSONEACHTAB)) - { - $result=show_addresses($conf,$langs,$db,$object,$_SERVER["PHP_SELF"].'?socid='.$object->id); - } - - if (! empty($conf->global->MAIN_REPEATTASKONEACHTAB)) - { - print load_fiche_titre($langs->trans("ActionsOnCompany"),'',''); - - // List of todo actions - show_actions_todo($conf,$langs,$db,$object); - - // List of done actions - show_actions_done($conf,$langs,$db,$object); - } } else { From e9374e8c08c46b1504d012bf4ffdff5a5995187f Mon Sep 17 00:00:00 2001 From: jean Date: Thu, 25 Sep 2014 09:26:32 +0200 Subject: [PATCH 03/10] adding hook for addMoreActionsbuttons --- htdocs/fourn/commande/card.php | 152 +++++++++++++++++---------------- 1 file changed, 79 insertions(+), 73 deletions(-) diff --git a/htdocs/fourn/commande/card.php b/htdocs/fourn/commande/card.php index ba3cb7e9de0..d0fa34d87ad 100644 --- a/htdocs/fourn/commande/card.php +++ b/htdocs/fourn/commande/card.php @@ -1814,98 +1814,104 @@ elseif (! empty($object->id)) /** * Boutons actions */ - if ($user->societe_id == 0 && $action != 'edit_line' && $action != 'delete') + $parameters = array(); + $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been + // modified by hook + if (empty($reshook)) { - print '
'; - - // Validate - if ($object->statut == 0 && $num > 0) + if ($user->societe_id == 0 && $action != 'edit_line' && $action != 'delete') { - if ($user->rights->fournisseur->commande->valider) + print '
'; + + // Validate + if ($object->statut == 0 && $num > 0) { - print ''.$langs->trans('Validate').''; + if ($user->rights->fournisseur->commande->valider) + { + print ''.$langs->trans('Validate').''; + } } - } - - // Modify - if ($object->statut == 1) - { - if ($user->rights->fournisseur->commande->commander) + + // Modify + if ($object->statut == 1) { - print ''.$langs->trans("Modify").''; + if ($user->rights->fournisseur->commande->commander) + { + print ''.$langs->trans("Modify").''; + } } - } - - // Approve - if ($object->statut == 1) - { - if ($user->rights->fournisseur->commande->approuver) + + // Approve + if ($object->statut == 1) { - print ''.$langs->trans("ApproveOrder").''; - print ''.$langs->trans("RefuseOrder").''; + if ($user->rights->fournisseur->commande->approuver) + { + print ''.$langs->trans("ApproveOrder").''; + print ''.$langs->trans("RefuseOrder").''; + } + else + { + print ''.$langs->trans("ApproveOrder").''; + print ''.$langs->trans("RefuseOrder").''; + } } - else + + // Send + if (in_array($object->statut, array(2, 3, 4, 5))) { - print ''.$langs->trans("ApproveOrder").''; - print ''.$langs->trans("RefuseOrder").''; + if ($user->rights->fournisseur->commande->commander) + { + print ''.$langs->trans('SendByMail').''; + } } - } - - // Send - if (in_array($object->statut, array(2, 3, 4, 5))) - { - if ($user->rights->fournisseur->commande->commander) + + // Reopen + if (in_array($object->statut, array(2, 5, 6, 7, 9))) { - print ''.$langs->trans('SendByMail').''; + if ($user->rights->fournisseur->commande->commander) + { + print ''.$langs->trans("ReOpen").''; + } } - } - - // Reopen - if (in_array($object->statut, array(2, 5, 6, 7, 9))) - { - if ($user->rights->fournisseur->commande->commander) + + // Create bill + if (! empty($conf->fournisseur->enabled) && $object->statut >= 2) // 2 means accepted { - print ''.$langs->trans("ReOpen").''; + if ($user->rights->fournisseur->facture->creer) + { + print ''.$langs->trans("CreateBill").''; + } + + //if ($user->rights->fournisseur->commande->creer && $object->statut > 2) + //{ + // print ''.$langs->trans("ClassifyBilled").''; + //} } - } - - // Create bill - if (! empty($conf->fournisseur->enabled) && $object->statut >= 2) // 2 means accepted - { - if ($user->rights->fournisseur->facture->creer) + + // Cancel + if ($object->statut == 2) { - print ''.$langs->trans("CreateBill").''; + if ($user->rights->fournisseur->commande->commander) + { + print ''.$langs->trans("CancelOrder").''; + } } - - //if ($user->rights->fournisseur->commande->creer && $object->statut > 2) - //{ - // print ''.$langs->trans("ClassifyBilled").''; - //} - } - - // Cancel - if ($object->statut == 2) - { - if ($user->rights->fournisseur->commande->commander) + + // Clone + if ($user->rights->fournisseur->commande->creer) { - print ''.$langs->trans("CancelOrder").''; + print ''.$langs->trans("ToClone").''; } + + // Delete + if ($user->rights->fournisseur->commande->supprimer) + { + print ''.$langs->trans("Delete").''; + } + + print "
"; } - - // Clone - if ($user->rights->fournisseur->commande->creer) - { - print ''.$langs->trans("ToClone").''; - } - - // Delete - if ($user->rights->fournisseur->commande->supprimer) - { - print ''.$langs->trans("Delete").''; - } - - print "
"; } print "
"; From 82a2bb16904b08bedbac160bba136e19c8d65eea Mon Sep 17 00:00:00 2001 From: jean Date: Thu, 25 Sep 2014 17:00:44 +0200 Subject: [PATCH 04/10] list bof orders to process : status validated or in process, or closed but not billed --- htdocs/commande/list.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/htdocs/commande/list.php b/htdocs/commande/list.php index d699192acbf..d285a241b46 100644 --- a/htdocs/commande/list.php +++ b/htdocs/commande/list.php @@ -155,8 +155,9 @@ if ($viewstatut <> '') } if ($viewstatut == -3) // To bill { - $sql.= ' AND c.fk_statut in (1,2,3)'; - $sql.= ' AND c.facture = 0'; // invoice not created + //$sql.= ' AND c.fk_statut in (1,2,3)'; + //$sql.= ' AND c.facture = 0'; // invoice not created + $sql .= ' AND ((c.fk_statut IN (1,2)) OR (c.fk_statut = 3 AND c.facture = 0))'; // validated, in process or closed but not billed } } if ($ordermonth > 0) From 16facc81aa16d5130b4c29ffb6601ac02488477d Mon Sep 17 00:00:00 2001 From: jean Date: Fri, 26 Sep 2014 10:11:38 +0200 Subject: [PATCH 05/10] Add link with order when invoice made for a shioppoing --- htdocs/compta/facture.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php index 00c927bad99..168beb73b43 100644 --- a/htdocs/compta/facture.php +++ b/htdocs/compta/facture.php @@ -865,6 +865,16 @@ else if ($action == 'add' && $user->rights->facture->creer) // Possibility to add external linked objects with hooks $object->linked_objects [$object->origin] = $object->origin_id; + // link with order if it is a shipping invoice + if ($object->origin == 'shipping') + { + require_once DOL_DOCUMENT_ROOT . '/expedition/class/expedition.class.php'; + $exp = new Expedition($db); + $exp->fetch($object->origin_id); + $exp->fetchObjectLinked(); + if (count ($exp->linkedObjectsIds['commande']) > 0) $object->linked_objects['commande'] = $exp->linkedObjectsIds['commande'][0]; + } + if (is_array($_POST['other_linked_objects']) && ! empty($_POST['other_linked_objects'])) { $object->linked_objects = array_merge($object->linked_objects, $_POST['other_linked_objects']); } From 4124ee6bc4118fc5afb9cb265b3d09ea6eccd878 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Mon, 29 Sep 2014 10:28:10 +0200 Subject: [PATCH 06/10] Fix: add model_pdf in fetch of contract object --- htdocs/contrat/class/contrat.class.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/htdocs/contrat/class/contrat.class.php b/htdocs/contrat/class/contrat.class.php index bb7e4b7ec02..0ddb1618f34 100644 --- a/htdocs/contrat/class/contrat.class.php +++ b/htdocs/contrat/class/contrat.class.php @@ -1,7 +1,7 @@ * Copyright (C) 2004-2012 Destailleur Laurent - * Copyright (C) 2005-2012 Regis Houssin + * Copyright (C) 2005-2014 Regis Houssin * Copyright (C) 2006 Andre Cianfarani * Copyright (C) 2008 Raphael Bertrand * Copyright (C) 2010-2014 Juanjo Menent @@ -65,6 +65,7 @@ class Contrat extends CommonObject var $note; // deprecated var $note_private; var $note_public; + var $modelpdf; var $fk_projet; @@ -401,7 +402,7 @@ class Contrat extends CommonObject $sql.= " fk_user_author,"; $sql.= " fk_projet,"; $sql.= " fk_commercial_signature, fk_commercial_suivi,"; - $sql.= " note_private, note_public, extraparams"; + $sql.= " note_private, note_public, model_pdf, extraparams"; $sql.= " ,ref_customer"; $sql.= " ,ref_ext"; $sql.= " FROM ".MAIN_DB_PREFIX."contrat"; @@ -436,6 +437,7 @@ class Contrat extends CommonObject $this->note = $result["note_private"]; // deprecated $this->note_private = $result["note_private"]; $this->note_public = $result["note_public"]; + $this->modelpdf = $result["model_pdf"]; $this->fk_projet = $result["fk_projet"]; // deprecated $this->fk_project = $result["fk_projet"]; From f1f4fc18e9caf36ea46edcdc8da141edf12f9193 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Mon, 29 Sep 2014 11:08:50 +0200 Subject: [PATCH 07/10] Fix: use "doc" instead "pdf" dir and uniformize code --- htdocs/admin/propal.php | 35 +- .../doc_generic_project_odt.modules.php | 2 +- .../modules/project/{pdf => doc}/index.html | 0 .../{pdf => doc}/pdf_baleine.modules.php | 2 +- .../doc_generic_task_odt.modules.php | 48 +-- .../project/task/{pdf => doc}/index.html | 0 htdocs/projet/admin/project.php | 387 ++++++++++-------- htdocs/projet/class/project.class.php | 2 +- htdocs/projet/class/task.class.php | 2 +- test/phpunit/BuildDocTest.php | 2 +- 10 files changed, 255 insertions(+), 225 deletions(-) rename htdocs/core/modules/project/{pdf => doc}/doc_generic_project_odt.modules.php (99%) rename htdocs/core/modules/project/{pdf => doc}/index.html (100%) rename htdocs/core/modules/project/{pdf => doc}/pdf_baleine.modules.php (99%) rename htdocs/core/modules/project/task/{pdf => doc}/doc_generic_task_odt.modules.php (96%) rename htdocs/core/modules/project/task/{pdf => doc}/index.html (100%) diff --git a/htdocs/admin/propal.php b/htdocs/admin/propal.php index 5503a906af2..328866eb964 100644 --- a/htdocs/admin/propal.php +++ b/htdocs/admin/propal.php @@ -171,28 +171,27 @@ if ($action == 'setModuleOptions') $db->begin(); for($i=0;$i < $post_size;$i++) - { - if (array_key_exists('param'.$i,$_POST)) - { - $param=GETPOST("param".$i,'alpha'); - $value=GETPOST("value".$i,'alpha'); - if ($param) $res = dolibarr_set_const($db,$param,$value,'chaine',0,'',$conf->entity); - if (! $res > 0) $error++; - } - } + { + if (array_key_exists('param'.$i,$_POST)) + { + $param=GETPOST("param".$i,'alpha'); + $value=GETPOST("value".$i,'alpha'); + if ($param) $res = dolibarr_set_const($db,$param,$value,'chaine',0,'',$conf->entity); + if (! $res > 0) $error++; + } + } if (! $error) - { - $db->commit(); - setEventMessage($langs->trans("SetupSaved")); - } - else - { - $db->rollback(); - setEventMessage($langs->trans("Error"),'errors'); + { + $db->commit(); + setEventMessage($langs->trans("SetupSaved")); + } + else + { + $db->rollback(); + setEventMessage($langs->trans("Error"),'errors'); } } - // Activate a model if ($action == 'set') { diff --git a/htdocs/core/modules/project/pdf/doc_generic_project_odt.modules.php b/htdocs/core/modules/project/doc/doc_generic_project_odt.modules.php similarity index 99% rename from htdocs/core/modules/project/pdf/doc_generic_project_odt.modules.php rename to htdocs/core/modules/project/doc/doc_generic_project_odt.modules.php index 5b3aa9a85e2..fc18f1068ce 100644 --- a/htdocs/core/modules/project/pdf/doc_generic_project_odt.modules.php +++ b/htdocs/core/modules/project/doc/doc_generic_project_odt.modules.php @@ -19,7 +19,7 @@ */ /** - * \file htdocs/core/modules/project/pdf/doc_generic_project_odt.modules.php + * \file htdocs/core/modules/project/doc/doc_generic_project_odt.modules.php * \ingroup project * \brief File of class to build ODT documents for third parties */ diff --git a/htdocs/core/modules/project/pdf/index.html b/htdocs/core/modules/project/doc/index.html similarity index 100% rename from htdocs/core/modules/project/pdf/index.html rename to htdocs/core/modules/project/doc/index.html diff --git a/htdocs/core/modules/project/pdf/pdf_baleine.modules.php b/htdocs/core/modules/project/doc/pdf_baleine.modules.php similarity index 99% rename from htdocs/core/modules/project/pdf/pdf_baleine.modules.php rename to htdocs/core/modules/project/doc/pdf_baleine.modules.php index 502e98eece2..6ce839daf99 100644 --- a/htdocs/core/modules/project/pdf/pdf_baleine.modules.php +++ b/htdocs/core/modules/project/doc/pdf_baleine.modules.php @@ -17,7 +17,7 @@ */ /** - * \file htdocs/core/modules/project/pdf/pdf_baleine.modules.php + * \file htdocs/core/modules/project/doc/pdf_baleine.modules.php * \ingroup project * \brief Fichier de la classe permettant de generer les projets au modele Baleine * \author Regis Houssin diff --git a/htdocs/core/modules/project/task/pdf/doc_generic_task_odt.modules.php b/htdocs/core/modules/project/task/doc/doc_generic_task_odt.modules.php similarity index 96% rename from htdocs/core/modules/project/task/pdf/doc_generic_task_odt.modules.php rename to htdocs/core/modules/project/task/doc/doc_generic_task_odt.modules.php index acbd33bcc5a..dd70a49f3e1 100644 --- a/htdocs/core/modules/project/task/pdf/doc_generic_task_odt.modules.php +++ b/htdocs/core/modules/project/task/doc/doc_generic_task_odt.modules.php @@ -1,28 +1,28 @@ * Copyright (C) 2012 Juanjo Menent -* Copyright (C) 2013 Florian Henry -* -* 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 . -* or see http://www.gnu.org/ -*/ + * Copyright (C) 2013 Florian Henry + * + * 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 . + * or see http://www.gnu.org/ + */ /** - * \file htdocs/core/modules/project/task/pdf/doc_generic_task_odt.modules.php + * \file htdocs/core/modules/project/task/doc/doc_generic_task_odt.modules.php * \ingroup project * \brief File of class to build ODT documents for third parties -*/ + */ require_once DOL_DOCUMENT_ROOT.'/core/modules/project/modules_project.php'; require_once DOL_DOCUMENT_ROOT.'/core/modules/project/task/modules_task.php'; @@ -304,7 +304,7 @@ class doc_generic_task_odt extends ModelePDFTask $texte = $this->description.".
\n"; $texte.= '
'; $texte.= ''; - $texte.= ''; + $texte.= ''; $texte.= ''; $texte.= ''; @@ -367,7 +367,7 @@ class doc_generic_task_odt extends ModelePDFTask */ function write_file($object,$outputlangs,$srctemplatepath) { - global $user,$langs,$conf,$mysoc; + global $user,$langs,$conf,$mysoc,$hookmanager; if (empty($srctemplatepath)) { @@ -819,8 +819,8 @@ class doc_generic_task_odt extends ModelePDFTask // Call the beforeODTSave hook $parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs); $reshook=$hookmanager->executeHooks('beforeODTSave',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks - - + + // Write new file if (!empty($conf->global->MAIN_ODT_AS_PDF)) { try { @@ -838,9 +838,9 @@ class doc_generic_task_odt extends ModelePDFTask return -1; } } - + $reshook=$hookmanager->executeHooks('afterODTCreation',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks - + if (! empty($conf->global->MAIN_UMASK)) @chmod($file, octdec($conf->global->MAIN_UMASK)); diff --git a/htdocs/core/modules/project/task/pdf/index.html b/htdocs/core/modules/project/task/doc/index.html similarity index 100% rename from htdocs/core/modules/project/task/pdf/index.html rename to htdocs/core/modules/project/task/doc/index.html diff --git a/htdocs/projet/admin/project.php b/htdocs/projet/admin/project.php index a23f65edafb..bf9951129ad 100644 --- a/htdocs/projet/admin/project.php +++ b/htdocs/projet/admin/project.php @@ -1,9 +1,9 @@ - * Copyright (C) 2011 Laurent Destailleur - * Copyright (C) 2011-2012 Juanjo Menent - * Copyright (C) 2011-2013 Philippe Grand - * Copyright (C) 2013 Florian Henry +/* Copyright (C) 2010-2014 Regis Houssin + * Copyright (C) 2011 Laurent Destailleur + * Copyright (C) 2011-2012 Juanjo Menent + * Copyright (C) 2011-2013 Philippe Grand + * Copyright (C) 2013 Florian Henry * * 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 @@ -99,7 +99,7 @@ else if ($action == 'specimen') $dirmodels=array_merge(array('/'),(array) $conf->modules_parts['models']); foreach($dirmodels as $reldir) { - $file=dol_buildpath($reldir."core/modules/project/pdf/pdf_".$modele.".modules.php",0); + $file=dol_buildpath($reldir."core/modules/project/doc/pdf_".$modele.".modules.php",0); if (file_exists($file)) { $filefound=1; @@ -144,7 +144,7 @@ else if ($action == 'specimentask') $dirmodels=array_merge(array('/'),(array) $conf->modules_parts['models']); foreach($dirmodels as $reldir) { - $file=dol_buildpath($reldir."core/modules/project/task/pdf/pdf_".$modele.".modules.php",0); + $file=dol_buildpath($reldir."core/modules/project/task/doc/pdf_".$modele.".modules.php",0); if (file_exists($file)) { $filefound=1; @@ -177,6 +177,35 @@ else if ($action == 'specimentask') } } +// Define constants for submodules that contains parameters (forms with param1, param2, ... and value1, value2, ...) +if ($action == 'setModuleOptions') +{ + $post_size=count($_POST); + + $db->begin(); + + for($i=0;$i < $post_size;$i++) + { + if (array_key_exists('param'.$i,$_POST)) + { + $param=GETPOST("param".$i,'alpha'); + $value=GETPOST("value".$i,'alpha'); + if ($param) $res = dolibarr_set_const($db,$param,$value,'chaine',0,'',$conf->entity); + if (! $res > 0) $error++; + } + } + if (! $error) + { + $db->commit(); + setEventMessage($langs->trans("SetupSaved")); + } + else + { + $db->rollback(); + setEventMessage($langs->trans("Error"),'errors'); + } +} + // Activate a model else if ($action == 'set') { @@ -256,26 +285,10 @@ else if ($action == 'setmodtask') dolibarr_set_const($db, "PROJECT_TASK_ADDON",$value,'chaine',0,'',$conf->entity); } -else if ($action=='setModuleOptions') { - if (dolibarr_set_const($db, "PROJECT_ADDON_PDF_ODT_PATH",GETPOST('value1'),'chaine',0,'',$conf->entity)) - { - // La constante qui a ete lue en avant du nouveau set - // on passe donc par une variable pour avoir un affichage coherent - $conf->global->PROJECT_ADDON_PDF_ODT_PATH = GETPOST('value1'); - } -} -else if ($action=='setModuleOptionsTask') { - if (dolibarr_set_const($db, "PROJECT_TASK_ADDON_PDF_ODT_PATH",GETPOST('value1'),'chaine',0,'',$conf->entity)) - { - // La constante qui a ete lue en avant du nouveau set - // on passe donc par une variable pour avoir un affichage coherent - $conf->global->PROJECT_TASK_ADDON_PDF_ODT_PATH = GETPOST('value1'); - } -} /* * View -*/ + */ $dirmodels=array_merge(array('/'),(array) $conf->modules_parts['models']); @@ -542,99 +555,108 @@ clearstatcache(); $var=true; foreach ($dirmodels as $reldir) { - $dir = dol_buildpath($reldir."core/modules/project/pdf/"); - - if (is_dir($dir)) + foreach (array('','/doc') as $valdir) { - $handle=opendir($dir); - if (is_resource($handle)) + $dir = dol_buildpath($reldir."core/modules/project/".$valdir); + + if (is_dir($dir)) { - while (($file = readdir($handle))!==false) + $handle=opendir($dir); + if (is_resource($handle)) { - if (preg_match('/\.modules\.php$/i',$file) && preg_match('/^(pdf_|doc_)/',$file)) + while (($file = readdir($handle))!==false) { - if (file_exists($dir.'/'.$file)) + $filelist[]=$file; + } + closedir($handle); + arsort($filelist); + + foreach($filelist as $file) + { + if (preg_match('/\.modules\.php$/i',$file) && preg_match('/^(pdf_|doc_)/',$file)) { - $name = substr($file, 4, dol_strlen($file) -16); - $classname = substr($file, 0, dol_strlen($file) -12); - - require_once $dir.'/'.$file; - $module = new $classname($db); - - $modulequalified=1; - if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) $modulequalified=0; - if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) $modulequalified=0; - - if ($modulequalified) + if (file_exists($dir.'/'.$file)) { - $var=!$var; - print '\n"; + $name = substr($file, 4, dol_strlen($file) -16); + $classname = substr($file, 0, dol_strlen($file) -12); - // Active - if (in_array($name, $def)) - { - print ""; - } - else - { - print ""; - } + require_once $dir.'/'.$file; + $module = new $classname($db); - // Default - print "'; + $modulequalified=1; + if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) $modulequalified=0; + if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) $modulequalified=0; - // Info - $htmltooltip = ''.$langs->trans("Name").': '.$module->name; - $htmltooltip.='
'.$langs->trans("Type").': '.($module->type?$module->type:$langs->trans("Unknown")); - if ($module->type == 'pdf') + if ($modulequalified) { - $htmltooltip.='
'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur; - } - $htmltooltip.='

'.$langs->trans("FeaturesSupported").':'; - $htmltooltip.='
'.$langs->trans("Logo").': '.yn($module->option_logo,1,1); - - print ''; + $var=!$var; + print '\n"; - // Preview - print ''; + // Active + if (in_array($name, $def)) + { + print ""; + } + else + { + print ""; + } - print "\n"; - } + // Default + print "'; + + // Info + $htmltooltip = ''.$langs->trans("Name").': '.$module->name; + $htmltooltip.='
'.$langs->trans("Type").': '.($module->type?$module->type:$langs->trans("Unknown")); + if ($module->type == 'pdf') + { + $htmltooltip.='
'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur; + } + $htmltooltip.='

'.$langs->trans("FeaturesSupported").':'; + $htmltooltip.='
'.$langs->trans("Logo").': '.yn($module->option_logo,1,1); + + print ''; + + // Preview + print ''; + + print "\n"; + } + } } } } - closedir($handle); } } } @@ -688,98 +710,107 @@ clearstatcache(); $var=true; foreach ($dirmodels as $reldir) { - $dir = dol_buildpath($reldir."core/modules/project/task/pdf/"); - - if (is_dir($dir)) + foreach (array('','/doc') as $valdir) { - $handle=opendir($dir); - if (is_resource($handle)) + $dir = dol_buildpath($reldir."core/modules/project/task/".$valdir); + + if (is_dir($dir)) { - while (($file = readdir($handle))!==false) + $handle=opendir($dir); + if (is_resource($handle)) { - if (preg_match('/\.modules\.php$/i',$file) && preg_match('/^(pdf_|doc_)/',$file)) + while (($file = readdir($handle))!==false) { - if (file_exists($dir.'/'.$file)) + $filelist[]=$file; + } + closedir($handle); + arsort($filelist); + + foreach($filelist as $file) + { + if (preg_match('/\.modules\.php$/i',$file) && preg_match('/^(pdf_|doc_)/',$file)) { - $name = substr($file, 4, dol_strlen($file) -16); - $classname = substr($file, 0, dol_strlen($file) -12); - - require_once $dir.'/'.$file; - $module = new $classname($db); - - $modulequalified=1; - if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) $modulequalified=0; - if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) $modulequalified=0; - - if ($modulequalified) + if (file_exists($dir.'/'.$file)) { - $var = !$var; - print '\n"; + $name = substr($file, 4, dol_strlen($file) -16); + $classname = substr($file, 0, dol_strlen($file) -12); - // Active - if (in_array($name, $def)) - { - print ""; - } - else - { - print ""; - } + require_once $dir.'/'.$file; + $module = new $classname($db); - // Defaut - print "'; + $modulequalified=1; + if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) $modulequalified=0; + if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) $modulequalified=0; - // Info - $htmltooltip = ''.$langs->trans("Name").': '.$module->name; - $htmltooltip.='
'.$langs->trans("Type").': '.($module->type?$module->type:$langs->trans("Unknown")); - if ($module->type == 'pdf') + if ($modulequalified) { - $htmltooltip.='
'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur; - } - $htmltooltip.='

'.$langs->trans("FeaturesSupported").':'; - $htmltooltip.='
'.$langs->trans("Logo").': '.yn($module->option_logo,1,1); - - print ''; + $var = !$var; + print '\n"; - // Preview - print '"; + } + else + { + print ""; + } + + // Defaut + print "'; + + // Info + $htmltooltip = ''.$langs->trans("Name").': '.$module->name; + $htmltooltip.='
'.$langs->trans("Type").': '.($module->type?$module->type:$langs->trans("Unknown")); + if ($module->type == 'pdf') + { + $htmltooltip.='
'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur; + } + $htmltooltip.='

'.$langs->trans("FeaturesSupported").':'; + $htmltooltip.='
'.$langs->trans("Logo").': '.yn($module->option_logo,1,1); + + print ''; + + // Preview + print ''; + print "\n"; } - else - { - print img_object($langs->trans("PreviewNotAvailable"),'generic'); - } - print ''; - print "\n"; } } } } - closedir($handle); } } } diff --git a/htdocs/projet/class/project.class.php b/htdocs/projet/class/project.class.php index fb7da8636b2..9659eb2ffe8 100644 --- a/htdocs/projet/class/project.class.php +++ b/htdocs/projet/class/project.class.php @@ -1368,7 +1368,7 @@ class Project extends CommonObject } } - $modelpath = "core/modules/project/pdf/"; + $modelpath = "core/modules/project/doc/"; return $this->commonGenerateDocument($modelpath, $modele, $outputlangs, $hidedetails, $hidedesc, $hideref); } diff --git a/htdocs/projet/class/task.class.php b/htdocs/projet/class/task.class.php index 2f4cc85cf7f..13360110310 100644 --- a/htdocs/projet/class/task.class.php +++ b/htdocs/projet/class/task.class.php @@ -1343,7 +1343,7 @@ class Task extends CommonObject } } - $modelpath = "core/modules/project/task/pdf/"; + $modelpath = "core/modules/project/task/doc/"; return $this->commonGenerateDocument($modelpath, $modele, $outputlangs, $hidedetails, $hidedesc, $hideref); } diff --git a/test/phpunit/BuildDocTest.php b/test/phpunit/BuildDocTest.php index 3f20b99fd14..3ed7a6524c7 100644 --- a/test/phpunit/BuildDocTest.php +++ b/test/phpunit/BuildDocTest.php @@ -42,7 +42,7 @@ require_once dirname(__FILE__).'/../../htdocs/core/lib/pdf.lib.php'; require_once dirname(__FILE__).'/../../htdocs/core/modules/facture/doc/pdf_crabe.modules.php'; require_once dirname(__FILE__).'/../../htdocs/core/modules/propale/doc/pdf_azur.modules.php'; require_once dirname(__FILE__).'/../../htdocs/core/modules/commande/doc/pdf_einstein.modules.php'; -require_once dirname(__FILE__).'/../../htdocs/core/modules/project/pdf/pdf_baleine.modules.php'; +require_once dirname(__FILE__).'/../../htdocs/core/modules/project/doc/pdf_baleine.modules.php'; require_once dirname(__FILE__).'/../../htdocs/core/modules/fichinter/doc/pdf_soleil.modules.php'; require_once dirname(__FILE__).'/../../htdocs/core/modules/expedition/doc/pdf_merou.modules.php'; require_once dirname(__FILE__).'/../../htdocs/core/modules/expedition/doc/pdf_rouget.modules.php'; From 8ccb5811858da0fb7111c43a9108b34be6770bb3 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 29 Sep 2014 13:21:03 +0200 Subject: [PATCH 08/10] Fix: Change for php 5.6 New: Management of color into type of events dictionnary (visible into peruser view). New: Can disable predefined type of events. --- ChangeLog | 13 +- htdocs/admin/dict.php | 28 ++- htdocs/comm/action/card.php | 228 +++++++++--------- htdocs/comm/action/class/actioncomm.class.php | 35 +-- htdocs/comm/action/index.php | 12 +- htdocs/comm/action/peruser.php | 44 ++-- htdocs/core/class/commonobject.class.php | 8 +- htdocs/core/class/html.form.class.php | 6 +- htdocs/langs/en_US/admin.lang | 1 + htdocs/langs/en_US/agenda.lang | 3 +- 10 files changed, 204 insertions(+), 174 deletions(-) diff --git a/ChangeLog b/ChangeLog index 841e4b39651..d93f5199c40 100644 --- a/ChangeLog +++ b/ChangeLog @@ -6,12 +6,10 @@ English Dolibarr ChangeLog ***** ChangeLog for 3.7 compared to 3.6.* ***** For users: - New: PDF event report show project and status of event. -- New: Onto event summary of elements, end date and status are visible. - New: Can filter on status on interventions. - New: Add help info of field type into dictionary of payment types. - New: Add proposals into referer page of thirdparty. - New: On contact list can set filter on both active and not active (no more exclusive select). -- New: Each user can include its own external ics calendar into dolibarr agenda view. - New: Intervention documents are now available in ECM module. - New: Can attach supplier order to a customer order. - New: Supervisor is now visible into user list. @@ -22,16 +20,21 @@ For users: - New: No more dependency between contract and service module. - New: [ task #867 ] Remove ESAEB external module code from core. - New: Can create proposal from an intervention. +- New: An event can be assigned to several users. - New: Can filter events on a group of users. - New: Can filter events of a thirdparty. +- New: Onto event summary of elements, end date and status are visible. - New: Split Agenda view (month, week, day) into different tabs. +- New: Add a view "per user" of agenda events (with different colors according to type of event). +- New: Each user can include its own external ics calendar into dolibarr agenda view. +- New: Add event FICHINTER_CLASSIFY_BILLED into list of possible events to + create an automatic event into agenda. +- New: Add new type of event (when type of events are used, not by default). +- New: Can disable predefined type of events. - New: Form to add a photo is immediatly available on photo page if permissions are ok (save one click per photo to add). - New: Add option PRODUCT_MAX_VISIBLE_PHOTO to limit number of photos shown on main product card. -- New: Add event FICHINTER_CLASSIFY_BILLED into list of possible events to - create an automatic event into agenda. -- New: Add new type of event (when type of events are used, not by default). - New: Add country into table of thirdparties type. This will allow to provide a list of thirdparty types specific to a country (like argentina that need type A or B). diff --git a/htdocs/admin/dict.php b/htdocs/admin/dict.php index dd8fa456600..7a84470b320 100644 --- a/htdocs/admin/dict.php +++ b/htdocs/admin/dict.php @@ -1,6 +1,6 @@ - * Copyright (C) 2004-2012 Laurent Destailleur + * Copyright (C) 2004-2014 Laurent Destailleur * Copyright (C) 2004 Benoit Mortier * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2010-2013 Juanjo Menent @@ -375,7 +375,7 @@ $tabfieldcheck[24] = array(); complete_dictionary_with_modules($taborder,$tabname,$tablib,$tabsql,$tabsqlsort,$tabfield,$tabfieldvalue,$tabfieldinsert,$tabrowid,$tabcond,$tabhelp,$tabfieldcheck); -// Define elementList and sourceList (used for dictionary "type of contacts") +// Define elementList and sourceList (used for dictionary type of contacts "llx_c_type_contact") $elementList = array(); $sourceList=array(); if ($id == 11) @@ -412,7 +412,7 @@ if ($id == 11) ); } -// Define localtax_typeList (used for dictionary "c_tva") +// Define localtax_typeList (used for dictionary "llx_c_tva") $localtax_typeList = array(); if ($id == 10) { @@ -425,7 +425,6 @@ if ($id == 10) "5" => $langs->trans("Yes").' ('.$langs->trans("Type")." 5)", //$langs->trans("%ageOnServiceWithoutVAT"), "6" => $langs->trans("Yes").' ('.$langs->trans("Type")." 6)" //$langs->trans("%ageOnServiceBeforeVAT"), ); - if (! empty($conf->global->MAIN_USE_LOCALTAX_TYPE_7)) $localtax_typeList["7"]= $langs->trans("Yes").' ('.$langs->trans("Type")." 7)"; //$langs->trans("AmountOnOrder") // We will enable this later. For the moment, work only of invoice localtype } @@ -445,6 +444,7 @@ if (GETPOST('actionadd') || GETPOST('actionmodify')) if ($value == 'country_id' && in_array($tablib[$id],array('DictionaryRegion','DictionaryCompanyType'))) continue; // For some pages, country is not mandatory if ($value == 'localtax1' && empty($_POST['localtax1_type'])) continue; if ($value == 'localtax2' && empty($_POST['localtax2_type'])) continue; + if ($value == 'color' && empty($_POST['color'])) continue; if ((! isset($_POST[$value]) || $_POST[$value]=='') && (! in_array($listfield[$f], array('decalage','module','accountancy_code','accountancy_code_sell','accountancy_code_buy'))) // Fields that are not mandatory ) @@ -1127,27 +1127,29 @@ if ($id) } } - // Est-ce une entree du dictionnaire qui peut etre desactivee ? - // True by default - $iserasable=1; + // Can an entry be erased or disabled ? + $iserasable=1;$isdisable=1; // true by default if (isset($obj->code)) { - if (($obj->code == '0' || $obj->code == '' || preg_match('/unknown/i',$obj->code))) $iserasable = 0; - else if ($obj->code == 'RECEP') $iserasable = 0; - else if ($obj->code == 'EF0') $iserasable = 0; + if (($obj->code == '0' || $obj->code == '' || preg_match('/unknown/i',$obj->code))) { $iserasable = 0; $isdisable = 0; } + else if ($obj->code == 'RECEP') { $iserasable = 0; $isdisable = 0; } + else if ($obj->code == 'EF0') { $iserasable = 0; $isdisable = 0; } } - if (isset($obj->type) && in_array($obj->type, array('system', 'systemauto'))) $iserasable=0; + if (isset($obj->type) && in_array($obj->type, array('system', 'systemauto'))) { $iserasable=0; } + if (in_array($obj->code, array('AC_OTH','AC_OTH_AUTO')) || in_array($obj->type, array('systemauto'))) { $isdisable=0; $isdisable = 0; } $url = $_SERVER["PHP_SELF"].'?'.($page?'page='.$page.'&':'').'sortfield='.$sortfield.'&sortorder='.$sortorder.'&rowid='.(! empty($obj->rowid)?$obj->rowid:(! empty($obj->code)?$obj->code:'')).'&code='.(! empty($obj->code)?$obj->code:'').'&id='.$id.'&'; // Active print '"; diff --git a/htdocs/comm/action/card.php b/htdocs/comm/action/card.php index 827e2df976a..e92dacc5dc9 100644 --- a/htdocs/comm/action/card.php +++ b/htdocs/comm/action/card.php @@ -35,7 +35,8 @@ require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php'; require_once DOL_DOCUMENT_ROOT.'/comm/action/class/cactioncomm.class.php'; require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php'; -if (! empty($conf->projet->enabled)) { +if (! empty($conf->projet->enabled)) +{ require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php'; } @@ -366,8 +367,8 @@ if ($action == 'update') $object->location = GETPOST('location'); $object->socid = $_POST["socid"]; $object->contactid = $_POST["contactid"]; - $object->societe->id = $_POST["socid"]; // deprecated - $object->contact->id = $_POST["contactid"]; // deprecated + //$object->societe->id = $_POST["socid"]; // deprecated + //$object->contact->id = $_POST["contactid"]; // deprecated $object->fk_project = $_POST["projectid"]; $object->note = $_POST["note"]; $object->pnote = $_POST["note"]; @@ -380,13 +381,14 @@ if ($action == 'update') setEventMessages($langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("DateEnd")),$object->errors,'errors'); $action = 'edit'; } + + $transparency=(GETPOST("transparency")=='on'?1:0); + // Users $listofuserid=array(); - //$assignedtouser=(GETPOST("assignedtouser") >0)?GETPOST("assignedtouser"):(! empty($object->usertodo->id) && $object->usertodo->id > 0 ? $object->usertodo->id : 0); - $assignedtouser=(! empty($object->usertodo->id) && $object->usertodo->id > 0 ? $object->usertodo->id : 0); - if ($assignedtouser) $listofuserid[$assignedtouser]=array('id'=>$assignedtouser, 'mandatory'=>0, 'transparency'=>$object->transparency); // Owner first - - if (! empty($_SESSION['assignedtouser'])) + $assignedtouser=(! empty($object->userownerid) && $object->userownerid > 0 ? $object->userownerid : 0); + if ($assignedtouser) $listofuserid[$assignedtouser]=array('id'=>$assignedtouser, 'mandatory'=>0, 'transparency'=>($user->id == $assignedtouser ? $transparency : '')); // Owner first + if (! empty($_SESSION['assignedtouser'])) // Now concat assigned users { // Restore array with key with same value than param 'id' $tmplist1=dol_json_decode($_SESSION['assignedtouser'], true); $tmplist2=array(); @@ -399,7 +401,7 @@ if ($action == 'update') $object->userassigned=array(); // Clear old content foreach($listofuserid as $key => $val) { - $object->userassigned[$val['id']]=array('id'=>$val['id'], 'mandatory'=>0, 'transparency'=>(GETPOST("transparency")=='on'?1:0)); + $object->userassigned[$val['id']]=array('id'=>$val['id'], 'mandatory'=>0, 'transparency'=>($user->id == $val['id'] ? $transparency : '')); } if (! empty($conf->global->AGENDA_ENABLE_DONEBY)) @@ -670,36 +672,19 @@ if ($action == 'create') $listofuserid=array(); if (empty($donotclearsession)) { - $assignedtouser=GETPOST("assignedtouser")?GETPOST("assignedtouser"):(! empty($object->usertodo->id) && $object->usertodo->id > 0 ? $object->usertodo->id : $user->id); + $assignedtouser=GETPOST("assignedtouser")?GETPOST("assignedtouser"):(! empty($object->userownerid) && $object->userownerid > 0 ? $object->userownerid : $user->id); if ($assignedtouser) $listofuserid[$assignedtouser]=array('id'=>$assignedtouser,'mandatory'=>0,'transparency'=>$object->transparency); // Owner first $_SESSION['assignedtouser']=dol_json_encode($listofuserid); } - /* - if (empty($donotclearsession)) - { - $assignedtouser=GETPOST("assignedtouser")?GETPOST("assignedtouser"):(! empty($object->usertodo->id) && $object->usertodo->id > 0 ? $object->usertodo->id : $user->id); - $_SESSION['assignedtouser']=dol_json_encode(array($assignedtouser=>array('id'=>$assignedtouser,'transparency'=>1,'mandatory'=>1))); - }*/ print $form->select_dolusers_forevent(($action=='create'?'add':'update'),'assignedtouser',1); - //print $form->select_dolusers(GETPOST("assignedtouser")?GETPOST("assignedtouser"):(! empty($object->usertodo->id) && $object->usertodo->id > 0 ? $object->usertodo->id : $user->id),'affectedto',1); - print ''; - - print '
'; - print (empty($module->name)?$name:$module->name); - print "\n"; - if (method_exists($module,'info')) print $module->info($langs); - else print $module->description; - print "\n"; - print 'scandir.'&label='.urlencode($module->name).'">'; - print img_picto($langs->trans("Enabled"),'switch_on'); - print ''; - print "\n"; - print 'scandir.'&label='.urlencode($module->name).'">'.img_picto($langs->trans("Disabled"),'switch_off').''; - print ""; - if ($conf->global->PROJECT_ADDON_PDF == "$name") - { - print img_picto($langs->trans("Default"),'on'); - } - else - { - print 'scandir.'&label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"),'off').''; - } - print ''; - print $form->textwithpicto('',$htmltooltip,1,0); - print '
'; + print (empty($module->name)?$name:$module->name); + print "\n"; + if (method_exists($module,'info')) print $module->info($langs); + else print $module->description; + print "'; - if ($module->type == 'pdf') - { - print ''.img_object($langs->trans("Preview"),'bill').''; - } - else - { - print img_object($langs->trans("PreviewNotAvailable"),'generic'); - } - print '\n"; + print 'scandir.'&label='.urlencode($module->name).'">'; + print img_picto($langs->trans("Enabled"),'switch_on'); + print ''; + print "\n"; + print 'scandir.'&label='.urlencode($module->name).'">'.img_picto($langs->trans("Disabled"),'switch_off').''; + print "
"; + if ($conf->global->PROJECT_ADDON_PDF == "$name") + { + print img_picto($langs->trans("Default"),'on'); + } + else + { + print 'scandir.'&label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"),'off').''; + } + print ''; + print $form->textwithpicto('',$htmltooltip,1,0); + print ''; + if ($module->type == 'pdf') + { + print ''.img_object($langs->trans("Preview"),'bill').''; + } + else + { + print img_object($langs->trans("PreviewNotAvailable"),'generic'); + } + print '
'; - print (empty($module->name)?$name:$module->name); - print "\n"; - if (method_exists($module,'info')) print $module->info($langs); - else print $module->description; - print "\n"; - print 'scandir.'&label='.urlencode($module->name).'">'; - print img_picto($langs->trans("Enabled"),'switch_on'); - print ''; - print "\n"; - print 'scandir.'&label='.urlencode($module->name).'">'.img_picto($langs->trans("Disabled"),'switch_off').''; - print ""; - if ($conf->global->PROJECT_TASK_ADDON_PDF == "$name") - { - print img_picto($langs->trans("Default"),'on'); - } - else - { - print 'scandir.'&label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"),'off').''; - } - print ''; - print $form->textwithpicto('',$htmltooltip,1,0); - print '
'; + print (empty($module->name)?$name:$module->name); + print "\n"; + if (method_exists($module,'info')) print $module->info($langs); + else print $module->description; + print "'; - if ($module->type == 'pdf') - { - print ''.img_object($langs->trans("Preview"),'bill').''; + // Active + if (in_array($name, $def)) + { + print "\n"; + print 'scandir.'&label='.urlencode($module->name).'">'; + print img_picto($langs->trans("Enabled"),'switch_on'); + print ''; + print "\n"; + print 'scandir.'&label='.urlencode($module->name).'">'.img_picto($langs->trans("Disabled"),'switch_off').''; + print ""; + if ($conf->global->PROJECT_TASK_ADDON_PDF == "$name") + { + print img_picto($langs->trans("Default"),'on'); + } + else + { + print 'scandir.'&label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"),'off').''; + } + print ''; + print $form->textwithpicto('',$htmltooltip,1,0); + print ''; + if ($module->type == 'pdf') + { + print ''.img_object($langs->trans("Preview"),'bill').''; + } + else + { + print img_object($langs->trans("PreviewNotAvailable"),'generic'); + } + print '
'; - if ($iserasable) print ''.$actl[$obj->active].''; + if ($isdisable) print ''.$actl[$obj->active].''; else { - if (isset($obj->type) && in_array($obj->type, array('system', 'systemauto')) && empty($obj->active)) print $langs->trans("Deprecated"); + if (in_array($obj->code, array('AC_OTH','AC_OTH_AUTO'))) print $langs->trans("AlwaysActive"); + else if (isset($obj->type) && in_array($obj->type, array('systemauto')) && empty($obj->active)) print $langs->trans("Deprecated"); + else if (isset($obj->type) && in_array($obj->type, array('system')) && ! empty($obj->active) && $obj->code != 'AC_OTH') print $langs->trans("UsedOnlyWithTypeOption"); else print $langs->trans("AlwaysActive"); } print "
'; - - print '

'; - - print ''; - - // Busy - print ''; // Realised by if (! empty($conf->global->AGENDA_ENABLE_DONEBY)) { print ''; } @@ -803,6 +788,7 @@ if ($id > 0) { $result1=$object->fetch($id); $result2=$object->fetch_thirdparty(); + $result2=$object->fetch_contact(); $result3=$object->fetch_userassigned(); $result4=$object->fetch_optionals($id,$extralabels); @@ -812,20 +798,15 @@ if ($id > 0) exit; } - if ($object->author->id > 0) { $tmpuser=new User($db); $res=$tmpuser->fetch($object->author->id); $object->author=$tmpuser; } - if ($object->usermod->id > 0) { $tmpuser=new User($db); $res=$tmpuser->fetch($object->usermod->id); $object->usermod=$tmpuser; } - if ($object->usertodo->id > 0) { $tmpuser=new User($db); $res=$tmpuser->fetch($object->usertodo->id); $object->usertodo=$tmpuser; } - if ($object->userdone->id > 0) { $tmpuser=new User($db); $res=$tmpuser->fetch($object->userdone->id); $object->userdone=$tmpuser; } + if ($object->authorid > 0) { $tmpuser=new User($db); $res=$tmpuser->fetch($object->authorid); $object->author=$tmpuser; } + if ($object->usermodid > 0) { $tmpuser=new User($db); $res=$tmpuser->fetch($object->usermodid); $object->usermod=$tmpuser; } + + if ($object->userownerid > 0) { $tmpuser=new User($db); $res=$tmpuser->fetch($object->userownerid); $object->usertodo=$tmpuser; } + if ($object->userdoneid > 0) { $tmpuser=new User($db); $res=$tmpuser->fetch($object->userdoneid); $object->userdone=$tmpuser; } - $contact = new Contact($db); - if ($object->contact->id) - { - $result=$contact->fetch($object->contact->id,$user); - } - $object->contact = $contact; /* - * Affichage onglets + * Show tabs */ $head=actions_prepare_head($object); @@ -867,7 +848,6 @@ if ($id > 0) print ''."\n"; } - // Fiche action en mode edition print ''; print ''; print ''; @@ -926,30 +906,33 @@ if ($id > 0) $listofuserid=array(); if (empty($donotclearsession)) { - if (is_object($object->usertodo)) $listofuserid[$object->usertodo->id]=array('id'=>$object->usertodo->id,'transparency'=>$object->transparency); // Owner first - $listofuserid=array_merge($listofuserid,$object->userassigned); + if ($object->userownerid > 0) $listofuserid[$object->userownerid]=array('id'=>$object->userownerid,'transparency'=>$object->userassigned[$user->id]['transparency'],'answer_status'=>$object->userassigned[$user->id]['answer_status'],'mandatory'=>$object->userassigned[$user->id]['mandatory']); // Owner first + if (! empty($object->userassigned)) // Now concat assigned users + { + // Restore array with key with same value than param 'id' + $tmplist1=$object->userassigned; $tmplist2=array(); + foreach($tmplist1 as $key => $val) + { + if ($val['id'] && $val['id'] != $object->userownerid) $listofuserid[$val['id']]=$val; + } + } $_SESSION['assignedtouser']=dol_json_encode($listofuserid); } print $form->select_dolusers_forevent(($action=='create'?'add':'update'),'assignedtouser',1); - //print $form->select_dolusers($object->usertodo->id>0?$object->usertodo->id:-1,'assignedtouser',1); - print ''; - - print '
'.$langs->trans("Busy").''; - print ''; + print $langs->trans("MyAvailability").': '.$langs->trans("Busy"); print '
'.$langs->trans("ActionDoneBy").''; - print $form->select_dolusers(GETPOST("doneby")?GETPOST("doneby"):(! empty($object->userdone->id) && $percent==100?$object->userdone->id:0),'doneby',1); + print $form->select_dolusers(GETPOST("doneby")?GETPOST("doneby"):(! empty($object->userdoneid) && $percent==100?$object->userdoneid:0),'doneby',1); print '


'; - - // Busy - print ''; // Realised by if (! empty($conf->global->AGENDA_ENABLE_DONEBY)) { print ''; } - print '
'.$langs->trans("Busy").''; - print 'transparency?' checked="checked"':'').'">'; + print $langs->trans("MyAvailability").': id]['transparency']?' checked="checked"':'').'">'.$langs->trans("Busy"); print '
'.$langs->trans("ActionDoneBy").''; - print $form->select_dolusers($object->userdone->id> 0?$object->userdone->id:-1,'doneby',1); + print $form->select_dolusers($object->userdoneid> 0?$object->userdoneid:-1,'doneby',1); print '


'; + print ''; + + print '

'; print ''; @@ -960,12 +943,12 @@ if ($id > 0) print ''; // Contact print ''; } @@ -979,10 +962,10 @@ if ($id > 0) $langs->load("project"); print ''; } @@ -1056,99 +1039,65 @@ if ($id > 0) if (empty($conf->global->AGENDA_DISABLE_LOCATION)) $rowspan++; // Date start - print ''; - print ''; print ''; // Date end - print ''; // Status - print ''; // Location if (empty($conf->global->AGENDA_DISABLE_LOCATION)) { - print ''; + print ''; } // Assigned to - //if ($object->usertodo->id > 0) print $object->usertodo->getNomUrl(1); - print ''; - - print '
'; $events=array(); $events[]=array('method' => 'getContacts', 'url' => dol_buildpath('/core/ajax/contacts.php',1), 'htmlname' => 'contactid', 'params' => array('add-customer-contact' => 'disabled')); - print $form->select_company($object->thirdparty->id,'socid','',1,1,0,$events); + print $form->select_company($object->socid,'socid','',1,1,0,$events); print ''.$langs->trans("Contact").''; - $form->select_contacts($object->thirdparty->id, $object->contact->id,'contactid',1); + $form->select_contacts($object->socid, $object->contactid,'contactid',1); print '
'.$langs->trans("Project").''; - $numprojet=$formproject->select_projects($object->thirdparty->id,$object->fk_project,'projectid'); + $numprojet=$formproject->select_projects($object->socid,$object->fk_project,'projectid'); if ($numprojet==0) { - print '   '.$langs->trans("AddProject").''; + print '   '.$langs->trans("AddProject").''; } print '
'.$langs->trans("DateActionStart").''; + print '
'.$langs->trans("DateActionStart").''; if (! $object->fulldayevent) print dol_print_date($object->datep,'dayhour'); else print dol_print_date($object->datep,'day'); if ($object->percentage == 0 && $object->datep && $object->datep < ($now - $delay_warning)) print img_warning($langs->trans("Late")); print ''."\n"; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - //print ''; - print img_picto($langs->trans("ViewCal"),'object_calendar','class="hideonsmartphone"').' '; - print ''."\n"; - print '
'; - print ''; - print ''; - print ''; - print ''; - print ''; - //print ''; - print img_picto($langs->trans("ViewCal"),'object_calendarweek','class="hideonsmartphone"').' '; - print '
'."\n"; - print '
'; - print ''; - print ''; - print ''; - print ''; - print ''; - //print ''; - print img_picto($langs->trans("ViewCal"),'object_calendarday','class="hideonsmartphone"').' '; - print '
'."\n"; - print '
'; - print ''; - print ''; - print ''; - print ''; - print ''; - //print ''; - print img_picto($langs->trans("ViewCal"),'object_calendarperuser','class="hideonsmartphone"').' '; - print '
'."\n"; - print '
'.$langs->trans("DateActionEnd").''; + print '
'.$langs->trans("DateActionEnd").''; if (! $object->fulldayevent) print dol_print_date($object->datef,'dayhour'); else print dol_print_date($object->datef,'day'); if ($object->percentage > 0 && $object->percentage < 100 && $object->datef && $object->datef < ($now- $delay_warning)) print img_warning($langs->trans("Late")); print '
'.$langs->trans("Status").' / '.$langs->trans("Percentage").''; + print '
'.$langs->trans("Status").' / '.$langs->trans("Percentage").''; print $object->getLibStatut(4); print '
'.$langs->trans("Location").''.$object->location.'
'.$langs->trans("Location").''.$object->location.'
'.$langs->trans("ActionAffectedTo").''; + print '
'.$langs->trans("ActionAffectedTo").''; $listofuserid=array(); if (empty($donotclearsession)) { - if (is_object($object->usertodo)) $listofuserid[$object->usertodo->id]=array('id'=>$object->usertodo->id,'transparency'=>$object->transparency); // Owner first - $listofuserid=array_merge($listofuserid,$object->userassigned); + if (is_object($object->usertodo)) $listofuserid[$object->userownerid]=array('id'=>$object->userownerid,'transparency'=>$object->transparency); // Owner first + if (! empty($object->userassigned)) // Now concat assigned users + { + // Restore array with key with same value than param 'id' + $tmplist1=$object->userassigned; $tmplist2=array(); + foreach($tmplist1 as $key => $val) + { + if ($val['id'] && $val['id'] != $object->userownerid) $listofuserid[$val['id']]=$val; + } + } $_SESSION['assignedtouser']=dol_json_encode($listofuserid); - //var_dump($_SESSION['assignedtouser']); } print $form->select_dolusers_forevent('view','assignedtouser',1); - print '


'; - - // Busy - print ''; + print $langs->trans("MyAvailability").': '.(($object->userassigned[$user->id]['transparency'] > 0)?$langs->trans("Busy"):$langs->trans("Available")); // We show nothing if event is assigned to nobody + print ' '; // Done by if ($conf->global->AGENDA_ENABLE_DONEBY) { print ''; } - print '
'.$langs->trans("Busy").''; - if ($object->usertodo->id > 0) print yn(($object->transparency > 0)?1:0); // We show nothing if event is assigned to nobody - print '
'.$langs->trans("ActionDoneBy").''; - if ($object->userdone->id > 0) print $object->userdone->getNomUrl(1); + if ($object->userdoneid > 0) print $object->userdone->getNomUrl(1); print '


'; + print '
'; + + print '

'; + + print ''; // Third party - Contact if ($conf->societe->enabled) @@ -1164,12 +1113,12 @@ if ($id > 0) print ''; print ''; print '
'.$langs->trans("Contact").''; - if ($object->contact->id > 0) + if ($object->contactid > 0) { print $object->contact->getNomUrl(1); - if ($object->contact->id && $object->type_code == 'AC_TEL') + if ($object->contactid && $object->type_code == 'AC_TEL') { - if ($object->contact->fetch($object->contact->id)) + if ($object->contact->fetch($object->contactid)) { print "
".dol_print_phone($object->contact->phone_pro); } @@ -1250,7 +1199,7 @@ if ($id > 0) if ($action != 'edit') { if ($user->rights->agenda->allactions->create || - (($object->author->id == $user->id || $object->usertodo->id == $user->id) && $user->rights->agenda->myactions->create)) + (($object->authorid == $user->id || $object->userownerid == $user->id) && $user->rights->agenda->myactions->create)) { print ''; } @@ -1260,7 +1209,7 @@ if ($id > 0) } if ($user->rights->agenda->allactions->delete || - (($object->author->id == $user->id || $object->usertodo->id == $user->id) && $user->rights->agenda->myactions->delete)) + (($object->authorid == $user->id || $object->userownerid == $user->id) && $user->rights->agenda->myactions->delete)) { print ''; } @@ -1272,6 +1221,47 @@ if ($id > 0) } print ''; + + + // Link to agenda views + print '
'; + print '
'; + print ''; + print ''; + print ''; + print ''; + print ''; + //print ''; + print img_picto($langs->trans("ViewCal"),'object_calendar','class="hideonsmartphone"').' '; + print '
'."\n"; + print '
'; + print ''; + print ''; + print ''; + print ''; + print ''; + //print ''; + print img_picto($langs->trans("ViewCal"),'object_calendarweek','class="hideonsmartphone"').' '; + print '
'."\n"; + print '
'; + print ''; + print ''; + print ''; + print ''; + print ''; + //print ''; + print img_picto($langs->trans("ViewCal"),'object_calendarday','class="hideonsmartphone"').' '; + print '
'."\n"; + print '
'; + print ''; + print ''; + print ''; + print ''; + print ''; + //print ''; + print img_picto($langs->trans("ViewCal"),'object_calendarperuser','class="hideonsmartphone"').' '; + print '
'."\n"; + print '
'; } diff --git a/htdocs/comm/action/class/actioncomm.class.php b/htdocs/comm/action/class/actioncomm.class.php index 773fdb48b0f..fc75488ee3d 100644 --- a/htdocs/comm/action/class/actioncomm.class.php +++ b/htdocs/comm/action/class/actioncomm.class.php @@ -39,9 +39,10 @@ class ActionComm extends CommonObject var $id; - var $type_id; // id into parent table llx_c_actioncomm (will be deprecated into future, link should not be required) - var $type_code; // code into parent table llx_c_actioncomm (will be deprecated into future, link should not be required). With defautl setup, should be AC_OTH_AUTO or AC_OTH - var $type; // label into parent table llx_c_actioncomm (will be deprecated into future, link should not be required) + var $type_id; // Id into parent table llx_c_actioncomm (used only if option to use type is set) + var $type_code; // Code into parent table llx_c_actioncomm (used only if option to use type is set). With default setup, should be AC_OTH_AUTO or AC_OTH. + var $type; // Label into parent table llx_c_actioncomm (used only if option to use type is set) + var $type_color; // Color into parent table llx_c_actioncomm (used only if option to use type is set) var $code; // Free code to identify action. Ie: Agenda trigger add here AC_TRIGGERNAME ('AC_COMPANY_CREATE', 'AC_PROPAL_VALIDATE', ...) var $label; @@ -56,7 +57,7 @@ class ActionComm extends CommonObject var $datef; // Date action end (datep2) var $durationp = -1; // -1=Unkown duration // deprecated var $fulldayevent = 0; // 1=Event on full day - var $punctual = 1; // Milestone + var $punctual = 1; // Milestone // TODO Not sure we need this. Milestone is already event with end date = start date var $percentage; // Percentage var $location; // Location @@ -66,7 +67,8 @@ class ActionComm extends CommonObject var $userassigned = array(); // Array of user ids var $userownerid; // Id of user owner - var $usertodo; // Object user of owner // deprecated + var $userdoneid; // Id of user done + var $usertodo; // Object user of owner // deprecated var $userdone; // Object user that did action // deprecated var $socid; @@ -352,25 +354,29 @@ class ActionComm extends CommonObject $this->note = $obj->note; $this->percentage = $obj->percentage; - $this->author->id = $obj->fk_user_author; - $this->author->firstname = $obj->firstname; - $this->author->lastname = $obj->lastname; - $this->usermod->id = $obj->fk_user_mod; + $this->authorid = $obj->fk_user_author; + $this->usermodid = $obj->fk_user_mod; + $this->author->id = $obj->fk_user_author; // deprecated + $this->author->firstname = $obj->firstname; // deprecated + $this->author->lastname = $obj->lastname; // deprecated + $this->usermod->id = $obj->fk_user_mod; // deprecated $this->userownerid = $obj->fk_user_action; + $this->userdoneid = $obj->fk_user_done; $this->usertodo->id = $obj->fk_user_action; // deprecated - //$this->userdone->id = $obj->fk_user_done; + $this->userdone->id = $obj->fk_user_done; // deprecated $this->priority = $obj->priority; $this->fulldayevent = $obj->fulldayevent; $this->location = $obj->location; $this->transparency = $obj->transparency; + $this->punctual = $obj->punctual; $this->socid = $obj->fk_soc; // To have fetch_thirdparty method working - $this->contactid = $obj->fk_contact; + $this->contactid = $obj->fk_contact; // To have fetch_contact method working $this->fk_project = $obj->fk_project; // To have fetch_project method working - $this->societe->id = $obj->fk_soc; // For backward compatibility - $this->contact->id = $obj->fk_contact; // For backward compatibility + $this->societe->id = $obj->fk_soc; // deprecated + $this->contact->id = $obj->fk_contact; // deprecated $this->fk_element = $obj->fk_element; $this->elementtype = $obj->elementtype; @@ -1041,6 +1047,7 @@ class ActionComm extends CommonObject $event['fulldayevent']=$obj->fulldayevent; $event['location']=$obj->location; $event['transparency']=(($obj->transparency > 0)?'OPAQUE':'TRANSPARENT'); // OPAQUE (busy) or TRANSPARENT (not busy) + $event['punctual']=$obj->punctual; $event['category']=$obj->libelle; // libelle type action // Define $urlwithroot $urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT,'/').'$/i','',trim($dolibarr_main_url_root)); @@ -1146,7 +1153,7 @@ class ActionComm extends CommonObject $this->punctual=0; $this->percentage=0; $this->location='Location'; - $this->transparency=0; + $this->transparency=1; // 1 means opaque $this->priority=1; $this->note = 'Note'; } diff --git a/htdocs/comm/action/index.php b/htdocs/comm/action/index.php index 24502897ec1..a1c03a7f15e 100644 --- a/htdocs/comm/action/index.php +++ b/htdocs/comm/action/index.php @@ -1140,7 +1140,7 @@ function show_day_events($db, $day, $month, $year, $monthshown, $style, &$eventa $ponct=($event->date_start_in_calendar == $event->date_end_in_calendar); - // Define $color and $cssclass of event + // Define $color (Hex string like '0088FF') and $cssclass of event $color=-1; $cssclass=''; $colorindex=-1; if (in_array($user->id, $keysofuserassigned)) { @@ -1163,8 +1163,14 @@ function show_day_events($db, $day, $month, $year, $monthshown, $style, &$eventa $color=$event->icalcolor; $cssclass=(! empty($event->icalname)?'family_'.dol_string_nospecial($event->icalname):'family_other unsortable'); } - else if ($event->type_code == 'BIRTHDAY') { $numbirthday++; $colorindex=2; $cssclass='family_birthday unsortable'; $color=sprintf("%02x%02x%02x",$theme_datacolor[$colorindex][0],$theme_datacolor[$colorindex][1],$theme_datacolor[$colorindex][2]); } - else { $numother++; $cssclass='family_other'; } + else if ($event->type_code == 'BIRTHDAY') + { + $numbirthday++; $colorindex=2; $cssclass='family_birthday unsortable'; $color=sprintf("%02x%02x%02x",$theme_datacolor[$colorindex][0],$theme_datacolor[$colorindex][1],$theme_datacolor[$colorindex][2]); + } + else + { + $numother++; $cssclass='family_other'; + } if ($color == -1) // Color was not forced. Set color according to color index. { // Define color index if not yet defined diff --git a/htdocs/comm/action/peruser.php b/htdocs/comm/action/peruser.php index 54dada1ff52..ad3bfddd2ef 100644 --- a/htdocs/comm/action/peruser.php +++ b/htdocs/comm/action/peruser.php @@ -108,7 +108,7 @@ $begin_d = GETPOST('begin_d')?GETPOST('begin_d','int'):($tmparray[0] != '' ? $tm $end_d = GETPOST('end_d')?GETPOST('end_d'):($tmparray[1] != '' ? $tmparray[1] : 5); if ($begin_d < 1 || $begin_d > 7) $begin_d = 1; if ($end_d < 1 || $end_d > 7) $end_d = 7; -if ($end_d <= $begin_d) $end_d = $begin_d + 1; +if ($end_d < $begin_d) $end_d = $begin_d + 1; if ($actioncode == '') $actioncode=(empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE)?'':$conf->global->AGENDA_DEFAULT_FILTER_TYPE); if ($status == '' && ! isset($_GET['status']) && ! isset($_POST['status'])) $status=(empty($conf->global->AGENDA_DEFAULT_FILTER_STATUS)?'':$conf->global->AGENDA_DEFAULT_FILTER_STATUS); @@ -321,7 +321,7 @@ $sql.= ' a.percent,'; $sql.= ' a.fk_user_author,a.fk_user_action,a.fk_user_done,'; $sql.= ' a.transparency, a.priority, a.fulldayevent, a.location,'; $sql.= ' a.fk_soc, a.fk_contact,'; -$sql.= ' ca.code'; +$sql.= ' ca.code, ca.color'; $sql.= ' FROM '.MAIN_DB_PREFIX.'c_actioncomm as ca, '.MAIN_DB_PREFIX."actioncomm as a"; if (! $user->rights->societe->client->voir && ! $socid) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON a.fk_soc = sc.fk_soc"; if ($usergroup > 0) $sql.= ", ".MAIN_DB_PREFIX."usergroup_user as ugu"; @@ -396,6 +396,7 @@ if ($resql) $event->datep=$db->jdate($obj->datep); // datep and datef are GMT date $event->datef=$db->jdate($obj->datep2); $event->type_code=$obj->code; + $event->type_color=$obj->color; //$event->libelle=$obj->label; // deprecated $event->label=$obj->label; $event->percentage=$obj->percent; @@ -665,7 +666,7 @@ jQuery(document).ready(function() { else if (ids.indexOf(",") > -1) /* There is several events */ { /* alert(\'several events\'); */ - url = "'.DOL_URL_ROOT.'/comm/action/listactions.php?usertodo="+userid + url = "'.DOL_URL_ROOT.'/comm/action/listactions.php?usertodo="+userid+"&dateselectyear="+year+"&dateselectmonth="+month+"&dateselectday="+dateselectday; window.location.href = url; } else /* One event */ @@ -744,12 +745,12 @@ function show_day_events2($username, $day, $month, $year, $monthshown, $style, & $ponct=($event->date_start_in_calendar == $event->date_end_in_calendar); - // Define $color and $cssclass of event + // Define $color (Hex string like '0088FF') and $cssclass of event $color=-1; $cssclass=''; $colorindex=-1; if (in_array($user->id, $keysofuserassigned)) { $nummytasks++; $cssclass='family_mytasks'; - // TODO Set color according to event type + $color=$event->type_color; } else if ($event->type_code == 'ICALEVENT') { @@ -760,15 +761,19 @@ function show_day_events2($username, $day, $month, $year, $monthshown, $style, & } $numicals[dol_string_nospecial($event->icalname)]++; } + $color=$event->icalcolor; $cssclass=(! empty($event->icalname)?'family_'.dol_string_nospecial($event->icalname):'family_other unsortable'); } - else if ($event->type_code == 'BIRTHDAY') { + else if ($event->type_code == 'BIRTHDAY') + { $numbirthday++; $colorindex=2; $cssclass='family_birthday unsortable'; $color=sprintf("%02x%02x%02x",$theme_datacolor[$colorindex][0],$theme_datacolor[$colorindex][1],$theme_datacolor[$colorindex][2]); } - else { $numother++; $cssclass='family_other'; + else + { + $numother++; $cssclass='family_other'; } - if ($color == -1) // Color was not forced. Set color according to color index. + if ($color < 0) // Color was not forced. Set color according to color index. { // Define color index if not yet defined $idusertouse=($event->userownerid?$event->userownerid:0); @@ -791,7 +796,7 @@ function show_day_events2($username, $day, $month, $year, $monthshown, $style, & for ($h = $begin_h; $h < $end_h; $h++) { //if ($username->id == 1 && $day==1) print 'h='.$h; - $color = ''; //init + $newcolor = ''; //init if (empty($event->fulldayevent)) { $a = dol_mktime((int) $h,0,0,$month,$day,$year,false,false); @@ -801,6 +806,8 @@ function show_day_events2($username, $day, $month, $year, $monthshown, $style, & $dateendtouse=$event->date_end_in_calendar; if ($dateendtouse==$event->date_start_in_calendar) $dateendtouse++; + //print dol_print_date($event->date_start_in_calendar,'dayhour').'-'.dol_print_date($a,'dayhour').'-'.dol_print_date($b,'dayhour').'
'; + if ($event->date_start_in_calendar < $b && $dateendtouse > $a) { $busy=$event->transparency; @@ -817,8 +824,9 @@ function show_day_events2($username, $day, $month, $year, $monthshown, $style, & $cases1[$h][$event->id]['typecode']=$event->type_code; if ($event->socid) { - $cases1[$h][$event->id]['string'].='xxx'; + //$cases1[$h][$event->id]['string'].='xxx'; } + $cases1[$h][$event->id]['color']=$color; } if ($event->date_start_in_calendar < $c && $dateendtouse > $b) { @@ -836,8 +844,9 @@ function show_day_events2($username, $day, $month, $year, $monthshown, $style, & $cases2[$h][$event->id]['typecode']=$event->type_code; if ($event->socid) { - $cases2[$h][$event->id]['string'].='xxx'; + //$cases2[$h][$event->id]['string'].='xxx'; } + $cases2[$h][$event->id]['color']=$color; } } else @@ -849,7 +858,8 @@ function show_day_events2($username, $day, $month, $year, $monthshown, $style, & $cases2[$h][$event->id]['string']=$event->label; $cases1[$h][$event->id]['typecode']=$event->type_code; $cases2[$h][$event->id]['typecode']=$event->type_code; - //break; + $cases1[$h][$event->id]['color']='009900'; + $cases2[$h][$event->id]['color']='009900'; } } $i++; @@ -861,6 +871,7 @@ function show_day_events2($username, $day, $month, $year, $monthshown, $style, & for ($h = $begin_h; $h < $end_h; $h++) { + $color1='';$color2=''; $style1='';$style2=''; $string1=' ';$string2=' '; $title1='';$title2=''; @@ -893,20 +904,25 @@ function show_day_events2($username, $day, $month, $year, $monthshown, $style, & $ids=array_keys($cases1[$h]); $output = array_slice($cases1[$h], 0, 1); if ($output[0]['string']) $title1.=' - '.$output[0]['string']; + if ($output[0]['color']) $color1 = $output[0]['color']; } + else if (count($cases1[$h]) > 1) $color1='222222'; + if (count($cases2[$h]) == 1) // 1 seul evenement { $ids=array_keys($cases2[$h]); $output = array_slice($cases2[$h], 0, 1); if ($output[0]['string']) $title2.=' - '.$output[0]['string']; + if ($output[0]['color']) $color2 = $output[0]['color']; } + else if (count($cases2[$h]) > 1) $color2='222222'; $ids1=join(',',array_keys($cases1[$h])); $ids2=join(',',array_keys($cases2[$h])); //var_dump($cases1[$h]); print ''; - print ''; print '
'; + print '
'; print $string1; - print ''; + print ''; print $string2; print '
'; diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index e8dcce57ac4..f65136ec81d 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -577,11 +577,15 @@ abstract class CommonObject /** * Charge le contact d'id $id dans this->contact * - * @param int $contactid Id du contact + * @param int $contactid Id du contact. Use this->contactid if empty. * @return int <0 if KO, >0 if OK */ - function fetch_contact($contactid) + function fetch_contact($contactid='') { + if (empty($contactid)) $contactid=$this->contactid; + + if (empty($contactid)) return 0; + require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php'; $contact = new Contact($this->db); $result=$contact->fetch($contactid); diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 8b6b656417e..33b1d42ca08 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -1329,9 +1329,9 @@ class Form { $assignedtouser=dol_json_decode($_SESSION['assignedtouser'], true); } - $numassignetouser=count($assignedtouser); + $nbassignetouser=count($assignedtouser); - if ($numassignetouser && $action != 'view') $out.='
'; + if ($nbassignetouser && $action != 'view') $out.='
'; $i=0; $ownerid=0; foreach($assignedtouser as $key => $value) { @@ -1339,7 +1339,7 @@ class Form $userstatic->fetch($value['id']); $out.=$userstatic->getNomUrl(1); if ($i == 0) { $ownerid = $value['id']; $out.=' ('.$langs->trans("Owner").')'; } - if ($numassignetouser > 1 && $action != 'view') $out.=' '; + if ($nbassignetouser > 1 && $action != 'view') $out.=' '; //$out.=' '.($value['mandatory']?$langs->trans("Mandatory"):$langs->trans("Optional")); //$out.=' '.($value['transparency']?$langs->trans("Busy"):$langs->trans("NotBusy")); $out.='
'; diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index 13003ea5cf3..5d67dc0b38e 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -219,6 +219,7 @@ AutomaticIfJavascriptDisabled=Automatic if Javascript is disabled AvailableOnlyIfJavascriptNotDisabled=Available only if JavaScript is not disabled AvailableOnlyIfJavascriptAndAjaxNotDisabled=Available only if JavaScript is not disabled Required=Required +UsedOnlyWithTypeOption=Used by some agenda option only Security=Security Passwords=Passwords DoNotStoreClearPassword=Do no store clear passwords in database but store only encrypted value (Activated recommended) diff --git a/htdocs/langs/en_US/agenda.lang b/htdocs/langs/en_US/agenda.lang index c4c332336d2..dd793c7bfdd 100644 --- a/htdocs/langs/en_US/agenda.lang +++ b/htdocs/langs/en_US/agenda.lang @@ -88,4 +88,5 @@ ExtSiteUrlAgenda=URL to access .ical file ExtSiteNoLabel=No Description WorkingTimeRange=Working time range WorkingDaysRange=Working days range -AddEvent=Create event \ No newline at end of file +AddEvent=Create event +MyAvailability=Ma disponibilité \ No newline at end of file From c5a7dfbabb36c3af7bda87de84ab6c738b860a09 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Mon, 29 Sep 2014 14:40:02 +0200 Subject: [PATCH 09/10] Fix: Add current context for avoid method execution in bad context, you can add this test in your method : eg if($currentcontext != 'formfile') return; --- htdocs/core/class/hookmanager.class.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/htdocs/core/class/hookmanager.class.php b/htdocs/core/class/hookmanager.class.php index 9d8ce90e812..52dc25dd452 100644 --- a/htdocs/core/class/hookmanager.class.php +++ b/htdocs/core/class/hookmanager.class.php @@ -1,6 +1,6 @@ - * Copyright (C) 2010-2012 Regis Houssin + * Copyright (C) 2010-2014 Regis Houssin * Copyright (C) 2010-2011 Juanjo Menent * * This program is free software; you can redistribute it and/or modify @@ -152,7 +152,7 @@ class HookManager $modulealreadyexecuted=array(); $resaction=0; $error=0; $result=''; $this->resPrint=''; $this->resArray=array(); - foreach($this->hooks as $modules) // this->hooks is an array with context as key and value is an array of modules that handle this context + foreach($this->hooks as $context => $modules) // this->hooks is an array with context as key and value is an array of modules that handle this context { if (! empty($modules)) { @@ -166,6 +166,8 @@ class HookManager // test to avoid to run twice a hook, when a module implements several active contexts if (in_array($module,$modulealreadyexecuted)) continue; $modulealreadyexecuted[$module]=$module; + // Add current context for avoid method execution in bad context, you can add this test in your method : eg if($currentcontext != 'formfile') return; + $parameters['currentcontext'] = $context; // Hooks that must return int (hooks with type 'addreplace') if ($hooktype == 'addreplace') { From 3d82f0965ec3747002232d821f7a8e1087126dfd Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Mon, 29 Sep 2014 15:20:54 +0200 Subject: [PATCH 10/10] Fix: Try to filter by context, use the test with $currentcontext in method for avoid to run twice (I have not found any other solution!) --- htdocs/core/class/hookmanager.class.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/htdocs/core/class/hookmanager.class.php b/htdocs/core/class/hookmanager.class.php index 52dc25dd452..c402353e8d7 100644 --- a/htdocs/core/class/hookmanager.class.php +++ b/htdocs/core/class/hookmanager.class.php @@ -156,6 +156,8 @@ class HookManager { if (! empty($modules)) { + $modulealreadyexecuted[$context]=array(); // Filter by context + foreach($modules as $module => $actionclassinstance) { //print "Before hook ".get_class($actionclassinstance)." method=".$method." hooktype=".$hooktype." results=".count($actionclassinstance->results)." resprints=".count($actionclassinstance->resprints)." resaction=".$resaction." result=".$result."
\n"; @@ -164,8 +166,8 @@ class HookManager // jump to next class if method does not exists if (! method_exists($actionclassinstance,$method)) continue; // test to avoid to run twice a hook, when a module implements several active contexts - if (in_array($module,$modulealreadyexecuted)) continue; - $modulealreadyexecuted[$module]=$module; + if (in_array($module,$modulealreadyexecuted[$context])) continue; + $modulealreadyexecuted[$context][$module]=$module; // Use the $currentcontext in method for avoid to run twice // Add current context for avoid method execution in bad context, you can add this test in your method : eg if($currentcontext != 'formfile') return; $parameters['currentcontext'] = $context; // Hooks that must return int (hooks with type 'addreplace')