Merge branch 'develop' of git@github.com:Dolibarr/dolibarr.git into develop

This commit is contained in:
Laurent Destailleur 2014-09-26 12:42:41 +02:00
commit 8e95f2e223
9 changed files with 293 additions and 149 deletions

View File

@ -138,6 +138,35 @@ else if ($action == 'specimen')
} }
} }
// Define constants for submodules that contains parameters (forms with param1, param2, ... and value1, value2, ...)
else 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();
setEventMessage($langs->trans("SetupSaved"));
}
else
{
$db->rollback();
setEventMessage($langs->trans("Error"),'errors');
}
}
// Activate a model // Activate a model
else if ($action == 'set') else if ($action == 'set')
{ {
@ -175,14 +204,6 @@ else if ($action == 'setmodel')
{ {
dolibarr_set_const($db, "EXPEDITION_ADDON_NUMBER",$value,'chaine',0,'',$conf->entity); dolibarr_set_const($db, "EXPEDITION_ADDON_NUMBER",$value,'chaine',0,'',$conf->entity);
} }
else if ($action=='setModuleOptions') {
if (dolibarr_set_const($db, "EXPEDITION_ADDON_PDF_ODT_PATH",GETPOST('value1'),'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->EXPEDITION_ADDON_PDF_ODT_PATH = GETPOST('value1');
}
}
/* /*

View File

@ -3,7 +3,7 @@
* Copyright (C) 2004-2011 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2004-2011 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2004 Sebastien Di Cintio <sdicintio@ressource-toi.org> * Copyright (C) 2004 Sebastien Di Cintio <sdicintio@ressource-toi.org>
* Copyright (C) 2004 Benoit Mortier <benoit.mortier@opensides.be> * Copyright (C) 2004 Benoit Mortier <benoit.mortier@opensides.be>
* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com> * Copyright (C) 2005-2014 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2008 Raphael Bertrand (Resultic) <raphael.bertrand@resultic.fr> * Copyright (C) 2008 Raphael Bertrand (Resultic) <raphael.bertrand@resultic.fr>
* Copyright (C) 2011-2013 Juanjo Menent <jmenent@2byte.es> * Copyright (C) 2011-2013 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2011-2013 Philippe Grand <philippe.grand@atoo-net.com> * Copyright (C) 2011-2013 Philippe Grand <philippe.grand@atoo-net.com>
@ -113,6 +113,35 @@ else if ($action == 'specimen') // For fiche inter
} }
} }
// 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();
setEventMessage($langs->trans("SetupSaved"));
}
else
{
$db->rollback();
setEventMessage($langs->trans("Error"),'errors');
}
}
// Activate a model // Activate a model
else if ($action == 'set') else if ($action == 'set')
{ {
@ -374,7 +403,16 @@ foreach ($dirmodels as $reldir)
{ {
while (($file = readdir($handle))!==false) while (($file = readdir($handle))!==false)
{ {
if (substr($file, dol_strlen($file) -12) == '.modules.php' && substr($file,0,4) == 'pdf_') $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))
{ {
$var=!$var; $var=!$var;
@ -384,12 +422,17 @@ foreach ($dirmodels as $reldir)
require_once $dir.'/'.$file; require_once $dir.'/'.$file;
$module = new $classname($db); $module = new $classname($db);
print '<tr '.$bc[$var].'><td>'; $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)
{
print '<tr '.$bc[$var].'><td width="100">';
print (empty($module->name)?$name:$module->name); print (empty($module->name)?$name:$module->name);
print "</td><td>\n"; print "</td><td>\n";
require_once $dir.$file; if (method_exists($module,'info')) print $module->info($langs);
$module = new $classname($db); else print $module->description;
print $module->description;
print '</td>'; print '</td>';
// Active // Active
@ -435,15 +478,22 @@ foreach ($dirmodels as $reldir)
print '</td>'; print '</td>';
// Preview // Preview
$link='<a href="'.$_SERVER["PHP_SELF"].'?action=specimen&module='.$name.'">'.img_object($langs->trans("Preview"),'intervention').'</a>';
print '<td align="center">'; print '<td align="center">';
print $link; if ($module->type == 'pdf')
{
print '<a href="'.$_SERVER["PHP_SELF"].'?action=specimen&module='.$name.'">'.img_object($langs->trans("Preview"),'intervention').'</a>';
}
else
{
print img_object($langs->trans("PreviewNotAvailable"),'generic');
}
print '</td>'; print '</td>';
print '</tr>'; print '</tr>';
} }
} }
closedir($handle); }
}
} }
} }
} }

View File

@ -4,7 +4,7 @@
* Copyright (C) 2004 Sebastien Di Cintio <sdicintio@ressource-toi.org> * Copyright (C) 2004 Sebastien Di Cintio <sdicintio@ressource-toi.org>
* Copyright (C) 2004 Benoit Mortier <benoit.mortier@opensides.be> * Copyright (C) 2004 Benoit Mortier <benoit.mortier@opensides.be>
* Copyright (C) 2004 Eric Seigne <eric.seigne@ryxeo.com> * Copyright (C) 2004 Eric Seigne <eric.seigne@ryxeo.com>
* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com> * Copyright (C) 2005-2014 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2011-2013 Juanjo Menent <jmenent@2byte.es> * Copyright (C) 2011-2013 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2011-2013 Philippe Grand <philippe.grand@atoo-net.com> * Copyright (C) 2011-2013 Philippe Grand <philippe.grand@atoo-net.com>
* *
@ -95,7 +95,7 @@ if ($action == 'specimen')
$dirmodels=array_merge(array('/'),(array) $conf->modules_parts['models']); $dirmodels=array_merge(array('/'),(array) $conf->modules_parts['models']);
foreach($dirmodels as $reldir) foreach($dirmodels as $reldir)
{ {
$file=dol_buildpath($reldir."core/modules/livraison/pdf/pdf_".$modele.".modules.php",0); $file=dol_buildpath($reldir."core/modules/livraison/doc/pdf_".$modele.".modules.php",0);
if (file_exists($file)) if (file_exists($file))
{ {
$filefound=1; $filefound=1;
@ -128,6 +128,35 @@ if ($action == 'specimen')
} }
} }
// 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();
setEventMessage($langs->trans("SetupSaved"));
}
else
{
$db->rollback();
setEventMessage($langs->trans("Error"),'errors');
}
}
if ($action == 'set') if ($action == 'set')
{ {
$ret = addDocumentModel($value, $type, $label, $scandir); $ret = addDocumentModel($value, $type, $label, $scandir);
@ -356,7 +385,7 @@ clearstatcache();
$var=true; $var=true;
foreach ($dirmodels as $reldir) foreach ($dirmodels as $reldir)
{ {
$dir = dol_buildpath($reldir."core/modules/livraison/pdf/"); $dir = dol_buildpath($reldir."core/modules/livraison/doc/");
if (is_dir($dir)) if (is_dir($dir))
{ {
@ -365,23 +394,39 @@ foreach ($dirmodels as $reldir)
{ {
while (($file = readdir($handle))!==false) while (($file = readdir($handle))!==false)
{ {
if (substr($file, dol_strlen($file) -12) == '.modules.php' && substr($file,0,4) == 'pdf_') $filelist[]=$file;
{ }
$name = substr($file, 4, dol_strlen($file) - 16); closedir($handle);
$classname = substr($file, 0, dol_strlen($file) - 12); arsort($filelist);
foreach($filelist as $file)
{
if (preg_match('/\.modules\.php$/i',$file) && preg_match('/^(pdf_|doc_)/',$file))
{
if (file_exists($dir.'/'.$file))
{
$var=!$var; $var=!$var;
print '<tr '.$bc[$var].'><td>'; $name = substr($file, 4, dol_strlen($file) -16);
print $name; $classname = substr($file, 0, dol_strlen($file) -12);
print "</td><td>\n";
require_once $dir.$file; require_once $dir.'/'.$file;
$module = new $classname($db); $module = new $classname($db);
print $module->description; $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)
{
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>'; print '</td>';
// Activ // Active
if (in_array($name, $def)) if (in_array($name, $def))
{ {
print "<td align=\"center\">\n"; print "<td align=\"center\">\n";
@ -417,14 +462,24 @@ foreach ($dirmodels as $reldir)
print '<td align="center">'; print '<td align="center">';
print $form->textwithpicto('',$htmltooltip,1,0); print $form->textwithpicto('',$htmltooltip,1,0);
print '</td>'; print '</td>';
// Preview
print '<td align="center">'; print '<td align="center">';
if ($module->type == 'pdf')
{
print '<a href="'.$_SERVER["PHP_SELF"].'?action=specimen&module='.$name.'">'.img_object($langs->trans("Preview"),'sending').'</a>'; print '<a href="'.$_SERVER["PHP_SELF"].'?action=specimen&module='.$name.'">'.img_object($langs->trans("Preview"),'sending').'</a>';
}
else
{
print img_object($langs->trans("PreviewNotAvailable"),'generic');
}
print '</td>'; print '</td>';
print '</tr>'; print '</tr>';
} }
} }
closedir($handle); }
}
} }
} }
} }

View File

@ -1,5 +1,5 @@
<?php <?php
/* Copyright (C) 2011-2012 Regis Houssin <regis.houssin@capnetworks.com> /* Copyright (C) 2011-2014 Regis Houssin <regis.houssin@capnetworks.com>
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -98,7 +98,7 @@ if (! empty($field) && ! empty($element) && ! empty($table_element) && ! empty($
dol_include_once('/'.$module.'/class/actions_'.$subelement.'.class.php'); dol_include_once('/'.$module.'/class/actions_'.$subelement.'.class.php');
$classname = 'Actions'.ucfirst($subelement); $classname = 'Actions'.ucfirst($subelement);
$object = new $classname($db); $object = new $classname($db);
$ret = $object->$methodname(); $ret = $object->$methodname($fk_element);
if ($ret > 0) echo json_encode($object->$cachename); if ($ret > 0) echo json_encode($object->$cachename);
} }
} }

View File

@ -4,7 +4,7 @@
* Copyright (C) 2004 Benoit Mortier <benoit.mortier@opensides.be> * Copyright (C) 2004 Benoit Mortier <benoit.mortier@opensides.be>
* Copyright (C) 2004 Sebastien Di Cintio <sdicintio@ressource-toi.org> * Copyright (C) 2004 Sebastien Di Cintio <sdicintio@ressource-toi.org>
* Copyright (C) 2004 Eric Seigne <eric.seigne@ryxeo.com> * Copyright (C) 2004 Eric Seigne <eric.seigne@ryxeo.com>
* Copyright (C) 2005-2013 Regis Houssin <regis.houssin@capnetworks.com> * Copyright (C) 2005-2014 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2006 Andre Cianfarani <acianfa@free.fr> * Copyright (C) 2006 Andre Cianfarani <acianfa@free.fr>
* Copyright (C) 2006 Marc Barilley/Ocebo <marc@ocebo.com> * Copyright (C) 2006 Marc Barilley/Ocebo <marc@ocebo.com>
* Copyright (C) 2007 Franky Van Liedekerke <franky.van.liedekerker@telenet.be> * Copyright (C) 2007 Franky Van Liedekerke <franky.van.liedekerker@telenet.be>
@ -124,11 +124,11 @@ class Form
* @param string $typeofdata Type of data ('string' by default, 'amount', 'email', 'numeric:99', 'text' or 'textarea:rows:cols', 'day' or 'datepicker', 'ckeditor:dolibarr_zzz:width:height:savemethod:toolbarstartexpanded:rows:cols', 'select:xxx'...) * @param string $typeofdata Type of data ('string' by default, 'amount', 'email', 'numeric:99', 'text' or 'textarea:rows:cols', 'day' or 'datepicker', 'ckeditor:dolibarr_zzz:width:height:savemethod:toolbarstartexpanded:rows:cols', 'select:xxx'...)
* @param string $editvalue When in edit mode, use this value as $value instead of value (for example, you can provide here a formated price instead of value). Use '' to use same than $value * @param string $editvalue When in edit mode, use this value as $value instead of value (for example, you can provide here a formated price instead of value). Use '' to use same than $value
* @param object $extObject External object * @param object $extObject External object
* @param string $success Success message * @param mixed $custommsg String or Array of custom messages : eg array('success' => 'MyMessage', 'error' => 'MyMessage')
* @param string $moreparam More param to add on a href URL * @param string $moreparam More param to add on a href URL
* @return string HTML edit field * @return string HTML edit field
*/ */
function editfieldval($text, $htmlname, $value, $object, $perm, $typeofdata='string', $editvalue='', $extObject=null, $success=null, $moreparam='') function editfieldval($text, $htmlname, $value, $object, $perm, $typeofdata='string', $editvalue='', $extObject=null, $custommsg=null, $moreparam='')
{ {
global $conf,$langs,$db; global $conf,$langs,$db;
@ -140,7 +140,7 @@ class Form
// When option to edit inline is activated // When option to edit inline is activated
if (! empty($conf->global->MAIN_USE_JQUERY_JEDITABLE) && ! preg_match('/^select;|datehourpicker/',$typeofdata)) // TODO add jquery timepicker if (! empty($conf->global->MAIN_USE_JQUERY_JEDITABLE) && ! preg_match('/^select;|datehourpicker/',$typeofdata)) // TODO add jquery timepicker
{ {
$ret.=$this->editInPlace($object, $value, $htmlname, $perm, $typeofdata, $editvalue, $extObject, $success); $ret.=$this->editInPlace($object, $value, $htmlname, $perm, $typeofdata, $editvalue, $extObject, $custommsg);
} }
else else
{ {
@ -244,10 +244,10 @@ class Form
* @param string $inputType Type of input ('numeric', 'datepicker', 'textarea:rows:cols', 'ckeditor:dolibarr_zzz:width:height:?:1:rows:cols', 'select:xxx') * @param string $inputType Type of input ('numeric', 'datepicker', 'textarea:rows:cols', 'ckeditor:dolibarr_zzz:width:height:?:1:rows:cols', 'select:xxx')
* @param string $editvalue When in edit mode, use this value as $value instead of value * @param string $editvalue When in edit mode, use this value as $value instead of value
* @param object $extObject External object * @param object $extObject External object
* @param string $success Success message * @param mixed $custommsg String or Array of custom messages : eg array('success' => 'MyMessage', 'error' => 'MyMessage')
* @return string HTML edit in place * @return string HTML edit in place
*/ */
private function editInPlace($object, $value, $htmlname, $condition, $inputType='textarea', $editvalue=null, $extObject=null, $success=null) private function editInPlace($object, $value, $htmlname, $condition, $inputType='textarea', $editvalue=null, $extObject=null, $custommsg=null)
{ {
global $conf; global $conf;
@ -334,7 +334,18 @@ class Form
$out.= '<input id="loadmethod_'.$htmlname.'" value="'.$loadmethod.'" type="hidden"/>'."\n"; $out.= '<input id="loadmethod_'.$htmlname.'" value="'.$loadmethod.'" type="hidden"/>'."\n";
if (! empty($savemethod)) $out.= '<input id="savemethod_'.$htmlname.'" value="'.$savemethod.'" type="hidden"/>'."\n"; if (! empty($savemethod)) $out.= '<input id="savemethod_'.$htmlname.'" value="'.$savemethod.'" type="hidden"/>'."\n";
if (! empty($ext_element)) $out.= '<input id="ext_element_'.$htmlname.'" value="'.$ext_element.'" type="hidden"/>'."\n"; if (! empty($ext_element)) $out.= '<input id="ext_element_'.$htmlname.'" value="'.$ext_element.'" type="hidden"/>'."\n";
if (! empty($success)) $out.= '<input id="success_'.$htmlname.'" value="'.$success.'" type="hidden"/>'."\n"; if (! empty($custommsg))
{
if (is_array($custommsg))
{
if (!empty($custommsg['success']))
$out.= '<input id="successmsg_'.$htmlname.'" value="'.$custommsg['success'].'" type="hidden"/>'."\n";
if (!empty($custommsg['error']))
$out.= '<input id="errormsg_'.$htmlname.'" value="'.$custommsg['error'].'" type="hidden"/>'."\n";
}
else
$out.= '<input id="successmsg_'.$htmlname.'" value="'.$custommsg.'" type="hidden"/>'."\n";
}
if ($inputType == 'textarea') { if ($inputType == 'textarea') {
$out.= '<input id="textarea_'.$htmlname.'_rows" value="'.$rows.'" type="hidden"/>'."\n"; $out.= '<input id="textarea_'.$htmlname.'_rows" value="'.$rows.'" type="hidden"/>'."\n";
$out.= '<input id="textarea_'.$htmlname.'_cols" value="'.$cols.'" type="hidden"/>'."\n"; $out.= '<input id="textarea_'.$htmlname.'_cols" value="'.$cols.'" type="hidden"/>'."\n";

View File

@ -1,4 +1,4 @@
// Copyright (C) 2011-2012 Regis Houssin <regis.houssin@capnetworks.com> // Copyright (C) 2011-2014 Regis Houssin <regis.houssin@capnetworks.com>
// Copyright (C) 2011 Laurent Destailleur <eldy@users.sourceforge.net> // Copyright (C) 2011 Laurent Destailleur <eldy@users.sourceforge.net>
// //
// This program is free software; you can redistribute it and/or modify // This program is free software; you can redistribute it and/or modify
@ -358,12 +358,19 @@ $(document).ready(function() {
var res = $.parseJSON(result); var res = $.parseJSON(result);
if (res.error) { if (res.error) {
$(obj).html(obj.revert); $(obj).html(obj.revert);
var htmlname = $(obj).attr('id').substr(8);
var errormsg = $( '#errormsg_' + htmlname ).val();
if (errormsg != undefined) {
$.jnotify(errormsg, "error", true);
} else {
$.jnotify(res.error, "error", true); $.jnotify(res.error, "error", true);
}
} else { } else {
var htmlname = $(obj).attr('id').substr(8); var htmlname = $(obj).attr('id').substr(8);
var success = $( '#success_' + htmlname ).val(); var successmsg = $( '#successmsg_' + htmlname ).val();
if (success != undefined) { if (successmsg != undefined) {
$.jnotify(success, "ok"); $.jnotify(successmsg, "ok");
} }
$(obj).html(res.value); $(obj).html(res.value);
$(obj).hide(); $(obj).hide();

View File

@ -1,6 +1,6 @@
<?php <?php
/* Copyright (C) 2004-2014 Laurent Destailleur <eldy@users.sourceforge.net> /* Copyright (C) 2004-2014 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2009 Regis Houssin <regis.houssin@capnetworks.com> * Copyright (C) 2005-2014 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2007 Franky Van Liedekerke <franky.van.liedekerke@telenet.be> * Copyright (C) 2007 Franky Van Liedekerke <franky.van.liedekerke@telenet.be>
* Copyright (C) 2008 Chiptronik * Copyright (C) 2008 Chiptronik
* Copyright (C) 2011-2012 Philippe Grand <philippe.grand@atoo-net.com> * Copyright (C) 2011-2012 Philippe Grand <philippe.grand@atoo-net.com>
@ -21,7 +21,7 @@
*/ */
/** /**
* \file htdocs/core/modules/livraison/pdf/pdf_typhon.modules.php * \file htdocs/core/modules/livraison/doc/pdf_typhon.modules.php
* \ingroup livraison * \ingroup livraison
* \brief File of class to manage receving receipts with template Typhon * \brief File of class to manage receving receipts with template Typhon
* \author Laurent Destailleur * \author Laurent Destailleur

View File

@ -1,6 +1,6 @@
<?php <?php
/* Copyright (C) 2003 Rodolphe Quiedeville <rodolphe@quiedeville.org> /* Copyright (C) 2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2005-2010 Regis Houssin <regis.houssin@capnetworks.com> * Copyright (C) 2005-2014 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2006-2007 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2006-2007 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2007 Franky Van Liedekerke <franky.van.liedekerke@telenet.be> * Copyright (C) 2007 Franky Van Liedekerke <franky.van.liedekerke@telenet.be>
* Copyright (C) 2011-2012 Philippe Grand <philippe.grand@atoo-net.com> * Copyright (C) 2011-2012 Philippe Grand <philippe.grand@atoo-net.com>
@ -953,7 +953,7 @@ class Livraison extends CommonObject
} }
} }
$modelpath = "core/modules/livraison/pdf/"; $modelpath = "core/modules/livraison/doc/";
return $this->commonGenerateDocument($modelpath, $modele, $outputlangs, 0, 0, 0); return $this->commonGenerateDocument($modelpath, $modele, $outputlangs, 0, 0, 0);
} }