From 45d9d525a444c5b3198f2cda9ec58e0436774700 Mon Sep 17 00:00:00 2001 From: Grand Philippe Date: Thu, 21 Mar 2013 09:22:26 +0100 Subject: [PATCH] display enhancement and standardize --- htdocs/admin/dons.php | 88 ++++++++++++++++++------------------------- 1 file changed, 36 insertions(+), 52 deletions(-) diff --git a/htdocs/admin/dons.php b/htdocs/admin/dons.php index 21c2b3a1a59..2e62048e329 100644 --- a/htdocs/admin/dons.php +++ b/htdocs/admin/dons.php @@ -1,6 +1,7 @@ * Copyright (C) 2012 Juanjo Menent + * Copyright (C) 2013 Philippe Grand * * 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 @@ -47,7 +48,7 @@ if ($action == 'specimen') $don = new Don($db); $don->initAsSpecimen(); - // Charge le modele + // Search template files $dir = DOL_DOCUMENT_ROOT . "/core/modules/dons/"; $file = $modele.".modules.php"; if (file_exists($dir.$file)) @@ -75,67 +76,39 @@ if ($action == 'specimen') } } -if ($action == 'setdoc') +// Set default model +else if ($action == 'setdoc') { - $value = GETPOST('value','alpha'); - $label = GETPOST('label','alpha'); - $scandir = GETPOST('scandir','alpha'); - - $db->begin(); + if (dolibarr_set_const($db, "COMMANDE_ADDON_PDF",$value,'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->COMMANDE_ADDON_PDF = $value; + } - if (dolibarr_set_const($db, "DON_ADDON_MODEL",$value,'chaine',0,'',$conf->entity)) - { - $conf->global->DON_ADDON_MODEL = $value; - } - - // On active le modele - $type='donation'; - $sql_del = "DELETE FROM ".MAIN_DB_PREFIX."document_model"; - $sql_del.= " WHERE nom = '".$db->escape($value)."' AND type = '".$type."'"; - $result1=$db->query($sql_del); - - $sql = "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity, libelle, description)"; - $sql.= " VALUES ('".$db->escape($value)."', '".$type."', ".$conf->entity.", "; - $sql.= ($label?"'".$db->escape($label)."'":'null').", "; - $sql.= (! empty($scandir)?"'".$db->escape($scandir)."'":"null"); - $sql.= ")"; - $result2=$db->query($sql); - if ($result1 && $result2) - { - $db->commit(); - } - else - { - $db->rollback(); - } + // On active le modele + $ret = delDocumentModel($value, $type); + if ($ret > 0) + { + $ret = addDocumentModel($value, $type, $label, $scandir); + } } -if ($action == 'set') +// Activate a model +else if ($action == 'set') { - $value = GETPOST('value','alpha'); - $label = GETPOST('label','alpha'); - $scandir = GETPOST('scandir','alpha'); - - $type='donation'; - $sql = "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity, libelle, description)"; - $sql.= " VALUES ('".$db->escape($value)."','".$type."',".$conf->entity.", "; - $sql.= ($label?"'".$db->escape($label)."'":'null').", "; - $sql.= (! empty($scandir)?"'".$db->escape($scandir)."'":"null"); - $sql.= ")"; - $resql=$db->query($sql); + $ret = addDocumentModel($value, $type, $label, $scandir); } -if ($action == 'del') +else if ($action == 'del') { - $value = GETPOST('value','alpha'); - - $type='donation'; - $sql = "DELETE FROM ".MAIN_DB_PREFIX."document_model"; - $sql .= " WHERE nom = '".$value."' AND type = '".$type."'"; - $resql=$db->query($sql); + $ret = delDocumentModel($value, $type); + if ($ret > 0) + { + if ($conf->global->COMMANDE_ADDON_PDF == "$value") dolibarr_del_const($db, 'COMMANDE_ADDON_PDF',$conf->entity); + } } - /* * View */ @@ -147,6 +120,17 @@ llxHeader('',$langs->trans("DonationsSetup"),'DonConfiguration'); $linkback=''.$langs->trans("BackToModuleList").''; print_fiche_titre($langs->trans("DonationsSetup"),$linkback,'setup'); +print '
'; + +$h = 0; + +$head[$h][0] = DOL_URL_ROOT."/admin/dons.php"; +$head[$h][1] = $langs->trans("Donations"); +$head[$h][2] = 'Donation'; +$hselected=$h; +$h++; + +dol_fiche_head($head, $hselected, $langs->trans("ModuleSetup")); // Document templates