Skip to content
Snippets Groups Projects
Commit 4c9cc63f authored by Regis Houssin's avatar Regis Houssin
Browse files

Merge pull request #152 from grandoc/develop

Prepair to display within a custom place
parents f874d68e df132198
No related branches found
No related tags found
No related merge requests found
...@@ -30,14 +30,17 @@ require_once(DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'); ...@@ -30,14 +30,17 @@ require_once(DOL_DOCUMENT_ROOT.'/projet/class/project.class.php');
require_once(DOL_DOCUMENT_ROOT.'/projet/class/task.class.php'); require_once(DOL_DOCUMENT_ROOT.'/projet/class/task.class.php');
$langs->load("admin"); $langs->load("admin");
$langs->load("errors");
$langs->load("other"); $langs->load("other");
$langs->load("projects"); $langs->load("projects");
if (!$user->admin) if (!$user->admin) accessforbidden();
accessforbidden();
$value = GETPOST('value','alpha'); $value = GETPOST('value','alpha');
$action = GETPOST('action','alpha'); $action = GETPOST('action','alpha');
$label = GETPOST('label','alpha');
$scandir = GETPOST('scandir','alpha');
$type='project';
/* /*
...@@ -84,7 +87,6 @@ if ($action == 'specimen') ...@@ -84,7 +87,6 @@ if ($action == 'specimen')
} }
} }
if ($filefound) if ($filefound)
{ {
require_once($file); require_once($file);
...@@ -111,26 +113,13 @@ if ($action == 'specimen') ...@@ -111,26 +113,13 @@ if ($action == 'specimen')
if ($action == 'set') if ($action == 'set')
{ {
$label = GETPOST('label','alpha'); $ret = addDocumentModel($value, $type, $label, $scandir);
$scandir = GETPOST('scandir','alpha');
$type='project';
$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);
} }
if ($action == 'del') if ($action == 'del')
{ {
$type='project'; $ret = delDocumentModel($value, $type);
$sql = "DELETE FROM ".MAIN_DB_PREFIX."document_model"; if ($ret > 0)
$sql.= " WHERE nom = '".$db->escape($value)."'";
$sql.= " AND type = '".$type."'";
$sql.= " AND entity = ".$conf->entity;
if ($db->query($sql))
{ {
if ($conf->global->PROJECT_ADDON_PDF == "$value") dolibarr_del_const($db, 'PROJECT_ADDON_PDF',$conf->entity); if ($conf->global->PROJECT_ADDON_PDF == "$value") dolibarr_del_const($db, 'PROJECT_ADDON_PDF',$conf->entity);
} }
...@@ -138,37 +127,18 @@ if ($action == 'del') ...@@ -138,37 +127,18 @@ if ($action == 'del')
if ($action == 'setdoc') if ($action == 'setdoc')
{ {
$label = GETPOST('label','alpha');
$scandir = GETPOST('scandir','alpha');
$db->begin();
if (dolibarr_set_const($db, "PROJECT_ADDON_PDF",$value,'chaine',0,'',$conf->entity)) if (dolibarr_set_const($db, "PROJECT_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->PROJECT_ADDON_PDF = $value; $conf->global->PROJECT_ADDON_PDF = $value;
} }
// On active le modele // On active le modele
$type='project'; $ret = delDocumentModel($value, $type);
$sql_del = "DELETE FROM ".MAIN_DB_PREFIX."document_model"; if ($ret > 0)
$sql_del.= " WHERE nom = '".$db->escape($value)."'";
$sql_del.= " AND type = '".$type."'";
$sql_del.= " AND entity = ".$conf->entity;
$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(); $ret = addDocumentModel($value, $type, $label, $scandir);
} }
} }
...@@ -177,7 +147,7 @@ if ($action == 'setmod') ...@@ -177,7 +147,7 @@ if ($action == 'setmod')
// TODO Verifier si module numerotation choisi peut etre active // TODO Verifier si module numerotation choisi peut etre active
// par appel methode canBeActivated // par appel methode canBeActivated
dolibarr_set_const($db, "PROJECT_ADDON",GETPOST('value','alpha'),'chaine',0,'',$conf->entity); dolibarr_set_const($db, "PROJECT_ADDON",$value,'chaine',0,'',$conf->entity);
} }
/* /*
...@@ -186,10 +156,10 @@ if ($action == 'setmod') ...@@ -186,10 +156,10 @@ if ($action == 'setmod')
$dirmodels=array_merge(array('/'),(array) $conf->modules_parts['models']); $dirmodels=array_merge(array('/'),(array) $conf->modules_parts['models']);
$form=new Form($db);
llxHeader(); llxHeader();
$form=new Form($db);
$linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php">'.$langs->trans("BackToModuleList").'</a>'; $linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php">'.$langs->trans("BackToModuleList").'</a>';
print_fiche_titre($langs->trans("ProjectsSetup"),$linkback,'setup'); print_fiche_titre($langs->trans("ProjectsSetup"),$linkback,'setup');
...@@ -197,9 +167,6 @@ print "<br>"; ...@@ -197,9 +167,6 @@ print "<br>";
// Project numbering module // Project numbering module
$dir = DOL_DOCUMENT_ROOT."/core/modules/project/";
print_titre($langs->trans("ProjectsNumberingModules")); print_titre($langs->trans("ProjectsNumberingModules"));
print '<table class="noborder" width="100%">'; print '<table class="noborder" width="100%">';
...@@ -235,12 +202,12 @@ foreach ($dirmodels as $reldir) ...@@ -235,12 +202,12 @@ foreach ($dirmodels as $reldir)
$module = new $file; $module = new $file;
if ($module->isEnabled())
{
// Show modules according to features level // Show modules according to features level
if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) continue; if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) continue;
if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) continue; if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) continue;
if ($module->isEnabled())
{
$var=!$var; $var=!$var;
print '<tr '.$bc[$var].'><td>'.$module->nom."</td><td>\n"; print '<tr '.$bc[$var].'><td>'.$module->nom."</td><td>\n";
print $module->info(); print $module->info();
...@@ -255,13 +222,13 @@ foreach ($dirmodels as $reldir) ...@@ -255,13 +222,13 @@ foreach ($dirmodels as $reldir)
print '</td>'."\n"; print '</td>'."\n";
print '<td align="center">'; print '<td align="center">';
if ($conf->global->PROJECT_ADDON == "$file") if ($conf->global->PROJECT_ADDON == $classname)
{ {
print img_picto($langs->trans("Activated"),'switch_on'); print img_picto($langs->trans("Activated"),'switch_on');
} }
else else
{ {
print '<a href="'.$_SERVER["PHP_SELF"].'?action=setmod&amp;value='.$file.'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"),'switch_off').'</a>'; print '<a href="'.$_SERVER["PHP_SELF"].'?action=setmod&amp;value='.$classname.'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"),'switch_off').'</a>';
} }
print '</td>'; print '</td>';
...@@ -305,8 +272,6 @@ print '</table><br>'; ...@@ -305,8 +272,6 @@ print '</table><br>';
* Modeles documents for projects * Modeles documents for projects
*/ */
//$dir = DOL_DOCUMENT_ROOT.'/core/modules/project/pdf/';
print_titre($langs->trans("ProjectsModelModule")); print_titre($langs->trans("ProjectsModelModule"));
// Defini tableau def de modele // Defini tableau def de modele
...@@ -375,16 +340,9 @@ foreach ($dirmodels as $reldir) ...@@ -375,16 +340,9 @@ foreach ($dirmodels as $reldir)
if (in_array($name, $def)) if (in_array($name, $def))
{ {
print "<td align=\"center\">\n"; print "<td align=\"center\">\n";
//if ($conf->global->PROJECT_ADDON_PDF != "$name")
//{
print '<a href="'.$_SERVER["PHP_SELF"].'?action=del&amp;value='.$name.'&amp;scandir='.$module->scandir.'&amp;label='.urlencode($module->name).'">'; print '<a href="'.$_SERVER["PHP_SELF"].'?action=del&amp;value='.$name.'&amp;scandir='.$module->scandir.'&amp;label='.urlencode($module->name).'">';
print img_picto($langs->trans("Enabled"),'switch_on'); print img_picto($langs->trans("Enabled"),'switch_on');
print '</a>'; print '</a>';
//}
//else
//{
// print img_picto($langs->trans("Enabled"),'on');
//}
print "</td>"; print "</td>";
} }
else else
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment