diff --git a/htdocs/admin/expedition.php b/htdocs/admin/expedition.php index d89b406280b..2efdfdd56ba 100644 --- a/htdocs/admin/expedition.php +++ b/htdocs/admin/expedition.php @@ -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 else if ($action == 'set') { @@ -175,14 +204,6 @@ else if ($action == 'setmodel') { 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'); - } -} /* diff --git a/htdocs/admin/fichinter.php b/htdocs/admin/fichinter.php index 37a3b2a5a5c..dad5f484a4d 100644 --- a/htdocs/admin/fichinter.php +++ b/htdocs/admin/fichinter.php @@ -3,7 +3,7 @@ * Copyright (C) 2004-2011 Laurent Destailleur * Copyright (C) 2004 Sebastien Di Cintio * Copyright (C) 2004 Benoit Mortier - * Copyright (C) 2005-2012 Regis Houssin + * Copyright (C) 2005-2014 Regis Houssin * Copyright (C) 2008 Raphael Bertrand (Resultic) * Copyright (C) 2011-2013 Juanjo Menent * Copyright (C) 2011-2013 Philippe Grand @@ -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 else if ($action == 'set') { @@ -261,13 +290,13 @@ foreach ($dirmodels as $reldir) require_once $dir.$file.'.php'; $module = new $file; - + if ($module->isEnabled()) { // Show modules according to features level if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) continue; if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) continue; - + $var=!$var; print ''.$module->nom."\n"; print $module->info(); @@ -372,78 +401,99 @@ foreach ($dirmodels as $reldir) $handle=opendir($dir); if (is_resource($handle)) { - while (($file = readdir($handle))!==false) - { - if (substr($file, dol_strlen($file) -12) == '.modules.php' && substr($file,0,4) == 'pdf_') + 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)) { - $var=!$var; - - $name = substr($file, 4, dol_strlen($file) -16); - $classname = substr($file, 0, dol_strlen($file) -12); - - require_once $dir.'/'.$file; - $module = new $classname($db); - - print ''; - print (empty($module->name)?$name:$module->name); - print "\n"; - require_once $dir.$file; - $module = new $classname($db); - print $module->description; - print ''; - - // Active - if (in_array($name, $def)) + if (file_exists($dir.'/'.$file)) { - print "\n"; - print 'scandir.'&label='.urlencode($module->name).'">'; - print img_picto($langs->trans("Enabled"),'switch_on'); - print ''; - print ""; - } - else - { - print "\n"; - print 'scandir.'&label='.urlencode($module->name).'">'.img_picto($langs->trans("Disabled"),'switch_off').''; - print ""; - } + $var=!$var; - // Default - print ""; - if ($conf->global->FICHEINTER_ADDON_PDF == "$name") - { - print img_picto($langs->trans("Default"),'on'); - } - else - { - print 'scandir.'&label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"),'off').''; - } - print ''; + $name = substr($file, 4, dol_strlen($file) -16); + $classname = substr($file, 0, dol_strlen($file) -12); - // Info - $htmltooltip = ''.$langs->trans("Name").': '.$module->name; - $htmltooltip.='
'.$langs->trans("Type").': '.($module->type?$module->type:$langs->trans("Unknown")); - $htmltooltip.='
'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur; - $htmltooltip.='

'.$langs->trans("FeaturesSupported").':'; - $htmltooltip.='
'.$langs->trans("Logo").': '.yn($module->option_logo,1,1); - $htmltooltip.='
'.$langs->trans("PaymentMode").': '.yn($module->option_modereg,1,1); - $htmltooltip.='
'.$langs->trans("PaymentConditions").': '.yn($module->option_condreg,1,1); - $htmltooltip.='
'.$langs->trans("MultiLanguage").': '.yn($module->option_multilang,1,1); - $htmltooltip.='
'.$langs->trans("WatermarkOnDraftOrders").': '.yn($module->option_draft_watermark,1,1); - print ''; - print $form->textwithpicto('',$htmltooltip,-1,0); - print ''; - - // Preview - $link=''.img_object($langs->trans("Preview"),'intervention').''; - print ''; - print $link; - print ''; + require_once $dir.'/'.$file; + $module = new $classname($db); - print ''; + $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 ''; + print (empty($module->name)?$name:$module->name); + print "\n"; + if (method_exists($module,'info')) print $module->info($langs); + else print $module->description; + print ''; + + // Active + if (in_array($name, $def)) + { + print "\n"; + print 'scandir.'&label='.urlencode($module->name).'">'; + print img_picto($langs->trans("Enabled"),'switch_on'); + print ''; + print ""; + } + else + { + print "\n"; + print 'scandir.'&label='.urlencode($module->name).'">'.img_picto($langs->trans("Disabled"),'switch_off').''; + print ""; + } + + // Default + print ""; + if ($conf->global->FICHEINTER_ADDON_PDF == "$name") + { + print img_picto($langs->trans("Default"),'on'); + } + else + { + print 'scandir.'&label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"),'off').''; + } + print ''; + + // Info + $htmltooltip = ''.$langs->trans("Name").': '.$module->name; + $htmltooltip.='
'.$langs->trans("Type").': '.($module->type?$module->type:$langs->trans("Unknown")); + $htmltooltip.='
'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur; + $htmltooltip.='

'.$langs->trans("FeaturesSupported").':'; + $htmltooltip.='
'.$langs->trans("Logo").': '.yn($module->option_logo,1,1); + $htmltooltip.='
'.$langs->trans("PaymentMode").': '.yn($module->option_modereg,1,1); + $htmltooltip.='
'.$langs->trans("PaymentConditions").': '.yn($module->option_condreg,1,1); + $htmltooltip.='
'.$langs->trans("MultiLanguage").': '.yn($module->option_multilang,1,1); + $htmltooltip.='
'.$langs->trans("WatermarkOnDraftOrders").': '.yn($module->option_draft_watermark,1,1); + print ''; + print $form->textwithpicto('',$htmltooltip,-1,0); + print ''; + + // Preview + print ''; + if ($module->type == 'pdf') + { + print ''.img_object($langs->trans("Preview"),'intervention').''; + } + else + { + print img_object($langs->trans("PreviewNotAvailable"),'generic'); + } + print ''; + + print ''; + } + } } } - closedir($handle); } } } diff --git a/htdocs/admin/livraison.php b/htdocs/admin/livraison.php index 415bff261de..b591aa79c08 100644 --- a/htdocs/admin/livraison.php +++ b/htdocs/admin/livraison.php @@ -4,7 +4,7 @@ * Copyright (C) 2004 Sebastien Di Cintio * Copyright (C) 2004 Benoit Mortier * Copyright (C) 2004 Eric Seigne - * Copyright (C) 2005-2012 Regis Houssin + * Copyright (C) 2005-2014 Regis Houssin * Copyright (C) 2011-2013 Juanjo Menent * Copyright (C) 2011-2013 Philippe Grand * @@ -95,7 +95,7 @@ if ($action == 'specimen') $dirmodels=array_merge(array('/'),(array) $conf->modules_parts['models']); 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)) { $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') { $ret = addDocumentModel($value, $type, $label, $scandir); @@ -356,75 +385,101 @@ clearstatcache(); $var=true; foreach ($dirmodels as $reldir) { - $dir = dol_buildpath($reldir."core/modules/livraison/pdf/"); + $dir = dol_buildpath($reldir."core/modules/livraison/doc/"); if (is_dir($dir)) { $handle = opendir($dir); if (is_resource($handle)) { - while (($file = readdir($handle))!==false) - { - if (substr($file, dol_strlen($file) -12) == '.modules.php' && substr($file,0,4) == 'pdf_') + 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)) { - $name = substr($file, 4, dol_strlen($file) - 16); - $classname = substr($file, 0, dol_strlen($file) - 12); + if (file_exists($dir.'/'.$file)) + { + $var=!$var; - $var=!$var; + $name = substr($file, 4, dol_strlen($file) -16); + $classname = substr($file, 0, dol_strlen($file) -12); - print ''; - print $name; - print "\n"; - require_once $dir.$file; - $module = new $classname($db); + require_once $dir.'/'.$file; + $module = new $classname($db); - print $module->description; - print ''; + $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; - // Activ - if (in_array($name, $def)) - { - print "\n"; - print 'scandir.'&label='.urlencode($module->name).'">'; - print img_picto($langs->trans("Enabled"),'switch_on'); - print ''; - print ""; - } - else - { - print "\n"; - print 'scandir.'&label='.urlencode($module->name).'">'.img_picto($langs->trans("Disabled"),'switch_off').''; - print ""; - } + if ($modulequalified) + { + print ''; + print (empty($module->name)?$name:$module->name); + print "\n"; + if (method_exists($module,'info')) print $module->info($langs); + else print $module->description; + print ''; - // Default - print ""; - if ($conf->global->LIVRAISON_ADDON_PDF == "$name") - { - print img_picto($langs->trans("Default"),'on'); - } - else - { - print 'scandir.'&label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"),'off').''; - } - print ''; + // Active + if (in_array($name, $def)) + { + print "\n"; + print 'scandir.'&label='.urlencode($module->name).'">'; + print img_picto($langs->trans("Enabled"),'switch_on'); + print ''; + print ""; + } + else + { + print "\n"; + print 'scandir.'&label='.urlencode($module->name).'">'.img_picto($langs->trans("Disabled"),'switch_off').''; + print ""; + } - // Info - $htmltooltip = ''.$langs->trans("Type").': '.($module->type?$module->type:$langs->trans("Unknown")); - $htmltooltip.='
'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur; - $htmltooltip.='

'.$langs->trans("FeaturesSupported").':'; - $htmltooltip.='
'.$langs->trans("Logo").': '.yn($module->option_logo,1,1); - print ''; - print $form->textwithpicto('',$htmltooltip,1,0); - print ''; - print ''; - print ''.img_object($langs->trans("Preview"),'sending').''; - print ''; + // Default + print ""; + if ($conf->global->LIVRAISON_ADDON_PDF == "$name") + { + print img_picto($langs->trans("Default"),'on'); + } + else + { + print 'scandir.'&label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"),'off').''; + } + print ''; - print ''; + // Info + $htmltooltip = ''.$langs->trans("Type").': '.($module->type?$module->type:$langs->trans("Unknown")); + $htmltooltip.='
'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur; + $htmltooltip.='

'.$langs->trans("FeaturesSupported").':'; + $htmltooltip.='
'.$langs->trans("Logo").': '.yn($module->option_logo,1,1); + print ''; + print $form->textwithpicto('',$htmltooltip,1,0); + print ''; + + // Preview + print ''; + if ($module->type == 'pdf') + { + print ''.img_object($langs->trans("Preview"),'sending').''; + } + else + { + print img_object($langs->trans("PreviewNotAvailable"),'generic'); + } + print ''; + + print ''; + } + } } } - closedir($handle); } } } diff --git a/htdocs/core/ajax/loadinplace.php b/htdocs/core/ajax/loadinplace.php index 69a0bbc72c7..de3a4e57d19 100644 --- a/htdocs/core/ajax/loadinplace.php +++ b/htdocs/core/ajax/loadinplace.php @@ -1,5 +1,5 @@ +/* Copyright (C) 2011-2014 Regis Houssin * * 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 @@ -98,7 +98,7 @@ if (! empty($field) && ! empty($element) && ! empty($table_element) && ! empty($ dol_include_once('/'.$module.'/class/actions_'.$subelement.'.class.php'); $classname = 'Actions'.ucfirst($subelement); $object = new $classname($db); - $ret = $object->$methodname(); + $ret = $object->$methodname($fk_element); if ($ret > 0) echo json_encode($object->$cachename); } } diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 5047d493f08..9cf905c6b72 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -4,7 +4,7 @@ * Copyright (C) 2004 Benoit Mortier * Copyright (C) 2004 Sebastien Di Cintio * Copyright (C) 2004 Eric Seigne - * Copyright (C) 2005-2013 Regis Houssin + * Copyright (C) 2005-2014 Regis Houssin * Copyright (C) 2006 Andre Cianfarani * Copyright (C) 2006 Marc Barilley/Ocebo * Copyright (C) 2007 Franky Van Liedekerke @@ -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 $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 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 * @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; @@ -140,7 +140,7 @@ class Form // When option to edit inline is activated 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 { @@ -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 $editvalue When in edit mode, use this value as $value instead of value * @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 */ - 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; @@ -334,7 +334,18 @@ class Form $out.= ''."\n"; if (! empty($savemethod)) $out.= ''."\n"; if (! empty($ext_element)) $out.= ''."\n"; - if (! empty($success)) $out.= ''."\n"; + if (! empty($custommsg)) + { + if (is_array($custommsg)) + { + if (!empty($custommsg['success'])) + $out.= ''."\n"; + if (!empty($custommsg['error'])) + $out.= ''."\n"; + } + else + $out.= ''."\n"; + } if ($inputType == 'textarea') { $out.= ''."\n"; $out.= ''."\n"; diff --git a/htdocs/core/js/editinplace.js b/htdocs/core/js/editinplace.js index 4fe29e4b4fb..17d70220b31 100644 --- a/htdocs/core/js/editinplace.js +++ b/htdocs/core/js/editinplace.js @@ -1,4 +1,4 @@ -// Copyright (C) 2011-2012 Regis Houssin +// Copyright (C) 2011-2014 Regis Houssin // Copyright (C) 2011 Laurent Destailleur // // This program is free software; you can redistribute it and/or modify @@ -358,12 +358,19 @@ $(document).ready(function() { var res = $.parseJSON(result); if (res.error) { $(obj).html(obj.revert); - $.jnotify(res.error, "error", true); + 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); + } + } else { var htmlname = $(obj).attr('id').substr(8); - var success = $( '#success_' + htmlname ).val(); - if (success != undefined) { - $.jnotify(success, "ok"); + var successmsg = $( '#successmsg_' + htmlname ).val(); + if (successmsg != undefined) { + $.jnotify(successmsg, "ok"); } $(obj).html(res.value); $(obj).hide(); diff --git a/htdocs/core/modules/livraison/pdf/index.html b/htdocs/core/modules/livraison/doc/index.html similarity index 100% rename from htdocs/core/modules/livraison/pdf/index.html rename to htdocs/core/modules/livraison/doc/index.html diff --git a/htdocs/core/modules/livraison/pdf/pdf_typhon.modules.php b/htdocs/core/modules/livraison/doc/pdf_typhon.modules.php similarity index 99% rename from htdocs/core/modules/livraison/pdf/pdf_typhon.modules.php rename to htdocs/core/modules/livraison/doc/pdf_typhon.modules.php index 569cfdff85e..363e7960fe8 100644 --- a/htdocs/core/modules/livraison/pdf/pdf_typhon.modules.php +++ b/htdocs/core/modules/livraison/doc/pdf_typhon.modules.php @@ -1,6 +1,6 @@ - * Copyright (C) 2005-2009 Regis Houssin + * Copyright (C) 2005-2014 Regis Houssin * Copyright (C) 2007 Franky Van Liedekerke * Copyright (C) 2008 Chiptronik * Copyright (C) 2011-2012 Philippe Grand @@ -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 * \brief File of class to manage receving receipts with template Typhon * \author Laurent Destailleur diff --git a/htdocs/livraison/class/livraison.class.php b/htdocs/livraison/class/livraison.class.php index ad20f319ed2..ebe46c78ac3 100644 --- a/htdocs/livraison/class/livraison.class.php +++ b/htdocs/livraison/class/livraison.class.php @@ -1,6 +1,6 @@ - * Copyright (C) 2005-2010 Regis Houssin + * Copyright (C) 2005-2014 Regis Houssin * Copyright (C) 2006-2007 Laurent Destailleur * Copyright (C) 2007 Franky Van Liedekerke * Copyright (C) 2011-2012 Philippe Grand @@ -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); }