diff --git a/build/rpm/dolibarr_fedora.spec b/build/rpm/dolibarr_fedora.spec index 1d769c43752..25da9600273 100755 --- a/build/rpm/dolibarr_fedora.spec +++ b/build/rpm/dolibarr_fedora.spec @@ -117,9 +117,9 @@ do lang2=`expr substr $lang 4 2 | tr "[:upper:]" "[:lower:]"`; echo "%dir %{_datadir}/%{name}/htdocs/langs/${lang}" >> %{name}.lang if [ "$lang1" = "$lang2" ] ; then - echo "%lang(${lang1}) %{_datadir}/%{name}/htdocs/langs/${lang}/*.lang" + echo "%lang(${lang1}) %{_datadir}/%{name}/htdocs/langs/${lang}/*.lang" else - echo "%lang(${lang}) %{_datadir}/%{name}/htdocs/langs/${lang}/*.lang" + echo "%lang(${lang}) %{_datadir}/%{name}/htdocs/langs/${lang}/*.lang" fi done >>%{name}.lang @@ -238,20 +238,20 @@ echo Create document directory $docdir export config=%{_sysconfdir}/dolibarr/conf.php if [ -s $config ] && grep -q "File generated by" $config then - # File already exist. We add params not found. - echo Add new params to overwrite path to use shared libraries/fonts - grep -q -c "dolibarr_lib_ADODB_PATH" $config || [ ! -d "/usr/share/php/adodb" ] || echo "" >> $config - grep -q -c "dolibarr_lib_FPDI_PATH" $config || [ ! -d "/usr/share/php/fpdi" ] || echo "" >> $config - #grep -q -c "dolibarr_lib_GEOIP_PATH" $config || echo "" >> $config - grep -q -c "dolibarr_lib_NUSOAP_PATH" $config || [ ! -d "/usr/share/php/nusoap" ] || echo "" >> $config - grep -q -c "dolibarr_lib_ODTPHP_PATHTOPCLZIP" $config || [ ! -d "/usr/share/php/libphp-pclzip" ] || echo "" >> $config - #grep -q -c "dolibarr_lib_PHPEXCEL_PATH" $config || echo "" >> $config - #grep -q -c "dolibarr_lib_TCPDF_PATH" $config || echo "" >> $config - grep -q -c "dolibarr_js_CKEDITOR" $config || [ ! -d "/usr/share/javascript/ckeditor" ] || echo "" >> $config - grep -q -c "dolibarr_js_JQUERY" $config || [ ! -d "/usr/share/javascript/jquery" ] || echo "" >> $config - grep -q -c "dolibarr_js_JQUERY_UI" $config || [ ! -d "/usr/share/javascript/jquery-ui" ] || echo "" >> $config - grep -q -c "dolibarr_js_JQUERY_FLOT" $config || [ ! -d "/usr/share/javascript/flot" ] || echo "" >> $config - grep -q -c "dolibarr_font_DOL_DEFAULT_TTF_BOLD" $config || echo "" >> $config + # File already exist. We add params not found. + echo Add new params to overwrite path to use shared libraries/fonts + grep -q -c "dolibarr_lib_ADODB_PATH" $config || [ ! -d "/usr/share/php/adodb" ] || echo "" >> $config + grep -q -c "dolibarr_lib_FPDI_PATH" $config || [ ! -d "/usr/share/php/fpdi" ] || echo "" >> $config + #grep -q -c "dolibarr_lib_GEOIP_PATH" $config || echo "" >> $config + grep -q -c "dolibarr_lib_NUSOAP_PATH" $config || [ ! -d "/usr/share/php/nusoap" ] || echo "" >> $config + grep -q -c "dolibarr_lib_ODTPHP_PATHTOPCLZIP" $config || [ ! -d "/usr/share/php/libphp-pclzip" ] || echo "" >> $config + #grep -q -c "dolibarr_lib_PHPEXCEL_PATH" $config || echo "" >> $config + #grep -q -c "dolibarr_lib_TCPDF_PATH" $config || echo "" >> $config + grep -q -c "dolibarr_js_CKEDITOR" $config || [ ! -d "/usr/share/javascript/ckeditor" ] || echo "" >> $config + grep -q -c "dolibarr_js_JQUERY" $config || [ ! -d "/usr/share/javascript/jquery" ] || echo "" >> $config + grep -q -c "dolibarr_js_JQUERY_UI" $config || [ ! -d "/usr/share/javascript/jquery-ui" ] || echo "" >> $config + grep -q -c "dolibarr_js_JQUERY_FLOT" $config || [ ! -d "/usr/share/javascript/flot" ] || echo "" >> $config + grep -q -c "dolibarr_font_DOL_DEFAULT_TTF_BOLD" $config || echo "" >> $config fi # Create config for SE Linux @@ -264,13 +264,13 @@ restorecon -R -v /var/lib/dolibarr # Create a config link dolibarr.conf if [ ! -L $apachelink ]; then - apachelinkdir=`dirname $apachelink` - if [ -d $apachelinkdir ]; then - echo Create dolibarr web server config link from %{_sysconfdir}/dolibarr/apache.conf to $apachelink - ln -fs %{_sysconfdir}/dolibarr/apache.conf $apachelink - else - echo Do not create link $apachelink - web server conf dir $apachelinkdir not found. web server package may not be installed - fi + apachelinkdir=`dirname $apachelink` + if [ -d $apachelinkdir ]; then + echo Create dolibarr web server config link from %{_sysconfdir}/dolibarr/apache.conf to $apachelink + ln -fs %{_sysconfdir}/dolibarr/apache.conf $apachelink + else + echo Do not create link $apachelink - web server conf dir $apachelinkdir not found. web server package may not be installed + fi fi echo Set permission to $apacheuser:$apachegroup on /var/lib/dolibarr @@ -302,30 +302,30 @@ echo if [ "x$1" = "x0" ] ; then - # Remove - echo "Removed package" + # Remove + echo "Removed package" - # Define vars - export apachelink="%{_sysconfdir}/httpd/conf.d/dolibarr.conf" - - # Remove apache link - if [ -L $apachelink ] ; - then - echo "Delete apache config link for Dolibarr ($apachelink)" - %{__rm} -f $apachelink - status=purge - fi - - # Restart web servers if required - if [ "x$status" = "xpurge" ] ; - then - # Restart web server - echo Restart web server - /sbin/service httpd restart - fi + # Define vars + export apachelink="%{_sysconfdir}/httpd/conf.d/dolibarr.conf" + + # Remove apache link + if [ -L $apachelink ] ; + then + echo "Delete apache config link for Dolibarr ($apachelink)" + %{__rm} -f $apachelink + status=purge + fi + + # Restart web servers if required + if [ "x$status" = "xpurge" ] ; + then + # Restart web server + echo Restart web server + /sbin/service httpd restart + fi else - # Upgrade - echo "No remove action done (this is an upgrade)" + # Upgrade + echo "No remove action done (this is an upgrade)" fi # version x.y.z-0.1.a for alpha, x.y.z-0.2.b for beta, x.y.z-0.3 for release diff --git a/build/rpm/dolibarr_generic.spec b/build/rpm/dolibarr_generic.spec index 8fe3de26340..3f059aafa24 100755 --- a/build/rpm/dolibarr_generic.spec +++ b/build/rpm/dolibarr_generic.spec @@ -190,9 +190,9 @@ do lang2=`expr substr $lang 4 2 | tr "[:upper:]" "[:lower:]"`; echo "%dir %{_datadir}/%{name}/htdocs/langs/${lang}" >> %{name}.lang if [ "$lang1" = "$lang2" ] ; then - echo "%lang(${lang1}) %{_datadir}/%{name}/htdocs/langs/${lang}/*.lang" + echo "%lang(${lang1}) %{_datadir}/%{name}/htdocs/langs/${lang}/*.lang" else - echo "%lang(${lang}) %{_datadir}/%{name}/htdocs/langs/${lang}/*.lang" + echo "%lang(${lang}) %{_datadir}/%{name}/htdocs/langs/${lang}/*.lang" fi done >>%{name}.lang @@ -323,28 +323,28 @@ export installconfig="%{_sysconfdir}/dolibarr/install.forced.php" # Detect OS os='unknown'; if [ -d %{_sysconfdir}/httpd/conf.d ]; then - export os='fedora-redhat'; - export apachelink="%{_sysconfdir}/httpd/conf.d/dolibarr.conf" - export apacheuser='apache'; - export apachegroup='apache'; + export os='fedora-redhat'; + export apachelink="%{_sysconfdir}/httpd/conf.d/dolibarr.conf" + export apacheuser='apache'; + export apachegroup='apache'; fi if [ -d %{_sysconfdir}/apache2/conf.d -a `grep ^wwwrun /etc/passwd | wc -l` -ge 1 ]; then - export os='opensuse'; - export apachelink="%{_sysconfdir}/apache2/conf.d/dolibarr.conf" - export apacheuser='wwwrun'; - export apachegroup='www'; + export os='opensuse'; + export apachelink="%{_sysconfdir}/apache2/conf.d/dolibarr.conf" + export apacheuser='wwwrun'; + export apachegroup='www'; fi if [ -d %{_sysconfdir}/httpd/conf.d -a `grep -i "^mageia\|mandriva" /etc/issue | wc -l` -ge 1 ]; then - export os='mageia-mandriva'; - export apachelink="%{_sysconfdir}/httpd/conf.d/dolibarr.conf" - export apacheuser='apache'; - export apachegroup='apache'; + export os='mageia-mandriva'; + export apachelink="%{_sysconfdir}/httpd/conf.d/dolibarr.conf" + export apacheuser='apache'; + export apachegroup='apache'; fi if [ -d %{_sysconfdir}/apache2/conf.d -a `grep ^www-data /etc/passwd | wc -l` -ge 1 ]; then - export os='ubuntu-debian'; - export apachelink="%{_sysconfdir}/apache2/conf.d/dolibarr.conf" - export apacheuser='www-data'; - export apachegroup='www-data'; + export os='ubuntu-debian'; + export apachelink="%{_sysconfdir}/apache2/conf.d/dolibarr.conf" + export apacheuser='www-data'; + export apachegroup='www-data'; fi echo OS detected: $os %endif @@ -363,16 +363,16 @@ echo Create document directory $docdir # Create install.forced.php into Dolibarr install directory if [ "x$os" = "xubuntu-debian" ] then - superuserlogin='' - superuserpassword='' - if [ -f %{_sysconfdir}/mysql/debian.cnf ] ; then - # Load superuser login and pass - superuserlogin=$(/bin/grep --max-count=1 "user" %{_sysconfdir}/mysql/debian.cnf | /bin/sed -e 's/^user[ =]*//g') - superuserpassword=$(/bin/grep --max-count=1 "password" %{_sysconfdir}/mysql/debian.cnf | /bin/sed -e 's/^password[ =]*//g') - fi - echo Mysql superuser found to use is $superuserlogin - %{__cat} /usr/share/dolibarr/build/rpm/install.forced.php.generic | sed -e 's/__SUPERUSERLOGIN__/'$superuserlogin'/g' | sed -e 's/__SUPERUSERPASSWORD__/'$superuserpassword'/g' > $installconfig - %{__chmod} -R 660 $installconfig + superuserlogin='' + superuserpassword='' + if [ -f %{_sysconfdir}/mysql/debian.cnf ] ; then + # Load superuser login and pass + superuserlogin=$(/bin/grep --max-count=1 "user" %{_sysconfdir}/mysql/debian.cnf | /bin/sed -e 's/^user[ =]*//g') + superuserpassword=$(/bin/grep --max-count=1 "password" %{_sysconfdir}/mysql/debian.cnf | /bin/sed -e 's/^password[ =]*//g') + fi + echo Mysql superuser found to use is $superuserlogin + %{__cat} /usr/share/dolibarr/build/rpm/install.forced.php.generic | sed -e 's/__SUPERUSERLOGIN__/'$superuserlogin'/g' | sed -e 's/__SUPERUSERPASSWORD__/'$superuserpassword'/g' > $installconfig + %{__chmod} -R 660 $installconfig fi %endif @@ -383,29 +383,29 @@ fi export config=%{_sysconfdir}/dolibarr/conf.php if [ -s $config ] && grep -q "File generated by" $config then - # File already exist. We add params not found. - echo Add new params to overwrite path to use shared libraries/fonts - grep -q -c "dolibarr_lib_ADODB_PATH" $config || [ ! -d "/usr/share/php/adodb" ] || echo "" >> $config - grep -q -c "dolibarr_lib_FPDI_PATH" $config || [ ! -d "/usr/share/php/fpdi" ] || echo "" >> $config - #grep -q -c "dolibarr_lib_GEOIP_PATH" $config || echo "" >> $config - grep -q -c "dolibarr_lib_NUSOAP_PATH" $config || [ ! -d "/usr/share/php/nusoap" ] || echo "" >> $config - grep -q -c "dolibarr_lib_ODTPHP_PATHTOPCLZIP" $config || [ ! -d "/usr/share/php/libphp-pclzip" ] || echo "" >> $config - #grep -q -c "dolibarr_lib_PHPEXCEL_PATH" $config || echo "" >> $config - #grep -q -c "dolibarr_lib_TCPDF_PATH" $config || echo "" >> $config - grep -q -c "dolibarr_js_CKEDITOR" $config || [ ! -d "/usr/share/javascript/ckeditor" ] || echo "" >> $config - grep -q -c "dolibarr_js_JQUERY" $config || [ ! -d "/usr/share/javascript/jquery" ] || echo "" >> $config - grep -q -c "dolibarr_js_JQUERY_UI" $config || [ ! -d "/usr/share/javascript/jquery-ui" ] || echo "" >> $config - grep -q -c "dolibarr_js_JQUERY_FLOT" $config || [ ! -d "/usr/share/javascript/flot" ] || echo "" >> $config + # File already exist. We add params not found. + echo Add new params to overwrite path to use shared libraries/fonts + grep -q -c "dolibarr_lib_ADODB_PATH" $config || [ ! -d "/usr/share/php/adodb" ] || echo "" >> $config + grep -q -c "dolibarr_lib_FPDI_PATH" $config || [ ! -d "/usr/share/php/fpdi" ] || echo "" >> $config + #grep -q -c "dolibarr_lib_GEOIP_PATH" $config || echo "" >> $config + grep -q -c "dolibarr_lib_NUSOAP_PATH" $config || [ ! -d "/usr/share/php/nusoap" ] || echo "" >> $config + grep -q -c "dolibarr_lib_ODTPHP_PATHTOPCLZIP" $config || [ ! -d "/usr/share/php/libphp-pclzip" ] || echo "" >> $config + #grep -q -c "dolibarr_lib_PHPEXCEL_PATH" $config || echo "" >> $config + #grep -q -c "dolibarr_lib_TCPDF_PATH" $config || echo "" >> $config + grep -q -c "dolibarr_js_CKEDITOR" $config || [ ! -d "/usr/share/javascript/ckeditor" ] || echo "" >> $config + grep -q -c "dolibarr_js_JQUERY" $config || [ ! -d "/usr/share/javascript/jquery" ] || echo "" >> $config + grep -q -c "dolibarr_js_JQUERY_UI" $config || [ ! -d "/usr/share/javascript/jquery-ui" ] || echo "" >> $config + grep -q -c "dolibarr_js_JQUERY_FLOT" $config || [ ! -d "/usr/share/javascript/flot" ] || echo "" >> $config %if 0%{?fedora} || 0%{?rhel_version} || 0%{?centos_version} - grep -q -c "dolibarr_font_DOL_DEFAULT_TTF_BOLD" $config || echo "" >> $config + grep -q -c "dolibarr_font_DOL_DEFAULT_TTF_BOLD" $config || echo "" >> $config %else %if 0%{?mdkversion} - grep -q -c "dolibarr_font_DOL_DEFAULT_TTF_BOLD" $config || echo "" >> $config + grep -q -c "dolibarr_font_DOL_DEFAULT_TTF_BOLD" $config || echo "" >> $config %else %if 0%{?suse_version} - grep -q -c "dolibarr_font_DOL_DEFAULT_TTF_BOLD" $config || echo "" >> $config + grep -q -c "dolibarr_font_DOL_DEFAULT_TTF_BOLD" $config || echo "" >> $config %else - grep -q -c "dolibarr_font_DOL_DEFAULT_TTF_BOLD" $config || echo "" >> $config + grep -q -c "dolibarr_font_DOL_DEFAULT_TTF_BOLD" $config || echo "" >> $config %endif %endif %endif @@ -418,12 +418,12 @@ if [ "x$os" = "xfedora-redhat" -a -s /sbin/restorecon ]; then %endif %if 0%{?mdkversion} || 0%{?suse_version} %else - echo Add SE Linux permissions for dolibarr - # semanage add records into /etc/selinux/targeted/contexts/files/file_contexts.local - semanage fcontext -a -t httpd_sys_script_rw_t "/etc/dolibarr(/.*?)" - semanage fcontext -a -t httpd_sys_script_rw_t "/var/lib/dolibarr(/.*?)" - restorecon -R -v /etc/dolibarr - restorecon -R -v /var/lib/dolibarr + echo Add SE Linux permissions for dolibarr + # semanage add records into /etc/selinux/targeted/contexts/files/file_contexts.local + semanage fcontext -a -t httpd_sys_script_rw_t "/etc/dolibarr(/.*?)" + semanage fcontext -a -t httpd_sys_script_rw_t "/var/lib/dolibarr(/.*?)" + restorecon -R -v /etc/dolibarr + restorecon -R -v /var/lib/dolibarr %endif %if 0%{?fedora} || 0%{?rhel_version} || 0%{?centos_version} || 0%{?mdkversion} || 0%{?suse_version} %else @@ -432,13 +432,13 @@ fi # Create a config link dolibarr.conf if [ ! -L $apachelink ]; then - apachelinkdir=`dirname $apachelink` - if [ -d $apachelinkdir ]; then - echo Create dolibarr web server config link from %{_sysconfdir}/dolibarr/apache.conf to $apachelink - ln -fs %{_sysconfdir}/dolibarr/apache.conf $apachelink - else - echo Do not create link $apachelink - web server conf dir $apachelinkdir not found. web server package may not be installed - fi + apachelinkdir=`dirname $apachelink` + if [ -d $apachelinkdir ]; then + echo Create dolibarr web server config link from %{_sysconfdir}/dolibarr/apache.conf to $apachelink + ln -fs %{_sysconfdir}/dolibarr/apache.conf $apachelink + else + echo Do not create link $apachelink - web server conf dir $apachelinkdir not found. web server package may not be installed + fi fi echo Set permission to $apacheuser:$apachegroup on /var/lib/dolibarr @@ -451,30 +451,30 @@ echo Restart web server /sbin/service httpd restart %else if [ -f %{_sysconfdir}/init.d/httpd ]; then - %{_sysconfdir}/init.d/httpd restart + %{_sysconfdir}/init.d/httpd restart fi if [ -f %{_sysconfdir}/init.d/apache2 ]; then - %{_sysconfdir}/init.d/apache2 restart + %{_sysconfdir}/init.d/apache2 restart fi %endif # Restart mysql server echo Restart mysql server %if 0%{?fedora} || 0%{?rhel_version} || 0%{?centos_version} || 0%{?mdkversion} - /sbin/service mysqld restart + /sbin/service mysqld restart %else %if 0%{?suse_version} if [ -f /etc/init.d/mysqld ]; then - /etc/init.d/mysqld restart + /etc/init.d/mysqld restart else - /sbin/service mysql restart + /sbin/service mysql restart fi %else if [ -f /etc/init.d/mysqld ]; then - /etc/init.d/mysqld restart + /etc/init.d/mysqld restart fi if [ -f /etc/init.d/mysql ]; then - /etc/init.d/mysql restart + /etc/init.d/mysql restart fi %endif %endif @@ -497,63 +497,63 @@ echo if [ "x$1" = "x0" ] ; then - # Remove - echo "Removed package" + # Remove + echo "Removed package" - # Define vars - os='unknown'; - %if 0%{?fedora} || 0%{?rhel_version} || 0%{?centos_version} || 0%{?mdkversion} - export apachelink="%{_sysconfdir}/httpd/conf.d/dolibarr.conf" - %else - %if 0%{?suse_version} - export apachelink="%{_sysconfdir}/apache2/conf.d/dolibarr.conf" - %else - if [ -d %{_sysconfdir}/httpd/conf.d ]; then - export os='fedora-redhat'; - export apachelink="%{_sysconfdir}/httpd/conf.d/dolibarr.conf" - fi - if [ -d %{_sysconfdir}/apache2/conf.d -a `grep ^wwwrun /etc/passwd | wc -l` -ge 1 ]; then - export os='opensuse'; - export apachelink="%{_sysconfdir}/apache2/conf.d/dolibarr.conf" - fi - if [ -d %{_sysconfdir}/httpd/conf.d -a `grep -i "^mageia\|mandriva" /etc/issue | wc -l` -ge 1 ]; then - export os='mageia-mandriva'; - export apachelink="%{_sysconfdir}/httpd/conf.d/dolibarr.conf" - fi - if [ -d %{_sysconfdir}/apache2/conf.d -a `grep ^www-data /etc/passwd | wc -l` -ge 1 ]; then - export os='ubuntu-debian'; - export apachelink="%{_sysconfdir}/apache2/conf.d/dolibarr.conf" - fi - %endif - %endif - - # Remove apache link - if [ -L $apachelink ] ; - then - echo "Delete apache config link for Dolibarr ($apachelink)" - %{__rm} -f $apachelink - status=purge - fi - - # Restart web servers if required - if [ "x$status" = "xpurge" ] ; - then - # Restart web server - echo Restart web server - %if 0%{?fedora} || 0%{?rhel_version} || 0%{?centos_version} || 0%{?mdkversion} - /sbin/service httpd restart - %else - if [ -f %{_sysconfdir}/init.d/httpd ]; then - %{_sysconfdir}/init.d/httpd restart - fi - if [ -f %{_sysconfdir}/init.d/apache2 ]; then - %{_sysconfdir}/init.d/apache2 restart - fi - %endif - fi + # Define vars + os='unknown'; + %if 0%{?fedora} || 0%{?rhel_version} || 0%{?centos_version} || 0%{?mdkversion} + export apachelink="%{_sysconfdir}/httpd/conf.d/dolibarr.conf" + %else + %if 0%{?suse_version} + export apachelink="%{_sysconfdir}/apache2/conf.d/dolibarr.conf" + %else + if [ -d %{_sysconfdir}/httpd/conf.d ]; then + export os='fedora-redhat'; + export apachelink="%{_sysconfdir}/httpd/conf.d/dolibarr.conf" + fi + if [ -d %{_sysconfdir}/apache2/conf.d -a `grep ^wwwrun /etc/passwd | wc -l` -ge 1 ]; then + export os='opensuse'; + export apachelink="%{_sysconfdir}/apache2/conf.d/dolibarr.conf" + fi + if [ -d %{_sysconfdir}/httpd/conf.d -a `grep -i "^mageia\|mandriva" /etc/issue | wc -l` -ge 1 ]; then + export os='mageia-mandriva'; + export apachelink="%{_sysconfdir}/httpd/conf.d/dolibarr.conf" + fi + if [ -d %{_sysconfdir}/apache2/conf.d -a `grep ^www-data /etc/passwd | wc -l` -ge 1 ]; then + export os='ubuntu-debian'; + export apachelink="%{_sysconfdir}/apache2/conf.d/dolibarr.conf" + fi + %endif + %endif + + # Remove apache link + if [ -L $apachelink ] ; + then + echo "Delete apache config link for Dolibarr ($apachelink)" + %{__rm} -f $apachelink + status=purge + fi + + # Restart web servers if required + if [ "x$status" = "xpurge" ] ; + then + # Restart web server + echo Restart web server + %if 0%{?fedora} || 0%{?rhel_version} || 0%{?centos_version} || 0%{?mdkversion} + /sbin/service httpd restart + %else + if [ -f %{_sysconfdir}/init.d/httpd ]; then + %{_sysconfdir}/init.d/httpd restart + fi + if [ -f %{_sysconfdir}/init.d/apache2 ]; then + %{_sysconfdir}/init.d/apache2 restart + fi + %endif + fi else - # Upgrade - echo "No remove action done (this is an upgrade)" + # Upgrade + echo "No remove action done (this is an upgrade)" fi # version x.y.z-0.1.a for alpha, x.y.z-0.2.b for beta, x.y.z-0.3 for release diff --git a/build/rpm/dolibarr_mandriva.spec b/build/rpm/dolibarr_mandriva.spec index a2726c03f47..eddba4a0ef2 100755 --- a/build/rpm/dolibarr_mandriva.spec +++ b/build/rpm/dolibarr_mandriva.spec @@ -114,9 +114,9 @@ do lang2=`expr substr $lang 4 2 | tr "[:upper:]" "[:lower:]"`; echo "%dir %{_datadir}/%{name}/htdocs/langs/${lang}" >> %{name}.lang if [ "$lang1" = "$lang2" ] ; then - echo "%lang(${lang1}) %{_datadir}/%{name}/htdocs/langs/${lang}/*.lang" + echo "%lang(${lang1}) %{_datadir}/%{name}/htdocs/langs/${lang}/*.lang" else - echo "%lang(${lang}) %{_datadir}/%{name}/htdocs/langs/${lang}/*.lang" + echo "%lang(${lang}) %{_datadir}/%{name}/htdocs/langs/${lang}/*.lang" fi done >>%{name}.lang @@ -235,31 +235,31 @@ echo Create document directory $docdir export config=%{_sysconfdir}/dolibarr/conf.php if [ -s $config ] && grep -q "File generated by" $config then - # File already exist. We add params not found. - echo Add new params to overwrite path to use shared libraries/fonts - grep -q -c "dolibarr_lib_ADODB_PATH" $config || [ ! -d "/usr/share/php/adodb" ] || echo "" >> $config - grep -q -c "dolibarr_lib_FPDI_PATH" $config || [ ! -d "/usr/share/php/fpdi" ] || echo "" >> $config - #grep -q -c "dolibarr_lib_GEOIP_PATH" $config || echo "" >> $config - grep -q -c "dolibarr_lib_NUSOAP_PATH" $config || [ ! -d "/usr/share/php/nusoap" ] || echo "" >> $config - grep -q -c "dolibarr_lib_ODTPHP_PATHTOPCLZIP" $config || [ ! -d "/usr/share/php/libphp-pclzip" ] || echo "" >> $config - #grep -q -c "dolibarr_lib_PHPEXCEL_PATH" $config || echo "" >> $config - #grep -q -c "dolibarr_lib_TCPDF_PATH" $config || echo "" >> $config - grep -q -c "dolibarr_js_CKEDITOR" $config || [ ! -d "/usr/share/javascript/ckeditor" ] || echo "" >> $config - grep -q -c "dolibarr_js_JQUERY" $config || [ ! -d "/usr/share/javascript/jquery" ] || echo "" >> $config - grep -q -c "dolibarr_js_JQUERY_UI" $config || [ ! -d "/usr/share/javascript/jquery-ui" ] || echo "" >> $config - grep -q -c "dolibarr_js_JQUERY_FLOT" $config || [ ! -d "/usr/share/javascript/flot" ] || echo "" >> $config - grep -q -c "dolibarr_font_DOL_DEFAULT_TTF_BOLD" $config || echo "" >> $config + # File already exist. We add params not found. + echo Add new params to overwrite path to use shared libraries/fonts + grep -q -c "dolibarr_lib_ADODB_PATH" $config || [ ! -d "/usr/share/php/adodb" ] || echo "" >> $config + grep -q -c "dolibarr_lib_FPDI_PATH" $config || [ ! -d "/usr/share/php/fpdi" ] || echo "" >> $config + #grep -q -c "dolibarr_lib_GEOIP_PATH" $config || echo "" >> $config + grep -q -c "dolibarr_lib_NUSOAP_PATH" $config || [ ! -d "/usr/share/php/nusoap" ] || echo "" >> $config + grep -q -c "dolibarr_lib_ODTPHP_PATHTOPCLZIP" $config || [ ! -d "/usr/share/php/libphp-pclzip" ] || echo "" >> $config + #grep -q -c "dolibarr_lib_PHPEXCEL_PATH" $config || echo "" >> $config + #grep -q -c "dolibarr_lib_TCPDF_PATH" $config || echo "" >> $config + grep -q -c "dolibarr_js_CKEDITOR" $config || [ ! -d "/usr/share/javascript/ckeditor" ] || echo "" >> $config + grep -q -c "dolibarr_js_JQUERY" $config || [ ! -d "/usr/share/javascript/jquery" ] || echo "" >> $config + grep -q -c "dolibarr_js_JQUERY_UI" $config || [ ! -d "/usr/share/javascript/jquery-ui" ] || echo "" >> $config + grep -q -c "dolibarr_js_JQUERY_FLOT" $config || [ ! -d "/usr/share/javascript/flot" ] || echo "" >> $config + grep -q -c "dolibarr_font_DOL_DEFAULT_TTF_BOLD" $config || echo "" >> $config fi # Create a config link dolibarr.conf if [ ! -L $apachelink ]; then - apachelinkdir=`dirname $apachelink` - if [ -d $apachelinkdir ]; then - echo Create dolibarr web server config link from %{_sysconfdir}/dolibarr/apache.conf to $apachelink - ln -fs %{_sysconfdir}/dolibarr/apache.conf $apachelink - else - echo Do not create link $apachelink - web server conf dir $apachelinkdir not found. web server package may not be installed - fi + apachelinkdir=`dirname $apachelink` + if [ -d $apachelinkdir ]; then + echo Create dolibarr web server config link from %{_sysconfdir}/dolibarr/apache.conf to $apachelink + ln -fs %{_sysconfdir}/dolibarr/apache.conf $apachelink + else + echo Do not create link $apachelink - web server conf dir $apachelinkdir not found. web server package may not be installed + fi fi echo Set permission to $apacheuser:$apachegroup on /var/lib/dolibarr @@ -269,19 +269,19 @@ echo Set permission to $apacheuser:$apachegroup on /var/lib/dolibarr # Restart web server echo Restart web server if [ -f %{_sysconfdir}/init.d/httpd ]; then - %{_sysconfdir}/init.d/httpd restart + %{_sysconfdir}/init.d/httpd restart fi if [ -f %{_sysconfdir}/init.d/apache2 ]; then - %{_sysconfdir}/init.d/apache2 restart + %{_sysconfdir}/init.d/apache2 restart fi # Restart mysql echo Restart mysql if [ -f /etc/init.d/mysqld ]; then - /etc/init.d/mysqld restart + /etc/init.d/mysqld restart fi if [ -f /etc/init.d/mysql ]; then - /etc/init.d/mysql restart + /etc/init.d/mysql restart fi # Show result @@ -301,35 +301,35 @@ echo if [ "x$1" = "x0" ] ; then - # Remove - echo "Removed package" + # Remove + echo "Removed package" - # Define vars - export apachelink="%{_sysconfdir}/httpd/conf.d/dolibarr.conf" - - # Remove apache link - if [ -L $apachelink ] ; - then - echo "Delete apache config link for Dolibarr ($apachelink)" - %{__rm} -f $apachelink - status=purge - fi - - # Restart web servers if required - if [ "x$status" = "xpurge" ] ; - then - # Restart web server - echo Restart web server - if [ -f %{_sysconfdir}/init.d/httpd ]; then - %{_sysconfdir}/init.d/httpd restart - fi - if [ -f %{_sysconfdir}/init.d/apache2 ]; then - %{_sysconfdir}/init.d/apache2 restart - fi - fi + # Define vars + export apachelink="%{_sysconfdir}/httpd/conf.d/dolibarr.conf" + + # Remove apache link + if [ -L $apachelink ] ; + then + echo "Delete apache config link for Dolibarr ($apachelink)" + %{__rm} -f $apachelink + status=purge + fi + + # Restart web servers if required + if [ "x$status" = "xpurge" ] ; + then + # Restart web server + echo Restart web server + if [ -f %{_sysconfdir}/init.d/httpd ]; then + %{_sysconfdir}/init.d/httpd restart + fi + if [ -f %{_sysconfdir}/init.d/apache2 ]; then + %{_sysconfdir}/init.d/apache2 restart + fi + fi else - # Upgrade - echo "No remove action done (this is an upgrade)" + # Upgrade + echo "No remove action done (this is an upgrade)" fi diff --git a/build/rpm/dolibarr_opensuse.spec b/build/rpm/dolibarr_opensuse.spec index 88483e29146..41264b4b7ce 100755 --- a/build/rpm/dolibarr_opensuse.spec +++ b/build/rpm/dolibarr_opensuse.spec @@ -115,9 +115,9 @@ do lang2=`expr substr $lang 4 2 | tr "[:upper:]" "[:lower:]"`; echo "%dir %{_datadir}/%{name}/htdocs/langs/${lang}" >> %{name}.lang if [ "$lang1" = "$lang2" ] ; then - echo "%lang(${lang1}) %{_datadir}/%{name}/htdocs/langs/${lang}/*.lang" + echo "%lang(${lang1}) %{_datadir}/%{name}/htdocs/langs/${lang}/*.lang" else - echo "%lang(${lang}) %{_datadir}/%{name}/htdocs/langs/${lang}/*.lang" + echo "%lang(${lang}) %{_datadir}/%{name}/htdocs/langs/${lang}/*.lang" fi done >>%{name}.lang @@ -246,31 +246,31 @@ echo Create document directory $docdir export config=%{_sysconfdir}/dolibarr/conf.php if [ -s $config ] && grep -q "File generated by" $config then - # File already exist. We add params not found. - echo Add new params to overwrite path to use shared libraries/fonts - grep -q -c "dolibarr_lib_ADODB_PATH" $config || [ ! -d "/usr/share/php/adodb" ] || echo "" >> $config - grep -q -c "dolibarr_lib_FPDI_PATH" $config || [ ! -d "/usr/share/php/fpdi" ] || echo "" >> $config - #grep -q -c "dolibarr_lib_GEOIP_PATH" $config || echo "" >> $config - grep -q -c "dolibarr_lib_NUSOAP_PATH" $config || [ ! -d "/usr/share/php/nusoap" ] || echo "" >> $config - grep -q -c "dolibarr_lib_ODTPHP_PATHTOPCLZIP" $config || [ ! -d "/usr/share/php/libphp-pclzip" ] || echo "" >> $config - #grep -q -c "dolibarr_lib_PHPEXCEL_PATH" $config || echo "" >> $config - #grep -q -c "dolibarr_lib_TCPDF_PATH" $config || echo "" >> $config - grep -q -c "dolibarr_js_CKEDITOR" $config || [ ! -d "/usr/share/javascript/ckeditor" ] || echo "" >> $config - grep -q -c "dolibarr_js_JQUERY" $config || [ ! -d "/usr/share/javascript/jquery" ] || echo "" >> $config - grep -q -c "dolibarr_js_JQUERY_UI" $config || [ ! -d "/usr/share/javascript/jquery-ui" ] || echo "" >> $config - grep -q -c "dolibarr_js_JQUERY_FLOT" $config || [ ! -d "/usr/share/javascript/flot" ] || echo "" >> $config - grep -q -c "dolibarr_font_DOL_DEFAULT_TTF_BOLD" $config || echo "" >> $config + # File already exist. We add params not found. + echo Add new params to overwrite path to use shared libraries/fonts + grep -q -c "dolibarr_lib_ADODB_PATH" $config || [ ! -d "/usr/share/php/adodb" ] || echo "" >> $config + grep -q -c "dolibarr_lib_FPDI_PATH" $config || [ ! -d "/usr/share/php/fpdi" ] || echo "" >> $config + #grep -q -c "dolibarr_lib_GEOIP_PATH" $config || echo "" >> $config + grep -q -c "dolibarr_lib_NUSOAP_PATH" $config || [ ! -d "/usr/share/php/nusoap" ] || echo "" >> $config + grep -q -c "dolibarr_lib_ODTPHP_PATHTOPCLZIP" $config || [ ! -d "/usr/share/php/libphp-pclzip" ] || echo "" >> $config + #grep -q -c "dolibarr_lib_PHPEXCEL_PATH" $config || echo "" >> $config + #grep -q -c "dolibarr_lib_TCPDF_PATH" $config || echo "" >> $config + grep -q -c "dolibarr_js_CKEDITOR" $config || [ ! -d "/usr/share/javascript/ckeditor" ] || echo "" >> $config + grep -q -c "dolibarr_js_JQUERY" $config || [ ! -d "/usr/share/javascript/jquery" ] || echo "" >> $config + grep -q -c "dolibarr_js_JQUERY_UI" $config || [ ! -d "/usr/share/javascript/jquery-ui" ] || echo "" >> $config + grep -q -c "dolibarr_js_JQUERY_FLOT" $config || [ ! -d "/usr/share/javascript/flot" ] || echo "" >> $config + grep -q -c "dolibarr_font_DOL_DEFAULT_TTF_BOLD" $config || echo "" >> $config fi # Create a config link dolibarr.conf if [ ! -L $apachelink ]; then - apachelinkdir=`dirname $apachelink` - if [ -d $apachelinkdir ]; then - echo Create dolibarr web server config link from %{_sysconfdir}/dolibarr/apache.conf to $apachelink - ln -fs %{_sysconfdir}/dolibarr/apache.conf $apachelink - else - echo Do not create link $apachelink - web server conf dir $apachelinkdir not found. web server package may not be installed - fi + apachelinkdir=`dirname $apachelink` + if [ -d $apachelinkdir ]; then + echo Create dolibarr web server config link from %{_sysconfdir}/dolibarr/apache.conf to $apachelink + ln -fs %{_sysconfdir}/dolibarr/apache.conf $apachelink + else + echo Do not create link $apachelink - web server conf dir $apachelinkdir not found. web server package may not be installed + fi fi echo Set permission to $apacheuser:$apachegroup on /var/lib/dolibarr @@ -280,18 +280,18 @@ echo Set permission to $apacheuser:$apachegroup on /var/lib/dolibarr # Restart web server echo Restart web server if [ -f %{_sysconfdir}/init.d/httpd ]; then - %{_sysconfdir}/init.d/httpd restart + %{_sysconfdir}/init.d/httpd restart fi if [ -f %{_sysconfdir}/init.d/apache2 ]; then - %{_sysconfdir}/init.d/apache2 restart + %{_sysconfdir}/init.d/apache2 restart fi # Restart mysql echo Restart mysql if [ -f /etc/init.d/mysqld ]; then - /etc/init.d/mysqld restart + /etc/init.d/mysqld restart else - /sbin/service mysql restart + /sbin/service mysql restart fi # Show result @@ -311,35 +311,35 @@ echo if [ "x$1" = "x0" ] ; then - # Remove - echo "Removed package" - - # Define vars - export apachelink="%{_sysconfdir}/apache2/conf.d/dolibarr.conf" - - # Remove apache link - if [ -L $apachelink ] ; - then - echo "Delete apache config link for Dolibarr ($apachelink)" - %{__rm} -f $apachelink - status=purge - fi - - # Restart web servers if required - if [ "x$status" = "xpurge" ] ; - then - # Restart web server - echo Restart web server - if [ -f %{_sysconfdir}/init.d/httpd ]; then - %{_sysconfdir}/init.d/httpd restart - fi - if [ -f %{_sysconfdir}/init.d/apache2 ]; then - %{_sysconfdir}/init.d/apache2 restart - fi - fi + # Remove + echo "Removed package" + + # Define vars + export apachelink="%{_sysconfdir}/apache2/conf.d/dolibarr.conf" + + # Remove apache link + if [ -L $apachelink ] ; + then + echo "Delete apache config link for Dolibarr ($apachelink)" + %{__rm} -f $apachelink + status=purge + fi + + # Restart web servers if required + if [ "x$status" = "xpurge" ] ; + then + # Restart web server + echo Restart web server + if [ -f %{_sysconfdir}/init.d/httpd ]; then + %{_sysconfdir}/init.d/httpd restart + fi + if [ -f %{_sysconfdir}/init.d/apache2 ]; then + %{_sysconfdir}/init.d/apache2 restart + fi + fi else - # Upgrade - echo "No remove action done (this is an upgrade)" + # Upgrade + echo "No remove action done (this is an upgrade)" fi diff --git a/dev/fixnotabfiles.sh b/dev/fixnotabfiles.sh new file mode 100755 index 00000000000..3e5d28966c9 --- /dev/null +++ b/dev/fixnotabfiles.sh @@ -0,0 +1,26 @@ +#!/bin/sh +#------------------------------------------------------ +# Script to find files that are not Unix encoded +# +# Laurent Destailleur - eldy@users.sourceforge.net +#------------------------------------------------------ +# Usage: fixnotabfiles.sh [list|fix] +#------------------------------------------------------ + +# Syntax +if [ "x$1" != "xlist" -a "x$1" != "xfix" ] +then + echo "Usage: fixnotabfiles.sh [list|fix]" +fi + +# To detec +if [ "x$1" = "xlist" ] +then + find build \( -iname "*.sh" -o -iname "*.spec" \) -exec grep -l -P '\t' {} \; +fi + +# To convert +if [ "x$1" = "xfix" ] +then + echo Feature not implemented. Please fix files manually. +fi diff --git a/htdocs/adherents/fiche.php b/htdocs/adherents/fiche.php index d019e4004d8..399cc712297 100644 --- a/htdocs/adherents/fiche.php +++ b/htdocs/adherents/fiche.php @@ -321,6 +321,7 @@ if ($action == 'update' && ! $_POST["cancel"] && $user->rights->adherent->creer) $result=$object->update($user,0,$nosyncuser,$nosyncuserpass); if ($result >= 0 && ! count($object->errors)) { + // Logo/Photo save $dir= $conf->adherent->dir_output . '/' . get_exdir($object->id,2,0,1).'/photos'; $file_OK = is_uploaded_file($_FILES['photo']['tmp_name']); if ($file_OK) @@ -361,8 +362,21 @@ if ($action == 'update' && ! $_POST["cancel"] && $user->rights->adherent->creer) $errmsgs[] = "ErrorBadImageFormat"; } } + else + { + switch($_FILES['photo']['error']) + { + case 1: //uploaded file exceeds the upload_max_filesize directive in php.ini + case 2: //uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the html form + $errors[] = "ErrorFileSizeTooLarge"; + break; + case 3: //uploaded file was only partially uploaded + $errors[] = "ErrorFilePartiallyUploaded"; + break; + } + } - $rowid=$object->id; + $rowid=$object->id; $action=''; if (! empty($backtopage)) @@ -848,11 +862,11 @@ else print ''.$langs->trans("PhoneMobile").''; // Skype - if (! empty($conf->skype->enabled)) + if (! empty($conf->skype->enabled)) { print ''.$langs->trans("Skype").''; } - + // Birthday print "".$langs->trans("Birthday")."\n"; $form->select_date(($object->naiss ? $object->naiss : -1),'naiss','','',1,'formsoc'); @@ -1093,7 +1107,7 @@ else if (! empty($conf->skype->enabled)) { print ''.$langs->trans("Skype").'skype).'">'; } - + // Birthday print "".$langs->trans("Birthday")."\n"; $form->select_date(($object->birth ? $object->birth : -1),'birth','','',1,'formsoc'); diff --git a/htdocs/comm/action/class/actioncomm.class.php b/htdocs/comm/action/class/actioncomm.class.php index 33057e96eb8..b10bb5f90a3 100644 --- a/htdocs/comm/action/class/actioncomm.class.php +++ b/htdocs/comm/action/class/actioncomm.class.php @@ -887,7 +887,7 @@ class ActionComm extends CommonObject $sql.= " AND a.entity = ".$conf->entity; foreach ($filters as $key => $value) { - if ($key == 'notolderthan') $sql.=" AND a.datep >= '".$this->db->idate($now-($value*24*60*60))."'"; + if ($key == 'notolderthan' && $value != '') $sql.=" AND a.datep >= '".$this->db->idate($now-($value*24*60*60))."'"; if ($key == 'year') $sql.=" AND a.datep BETWEEN '".$this->db->idate(dol_get_first_day($value,1))."' AND '".$this->db->idate(dol_get_last_day($value,12))."'"; if ($key == 'id') $sql.=" AND a.id=".(is_numeric($value)?$value:0); if ($key == 'idfrom') $sql.=" AND a.id >= ".(is_numeric($value)?$value:0); diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index dead4b4beb4..8da52e301e6 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -2358,7 +2358,7 @@ function dol_print_error_email($prefixcode) * @param string $field Field to use for new sorting * @param string $begin ("" by defaut) * @param string $moreparam Add more parameters on sort url links ("" by default) - * @param string $td Options of attribute td ("" by defaut) + * @param string $td Options of attribute td ("" by defaut, example: 'align="center"') * @param string $sortfield Current field used to sort * @param string $sortorder Current sort order * @return void diff --git a/htdocs/core/lib/xcal.lib.php b/htdocs/core/lib/xcal.lib.php index 9badeae5290..4483e9540e5 100644 --- a/htdocs/core/lib/xcal.lib.php +++ b/htdocs/core/lib/xcal.lib.php @@ -484,7 +484,7 @@ function quotedPrintEncode($str,$forcal=0) { $newpara = ''; - $strlength=dol_strlen($line); + $strlength=strlen($line); // Do not use dol_strlen here, we need number of bytes for ($j = 0; $j <= ($strlength - 1); $j++) { $char = substr($line, $j, 1); @@ -493,7 +493,7 @@ function quotedPrintEncode($str,$forcal=0) if ( $ascii < 32 || $ascii == 61 || $ascii > 126 ) $char = '=' . strtoupper(sprintf("%02X", $ascii)); - if ((dol_strlen($newpara) + dol_strlen($char)) >= 76 ) + if ((strlen($newpara) + strlen($char)) >= 76 ) // Do not use dol_strlen here, we need number of bytes { $out .= $newpara . '=' . "\r\n"; // CRLF if ($forcal) $out .= " "; // + Space for cal diff --git a/htdocs/langs/en_US/banks.lang b/htdocs/langs/en_US/banks.lang index 3503ff11e62..e4de38e621e 100644 --- a/htdocs/langs/en_US/banks.lang +++ b/htdocs/langs/en_US/banks.lang @@ -154,3 +154,5 @@ DefaultRIB=Default BAN AllRIB=All BAN LabelRIB=BAN Label NoBANRecord=No BAN record +DeleteARib=Delete BAN record +ConfirmDeleteRib=Are you sure you want to delete this BAN record ? diff --git a/htdocs/langs/fr_FR/banks.lang b/htdocs/langs/fr_FR/banks.lang index 29440edd862..4d44e9619eb 100644 --- a/htdocs/langs/fr_FR/banks.lang +++ b/htdocs/langs/fr_FR/banks.lang @@ -154,3 +154,5 @@ DefaultRIB=RIB par défaut AllRIB=Tous les RIB LabelRIB=Nom du RIB NoBANRecord=Aucun RIB enregistré +DeleteARib=Supprimé RIB enregistré +ConfirmDeleteRib=Etes vous sur de vouloir supprimé ce RIB ? diff --git a/htdocs/societe/class/companybankaccount.class.php b/htdocs/societe/class/companybankaccount.class.php index 8b8e3b382c7..fe1726ab345 100644 --- a/htdocs/societe/class/companybankaccount.class.php +++ b/htdocs/societe/class/companybankaccount.class.php @@ -77,13 +77,23 @@ class CompanyBankAccount extends Account { $now=dol_now(); - $sql = "INSERT INTO ".MAIN_DB_PREFIX."societe_rib (fk_soc, datec) values ($this->socid, '".$this->db->idate($now)."')"; + // Correct default_rib to be sure to have always one default + $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."societe_rib where fk_soc = ".$this->socid." AND default_rib = 1"; + $result = $this->db->query($sql); + if ($result) + { + $numrows=$this->db->num_rows($result); + if ($this->default_rib && $numrows > 0) $this->default_rib = 0; + if (empty($this->default_rib) && $numrows == 0) $this->default_rib = 1; + } + + $sql = "INSERT INTO ".MAIN_DB_PREFIX."societe_rib (fk_soc, datec)"; + $sql.= " VALUES (".$this->socid.", '".$this->db->idate($now)."')"; $resql=$this->db->query($sql); if ($resql) { if ($this->db->affected_rows($resql)) { - $this->default_rib = 1; $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."societe_rib"); return 1; } @@ -120,7 +130,7 @@ class CompanyBankAccount extends Account // return 0; // } - if (!$this->id) { + if (! $this->id) { $this->create(); } @@ -204,6 +214,30 @@ class CompanyBankAccount extends Account } } + /** + * Delete a rib from database + * + * @param User $user User deleting + * @return int <0 if KO, >0 if OK + */ + function delete($user) + { + global $conf; + + $sql = "DELETE FROM ".MAIN_DB_PREFIX."societe_rib"; + $sql.= " WHERE rowid = ".$this->id; + + dol_syslog(get_class($this)."::delete sql=".$sql); + $result = $this->db->query($sql); + if ($result) { + return 1; + } + else { + dol_print_error($this->db); + return -1; + } + } + /** * Return RIB * diff --git a/htdocs/societe/rib.php b/htdocs/societe/rib.php index b3432d105a8..819c3b6986c 100644 --- a/htdocs/societe/rib.php +++ b/htdocs/societe/rib.php @@ -31,11 +31,12 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/bank.lib.php'; require_once DOL_DOCUMENT_ROOT.'/societe/class/companybankaccount.class.php'; $langs->load("companies"); +$langs->load("commercial"); $langs->load("banks"); $langs->load("bills"); // Security check -$socid = isset($_GET["socid"])?$_GET["socid"]:''; +$socid = GETPOST("socid"); if ($user->societe_id) $socid=$user->societe_id; $result = restrictedArea($user, 'societe','',''); @@ -43,17 +44,21 @@ $soc = new Societe($db); $soc->id = $_GET["socid"]; $soc->fetch($_GET["socid"]); +$id=GETPOST("id","int"); +$ribid=GETPOST("ribid","int"); +$action=GETPOST("action"); + /* * Actions */ -if ($_POST["action"] == 'update' && ! $_POST["cancel"]) +if ($action == 'update' && ! $_POST["cancel"]) { // Modification $account = new CompanyBankAccount($db); - $account->fetch($_POST["id"]); + $account->fetch($id); $account->socid = $soc->id; @@ -85,7 +90,7 @@ if ($_POST["action"] == 'update' && ! $_POST["cancel"]) } } -if ($_POST["action"] == 'add' && ! $_POST["cancel"]) +if ($action == 'add' && ! $_POST["cancel"]) { // Ajout $account = new CompanyBankAccount($db); @@ -106,7 +111,7 @@ if ($_POST["action"] == 'add' && ! $_POST["cancel"]) $account->proprio = $_POST["proprio"]; $account->owner_address = $_POST["owner_address"]; - $result = $account->update($user); + $result = $account->update($user); // TODO Use create and include update into create method if (! $result) { $message=$account->error; @@ -120,10 +125,10 @@ if ($_POST["action"] == 'add' && ! $_POST["cancel"]) } } -if ($_GET['action'] == 'setasdefault') +if ($action == 'setasdefault') { $account = new CompanyBankAccount($db); - $res = $account->setAsDefault($_GET['ribid']); + $res = $account->setAsDefault(GETPOST('ribid','int')); if ($res) { $url=DOL_URL_ROOT.'/societe/rib.php?socid='.$soc->id; header('Location: '.$url); @@ -133,10 +138,35 @@ if ($_GET['action'] == 'setasdefault') } } +if ($action == 'confirm_delete' && $_GET['confirm'] == 'yes') +{ + $account = new CompanyBankAccount($db); + if ($account->fetch($ribid?$ribid:$id)) + { + $result = $account->delete($user); + if ($result > 0) + { + $url = $_SERVER['PHP_SELF']."?socid=".$soc->id; + header('Location: '.$url); + exit; + } + else + { + $message = $account->error; + } + } + else + { + $message = $account->error; + } +} + /* * View */ +$form = new Form($db); + llxHeader(); $head=societe_prepare_head2($soc); @@ -144,10 +174,10 @@ $head=societe_prepare_head2($soc); dol_fiche_head($head, 'rib', $langs->trans("ThirdParty"),0,'company'); $account = new CompanyBankAccount($db); -if (!$_GET['id']) +if (! $id) $account->fetch(0,$soc->id); else - $account->fetch($_GET['id']); + $account->fetch($id); if (empty($account->socid)) $account->socid=$soc->id; @@ -158,10 +188,17 @@ if (empty($account->socid)) $account->socid=$soc->id; /* */ /* ************************************************************************** */ -if ($_GET["socid"] && $_GET["action"] != 'edit' && $_GET["action"] != "create") +if ($socid && $action != 'edit' && $action != "create") { + // Confirm delete third party + if ($action == 'delete') + { + print $form->formconfirm($_SERVER["PHP_SELF"]."?socid=".$soc->id."&ribid=".($ribid?$ribid:$id), $langs->trans("DeleteARib"), $langs->trans("ConfirmDeleteRib", $account->getRibLabel()), "confirm_delete", '', 0, 1); + } + print_titre($langs->trans("DefaultRIB")); - print ''; + + print '
'; print ''; print ''; @@ -236,11 +273,12 @@ if ($_GET["socid"] && $_GET["action"] != 'edit' && $_GET["action"] != "create") print_liste_field_titre($langs->trans("LabelRIB")); print_liste_field_titre($langs->trans("Bank")); print_liste_field_titre($langs->trans("RIB")); - print_liste_field_titre($langs->trans("DefaultRIB")); + print_liste_field_titre($langs->trans("DefaultRIB"), '', '', '', '', 'align="center"'); print ''; print ''; - foreach ($rib_list as $rib) { + foreach ($rib_list as $rib) + { print ""; print ''; print ''; @@ -248,16 +286,26 @@ if ($_GET["socid"] && $_GET["action"] != 'edit' && $_GET["action"] != "create") print ''; print ''; print ''; $var = !$var; diff --git a/htdocs/societe/soc.php b/htdocs/societe/soc.php index 07610bb88ba..9d5a707aac1 100644 --- a/htdocs/societe/soc.php +++ b/htdocs/societe/soc.php @@ -4,10 +4,9 @@ * Copyright (C) 2004-2013 Laurent Destailleur * Copyright (C) 2005 Eric Seigne * Copyright (C) 2005-2012 Regis Houssin - * Copyright (C) 2008 Patrick Raguin + * Copyright (C) 2008 Patrick Raguin * Copyright (C) 2010-2013 Juanjo Menent - * Copyright (C) 2011-2013 Alexandre Spangaro - * + * Copyright (C) 2011-2013 Alexandre Spangaro * * 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 @@ -280,7 +279,7 @@ if (empty($reshook)) } } - // Gestion du logo de la société + // Logo/Photo save $dir = $conf->societe->multidir_output[$conf->entity]."/".$object->id."/logos/"; $file_OK = is_uploaded_file($_FILES['photo']['tmp_name']); if ($file_OK) @@ -311,6 +310,19 @@ if (empty($reshook)) } } } + else + { + switch($_FILES['photo']['error']) + { + case 1: //uploaded file exceeds the upload_max_filesize directive in php.ini + case 2: //uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the html form + $errors[] = "ErrorFileSizeTooLarge"; + break; + case 3: //uploaded file was only partially uploaded + $errors[] = "ErrorFilePartiallyUploaded"; + break; + } + } // Gestion du logo de la société } else @@ -354,7 +366,7 @@ if (empty($reshook)) $error = $object->error; $errors = $object->errors; } - // Gestion du logo de la société + // Logo/Photo save $dir = $conf->societe->multidir_output[$object->entity]."/".$object->id."/logos"; $file_OK = is_uploaded_file($_FILES['photo']['tmp_name']); if ($file_OK) @@ -393,10 +405,23 @@ if (empty($reshook)) } } else - { + { $errors[] = "ErrorBadImageFormat"; } } + else + { + switch($_FILES['photo']['error']) + { + case 1: //uploaded file exceeds the upload_max_filesize directive in php.ini + case 2: //uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the html form + $errors[] = "ErrorFileSizeTooLarge"; + break; + case 3: //uploaded file was only partially uploaded + $errors[] = "ErrorFilePartiallyUploaded"; + break; + } + } // Gestion du logo de la société @@ -855,7 +880,7 @@ else { print ''; } - + // Phone / Fax print ''; print ''; @@ -1273,13 +1298,13 @@ else // EMail / Web print ''; print ''; - + // Skype if (! empty($conf->skype->enabled)) { print ''; } - + // Phone / Fax print ''; print ''; @@ -1587,7 +1612,7 @@ else print ''; - + // Skype if (! empty($conf->skype->enabled)) { diff --git a/htdocs/theme/eldy/style.css.php b/htdocs/theme/eldy/style.css.php index 19b2cb5bd84..0abcb79f4ec 100644 --- a/htdocs/theme/eldy/style.css.php +++ b/htdocs/theme/eldy/style.css.php @@ -1976,14 +1976,14 @@ div.ok { } div.warning { - color: #504020; + color: #302020; padding: 0.3em 0.3em 0.3em 0.3em; margin: 0.5em 0em 0.5em 0em; border: 1px solid #e0d0b0; -moz-border-radius:6px; -webkit-border-radius: 6px; border-radius: 6px; - background: #FFEF9A; + background: #EFDF9A; text-shadow: 0 1px 0 rgba(255, 255, 255, 0.5); }
'.$langs->trans("LabelRIB").''.$account->label.'
'.$rib->label.''.$rib->bank.''; if (!$rib->default_rib) { print ''; - print img_picto($langs->trans("Disabled"),'switch_off'); + print img_picto($langs->trans("Disabled"),'off'); print ''; } else { - print img_picto($langs->trans("Enabled"),'switch_on'); + print img_picto($langs->trans("Enabled"),'on'); } print ''; - print ''; - print img_picto($langs->trans("Modify"),'edit'); - print ''; + if ($user->rights->societe->creer) + { + print ''; + print img_picto($langs->trans("Modify"),'edit'); + print ''; + + print ' '; + + print ''; + print img_picto($langs->trans("Delete"),'delete'); + print ''; + } + print '
'.$langs->trans('Skype').'
'.$langs->trans('Phone').''.$langs->trans('Fax').'
'.$langs->trans('EMail').(! empty($conf->global->SOCIETE_MAIL_REQUIRED)?'*':'').'
'.$langs->trans('Web').'
'.$langs->trans('Skype').'
'.$langs->trans('Phone').''.$langs->trans('Fax').'
'.$langs->trans('Web').''; print dol_print_url($object->url); print '