diff --git a/htdocs/admin/facture.php b/htdocs/admin/facture.php index 359e3e481b8..3a8c5bc5464 100644 --- a/htdocs/admin/facture.php +++ b/htdocs/admin/facture.php @@ -359,6 +359,8 @@ foreach ($conf->file->dol_document_root as $dirroot) print ''; print "\n"; + + if (! empty($module->error)) dol_htmloutput_errors($module->error,'',$conf->global->MAIN_USE_JQUERY_JNOTIFY); } } } diff --git a/htdocs/includes/jquery/plugins/jnotify/jquery.jnotify.min.css b/htdocs/includes/jquery/plugins/jnotify/jquery.jnotify.min.css new file mode 100644 index 00000000000..77a2a82e1b1 --- /dev/null +++ b/htdocs/includes/jquery/plugins/jnotify/jquery.jnotify.min.css @@ -0,0 +1 @@ +.jnotify-container{position:fixed;top:0;left:0;width:100%;z-index:100000;}.jnotify-container .jnotify-notification{position:relative;}.jnotify-container .jnotify-notification .jnotify-background{position:absolute;top:0;left:0;width:100%;height:100%;background-color:#e3f0db;filter:alpha(opacity=90);-moz-opacity:.90;opacity:.90;z-index:1;}.jnotify-container .jnotify-notification a.jnotify-close,.jnotify-container .jnotify-notification a.jnotify-close:link,.jnotify-container .jnotify-notification a.jnotify-close:visited,.jnotify-container .jnotify-notification a.jnotify-close:focus,.jnotify-container .jnotify-notification a.jnotify-close:hover{position:absolute;top:2px;right:5px;padding:0 5px;font:bold 1.4em Arial,Helvetica,sans-serif;line-height:1em;color:#567b1b;text-decoration:none;z-index:3;cursor:pointer;}.jnotify-container .jnotify-notification .jnotify-message{position:relative;z-index:2;padding:20px;text-align:center;color:#567b1b;font:bold 1.4em Arial,Helvetica,sans-serif;line-height:1.2em;}.jnotify-container .jnotify-notification .jnotify-message *{font-size:1em;}.jnotify-container .jnotify-notification-error .jnotify-background{background-color:#d79eac;}.jnotify-container .jnotify-notification-error .jnotify-close,.jnotify-container .jnotify-notification-error .jnotify-message{color:#a72947!important;}.jnotify-container .jnotify-notification-warning .jnotify-background{background-color:#fff7d1;}.jnotify-container .jnotify-notification-warning .jnotify-close,.jnotify-container .jnotify-notification-warning .jnotify-message{color:#c2a928!important;} \ No newline at end of file diff --git a/htdocs/includes/jquery/plugins/jnotify/jquery.jnotify.min.js b/htdocs/includes/jquery/plugins/jnotify/jquery.jnotify.min.js new file mode 100644 index 00000000000..0c70e3e7c58 --- /dev/null +++ b/htdocs/includes/jquery/plugins/jnotify/jquery.jnotify.min.js @@ -0,0 +1,21 @@ +/* + * jNotify jQuery Plug-in + * + * Copyright 2010 Giva, Inc. (http://www.givainc.com/labs/) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * Date: 2010-09-30 + * Rev: 1.1.00 + */ +(function(B){B.jnotify=function(K,M,L){return new C(K,M,L)};B.jnotify.version="1.1.00";var J,D=[],E=0,H=false,I=false,G,F,A={type:"",delay:2000,sticky:false,closeLabel:"×",showClose:true,fadeSpeed:1000,slideSpeed:250,classContainer:"jnotify-container",classNotification:"jnotify-notification",classBackground:"jnotify-background",classClose:"jnotify-close",classMessage:"jnotify-message",init:null,create:null,beforeRemove:null,remove:null,transition:null};B.jnotify.setup=function(K){A=B.extend({},A,K)};B.jnotify.play=function(M,N){if(H&&(M!==true)||(D.length==0)){return }H=true;var L=D.shift();F=L;var K=(arguments.length>=2)?parseInt(N,10):L.options.delay;G=setTimeout(function(){G=0;L.remove(function(){if(D.length==0){H=false}else{if(!I){B.jnotify.play(true)}}})},K)};B.jnotify.pause=function(){clearTimeout(G);if(G){D.unshift(F)}I=H=true};B.jnotify.resume=function(){I=false;B.jnotify.play(true,0)};function C(P,N){var M=this,K=typeof N;if(K=="number"){N=B.extend({},A,{delay:N})}else{if(K=="boolean"){N=B.extend({},A,{sticky:true})}else{if(K=="string"){N=B.extend({},A,{type:N,delay:((arguments.length>2)&&(typeof arguments[2]=="number"))?arguments[2]:A.delay,sticky:((arguments.length>2)&&(typeof arguments[2]=="boolean"))?arguments[2]:A.sticky})}else{N=B.extend({},A,N)}}}this.options=N;if(!J){J=B('
').appendTo("body");if(B.isFunction(N.init)){N.init.apply(M,[J])}}function O(S){var R='
'+(N.sticky&&N.showClose?(''+N.closeLabel+""):"")+'
'+S+"
";E++;var Q=B(R);if(N.sticky){Q.find("a."+N.classClose).bind("click.jnotify",function(){M.remove()})}if(B.isFunction(N.create)){N.create.apply(M,[Q])}return Q.appendTo(J)}this.remove=function(U){var Q=L.find("."+N.classMessage),S=Q.parent();var R=E--;if(B.isFunction(N.beforeRemove)){N.beforeRemove.apply(M,[Q])}function T(){S.remove();if(B.isFunction(U)){U.apply(M,[Q])}if(B.isFunction(N.remove)){N.remove.apply(M,[Q])}}if(B.isFunction(N.transition)){N.transition.apply(M,[S,Q,R,T,N])}else{Q.fadeTo(N.fadeSpeed,0.01,function(){if(R<=1){T()}else{S.slideUp(N.slideSpeed,T)}});if(E<=0){S.fadeOut(N.fadeSpeed)}}};var L=O(P);if(!N.sticky){D.push(this);B.jnotify.play()}return this}})(jQuery); \ No newline at end of file diff --git a/htdocs/includes/modules/facture/mod_facture_mercure.php b/htdocs/includes/modules/facture/mod_facture_mercure.php index 998acaea7e7..99fee698c2b 100644 --- a/htdocs/includes/modules/facture/mod_facture_mercure.php +++ b/htdocs/includes/modules/facture/mod_facture_mercure.php @@ -132,6 +132,7 @@ class mod_facture_mercure extends ModeleNumRefFactures else $where.=" AND type != 2"; $numFinal=get_next_value($db,$mask,'facture','facnumber',$where,$objsoc,$facture->date,$mode); + if (! preg_match('/([0-9])+/',$numFinal)) $this->error = $numFinal; return $numFinal; } diff --git a/htdocs/lib/functions.lib.php b/htdocs/lib/functions.lib.php index d3e9a6066cb..5ec4274b06c 100644 --- a/htdocs/lib/functions.lib.php +++ b/htdocs/lib/functions.lib.php @@ -3414,31 +3414,44 @@ function monthArrayOrSelected($selected=0) * @return html Return html output * @see dol_print_error */ -function dol_htmloutput_mesg($mesgstring='',$mesgarray='', $style='ok') +function dol_htmloutput_mesg($mesgstring='',$mesgarray='', $style='ok', $ajax=0) { global $langs; $ret = ''; + $out = ''; if (is_array($mesgarray) && sizeof($mesgarray)) { $langs->load("errors"); - print '
'; + if (! $ajax) $out.= '
'; foreach($mesgarray as $message) { $ret++; - print $langs->trans($message); - if ($ret < sizeof($mesgarray)) print "
\n"; + $out.= $langs->trans($message); + if ($ret < sizeof($mesgarray)) $out.= "
\n"; } - print '
'; + if (! $ajax) $out.= '
'; } if ($mesgstring) { $langs->load("errors"); $ret++; - print '
'; - print $langs->trans($mesgstring); - print '
'; + if (! $ajax) $out.= '
'; + $out.= $langs->trans($mesgstring); + if (! $ajax) $out.= '
'; + } + if ($ajax) + { + print ''; + } + else + { + print $out; } return $ret; @@ -3451,9 +3464,9 @@ function dol_htmloutput_mesg($mesgstring='',$mesgarray='', $style='ok') * @return html Return html output * @see dol_print_error */ -function dol_htmloutput_errors($mesgstring='',$mesgarray='') +function dol_htmloutput_errors($mesgstring='',$mesgarray='',$ajax=0) { - return dol_htmloutput_mesg($mesgstring, $mesgarray, 'error'); + return dol_htmloutput_mesg($mesgstring, $mesgarray, 'error',$ajax); } diff --git a/htdocs/lib/functions2.lib.php b/htdocs/lib/functions2.lib.php index 0ad45864139..32b17e513f2 100644 --- a/htdocs/lib/functions2.lib.php +++ b/htdocs/lib/functions2.lib.php @@ -422,46 +422,33 @@ function get_next_value($db,$mask,$table,$field,$where='',$objsoc='',$date='',$m { if ($maskraz > 12) return 'ErrorBadMaskBadRazMonth'; - // Define posy, posm and reg - if ($maskraz > 1) - { - if (! preg_match('/^(.*)\{(y+)\}\{(m+)\}/i',$maskwithonlyymcode) - && ! preg_match('/^(.*)\{(m+)\}\{(y+)\}/i',$maskwithonlyymcode)) return 'ErrorCantUseRazInStartedYearIfNoYearMonthInMask'; - if (preg_match('/^(.*)\{(y+)\}\{(m+)\}/i',$maskwithonlyymcode,$reg)) { $posy=2; $posm=3; } - elseif (preg_match('/^(.*)\{(m+)\}\{(y+)\}/i',$maskwithonlyymcode,$reg)) { $posy=3; $posm=2; } - if (dol_strlen($reg[$posy]) < 2) return 'ErrorCantUseRazWithYearOnOneDigit'; - } - else - { - if (! preg_match('/^(.*)\{(y+)\}/i',$maskwithonlyymcode)) return 'ErrorCantUseRazIfNoYearInMask'; - if (preg_match('/^(.*)\{(y+)\}/i',$maskwithonlyymcode,$reg)) { $posy=2; $posm=0; } - } - //print "x".$maskwithonlyymcode." ".$maskraz." ".$posy." ".$posm; - + // Define reg + if ($maskraz > 1 && ! preg_match('/^(.*)\{(m+)\}\{(y+)\}/i',$maskwithonlyymcode,$reg) + && ! preg_match('/^(.*)\{(y)+\}\{(m)+\}/i',$maskwithonlyymcode,$reg)) return 'ErrorCantUseRazInStartedYearIfNoYearMonthInMask'; + if ($maskraz <= 1 && ! preg_match('/^(.*)\{(y)+\}/i',$maskwithonlyymcode,$reg)) return 'ErrorCantUseRazIfNoYearInMask'; + //print "x".$maskwithonlyymcode." ".$maskraz; + // Define $yearcomp and $monthcomp (that will be use in the select where to search max number) $monthcomp=$maskraz; $yearoffset=0; $yearcomp=0; if (date("m",$date) < $maskraz) { $yearoffset=-1; } // If current month lower that month of return to zero, year is previous year - if (dol_strlen($reg[$posy]) == 4) $yearcomp=sprintf("%04d",date("Y",$date)+$yearoffset); - if (dol_strlen($reg[$posy]) == 2) $yearcomp=sprintf("%02d",date("y",$date)+$yearoffset); - if (dol_strlen($reg[$posy]) == 1) $yearcomp=substr(date("y",$date),2,1)+$yearoffset; + if (dol_strlen($reg[2]) == 4) $yearcomp=sprintf("%04d",date("Y",$date)+$yearoffset); + if (dol_strlen($reg[2]) == 2) $yearcomp=sprintf("%02d",date("y",$date)+$yearoffset); + if (dol_strlen($reg[2]) == 1) $yearcomp=substr(date("y",$date),2,1)+$yearoffset; + $sqlwhere=''; $sqlwhere.='( (SUBSTRING('.$field.', '.(dol_strlen($reg[1])+1).', '.dol_strlen($reg[2]).') >= '.$yearcomp; if ($monthcomp > 1) // Test useless if monthcomp = 1 (or 0 is same as 1) { - if (dol_strlen($reg[$posy]) == 4) $yearcomp1=sprintf("%04d",date("Y",$date)+$yearoffset+1); - if (dol_strlen($reg[$posy]) == 2) $yearcomp1=sprintf("%02d",date("y",$date)+$yearoffset+1); - // FIXME If mask is {mm}{yy}, sqlwhere is wrong here - $sqlwhere.=' AND SUBSTRING('.$field.', '.(dol_strlen($reg[1])+dol_strlen($reg[2])+1).', '.dol_strlen($reg[3]).') >= '.$monthcomp.')'; - $sqlwhere.=' OR SUBSTRING('.$field.', '.(dol_strlen($reg[1])+1).', '.dol_strlen($reg[2]).') >= '.$yearcomp1.' )'; + $sqlwhere.=' AND SUBSTRING('.$field.', '.(dol_strlen($reg[1])+dol_strlen($reg[2])+1).', '.dol_strlen($reg[3]).') >= '.$monthcomp.')'; + $sqlwhere.=' OR SUBSTRING('.$field.', '.(dol_strlen($reg[1])+1).', '.dol_strlen($reg[2]).') >= '.sprintf("%02d",($yearcomp+1)).' )'; } else { $sqlwhere.=') )'; } } - //print $sqlwhere; //print "masktri=".$masktri." maskcounter=".$maskcounter." maskraz=".$maskraz." maskoffset=".$maskoffset." yearcomp=".$yearcomp."
\n"; // Define $sqlstring diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index 71240b780b7..9fc4602b7e6 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -858,6 +858,8 @@ function top_htmlhead($head, $title='', $disablejs=0, $disablehead=0, $arrayofjs if (!empty($conf->global->MAIN_USE_JQUERY_THEME)) $jquerytheme = $conf->global->MAIN_USE_JQUERY_THEME; print ''."\n"; print ''."\n"; + // jQuery jnotify + if ($conf->global->MAIN_USE_JQUERY_JNOTIFY) print ''."\n"; } print ''."\n"; @@ -904,6 +906,8 @@ function top_htmlhead($head, $title='', $disablejs=0, $disablehead=0, $arrayofjs { print ''."\n"; } + // jQuery jnotify + if ($conf->global->MAIN_USE_JQUERY_JNOTIFY) print ''."\n"; // CKEditor if (! empty($conf->global->FCKEDITOR_EDITORNAME) && $conf->global->FCKEDITOR_EDITORNAME == 'ckeditor') {