* Copyright (C) 2008-2012 Regis Houssin * 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 htdocs/ecm/docdir.php * \ingroup ecm * \brief Main page for ECM section area */ require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; require_once DOL_DOCUMENT_ROOT.'/ecm/class/htmlecm.form.class.php'; require_once DOL_DOCUMENT_ROOT.'/ecm/class/ecmdirectory.class.php'; // Load traductions files $langs->load("ecm"); $langs->load("companies"); $langs->load("other"); $langs->load("users"); $langs->load("orders"); $langs->load("propal"); $langs->load("bills"); $langs->load("contracts"); $langs->load("categories"); if (! $user->rights->ecm->setup) accessforbidden(); // Get parameters $socid = GETPOST('socid','int'); $action=GETPOST('action','alpha'); $confirm=GETPOST('confirm','alpha'); // Security check if ($user->societe_id > 0) { $action = ''; $socid = $user->societe_id; } $section=$urlsection=GETPOST('section'); if (empty($urlsection)) $urlsection='misc'; $upload_dir = $conf->ecm->dir_output.'/'.$urlsection; $sortfield = GETPOST("sortfield",'alpha'); $sortorder = GETPOST("sortorder",'alpha'); $page = GETPOST("page",'int'); if ($page == -1) { $page = 0; } $offset = $conf->liste_limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; if (! $sortorder) $sortorder="ASC"; if (! $sortfield) $sortfield="label"; $ecmdir = new EcmDirectory($db); if (! empty($section)) { $result=$ecmdir->fetch($section); if (! $result > 0) { dol_print_error($db,$ecmdir->error); exit; } } /* * Actions */ // Action ajout d'un produit ou service if ($action == 'add' && $user->rights->ecm->setup) { if (! empty($_POST["cancel"])) { header("Location: ".DOL_URL_ROOT.'/ecm/index.php?action=file_manager'); exit; } $ecmdir->ref = trim($_POST["ref"]); $ecmdir->label = trim($_POST["label"]); $ecmdir->description = trim($_POST["desc"]); $ecmdir->fk_parent = $_POST["catParent"]; $ok=true; if (! $ecmdir->label) { setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentities("Label")), 'errors'); $action = 'create'; $ok=false; } if ($ok) { $id = $ecmdir->create($user); if ($id > 0) { header("Location: ".DOL_URL_ROOT.'/ecm/index.php?action=file_manager'); exit; } else { $langs->load("errors"); setEventMessage($langs->trans($ecmdir->error), 'errors'); setEventMessage($ecmdir->errors, 'errors'); $action = 'create'; } } } // Suppression fichier else if ($action == 'confirm_deletesection' && $confirm == 'yes') { $result=$ecmdir->delete($user); setEventMessage($langs->trans("ECMSectionWasRemoved", $ecmdir->label)); } /* * View */ llxHeader(); $form=new Form($db); $formecm=new FormEcm($db); if ($action == 'create') { //*********************** // Create //*********************** print '
'; print ''; print ''; $title=$langs->trans("ECMNewSection"); print_fiche_titre($title); dol_fiche_head(); print ''; // Label print ''."\n"; print ''."\n"; // Description print ''."\n"; print ''."\n"; print '
'.$langs->trans("Label").'
'.$langs->trans("AddIn").''; print $formecm->select_all_sections(! empty($_GET["catParent"])?$_GET["catParent"]:$ecmdir->fk_parent,'catParent'); print '
'.$langs->trans("Description").''; print ''; print '

'; dol_fiche_end(); print '
'; print ''; print '     '; print ''; print '
'; print '
'; } if (empty($action) || $action == 'delete_section') { //*********************** // List //*********************** print_fiche_titre($langs->trans("ECMSectionOfDocuments")); print '
'; /* $ecmdir->ref=$ecmdir->label; print $langs->trans("ECMSection").': '; print img_picto('','object_dir').' '; print ''.$langs->trans("ECMRoot").''; //print ' -> '.$ecmdir->getNomUrl(1).'
'; print "

"; */ // Confirmation de la suppression d'une ligne categorie if ($action == 'delete_section') { print $form->formconfirm($_SERVER["PHP_SELF"].'?section='.$section, $langs->trans('DeleteSection'), $langs->trans('ConfirmDeleteSection',$ecmdir->label), 'confirm_deletesection'); } // Construit fiche rubrique // Actions buttons print '
'; if ($user->rights->ecm->setup) { print ''.$langs->trans('Delete').''; } else { print ''.$langs->trans('Delete').''; } print '
'; } // End of page llxFooter(); $db->close();