diff --git a/dev/skeletons/skeleton_page.php b/dev/skeletons/skeleton_page.php index aab1a965eb6..4f9efe04c42 100644 --- a/dev/skeletons/skeleton_page.php +++ b/dev/skeletons/skeleton_page.php @@ -53,6 +53,7 @@ $langs->load("other"); // Get parameters $id = GETPOST('id','int'); $action = GETPOST('action','alpha'); +$backtopage = GETPOST('backtopage'); $myparam = GETPOST('myparam','alpha'); // Protection if external user @@ -77,10 +78,18 @@ 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') { + if (GETPOST('cancel')) + { + $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"); @@ -90,14 +99,15 @@ if ($action == 'add') $error++; setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Ref")),'errors'); } - + if (! $error) { $result=$object->create($user); if ($result > 0) { // Creation OK - header("Location: ".dol_buildpath('/mymodule/list.php',1)); + $urltogo=$backtopage?$backtopage:dol_buildpath('/mymodule/list.php',1); + header("Location: ".$urltogo); exit; } { @@ -113,6 +123,62 @@ if ($action == 'add') } } +// 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++; + setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Ref")),'errors'); + } + + if (! $error) + { + $result=$object->update($user); + if ($result > 0) + { + $action='view'; + } + else + { + // Creation KO + if (! empty($object->errors)) setEventMessage($object->errors, 'errors'); + else setEventMessage($object->error, 'errors'); + $action='edit'; + } + } + else + { + $action='edit'; + } +} + +// Action to delete +if ($action == 'confirm_delete') +{ + $result=$object->delete($user); + if ($result > 0) + { + // Delete OK + setEventMessage($langs->trans("RecordDeleted")); + header("Location: ".dol_buildpath('/buildingmanagement/list.php',1)); + exit; + } + else + { + if (! empty($object->errors)) setEventMessage($object->errors,'errors'); + else setEventMessage($object->error,'errors'); + } +} + @@ -194,6 +260,35 @@ if ($action == 'list' || empty($id)) +// Part to create +if ($action == 'create') +{ + print_fiche_titre($langs->trans("NewResidence")); + + dol_fiche_head(); + + print '
'; + print ''; + print ''; + + print ''."\n"; + print ''; + + print '
'.$langs->trans("Label").''; + print ''; + print '
'."\n"; + + print '
'; + + print '
 
'; + + print '
'; + + dol_fiche_end(); +} + + + // Part to edit record if ($id && $action == 'edit') { @@ -201,6 +296,8 @@ if ($id && $action == 'edit') print '
'; print ''; + print ''; + print ''; print '
'; @@ -218,12 +315,12 @@ if ($id && $action == 'edit') if ($id && (empty($action) || $action == 'view')) { dol_fiche_head(); - - - + + + dol_fiche_end(); - - + + // Buttons print '
'."\n"; $parameters=array(); @@ -248,12 +345,12 @@ if ($id && (empty($action) || $action == 'view')) } } print '
'."\n"; - - + + // Example 2 : Adding links to objects // The class must extends CommonObject class to have this method available //$somethingshown=$object->showLinkedObjectBlock(); - + } diff --git a/htdocs/fichinter/fiche.php b/htdocs/fichinter/fiche.php index d459b20767b..02b2b2ea7dd 100644 --- a/htdocs/fichinter/fiche.php +++ b/htdocs/fichinter/fiche.php @@ -1301,7 +1301,7 @@ else if ($id > 0 || ! empty($ref)) } } - print "
"; + print ""; print '
'; diff --git a/htdocs/societe/info.php b/htdocs/societe/info.php index 0deec041932..446a4f415fb 100644 --- a/htdocs/societe/info.php +++ b/htdocs/societe/info.php @@ -76,7 +76,8 @@ print '
'; dol_print_object_info($soc); print '
'; -print ''; + +dol_fiche_end(); llxFooter();