diff --git a/dev/skeletons/skeleton_page.php b/dev/skeletons/skeleton_page.php index 9e6d76ee6d8..334980b1470 100644 --- a/dev/skeletons/skeleton_page.php +++ b/dev/skeletons/skeleton_page.php @@ -1,5 +1,5 @@ +/* Copyright (C) 2007-2015 Laurent Destailleur * Copyright (C) ---Put here your own copyright and developer email--- * * This program is free software; you can redistribute it and/or modify @@ -72,6 +72,9 @@ if (($id > 0 || ! empty($ref)) && $action != 'add') if ($result < 0) dol_print_error($db); } +// Initialize technical object to manage hooks of modules. Note that conf->hooks_modules contains array array +$hookmanager->initHooks(array('skeleton')); + /******************************************************************* @@ -80,108 +83,114 @@ if (($id > 0 || ! empty($ref)) && $action != 'add') * Put here all code to do according to value of "action" parameter ********************************************************************/ -// Action to add record -if ($action == 'add') +$parameters=array(); +$reshook=$hookmanager->executeHooks('doActions',$parameters); // Note that $action and $object may have been modified by some hooks +if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + +if (empty($reshook)) { - if (GETPOST('cancel')) + // Action to add record + if ($action == 'add') { - $urltogo=$backtopage?$backtopage:dol_buildpath('/buildingmanagement/list.php',1); - header("Location: ".$urltogo); - exit; - } - - $error=0; - - /* object_prop_getpost_prop */ - $object->prop1=GETPOST("field1"); - $object->prop2=GETPOST("field2"); - - if (empty($object->ref)) - { - $error++; - setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Ref")),'errors'); - } - - if (! $error) - { - $result=$object->create($user); - if ($result > 0) + if (GETPOST('cancel')) { - // Creation OK - $urltogo=$backtopage?$backtopage:dol_buildpath('/mymodule/list.php',1); + $urltogo=$backtopage?$backtopage:dol_buildpath('/buildingmanagement/list.php',1); header("Location: ".$urltogo); exit; } + + $error=0; + + /* object_prop_getpost_prop */ + $object->prop1=GETPOST("field1"); + $object->prop2=GETPOST("field2"); + + if (empty($object->ref)) { - // Creation KO - if (! empty($object->errors)) setEventMessages(null, $object->errors, 'errors'); - else setEventMessages($object->error, null, 'errors'); - $action='create'; + $error++; + setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Ref")),'errors'); } - } - else - { - $action='create'; - } -} -// Cancel -if ($action == 'update' && GETPOST('cancel')) $action='view'; - -// Action to update record -if ($action == 'update' && ! GETPOST('cancel')) -{ - $error=0; - - $object->prop1=GETPOST("field1"); - $object->prop2=GETPOST("field2"); - - if (empty($object->ref)) - { - $error++; - setEventMessages($langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Ref")),null,'errors'); - } - - if (! $error) - { - $result=$object->update($user); - if ($result > 0) + if (! $error) { - $action='view'; + $result=$object->create($user); + if ($result > 0) + { + // Creation OK + $urltogo=$backtopage?$backtopage:dol_buildpath('/mymodule/list.php',1); + header("Location: ".$urltogo); + exit; + } + { + // Creation KO + if (! empty($object->errors)) setEventMessages(null, $object->errors, 'errors'); + else setEventMessages($object->error, null, 'errors'); + $action='create'; + } + } + else + { + $action='create'; + } + } + + // Cancel + if ($action == 'update' && GETPOST('cancel')) $action='view'; + + // Action to update record + if ($action == 'update' && ! GETPOST('cancel')) + { + $error=0; + + $object->prop1=GETPOST("field1"); + $object->prop2=GETPOST("field2"); + + if (empty($object->ref)) + { + $error++; + setEventMessages($langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Ref")),null,'errors'); + } + + if (! $error) + { + $result=$object->update($user); + if ($result > 0) + { + $action='view'; + } + else + { + // Creation KO + if (! empty($object->errors)) setEventMessages(null, $object->errors, 'errors'); + else setEventMessages($object->error, null, 'errors'); + $action='edit'; + } } else { - // Creation KO - if (! empty($object->errors)) setEventMessages(null, $object->errors, 'errors'); - else setEventMessages($object->error, null, 'errors'); $action='edit'; } } - else + + // Action to delete + if ($action == 'confirm_delete') { - $action='edit'; + $result=$object->delete($user); + if ($result > 0) + { + // Delete OK + setEventMessages($langs->trans("RecordDeleted"), null, 'mesgs'); + header("Location: ".dol_buildpath('/buildingmanagement/list.php',1)); + exit; + } + else + { + if (! empty($object->errors)) setEventMessages(null,$object->errors,'errors'); + else setEventMessages($object->error,null,'errors'); + } } } -// Action to delete -if ($action == 'confirm_delete') -{ - $result=$object->delete($user); - if ($result > 0) - { - // Delete OK - setEventMessages($langs->trans("RecordDeleted"), null, 'mesgs'); - header("Location: ".dol_buildpath('/buildingmanagement/list.php',1)); - exit; - } - else - { - if (! empty($object->errors)) setEventMessages(null,$object->errors,'errors'); - else setEventMessages($object->error,null,'errors'); - } -} - - @@ -225,11 +234,39 @@ if ($action == 'list' || empty($id)) $sql.= " WHERE field3 = 'xxx'"; $sql.= " ORDER BY field1 ASC"; - print ''."\n"; + print ''; + + if (! empty($moreforfilter)) + { + print '
'; + print $moreforfilter; + $parameters=array(); + $formconfirm=$hookmanager->executeHooks('printFieldPreListTitle',$parameters); // Note that $action and $object may have been modified by hook + print '
'; + } + + print '
'."\n"; + + // Fields title print ''; print_liste_field_titre($langs->trans('field1'),$_SERVER['PHP_SELF'],'t.field1','',$param,'',$sortfield,$sortorder); print_liste_field_titre($langs->trans('field2'),$_SERVER['PHP_SELF'],'t.field2','',$param,'',$sortfield,$sortorder); - print ''; + $parameters=array(); + $formconfirm=$hookmanager->executeHooks('printFieldListTitle',$parameters); // Note that $action and $object may have been modified by hook + print ''."\n"; + + // Fields title search + print ''; + print ''; + print ''; + $parameters=array(); + $formconfirm=$hookmanager->executeHooks('printFieldListOption',$parameters); // Note that $action and $object may have been modified by hook + print ''."\n"; + dol_syslog($script_file, LOG_DEBUG); $resql=$db->query($sql); @@ -243,21 +280,32 @@ if ($action == 'list' || empty($id)) if ($obj) { // You can use here results - print ''; + print ''; + print ''; + $parameters=array('obj' => $obj); + $formconfirm=$hookmanager->executeHooks('printFieldListValue',$parameters); // Note that $action and $object may have been modified by hook + print ''; } $i++; } } else - { + { $error++; dol_print_error($db); } - print '
'; + print ''; + print ''; + print ''; + print '
'; + print '
'; print $obj->field1; + print ''; print $obj->field2; - print '
'."\n"; + $db->free($resql); + + $parameters=array('sql' => $sql); + $formconfirm=$hookmanager->executeHooks('printFieldListFooter',$parameters); // Note that $action and $object may have been modified by hook + + print "\n"; + print "\n"; } @@ -267,12 +315,12 @@ if ($action == 'create') { print_fiche_titre($langs->trans("NewResidence")); - dol_fiche_head(); - print '
'; print ''; print ''; + dol_fiche_head(); + print ''."\n"; print '
'.$langs->trans("Label").''; print ''; @@ -280,13 +328,11 @@ if ($action == 'create') print '
'."\n"; - print '
'; + dol_fiche_end(); print '
 
