* Copyright (C) 2015 Alexandre Spangaro * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ /** * \file resource/add.php * \ingroup resource * \brief Page to manage resource object * Initialy built by build_class_from_table on 2013-07-24 16:03 */ require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/resource/class/resource.class.php'; require_once DOL_DOCUMENT_ROOT.'/resource/class/html.formresource.class.php'; // Load traductions files required by page $langs->load("resource"); $langs->load("companies"); $langs->load("other"); $langs->load("resource"); // Get parameters $id = GETPOST('id','int'); $action = GETPOST('action','alpha'); $cancel = GETPOST('cancel','alpha'); if (empty($sortorder)) $sortorder="DESC"; if (empty($sortfield)) $sortfield="t.rowid"; if (empty($arch)) $arch = 0; if ($page == -1) { $page = 0 ; } $limit = $conf->global->limit; $offset = $limit * $page ; $pageprev = $page - 1; $pagenext = $page + 1; // Protection if external user if ($user->societe_id > 0) { accessforbidden(); } $object = new Resource($db); if ($action == 'confirm_add_resource') { if (! $cancel) { $error=''; $ref=GETPOST('ref','alpha'); $description=GETPOST('description','alpha'); $fk_code_type_resource=GETPOST('fk_code_type_resource','alpha'); if (empty($ref)) { $mesg=$langs->trans("ErrorFieldRequired",$langs->transnoentities("Ref")); setEventMessage($mesg, 'errors'); $error++; } if (! $error) { $object=new Resource($db); $object->ref=$ref; $object->description=$description; $object->fk_code_type_resource=$fk_code_type_resource; $result=$object->create($user); if ($result > 0) { // Creation OK $db->commit(); setEventMessage($langs->trans('ResourceCreatedWithSuccess')); Header("Location: card.php?id=" . $object->id); return; } else { // Creation KO setEventMessage($object->error, 'errors'); $action = ''; } } else { $action = ''; } } else { Header("Location: list.php"); } } /* * View * */ $form=new Form($db); $formresource = new FormResource($db); if (! $action) { $pagetitle=$langs->trans('AddResource'); llxHeader('',$pagetitle,''); print_fiche_titre($pagetitle,'','title_generic'); print '
'; print ''; dol_fiche_head(''); print ''; // Ref / label $field = 'ref'; print ''; print ''; print ''; print ''; // Type print ''; print ''; // Description $field = 'description'; print ''; print ''; print ''; print ''; print '
'; print $langs->trans('ResourceFormLabel_'.$field); print ''; print ''; print '
'.$langs->trans("ResourceType").''; $ret = $formresource->select_types_resource($object->fk_code_type_resource,'fk_code_type_resource','',2); print '
'; print $langs->trans('ResourceFormLabel_'.$field); print ''; require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; $doleditor = new DolEditor($field, $$field, 160, '', '', false); $doleditor->Create(); print '
'; dol_fiche_end(''); echo '
', '', '     ', '', '
'; print '
'; } // End of page llxFooter(); $db->close();