forked from Wavyzz/dolibarr
New USER odt
This commit is contained in:
@@ -35,11 +35,12 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
|
||||
$langs->load("admin");
|
||||
$langs->load("members");
|
||||
$langs->load("users");
|
||||
|
||||
if (! $user->admin) accessforbidden();
|
||||
|
||||
$extrafields = new ExtraFields($db);
|
||||
|
||||
$action = GETPOST('action','alpha');
|
||||
$value = GETPOST('value','alpha');
|
||||
$type='user';
|
||||
|
||||
/*
|
||||
@@ -47,7 +48,36 @@ $type='user';
|
||||
*/
|
||||
|
||||
// Activate a model
|
||||
if ($action == 'set_default')
|
||||
|
||||
// Define constants for submodules that contains parameters (forms with param1, param2, ... and value1, value2, ...)
|
||||
if ($action == 'setModuleOptions')
|
||||
{
|
||||
$post_size=count($_POST);
|
||||
|
||||
$db->begin();
|
||||
|
||||
for($i=0;$i < $post_size;$i++)
|
||||
{
|
||||
if (array_key_exists('param'.$i,$_POST))
|
||||
{
|
||||
$param=GETPOST("param".$i,'alpha');
|
||||
$value=GETPOST("value".$i,'alpha');
|
||||
if ($param) $res = dolibarr_set_const($db,$param,$value,'chaine',0,'',$conf->entity);
|
||||
if (! $res > 0) $error++;
|
||||
}
|
||||
}
|
||||
if (! $error)
|
||||
{
|
||||
$db->commit();
|
||||
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
|
||||
}
|
||||
else
|
||||
{
|
||||
$db->rollback();
|
||||
setEventMessages($langs->trans("Error"), null, 'errors');
|
||||
}
|
||||
}
|
||||
elseif ($action == 'set_default')
|
||||
{
|
||||
$ret = addDocumentModel($value, $type, $label, $scandir);
|
||||
$res = true;
|
||||
@@ -70,7 +100,7 @@ elseif ($action == 'setdoc')
|
||||
{
|
||||
// La constante qui a ete lue en avant du nouveau set
|
||||
// on passe donc par une variable pour avoir un affichage coherent
|
||||
$conf->global->PRODUCT_ADDON_PDF_ODT = $value;
|
||||
$conf->global->USER_ADDON_PDF_ODT = $value;
|
||||
}
|
||||
|
||||
// On active le modele
|
||||
@@ -175,6 +205,164 @@ print '</td></tr>';
|
||||
|
||||
print '</table>';
|
||||
|
||||
|
||||
|
||||
$dirmodels=array_merge(array('/'),(array) $conf->modules_parts['models']);
|
||||
|
||||
$form=new Form($db);
|
||||
|
||||
// Defini tableau def des modeles
|
||||
$def = array();
|
||||
$sql = "SELECT nom";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."document_model";
|
||||
$sql.= " WHERE type = '".$type."'";
|
||||
$sql.= " AND entity = ".$conf->entity;
|
||||
$resql=$db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
$i = 0;
|
||||
$num_rows=$db->num_rows($resql);
|
||||
while ($i < $num_rows)
|
||||
{
|
||||
$array = $db->fetch_array($resql);
|
||||
array_push($def, $array[0]);
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
dol_print_error($db);
|
||||
}
|
||||
|
||||
print '<table class="noborder" width="100%">';
|
||||
print '<tr class="liste_titre">';
|
||||
print '<td>'.$langs->trans("Name").'</td>';
|
||||
print '<td>'.$langs->trans("Description").'</td>';
|
||||
print '<td align="center" width="60">'.$langs->trans("Status")."</td>\n";
|
||||
print '<td align="center" width="60">'.$langs->trans("Default")."</td>\n";
|
||||
print '<td align="center" width="80">'.$langs->trans("ShortInfo").'</td>';
|
||||
print '<td align="center" width="80">'.$langs->trans("Preview").'</td>';
|
||||
print "</tr>\n";
|
||||
|
||||
clearstatcache();
|
||||
|
||||
$var=true;
|
||||
foreach ($dirmodels as $reldir)
|
||||
{
|
||||
foreach (array('','/doc') as $valdir)
|
||||
{
|
||||
$dir = dol_buildpath($reldir."core/modules/user".$valdir);
|
||||
if (is_dir($dir))
|
||||
{
|
||||
$handle=opendir($dir);
|
||||
if (is_resource($handle))
|
||||
{
|
||||
while (($file = readdir($handle))!==false)
|
||||
{
|
||||
$filelist[]=$file;
|
||||
}
|
||||
closedir($handle);
|
||||
arsort($filelist);
|
||||
|
||||
foreach($filelist as $file)
|
||||
{
|
||||
if (preg_match('/\.modules\.php$/i',$file) && preg_match('/^(pdf_|doc_)/',$file))
|
||||
{
|
||||
|
||||
if (file_exists($dir.'/'.$file))
|
||||
{
|
||||
$name = substr($file, 4, dol_strlen($file) -16);
|
||||
$classname = substr($file, 0, dol_strlen($file) -12);
|
||||
|
||||
require_once $dir.'/'.$file;
|
||||
$module = new $classname($db);
|
||||
|
||||
$modulequalified=1;
|
||||
if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) $modulequalified=0;
|
||||
if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) $modulequalified=0;
|
||||
|
||||
if ($modulequalified)
|
||||
{
|
||||
$var = !$var;
|
||||
print '<tr '.$bc[$var].'><td width="100">';
|
||||
print (empty($module->name)?$name:$module->name);
|
||||
print "</td><td>\n";
|
||||
if (method_exists($module,'info')) print $module->info($langs);
|
||||
else print $module->description;
|
||||
print '</td>';
|
||||
|
||||
// Active
|
||||
if (in_array($name, $def))
|
||||
{
|
||||
print '<td align="center">'."\n";
|
||||
print '<a href="'.$_SERVER["PHP_SELF"].'?action=del_default&value='.$name.'">';
|
||||
print img_picto($langs->trans("Enabled"),'switch_on');
|
||||
print '</a>';
|
||||
print '</td>';
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<td align="center">'."\n";
|
||||
print '<a href="'.$_SERVER["PHP_SELF"].'?action=set_default&value='.$name.'&scandir='.$module->scandir.'&label='.urlencode($module->name).'">'.img_picto($langs->trans("Disabled"),'switch_off').'</a>';
|
||||
print "</td>";
|
||||
}
|
||||
|
||||
// Defaut
|
||||
print '<td align="center">';
|
||||
if ($conf->global->USER_ADDON_PDF == $name)
|
||||
{
|
||||
print img_picto($langs->trans("Default"),'on');
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<a href="'.$_SERVER["PHP_SELF"].'?action=setdoc&value='.$name.'&scandir='.$module->scandir.'&label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"),'off').'</a>';
|
||||
}
|
||||
print '</td>';
|
||||
|
||||
// Info
|
||||
$htmltooltip = ''.$langs->trans("Name").': '.$module->name;
|
||||
$htmltooltip.='<br>'.$langs->trans("Type").': '.($module->type?$module->type:$langs->trans("Unknown"));
|
||||
if ($module->type == 'pdf')
|
||||
{
|
||||
$htmltooltip.='<br>'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur;
|
||||
}
|
||||
$htmltooltip.='<br><br><u>'.$langs->trans("FeaturesSupported").':</u>';
|
||||
$htmltooltip.='<br>'.$langs->trans("Logo").': '.yn($module->option_logo,1,1);
|
||||
$htmltooltip.='<br>'.$langs->trans("PaymentMode").': '.yn($module->option_modereg,1,1);
|
||||
$htmltooltip.='<br>'.$langs->trans("PaymentConditions").': '.yn($module->option_condreg,1,1);
|
||||
$htmltooltip.='<br>'.$langs->trans("MultiLanguage").': '.yn($module->option_multilang,1,1);
|
||||
$htmltooltip.='<br>'.$langs->trans("WatermarkOnDraftOrders").': '.yn($module->option_draft_watermark,1,1);
|
||||
|
||||
|
||||
print '<td align="center">';
|
||||
print $form->textwithpicto('',$htmltooltip,1,0);
|
||||
print '</td>';
|
||||
|
||||
// Preview
|
||||
print '<td align="center">';
|
||||
if ($module->type == 'pdf')
|
||||
{
|
||||
print '<a href="'.$_SERVER["PHP_SELF"].'?action=specimen&module='.$name.'">'.img_object($langs->trans("Preview"),'contract').'</a>';
|
||||
}
|
||||
else
|
||||
{
|
||||
print img_object($langs->trans("PreviewNotAvailable"),'generic');
|
||||
}
|
||||
print '</td>';
|
||||
|
||||
print "</tr>\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
print '</table>';
|
||||
print "<br>";
|
||||
|
||||
dol_fiche_end();
|
||||
|
||||
llxFooter();
|
||||
|
||||
@@ -416,8 +416,8 @@ class FormFile
|
||||
if (is_array($genallowed)) $modellist=$genallowed;
|
||||
else
|
||||
{
|
||||
include_once DOL_DOCUMENT_ROOT.'/core/modules/user/modules_user.php';
|
||||
$modellist=ModelePDFProduct::liste_modeles($this->db);
|
||||
include_once DOL_DOCUMENT_ROOT.'/core/modules/user/modules_user.class.php';
|
||||
$modellist=ModelePDFUser::liste_modeles($this->db);
|
||||
}
|
||||
}
|
||||
elseif ($modulepart == 'group')
|
||||
|
||||
@@ -580,6 +580,11 @@ if (empty($reshook)) {
|
||||
setEventMessages($ldap->error, $ldap->errors, 'errors');
|
||||
}
|
||||
}
|
||||
|
||||
// Actions to build doc
|
||||
$upload_dir = $conf->user->dir_output;
|
||||
$permissioncreate=$user->rights->user->user->creer;
|
||||
include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php';
|
||||
}
|
||||
|
||||
|
||||
@@ -2284,8 +2289,8 @@ else
|
||||
$filename = dol_sanitizeFileName($object->ref);
|
||||
$filedir = $conf->user->dir_output . "/" . dol_sanitizeFileName($object->ref);
|
||||
$urlsource = $_SERVER["PHP_SELF"] . "?id=" . $object->id;
|
||||
$genallowed = $user->rights->user->creer;
|
||||
$delallowed = $user->rights->user->supprimer;
|
||||
$genallowed = $user->rights->user->user->creer;
|
||||
$delallowed = $user->rights->user->user->supprimer;
|
||||
|
||||
$var = true;
|
||||
|
||||
|
||||
@@ -2622,5 +2622,39 @@ class User extends CommonObject
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a document onto disk according to template module.
|
||||
*
|
||||
* @param string $modele Force model to use ('' to not force)
|
||||
* @param Translate $outputlangs Object langs to use for output
|
||||
* @param int $hidedetails Hide details of lines
|
||||
* @param int $hidedesc Hide description
|
||||
* @param int $hideref Hide ref
|
||||
* @return int 0 if KO, 1 if OK
|
||||
*/
|
||||
public function generateDocument($modele, $outputlangs, $hidedetails=0, $hidedesc=0, $hideref=0)
|
||||
{
|
||||
global $conf,$user,$langs;
|
||||
|
||||
$langs->load("user");
|
||||
|
||||
// Positionne le modele sur le nom du modele a utiliser
|
||||
if (! dol_strlen($modele))
|
||||
{
|
||||
if (! empty($conf->global->USER_ADDON_PDF))
|
||||
{
|
||||
$modele = $conf->global->USER_ADDON_PDF;
|
||||
}
|
||||
else
|
||||
{
|
||||
$modele = 'bluesky';
|
||||
}
|
||||
}
|
||||
|
||||
$modelpath = "core/modules/user/doc/";
|
||||
|
||||
return $this->commonGenerateDocument($modelpath, $modele, $outputlangs, $hidedetails, $hidedesc, $hideref);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user