'; print '
'; - - dol_fiche_end(); } @@ -294,21 +340,19 @@ if ($action == 'create') // Part to edit record if (($id || $ref) && $action == 'edit') { + print '
'; + dol_fiche_head(); - print ''; print ''; print ''; print ''; - - print '
'; + dol_fiche_end(); print '
'; print '
'; - - dol_fiche_end(); } diff --git a/htdocs/comm/list.php b/htdocs/comm/list.php index a82413e9d4f..cf5bacc5e25 100644 --- a/htdocs/comm/list.php +++ b/htdocs/comm/list.php @@ -92,6 +92,7 @@ if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter")) // Both if ($search_status=='') $search_status=1; // always display activ customer first + /* * view */ @@ -202,10 +203,9 @@ if ($result) print_liste_field_titre($langs->trans("AccountancyCode"),$_SERVER["PHP_SELF"],"s.code_compta","",$param,'align="left"',$sortfield,$sortorder); print_liste_field_titre($langs->trans("DateCreation"),$_SERVER["PHP_SELF"],"datec","",$param,'align="right"',$sortfield,$sortorder); print_liste_field_titre($langs->trans("Status"),$_SERVER["PHP_SELF"],"s.status","",$param,'align="center"',$sortfield,$sortorder); - print ' '; + print_liste_field_titre(''); $parameters=array(); $formconfirm=$hookmanager->executeHooks('printFieldListTitle',$parameters); // Note that $action and $object may have been modified by hook - print "\n"; print ''; @@ -245,7 +245,8 @@ if ($result) $parameters=array(); $formconfirm=$hookmanager->executeHooks('printFieldListOption',$parameters); // Note that $action and $object may have been modified by hook - print "\n"; + print ''."\n"; + $var=True; @@ -281,13 +282,13 @@ if ($result) print "\n"; $i++; } - //print_barre_liste($langs->trans("ListOfCustomers"), $page, $_SERVER["PHP_SELF"],'',$sortfield,$sortorder,'',$num); - print "\n"; - print "\n"; $db->free($result); $parameters=array('sql' => $sql); $formconfirm=$hookmanager->executeHooks('printFieldListFooter',$parameters); // Note that $action and $object may have been modified by hook + + print "\n"; + print "\n"; } else { diff --git a/htdocs/projet/list.php b/htdocs/projet/list.php index 4464c9cb8ef..eacc44cb3dd 100644 --- a/htdocs/projet/list.php +++ b/htdocs/projet/list.php @@ -1,6 +1,6 @@ - * Copyright (C) 2004-2010 Laurent Destailleur + * Copyright (C) 2004-2015 Laurent Destailleur * Copyright (C) 2005 Marc Bariley / Ocebo * Copyright (C) 2005-2010 Regis Houssin * Copyright (C) 2013 Cédric Salvador @@ -100,6 +100,12 @@ if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter")) // Both $syear=""; } +// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array +$hookmanager->initHooks(array('projectlist')); + + + + /* * View */ @@ -212,10 +218,7 @@ if ($resql) if ($mine) $text=$langs->trans('MyProjects'); print_barre_liste($text, $page, $_SERVER["PHP_SELF"], "", $sortfield, $sortorder, "", $num,'','title_project'); - print '
'; - - print ''; - + print ''; // Show description of content if ($mine) print $langs->trans("MyProjectsDesc").'

'; @@ -242,13 +245,16 @@ if ($resql) } if (! empty($moreforfilter)) { - print ''; - print ''; + $parameters=array(); + $formconfirm=$hookmanager->executeHooks('printFieldPreListTitle',$parameters); // Note that $action and $object may have been modified by hook + print ''; } + print '
'; + print '
'; print $moreforfilter; - print '
'; + print ''; print_liste_field_titre($langs->trans("Ref"),$_SERVER["PHP_SELF"],"p.ref","",$param,"",$sortfield,$sortorder); print_liste_field_titre($langs->trans("Label"),$_SERVER["PHP_SELF"],"p.title","",$param,"",$sortfield,$sortorder); @@ -259,6 +265,8 @@ if ($resql) print_liste_field_titre($langs->trans("Visibility"),$_SERVER["PHP_SELF"],"p.public","",$param,"",$sortfield,$sortorder); print_liste_field_titre($langs->trans("Status"),$_SERVER["PHP_SELF"],'p.fk_statut',"",$param,'align="right"',$sortfield,$sortorder); print_liste_field_titre(''); + $parameters=array(); + $formconfirm=$hookmanager->executeHooks('printFieldListTitle',$parameters); // Note that $action and $object may have been modified by hook print "\n"; print ''; @@ -301,6 +309,11 @@ if ($resql) print ''; print ''; + $parameters=array(); + $formconfirm=$hookmanager->executeHooks('printFieldListOption',$parameters); // Note that $action and $object may have been modified by hook + print ''."\n"; + + while ($i < $num) { $objp = $db->fetch_object($resql); @@ -396,21 +409,29 @@ if ($resql) $projectstatic->statut = $objp->fk_statut; print ''; + $parameters=array('obj' => $objp); + $formconfirm=$hookmanager->executeHooks('printFieldListValue',$parameters); // Note that $action and $object may have been modified by hook + print "\n"; } $i++; - } - $db->free($resql); + } + $db->free($resql); + + $parameters=array('sql' => $sql); + $formconfirm=$hookmanager->executeHooks('printFieldListFooter',$parameters); // Note that $action and $object may have been modified by hook + + print "
'.$projectstatic->getLibStatut(5).'
\n"; + print "
\n"; } else { dol_print_error($db); } -print ""; llxFooter(); diff --git a/htdocs/societe/soc.php b/htdocs/societe/soc.php index cc1af52b2dd..863863811e0 100644 --- a/htdocs/societe/soc.php +++ b/htdocs/societe/soc.php @@ -159,10 +159,6 @@ if (empty($reshook)) } //External modules should update their ones too - $hookmanager->initHooks(array( - 'mergethirds' - )); - if (!$errors) { $reshook = $hookmanager->executeHooks('replaceThirdparty', array(