diff --git a/.dockerignore b/.dockerignore deleted file mode 100644 index e5908c26ac0..00000000000 --- a/.dockerignore +++ /dev/null @@ -1,16 +0,0 @@ -build -build.xml -ChangeLog -composer.json -CONTRIBUTING.md -COPYING -COPYRIGHT -dev -doc -Dockerfile -INSTALL -README-FR.md -README.md -robots.txt -scripts -test \ No newline at end of file diff --git a/ChangeLog b/ChangeLog index 154222d599a..494050efbfc 100644 --- a/ChangeLog +++ b/ChangeLog @@ -28,7 +28,7 @@ NEW: add property to show warnings when activating modules NEW: add rapport file for supplier paiement NEW: Add statistics on supplier tab. NEW: Add tooltip help on shipment weight and volume calculation -NEW: An external module can hook and add mass actions +NEW: An external module can hook and add mass actions. NEW: Better reponsive design NEW: Bookmarks are into a combo list. NEW: Bulk actions available on supplier orders @@ -158,6 +158,37 @@ content by doing a print into function, sometimes by returning content into "res hook specifications so you must return output into "resprint". +***** ChangeLog for 5.0.5 compared to 5.0.4 ***** +FIX: #7075 : bad path for document +FIX: #7156 +FIX: #7173 +FIX: #7224 +FIX: #7226 +FIX: #7239 +FIX: add supplierproposaldet without price (new product) +FIX: amount overlap other amount when a pagebreak is done due to an image at the bottom of page. +FIX: Bad tax calculation with expense report +FIX: Best buy price calculation +FIX: Buying prices must always be in positive value. +FIX: calculate correct remain to pay for planned bank transactions +FIX: delete linked element on facture rec +FIX: edit sociale was emptying label +FIX: Error when updating thirdparty not returned +FIX: holidays with postgresql like on rowid integer +FIX: id of user not saved when making a payment of expense report +FIX: invoice page list +FIX: invoice situation VAT total rounding into PDF crabe +FIX: PgSQL compatibility. +FIX: remove order rights on invoice page +FIX: status were wrong on product referent list +FIX: supplier id was not passed to hooks +FIX: Support of vat code when using price per customer +FIX: User id correction on holiday request +FIX: value of user id filled to 0 in llx_bank_url when recording an expense report. +FIX: we have to check if contact doesn't already exist on add_contact() function +FIX: We should be able to insert data with value '0' into const +FIX: install process with DoliWamp + ***** ChangeLog for 5.0.4 compared to 5.0.3 ***** FIX: #5640 Prices of a predefined product/service were incorrect under certain circumstances FIX: #6541 since 4.0.4 to 5.0.0 autofill zip/town not working @@ -662,7 +693,7 @@ NEW: Disabled users are striked. NEW: Enhance navigation of project module NEW: fichinter lines ordered by rang AND DATE NEW: hidden conf to use input file multiple from mail form -NEW: hidden feature: SUPPLIERORDER_WITH_NOPRICEDEFINED allow supplier order even if no supplier price defined +NEW: hidden feature: SUPPLIER_ORDER_WITH_NOPRICEDEFINED allow supplier order even if no supplier price defined NEW: Hidden option MAIN_LANDING_PAGE to choose the first page to show after login works as a "global" option (llx_const) and as a "per user" option (llx_user_param). NEW: Holiday is a now a RH module. All RH module provides by default visilibity on users of its hierarchy. NEW: If error is reported during migration process, you can ignore it to avoid to be locked. diff --git a/build/docker/.dockerignore b/build/docker/.dockerignore new file mode 100644 index 00000000000..e345920fb8c --- /dev/null +++ b/build/docker/.dockerignore @@ -0,0 +1,3 @@ +Dockerfile +README.md +docker-compose.yml diff --git a/Dockerfile b/build/docker/Dockerfile similarity index 72% rename from Dockerfile rename to build/docker/Dockerfile index 00a5d0ef567..caa7b0c436a 100644 --- a/Dockerfile +++ b/build/docker/Dockerfile @@ -1,4 +1,7 @@ -FROM php:5.6-apache +FROM php:7.0-apache + +ENV HOST_USER_ID 33 +ENV PHP_INI_DATE_TIMEZONE 'UTC' RUN apt-get update && apt-get install -y libpng12-dev libjpeg-dev libldap2-dev \ && rm -rf /var/lib/apt/lists/* \ @@ -9,11 +12,9 @@ RUN apt-get update && apt-get install -y libpng12-dev libjpeg-dev libldap2-dev \ && docker-php-ext-install mysqli \ && apt-get purge -y libpng12-dev libjpeg-dev libldap2-dev -COPY htdocs/ /var/www/html/ - -RUN chown -hR www-data:www-data /var/www/html - -VOLUME /var/www/html/conf -VOLUME /var/www/html/documents +COPY docker-run.sh /usr/local/bin/ +RUN chmod +x /usr/local/bin/docker-run.sh EXPOSE 80 + +ENTRYPOINT ["docker-run.sh"] diff --git a/build/docker/README.md b/build/docker/README.md new file mode 100644 index 00000000000..5a0997cf121 --- /dev/null +++ b/build/docker/README.md @@ -0,0 +1,25 @@ +# How to use it ? + +The docker-compose.yml file is used to build and run Dolibarr in the current workspace. + +Before build/run, define the variable HOST_USER_ID as following: + + export HOST_USER_ID=$(id -u) + +Go in repository build/docker : + + cd build/docker + +And then, you can run : + + docker-compose up + +This will run 3 container Docker : Dolibarr, MariaDB and PhpMyAdmin. + +The URL to go to the Dolibarr is : + + http://0.0.0.0 + +The URL to go to PhpMyAdmin is (login/password is root/root) : + + http://0.0.0.0:8080 diff --git a/build/docker/docker-compose.yml b/build/docker/docker-compose.yml new file mode 100644 index 00000000000..a2017335197 --- /dev/null +++ b/build/docker/docker-compose.yml @@ -0,0 +1,25 @@ +mariadb: + image: mariadb:latest + environment: + MYSQL_ROOT_PASSWORD: root + MYSQL_DATABASE: dolibarr + +phpmyadmin: + image: phpmyadmin/phpmyadmin + environment: + PMA_HOST: mariadb + links: + - mariadb + ports: + - "8080:80" + +web: + build: . + environment: + HOST_USER_ID: $HOST_USER_ID + volumes: + - ../../htdocs:/var/www/html + links: + - mariadb + ports: + - "80:80" diff --git a/build/docker/docker-run.sh b/build/docker/docker-run.sh new file mode 100644 index 00000000000..c151e1c3cab --- /dev/null +++ b/build/docker/docker-run.sh @@ -0,0 +1,15 @@ +#!/bin/bash + +usermod -u $HOST_USER_ID www-data +groupmod -g $HOST_USER_ID www-data + +chown -hR www-data:www-data /var/www + +if [ ! -f /usr/local/etc/php/php.ini ]; then + cat < /usr/local/etc/php/php.ini +date.timezone = $PHP_INI_DATE_TIMEZONE +display_errors = On +EOF +fi + +exec apache2-foreground diff --git a/build/perl/virtualmin/README b/build/perl/virtualmin/README index 22db444a31f..6da04e5f0b8 100644 --- a/build/perl/virtualmin/README +++ b/build/perl/virtualmin/README @@ -1,8 +1,10 @@ README (English) ################################################## -Install script for Virtualmin Pro +Install script for Virtualmin Professional / GPL ################################################## -This script will install automatically Dolibarr from Virtualmin Pro -http://www.virtualmin.com +This script will install automatically Dolibarr from Virtualmin. +(Included in the professional version and can be added in the GPL version) + +https://www.virtualmin.com http://www.webmin.com/virtualmin.html \ No newline at end of file diff --git a/build/perl/virtualmin/dolibarr.pl b/build/perl/virtualmin/dolibarr.pl index 32324d28e42..08d02e8b2b8 100644 --- a/build/perl/virtualmin/dolibarr.pl +++ b/build/perl/virtualmin/dolibarr.pl @@ -1,7 +1,7 @@ #---------------------------------------------------------------------------- # \file dolibarr.pl # \brief Dolibarr script install for Virtualmin Pro -# \author (c)2009-2015 Regis Houssin +# \author (c)2009-2017 Regis Houssin #---------------------------------------------------------------------------- @@ -30,7 +30,12 @@ return "Regis Houssin"; # script_dolibarr_versions() sub script_dolibarr_versions { -return ( "3.8.1", "3.7.1", "3.6.4", "3.5.7" ); +return ( "5.0.4", "4.0.6", "3.9.4" ); +} + +sub script_dolibarr_release +{ +return 2; # for mysqli fix } sub script_dolibarr_category @@ -177,9 +182,9 @@ if ($opts->{'newdb'} && !$upgrade) { local ($dbtype, $dbname) = split(/_/, $opts->{'db'}, 2); local $dbuser = $dbtype eq "mysql" ? &mysql_user($d) : &postgres_user($d); local $dbpass = $dbtype eq "mysql" ? &mysql_pass($d) : &postgres_pass($d, 1); -local $dbphptype = $dbtype eq "mysql" && $version >= 3.6 ? "mysql" : +local $dbphptype = $dbtype eq "mysql" && $version < 3.6 ? "mysql" : $dbtype eq "mysql" ? "mysqli" : "pgsql"; -local $dbhost = &get_database_host($dbtype); +local $dbhost = &get_database_host($dbtype, $d); local $dberr = &check_script_db_connection($dbtype, $dbname, $dbuser, $dbpass); return (0, "Database connection failed : $dberr") if ($dberr); @@ -206,9 +211,6 @@ $pgcharset = $tmpl->{'postgres_encoding'}; $charset = $dbtype eq "mysql" ? $mycharset : $pgcharset; $collate = $dbtype eq "mysql" ? $mycollate : "C"; -# Install filename -local $step = $version >= 3.8 ? "step" : "etape"; - $path = &script_path_url($d, $opts); if ($path =~ /^https:/ || $d->{'ssl'}) { $url = "https://$d->{'dom'}"; @@ -222,15 +224,11 @@ if ($opts->{'path'} =~ /\w/) { if (!$upgrade) { local $cdef = "$opts->{'dir'}/conf/conf.php.example"; - &run_as_domain_user($d, "cp ".quotemeta($cdef)." ".quotemeta($cfile)); + ©_source_dest_as_domain_user($d, $cdef, $cfile); &set_permissions_as_domain_user($d, 0777, $cfiledir); - &set_permissions_as_domain_user($d, 0666, $cfile); + ©_source_dest_as_domain_user($d, $cfile); &run_as_domain_user($d, "mkdir ".quotemeta($docdir)); &set_permissions_as_domain_user($d, 0777, $docdir); - if (!$version >= 3.7.2) { - &run_as_domain_user($d, "mkdir ".quotemeta($altdir)); - &set_permissions_as_domain_user($d, 0777, $altdir); - } } else { # Preserve old config file, documents and custom directory @@ -266,7 +264,8 @@ if ($upgrade) { [ "versionfrom", $upgrade->{'version'} ], [ "versionto", $ver ], ); - local $err = &call_dolibarr_wizard_page(\@params, $step."5", $d, $opts); + local $p = $ver >= 3.8 ? "step5" : "etape5"; + local $err = &call_dolibarr_wizard_page(\@params, $p, $d, $opts); return (-1, "Dolibarr wizard failed : $err") if ($err); # Remove the installation directory. @@ -289,15 +288,17 @@ else { [ "main_force_https", $opts->{'forcehttps'} ], [ "dolibarr_main_db_character_set", $charset ], [ "dolibarr_main_db_collation", $collate ], - [ "main_use_alt_dir", "1" ], + [ "usealternaterootdir", "1" ], [ "main_alt_dir_name", "custom" ], ); - local $err = &call_dolibarr_wizard_page(\@params, $step."1", $d, $opts); + local $p = $ver >= 3.8 ? "step1" : "etape1"; + local $err = &call_dolibarr_wizard_page(\@params, $p, $d, $opts); return (-1, "Dolibarr wizard failed : $err") if ($err); # Second page (Populate database) local @params = ( [ "action", "set" ] ); - local $err = &call_dolibarr_wizard_page(\@params, $step."2", $d, $opts); + local $p = $ver >= 3.8 ? "step2" : "etape2"; + local $err = &call_dolibarr_wizard_page(\@params, $p, $d, $opts); return (-1, "Dolibarr wizard failed : $err") if ($err); # Third page (Add administrator account) @@ -306,7 +307,8 @@ else { [ "pass", $dompass ], [ "pass_verif", $dompass ], ); - local $err = &call_dolibarr_wizard_page(\@params, $step."5", $d, $opts); + local $p = $ver >= 3.8 ? "step5" : "etape5"; + local $err = &call_dolibarr_wizard_page(\@params, $p, $d, $opts); return (-1, "Dolibarr wizard failed : $err") if ($err); # Remove the installation directory and protect config file. @@ -384,7 +386,10 @@ sub script_dolibarr_check_latest { local ($ver) = @_; local @vers = &osdn_package_versions("dolibarr", - $ver >= 3.8 ? "dolibarr\\-(3\\.[0-9\\.]+)\\.tgz" : + $ver >= 5.0 ? "dolibarr\\-(5\\.0\\.[0-9\\.]+)\\.tgz" : + $ver >= 4.0 ? "dolibarr\\-(4\\.0\\.[0-9\\.]+)\\.tgz" : + $ver >= 3.9 ? "dolibarr\\-(3\\.9\\.[0-9\\.]+)\\.tgz" : + $ver >= 3.8 ? "dolibarr\\-(3\\.8\\.[0-9\\.]+)\\.tgz" : $ver >= 3.7 ? "dolibarr\\-(3\\.7\\.[0-9\\.]+)\\.tgz" : $ver >= 3.6 ? "dolibarr\\-(3\\.6\\.[0-9\\.]+)\\.tgz" : $ver >= 3.5 ? "dolibarr\\-(3\\.5\\.[0-9\\.]+)\\.tgz" : diff --git a/doc/images/dolibarr_screenshot5_1920x1080_a.jpg b/doc/images/dolibarr_screenshot5_1920x1080_a.jpg new file mode 100644 index 00000000000..1c6e2cbdbdf Binary files /dev/null and b/doc/images/dolibarr_screenshot5_1920x1080_a.jpg differ diff --git a/doc/images/dolibarr_screenshot5_1920x1080_b.jpg b/doc/images/dolibarr_screenshot5_1920x1080_b.jpg new file mode 100644 index 00000000000..5f7d8a5b573 Binary files /dev/null and b/doc/images/dolibarr_screenshot5_1920x1080_b.jpg differ diff --git a/htdocs/accountancy/admin/fiscalyear_card.php b/htdocs/accountancy/admin/fiscalyear_card.php index fa817942a54..420246411c8 100644 --- a/htdocs/accountancy/admin/fiscalyear_card.php +++ b/htdocs/accountancy/admin/fiscalyear_card.php @@ -145,12 +145,12 @@ else if ($action == 'update') { * View */ +$form = new Form($db); + $title = $langs->trans("Fiscalyear") . " - " . $langs->trans("Card"); $helpurl = ""; llxHeader("",$title,$helpurl); -$form = new Form($db); - if ($action == 'create') { print load_fiche_titre($langs->trans("NewFiscalYear")); diff --git a/htdocs/accountancy/journal/bankjournal.php b/htdocs/accountancy/journal/bankjournal.php index 587d36d227a..505e2a9f534 100644 --- a/htdocs/accountancy/journal/bankjournal.php +++ b/htdocs/accountancy/journal/bankjournal.php @@ -4,7 +4,7 @@ use Stripe\BankAccount; /* Copyright (C) 2007-2010 Laurent Destailleur * Copyright (C) 2007-2010 Jean Heimburger * Copyright (C) 2011 Juanjo Menent - * Copyright (C) 2012 Regis Houssin + * Copyright (C) 2012 Regis Houssin * Copyright (C) 2013 Christophe Battarel * Copyright (C) 2013-2017 Alexandre Spangaro * Copyright (C) 2013-2014 Florian Henry diff --git a/htdocs/accountancy/journal/expensereportsjournal.php b/htdocs/accountancy/journal/expensereportsjournal.php index d253fb2820a..3862bc4ec63 100644 --- a/htdocs/accountancy/journal/expensereportsjournal.php +++ b/htdocs/accountancy/journal/expensereportsjournal.php @@ -2,7 +2,7 @@ /* Copyright (C) 2007-2010 Laurent Destailleur * Copyright (C) 2007-2010 Jean Heimburger * Copyright (C) 2011 Juanjo Menent - * Copyright (C) 2012 Regis Houssin + * Copyright (C) 2012 Regis Houssin * Copyright (C) 2013-2017 Alexandre Spangaro * Copyright (C) 2013-2016 Olivier Geffroy * Copyright (C) 2013-2016 Florian Henry diff --git a/htdocs/accountancy/journal/purchasesjournal.php b/htdocs/accountancy/journal/purchasesjournal.php index b095e4650dc..ceacabd57e9 100644 --- a/htdocs/accountancy/journal/purchasesjournal.php +++ b/htdocs/accountancy/journal/purchasesjournal.php @@ -2,7 +2,7 @@ /* Copyright (C) 2007-2010 Laurent Destailleur * Copyright (C) 2007-2010 Jean Heimburger * Copyright (C) 2011 Juanjo Menent - * Copyright (C) 2012 Regis Houssin + * Copyright (C) 2012 Regis Houssin * Copyright (C) 2013-2017 Alexandre Spangaro * Copyright (C) 2013-2016 Olivier Geffroy * Copyright (C) 2013-2016 Florian Henry diff --git a/htdocs/accountancy/journal/sellsjournal.php b/htdocs/accountancy/journal/sellsjournal.php index c03c800f5d6..51493942516 100644 --- a/htdocs/accountancy/journal/sellsjournal.php +++ b/htdocs/accountancy/journal/sellsjournal.php @@ -2,7 +2,7 @@ /* Copyright (C) 2007-2010 Laurent Destailleur * Copyright (C) 2007-2010 Jean Heimburger * Copyright (C) 2011 Juanjo Menent - * Copyright (C) 2012 Regis Houssin + * Copyright (C) 2012 Regis Houssin * Copyright (C) 2013 Christophe Battarel * Copyright (C) 2013-2017 Alexandre Spangaro * Copyright (C) 2013-2016 Florian Henry diff --git a/htdocs/adherents/class/adherent_type.class.php b/htdocs/adherents/class/adherent_type.class.php index a7775332812..eec88a59c11 100644 --- a/htdocs/adherents/class/adherent_type.class.php +++ b/htdocs/adherents/class/adherent_type.class.php @@ -134,7 +134,7 @@ class AdherentType extends CommonObject $sql.= "note = '".$this->db->escape($this->note)."',"; $sql.= "vote = '".$this->db->escape($this->vote)."',"; $sql.= "mail_valid = '".$this->db->escape($this->mail_valid)."'"; - $sql .= " WHERE rowid =".$this->id; + $sql.= " WHERE rowid =".$this->id; $result = $this->db->query($sql); if ($result) @@ -252,7 +252,7 @@ class AdherentType extends CommonObject $sql = "SELECT rowid, libelle"; $sql.= " FROM ".MAIN_DB_PREFIX."adherent_type"; - $sql.= " WHERE entity = ".$conf->entity; + $sql.= " WHERE entity IN (".getEntity('adherent').")"; $resql=$this->db->query($sql); if ($resql) diff --git a/htdocs/adherents/subscription.php b/htdocs/adherents/subscription.php index cd30bc28080..8002b33b1f6 100644 --- a/htdocs/adherents/subscription.php +++ b/htdocs/adherents/subscription.php @@ -114,7 +114,6 @@ if ($action == 'confirm_create_thirdparty' && $confirm == 'yes' && $user->rights if ($result < 0) { $langs->load("errors"); - $errmsg=$langs->trans($company->error); setEventMessages($company->error, $company->errors, 'errors'); } else @@ -124,7 +123,7 @@ if ($action == 'confirm_create_thirdparty' && $confirm == 'yes' && $user->rights } else { - $errmsg=$object->error; + setEventMessages($object->error, $object->errors, 'errors'); } } @@ -212,7 +211,7 @@ if ($user->rights->adherent->cotisation->creer && $action == 'subscription' && ! { $paymentdate=dol_mktime(0, 0, 0, $_POST["paymentmonth"], $_POST["paymentday"], $_POST["paymentyear"]); } - $subscription=$_POST["subscription"]; // Amount of subscription + $subscription=price2num(GETPOST("subscription",'alpha')); // Amount of subscription $label=$_POST["label"]; // Payment informations @@ -230,6 +229,7 @@ if ($user->rights->adherent->cotisation->creer && $action == 'subscription' && ! $error++; $langs->load("errors"); $errmsg=$langs->trans("ErrorBadDateFormat",$langs->transnoentitiesnoconv("DateSubscription")); + setEventMessages($errmsg, null, 'errors'); $action='addsubscription'; } if (GETPOST('end') && ! $datesubend) @@ -237,6 +237,7 @@ if ($user->rights->adherent->cotisation->creer && $action == 'subscription' && ! $error++; $langs->load("errors"); $errmsg=$langs->trans("ErrorBadDateFormat",$langs->transnoentitiesnoconv("DateEndSubscription")); + setEventMessages($errmsg, null, 'errors'); $action='addsubscription'; } if (! $datesubend) @@ -247,16 +248,20 @@ if ($user->rights->adherent->cotisation->creer && $action == 'subscription' && ! { $error++; $errmsg=$langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("DatePayment")); + setEventMessages($errmsg, null, 'errors'); $action='addsubscription'; } + $amount = price2num(GETPOST("subscription",'alpha')); + // Check if a payment is mandatory or not if (! $error && $adht->subscription) // Member type need subscriptions { - if (! is_numeric($_POST["subscription"])) + if (! is_numeric($amount)) { // If field is '' or not a numeric value $errmsg=$langs->trans("ErrorFieldRequired",$langs->transnoentities("Amount")); + setEventMessages($errmsg, null, 'errors'); $error++; $action='addsubscription'; } @@ -274,7 +279,11 @@ if ($user->rights->adherent->cotisation->creer && $action == 'subscription' && ! { if ($_POST["accountid"]) $errmsg=$langs->trans("ErrorDoNotProvideAccountsIfNullAmount"); } - if ($errmsg) $action='addsubscription'; + if ($errmsg) + { + setEventMessages($errmsg, null, 'errors'); + $action='addsubscription'; + } } } } @@ -320,6 +329,7 @@ if ($user->rights->adherent->cotisation->creer && $action == 'subscription' && ! { $error++; $errmsg=$db->lasterror(); + setEventMessages($errmsg, null, 'errors'); } } else @@ -327,14 +337,16 @@ if ($user->rights->adherent->cotisation->creer && $action == 'subscription' && ! $error++; $errmsg=$acct->error; $errmsgs=$acct->errors; - } + setEventMessages($errmsg, $errmsgs, 'errors'); + } } else { $error++; $errmsg=$acct->error; $errmsgs=$acct->errors; - } + setEventMessages($errmsg, $errmsgs, 'errors'); + } } // If option choosed, we create invoice @@ -352,6 +364,7 @@ if ($user->rights->adherent->cotisation->creer && $action == 'subscription' && ! { $langs->load("errors"); $errmsg=$langs->trans("ErrorMemberNotLinkedToAThirpartyLinkOrCreateFirst"); + setEventMessages($errmsg, null, 'errors'); $error++; } } @@ -362,6 +375,7 @@ if ($user->rights->adherent->cotisation->creer && $action == 'subscription' && ! { $errmsg=$customer->error; $errmsgs=$acct->errors; + setEventMessages($errmsg, $errmsgs, 'errors'); $error++; } } @@ -379,6 +393,7 @@ if ($user->rights->adherent->cotisation->creer && $action == 'subscription' && ! { $error++; $errmsg='ErrorNoPaymentTermRECEPFound'; + setEventMessages($errmsg, null, 'errors'); } } $invoice->socid=$object->fk_soc; @@ -396,6 +411,7 @@ if ($user->rights->adherent->cotisation->creer && $action == 'subscription' && ! { $errmsg=$invoice->error; $errmsgs=$invoice->errors; + setEventMessages($errmsg, $errmsgs, 'errors'); $error++; } } @@ -416,6 +432,7 @@ if ($user->rights->adherent->cotisation->creer && $action == 'subscription' && ! if ($result <= 0) { $errmsg=$invoice->error; + setEventMessages($errmsg, null, 'errors'); $error++; } } @@ -428,6 +445,7 @@ if ($user->rights->adherent->cotisation->creer && $action == 'subscription' && ! { $errmsg=$invoice->error; $errmsgs=$invoice->errors; + setEventMessages($errmsg, $errmsgs, 'errors'); $error++; } } @@ -455,6 +473,7 @@ if ($user->rights->adherent->cotisation->creer && $action == 'subscription' && ! { $errmsg=$paiement->error; $errmsgs=$paiement->errors; + setEventMessages($errmsg, $errmsgs, 'errors'); $error++; } } @@ -536,6 +555,7 @@ if ($user->rights->adherent->cotisation->creer && $action == 'subscription' && ! if ($result < 0) { $errmsg=$object->error; + setEventMessages($errmsg, null, 'errors'); } } diff --git a/htdocs/admin/agenda.php b/htdocs/admin/agenda.php index a30ebad4703..fa2c11849fb 100644 --- a/htdocs/admin/agenda.php +++ b/htdocs/admin/agenda.php @@ -131,12 +131,11 @@ if (preg_match('/del_(.*)/',$action,$reg)) * View */ -llxHeader(); +$wikihelp='EN:Module_Agenda_En|FR:Module_Agenda|ES:Módulo_Agenda'; +llxHeader('', $langs->trans("AgendaSetup"), $wikihelp); $linkback=''.$langs->trans("BackToModuleList").''; print load_fiche_titre($langs->trans("AgendaSetup"),$linkback,'title_setup'); -print "
\n"; - print '
'; print ''; diff --git a/htdocs/admin/agenda_extrafields.php b/htdocs/admin/agenda_extrafields.php index 74ae6cb2d95..b331611e511 100644 --- a/htdocs/admin/agenda_extrafields.php +++ b/htdocs/admin/agenda_extrafields.php @@ -67,11 +67,11 @@ require DOL_DOCUMENT_ROOT.'/core/actions_extrafields.inc.php'; $textobject=$langs->transnoentitiesnoconv("Agenda"); -llxHeader('',$langs->trans("AgendaSetup")); +$wikihelp='EN:Module_Agenda_En|FR:Module_Agenda|ES:Módulo_Agenda'; +llxHeader('', $langs->trans("AgendaSetup"), $wikihelp); $linkback=''.$langs->trans("BackToModuleList").''; print load_fiche_titre($langs->trans("AgendaSetup"),$linkback,'title_setup'); -print "
\n"; $head=agenda_prepare_head(); diff --git a/htdocs/admin/agenda_extsites.php b/htdocs/admin/agenda_extsites.php index 0b69b947a38..24319a34a28 100644 --- a/htdocs/admin/agenda_extsites.php +++ b/htdocs/admin/agenda_extsites.php @@ -125,11 +125,11 @@ $formother=new FormOther($db); $arrayofjs=array(); $arrayofcss=array(); -llxHeader('',$langs->trans("AgendaSetup"),'','',0,0,$arrayofjs,$arrayofcss); +$wikihelp='EN:Module_Agenda_En|FR:Module_Agenda|ES:Módulo_Agenda'; +llxHeader('',$langs->trans("AgendaSetup"),$wikihelp,'',0,0,$arrayofjs,$arrayofcss); $linkback=''.$langs->trans("BackToModuleList").''; print load_fiche_titre($langs->trans("AgendaSetup"),$linkback,'title_setup'); -print '
'; print ''; print ''; @@ -210,7 +210,7 @@ while ($i <= $MAXAGENDA) $color='AGENDA_EXT_COLOR'.$key; $enabled='AGENDA_EXT_ENABLED'.$key; - + print ''; // Nb print ''.$langs->trans("AgendaExtNb",$key).""; diff --git a/htdocs/admin/agenda_other.php b/htdocs/admin/agenda_other.php index cf4f3832a1f..a5e37f620f7 100644 --- a/htdocs/admin/agenda_other.php +++ b/htdocs/admin/agenda_other.php @@ -42,7 +42,7 @@ $action = GETPOST('action','alpha'); $value = GETPOST('value','alpha'); $param = GETPOST('param','alpha'); $cancel = GETPOST('cancel','alpha'); -$scandir = GETPOST('scandir','alpha'); +$scandir = GETPOST('scan_dir','alpha'); $type = 'action'; @@ -174,12 +174,12 @@ else if ($action == 'setdoc') $formactions=new FormActions($db); $dirmodels=array_merge(array('/'),(array) $conf->modules_parts['models']); -llxHeader(); + +$wikihelp='EN:Module_Agenda_En|FR:Module_Agenda|ES:Módulo_Agenda'; +llxHeader('', $langs->trans("AgendaSetup"),$wikihelp); $linkback=''.$langs->trans("BackToModuleList").''; print load_fiche_titre($langs->trans("AgendaSetup"),$linkback,'title_setup'); -print "
\n"; - @@ -273,7 +273,7 @@ if ($conf->global->MAIN_FEATURES_LEVEL >= 2) print ''."\n"; if ($conf->global->ACTION_EVENT_ADDON_PDF != "$name") { - print 'scandir.'&label='.urlencode($module->name).'&type=action">'; + print 'scandir.'&label='.urlencode($module->name).'&type=action">'; print img_picto($langs->trans("Enabled"),'switch_on'); print ''; } @@ -286,7 +286,7 @@ if ($conf->global->MAIN_FEATURES_LEVEL >= 2) else { print ''."\n"; - print 'scandir.'&label='.urlencode($module->name).'&type=action">'.img_picto($langs->trans("Disabled"),'switch_off').''; + print 'scandir.'&label='.urlencode($module->name).'&type=action">'.img_picto($langs->trans("Disabled"),'switch_off').''; print ""; } @@ -298,7 +298,7 @@ if ($conf->global->MAIN_FEATURES_LEVEL >= 2) } else { - print 'scandir.'&label='.urlencode($module->name).'&type=action"" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"),'off').''; + print 'scandir.'&label='.urlencode($module->name).'&type=action"" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"),'off').''; } print ''; @@ -389,37 +389,6 @@ $tmplist=array('show_list'=>$langs->trans("ViewList"), 'show_month'=>$langs->tra print $form->selectarray('AGENDA_DEFAULT_VIEW', $tmplist, $conf->global->AGENDA_DEFAULT_VIEW); print ''."\n"; -// AGENDA NOTIFICATION -if ($conf->global->MAIN_FEATURES_LEVEL > 0) -{ - - print ''."\n"; - print ''.$langs->trans('AGENDA_NOTIFICATION').''."\n"; - print ' '."\n"; - print ''."\n"; - - if (empty($conf->global->AGENDA_NOTIFICATION)) { - print ''.img_picto($langs->trans('Disabled'),'switch_off').''; - print ''."\n"; - } else { - print ''.img_picto($langs->trans('Enabled'),'switch_on').''; - print ''."\n"; - - print ''."\n"; - print ''.$langs->trans('AGENDA_NOTIFICATION_SOUND').''."\n"; - print ' '."\n"; - print ''."\n"; - - if (empty($conf->global->AGENDA_NOTIFICATION_SOUND)) { - print ''.img_picto($langs->trans('Disabled'),'switch_off').''; - } else { - print ''.img_picto($langs->trans('Enabled'),'switch_on').''; - } - - print ''."\n"; - } -} - print ''; dol_fiche_end(); diff --git a/htdocs/admin/agenda_reminder.php b/htdocs/admin/agenda_reminder.php new file mode 100644 index 00000000000..635f3c0cdd5 --- /dev/null +++ b/htdocs/admin/agenda_reminder.php @@ -0,0 +1,255 @@ + + * + * 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 + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** + * \file htdocs/admin/agenda_reminder.php + * \ingroup agenda + * \brief Page to setup agenda reminder options + */ + +require '../main.inc.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/agenda.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php'; + +if (!$user->admin) + accessforbidden(); + +$langs->load("admin"); +$langs->load("other"); +$langs->load("agenda"); + +$action = GETPOST('action','alpha'); +$value = GETPOST('value','alpha'); +$param = GETPOST('param','alpha'); +$cancel = GETPOST('cancel','alpha'); +$scandir = GETPOST('scandir','alpha'); +$type = 'action'; + + +/* + * Actions + */ + +include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php'; + +if (preg_match('/set_(.*)/',$action,$reg)) +{ + $code=$reg[1]; + $value=(GETPOST($code) ? GETPOST($code) : 1); + if (dolibarr_set_const($db, $code, $value, 'chaine', 0, '', $conf->entity) > 0) + { + Header("Location: ".$_SERVER["PHP_SELF"]); + exit; + } + else + { + dol_print_error($db); + } +} + +if (preg_match('/del_(.*)/',$action,$reg)) +{ + $code=$reg[1]; + if (dolibarr_del_const($db, $code, $conf->entity) > 0) + { + Header("Location: ".$_SERVER["PHP_SELF"]); + exit; + } + else + { + dol_print_error($db); + } +} +if ($action == 'set') +{ + dolibarr_set_const($db, 'AGENDA_USE_EVENT_TYPE_DEFAULT', GETPOST('AGENDA_USE_EVENT_TYPE_DEFAULT'), 'chaine', 0, '', $conf->entity); + dolibarr_set_const($db, 'AGENDA_DEFAULT_FILTER_TYPE', GETPOST('AGENDA_DEFAULT_FILTER_TYPE'), 'chaine', 0, '', $conf->entity); + dolibarr_set_const($db, 'AGENDA_DEFAULT_FILTER_STATUS', GETPOST('AGENDA_DEFAULT_FILTER_STATUS'), 'chaine', 0, '', $conf->entity); + dolibarr_set_const($db, 'AGENDA_DEFAULT_VIEW', GETPOST('AGENDA_DEFAULT_VIEW'), 'chaine', 0, '', $conf->entity); +} +else if ($action == 'specimen') // For orders +{ + $modele=GETPOST('module','alpha'); + + $commande = new CommandeFournisseur($db); + $commande->initAsSpecimen(); + $commande->thirdparty=$specimenthirdparty; + + // Search template files + $file=''; $classname=''; $filefound=0; + $dirmodels=array_merge(array('/'),(array) $conf->modules_parts['models']); + foreach($dirmodels as $reldir) + { + $file=dol_buildpath($reldir."core/modules/action/doc/pdf_".$modele.".modules.php",0); + if (file_exists($file)) + { + $filefound=1; + $classname = "pdf_".$modele; + break; + } + } + + if ($filefound) + { + require_once $file; + + $module = new $classname($db,$commande); + + if ($module->write_file($commande,$langs) > 0) + { + header("Location: ".DOL_URL_ROOT."/document.php?modulepart=action&file=SPECIMEN.pdf"); + return; + } + else + { + setEventMessages($module->error, $module->errors, 'errors'); + dol_syslog($module->error, LOG_ERR); + } + } + else + { + setEventMessages($langs->trans("ErrorModuleNotFound"), null, 'errors'); + dol_syslog($langs->trans("ErrorModuleNotFound"), LOG_ERR); + } +} + +// Activate a model +else if ($action == 'setmodel') +{ + //print "sssd".$value; + $ret = addDocumentModel($value, $type, $label, $scandir); +} + +else if ($action == 'del') +{ + $ret = delDocumentModel($value, $type); + if ($ret > 0) + { + if ($conf->global->ACTION_EVENT_ADDON_PDF == "$value") dolibarr_del_const($db, 'ACTION_EVENT_ADDON_PDF',$conf->entity); + } +} + +// Set default model +else if ($action == 'setdoc') +{ + if (dolibarr_set_const($db, "ACTION_EVENT_ADDON_PDF",$value,'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->ACTION_EVENT_ADDON_PDF = $value; + } + + // On active le modele + $ret = delDocumentModel($value, $type); + if ($ret > 0) + { + $ret = addDocumentModel($value, $type, $label, $scandir); + } +} + + +/** + * View + */ + +$formactions=new FormActions($db); +$dirmodels=array_merge(array('/'),(array) $conf->modules_parts['models']); +llxHeader(); + +$linkback=''.$langs->trans("BackToModuleList").''; +print load_fiche_titre($langs->trans("AgendaSetup"),$linkback,'title_setup'); +print "
\n"; + + + + +$head=agenda_prepare_head(); + +dol_fiche_head($head, 'reminders', $langs->trans("Agenda"), -1, 'action'); + +print ''; +print ''; + +print ''."\n"; +print ''."\n"; +print ''."\n"; +print ''."\n"; +print ''."\n"; +print ''."\n"; + + +// AGENDA REMINDER EMAIL +if ($conf->global->MAIN_FEATURES_LEVEL > 0) +{ + print ''."\n"; + print ''."\n"; + print ''."\n"; + print ''."\n"; + } else { + print ''.img_picto($langs->trans('Enabled'),'switch_on').''; + print ''."\n"; + } +} + +// AGENDA REMINDER BROWSER +if ($conf->global->MAIN_FEATURES_LEVEL > 0) +{ + print ''."\n"; + print ''."\n"; + print ''."\n"; + print ''."\n"; + } else { + print ''.img_picto($langs->trans('Enabled'),'switch_on').''; + print ''."\n"; + + print ''."\n"; + print ''."\n"; + print ''."\n"; + print ''."\n"; + } +} + +print '
'.$langs->trans("Parameters").' '.$langs->trans("Value").'
'.$langs->trans('AGENDA_REMINDER_EMAIL', $langs->transnoentities("Module2300Name")).' '."\n"; + + if (empty($conf->global->AGENDA_REMINDER_EMAIL)) { + print ''.img_picto($langs->trans('Disabled'),'switch_off').''; + print '
'.$langs->trans('AGENDA_REMINDER_BROWSER').' '."\n"; + + if (empty($conf->global->AGENDA_REMINDER_BROWSER)) { + print ''.img_picto($langs->trans('Disabled'),'switch_off').''; + print '
'.$langs->trans('AGENDA_REMINDER_BROWSER_SOUND').' '."\n"; + + if (empty($conf->global->AGENDA_REMINDER_BROWSER_SOUND)) { + print ''.img_picto($langs->trans('Disabled'),'switch_off').''; + } else { + print ''.img_picto($langs->trans('Enabled'),'switch_on').''; + } + + print '
'; + +dol_fiche_end(); + +print '
'; + +print ''; + +print "
"; + +llxFooter(); + +$db->close(); diff --git a/htdocs/admin/agenda_xcal.php b/htdocs/admin/agenda_xcal.php index 99742b19f57..93f0e909ab9 100644 --- a/htdocs/admin/agenda_xcal.php +++ b/htdocs/admin/agenda_xcal.php @@ -71,11 +71,11 @@ if ($actionsave) if (! isset($conf->global->MAIN_AGENDA_EXPORT_PAST_DELAY)) $conf->global->MAIN_AGENDA_EXPORT_PAST_DELAY=100; -llxHeader(); +$wikihelp='EN:Module_Agenda_En|FR:Module_Agenda|ES:Módulo_Agenda'; +llxHeader('', $langs->trans("AgendaSetup"), $wikihelp); $linkback=''.$langs->trans("BackToModuleList").''; print load_fiche_titre($langs->trans("AgendaSetup"),$linkback,'title_setup'); -print '
'; print '
'; diff --git a/htdocs/admin/bank.php b/htdocs/admin/bank.php index afe60acff2e..c42fd305eba 100644 --- a/htdocs/admin/bank.php +++ b/htdocs/admin/bank.php @@ -1,4 +1,5 @@ * Copyright (C) 2010-2016 Juanjo Menent * Copyright (C) 2013-2014 Philippe Grand @@ -21,15 +22,14 @@ /** * \file htdocs/admin/bank.php - * \ingroup bank - * \brief Page to setup the bank module + * \ingroup bank + * \brief Page to setup the bank module */ - require '../main.inc.php'; -require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; -require_once DOL_DOCUMENT_ROOT.'/core/lib/bank.lib.php'; -require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; -require_once DOL_DOCUMENT_ROOT.'/societe/class/companybankaccount.class.php'; +require_once DOL_DOCUMENT_ROOT . '/core/lib/admin.lib.php'; +require_once DOL_DOCUMENT_ROOT . '/core/lib/bank.lib.php'; +require_once DOL_DOCUMENT_ROOT . '/compta/bank/class/account.class.php'; +require_once DOL_DOCUMENT_ROOT . '/societe/class/companybankaccount.class.php'; $langs->load("admin"); $langs->load("companies"); @@ -38,12 +38,12 @@ $langs->load("other"); $langs->load("banks"); if (!$user->admin) - accessforbidden(); + accessforbidden(); -$action = GETPOST('action','alpha'); -$value = GETPOST('value','alpha'); -$label = GETPOST('label','alpha'); -$scandir = GETPOST('scandir','alpha'); +$action = GETPOST('action', 'alpha'); +$value = GETPOST('value', 'alpha'); +$label = GETPOST('label', 'alpha'); +$scandir = GETPOST('scan_dir', 'alpha'); $type = 'bankaccount'; @@ -52,100 +52,109 @@ $type = 'bankaccount'; */ //Order display of bank account -if ($action == 'setbankorder') -{ - if (dolibarr_set_const($db, "BANK_SHOW_ORDER_OPTION",GETPOST('value','alpha'),'chaine',0,'',$conf->entity) > 0) - { - header("Location: ".$_SERVER["PHP_SELF"]); - exit; - } - else - { - dol_print_error($db); - } +if ($action == 'setbankorder') { + if (dolibarr_set_const($db, "BANK_SHOW_ORDER_OPTION", + GETPOST('value', 'alpha'), 'chaine', 0, '', $conf->entity) > 0) { + header("Location: " . $_SERVER["PHP_SELF"]); + exit; + } + else { + dol_print_error($db); + } +} + +//Auto report last num releve on conciliate +if ($action == 'setreportlastnumreleve') { + if (dolibarr_set_const($db, "BANK_REPORT_LAST_NUM_RELEVE", 1, 'chaine', 0, + '', $conf->entity) > 0) { + header("Location: " . $_SERVER["PHP_SELF"]); + exit; + } + else { + dol_print_error($db); + } +} +elseif ($action == 'unsetreportlastnumreleve') { + if (dolibarr_set_const($db, "BANK_REPORT_LAST_NUM_RELEVE", 0, 'chaine', 0, + '', $conf->entity) > 0) { + header("Location: " . $_SERVER["PHP_SELF"]); + exit; + } + else { + dol_print_error($db); + } } -if ($action == 'specimen') -{ - $modele=GETPOST('module','alpha'); - - if ($modele == 'sepamandate') - { +if ($action == 'specimen') { + $modele = GETPOST('module', 'alpha'); + + if ($modele == 'sepamandate') { $object = new CompanyBankAccount($db); } - else - { + else { $object = new Account($db); } $object->initAsSpecimen(); - + // Search template files - $file=''; $classname=''; $filefound=0; - $dirmodels=array_merge(array('/'),(array) $conf->modules_parts['models']); - foreach($dirmodels as $reldir) - { - $file=dol_buildpath($reldir."core/modules/bank/doc/pdf_".$modele.".modules.php",0); - if (file_exists($file)) - { - $filefound=1; - $classname = "pdf_".$modele; + $file = ''; + $classname = ''; + $filefound = 0; + $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); + foreach ($dirmodels as $reldir) { + $file = dol_buildpath($reldir . "core/modules/bank/doc/pdf_" . $modele . ".modules.php", + 0); + if (file_exists($file)) { + $filefound = 1; + $classname = "pdf_" . $modele; break; } } - - if ($filefound) - { + + if ($filefound) { require_once $file; - + $module = new $classname($db); - - if ($module->write_file($object,$langs) > 0) - { - header("Location: ".DOL_URL_ROOT."/document.php?modulepart=bank&file=SPECIMEN.pdf"); + + if ($module->write_file($object, $langs) > 0) { + header("Location: " . DOL_URL_ROOT . "/document.php?modulepart=bank&file=SPECIMEN.pdf"); return; } - else - { + else { setEventMessages($module->error, null, 'errors'); dol_syslog($module->error, LOG_ERR); } } - else - { + else { setEventMessages($langs->trans("ErrorModuleNotFound"), null, 'errors'); dol_syslog($langs->trans("ErrorModuleNotFound"), LOG_ERR); } } // Activate a model -if ($action == 'set') -{ - $ret = addDocumentModel($value, $type, $label, $scandir); +if ($action == 'set') { + $ret = addDocumentModel($value, $type, $label, $scandir); } - -else if ($action == 'del') -{ - $ret = delDocumentModel($value, $type); - if ($ret > 0) - { - if ($conf->global->BANKADDON_PDF == "$value") dolibarr_del_const($db, 'BANKADDON_PDF',$conf->entity); - } +else if ($action == 'del') { + $ret = delDocumentModel($value, $type); + if ($ret > 0) { + if ($conf->global->BANKADDON_PDF == "$value") + dolibarr_del_const($db, 'BANKADDON_PDF', $conf->entity); + } } // Set default model -else if ($action == 'setdoc') -{ - if (dolibarr_set_const($db, "BANKADDON_PDF",$value,'chaine',0,'',$conf->entity)) - { +else if ($action == 'setdoc') { + if (dolibarr_set_const($db, "BANKADDON_PDF", $value, 'chaine', 0, '', + $conf->entity)) { // The constant that was read before the new set // We therefore requires a variable to have a coherent view $conf->global->BANKADDON_PDF = $value; } - + // On active le modele $ret = delDocumentModel($value, $type); - if ($ret > 0) - { + if ($ret > 0) { $ret = addDocumentModel($value, $type, $label, $scandir); } } @@ -156,80 +165,78 @@ else if ($action == 'setdoc') * view */ -$form=new Form($db); +$form = new Form($db); -$dirmodels=array_merge(array('/'),(array) $conf->modules_parts['models']); +$dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); -llxHeader("",$langs->trans("BankSetupModule")); +llxHeader("", $langs->trans("BankSetupModule")); -$linkback=''.$langs->trans("BackToModuleList").''; -print load_fiche_titre($langs->trans("BankSetupModule"),$linkback,'title_setup'); +$linkback = '' . $langs->trans("BackToModuleList") . ''; +print load_fiche_titre($langs->trans("BankSetupModule"), $linkback, + 'title_setup'); $head = bank_admin_prepare_head(null); dol_fiche_head($head, 'general', $langs->trans("BankSetupModule"), -1, 'account'); -$var=true; +$var = true; -$var=! $var; +$var = !$var; //Show bank account order print load_fiche_titre($langs->trans("BankOrderShow"), '', ''); print ''; print ''; -print ''; -print ''; -print ''; -print ''; +print ''; +print ''; +print ''; +print ''; print ''; print "\n"; -$bankorder[0][0]=$langs->trans("BankOrderGlobal"); -$bankorder[0][1]=$langs->trans("BankOrderGlobalDesc"); -$bankorder[0][2]='BankCode DeskCode BankAccountNumber BankAccountNumberKey'; -$bankorder[1][0]=$langs->trans("BankOrderES"); -$bankorder[1][1]=$langs->trans("BankOrderESDesc"); -$bankorder[1][2]='BankCode DeskCode BankAccountNumberKey BankAccountNumber'; +$bankorder[0][0] = $langs->trans("BankOrderGlobal"); +$bankorder[0][1] = $langs->trans("BankOrderGlobalDesc"); +$bankorder[0][2] = 'BankCode DeskCode BankAccountNumber BankAccountNumberKey'; +$bankorder[1][0] = $langs->trans("BankOrderES"); +$bankorder[1][1] = $langs->trans("BankOrderESDesc"); +$bankorder[1][2] = 'BankCode DeskCode BankAccountNumberKey BankAccountNumber'; $var = true; -$i=0; +$i = 0; -$nbofbank=count($bankorder); -while ($i < $nbofbank) -{ - $var = !$var; +$nbofbank = count($bankorder); +while ($i < $nbofbank) { + $var = !$var; - print ''; - print ''; - print '\n"; + print ''; + print ''; + print '\n"; - if ($conf->global->BANK_SHOW_ORDER_OPTION == $i) - { - print ''; - } - else - { - print ''; - } - print ''; - print ''."\n"; - $i++; + if ($conf->global->BANK_SHOW_ORDER_OPTION == $i) { + print ''; + } + else { + print ''; + } + print ''; + print '' . "\n"; + $i++; } -print '
'.$langs->trans("Name").''.$langs->trans("Description").''.$langs->trans("Example").''.$langs->trans("Status").'' . $langs->trans("Name") . '' . $langs->trans("Description") . '' . $langs->trans("Example") . '' . $langs->trans("Status") . ' 
'.$bankorder[$i][0]."\n"; - print $bankorder[$i][1]; - print ''; - $tmparray=explode(' ',$bankorder[$i][2]); - foreach($tmparray as $key => $val) - { - if ($key > 0) print ', '; - print $langs->trans($val); - } - print "
' . $bankorder[$i][0] . "\n"; + print $bankorder[$i][1]; + print ''; + $tmparray = explode(' ', $bankorder[$i][2]); + foreach ($tmparray as $key => $val) { + if ($key > 0) + print ', '; + print $langs->trans($val); + } + print "'; - print img_picto($langs->trans("Activated"),'on'); - print ''; - print img_picto($langs->trans("Disabled"),'off'); - print ' 
'; + print img_picto($langs->trans("Activated"), 'on'); + print ''; + print img_picto($langs->trans("Disabled"), 'off'); + print ' 
'."\n"; +print '' . "\n"; print '

'; @@ -257,7 +264,8 @@ if ($resql) { array_push($def, $array[0]); $i ++; } -} else { +} +else { dol_print_error($db); } @@ -273,11 +281,10 @@ print "\n"; clearstatcache(); -foreach ($dirmodels as $reldir) -{ +foreach ($dirmodels as $reldir) { foreach (array('', '/doc') as $valdir) { $dir = dol_buildpath($reldir . "core/modules/bank" . $valdir); - + if (is_dir($dir)) { $handle = opendir($dir); if (is_resource($handle)) { @@ -286,23 +293,26 @@ foreach ($dirmodels as $reldir) } closedir($handle); arsort($filelist); - + foreach ($filelist as $file) { - if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file)) { - + if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', + $file)) { + if (file_exists($dir . '/' . $file)) { $name = substr($file, 4, dol_strlen($file) - 16); $classname = substr($file, 0, dol_strlen($file) - 12); - + require_once $dir . '/' . $file; $module = new $classname($db); - + $modulequalified = 1; - if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) + if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL + < 2) $modulequalified = 0; - if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) + if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL + < 1) $modulequalified = 0; - + if ($modulequalified) { print ''; print(empty($module->name) ? $name : $module->name); @@ -312,29 +322,35 @@ foreach ($dirmodels as $reldir) else print $module->description; print ''; - + // Active if (in_array($name, $def)) { print '' . "\n"; print ''; - print img_picto($langs->trans("Enabled"), 'switch_on'); + print img_picto($langs->trans("Enabled"), + 'switch_on'); print ''; print ''; - } else { + } + else { print '' . "\n"; - print '' . img_picto($langs->trans("Disabled"), 'switch_off') . ''; + print '' . img_picto($langs->trans("Disabled"), + 'switch_off') . ''; print ""; } - + // Default print ''; if ($conf->global->BANKADDON_PDF == $name) { - print img_picto($langs->trans("Default"), 'on'); - } else { - print '' . img_picto($langs->trans("Disabled"), 'off') . ''; + print img_picto($langs->trans("Default"), + 'on'); + } + else { + print '' . 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")); @@ -342,27 +358,33 @@ foreach ($dirmodels as $reldir) $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("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("MultiLanguage") . ': ' . yn($module->option_multilang, + 1, 1); // $htmltooltip.='
'.$langs->trans("Discounts").': '.yn($module->option_escompte,1,1); // $htmltooltip.='
'.$langs->trans("CreditNote").': '.yn($module->option_credit_note,1,1); //$htmltooltip .= '
' . $langs->trans("WatermarkOnDraftOrders") . ': ' . yn($module->option_draft_watermark, 1, 1); - + print ''; - print $form->textwithpicto('', $htmltooltip, 1, 0); + print $form->textwithpicto('', $htmltooltip, 1, + 0); print ''; - + // Preview print ''; if ($module->type == 'pdf') { - print '' . img_object($langs->trans("Preview"), 'bill') . ''; - } else { - print img_object($langs->trans("PreviewNotAvailable"), 'generic'); + print '' . img_object($langs->trans("Preview"), + 'bill') . ''; + } + else { + print img_object($langs->trans("PreviewNotAvailable"), + 'generic'); } print ''; - + print "\n"; } } @@ -372,9 +394,51 @@ foreach ($dirmodels as $reldir) } } } +print ''; //} + +print '

'; + + +/* + * Document templates generators + */ +//if (! empty($conf->global->MAIN_FEATURES_LEVEL)) +//{ +print load_fiche_titre($langs->trans("BankAccountReleveModule"), '', ''); + + +print "\n"; +print "\n"; +print ''; +print ''; +print '\n"; +print "\n"; + +print ''; +// Active +if ($conf->global->BANK_REPORT_LAST_NUM_RELEVE) { + print ''; +} +else { + print '"; +} + +print "\n"; +print '
' . $langs->trans("Name") . '' . $langs->trans("Description") . '' . $langs->trans("Status") . "
'; +print $langs->trans('AccountStatement'); +print "\n"; +print $langs->trans('AutoReportLastAccountStatement'); +print '' . "\n"; + print ''; + print img_picto($langs->trans("Enabled"), 'switch_on'); + print ''; + print '' . "\n"; + print '' . img_picto($langs->trans("Disabled"), + 'switch_off') . ''; + print "
'; dol_fiche_end(); llxFooter(); diff --git a/htdocs/admin/chequereceipts.php b/htdocs/admin/chequereceipts.php index 3d3db2451d2..0a31b24b109 100644 --- a/htdocs/admin/chequereceipts.php +++ b/htdocs/admin/chequereceipts.php @@ -190,7 +190,7 @@ foreach ($dirmodels as $reldir) } else { - print 'scandir.'&label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"),'switch_off').''; + print 'scandir.'&label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"),'switch_off').''; } print ''; diff --git a/htdocs/admin/commande.php b/htdocs/admin/commande.php index e9ad5ab6ed6..1c88073cf2b 100644 --- a/htdocs/admin/commande.php +++ b/htdocs/admin/commande.php @@ -46,7 +46,7 @@ if (! $user->admin) accessforbidden(); $action = GETPOST('action','alpha'); $value = GETPOST('value','alpha'); $label = GETPOST('label','alpha'); -$scandir = GETPOST('scandir','alpha'); +$scandir = GETPOST('scan_dir','alpha'); $type = 'order'; @@ -464,7 +464,7 @@ foreach ($dirmodels as $reldir) else { print ''."\n"; - print 'scandir.'&label='.urlencode($module->name).'">'.img_picto($langs->trans("Disabled"),'switch_off').''; + print 'scandir.'&label='.urlencode($module->name).'">'.img_picto($langs->trans("Disabled"),'switch_off').''; print ""; } @@ -476,7 +476,7 @@ foreach ($dirmodels as $reldir) } else { - print 'scandir.'&label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"),'off').''; + print 'scandir.'&label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"),'off').''; } print ''; diff --git a/htdocs/admin/contract.php b/htdocs/admin/contract.php index 427b3a531c4..ae8daea86e2 100644 --- a/htdocs/admin/contract.php +++ b/htdocs/admin/contract.php @@ -37,7 +37,7 @@ if (!$user->admin) accessforbidden(); $action = GETPOST('action','alpha'); $value = GETPOST('value','alpha'); $label = GETPOST('label','alpha'); -$scandir = GETPOST('scandir','alpha'); +$scandir = GETPOST('scan_dir','alpha'); $type='contract'; if (empty($conf->global->CONTRACT_ADDON)) @@ -397,7 +397,7 @@ foreach ($dirmodels as $reldir) else { print ''."\n"; - print 'scandir.'&label='.urlencode($module->name).'">'.img_picto($langs->trans("Disabled"),'switch_off').''; + print 'scandir.'&label='.urlencode($module->name).'">'.img_picto($langs->trans("Disabled"),'switch_off').''; print ""; } @@ -409,7 +409,7 @@ foreach ($dirmodels as $reldir) } else { - print 'scandir.'&label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"),'off').''; + print 'scandir.'&label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"),'off').''; } print ''; diff --git a/htdocs/admin/dolistore/ajax/image.php b/htdocs/admin/dolistore/ajax/image.php new file mode 100644 index 00000000000..10ce4656c40 --- /dev/null +++ b/htdocs/admin/dolistore/ajax/image.php @@ -0,0 +1,67 @@ +. + * Copyright (C) 2008-2011 Laurent Destailleur + * + * This program is free software; you can redistribute it and/or modifyion 2.0 (the "License"); + * it under the terms of the GNU General Public License as published bypliance with the License. + * the Free Software Foundation; either version 3 of the License, or + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * or see http://www.gnu.org/ + */ + +if (!defined('REQUIRE_JQUERY_BLOCKUI')) define('REQUIRE_JQUERY_BLOCKUI', 1); + + +/** + * \file htdocs/commande/info.php + * \ingroup commande + * \brief Page des informations d'une commande + */ +$res = 0; +if (!$res && file_exists("../main.inc.php")) $res = @include("../main.inc.php"); +if (!$res && file_exists("../../main.inc.php")) $res = @include("../../main.inc.php"); +if (!$res && file_exists("../../../main.inc.php")) $res = @include("../../../main.inc.php"); +if (!$res && file_exists("../../../../main.inc.php")) $res = @include("../../../../main.inc.php"); +if (!$res && file_exists("../../../dolibarr/htdocs/main.inc.php")) + $res = @include("../../../dolibarr/htdocs/main.inc.php"); // Used on dev env only +if (!$res && file_exists("../../../../dolibarr/htdocs/main.inc.php")) + $res = @include("../../../../dolibarr/htdocs/main.inc.php"); // Used on dev env only +if (!$res && file_exists("../../../../../dolibarr/htdocs/main.inc.php")) + $res = @include("../../../../../dolibarr/htdocs/main.inc.php"); // Used on dev env only +if (!$res) die("Include of main fails"); + +// CORE + +global $lang, $user, $conf; + + +dol_include_once('/dolistore/class/dolistore.class.php'); +$dolistore = new Dolistore(); + +$id_product = GETPOST('id_product', 'int'); +$id_image = GETPOST('id_image', 'int'); +// quality : image resize with this in the URL : "cart_default", "home_default", "large_default", "medium_default", "small_default", "thickbox_default" +$quality = GETPOST('quality', 'alpha'); + +try { + $url = $conf->global->MAIN_MODULE_DOLISTORE_API_SRV.'/api/images/products/'.$id_product.'/'.$id_image.'/'.$quality; + $api = new PrestaShopWebservice($conf->global->MAIN_MODULE_DOLISTORE_API_SRV, + $conf->global->MAIN_MODULE_DOLISTORE_API_KEY, $dolistore->debug_api); + //echo $url; + $request = $api->executeRequest($url, array(CURLOPT_CUSTOMREQUEST => 'GET')); + header('Content-type:image'); + print $request['response']; +} catch (PrestaShopWebserviceException $e) { + // Here we are dealing with errors + $trace = $e->getTrace(); + if ($trace[0]['args'][0] == 404) die('Bad ID'); + else if ($trace[0]['args'][0] == 401) die('Bad auth key'); + else die('Can not access to '.$conf->global->MAIN_MODULE_DOLISTORE_API_SRV); +} \ No newline at end of file diff --git a/htdocs/admin/dolistore/class/PSWebServiceLibrary.class.php b/htdocs/admin/dolistore/class/PSWebServiceLibrary.class.php new file mode 100644 index 00000000000..bb59fa93929 --- /dev/null +++ b/htdocs/admin/dolistore/class/PSWebServiceLibrary.class.php @@ -0,0 +1,413 @@ + +* @copyright 2007-2013 PrestaShop SA +* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) +* International Registered Trademark & Property of PrestaShop SA +* PrestaShop Webservice Library +* @package PrestaShopWebservice +*/ + +/** + * @package PrestaShopWebservice + */ +class PrestaShopWebservice +{ + + /** @var string Shop URL */ + protected $url; + + /** @var string Authentification key */ + protected $key; + + /** @var boolean is debug activated */ + protected $debug; + + /** @var string PS version */ + protected $version; + + /** @var array compatible versions of PrestaShop Webservice */ + const PSCOMPATIBLEVERSIONMIN = '1.4.0.0'; + const PSCOMPATIBLEVERSIONMAX = '1.6.99.99'; + + /** + * PrestaShopWebservice constructor. Throw an exception when CURL is not installed/activated + * + * getMessage(); + * } + * ?> + * + * @param string $url Root URL for the shop + * @param string $key Authentification key + * @param mixed $debug Debug mode Activated (true) or deactivated (false) + */ + function __construct($url, $key, $debug = true) { + if (!extension_loaded('curl')) + throw new PrestaShopWebserviceException('Please activate the PHP extension \'curl\' to allow use of PrestaShop webservice library'); + $this->url = $url; + $this->key = $key; + $this->debug = $debug; + $this->version = 'unknown'; + } + + /** + * Take the status code and throw an exception if the server didn't return 200 or 201 code + * @param int $status_code Status code of an HTTP return + */ + protected function checkStatusCode($status_code) + { + $error_label = 'This call to PrestaShop Web Services failed and returned an HTTP status of %d. That means: %s.'; + switch($status_code) + { + case 200: case 201: break; + case 204: throw new PrestaShopWebserviceException(sprintf($error_label, $status_code, 'No content'));break; + case 400: throw new PrestaShopWebserviceException(sprintf($error_label, $status_code, 'Bad Request'));break; + case 401: throw new PrestaShopWebserviceException(sprintf($error_label, $status_code, 'Unauthorized'));break; + case 404: throw new PrestaShopWebserviceException(sprintf($error_label, $status_code, 'Not Found'));break; + case 405: throw new PrestaShopWebserviceException(sprintf($error_label, $status_code, 'Method Not Allowed'));break; + case 500: throw new PrestaShopWebserviceException(sprintf($error_label, $status_code, 'Internal Server Error'));break; + default: throw new PrestaShopWebserviceException('This call to PrestaShop Web Services returned an unexpected HTTP status of:' . $status_code); + } + } + /** + * Handles a CURL request to PrestaShop Webservice. Can throw exception. + * @param string $url Resource name + * @param mixed $curl_params CURL parameters (sent to curl_set_opt) + * @return array status_code, response + */ + public function executeRequest($url, $curl_params = array()) + { + $defaultParams = array( + CURLOPT_HEADER => TRUE, + CURLOPT_RETURNTRANSFER => TRUE, + CURLINFO_HEADER_OUT => TRUE, + CURLOPT_HTTPAUTH => CURLAUTH_BASIC, + CURLOPT_USERPWD => $this->key.':', + CURLOPT_HTTPHEADER => array( 'Expect:' ) + ); + + $session = curl_init($url); + + $curl_options = array(); + foreach ($defaultParams as $defkey => $defval) + { + if (isset($curl_params[$defkey])) + $curl_options[$defkey] = $curl_params[$defkey]; + else + $curl_options[$defkey] = $defaultParams[$defkey]; + } + foreach ($curl_params as $defkey => $defval) + if (!isset($curl_options[$defkey])) + $curl_options[$defkey] = $curl_params[$defkey]; + + curl_setopt_array($session, $curl_options); + $response = curl_exec($session); + + $index = strpos($response, "\r\n\r\n"); + if ($index === false && $curl_params[CURLOPT_CUSTOMREQUEST] != 'HEAD') + throw new PrestaShopWebserviceException('Bad HTTP response'); + + $header = substr($response, 0, $index); + $body = substr($response, $index + 4); + + $headerArrayTmp = explode("\n", $header); + + $headerArray = array(); + foreach ($headerArrayTmp as &$headerItem) + { + $tmp = explode(':', $headerItem); + $tmp = array_map('trim', $tmp); + if (count($tmp) == 2) + $headerArray[$tmp[0]] = $tmp[1]; + } + + if (array_key_exists('PSWS-Version', $headerArray)) + { + $this->version = $headerArray['PSWS-Version']; + if ( + version_compare(PrestaShopWebservice::PSCOMPATIBLEVERSIONMIN, $headerArray['PSWS-Version']) == 1 || + version_compare(PrestaShopWebservice::PSCOMPATIBLEVERSIONMAX, $headerArray['PSWS-Version']) == -1 + ) + throw new PrestaShopWebserviceException('This library is not compatible with this version of PrestaShop. Please upgrade/downgrade this library'); + } + + if ($this->debug) + { + $this->printDebug('HTTP REQUEST HEADER', curl_getinfo($session, CURLINFO_HEADER_OUT)); + $this->printDebug('HTTP RESPONSE HEADER', $header); + + } + $status_code = curl_getinfo($session, CURLINFO_HTTP_CODE); + if ($status_code === 0) + throw new PrestaShopWebserviceException('CURL Error: '.curl_error($session)); + curl_close($session); + if ($this->debug) + { + if ($curl_params[CURLOPT_CUSTOMREQUEST] == 'PUT' || $curl_params[CURLOPT_CUSTOMREQUEST] == 'POST') + $this->printDebug('XML SENT', urldecode($curl_params[CURLOPT_POSTFIELDS])); + if ($curl_params[CURLOPT_CUSTOMREQUEST] != 'DELETE' && $curl_params[CURLOPT_CUSTOMREQUEST] != 'HEAD') + $this->printDebug('RETURN HTTP BODY', $body); + } + return array('status_code' => $status_code, 'response' => $body, 'header' => $header); + } + + public function printDebug($title, $content) + { + echo '
'.$title.'
'.htmlentities($content).'
'; + } + + public function getVersion() + { + return $this->version; + } + + /** + * Load XML from string. Can throw exception + * @param string $response String from a CURL response + * @return SimpleXMLElement status_code, response + */ + protected function parseXML($response) + { + if ($response != '') + { + libxml_clear_errors(); + libxml_use_internal_errors(true); + $xml = simplexml_load_string($response,'SimpleXMLElement', LIBXML_NOCDATA); + if (libxml_get_errors()) + { + $msg = var_export(libxml_get_errors(), true); + libxml_clear_errors(); + throw new PrestaShopWebserviceException('HTTP XML response is not parsable: '.$msg); + } + return $xml; + } + else + throw new PrestaShopWebserviceException('HTTP response is empty'); + } + + /** + * Add (POST) a resource + *

Unique parameter must take :

+ * 'resource' => Resource name
+ * 'postXml' => Full XML string to add resource

+ * Examples are given in the tutorial

+ * + * @param array $options Options + * @return SimpleXMLElement status_code, response + */ + public function add($options) + { + $xml = ''; + + if (isset($options['resource'], $options['postXml']) || isset($options['url'], $options['postXml'])) + { + $url = (isset($options['resource']) ? $this->url.'/api/'.$options['resource'] : $options['url']); + $xml = $options['postXml']; + if (isset($options['id_shop'])) + $url .= '&id_shop='.$options['id_shop']; + if (isset($options['id_group_shop'])) + $url .= '&id_group_shop='.$options['id_group_shop']; + } + else + throw new PrestaShopWebserviceException('Bad parameters given'); + $request = self::executeRequest($url, array(CURLOPT_CUSTOMREQUEST => 'POST', CURLOPT_POSTFIELDS => $xml)); + + self::checkStatusCode($request['status_code']); + return self::parseXML($request['response']); + } + + /** + * Retrieve (GET) a resource + *

Unique parameter must take :

+ * 'url' => Full URL for a GET request of Webservice (ex: http://mystore.com/api/customers/1/)
+ * OR
+ * 'resource' => Resource name,
+ * 'id' => ID of a resource you want to get

+ *

+ * + * get(array('resource' => 'orders', 'id' => 1)); + * // Here in $xml, a SimpleXMLElement object you can parse + * foreach ($xml->children()->children() as $attName => $attValue) + * echo $attName.' = '.$attValue.'
'; + * } + * catch (PrestaShopWebserviceException $ex) + * { + * echo 'Error : '.$ex->getMessage(); + * } + * ?> + *
+ * @param array $options Array representing resource to get. + * @return SimpleXMLElement status_code, response + */ + public function get($options) + { + if (isset($options['url'])) + $url = $options['url']; + elseif (isset($options['resource'])) + { + $url = $this->url.'/api/'.$options['resource']; + $url_params = array(); + if (isset($options['id'])) + $url .= '/'.$options['id']; + + $params = array('filter', 'display', 'sort', 'limit', 'id_shop', 'id_group_shop'); + foreach ($params as $p) + foreach ($options as $k => $o) + if (strpos($k, $p) !== false) + $url_params[$k] = $options[$k]; + if (count($url_params) > 0) + $url .= '?'.http_build_query($url_params); + } + else + throw new PrestaShopWebserviceException('Bad parameters given '); + + $request = self::executeRequest($url, array(CURLOPT_CUSTOMREQUEST => 'GET')); + self::checkStatusCode($request['status_code']);// check the response validity + return self::parseXML($request['response']); + } + + /** + * Head method (HEAD) a resource + * + * @param array $options Array representing resource for head request. + * @return SimpleXMLElement status_code, response + */ + public function head($options) + { + if (isset($options['url'])) + $url = $options['url']; + elseif (isset($options['resource'])) + { + $url = $this->url.'/api/'.$options['resource']; + $url_params = array(); + if (isset($options['id'])) + $url .= '/'.$options['id']; + + $params = array('filter', 'display', 'sort', 'limit'); + foreach ($params as $p) + foreach ($options as $k => $o) + if (strpos($k, $p) !== false) + $url_params[$k] = $options[$k]; + if (count($url_params) > 0) + $url .= '?'.http_build_query($url_params); + } + else + throw new PrestaShopWebserviceException('Bad parameters given'); + $request = self::executeRequest($url, array(CURLOPT_CUSTOMREQUEST => 'HEAD', CURLOPT_NOBODY => true)); + self::checkStatusCode($request['status_code']);// check the response validity + return $request['header']; + } + /** + * Edit (PUT) a resource + *

Unique parameter must take :

+ * 'resource' => Resource name ,
+ * 'id' => ID of a resource you want to edit,
+ * 'putXml' => Modified XML string of a resource

+ * Examples are given in the tutorial

+ * @param array $options Array representing resource to edit. + */ + public function edit($options) + { + $xml = ''; + if (isset($options['url'])) + $url = $options['url']; + elseif ((isset($options['resource'], $options['id']) || isset($options['url'])) && $options['putXml']) + { + $url = (isset($options['url']) ? $options['url'] : $this->url.'/api/'.$options['resource'].'/'.$options['id']); + $xml = $options['putXml']; + if (isset($options['id_shop'])) + $url .= '&id_shop='.$options['id_shop']; + if (isset($options['id_group_shop'])) + $url .= '&id_group_shop='.$options['id_group_shop']; + } + else + throw new PrestaShopWebserviceException('Bad parameters given'); + + $request = self::executeRequest($url, array(CURLOPT_CUSTOMREQUEST => 'PUT', CURLOPT_POSTFIELDS => $xml)); + self::checkStatusCode($request['status_code']);// check the response validity + return self::parseXML($request['response']); + } + + /** + * Delete (DELETE) a resource. + * Unique parameter must take :

+ * 'resource' => Resource name
+ * 'id' => ID or array which contains IDs of a resource(s) you want to delete

+ * + * delete(array('resource' => 'orders', 'id' => 1)); + * // Following code will not be executed if an exception is thrown. + * echo 'Successfully deleted.'; + * } + * catch (PrestaShopWebserviceException $ex) + * { + * echo 'Error : '.$ex->getMessage(); + * } + * ?> + * + * @param array $options Array representing resource to delete. + */ + public function delete($options) + { + if (isset($options['url'])) + $url = $options['url']; + elseif (isset($options['resource']) && isset($options['id'])) + if (is_array($options['id'])) + $url = $this->url.'/api/'.$options['resource'].'/?id=['.implode(',', $options['id']).']'; + else + $url = $this->url.'/api/'.$options['resource'].'/'.$options['id']; + if (isset($options['id_shop'])) + $url .= '&id_shop='.$options['id_shop']; + if (isset($options['id_group_shop'])) + $url .= '&id_group_shop='.$options['id_group_shop']; + $request = self::executeRequest($url, array(CURLOPT_CUSTOMREQUEST => 'DELETE')); + self::checkStatusCode($request['status_code']);// check the response validity + return true; + } + + +} + +/** + * @package PrestaShopWebservice + */ +class PrestaShopWebserviceException extends Exception +{ + +} diff --git a/htdocs/admin/dolistore/class/dolistore.class.php b/htdocs/admin/dolistore/class/dolistore.class.php new file mode 100644 index 00000000000..5e0aa546cc0 --- /dev/null +++ b/htdocs/admin/dolistore/class/dolistore.class.php @@ -0,0 +1,316 @@ +. + * + * This program is free software; you can redistribute it and/or modifyion 2.0 (the "License"); + * it under the terms of the GNU General Public License as published bypliance with the License. + * the Free Software Foundation; either version 3 of the License, or + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * or see http://www.gnu.org/ + */ + +include_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; +include_once DOL_DOCUMENT_ROOT.'/admin/dolistore/class/PSWebServiceLibrary.class.php'; + +/** + * Class DolistoreModel + */ +class Dolistore extends DolistoreModel +{ + // params + public $start // beginning of pagination + , $end // end of pagination + , $per_page // pagination: display per page + , $categorie // the current categorie + , $search // the search keywords + // setups + , $url // the url of this page + , $shop_url // the url of the shop + , $vat_rate // the vat rate used in the shop (prices are provided without vat) + , $lang // the integer representing the lang in the store + , $debug_api; // usefull if no dialog + + function __construct($options = array('start' => 0, 'end' => 10, 'per_page' => 50, 'categorie' => 0)) + { + global $conf, $langs; + + $this->start = $options['start']; + $this->end = $options['end']; + $this->per_page = $options['per_page']; + $this->categorie = $options['categorie']; + $this->search = $options['search']; + + $this->url = DOL_URL_ROOT.'/admin/modules.php?mode=marketplace'; + $this->shop_url = 'https://www.dolistore.com/index.php?controller=product&id_product='; + $this->vat_rate = 1.2; // 20% de TVA + $this->debug_api = false; + + if ($this->end == 0) { + $this->end = $this->per_page; + } + + $langtmp = explode('_', $langs->defaultlang); + $lang = $langtmp[0]; + $lang_array = array('fr'=>1, 'en'=>2, 'es'=>3, 'it'=>4, 'de'=>5); + if (! in_array($lang, array_keys($lang_array))) $lang = 'en'; + $this->lang = $lang_array[$lang]; // 1=fr 2=en ... + + try { + $this->api = new PrestaShopWebservice($conf->global->MAIN_MODULE_DOLISTORE_API_SRV, + $conf->global->MAIN_MODULE_DOLISTORE_API_KEY, $this->debug_api); + + // Here we set the option array for the Webservice : we want products resources + $opt = array(); + $opt['resource'] = 'products'; + // make a search to limit the id returned. + if ($this->search != '') { + $opt2 = array(); + $opt2['url'] = $conf->global->MAIN_MODULE_DOLISTORE_API_SRV.'/api/search?query='.$this->search.'&language='.$this->lang; + // Call + $xml = $this->api->get($opt2); + $products = array(); + foreach ($xml->products->children() as $product) { + $products[] = (int) $product['id']; + } + $opt['filter[id]'] = '['.implode('|', $products).']'; + } elseif ($this->categorie != 0) { + $opt2 = array(); + $opt2['resource'] = 'categories'; + $opt2['id'] = $this->categorie; + // Call + $xml = $this->api->get($opt2); + $products = array(); + foreach ($xml->category->associations->products->children() as $product) { + $products[] = (int) $product->id; + } + $opt['filter[id]'] = '['.implode('|', $products).']'; + } + $opt['display'] = '[id,name,id_default_image,id_category_default,reference,price,condition,show_price,date_add,date_upd,description_short,description,module_version,dolibarr_min,dolibarr_max]'; + $opt['sort'] = 'id_desc'; + $opt['filter[active]'] = '[1]'; + $opt['limit'] = "$this->start,$this->end"; + // Call + $xml = $this->api->get($opt); + $this->products = $xml->products->children(); + + + // Here we set the option array for the Webservice : we want categories resources + $opt = array(); + $opt['resource'] = 'categories'; + $opt['display'] = '[id,id_parent,nb_products_recursive,active,is_root_category,name,description]'; + $opt['sort'] = 'id_asc'; + // Call + $xml = $this->api->get($opt); + $this->categories = $xml->categories->children(); + } catch (PrestaShopWebserviceException $e) { + // Here we are dealing with errors + $trace = $e->getTrace(); + if ($trace[0]['args'][0] == 404) die('Bad ID'); + else if ($trace[0]['args'][0] == 401) die('Bad auth key'); + else die('Can not access to '.$conf->global->MAIN_MODULE_DOLISTORE_API_SRV); + } + } + + function get_previous_url() + { + $param_array = array(); + if ($this->start < $this->per_page) { + $sub = 0; + } else { + $sub = $this->per_page; + } + $param_array['start'] = $this->start - $sub; + $param_array['end'] = $this->end - $sub; + if ($this->categorie != 0) { + $param_array['categorie'] = $this->categorie; + } + $param = http_build_query($param_array); + return $this->url."&".$param; + } + + function get_next_url() + { + $param_array = array(); + if (count($this->products) < $this->per_page) { + $add = 0; + } else { + $add = $this->per_page; + } + $param_array['start'] = $this->start + $add; + $param_array['end'] = $this->end + $add; + if ($this->categorie != 0) { + $param_array['categorie'] = $this->categorie; + } + $param = http_build_query($param_array); + return $this->url."&".$param; + } + + function version_compare($v1, $v2) + { + $v1 = explode('.', $v1); + $v2 = explode('.', $v2); + $ret = 0; + $level = 0; + $count1 = count($v1); + $count2 = count($v2); + $maxcount = max($count1, $count2); + while ($level < $maxcount) { + $operande1 = isset($v1[$level]) ? $v1[$level] : 'x'; + $operande2 = isset($v2[$level]) ? $v2[$level] : 'x'; + $level++; + if (strtoupper($operande1) == 'X' || strtoupper($operande2) == 'X' || $operande1 == '*' || $operande2 == '*') { + break; + } + if ($operande1 < $operande2) { + $ret = -$level; + break; + } + if ($operande1 > $operande2) { + $ret = $level; + break; + } + } + //print join('.',$versionarray1).'('.count($versionarray1).') / '.join('.',$versionarray2).'('.count($versionarray2).') => '.$ret.'
'."\n"; + return $ret; + } +} + + +/** + * Class DolistoreModel + */ +class DolistoreModel +{ + + function get_categories($parent = 0) + { + if (!isset($this->categories)) die('not possible'); + if ($parent != 0) { + $html = '
    '; + } else { + $html = ''; + } + + $nbofcateg = count($this->categories); + for ($i = 0; $i < $nbofcateg; $i++) + { + $cat = $this->categories[$i]; + if ($cat->is_root_category == 1 && $parent == 0) { + $html .= '
  • '.$cat->name->language[$this->lang].' '.$cat->nb_products_recursive.'

    '; + $html .= self::get_categories($cat->id); + $html .= "
  • \n"; + } elseif (trim($cat->id_parent) == $parent && $cat->active == 1 && trim($cat->id_parent) != 0) { // si cat est de ce niveau + $select = ($cat->id == $this->categorie) ? ' selected' : ''; + $html .= '
  • '.$cat->name->language[$this->lang].' '.$cat->nb_products_recursive.''; + $html .= self::get_categories($cat->id); + $html .= "
  • \n"; + } else { + + } + } + + if ($html == '
      ') { + return ''; + } + if ($parent != 0) { + return $html.'
    '; + } else { + return $html; + } + } + + function get_products() + { + global $langs, $conf; + $html = ""; + $parity = "pair"; + $last_month = time() - (30 * 24 * 60 * 60); + foreach ($this->products as $product) { + $parity = ($parity == "impair") ? 'pair' : 'impair'; + + // check new product ? + $newapp = ''; + if ($last_month < strtotime($product->date_add)) { + $newapp .= ''.$langs->trans('New').' '; + } + + // check updated ? + if ($last_month < strtotime($product->date_upd) && $newapp == '') { + $newapp .= ''.$langs->trans('Updated').' '; + } + + // add image or default ? + if ($product->id_default_image != '') { + $image_url = dol_buildPath('/dolistore/ajax/image.php?id_product=', 2).$product->id.'&id_image='.$product->id_default_image; + $images = ''. + ''; + } else { + $images = ''; + } + + // free or pay ? + if ($product->price > 0) { + $price = '

    '.price(round((float) $product->price * $this->vat_rate, 2)).' €

    '; + $download_link = ''; + } else { + $price = $langs->trans('Free'); + $download_link = ''; + } + + //checking versions + if ($this->version_compare($product->dolibarr_min, DOL_VERSION) <= 0) { + if ($this->version_compare($product->dolibarr_max, DOL_VERSION) >= 0) { + //compatible + $version = ''.$langs->trans('CompatibleUpTo', $product->dolibarr_max, + $product->dolibarr_min, $product->dolibarr_max).''; + $compatible = ''; + } else { + //never compatible, module expired + $version = ''.$langs->trans('NotCompatible', DOL_VERSION, + $product->dolibarr_min, $product->dolibarr_max).''; + $compatible = 'NotCompatible'; + } + } else { + //need update + $version = ''.$langs->trans('CompatibleAfterUpdate', DOL_VERSION, + $product->dolibarr_min, $product->dolibarr_max).''; + $compatible = 'NotCompatible'; + } + + //output template + $html .= ' +
    '.$newapp.$images.'
    +

    '.$product->name->language[$this->lang].'Details' + .'
    '.$version.'

    + '.dol_print_date(strtotime($product->date_upd)).' - '.$langs->trans('Référence').': '.$product->reference.' - '.$langs->trans('Id').': '.$product->id.'

    '.$product->description_short->language[$this->lang].' + '.$product->description->language[$this->lang].' + '.$price.' + '.$download_link.' + '; + } + return $html; + } + + function get_previous_link($text = '<<') + { + return ''.$text.''; + } + + function get_next_link($text = '>>') + { + return ''.$text.''; + } +} diff --git a/htdocs/admin/dolistore/class/init.php b/htdocs/admin/dolistore/class/init.php new file mode 100644 index 00000000000..df5773d9e7d --- /dev/null +++ b/htdocs/admin/dolistore/class/init.php @@ -0,0 +1,72 @@ +CRUD Tutorial - Customer's list + +* @copyright 2007-2013 PrestaShop SA +* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) +* International Registered Trademark & Property of PrestaShop SA +* PrestaShop Webservice Library +* @package PrestaShopWebservice +*/ +// Here we define constants /!\ You need to replace this parameters +//https://dolistorecatalogpublickey1234567@vmdevwww.dolistore.com/api/ +define('DEBUG', true); // Debug mode +define('PS_SHOP_PATH', 'http://vmdevwww.dolistore.com/'); // Root path of your PrestaShop store +define('PS_WS_AUTH_KEY', 'dolistorecatalogpublickey1234567'); // Auth key (Get it in your Back Office) +require_once('./PSWebServiceLibrary.php'); +// Here we make the WebService Call +try +{ + $webService = new PrestaShopWebservice(PS_SHOP_PATH, PS_WS_AUTH_KEY, DEBUG); + + // Here we set the option array for the Webservice : we want customers resources + $opt['resource'] = 'categories'; + $opt['id'] = '1'; + + // Call + $xml = $webService->get($opt); + // Here we get the elements from children of customers markup "customer" + $resources = $xml->categories->children(); +} +catch (PrestaShopWebserviceException $e) +{ + // Here we are dealing with errors + $trace = $e->getTrace(); + if ($trace[0]['args'][0] == 404) echo 'Bad ID'; + else if ($trace[0]['args'][0] == 401) echo 'Bad auth key'; + else echo 'Other error'; +} +// We set the Title +echo "

    Categories's List

    "; +echo ''; +// if $resources is set we can lists element in it otherwise do nothing cause there's an error +if (isset($resources)) +{ + echo ''; + foreach ($resources as $resource) + { + // Iterates on the found IDs + echo ''; + } +} +echo '
    Id
    '.$resource->attributes().'
    '; +?> + \ No newline at end of file diff --git a/htdocs/admin/dolistore/css/dolistore.css b/htdocs/admin/dolistore/css/dolistore.css new file mode 100644 index 00000000000..18549c3ed83 --- /dev/null +++ b/htdocs/admin/dolistore/css/dolistore.css @@ -0,0 +1,234 @@ + +div.divsearchfield { + float: left; + margin: 4px 12px 4px 2px; + padding-left: 2px; +} + +.margeCoteGauche,.margeCote{ + padding-right: 20px!important; +} +.margeCote,.margeCoteDroite{ + padding-left: 20px!important; +} +.nomargesupinf{ + margin-top: 0; + margin-bottom: 0; +} +#category-tree-left{ + display: none; + vertical-align: top; + width: 24%; +} +#listing-content{ + box-sizing: border-box; + display: inline-block; + width: 100%; +} +.tree{ + margin: 0px 0px 0px 0px; + padding:0px; + list-style: none; line-height: 2em; font-family: Arial; +} +.tree li{ + font-size: 16px; + position: relative;list-style: none; +} +.tree li:before{ + position: absolute; + left: -15px; + top: -4px; + content: ''; + display: block; + border-left: 1px solid #ddd; + height: 1em; + border-bottom: 1px solid #ddd; + width: 10px; +} +.tree li:after{ + position: absolute; + left: -15px; + bottom: -7px; + content: ''; + display: block; + border-left: 1px solid #ddd; + height: 100%; +} + +.tree li.root{ + margin: 0px 0px 0px 0px; +} +.tree li.root:before{ + display: none; +} + +.tree li.root:after{ + display: none; +} +.tree li:last-child:after{ + display: none +} +.blockUI { + cursor: auto!important; +} +.newAppParent{ + position: relative; + overflow: hidden; + min-height: 100px; +} +.newApp, .updatedApp{ + background-color: orange; + box-shadow: 0 0 20px rgba(0, 0, 0, 0.35); + box-sizing: border-box; + color: white; + display: block; + font-size: 18px; + font-weight: bold; + left: -34px; + padding: 5px 0; + position: absolute; + text-align: center; + text-shadow: 0 0 5px rgba(0, 0, 0, 0.35); + top: 22px; + transform: rotate(-45deg); + width: 150px; +} +.updatedApp{ + background-color: greenyellow; +} +.notcompatible { + color: red; +} +.compatibleafterupdate { + color: orange; +} +.compatible { + background-image: url("../img/compatible.png"); + background-position: left center; + background-repeat: no-repeat; + color: green; + display: inline-block; + height: 32px; + line-height: 32px; + padding-left: 35px; +} +tr.app { + height:250px; +} + +div#newsDoli.tabBar { + margin-top: 50px; + margin-right: 30px; +} +.selected { + text-decoration: underline!important; +} +.searchDolistore, .searchDolistore:hover { + padding-left: 30px; + padding-right: 30px; + font-weight: bold; +} +.searchDolistore:hover { + text-decoration: underline!important; +} + +.score{ + font-size: 16px; + font-weight: bold; +} +.formReviewArea{ + display:none; +} +.formReview div.divsearchfield{ + float: none; +} +.input100{ + box-sizing: border-box; + width: 100%; +} +.input50{ + box-sizing: border-box; + width: 49%; +} +textarea.row4{ + min-height: 100px; +} + + +.reviewList { + max-height: 150px; + overflow-y: scroll; +} + +.reviewRow{ + margin-bottom: 20px; +} +.reviewRow .reviewMarge { + float:left; + width: 220px; + padding: 0 20px 20px 0; +} +.reviewRow .score { + font-size: 48px; + display: block; + text-align: center; +} +.reviewRow .reviewDate { + color:grey; +} +.reviewRow:after{ + clear: both; + content:''; + display: block; +} +h2.appTitle small{ + font-weight: normal; +} +tr.NotCompatible{ + /* IE 8 */ + -ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=25)"; + + /* IE 5-7 */ + filter: alpha(opacity=25); + + /* Netscape */ + -moz-opacity: 0.25; + + /* Safari 1.x */ + -khtml-opacity: 0.25; + + /* Good browsers */ + opacity: 0.25; +} +tr.NotCompatible:hover{ + /* IE 8 */ + -ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=100)"; + + /* IE 5-7 */ + filter: alpha(opacity=100); + + /* Netscape */ + -moz-opacity: 1; + + /* Safari 1.x */ + -khtml-opacity: 1; + + /* Good browsers */ + opacity: 1; +} +@media only screen and (min-width: 1150px) { + #categorieArea{ + display:none; + } + #category-tree-left{ + display:inline-block; + } + #listing-content{ + width: 75%; + } +} +span.details{ + font-size: 12px; + margin-left: 10px; + vertical-align: super; +} \ No newline at end of file diff --git a/htdocs/admin/dolistore/img/Download-128.png b/htdocs/admin/dolistore/img/Download-128.png new file mode 100644 index 00000000000..89756d1f012 Binary files /dev/null and b/htdocs/admin/dolistore/img/Download-128.png differ diff --git a/htdocs/admin/dolistore/img/NoImageAvailable.png b/htdocs/admin/dolistore/img/NoImageAvailable.png new file mode 100644 index 00000000000..9a88d4362da Binary files /dev/null and b/htdocs/admin/dolistore/img/NoImageAvailable.png differ diff --git a/htdocs/admin/dolistore/img/compatible.png b/htdocs/admin/dolistore/img/compatible.png new file mode 100644 index 00000000000..93a85574165 Binary files /dev/null and b/htdocs/admin/dolistore/img/compatible.png differ diff --git a/htdocs/admin/dolistore/img/dolistore.png b/htdocs/admin/dolistore/img/dolistore.png new file mode 100644 index 00000000000..d3fc61e7293 Binary files /dev/null and b/htdocs/admin/dolistore/img/dolistore.png differ diff --git a/htdocs/admin/dolistore/img/follow.png b/htdocs/admin/dolistore/img/follow.png new file mode 100644 index 00000000000..78383c1157f Binary files /dev/null and b/htdocs/admin/dolistore/img/follow.png differ diff --git a/htdocs/admin/dolistore/img/object_dolistore.png b/htdocs/admin/dolistore/img/object_dolistore.png new file mode 100644 index 00000000000..213d0e0a3b7 Binary files /dev/null and b/htdocs/admin/dolistore/img/object_dolistore.png differ diff --git a/htdocs/admin/expedition.php b/htdocs/admin/expedition.php index af932b94b45..ba389c5207a 100644 --- a/htdocs/admin/expedition.php +++ b/htdocs/admin/expedition.php @@ -45,7 +45,7 @@ if (! $user->admin) $action=GETPOST('action','alpha'); $value=GETPOST('value','alpha'); $label = GETPOST('label','alpha'); -$scandir = GETPOST('scandir','alpha'); +$scandir = GETPOST('scan_dir','alpha'); $type='shipping'; if (empty($conf->global->EXPEDITION_ADDON_NUMBER)) @@ -263,7 +263,7 @@ foreach ($dirmodels as $reldir) } else { - print 'scandir.'&label='.urlencode($module->name).'">'; + print 'scandir.'&label='.urlencode($module->name).'">'; print img_picto($langs->trans("Disabled"),'switch_off'); print ''; } @@ -402,7 +402,7 @@ foreach ($dirmodels as $reldir) else { print ''."\n"; - print 'scandir.'&label='.urlencode($module->name).'">'.img_picto($langs->trans("Disabled"),'switch_off').''; + print 'scandir.'&label='.urlencode($module->name).'">'.img_picto($langs->trans("Disabled"),'switch_off').''; print ""; } @@ -414,7 +414,7 @@ foreach ($dirmodels as $reldir) } else { - print 'scandir.'&label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"),'off').''; + print 'scandir.'&label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"),'off').''; } print ''; @@ -440,7 +440,7 @@ foreach ($dirmodels as $reldir) print ''; if ($module->type == 'pdf') { - print 'scandir.'&label='.urlencode($module->name).'">'.img_object($langs->trans("Preview"),'sending').''; + print 'scandir.'&label='.urlencode($module->name).'">'.img_object($langs->trans("Preview"),'sending').''; } else { diff --git a/htdocs/admin/expensereport.php b/htdocs/admin/expensereport.php index fb4651be817..1dd5166e1cb 100644 --- a/htdocs/admin/expensereport.php +++ b/htdocs/admin/expensereport.php @@ -44,7 +44,7 @@ if (! $user->admin) accessforbidden(); $action = GETPOST('action','alpha'); $value = GETPOST('value','alpha'); $label = GETPOST('label','alpha'); -$scandir = GETPOST('scandir','alpha'); +$scandir = GETPOST('scan_dir','alpha'); $type='expensereport'; @@ -400,7 +400,7 @@ foreach ($dirmodels as $reldir) if (in_array($name, $def)) { print "\n"; - print 'scandir.'&label='.urlencode($module->name).'">'; + print 'scandir.'&label='.urlencode($module->name).'">'; print img_picto($langs->trans("Enabled"),'switch_on'); print ''; print ""; @@ -408,7 +408,7 @@ foreach ($dirmodels as $reldir) else { print "\n"; - print 'scandir.'&label='.urlencode($module->name).'">'.img_picto($langs->trans("Disabled"),'switch_off').''; + print 'scandir.'&label='.urlencode($module->name).'">'.img_picto($langs->trans("Disabled"),'switch_off').''; print ""; } @@ -420,7 +420,7 @@ foreach ($dirmodels as $reldir) } else { - print 'scandir.'&label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"),'off').''; + print 'scandir.'&label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"),'off').''; } print ''; diff --git a/htdocs/admin/fichinter.php b/htdocs/admin/fichinter.php index 64257225719..62533ced467 100644 --- a/htdocs/admin/fichinter.php +++ b/htdocs/admin/fichinter.php @@ -44,7 +44,7 @@ if (! $user->admin) accessforbidden(); $action = GETPOST('action','alpha'); $value = GETPOST('value','alpha'); $label = GETPOST('label','alpha'); -$scandir = GETPOST('scandir','alpha'); +$scandir = GETPOST('scan_dir','alpha'); $type='ficheinter'; @@ -431,7 +431,7 @@ foreach ($dirmodels as $reldir) if (in_array($name, $def)) { print "\n"; - print 'scandir.'&label='.urlencode($module->name).'">'; + print 'scandir.'&label='.urlencode($module->name).'">'; print img_picto($langs->trans("Enabled"),'switch_on'); print ''; print ""; @@ -439,7 +439,7 @@ foreach ($dirmodels as $reldir) else { print "\n"; - print 'scandir.'&label='.urlencode($module->name).'">'.img_picto($langs->trans("Disabled"),'switch_off').''; + print 'scandir.'&label='.urlencode($module->name).'">'.img_picto($langs->trans("Disabled"),'switch_off').''; print ""; } @@ -451,7 +451,7 @@ foreach ($dirmodels as $reldir) } else { - print 'scandir.'&label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"),'off').''; + print 'scandir.'&label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"),'off').''; } print ''; @@ -495,7 +495,6 @@ print "
    "; /* * Other options - * */ print load_fiche_titre($langs->trans("OtherOptions"),'',''); diff --git a/htdocs/admin/limits.php b/htdocs/admin/limits.php index 1d4b5cee8d4..36b0d4d0df1 100644 --- a/htdocs/admin/limits.php +++ b/htdocs/admin/limits.php @@ -101,25 +101,24 @@ if ($action == 'edit') print ''; clearstatcache(); - $var=true; print ''; print ''; - + print ''; - + print ''; - + print ''; - + print ''; @@ -135,25 +134,23 @@ if ($action == 'edit') } else { - $var=true; - print '
    '.$langs->trans("Parameter").''.$langs->trans("Value").'
    '; print $form->textwithpicto($langs->trans("MAIN_MAX_DECIMALS_UNIT"),$langs->trans("ParameterActiveForNextInputOnly")); print '
    '; print $form->textwithpicto($langs->trans("MAIN_MAX_DECIMALS_TOT"),$langs->trans("ParameterActiveForNextInputOnly")); print '
    '.$langs->trans("MAIN_MAX_DECIMALS_SHOWN").'
    '; print $form->textwithpicto($langs->trans("MAIN_ROUNDING_RULE_TOT"),$langs->trans("ParameterActiveForNextInputOnly")); print '
    '; print ''; - + print ''; - + print ''; - + print ''; - + print ''; diff --git a/htdocs/admin/livraison.php b/htdocs/admin/livraison.php index fe41afabfb8..24e2772ae0d 100644 --- a/htdocs/admin/livraison.php +++ b/htdocs/admin/livraison.php @@ -44,7 +44,7 @@ if (!$user->admin) accessforbidden(); $action = GETPOST('action','alpha'); $value = GETPOST('value','alpha'); $label = GETPOST('label','alpha'); -$scandir = GETPOST('scandir','alpha'); +$scandir = GETPOST('scan_dir','alpha'); $type='delivery'; @@ -385,7 +385,7 @@ foreach ($dirmodels as $reldir) if (in_array($name, $def)) { print ""; @@ -393,7 +393,7 @@ foreach ($dirmodels as $reldir) else { print ""; } @@ -405,7 +405,7 @@ foreach ($dirmodels as $reldir) } else { - print 'scandir.'&label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"),'off').''; + print 'scandir.'&label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"),'off').''; } print ''; diff --git a/htdocs/admin/mails.php b/htdocs/admin/mails.php index dadf7b476ee..5ff8078e826 100644 --- a/htdocs/admin/mails.php +++ b/htdocs/admin/mails.php @@ -114,7 +114,7 @@ $server=! empty($conf->global->MAIN_MAIL_SMTP_SERVER)?$conf->global->MAIN_MAIL_S if (! $server) $server='127.0.0.1'; -$wikihelp='EN:Setup EMails|FR:Paramétrage EMails|ES:Configuración EMails'; +$wikihelp='EN:Setup_EMails|FR:Paramétrage_EMails|ES:Configuración_EMails'; llxHeader('',$langs->trans("Setup"),$wikihelp); print load_fiche_titre($langs->trans("EMailsSetup"),'','title_setup'); @@ -127,6 +127,14 @@ $head[$h][1] = $langs->trans("OutGoingEmailSetup"); $head[$h][2] = 'common'; $h++; +if ($conf->mailing->enabled) +{ + $head[$h][0] = DOL_URL_ROOT."/admin/mails_emailing.php"; + $head[$h][1] = $langs->trans("OutGoingEmailSetupForEmailing"); + $head[$h][2] = 'common_emailing'; + $h++; +} + $head[$h][0] = DOL_URL_ROOT."/admin/mails_templates.php"; $head[$h][1] = $langs->trans("DictionaryEMailTemplates"); $head[$h][2] = 'templates'; @@ -238,7 +246,7 @@ if ($action == 'edit') $var=true; print '
    '.$langs->trans("Parameter").''.$langs->trans("Value").'
    '; print $form->textwithpicto($langs->trans("MAIN_MAX_DECIMALS_UNIT"),$langs->trans("ParameterActiveForNextInputOnly")); print ''.$conf->global->MAIN_MAX_DECIMALS_UNIT.'
    '; print $form->textwithpicto($langs->trans("MAIN_MAX_DECIMALS_TOT"),$langs->trans("ParameterActiveForNextInputOnly")); print ''.$conf->global->MAIN_MAX_DECIMALS_TOT.'
    '.$langs->trans("MAIN_MAX_DECIMALS_SHOWN").''.$conf->global->MAIN_MAX_DECIMALS_SHOWN.'
    '; print $form->textwithpicto($langs->trans("MAIN_ROUNDING_RULE_TOT"),$langs->trans("ParameterActiveForNextInputOnly")); print ''.$conf->global->MAIN_ROUNDING_RULE_TOT.'
    \n"; - print 'scandir.'&label='.urlencode($module->name).'">'; + print 'scandir.'&label='.urlencode($module->name).'">'; print img_picto($langs->trans("Enabled"),'switch_on'); print ''; print "\n"; - print 'scandir.'&label='.urlencode($module->name).'">'.img_picto($langs->trans("Disabled"),'switch_off').''; + print 'scandir.'&label='.urlencode($module->name).'">'.img_picto($langs->trans("Disabled"),'switch_off').''; print "
    '; - print ''; + print ''; // Disable @@ -462,7 +470,7 @@ else $var=true; print '
    '.$langs->trans("Parameter").''.$langs->trans("Value").'
    '.$langs->trans("Parameter").''.$langs->trans("Value").'
    '; - print ''; + print ''; // Disable diff --git a/htdocs/admin/mails_emailing.php b/htdocs/admin/mails_emailing.php new file mode 100644 index 00000000000..b98661edab5 --- /dev/null +++ b/htdocs/admin/mails_emailing.php @@ -0,0 +1,643 @@ + + * Copyright (C) 2009-2012 Regis Houssin + * Copyright (C) 2013 Juanjo Menent + * Copyright (C) 2016 Jonathan TISSEAU + * + * 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 + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** + * \file htdocs/admin/mails.php + * \brief Page to setup emails sending + */ + +require '../main.inc.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; + +$langs->load("companies"); +$langs->load("products"); +$langs->load("admin"); +$langs->load("mails"); +$langs->load("other"); +$langs->load("errors"); + +$action=GETPOST('action','alpha'); + +if (! $user->admin) accessforbidden(); + +$usersignature=$user->signature; +// For action = test or send, we ensure that content is not html, even for signature, because this we want a test with NO html. +if ($action == 'test' || $action == 'send') +{ + $usersignature=dol_string_nohtmltag($usersignature); +} + +$substitutionarrayfortest=array( +'__LOGIN__' => $user->login, +'__ID__' => 'TESTIdRecord', +'__EMAIL__' => 'TESTEMail', +'__LASTNAME__' => 'TESTLastname', +'__FIRSTNAME__' => 'TESTFirstname', +'__SIGNATURE__' => (($user->signature && empty($conf->global->MAIN_MAIL_DO_NOT_USE_SIGN))?$usersignature:''), +//'__PERSONALIZED__' => 'TESTPersonalized' // Hiden because not used yet +); +complete_substitutions_array($substitutionarrayfortest, $langs); + + + +/* + * Actions + */ + +if ($action == 'update' && empty($_POST["cancel"])) +{ + // Send mode parameters + dolibarr_set_const($db, "MAIN_MAIL_SENDMODE_EMAILING", GETPOST("MAIN_MAIL_SENDMODE_EMAILING"),'chaine',0,'',$conf->entity); + dolibarr_set_const($db, "MAIN_MAIL_SMTP_PORT_EMAILING", GETPOST("MAIN_MAIL_SMTP_PORT_EMAILING"),'chaine',0,'',$conf->entity); + dolibarr_set_const($db, "MAIN_MAIL_SMTP_SERVER_EMAILING", GETPOST("MAIN_MAIL_SMTP_SERVER_EMAILING"),'chaine',0,'',$conf->entity); + dolibarr_set_const($db, "MAIN_MAIL_SMTPS_ID_EMAILING", GETPOST("MAIN_MAIL_SMTPS_ID_EMAILING"), 'chaine',0,'',$conf->entity); + dolibarr_set_const($db, "MAIN_MAIL_SMTPS_PW_EMAILING", GETPOST("MAIN_MAIL_SMTPS_PW_EMAILING"), 'chaine',0,'',$conf->entity); + dolibarr_set_const($db, "MAIN_MAIL_EMAIL_TLS_EMAILING", GETPOST("MAIN_MAIL_EMAIL_TLS_EMAILING"),'chaine',0,'',$conf->entity); + dolibarr_set_const($db, "MAIN_MAIL_EMAIL_STARTTLS_EMAILING", GETPOST("MAIN_MAIL_EMAIL_STARTTLS_EMAILING"),'chaine',0,'',$conf->entity); + + header("Location: ".$_SERVER["PHP_SELF"]."?mainmenu=home&leftmenu=setup"); + exit; +} + + +// Actions to send emails +$id=0; +$actiontypecode=''; // Not an event for agenda +$trigger_name=''; // Disable triggers +$paramname='id'; +$mode='emailfortest'; +$trackid=(($action == 'testhtml')?"testhtml":"test"); +$sendcontext='emailing'; // Force to use dedicated context of setup for emailing +include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php'; + +if ($action == 'presend' && GETPOST('trackid') == 'test') $action='test'; +if ($action == 'presend' && GETPOST('trackid') == 'testhtml') $action='testhtml'; + + + + +/* + * View + */ + +$linuxlike=1; +if (preg_match('/^win/i',PHP_OS)) $linuxlike=0; +if (preg_match('/^mac/i',PHP_OS)) $linuxlike=0; + +if (empty($conf->global->MAIN_MAIL_SENDMODE_EMAILING)) $conf->global->MAIN_MAIL_SENDMODE_EMAILING='default'; +$port=! empty($conf->global->MAIN_MAIL_SMTP_PORT_EMAILING)?$conf->global->MAIN_MAIL_SMTP_PORT_EMAILING:ini_get('smtp_port'); +if (! $port) $port=25; +$server=! empty($conf->global->MAIN_MAIL_SMTP_SERVER_EMAILING)?$conf->global->MAIN_MAIL_SMTP_SERVER_EMAILING:ini_get('SMTP'); +if (! $server) $server='127.0.0.1'; + + +$wikihelp='EN:Setup_EMails|FR:Paramétrage_EMails|ES:Configuración_EMails'; +llxHeader('',$langs->trans("Setup"),$wikihelp); + +print load_fiche_titre($langs->trans("EMailsSetup"),'','title_setup'); + + +$h = 0; + +$head[$h][0] = DOL_URL_ROOT."/admin/mails.php"; +$head[$h][1] = $langs->trans("OutGoingEmailSetup"); +$head[$h][2] = 'common'; +$h++; + +if ($conf->mailing->enabled) +{ + $head[$h][0] = DOL_URL_ROOT."/admin/mails_emailing.php"; + $head[$h][1] = $langs->trans("OutGoingEmailSetupForEmailing"); + $head[$h][2] = 'common_emailing'; + $h++; +} + +$head[$h][0] = DOL_URL_ROOT."/admin/mails_templates.php"; +$head[$h][1] = $langs->trans("DictionaryEMailTemplates"); +$head[$h][2] = 'templates'; +$h++; + + +// List of sending methods +$listofmethods=array(); +$listofmethods['default']=$langs->trans('DefaultOutgoingEmailSetup'); +$listofmethods['mail']='PHP mail function'; +//$listofmethods['simplemail']='Simplemail class'; +$listofmethods['smtps']='SMTP/SMTPS socket library'; +$listofmethods['swiftmailer']='Swift Mailer socket library'; + + +if ($action == 'edit') +{ + $form=new Form($db); + + if ($conf->use_javascript_ajax) + { + print "\n".''."\n"; + } + + print ''; + print ''; + print ''; + + dol_fiche_head($head, 'common_emailing', '', -1); + + print $langs->trans("EMailsDesc")."
    \n"; + print "
    \n"; + + + clearstatcache(); + $var=true; + + print '
    '.$langs->trans("Parameter").''.$langs->trans("Value").'
    '.$langs->trans("Parameter").''.$langs->trans("Value").'
    '; + print ''; + + // Method + + print ''; + + // Host server + + print ''; + + // Port + + print ''; + + // ID + if (! empty($conf->use_javascript_ajax) || (isset($conf->global->MAIN_MAIL_SENDMODE_EMAILING) && in_array($conf->global->MAIN_MAIL_SENDMODE_EMAILING, array('smtps', 'swiftmailer')))) + { + + $mainstmpid=(! empty($conf->global->MAIN_MAIL_SMTPS_ID_EMAILING)?$conf->global->MAIN_MAIL_SMTPS_ID_EMAILING:''); + print ''; + } + + // PW + if (! empty($conf->use_javascript_ajax) || (isset($conf->global->MAIN_MAIL_SENDMODE_EMAILING) && in_array($conf->global->MAIN_MAIL_SENDMODE_EMAILING, array('smtps', 'swiftmailer')))) + { + + $mainsmtppw=(! empty($conf->global->MAIN_MAIL_SMTPS_PW_EMAILING)?$conf->global->MAIN_MAIL_SMTPS_PW_EMAILING:''); + print ''; + } + + // TLS + + print ''; + + // STARTTLS + + print ''; + + print '
    '.$langs->trans("Parameter").''.$langs->trans("Value").'
    '.$langs->trans("MAIN_MAIL_SENDMODE").''; + + // SuperAdministrator access only + if ((empty($conf->global->MAIN_MODULE_MULTICOMPANY)) || ($user->admin && !$user->entity)) + { + print $form->selectarray('MAIN_MAIL_SENDMODE_EMAILING',$listofmethods,$conf->global->MAIN_MAIL_SENDMODE_EMAILING); + } + else + { + $text = $listofmethods[$conf->global->MAIN_MAIL_SENDMODE_EMAILING]; + if (empty($text)) $text = $langs->trans("Undefined"); + $htmltext = $langs->trans("ContactSuperAdminForChange"); + print $form->textwithpicto($text,$htmltext,1,'superadmin'); + print ''; + } + print '
    '; + if (! $conf->use_javascript_ajax && $linuxlike && $conf->global->MAIN_MAIL_SENDMODE_EMAILING == 'mail') + { + print $langs->trans("MAIN_MAIL_SMTP_SERVER_NotAvailableOnLinuxLike"); + print ''; + print $langs->trans("SeeLocalSendMailSetup"); + } + else + { + $mainserver = (! empty($conf->global->MAIN_MAIL_SMTP_SERVER_EMAILING)?$conf->global->MAIN_MAIL_SMTP_SERVER_EMAILING:''); + $smtpserver = ini_get('SMTP')?ini_get('SMTP'):$langs->transnoentities("Undefined"); + if ($linuxlike) print $langs->trans("MAIN_MAIL_SMTP_SERVER_NotAvailableOnLinuxLike"); + else print $langs->trans("MAIN_MAIL_SMTP_SERVER",$smtpserver); + print ''; + // SuperAdministrator access only + if (empty($conf->multicompany->enabled) || ($user->admin && ! $user->entity)) + { + print ''; + print ''; + print ''.$langs->trans("SeeLocalSendMailSetup").''; + } + else + { + $text = ! empty($mainserver) ? $mainserver : $smtpserver; + $htmltext = $langs->trans("ContactSuperAdminForChange"); + print $form->textwithpicto($text,$htmltext,1,'superadmin'); + print ''; + } + } + print '
    '; + if (! $conf->use_javascript_ajax && $linuxlike && $conf->global->MAIN_MAIL_SENDMODE_EMAILING == 'mail') + { + print $langs->trans("MAIN_MAIL_SMTP_PORT_NotAvailableOnLinuxLike"); + print ''; + print $langs->trans("SeeLocalSendMailSetup"); + } + else + { + $mainport = (! empty($conf->global->MAIN_MAIL_SMTP_PORT_EMAILING) ? $conf->global->MAIN_MAIL_SMTP_PORT_EMAILING : ''); + $smtpport = ini_get('smtp_port')?ini_get('smtp_port'):$langs->transnoentities("Undefined"); + if ($linuxlike) print $langs->trans("MAIN_MAIL_SMTP_PORT_NotAvailableOnLinuxLike"); + else print $langs->trans("MAIN_MAIL_SMTP_PORT",$smtpport); + print ''; + // SuperAdministrator access only + if (empty($conf->multicompany->enabled) || ($user->admin && ! $user->entity)) + { + print ''; + print ''; + print ''.$langs->trans("SeeLocalSendMailSetup").''; + } + else + { + $text = (! empty($mainport) ? $mainport : $smtpport); + $htmltext = $langs->trans("ContactSuperAdminForChange"); + print $form->textwithpicto($text,$htmltext,1,'superadmin'); + print ''; + } + } + print '
    '.$langs->trans("MAIN_MAIL_SMTPS_ID").''; + // SuperAdministrator access only + if (empty($conf->multicompany->enabled) || ($user->admin && !$user->entity)) + { + print ''; + } + else + { + $htmltext = $langs->trans("ContactSuperAdminForChange"); + print $form->textwithpicto($conf->global->MAIN_MAIL_SMTPS_ID_EMAILING,$htmltext,1,'superadmin'); + print ''; + } + print '
    '.$langs->trans("MAIN_MAIL_SMTPS_PW").''; + // SuperAdministrator access only + if (empty($conf->multicompany->enabled) || ($user->admin && !$user->entity)) + { + print ''; + } + else + { + $htmltext = $langs->trans("ContactSuperAdminForChange"); + print $form->textwithpicto($conf->global->MAIN_MAIL_SMTPS_PW_EMAILING,$htmltext,1,'superadmin'); + print ''; + } + print '
    '.$langs->trans("MAIN_MAIL_EMAIL_TLS").''; + if (! empty($conf->use_javascript_ajax) || (isset($conf->global->MAIN_MAIL_SENDMODE_EMAILING) && in_array($conf->global->MAIN_MAIL_SENDMODE_EMAILING, array('smtps', 'swiftmailer')))) + { + if (function_exists('openssl_open')) + { + print $form->selectyesno('MAIN_MAIL_EMAIL_TLS_EMAILING',(! empty($conf->global->MAIN_MAIL_EMAIL_TLS_EMAILING)?$conf->global->MAIN_MAIL_EMAIL_TLS_EMAILING:0),1); + } + else print yn(0).' ('.$langs->trans("YourPHPDoesNotHaveSSLSupport").')'; + } + else print yn(0).' ('.$langs->trans("NotSupported").')'; + print '
    '.$langs->trans("MAIN_MAIL_EMAIL_STARTTLS").''; + if (! empty($conf->use_javascript_ajax) || (isset($conf->global->MAIN_MAIL_SENDMODE_EMAILING) && in_array($conf->global->MAIN_MAIL_SENDMODE_EMAILING, array('smtps', 'swiftmailer')))) + { + if (function_exists('openssl_open')) + { + print $form->selectyesno('MAIN_MAIL_EMAIL_STARTTLS_EMAILING',(! empty($conf->global->MAIN_MAIL_EMAIL_STARTTLS_EMAILING)?$conf->global->MAIN_MAIL_EMAIL_STARTTLS_EMAILING:0),1); + } + else print yn(0).' ('.$langs->trans("YourPHPDoesNotHaveSSLSupport").')'; + } + else print yn(0).' ('.$langs->trans("NotSupported").')'; + print '
    '; + + dol_fiche_end(); + + print '
    '; + print ''; + print '     '; + print ''; + print '
    '; + + print ''; +} +else +{ + dol_fiche_head($head, 'common_emailing', '', -1); + + print $langs->trans("EMailsDesc")."
    \n"; + print "
    \n"; + + + $var=true; + + print ''; + print ''; + + // Method + + print ''; + + if (! empty($conf->global->MAIN_MAIL_SENDMODE_EMAILING) && $conf->global->MAIN_MAIL_SENDMODE_EMAILING != 'default') + { + // Host server + + if ($linuxlike && (isset($conf->global->MAIN_MAIL_SENDMODE_EMAILING) && $conf->global->MAIN_MAIL_SENDMODE_EMAILING == 'mail')) + { + print ''; + } + else + { + print ''; + } + + // Port + + if ($linuxlike && (isset($conf->global->MAIN_MAIL_SENDMODE_EMAILING) && $conf->global->MAIN_MAIL_SENDMODE_EMAILING == 'mail')) + { + print ''; + } + else + { + print ''; + } + + // SMTPS ID + + if (isset($conf->global->MAIN_MAIL_SENDMODE_EMAILING) && in_array($conf->global->MAIN_MAIL_SENDMODE_EMAILING, array('smtps', 'swiftmailer'))) + { + print ''; + } + + // SMTPS PW + + if (isset($conf->global->MAIN_MAIL_SENDMODE_EMAILING) && in_array($conf->global->MAIN_MAIL_SENDMODE_EMAILING, array('smtps', 'swiftmailer'))) + { + print ''; + } + + // TLS + + print ''; + + // STARTTLS + + print ''; + } + + print '
    '.$langs->trans("Parameter").''.$langs->trans("Value").'
    '.$langs->trans("MAIN_MAIL_SENDMODE").''; + $text=$listofmethods[$conf->global->MAIN_MAIL_SENDMODE_EMAILING]; + if (empty($text)) $text=$langs->trans("Undefined").img_warning(); + print $text; + print '
    '.$langs->trans("MAIN_MAIL_SMTP_SERVER_NotAvailableOnLinuxLike").''.$langs->trans("SeeLocalSendMailSetup").'
    '.$langs->trans("MAIN_MAIL_SMTP_SERVER",ini_get('SMTP')?ini_get('SMTP'):$langs->transnoentities("Undefined")).''.(! empty($conf->global->MAIN_MAIL_SMTP_SERVER_EMAILING)?$conf->global->MAIN_MAIL_SMTP_SERVER_EMAILING:'').'
    '.$langs->trans("MAIN_MAIL_SMTP_PORT_NotAvailableOnLinuxLike").''.$langs->trans("SeeLocalSendMailSetup").'
    '.$langs->trans("MAIN_MAIL_SMTP_PORT",ini_get('smtp_port')?ini_get('smtp_port'):$langs->transnoentities("Undefined")).''.(! empty($conf->global->MAIN_MAIL_SMTP_PORT_EMAILING)?$conf->global->MAIN_MAIL_SMTP_PORT_EMAILING:'').'
    '.$langs->trans("MAIN_MAIL_SMTPS_ID").''.$conf->global->MAIN_MAIL_SMTPS_ID_EMAILING.'
    '.$langs->trans("MAIN_MAIL_SMTPS_PW").''.preg_replace('/./','*',$conf->global->MAIN_MAIL_SMTPS_PW_EMAILING).'
    '.$langs->trans("MAIN_MAIL_EMAIL_TLS").''; + if (isset($conf->global->MAIN_MAIL_SENDMODE_EMAILING) && in_array($conf->global->MAIN_MAIL_SENDMODE_EMAILING, array('smtps', 'swiftmailer'))) + { + if (function_exists('openssl_open')) + { + print yn($conf->global->MAIN_MAIL_EMAIL_TLS_EMAILING); + } + else print yn(0).' ('.$langs->trans("YourPHPDoesNotHaveSSLSupport").')'; + } + else print yn(0).' ('.$langs->trans("NotSupported").')'; + print '
    '.$langs->trans("MAIN_MAIL_EMAIL_STARTTLS").''; + if (isset($conf->global->MAIN_MAIL_SENDMODE_EMAILING) && in_array($conf->global->MAIN_MAIL_SENDMODE_EMAILING, array('smtps', 'swiftmailer'))) + { + if (function_exists('openssl_open')) + { + print yn($conf->global->MAIN_MAIL_EMAIL_STARTTLS_EMAILING); + } + else print yn(0).' ('.$langs->trans("YourPHPDoesNotHaveSSLSupport").')'; + } + else print yn(0).' ('.$langs->trans("NotSupported").')'; + print '
    '; + + dol_fiche_end(); + + + if ($conf->global->MAIN_MAIL_SENDMODE_EMAILING == 'mail' && empty($conf->global->MAIN_FIX_FOR_BUGGED_MTA)) + { + print '
    '; + /* + // Warning 1 + if ($linuxlike) + { + $sendmailoption=ini_get('mail.force_extra_parameters'); + if (empty($sendmailoption) || ! preg_match('/ba/',$sendmailoption)) + { + print info_admin($langs->trans("SendmailOptionNotComplete")); + } + }*/ + // Warning 2 + print info_admin($langs->trans("SendmailOptionMayHurtBuggedMTA")); + } + + + // Boutons actions + print '
    '; + + print ''.$langs->trans("Modify").''; + + if (! empty($conf->global->MAIN_MAIL_SENDMODE_EMAILING) && $conf->global->MAIN_MAIL_SENDMODE_EMAILING != 'default') + { + if ($conf->global->MAIN_MAIL_SENDMODE_EMAILING != 'mail' || ! $linuxlike) + { + if (function_exists('fsockopen') && $port && $server) + { + print ''.$langs->trans("DoTestServerAvailability").''; + } + } + else + { + print ''.$langs->trans("DoTestServerAvailability").''; + } + + print ''.$langs->trans("DoTestSend").''; + + if (! empty($conf->fckeditor->enabled)) + { + print ''.$langs->trans("DoTestSendHTML").''; + } + } + + print '
    '; + + + if ($conf->global->MAIN_MAIL_SENDMODE_EMAILING == 'mail' && ! in_array($action, array('testconnect', 'test', 'testhtml'))) + { + $text = $langs->trans("WarningPHPMail"); + print info_admin($text); + } + + // Run the test to connect + if ($action == 'testconnect') + { + print load_fiche_titre($langs->trans("DoTestServerAvailability")); + + include_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php'; + $mail = new CMailFile('','','',''); + $result=$mail->check_server_port($server,$port); + if ($result) print '
    '.$langs->trans("ServerAvailableOnIPOrPort",$server,$port).'
    '; + else + { + $errormsg = $langs->trans("ServerNotAvailableOnIPOrPort",$server,$port); + + if ($mail->error) { + $errormsg .= ' - '.$mail->error; + } + + setEventMessages($errormsg, null, 'errors'); + } + print '
    '; + } + + // Show email send test form + if ($action == 'test' || $action == 'testhtml') + { + print '
    '; + print load_fiche_titre($action == 'testhtml'?$langs->trans("DoTestSendHTML"):$langs->trans("DoTestSend")); + + dol_fiche_head(''); + + // Cree l'objet formulaire mail + include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php'; + $formmail = new FormMail($db); + $formmail->fromname = (isset($_POST['fromname'])?$_POST['fromname']:$conf->global->MAIN_MAIL_EMAIL_FROM); + $formmail->frommail = (isset($_POST['frommail'])?$_POST['frommail']:$conf->global->MAIN_MAIL_EMAIL_FROM); + $formmail->trackid=(($action == 'testhtml')?"testhtml":"test"); + $formmail->withfromreadonly=0; + $formmail->withsubstit=0; + $formmail->withfrom=1; + $formmail->witherrorsto=1; + $formmail->withto=(! empty($_POST['sendto'])?$_POST['sendto']:($user->email?$user->email:1)); + $formmail->withtocc=(! empty($_POST['sendtocc'])?$_POST['sendtocc']:1); // ! empty to keep field if empty + $formmail->withtoccc=(! empty($_POST['sendtoccc'])?$_POST['sendtoccc']:1); // ! empty to keep field if empty + $formmail->withtopic=(isset($_POST['subject'])?$_POST['subject']:$langs->trans("Test")); + $formmail->withtopicreadonly=0; + $formmail->withfile=2; + $formmail->withbody=(isset($_POST['message'])?$_POST['message']:($action == 'testhtml'?$langs->transnoentities("PredefinedMailTestHtml"):$langs->transnoentities("PredefinedMailTest"))); + $formmail->withbodyreadonly=0; + $formmail->withcancel=1; + $formmail->withdeliveryreceipt=1; + $formmail->withfckeditor=($action == 'testhtml'?1:0); + $formmail->ckeditortoolbar='dolibarr_mailings'; + // Tableau des substitutions + $formmail->substit=$substitutionarrayfortest; + // Tableau des parametres complementaires du post + $formmail->param["action"]="send"; + $formmail->param["models"]="body"; + $formmail->param["mailid"]=0; + $formmail->param["returnurl"]=$_SERVER["PHP_SELF"]; + + // Init list of files + if (GETPOST("mode")=='init') + { + $formmail->clear_attached_files(); + } + + print $formmail->get_form('addfile','removefile'); + + dol_fiche_end(); + } +} + + +llxFooter(); + +$db->close(); diff --git a/htdocs/admin/mails_templates.php b/htdocs/admin/mails_templates.php index dabc0f5f730..2bf6faf2112 100644 --- a/htdocs/admin/mails_templates.php +++ b/htdocs/admin/mails_templates.php @@ -45,6 +45,7 @@ $langs->load("errors"); $langs->load("admin"); $langs->load("main"); $langs->load("mails"); +$langs->load("languages"); $action=GETPOST('action','alpha')?GETPOST('action','alpha'):'view'; $confirm=GETPOST('confirm','alpha'); @@ -85,17 +86,17 @@ $tabsqlsort[25]="label ASC"; // Nom des champs en resultat de select pour affichage du dictionnaire $tabfield=array(); -$tabfield[25]= "label,type_template,private,position,topic,content"; +$tabfield[25]= "label,type_template,lang,private,position,topic,content"; if (! empty($conf->global->MAIN_EMAIL_TEMPLATES_FOR_OBJECT_LINES)) $tabfield[25].=',content_lines'; // Nom des champs d'edition pour modification d'un enregistrement $tabfieldvalue=array(); -$tabfieldvalue[25]= "label,type_template,private,position,topic,content"; +$tabfieldvalue[25]= "label,type_template,lang,private,position,topic,content"; if (! empty($conf->global->MAIN_EMAIL_TEMPLATES_FOR_OBJECT_LINES)) $tabfieldvalue[25].=',content_lines'; // Nom des champs dans la table pour insertion d'un enregistrement $tabfieldinsert=array(); -$tabfieldinsert[25]= "label,type_template,private,position,topic,content"; +$tabfieldinsert[25]= "label,type_template,lang,private,position,topic,content"; if (! empty($conf->global->MAIN_EMAIL_TEMPLATES_FOR_OBJECT_LINES)) $tabfieldinsert[25].=',content_lines'; $tabfieldinsert[25].=',entity'; // Must be at end because not into other arrays @@ -144,16 +145,16 @@ $sourceList=array(); // We save list of template email Dolibarr can manage. This list can found by a grep into code on "->param['models']" $elementList = array(); -if ($conf->propal->enabled) $elementList['propal_send']=$langs->trans('MailToSendProposal'); -if ($conf->commande->enabled) $elementList['order_send']=$langs->trans('MailToSendOrder'); -if ($conf->facture->enabled) $elementList['facture_send']=$langs->trans('MailToSendInvoice'); -if ($conf->expedition->enabled) $elementList['shipping_send']=$langs->trans('MailToSendShipment'); -if ($conf->ficheinter->enabled) $elementList['fichinter_send']=$langs->trans('MailToSendIntervention'); +if ($conf->propal->enabled) $elementList['propal_send']=$langs->trans('MailToSendProposal'); +if ($conf->commande->enabled) $elementList['order_send']=$langs->trans('MailToSendOrder'); +if ($conf->facture->enabled) $elementList['facture_send']=$langs->trans('MailToSendInvoice'); +if ($conf->expedition->enabled) $elementList['shipping_send']=$langs->trans('MailToSendShipment'); +if ($conf->ficheinter->enabled) $elementList['fichinter_send']=$langs->trans('MailToSendIntervention'); if ($conf->supplier_proposal->enabled) $elementList['supplier_proposal_send']=$langs->trans('MailToSendSupplierRequestForQuotation'); -if ($conf->fournisseur->enabled) $elementList['order_supplier_send']=$langs->trans('MailToSendSupplierOrder'); -if ($conf->fournisseur->enabled) $elementList['invoice_supplier_send']=$langs->trans('MailToSendSupplierInvoice'); -if ($conf->societe->enabled) $elementList['thirdparty']=$langs->trans('MailToThirdparty'); -if ($conf->contrat->enabled) $elementList['contract']=$langs->trans('MailToSendContract'); +if ($conf->fournisseur->enabled) $elementList['order_supplier_send']=$langs->trans('MailToSendSupplierOrder'); +if ($conf->fournisseur->enabled) $elementList['invoice_supplier_send']=$langs->trans('MailToSendSupplierInvoice'); +if ($conf->societe->enabled) $elementList['thirdparty']=$langs->trans('MailToThirdparty'); +if ($conf->contrat->enabled) $elementList['contract']=$langs->trans('MailToSendContract'); $parameters=array('elementList'=>$elementList); $reshook=$hookmanager->executeHooks('emailElementlist',$parameters); // Note that $action and $object may have been modified by some hooks @@ -204,7 +205,7 @@ if (empty($reshook)) if ($value == 'content') $value='content-'.$rowid; if ($value == 'content_lines') $value='content_lines-'.$rowid; - if (! isset($_POST[$value]) || $_POST[$value]=='') + if ((! isset($_POST[$value]) || $_POST[$value]=='') && $value != 'lang') { $ok=0; $fieldnamekey=$listfield[$f]; @@ -253,15 +254,16 @@ if (empty($reshook)) $i=0; foreach ($listfieldinsert as $f => $value) { - //var_dump($i.' - '.$listfieldvalue[$i].' - '.$_POST[$listfieldvalue[$i]].' - '.$value); - if ($value == 'entity') { - $_POST[$listfieldvalue[$i]] = $conf->entity; - } + $keycode=$listfieldvalue[$i]; + if ($value == 'lang') $keycode='langcode'; + + //var_dump($i.' - '.$listfieldvalue[$i].' - '.$_POST[$listfieldvalue[$i]].' - '.$value); + if ($value == 'entity') $_POST[$keycode] = $conf->entity; if ($i) $sql.=","; - if ($value == 'private' && ! is_numeric($_POST[$listfieldvalue[$i]])) $_POST[$listfieldvalue[$i]]='0'; - if ($value == 'position' && ! is_numeric($_POST[$listfieldvalue[$i]])) $_POST[$listfieldvalue[$i]]='1'; - if ($_POST[$listfieldvalue[$i]] == '') $sql.="null"; // For vat, we want/accept code = '' - else $sql.="'".$db->escape($_POST[$listfieldvalue[$i]])."'"; + if ($value == 'private' && ! is_numeric($_POST[$keycode])) $_POST[$keycode]='0'; + if ($value == 'position' && ! is_numeric($_POST[$keycode])) $_POST[$keycode]='1'; + if ($_POST[$keycode] == '' || ($keycode == 'langcode' && empty($_POST[$keycode]))) $sql.="null"; // For vat, we want/accept code = '' + else $sql.="'".$db->escape($_POST[$keycode])."'"; $i++; } $sql.=",1)"; @@ -301,15 +303,16 @@ if (empty($reshook)) $i = 0; foreach ($listfieldmodify as $field) { + $keycode=$listfieldvalue[$i]; + if ($field == 'lang') $keycode='langcode'; + if ($field == 'content') $_POST['content']=$_POST['content-'.$rowid]; if ($field == 'content_lines') $_POST['content_lines']=$_POST['content_lines-'.$rowid]; - if ($field == 'entity') { - $_POST[$listfieldvalue[$i]] = $conf->entity; - } + if ($field == 'entity') $_POST[$keycode] = $conf->entity; if ($i) $sql.=","; $sql.= $field."="; - if ($_POST[$listfieldvalue[$i]] == '') $sql.="null"; // For vat, we want/accept code = '' - else $sql.="'".$db->escape($_POST[$listfieldvalue[$i]])."'"; + if ($_POST[$keycode] == '' || ($keycode == 'langcode' && empty($_POST[$keycode]))) $sql.="null"; // For vat, we want/accept code = '' + else $sql.="'".$db->escape($_POST[$keycode])."'"; $i++; } $sql.= " WHERE ".$rowidcol." = '".$rowid."'"; @@ -410,6 +413,14 @@ $head[$h][1] = $langs->trans("OutGoingEmailSetup"); $head[$h][2] = 'common'; $h++; +if ($conf->mailing->enabled) +{ + $head[$h][0] = DOL_URL_ROOT."/admin/mails_emailing.php"; + $head[$h][1] = $langs->trans("OutGoingEmailSetupForEmailing"); + $head[$h][2] = 'common_emailing'; + $h++; +} + $head[$h][0] = DOL_URL_ROOT."/admin/mails_templates.php"; $head[$h][1] = $langs->trans("DictionaryEMailTemplates"); $head[$h][2] = 'templates'; @@ -426,16 +437,13 @@ if ($action == 'delete') //var_dump($elementList); -$sql="SELECT rowid as rowid, label, type_template, private, position, topic, content_lines, content, active"; +$sql="SELECT rowid as rowid, label, type_template, lang, private, position, topic, content_lines, content, active"; $sql.=" FROM ".MAIN_DB_PREFIX."c_email_templates"; $sql.=" WHERE entity IN (".getEntity('email_template').")"; if ($search_label) $sql.=natural_search('label', $search_label); - -if ($search_country_id > 0) +if (empty($conf->global->MAIN_MULTILANGS)) { - if (preg_match('/ WHERE /',$sql)) $sql.= " AND "; - else $sql.=" WHERE "; - $sql.= " c.rowid = ".$search_country_id; + $sql.= " AND (lang = '".$langs->defaultlang."' OR lang IS NULL)"; } if ($sortfield) @@ -461,21 +469,21 @@ $sql.=$db->plimit($listlimit+1,$offset); $fieldlist=explode(',',$tabfield[$id]); -print '
    '; -print ''; -print ''; - -print ''; - // Form to add a new line $alabelisused=0; $var=false; $fieldlist=explode(',',$tabfield[$id]); -if ($action != 'edit') -{ - // Line for title +//if ($action != 'edit') +//{ + print ''; + print ''; + print ''; + + print '
    '; + + // Line for title print ''; foreach ($fieldlist as $field => $value) { @@ -585,12 +593,13 @@ if ($action != 'edit') $colspan=count($fieldlist)+1; //print ''; // Keep   to have a line with enough height -} -print '
     
    '; -print '
    '; + print ''; -print '
    '; + print ''; + + print '
    '; +//} print '
    '; print ''; @@ -691,6 +700,7 @@ if ($resql) $obj = $db->fetch_object($resql); //print_r($obj); print ''; + if ($action == 'edit' && ($rowid == (! empty($obj->rowid)?$obj->rowid:$obj->code))) { $tmpaction='edit'; @@ -724,15 +734,15 @@ if ($resql) // Show value for field if ($showfield) { - print ''; // To create an artificial CR for the current tr we are on + print ''; + print ''; // To create an artificial CR for the current tr we are on $okforextended = true; - if (empty($conf->global->FCKEDITOR_ENABLE_MAIL)) - $okforextended = false; - $doleditor = new DolEditor($tmpfieldlist.'-'.$rowid, (! empty($obj->{$tmpfieldlist}) ? $obj->{$tmpfieldlist} : ''), '', 140, 'dolibarr_mailings', 'In', 0, false, $okforextended, ROWS_6, '90%'); - print $doleditor->Create(1); - print ''; - print ''; - + if (empty($conf->global->FCKEDITOR_ENABLE_MAIL)) $okforextended = false; + $doleditor = new DolEditor($tmpfieldlist.'-'.$rowid, (! empty($obj->{$tmpfieldlist}) ? $obj->{$tmpfieldlist} : ''), '', 140, 'dolibarr_mailings', 'In', 0, false, $okforextended, ROWS_6, '90%'); + print $doleditor->Create(1); + print ''; + print ''; + print ''; } } } @@ -756,12 +766,16 @@ if ($resql) { $valuetoshow = isset($elementList[$valuetoshow])?$elementList[$valuetoshow]:$valuetoshow; } + if ($value == 'lang' && $valuetoshow) + { + $valuetoshow = $valuetoshow.' - '.$langs->trans("Language_".$valuetoshow); + } $class='tddict'; // Show value for field if ($showfield) { - print ''.$valuetoshow.''; + print ''.$valuetoshow.''; } } } @@ -876,14 +890,29 @@ function fieldList($fieldlist, $obj='', $tabname='', $context='') if ($fieldlist[$field] == 'lang') { print ''; - print $formadmin->select_language($conf->global->MAIN_LANG_DEFAULT,'lang'); + if (! empty($conf->global->MAIN_MULTILANGS)) + { + $selectedlang = $langs->defaultlang; + if ($context == 'edit') $selectedlang = $obj->{$fieldlist[$field]}; + print $formadmin->select_language($selectedlang, 'langcode', 0, null, 1); + } + else + { + if (! empty($obj->{$fieldlist[$field]})) + { + print $obj->{$fieldlist[$field]}.' - '.$langs->trans('Language_'.$obj->{$fieldlist[$field]}); + } + $keyname=$fieldlist[$field]; + if ($keyname == 'lang') $keyname='langcode'; // Avoid conflict with lang param + print ''; + } print ''; } // Le type de template elseif ($fieldlist[$field] == 'type_template') { print ''; - print $form->selectarray('type_template', $elementList,(! empty($obj->{$fieldlist[$field]})?$obj->{$fieldlist[$field]}:'')); + print $form->selectarray('type_template', $elementList, (! empty($obj->{$fieldlist[$field]})?$obj->{$fieldlist[$field]}:''), 1); print ''; } elseif (in_array($fieldlist[$field], array('content','content_lines'))) continue; diff --git a/htdocs/admin/modulehelp.php b/htdocs/admin/modulehelp.php index 830b323545f..e0caaba0a93 100644 --- a/htdocs/admin/modulehelp.php +++ b/htdocs/admin/modulehelp.php @@ -35,7 +35,8 @@ if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1'); // If there is n require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; -require_once DOL_DOCUMENT_ROOT . '/core/lib/functions2.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; $langs->load("errors"); $langs->load("admin"); @@ -371,18 +372,20 @@ if ($mode == 'feature') if (count($objMod->requiredby)) $text.=join(',', $objMod->requiredby); else $text.=$langs->trans("None"); - $text.='


    '; + $text.='

    '; - $text.=''.$langs->trans("AddRemoveTabs").': '; - if (isset($objMod->tabs) && is_array($objMod->tabs) && count($objMod->tabs)) + $text.='
    '.$langs->trans("AddDataTables").': '; + $sqlfiles = dol_dir_list(dol_buildpath($moduledir.'/sql/'), 'files', 0, 'llx.*\.sql', array('\.key\.sql')); + if (count($sqlfiles) > 0) { - $i=0; - foreach($objMod->tabs as $val) - { - $tmp=explode(':',$val,3); - $text.=($i?', ':'').$tmp[0].':'.$tmp[1]; - $i++; - } + $text.=$langs->trans("Yes").' ('; + $i=0; + foreach($sqlfiles as $val) + { + $text.=($i?', ':'').preg_replace('/\.sql$/','',preg_replace('/llx_/','',$val['name'])); + $i++; + } + $text.=')'; } else $text.=$langs->trans("No"); @@ -402,13 +405,24 @@ if ($mode == 'feature') $text.='
    '; - $text.='
    '.$langs->trans("AddBoxes").': '; - if (isset($objMod->boxes) && is_array($objMod->boxes) && count($objMod->boxes)) + $text.='
    '.$langs->trans("AddData").': '; + $filedata = dol_buildpath($moduledir.'/sql/data.sql'); + if (dol_is_file($filedata)) + { + $text.=$langs->trans("Yes").' ('.$moduledir.'/sql/data.sql'.')'; + } + else $text.=$langs->trans("No"); + + $text.='
    '; + + $text.='
    '.$langs->trans("AddRemoveTabs").': '; + if (isset($objMod->tabs) && is_array($objMod->tabs) && count($objMod->tabs)) { $i=0; - foreach($objMod->boxes as $val) + foreach($objMod->tabs as $val) { - $text.=($i?', ':'').($val['file']?$val['file']:$val[0]); + $tmp=explode(':',$val,3); + $text.=($i?', ':'').$tmp[0].':'.$tmp[1]; $i++; } } @@ -474,6 +488,20 @@ if ($mode == 'feature') $text.='
    '; + $text.='
    '.$langs->trans("AddBoxes").': '; + if (isset($objMod->boxes) && is_array($objMod->boxes) && count($objMod->boxes)) + { + $i=0; + foreach($objMod->boxes as $val) + { + $text.=($i?', ':'').($val['file']?$val['file']:$val[0]); + $i++; + } + } + else $text.=$langs->trans("No"); + + $text.='
    '; + $text.='
    '.$langs->trans("AddHooks").': '; if (isset($objMod->module_parts) && is_array($objMod->module_parts['hooks']) && count($objMod->module_parts['hooks'])) { diff --git a/htdocs/admin/modules.php b/htdocs/admin/modules.php index a59d6fca3bb..2c18e9c4927 100644 --- a/htdocs/admin/modules.php +++ b/htdocs/admin/modules.php @@ -32,6 +32,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/geturl.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/admin/dolistore/class/dolistore.class.php'; $langs->load("errors"); $langs->load("admin"); @@ -46,6 +47,17 @@ $search_status=GETPOST('search_status','alpha'); $search_nature=GETPOST('search_nature','alpha'); $search_version=GETPOST('search_version','alpha'); + +// For dolistore search +$options = array(); +$options['per_page'] = 20; +$options['categorie'] = GETPOST('categorie', 'int') + 0; +$options['start'] = GETPOST('start', 'int') + 0; +$options['end'] = GETPOST('end', 'int') + 0; +$options['search'] = GETPOST('search_keyword', 'alpha'); +$dolistore = new Dolistore($options); + + if (! $user->admin) accessforbidden(); @@ -240,6 +252,11 @@ if ($action == 'reset' && $user->admin) * View */ +$form = new Form($db); + +$morejs = array("/admin/dolistore/js/dolistore.js.php"); +$morecss = array("/admin/dolistore/css/dolistore.css"); + // Set dir where external modules are installed if (! dol_is_dir($dirins)) { @@ -247,10 +264,8 @@ if (! dol_is_dir($dirins)) } $dirins_ok=(dol_is_dir($dirins)); -$form = new Form($db); - $help_url='EN:First_setup|FR:Premiers_paramétrages|ES:Primeras_configuraciones'; -llxHeader('',$langs->trans("Setup"),$help_url); +llxHeader('',$langs->trans("Setup"),$help_url, '', '', '', $morejs, $morecss, 0, 0); $arrayofnatures=array('core'=>$langs->transnoentitiesnoconv("Core"), 'external'=>$langs->transnoentitiesnoconv("External").' - '.$langs->trans("AllPublishers")); $arrayofwarnings=array(); // Array of warning each module want to show when activated @@ -423,24 +438,9 @@ print load_fiche_titre($langs->trans("ModulesSetup"),$moreinfo,'title_setup'); if ($mode=='common') print ''.$langs->trans("ModulesDesc")."
    \n"; if ($mode=='marketplace') print ''.$langs->trans("ModulesMarketPlaceDesc")."
    \n"; if ($mode=='deploy') print ''.$langs->trans("ModulesDeployDesc", $langs->transnoentitiesnoconv("AvailableModules"))."
    \n"; +if ($mode=='develop') print ''.$langs->trans("ModulesDevelopDesc")."
    \n"; - -$h = 0; - -$head[$h][0] = DOL_URL_ROOT."/admin/modules.php?mode=common"; -$head[$h][1] = $langs->trans("AvailableModules"); -$head[$h][2] = 'common'; -$h++; - -$head[$h][0] = DOL_URL_ROOT."/admin/modules.php?mode=marketplace"; -$head[$h][1] = $langs->trans("ModulesMarketPlaces"); -$head[$h][2] = 'marketplace'; -$h++; - -$head[$h][0] = DOL_URL_ROOT."/admin/modules.php?mode=deploy"; -$head[$h][1] = $langs->trans("AddExtensionThemeModuleOrOther"); -$head[$h][2] = 'deploy'; -$h++; +$head = modules_prepare_head(); print "
    \n"; @@ -817,7 +817,6 @@ if ($mode == 'marketplace') print ''.$langs->trans("URL").''; print ''; - print "\n"; $url='https://www.dolistore.com'; print ''; @@ -825,17 +824,57 @@ if ($mode == 'marketplace') print ''.$url.''; print ''; - - print "\n"; - $url='https://partners.dolibarr.org'; - print ''; - print ''.$langs->trans("DoliPartnersDesc").''; - print ''.$url.''; - print ''; - print "\n"; dol_fiche_end(); + + print '
    '; + + if (empty($conf->global->MAIN_DISABLE_DOLISTORE_SEARCH) && $conf->global->MAIN_FEATURES_LEVEL >= 1) + { + print ''.$langs->trans('DOLISTOREdescriptionLong').''; + + + ?> +

    + +
    + + +
    trans('Mot-cle') ?>: +
    +
    +


    + +
    +
    +
      + get_categories(); ?> +
    +
    +
    + + + + + + + + get_products($categorie); ?> + + + + + + +
    get_previous_link() ?> get_next_link() ?> trans('AchatTelechargement') ?>
    get_previous_link() ?> get_next_link() ?> trans('AchatTelechargement') ?>
    +
    + + \n"; + print "\n"; + //print ''.$langs->trans("Logo").''; + print ''.$langs->trans("DevelopYourModuleDesc").''; + print ''.$langs->trans("URL").''; + print ''; + + print "\n"; + $url='https://partners.dolibarr.org'; + print ''; + print ''.$langs->trans("DoliPartnersDesc").''; + print ''.$url.''; + print ''; + + print "\n"; + + dol_fiche_end(); +} + + + llxFooter(); $db->close(); diff --git a/htdocs/admin/payment.php b/htdocs/admin/payment.php index 061b9d50f6a..2ef7a500268 100644 --- a/htdocs/admin/payment.php +++ b/htdocs/admin/payment.php @@ -36,7 +36,7 @@ if (! $user->admin) accessforbidden(); $action = GETPOST('action','alpha'); $value = GETPOST('value','alpha'); $label = GETPOST('label','alpha'); -$scandir = GETPOST('scandir','alpha'); +$scandir = GETPOST('scan_dir','alpha'); $type='invoice'; if (empty($conf->global->PAYMENT_ADDON)) $conf->global->PAYMENT_ADDON = 'mod_payment_cicada.php'; @@ -188,7 +188,7 @@ foreach ($dirmodels as $reldir) } else { - print 'scandir.'&label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"),'switch_off').''; + print 'scandir.'&label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"),'switch_off').''; } print ''; diff --git a/htdocs/admin/prelevement.php b/htdocs/admin/prelevement.php index 86108be0136..f368010078b 100644 --- a/htdocs/admin/prelevement.php +++ b/htdocs/admin/prelevement.php @@ -332,7 +332,7 @@ foreach ($dirmodels as $reldir) else { print ''."\n"; - print 'scandir.'&label='.urlencode($module->name).'">'.img_picto($langs->trans("Disabled"),'switch_off').''; + print 'scandir.'&label='.urlencode($module->name).'">'.img_picto($langs->trans("Disabled"),'switch_off').''; print ""; } @@ -344,7 +344,7 @@ foreach ($dirmodels as $reldir) } else { - print 'scandir.'&label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"),'off').''; + print 'scandir.'&label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"),'off').''; } print ''; diff --git a/htdocs/admin/propal.php b/htdocs/admin/propal.php index 2f90145f3cc..b3434d0bd7a 100644 --- a/htdocs/admin/propal.php +++ b/htdocs/admin/propal.php @@ -43,7 +43,7 @@ if (! $user->admin) accessforbidden(); $action = GETPOST('action','alpha'); $value = GETPOST('value','alpha'); $label = GETPOST('label','alpha'); -$scandir = GETPOST('scandir','alpha'); +$scandir = GETPOST('scan_dir','alpha'); $type='propal'; /* @@ -443,7 +443,7 @@ foreach ($dirmodels as $reldir) else { print "\n"; - print 'scandir.'&label='.urlencode($module->name).'">'.img_picto($langs->trans("Disabled"),'switch_off').''; + print 'scandir.'&label='.urlencode($module->name).'">'.img_picto($langs->trans("Disabled"),'switch_off').''; print ""; } @@ -455,7 +455,7 @@ foreach ($dirmodels as $reldir) } else { - print 'scandir.'&label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"),'off').''; + print 'scandir.'&label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"),'off').''; } print ''; diff --git a/htdocs/admin/security_file.php b/htdocs/admin/security_file.php index 8c1b1fa5b07..66e31f0c7c1 100644 --- a/htdocs/admin/security_file.php +++ b/htdocs/admin/security_file.php @@ -1,5 +1,5 @@ +/* Copyright (C) 2004-2017 Laurent Destailleur * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2013 Juanjo Menent * @@ -103,6 +103,7 @@ else if ($action == 'delete') exit; } + /* * View */ diff --git a/htdocs/admin/supplier_invoice.php b/htdocs/admin/supplier_invoice.php index 6d65af336b9..d3ea8b9a63e 100644 --- a/htdocs/admin/supplier_invoice.php +++ b/htdocs/admin/supplier_invoice.php @@ -44,7 +44,7 @@ accessforbidden(); $type=GETPOST('type', 'alpha'); $value=GETPOST('value', 'alpha'); $action=GETPOST('action', 'alpha'); -$scandir = GETPOST('scandir','alpha'); +$scandir = GETPOST('scan_dir','alpha'); $specimenthirdparty=new Societe($db); $specimenthirdparty->initAsSpecimen(); @@ -398,7 +398,7 @@ foreach ($dirmodels as $reldir) //if ($conf->global->INVOICE_SUPPLIER_ADDON_PDF != "$name") //{ // Even if choice is the default value, we allow to disable it: For supplier invoice, we accept to have no doc generation at all - print 'scandir.'&label='.urlencode($module->name).'&type=invoice_supplier">'; + print 'scandir.'&label='.urlencode($module->name).'&type=invoice_supplier">'; print img_picto($langs->trans("Enabled"),'switch_on'); print ''; /*} @@ -411,7 +411,7 @@ foreach ($dirmodels as $reldir) else { print ''."\n"; - print 'scandir.'&label='.urlencode($module->name).'&type=invoice_supplier">'.img_picto($langs->trans("Disabled"),'switch_off').''; + print 'scandir.'&label='.urlencode($module->name).'&type=invoice_supplier">'.img_picto($langs->trans("Disabled"),'switch_off').''; print ""; } @@ -421,11 +421,11 @@ foreach ($dirmodels as $reldir) { //print img_picto($langs->trans("Default"),'on'); // Even if choice is the default value, we allow to disable it: For supplier invoice, we accept to have no doc generation at all - print 'scandir.'&label='.urlencode($module->name).'&type=invoice_supplier"" alt="'.$langs->trans("Disable").'">'.img_picto($langs->trans("Enabled"),'on').''; + print 'scandir.'&label='.urlencode($module->name).'&type=invoice_supplier"" alt="'.$langs->trans("Disable").'">'.img_picto($langs->trans("Enabled"),'on').''; } else { - print 'scandir.'&label='.urlencode($module->name).'&type=invoice_supplier"" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"),'off').''; + print 'scandir.'&label='.urlencode($module->name).'&type=invoice_supplier"" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"),'off').''; } print ''; diff --git a/htdocs/admin/supplier_order.php b/htdocs/admin/supplier_order.php index 21b3de68835..6b99bb1c39c 100644 --- a/htdocs/admin/supplier_order.php +++ b/htdocs/admin/supplier_order.php @@ -45,7 +45,7 @@ $type=GETPOST('type', 'alpha'); $value=GETPOST('value', 'alpha'); $label = GETPOST('label','alpha'); $action=GETPOST('action', 'alpha'); -$scandir = GETPOST('scandir','alpha'); +$scandir = GETPOST('scan_dir','alpha'); $specimenthirdparty=new Societe($db); $specimenthirdparty->initAsSpecimen(); @@ -420,7 +420,7 @@ foreach ($dirmodels as $reldir) print ''."\n"; if ($conf->global->COMMANDE_SUPPLIER_ADDON_PDF != "$name") { - print 'scandir.'&label='.urlencode($module->name).'&type=order_supplier">'; + print 'scandir.'&label='.urlencode($module->name).'&type=order_supplier">'; print img_picto($langs->trans("Enabled"),'switch_on'); print ''; } @@ -433,7 +433,7 @@ foreach ($dirmodels as $reldir) else { print ''."\n"; - print 'scandir.'&label='.urlencode($module->name).'&type=order_supplier">'.img_picto($langs->trans("Disabled"),'switch_off').''; + print 'scandir.'&label='.urlencode($module->name).'&type=order_supplier">'.img_picto($langs->trans("Disabled"),'switch_off').''; print ""; } @@ -445,7 +445,7 @@ foreach ($dirmodels as $reldir) } else { - print 'scandir.'&label='.urlencode($module->name).'&type=order_supplier"" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"),'off').''; + print 'scandir.'&label='.urlencode($module->name).'&type=order_supplier"" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"),'off').''; } print ''; diff --git a/htdocs/admin/supplier_payment.php b/htdocs/admin/supplier_payment.php index 4227f4d4221..c83b60cab63 100644 --- a/htdocs/admin/supplier_payment.php +++ b/htdocs/admin/supplier_payment.php @@ -39,7 +39,7 @@ if (! $user->admin) accessforbidden(); $action = GETPOST('action','alpha'); $value = GETPOST('value','alpha'); $label = GETPOST('label','alpha'); -$scandir = GETPOST('scandir','alpha'); +$scandir = GETPOST('scan_dir','alpha'); $type='supplier_payment'; @@ -274,7 +274,7 @@ foreach ($dirmodels as $reldir) } else { - print 'scandir.'&label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"),'switch_off').''; + print 'scandir.'&label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"),'switch_off').''; } print ''; diff --git a/htdocs/admin/supplier_proposal.php b/htdocs/admin/supplier_proposal.php index 4e7efa4d922..44d8b2f3627 100644 --- a/htdocs/admin/supplier_proposal.php +++ b/htdocs/admin/supplier_proposal.php @@ -38,7 +38,7 @@ if (! $user->admin) accessforbidden(); $action = GETPOST('action','alpha'); $value = GETPOST('value','alpha'); $label = GETPOST('label','alpha'); -$scandir = GETPOST('scandir','alpha'); +$scandir = GETPOST('scan_dir','alpha'); $type='supplier_proposal'; $error=0; @@ -423,7 +423,7 @@ foreach ($dirmodels as $reldir) else { print "\n"; - print 'scandir.'&label='.urlencode($module->name).'">'.img_picto($langs->trans("Disabled"),'switch_off').''; + print 'scandir.'&label='.urlencode($module->name).'">'.img_picto($langs->trans("Disabled"),'switch_off').''; print ""; } @@ -435,7 +435,7 @@ foreach ($dirmodels as $reldir) } else { - print 'scandir.'&label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"),'off').''; + print 'scandir.'&label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"),'off').''; } print ''; diff --git a/htdocs/admin/websites.php b/htdocs/admin/websites.php index e25878b3aaa..4f829db31df 100644 --- a/htdocs/admin/websites.php +++ b/htdocs/admin/websites.php @@ -133,7 +133,7 @@ if (GETPOST('actionadd','alpha') || GETPOST('actionmodify','alpha')) $fieldnamekey=$listfield[$f]; setEventMessages($langs->transnoentities("ErrorFieldRequired", $langs->transnoentities($fieldnamekey)), null, 'errors'); } - if ($value == 'ref' && ! preg_match('/^[a-z0-9]+$/i', $_POST[$value])) + if ($value == 'ref' && ! preg_match('/^[a-z0-9_\-\.]+$/i', $_POST[$value])) { $ok=0; $fieldnamekey=$listfield[$f]; @@ -247,6 +247,8 @@ if (GETPOST('actionadd','alpha') || GETPOST('actionmodify','alpha')) if ($tabrowid[$id]) { $rowidcol=$tabrowid[$id]; } else { $rowidcol="rowid"; } + $db->begin(); + $website=new Website($db); $rowid=GETPOST('rowid','int'); $website->fetch($rowid); @@ -281,14 +283,41 @@ if (GETPOST('actionadd','alpha') || GETPOST('actionmodify','alpha')) $newname = dol_sanitizeFileName(GETPOST('ref','aZ09')); if ($newname != $website->ref) { - $srcfile=DOL_DATA_ROOT.'/websites/'.$website->ref; - $destfile=DOL_DATA_ROOT.'/websites/'.$newname; - @rename($srcfile, $destfile); + $srcfile=DOL_DATA_ROOT.'/websites/'.$website->ref; + $destfile=DOL_DATA_ROOT.'/websites/'.$newname; + + if (dol_is_dir($destfile)) + { + $error++; + setEventMessages($langs->trans('ErrorDirAlreadyExists', $destfile), null, 'errors'); + } + else + { + @rename($srcfile, $destfile); + + // We must now rename $website->ref into $newname inside files + $arrayreplacement = array($website->ref.'/htmlheader.html' => $newname.'/htmlheader.html'); + $listofilestochange = dol_dir_list($destfile, 'files', 0, '\.php$'); + foreach ($listofilestochange as $key => $value) + { + dolReplaceInFile($value['fullname'], $arrayreplacement); + } + } } } else { - setEventMessages($db->error(), null, 'errors'); + $error++; + setEventMessages($db->lasterror(), null, 'errors'); + } + + if (! $error) + { + $db->commit(); + } + else + { + $db->rollback(); } } //$_GET["id"]=GETPOST('id', 'int'); // Force affichage dictionnaire en cours d'edition diff --git a/htdocs/categories/class/categorie.class.php b/htdocs/categories/class/categorie.class.php index d1b8975eaf4..538f07133c5 100644 --- a/htdocs/categories/class/categorie.class.php +++ b/htdocs/categories/class/categorie.class.php @@ -62,14 +62,15 @@ class Categorie extends CommonObject * @note This array should be remove in future, once previous constants are moved to the string value. Deprecated */ private $MAP_ID = array( - 'product' => 0, - 'supplier' => 1, - 'customer' => 2, - 'member' => 3, - 'contact' => 4, - 'account' => 5, - 'project' => 6, - 'user' => 7, + 'product' => 0, + 'supplier' => 1, + 'customer' => 2, + 'member' => 3, + 'contact' => 4, + 'bank_account' => 5, + 'project' => 6, + 'user' => 7, + 'bank_line' => 8, ); public static $MAP_ID_TO_CODE = array( 0 => 'product', @@ -77,9 +78,10 @@ class Categorie extends CommonObject 2 => 'customer', 3 => 'member', 4 => 'contact', - 5 => 'account', + 5 => 'bank_account', 6 => 'project', 7 => 'user', + 8 => 'bank_line', ); /** @@ -94,7 +96,8 @@ class Categorie extends CommonObject 'member' => 'member', 'contact' => 'socpeople', 'user' => 'user', - 'account' => 'account', + 'account' => 'account', // old for bank_account + 'bank_account' => 'account', 'project' => 'project', ); /** @@ -109,7 +112,8 @@ class Categorie extends CommonObject 'member' => 'member', 'contact' => 'contact', 'user' => 'user', - 'account' => 'account', + 'account' => 'account', // old for bank_account + 'bank_account'=> 'account', 'project' => 'project', ); /** @@ -124,7 +128,8 @@ class Categorie extends CommonObject 'member' => 'Adherent', 'contact' => 'Contact', 'user' => 'User', - 'account' => 'Account', + 'account' => 'Account', // old for bank account + 'bank_account' => 'Account', 'project' => 'Project', ); /** @@ -947,8 +952,8 @@ class Categorie extends CommonObject * fulllabel = nom avec chemin complet de la categorie * fullpath = chemin complet compose des id * - * @param string $type Type of categories ('customer', 'supplier', 'contact', 'product', 'member') or (0, 1, 2, ...). - * @param int $markafterid Removed all categories including the leaf $markafterid in category tree. + * @param string $type Type of categories ('customer', 'supplier', 'contact', 'product', 'member') or (0, 1, 2, ...). + * @param int $markafterid Removed all categories including the leaf $markafterid in category tree. * * @return array Array of categories. this->cats and this->motherof are set. */ @@ -1340,11 +1345,11 @@ class Categorie extends CommonObject * Return list of categories (object instances or labels) linked to element of id $id and type $type * Should be named getListOfCategForObject * - * @param int $id Id of element - * @param int $type Type of category ('customer', 'supplier', 'contact', 'product', 'member') or (0, 1, 2, ...) - * @param string $mode 'id'=Get array of category ids, 'object'=Get array of fetched category instances, 'label'=Get array of category - * labels, 'id'= Get array of category IDs - * @return mixed Array of category objects or < 0 if KO + * @param int $id Id of element + * @param string|int $type Type of category ('customer', 'supplier', 'contact', 'product', 'member') or (0, 1, 2, ...) + * @param string $mode 'id'=Get array of category ids, 'object'=Get array of fetched category instances, 'label'=Get array of category + * labels, 'id'= Get array of category IDs + * @return mixed Array of category objects or < 0 if KO */ function containing($id, $type, $mode='object') { @@ -1352,7 +1357,7 @@ class Categorie extends CommonObject if (is_numeric($type)) $type = Categorie::$MAP_ID_TO_CODE[$type]; - if ($type == Categorie::TYPE_BANK_LINE) // TODO Remove this with standard category code + if ($type === Categorie::TYPE_BANK_LINE) // TODO Remove this with standard category code { // Load bank groups $sql = "SELECT c.label, c.rowid"; diff --git a/htdocs/categories/index.php b/htdocs/categories/index.php index c751fad67a7..149eb160a78 100644 --- a/htdocs/categories/index.php +++ b/htdocs/categories/index.php @@ -54,7 +54,7 @@ elseif ($type == Categorie::TYPE_SUPPLIER) { $title=$langs->trans("SuppliersCat elseif ($type == Categorie::TYPE_CUSTOMER) { $title=$langs->trans("CustomersCategoriesArea"); $typetext='customer'; } elseif ($type == Categorie::TYPE_MEMBER) { $title=$langs->trans("MembersCategoriesArea"); $typetext='member'; } elseif ($type == Categorie::TYPE_CONTACT) { $title=$langs->trans("ContactsCategoriesArea"); $typetext='contact'; } -elseif ($type == Categorie::TYPE_ACCOUNT) { $title=$langs->trans("AccountsCategoriesArea"); $typetext='account'; } +elseif ($type == Categorie::TYPE_ACCOUNT) { $title=$langs->trans("AccountsCategoriesArea"); $typetext='bank_account'; } elseif ($type == Categorie::TYPE_PROJECT) { $title=$langs->trans("ProjectsCategoriesArea"); $typetext='project'; } elseif ($type == Categorie::TYPE_USER) { $title=$langs->trans("UsersCategoriesArea"); $typetext='user'; } else { $title=$langs->trans("CategoriesArea"); $typetext='unknown'; } diff --git a/htdocs/comm/action/card.php b/htdocs/comm/action/card.php index 16bb308c966..c2dbdd46ed6 100644 --- a/htdocs/comm/action/card.php +++ b/htdocs/comm/action/card.php @@ -577,6 +577,11 @@ if ($action == 'mupdate') } +// Actions to delete doc +$upload_dir = $conf->agenda->dir_output.'/'.dol_sanitizeFileName($object->ref); +$permissioncreate = ($user->rights->agenda->allactions->delete || (($object->authorid == $user->id || $object->userownerid == $user->id) && $user->rights->agenda->myactions->delete)); +include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php'; + /* * View @@ -709,7 +714,7 @@ if ($action == 'create') // Location if (empty($conf->global->AGENDA_DISABLE_LOCATION)) { - print ''.$langs->trans("Location").''; + print ''.$langs->trans("Location").''; } // Assigned to @@ -965,7 +970,7 @@ if ($id > 0) } // Title - print 'global->AGENDA_USE_EVENT_TYPE)?' class="fieldrequired"':'').'>'.$langs->trans("Title").''; + print 'global->AGENDA_USE_EVENT_TYPE)?' class="fieldrequired"':'').'>'.$langs->trans("Title").''; // Full day event print ''.$langs->trans("EventOnFullDay").'fulldayevent?' checked':'').'>'; @@ -1049,7 +1054,7 @@ if ($id > 0) // Location if (empty($conf->global->AGENDA_DISABLE_LOCATION)) { - print ''.$langs->trans("Location").''; + print ''.$langs->trans("Location").''; } // Assigned to @@ -1212,7 +1217,6 @@ if ($id > 0) $out.=''.$langs->trans("ViewDay").''; $linkback.=$out; - $morehtmlref='
    '; // Thirdparty //$morehtmlref.='
    '.$langs->trans('ThirdParty') . ' : ' . $object->thirdparty->getNomUrl(1); @@ -1477,7 +1481,7 @@ if ($id > 0) */ $filedir=$conf->agenda->multidir_output[$conf->entity].'/'.$object->id; - $urlsource=$_SERVER["PHP_SELF"]."?socid=".$object->id; + $urlsource=$_SERVER["PHP_SELF"]."?id=".$object->id; $genallowed=$user->rights->agenda->myactions->create; $delallowed=$user->rights->agenda->myactions->delete; diff --git a/htdocs/comm/action/class/actioncomm.class.php b/htdocs/comm/action/class/actioncomm.class.php index f6d6b4a0975..704f307283e 100644 --- a/htdocs/comm/action/class/actioncomm.class.php +++ b/htdocs/comm/action/class/actioncomm.class.php @@ -1509,9 +1509,19 @@ class ActionComm extends CommonObject { global $conf, $langs; + $this->output = ''; + $this->error=''; + + if (empty($conf->global->AGENDA_REMINDER_EMAIL)) + { + $this->output = $langs->trans('EventRemindersByEmailNotEnabled', $langs->transnoentitiesnoconv("Agenda")); + return 0; + } + dol_syslog(__METHOD__, LOG_DEBUG); + return 0; } diff --git a/htdocs/comm/mailing/cibles.php b/htdocs/comm/mailing/cibles.php index a2743246560..9669d8c0ff3 100644 --- a/htdocs/comm/mailing/cibles.php +++ b/htdocs/comm/mailing/cibles.php @@ -56,6 +56,7 @@ $action=GETPOST('action','aZ09'); $search_lastname=GETPOST("search_lastname"); $search_firstname=GETPOST("search_firstname"); $search_email=GETPOST("search_email"); +$search_other=GETPOST("search_other"); $search_dest_status=GETPOST('search_dest_status'); // Search modules dirs @@ -90,8 +91,7 @@ if ($action == 'add') { require_once $file; - // We fill $filtersarray. Using this variable is now deprecated. - // Kept for backward compatibility. + // We fill $filtersarray. Using this variable is now deprecated. Kept for backward compatibility. $filtersarray=array(); if (isset($_POST["filter"])) $filtersarray[0]=$_POST["filter"]; @@ -156,11 +156,13 @@ if ($action == 'delete') } } -if ($_POST["button_removefilter"]) +// Purge search criteria +if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x','alpha') ||GETPOST('button_removefilter','alpha')) // All tests are required to be compatible with all browsers { $search_lastname=''; $search_firstname=''; $search_email=''; + $search_other=''; $search_dest_status=''; } @@ -303,12 +305,10 @@ if ($object->fetch($id) >= 0) if ($qualified) { $var = !$var; - //print ''; -// print '
    '; if ($allowaddtarget) { - print '
    '; + print ''; print ''; } else @@ -316,13 +316,11 @@ if ($object->fetch($id) >= 0) print '
    '; } - //print ''; print '
    '; if (empty($obj->picto)) $obj->picto='generic'; - print img_object($langs->trans("Module").': '.get_class($obj),$obj->picto); + print img_object($langs->trans("EmailingTargetSelector").': '.get_class($obj),$obj->picto); print ' '; print $obj->getDesc(); - //print ''; print '
    '; try { @@ -333,7 +331,6 @@ if ($object->fetch($id) >= 0) dol_syslog($e->getMessage(), LOG_ERR); } - //print ''; print '
    '; if ($nbofrecipient >= 0) { @@ -343,10 +340,8 @@ if ($object->fetch($id) >= 0) { print $langs->trans("Error").' '.img_error($obj->error); } - //print ''; print '
    '; - //print ''; print '
    '; if ($allowaddtarget) { @@ -360,10 +355,8 @@ if ($object->fetch($id) >= 0) if ($filter) print $filter; else print $langs->trans("None"); } - //print ''; print '
    '; - //print ''; print '
    '; if ($allowaddtarget) { @@ -375,19 +368,14 @@ if ($object->fetch($id) >= 0) //print $langs->trans("MailNoChangePossible"); print " "; } - //print ''; print '
    '; if ($allowaddtarget) print ''; else print '
    '; - - //print "\n"; -// print '
    '."\n"; } } } // End foreach dir - //print ''; print '
    '; print '

    '; @@ -397,9 +385,10 @@ if ($object->fetch($id) >= 0) $sql = "SELECT mc.rowid, mc.lastname, mc.firstname, mc.email, mc.other, mc.statut, mc.date_envoi, mc.source_url, mc.source_id, mc.source_type, mc.error_text"; $sql .= " FROM ".MAIN_DB_PREFIX."mailing_cibles as mc"; $sql .= " WHERE mc.fk_mailing=".$object->id; - if ($search_lastname) $sql.= " AND mc.lastname LIKE '%".$db->escape($search_lastname)."%'"; - if ($search_firstname) $sql.= " AND mc.firstname LIKE '%".$db->escape($search_firstname)."%'"; - if ($search_email) $sql.= " AND mc.email LIKE '%".$db->escape($search_email)."%'"; + if ($search_lastname) $sql.= natural_search("mc.lastname", $search_lastname); + if ($search_firstname) $sql.= natural_search("mc.firstname", $search_firstname); + if ($search_email) $sql.= natural_search("mc.email", $search_email); + if ($search_other) $sql.= natural_search("mc.other", $search_other); if ($search_dest_status != '' && $search_dest_status >= -1) $sql.= " AND mc.statut=".$db->escape($search_dest_status)." "; $sql .= $db->order($sortfield,$sortorder); @@ -423,6 +412,7 @@ if ($object->fetch($id) >= 0) if ($search_lastname) $param.= "&search_lastname=".urlencode($search_lastname); if ($search_firstname) $param.= "&search_firstname=".urlencode($search_firstname); if ($search_email) $param.= "&search_email=".urlencode($search_email); + if ($search_other) $param.= "&search_other=".urlencode($search_other); print '
    '; print ''; @@ -469,7 +459,7 @@ if ($object->fetch($id) >= 0) print ''; // Other print ''; - print ' '; + print ''; print ''; // Source print ''; diff --git a/htdocs/compta/bank/bankentries.php b/htdocs/compta/bank/bankentries.php index 39542bf12c8..f7a33741d02 100644 --- a/htdocs/compta/bank/bankentries.php +++ b/htdocs/compta/bank/bankentries.php @@ -605,7 +605,7 @@ if ($resql) // print ''; print '
    '; print ''.$langs->trans("InputReceiptNumber").': '; - print ''; // The only default value is value we just entered + print ''; // The only default value is value we just entered print '
    '; if ($options) { print $langs->trans("EventualyAddCategory").': '; @@ -649,6 +649,16 @@ if ($resql) { dol_print_error($db); } + /** + * Using BANK_REPORT_LAST_NUM_RELEVE to automatically report last num (or not) + */ + if ($conf->global->BANK_REPORT_LAST_NUM_RELEVE == 1) { + print ' + + '; + } print '

    '; // print ''; } @@ -1117,7 +1127,16 @@ if ($resql) // Date ope if (! empty($arrayfields['b.dateo']['checked'])) { - print ''.dol_print_date($db->jdate($objp->do),"day")."\n"; + print ''; + print ''.dol_print_date($db->jdate($objp->do),"day").""; + print ' '; + print ''; + print ''; + print img_edit_remove() . " "; + print ''; + print img_edit_add() .""; + print ''; + print "\n"; if (! $i) $totalarray['nbfield']++; } diff --git a/htdocs/compta/bank/card.php b/htdocs/compta/bank/card.php index 1f55698d13f..7c94e03e339 100644 --- a/htdocs/compta/bank/card.php +++ b/htdocs/compta/bank/card.php @@ -560,11 +560,7 @@ else $_GET["id"]=$object->id; } - /* - * Affichage onglets - */ - - // Onglets + // Show tabs $head=bank_prepare_head($object); dol_fiche_head($head, 'bankname', $langs->trans("FinancialAccount"), -1, 'account'); @@ -592,18 +588,6 @@ else print ''; - - // Ref - /* - print ''; - print '';*/ - - // Label - /*print ''; - print '';*/ - // Type print ''; print ''; @@ -616,26 +600,6 @@ else print $langs->trans("Currency".$selectedcode); print ''; - // Status - /*print ''; - print '';*/ - - // Country - /* - print ''; - - // State - print '';*/ - // Conciliate print ''; print '"; } diff --git a/htdocs/compta/bank/class/account.class.php b/htdocs/compta/bank/class/account.class.php index 08631abec79..47c3e5122ff 100644 --- a/htdocs/compta/bank/class/account.class.php +++ b/htdocs/compta/bank/class/account.class.php @@ -1959,6 +1959,67 @@ class AccountLine extends CommonObject } + /** + * Increase/decrease operation date of a rowid + * + * @param int $rowid Id of line + * @param int $sign 1 or -1 + * @return int >0 if OK, 0 if KO + */ + function dateo_change($rowid,$sign=1) + { + $sql = "SELECT dateo FROM ".MAIN_DB_PREFIX."bank WHERE rowid = ".$rowid; + $resql = $this->db->query($sql); + if ($resql) + { + $obj=$this->db->fetch_object($resql); + $newdate=$this->db->jdate($obj->dateo)+(3600*24*$sign); + + $sql = "UPDATE ".MAIN_DB_PREFIX."bank SET"; + $sql.= " dateo = '".$this->db->idate($newdate)."'"; + $sql.= " WHERE rowid = ".$rowid; + + $result = $this->db->query($sql); + if ($result) + { + if ($this->db->affected_rows($result)) + { + return 1; + } + } + else + { + dol_print_error($this->db); + return 0; + } + } + else dol_print_error($this->db); + return 0; + } + + /** + * Increase operation date of a rowid + * + * @param int $id Id of line to change + * @return int >0 if OK, 0 if KO + */ + function dateo_next($id) + { + return $this->dateo_change($id,1); + } + + /** + * Decrease operation date of a rowid + * + * @param int $id Id of line to change + * @return int >0 if OK, 0 if KO + */ + function dateo_previous($id) + { + return $this->dateo_change($id,-1); + } + + /** * Load miscellaneous information for tab "Info" * diff --git a/htdocs/compta/bank/document.php b/htdocs/compta/bank/document.php index 084cddf51cd..40f06895792 100644 --- a/htdocs/compta/bank/document.php +++ b/htdocs/compta/bank/document.php @@ -3,7 +3,7 @@ /* Copyright (C) 2003-2007 Rodolphe Quiedeville * Copyright (C) 2004-2008 Laurent Destailleur * Copyright (C) 2005 Marc Barilley / Ocebo - * Copyright (C) 2005-2011 Regis Houssin + * Copyright (C) 2005-2017 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 @@ -62,9 +62,7 @@ $result = restrictedArea($user, 'banque', $fieldvalue, 'bank_account', '', '', $sortfield = GETPOST("sortfield", 'alpha'); $sortorder = GETPOST("sortorder", 'alpha'); $page = GETPOST("page", 'int'); -if ($page == -1) { - $page = 0; -} +if (empty($page) || $page == -1) { $page = 0; } $offset = $conf->liste_limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; @@ -122,21 +120,21 @@ if ($id > 0 || !empty($ref)) { $linkback = ''.$langs->trans("BackToList").''; dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref); - - + + print '
    '; print '
    '; - + print '
    '.$langs->trans("Ref").''; - print $form->showrefnav($object, 'ref', $linkback, 1, 'ref'); - print '
    '.$langs->trans("Label").''.$object->label.'
    '.$langs->trans("AccountType").''.$object->type_lib[$object->type].'
    '.$langs->trans("Status").''.$object->getLibStatut(4).'
    '.$langs->trans("BankAccountCountry").''; - if ($object->country_id > 0) - { - $img=picto_from_langcode($object->country_code); - print $img?$img.' ':''; - print getCountry($object->getCountryCode(),0,$db); - } - print '
    '.$langs->trans('State').''; - if ($object->state_id > 0) print getState($object->state_id); - print '
    '.$langs->trans("Conciliable").''; @@ -694,7 +658,7 @@ else // Categories if ($conf->categorie->enabled) { print '
    '.$langs->trans("Categories").''; - print $form->showCategories($object->id,'account',1); + print $form->showCategories($object->id,'bank_account',1); print "
    '; print ''; print ''; print "
    ' . $langs->trans("NbOfAttachedFiles") . '' . count($filearray) . '
    ' . $langs->trans("TotalSizeOfAttachedFiles") . '' . $totalsize . ' ' . $langs->trans("bytes") . '
    \n"; print ''; - + dol_fiche_end(); - + $modulepart = 'bank'; $permission = $user->rights->banque->modifier; $permtoedit = $user->rights->banque->modifier; diff --git a/htdocs/compta/bank/index.php b/htdocs/compta/bank/index.php index 7d5046d18c9..9e5ddf8008a 100644 --- a/htdocs/compta/bank/index.php +++ b/htdocs/compta/bank/index.php @@ -492,21 +492,36 @@ foreach ($accounts as $key=>$type) // Account number if (! empty($arrayfields['b.account_number']['checked'])) { - $accountingaccount = new AccountingAccount($db); - $accountingaccount->fetch('',$acc->account_number); - - print ''.$accountingaccount->getNomUrl(0,1,1,'',1).''; - + print ''; + if (! empty($conf->accounting->enabled)) + { + $accountingaccount = new AccountingAccount($db); + $accountingaccount->fetch('',$acc->account_number); + print $accountingaccount->getNomUrl(0,1,1,'',1); + } + else + { + print $acc->account_number; + } + print ''; if (! $i) $totalarray['nbfield']++; } // Accountancy journal if (! empty($arrayfields['b.fk_accountancy_journal']['checked'])) { - $accountingjournal = new AccountingJournal($db); - $accountingjournal->fetch($acc->fk_accountancy_journal); - - print ''.$accountingjournal->getNomUrl(0,1,1,'',1).''; + print ''; + if (! empty($conf->accounting->enabled)) + { + $accountingjournal = new AccountingJournal($db); + $accountingjournal->fetch('',$acc->fk_accountancy_journal); + print $accountingjournal->getNomUrl(0,1,1,'',1); + } + else + { + print ''; + } + print ''; if (! $i) $totalarray['nbfield']++; } diff --git a/htdocs/compta/bank/ligne.php b/htdocs/compta/bank/ligne.php index 99362167a07..525b7a72e12 100644 --- a/htdocs/compta/bank/ligne.php +++ b/htdocs/compta/bank/ligne.php @@ -71,13 +71,20 @@ if ($cancel) } } -if ($user->rights->banque->consolidate && $action == 'dvnext') + +if ($user->rights->banque->consolidate && $action == 'donext') +{ + $al = new AccountLine($db); + $al->dateo_next($_GET["rowid"]); +}elseif ($user->rights->banque->consolidate && $action == 'doprev') +{ + $al = new AccountLine($db); + $al->dateo_previous($_GET["rowid"]); +}elseif ($user->rights->banque->consolidate && $action == 'dvnext') { $al = new AccountLine($db); $al->datev_next($_GET["rowid"]); -} - -if ($user->rights->banque->consolidate && $action == 'dvprev') +}elseif ($user->rights->banque->consolidate && $action == 'dvprev') { $al = new AccountLine($db); $al->datev_previous($_GET["rowid"]); @@ -479,6 +486,14 @@ if ($result) { print ''; print $form->select_date($db->jdate($objp->do),'dateo','','','','update',1,0,1,$objp->rappro); + if (! $objp->rappro) + { + print '   '; + print ''; + print img_edit_remove() . " "; + print ''; + print img_edit_add() .""; + } print ''; } else diff --git a/htdocs/compta/bank/transfer.php b/htdocs/compta/bank/transfer.php index 0d9a9a94aea..1f3ca1cde8e 100644 --- a/htdocs/compta/bank/transfer.php +++ b/htdocs/compta/bank/transfer.php @@ -55,7 +55,7 @@ if ($action == 'add_confirm') if (! $label) { - + $error++; setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Description")), null, 'errors'); } if (! $amount) diff --git a/htdocs/compta/facture/admin/facture_rec_cust_extrafields.php b/htdocs/compta/facture/admin/facture_rec_cust_extrafields.php new file mode 100644 index 00000000000..1bc9272a32f --- /dev/null +++ b/htdocs/compta/facture/admin/facture_rec_cust_extrafields.php @@ -0,0 +1,121 @@ + +* Copyright (C) 2003 Jean-Louis Bergamo +* Copyright (C) 2004-2011 Laurent Destailleur +* Copyright (C) 2012 Regis Houssin +* Copyright (C) 2013 Jean-Francois FERRY +* Copyright (C) 2017 John BOTELLA +* +* 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 +* the Free Software Foundation; either version 3 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program. If not, see . +*/ + +/** +* \file htdocs/compta/facture/admin/facture_cust_extrafields.php +* \ingroup invoice +* \brief Page to setup extra fields of customer invoice +*/ + +require '../../../main.inc.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/invoice.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; + +$langs->load("companies"); +$langs->load("admin"); +$langs->load("bills"); + +$extrafields = new ExtraFields($db); +$form = new Form($db); + +// List of supported format +$tmptype2label=ExtraFields::$type2label; +$type2label=array(''); +foreach ($tmptype2label as $key => $val) $type2label[$key]=$langs->trans($val); + +$action=GETPOST('action', 'alpha'); +$attrname=GETPOST('attrname', 'alpha'); +$elementtype='facture_rec'; //Must be the $table_element of the class that manage extrafield + +if (!$user->admin) accessforbidden(); + + +/* +* Actions +*/ + +require DOL_DOCUMENT_ROOT.'/core/actions_extrafields.inc.php'; + + + +/* +* View +*/ + +$textobject=strtolower($langs->transnoentitiesnoconv("BillsCustomers")); + +llxHeader('',$langs->trans("BillsSetup")); + +$linkback=''.$langs->trans("BackToModuleList").''; + +print load_fiche_titre($langs->trans("BillsSetup"),$linkback,'title_setup'); + +$head = invoice_admin_prepare_head(); + +dol_fiche_head($head, 'attributesrec', $langs->trans("Invoices"), -1, 'invoice'); + +require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_view.tpl.php'; + +dol_fiche_end(); + + +// Buttons +if ($action != 'create' && $action != 'edit') +{ + print '
    '; + print "".$langs->trans("NewAttribute").""; + print "
    "; +} + + +/* ************************************************************************** */ +/* */ +/* Creation of an optional field */ +/* */ +/* ************************************************************************** */ + +if ($action == 'create') +{ + print "
    "; + print load_fiche_titre($langs->trans('NewAttribute')); + + require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_add.tpl.php'; +} + +/* ************************************************************************** */ +/* */ +/* Edition of an optional field */ +/* */ +/* ************************************************************************** */ +if ($action == 'edit' && ! empty($attrname)) +{ + $langs->load("members"); + + print "
    "; + print load_fiche_titre($langs->trans("FieldEdition", $attrname)); + + require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_edit.tpl.php'; +} + +llxFooter(); + +$db->close(); diff --git a/htdocs/compta/facture/admin/facturedet_rec_cust_extrafields.php b/htdocs/compta/facture/admin/facturedet_rec_cust_extrafields.php new file mode 100644 index 00000000000..8c2a0b3365a --- /dev/null +++ b/htdocs/compta/facture/admin/facturedet_rec_cust_extrafields.php @@ -0,0 +1,119 @@ + +* Copyright (C) 2003 Jean-Louis Bergamo +* Copyright (C) 2004-2011 Laurent Destailleur +* Copyright (C) 2012 Regis Houssin +* Copyright (C) 2013 Jean-Francois FERRY +* Copyright (C) 2013 Florian Henry +* +* 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 +* the Free Software Foundation; either version 3 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program. If not, see . +*/ + +/** +* \file htdocs/compta/facture/admin/facture_cust_extrafields.php +* \ingroup invoice +* \brief Page to setup extra fields of customer invoice +*/ + +require '../../../main.inc.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/invoice.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; + +$langs->load("companies"); +$langs->load("admin"); +$langs->load("bills"); + +$extrafields = new ExtraFields($db); +$form = new Form($db); + +// List of supported format +$tmptype2label=ExtraFields::$type2label; +$type2label=array(''); +foreach ($tmptype2label as $key => $val) $type2label[$key]=$langs->trans($val); + +$action=GETPOST('action', 'alpha'); +$attrname=GETPOST('attrname', 'alpha'); +$elementtype='facturedet_rec'; //Must be the $table_element of the class that manage extrafield + +if (!$user->admin) accessforbidden(); + + +/* +* Actions +*/ + +require DOL_DOCUMENT_ROOT.'/core/actions_extrafields.inc.php'; + + + +/* +* View +*/ + +$textobject=strtolower($langs->transnoentitiesnoconv("BillsCustomers")); + +llxHeader('',$langs->trans("BillsSetup")); + +$linkback=''.$langs->trans("BackToModuleList").''; + +print load_fiche_titre($langs->trans("BillsSetup"),$linkback,'title_setup'); + +$head = invoice_admin_prepare_head(); + +dol_fiche_head($head, 'attributeslinesrec', $langs->trans("Invoices"), -1, 'invoice'); + +require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_view.tpl.php'; + +dol_fiche_end(); + + +// Buttons +if ($action != 'create' && $action != 'edit') +{ + print '
    '; + print "".$langs->trans("NewAttribute").""; + print "
    "; +} + + +/* ************************************************************************** */ +/* */ +/* Creation d'un champ optionnel +/* */ +/* ************************************************************************** */ + +if ($action == 'create') +{ + print "
    "; + print load_fiche_titre($langs->trans('NewAttribute')); + + require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_add.tpl.php'; +} + +/* ************************************************************************** */ +/* */ +/* Edition d'un champ optionnel */ +/* */ +/* ************************************************************************** */ +if ($action == 'edit' && ! empty($attrname)) +{ + print "
    "; + print load_fiche_titre($langs->trans("FieldEdition", $attrname)); + + require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_edit.tpl.php'; +} + +llxFooter(); + +$db->close(); diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index e10544f3c18..731b8aafec6 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -664,12 +664,13 @@ if (empty($reshook)) if ($object->type == Facture::TYPE_STANDARD || $object->type == Facture::TYPE_REPLACEMENT || $object->type == Facture::TYPE_SITUATION) { // If we're on a standard invoice, we have to get excess received to create a discount in TTC without VAT - $sql = 'SELECT SUM(pf.amount) as total_paiements FROM llx_c_paiement as c, llx_paiement_facture as pf, llx_paiement as p - WHERE pf.fk_facture = '.$object->id.' AND p.fk_paiement = c.id AND pf.fk_paiement = p.rowid ORDER BY p.datep, p.tms'; + WHERE pf.fk_facture = '.$object->id.' AND p.fk_paiement = c.id AND pf.fk_paiement = p.rowid'; $resql = $db->query($sql); + if (! $resql) dol_print_error($db); + $res = $db->fetch_object($resql); $total_paiements = $res->total_paiements; @@ -4128,11 +4129,11 @@ else if ($id > 0 || ! empty($ref)) if ($objectidnext) { print '
    ' . $langs->trans('DoPayment') . '
    '; } else { - if ($resteapayer == 0) { - print '
    ' . $langs->trans('DoPayment') . '
    '; - } else { + //if ($resteapayer == 0) { + // print '
    ' . $langs->trans('DoPayment') . '
    '; + //} else { print ''; - } + //} } } diff --git a/htdocs/compta/facture/class/facture-rec.class.php b/htdocs/compta/facture/class/facture-rec.class.php index 52fb375000c..967fdc908bc 100644 --- a/htdocs/compta/facture/class/facture-rec.class.php +++ b/htdocs/compta/facture/class/facture-rec.class.php @@ -43,7 +43,7 @@ class FactureRec extends CommonInvoice public $table_element_line='facturedet_rec'; public $fk_element='fk_facture'; public $picto='bill'; - + var $entity; var $number; var $date; @@ -58,7 +58,7 @@ class FactureRec extends CommonInvoice var $date_when; var $nb_gen_done; var $nb_gen_max; - + var $rang; var $special_code; @@ -91,20 +91,20 @@ class FactureRec extends CommonInvoice // Clean parameters $this->titre=trim($this->titre); $this->usenewprice=empty($this->usenewprice)?0:$this->usenewprice; - + // No frequency defined then no next date to execution - if (empty($this->frequency)) + if (empty($this->frequency)) { $this->frequency=0; $this->date_when=NULL; } - - + + $this->frequency=abs($this->frequency); $this->nb_gen_done=0; $this->nb_gen_max=empty($this->nb_gen_max)?0:$this->nb_gen_max; $this->auto_validate=empty($this->auto_validate)?0:$this->auto_validate; - + $this->db->begin(); // Charge facture modele @@ -197,7 +197,7 @@ class FactureRec extends CommonInvoice $error++; } } - + // Add object linked if (! $error && $this->id && is_array($this->linked_objects) && ! empty($this->linked_objects)) { @@ -210,7 +210,7 @@ class FactureRec extends CommonInvoice $error++; } } - } + } if ($error) { @@ -268,7 +268,7 @@ class FactureRec extends CommonInvoice if ($ref_ext) $sql.= " AND f.ref_ext='".$this->db->escape($ref_ext)."'"; if ($ref_int) $sql.= " AND f.ref_int='".$this->db->escape($ref_int)."'"; */ - + $result = $this->db->query($sql); if ($result) { @@ -326,6 +326,14 @@ class FactureRec extends CommonInvoice if ($this->statut == self::STATUS_DRAFT) $this->brouillon = 1; + + // Retreive all extrafield for thirdparty + // fetch optionals attributes and labels + require_once(DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'); + $extrafields=new ExtraFields($this->db); + $extralabels=$extrafields->fetch_name_optionals_label($this->table_element,true); + $this->fetch_optionals($this->id,$extralabels); + /* * Lines */ @@ -361,8 +369,8 @@ class FactureRec extends CommonInvoice { return $this->fetch_lines(); } - - + + /** * Recupere les lignes de factures predefinies dans this->lines * @@ -386,7 +394,7 @@ class FactureRec extends CommonInvoice $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON l.fk_product = p.rowid'; $sql.= ' WHERE l.fk_facture = '.$this->id; $sql.= ' ORDER BY l.rang'; - + dol_syslog('FactureRec::fetch_lines', LOG_DEBUG); $result = $this->db->query($sql); if ($result) @@ -396,7 +404,7 @@ class FactureRec extends CommonInvoice while ($i < $num) { $objp = $this->db->fetch_object($result); - $line = new FactureLigne($this->db); + $line = new FactureLigneRec($this->db); $line->id = $objp->rowid; $line->rowid = $objp->rowid; @@ -431,11 +439,20 @@ class FactureRec extends CommonInvoice $line->special_code = $objp->special_code; $line->fk_unit = $objp->fk_unit; $line->fk_contract_line = $objp->fk_contract_line; - + // Ne plus utiliser $line->price = $objp->price; $line->remise = $objp->remise; + + // Retreive all extrafield for thirdparty + // fetch optionals attributes and labels + require_once(DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'); + $extrafieldsline=new ExtraFields($line->db); + $extrafieldsline=$extrafieldsline->fetch_name_optionals_label($line->table_element,true); + $extralabelsline = $line->fetch_optionals($line->id,$extrafieldsline); + + $this->lines[$i] = $line; $i++; @@ -463,12 +480,12 @@ class FactureRec extends CommonInvoice function delete($user, $notrigger=0, $idwarehouse=-1) { $rowid=$this->id; - + dol_syslog(get_class($this)."::delete rowid=".$rowid, LOG_DEBUG); - + $error=0; $this->db->begin(); - + $sql = "DELETE FROM ".MAIN_DB_PREFIX."facturedet_rec WHERE fk_facture = ".$rowid; dol_syslog($sql); if ($this->db->query($sql)) @@ -481,7 +498,7 @@ class FactureRec extends CommonInvoice $res = $this->deleteObjectLinked(); if ($res < 0) $error=-3; } - else + else { $this->error=$this->db->lasterror(); $error=-1; @@ -492,7 +509,7 @@ class FactureRec extends CommonInvoice $this->error=$this->db->lasterror(); $error=-2; } - + if (! $error) { $this->db->commit(); @@ -531,7 +548,7 @@ class FactureRec extends CommonInvoice function addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1=0, $txlocaltax2=0, $fk_product=0, $remise_percent=0, $price_base_type='HT', $info_bits=0, $fk_remise_except='', $pu_ttc=0, $type=0, $rang=-1, $special_code=0, $label='', $fk_unit=null) { global $mysoc; - + $facid=$this->id; dol_syslog(get_class($this)."::addline facid=$facid,desc=$desc,pu_ht=$pu_ht,qty=$qty,txtva=$txtva,txlocaltax1=$txlocaltax1,txlocaltax2=$txlocaltax2,fk_product=$fk_product,remise_percent=$remise_percent,info_bits=$info_bits,fk_remise_except=$fk_remise_except,price_base_type=$price_base_type,pu_ttc=$pu_ttc,type=$type,fk_unit=$fk_unit", LOG_DEBUG); @@ -584,7 +601,7 @@ class FactureRec extends CommonInvoice $total_ttc = $tabprice[2]; $total_localtax1=$tabprice[9]; $total_localtax2=$tabprice[10]; - + $product_type=$type; if ($fk_product) { @@ -647,9 +664,10 @@ class FactureRec extends CommonInvoice dol_syslog(get_class($this)."::addline", LOG_DEBUG); if ($this->db->query($sql)) { + $lineId = $this->db->last_insert_id(MAIN_DB_PREFIX."facturedet_rec"); $this->id=$facid; $this->update_price(); - return 1; + return $lineId; } else { @@ -685,12 +703,12 @@ class FactureRec extends CommonInvoice function updateline($rowid, $desc, $pu_ht, $qty, $txtva, $txlocaltax1=0, $txlocaltax2=0, $fk_product=0, $remise_percent=0, $price_base_type='HT', $info_bits=0, $fk_remise_except='', $pu_ttc=0, $type=0, $rang=-1, $special_code=0, $label='', $fk_unit=null) { global $mysoc; - + $facid=$this->id; - + dol_syslog(get_class($this)."::updateline facid=".$facid." rowid=$rowid,desc=$desc,pu_ht=$pu_ht,qty=$qty,txtva=$txtva,txlocaltax1=$txlocaltax1,txlocaltax2=$txlocaltax2,fk_product=$fk_product,remise_percent=$remise_percent,info_bits=$info_bits,fk_remise_except=$fk_remise_except,price_base_type=$price_base_type,pu_ttc=$pu_ttc,type=$type,fk_unit=$fk_unit", LOG_DEBUG); include_once DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php'; - + // Check parameters if ($type < 0) return -1; @@ -715,7 +733,7 @@ class FactureRec extends CommonInvoice $txtva=price2num($txtva); $txlocaltax1 = price2num($txlocaltax1); $txlocaltax2 = price2num($txlocaltax2); - + if ($price_base_type=='HT') { $pu=$pu_ht; @@ -724,7 +742,7 @@ class FactureRec extends CommonInvoice { $pu=$pu_ttc; } - + // Calcul du total TTC et de la TVA pour la ligne a partir de // qty, pu, remise_percent et txtva // TRES IMPORTANT: C'est au moment de l'insertion ligne qu'on doit stocker @@ -736,7 +754,7 @@ class FactureRec extends CommonInvoice $total_ttc = $tabprice[2]; $total_localtax1=$tabprice[9]; $total_localtax2=$tabprice[10]; - + $product_type=$type; if ($fk_product) { @@ -744,7 +762,7 @@ class FactureRec extends CommonInvoice $result=$product->fetch($fk_product); $product_type=$product->type; } - + $sql = "UPDATE ".MAIN_DB_PREFIX."facturedet_rec SET "; $sql.= "fk_facture = '".$facid."'"; $sql.= ", label=".(! empty($label)?"'".$this->db->escape($label)."'":"null"); @@ -784,12 +802,12 @@ class FactureRec extends CommonInvoice return -1; } } - } - - + } + + /** - * Return the next date of - * + * Return the next date of + * * @return timestamp false if KO, timestamp if OK */ function getNextDate() @@ -797,27 +815,27 @@ class FactureRec extends CommonInvoice if (empty($this->date_when)) return false; return dol_time_plus_duree($this->date_when, $this->frequency, $this->unit_frequency); } - + /** * Create all recurrents invoices (for all entities if multicompany is used). * A result may also be provided into this->output. - * - * WARNING: This method change context $conf->entity to be in correct context for each recurring invoice found. - * - * @return int 0 if OK, < 0 if KO (this function is used also by cron so only 0 is OK) + * + * WARNING: This method change context $conf->entity to be in correct context for each recurring invoice found. + * + * @return int 0 if OK, < 0 if KO (this function is used also by cron so only 0 is OK) */ function createRecurringInvoices() { global $conf, $langs, $db, $user; - + $langs->load("bills"); - + $nb_create=0; - + $now = dol_now(); $tmparray=dol_getdate($now); $today = dol_mktime(23,59,59,$tmparray['mon'],$tmparray['mday'],$tmparray['year']); // Today is last second of current day - + dol_syslog("createRecurringInvoices"); $sql = 'SELECT rowid FROM '.MAIN_DB_PREFIX.'facture_rec'; $sql.= ' WHERE frequency > 0'; // A recurring invoice is an invoice with a frequency @@ -825,30 +843,30 @@ class FactureRec extends CommonInvoice $sql.= ' AND (nb_gen_done < nb_gen_max OR nb_gen_max = 0)'; $sql.= $db->order('entity', 'ASC'); //print $sql;exit; - + $resql = $db->query($sql); if ($resql) { $i=0; $num = $db->num_rows($resql); - + if ($num) $this->output.=$langs->trans("FoundXQualifiedRecurringInvoiceTemplate", $num)."\n"; else $this->output.=$langs->trans("NoQualifiedRecurringInvoiceTemplateFound"); - + $saventity = $conf->entity; - + while ($i < $num) // Loop on each template invoice { $line = $db->fetch_object($resql); $db->begin(); - + $facturerec = new FactureRec($db); $facturerec->fetch($line->rowid); - + // Set entity context $conf->entity = $facturerec->entity; - + dol_syslog("createRecurringInvoices Process invoice template id=".$facturerec->id.", ref=".$facturerec->ref.", entity=".$facturerec->entity); $error=0; @@ -856,12 +874,12 @@ class FactureRec extends CommonInvoice $facture = new Facture($db); $facture->fac_rec = $facturerec->id; // We will create $facture from this recurring invoice $facture->fk_fac_rec_source = $facturerec->id; // We will create $facture from this recurring invoice - + $facture->type = self::TYPE_STANDARD; $facture->brouillon = 1; $facture->date = $facturerec->date_when; // We could also use dol_now here but we prefer date_when so invoice has real date when we would like even if we generate later. $facture->socid = $facturerec->socid; - + $invoiceidgenerated = $facture->create($user); if ($invoiceidgenerated <= 0) { @@ -894,16 +912,16 @@ class FactureRec extends CommonInvoice $i++; } - + $conf->entity = $saventity; // Restore entity context } else dol_print_error($db); - + $this->output=trim($this->output); - + return $error?$error:0; } - + /** * Return clicable name (with picto eventually) * @@ -920,13 +938,13 @@ class FactureRec extends CommonInvoice $result=''; $label=$langs->trans("ShowInvoice").': '.$this->ref; - + $url = DOL_URL_ROOT.'/compta/facture/fiche-rec.php?facid='.$this->id; - + if ($short) return $url; - + $picto='bill'; - + $link = ''; $linkend=''; @@ -958,7 +976,7 @@ class FactureRec extends CommonInvoice // Load array of products prodids $num_prods = 0; $prodids = array(); - + $sql = "SELECT rowid"; $sql.= " FROM ".MAIN_DB_PREFIX."product"; $sql.= " WHERE entity IN (".getEntity('product').")"; @@ -1071,7 +1089,7 @@ class FactureRec extends CommonInvoice $this->lines[$xnbp]=$line; $xnbp++; } - + $this->usenewprice = 1; } @@ -1091,7 +1109,7 @@ class FactureRec extends CommonInvoice return CommonObject::commonReplaceThirdparty($db, $origin_id, $dest_id, $tables); } - + /** * Update frequency and unit * @@ -1115,12 +1133,12 @@ class FactureRec extends CommonInvoice $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element; $sql.= ' SET frequency = '.($frequency?$this->db->escape($frequency):'null'); - if (!empty($unit)) + if (!empty($unit)) { $sql.= ', unit_frequency = \''.$this->db->escape($unit).'\''; } $sql.= ' WHERE rowid = '.$this->id; - + dol_syslog(get_class($this)."::setFrequencyAndUnit", LOG_DEBUG); if ($this->db->query($sql)) { @@ -1134,7 +1152,7 @@ class FactureRec extends CommonInvoice return -1; } } - + /** * Update the next date of execution * @@ -1167,7 +1185,7 @@ class FactureRec extends CommonInvoice return -1; } } - + /** * Update the maximum period * @@ -1181,9 +1199,9 @@ class FactureRec extends CommonInvoice dol_syslog(get_class($this)."::setMaxPeriod was called on objet with property table_element not defined",LOG_ERR); return -1; } - + if (empty($nb)) $nb=0; - + $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element; $sql.= ' SET nb_gen_max = '.$nb; $sql.= ' WHERE rowid = '.$this->id; @@ -1200,7 +1218,7 @@ class FactureRec extends CommonInvoice return -1; } } - + /** * Update the auto validate invoice * @@ -1214,7 +1232,7 @@ class FactureRec extends CommonInvoice dol_syslog(get_class($this)."::setAutoValidate was called on objet with property table_element not defined",LOG_ERR); return -1; } - + $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element; $sql.= ' SET auto_validate = '.$validate; $sql.= ' WHERE rowid = '.$this->id; @@ -1241,7 +1259,10 @@ class FactureRec extends CommonInvoice */ class FactureLigneRec extends CommonInvoiceLine { - + + public $element='facturedetrec'; + public $table_element='facturedet_rec'; + /** * Delete line in database * @@ -1250,25 +1271,24 @@ class FactureLigneRec extends CommonInvoiceLine function delete() { global $conf,$langs,$user; - + $error=0; - + $this->db->begin(); - - // Call trigger - /*$result=$this->call_trigger('LINEBILLREC_DELETE',$user); - if ($result < 0) - { - $this->db->rollback(); - return -1; - }*/ - // End call triggers - - - $sql = "DELETE FROM ".MAIN_DB_PREFIX."facturedet_rec WHERE rowid = ".($this->rowid > 0 ? $this->rowid : $this->id); + + $sql = "DELETE FROM ".MAIN_DB_PREFIX.$this->table_element." WHERE rowid = ".($this->rowid > 0 ? $this->rowid : $this->id); dol_syslog(get_class($this)."::delete", LOG_DEBUG); if ($this->db->query($sql) ) { + // Call trigger + $result=$this->call_trigger('LINEBILLREC_DELETE',$user); + if ($result < 0) + { + $this->db->rollback(); + return -1; + } + // End call triggers + $this->db->commit(); return 1; } @@ -1279,5 +1299,160 @@ class FactureLigneRec extends CommonInvoiceLine return -1; } } - + + + /** + * Recupere les lignes de factures predefinies dans this->lines + * + * @param int $rowid Id of invoice + * @return int 1 if OK, < 0 if KO + */ + function fetch($rowid) + { + $sql = 'SELECT l.rowid, l.fk_facture ,l.fk_product, l.product_type, l.label as custom_label, l.description, l.product_type, l.price, l.qty, l.vat_src_code, l.tva_tx, '; + $sql.= ' l.localtax1_tx, l.localtax2_tx, l.localtax1_type, l.localtax2_type, l.remise, l.remise_percent, l.subprice,'; + $sql.= ' l.info_bits, l.total_ht, l.total_tva, l.total_ttc,'; + $sql.= ' l.rang, l.special_code,'; + $sql.= ' l.fk_unit, l.fk_contract_line,'; + $sql.= ' p.ref as product_ref, p.fk_product_type as fk_product_type, p.label as product_label, p.description as product_desc'; + $sql.= ' FROM '.MAIN_DB_PREFIX.'facturedet_rec as l'; + $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON l.fk_product = p.rowid'; + $sql.= ' WHERE l.rowid = '.$rowid; + $sql.= ' ORDER BY l.rang'; + + dol_syslog('FactureRec::fetch', LOG_DEBUG); + $result = $this->db->query($sql); + if ($result) + { + + $objp = $this->db->fetch_object($result); + + $this->id = $objp->rowid; + $this->label = $objp->custom_label; // Label line + $this->desc = $objp->description; // Description line + $this->description = $objp->description; // Description line + $this->product_type = $objp->product_type; // Type of line + $this->ref = $objp->product_ref; // Ref product + $this->product_ref = $objp->product_ref; // Ref product + $this->libelle = $objp->product_label; // deprecated + $this->product_label = $objp->product_label; // Label product + $this->product_desc = $objp->product_desc; // Description product + $this->fk_product_type = $objp->fk_product_type; // Type of product + $this->qty = $objp->qty; + $this->price = $objp->price; + $this->subprice = $objp->subprice; + $this->fk_facture = $objp->fk_facture; + $this->vat_src_code = $objp->vat_src_code; + $this->tva_tx = $objp->tva_tx; + $this->localtax1_tx = $objp->localtax1_tx; + $this->localtax2_tx = $objp->localtax2_tx; + $this->localtax1_type = $objp->localtax1_type; + $this->localtax2_type = $objp->localtax2_type; + $this->remise_percent = $objp->remise_percent; + $this->fk_remise_except = $objp->fk_remise_except; + $this->fk_product = $objp->fk_product; + $this->info_bits = $objp->info_bits; + $this->total_ht = $objp->total_ht; + $this->total_tva = $objp->total_tva; + $this->total_ttc = $objp->total_ttc; + $this->code_ventilation = $objp->fk_code_ventilation; + $this->rang = $objp->rang; + $this->special_code = $objp->special_code; + $this->fk_unit = $objp->fk_unit; + $this->fk_contract_line = $objp->fk_contract_line; + + + $this->db->free($result); + return 1; + } + else + { + $this->error=$this->db->lasterror(); + return -3; + } + } + + + /** + * Update a line to invoice_rec. + * + * @return int <0 if KO, Id of line if OK + */ + function update() + { + global $user; + + include_once DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php'; + + if ($fk_product) + { + $product=new Product($this->db); + $result=$product->fetch($fk_product); + $product_type=$product->type; + } + + $sql = "UPDATE ".MAIN_DB_PREFIX."facturedet_rec SET "; + $sql.= " fk_facture = ".$this->fk_facture; + $sql.= ", label=".(! empty($this->label)?"'".$this->db->escape($this->label)."'":"null"); + $sql.= ", description='".$this->db->escape($this->desc)."'"; + $sql.= ", price=".price2num($this->price); + $sql.= ", qty=".price2num($this->qty); + $sql.= ", tva_tx=".price2num($this->tva_tx); + $sql.= ", vat_src_code='".$this->db->escape($this->vat_src_code)."'"; + $sql.= ", localtax1_tx=".price2num($this->localtax1_tx); + $sql.= ", localtax1_type='".$this->db->escape($this->localtax1_type)."'"; + $sql.= ", localtax2_tx=".price2num($this->localtax2_tx); + $sql.= ", localtax2_type='".$this->db->escape($this->localtax2_type)."'"; + $sql.= ", fk_product=".(! empty($this->fk_product)?"'".$this->fk_product."'":"null"); + $sql.= ", product_type=".$this->product_type; + $sql.= ", remise_percent='".price2num($this->remise_percent)."'"; + $sql.= ", subprice='".price2num($this->subprice)."'"; + $sql.= ", total_ht='".price2num($this->total_ht)."'"; + $sql.= ", total_tva='".price2num($this->total_tva)."'"; + $sql.= ", total_localtax1='".price2num($this->total_localtax1)."'"; + $sql.= ", total_localtax2='".price2num($this->total_localtax2)."'"; + $sql.= ", total_ttc='".price2num($this->total_ttc)."'"; + $sql.= ", rang=".$this->rang; + $sql.= ", special_code=".$this->special_code; + $sql.= ", fk_unit=".($this->fk_unit ?"'".$this->db->escape($this->fk_unit )."'":"null"); + $sql.= ", fk_contract_line=".($this->fk_contract_line?$this->fk_contract_line:"null"); + + $sql.= " WHERE rowid = ".$this->id; + + dol_syslog(get_class($this)."::updateline", LOG_DEBUG); + $resql=$this->db->query($sql); + if ($resql) + { + if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used + { + $result=$this->insertExtraFields(); + if ($result < 0) + { + $error++; + } + } + + if (! $notrigger) + { + // Call trigger + $result=$this->call_trigger('LINEBILL_REC_UPDATE',$user); + if ($result < 0) + { + $this->db->rollback(); + return -2; + } + // End call triggers + } + $this->db->commit(); + return 1; + } + else + { + $this->error=$this->db->error(); + $this->db->rollback(); + return -2; + } + + } + } diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 598616798b6..14e18cda847 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -315,6 +315,8 @@ class Facture extends CommonInvoice $this->note_private=trim($this->note_private); $this->note_private=dol_concatdesc($this->note_private, $langs->trans("GeneratedFromRecurringInvoice", $_facrec->ref)); + $this->array_options=$_facrec->array_options; + //if (! $this->remise) $this->remise = 0; if (! $this->mode_reglement_id) $this->mode_reglement_id = 0; $this->brouillon = 1; @@ -634,7 +636,7 @@ class Facture extends CommonInvoice if (empty($tva_tx)) $tva_npr=0; $localtax1_tx=get_localtax($tva_tx,1,$soc,$mysoc,$tva_npr); $localtax2_tx=get_localtax($tva_tx,2,$soc,$mysoc,$tva_npr); - + $result_insert = $this->addline( $_facrec->lines[$i]->desc, $_facrec->lines[$i]->subprice, @@ -654,7 +656,7 @@ class Facture extends CommonInvoice null, 0, $_facrec->lines[$i]->label, - null, + empty($_facrec->lines[$i]->array_options)?null:$_facrec->lines[$i]->array_options, $_facrec->lines[$i]->situation_percent, '', $_facrec->lines[$i]->fk_unit diff --git a/htdocs/compta/facture/fiche-rec.php b/htdocs/compta/facture/fiche-rec.php index 3a072f946be..025940c8b3a 100644 --- a/htdocs/compta/facture/fiche-rec.php +++ b/htdocs/compta/facture/fiche-rec.php @@ -40,6 +40,7 @@ if (! empty($conf->projet->enabled)) { require_once DOL_DOCUMENT_ROOT . '/core/class/html.formprojet.class.php'; require_once DOL_DOCUMENT_ROOT . '/core/class/doleditor.class.php'; require_once DOL_DOCUMENT_ROOT . '/core/lib/invoice.lib.php'; +require_once DOL_DOCUMENT_ROOT . '/core/class/extrafields.class.php'; $langs->load('bills'); $langs->load('compta'); @@ -103,7 +104,7 @@ $hookmanager->initHooks(array('invoicereccard','globalcard')); $extrafields = new ExtraFields($db); // fetch optionals attributes and labels -$extralabels = $extrafields->fetch_name_optionals_label('facture'); +$extralabels = $extrafields->fetch_name_optionals_label('facture_rec'); $search_array_options=$extrafields->getOptionalsFromPost($extralabels,'','search_'); $permissionnote = $user->rights->facture->creer; // Used by the include of actions_setnotes.inc.php @@ -394,6 +395,28 @@ if (empty($reshook)) setEventMessages($line->error, $line->errors, 'errors'); } } + else if ($action == 'update_extras') + { + // Fill array 'array_options' with data from update form + $extralabels = $extrafields->fetch_name_optionals_label($object->table_element); + $ret = $extrafields->setOptionalsFromPost($extralabels, $object, GETPOST('attribute')); + if ($ret < 0) + $error ++; + + if (! $error) { + + $result = $object->insertExtraFields(); + if ($result < 0) { + $error ++; + } + } else if ($reshook < 0) + $error ++; + + if ($error) { + $action = 'edit_extras'; + setEventMessages($object->error, $object->errors, 'errors'); + } + } // Add a new line if ($action == 'addline' && $user->rights->facture->creer) @@ -737,6 +760,18 @@ if (empty($reshook)) $extrafieldsline = new ExtraFields($db); $extralabelsline = $extrafieldsline->fetch_name_optionals_label($object->table_element_line); $array_options = $extrafieldsline->getOptionalsFromPost($extralabelsline); + + $objectline = new FactureLigneRec($db); + if ($objectline->fetch(GETPOST('lineid'))) + { + $objectline->array_options=$array_options; + $result=$objectline->insertExtraFields(); + if ($result < 0) + { + setEventMessages($langs->trans('Error').$result, null, 'errors'); + } + } + // Unset extrafield if (is_array($extralabelsline)) { @@ -1326,6 +1361,11 @@ else print ""; print ''; + + // Other attributes + $cols = 2; + include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php'; + print ''; print ''; diff --git a/htdocs/compta/facture/info.php b/htdocs/compta/facture/info.php index 56f89a83154..fd43cc42982 100644 --- a/htdocs/compta/facture/info.php +++ b/htdocs/compta/facture/info.php @@ -39,6 +39,8 @@ $ref=GETPOST("ref",'alpha'); * View */ +$form = new Form($db); + $title = $langs->trans('InvoiceCustomer') . " - " . $langs->trans('Info'); $helpurl = "EN:Customers_Invoices|FR:Factures_Clients|ES:Facturas_a_clientes"; llxHeader('', $title, $helpurl); diff --git a/htdocs/compta/sociales/info.php b/htdocs/compta/sociales/info.php index 91334134a2c..b67c844a7b9 100644 --- a/htdocs/compta/sociales/info.php +++ b/htdocs/compta/sociales/info.php @@ -60,6 +60,8 @@ if ($action == 'setlib' && $user->rights->tax->charges->creer) * View */ +$form = new Form($db); + if (! empty($conf->projet->enabled)) { $formproject = new FormProjets($db); } $title = $langs->trans("SocialContribution") . ' - ' . $langs->trans("Info"); diff --git a/htdocs/compta/stats/index.php b/htdocs/compta/stats/index.php index 19c106a44dc..1735033cab7 100644 --- a/htdocs/compta/stats/index.php +++ b/htdocs/compta/stats/index.php @@ -2,6 +2,7 @@ /* Copyright (C) 2001-2004 Rodolphe Quiedeville * Copyright (C) 2004-2012 Laurent Destailleur * Copyright (C) 2005-2009 Regis Houssin + * Copyright (C) 2017 Olivier Geffroy * * 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 @@ -62,6 +63,7 @@ if ($modecompta=="CREANCES-DETTES") $nom=$langs->trans("SalesTurnover"); $calcmode=$langs->trans("CalcModeDebt"); $calcmode.='
    ('.$langs->trans("SeeReportInInputOutputMode",'','').')'; + $calcmode.='
    ('.$langs->trans("SeeReportInBookkeepingMode",'','').')'; $period="$year_start - $year_end"; $periodlink=($year_start?"".img_previous()." ".img_next()."":""); $description=$langs->trans("RulesCADue"); @@ -70,10 +72,12 @@ if ($modecompta=="CREANCES-DETTES") $builddate=time(); //$exportlink=$langs->trans("NotYetAvailable"); } -else { +else if ($modecompta=="RECETTES-DEPENSES") +{ $nom=$langs->trans("SalesTurnover"); $calcmode=$langs->trans("CalcModeEngagement"); $calcmode.='
    ('.$langs->trans("SeeReportInDueDebtMode",'','').')'; + $calcmode.='
    ('.$langs->trans("SeeReportInBookkeepingMode",'','').')'; $period="$year_start - $year_end"; $periodlink=($year_start?"".img_previous()." ".img_next()."":""); $description=$langs->trans("RulesCAIn"); @@ -81,6 +85,20 @@ else { $builddate=time(); //$exportlink=$langs->trans("NotYetAvailable"); } +else if ($modecompta=="BOOKKEEPING") +{ + $nom=$langs->trans("BookkeepingTurnover"); + $calcmode=$langs->trans("CalcModeBookkeeping"); + $calcmode.='
    ('.$langs->trans("SeeReportInDueDebtMode",'','').')'; + $calcmode.='
    ('.$langs->trans("SeeReportInInputOutputMode",'','').')'; + $period="$year_start - $year_end"; + $periodlink=($year_start?"".img_previous()." ".img_next()."":""); + $description=$langs->trans("RulesCABookkeeping"); + $description.= $langs->trans("DepositsAreIncluded"); + $builddate=time(); + //$exportlink=$langs->trans("NotYetAvailable"); +} + $moreparam=array(); if (! empty($modecompta)) $moreparam['modecompta']=$modecompta; report_header($nom,$nomlink,$period,$periodlink,$description,$builddate,$exportlink,$moreparam,$calcmode); @@ -98,8 +116,10 @@ if ($modecompta == 'CREANCES-DETTES') $sql.= " WHERE f.fk_statut in (1,2)"; if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) $sql.= " AND f.type IN (0,1,2,5)"; else $sql.= " AND f.type IN (0,1,2,3,5)"; + $sql.= " AND f.entity = ".$conf->entity; +if ($socid) $sql.= " AND f.fk_soc = ".$socid; } -else +else if ($modecompta=="RECETTES-DEPENSES") { /* * Liste des paiements (les anciens paiements ne sont pas vus par cette requete car, sur les @@ -111,9 +131,19 @@ else $sql.= ", ".MAIN_DB_PREFIX."paiement as p"; $sql.= " WHERE p.rowid = pf.fk_paiement"; $sql.= " AND pf.fk_facture = f.rowid"; -} -$sql.= " AND f.entity = ".$conf->entity; + $sql.= " AND f.entity = ".$conf->entity; if ($socid) $sql.= " AND f.fk_soc = ".$socid; +} +else if ($modecompta=="BOOKKEEPING") +{ + $sql = "SELECT date_format(b.doc_date,'%Y-%m') as dm, sum(b.credit) as amount_ttc"; + $sql.= " FROM ".MAIN_DB_PREFIX."accounting_bookkeeping as b"; + $sql.= " WHERE b.numero_compte IN (SELECT a.account_number" ; + $sql.= " FROM ".MAIN_DB_PREFIX."accounting_account as a"; + $sql.= " WHERE a.fk_accounting_category = 1 ) " ; // todo sql with accounting category, but we need to define category in turnover +} + + $sql.= " GROUP BY dm"; $sql.= " ORDER BY dm"; @@ -481,7 +511,7 @@ print ''; $i++; } - print "Facture a encaisser : ".price($total_ttc_Rac)."<-- bug ici car n'exclut pas le deja r�gl� des factures partiellement r�gl�es"; + print "Facture a encaisser : ".price($total_ttc_Rac)."<-- bug ici car n'exclut pas le deja r?gl? des factures partiellement r?gl?es"; } $db->free($resql); } diff --git a/htdocs/contact/agenda.php b/htdocs/contact/agenda.php index 7f35c71cd11..cc7f36261cc 100644 --- a/htdocs/contact/agenda.php +++ b/htdocs/contact/agenda.php @@ -211,7 +211,7 @@ else dol_fiche_head($head, 'agenda', $title, -1, 'contact'); $linkback = ''.$langs->trans("BackToList").''; - + $morehtmlref='
    '; if (empty($conf->global->SOCIETE_DISABLE_CONTACTS)) { @@ -223,42 +223,42 @@ else else $morehtmlref.=$langs->trans("ContactNotLinkedToCompany"); } $morehtmlref.='
    '; - + dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'ref', $morehtmlref); - + print '
    '; - + print '
    '; - + $object->info($id); print dol_print_object_info($object, 1); - + print '
    '; - + print dol_fiche_end(); - + // Actions buttons - + $objcon=$object; $object->fetch_thirdparty(); $objthirdparty=$object->thirdparty; - + $out=''; $permok=$user->rights->agenda->myactions->create; if ((! empty($objthirdparty->id) || ! empty($objcon->id)) && $permok) { //$out.='trans("AddAnAction"),'filenew'); //$out.=""; } - - + + print '
    '; - + if (! empty($conf->agenda->enabled)) { if (! empty($user->rights->agenda->myactions->create) || ! empty($user->rights->agenda->allactions->create)) @@ -270,22 +270,22 @@ else print ''.$langs->trans("AddAction").''; } } - + print '
    '; - + if (! empty($conf->agenda->enabled) && (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read) )) { $param='&id='.$id; if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage; if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit; - - + + print load_fiche_titre($langs->trans("TasksHistoryForThisContact"),'',''); - + // List of all actions $filters=array(); $filters['search_agenda_label']=$search_agenda_label; - + show_actions_done($conf,$langs,$db,$objthirdparty,$object,0,$actioncode, '', $filters, $sortfield, $sortorder); } } diff --git a/htdocs/contrat/class/contrat.class.php b/htdocs/contrat/class/contrat.class.php index bf31ef4070c..a521f05269b 100644 --- a/htdocs/contrat/class/contrat.class.php +++ b/htdocs/contrat/class/contrat.class.php @@ -1278,6 +1278,15 @@ class Contrat extends CommonObject //// End call triggers } } + + if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED) && is_array($this->array_options) && count($this->array_options)>0) // For avoid conflicts if trigger used + { + $result=$this->insertExtraFields(); + if ($result < 0) + { + $error++; + } + } if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED) && is_array($this->array_options) && count($this->array_options)>0) // For avoid conflicts if trigger used { @@ -1831,13 +1840,13 @@ class Contrat extends CommonObject $text.=':     '; } $text.=($mode == 7?'
    ':''); - $text.=($mode != 7 || $this->nbofserviceswait > 0) ? ($this->nbofserviceswait.$line->LibStatut(0,3)).(($mode != 7 || $this->nbofservicesopened || $this->nbofservicesexpired || $this->nbofservicesclosed)?'   ':'') : ''; + $text.=($mode != 7 || $this->nbofserviceswait > 0) ? ($this->nbofserviceswait.$line->LibStatut(0,3,-1,'class="paddingleft2 inline-block valigntextbottom"')).(($mode != 7 || $this->nbofservicesopened || $this->nbofservicesexpired || $this->nbofservicesclosed)?'   ':'') : ''; $text.=($mode == 7?'
    ':''); - $text.=($mode != 7 || $this->nbofservicesopened > 0) ? ($this->nbofservicesopened.$line->LibStatut(4,3,0)).(($mode != 7 || $this->nbofservicesexpired || $this->nbofservicesclosed)?'   ':'') : ''; + $text.=($mode != 7 || $this->nbofservicesopened > 0) ? ($this->nbofservicesopened.$line->LibStatut(4,3,0,'class="paddingleft2 inline-block valigntextbottom"')).(($mode != 7 || $this->nbofservicesexpired || $this->nbofservicesclosed)?'   ':'') : ''; $text.=($mode == 7?'
    ':''); - $text.=($mode != 7 || $this->nbofservicesexpired > 0) ? ($this->nbofservicesexpired.$line->LibStatut(4,3,1)).(($mode != 7 || $this->nbofservicesclosed)?'   ':'') : ''; + $text.=($mode != 7 || $this->nbofservicesexpired > 0) ? ($this->nbofservicesexpired.$line->LibStatut(4,3,1,'class="paddingleft2 inline-block valigntextbottom"')).(($mode != 7 || $this->nbofservicesclosed)?'   ':'') : ''; $text.=($mode == 7?'
    ':''); - $text.=($mode != 7 || $this->nbofservicesclosed > 0) ? ($this->nbofservicesclosed.$line->LibStatut(5,3)) : ''; + $text.=($mode != 7 || $this->nbofservicesclosed > 0) ? ($this->nbofservicesclosed.$line->LibStatut(5,3,-1,'class="paddingleft2 inline-block valigntextbottom"')) : ''; $text.=($mode == 7?'
    ':''); return $text; } @@ -2509,9 +2518,10 @@ class ContratLigne extends CommonObjectLine * @param int $statut Id statut * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto * @param int $expired 0=Not expired, 1=Expired, -1=Both or unknown + * @param string $moreatt More attribute * @return string Libelle */ - function LibStatut($statut,$mode,$expired=-1) + function LibStatut($statut,$mode,$expired=-1,$moreatt='') { global $langs; $langs->load("contracts"); @@ -2541,11 +2551,11 @@ class ContratLigne extends CommonObjectLine } if ($mode == 3) { - if ($statut == 0) { return img_picto($langs->trans('ServiceStatusInitial'),'statut0'); } - if ($statut == 4 && $expired == -1) { return img_picto($langs->trans('ServiceStatusRunning'),'statut4'); } - if ($statut == 4 && $expired == 0) { return img_picto($langs->trans('ServiceStatusNotLate'),'statut4'); } - if ($statut == 4 && $expired == 1) { return img_picto($langs->trans('ServiceStatusLate'),'statut3'); } - if ($statut == 5) { return img_picto($langs->trans('ServiceStatusClosed'),'statut6'); } + if ($statut == 0) { return img_picto($langs->trans('ServiceStatusInitial'),'statut0',$moreatt); } + if ($statut == 4 && $expired == -1) { return img_picto($langs->trans('ServiceStatusRunning'),'statut4',$moreatt); } + if ($statut == 4 && $expired == 0) { return img_picto($langs->trans('ServiceStatusNotLate'),'statut4',$moreatt); } + if ($statut == 4 && $expired == 1) { return img_picto($langs->trans('ServiceStatusLate'),'statut3',$moreatt); } + if ($statut == 5) { return img_picto($langs->trans('ServiceStatusClosed'),'statut6',$moreatt); } } if ($mode == 4) { diff --git a/htdocs/contrat/info.php b/htdocs/contrat/info.php index 35cca237b21..95ab0b9ca25 100644 --- a/htdocs/contrat/info.php +++ b/htdocs/contrat/info.php @@ -39,8 +39,10 @@ $result = restrictedArea($user, 'contrat', $id, ''); /* -* View -*/ + * View + */ + +$form = new Form($db); llxHeader('',$langs->trans("Contract"),""); diff --git a/htdocs/contrat/services.php b/htdocs/contrat/services.php index 51061b4b6ad..aaf0d0cd796 100644 --- a/htdocs/contrat/services.php +++ b/htdocs/contrat/services.php @@ -154,6 +154,7 @@ if (empty($reshook)) if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x','alpha') || GETPOST('button_removefilter','alpha')) // All test are required to be compatible with all browsers { + $search_product_category=0; $search_name=""; $search_contract=""; $search_service=""; @@ -176,6 +177,8 @@ if (empty($reshook)) $filter_opcloture=""; $mode=''; $filter=''; + $toselect=''; + $search_array_options=array(); } } diff --git a/htdocs/core/actions_extrafields.inc.php b/htdocs/core/actions_extrafields.inc.php index 278a931b437..96dd3e3f7b9 100644 --- a/htdocs/core/actions_extrafields.inc.php +++ b/htdocs/core/actions_extrafields.inc.php @@ -14,7 +14,7 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . * or see http://www.gnu.org/ - * + * * $elementype must be defined. */ @@ -158,12 +158,11 @@ if ($action == 'add') $params['options'][$key] = $value; } } - $result=$extrafields->addExtraField( GETPOST('attrname', 'alpha'), GETPOST('label', 'alpha'), $type, - GETPOST('pos', 'alpha'), + GETPOST('pos', 'int'), $extrasize, $elementtype, (GETPOST('unique', 'alpha')?1:0), @@ -175,8 +174,8 @@ if ($action == 'add') (GETPOST('list', 'alpha')?1:0), (GETPOST('ishidden', 'alpha')?1:0), GETPOST('computed_value','alpha'), - (GETPOST('entitycurrentorall', 'alpha')?0:'') - + (GETPOST('entitycurrentorall', 'alpha')?0:''), + GETPOST('langfile', 'alpha') ); if ($result > 0) { @@ -338,7 +337,8 @@ if ($action == 'update') (GETPOST('ishidden', 'alpha')?1:0), GETPOST('default_value','alpha'), GETPOST('computed_value','alpha'), - (GETPOST('entitycurrentorall', 'alpha')?0:'') + (GETPOST('entitycurrentorall', 'alpha')?0:''), + GETPOST('langfile') ); if ($result > 0) { diff --git a/htdocs/core/actions_massactions.inc.php b/htdocs/core/actions_massactions.inc.php index f9adfafd5a8..df1c45f66dd 100644 --- a/htdocs/core/actions_massactions.inc.php +++ b/htdocs/core/actions_massactions.inc.php @@ -440,26 +440,26 @@ if (! $error && $massaction == "builddoc" && $permtoread && ! GETPOST('button_se $outputlangs->setDefaultLang($newlang); } - if(!empty($conf->global->USE_PDFTK_FOR_PDF_CONCAT)) { + if (!empty($conf->global->USE_PDFTK_FOR_PDF_CONCAT)) + { // Create output dir if not exists - dol_mkdir($diroutputmassaction); - - // Defined name of merged file - $filename=strtolower(dol_sanitizeFileName($langs->transnoentities($objectlabel))); - $filename=preg_replace('/\s/','_',$filename); - - // Save merged file - if ($filter=='paye:0') - { - if ($option=='late') $filename.='_'.strtolower(dol_sanitizeFileName($langs->transnoentities("Unpaid"))).'_'.strtolower(dol_sanitizeFileName($langs->transnoentities("Late"))); - else $filename.='_'.strtolower(dol_sanitizeFileName($langs->transnoentities("Unpaid"))); - } - if ($year) $filename.='_'.$year; - if ($month) $filename.='_'.$month; + dol_mkdir($diroutputmassaction); + + // Defined name of merged file + $filename=strtolower(dol_sanitizeFileName($langs->transnoentities($objectlabel))); + $filename=preg_replace('/\s/','_',$filename); + + // Save merged file + if ($filter=='paye:0') + { + if ($option=='late') $filename.='_'.strtolower(dol_sanitizeFileName($langs->transnoentities("Unpaid"))).'_'.strtolower(dol_sanitizeFileName($langs->transnoentities("Late"))); + else $filename.='_'.strtolower(dol_sanitizeFileName($langs->transnoentities("Unpaid"))); + } + if ($year) $filename.='_'.$year; + if ($month) $filename.='_'.$month; if (count($files)>0) { - $now=dol_now(); $file=$diroutputmassaction.'/'.$filename.'_'.dol_print_date($now,'dayhourlog').'.pdf'; @@ -474,14 +474,13 @@ if (! $error && $massaction == "builddoc" && $permtoread && ! GETPOST('button_se if (! empty($conf->global->MAIN_UMASK)) @chmod($file, octdec($conf->global->MAIN_UMASK)); - $langs->load("exports"); - setEventMessages($langs->trans('FileSuccessfullyBuilt',$filename.'_'.dol_print_date($now,'dayhourlog')), null, 'mesgs'); + $langs->load("exports"); + setEventMessages($langs->trans('FileSuccessfullyBuilt',$filename.'_'.dol_print_date($now,'dayhourlog')), null, 'mesgs'); } else { setEventMessages($langs->trans('NoPDFAvailableForDocGenAmongChecked'), null, 'errors'); } - } else { // Create empty PDF @@ -519,18 +518,18 @@ if (! $error && $massaction == "builddoc" && $permtoread && ! GETPOST('button_se // Save merged file if ($filter=='paye:0') { - if ($option=='late') $filename.='_'.strtolower(dol_sanitizeFileName($langs->transnoentities("Unpaid"))).'_'.strtolower(dol_sanitizeFileName($langs->transnoentities("Late"))); - else $filename.='_'.strtolower(dol_sanitizeFileName($langs->transnoentities("Unpaid"))); + if ($option=='late') $filename.='_'.strtolower(dol_sanitizeFileName($langs->transnoentities("Unpaid"))).'_'.strtolower(dol_sanitizeFileName($langs->transnoentities("Late"))); + else $filename.='_'.strtolower(dol_sanitizeFileName($langs->transnoentities("Unpaid"))); } if ($year) $filename.='_'.$year; if ($month) $filename.='_'.$month; if ($pagecount) { - $now=dol_now(); - $file=$diroutputmassaction.'/'.$filename.'_'.dol_print_date($now,'dayhourlog').'.pdf'; - $pdf->Output($file,'F'); - if (! empty($conf->global->MAIN_UMASK)) - @chmod($file, octdec($conf->global->MAIN_UMASK)); + $now=dol_now(); + $file=$diroutputmassaction.'/'.$filename.'_'.dol_print_date($now,'dayhourlog').'.pdf'; + $pdf->Output($file,'F'); + if (! empty($conf->global->MAIN_UMASK)) + @chmod($file, octdec($conf->global->MAIN_UMASK)); $langs->load("exports"); setEventMessages($langs->trans('FileSuccessfullyBuilt',$filename.'_'.dol_print_date($now,'dayhourlog')), null, 'mesgs'); diff --git a/htdocs/core/actions_sendmails.inc.php b/htdocs/core/actions_sendmails.inc.php index 1998808bf11..58bc00e3f0f 100644 --- a/htdocs/core/actions_sendmails.inc.php +++ b/htdocs/core/actions_sendmails.inc.php @@ -345,7 +345,8 @@ if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_PO } // Send mail - $mailfile = new CMailFile($subject,$sendto,$from,$message,$filepath,$mimetype,$filename,$sendtocc,$sendtobcc,$deliveryreceipt,-1,'','',$trackid); + if (empty($sendcontext)) $sendcontext = 'standard'; + $mailfile = new CMailFile($subject,$sendto,$from,$message,$filepath,$mimetype,$filename,$sendtocc,$sendtobcc,$deliveryreceipt,-1,'','',$trackid,'',$sendcontext); if ($mailfile->error) { setEventMessage($mailfile->error, 'errors'); diff --git a/htdocs/core/actions_setmoduleoptions.inc.php b/htdocs/core/actions_setmoduleoptions.inc.php index b8ae96cb920..eadce1dc74c 100644 --- a/htdocs/core/actions_setmoduleoptions.inc.php +++ b/htdocs/core/actions_setmoduleoptions.inc.php @@ -1,5 +1,5 @@ +/* Copyright (C) 2014-2017 Laurent Destailleur * * 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 @@ -17,15 +17,43 @@ */ /** - * \file htdocs/core/actions_setnotes.inc.php + * \file htdocs/core/actions_setmoduleoptions.inc.php * \brief Code for actions on setting notes of object page */ // $action must be defined -// $_FILES may be defined +// $arrayofparameters must be set for action 'update' +// $nomessageinupdate can be set to 1 // $nomessageinsetmoduleoptions can be set to 1 +if ($action == 'update' && is_array($arrayofparameters)) +{ + $db->begin(); + + $ok=True; + foreach($arrayofparameters as $key => $val) + { + $result=dolibarr_set_const($db,$key,GETPOST($key, 'alpha'),'chaine',0,'',$conf->entity); + if ($result < 0) + { + $ok=False; + break; + } + } + + if (! $error) + { + $db->commit(); + if (empty($nomessageinupdate)) setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); + } + else + { + $db->rollback(); + if (empty($nomessageinupdate)) setEventMessages($langs->trans("SetupNotSaved"), null, 'errors'); + } +} + // Define constants for submodules that contains parameters (forms with param1, param2, ... and value1, value2, ...) if ($action == 'setModuleOptions') { diff --git a/htdocs/core/ajax/ajaxdirpreview.php b/htdocs/core/ajax/ajaxdirpreview.php index 74d9db0ec6d..203bd71e645 100644 --- a/htdocs/core/ajax/ajaxdirpreview.php +++ b/htdocs/core/ajax/ajaxdirpreview.php @@ -39,11 +39,11 @@ if (! isset($mode) || $mode != 'noajax') // For ajax call require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; require_once DOL_DOCUMENT_ROOT.'/ecm/class/ecmdirectory.class.php'; - $action=GETPOST('action','aZ09'); - $file=urldecode(GETPOST('file')); - $section=GETPOST("section"); - $module=GETPOST("module"); - $urlsource=GETPOST("urlsource"); + $action=GETPOST('action','aZ09'); + $file=urldecode(GETPOST('file','alpha')); + $section=GETPOST("section",'alpha'); + $module=GETPOST("module",'alpha'); + $urlsource=GETPOST("urlsource",'alpha'); $search_doc_ref=GETPOST('search_doc_ref','alpha'); $sortfield = GETPOST("sortfield",'alpha'); @@ -56,7 +56,9 @@ if (! isset($mode) || $mode != 'noajax') // For ajax call if (! $sortorder) $sortorder="ASC"; if (! $sortfield) $sortfield="name"; - $upload_dir = dirname(str_replace("../","/", $conf->ecm->dir_output.'/'.$file)); + $rootdirfordoc = $conf->ecm->dir_output; + + $upload_dir = dirname(str_replace("../", "/", $rootdirfordoc.'/'.$file)); $ecmdir = new EcmDirectory($db); $result=$ecmdir->fetch($section); @@ -68,7 +70,9 @@ if (! isset($mode) || $mode != 'noajax') // For ajax call } else // For no ajax call { - $ecmdir = new EcmDirectory($db); + $rootdirfordoc = $conf->ecm->dir_output; + + $ecmdir = new EcmDirectory($db); $relativepath=''; if ($section > 0) { @@ -80,7 +84,7 @@ else // For no ajax call } } $relativepath=$ecmdir->getRelativePath(); - $upload_dir = $conf->ecm->dir_output.'/'.$relativepath; + $upload_dir = $rootdirfordoc.'/'.$relativepath; } if (empty($url)) $url=DOL_URL_ROOT.'/ecm/index.php'; @@ -95,8 +99,7 @@ if ($user->societe_id > 0) $socid = $user->societe_id; //print 'xxx'.$upload_dir; // Security: -// On interdit les remontees de repertoire ainsi que les pipe dans -// les noms de fichiers. +// On interdit les remontees de repertoire ainsi que les pipe dans les noms de fichiers. if (preg_match('/\.\./',$upload_dir) || preg_match('/[<>|]/',$upload_dir)) { dol_syslog("Refused to deliver file ".$upload_dir); @@ -105,6 +108,16 @@ if (preg_match('/\.\./',$upload_dir) || preg_match('/[<>|]/',$upload_dir)) exit; } +// Check permissions +if ($modulepart == 'ecm') +{ + if (! $user->rights->ecm->read) accessforbidden(); +} +if ($modulepart == 'medias') +{ + // Always allowed +} + /* * Action @@ -153,7 +166,7 @@ if ($type == 'directory') $excludefiles = array('^SPECIMEN\.pdf$','^\.','(\.meta|_preview.*\.png)$','^temp$','^payments$','^CVS$','^thumbs$'); $sorting = (strtolower($sortorder)=='desc'?SORT_DESC:SORT_ASC); - // Right area. If module is defined, we are in automatic ecm. + // Right area. If module is defined here, we are in automatic ecm. $automodules = array('company', 'invoice', 'invoice_supplier', 'propal', 'order', 'order_supplier', 'contract', 'product', 'tax', 'project', 'fichinter', 'user', 'expensereport'); // TODO change for multicompany sharing @@ -197,20 +210,33 @@ if ($type == 'directory') $filter=preg_quote($search_doc_ref, '/'); $filearray=dol_dir_list($upload_dir, "files", 1, $filter, $excludefiles, $sortfield, $sorting,1); - $formfile->list_of_autoecmfiles($upload_dir,$filearray,$module,$param,1,'',$user->rights->ecm->upload,1,$textifempty,$maxlengthname,$url,1); + $perm=$user->rights->ecm->upload; + + $formfile->list_of_autoecmfiles($upload_dir,$filearray,$module,$param,1,'',$perm,1,$textifempty,$maxlengthname,$url,1); } // Manual list else { - $relativepath=$ecmdir->getRelativePath(); - $upload_dir = $conf->ecm->dir_output.'/'.$relativepath; + if ($module == 'medias') + { + $relativepath=GETPOST('file','alpha'); + $upload_dir = $dolibarr_main_data_root.'/medias/'.$relativepath; + } + else + { + $relativepath=$ecmdir->getRelativePath(); + $upload_dir = $conf->ecm->dir_output.'/'.$relativepath; + } // If $section defined with value 0 - if ($section === '0' || empty($section)) + if (($section === '0' || empty($section)) && ($module != 'medias')) { $filearray=array(); } - else $filearray=dol_dir_list($upload_dir,"files",0,'',array('^\.','(\.meta|_preview.*\.png)$','^temp$','^CVS$'),$sortfield, $sorting,1); + else + { + $filearray=dol_dir_list($upload_dir,"files",0,'',array('^\.','(\.meta|_preview.*\.png)$','^temp$','^CVS$'),$sortfield, $sorting,1); + } if ($section) { @@ -222,7 +248,18 @@ if ($type == 'directory') else if ($section === '0') $textifempty='
    '.$langs->trans("DirNotSynchronizedSyncFirst").'

    '; else $textifempty=($showonrightsize=='featurenotyetavailable'?$langs->trans("FeatureNotYetAvailable"):$langs->trans("ECMSelectASection")); - $formfile->list_of_documents($filearray,'','ecm',$param,1,$relativepath,$user->rights->ecm->upload,1,$textifempty,$maxlengthname,'',$url); + if ($module == 'medias') + { + $modulepart='medias'; + $perm=($user->rights->websites->creer || $user->rights->emailing->creer); + } + else + { + $modulepart='ecm'; + $perm=$user->rights->ecm->upload; + } + + $formfile->list_of_documents($filearray,'',$modulepart,$param,1,$relativepath,$perm,1,$textifempty,$maxlengthname,'',$url); } } diff --git a/htdocs/core/ajax/ajaxdirtree.php b/htdocs/core/ajax/ajaxdirtree.php index 14b05c75905..c376bee9da3 100644 --- a/htdocs/core/ajax/ajaxdirtree.php +++ b/htdocs/core/ajax/ajaxdirtree.php @@ -45,13 +45,14 @@ if ($selecteddir != '/') $selecteddir = preg_replace('/\/$/','',$selecteddir); $langs->load("ecm"); -// Define selecteddir (fullpath). +// Define fullpathselecteddir. +$fullpathselecteddir=''; if ($modulepart == 'ecm') $fullpathselecteddir=$conf->ecm->dir_output.'/'.($selecteddir != '/' ? $selecteddir : ''); +if ($modulepart == 'medias') $fullpathselecteddir=$dolibarr_main_data_root.'/medias/'.($selecteddir != '/' ? $selecteddir : ''); // Security: -// On interdit les remontees de repertoire ainsi que les pipe dans -// les noms de fichiers. +// On interdit les remontees de repertoire ainsi que les pipe dans les noms de fichiers. if (preg_match('/\.\./',$fullpathselecteddir) || preg_match('/[<>|]/',$fullpathselecteddir)) { dol_syslog("Refused to deliver file ".$original_file); @@ -63,9 +64,12 @@ if (preg_match('/\.\./',$fullpathselecteddir) || preg_match('/[<>|]/',$fullpaths // Check permissions if ($modulepart == 'ecm') { - if (! $user->rights->ecm->read) accessforbidden(); + if (! $user->rights->ecm->read) accessforbidden(); +} +if ($modulepart == 'medias') +{ + // Always allowed } - /* @@ -97,7 +101,8 @@ foreach($sqltree as $keycursor => $val) if (file_exists($fullpathselecteddir)) { $files = @scandir($fullpathselecteddir); - if ($files) + + if ($files) { natcasesort($files); if ( count($files) > 2 ) /* The 2 accounts for . and .. */ diff --git a/htdocs/core/ajax/bankconciliate.php b/htdocs/core/ajax/bankconciliate.php index 65620c5429c..e5bfb674e8f 100644 --- a/htdocs/core/ajax/bankconciliate.php +++ b/htdocs/core/ajax/bankconciliate.php @@ -71,3 +71,27 @@ if (($user->rights->banque->modifier || $user->rights->banque->consolidate) && $ exit; } +if (($user->rights->banque->modifier || $user->rights->banque->consolidate) && $action == 'donext') +{ + // Increase date + $al = new AccountLine($db); + $al->dateo_next(GETPOST('rowid','int')); + $al->fetch(GETPOST('rowid','int')); + + print ''.dol_print_date($db->jdate($al->dateo),"day").''; + + exit; +} + +if (($user->rights->banque->modifier || $user->rights->banque->consolidate) && $action == 'doprev') +{ + // Decrease date + $al =new AccountLine($db); + $al->dateo_previous(GETPOST('rowid','int')); + $al->fetch(GETPOST('rowid','int')); + + print ''.dol_print_date($db->jdate($al->dateo),"day").''; + + exit; +} + diff --git a/htdocs/core/boxes/box_activity.php b/htdocs/core/boxes/box_activity.php index ae3e270101e..02b1d1880c8 100644 --- a/htdocs/core/boxes/box_activity.php +++ b/htdocs/core/boxes/box_activity.php @@ -97,181 +97,95 @@ class box_activity extends ModeleBoxes $cumuldata = array(); - // list the summary of the bills - if (! empty($conf->facture->enabled) && $user->rights->facture->lire) + + // list the summary of the propals + if (! empty($conf->propal->enabled) && $user->rights->propale->lire) { - include_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; - $facturestatic=new Facture($db); + include_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; + $propalstatic=new Propal($db); - // part 1 - $cachedir = DOL_DATA_ROOT.'/facture/temp'; - $filename = '/boxactivity-invoice'.$fileid; + $cachedir = DOL_DATA_ROOT.'/propale/temp'; + $filename = '/boxactivity-propal'.$fileid; + $refresh = dol_cache_refresh($cachedir, $filename, $cachetime); + $data = array(); + if ($refresh) + { + $sql = "SELECT p.fk_statut, SUM(p.total) as Mnttot, COUNT(*) as nb"; + $sql.= " FROM (".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."propal as p"; + if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql.= ")"; + $sql.= " WHERE p.entity = ".$conf->entity; + $sql.= " AND p.fk_soc = s.rowid"; + if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; + if($user->societe_id) $sql.= " AND s.rowid = ".$user->societe_id; + $sql.= " AND p.datep >= '".$db->idate($tmpdate)."'"; + $sql.= " AND p.date_cloture IS NULL"; // just unclosed + $sql.= " GROUP BY p.fk_statut"; + $sql.= " ORDER BY p.fk_statut DESC"; - $refresh = dol_cache_refresh($cachedir, $filename, $cachetime); - $data = array(); - if ($refresh) - { - $sql = "SELECT f.fk_statut, SUM(f.total_ttc) as Mnttot, COUNT(*) as nb"; - $sql.= " FROM (".MAIN_DB_PREFIX."societe as s,".MAIN_DB_PREFIX."facture as f"; - if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql.= ")"; - $sql.= " WHERE f.entity = ".$conf->entity; - if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; - if($user->societe_id) $sql.= " AND s.rowid = ".$user->societe_id; - $sql.= " AND f.fk_soc = s.rowid"; - $sql.= " AND f.datef >= '".$db->idate($tmpdate)."' AND paye=1"; - $sql.= " GROUP BY f.fk_statut"; - $sql.= " ORDER BY f.fk_statut DESC"; + $result = $db->query($sql); + if ($result) + { + $num = $db->num_rows($result); - $result = $db->query($sql); - if ($result) { - $num = $db->num_rows($result); - $j=0; - while ($j < $num) { - $data[$j]=$db->fetch_object($result); - $j++; - } - if (! empty($conf->global->MAIN_ACTIVATE_FILECACHE)) { - dol_filecache($cachedir, $filename, $data); - } - $db->free($result); - } else { - dol_print_error($db); - } - } else { - $data = dol_readcachefile($cachedir, $filename); - } + $j=0; + while ($j < $num) { + $data[$j]=$db->fetch_object($result); + $j++; + } + if (! empty($conf->global->MAIN_ACTIVATE_FILECACHE)) { + dol_filecache($cachedir, $filename, $data); + } + $db->free($result); + } else { + dol_print_error($db); + } + } + else + { + $data = dol_readcachefile($cachedir, $filename); + } - $cumuldata=array_merge($cumuldata, $data); - if (! empty($data)) { - $j=0; - while ($line < count($cumuldata)) { - $billurl="viewstatut=2&paye=1&year=".$data[$j]->annee; - $this->info_box_contents[$line][0] = array( - 'td' => 'align="left" width="16"', - 'tooltip' => $langs->trans('Bills').' '.$facturestatic->LibStatut(1,$data[$j]->fk_statut,0), - 'url' => DOL_URL_ROOT."/compta/facture/list.php?".$billurl."&mainmenu=accountancy&leftmenu=customers_bills", - 'logo' => 'bill', - ); + $cumuldata=array_merge($cumuldata, $data); + if (! empty($data)) + { + $j=0; + while ($line < count($cumuldata)) + { + $this->info_box_contents[$line][0] = array( + 'td' => 'align="left" width="16"', + 'url' => DOL_URL_ROOT."/comm/propal/list.php?mainmenu=commercial&leftmenu=propals&viewstatut=".$data[$j]->fk_statut, + 'tooltip' => $langs->trans("Proposals")." ".$propalstatic->LibStatut($data[$j]->fk_statut,0), + 'logo' => 'object_propal' + ); - $this->info_box_contents[$line][1] = array( - 'td' => '', - 'text' => $langs->trans("Bills")." ".$facturestatic->LibStatut(1,$data[$j]->fk_statut,0)." ".$data[$j]->annee, - ); + $this->info_box_contents[$line][1] = array( + 'td' => '', + 'text' => $langs->trans("Proposals")." ".$propalstatic->LibStatut($data[$j]->fk_statut,0), + ); - $this->info_box_contents[$line][2] = array( - 'td' => 'class="right"', - 'tooltip' => $langs->trans('Bills').' '.$facturestatic->LibStatut(1,$data[$j]->fk_statut,0), - 'text' => $data[$j]->nb, - 'url' => DOL_URL_ROOT."/compta/facture/list.php?".$billurl."&mainmenu=accountancy&leftmenu=customers_bills", - ); + $this->info_box_contents[$line][2] = array( + 'td' => 'class="right"', + 'text' => $data[$j]->nb, + 'tooltip' => $langs->trans("Proposals")." ".$propalstatic->LibStatut($data[$j]->fk_statut,0), + 'url' => DOL_URL_ROOT."/comm/propal/list.php?mainmenu=commercial&leftmenu=propals&viewstatut=".$data[$j]->fk_statut, + ); + $totalnb += $data[$j]->nb; - $this->info_box_contents[$line][3] = array( - 'td' => 'class="right"', - 'text' => price($data[$j]->Mnttot,1,$langs,0,0,-1,$conf->currency) - ); + $this->info_box_contents[$line][3] = array( + 'td' => 'class="right"', + 'text' => price($data[$j]->Mnttot,1,$langs,0,0,-1,$conf->currency), + ); + $totalMnt += $data[$j]->Mnttot; + $this->info_box_contents[$line][4] = array( + 'td' => 'align="right" width="18"', + 'text' => $propalstatic->LibStatut($data[$j]->fk_statut,3), + ); - // We add only for the current year - if ($data[$j]->annee == date("Y")) { - $totalnb += $data[$j]->nb; - $totalMnt += $data[$j]->Mnttot; - } - $this->info_box_contents[$line][4] = array( - 'td' => 'align="right" width="18"', - 'text' => $facturestatic->LibStatut(1,$data[$j]->fk_statut,3), - ); - $line++; - $j++; - } - if (count($data)==0) - $this->info_box_contents[$line][0] = array( - 'td' => 'align="center"', - 'text'=>$langs->trans("NoRecordedInvoices"), - ); - } - - // part 2 - $cachedir = DOL_DATA_ROOT.'/facture/temp'; - $filename = '/boxactivity-invoice2'.$fileid; - - $refresh = dol_cache_refresh($cachedir, $filename, $cachetime); - - if ($refresh) { - $sql = "SELECT f.fk_statut, SUM(f.total_ttc) as Mnttot, COUNT(*) as nb"; - $sql.= " FROM ".MAIN_DB_PREFIX."societe as s,".MAIN_DB_PREFIX."facture as f"; - $sql.= " WHERE f.entity = ".$conf->entity; - $sql.= " AND f.fk_soc = s.rowid"; - $sql.= " AND paye=0"; - $sql.= " GROUP BY f.fk_statut"; - $sql.= " ORDER BY f.fk_statut DESC"; - - $result = $db->query($sql); - if ($result) { - $num = $db->num_rows($result); - $j=0; - while ($j < $num) { - $data[$j]=$db->fetch_object($result); - $j++; - } - if (! empty($conf->global->MAIN_ACTIVATE_FILECACHE)) { - dol_filecache($cachedir, $filename, $data); - } - $db->free($result); - } else { - dol_print_error($db); - } - } else { - $data = dol_readcachefile($cachedir, $filename); - } - - $cumuldata=array_merge($cumuldata, $data); - if (! empty($data)) { - $j=0; - - while ($line < count($cumuldata)) { - $billurl="viewstatut=".$data[$j]->fk_statut."&paye=0"; - $this->info_box_contents[$line][0] = array( - 'td' => 'align="left" width="16"', - 'tooltip' => $langs->trans('Bills').' '.$facturestatic->LibStatut(0,$data[$j]->fk_statut,0), - 'url' => DOL_URL_ROOT."/compta/facture/list.php?".$billurl."&mainmenu=accountancy&leftmenu=customers_bills", - 'logo' => 'bill', - ); - - $this->info_box_contents[$line][1] = array( - 'td' => '', - 'text' => $langs->trans("Bills")." ".$facturestatic->LibStatut(0,$data[$j]->fk_statut,0), - ); - - $this->info_box_contents[$line][2] = array( - 'td' => 'class="right"', - 'text' => $data[$j]->nb, - 'tooltip' => $langs->trans('Bills').' '.$facturestatic->LibStatut(0,$data[$j]->fk_statut,0), - 'url' => DOL_URL_ROOT."/compta/facture/list.php?".$billurl."&mainmenu=accountancy&leftmenu=customers_bills", - ); - $totalnb += $data[$j]->nb; - $this->info_box_contents[$line][3] = array( - 'td' => 'class="right"', - 'text' => price($data[$j]->Mnttot,1,$langs,0,0,-1,$conf->currency), - ); - $totalMnt += $objp->Mnttot; - $this->info_box_contents[$line][4] = array( - 'td' => 'align="right" width="18"', - 'text' => $facturestatic->LibStatut(0,$data[$j]->fk_statut,3), - ); - $line++; - $j++; - } - if ($num==0) - $this->info_box_contents[$line][0] = array( - 'td' => 'align="center"', - 'text'=>$langs->trans("NoRecordedInvoices"), - ); - } else { - $this->info_box_contents[0][0] = array( - 'td' => '', - 'maxlength'=>500, 'text' => ($db->error().' sql='.$sql), - ); - } + $line++; + $j++; + } + } } // list the summary of the orders @@ -295,12 +209,10 @@ class box_activity extends ModeleBoxes if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; if($user->societe_id) $sql.= " AND s.rowid = ".$user->societe_id; $sql.= " AND c.date_commande >= '".$db->idate($tmpdate)."'"; - $sql.= " AND c.facture=0"; $sql.= " GROUP BY c.fk_statut"; $sql.= " ORDER BY c.fk_statut DESC"; $result = $db->query($sql); - if ($result) { $num = $db->num_rows($result); $j=0; @@ -359,94 +271,182 @@ class box_activity extends ModeleBoxes } } - // list the summary of the propals - if (! empty($conf->propal->enabled) && $user->rights->propale->lire) + + // list the summary of the bills + if (! empty($conf->facture->enabled) && $user->rights->facture->lire) { - include_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; - $propalstatic=new Propal($db); + include_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; + $facturestatic=new Facture($db); - $cachedir = DOL_DATA_ROOT.'/propale/temp'; - $filename = '/boxactivity-propal'.$fileid; - $refresh = dol_cache_refresh($cachedir, $filename, $cachetime); - $data = array(); - if ($refresh) - { - $sql = "SELECT p.fk_statut, SUM(p.total) as Mnttot, COUNT(*) as nb"; - $sql.= " FROM (".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."propal as p"; - if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql.= ")"; - $sql.= " WHERE p.entity = ".$conf->entity; - $sql.= " AND p.fk_soc = s.rowid"; - if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; - if($user->societe_id) $sql.= " AND s.rowid = ".$user->societe_id; - $sql.= " AND p.datep >= '".$db->idate($tmpdate)."'"; - $sql.= " AND p.date_cloture IS NULL"; // just unclosed - $sql.= " GROUP BY p.fk_statut"; - $sql.= " ORDER BY p.fk_statut DESC"; + // part 1 + $cachedir = DOL_DATA_ROOT.'/facture/temp'; + $filename = '/boxactivity-invoice'.$fileid; - $result = $db->query($sql); - if ($result) - { - $num = $db->num_rows($result); + $refresh = dol_cache_refresh($cachedir, $filename, $cachetime); + $data = array(); + if ($refresh) + { + $sql = "SELECT f.fk_statut, SUM(f.total_ttc) as Mnttot, COUNT(*) as nb"; + $sql.= " FROM (".MAIN_DB_PREFIX."societe as s,".MAIN_DB_PREFIX."facture as f"; + if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql.= ")"; + $sql.= " WHERE f.entity = ".$conf->entity; + if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; + if($user->societe_id) $sql.= " AND s.rowid = ".$user->societe_id; + $sql.= " AND f.fk_soc = s.rowid"; + $sql.= " AND f.datef >= '".$db->idate($tmpdate)."' AND paye=1"; + $sql.= " GROUP BY f.fk_statut"; + $sql.= " ORDER BY f.fk_statut DESC"; - $j=0; - while ($j < $num) { - $data[$j]=$db->fetch_object($result); - $j++; - } - if (! empty($conf->global->MAIN_ACTIVATE_FILECACHE)) { - dol_filecache($cachedir, $filename, $data); - } - $db->free($result); - } else { - dol_print_error($db); - } - } - else - { - $data = dol_readcachefile($cachedir, $filename); - } + $result = $db->query($sql); + if ($result) { + $num = $db->num_rows($result); + $j=0; + while ($j < $num) { + $data[$j]=$db->fetch_object($result); + $j++; + } + if (! empty($conf->global->MAIN_ACTIVATE_FILECACHE)) { + dol_filecache($cachedir, $filename, $data); + } + $db->free($result); + } else { + dol_print_error($db); + } + } else { + $data = dol_readcachefile($cachedir, $filename); + } - $cumuldata=array_merge($cumuldata, $data); - if (! empty($data)) - { - $j=0; - while ($line < count($cumuldata)) - { - $this->info_box_contents[$line][0] = array( - 'td' => 'align="left" width="16"', - 'url' => DOL_URL_ROOT."/comm/propal/list.php?mainmenu=commercial&leftmenu=propals&viewstatut=".$data[$j]->fk_statut, - 'tooltip' => $langs->trans("Proposals")." ".$propalstatic->LibStatut($data[$j]->fk_statut,0), - 'logo' => 'object_propal' - ); + $cumuldata=array_merge($cumuldata, $data); + if (! empty($data)) { + $j=0; + while ($line < count($cumuldata)) { + $billurl="search_status=2&paye=1&year=".$data[$j]->annee; + $this->info_box_contents[$line][0] = array( + 'td' => 'align="left" width="16"', + 'tooltip' => $langs->trans('Bills').' '.$facturestatic->LibStatut(1,$data[$j]->fk_statut,0), + 'url' => DOL_URL_ROOT."/compta/facture/list.php?".$billurl."&mainmenu=accountancy&leftmenu=customers_bills", + 'logo' => 'bill', + ); - $this->info_box_contents[$line][1] = array( - 'td' => '', - 'text' => $langs->trans("Proposals")." ".$propalstatic->LibStatut($data[$j]->fk_statut,0), - ); + $this->info_box_contents[$line][1] = array( + 'td' => '', + 'text' => $langs->trans("Bills")." ".$facturestatic->LibStatut(1,$data[$j]->fk_statut,0)." ".$data[$j]->annee, + ); - $this->info_box_contents[$line][2] = array( - 'td' => 'class="right"', - 'text' => $data[$j]->nb, - 'tooltip' => $langs->trans("Proposals")." ".$propalstatic->LibStatut($data[$j]->fk_statut,0), - 'url' => DOL_URL_ROOT."/comm/propal/list.php?mainmenu=commercial&leftmenu=propals&viewstatut=".$data[$j]->fk_statut, - ); - $totalnb += $data[$j]->nb; + $this->info_box_contents[$line][2] = array( + 'td' => 'class="right"', + 'tooltip' => $langs->trans('Bills').' '.$facturestatic->LibStatut(1,$data[$j]->fk_statut,0), + 'text' => $data[$j]->nb, + 'url' => DOL_URL_ROOT."/compta/facture/list.php?".$billurl."&mainmenu=accountancy&leftmenu=customers_bills", + ); - $this->info_box_contents[$line][3] = array( - 'td' => 'class="right"', - 'text' => price($data[$j]->Mnttot,1,$langs,0,0,-1,$conf->currency), - ); - $totalMnt += $data[$j]->Mnttot; - $this->info_box_contents[$line][4] = array( - 'td' => 'align="right" width="18"', - 'text' => $propalstatic->LibStatut($data[$j]->fk_statut,3), - ); + $this->info_box_contents[$line][3] = array( + 'td' => 'class="right"', + 'text' => price($data[$j]->Mnttot,1,$langs,0,0,-1,$conf->currency) + ); - $line++; - $j++; - } - } + // We add only for the current year + if ($data[$j]->annee == date("Y")) { + $totalnb += $data[$j]->nb; + $totalMnt += $data[$j]->Mnttot; + } + $this->info_box_contents[$line][4] = array( + 'td' => 'align="right" width="18"', + 'text' => $facturestatic->LibStatut(1,$data[$j]->fk_statut,3), + ); + $line++; + $j++; + } + if (count($data)==0) + $this->info_box_contents[$line][0] = array( + 'td' => 'align="center"', + 'text'=>$langs->trans("NoRecordedInvoices"), + ); + } + + // part 2 + $cachedir = DOL_DATA_ROOT.'/facture/temp'; + $filename = '/boxactivity-invoice2'.$fileid; + + $refresh = dol_cache_refresh($cachedir, $filename, $cachetime); + + if ($refresh) { + $sql = "SELECT f.fk_statut, SUM(f.total_ttc) as Mnttot, COUNT(*) as nb"; + $sql.= " FROM ".MAIN_DB_PREFIX."societe as s,".MAIN_DB_PREFIX."facture as f"; + $sql.= " WHERE f.entity = ".$conf->entity; + $sql.= " AND f.fk_soc = s.rowid"; + $sql.= " AND paye=0"; + $sql.= " GROUP BY f.fk_statut"; + $sql.= " ORDER BY f.fk_statut DESC"; + + $result = $db->query($sql); + if ($result) { + $num = $db->num_rows($result); + $j=0; + while ($j < $num) { + $data[$j]=$db->fetch_object($result); + $j++; + } + if (! empty($conf->global->MAIN_ACTIVATE_FILECACHE)) { + dol_filecache($cachedir, $filename, $data); + } + $db->free($result); + } else { + dol_print_error($db); + } + } else { + $data = dol_readcachefile($cachedir, $filename); + } + + $cumuldata=array_merge($cumuldata, $data); + if (! empty($data)) { + $j=0; + + while ($line < count($cumuldata)) { + $billurl="search_status=".$data[$j]->fk_statut."&paye=0"; + $this->info_box_contents[$line][0] = array( + 'td' => 'align="left" width="16"', + 'tooltip' => $langs->trans('Bills').' '.$facturestatic->LibStatut(0,$data[$j]->fk_statut,0), + 'url' => DOL_URL_ROOT."/compta/facture/list.php?".$billurl."&mainmenu=accountancy&leftmenu=customers_bills", + 'logo' => 'bill', + ); + + $this->info_box_contents[$line][1] = array( + 'td' => '', + 'text' => $langs->trans("Bills")." ".$facturestatic->LibStatut(0,$data[$j]->fk_statut,0), + ); + + $this->info_box_contents[$line][2] = array( + 'td' => 'class="right"', + 'text' => $data[$j]->nb, + 'tooltip' => $langs->trans('Bills').' '.$facturestatic->LibStatut(0,$data[$j]->fk_statut,0), + 'url' => DOL_URL_ROOT."/compta/facture/list.php?".$billurl."&mainmenu=accountancy&leftmenu=customers_bills", + ); + $totalnb += $data[$j]->nb; + $this->info_box_contents[$line][3] = array( + 'td' => 'class="right"', + 'text' => price($data[$j]->Mnttot,1,$langs,0,0,-1,$conf->currency), + ); + $totalMnt += $objp->Mnttot; + $this->info_box_contents[$line][4] = array( + 'td' => 'align="right" width="18"', + 'text' => $facturestatic->LibStatut(0,$data[$j]->fk_statut,3), + ); + $line++; + $j++; + } + if ($num==0) + $this->info_box_contents[$line][0] = array( + 'td' => 'align="center"', + 'text'=>$langs->trans("NoRecordedInvoices"), + ); + } else { + $this->info_box_contents[0][0] = array( + 'td' => '', + 'maxlength'=>500, 'text' => ($db->error().' sql='.$sql), + ); + } } // Add the sum in the bottom of the boxes diff --git a/htdocs/core/class/CMailFile.class.php b/htdocs/core/class/CMailFile.class.php index 3b3efe96fb0..b05b8a162a1 100644 --- a/htdocs/core/class/CMailFile.class.php +++ b/htdocs/core/class/CMailFile.class.php @@ -38,8 +38,7 @@ class CMailFile { public $sendcontext; public $sendmode; - public $sendsetup; - + var $subject; // Topic: Subject of email var $addr_from; // From: Label and EMail of sender (must include '<>'). For example '' or 'John Doe ' or ''). Note that with gmail smtps, value here is forced by google to account (but not the reply-to). // Sender: Who send the email ("Sender" has sent emails on behalf of "From"). @@ -115,14 +114,15 @@ class CMailFile global $conf, $dolibarr_main_data_root; $this->sendcontext = $sendcontext; - + + // Define this->sendmode $this->sendmode = ''; - if ($this->sendcontext == 'emailing') $this->sendmode = $conf->global->EMAILING_MAIL_SENDMODE; + if ($this->sendcontext == 'emailing' && !empty($conf->global->MAIN_MAIL_SENDMODE_EMAILING) && $conf->global->MAIN_MAIL_SENDMODE_EMAILING != 'default') + { + $this->sendmode = $conf->global->MAIN_MAIL_SENDMODE_EMAILING; + } if (empty($this->sendmode)) $this->sendmode=$conf->global->MAIN_MAIL_SENDMODE; if (empty($this->sendmode)) $this->sendmode='mail'; - - $this->sendsetup = array(); - // We define end of line (RFC 821). $this->eol="\r\n"; @@ -145,7 +145,7 @@ class CMailFile $this->alternative_boundary = 'mul_'.dol_hash(uniqid("dolibarr3"), 3); // Force md5 hash (does not contains special chars) dol_syslog("CMailFile::CMailfile: sendmode=".$this->sendmode." charset=".$conf->file->character_set_client." from=$from, to=$to, addr_cc=$addr_cc, addr_bcc=$addr_bcc, errors_to=$errors_to, trackid=$trackid sendcontext=$sendcontext", LOG_DEBUG); - dol_syslog("CMailFile::CMailfile: subject=$subject, deliveryreceipt=$deliveryreceipt, msgishtml=$msgishtml", LOG_DEBUG); + dol_syslog("CMailFile::CMailfile: subject=".$subject.", deliveryreceipt=".$deliveryreceipt.", msgishtml=".$msgishtml, LOG_DEBUG); if (empty($subject)) { @@ -157,7 +157,7 @@ class CMailFile { dol_syslog("CMailFile::CMailfile: Try to send an email with empty body"); $msg='.'; // Avoid empty message (with empty message conten show a multipart structure) - } + } // Detect if message is HTML (use fast method) if ($msgishtml == -1) @@ -230,7 +230,7 @@ class CMailFile $this->addr_bcc = $addr_bcc; $this->deliveryreceipt = $deliveryreceipt; $this->trackid = $trackid; - + $smtp_headers = $this->write_smtpheaders(); if (! empty($moreinheader)) $smtp_headers.=$moreinheader; // $moreinheader contains the \r\n @@ -339,7 +339,7 @@ class CMailFile $this->phpmailer->SetReplyTo($this->getValidAddress($from,0,1)); // Set property with this->phpmailer->setReplyTo after constructor if you want to use another value than the From // TODO Add trackid into smtp header // TODO if (! empty($moreinheader)) ... - + if (! empty($this->html)) { if (!empty($css)) @@ -487,9 +487,7 @@ class CMailFile { require_once DOL_DOCUMENT_ROOT . '/core/class/hookmanager.class.php'; $hookmanager = new HookManager($db); - $hookmanager->initHooks(array( - 'maildao' - )); + $hookmanager->initHooks(array('maildao')); $reshook = $hookmanager->executeHooks('doactions', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks if (! empty($reshook)) { @@ -532,6 +530,22 @@ class CMailFile return false; } + $keyforsmtpserver='MAIN_MAIL_SMTP_SERVER'; + $keyforsmtpport ='MAIN_MAIL_SMTP_PORT'; + $keyforsmtpid ='MAIN_MAIL_SMTPS_ID'; + $keyforsmtppw ='MAIN_MAIL_SMTPS_PW'; + $keyfortls ='MAIN_MAIL_EMAIL_TLS'; + $keyforstarttls ='MAIN_MAIL_EMAIL_STARTTLS'; + if ($this->sendcontext == 'emailing' && !empty($conf->global->MAIN_MAIL_SENDMODE_EMAILING) && $conf->global->MAIN_MAIL_SENDMODE_EMAILING != 'default') + { + $keyforsmtpserver='MAIN_MAIL_SMTP_SERVER_EMAILING'; + $keyforsmtpport ='MAIN_MAIL_SMTP_PORT_EMAILING'; + $keyforsmtpid ='MAIN_MAIL_SMTPS_ID_EMAILING'; + $keyforsmtppw ='MAIN_MAIL_SMTPS_PW_EMAILING'; + $keyfortls ='MAIN_MAIL_EMAIL_TLS_EMAILING'; + $keyforstarttls ='MAIN_MAIL_EMAIL_STARTTLS_EMAILING'; + } + // Action according to choosed sending method if ($this->sendmode == 'mail') { @@ -548,9 +562,9 @@ class CMailFile @ini_set('sendmail_from',$this->getValidAddress($this->addr_from,2)); } - // Forcage parametres - if (! empty($conf->global->MAIN_MAIL_SMTP_SERVER)) ini_set('SMTP',$conf->global->MAIN_MAIL_SMTP_SERVER); - if (! empty($conf->global->MAIN_MAIL_SMTP_PORT)) ini_set('smtp_port',$conf->global->MAIN_MAIL_SMTP_PORT); + // Force parameters + if (! empty($conf->global->$keyforsmtpserver)) ini_set('SMTP',$conf->global->$keyforsmtpserver); + if (! empty($conf->global->$keyforsmtpport)) ini_set('smtp_port',$conf->global->$keyforsmtpport); $dest=$this->getValidAddress($this->addr_to,2); if (! $dest) @@ -610,9 +624,9 @@ class CMailFile @ini_restore('sendmail_from'); } - // Forcage parametres - if (! empty($conf->global->MAIN_MAIL_SMTP_SERVER)) ini_restore('SMTP'); - if (! empty($conf->global->MAIN_MAIL_SMTP_PORT)) ini_restore('smtp_port'); + // Restore parameters + if (! empty($conf->global->$keyforsmtpserver)) ini_restore('SMTP'); + if (! empty($conf->global->$keyforsmtpport)) ini_restore('smtp_port'); } else if ($this->sendmode == 'smtps') { @@ -622,28 +636,30 @@ class CMailFile $this->smtps->setTransportType(0); // Only this method is coded in SMTPs library // Clean parameters - if (empty($conf->global->MAIN_MAIL_SMTP_SERVER)) $conf->global->MAIN_MAIL_SMTP_SERVER=ini_get('SMTP'); - if (empty($conf->global->MAIN_MAIL_SMTP_PORT)) $conf->global->MAIN_MAIL_SMTP_PORT=ini_get('smtp_port'); - - // TODO Manage alternative parameters + if (empty($conf->global->$keyforsmtpserver)) $conf->global->$keyforsmtpserver=ini_get('SMTP'); + if (empty($conf->global->$keyforsmtpport)) $conf->global->$keyforsmtpport=ini_get('smtp_port'); // If we use SSL/TLS - $server=$conf->global->MAIN_MAIL_SMTP_SERVER; - if (! empty($conf->global->MAIN_MAIL_EMAIL_TLS) && function_exists('openssl_open')) $server='ssl://'.$server; - $port=$conf->global->MAIN_MAIL_SMTP_PORT; + $server=$conf->global->$keyforsmtpserver; + $secure=''; + if (! empty($conf->global->$keyfortls) && function_exists('openssl_open')) $secure='ssl'; + if (! empty($conf->global->$keyforstarttls) && function_exists('openssl_open')) $secure='tls'; + $server=($secure?$secure.'://':'').$server; + + $port=$conf->global->$keyforsmtpport; $this->smtps->setHost($server); $this->smtps->setPort($port); // 25, 465...; $loginid=''; $loginpass=''; - if (! empty($conf->global->MAIN_MAIL_SMTPS_ID)) + if (! empty($conf->global->$keyforsmtpid)) { - $loginid = $conf->global->MAIN_MAIL_SMTPS_ID; + $loginid = $conf->global->$keyforsmtpid; $this->smtps->setID($loginid); } - if (! empty($conf->global->MAIN_MAIL_SMTPS_PW)) + if (! empty($conf->global->$keyforsmtppw)) { - $loginpass = $conf->global->MAIN_MAIL_SMTPS_PW; + $loginpass = $conf->global->$keyforsmtppw; $this->smtps->setPW($loginpass); } @@ -651,14 +667,14 @@ class CMailFile $from=$this->smtps->getFrom('org'); if (! $from) { - $this->error="Failed to send mail with smtps lib to HOST=".$server.", PORT=".$conf->global->MAIN_MAIL_SMTP_PORT."
    Sender address '$from' invalid"; + $this->error="Failed to send mail with smtps lib to HOST=".$server.", PORT=".$conf->global->$keyforsmtpport."
    Sender address '$from' invalid"; dol_syslog("CMailFile::sendfile: mail end error=".$this->error, LOG_ERR); $res=false; } $dest=$this->smtps->getTo(); if (! $dest) { - $this->error="Failed to send mail with smtps lib to HOST=".$server.", PORT=".$conf->global->MAIN_MAIL_SMTP_PORT."
    Recipient address '$dest' invalid"; + $this->error="Failed to send mail with smtps lib to HOST=".$server.", PORT=".$conf->global->$keyforsmtpport."
    Recipient address '$dest' invalid"; dol_syslog("CMailFile::sendfile: mail end error=".$this->error, LOG_ERR); $res=false; } @@ -666,7 +682,7 @@ class CMailFile if ($res) { if (! empty($conf->global->MAIN_MAIL_DEBUG)) $this->smtps->setDebug(true); - + $result=$this->smtps->sendMsg(); //print $result; @@ -684,26 +700,24 @@ class CMailFile } else if ($this->sendmode == 'swiftmailer') { - // Use Swift Mailer library // ------------------------------------------ require_once DOL_DOCUMENT_ROOT.'/includes/swiftmailer/lib/swift_required.php'; - // Forcage parametres - if (empty($conf->global->MAIN_MAIL_SMTP_SERVER)) $conf->global->MAIN_MAIL_SMTP_SERVER=ini_get('SMTP'); - if (empty($conf->global->MAIN_MAIL_SMTP_PORT)) $conf->global->MAIN_MAIL_SMTP_PORT=ini_get('smtp_port'); + // Clean parameters + if (empty($conf->global->$keyforsmtpserver)) $conf->global->$keyforsmtpserver=ini_get('SMTP'); + if (empty($conf->global->$keyforsmtpport)) $conf->global->$keyforsmtpport=ini_get('smtp_port'); // If we use SSL/TLS - $server=$conf->global->MAIN_MAIL_SMTP_SERVER; + $server=$conf->global->$keyforsmtpserver; $secure=''; - //var_dump(stream_get_transports()); - if (! empty($conf->global->MAIN_MAIL_EMAIL_TLS) && function_exists('openssl_open')) $secure='ssl'; - if (! empty($conf->global->MAIN_MAIL_EMAIL_STARTTLS) && function_exists('openssl_open')) $secure='tls'; + if (! empty($conf->global->$keyfortls) && function_exists('openssl_open')) $secure='ssl'; + if (! empty($conf->global->$keyforstarttls) && function_exists('openssl_open')) $secure='tls'; - $this->transport = Swift_SmtpTransport::newInstance($server, $conf->global->MAIN_MAIL_SMTP_PORT, $secure); + $this->transport = Swift_SmtpTransport::newInstance($server, $conf->global->$keyforsmtpport, $secure); - if (! empty($conf->global->MAIN_MAIL_SMTPS_ID)) $this->transport->setUsername($conf->global->MAIN_MAIL_SMTPS_ID); - if (! empty($conf->global->MAIN_MAIL_SMTPS_PW)) $this->transport->setPassword($conf->global->MAIN_MAIL_SMTPS_PW); + if (! empty($conf->global->$keyforsmtpid)) $this->transport->setUsername($conf->global->$keyforsmtpid); + if (! empty($conf->global->$keyforsmtppw)) $this->transport->setPassword($conf->global->$keyforsmtppw); //$smtps->_msgReplyTo = 'reply@web.com'; // Create the Mailer using your created Transport @@ -1026,7 +1040,7 @@ class CMailFile $out.= $this->eol; $out.= "--" . $this->related_boundary . $this->eol; } - + if (! $this->atleastoneimage && $strContentAltText && ! empty($conf->global->MAIN_MAIL_USE_MULTI_PART)) // Add plain text message part before html part { $out.= "Content-Type: multipart/alternative; boundary=\"".$this->alternative_boundary."\"".$this->eol; @@ -1036,7 +1050,7 @@ class CMailFile $out.= $this->eol.$strContentAltText.$this->eol; $out.= "--" . $this->alternative_boundary . $this->eol; } - + $out.= "Content-Type: text/html; charset=".$conf->file->character_set_client.$this->eol; $out.= $this->eol.$strContent.$this->eol; @@ -1154,13 +1168,30 @@ class CMailFile function check_server_port($host,$port) { global $conf; + $_retVal=0; $timeout=5; // Timeout in seconds if (function_exists('fsockopen')) { + $keyforsmtpserver='MAIN_MAIL_SMTP_SERVER'; + $keyforsmtpport ='MAIN_MAIL_SMTP_PORT'; + $keyforsmtpid ='MAIN_MAIL_SMTPS_ID'; + $keyforsmtppw ='MAIN_MAIL_SMTPS_PW'; + $keyfortls ='MAIN_MAIL_EMAIL_TLS'; + $keyforstarttls ='MAIN_MAIL_EMAIL_STARTTLS'; + if ($this->sendcontext == 'emailing' && !empty($conf->global->MAIN_MAIL_SENDMODE_EMAILING) && $conf->global->MAIN_MAIL_SENDMODE_EMAILING != 'default') + { + $keyforsmtpserver='MAIN_MAIL_SMTP_SERVER_EMAILING'; + $keyforsmtpport ='MAIN_MAIL_SMTP_PORT_EMAILING'; + $keyforsmtpid ='MAIN_MAIL_SMTPS_ID_EMAILING'; + $keyforsmtppw ='MAIN_MAIL_SMTPS_PW_EMAILING'; + $keyfortls ='MAIN_MAIL_EMAIL_TLS_EMAILING'; + $keyforstarttls ='MAIN_MAIL_EMAIL_STARTTLS_EMAILING'; + } + // If we use SSL/TLS - if (! empty($conf->global->MAIN_MAIL_EMAIL_TLS) && function_exists('openssl_open')) $host='ssl://'.$host; + if (! empty($conf->global->$keyfortls) && function_exists('openssl_open')) $host='ssl://'.$host; // tls smtp start with no encryption //if (! empty($conf->global->MAIN_MAIL_EMAIL_STARTTLS) && function_exists('openssl_open')) $host='tls://'.$host; @@ -1355,7 +1386,7 @@ class CMailFile if ($email) { $i++; - + $newemail=''; if ($format == 4) { diff --git a/htdocs/core/class/commondocgenerator.class.php b/htdocs/core/class/commondocgenerator.class.php index 1961cbb7af6..535200ab95a 100644 --- a/htdocs/core/class/commondocgenerator.class.php +++ b/htdocs/core/class/commondocgenerator.class.php @@ -374,13 +374,12 @@ abstract class CommonDocGenerator $array_key.'_total_localtax1_locale'=>price($object->total_localtax1, 0, $outputlangs), $array_key.'_total_localtax2_locale'=>price($object->total_localtax2, 0, $outputlangs), $array_key.'_total_ttc_locale'=>price($object->total_ttc, 0, $outputlangs), - $array_key.'_total_discount_ht_locale' => price($object->getTotalDiscount(), 0, $outputlangs), + $array_key.'_total_ht'=>price2num($object->total_ht), $array_key.'_total_vat'=>(! empty($object->total_vat)?price2num($object->total_vat):price2num($object->total_tva)), $array_key.'_total_localtax1'=>price2num($object->total_localtax1), $array_key.'_total_localtax2'=>price2num($object->total_localtax2), $array_key.'_total_ttc'=>price2num($object->total_ttc), - $array_key.'_total_discount_ht' => price2num($object->getTotalDiscount()), $array_key.'_multicurrency_code' => price2num($object->multicurrency_code), $array_key.'_multicurrency_tx' => price2num($object->multicurrency_tx), @@ -411,18 +410,29 @@ abstract class CommonDocGenerator $array_key.'_remain_to_pay'=>price2num($object->total_ttc - $sumpayed - $sumdeposit - $sumcreditnote, 'MT') ); + if (method_exists($object, 'getTotalDiscount')) { + $resarray[$array_key.'_total_discount_ht_locale'] = price($object->getTotalDiscount(), 0, $outputlangs); + $resarray[$array_key.'_total_discount_ht'] = price2num($object->getTotalDiscount()); + } else { + $resarray[$array_key.'_total_discount_ht_locale'] = ''; + $resarray[$array_key.'_total_discount_ht'] = ''; + } + // Add vat by rates - foreach ($object->lines as $line) + if (is_array($object->lines) && count($object->lines)>0) { - // $line->tva_tx format depends on database field accuraty, no reliable. This is kept for backward comaptibility - if (empty($resarray[$array_key.'_total_vat_'.$line->tva_tx])) $resarray[$array_key.'_total_vat_'.$line->tva_tx]=0; - $resarray[$array_key.'_total_vat_'.$line->tva_tx]+=$line->total_tva; - $resarray[$array_key.'_total_vat_locale_'.$line->tva_tx]=price($resarray[$array_key.'_total_vat_'.$line->tva_tx]); - // $vatformated is vat without not expected chars (so 20, or 8.5 or 5.99 for example) - $vatformated=vatrate($line->tva_tx); - if (empty($resarray[$array_key.'_total_vat_'.$vatformated])) $resarray[$array_key.'_total_vat_'.$vatformated]=0; - $resarray[$array_key.'_total_vat_'.$vatformated]+=$line->total_tva; - $resarray[$array_key.'_total_vat_locale_'.$vatformated]=price($resarray[$array_key.'_total_vat_'.$vatformated]); + foreach ($object->lines as $line) + { + // $line->tva_tx format depends on database field accuraty, no reliable. This is kept for backward comaptibility + if (empty($resarray[$array_key.'_total_vat_'.$line->tva_tx])) $resarray[$array_key.'_total_vat_'.$line->tva_tx]=0; + $resarray[$array_key.'_total_vat_'.$line->tva_tx]+=$line->total_tva; + $resarray[$array_key.'_total_vat_locale_'.$line->tva_tx]=price($resarray[$array_key.'_total_vat_'.$line->tva_tx]); + // $vatformated is vat without not expected chars (so 20, or 8.5 or 5.99 for example) + $vatformated=vatrate($line->tva_tx); + if (empty($resarray[$array_key.'_total_vat_'.$vatformated])) $resarray[$array_key.'_total_vat_'.$vatformated]=0; + $resarray[$array_key.'_total_vat_'.$vatformated]+=$line->total_tva; + $resarray[$array_key.'_total_vat_locale_'.$vatformated]=price($resarray[$array_key.'_total_vat_'.$vatformated]); + } } // Retrieve extrafields if (is_array($object->array_options) && count($object->array_options)) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index a9edc715b3e..450bc4ba393 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -3876,7 +3876,7 @@ abstract class CommonObject * * @param string $modelspath Relative folder where generators are placed * @param string $modele Generator to use. Caller must set it to obj->modelpdf or GETPOST('modelpdf') for example. - * @param Translate $outputlangs Language to use + * @param Translate $outputlangs Output language to use * @param int $hidedetails 1 to hide details. 0 by default * @param int $hidedesc 1 to hide product description. 0 by default * @param int $hideref 1 to hide product reference. 0 by default @@ -3885,7 +3885,7 @@ abstract class CommonObject */ protected function commonGenerateDocument($modelspath, $modele, $outputlangs, $hidedetails, $hidedesc, $hideref, $moreparams=null) { - global $conf, $langs; + global $conf, $langs, $user; $srctemplatepath=''; @@ -3903,7 +3903,6 @@ abstract class CommonObject $srctemplatepath=$tmp[1]; } - // Search template files $file=''; $classname=''; $filefound=0; $dirmodels=array('/'); @@ -3995,7 +3994,10 @@ abstract class CommonObject $arrayofrecords = array(); // The write_file of templates of adherent class need this $resultwritefile = $obj->write_file($this, $outputlangs, $srctemplatepath, 'member', 1, $moreparams); } - else $resultwritefile = $obj->write_file($this, $outputlangs, $srctemplatepath, $hidedetails, $hidedesc, $hideref, $moreparams); + else + { + $resultwritefile = $obj->write_file($this, $outputlangs, $srctemplatepath, $hidedetails, $hidedesc, $hideref, $moreparams); + } if ($resultwritefile > 0) { @@ -4005,6 +4007,58 @@ abstract class CommonObject require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; dol_delete_preview($this); + // Index file in database + if (! empty($obj->result['fullpath'])) + { + $destfull = $obj->result['fullpath']; + $upload_dir = dirname($destfull); + $destfile = basename($destfull); + $rel_dir = preg_replace('/^'.preg_quote(DOL_DATA_ROOT,'/').'/', '', $upload_dir); + + if (! preg_match('/[\\/]temp[\\/]|[\\/]thumbs|\.meta$/', $rel_dir)) // If not a tmp dir + { + $filename = basename($destfile); + $rel_dir = preg_replace('/[\\/]$/', '', $rel_dir); + $rel_dir = preg_replace('/^[\\/]/', '', $rel_dir); + + include_once DOL_DOCUMENT_ROOT.'/ecm/class/ecmfiles.class.php'; + $ecmfile=new EcmFiles($this->db); + $result = $ecmfile->fetch(0, '', ($rel_dir?$rel_dir.'/':'').$filename); + if ($result > 0) + { + $ecmfile->label = md5_file(dol_osencode($destfull)); + $ecmfile->fullpath_orig = ''; + $ecmfile->gen_or_uploaded = 'generated'; + $ecmfile->description = ''; // indexed content + $ecmfile->keyword = ''; // keyword content + $result = $ecmfile->update($user); + if ($result < 0) + { + setEventMessages($ecmfile->error, $ecmfile->errors, 'warnings'); + } + } + else + { + $ecmfile->filepath = $rel_dir; + $ecmfile->filename = $filename; + $ecmfile->label = md5_file(dol_osencode($destfull)); + $ecmfile->fullpath_orig = ''; + $ecmfile->gen_or_uploaded = 'generated'; + $ecmfile->description = ''; // indexed content + $ecmfile->keyword = ''; // keyword content + $result = $ecmfile->create($user); + if ($result < 0) + { + setEventMessages($ecmfile->error, $ecmfile->errors, 'warnings'); + } + } + } + } + else + { + dol_syslog('Method ->write_file was called on object '.get_class($obj).' and return a success but the return array ->result["fullpath"] was not set.', LOG_WARNING); + } + // Success in building document. We build meta file. dol_meta_create($this); @@ -4153,7 +4207,7 @@ abstract class CommonObject if (! is_array($optionsArray)) { - // $extrafields is not a known object, we initialize it. Best practice is to have $extrafields defined into card.php or list.php page. + // If $extrafields is not a known object, we initialize it. Best practice is to have $extrafields defined into card.php or list.php page. // TODO Use of existing extrafield is not yet ready (must mutualize code that use extrafields in form first) // global $extrafields; //if (! is_object($extrafields)) @@ -4174,7 +4228,7 @@ abstract class CommonObject if ($table_element == 'categorie') $table_element = 'categories'; // For compatibility // Request to get complementary values - if (count($optionsArray) > 0) + if (is_array($optionsArray) && count($optionsArray) > 0) { $sql = "SELECT rowid"; foreach ($optionsArray as $name => $label) @@ -4298,6 +4352,12 @@ abstract class CommonObject $this->array_options[$key] = null; } break; + /*case 'select': // Not required, we chosed value='0' for undefined values + if ($value=='-1') + { + $this->array_options[$key] = null; + } + break;*/ case 'price': $this->array_options[$key] = price2num($this->array_options[$key]); break; @@ -4431,6 +4491,12 @@ abstract class CommonObject $this->array_options["options_".$key] = null; } break; + /*case 'select': // Not required, we chosed value='0' for undefined values + if ($value=='-1') + { + $this->array_options[$key] = null; + } + break;*/ case 'price': $this->array_options["options_".$key] = price2num($this->array_options["options_".$key]); break; @@ -4499,6 +4565,9 @@ abstract class CommonObject $e = 0; foreach($extrafields->attribute_label as $key=>$label) { + // Load language if required + if (! empty($extrafields->attributes[$this->table_element]['langfile'][$key])) $langs->load($extrafields->attributes[$this->table_element]['langfile'][$key]); + if (is_array($params) && count($params)>0) { if (array_key_exists('colspan',$params)) { $colspan=$params['colspan']; @@ -4881,7 +4950,7 @@ abstract class CommonObject else { $queryarray[$field] = (int) price2num($this->{$field}); - if (empty($queryarray[$field])) $queryarray[$field]=0; // May be rest to null later if property 'nullifempty' is on for this field. + if (empty($queryarray[$field])) $queryarray[$field]=0; // May be reset to null later if property 'notnull' is -1 for this field. } } else if($this->isFloat($info)) @@ -4895,7 +4964,7 @@ abstract class CommonObject } if ($info['type'] == 'timestamp' && empty($queryarray[$field])) unset($queryarray[$field]); - if (! empty($info['nullifempty']) && empty($queryarray[$field])) $queryarray[$field] = null; + if (! empty($info['notnull']) && $info['notnull'] == -1 && empty($queryarray[$field])) $queryarray[$field] = null; } return $queryarray; @@ -4985,7 +5054,7 @@ abstract class CommonObject $fieldvalues = $this->set_save_query(); if (array_key_exists('date_creation', $fieldvalues) && empty($fieldvalues['date_creation'])) $fieldvalues['date_creation']=$this->db->idate($now); if (array_key_exists('fk_user_creat', $fieldvalues) && ! ($fieldvalues['fk_user_creat'] > 0)) $fieldvalues['fk_user_creat']=$user->id; - unset($fieldvalues['rowid']); // We suppose the field rowid is reserved field for autoincrement field. + unset($fieldvalues['rowid']); // The field 'rowid' is reserved field name for autoincrement field so we don't need it into insert. $keys=array(); $values = array(); @@ -5002,7 +5071,7 @@ abstract class CommonObject $sql.= ' ('.implode( ", ", $keys ).')'; $sql.= ' VALUES ('.implode( ", ", $values ).')'; - $res = $this->db->query( $sql ); + $res = $this->db->query($sql); if ($res===false) { $error++; $this->errors[] = $this->db->lasterror(); diff --git a/htdocs/core/class/conf.class.php b/htdocs/core/class/conf.class.php index 77c24ff4109..15a17feaea8 100644 --- a/htdocs/core/class/conf.class.php +++ b/htdocs/core/class/conf.class.php @@ -579,6 +579,9 @@ class Conf $conf->global->AGENDA_DEFAULT_FILTER_TYPE='0'; // 'AC_NON_AUTO' does not exists when AGENDA_DEFAULT_FILTER_TYPE is not on. } + $conf->global->MAIN_MODULE_DOLISTORE_API_SRV='https://www.dolistore.com'; + $conf->global->MAIN_MODULE_DOLISTORE_API_KEY='dolistorecatalogpublickey1234567'; + // For backward compatibility if (isset($this->product)) $this->produit=$this->product; if (isset($this->facture)) $this->invoice=$this->facture; diff --git a/htdocs/core/class/doleditor.class.php b/htdocs/core/class/doleditor.class.php index eaf72ffff71..e67fe9ee224 100644 --- a/htdocs/core/class/doleditor.class.php +++ b/htdocs/core/class/doleditor.class.php @@ -63,7 +63,7 @@ class DolEditor * @param string $cols Size of cols for textarea tool (textarea number of cols '70' or percent 'x%') * @param int $readonly 0=Read/Edit, 1=Read only */ - function __construct($htmlname,$content,$width='',$height=200,$toolbarname='Basic',$toolbarlocation='In',$toolbarstartexpanded=false,$uselocalbrowser=true,$okforextendededitor=true,$rows=0,$cols=0,$readonly=0) + function __construct($htmlname, $content, $width='', $height=200, $toolbarname='Basic', $toolbarlocation='In', $toolbarstartexpanded=false, $uselocalbrowser=true, $okforextendededitor=true, $rows=0, $cols=0, $readonly=0) { global $conf,$langs; @@ -282,11 +282,10 @@ class DolEditor $out.= ($this->height?' height: '.$this->height.'px; ':''); //$out.=" min-height: 100px;"; $out.= '">'; - /*$out.= preg_replace(array('/^<\?php/','/\?>$/'), array('<?php','?>'), $this->content); */ - $out.= htmlentities($this->content); + $out.= htmlspecialchars($this->content); $out.= ''; $out.= ''; $out.= ''; - } print $this->select_produits_fournisseurs_list($socid,$selected,$htmlname,$filtertype,$filtre,'',-1,0,0,$alsoproductwithnosupplierprice); } } @@ -3410,12 +3401,12 @@ class Form /** * Return list of categories having choosed type * - * @param int $type Type of category ('customer', 'supplier', 'contact', 'product', 'member'). Old mode (0, 1, 2, ...) is deprecated. - * @param string $selected Id of category preselected or 'auto' (autoselect category if there is only one element) - * @param string $htmlname HTML field name - * @param int $maxlength Maximum length for labels - * @param int $excludeafterid Exclude all categories after this leaf in category tree. - * @param int $outputmode 0=HTML select string, 1=Array + * @param string|int $type Type of category ('customer', 'supplier', 'contact', 'product', 'member'). Old mode (0, 1, 2, ...) is deprecated. + * @param string $selected Id of category preselected or 'auto' (autoselect category if there is only one element) + * @param string $htmlname HTML field name + * @param int $maxlength Maximum length for labels + * @param int $excludeafterid Exclude all categories after this leaf in category tree. + * @param int $outputmode 0=HTML select string, 1=Array * @return string * @see select_categories */ @@ -3458,7 +3449,7 @@ class Form else { $cat = new Categorie($this->db); - $cate_arbo = $cat->get_full_arbo($type,$excludeafterid); + $cate_arbo = $cat->get_full_arbo($type, $excludeafterid); } $output = ''."\n"; $retstring.=''."\n"; @@ -4801,7 +4810,7 @@ class Form } else { - print "Bad value of MAIN_POPUP_CALENDAR"; + $retstring.="Bad value of MAIN_POPUP_CALENDAR"; } } // Show date with combo selects @@ -5071,7 +5080,7 @@ class Form * @param string $htmlname Name of html select area. Must start with "multi" if this is a multiselect * @param array $array Array (key => value) * @param string|string[] $id Preselected key or preselected keys for multiselect - * @param int $show_empty 0 no empty value allowed, 1 or string to add an empty value into list (value is '' or ' ' if 1), <0 to add an empty value with key that is this value. + * @param int|string $show_empty 0 no empty value allowed, 1 or string to add an empty value into list (key is -1 and value is '' or ' ' if 1, key is -1 and value is text if string), <0 to add an empty value with key that is this value. * @param int $key_in_label 1 to show key into label with format "[key] value" * @param int $value_as_key 1 to use value as key * @param string $moreparam Add more parameters onto the select tag. For example 'style="width: 95%"' to avoid select2 component to go over parent container diff --git a/htdocs/core/class/html.formadmin.class.php b/htdocs/core/class/html.formadmin.class.php index 16a16719366..e2a423e9ca4 100644 --- a/htdocs/core/class/html.formadmin.class.php +++ b/htdocs/core/class/html.formadmin.class.php @@ -69,7 +69,7 @@ class FormAdmin $out.= 'withto) :"").'" />'; + $out.= '
    '.$langs->trans("and").' withto) :"").'" />'; } } else @@ -489,7 +489,7 @@ class FormMail extends Form } if (! empty($this->withto) && is_array($this->withto)) { - if (! empty($this->withtofree)) $out.= " ".$langs->trans("or")." "; + if (! empty($this->withtofree)) $out.= " ".$langs->trans("and")."/".$langs->trans("or")." "; // multiselect array convert html entities into options tags, even if we dont want this, so we encode them a second time $tmparray = $this->withto; foreach($tmparray as $key => $val) @@ -522,7 +522,7 @@ class FormMail extends Form $out.= 'withtocc) : (isset($_POST["sendtocc"])?$_POST["sendtocc"]:"") ).'" />'; if (! empty($this->withtocc) && is_array($this->withtocc)) { - $out.= " ".$langs->trans("or")." "; + $out.= " ".$langs->trans("and")."/".$langs->trans("or")." "; // multiselect array convert html entities into options tags, even if we dont want this, so we encode them a second time $tmparray = $this->withtocc; foreach($tmparray as $key => $val) @@ -551,7 +551,7 @@ class FormMail extends Form $out.= 'withtoccc) : (isset($_POST["sendtoccc"])?$_POST["sendtoccc"]:"") ).'" />'; if (! empty($this->withtoccc) && is_array($this->withtoccc)) { - $out.= " ".$langs->trans("or")." "; + $out.= " ".$langs->trans("and")."/".$langs->trans("or")." "; // multiselect array convert html entities into options tags, even if we dont want this, so we encode them a second time $tmparray = $this->withtoccc; foreach($tmparray as $key => $val) diff --git a/htdocs/core/class/smtps.class.php b/htdocs/core/class/smtps.class.php index c92558bf1d3..cfaa88363a4 100644 --- a/htdocs/core/class/smtps.class.php +++ b/htdocs/core/class/smtps.class.php @@ -358,8 +358,11 @@ class SMTPs // This is done here because '@fsockopen' will not give me this // information if it failes to connect because it can't find the HOST $host=$this->getHost(); + $usetls = preg_match('@tls://@i',$host); + $host=preg_replace('@tcp://@i','',$host); // Remove prefix $host=preg_replace('@ssl://@i','',$host); // Remove prefix + $host=preg_replace('@tls://@i','',$host); // Remove prefix // @CHANGE LDR include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; @@ -373,7 +376,7 @@ class SMTPs { //See if we can connect to the SMTP server if ($this->socket = @fsockopen( - $this->getHost(), // Host to 'hit', IP or domain + preg_replace('@tls://@i','',$this->getHost()), // Host to 'hit', IP or domain $this->getPort(), // which Port number to use $this->errno, // actual system level error $this->errstr, // and any text that goes with the error @@ -416,16 +419,17 @@ class SMTPs // This improvment as provided by 'SirSir' to // accomodate both SMTP AND ESMTP capable servers $host=$this->getHost(); + $usetls = preg_match('@tls://@i',$host); + $host=preg_replace('@tcp://@i','',$host); // Remove prefix $host=preg_replace('@ssl://@i','',$host); // Remove prefix - if (!empty($conf->global->MAIN_MAIL_EMAIL_STARTTLS)) - { - $host=preg_replace('@tls://@i','',$host); // Remove prefix - $host='tls://'.$host; - } + $host=preg_replace('@tls://@i','',$host); // Remove prefix + + if ($usetls) $host='tls://'.$host; + if ( $_retVal = $this->socket_send_str('EHLO ' . $host, '250') ) { - if (!empty($conf->global->MAIN_MAIL_EMAIL_STARTTLS)) + if ($usetls) { /* The following dialog illustrates how a client and server can start a TLS STARTTLS session @@ -443,7 +447,7 @@ class SMTPs // Second pass EHLO C: EHLO client-domain.com S: 250-server-domain.com - S: 250 AUTH LOGIN + S: 250 AUTH LOGIN C: socket_send_str('STARTTLS', 220)) @@ -456,7 +460,7 @@ class SMTPs $this->_setErr(132, 'STARTTLS connection failed.'); return $_retVal; } - // Most server servers expect a 2nd pass of EHLO after TLS is established to get another time + // Most server servers expect a 2nd pass of EHLO after TLS is established to get another time // the answer with list of supported AUTH methods. They may differs between non STARTTLS and with STARTTLS. if (!$_retVal = $this->socket_send_str('EHLO '.$host, '250')) { @@ -514,8 +518,12 @@ class SMTPs { // Send the RFC821 specified HELO. $host=$this->getHost(); + $usetls = preg_match('@tls://@i',$host); + $host=preg_replace('@tcp://@i','',$host); // Remove prefix $host=preg_replace('@ssl://@i','',$host); // Remove prefix + $host=preg_replace('@tls://@i','',$host); // Remove prefix + $_retVal = $this->socket_send_str('HELO ' . $host, '250'); } @@ -1237,8 +1245,11 @@ class SMTPs */ $host=$this->getHost(); + $usetls = preg_match('@tls://@i',$host); + $host=preg_replace('@tcp://@i','',$host); // Remove prefix $host=preg_replace('@ssl://@i','',$host); // Remove prefix + $host=preg_replace('@tls://@i','',$host); // Remove prefix $host=dol_getprefix('email'); diff --git a/htdocs/core/js/blockUI.js b/htdocs/core/js/blockUI.js index c72ad69580d..6abcc706e25 100644 --- a/htdocs/core/js/blockUI.js +++ b/htdocs/core/js/blockUI.js @@ -23,7 +23,7 @@ // Examples $(document).ready(function() { // override these in your code to change the default behavior and style - $.blockUI.events = { + /*$.blockUI.events = { // styles applied when using $.growlUI dolEventValidCSS: { @@ -59,7 +59,7 @@ $(document).ready(function() { 'border-radius': '10px' } - }; + };*/ $.dolEventValid = function(title, message, timeout, onClose) { var $m = $('
    '); @@ -67,7 +67,7 @@ $(document).ready(function() { if (message) $m.append('

    '+message+'

    '); if (timeout == undefined) timeout = 3000; $.blockUI({ - message: $m, fadeIn: 200, fadeOut: 700, centerY: false, + message: $m, fadeIn: 0, fadeOut: 0, centerY: false, timeout: timeout, showOverlay: false, onUnblock: onClose, css: $.blockUI.events.dolEventValidCSS @@ -80,7 +80,7 @@ $(document).ready(function() { if (message) $m.append('

    '+message+'

    '); if (timeout == undefined) timeout = 0; $.blockUI({ - message: $m, fadeIn: 200, centerY: false, + message: $m, fadeIn: 0, centerY: false, timeout: timeout, showOverlay: false, onUnblock: onClose, css: $.blockUI.events.dolEventErrorCSS @@ -98,7 +98,6 @@ $(document).ready(function() { '-webkit-border-radius': '10px', '-moz-border-radius': '10px', 'border-radius': '10px', - opacity: .5, color: '#fff' } }); diff --git a/htdocs/core/js/lib_head.js.php b/htdocs/core/js/lib_head.js.php index 478d66f2c2a..55055792510 100644 --- a/htdocs/core/js/lib_head.js.php +++ b/htdocs/core/js/lib_head.js.php @@ -46,7 +46,7 @@ else header('Cache-Control: no-cache'); ?> /* - * ================================================================= + * ================================================================= * Purpose: * Pour la saisie des dates par calendrier Input: base "/theme/eldy" dateFieldID * "dateo" Nom du champ format "dd/MM/yyyy" Format issu de Dolibarr de @@ -63,7 +63,7 @@ function showDP(base,dateFieldID,format,codelang) showDP.datefieldID=dateFieldID; // Must be after the close var dateField=getObjectFromID(dateFieldID); - + // get positioning var thetop=getTop(dateField)+dateField.offsetHeight; @@ -86,7 +86,7 @@ function showDP(base,dateFieldID,format,codelang) showDP.box.style.position="absolute"; showDP.box.style.top=thetop + "px"; showDP.box.style.left=theleft + "px"; - + if (dateField.value) // Si il y avait valeur initiale dans champ { selDate=getDateFromFormat(dateField.value,format); @@ -129,7 +129,7 @@ function resetDP(base,dateFieldID,format,codelang) var dateField=getObjectFromID(dateFieldID); dateField.value = formatDate(new Date(), format); dpChangeDay(dateFieldID,format); - + var alreadybox=getObjectFromID("DPCancel"); if (alreadybox) showDP(base,dateFieldID,format,codelang); } @@ -147,25 +147,26 @@ function loadMonth(base,month,year,ymd,codelang) } var req=null; - + req=loadXMLDoc(theURL,null,false); if (req.responseText == '') alert('Failed to get URL '.theURL); // alert(theURL+' - '+req.responseText); // L'url doit avoir la meme racine // que la pages et elements sinon pb de securite. - showDP.box.innerHTML=req.responseText; + showDP.box.innerHTML=req.responseText; } function closeDPBox() { document.body.removeChild(showDP.box); displaySelectBoxes(); - showDP.box=null; - showDP.datefieldID=null; + showDP.box=null; + showDP.datefieldID=null; } function dpChangeDay(dateFieldID,format) { showDP.datefieldID=dateFieldID; + console.log("Call dpChangeDay, we save date into detailed fields."); var thefield=getObjectFromID(showDP.datefieldID); var thefieldday=getObjectFromID(showDP.datefieldID+"day"); @@ -200,7 +201,7 @@ function dpClickDay(year,month,day,format) var thefieldmonth=getObjectFromID(showDP.datefieldID+"month"); var thefieldyear=getObjectFromID(showDP.datefieldID+"year"); - var dt = new Date(year, month-1, day); + var dt = new Date(year, month-1, day); thefield.value=formatDate(dt,format); if(thefield.onchange) thefield.onchange.call(thefield); @@ -238,7 +239,7 @@ function getTop(theitem){ offsetTop += offsetTrail.offsetTop; offsetTrail = offsetTrail.offsetParent; } - if (navigator.userAgent.indexOf("Mac") != -1 && typeof document.body.leftMargin != "undefined") + if (navigator.userAgent.indexOf("Mac") != -1 && typeof document.body.leftMargin != "undefined") offsetTop += document.body.TopMargin; return offsetTop; } @@ -251,7 +252,7 @@ function getLeft(theitem){ offsetLeft += offsetTrail.offsetLeft; offsetTrail = offsetTrail.offsetParent; } - if (navigator.userAgent.indexOf("Mac") != -1 && typeof document.body.leftMargin != "undefined") + if (navigator.userAgent.indexOf("Mac") != -1 && typeof document.body.leftMargin != "undefined") offsetLeft += document.body.leftMargin; return offsetLeft; } @@ -260,16 +261,16 @@ function getLeft(theitem){ // Create XMLHttpRequest object and load url // Used by calendar or other ajax processes // Return req built or false if error -function loadXMLDoc(url,readyStateFunction,async) +function loadXMLDoc(url,readyStateFunction,async) { // req must be defined by caller with // var req = false; - + // branch for native XMLHttpRequest object (Mozilla, Safari...) if (window.XMLHttpRequest) { req = new XMLHttpRequest(); - + // if (req.overrideMimeType) { // req.overrideMimeType('text/xml'); // } @@ -286,7 +287,7 @@ function loadXMLDoc(url,readyStateFunction,async) try { req = new ActiveXObject("Microsoft.XMLHTTP"); } catch (e) {} - } + } } // If XMLHttpRequestObject req is ok, call URL @@ -321,9 +322,9 @@ function loadXMLDoc(url,readyStateFunction,async) */ function hideSelectBoxes() { var brsVersion = parseInt(window.navigator.appVersion.charAt(0), 10); - if (brsVersion <= 6 && window.navigator.userAgent.indexOf("MSIE 6") > -1) - { - for(var i = 0; i < document.all.length; i++) + if (brsVersion <= 6 && window.navigator.userAgent.indexOf("MSIE 6") > -1) + { + for(var i = 0; i < document.all.length; i++) { if(document.all[i].tagName) if(document.all[i].tagName == "SELECT") @@ -337,9 +338,9 @@ function hideSelectBoxes() { */ function displaySelectBoxes() { var brsVersion = parseInt(window.navigator.appVersion.charAt(0), 10); - if (brsVersion <= 6 && window.navigator.userAgent.indexOf("MSIE 6") > -1) - { - for(var i = 0; i < document.all.length; i++) + if (brsVersion <= 6 && window.navigator.userAgent.indexOf("MSIE 6") > -1) + { + for(var i = 0; i < document.all.length; i++) { if(document.all[i].tagName) if(document.all[i].tagName == "SELECT") @@ -351,7 +352,7 @@ function displaySelectBoxes() { /* - * ================================================================= + * ================================================================= * Function: * formatDate (javascript object Date(), format) Purpose: Returns a date in the * output format specified. The format string can use the following tags: Field | @@ -366,10 +367,10 @@ function displaySelectBoxes() { function formatDate(date,format) { // alert('formatDate date='+date+' format='+format); - + // Force parametres en chaine format=format+""; - + var result=""; var year=date.getYear()+""; if (year.length < 4) { year=""+(year-0+1900); } @@ -402,7 +403,7 @@ function formatDate(date,format) else if (substr == 'mm') { result=result+(minute<0||minute>9?"":"0")+minute; } else if (substr == 'ss') { result=result+(seconde<0||seconde>9?"":"0")+seconde; } else { result=result+substr; } - + i+=substr.length; } @@ -412,22 +413,22 @@ function formatDate(date,format) /* - * ================================================================= + * ================================================================= * Function: * getDateFromFormat(date_string, format_string) Purpose: This function takes a * date string and a format string. It parses the date string with format and it * returns the date as a javascript Date() object. If date does not match - * format, it returns 0. The format string can use the following tags: + * format, it returns 0. The format string can use the following tags: * Field | Tags * -------------+----------------------------------- - * Year | yyyy (4 digits), yy (2 digits) - * Month | MM (2 digits) - * Day of Month | dd (2 digits) - * Hour (1-12) | hh (2 digits) - * Hour (0-23) | HH (2 digits) - * Minute | mm (2 digits) + * Year | yyyy (4 digits), yy (2 digits) + * Month | MM (2 digits) + * Day of Month | dd (2 digits) + * Hour (1-12) | hh (2 digits) + * Hour (0-23) | HH (2 digits) + * Minute | mm (2 digits) * Second | ss (2 digits) - * Author: Laurent Destailleur + * Author: Laurent Destailleur * Licence: GPL * ================================================================== */ @@ -440,7 +441,7 @@ function getDateFromFormat(val,format) format=format+""; if (val == '') return 0; - + var now=new Date(); var year=now.getYear(); if (year.length < 4) { year=""+(year-0+1900); } var month=now.getMonth()+1; @@ -466,37 +467,37 @@ function getDateFromFormat(val,format) } // alert('substr='+substr); - if (substr == "yyyy") year=getIntegerInString(val,d,4,4); - if (substr == "yy") year=""+(getIntegerInString(val,d,2,2)-0+1900); - if (substr == "MM" ||substr == "M") - { - month=getIntegerInString(val,d,1,2); - d -= 2- month.length; - } - if (substr == "dd") - { - day=getIntegerInString(val,d,1,2); - d -= 2- day.length; - } - if (substr == "HH" ||substr == "hh" ) - { - hour=getIntegerInString(val,d,1,2); - d -= 2- hour.length; - } - if (substr == "mm"){ - minute=getIntegerInString(val,d,1,2); - d -= 2- minute.length; - } - if (substr == "ss") - { - seconde=getIntegerInString(val,d,1,2); - d -= 2- seconde.length; - } - + if (substr == "yyyy") year=getIntegerInString(val,d,4,4); + if (substr == "yy") year=""+(getIntegerInString(val,d,2,2)-0+1900); + if (substr == "MM" ||substr == "M") + { + month=getIntegerInString(val,d,1,2); + d -= 2- month.length; + } + if (substr == "dd") + { + day=getIntegerInString(val,d,1,2); + d -= 2- day.length; + } + if (substr == "HH" ||substr == "hh" ) + { + hour=getIntegerInString(val,d,1,2); + d -= 2- hour.length; + } + if (substr == "mm"){ + minute=getIntegerInString(val,d,1,2); + d -= 2- minute.length; + } + if (substr == "ss") + { + seconde=getIntegerInString(val,d,1,2); + d -= 2- seconde.length; + } + i+=substr.length; d+=substr.length; } - + // Check if format param are ok if (year==null||year<1) { return 0; } if (month==null||(month<1)||(month>12)) { return 0; } @@ -504,15 +505,15 @@ function getDateFromFormat(val,format) if (hour==null||(hour<0)||(hour>24)) { return 0; } if (minute==null||(minute<0)||(minute>60)) { return 0; } if (seconde==null||(seconde<0)||(seconde>60)) { return 0; } - + // alert(year+' '+month+' '+day+' '+hour+' '+minute+' '+seconde); return new Date(year,month-1,day,hour,minute,seconde); } /* - * ================================================================= + * ================================================================= * Function: - * stringIsInteger(string) + * stringIsInteger(string) * Purpose: Return true if string is an integer * ================================================================== */ @@ -530,9 +531,9 @@ function stringIsInteger(str) } /* - * ================================================================= + * ================================================================= * Function: - * getIntegerInString(string,pos,minlength,maxlength) + * getIntegerInString(string,pos,minlength,maxlength) * Purpose: Return part of string from position i that is integer * ================================================================== */ @@ -549,10 +550,10 @@ function getIntegerInString(str,i,minlength,maxlength) /* - * ================================================================= + * ================================================================= * Purpose: - * Clean string to have it url encoded - * Input: s + * Clean string to have it url encoded + * Input: s * Author: Laurent Destailleur * Licence: GPL * ================================================================== @@ -566,11 +567,11 @@ function urlencode(s) { /* - * ================================================================= + * ================================================================= * Purpose: * Applique un delai avant execution. Used for autocompletion of companies. - * Input: funct, delay - * Author: Regis Houssin + * Input: funct, delay + * Author: Regis Houssin * Licence: GPL * ================================================================== */ @@ -581,11 +582,11 @@ function urlencode(s) { /* - * ================================================================= + * ================================================================= * Purpose: * Clean values of a "Sortable.serialize". Used by drag and drop. - * Input: expr - * Author: Regis Houssin + * Input: expr + * Author: Regis Houssin * Licence: GPL * ================================================================== */ @@ -599,12 +600,12 @@ function cleanSerialize(expr) { /* - * ================================================================= + * ================================================================= * Purpose: Display a temporary message in input text fields (For showing help message on * input field). * Input: fieldId * Input: message - * Author: Regis Houssin + * Author: Regis Houssin * Licence: GPL * ================================================================== */ @@ -617,11 +618,11 @@ function displayMessage(fieldId,message) { } /* - * ================================================================= + * ================================================================= * Purpose: Hide a temporary message in input text fields (For showing help message on - * input field). - * Input: fiedId - * Input: message + * input field). + * Input: fiedId + * Input: message * Author: Regis Houssin * Licence: GPL * ================================================================== @@ -673,7 +674,7 @@ function setConstant(url, code, input, entity, strict) { $(newvalue).removeClass("butAction"); $(newvalue).addClass("butActionRefused"); } - }); + }); // Show another element } else if (type == "showhide" || type == "show") { $.each(data, function(key, value) { @@ -734,7 +735,7 @@ function delConstant(url, code, input, entity, strict) { $(newvalue).removeClass("butActionRefused"); $(newvalue).addClass("butAction"); } - }); + }); // Hide another element } else if (type == "showhide" || type == "hide") { $.each(data, function(key, value) { @@ -816,13 +817,13 @@ function confirmConstantAction(action, url, code, input, box, entity, yesButton, } } -/* - * ================================================================= +/* + * ================================================================= * This is to allow to transform all select box into ajax autocomplete box - * with just one line: + * with just one line: * $(function() { $( "#idofmylist" ).combobox(); }); - * Do not use it on large combo boxes - * ================================================================= + * Do not use it on large combo boxes + * ================================================================= */ (function( $ ) { $.widget( "ui.combobox", { @@ -933,11 +934,11 @@ function confirmConstantAction(action, url, code, input, box, entity, yesButton, /** * Function to output a dialog bog for copy/paste - * + * * @param string text Text to put into copy/paste area * @param string text2 Text to put under the copy/paste area */ -function copyToClipboard(text,text2) +function copyToClipboard(text,text2) { text = text.replace(/
    /g,"\n"); var newElem = '

    '+text2; @@ -951,7 +952,7 @@ function copyToClipboard(text,text2) /** * Show a popup HTML page. Use the "window.open" function. - * + * * @param string url Url * @param string title Title of popup * @return boolean False @@ -982,15 +983,17 @@ function newpopup(url,title) { function document_preview(file, type, title) { var ValidImageTypes = ["image/gif", "image/jpeg", "image/png"]; + var showOriginalSizeButton = false; + console.log("document_preview A click was done. file="+file+", type="+type+", title="+title); - + if ($.inArray(type, ValidImageTypes) < 0) { var width='85%'; var object_width='100%'; var height = $( window ).height()*0.90; var object_height='98%'; - show_preview(); + show_preview('notimage'); } else { var object_width=0; @@ -1004,23 +1007,38 @@ function document_preview(file, type, title) width = $( window ).width()*0.90; if(object_width < width){ + console.log("Object width is small, we set width of popup according to image width."); width = object_width + 30 } height = $( window ).height()*0.85; if(object_height < height){ + console.log("Object height is small, we set height of popup according to image height."); height = object_height + 80 } + else + { + showOriginalSizeButton = true; + } - show_preview(); + show_preview('image'); }; img.src = file; } - function show_preview(){ - /* console.log("file="+file+" type="+type+" width="+width+" height="+height); */ + function show_preview(mode) { + /* console.log("mode="+mode+" file="+file+" type="+type+" width="+width+" height="+height); */ var newElem = ''; + optionsbuttons = {} + if (mode == 'image' && showOriginalSizeButton) + { + optionsbuttons = { + "trans("OriginalSize")); ?>": function() { console.log("Click on original size"); jQuery(".ui-dialog-content.ui-widget-content > object").css({ "max-height": "none" }); }, + "trans("Close")); ?>": function() { $( this ).dialog( "close" ); } + }; + } + $("#dialogforpopup").html(newElem); $("#dialogforpopup").dialog({ closeOnEscape: true, @@ -1028,19 +1046,25 @@ function document_preview(file, type, title) width: width, height: height, modal: true, - title: title + title: title, + buttons: optionsbuttons }); + + if (showOriginalSizeButton) + { + jQuery(".ui-dialog-content.ui-widget-content > object").css({ "max-height": "100%", "width": "auto", "margin-left": "auto", "margin-right": "auto", "display": "block" }); + } } } /* - * Provide a function to get an URL GET parameter in javascript - * + * Provide a function to get an URL GET parameter in javascript + * * @param string name Name of parameter * @param mixed valueifnotfound Value if not found * @return string Value */ -function getParameterByName(name, valueifnotfound) +function getParameterByName(name, valueifnotfound) { name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]"); var regex = new RegExp("[\\?&]" + name + "=([^&#]*)"), @@ -1098,7 +1122,7 @@ function getParameterByName(name, valueifnotfound) } })(); -// Another solution, easier, to build a javascript rounding function +// Another solution, easier, to build a javascript rounding function function dolroundjs(number, decimals) { return +(Math.round(number + "e+" + decimals) + "e-" + decimals); } @@ -1146,10 +1170,10 @@ function price2numjs(amount) { amount = amount.replace(dec, '.'); //console.log("amount before="+amount+" rouding="+rounding) var res = Math.round10(amount, - rounding); - // Other solution is + // Other solution is // var res = dolroundjs(amount, rounding) console.log("res="+res) return res; } - + diff --git a/htdocs/core/js/lib_notification.js.php b/htdocs/core/js/lib_notification.js.php index b640f4cc81b..ba725d3e226 100644 --- a/htdocs/core/js/lib_notification.js.php +++ b/htdocs/core/js/lib_notification.js.php @@ -90,7 +90,7 @@ if (! ($_SERVER['HTTP_REFERER'] === $dolibarr_main_url_root . '/' || $_SERVER['H if (arr.length > 0) { var audio = null; global->AGENDA_NOTIFICATION_SOUND)) { + if (! empty($conf->global->AGENDA_REMINDER_BROWSER_SOUND)) { print 'audio = new Audio(\''.DOL_URL_ROOT.'/theme/common/sound/notification_agenda.wav'.'\');'; } ?> diff --git a/htdocs/core/lib/admin.lib.php b/htdocs/core/lib/admin.lib.php index 04393fa4d29..c97bd21e250 100644 --- a/htdocs/core/lib/admin.lib.php +++ b/htdocs/core/lib/admin.lib.php @@ -143,10 +143,10 @@ function run_sql($sqlfile,$silent=1,$entity='',$usesavepoint=1,$handler='',$oker { while (! feof($fp)) { - $buf = fgets($fp, 4096); + $buf = fgets($fp, 32768); // Test if request must be ran only for particular database or version (if yes, we must remove the -- comment) - if (preg_match('/^--\sV(MYSQL|PGSQL|)([0-9\.]+)/i',$buf,$reg)) + if (preg_match('/^--\sV(MYSQL|PGSQL)([^\s]*)/i',$buf,$reg)) { $qualified=1; @@ -159,20 +159,29 @@ function run_sql($sqlfile,$silent=1,$entity='',$usesavepoint=1,$handler='',$oker // restrict on version if ($qualified) { - - $versionrequest=explode('.',$reg[2]); - //print var_dump($versionrequest); - //print var_dump($versionarray); - if (! count($versionrequest) || ! count($versionarray) || versioncompare($versionrequest,$versionarray) > 0) - { - $qualified=0; - } + if (! empty($reg[2])) + { + if (is_numeric($reg[2])) // This is a version + { + $versionrequest=explode('.',$reg[2]); + //print var_dump($versionrequest); + //print var_dump($versionarray); + if (! count($versionrequest) || ! count($versionarray) || versioncompare($versionrequest,$versionarray) > 0) + { + $qualified=0; + } + } + else // This is a test on a constant. For example when we have -- VMYSQLUTF8UNICODE, we test constant $conf->global->UTF8UNICODE + { + if (empty($conf->db->dolibarr_main_db_collation) || ($reg[2] != strtoupper(preg_replace('/_/', '', $conf->db->dolibarr_main_db_collation)))) $qualified=0; + } + } } if ($qualified) { // Version qualified, delete SQL comments - $buf=preg_replace('/^--\sV(MYSQL|PGSQL|)([0-9\.]+)/i','',$buf); + $buf=preg_replace('/^--\sV(MYSQL|PGSQL)([^\s]*)/i','',$buf); //print "Ligne $i qualifi?e par version: ".$buf.'
    '; } } @@ -180,7 +189,7 @@ function run_sql($sqlfile,$silent=1,$entity='',$usesavepoint=1,$handler='',$oker // Add line buf to buffer if not a comment if (! preg_match('/^--/',$buf)) { - $buf=preg_replace('/--.*$/','',$buf); //remove comment from a line that not start with -- before add it to the buffer + $buf=preg_replace('/([,;ERLT\)])\s*--.*$/i','\1',$buf); //remove comment from a line that not start with -- before add it to the buffer $buffer .= trim($buf); } @@ -523,6 +532,43 @@ function dolibarr_set_const($db, $name, $value, $type='chaine', $visible=0, $not } + + +/** + * Prepare array with list of tabs + * + * @return array Array of tabs to show + */ +function modules_prepare_head() +{ + global $langs, $conf, $user; + $h = 0; + $head = array(); + + $head[$h][0] = DOL_URL_ROOT."/admin/modules.php?mode=common"; + $head[$h][1] = $langs->trans("AvailableModules"); + $head[$h][2] = 'common'; + $h++; + + $head[$h][0] = DOL_URL_ROOT."/admin/modules.php?mode=marketplace"; + $head[$h][1] = $langs->trans("ModulesMarketPlaces"); + $head[$h][2] = 'marketplace'; + $h++; + + $head[$h][0] = DOL_URL_ROOT."/admin/modules.php?mode=deploy"; + $head[$h][1] = $langs->trans("AddExtensionThemeModuleOrOther"); + $head[$h][2] = 'deploy'; + $h++; + + $head[$h][0] = DOL_URL_ROOT."/admin/modules.php?mode=develop"; + $head[$h][1] = $langs->trans("ModulesDevelopYourModule"); + $head[$h][2] = 'develop'; + $h++; + + return $head; +} + + /** * Prepare array with list of tabs * @@ -545,10 +591,17 @@ function security_prepare_head() $h++; $head[$h][0] = DOL_URL_ROOT."/admin/security_file.php"; - $head[$h][1] = $langs->trans("Files"); + $head[$h][1] = $langs->trans("Files").' ('.$langs->trans("Upload").')'; $head[$h][2] = 'file'; $h++; + /* + $head[$h][0] = DOL_URL_ROOT."/admin/security_file_download.php"; + $head[$h][1] = $langs->trans("Files").' ('.$langs->trans("Download").')'; + $head[$h][2] = 'filedownload'; + $h++; + */ + $head[$h][0] = DOL_URL_ROOT."/admin/proxy.php"; $head[$h][1] = $langs->trans("ExternalAccess"); $head[$h][2] = 'proxy'; diff --git a/htdocs/core/lib/agenda.lib.php b/htdocs/core/lib/agenda.lib.php index 5ac0982a3a0..0a4ad9ffcc9 100644 --- a/htdocs/core/lib/agenda.lib.php +++ b/htdocs/core/lib/agenda.lib.php @@ -412,6 +412,14 @@ function agenda_prepare_head() $head[$h][2] = 'autoactions'; $h++; + if ($conf->global->MAIN_FEATURES_LEVEL > 0) + { + $head[$h][0] = DOL_URL_ROOT."/admin/agenda_reminder.php"; + $head[$h][1] = $langs->trans("Reminders"); + $head[$h][2] = 'reminders'; + $h++; + } + $head[$h][0] = DOL_URL_ROOT."/admin/agenda_xcal.php"; $head[$h][1] = $langs->trans("ExportCal"); $head[$h][2] = 'xcal'; diff --git a/htdocs/core/lib/ajax.lib.php b/htdocs/core/lib/ajax.lib.php index 76a1458b913..dc86a2ef9f3 100644 --- a/htdocs/core/lib/ajax.lib.php +++ b/htdocs/core/lib/ajax.lib.php @@ -40,6 +40,7 @@ * Ex: array('disabled'=> ) * Ex: array('show'=> ) * Ex: array('update_textarea'=> ) + * Ex: array('option_disabled'=> id to disable and warning to show if we select a disabled value (this is possible when using autocomplete ajax) * @return string Script */ function ajax_autocompleter($selected, $htmlname, $url, $urloption='', $minLength=2, $autoselect=0, $ajaxoptions=array()) @@ -146,6 +147,7 @@ function ajax_autocompleter($selected, $htmlname, $url, $urloption='', $minLengt $("#'.$htmlname.'").val(ui.item.id).trigger("change"); // Select new value // Disable an element if (options.option_disabled) { + console.log("Make action option_disabled on #"+options.option_disabled+" with disabled="+ui.item.disabled) if (ui.item.disabled) { $("#" + options.option_disabled).prop("disabled", true); if (options.error) { @@ -154,28 +156,32 @@ function ajax_autocompleter($selected, $htmlname, $url, $urloption='', $minLengt if (options.warning) { $.jnotify(options.warning, "warning", false); // Output with jnotify the warning message } - } else { + } else { $("#" + options.option_disabled).removeAttr("disabled"); } } if (options.disabled) { + console.log("Make action disabled on each "+options.option_disabled) $.each(options.disabled, function(key, value) { $("#" + value).prop("disabled", true); }); } if (options.show) { + console.log("Make action show on each "+options.show) $.each(options.show, function(key, value) { $("#" + value).show().trigger("show"); }); } // Update an input if (ui.item.update) { + console.log("Make action update on each ui.item.update") // loop on each "update" fields $.each(ui.item.update, function(key, value) { $("#" + key).val(value).trigger("change"); }); } if (ui.item.textarea) { + console.log("Make action textarea on each ui.item.textarea") $.each(ui.item.textarea, function(key, value) { if (typeof CKEDITOR == "object" && typeof CKEDITOR.instances != "undefined" && CKEDITOR.instances[key] != "undefined") { CKEDITOR.instances[key].setData(value); @@ -192,7 +198,6 @@ function ajax_autocompleter($selected, $htmlname, $url, $urloption='', $minLengt } ,delay: 500 }).data("'.$dataforrenderITem.'")._renderItem = function( ul, item ) { - return $("
  • ") .data( "'.$dataforitem.'", item ) // jQuery UI > 1.10.0 .append( \'\' + item.label + "" ) diff --git a/htdocs/core/lib/company.lib.php b/htdocs/core/lib/company.lib.php index ae4dfe1c2e4..fe36e0e02f4 100644 --- a/htdocs/core/lib/company.lib.php +++ b/htdocs/core/lib/company.lib.php @@ -1043,7 +1043,7 @@ function show_actions_done($conf, $langs, $db, $filterobj, $objcon='', $noprint= global $param; // Check parameters - if (! is_object($filterobj)) dol_print_error('','BadParameter'); + if (! is_object($filterobj) && ! is_object($objcon)) dol_print_error('','BadParameter'); $out=''; $histo=array(); @@ -1061,24 +1061,24 @@ function show_actions_done($conf, $langs, $db, $filterobj, $objcon='', $noprint= $sql.= " a.fk_user_author, a.fk_contact,"; $sql.= " c.code as acode, c.libelle as alabel, c.picto as apicto,"; $sql.= " u.rowid as user_id, u.login as user_login, u.photo as user_photo, u.firstname as user_firstname, u.lastname as user_lastname"; - if (get_class($filterobj) == 'Societe') $sql.= ", sp.lastname, sp.firstname"; - if (get_class($filterobj) == 'Adherent') $sql.= ", m.lastname, m.firstname"; - if (get_class($filterobj) == 'CommandeFournisseur') $sql.= ", o.ref"; + if (is_object($filterobj) && get_class($filterobj) == 'Societe') $sql.= ", sp.lastname, sp.firstname"; + if (is_object($filterobj) && get_class($filterobj) == 'Adherent') $sql.= ", m.lastname, m.firstname"; + if (is_object($filterobj) && get_class($filterobj) == 'CommandeFournisseur') $sql.= ", o.ref"; $sql.= " FROM ".MAIN_DB_PREFIX."user as u, ".MAIN_DB_PREFIX."actioncomm as a"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_actioncomm as c ON a.fk_action = c.id"; - if (get_class($filterobj) == 'Societe') $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."socpeople as sp ON a.fk_contact = sp.rowid"; - if (get_class($filterobj) == 'Adherent') $sql.= ", ".MAIN_DB_PREFIX."adherent as m"; - if (get_class($filterobj) == 'CommandeFournisseur') $sql.= ", ".MAIN_DB_PREFIX."commande_fournisseur as o"; + if (is_object($filterobj) && get_class($filterobj) == 'Societe') $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."socpeople as sp ON a.fk_contact = sp.rowid"; + if (is_object($filterobj) && get_class($filterobj) == 'Adherent') $sql.= ", ".MAIN_DB_PREFIX."adherent as m"; + if (is_object($filterobj) && get_class($filterobj) == 'CommandeFournisseur') $sql.= ", ".MAIN_DB_PREFIX."commande_fournisseur as o"; $sql.= " WHERE u.rowid = a.fk_user_action"; $sql.= " AND a.entity IN (".getEntity('agenda').")"; - if (get_class($filterobj) == 'Societe' && $filterobj->id) $sql.= " AND a.fk_soc = ".$filterobj->id; - if (get_class($filterobj) == 'Project' && $filterobj->id) $sql.= " AND a.fk_project = ".$filterobj->id; - if (get_class($filterobj) == 'Adherent') + if (is_object($filterobj) && get_class($filterobj) == 'Societe' && $filterobj->id) $sql.= " AND a.fk_soc = ".$filterobj->id; + if (is_object($filterobj) && get_class($filterobj) == 'Project' && $filterobj->id) $sql.= " AND a.fk_project = ".$filterobj->id; + if (is_object($filterobj) && get_class($filterobj) == 'Adherent') { $sql.= " AND a.fk_element = m.rowid AND a.elementtype = 'member'"; if ($filterobj->id) $sql.= " AND a.fk_element = ".$filterobj->id; } - if (get_class($filterobj) == 'CommandeFournisseur') + if (is_object($filterobj) && get_class($filterobj) == 'CommandeFournisseur') { $sql.= " AND a.fk_element = o.rowid AND a.elementtype = 'order_supplier'"; if ($filterobj->id) $sql.= " AND a.fk_element = ".$filterobj->id; @@ -1239,7 +1239,7 @@ function show_actions_done($conf, $langs, $db, $filterobj, $objcon='', $noprint= $facturestatic=new Facture($db); $out.=''; - if ($objcon && get_class($objcon) == 'Contact' && get_class($filterobj) == 'Societe') + if ($objcon && get_class($objcon) == 'Contact' && $filterobj && get_class($filterobj) == 'Societe') { $out.=''; } @@ -1247,7 +1247,7 @@ function show_actions_done($conf, $langs, $db, $filterobj, $objcon='', $noprint= { $out.=''; } - if (get_class($filterobj) == 'Societe') $out.=''; + if ($filterobj && get_class($filterobj) == 'Societe') $out.=''; $out.="\n"; diff --git a/htdocs/core/lib/files.lib.php b/htdocs/core/lib/files.lib.php index 394b3e76778..8643e951fd4 100644 --- a/htdocs/core/lib/files.lib.php +++ b/htdocs/core/lib/files.lib.php @@ -284,6 +284,90 @@ function dol_dir_list_in_database($path, $filter="", $excludefilter=null, $sortc } +/** + * Complete $filearray with data from database. + * This will call doldir_list_indatabase to complate filearray. + * + * @param array $filearray Array of files get using dol_dir_list + * @param string $relativedir Relative dir from DOL_DATA_ROOT + * @return void + */ +function completeFileArrayWithDatabaseInfo(&$filearray, $relativedir) +{ + global $db, $user; + + $filearrayindatabase = dol_dir_list_in_database($relativedir, '', null, 'name', SORT_ASC); + + //var_dump($filearray); + //var_dump($filearrayindatabase); + + // Complete filearray with properties found into $filearrayindatabase + foreach($filearray as $key => $val) + { + $found=0; + // Search if it exists into $filearrayindatabase + foreach($filearrayindatabase as $key2 => $val2) + { + if ($filearrayindatabase[$key2]['name'] == $filearray[$key]['name']) + { + $filearray[$key]['position_name']=($filearrayindatabase[$key2]['position']?$filearrayindatabase[$key2]['position']:'0').'_'.$filearrayindatabase[$key2]['name']; + $filearray[$key]['position']=$filearrayindatabase[$key2]['position']; + $filearray[$key]['cover']=$filearrayindatabase[$key2]['cover']; + $filearray[$key]['acl']=$filearrayindatabase[$key2]['acl']; + $filearray[$key]['rowid']=$filearrayindatabase[$key2]['rowid']; + $filearray[$key]['label']=$filearrayindatabase[$key2]['label']; + $found=1; + break; + } + } + + if (! $found) // This happen in transition toward version 6, or if files were added manually into os dir. + { + $filearray[$key]['position']='999999'; // File not indexed are at end. So if we add a file, it will not replace an existing position + $filearray[$key]['cover']=0; + $filearray[$key]['acl']=''; + + $rel_filename = preg_replace('/^'.preg_quote(DOL_DATA_ROOT,'/').'/', '', $filearray[$key]['fullname']); + if (! preg_match('/([\\/]temp[\\/]|[\\/]thumbs|\.meta$)/', $rel_filetorenameafter)) // If not a tmp file + { + dol_syslog("list_of_documents We found a file called '".$filearray[$key]['name']."' not indexed into database. We add it"); + include_once DOL_DOCUMENT_ROOT.'/ecm/class/ecmfiles.class.php'; + $ecmfile=new EcmFiles($db); + + // Add entry into database + $filename = basename($rel_filename); + $rel_dir = dirname($rel_filename); + $rel_dir = preg_replace('/[\\/]$/', '', $rel_dir); + $rel_dir = preg_replace('/^[\\/]/', '', $rel_dir); + + $ecmfile->filepath = $rel_dir; + $ecmfile->filename = $filename; + $ecmfile->label = md5_file(dol_osencode($filearray[$key]['fullname'])); // $destfile is a full path to file + $ecmfile->fullpath_orig = $filearray[$key]['fullname']; + $ecmfile->gen_or_uploaded = 'unknown'; + $ecmfile->description = ''; // indexed content + $ecmfile->keyword = ''; // keyword content + $result = $ecmfile->create($user); + if ($result < 0) + { + setEventMessages($ecmfile->error, $ecmfile->errors, 'warnings'); + } + else + { + $filearray[$key]['rowid']=$result; + } + } + else + { + $filearray[$key]['rowid']=0; // Should not happened + } + } + } + + /*var_dump($filearray);*/ +} + + /** * Fast compare of 2 files identified by their properties ->name, ->date and ->size * @@ -588,7 +672,7 @@ function dol_copy($srcfile, $destfile, $newmask=0, $overwriteifexists=1) } /** - * Copy a dir to another dir. + * Copy a dir to another dir. This include recursive subdirectories. * * @param string $srcfile Source file (a directory) * @param string $destfile Destination file (a directory) @@ -630,7 +714,7 @@ function dolCopyDir($srcfile, $destfile, $newmask, $overwriteifexists, $arrayrep $dir_handle=opendir($ossrcfile); while ($file=readdir($dir_handle)) { - if ($file!="." && $file!="..") + if ($file != "." && $file != ".." && ! is_link($ossrcfile."/".$file)) { if (is_dir($ossrcfile."/".$file)) { @@ -679,7 +763,7 @@ function dolCopyDir($srcfile, $destfile, $newmask, $overwriteifexists, $arrayrep * Move a file into another name. * Note: * - This function differs from dol_move_uploaded_file, because it can be called in any context. - * - Database of files is updated. + * - Database indexes for files are updated. * - Test on antivirus is done only if param testvirus is provided and an antivirus was set. * * @param string $srcfile Source file (can't be a directory. use native php @rename() to move a directory) @@ -742,7 +826,7 @@ function dol_move($srcfile, $destfile, $newmask=0, $overwriteifexists=1, $testvi // Rename entry into ecm database $rel_filetorenamebefore = preg_replace('/^'.preg_quote(DOL_DATA_ROOT,'/').'/', '', $srcfile); $rel_filetorenameafter = preg_replace('/^'.preg_quote(DOL_DATA_ROOT,'/').'/', '', $destfile); - if (! preg_match('/(\/temp\/|\/thumbs|\.meta$)/', $rel_filetorenameafter)) // If not a tmp file + if (! preg_match('/([\\/]temp[\\/]|[\\/]thumbs|\.meta$)/', $rel_filetorenameafter)) // If not a tmp file { $rel_filetorenamebefore = preg_replace('/^[\\/]/', '', $rel_filetorenamebefore); $rel_filetorenameafter = preg_replace('/^[\\/]/', '', $rel_filetorenameafter); @@ -999,7 +1083,8 @@ function dol_move_uploaded_file($src_file, $dest_file, $allowoverwrite, $disable } /** - * Remove a file or several files with a mask + * Remove a file or several files with a mask. + * This delete file physically but also database indexes. * * @param string $file File to delete or mask of files to delete * @param int $disableglob Disable usage of glob like * so function is an exact delete function that will return error if no file found @@ -1154,7 +1239,7 @@ function dol_delete_dir_recursive($dir, $count=0, $nophperrors=0, $onlysub=0, &$ if ($item != "." && $item != "..") { - if (is_dir(dol_osencode("$dir/$item"))) + if (is_dir(dol_osencode("$dir/$item")) && ! is_link(dol_osencode("$dir/$item"))) { $count=dol_delete_dir_recursive("$dir/$item", $count, $nophperrors, 0, $countdeleted); } @@ -1239,16 +1324,17 @@ function dol_delete_preview($object) /** * Create a meta file with document file into same directory. - * This should allow "grep" search. - * This feature is enabled only if option MAIN_DOC_CREATE_METAFILE is set. + * This make "grep" search possible. + * This feature to generate the meta file is enabled only if option MAIN_DOC_CREATE_METAFILE is set. * * @param CommonObject $object Object - * @return int 0 if we did nothing, >0 success, <0 error + * @return int 0 if do nothing, >0 if we update meta file too, <0 if KO */ function dol_meta_create($object) { global $conf; + // Create meta file if (empty($conf->global->MAIN_DOC_CREATE_METAFILE)) return 0; // By default, no metafile. // Define parent dir of elements @@ -1266,9 +1352,9 @@ function dol_meta_create($object) { $object->fetch_thirdparty(); - $facref = dol_sanitizeFileName($object->ref); - $dir = $dir . "/" . $facref; - $file = $dir . "/" . $facref . ".meta"; + $objectref = dol_sanitizeFileName($object->ref); + $dir = $dir . "/" . $objectref; + $file = $dir . "/" . $objectref . ".meta"; if (! is_dir($dir)) { @@ -1283,15 +1369,15 @@ function dol_meta_create($object) DATE=\"" . dol_print_date($object->date,'') . "\" NB_ITEMS=\"" . $nblignes . "\" CLIENT=\"" . $client . "\" - TOTAL_HT=\"" . $object->total_ht . "\" - TOTAL_TTC=\"" . $object->total_ttc . "\"\n"; + AMOUNT_WO_TAX=\"" . $object->total_ht . "\" + AMOUNT_INC_TAX=\"" . $object->total_ttc . "\"\n"; for ($i = 0 ; $i < $nblignes ; $i++) { //Pour les articles $meta .= "ITEM_" . $i . "_QUANTITY=\"" . $object->lines[$i]->qty . "\" - ITEM_" . $i . "_TOTAL_HT=\"" . $object->lines[$i]->total_ht . "\" - ITEM_" . $i . "_TVA=\"" .$object->lines[$i]->tva_tx . "\" + ITEM_" . $i . "_AMOUNT_WO_TAX=\"" . $object->lines[$i]->total_ht . "\" + ITEM_" . $i . "_VAT=\"" .$object->lines[$i]->tva_tx . "\" ITEM_" . $i . "_DESCRIPTION=\"" . str_replace("\r\n","",nl2br($object->lines[$i]->desc)) . "\" "; } @@ -1305,6 +1391,10 @@ function dol_meta_create($object) return 1; } + else + { + dol_syslog('FailedToDetectDirInDolMetaCreateFor'.$object->element, LOG_WARNING); + } return 0; } @@ -1343,7 +1433,7 @@ function dol_init_file_process($pathtoscan='', $trackid='') /** - * Get and save an upload file (for example after submitting a new file a mail form). + * Get and save an upload file (for example after submitting a new file a mail form). Database index of file is also updated if donotupdatesession is set. * All information used are in db, conf, langs, user and _FILES. * Note: This function can be used only into a HTML page context. * @@ -1437,7 +1527,7 @@ function dol_add_file_process($upload_dir, $allowoverwrite=0, $donotupdatesessio { $rel_dir = preg_replace('/^'.preg_quote(DOL_DATA_ROOT,'/').'/', '', $upload_dir); - if (! preg_match('/[\\/]temp[\\/]/', $rel_dir)) // If not a tmp dir + if (! preg_match('/[\\/]temp[\\/]|[\\/]thumbs|\.meta$/', $rel_dir)) // If not a tmp dir { $filename = basename($destfile); $rel_dir = preg_replace('/[\\/]$/', '', $rel_dir); @@ -1839,7 +1929,7 @@ function dol_most_recent_file($dir,$regexfilter='',$excludefilter=array('(\.meta function dol_check_secure_access_document($modulepart, $original_file, $entity, $fuser='', $refname='', $mode='read') { global $user, $conf, $db; - global $dolibarr_main_data_root; + global $dolibarr_main_data_root, $dolibarr_main_document_root_alt; if (! is_object($fuser)) $fuser=$user; @@ -1875,6 +1965,16 @@ function dol_check_secure_access_document($modulepart, $original_file, $entity, $accessallowed=($user->admin && basename($original_file) == $original_file && preg_match('/^dolibarr.*\.log$/', basename($original_file))); $original_file=$dolibarr_main_data_root.'/'.$original_file; } + // Wrapping for *.zip files, like when used with url http://.../document.php?modulepart=packages&file=module_myfile.zip + elseif ($modulepart == 'packages' && !empty($dolibarr_main_data_root)) + { + // Dir for custom dirs + $tmp=explode(',', $dolibarr_main_document_root_alt); + $dirins = $tmp[0]; + + $accessallowed=($user->admin && preg_match('/^module_.*\.zip$/', basename($original_file))); + $original_file=$dirins.'/'.$original_file; + } // Wrapping for some images elseif (($modulepart == 'mycompany' || $modulepart == 'companylogo') && !empty($conf->mycompany->dir_output)) { diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 15af95ffb9c..7d654104257 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -190,8 +190,9 @@ function getBrowserInfo($user_agent) } // OS - if (preg_match('/linux/i', $user_agent)) { $os='linux'; } + if (preg_match('/linux/i', $user_agent)) { $os='linux'; } elseif (preg_match('/macintosh/i', $user_agent)) { $os='macintosh'; } + elseif (preg_match('/windows/i', $user_agent)) { $os='windows'; } // Name if (preg_match('/firefox(\/|\s)([\d\.]*)/i', $user_agent, $reg)) { $name='firefox'; $version=$reg[2]; } @@ -201,7 +202,8 @@ function getBrowserInfo($user_agent) elseif (preg_match('/epiphany/i', $user_agent)) { $name='epiphany'; } elseif (preg_match('/safari(\/|\s)([\d\.]*)/i', $user_agent, $reg)) { $name='safari'; $version=$reg[2]; } // Safari is often present in string for mobile but its not. elseif (preg_match('/opera(\/|\s)([\d\.]*)/i', $user_agent, $reg)) { $name='opera'; $version=$reg[2]; } - elseif (preg_match('/(MSIE\s([0-9]+\.[0-9]))|.*(Trident\/[0-9]+.[0-9];\srv:([0-9]+\.[0-9]+))/i', $user_agent, $reg)) { $name='ie'; $version=end($reg); } // MS products at end + elseif (preg_match('/(MSIE\s([0-9]+\.[0-9]))|.*(Trident\/[0-9]+.[0-9];.*rv:([0-9]+\.[0-9]+))/i', $user_agent, $reg)) { $name='ie'; $version=end($reg); } // MS products at end + elseif (preg_match('/(Windows NT\s([0-9]+\.[0-9])).*(Trident\/[0-9]+.[0-9];.*rv:([0-9]+\.[0-9]+))/i', $user_agent, $reg)) { $name='ie'; $version=end($reg); } // MS products at end elseif (preg_match('/l(i|y)n(x|ks)(\(|\/|\s)*([\d\.]+)/i', $user_agent, $reg)) { $name='lynxlinks'; $version=$reg[4]; } if ($tablet) { @@ -1190,10 +1192,10 @@ function dol_banner_tab($object, $paramid, $morehtml='', $shownav=1, $fieldid='r $nophoto=''; $morehtmlleft.='
    '; } - elseif ($conf->browser->layout != 'phone') { // Show no photo link + //elseif ($conf->browser->layout != 'phone') { // Show no photo link $nophoto='/public/theme/common/nophoto.png'; $morehtmlleft.='
    No photo
    '; - } + //} } } else @@ -1270,7 +1272,7 @@ function dol_banner_tab($object, $paramid, $morehtml='', $shownav=1, $fieldid='r } } - if (! $phototoshow && $conf->browser->layout != 'phone') // Show No photo link (picto of pbject) + if (! $phototoshow) // Show No photo link (picto of pbject) { $morehtmlleft.='
    '; if ($object->element == 'action') @@ -1288,6 +1290,7 @@ function dol_banner_tab($object, $paramid, $morehtml='', $shownav=1, $fieldid='r } $morehtmlleft.=''; $morehtmlleft.='
    No photo
    '; + $morehtmlleft.='
    '; } } @@ -6261,7 +6264,7 @@ function natural_search($fields, $value, $mode=0, $nofirstand=0) $newres .= $db->escape($tmpcrit2); $newres .= $tmpafter; $newres .= "'"; - if (empty($tmpcrit2)) + if ($tmpcrit2 == '') { $newres .= ' OR ' . $field . " IS NULL"; } @@ -6454,7 +6457,7 @@ function dol_mimetype($file,$default='application/octet-stream',$mode=0) /** * Return value from dictionary - * + * * @param string $tablename name of dictionary * @param string $field the value to return * @param int $id id of line @@ -6464,13 +6467,13 @@ function dol_mimetype($file,$default='application/octet-stream',$mode=0) function getDictvalue($tablename, $field, $id, $checkentity=false, $rowidfield='rowid') { global $dictvalues,$db,$langs; - + if (!isset($dictvalues[$tablename])) { $dictvalues[$tablename] = array(); $sql = 'SELECT * FROM '.$tablename.' WHERE 1'; if ($checkentity) $sql.= ' entity IN (0,'.getEntity('').')'; - + $resql = $db->query($sql); if ($resql) { @@ -6484,7 +6487,7 @@ function getDictvalue($tablename, $field, $id, $checkentity=false, $rowidfield=' dol_print_error($db); } } - + if (!empty($dictvalues[$tablename][$id])) return $dictvalues[$tablename][$id]->{$field}; // Found else // Not found { diff --git a/htdocs/core/lib/invoice.lib.php b/htdocs/core/lib/invoice.lib.php index 220cc5aeccc..4e7fa860529 100644 --- a/htdocs/core/lib/invoice.lib.php +++ b/htdocs/core/lib/invoice.lib.php @@ -4,6 +4,7 @@ * Copyright (C) 2013 Florian Henry * Copyright (C) 2015 Juanjo Menent * Copyright (C) 2017 Charlie Benke + * Copyright (C) 2017 ATM-CONSULTING * * 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 @@ -151,6 +152,16 @@ function invoice_admin_prepare_head() $head[$h][1] = $langs->trans("ExtraFieldsLines"); $head[$h][2] = 'attributeslines'; $h++; + + $head[$h][0] = DOL_URL_ROOT.'/compta/facture/admin/facture_rec_cust_extrafields.php'; + $head[$h][1] = $langs->trans("ExtraFieldsCustomerInvoicesRec"); + $head[$h][2] = 'attributesrec'; + $h++; + + $head[$h][0] = DOL_URL_ROOT.'/compta/facture/admin/facturedet_rec_cust_extrafields.php'; + $head[$h][1] = $langs->trans("ExtraFieldsLinesRec"); + $head[$h][2] = 'attributeslinesrec'; + $h++; complete_head_from_modules($conf,$langs,null,$head,$h,'invoice_admin','remove'); diff --git a/htdocs/core/lib/pdf.lib.php b/htdocs/core/lib/pdf.lib.php index 19063ae79c2..5b344056efb 100644 --- a/htdocs/core/lib/pdf.lib.php +++ b/htdocs/core/lib/pdf.lib.php @@ -748,7 +748,7 @@ function pdf_bank(&$pdf,$outputlangs,$curx,$cury,$account,$onlynumber=0,$default $pdf->MultiCell($tmplength, 3, $outputlangs->convToOutputCharset($content), 0, 'C', 0); $pdf->SetXY($curx, $cury + 1); $curx += $tmplength; - $pdf->SetFont('', 'B', $default_font_size - 4); + $pdf->SetFont('', 'B', $default_font_size - $diffsizecontent); $pdf->MultiCell($tmplength, 3, $outputlangs->transnoentities($val), 0, 'C', 0); if (empty($onlynumber)) { $pdf->line($curx, $cury + 1, $curx, $cury + 7); @@ -794,6 +794,7 @@ function pdf_bank(&$pdf,$outputlangs,$curx,$cury,$account,$onlynumber=0,$default $pdf->MultiCell(100, 3, $val, 0, 'L', 0); $tmpy=$pdf->getStringHeight(100, $val); $cury+=$tmpy; + $cur+=1; } else if (! $usedetailedbban) $cury+=1; diff --git a/htdocs/core/lib/project.lib.php b/htdocs/core/lib/project.lib.php index 607b107de2c..035b7eac57b 100644 --- a/htdocs/core/lib/project.lib.php +++ b/htdocs/core/lib/project.lib.php @@ -635,12 +635,27 @@ function projectLinesPerDay(&$inc, $parent, $fuser, $lines, &$level, &$projectsr print ''; */ + // Project + print ""; + print $projectstatic->getNomUrl(1,'',0,$langs->transnoentitiesnoconv("YourRole").': '.$projectsrole[$lines[$i]->fk_project]); + print ""; + // Ref print ''; $taskstatic->ref=($lines[$i]->ref?$lines[$i]->ref:$lines[$i]->id); print $taskstatic->getNomUrl(1,'withproject'); print ''; + if (! empty($conf->global->PROJECT_LINES_PERDAY_SHOW_THIRDPARTY)) + { + // Thirdparty + print ''; + $thirdpartystatic->id=$lines[$i]->socid; + $thirdpartystatic->name=$lines[$i]->thirdparty_name; + print $thirdpartystatic->getNomUrl(1, 'project', 10); + print ''; + } + // Label task print ""; for ($k = 0 ; $k < $level ; $k++) print "   "; @@ -654,21 +669,6 @@ function projectLinesPerDay(&$inc, $parent, $fuser, $lines, &$level, &$projectsr //print get_date_range($lines[$i]->date_start,$lines[$i]->date_end,'',$langs,0); print "\n"; - // Project - print ""; - print $projectstatic->getNomUrl(1,'',0,$langs->transnoentitiesnoconv("YourRole").': '.$projectsrole[$lines[$i]->fk_project]); - print ""; - - if (! empty($conf->global->PROJECT_LINES_PERDAY_SHOW_THIRDPARTY)) - { - // Thirdparty - print ''; - $thirdpartystatic->id=$lines[$i]->socid; - $thirdpartystatic->name=$lines[$i]->thirdparty_name; - print $thirdpartystatic->getNomUrl(1, 'project', 10); - print ''; - } - // Planned Workload print ''; if ($lines[$i]->planned_workload) print convertSecondToTime($lines[$i]->planned_workload,'allhourmin'); @@ -745,7 +745,13 @@ function projectLinesPerDay(&$inc, $parent, $fuser, $lines, &$level, &$projectsr // Warning print ''; if ((! $lines[$i]->public) && $disabledproject) print $form->textwithpicto('',$langs->trans("UserIsNotContactOfProject")); - else if ($disabledtask) print $form->textwithpicto('',$langs->trans("TaskIsNotAssignedToUser", $langs->transnoentitiesnoconv("AssignTaskToUser", '...'))); + else if ($disabledtask) + { + $titleassigntask = $langs->trans("AssignTaskToMe"); + if ($fuser->id != $user->id) $titleassigntask = $langs->trans("AssignTaskToUser", '...'); + + print $form->textwithpicto('',$langs->trans("TaskIsNotAssignedToUser", $titleassigntask)); + } print ''; print "\n"; @@ -834,6 +840,12 @@ function projectLinesPerWeek(&$inc, $firstdaytoshow, $fuser, $parent, $lines, &$ $workloadforid[$projectstatic->id]=1; } + $projectstatic->id=$lines[$i]->fk_project; + $projectstatic->ref=$lines[$i]->projectref; + $projectstatic->title=$lines[$i]->projectlabel; + $projectstatic->public=$lines[$i]->public; + $projectstatic->thirdparty_name=$lines[$i]->thirdparty_name; + print ''."\n"; // User @@ -843,6 +855,21 @@ function projectLinesPerWeek(&$inc, $firstdaytoshow, $fuser, $parent, $lines, &$ print ''; */ + // Project + print ''; + print $projectstatic->getNomUrl(1,'',0,$langs->transnoentitiesnoconv("YourRole").': '.$projectsrole[$lines[$i]->fk_project]); + print ""; + + if (! empty($conf->global->PROJECT_LINES_PERWEEK_SHOW_THIRDPARTY)) + { + // Thirdparty + print ''; + $thirdpartystatic->id=$lines[$i]->thirdparty_id; + $thirdpartystatic->name=$lines[$i]->thirdparty_name; + print $thirdpartystatic->getNomUrl(1, 'project'); + print ''; + } + // Ref print ''; $taskstatic->id=$lines[$i]->id; @@ -864,26 +891,6 @@ function projectLinesPerWeek(&$inc, $firstdaytoshow, $fuser, $parent, $lines, &$ //print get_date_range($lines[$i]->date_start,$lines[$i]->date_end,'',$langs,0); print "\n"; - // Project - print ''; - $projectstatic->id=$lines[$i]->fk_project; - $projectstatic->ref=$lines[$i]->projectref; - $projectstatic->title=$lines[$i]->projectlabel; - $projectstatic->public=$lines[$i]->public; - $projectstatic->thirdparty_name=$lines[$i]->thirdparty_name; - print $projectstatic->getNomUrl(1,'',0,$langs->transnoentitiesnoconv("YourRole").': '.$projectsrole[$lines[$i]->fk_project]); - print ""; - - if (! empty($conf->global->PROJECT_LINES_PERWEEK_SHOW_THIRDPARTY)) - { - // Thirdparty - print ''; - $thirdpartystatic->id=$lines[$i]->thirdparty_id; - $thirdpartystatic->name=$lines[$i]->thirdparty_name; - print $thirdpartystatic->getNomUrl(1, 'project'); - print ''; - } - // Planned Workload print ''; if ($lines[$i]->planned_workload) print convertSecondToTime($lines[$i]->planned_workload,'allhourmin'); @@ -961,7 +968,13 @@ function projectLinesPerWeek(&$inc, $firstdaytoshow, $fuser, $parent, $lines, &$ // Warning print ''; if ((! $lines[$i]->public) && $disabledproject) print $form->textwithpicto('',$langs->trans("UserIsNotContactOfProject")); - else if ($disabledtask) print $form->textwithpicto('',$langs->trans("TaskIsNotAssignedToUser", $langs->transnoentitiesnoconv("AssignTaskToUser", '...'))); + else if ($disabledtask) + { + $titleassigntask = $langs->trans("AssignTaskToMe"); + if ($fuser->id != $user->id) $titleassigntask = $langs->trans("AssignTaskToUser", '...'); + + print $form->textwithpicto('',$langs->trans("TaskIsNotAssignedToUser", $titleassigntask)); + } print ''; print "\n"; diff --git a/htdocs/core/lib/security.lib.php b/htdocs/core/lib/security.lib.php index d3250263a6f..581c324674a 100644 --- a/htdocs/core/lib/security.lib.php +++ b/htdocs/core/lib/security.lib.php @@ -376,7 +376,7 @@ function checkUserAccessToObject($user, $featuresarray, $objectid=0, $tableandsh $check = array('adherent','banque','user','usergroup','produit','service','produit|service','categorie'); // Test on entity only (Objects with no link to company) $checksoc = array('societe'); // Test for societe object - $checkother = array('contact'); // Test on entity and link to societe. Allowed if link is empty (Ex: contacts...). + $checkother = array('contact','agenda'); // Test on entity and link to third party. Allowed if link is empty (Ex: contacts...). $checkproject = array('projet','project'); // Test for project object $checktask = array('projet_task'); $nocheck = array('barcode','stock','fournisseur'); // No test diff --git a/htdocs/core/lib/tax.lib.php b/htdocs/core/lib/tax.lib.php index fe84d1a15ec..6fbfbec3bf6 100644 --- a/htdocs/core/lib/tax.lib.php +++ b/htdocs/core/lib/tax.lib.php @@ -2,7 +2,7 @@ /* Copyright (C) 2004-2009 Laurent Destailleur * Copyright (C) 2006-2007 Yannick Warnier * Copyright (C) 2011 Regis Houssin - * Copyright (C) 2012-2016 Juanjo Menent + * Copyright (C) 2012-2017 Juanjo Menent * Copyright (C) 2012 Cédric Salvador * Copyright (C) 2012-2014 Raphaël Doursenaud * Copyright (C) 2015 Marcos García @@ -583,11 +583,11 @@ function tax_by_date($type, $db, $y, $q, $date_start, $date_end, $modetax, $dire { $oldrowid=$assoc['rowid']; $list[$assoc['rate']]['totalht'] += $assoc['total_ht']; + $list[$assoc['rate']]['vat'] += $assoc['total_vat']; $list[$assoc['rate']]['localtax1'] += $assoc['total_localtax1']; $list[$assoc['rate']]['localtax2'] += $assoc['total_localtax2']; } - $list[$assoc['rate']]['vat'] = $assoc['total_vat']; $list[$assoc['rate']]['dtotal_ttc'][] = $assoc['total_ttc']; $list[$assoc['rate']]['dtype'][] = 'ExpenseReportPayment'; $list[$assoc['rate']]['datef'][] = $assoc['datef']; diff --git a/htdocs/core/lib/website.lib.php b/htdocs/core/lib/website.lib.php index a60be612e2d..4396b5a862c 100644 --- a/htdocs/core/lib/website.lib.php +++ b/htdocs/core/lib/website.lib.php @@ -27,6 +27,7 @@ * * @param string $content Content string * @return void + * @see dolWebsiteSaveContent */ function dolWebsiteOutput($content) { @@ -87,7 +88,61 @@ function dolWebsiteOutput($content) /** - * Clean an HTML page to report only content, so we can include it into another page + * Convert a page content to have correct links into a new html content. + * Used to ouput the page on the Preview. + * + * @param Website $website Web site object + * @param string $content Content to replace + * @return boolean True if OK + */ +function dolWebsiteReplacementOfLinks($website, $content) +{ + // Replace php code. Note $content may come from database and does not contains body tags. + $content = preg_replace('/<\?php[^\?]+\?>\n*/ims', '...php...', $content); + + // Replace relative link / with dolibarr URL + $content = preg_replace('/(href=")\/\"/', '\1'.DOL_URL_ROOT.'/websites/index.php?website='.$website->ref.'&pageid='.$website->fk_default_home.'"', $content, -1, $nbrep); + // Replace relative link /xxx.php with dolibarr URL + $content = preg_replace('/(href=")\/?([^\"]*)(\.php\")/', '\1'.DOL_URL_ROOT.'/websites/index.php?website='.$website->ref.'&pageref=\2"', $content, -1, $nbrep); + + $content = preg_replace('/url\((["\']?)medias\//', 'url(\1'.DOL_URL_ROOT.'/viewimage.php?modulepart=medias&file=', $content, -1, $nbrep); + + // ]*>/ims','/<\/body>.*$/ims'), array('', ''), $content);*/ if (empty($includehtmlcontentopened)) $includehtmlcontentopened=0; $includehtmlcontentopened++; @@ -111,7 +164,18 @@ function dolIncludeHtmlContent($contentfile) print 'ERROR: RECURSIVE CONTENT LEVEL. Depth of recursive call is more than the limit of '.$MAXLEVEL.".\n"; return; } + // file_get_contents is not possible. We must execute code with include + //$content = file_get_contents($fullpathfile); + //print preg_replace(array('/^.*]*>/ims','/<\/body>.*$/ims'), array('', ''), $content);*/ + + ob_start(); $res = include $fullpathfile; // Include because we want to execute code content + $tmpoutput = ob_get_contents(); + ob_end_clean(); + + print "\n".''."\n"; + print preg_replace(array('/^.*]*>/ims','/<\/body>.*$/ims'), array('', ''), $tmpoutput); + if (! $res) { print 'ERROR: FAILED TO INCLUDE PAGE '.$contentfile.".\n"; diff --git a/htdocs/core/modules/action/rapport.pdf.php b/htdocs/core/modules/action/rapport.pdf.php index a2d9bbe05dc..c6b652e265e 100644 --- a/htdocs/core/modules/action/rapport.pdf.php +++ b/htdocs/core/modules/action/rapport.pdf.php @@ -178,6 +178,8 @@ class CommActionRapport if (! empty($conf->global->MAIN_UMASK)) @chmod($file, octdec($conf->global->MAIN_UMASK)); + $this->result = array('fullpath'=>$file); + return 1; } } diff --git a/htdocs/core/modules/bank/doc/pdf_ban.modules.php b/htdocs/core/modules/bank/doc/pdf_ban.modules.php index 699b186a9d2..9941742d8d7 100644 --- a/htdocs/core/modules/bank/doc/pdf_ban.modules.php +++ b/htdocs/core/modules/bank/doc/pdf_ban.modules.php @@ -249,6 +249,8 @@ class pdf_ban extends ModeleBankAccountDoc if (! empty($conf->global->MAIN_UMASK)) @chmod($file, octdec($conf->global->MAIN_UMASK)); + $this->result = array('fullpath'=>$file); + return 1; // Pas d'erreur } else diff --git a/htdocs/core/modules/bank/doc/pdf_sepamandate.modules.php b/htdocs/core/modules/bank/doc/pdf_sepamandate.modules.php index 3dc615d9deb..e44ab8cafd8 100644 --- a/htdocs/core/modules/bank/doc/pdf_sepamandate.modules.php +++ b/htdocs/core/modules/bank/doc/pdf_sepamandate.modules.php @@ -396,6 +396,8 @@ class pdf_sepamandate extends ModeleBankAccountDoc if (! empty($conf->global->MAIN_UMASK)) @chmod($file, octdec($conf->global->MAIN_UMASK)); + $this->result = array('fullpath'=>$file); + return 1; // Pas d'erreur } else diff --git a/htdocs/core/modules/barcode/doc/tcpdfbarcode.modules.php b/htdocs/core/modules/barcode/doc/tcpdfbarcode.modules.php index 47912c47c20..5b9422b15e7 100644 --- a/htdocs/core/modules/barcode/doc/tcpdfbarcode.modules.php +++ b/htdocs/core/modules/barcode/doc/tcpdfbarcode.modules.php @@ -1,6 +1,6 @@ - * Copyright (C) 2005 Regis Houssin + * Copyright (C) 2005 Regis Houssin * Copyright (C) 2015 Francis Appels * * This program is free software; you can redistribute it and/or modify diff --git a/htdocs/core/modules/cheque/doc/pdf_blochet.class.php b/htdocs/core/modules/cheque/doc/pdf_blochet.class.php index dc8681a85fd..1e539a2019f 100644 --- a/htdocs/core/modules/cheque/doc/pdf_blochet.class.php +++ b/htdocs/core/modules/cheque/doc/pdf_blochet.class.php @@ -193,6 +193,8 @@ class BordereauChequeBlochet extends ModeleChequeReceipts if (! empty($conf->global->MAIN_UMASK)) @chmod($file, octdec($conf->global->MAIN_UMASK)); + $this->result = array('fullpath'=>$file); + $outputlangs->charset_output=$sav_charset_output; return 1; // Pas d'erreur } diff --git a/htdocs/core/modules/commande/doc/doc_generic_order_odt.modules.php b/htdocs/core/modules/commande/doc/doc_generic_order_odt.modules.php index 9e26b31b0ce..9ff01c9f5b5 100644 --- a/htdocs/core/modules/commande/doc/doc_generic_order_odt.modules.php +++ b/htdocs/core/modules/commande/doc/doc_generic_order_odt.modules.php @@ -275,9 +275,9 @@ class doc_generic_order_odt extends ModelePDFCommandes dol_mkdir($conf->commande->dir_temp); - // If BILLING contact defined on invoice, we use it + // If CUSTOMER contact defined on order, we use it $usecontact=false; - $arrayidcontact=$object->getIdContact('external','BILLING'); + $arrayidcontact=$object->getIdContact('external','CUSTOMER'); if (count($arrayidcontact) > 0) { $usecontact=true; @@ -289,7 +289,11 @@ class doc_generic_order_odt extends ModelePDFCommandes { // On peut utiliser le nom de la societe du contact if (! empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) $socobject = $object->contact; - else $socobject = $object->thirdparty; + else { + $socobject = $object->thirdparty; + // if we have a CUSTOMER contact and we dont use it as recipient we store the contact object for later use + $contactobject = $object->contact; + } } else { @@ -356,8 +360,12 @@ class doc_generic_order_odt extends ModelePDFCommandes $array_thirdparty=$this->get_substitutionarray_thirdparty($socobject,$outputlangs); $array_objet=$this->get_substitutionarray_object($object,$outputlangs); $array_other=$this->get_substitutionarray_other($outputlangs); + // retrieve contact information for use in order as contact_xxx tags + $array_thirdparty_contact = array(); + if ($usecontact) + $array_thirdparty_contact=$this->get_substitutionarray_contact($contactobject,$outputlangs,'contact'); - $tmparray = array_merge($array_user,$array_soc,$array_thirdparty,$array_objet,$array_other); + $tmparray = array_merge($array_user,$array_soc,$array_thirdparty,$array_objet,$array_other,$array_thirdparty_contact); complete_substitutions_array($tmparray, $outputlangs, $object); // Call the ODTSubstitution hook @@ -459,6 +467,8 @@ class doc_generic_order_odt extends ModelePDFCommandes $odfHandler=null; // Destroy object + $this->result = array('fullpath'=>$file); + return 1; // Success } else diff --git a/htdocs/core/modules/commande/doc/pdf_einstein.modules.php b/htdocs/core/modules/commande/doc/pdf_einstein.modules.php index a3ae305549d..d1c25ba978f 100644 --- a/htdocs/core/modules/commande/doc/pdf_einstein.modules.php +++ b/htdocs/core/modules/commande/doc/pdf_einstein.modules.php @@ -562,15 +562,10 @@ class pdf_einstein extends ModelePDFCommandes // Show square if ($pagenb == 1) - { $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0, $object->multicurrency_code); - $bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1; - } else - { $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0, $object->multicurrency_code); - $bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1; - } + $bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1; // Affiche zone infos $posy=$this->_tableau_info($pdf, $object, $bottomlasttab, $outputlangs); @@ -587,22 +582,24 @@ class pdf_einstein extends ModelePDFCommandes */ // Pied de page - $this->_pagefoot($pdf,$object,$outputlangs); - if (method_exists($pdf,'AliasNbPages')) $pdf->AliasNbPages(); + $this->_pagefoot($pdf, $object, $outputlangs); + if (method_exists($pdf, 'AliasNbPages')) $pdf->AliasNbPages(); $pdf->Close(); - $pdf->Output($file,'F'); + $pdf->Output($file, 'F'); // Add pdfgeneration hook $hookmanager->initHooks(array('pdfgeneration')); - $parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs); + $parameters=array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs); global $action; - $reshook=$hookmanager->executeHooks('afterPDFCreation',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks + $reshook=$hookmanager->executeHooks('afterPDFCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks if (! empty($conf->global->MAIN_UMASK)) @chmod($file, octdec($conf->global->MAIN_UMASK)); + $this->result = array('fullpath'=>$file); + return 1; // Pas d'erreur } else diff --git a/htdocs/core/modules/contract/doc/doc_generic_contract_odt.modules.php b/htdocs/core/modules/contract/doc/doc_generic_contract_odt.modules.php index f9dac51389f..eeb267512d4 100644 --- a/htdocs/core/modules/contract/doc/doc_generic_contract_odt.modules.php +++ b/htdocs/core/modules/contract/doc/doc_generic_contract_odt.modules.php @@ -454,6 +454,8 @@ class doc_generic_contract_odt extends ModelePDFContract $odfHandler=null; // Destroy object + $this->result = array('fullpath'=>$file); + return 1; // Success } else diff --git a/htdocs/core/modules/contract/doc/pdf_strato.modules.php b/htdocs/core/modules/contract/doc/pdf_strato.modules.php index c06882fa121..646d00afe7b 100644 --- a/htdocs/core/modules/contract/doc/pdf_strato.modules.php +++ b/htdocs/core/modules/contract/doc/pdf_strato.modules.php @@ -396,6 +396,8 @@ class pdf_strato extends ModelePDFContract if (! empty($conf->global->MAIN_UMASK)) @chmod($file, octdec($conf->global->MAIN_UMASK)); + $this->result = array('fullpath'=>$file); + return 1; } else diff --git a/htdocs/core/modules/dons/html_cerfafr.modules.php b/htdocs/core/modules/dons/html_cerfafr.modules.php index 5e557f95f33..24027375528 100644 --- a/htdocs/core/modules/dons/html_cerfafr.modules.php +++ b/htdocs/core/modules/dons/html_cerfafr.modules.php @@ -259,6 +259,8 @@ class html_cerfafr extends ModeleDon if (! empty($conf->global->MAIN_UMASK)) @chmod($file, octdec($conf->global->MAIN_UMASK)); + $this->result = array('fullpath'=>$file); + return 1; } else diff --git a/htdocs/core/modules/expedition/doc/doc_generic_shipment_odt.modules.php b/htdocs/core/modules/expedition/doc/doc_generic_shipment_odt.modules.php index 2693a4f013a..77a5677c003 100644 --- a/htdocs/core/modules/expedition/doc/doc_generic_shipment_odt.modules.php +++ b/htdocs/core/modules/expedition/doc/doc_generic_shipment_odt.modules.php @@ -510,6 +510,8 @@ class doc_generic_shipment_odt extends ModelePdfExpedition $odfHandler=null; // Destroy object + $this->result = array('fullpath'=>$file); + return 1; // Success } else diff --git a/htdocs/core/modules/expedition/doc/pdf_merou.modules.php b/htdocs/core/modules/expedition/doc/pdf_merou.modules.php index 72b9a7e6def..68795126487 100644 --- a/htdocs/core/modules/expedition/doc/pdf_merou.modules.php +++ b/htdocs/core/modules/expedition/doc/pdf_merou.modules.php @@ -359,6 +359,8 @@ class pdf_merou extends ModelePdfExpedition if (! empty($conf->global->MAIN_UMASK)) @chmod($file, octdec($conf->global->MAIN_UMASK)); + $this->result = array('fullpath'=>$file); + return 1; } else diff --git a/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php b/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php index 3f7a73a650c..ae0b95ecc78 100644 --- a/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php +++ b/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php @@ -567,6 +567,8 @@ class pdf_rouget extends ModelePdfExpedition if (! empty($conf->global->MAIN_UMASK)) @chmod($file, octdec($conf->global->MAIN_UMASK)); + $this->result = array('fullpath'=>$file); + return 1; // No error } else diff --git a/htdocs/core/modules/expensereport/doc/pdf_standard.modules.php b/htdocs/core/modules/expensereport/doc/pdf_standard.modules.php index e4ad7b7db36..6182b5afca3 100644 --- a/htdocs/core/modules/expensereport/doc/pdf_standard.modules.php +++ b/htdocs/core/modules/expensereport/doc/pdf_standard.modules.php @@ -474,6 +474,8 @@ class pdf_standard extends ModeleExpenseReport if (! empty($conf->global->MAIN_UMASK)) @chmod($file, octdec($conf->global->MAIN_UMASK)); + $this->result = array('fullpath'=>$file); + return 1; // Pas d'erreur } else diff --git a/htdocs/core/modules/facture/doc/doc_generic_invoice_odt.modules.php b/htdocs/core/modules/facture/doc/doc_generic_invoice_odt.modules.php index a8baaab2282..79b848c5773 100644 --- a/htdocs/core/modules/facture/doc/doc_generic_invoice_odt.modules.php +++ b/htdocs/core/modules/facture/doc/doc_generic_invoice_odt.modules.php @@ -474,6 +474,8 @@ class doc_generic_invoice_odt extends ModelePDFFactures $odfHandler=null; // Destroy object + $this->result = array('fullpath'=>$file); + return 1; // Success } else diff --git a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php index 4f72175ca72..81aa216a93a 100644 --- a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php +++ b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php @@ -701,6 +701,8 @@ class pdf_crabe extends ModelePDFFactures if (! empty($conf->global->MAIN_UMASK)) @chmod($file, octdec($conf->global->MAIN_UMASK)); + $this->result = array('fullpath'=>$file); + return 1; // No error } else diff --git a/htdocs/core/modules/fichinter/doc/pdf_soleil.modules.php b/htdocs/core/modules/fichinter/doc/pdf_soleil.modules.php index 4d889f84902..f333fcafd79 100644 --- a/htdocs/core/modules/fichinter/doc/pdf_soleil.modules.php +++ b/htdocs/core/modules/fichinter/doc/pdf_soleil.modules.php @@ -392,6 +392,8 @@ class pdf_soleil extends ModelePDFFicheinter if (! empty($conf->global->MAIN_UMASK)) @chmod($file, octdec($conf->global->MAIN_UMASK)); + $this->result = array('fullpath'=>$file); + return 1; } else diff --git a/htdocs/core/modules/livraison/doc/pdf_typhon.modules.php b/htdocs/core/modules/livraison/doc/pdf_typhon.modules.php index 1f8e06eb04d..eeba25962cb 100644 --- a/htdocs/core/modules/livraison/doc/pdf_typhon.modules.php +++ b/htdocs/core/modules/livraison/doc/pdf_typhon.modules.php @@ -566,6 +566,8 @@ class pdf_typhon extends ModelePDFDeliveryOrder if (! empty($conf->global->MAIN_UMASK)) @chmod($file, octdec($conf->global->MAIN_UMASK)); + $this->result = array('fullpath'=>$file); + return 1; // pas d'erreur } else diff --git a/htdocs/core/modules/mailings/contacts1.modules.php b/htdocs/core/modules/mailings/contacts1.modules.php index 0e4966a5ada..8aae15b9cc8 100644 --- a/htdocs/core/modules/mailings/contacts1.modules.php +++ b/htdocs/core/modules/mailings/contacts1.modules.php @@ -28,8 +28,7 @@ include_once DOL_DOCUMENT_ROOT.'/core/modules/mailings/modules_mailings.php'; /** - * \class mailing_contacts1 - * \brief Class to offer a selector of emailing targets with Rule 'Poire'. + * Class to offer a selector of emailing targets from contacts */ class mailing_contacts1 extends MailingTargets { @@ -39,7 +38,7 @@ class mailing_contacts1 extends MailingTargets var $require_module=array("societe"); // Module mailing actif si modules require_module actifs var $require_admin=0; // Module mailing actif pour user admin ou non var $picto='contact'; - + var $db; @@ -101,8 +100,7 @@ class mailing_contacts1 extends MailingTargets $sql.= " AND c.no_email = 0"; $sql.= " AND c.statut = 1"; - // La requete doit retourner un champ "nb" pour etre comprise - // par parent::getNbOfRecipients + // The request must return a field called "nb" to be understandable by parent::getNbOfRecipients return parent::getNbOfRecipients($sql); } @@ -118,10 +116,86 @@ class mailing_contacts1 extends MailingTargets $langs->load("companies"); $langs->load("commercial"); $langs->load("suppliers"); + $langs->load("categories"); $s=''; - $s.=''; + $s.=''; + if ($resql) + { + $num = $this->db->num_rows($resql); + $i = 0; + while ($i < $num) + { + $obj = $this->db->fetch_object($resql); + $s.=''; + $i++; + } + } + else dol_print_error($this->db); + $s.=''; + + $s.=' '; + + // Filter on contact category + $s .= $langs->trans("ContactCategoriesShort").': '; + $sql = "SELECT c.label, count(distinct(sp.email)) AS nb"; + $sql.= " FROM "; + $sql.= " ".MAIN_DB_PREFIX."socpeople as sp,"; + $sql.= " ".MAIN_DB_PREFIX."categorie as c,"; + $sql.= " ".MAIN_DB_PREFIX."categorie_contact as cs"; + $sql.= " WHERE sp.statut = 1"; // Note that null != '' is false + //$sql.= " AND sp.no_email = 0"; + //$sql.= " AND sp.email != ''"; + //$sql.= " AND sp.entity IN (".getEntity('societe').")"; + $sql.= " AND cs.fk_categorie = c.rowid"; + $sql.= " AND cs.fk_socpeople = sp.rowid"; + $sql.= " GROUP BY c.label"; + $sql.= " ORDER BY c.label"; + $resql = $this->db->query($sql); + + $s.=''; + + $s.='
    '; + // Add prospect of a particular level + $s.=$langs->trans("NatureOfThirdParty").': '; + $s.=''; + + $s.= ' '; + + // Filter on thirdparty category + $s .= $langs->trans("CustomersProspectsCategoriesShort").': '; + $sql = "SELECT c.label, count(distinct(sp.email)) AS nb"; + $sql.= " FROM "; + $sql.= " ".MAIN_DB_PREFIX."socpeople as sp,"; + $sql.= " ".MAIN_DB_PREFIX."categorie as c,"; + $sql.= " ".MAIN_DB_PREFIX."categorie_societe as cs"; + $sql.= " WHERE sp.statut = 1"; // Note that null != '' is false + //$sql.= " AND sp.no_email = 0"; + //$sql.= " AND sp.email != ''"; + //$sql.= " AND sp.entity IN (".getEntity('societe').")"; + $sql.= " AND cs.fk_categorie = c.rowid"; + $sql.= " AND cs.fk_soc = sp.fk_soc"; + $sql.= " GROUP BY c.label"; + $sql.= " ORDER BY c.label"; + $resql = $this->db->query($sql); + + $s.=''; + + $s.= ' '; + + // Filter on thirdparty category + $s .= $langs->trans("SuppliersCategoriesShort").': '; + $sql = "SELECT c.label, count(distinct(sp.email)) AS nb"; + $sql.= " FROM "; + $sql.= " ".MAIN_DB_PREFIX."socpeople as sp,"; + $sql.= " ".MAIN_DB_PREFIX."categorie as c,"; + $sql.= " ".MAIN_DB_PREFIX."categorie_fournisseur as cs"; + $sql.= " WHERE sp.statut = 1"; // Note that null != '' is false + //$sql.= " AND sp.no_email = 0"; + //$sql.= " AND sp.email != ''"; + //$sql.= " AND sp.entity IN (".getEntity('societe').")"; + $sql.= " AND cs.fk_categorie = c.rowid"; + $sql.= " AND cs.fk_soc = sp.fk_soc"; + $sql.= " GROUP BY c.label"; + $sql.= " ORDER BY c.label"; + $resql = $this->db->query($sql); + + $s.=''; + return $s; } @@ -168,13 +328,19 @@ class mailing_contacts1 extends MailingTargets * Ajoute destinataires dans table des cibles * * @param int $mailing_id Id of emailing - * @param array $filtersarray Requete sql de selection des destinataires + * @param array $filtersarray Optional filter data (deprecated) * @return int <0 si erreur, nb ajout si ok */ function add_to_target($mailing_id,$filtersarray=array()) { global $conf, $langs; + $filter = GETPOST('filter','alpha'); + $filter_jobposition = GETPOST('filter_jobposition','alpha'); + $filter_category = GETPOST('filter_category','alpha'); + $filter_category_customer = GETPOST('filter_category_customer','alpha'); + $filter_category_supplier = GETPOST('filter_category_supplier','alpha'); + $cibles = array(); // List prospects levels @@ -197,27 +363,43 @@ class mailing_contacts1 extends MailingTargets } else dol_print_error($this->db); - // La requete doit retourner: id, email, fk_contact, name, firstname, other - $sql = "SELECT c.rowid as id, c.email as email, c.rowid as fk_contact,"; - $sql.= " c.lastname, c.firstname, c.civility as civility_id,"; + // Request must return: id, email, fk_contact, lastname, firstname, other + $sql = "SELECT sp.rowid as id, sp.email as email, sp.rowid as fk_contact, sp.lastname, sp.firstname, sp.civility as civility_id, sp.poste as jobposition,"; $sql.= " s.nom as companyname"; - $sql.= " FROM ".MAIN_DB_PREFIX."socpeople as c"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = c.fk_soc"; - $sql.= " WHERE c.entity IN (".getEntity('societe').")"; - $sql.= " AND c.email <> ''"; - $sql.= " AND c.no_email = 0"; - $sql.= " AND c.statut = 1"; - $sql.= " AND c.email NOT IN (SELECT email FROM ".MAIN_DB_PREFIX."mailing_cibles WHERE fk_mailing=".$mailing_id.")"; - foreach($filtersarray as $key) + $sql.= " FROM ".MAIN_DB_PREFIX."socpeople as sp"; + $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = sp.fk_soc"; + if ($filter_category <> 'all') $sql.= ", ".MAIN_DB_PREFIX."categorie as c"; + if ($filter_category <> 'all') $sql.= ", ".MAIN_DB_PREFIX."categorie_contact as cs"; + if ($filter_category_customer <> 'all') $sql.= ", ".MAIN_DB_PREFIX."categorie as c2"; + if ($filter_category_customer <> 'all') $sql.= ", ".MAIN_DB_PREFIX."categorie_societe as c2s"; + if ($filter_category_supplier <> 'all') $sql.= ", ".MAIN_DB_PREFIX."categorie as c3"; + if ($filter_category_supplier <> 'all') $sql.= ", ".MAIN_DB_PREFIX."categorie_fournisseur as c3s"; + $sql.= " WHERE sp.entity IN (".getEntity('societe').")"; + $sql.= " AND sp.email <> ''"; + $sql.= " AND sp.no_email = 0"; + $sql.= " AND sp.statut = 1"; + $sql.= " AND sp.email NOT IN (SELECT email FROM ".MAIN_DB_PREFIX."mailing_cibles WHERE fk_mailing=".$mailing_id.")"; + // Filter on category + if ($filter_category <> 'all') $sql.= " AND cs.fk_categorie = c.rowid AND cs.fk_socpeople = sp.rowid"; + if ($filter_category <> 'all') $sql.= " AND c.label = '".$this->db->escape($filter_category)."'"; + if ($filter_category_customer <> 'all') $sql.= " AND c2s.fk_categorie = c2.rowid AND c2s.fk_soc = sp.fk_soc"; + if ($filter_category_customer <> 'all') $sql.= " AND c2.label = '".$this->db->escape($filter_category_customer)."'"; + if ($filter_category_supplier <> 'all') $sql.= " AND c3s.fk_categorie = c3.rowid AND c3s.fk_soc = sp.fk_soc"; + if ($filter_category_supplier <> 'all') $sql.= " AND c3.label = '".$this->db->escape($filter_category_supplier)."'"; + // Filter on nature + $key = $filter; { - if ($key == 'prospects') $sql.= " AND s.client=2"; //print "xx".$key; + if ($key == 'prospects') $sql.= " AND s.client=2"; foreach($prospectlevel as $codelevel=>$valuelevel) if ($key == 'prospectslevel'.$codelevel) $sql.= " AND s.fk_prospectlevel='".$codelevel."'"; if ($key == 'customers') $sql.= " AND s.client=1"; if ($key == 'suppliers') $sql.= " AND s.fournisseur=1"; } - $sql.= " ORDER BY c.email"; - //print "x".$sql; + // Filter on job position + $key = $filter_jobposition; + if (! empty($key) && $key != 'all') $sql.= " AND sp.poste ='".$this->db->escape($key)."'"; + $sql.= " ORDER BY sp.email"; + //print "wwwwwwx".$sql; // Stocke destinataires dans cibles $result=$this->db->query($sql); @@ -242,8 +424,9 @@ class mailing_contacts1 extends MailingTargets 'firstname' => $obj->firstname, 'other' => ($langs->transnoentities("ThirdParty").'='.$obj->companyname).';'. - ($langs->transnoentities("UserTitle").'='.($obj->civility_id?$langs->transnoentities("Civility".$obj->civility_id):'')), - 'source_url' => $this->url($obj->id), + ($langs->transnoentities("UserTitle").'='.($obj->civility_id?$langs->transnoentities("Civility".$obj->civility_id):'')).';'. + ($langs->transnoentities("JobPosition").'='.$obj->jobposition), + 'source_url' => $this->url($obj->id), 'source_id' => $obj->id, 'source_type' => 'contact' ); diff --git a/htdocs/core/modules/mailings/contacts2.modules.php b/htdocs/core/modules/mailings/contacts2.modules.php deleted file mode 100644 index a9c05434cd3..00000000000 --- a/htdocs/core/modules/mailings/contacts2.modules.php +++ /dev/null @@ -1,222 +0,0 @@ - - * Copyright (C) 2013 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 - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - * or see http://www.gnu.org/ - */ - -/** - * \file htdocs/core/modules/mailings/contacts2.modules.php - * \ingroup mailing - * \brief Provides a list of recipients for mailing module - */ - -include_once DOL_DOCUMENT_ROOT.'/core/modules/mailings/modules_mailings.php'; - - -/** - * \class mailing_contacts2 - * \brief Class to manage a list of personalised recipients for mailing feature - */ -class mailing_contacts2 extends MailingTargets -{ - var $name='ContactsByFunction'; - // This label is used if no translation is found for key XXX neither MailingModuleDescXXX where XXX=name is found - var $desc='Add contacts by function'; - var $require_admin=0; - - var $require_module=array(); - var $picto='contact'; - var $db; - - - /** - * Constructor - * - * @param DoliDB $db Database handler - */ - function __construct($db) - { - $this->db=$db; - } - - - /** - * Renvoie url lien vers fiche de la source du destinataire du mailing - * - * @param int $id ID - * @return string Url lien - */ - function url($id) - { - return ''.img_object('',"contact").''; - } - - /** - * This is the main function that returns the array of emails - * - * @param int $mailing_id Id of mailing. No need to use it. - * @param array $filtersarray Function - * @return int <0 if error, number of emails added if ok - */ - function add_to_target($mailing_id,$filtersarray=array()) - { - global $conf,$langs; - - $target = array(); - - // La requete doit retourner: id, email, fk_contact, name, firstname, other - $sql = "SELECT sp.rowid as id, sp.email as email, sp.rowid as fk_contact,"; - $sql.= " sp.lastname, sp.firstname as firstname, sp.civility as civility_id,"; - $sql.= " s.nom as companyname"; - $sql.= " FROM ".MAIN_DB_PREFIX."socpeople as sp"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = sp.fk_soc"; - $sql.= " WHERE sp.entity IN (".getEntity('societe').")"; - $sql.= " AND sp.email <> ''"; // Note that null != '' is false - $sql.= " AND sp.no_email = 0"; - $sql.= " AND sp.statut = 1"; - //$sql.= " AND sp.poste != ''"; - $sql.= " AND sp.email NOT IN (SELECT email FROM ".MAIN_DB_PREFIX."mailing_cibles WHERE fk_mailing=".$mailing_id.")"; - if ($filtersarray[0]<>'all') $sql.= " AND sp.poste ='".$this->db->escape($filtersarray[0])."'"; - $sql.= " ORDER BY sp.lastname, sp.firstname"; - $resql = $this->db->query($sql); - if ($resql) - { - $num = $this->db->num_rows($resql); - $i = 0; - while ($i < $num) - { - $obj= $this->db->fetch_object($resql); - $target[] = array( - 'email' => $obj->email, - 'fk_contact' => $obj->fk_contact, - 'lastname' => $obj->lastname, - 'firstname' => $obj->firstname, - 'other' => - ($langs->transnoentities("ThirdParty").'='.$obj->companyname).';'. - ($langs->transnoentities("UserTitle").'='.($obj->civility_id?$langs->transnoentities("Civility".$obj->civility_id):'')), - 'source_url' => $this->url($obj->id), - 'source_id' => $obj->id, - 'source_type' => 'contact' - ); - $i++; - } - } - - return parent::add_to_target($mailing_id, $target); - } - - - /** - * On the main mailing area, there is a box with statistics. - * If you want to add a line in this report you must provide an - * array of SQL request that returns two field: - * One called "label", One called "nb". - * - * @return array Array with SQL requests - */ - function getSqlArrayForStats() - { - global $conf; - - $statssql=array(); - /*for ($i=0; $i<5; $i++) { - $statssql[$i] = "SELECT sp.poste as label"; - $statssql[$i].= ", count(distinct(sp.email)) as nb"; - $statssql[$i].= " FROM ".MAIN_DB_PREFIX."socpeople as sp,"; - $statssql[$i].= " ".MAIN_DB_PREFIX."societe as s"; - $statssql[$i].= " WHERE s.rowid = sp.fk_soc"; - $statssql[$i].= " AND sp.email != ''"; // Note that null != '' is false - $statssql[$i].= " AND (sp.poste IS NOT NULL AND sp.poste != '')"; - $statssql[$i].= " AND sp.entity IN (".getEntity('societe').")"; - $statssql[$i].= " GROUP BY label"; - $statssql[$i].= " ORDER BY nb DESC"; - $statssql[$i].= " LIMIT $i,1"; - }*/ - - return $statssql; - } - - - /** - * Return here number of distinct emails returned by your selector. - * - * @param string $sql Requete sql de comptage - * @return int - */ - function getNbOfRecipients($sql='') - { - global $conf; - - // We must report here number of contacts when absolutely no filter selected (so all contacts). - // Number with a filter are show in the combo list for each filter. - // If we want a filter "a position is defined", we must add it into formFilter - $sql = "SELECT count(distinct(sp.email)) as nb"; - $sql.= " FROM ".MAIN_DB_PREFIX."socpeople as sp"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = sp.fk_soc"; - $sql.= " WHERE sp.entity IN (".getEntity('societe').")"; - $sql.= " AND sp.email != ''"; // Note that null != '' is false - $sql.= " AND sp.no_email = 0"; - $sql.= " AND sp.statut = 1"; - //$sql.= " AND sp.poste != ''"; - // La requete doit retourner un champ "nb" pour etre comprise - // par parent::getNbOfRecipients - return parent::getNbOfRecipients($sql); - } - - /** - * This is to add a form filter to provide variant of selector - * If used, the HTML select must be called "filter" - * - * @return string A html select zone - */ - function formFilter() - { - global $conf, $langs; - - $langs->load("companies"); - - $sql = "SELECT sp.poste, count(distinct(sp.email)) AS nb"; - $sql.= " FROM ".MAIN_DB_PREFIX."socpeople as sp"; - $sql.= " WHERE sp.entity IN (".getEntity('societe').")"; - $sql.= " AND sp.email != ''"; // Note that null != '' is false - $sql.= " AND sp.no_email = 0"; - $sql.= " AND sp.statut = 1"; - $sql.= " AND (sp.poste IS NOT NULL AND sp.poste != '')"; - $sql.= " GROUP BY sp.poste"; - $sql.= " ORDER BY sp.poste"; - - $resql = $this->db->query($sql); - - $s=''; - $s.=''; - return $s; - } - -} - diff --git a/htdocs/core/modules/mailings/contacts3.modules.php b/htdocs/core/modules/mailings/contacts3.modules.php deleted file mode 100644 index c16f6869668..00000000000 --- a/htdocs/core/modules/mailings/contacts3.modules.php +++ /dev/null @@ -1,250 +0,0 @@ - - * Copyright (C) 2013 Laurent Destailleur - * - * 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 - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - * or see http://www.gnu.org/ - */ - -/** - * \file htdocs/core/modules/mailings/contacts3.modules.php - * \ingroup mailing - * \brief Provides a list of recipients for mailing module - */ - -include_once DOL_DOCUMENT_ROOT.'/core/modules/mailings/modules_mailings.php'; - - -/** - * Class to manage a list of personalised recipients for mailing feature - */ -class mailing_contacts3 extends MailingTargets -{ - var $name='ContactsByCompanyCategory'; - // This label is used if no translation is found for key XXX neither MailingModuleDescXXX where XXX=name is found - var $desc='Add contacts by company category'; - var $require_admin=0; - - var $require_module=array(); - var $picto='contact'; - var $db; - - - /** - * Constructor - * - * @param DoliDB $db Database handler - */ - function __construct($db) - { - $this->db=$db; - } - - /** - * Renvoie url lien vers fiche de la source du destinataire du mailing - * - * @param int $id ID - * @return string Url lien - */ - function url($id) - { - return ''.img_object('',"contact").''; - } - - /** - * This is the main function that returns the array of emails - * - * @param int $mailing_id Id of mailing. No need to use it. - * @param array $filtersarray Category - * @return int <0 if error, number of emails added if ok - */ - function add_to_target($mailing_id,$filtersarray=array()) - { - global $conf,$langs; - - $target = array(); - - // La requete doit retourner: id, email, fk_contact, name, firstname, other - $sql = "SELECT sp.rowid as id, sp.email as email, sp.rowid as fk_contact,"; - $sql.= " sp.lastname, sp.firstname, sp.civility as civility_id,"; - $sql.= " s.nom as companyname"; - $sql.= " FROM ".MAIN_DB_PREFIX."socpeople as sp"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = sp.fk_soc"; - if ($filtersarray[0] <> 'all') $sql.= ", ".MAIN_DB_PREFIX."categorie as c"; - if ($filtersarray[0] <> 'all') $sql.= ", ".MAIN_DB_PREFIX."categorie_societe as cs"; - $sql.= " WHERE sp.email <> ''"; // Note that null != '' is false - $sql.= " AND sp.no_email = 0"; - $sql.= " AND sp.statut = 1"; - $sql.= " AND sp.entity IN (".getEntity('societe').")"; - $sql.= " AND sp.email NOT IN (SELECT email FROM ".MAIN_DB_PREFIX."mailing_cibles WHERE fk_mailing=".$mailing_id.")"; - if ($filtersarray[0] <> 'all') $sql.= " AND cs.fk_categorie = c.rowid"; - if ($filtersarray[0] <> 'all') $sql.= " AND cs.fk_soc = sp.fk_soc"; - if ($filtersarray[0] <> 'all') $sql.= " AND c.label = '".$this->db->escape($filtersarray[0])."'"; - $sql.= " ORDER BY sp.lastname, sp.firstname"; - - $resql = $this->db->query($sql); - if ($resql) - { - $num = $this->db->num_rows($resql); - $i = 0; - - while ($i < $num) - { - $obj= $this->db->fetch_object($resql); - $target[] = array( - 'email' => $obj->email, - 'fk_contact' => $obj->fk_contact, - 'lastname' => $obj->lastname, - 'firstname' => $obj->firstname, - 'other' => - ($langs->transnoentities("ThirdParty").'='.$obj->companyname).';'. - ($langs->transnoentities("UserTitle").'='.($obj->civility_id?$langs->transnoentities("Civility".$obj->civility_id):'')), - 'source_url' => $this->url($obj->id), - 'source_id' => $obj->id, - 'source_type' => 'contact' - ); - $i++; - } - } - - return parent::add_to_target($mailing_id, $target); - } - - - /** - * On the main mailing area, there is a box with statistics. - * If you want to add a line in this report you must provide an - * array of SQL request that returns two field: - * One called "label", One called "nb". - * - * @return array Array with SQL requests - */ - function getSqlArrayForStats() - { - global $conf, $langs; - - $statssql=array(); - /*for ($i=0; $i<5; $i++) { - $statssql[$i] = "SELECT c.label, count(sp.rowid) AS nb"; - $statssql[$i].= " FROM ".MAIN_DB_PREFIX."socpeople as sp,"; - $statssql[$i].= " ".MAIN_DB_PREFIX."societe as s,"; - $statssql[$i].= " ".MAIN_DB_PREFIX."categorie as c,"; - $statssql[$i].= " ".MAIN_DB_PREFIX."categorie_societe as cs"; - $statssql[$i].= " WHERE s.rowid = sp.fk_soc"; - $statssql[$i].= " AND sp.email != ''"; // Note that null != '' is false - $statssql[$i].= " AND sp.entity IN (".getEntity('societe').")"; - $statssql[$i].= " AND cs.fk_categorie = c.rowid"; - $statssql[$i].= " AND cs.fk_soc = sp.fk_soc"; - $statssql[$i].= " GROUP BY c.label"; - $statssql[$i].= " ORDER BY nb DESC"; - $statssql[$i].= " LIMIT $i,1"; - }*/ - - return $statssql; - } - - - /** - * Return here number of distinct emails returned by your selector. - * - * @param string $sql Requete sql de comptage - * @return int Number of recipients - */ - function getNbOfRecipients($sql='') - { - global $conf; - - // We must report here number of contacts when absolutely no filter selected (so all contacts). - // Number with a filter are show in the combo list for each filter. - // If we want a filter "is inside at least one category", we must add it into formFilter - $sql = "SELECT count(distinct(c.email)) as nb"; - $sql.= " FROM ".MAIN_DB_PREFIX."socpeople as c"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = c.fk_soc"; - $sql.= " WHERE c.entity IN (".getEntity('societe').")"; - $sql.= " AND c.email != ''"; // Note that null != '' is false - $sql.= " AND c.no_email = 0"; - $sql.= " AND c.statut = 1"; - /* - $sql = "SELECT count(distinct(sp.email)) as nb"; - $sql.= " FROM ".MAIN_DB_PREFIX."socpeople as sp,"; - $sql.= " ".MAIN_DB_PREFIX."societe as s,"; - $sql.= " ".MAIN_DB_PREFIX."categorie as c,"; - $sql.= " ".MAIN_DB_PREFIX."categorie_societe as cs"; - $sql.= " WHERE s.rowid = sp.fk_soc"; - $sql.= " AND sp.entity IN (".getEntity('societe').")"; - $sql.= " AND sp.email != ''"; // Note that null != '' is false - $sql.= " AND cs.fk_categorie = c.rowid"; - $sql.= " AND cs.fk_soc = sp.fk_soc"; - */ - // La requete doit retourner un champ "nb" pour etre comprise - // par parent::getNbOfRecipients - return parent::getNbOfRecipients($sql); - } - - /** - * This is to add a form filter to provide variant of selector - * If used, the HTML select must be called "filter". - * - * @return string A html select zone - */ - function formFilter() - { - global $conf, $langs; - - $langs->load("companies"); - - $sql = "SELECT c.label, count(distinct(sp.email)) AS nb"; - $sql.= " FROM ".MAIN_DB_PREFIX."socpeople as sp,"; - $sql.= " ".MAIN_DB_PREFIX."categorie as c,"; - $sql.= " ".MAIN_DB_PREFIX."categorie_societe as cs"; - $sql.= " WHERE sp.email != ''"; // Note that null != '' is false - $sql.= " AND sp.no_email = 0"; - $sql.= " AND sp.statut = 1"; - $sql.= " AND sp.entity IN (".getEntity('societe').")"; - $sql.= " AND cs.fk_categorie = c.rowid"; - $sql.= " AND cs.fk_soc = sp.fk_soc"; - $sql.= " GROUP BY c.label"; - $sql.= " ORDER BY c.label"; - - $resql = $this->db->query($sql); - - $s=''; - $s.=''; - - return $s; - } - -} - diff --git a/htdocs/core/modules/mailings/contacts4.modules.php b/htdocs/core/modules/mailings/contacts4.modules.php deleted file mode 100644 index f4c67874bfb..00000000000 --- a/htdocs/core/modules/mailings/contacts4.modules.php +++ /dev/null @@ -1,252 +0,0 @@ - - * Copyright (C) 2013 Florian HENRY - * - * 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 - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - * or see http://www.gnu.org/ - */ - -/** - * \file htdocs/core/modules/mailings/contacts4.modules.php - * \ingroup mailing - * \brief Provides a list of recipients for mailing module - */ - -include_once DOL_DOCUMENT_ROOT.'/core/modules/mailings/modules_mailings.php'; - - -/** - * Class to manage a list of personalised recipients for mailing feature - */ -class mailing_contacts4 extends MailingTargets -{ - var $name='ContactsByCategory'; - // This label is used if no translation is found for key XXX neither MailingModuleDescXXX where XXX=name is found - var $desc='Add contacts by category'; - var $require_admin=0; - - var $require_module=array(); - var $picto='contact'; - var $db; - - - /** - * Constructor - * - * @param DoliDB $db Database handler - */ - function __construct($db) - { - $this->db=$db; - } - - /** - * Renvoie url lien vers fiche de la source du destinataire du mailing - * - * @param int $id ID - * @return string Url lien - */ - function url($id) - { - return ''.img_object('',"contact").''; - } - - /** - * This is the main function that returns the array of emails - * - * @param int $mailing_id Id of mailing. No need to use it. - * @param array $filtersarray Category - * @return int <0 if error, number of emails added if ok - */ - function add_to_target($mailing_id,$filtersarray=array()) - { - global $conf,$langs; - - $target = array(); - - // La requete doit retourner: id, email, fk_contact, name, firstname, other - $sql = "SELECT sp.rowid as id, sp.email as email, sp.rowid as fk_contact,"; - $sql.= " sp.lastname, sp.firstname, sp.civility as civility_id,"; - $sql.= " s.nom as companyname"; - $sql.= " FROM ".MAIN_DB_PREFIX."socpeople as sp"; - if ($filtersarray[0] <> 'all')$sql.= " INNER JOIN ".MAIN_DB_PREFIX."categorie_contact as cs ON cs.fk_socpeople=sp.rowid"; - if ($filtersarray[0] <> 'all') $sql.= " INNER JOIN ".MAIN_DB_PREFIX."categorie as c ON cs.fk_categorie = c.rowid"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = sp.fk_soc"; - $sql.= " WHERE sp.email != ''"; // Note that null != '' is false - $sql.= " AND sp.no_email = 0"; - $sql.= " AND sp.statut = 1"; - $sql.= " AND sp.entity IN (".getEntity('societe').")"; - if ($filtersarray[0] <> 'all') $sql.= " AND c.label = '".$this->db->escape($filtersarray[0])."'"; - $sql.= " ORDER BY sp.lastname, sp.firstname"; - - dol_syslog(get_class($this).':: add_to_target',LOG_DEBUG); - $resql = $this->db->query($sql); - if ($resql) - { - $num = $this->db->num_rows($resql); - $i = 0; - - while ($i < $num) - { - $obj= $this->db->fetch_object($resql); - $target[] = array( - 'email' => $obj->email, - 'fk_contact' => $obj->fk_contact, - 'lastname' => $obj->lastname, - 'firstname' => $obj->firstname, - 'other' => - ($langs->transnoentities("ThirdParty").'='.$obj->companyname).';'. - ($langs->transnoentities("UserTitle").'='.($obj->civility_id?$langs->transnoentities("Civility".$obj->civility_id):'')), - 'source_url' => $this->url($obj->id), - 'source_id' => $obj->id, - 'source_type' => 'contact' - ); - $i++; - } - }else { - $this->error=$this->db->lasterrno(); - return -1; - } - - return parent::add_to_target($mailing_id, $target); - } - - - /** - * On the main mailing area, there is a box with statistics. - * If you want to add a line in this report you must provide an - * array of SQL request that returns two field: - * One called "label", One called "nb". - * - * @return array Array with SQL requests - */ - function getSqlArrayForStats() - { - global $conf, $langs; - - $statssql=array(); - /*for ($i=0; $i<5; $i++) { - $statssql[$i] = "SELECT c.label, count(sp.rowid) AS nb"; - $statssql[$i].= " FROM ".MAIN_DB_PREFIX."socpeople as sp,"; - $statssql[$i].= " ".MAIN_DB_PREFIX."societe as s,"; - $statssql[$i].= " ".MAIN_DB_PREFIX."categorie as c,"; - $statssql[$i].= " ".MAIN_DB_PREFIX."categorie_societe as cs"; - $statssql[$i].= " WHERE s.rowid = sp.fk_soc"; - $statssql[$i].= " AND sp.email != ''"; // Note that null != '' is false - $statssql[$i].= " AND sp.entity IN (".getEntity('societe').")"; - $statssql[$i].= " AND cs.fk_categorie = c.rowid"; - $statssql[$i].= " AND cs.fk_soc = sp.fk_soc"; - $statssql[$i].= " GROUP BY c.label"; - $statssql[$i].= " ORDER BY nb DESC"; - $statssql[$i].= " LIMIT $i,1"; - }*/ - - return $statssql; - } - - - /** - * Return here number of distinct emails returned by your selector. - * - * @param string $sql Requete sql de comptage - * @return int Number of recipients - */ - function getNbOfRecipients($sql='') - { - global $conf; - - // We must report here number of contacts when absolutely no filter selected (so all contacts). - // Number with a filter are show in the combo list for each filter. - // If we want a filter "is inside at least one category", we must add it into formFilter - $sql = "SELECT count(distinct(c.email)) as nb"; - $sql.= " FROM ".MAIN_DB_PREFIX."socpeople as c"; - $sql.= " WHERE c.entity IN (".getEntity('societe').")"; - $sql.= " AND c.email != ''"; // Note that null != '' is false - $sql.= " AND c.no_email = 0"; - $sql.= " AND c.statut = 1"; - /* - $sql = "SELECT count(distinct(sp.email)) as nb"; - $sql.= " FROM ".MAIN_DB_PREFIX."socpeople as sp,"; - $sql.= " ".MAIN_DB_PREFIX."societe as s,"; - $sql.= " ".MAIN_DB_PREFIX."categorie as c,"; - $sql.= " ".MAIN_DB_PREFIX."categorie_societe as cs"; - $sql.= " WHERE s.rowid = sp.fk_soc"; - $sql.= " AND sp.entity IN (".getEntity('societe').")"; - $sql.= " AND sp.email != ''"; // Note that null != '' is false - $sql.= " AND cs.fk_categorie = c.rowid"; - $sql.= " AND cs.fk_soc = sp.fk_soc"; - */ - // La requete doit retourner un champ "nb" pour etre comprise - // par parent::getNbOfRecipients - return parent::getNbOfRecipients($sql); - } - - /** - * This is to add a form filter to provide variant of selector - * If used, the HTML select must be called "filter". - * - * @return string A html select zone - */ - function formFilter() - { - global $conf, $langs; - - $langs->load("companies"); - - $sql = "SELECT c.label, count(distinct(sp.email)) AS nb"; - $sql.= " FROM ".MAIN_DB_PREFIX."socpeople as sp"; - $sql.= " INNER JOIN ".MAIN_DB_PREFIX."categorie_contact as cs ON cs.fk_socpeople=sp.rowid"; - $sql.= " INNER JOIN ".MAIN_DB_PREFIX."categorie as c ON cs.fk_categorie = c.rowid"; - $sql.= " WHERE sp.email != ''"; // Note that null != '' is false - $sql.= " AND sp.no_email = 0"; - $sql.= " AND sp.statut = 1"; - $sql.= " AND sp.entity IN (".getEntity('societe').")"; - $sql.= " GROUP BY c.label"; - $sql.= " ORDER BY c.label"; - - $resql = $this->db->query($sql); - - dol_syslog(get_class($this).':: formFilter',LOG_DEBUG); - if ($resql) { - $s=''; - $s.=''; - return $s; - } - else { - $this->error=$this->db->lasterrno(); - return -1; - } - - } - -} - diff --git a/htdocs/core/modules/mailings/fraise.modules.php b/htdocs/core/modules/mailings/fraise.modules.php index 05d9e525652..e0226017ede 100644 --- a/htdocs/core/modules/mailings/fraise.modules.php +++ b/htdocs/core/modules/mailings/fraise.modules.php @@ -34,7 +34,7 @@ class mailing_fraise extends MailingTargets { var $name='FundationMembers'; // Identifiant du module mailing // This label is used if no translation is found for key XXX neither MailingModuleDescXXX where XXX=name is found - var $desc='Foundation members with emails (by status)'; + var $desc='Foundation members with emails'; // Set to 1 if selector is available for admin users only var $require_admin=0; @@ -108,10 +108,14 @@ class mailing_fraise extends MailingTargets { global $conf, $langs; $langs->load("members"); + $langs->load("categories"); + $langs->load("companies"); $form=new Form($this->db); $s=''; + + // Status $s.=$langs->trans("Status").': '; $s.=' '; $s.=$langs->trans("Type").': '; - $s.=''; $sql = "SELECT rowid, libelle, statut"; $sql.= " FROM ".MAIN_DB_PREFIX."adherent_type"; $sql.= " WHERE entity = ".$conf->entity; @@ -150,6 +154,47 @@ class mailing_fraise extends MailingTargets } $s.=''; + + $s.=' '; + + $s.=$langs->trans("Category").': '; + $s.=''; + + $s.='
    '; $s.=$langs->trans("DateEndSubscription").':  '; $s.=$langs->trans("After").' > '.$form->select_date(-1,'subscriptionafter',0,0,1,'fraise',1,0,1,0); @@ -200,18 +245,29 @@ class mailing_fraise extends MailingTargets $sql = "SELECT a.rowid as id, a.email as email, null as fk_contact, "; $sql.= " a.lastname, a.firstname,"; $sql.= " a.datefin, a.civility as civility_id, a.login, a.societe"; // Other fields - $sql.= " FROM ".MAIN_DB_PREFIX."adherent as a, ".MAIN_DB_PREFIX."adherent_type as ta"; + $sql.= " FROM ".MAIN_DB_PREFIX."adherent as a"; + if ($_POST['filter_category']) + { + $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."categorie_member as cm ON cm.fk_member = a.rowid"; + $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."categorie as c ON c.rowid = cm.fk_categorie"; + } + $sql.= " , ".MAIN_DB_PREFIX."adherent_type as ta"; $sql.= " WHERE a.email <> ''"; // Note that null != '' is false $sql.= " AND a.email NOT IN (SELECT email FROM ".MAIN_DB_PREFIX."mailing_cibles WHERE fk_mailing=".$mailing_id.")"; + // Filter on status if (isset($_POST["filter"]) && $_POST["filter"] == '-1') $sql.= " AND a.statut=-1"; if (isset($_POST["filter"]) && $_POST["filter"] == '1a') $sql.= " AND a.statut=1 AND a.datefin >= '".$this->db->idate($now)."'"; if (isset($_POST["filter"]) && $_POST["filter"] == '1b') $sql.= " AND a.statut=1 AND (a.datefin IS NULL or a.datefin < '".$this->db->idate($now)."')"; if (isset($_POST["filter"]) && $_POST["filter"] == '0') $sql.= " AND a.statut=0"; + // Filter on date if ($dateendsubscriptionafter > 0) $sql.=" AND datefin > '".$this->db->idate($dateendsubscriptionafter)."'"; if ($dateendsubscriptionbefore > 0) $sql.=" AND datefin < '".$this->db->idate($dateendsubscriptionbefore)."'"; $sql.= " AND a.fk_adherent_type = ta.rowid"; - if ($_POST['filtertype']) $sql.= " AND ta.rowid='".$_POST['filtertype']."'"; - $sql.= " ORDER BY a.email"; + // Filter on type + if ($_POST['filter_type']) $sql.= " AND ta.rowid='".$_POST['filter_type']."'"; + // Filter on category + if ($_POST['filter_category']) $sql.= " AND c.rowid='".$_POST['filter_category']."'"; + $sql.= " ORDER BY a.email"; //print $sql; // Add targets into table diff --git a/htdocs/core/modules/mailings/framboise.modules.php b/htdocs/core/modules/mailings/framboise.modules.php deleted file mode 100644 index 82f7e51e0ef..00000000000 --- a/htdocs/core/modules/mailings/framboise.modules.php +++ /dev/null @@ -1,234 +0,0 @@ - - * Copyright (C) 2005-2009 Regis Houssin - * - * This file is an example to follow to add your own email selector inside - * the Dolibarr email tool. - * Follow instructions given in README file to know what to change to build - * your own emailing list selector. - * Code that need to be changed in this file are marked by "CHANGE THIS" tag. - */ - -/** - * \file htdocs/core/modules/mailings/framboise.modules.php - * \ingroup mailing - * \brief Example file to provide a list of recipients for mailing module - */ - -include_once DOL_DOCUMENT_ROOT.'/core/modules/mailings/modules_mailings.php'; - - -/** - * Class to manage a list of personalised recipients for mailing feature - */ -class mailing_framboise extends MailingTargets -{ - var $name='MembersCategories'; - // This label is used if no translation is found for key XXX neither MailingModuleDescXXX where XXX=name is found - var $desc="Foundation members with emails (by categories)"; - // Set to 1 if selector is available for admin users only - var $require_admin=0; - - var $require_module=array("adherent","categorie"); - var $picto='user'; - var $db; - - - /** - * Constructor - * - * @param DoliDB $db Database handler - */ - function __construct($db) - { - $this->db=$db; - } - - - /** - * This is the main function that returns the array of emails. - * - * @param int $mailing_id Id of mailing. No need to use it. - * @param array $filtersarray If you used the formFilter function. Empty otherwise. - * @return int <0 if error, number of emails added if ok - */ - function add_to_target($mailing_id,$filtersarray=array()) - { - global $conf, $langs; - $langs->load("members"); - $langs->load("companies"); - - $cibles = array(); - - // Select the members from category - $sql = "SELECT a.rowid as id, a.email as email, a.lastname, null as fk_contact, a.firstname,"; - $sql.= " a.datefin, a.civility as civility_id, a.login, a.societe,"; // Other fields - if ($_POST['filter']) $sql.= " c.label"; - else $sql.=" null as label"; - $sql.= " FROM ".MAIN_DB_PREFIX."adherent as a"; - if ($_POST['filter']) - { - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."categorie_member as cm ON cm.fk_member = a.rowid"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."categorie as c ON c.rowid = cm.fk_categorie"; - } - $sql.= " WHERE a.email != ''"; - $sql.= " AND a.entity = ".$conf->entity; - if ($_POST['filter']) $sql.= " AND c.rowid='".$_POST['filter']."'"; - $sql.= " ORDER BY a.email"; - - // Stocke destinataires dans cibles - $result=$this->db->query($sql); - if ($result) - { - $num = $this->db->num_rows($result); - $i = 0; - $j = 0; - - dol_syslog(get_class($this)."::add_to_target mailing ".$num." targets found"); - - $old = ''; - while ($i < $num) - { - $obj = $this->db->fetch_object($result); - if ($old <> $obj->email) - { - $cibles[$j] = array( - 'email' => $obj->email, - 'fk_contact' => $obj->fk_contact, - 'lastname' => $obj->lastname, - 'firstname' => $obj->firstname, - 'other' => - ($langs->transnoentities("Login").'='.$obj->login).';'. - ($langs->transnoentities("UserTitle").'='.($obj->civility_id?$langs->transnoentities("Civility".$obj->civility_id):'')).';'. - ($langs->transnoentities("DateEnd").'='.dol_print_date($this->db->jdate($obj->datefin),'day')).';'. - ($langs->transnoentities("Company").'='.$obj->societe).';'. - ($obj->label?$langs->transnoentities("Category").'='.$obj->label:''), - 'source_url' => $this->url($obj->id), - 'source_id' => $obj->id, - 'source_type' => 'member' - ); - $old = $obj->email; - $j++; - } - - $i++; - } - } - else - { - dol_syslog($this->db->error()); - $this->error=$this->db->error(); - return -1; - } - - return parent::add_to_target($mailing_id, $cibles); - } - - - /** - * On the main mailing area, there is a box with statistics. - * If you want to add a line in this report you must provide an - * array of SQL request that returns two field: - * One called "label", One called "nb". - * - * @return array Array with SQL requests - */ - function getSqlArrayForStats() - { - // CHANGE THIS: Optionnal - - //var $statssql=array(); - //$this->statssql[0]="SELECT field1 as label, count(distinct(email)) as nb FROM mytable WHERE email IS NOT NULL"; - return array(); - } - - - /** - * Return here number of distinct emails returned by your selector. - * For example if this selector is used to extract 500 different - * emails from a text file, this function must return 500. - * - * @param string $sql Requete sql de comptage - * @return int Nb of recipients - */ - function getNbOfRecipients($sql='') - { - global $conf; - - $sql = "SELECT count(distinct(a.email)) as nb"; - $sql.= " FROM ".MAIN_DB_PREFIX."adherent as a"; - $sql.= " WHERE a.email != ''"; - $sql.= " AND a.entity = ".$conf->entity; - - // La requete doit retourner un champ "nb" pour etre comprise - // par parent::getNbOfRecipients - return parent::getNbOfRecipients($sql); - } - - /** - * This is to add a form filter to provide variant of selector - * If used, the HTML select must be called "filter" - * - * @return string A html select zone - */ - function formFilter() - { - global $conf, $langs; - - $langs->load("companies"); - $langs->load("categories"); - - $s=''; - $s.=''; - return $s; - - } - - - /** - * Can include an URL link on each record provided by selector shown on target page. - * - * @param int $id Id of member - * @return string Url link - */ - function url($id) - { - return ''.img_object('',"user").''; - } - -} - diff --git a/htdocs/core/modules/member/doc/pdf_standard.class.php b/htdocs/core/modules/member/doc/pdf_standard.class.php index c97da24d174..6fd8ecfee70 100644 --- a/htdocs/core/modules/member/doc/pdf_standard.class.php +++ b/htdocs/core/modules/member/doc/pdf_standard.class.php @@ -418,6 +418,8 @@ class pdf_standard extends CommonStickerGenerator @chmod($file, octdec($conf->global->MAIN_UMASK)); + $this->result = array('fullpath'=>$file); + // Output to http stream if (empty($nooutput)) { diff --git a/htdocs/core/modules/modAdherent.class.php b/htdocs/core/modules/modAdherent.class.php index 041892c35ee..ade0e2c7e75 100644 --- a/htdocs/core/modules/modAdherent.class.php +++ b/htdocs/core/modules/modAdherent.class.php @@ -53,7 +53,8 @@ class modAdherent extends DolibarrModules // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module) $this->name = preg_replace('/^mod/i','',get_class($this)); $this->description = "Management of members of a foundation or association"; - $this->version = 'dolibarr'; // 'experimental' or 'dolibarr' or version + // Possible values for version are: 'development', 'experimental', 'dolibarr' or version + $this->version = 'dolibarr'; $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); $this->special = 0; $this->picto='user'; @@ -75,119 +76,119 @@ class modAdherent extends DolibarrModules //----------- $this->const = array(); $r=0; - + $this->const[$r][0] = "ADHERENT_ADDON_PDF"; $this->const[$r][1] = "chaine"; $this->const[$r][2] = "standard"; $this->const[$r][3] = 'Name of PDF model of member'; $this->const[$r][4] = 0; $r++; - + $this->const[$r][0] = "ADHERENT_MAIL_RESIL"; $this->const[$r][1] = "texte"; $this->const[$r][2] = "Votre adhésion vient d'être résiliée.\r\nNous espérons vous revoir très bientôt"; $this->const[$r][3] = "Mail de résiliation"; $this->const[$r][4] = 0; $r++; - + $this->const[$r][0] = "ADHERENT_MAIL_VALID"; $this->const[$r][1] = "texte"; $this->const[$r][2] = "Votre adhésion vient d'être validée. \r\nVoici le rappel de vos coordonnées (toute information erronée entrainera la non validation de votre inscription) :\r\n\r\n%INFOS%\r\n\r\n"; $this->const[$r][3] = "Mail de validation"; $this->const[$r][4] = 0; $r++; - + $this->const[$r][0] = "ADHERENT_MAIL_VALID_SUBJECT"; $this->const[$r][1] = "chaine"; $this->const[$r][2] = "Votre adhésion a été validée"; $this->const[$r][3] = "Sujet du mail de validation"; $this->const[$r][4] = 0; $r++; - + $this->const[$r][0] = "ADHERENT_MAIL_RESIL_SUBJECT"; $this->const[$r][1] = "chaine"; $this->const[$r][2] = "Résiliation de votre adhésion"; $this->const[$r][3] = "Sujet du mail de résiliation"; $this->const[$r][4] = 0; $r++; - + $this->const[$r][0] = "ADHERENT_MAIL_FROM"; $this->const[$r][1] = "chaine"; $this->const[$r][2] = ""; $this->const[$r][3] = "From des mails"; $this->const[$r][4] = 0; $r++; - + $this->const[$r][0] = "ADHERENT_MAIL_COTIS"; $this->const[$r][1] = "texte"; $this->const[$r][2] = "Bonjour %FIRSTNAME%,\r\nCet email confirme que votre cotisation a été reçue\r\net enregistrée"; $this->const[$r][3] = "Mail de validation de cotisation"; $this->const[$r][4] = 0; $r++; - + $this->const[$r][0] = "ADHERENT_MAIL_COTIS_SUBJECT"; $this->const[$r][1] = "chaine"; $this->const[$r][2] = "Reçu de votre cotisation"; $this->const[$r][3] = "Sujet du mail de validation de cotisation"; $this->const[$r][4] = 0; $r++; - + $this->const[$r][0] = "ADHERENT_CARD_HEADER_TEXT"; $this->const[$r][1] = "chaine"; $this->const[$r][2] = "%YEAR%"; $this->const[$r][3] = "Texte imprimé sur le haut de la carte adhérent"; $this->const[$r][4] = 0; $r++; - + $this->const[$r][0] = "ADHERENT_CARD_FOOTER_TEXT"; $this->const[$r][1] = "chaine"; $this->const[$r][2] = "%COMPANY%"; $this->const[$r][3] = "Texte imprimé sur le bas de la carte adhérent"; $this->const[$r][4] = 0; $r++; - + $this->const[$r][0] = "ADHERENT_CARD_TEXT"; $this->const[$r][1] = "texte"; $this->const[$r][2] = "%FULLNAME%\r\nID: %ID%\r\n%EMAIL%\r\n%ADDRESS%\r\n%ZIP% %TOWN%\r\n%COUNTRY%"; $this->const[$r][3] = "Text to print on member cards"; $this->const[$r][4] = 0; $r++; - + $this->const[$r][0] = "ADHERENT_MAILMAN_ADMINPW"; $this->const[$r][1] = "chaine"; $this->const[$r][2] = ""; $this->const[$r][3] = "Mot de passe Admin des liste mailman"; $this->const[$r][4] = 0; $r++; - + $this->const[$r][0] = "ADHERENT_BANK_ACCOUNT"; $this->const[$r][1] = "chaine"; $this->const[$r][2] = ""; $this->const[$r][3] = "ID du Compte banquaire utilise"; $this->const[$r][4] = 0; $r++; - + $this->const[$r][0] = "ADHERENT_BANK_CATEGORIE"; $this->const[$r][1] = "chaine"; $this->const[$r][2] = ""; $this->const[$r][3] = "ID de la catégorie bancaire des cotisations"; $this->const[$r][4] = 0; $r++; - + $this->const[$r][0] = "ADHERENT_ETIQUETTE_TYPE"; $this->const[$r][1] = "chaine"; $this->const[$r][2] = "L7163"; $this->const[$r][3] = "Type of address sheets"; $this->const[$r][4] = 0; $r++; - + $this->const[$r][0] = "ADHERENT_ETIQUETTE_TEXT"; $this->const[$r][1] = "texte"; $this->const[$r][2] = "%FULLNAME%\n%ADDRESS%\n%ZIP% %TOWN%\n%COUNTRY%"; $this->const[$r][3] = "Text to print on member address sheets"; $this->const[$r][4] = 0; $r++; - + // Boxes //------- $this->boxes = array(0=>array('file'=>'box_members.php','enabledbydefaulton'=>'Home')); @@ -260,8 +261,8 @@ class modAdherent extends DolibarrModules // Menus //------- $this->menu = 1; // This module add menu entries. They are coded into menu manager. - - + + // Exports //-------- $r=0; @@ -325,8 +326,8 @@ class modAdherent extends DolibarrModules $this->import_regex_array[$r]=array('a.civility'=>'code@'.MAIN_DB_PREFIX.'c_civility','a.fk_adherent_type'=>'rowid@'.MAIN_DB_PREFIX.'adherent_type','a.morphy'=>'(phy|mor)','a.statut'=>'^[0|1]','a.datec'=>'^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]$','a.datefin'=>'^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]$'); $this->import_examplevalues_array[$r]=array('a.civility'=>"MR",'a.lastname'=>'Smith','a.firstname'=>'John','a.login'=>'jsmith','a.pass'=>'passofjsmith','a.fk_adherent_type'=>'1','a.morphy'=>'"mor" or "phy"','a.societe'=>'JS company','a.address'=>'21 jump street','a.zip'=>'55000','a.town'=>'New York','a.country'=>'1','a.email'=>'jsmith@example.com','a.birth'=>'1972-10-10','a.statut'=>"0 or 1",'a.note_public'=>"This is a public comment on member",'a.note_private'=>"This is private comment on member",'a.datec'=>dol_print_date($now,'%Y-%m-%d'),'a.datefin'=>dol_print_date(dol_time_plus_duree($now, 1, 'y'),'%Y-%m-%d')); } - - + + /** * Function called when module is enabled. * The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database. @@ -338,16 +339,16 @@ class modAdherent extends DolibarrModules function init($options='') { global $conf,$langs; - + // Permissions $this->remove($options); - + //ODT template /* $src=DOL_DOCUMENT_ROOT.'/install/doctemplates/orders/template_order.odt'; $dirodt=DOL_DATA_ROOT.'/doctemplates/orders'; $dest=$dirodt.'/template_order.odt'; - + if (file_exists($src) && ! file_exists($dest)) { require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; @@ -360,12 +361,12 @@ class modAdherent extends DolibarrModules return 0; } }*/ - + $sql = array( "DELETE FROM ".MAIN_DB_PREFIX."document_model WHERE nom = '".$this->db->escape($this->const[0][2])."' AND type='member' AND entity = ".$conf->entity, "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('".$this->db->escape($this->const[0][2])."','member',".$conf->entity.")" ); - + return $this->_init($sql,$options); - } + } } diff --git a/htdocs/core/modules/modAgenda.class.php b/htdocs/core/modules/modAgenda.class.php index 1c893cfbc59..a42c3001b44 100644 --- a/htdocs/core/modules/modAgenda.class.php +++ b/htdocs/core/modules/modAgenda.class.php @@ -55,7 +55,8 @@ class modAgenda extends DolibarrModules // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module) $this->name = preg_replace('/^mod/i','',get_class($this)); $this->description = "Follow events or rendez-vous. Record manual events into Agendas or let application record automatic events for log tracking."; - $this->version = 'dolibarr'; // 'experimental' or 'dolibarr' or version + // Possible values for version are: 'development', 'experimental', 'dolibarr' or version + $this->version = 'dolibarr'; // Key used in llx_const table to save module status enabled/disabled (where MYMODULE is value of property name of module in uppercase) $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); $this->special = 0; @@ -108,7 +109,7 @@ class modAgenda extends DolibarrModules // Cronjobs //------------ $this->cronjobs = array( - 0=>array('label'=>'SendEmailsReminders', 'jobtype'=>'method', 'class'=>'comm/action/class/actioncomm.class.php', 'objectname'=>'ActionComm', 'method'=>'sendEmailsReminder', 'parameters'=>'', 'comment'=>'SendEMailsReminder', 'frequency'=>10, 'unitfrequency'=>60, 'priority'=>10, 'status'=>1, 'test'=>'$conf->global->MAIN_FEATURES_LEVEL > 0'), + 0=>array('label'=>'SendEmailsReminders', 'jobtype'=>'method', 'class'=>'comm/action/class/actioncomm.class.php', 'objectname'=>'ActionComm', 'method'=>'sendEmailsReminder', 'parameters'=>'', 'comment'=>'SendEMailsReminder', 'frequency'=>10, 'unitfrequency'=>60, 'priority'=>10, 'status'=>1, 'test'=>'1'), // 1=>array('label'=>'My label', 'jobtype'=>'command', 'command'=>'', 'parameters'=>'', 'comment'=>'Comment', 'frequency'=>1, 'unitfrequency'=>3600*24) ); diff --git a/htdocs/core/modules/modBarcode.class.php b/htdocs/core/modules/modBarcode.class.php index 0bb858fa07a..69df9843630 100644 --- a/htdocs/core/modules/modBarcode.class.php +++ b/htdocs/core/modules/modBarcode.class.php @@ -48,7 +48,8 @@ class modBarcode extends DolibarrModules // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module) $this->name = preg_replace('/^mod/i','',get_class($this)); $this->description = "Gestion des codes barres"; - $this->version = 'dolibarr'; // 'development' or 'experimental' or 'dolibarr' or version + // Possible values for version are: 'development', 'experimental', 'dolibarr' or version + $this->version = 'dolibarr'; $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); $this->special = 2; $this->picto='barcode'; diff --git a/htdocs/core/modules/modBlockedLog.class.php b/htdocs/core/modules/modBlockedLog.class.php index 3125627c007..f26c5fe525f 100644 --- a/htdocs/core/modules/modBlockedLog.class.php +++ b/htdocs/core/modules/modBlockedLog.class.php @@ -47,7 +47,8 @@ class modBlockedLog extends DolibarrModules // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module) $this->name = preg_replace('/^mod/i','',get_class($this)); $this->description = "Enable a log on some business events into a non reversible log. This module may be mandatory for some countries."; - $this->version = 'development'; // 'development', 'experimental' or 'dolibarr' or version + // Possible values for version are: 'development', 'experimental', 'dolibarr' or version + $this->version = 'development'; // Key used in llx_const table to save module status enabled/disabled (where MYMODULE is value of property name of module in uppercase) $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); // Where to store the module in setup page (0=common,1=interface,2=others,3=very specific) diff --git a/htdocs/core/modules/modCollab.class.php b/htdocs/core/modules/modCollab.class.php index 506eb99b540..01a80d0b702 100644 --- a/htdocs/core/modules/modCollab.class.php +++ b/htdocs/core/modules/modCollab.class.php @@ -42,7 +42,7 @@ class modCollab extends DolibarrModules $this->db = $db; $this->numero = 30000; - + // Family can be 'crm','financial','hr','projects','products','ecm','technic','other' // It is used to group modules in module setup page $this->family = "portal"; @@ -50,7 +50,8 @@ class modCollab extends DolibarrModules // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module) $this->name = preg_replace('/^mod/i','',get_class($this)); $this->description = "Enable the public collaboration features, like shared pad, shared online sheets, etc..."; - $this->version = 'development'; // 'experimental' or 'dolibarr' or version + // Possible values for version are: 'development', 'experimental', 'dolibarr' or version + $this->version = 'development'; // Key used in llx_const table to save module status enabled/disabled (where MYMODULE is value of property name of module in uppercase) $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); // Where to store the module in setup page (0=common,1=interface,2=others,3=very specific) diff --git a/htdocs/core/modules/modCron.class.php b/htdocs/core/modules/modCron.class.php index 90dae11dd72..55f0f96c546 100644 --- a/htdocs/core/modules/modCron.class.php +++ b/htdocs/core/modules/modCron.class.php @@ -50,7 +50,8 @@ class modCron extends DolibarrModules // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module) $this->name = preg_replace('/^mod/i','',get_class($this)); $this->description = "Enable the Dolibarr cron service"; - $this->version = 'dolibarr'; // 'experimental' or 'dolibarr' or version + // Possible values for version are: 'development', 'experimental', 'dolibarr' or version + $this->version = 'dolibarr'; // Key used in llx_const table to save module status enabled/disabled (where MYMODULE is value of property name of module in uppercase) $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); // Where to store the module in setup page (0=common,1=interface,2=others,3=very specific) diff --git a/htdocs/core/modules/modDon.class.php b/htdocs/core/modules/modDon.class.php index 881dd27e414..08564e241aa 100644 --- a/htdocs/core/modules/modDon.class.php +++ b/htdocs/core/modules/modDon.class.php @@ -49,7 +49,8 @@ class modDon extends DolibarrModules // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module) $this->name = preg_replace('/^mod/i','',get_class($this)); $this->description = "Gestion des dons"; - $this->version = 'dolibarr'; // 'experimental' or 'dolibarr' or version + // Possible values for version are: 'development', 'experimental', 'dolibarr' or version + $this->version = 'dolibarr'; $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); $this->special = 0; // Name of png file (without png) used for this module. @@ -135,12 +136,12 @@ class modDon extends DolibarrModules $this->rights[3][2] = 'd'; $this->rights[3][3] = 0; $this->rights[3][4] = 'supprimer'; - - + + // Menus //------- $this->menu = 1; // This module add menu entries. They are coded into menu manager. - + } diff --git a/htdocs/core/modules/modDynamicPrices.class.php b/htdocs/core/modules/modDynamicPrices.class.php index cb6544f4d29..21aa3644e3e 100644 --- a/htdocs/core/modules/modDynamicPrices.class.php +++ b/htdocs/core/modules/modDynamicPrices.class.php @@ -45,7 +45,8 @@ class modDynamicPrices extends DolibarrModules // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module) $this->name = preg_replace('/^mod/i','',get_class($this)); $this->description = "Enable the usage of math expressions for prices"; - $this->version = 'experimental'; // 'experimental' or 'dolibarr' or version + // Possible values for version are: 'development', 'experimental', 'dolibarr' or version + $this->version = 'experimental'; // Key used in llx_const table to save module status enabled/disabled (where MYMODULE is value of property name of module in uppercase) $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); // Where to store the module in setup page (0=common,1=interface,2=others,3=very specific) @@ -83,6 +84,6 @@ class modDynamicPrices extends DolibarrModules $this->rights = array(); $this->rights_class = 'dynamicprices'; $r=0; - + } } diff --git a/htdocs/core/modules/modExport.class.php b/htdocs/core/modules/modExport.class.php index cc0090c2fc8..70efc2c165f 100644 --- a/htdocs/core/modules/modExport.class.php +++ b/htdocs/core/modules/modExport.class.php @@ -48,8 +48,8 @@ class modExport extends DolibarrModules // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module) $this->name = preg_replace('/^mod/i','',get_class($this)); $this->description = "Outils d'exports de donnees Dolibarr (via un assistant)"; - // Possible values for version are: 'experimental' or 'dolibarr' or version - $this->version = 'dolibarr'; // 'experimental' or 'dolibarr' or version + // Possible values for version are: 'development', 'experimental', 'dolibarr' or version + $this->version = 'dolibarr'; $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); $this->special = 0; $this->picto = 'technic'; @@ -90,11 +90,11 @@ class modExport extends DolibarrModules $this->rights[$r][2] = 'w'; $this->rights[$r][3] = 0; $this->rights[$r][4] = 'creer'; - - + + // Menus //------- $this->menu = 1; // This module add menu entries. They are coded into menu manager. - + } } diff --git a/htdocs/core/modules/modExternalRss.class.php b/htdocs/core/modules/modExternalRss.class.php index 7ae60e5e9eb..e3f4a538c4d 100644 --- a/htdocs/core/modules/modExternalRss.class.php +++ b/htdocs/core/modules/modExternalRss.class.php @@ -49,7 +49,8 @@ class modExternalRss extends DolibarrModules // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module) $this->name = preg_replace('/^mod/i','',get_class($this)); $this->description = "Ajout de files d'informations RSS dans les ecrans Dolibarr"; - $this->version = 'dolibarr'; // 'experimental' or 'dolibarr' or version + // Possible values for version are: 'development', 'experimental', 'dolibarr' or version + $this->version = 'dolibarr'; $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); $this->special = 1; $this->picto='rss'; diff --git a/htdocs/core/modules/modFckeditor.class.php b/htdocs/core/modules/modFckeditor.class.php index 8752c553a77..54e1eadd735 100644 --- a/htdocs/core/modules/modFckeditor.class.php +++ b/htdocs/core/modules/modFckeditor.class.php @@ -49,7 +49,8 @@ class modFckeditor extends DolibarrModules // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module) $this->name = preg_replace('/^mod/i','',get_class($this)); $this->description = "Editeur WYSIWYG"; - $this->version = 'dolibarr'; // 'experimental' or 'dolibarr' or version + // Possible values for version are: 'development', 'experimental', 'dolibarr' or version + $this->version = 'dolibarr'; $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); $this->special = 2; // Name of png file (without png) used for this module. diff --git a/htdocs/core/modules/modImport.class.php b/htdocs/core/modules/modImport.class.php index 2efebb58d80..18696ef4b11 100644 --- a/htdocs/core/modules/modImport.class.php +++ b/htdocs/core/modules/modImport.class.php @@ -48,8 +48,8 @@ class modImport extends DolibarrModules // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module) $this->name = preg_replace('/^mod/i','',get_class($this)); $this->description = "Outils d'imports de donnees Dolibarr (via un assistant)"; - // Possible values for version are: 'experimental' or 'dolibarr' or version - $this->version = 'dolibarr'; // 'experimental' or 'dolibarr' or version + // Possible values for version are: 'development', 'experimental', 'dolibarr' or 'dolibarr_deprecated' or version + $this->version = 'dolibarr'; $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); $this->special = 0; $this->picto = 'technic'; @@ -85,11 +85,11 @@ class modImport extends DolibarrModules $this->rights[$r][2] = 'r'; $this->rights[$r][3] = 0; $this->rights[$r][4] = 'run'; - - + + // Menus //------- $this->menu = 1; // This module add menu entries. They are coded into menu manager. - + } } diff --git a/htdocs/core/modules/modLabel.class.php b/htdocs/core/modules/modLabel.class.php index 05e98d36454..4f7cb8cacbb 100644 --- a/htdocs/core/modules/modLabel.class.php +++ b/htdocs/core/modules/modLabel.class.php @@ -48,7 +48,8 @@ class modLabel extends DolibarrModules // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module) $this->name = preg_replace('/^mod/i','',get_class($this)); $this->description = "Gestion des etiquettes"; - $this->version = 'development'; // 'development' or 'experimental' or 'dolibarr' or version + // Possible values for version are: 'development', 'experimental', 'dolibarr' or version + $this->version = 'development'; $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); $this->special = 2; $this->picto='label'; diff --git a/htdocs/core/modules/modLdap.class.php b/htdocs/core/modules/modLdap.class.php index 31f51d5d956..27174a7dda0 100644 --- a/htdocs/core/modules/modLdap.class.php +++ b/htdocs/core/modules/modLdap.class.php @@ -46,7 +46,8 @@ class modLdap extends DolibarrModules // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module) $this->name = preg_replace('/^mod/i','',get_class($this)); $this->description = "Synchronisation Ldap"; - $this->version = 'dolibarr'; // 'experimental' or 'dolibarr' or version + // Possible values for version are: 'development', 'experimental', 'dolibarr' or version + $this->version = 'dolibarr'; $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); // Where to store the module in setup page (0=common,1=interface,2=others,3=very specific) $this->special = 1; diff --git a/htdocs/core/modules/modMailing.class.php b/htdocs/core/modules/modMailing.class.php index 45d2685abe4..64966e2105c 100644 --- a/htdocs/core/modules/modMailing.class.php +++ b/htdocs/core/modules/modMailing.class.php @@ -48,7 +48,8 @@ class modMailing extends DolibarrModules // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module) $this->name = preg_replace('/^mod/i','',get_class($this)); $this->description = "Gestion des EMailings"; - $this->version = 'dolibarr'; // 'experimental' or 'dolibarr' or version + // Possible values for version are: 'development', 'experimental', 'dolibarr' or version + $this->version = 'dolibarr'; $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); $this->special = 0; $this->picto='email'; @@ -130,7 +131,7 @@ class modMailing extends DolibarrModules // Menus //------- $this->menu = 1; // This module add menu entries. They are coded into menu manager. - + } diff --git a/htdocs/core/modules/modMailmanSpip.class.php b/htdocs/core/modules/modMailmanSpip.class.php index 3900c0549b9..209dcba3d2b 100644 --- a/htdocs/core/modules/modMailmanSpip.class.php +++ b/htdocs/core/modules/modMailmanSpip.class.php @@ -48,7 +48,8 @@ class modMailmanSpip extends DolibarrModules $this->name = preg_replace('/^mod/i','',get_class($this)); $this->description = "Mailman or Spip interface for member module"; - $this->version = 'dolibarr'; // 'development' or 'experimental' or 'dolibarr' or version + // Possible values for version are: 'development', 'experimental', 'dolibarr' or 'dolibarr_deprecated' or version + $this->version = 'dolibarr'; $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); $this->special = 1; @@ -76,10 +77,10 @@ class modMailmanSpip extends DolibarrModules // Permissions $this->rights = array(); $this->rights_class = 'clicktodial'; - + // Menus //------- $this->menu = 1; // This module add menu entries. They are coded into menu manager. - + } } diff --git a/htdocs/core/modules/modModuleBuilder.class.php b/htdocs/core/modules/modModuleBuilder.class.php index dabfda48518..944664f2339 100644 --- a/htdocs/core/modules/modModuleBuilder.class.php +++ b/htdocs/core/modules/modModuleBuilder.class.php @@ -47,7 +47,8 @@ class modModuleBuilder extends DolibarrModules // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module) $this->name = preg_replace('/^mod/i','',get_class($this)); $this->description = "A tool to help developers to build their own module."; - $this->version = 'experimental'; // 'development', 'experimental' or 'dolibarr' or version + // Possible values for version are: 'development', 'experimental', 'dolibarr' or version + $this->version = 'experimental'; // Key used in llx_const table to save module status enabled/disabled (where MYMODULE is value of property name of module in uppercase) $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); // Where to store the module in setup page (0=common,1=interface,2=others,3=very specific) diff --git a/htdocs/core/modules/modNotification.class.php b/htdocs/core/modules/modNotification.class.php index 298d877d4aa..a4a56e1da0d 100644 --- a/htdocs/core/modules/modNotification.class.php +++ b/htdocs/core/modules/modNotification.class.php @@ -46,7 +46,8 @@ class modNotification extends DolibarrModules $this->name = preg_replace('/^mod/i','',get_class($this)); $this->description = "EMail notifications (push) on business Dolibarr events"; $this->descriptionlong = 'Module600Long'; - $this->version = 'dolibarr'; // 'experimental' or 'dolibarr' or version + // Possible values for version are: 'development', 'experimental', 'dolibarr' or version + $this->version = 'dolibarr'; $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); $this->special = 1; $this->picto='email'; diff --git a/htdocs/core/modules/modOauth.class.php b/htdocs/core/modules/modOauth.class.php index 4be01e561fe..4d64c666c60 100644 --- a/htdocs/core/modules/modOauth.class.php +++ b/htdocs/core/modules/modOauth.class.php @@ -52,7 +52,8 @@ class modOauth extends DolibarrModules $this->name = preg_replace('/^mod/i','',get_class($this)); // Module description, used if translation string 'ModuleXXXDesc' not found (where XXX is value of numeric property 'numero' of module) $this->description = "Enable OAuth authentication"; - $this->version = 'dolibarr'; // 'development' or 'experimental' or 'dolibarr' or version + // Possible values for version are: 'development', 'experimental', 'dolibarr' or 'dolibarr_deprecated' or version + $this->version = 'dolibarr'; $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); // Where to store the module in setup page (0=common,1=interface,2=others,3=very specific) $this->special = 1; diff --git a/htdocs/core/modules/modReceiptPrinter.class.php b/htdocs/core/modules/modReceiptPrinter.class.php index 2fc7d10fe5a..50c93f07220 100644 --- a/htdocs/core/modules/modReceiptPrinter.class.php +++ b/htdocs/core/modules/modReceiptPrinter.class.php @@ -52,7 +52,8 @@ class modReceiptPrinter extends DolibarrModules $this->name = preg_replace('/^mod/i','',get_class($this)); // Module description, used if translation string 'ModuleXXXDesc' not found (where XXX is value of numeric property 'numero' of module) $this->description = "ReceiptPrinterDesc"; - $this->version = 'development'; // 'development' or 'experimental' or 'dolibarr' or version + // Possible values for version are: 'development', 'experimental', 'dolibarr' or 'dolibarr_deprecated' or version + $this->version = 'development'; $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); // Where to store the module in setup page (0=common,1=interface,2=others,3=very specific) $this->special = 1; diff --git a/htdocs/core/modules/modSkype.class.php b/htdocs/core/modules/modSkype.class.php index ca9179d5fa3..4c7d862cf66 100644 --- a/htdocs/core/modules/modSkype.class.php +++ b/htdocs/core/modules/modSkype.class.php @@ -48,7 +48,8 @@ class modSkype extends DolibarrModules // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module) $this->name = preg_replace('/^mod/i','',get_class($this)); $this->description = "Enable Skype links into contacts"; - $this->version = 'dolibarr'; // 'experimental' or 'dolibarr' or version + // Possible values for version are: 'development', 'experimental', 'dolibarr' or version + $this->version = 'dolibarr'; // Key used in llx_const table to save module status enabled/disabled (where MYMODULE is value of property name of module in uppercase) $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); // Where to store the module in setup page (0=common,1=interface,2=others,3=very specific) diff --git a/htdocs/core/modules/modSyslog.class.php b/htdocs/core/modules/modSyslog.class.php index fc8ad99abf8..6ef7648531a 100644 --- a/htdocs/core/modules/modSyslog.class.php +++ b/htdocs/core/modules/modSyslog.class.php @@ -52,7 +52,7 @@ class modSyslog extends DolibarrModules // Can be enabled / disabled only in the main company $this->core_enabled = true; // Possible values for version are: 'development', 'experimental', 'dolibarr' or version - $this->version = 'dolibarr'; // 'experimental' or 'dolibarr' or version + $this->version = 'dolibarr'; // Key used in llx_const table to save module status enabled/disabled (where MYMODULE is value of property name of module in uppercase) $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); // Where to store the module in setup page (0=common,1=interface,2=others,3=very specific) diff --git a/htdocs/core/modules/modWebServices.class.php b/htdocs/core/modules/modWebServices.class.php index 59e934500b6..f4383bc6dc5 100644 --- a/htdocs/core/modules/modWebServices.class.php +++ b/htdocs/core/modules/modWebServices.class.php @@ -44,7 +44,8 @@ class modWebServices extends DolibarrModules // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module) $this->name = preg_replace('/^mod/i','',get_class($this)); $this->description = "Enable the Dolibarr web services server"; - $this->version = 'dolibarr'; // 'experimental' or 'dolibarr' or version + // Possible values for version are: 'development', 'experimental', 'dolibarr' or version + $this->version = 'dolibarr'; // Key used in llx_const table to save module status enabled/disabled (where MYMODULE is value of property name of module in uppercase) $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); // Where to store the module in setup page (0=common,1=interface,2=others,3=very specific) diff --git a/htdocs/core/modules/modWebServicesClient.class.php b/htdocs/core/modules/modWebServicesClient.class.php index c5365ba4459..2dd0ee871c5 100644 --- a/htdocs/core/modules/modWebServicesClient.class.php +++ b/htdocs/core/modules/modWebServicesClient.class.php @@ -44,7 +44,8 @@ class modWebServicesClient extends DolibarrModules // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module) $this->name = preg_replace('/^mod/i','',get_class($this)); $this->description = "Enable the web service client to call external supplier web services"; - $this->version = 'experimental'; // 'experimental' or 'dolibarr' or version + // Possible values for version are: 'development', 'experimental', 'dolibarr' or version + $this->version = 'experimental'; // Key used in llx_const table to save module status enabled/disabled (where MYMODULE is value of property name of module in uppercase) $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); // Where to store the module in setup page (0=common,1=interface,2=others,3=very specific) diff --git a/htdocs/core/modules/modWebsites.class.php b/htdocs/core/modules/modWebsites.class.php index 2c8e2e608a5..d6d984193d9 100644 --- a/htdocs/core/modules/modWebsites.class.php +++ b/htdocs/core/modules/modWebsites.class.php @@ -50,7 +50,8 @@ class modWebsites extends DolibarrModules // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module) $this->name = preg_replace('/^mod/i','',get_class($this)); $this->description = "Enable to build and serve public websites with CMS features"; - $this->version = 'development'; // 'experimental' or 'dolibarr' or version + // Possible values for version are: 'development', 'experimental', 'dolibarr' or version + $this->version = 'experimental'; // Key used in llx_const table to save module status enabled/disabled (where MYMODULE is value of property name of module in uppercase) $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); // Where to store the module in setup page (0=common,1=interface,2=others,3=very specific) diff --git a/htdocs/core/modules/printsheet/doc/pdf_standardlabel.class.php b/htdocs/core/modules/printsheet/doc/pdf_standardlabel.class.php index 6411e97c423..78898735f0c 100644 --- a/htdocs/core/modules/printsheet/doc/pdf_standardlabel.class.php +++ b/htdocs/core/modules/printsheet/doc/pdf_standardlabel.class.php @@ -326,8 +326,6 @@ class pdf_standardlabel extends CommonStickerGenerator if (! empty($conf->global->MAIN_UMASK)) @chmod($file, octdec($conf->global->MAIN_UMASK)); - - // Output to http stream clearstatcache(); @@ -346,6 +344,8 @@ class pdf_standardlabel extends CommonStickerGenerator readfile($file); + $this->result = array('fullpath'=>$file); + return 1; } } diff --git a/htdocs/core/modules/printsheet/doc/pdf_tcpdflabel.class.php b/htdocs/core/modules/printsheet/doc/pdf_tcpdflabel.class.php index 4605b81de5e..faa62d45431 100644 --- a/htdocs/core/modules/printsheet/doc/pdf_tcpdflabel.class.php +++ b/htdocs/core/modules/printsheet/doc/pdf_tcpdflabel.class.php @@ -367,8 +367,6 @@ class pdf_tcpdflabel extends CommonStickerGenerator if (! empty($conf->global->MAIN_UMASK)) @chmod($file, octdec($conf->global->MAIN_UMASK)); - - // Output to http stream clearstatcache(); @@ -387,6 +385,8 @@ class pdf_tcpdflabel extends CommonStickerGenerator readfile($file); + $this->result = array('fullpath'=>$file); + return 1; } } diff --git a/htdocs/core/modules/product/doc/doc_generic_product_odt.modules.php b/htdocs/core/modules/product/doc/doc_generic_product_odt.modules.php index 811a99d5b2a..c7eed903e8e 100644 --- a/htdocs/core/modules/product/doc/doc_generic_product_odt.modules.php +++ b/htdocs/core/modules/product/doc/doc_generic_product_odt.modules.php @@ -483,6 +483,8 @@ class doc_generic_product_odt extends ModelePDFProduct $odfHandler=null; // Destroy object + $this->result = array('fullpath'=>$file); + return 1; // Success } else diff --git a/htdocs/core/modules/product/doc/pdf_standard.modules.php b/htdocs/core/modules/product/doc/pdf_standard.modules.php index 29df1127242..62f8624110f 100644 --- a/htdocs/core/modules/product/doc/pdf_standard.modules.php +++ b/htdocs/core/modules/product/doc/pdf_standard.modules.php @@ -542,6 +542,8 @@ class pdf_standard extends ModelePDFProduct if (! empty($conf->global->MAIN_UMASK)) @chmod($file, octdec($conf->global->MAIN_UMASK)); + $this->result = array('fullpath'=>$file); + return 1; // Pas d'erreur } else diff --git a/htdocs/core/modules/project/doc/doc_generic_project_odt.modules.php b/htdocs/core/modules/project/doc/doc_generic_project_odt.modules.php index e050bf8e3eb..be4f5898f85 100644 --- a/htdocs/core/modules/project/doc/doc_generic_project_odt.modules.php +++ b/htdocs/core/modules/project/doc/doc_generic_project_odt.modules.php @@ -1066,6 +1066,8 @@ class doc_generic_project_odt extends ModelePDFProjects $odfHandler=null; // Destroy object + $this->result = array('fullpath'=>$file); + return 1; // Success } else diff --git a/htdocs/core/modules/project/doc/pdf_baleine.modules.php b/htdocs/core/modules/project/doc/pdf_baleine.modules.php index 334846ab69b..b2ad0f26c0e 100644 --- a/htdocs/core/modules/project/doc/pdf_baleine.modules.php +++ b/htdocs/core/modules/project/doc/pdf_baleine.modules.php @@ -154,11 +154,11 @@ class pdf_baleine extends ModelePDFProjects $task = new Task($this->db); $tasksarray = $task->getTasksArray(0,0,$object->id); - if (! $object->id > 0) // Special case when used with object = specimen, we may return all lines + if (! $object->id > 0) // Special case when used with object = specimen, we may return all lines { $tasksarray=array_slice($tasksarray, 0, min(5, count($tasksarray))); } - + $object->lines=$tasksarray; $nblignes=count($object->lines); @@ -329,6 +329,8 @@ class pdf_baleine extends ModelePDFProjects if (! empty($conf->global->MAIN_UMASK)) @chmod($file, octdec($conf->global->MAIN_UMASK)); + $this->result = array('fullpath'=>$file); + return 1; // Pas d'erreur } else diff --git a/htdocs/core/modules/project/doc/pdf_beluga.modules.php b/htdocs/core/modules/project/doc/pdf_beluga.modules.php index 15fd0e5f615..8a288c547d5 100644 --- a/htdocs/core/modules/project/doc/pdf_beluga.modules.php +++ b/htdocs/core/modules/project/doc/pdf_beluga.modules.php @@ -503,6 +503,8 @@ class pdf_beluga extends ModelePDFProjects if (! empty($conf->global->MAIN_UMASK)) @chmod($file, octdec($conf->global->MAIN_UMASK)); + $this->result = array('fullpath'=>$file); + return 1; // Pas d'erreur } else diff --git a/htdocs/core/modules/project/task/doc/doc_generic_task_odt.modules.php b/htdocs/core/modules/project/task/doc/doc_generic_task_odt.modules.php index 187018e0031..17e08dd4fd3 100644 --- a/htdocs/core/modules/project/task/doc/doc_generic_task_odt.modules.php +++ b/htdocs/core/modules/project/task/doc/doc_generic_task_odt.modules.php @@ -829,6 +829,8 @@ class doc_generic_task_odt extends ModelePDFTask $odfHandler=null; // Destroy object + $this->result = array('fullpath'=>$file); + return 1; // Success } else diff --git a/htdocs/core/modules/propale/doc/doc_generic_proposal_odt.modules.php b/htdocs/core/modules/propale/doc/doc_generic_proposal_odt.modules.php index 130aa90ecfd..372edb5e5de 100644 --- a/htdocs/core/modules/propale/doc/doc_generic_proposal_odt.modules.php +++ b/htdocs/core/modules/propale/doc/doc_generic_proposal_odt.modules.php @@ -494,6 +494,8 @@ class doc_generic_proposal_odt extends ModelePDFPropales $odfHandler=null; // Destroy object + $this->result = array('fullpath'=>$file); + return 1; // Success } else diff --git a/htdocs/core/modules/propale/doc/pdf_azur.modules.php b/htdocs/core/modules/propale/doc/pdf_azur.modules.php index 250796dd9d5..602375c62ed 100644 --- a/htdocs/core/modules/propale/doc/pdf_azur.modules.php +++ b/htdocs/core/modules/propale/doc/pdf_azur.modules.php @@ -451,8 +451,6 @@ class pdf_azur extends ModelePDFPropales // Description of product line $curX = $this->posxdesc-1; - $showpricebeforepagebreak=1; - $pdf->startTransaction(); pdf_writelinedesc($pdf,$object,$i,$outputlangs,$this->posxpicture-$curX,3,$curX,$curY,$hideref,$hidedesc); $pageposafter=$pdf->getPage(); @@ -761,6 +759,8 @@ class pdf_azur extends ModelePDFPropales if (! empty($conf->global->MAIN_UMASK)) @chmod($file, octdec($conf->global->MAIN_UMASK)); + $this->result = array('fullpath'=>$file); + return 1; // Pas d'erreur } else diff --git a/htdocs/core/modules/rapport/pdf_paiement.class.php b/htdocs/core/modules/rapport/pdf_paiement.class.php index 11ee8a32d7d..da1223526db 100644 --- a/htdocs/core/modules/rapport/pdf_paiement.class.php +++ b/htdocs/core/modules/rapport/pdf_paiement.class.php @@ -275,7 +275,9 @@ class pdf_paiement if (! empty($conf->global->MAIN_UMASK)) @chmod($file, octdec($conf->global->MAIN_UMASK)); - + + $this->result = array('fullpath'=>$file); + return 1; } diff --git a/htdocs/core/modules/rapport/pdf_paiement_fourn.class.php b/htdocs/core/modules/rapport/pdf_paiement_fourn.class.php index f20e912e1ed..108b3bd6ce6 100644 --- a/htdocs/core/modules/rapport/pdf_paiement_fourn.class.php +++ b/htdocs/core/modules/rapport/pdf_paiement_fourn.class.php @@ -274,6 +274,8 @@ class pdf_paiement_fourn if (! empty($conf->global->MAIN_UMASK)) @chmod($file, octdec($conf->global->MAIN_UMASK)); + $this->result = array('fullpath'=>$file); + return 1; } diff --git a/htdocs/core/modules/societe/doc/doc_generic_odt.modules.php b/htdocs/core/modules/societe/doc/doc_generic_odt.modules.php index edee43b274c..539d5df8c2a 100644 --- a/htdocs/core/modules/societe/doc/doc_generic_odt.modules.php +++ b/htdocs/core/modules/societe/doc/doc_generic_odt.modules.php @@ -459,6 +459,8 @@ class doc_generic_odt extends ModeleThirdPartyDoc $odfHandler=null; // Destroy object + $this->result = array('fullpath'=>$file); + return 1; // Success } else diff --git a/htdocs/core/modules/supplier_invoice/pdf/pdf_canelle.modules.php b/htdocs/core/modules/supplier_invoice/pdf/pdf_canelle.modules.php index 1e7e6f4bcad..8fd90eb3e31 100644 --- a/htdocs/core/modules/supplier_invoice/pdf/pdf_canelle.modules.php +++ b/htdocs/core/modules/supplier_invoice/pdf/pdf_canelle.modules.php @@ -539,6 +539,8 @@ class pdf_canelle extends ModelePDFSuppliersInvoices if (! empty($conf->global->MAIN_UMASK)) @chmod($file, octdec($conf->global->MAIN_UMASK)); + $this->result = array('fullpath'=>$file); + return 1; // Pas d'erreur } else diff --git a/htdocs/core/modules/supplier_order/pdf/pdf_muscadet.modules.php b/htdocs/core/modules/supplier_order/pdf/pdf_muscadet.modules.php index c882ed89800..8b8a9e3d832 100644 --- a/htdocs/core/modules/supplier_order/pdf/pdf_muscadet.modules.php +++ b/htdocs/core/modules/supplier_order/pdf/pdf_muscadet.modules.php @@ -110,17 +110,17 @@ class pdf_muscadet extends ModelePDFSuppliersOrders if ($conf->global->PRODUCT_USE_UNITS) { - $this->posxtva=99; + $this->posxtva=95; $this->posxup=114; - $this->posxqty=130; + $this->posxqty=132; $this->posxunit=147; } else { - $this->posxtva=112; + $this->posxtva=110; $this->posxup=126; $this->posxqty=145; } - //if (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT)) $this->posxtva=$this->posxup; + if (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT)) $this->posxup = $this->posxtva; // posxtva is picture position reference $this->posxpicture=$this->posxtva - (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH)?20:$conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH); // width of images if ($this->page_largeur < 210) // To work with US executive format { @@ -167,6 +167,44 @@ class pdf_muscadet extends ModelePDFSuppliersOrders $outputlangs->load("products"); $outputlangs->load("orders"); + $nblignes = count($object->lines); + + // Loop on each lines to detect if there is at least one image to show + $realpatharray=array(); + if (! empty($conf->global->MAIN_GENERATE_SUPPLIER_ORDER_WITH_PICTURE)) + { + for ($i = 0 ; $i < $nblignes ; $i++) + { + if (empty($object->lines[$i]->fk_product)) continue; + + $objphoto = new Product($this->db); + $objphoto->fetch($object->lines[$i]->fk_product); + + if (! empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO)) + { + $pdir = get_exdir($object->lines[$i]->fk_product,2,0,0,$objphoto,'product') . $object->lines[$i]->fk_product ."/photos/"; + $dir = $conf->product->dir_output.'/'.$pdir; + } + else + { + $pdir = get_exdir(0,2,0,0,$objphoto,'product') . dol_sanitizeFileName($objphoto->ref).'/'; + $dir = $conf->product->dir_output.'/'.$pdir; + } + + $realpath=''; + foreach ($objphoto->liste_photos($dir,1) as $key => $obj) + { + $filename=$obj['photo']; + //if ($obj['photo_vignette']) $filename='thumbs/'.$obj['photo_vignette']; + $realpath = $dir.$filename; + break; + } + + if ($realpath) $realpatharray[$i]=$realpath; + } + } + if (count($realpatharray) == 0) $this->posxpicture=$this->posxtva; + if ($conf->fournisseur->dir_output.'/commande') { $object->fetch_thirdparty(); @@ -338,16 +376,52 @@ class pdf_muscadet extends ModelePDFSuppliersOrders $pdf->SetFont('','', $default_font_size - 1); // Into loop to work with multipage $pdf->SetTextColor(0,0,0); + // Define size of image if we need it + $imglinesize=array(); + if (! empty($realpatharray[$i])) $imglinesize=pdf_getSizeForImage($realpatharray[$i]); + $pdf->setTopMargin($tab_top_newpage); $pdf->setPageOrientation('', 1, $heightforfooter+$heightforfreetext+$heightforinfotot); // The only function to edit the bottom margin of current page to set it. $pageposbefore=$pdf->getPage(); + $showpricebeforepagebreak=1; + $posYAfterImage=0; + $posYAfterDescription=0; + + // We start with Photo of product line + if (!empty($imglinesize['width']) && !empty($imglinesize['height']) && ($curY + $imglinesize['height']) > ($this->page_hauteur-($heightforfooter+$heightforfreetext+$heightforinfotot))) // If photo too high, we moved completely on new page + { + $pdf->AddPage('','',true); + if (! empty($tplidx)) $pdf->useTemplate($tplidx); + if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); + $pdf->setPage($pageposbefore+1); + + $curY = $tab_top_newpage; + $showpricebeforepagebreak=0; + } + + if (!empty($imglinesize['width']) && !empty($imglinesize['height'])) + { + $curX = $this->posxpicture-1; + $pdf->Image($realpatharray[$i], $curX + (($this->posxtva-$this->posxpicture-$imglinesize['width'])/2), $curY, $imglinesize['width'], $imglinesize['height'], '', '', '', 2, 300); // Use 300 dpi + // $pdf->Image does not increase value return by getY, so we save it manually + $posYAfterImage=$curY+$imglinesize['height']; + } // Description of product line $curX = $this->posxdesc-1; $showpricebeforepagebreak=1; $pdf->startTransaction(); - pdf_writelinedesc($pdf,$object,$i,$outputlangs,$this->posxtva-$curX,3,$curX,$curY,$hideref,$hidedesc,1); + if ($posYAfterImage > 0) + { + $descWidth = $this->posxpicture-$curX; + } + else + { + $descWidth = $this->posxtva-$curX; + } + pdf_writelinedesc($pdf,$object,$i,$outputlangs,$descWidth,3,$curX,$curY,$hideref,$hidedesc,1); + $pageposafter=$pdf->getPage(); if ($pageposafter > $pageposbefore) // There is a pagebreak { @@ -355,7 +429,7 @@ class pdf_muscadet extends ModelePDFSuppliersOrders $pageposafter=$pageposbefore; //print $pageposafter.'-'.$pageposbefore;exit; $pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it. - pdf_writelinedesc($pdf,$object,$i,$outputlangs,$this->posxtva-$curX,4,$curX,$curY,$hideref,$hidedesc,1); + pdf_writelinedesc($pdf,$object,$i,$outputlangs,$descWidth,3,$curX,$curY,$hideref,$hidedesc,1); $posyafter=$pdf->GetY(); if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))) // There is no space left for total+free text { @@ -472,6 +546,7 @@ class pdf_muscadet extends ModelePDFSuppliersOrders if (! isset($this->tva[$vatrate])) $this->tva[$vatrate]=0; $this->tva[$vatrate] += $tvaligne; + if ($posYAfterImage > $posYAfterDescription) $nexY=$posYAfterImage; // Add line if (! empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblignes - 1)) @@ -563,6 +638,8 @@ class pdf_muscadet extends ModelePDFSuppliersOrders if (! empty($conf->global->MAIN_UMASK)) @chmod($file, octdec($conf->global->MAIN_UMASK)); + $this->result = array('fullpath'=>$file); + return 1; // Pas d'erreur } else @@ -924,7 +1001,7 @@ class pdf_muscadet extends ModelePDFSuppliersOrders if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT)) { - $pdf->line($this->posxtva-1, $tab_top, $this->posxtva-1, $tab_top + $tab_height); + $pdf->line($this->posxtva, $tab_top, $this->posxtva, $tab_top + $tab_height); if (empty($hidetop)) { $pdf->SetXY($this->posxtva-3, $tab_top+1); @@ -932,7 +1009,7 @@ class pdf_muscadet extends ModelePDFSuppliersOrders } } - $pdf->line($this->posxup-1, $tab_top, $this->posxup-1, $tab_top + $tab_height); + $pdf->line($this->posxup, $tab_top, $this->posxup, $tab_top + $tab_height); if (empty($hidetop)) { $pdf->SetXY($this->posxup-1, $tab_top+1); diff --git a/htdocs/core/modules/supplier_payment/doc/pdf_standard.modules.php b/htdocs/core/modules/supplier_payment/doc/pdf_standard.modules.php index 6fbfb4b1bf4..2b657dbd962 100644 --- a/htdocs/core/modules/supplier_payment/doc/pdf_standard.modules.php +++ b/htdocs/core/modules/supplier_payment/doc/pdf_standard.modules.php @@ -442,6 +442,8 @@ class pdf_standard extends ModelePDFSuppliersPayments if (! empty($conf->global->MAIN_UMASK)) @chmod($file, octdec($conf->global->MAIN_UMASK)); + $this->result = array('fullpath'=>$file); + return 1; // Pas d'erreur } else diff --git a/htdocs/core/modules/supplier_proposal/doc/doc_generic_supplier_proposal_odt.modules.php b/htdocs/core/modules/supplier_proposal/doc/doc_generic_supplier_proposal_odt.modules.php index 212685ba519..4f445501669 100644 --- a/htdocs/core/modules/supplier_proposal/doc/doc_generic_supplier_proposal_odt.modules.php +++ b/htdocs/core/modules/supplier_proposal/doc/doc_generic_supplier_proposal_odt.modules.php @@ -486,6 +486,8 @@ class doc_generic_supplier_proposal_odt extends ModelePDFSupplierProposal $odfHandler=null; // Destroy object + $this->result = array('fullpath'=>$file); + return 1; // Success } else diff --git a/htdocs/core/modules/supplier_proposal/doc/pdf_aurore.modules.php b/htdocs/core/modules/supplier_proposal/doc/pdf_aurore.modules.php index a7e8952c604..5f3f9550179 100644 --- a/htdocs/core/modules/supplier_proposal/doc/pdf_aurore.modules.php +++ b/htdocs/core/modules/supplier_proposal/doc/pdf_aurore.modules.php @@ -108,7 +108,7 @@ class pdf_aurore extends ModelePDFSupplierProposal $this->posxqty=145; $this->posxdiscount=162; $this->postotalht=174; - if (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT) || ! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_COLUMN)) $this->posxtva=$this->posxup; + if (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT) || ! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_COLUMN)) $this->posxup=$this->posxtva; $this->posxpicture=$this->posxtva - (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH)?20:$conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH); // width of images if ($this->page_largeur < 210) // To work with US executive format { @@ -357,7 +357,7 @@ class pdf_aurore extends ModelePDFSupplierProposal $posYAfterDescription=0; // We start with Photo of product line - if (isset($imglinesize['width']) && isset($imglinesize['height']) && ($curY + $imglinesize['height']) > ($this->page_hauteur-($heightforfooter+$heightforfreetext+$heightforinfotot))) // If photo too high, we moved completely on new page + if (!empty($imglinesize['width']) && !empty($imglinesize['height']) && ($curY + $imglinesize['height']) > ($this->page_hauteur-($heightforfooter+$heightforfreetext+$heightforinfotot))) // If photo too high, we moved completely on new page { $pdf->AddPage('','',true); if (! empty($tplidx)) $pdf->useTemplate($tplidx); @@ -368,7 +368,7 @@ class pdf_aurore extends ModelePDFSupplierProposal $showpricebeforepagebreak=0; } - if (isset($imglinesize['width']) && isset($imglinesize['height'])) + if (!empty($imglinesize['width']) && !empty($imglinesize['height'])) { $curX = $this->posxpicture-1; $pdf->Image($realpatharray[$i], $curX + (($this->posxtva-$this->posxpicture-$imglinesize['width'])/2), $curY, $imglinesize['width'], $imglinesize['height'], '', '', '', 2, 300); // Use 300 dpi @@ -380,7 +380,15 @@ class pdf_aurore extends ModelePDFSupplierProposal $curX = $this->posxdesc-1; $pdf->startTransaction(); - pdf_writelinedesc($pdf,$object,$i,$outputlangs,$this->posxpicture-$curX,3,$curX,$curY,$hideref,$hidedesc); + if ($posYAfterImage > 0) + { + $descWidth = $this->posxpicture-$curX; + } + else + { + $descWidth = $this->posxtva-$curX; + } + pdf_writelinedesc($pdf,$object,$i,$outputlangs,$descWidth,3,$curX,$curY,$hideref,$hidedesc,1); $pageposafter=$pdf->getPage(); if ($pageposafter > $pageposbefore) // There is a pagebreak @@ -389,7 +397,7 @@ class pdf_aurore extends ModelePDFSupplierProposal $pageposafter=$pageposbefore; //print $pageposafter.'-'.$pageposbefore;exit; $pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it. - pdf_writelinedesc($pdf,$object,$i,$outputlangs,$this->posxpicture-$curX,3,$curX,$curY,$hideref,$hidedesc); + pdf_writelinedesc($pdf,$object,$i,$outputlangs,$descWidth,3,$curX,$curY,$hideref,$hidedesc); $pageposafter=$pdf->getPage(); $posyafter=$pdf->GetY(); @@ -597,6 +605,8 @@ class pdf_aurore extends ModelePDFSupplierProposal if (! empty($conf->global->MAIN_UMASK)) @chmod($file, octdec($conf->global->MAIN_UMASK)); + $this->result = array('fullpath'=>$file); + return 1; // Pas d'erreur } else @@ -1131,20 +1141,10 @@ class pdf_aurore extends ModelePDFSupplierProposal $pdf->MultiCell(108,2, $outputlangs->transnoentities("Designation"),'','L'); } - if (! empty($conf->global->MAIN_GENERATE_PROPOSALS_WITH_PICTURE)) - { - $pdf->line($this->posxpicture-1, $tab_top, $this->posxpicture-1, $tab_top + $tab_height); - if (empty($hidetop)) - { - //$pdf->SetXY($this->posxpicture-1, $tab_top+1); - //$pdf->MultiCell($this->posxtva-$this->posxpicture-1,2, $outputlangs->transnoentities("Photo"),'','C'); - } - } - if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT)) { - //$pdf->line($this->posxtva-1, $tab_top, $this->posxtva-1, $tab_top + $tab_height); - $pdf->line($this->posxtva-2, $tab_top, $this->posxtva-2, $tab_top + $tab_height); + $pdf->line($this->posxtva, $tab_top, $this->posxtva, $tab_top + $tab_height); + //$pdf->line($this->posxtva-2, $tab_top, $this->posxtva-2, $tab_top + $tab_height); if (empty($hidetop)) { $pdf->SetXY($this->posxtva-5, $tab_top+1); diff --git a/htdocs/core/modules/user/doc/doc_generic_user_odt.modules.php b/htdocs/core/modules/user/doc/doc_generic_user_odt.modules.php index b7079dde30e..38d9ce62f50 100644 --- a/htdocs/core/modules/user/doc/doc_generic_user_odt.modules.php +++ b/htdocs/core/modules/user/doc/doc_generic_user_odt.modules.php @@ -408,6 +408,8 @@ class doc_generic_user_odt extends ModelePDFUser $odfHandler=null; // Destroy object + $this->result = array('fullpath'=>$file); + return 1; // Success } else diff --git a/htdocs/core/modules/usergroup/doc/doc_generic_usergroup_odt.modules.php b/htdocs/core/modules/usergroup/doc/doc_generic_usergroup_odt.modules.php index 35367052796..453bde8515f 100644 --- a/htdocs/core/modules/usergroup/doc/doc_generic_usergroup_odt.modules.php +++ b/htdocs/core/modules/usergroup/doc/doc_generic_usergroup_odt.modules.php @@ -485,6 +485,8 @@ class doc_generic_usergroup_odt extends ModelePDFUserGroup $odfHandler=null; // Destroy object + $this->result = array('fullpath'=>$file); + return 1; // Success } else diff --git a/htdocs/core/tpl/admin_extrafields_add.tpl.php b/htdocs/core/tpl/admin_extrafields_add.tpl.php index ce63a3a0902..a7f98bdba72 100644 --- a/htdocs/core/tpl/admin_extrafields_add.tpl.php +++ b/htdocs/core/tpl/admin_extrafields_add.tpl.php @@ -1,5 +1,5 @@ +/* Copyright (C) 2010-2017 Laurent Destailleur * Copyright (C) 2012 Regis Houssin * Copyright (C) 2016 Charlie Benke * @@ -56,11 +56,11 @@ // Case of computed field console.log(type); - if (type == '' || type == 'varchar' || type == 'int' || type == 'double' || type == 'price') { - jQuery("tr.extra_computed_value").show(); + if (type == '' || type == 'varchar' || type == 'int' || type == 'double' || type == 'price') { + jQuery("tr.extra_computed_value").show(); } else { computed_value.val(''); jQuery("tr.extra_computed_value").hide(); - } + } if (computed_value.val()) { console.log("We enter a computed formula"); @@ -75,7 +75,7 @@ jQuery("#default_value, #unique, #required, #alwayseditable, #ishidden, #list").attr('disabled', false); jQuery("tr.extra_default_value, tr.extra_unique, tr.extra_required, tr.extra_alwayseditable, tr.extra_ishidden, tr.extra_list").show(); } - + if (type == 'date') { size.val('').prop('disabled', true); unique.removeAttr('disabled'); jQuery("#value_choice").hide();jQuery("#helpchkbxlst").hide(); } else if (type == 'datetime') { size.val('').prop('disabled', true); unique.removeAttr('disabled'); jQuery("#value_choice").hide(); jQuery("#helpchkbxlst").hide();} else if (type == 'double') { size.val('24,8').removeAttr('disabled'); unique.removeAttr('disabled'); jQuery("#value_choice").hide(); jQuery("#helpchkbxlst").hide();} @@ -90,8 +90,8 @@ else if (type == 'checkbox') { size.val('').prop('disabled', true); unique.removeAttr('checked').prop('disabled', true); jQuery("#value_choice").show();jQuery("#helpselect").show();jQuery("#helpsellist").hide();jQuery("#helpchkbxlst").hide();jQuery("#helplink").hide();} else if (type == 'chkbxlst') { size.val('').prop('disabled', true); unique.removeAttr('checked').prop('disabled', true); jQuery("#value_choice").show();jQuery("#helpselect").hide();jQuery("#helpsellist").hide();jQuery("#helpchkbxlst").show();jQuery("#helplink").hide();} else if (type == 'link') { size.val('').prop('disabled', true); unique.removeAttr('disabled'); jQuery("#value_choice").show();jQuery("#helpselect").hide();jQuery("#helpsellist").hide();jQuery("#helpchkbxlst").hide();jQuery("#helplink").show();} - else if (type == 'separate') { - size.val('').prop('disabled', true); unique.removeAttr('checked').prop('disabled', true); required.val('').prop('disabled', true); + else if (type == 'separate') { + size.val('').prop('disabled', true); unique.removeAttr('checked').prop('disabled', true); required.val('').prop('disabled', true); jQuery("#value_choice").hide();jQuery("#helpselect").hide();jQuery("#helpsellist").hide();jQuery("#helpchkbxlst").hide();jQuery("#helplink").hide(); } else { // type = string @@ -102,12 +102,12 @@ if (type == 'separate') { required.removeAttr('checked').prop('disabled', true); alwayseditable.removeAttr('checked').prop('disabled', true); list.val('').prop('disabled', true); - jQuery('#size, #default_value').val('').prop('disabled', true); + jQuery('#size, #default_value').val('').prop('disabled', true); } else { default_value.removeAttr('disabled'); - required.removeAttr('disabled'); alwayseditable.removeAttr('disabled'); list.val('').removeAttr('disabled'); + required.removeAttr('disabled'); alwayseditable.removeAttr('disabled'); list.val('').removeAttr('disabled'); } } init_typeoffields(''); @@ -158,7 +158,9 @@ -trans("Position"); ?> +trans("Position"); ?> + +trans("LanguageFile"); ?> textwithpicto($langs->trans("ComputedFormula"), $langs->trans("ComputedFormulaDesc"), 1, 'help', '', 0, 2, 'tooltipcompute'); ?>"> diff --git a/htdocs/core/tpl/admin_extrafields_edit.tpl.php b/htdocs/core/tpl/admin_extrafields_edit.tpl.php index 5a9a5b43d93..beb1e34055e 100644 --- a/htdocs/core/tpl/admin_extrafields_edit.tpl.php +++ b/htdocs/core/tpl/admin_extrafields_edit.tpl.php @@ -54,11 +54,11 @@ ?> // Case of computed field - if (type == 'varchar' || type == 'int' || type == 'double' || type == 'price') { - jQuery("tr.extra_computed_value").show(); + if (type == 'varchar' || type == 'int' || type == 'double' || type == 'price') { + jQuery("tr.extra_computed_value").show(); } else { computed_value.val(''); jQuery("tr.extra_computed_value").hide(); - } + } if (computed_value.val()) { console.log("We enter a computed formula"); @@ -73,7 +73,7 @@ jQuery("#default_value, #unique, #required, #alwayseditable, #ishidden, #list").attr('disabled', false); jQuery("tr.extra_default_value, tr.extra_unique, tr.extra_required, tr.extra_alwayseditable, tr.extra_ishidden, tr.extra_list").show(); } - + if (type == 'date') { size.val('').prop('disabled', true); unique.removeAttr('disabled'); jQuery("#value_choice").hide();jQuery("#helpchkbxlst").hide(); } else if (type == 'datetime') { size.val('').prop('disabled', true); unique.removeAttr('disabled'); jQuery("#value_choice").hide(); jQuery("#helpchkbxlst").hide();} else if (type == 'double') { size.removeAttr('disabled'); unique.removeAttr('disabled'); jQuery("#value_choice").hide(); jQuery("#helpchkbxlst").hide();} @@ -91,19 +91,19 @@ else if (type == 'separate') { size.val('').prop('disabled', true); unique.removeAttr('checked').prop('disabled', true); required.val('').prop('disabled', true); default_value.val('').prop('disabled', true); jQuery("#value_choice").hide();jQuery("#helpselect").hide();jQuery("#helpsellist").hide();jQuery("#helpchkbxlst").hide();jQuery("#helplink").hide();} else { // type = string size.val('').prop('disabled', true); - unique.removeAttr('disabled'); + unique.removeAttr('disabled'); } if (type == 'separate') { - required.removeAttr('checked').prop('disabled', true); alwayseditable.removeAttr('checked').prop('disabled', true); list.val('').prop('disabled', true); - jQuery('#size, #default_value').val('').prop('disabled', true); + required.removeAttr('checked').prop('disabled', true); alwayseditable.removeAttr('checked').prop('disabled', true); list.val('').prop('disabled', true); + jQuery('#size, #default_value').val('').prop('disabled', true); } else { default_value.removeAttr('disabled'); - required.removeAttr('disabled'); alwayseditable.removeAttr('disabled'); list.val('').removeAttr('disabled'); - } + required.removeAttr('disabled'); alwayseditable.removeAttr('disabled'); list.val('').removeAttr('disabled'); + } } init_typeoffields(jQuery("#type").val()); jQuery("#type").change(function() { @@ -113,7 +113,7 @@ // If we enter a formula, we disable other fields jQuery("#computed_value").keyup(function() { init_typeoffields(jQuery('#type').val()); - }); + }); }); @@ -129,23 +129,20 @@ attribute_type[$attrname]; -$size=$extrafields->attribute_size[$attrname]; -$computed=$extrafields->attribute_computed[$attrname]; -$default=$extrafields->attribute_default[$attrname]; -$unique=$extrafields->attribute_unique[$attrname]; -$required=$extrafields->attribute_required[$attrname]; -$pos=$extrafields->attribute_pos[$attrname]; -$alwayseditable=$extrafields->attribute_alwayseditable[$attrname]; -$param=$extrafields->attribute_param[$attrname]; -$perms=$extrafields->attribute_perms[$attrname]; -$list=$extrafields->attribute_list[$attrname]; -if (! empty($conf->global->MAIN_CAN_HIDE_EXTRAFIELDS)) { - $ishidden=$extrafields->attribute_hidden[$attrname]; -} -if ($conf->multicompany->enabled) { - $entitycurrentorall=$extrafields->attribute_entityid[$attrname]; -} +$type=$extrafields->attributes[$elementtype]['type'][$attrname]; +$size=$extrafields->attributes[$elementtype]['size'][$attrname]; +$computed=$extrafields->attributes[$elementtype]['computed'][$attrname]; +$default=$extrafields->attributes[$elementtype]['default'][$attrname]; +$unique=$extrafields->attributes[$elementtype]['unique'][$attrname]; +$required=$extrafields->attributes[$elementtype]['required'][$attrname]; +$pos=$extrafields->attributes[$elementtype]['pos'][$attrname]; +$alwayseditable=$extrafields->attributes[$elementtype]['alwayseditable'][$attrname]; +$param=$extrafields->attributes[$elementtype]['param'][$attrname]; +$perms=$extrafields->attributes[$elementtype]['perms'][$attrname]; +$langfile=$extrafields->attributes[$elementtype]['langfile'][$attrname]; +$list=$extrafields->attributes[$elementtype]['list'][$attrname]; +$ishidden=$extrafields->attributes[$elementtype]['hidden'][$attrname]; +$entitycurrentorall=$extrafields->attributes[$elementtype]['entityid'][$attrname]; if((($type == 'select') || ($type == 'checkbox') || ($type == 'radio')) && is_array($param)) { @@ -220,7 +217,9 @@ else - + + + diff --git a/htdocs/core/tpl/extrafields_view.tpl.php b/htdocs/core/tpl/extrafields_view.tpl.php index 0f1d581c99f..56eb8652d2b 100644 --- a/htdocs/core/tpl/extrafields_view.tpl.php +++ b/htdocs/core/tpl/extrafields_view.tpl.php @@ -37,10 +37,14 @@ $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, print $hookmanager->resPrint; if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); +//var_dump($extrafields->attributes); if (empty($reshook) && ! empty($extrafields->attributes[$object->table_element]['label'])) { foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $label) { + // Load language if required + if (! empty($extrafields->attributes[$object->table_element]['langfile'][$key])) $langs->load($extrafields->attributes[$object->table_element]['langfile'][$key]); + if ($action == 'edit_extras') { $value = (isset($_POST["options_" . $key]) ? $_POST["options_" . $key] : $object->array_options["options_" . $key]); @@ -77,6 +81,7 @@ if (empty($reshook) && ! empty($extrafields->attributes[$object->table_element][ if ($object->element=='shipping') $permok=$user->rights->expedition->creer; if ($object->element=='delivery') $permok=$user->rights->expedition->livraison->creer; if ($object->element=='productlot') $permok=$user->rights->stock->creer; + if ($object->element=='facturerec') $permok=$user->rights->facture->creer; if (($object->statut == 0 || ! empty($extrafields->attributes[$object->table_element]['alwayseditable'][$key])) && $permok && ($action != 'edit_extras' || GETPOST('attribute') != $key) diff --git a/htdocs/core/tpl/login.tpl.php b/htdocs/core/tpl/login.tpl.php index a1fdc3e9e9d..35f6f857526 100644 --- a/htdocs/core/tpl/login.tpl.php +++ b/htdocs/core/tpl/login.tpl.php @@ -49,7 +49,7 @@ print top_htmlhead('', $titleofloginpage, 0, 0, $arrayofjs, array(), 0, $disable ?> -global->MAIN_LOGIN_BACKGROUND)?'':' style="background-image: url(\''.DOL_URL_ROOT.'/viewimage.php?cache=1&noalt=1&modulepart=mycompany&file='.urlencode($conf->global->MAIN_LOGIN_BACKGROUND).'\')"'; ?>> +global->MAIN_LOGIN_BACKGROUND)?'':' style="background-size: cover; background-image: url(\''.DOL_URL_ROOT.'/viewimage.php?cache=1&noalt=1&modulepart=mycompany&file='.urlencode($conf->global->MAIN_LOGIN_BACKGROUND).'\')"'; ?>> dol_use_jmobile)) { ?> + form_attach_new_file($_SERVER["PHP_SELF"], 'none', 0, ($section?$section:-1), $user->rights->ecm->upload, 48, null, '', 0, '', 0, $nameforformuserfile); +} +else print ' '; + +print ''; +// End Add new file area + + print ''; // End top panel, toolbar ?> -
    +
    '; if ($action == 'delete_section') { print $form->formconfirm($_SERVER["PHP_SELF"].'?section='.$section, $langs->trans('DeleteSection'), $langs->trans('ConfirmDeleteSection',$ecmdir->label), 'confirm_deletesection','','',1); - } // End confirm @@ -615,7 +625,7 @@ if (empty($action) || $action == 'file_manager' || preg_match('/refresh/i',$acti // End left panel ?>
    -
    +
    -
    -use_javascript_ajax) && empty($conf->global->MAIN_ECM_DISABLE_JS)) || ! empty($section)) -{ - if (empty($section) || $section == -1) - { - ?> - - form_attach_new_file($_SERVER["PHP_SELF"], 'none', 0, ($section?$section:-1), $user->rights->ecm->upload, 48, null, '', 0, '', 0, 'formuserfile'); -} -else print ' '; - - - -// End Add new file area -?> -
    use_javascript_ajax) && empty($conf->global->MAIN_ECM_DISABLE_JS)) { include DOL_DOCUMENT_ROOT.'/ecm/tpl/enablefiletreeajax.tpl.php'; diff --git a/htdocs/ecm/index_auto.php b/htdocs/ecm/index_auto.php index 9d314e20bbd..3fa2bc1dc7a 100644 --- a/htdocs/ecm/index_auto.php +++ b/htdocs/ecm/index_auto.php @@ -23,9 +23,6 @@ * \brief Main page for ECM section area */ -if (! defined('REQUIRE_JQUERY_LAYOUT')) define('REQUIRE_JQUERY_LAYOUT','1'); -if (! defined('REQUIRE_JQUERY_BLOCKUI')) define('REQUIRE_JQUERY_BLOCKUI', 1); - require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/ecm.lib.php'; @@ -54,6 +51,7 @@ $section=GETPOST('section','int')?GETPOST('section','int'):GETPOST('section_id', $module=GETPOST('module','alpha'); if (! $section) $section=0; $section_dir=GETPOST('section_dir','alpha'); + $search_doc_ref=GETPOST('search_doc_ref','alpha'); $sortfield = GETPOST("sortfield",'alpha'); @@ -95,54 +93,6 @@ if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x', $search_doc_ref=''; } -// Upload file -if (GETPOST("sendit") && ! empty($conf->global->MAIN_UPLOAD_DOC)) -{ - // Define relativepath and upload_dir - $relativepath=''; - if ($ecmdir->id) $relativepath=$ecmdir->getRelativePath(); - else $relativepath=$section_dir; - $upload_dir = $conf->ecm->dir_output.'/'.$relativepath; - - if (empty($_FILES['userfile']['tmp_name'])) - { - $error++; - setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("File")), null, 'errors'); - } - - if (! $error) - { - if (dol_mkdir($upload_dir) >= 0) - { - $resupload = dol_move_uploaded_file($_FILES['userfile']['tmp_name'], $upload_dir . "/" . dol_unescapefile($_FILES['userfile']['name']),0, 0, $_FILES['userfile']['error']); - if (is_numeric($resupload) && $resupload > 0) - { - $result=$ecmdir->changeNbOfFiles('+'); - } - else - { - $langs->load("errors"); - if ($resupload < 0) // Unknown error - { - setEventMessages($langs->trans("ErrorFileNotUploaded"), null, 'errors'); - } - else if (preg_match('/ErrorFileIsInfectedWithAVirus/',$resupload)) // Files infected by a virus - { - setEventMessages($langs->trans("ErrorFileIsInfectedWithAVirus"), null, 'errors'); - } - else // Known error - { - setEventMessages($langs->trans($resupload), null, 'errors'); - } - } - } - else - { - $langs->load("errors"); - setEventMessages($langs->trans("ErrorFailToCreateDir",$upload_dir), null, 'errors'); - } - } -} @@ -161,7 +111,6 @@ if ($action == 'add' && $user->rights->ecm->setup) } else { - //TODO: Translate setEventMessages('Error '.$langs->trans($ecmdir->error), null, 'errors'); $action = "create"; } @@ -210,6 +159,8 @@ if ($action == 'confirm_deletesection' && GETPOST('confirm') == 'yes') } // Refresh directory view +// This refresh list of dirs, not list of files (for preformance reason). List of files is refresh only if dir was not synchronized. +// To refresh content of dir with cache, just open the dir in edit mode. if ($action == 'refreshmanual') { $ecmdirtmp = new EcmDirectory($db); @@ -355,8 +306,9 @@ if ($action == 'refreshmanual') //print $_SESSION["dol_screenheight"]; $maxheightwin=(isset($_SESSION["dol_screenheight"]) && $_SESSION["dol_screenheight"] > 466)?($_SESSION["dol_screenheight"]-136):660; // Also into index.php file -$morejs=array(); -if (empty($conf->global->MAIN_ECM_DISABLE_JS)) $morejs=array("/includes/jquery/plugins/jqueryFileTree/jqueryFileTree.js"); +//$morejs=array(); +$morejs=array('includes/jquery/plugins/blockUI/jquery.blockUI.js','core/js/blockUI.js'); // Used by ecm/tpl/enabledfiletreeajax.tpl.pgp +if (empty($conf->global->MAIN_ECM_DISABLE_JS)) $morejs[]="/includes/jquery/plugins/jqueryFileTree/jqueryFileTree.js"; llxHeader($moreheadcss.$moreheadjs,$langs->trans("ECMArea"),'','','','',$morejs,'',0,0); @@ -402,8 +354,10 @@ if ($action == 'delete' && empty($conf->use_javascript_ajax)) $classviewhide='inline-block'; + + $head = ecm_prepare_dasboard_head(''); -dol_fiche_head($head, 'index_auto', $langs->trans("ECMArea").' - '.$langs->trans("ECMFileManager"), 1, ''); +dol_fiche_head($head, 'index_auto', $langs->trans("ECMArea").' - '.$langs->trans("ECMFileManager"), -1, ''); // Start container of all panels @@ -414,11 +368,11 @@ dol_fiche_head($head, 'index_auto', $langs->trans("ECMArea").' - '.$langs->trans '; +print '
    '; // Toolbar $url=((! empty($conf->use_javascript_ajax) && empty($conf->global->MAIN_ECM_DISABLE_JS))?'#':($_SERVER["PHP_SELF"].'?action=refreshmanual'.($module?'&module='.$module:'').($section?'&section='.$section:''))); -print ''; +print ''; print ''; print ''; @@ -504,7 +458,7 @@ if (empty($action) || $action == 'file_manager' || preg_match('/refresh/i',$acti } -// End left banner +// End left panel ?>
    @@ -530,7 +484,7 @@ include_once DOL_DOCUMENT_ROOT.'/core/ajax/ajaxdirpreview.php'; // End of page -dol_fiche_end(1); +dol_fiche_end(); if (! empty($conf->use_javascript_ajax) && empty($conf->global->MAIN_ECM_DISABLE_JS)) { diff --git a/htdocs/ecm/tpl/enablefiletreeajax.tpl.php b/htdocs/ecm/tpl/enablefiletreeajax.tpl.php index bbcbb7090a4..aadf3fdba22 100644 --- a/htdocs/ecm/tpl/enablefiletreeajax.tpl.php +++ b/htdocs/ecm/tpl/enablefiletreeajax.tpl.php @@ -24,6 +24,10 @@ '."\n"; print ''."\n"; } - // jQuery blockUI - if (! empty($conf->global->MAIN_USE_JQUERY_BLOCKUI) || defined('REQUIRE_JQUERY_BLOCKUI')) - { - print ''."\n"; - print ''."\n"; - print ''."\n"; - } // Flot if (empty($conf->global->MAIN_DISABLE_JQUERY_FLOT) && ! defined('DISABLE_JQUERY_FLOT')) { @@ -1311,7 +1302,7 @@ function top_htmlhead($head, $title='', $disablejs=0, $disablehead=0, $arrayofjs if (! defined('DISABLE_BROWSER_NOTIF')) { $enablebrowsernotif=false; - if (! empty($conf->agenda->enabled) && ! empty($conf->global->AGENDA_NOTIFICATION)) $enablebrowsernotif=true; + if (! empty($conf->agenda->enabled) && ! empty($conf->global->AGENDA_REMINDER_BROWSER)) $enablebrowsernotif=true; if ($conf->browser->layout == 'phone') $enablebrowsernotif=false; if ($enablebrowsernotif) { @@ -1327,7 +1318,7 @@ function top_htmlhead($head, $title='', $disablejs=0, $disablehead=0, $arrayofjs // Add datepicker default options if (! defined('DISABLE_DATE_PICKER')) { - print ''."\n"; + print ''."\n"; } // JS forced by modules (relative url starting with /) diff --git a/htdocs/modulebuilder/index.php b/htdocs/modulebuilder/index.php index 0ba9bbaa071..91bf15787ee 100644 --- a/htdocs/modulebuilder/index.php +++ b/htdocs/modulebuilder/index.php @@ -146,7 +146,10 @@ if ($dirins && $action == 'initmodule' && $modulename) 'MyModule'=>$modulename, 'MYMODULE'=>strtoupper($modulename), 'My module'=>$modulename, - 'htdocs/modulebuilder/template/'=>strtolower($modulename), + 'my module'=>$modulename, + 'Mon module'=>$modulename, + 'mon module'=>$modulename, + 'htdocs/modulebuilder/template'=>strtolower($modulename), '---Put here your own copyright and developer email---'=>dol_print_date($now,'%Y').' '.$user->getFullName($langs).($user->email?' <'.$user->email.'>':'') ); @@ -293,7 +296,10 @@ if ($dirins && $action == 'initobject' && $module && $objectname) 'MyModule'=>$module, 'MYMODULE'=>strtoupper($module), 'My module'=>$module, - 'htdocs/modulebuilder/template/'=>strtolower($modulename), + 'my module'=>$module, + 'mon module'=>$module, + 'Mon module'=>$module, + 'htdocs/modulebuilder/template/'=>strtolower($modulename), 'myobject'=>strtolower($objectname), 'MyObject'=>$objectname ); @@ -405,7 +411,7 @@ if ($dirins && $action == 'confirm_deleteobject' && $objectname) $filetogenerate = array( 'myobject_card.php'=>strtolower($objectname).'_card.php', 'myobject_note.php'=>strtolower($objectname).'_note.php', - 'myobject_document.php'=>strtolower($objectname).'_note.php', + 'myobject_document.php'=>strtolower($objectname).'_document.php', 'myobject_agenda.php'=>strtolower($objectname).'_agenda.php', 'myobject_list.php'=>strtolower($objectname).'_list.php', 'lib/myobject.lib.php'=>'lib/'.strtolower($objectname).'.lib.php', @@ -502,11 +508,11 @@ if ($dirins && $action == 'generatepackage') $FILENAMEZIP="module_".$modulelowercase.'-'.$arrayversion[0].'.'.$arrayversion[1].($arrayversion[2]?".".$arrayversion[2]:"").".zip"; $dirofmodule = dol_buildpath($modulelowercase, 0).'/bin'; - $outputfile = $dirofmodule.'/'.$FILENAMEZIP; + $outputfilezip = $dirofmodule.'/'.$FILENAMEZIP; if ($dirofmodule) { if (! dol_is_dir($dirofmodule)) dol_mkdir($dirofmodule); - $result = dol_compress_dir($dir, $outputfile, 'zip'); + $result = dol_compress_dir($dir, $outputfilezip, 'zip'); } else { @@ -515,13 +521,13 @@ if ($dirins && $action == 'generatepackage') if ($result > 0) { - setEventMessages($langs->trans("ZipFileGeneratedInto", $outputfile), null); + setEventMessages($langs->trans("ZipFileGeneratedInto", $outputfilezip), null); } else { $error++; $langs->load("errors"); - setEventMessages($langs->trans("ErrorFailToGenerateFile", $outputfile), null, 'errors'); + setEventMessages($langs->trans("ErrorFailToGenerateFile", $outputfilezip), null, 'errors'); } } else @@ -570,7 +576,7 @@ if ($dirins && $action == 'generatedoc') $FILENAMEDOC=$modulelowercase.'.html'; $dirofmodule = dol_buildpath($modulelowercase, 0).'/doc'; - $outputfile = $dirofmodule.'/'.$FILENAMEDOC; + $outputfiledoc = $dirofmodule.'/'.$FILENAMEDOC; if ($dirofmodule) { if (! dol_is_dir($dirofmodule)) dol_mkdir($dirofmodule); @@ -585,13 +591,13 @@ if ($dirins && $action == 'generatedoc') if ($result > 0) { - setEventMessages($langs->trans("DocFileGeneratedInto", $outputfile), null); + setEventMessages($langs->trans("DocFileGeneratedInto", $outputfiledoc), null); } else { $error++; $langs->load("errors"); - setEventMessages($langs->trans("ErrorFailToGenerateFile", $outputfile), null, 'errors'); + setEventMessages($langs->trans("ErrorFailToGenerateFile", $outputfiledoc), null, 'errors'); } } else @@ -908,6 +914,11 @@ elseif (! empty($module)) $head2[$h][2] = 'specifications'; $h++; + $head2[$h][0] = $_SERVER["PHP_SELF"].'?tab=languages&module='.$module.($forceddirread?'@'.$dirread:''); + $head2[$h][1] = $langs->trans("Languages"); + $head2[$h][2] = 'languages'; + $h++; + $head2[$h][0] = $_SERVER["PHP_SELF"].'?tab=objects&module='.$module.($forceddirread?'@'.$dirread:''); $head2[$h][1] = $langs->trans("Objects"); $head2[$h][2] = 'objects'; @@ -1151,6 +1162,51 @@ elseif (! empty($module)) } } + if ($tab == 'languages') + { + if ($action != 'editfile' || empty($file)) + { + $langfiles=dol_dir_list(dol_buildpath($modulelowercase.'/langs', 0), 'files', 1, '\.lang$'); + + foreach ($langfiles as $langfile) + { + $pathtofile = $modulelowercase.'/langs/'.$langfile['relativename']; + print ' '.$langs->trans("LanguageFile").' '.basename(dirname($pathtofile)).' : '.$pathtofile.''; + print ' '.img_picto($langs->trans("Edit"), 'edit').''; + print '
    '; + } + } + else + { + // Edit text language file + + //print $langs->trans("UseAsciiDocFormat").'
    '; + + $fullpathoffile=dol_buildpath($file, 0); + + $content = file_get_contents($fullpathoffile); + + // New module + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + + $doleditor=new DolEditor('editfilecontent', $content, '', '300', 'Full', 'In', true, false, 'ace', 0, '99%'); + print $doleditor->Create(1, '', false, $langs->trans("File").' : '.$file, (GETPOST('format','aZ09')?GETPOST('format','aZ09'):'text')); + print '
    '; + print '
    '; + print ''; + print '   '; + print ''; + print '
    '; + + print ''; + } + } + if ($tab == 'objects') { $head3 = array(); @@ -1171,6 +1227,7 @@ elseif (! empty($module)) foreach($listofobject as $fileobj) { if (preg_match('/^api_/',$fileobj['name'])) continue; + if (preg_match('/^actions_/',$fileobj['name'])) continue; $tmpcontent=file_get_contents($fileobj['fullname']); if (preg_match('/class\s+([^\s]*)\s+extends\s+CommonObject/ims',$tmpcontent,$reg)) @@ -1180,7 +1237,7 @@ elseif (! empty($module)) if (empty($firstobjectname)) $firstobjectname = $objectname; } - $head3[$h][0] = $_SERVER["PHP_SELF"].'?tab=objects&module='.$module.($forceddirread?'@'.$dirread:'').'&tabobj='.$objectname; + $head3[$h][0] = $_SERVER["PHP_SELF"].'?tab=objects&module='.$module.($forceddirread?'@'.$dirread:'').'&tabobj='.$objectname; $head3[$h][1] = $objectname; $head3[$h][2] = $objectname; $h++; @@ -1246,14 +1303,17 @@ elseif (! empty($module)) if ($action != 'editfile' || empty($file)) { try { - $pathtoclass = strtolower($module).'/class/'.strtolower($tabobj).'.class.php'; - $pathtoapi = strtolower($module).'/class/api_'.strtolower($tabobj).'.class.php'; - $pathtolist = strtolower($module).'/'.strtolower($tabobj).'_list.php'; - $pathtocard = strtolower($module).'/'.strtolower($tabobj).'_card.php'; - $pathtophpunit = strtolower($module).'/test/phpunit/'.$tabobj.'Test.php'; - $pathtosql = strtolower($module).'/sql/llx_'.strtolower($tabobj).'.sql'; + $pathtoclass = strtolower($module).'/class/'.strtolower($tabobj).'.class.php'; + $pathtoapi = strtolower($module).'/class/api_'.strtolower($tabobj).'.class.php'; + $pathtoagenda = strtolower($module).'/'.strtolower($tabobj).'_agenda.php'; + $pathtocard = strtolower($module).'/'.strtolower($tabobj).'_card.php'; + $pathtodocument = strtolower($module).'/'.strtolower($tabobj).'_document.php'; + $pathtolist = strtolower($module).'/'.strtolower($tabobj).'_list.php'; + $pathtonote = strtolower($module).'/'.strtolower($tabobj).'_note.php'; + $pathtophpunit = strtolower($module).'/test/phpunit/'.$tabobj.'Test.php'; + $pathtosql = strtolower($module).'/sql/llx_'.strtolower($tabobj).'.sql'; $pathtosqlextra = strtolower($module).'/sql/llx_'.strtolower($tabobj).'_extrafields.sql'; - $pathtosqlkey = strtolower($module).'/sql/llx_'.strtolower($tabobj).'.key.sql'; + $pathtosqlkey = strtolower($module).'/sql/llx_'.strtolower($tabobj).'.key.sql'; print '
    '; print ' '.$langs->trans("ClassFile").' : '.$pathtoclass.''; print ' '.img_picto($langs->trans("Edit"), 'edit').''; @@ -1279,6 +1339,15 @@ elseif (! empty($module)) print '
    '; print ' '.$langs->trans("PageForCreateEditView").' : '.$pathtocard.''; print ' '.img_picto($langs->trans("Edit"), 'edit').''; + print '
    '; + print ' '.$langs->trans("PageForAgendaTab").' : '.$pathtoagenda.''; + print ' '.img_picto($langs->trans("Edit"), 'edit').''; + print '
    '; + print ' '.$langs->trans("PageForDocumentTab").' : '.$pathtodocument.''; + print ' '.img_picto($langs->trans("Edit"), 'edit').''; + print '
    '; + print ' '.$langs->trans("PageForNoteTab").' : '.$pathtonote.''; + print ' '.img_picto($langs->trans("Edit"), 'edit').''; print '
    '; print '


    '; @@ -1522,14 +1591,21 @@ elseif (! empty($module)) if ($action != 'editfile' || empty($file)) { - foreach ($triggers as $trigger) - { - $pathtofile = $trigger['relpath']; + if (! empty($triggers)) + { + foreach ($triggers as $trigger) + { + $pathtofile = $trigger['relpath']; - print ' '.$langs->trans("TriggersFile").' : '.$pathtofile.''; - print ' '.img_picto($langs->trans("Edit"), 'edit').''; - print '
    '; - } + print ' '.$langs->trans("TriggersFile").' : '.$pathtofile.''; + print ' '.img_picto($langs->trans("Edit"), 'edit').''; + print '
    '; + } + } + else + { + print $langs->trans("NoTrigger"); + } } else { @@ -1566,13 +1642,20 @@ elseif (! empty($module)) if ($action != 'editfile' || empty($file)) { - foreach ($widgets as $widget) - { - $pathtofile = $widget['relpath']; + if (! empty($widget)) + { + foreach ($widgets as $widget) + { + $pathtofile = $widget['relpath']; - print ' '.$langs->trans("WidgetFile").' : '.$pathtofile.''; - print ' '.img_picto($langs->trans("Edit"), 'edit').''; - print '
    '; + print ' '.$langs->trans("WidgetFile").' : '.$pathtofile.''; + print ' '.img_picto($langs->trans("Edit"), 'edit').''; + print '
    '; + } + } + else + { + print $langs->trans("NoWidget"); } } else @@ -1638,51 +1721,58 @@ elseif (! empty($module)) print_liste_field_titre("Comment",$_SERVER["PHP_SELF"],"","",$param,'',$sortfield,$sortorder); print "\n"; - foreach ($cronjobs as $cron) + if (count($cronjobs)) { - print '
    '; + foreach ($cronjobs as $cron) + { + print ''; - print ''; + print ''; - print ''; + print ''; - print ''; + print ''; - print ''; + print ''; - print ''; + print ''; - print ''; + print ''; + } + } + else + { + print ''; } print '
    trans("Position"); ?>
    trans("Position"); ?>
    trans("LanguageFile"); ?>
    textwithpicto($langs->trans("ComputedFormula"), $langs->trans("ComputedFormulaDesc"), 1, 'help', '', 0, 2, 'tooltipcompute'); ?>
    '; - print $cron['label']; - print ''; + print $cron['label']; + print ''; - if ($cron['jobtype']=='method') - { - $text=$langs->trans("CronClass"); - $texttoshow=$langs->trans('CronModule').': '.$module.'
    '; - $texttoshow.=$langs->trans('CronClass').': '. $cron['class'].'
    '; - $texttoshow.=$langs->trans('CronObject').': '. $cron['objectname'].'
    '; - $texttoshow.=$langs->trans('CronMethod').': '. $cron['method']; - $texttoshow.='
    '.$langs->trans('CronArgs').': '. $cron['parameters']; - $texttoshow.='
    '.$langs->trans('Comment').': '. $langs->trans($cron['comment']); - } - elseif ($cron['jobtype']=='command') - { - $text=$langs->trans('CronCommand'); - $texttoshow=$langs->trans('CronCommand').': '.dol_trunc($cron['command']); - $texttoshow.='
    '.$langs->trans('CronArgs').': '. $cron['parameters']; - $texttoshow.='
    '.$langs->trans('Comment').': '. $langs->trans($cron['comment']); - } - print $form->textwithpicto($text, $texttoshow, 1); - print '
    '; + if ($cron['jobtype']=='method') + { + $text=$langs->trans("CronClass"); + $texttoshow=$langs->trans('CronModule').': '.$module.'
    '; + $texttoshow.=$langs->trans('CronClass').': '. $cron['class'].'
    '; + $texttoshow.=$langs->trans('CronObject').': '. $cron['objectname'].'
    '; + $texttoshow.=$langs->trans('CronMethod').': '. $cron['method']; + $texttoshow.='
    '.$langs->trans('CronArgs').': '. $cron['parameters']; + $texttoshow.='
    '.$langs->trans('Comment').': '. $langs->trans($cron['comment']); + } + elseif ($cron['jobtype']=='command') + { + $text=$langs->trans('CronCommand'); + $texttoshow=$langs->trans('CronCommand').': '.dol_trunc($cron['command']); + $texttoshow.='
    '.$langs->trans('CronArgs').': '. $cron['parameters']; + $texttoshow.='
    '.$langs->trans('Comment').': '. $langs->trans($cron['comment']); + } + print $form->textwithpicto($text, $texttoshow, 1); + print '
    '; - if($cron['unitfrequency'] == "60") print $langs->trans('CronEach')." ".($cron['frequency'])." ".$langs->trans('Minutes'); - if($cron['unitfrequency'] == "3600") print $langs->trans('CronEach')." ".($cron['frequency'])." ".$langs->trans('Hours'); - if($cron['unitfrequency'] == "86400") print $langs->trans('CronEach')." ".($cron['frequency'])." ".$langs->trans('Days'); - if($cron['unitfrequency'] == "604800") print $langs->trans('CronEach')." ".($cron['frequency'])." ".$langs->trans('Weeks'); - print ''; + if($cron['unitfrequency'] == "60") print $langs->trans('CronEach')." ".($cron['frequency'])." ".$langs->trans('Minutes'); + if($cron['unitfrequency'] == "3600") print $langs->trans('CronEach')." ".($cron['frequency'])." ".$langs->trans('Hours'); + if($cron['unitfrequency'] == "86400") print $langs->trans('CronEach')." ".($cron['frequency'])." ".$langs->trans('Days'); + if($cron['unitfrequency'] == "604800") print $langs->trans('CronEach')." ".($cron['frequency'])." ".$langs->trans('Weeks'); + print ''; - print $cron['status']; - print ''; + print $cron['status']; + print ''; - if (!empty($cron['comment'])) {print $cron['comment'];} - print ''; + if (!empty($cron['comment'])) {print $cron['comment'];} + print '
    '.$langs->trans("None").'
    '; @@ -1755,7 +1845,7 @@ elseif (! empty($module)) if (count($arrayversion)) { $FILENAMEZIP="module_".$modulelowercase.'-'.$arrayversion[0].'.'.$arrayversion[1].($arrayversion[2]?".".$arrayversion[2]:"").".zip"; - $outputfile = dol_buildpath($modulelowercase, 0).'/bin/'.$FILENAMEZIP; + $outputfilezip = dol_buildpath($modulelowercase, 0).'/bin/'.$FILENAMEZIP; $FILENAMEDOC=$modulelowercase.'.html'; $outputfiledoc = dol_buildpath($modulelowercase, 0).'/doc/'.$FILENAMEDOC; @@ -1764,10 +1854,11 @@ elseif (! empty($module)) print '
    '; print ' '. $langs->trans("PathToModulePackage") . ' : '; - if (! dol_is_file($outputfile)) print ''.$langs->trans("FileNotYetGenerated").''; + if (! dol_is_file($outputfilezip)) print ''.$langs->trans("FileNotYetGenerated").''; else { - print ''.$outputfile.''; - print ' ('.$langs->trans("GeneratedOn").' '.dol_print_date(dol_filemtime($outputfile), 'dayhour').')'; + $relativepath = $modulelowercase.'/bin/'.$FILENAMEZIP; + print ''.$outputfilezip.''; + print ' ('.$langs->trans("GeneratedOn").' '.dol_print_date(dol_filemtime($outputfilezip), 'dayhour').')'; } print '
    '; diff --git a/htdocs/modulebuilder/template/admin/about.php b/htdocs/modulebuilder/template/admin/about.php index ac21d2810e0..d492f72da79 100644 --- a/htdocs/modulebuilder/template/admin/about.php +++ b/htdocs/modulebuilder/template/admin/about.php @@ -81,16 +81,11 @@ $head = mymoduleAdminPrepareHead(); dol_fiche_head( $head, 'about', - $langs->trans("MyModuleName"), + $langs->trans("ModuleMyModuleName"), 0, 'mymodule@mymodule' ); -// About page goes here -echo $langs->trans("MyModuleAboutPage"); - -echo '
    '; - dol_include_once('/mymodule/core/modules/modMyModule.class.php'); $tmpmodule = new modMyModule($db); print $tmpmodule->getDescLong(); diff --git a/htdocs/modulebuilder/template/admin/setup.php b/htdocs/modulebuilder/template/admin/setup.php index d32bd0a1723..46b608efa8e 100644 --- a/htdocs/modulebuilder/template/admin/setup.php +++ b/htdocs/modulebuilder/template/admin/setup.php @@ -42,8 +42,9 @@ global $langs, $user; require_once DOL_DOCUMENT_ROOT . "/core/lib/admin.lib.php"; require_once '../lib/mymodule.lib.php'; //require_once "../class/myclass.class.php"; + // Translations -$langs->load("mymodule@mymodule"); +$langs->loadLangs(array("admin", "mymodule@mymodule")); // Access control if (! $user->admin) accessforbidden(); @@ -51,6 +52,8 @@ if (! $user->admin) accessforbidden(); // Parameters $action = GETPOST('action', 'alpha'); +$arrayofparameters=array('MYMODULE_MYPARAM1'=>'1', 'MYMODULE_MYPARAM2'=>'2'); + /* * Actions @@ -76,14 +79,62 @@ $head = mymoduleAdminPrepareHead(); dol_fiche_head( $head, 'settings', - $langs->trans("Module500000Name"), - 0, + $langs->trans("ModuleMyModuleName"), + -1, "mymodule@mymodule" ); // Setup page goes here echo $langs->trans("MyModuleSetupPage"); + +if ($action == 'edit') +{ + print '
    '; + print ''; + print ''; + + print ''; + print ''; + + foreach($arrayofparameters as $key => $val) + { + print ''; + } + + print '
    '.$langs->trans("Parameter").''.$langs->trans("Value").'
    '; + print $form->textwithpicto($langs->trans($key),$langs->trans($key.'Tooltip')); + print '
    '; + + print '
    '; + print ''; + print '
    '; + + print '
    '; + print '
    '; +} +else +{ + print ''; + print ''; + + foreach($arrayofparameters as $key => $val) + { + print ''; + } + + print '
    '.$langs->trans("Parameter").''.$langs->trans("Value").'
    '; + print $form->textwithpicto($langs->trans($key),$langs->trans($key.'Tooltip')); + print '' . $conf->global->$key . '
    '; + + print '
    '; + print ''.$langs->trans("Modify").''; + print '
    '; +} + + // Page end dol_fiche_end(); + llxFooter(); +$db->close(); diff --git a/htdocs/modulebuilder/template/class/actions_mymodule.class.php b/htdocs/modulebuilder/template/class/actions_mymodule.class.php index b8b43f1359d..7b353113c00 100644 --- a/htdocs/modulebuilder/template/class/actions_mymodule.class.php +++ b/htdocs/modulebuilder/template/class/actions_mymodule.class.php @@ -78,13 +78,9 @@ class ActionsMyModule $error = 0; // Error counter - /* - print_r($parameters); - print_r($object); - echo "action: " . $action; - */ - - if (in_array($parameters['currentcontext'], array('somecontext1','somecontext2'))) { // do something only for the context 'somecontext1' or 'somecontext2' + /* print_r($parameters); print_r($object); echo "action: " . $action; */ + if (in_array($parameters['currentcontext'], array('somecontext1','somecontext2'))) // do something only for the context 'somecontext1' or 'somecontext2' + { } @@ -115,14 +111,9 @@ class ActionsMyModule $error = 0; // Error counter - /* - print_r($parameters); - print_r($object); - echo "action: " . $action; - */ - - if (in_array($parameters['currentcontext'], array('somecontext1','somecontext2'))) { // do something only for the context 'somecontext1' or 'somecontext2' - + /* print_r($parameters); print_r($object); echo "action: " . $action; */ + if (in_array($parameters['currentcontext'], array('somecontext1','somecontext2'))) // do something only for the context 'somecontext1' or 'somecontext2' + { foreach($parameters['toselect'] as $objectid) { // Do action on each object id @@ -156,7 +147,8 @@ class ActionsMyModule $error = 0; // Error counter - if (in_array($parameters['currentcontext'], array('somecontext1','somecontext2'))) // do something only for the context 'somecontext' + /* print_r($parameters); print_r($object); echo "action: " . $action; */ + if (in_array($parameters['currentcontext'], array('somecontext1','somecontext2'))) // do something only for the context 'somecontext1' or 'somecontext2' { $this->resprints = ''; } @@ -171,4 +163,64 @@ class ActionsMyModule + /** + * Execute action + * + * @param array $parameters Array of parameters + * @param Object $object Object output on PDF + * @param string $action 'add', 'update', 'view' + * @return int <0 if KO, + * =0 if OK but we want to process standard actions too, + * >0 if OK and we want to replace standard actions. + */ + function beforePDFCreation($parameters, &$object, &$action) + { + global $langs,$conf; + global $hookmanager; + + $outputlangs=$langs; + + $ret=0; $deltemp=array(); + dol_syslog(get_class($this).'::executeHooks action='.$action); + + /* print_r($parameters); print_r($object); echo "action: " . $action; */ + if (in_array($parameters['currentcontext'], array('somecontext1','somecontext2'))) // do something only for the context 'somecontext1' or 'somecontext2' + { + + } + + return $ret; + } + + /** + * Execute action + * + * @param array $parameters Array of parameters + * @param Object $pdfhandler PDF builder handler + * @param string $action 'add', 'update', 'view' + * @return int <0 if KO, + * =0 if OK but we want to process standard actions too, + * >0 if OK and we want to replace standard actions. + */ + function afterPDFCreation($parameters, &$pdfhandler, &$action) + { + global $langs,$conf; + global $hookmanager; + + $outputlangs=$langs; + + $ret=0; $deltemp=array(); + dol_syslog(get_class($this).'::executeHooks action='.$action); + + /* print_r($parameters); print_r($object); echo "action: " . $action; */ + if (in_array($parameters['currentcontext'], array('somecontext1','somecontext2'))) // do something only for the context 'somecontext1' or 'somecontext2' + { + + } + + return $ret; + } + + /* Add here any other hooked methods... */ + } diff --git a/htdocs/modulebuilder/template/class/myobject.class.php b/htdocs/modulebuilder/template/class/myobject.class.php index 49aa42ad96d..d8c35c64a81 100644 --- a/htdocs/modulebuilder/template/class/myobject.class.php +++ b/htdocs/modulebuilder/template/class/myobject.class.php @@ -59,11 +59,15 @@ class MyObject extends CommonObject /** - * 'type' if the field format, 'label' the translation key, 'enabled' is a condition when the filed must be managed, - * 'visible' says if field is visible in list (-1 means not shown by default but can be aded into list to be viewed) - * 'notnull' if not null in database, 'index' if we want an index in database - * 'position' is the sort order of field - * 'searchall' is 1 if we want to search in this field when making a search from the quick search button + * 'type' if the field format. + * 'label' the translation key. + * 'enabled' is a condition when the filed must be managed. + * 'visible' says if field is visible in list (-1 means not shown by default but can be aded into list to be viewed). + * 'notnull' is set to 1 if not null in database. Set to -1 if we must set data to null if empty ('' or 0). + * 'index' if we want an index in database. + * 'foreignkey'=>'tablename.field' if the field is a foreign key (it is recommanded to name the field fk_...). + * 'position' is the sort order of field. + * 'searchall' is 1 if we want to search in this field when making a search from the quick search button. * 'isameasure' must be set to 1 if you want to have a total on list for this field. Field type must be summable like integer or double(24,8). * 'comment' is not used. You can store here any text of your choice. */ @@ -73,19 +77,19 @@ class MyObject extends CommonObject * @var array Array with all fields and their property. Do not use it as a static var. It may be modified by constructor. */ public $fields=array( - 'rowid' =>array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>1, 'visible'=>-1, 'notnull'=>true, 'index'=>true, 'position'=>1, 'comment'=>'Id'), - 'ref' =>array('type'=>'varchar(64)', 'label'=>'Ref', 'enabled'=>1, 'visible'=>1, 'notnull'=>true, 'index'=>true, 'position'=>10, 'searchall'=>1, 'comment'=>'Reference of object'), - 'entity' =>array('type'=>'integer', 'label'=>'Entity', 'enabled'=>1, 'visible'=>0, 'notnull'=>true, 'index'=>true, 'position'=>20), + 'rowid' =>array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'index'=>1, 'position'=>1, 'comment'=>'Id'), + 'ref' =>array('type'=>'varchar(64)', 'label'=>'Ref', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'index'=>1, 'position'=>10, 'searchall'=>1, 'comment'=>'Reference of object'), + 'entity' =>array('type'=>'integer', 'label'=>'Entity', 'enabled'=>1, 'visible'=>0, 'notnull'=>1, 'index'=>1, 'position'=>20), 'label' =>array('type'=>'varchar(255)', 'label'=>'Label', 'enabled'=>1, 'visible'=>1, 'position'=>30, 'searchall'=>1), 'amount' =>array('type'=>'double(24,8)', 'label'=>'Amount', 'enabled'=>1, 'visible'=>1, 'position'=>40, 'searchall'=>0, 'isameasure'=>1), - 'status' =>array('type'=>'integer', 'label'=>'Status', 'enabled'=>1, 'visible'=>1, 'index'=>true, 'position'=>1000), - 'date_creation' =>array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>1, 'visible'=>-1, 'notnull'=>true, 'position'=>500), - 'tms' =>array('type'=>'timestamp', 'label'=>'DateModification', 'enabled'=>1, 'visible'=>-1, 'notnull'=>true, 'position'=>500), + 'status' =>array('type'=>'integer', 'label'=>'Status', 'enabled'=>1, 'visible'=>1, 'index'=>1, 'position'=>1000), + 'date_creation' =>array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>500), + 'tms' =>array('type'=>'timestamp', 'label'=>'DateModification', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>500), //'date_valid' =>array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>1, 'visible'=>-1, 'position'=>500), - 'fk_user_creat' =>array('type'=>'integer', 'label'=>'UserAuthor', 'enabled'=>1, 'visible'=>-1, 'notnull'=>true, 'position'=>500), - 'fk_user_modif' =>array('type'=>'integer', 'label'=>'UserModif', 'enabled'=>1, 'visible'=>-1, 'position'=>500), + 'fk_user_creat' =>array('type'=>'integer', 'label'=>'UserAuthor', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>500), + 'fk_user_modif' =>array('type'=>'integer', 'label'=>'UserModif', 'enabled'=>1, 'visible'=>-1, 'notnull'=>-1, 'position'=>500), //'fk_user_valid' =>array('type'=>'integer', 'label'=>'UserValid', 'enabled'=>1, 'visible'=>-1, 'position'=>500), - 'import_key' =>array('type'=>'varchar(14)', 'label'=>'ImportId', 'enabled'=>1, 'visible'=>-1, 'index'=>true, 'position'=>1000, 'nullifempty'=>1), + 'import_key' =>array('type'=>'varchar(14)', 'label'=>'ImportId', 'enabled'=>1, 'visible'=>-1, 'notnull'=>-1, 'index'=>1, 'position'=>1000), ); // END MODULEBUILDER PROPERTIES @@ -145,9 +149,9 @@ class MyObject extends CommonObject /** * Clone and object into another one * - * @param User $user User that creates - * @param int $fromid Id of object to clone - * @return int New id of clone + * @param User $user User that creates + * @param int $fromid Id of object to clone + * @return mixed New object created, <0 if KO */ public function createFromClone(User $user, $fromid) { @@ -184,7 +188,7 @@ class MyObject extends CommonObject // End if (!$error) { $this->db->commit(); - return $object->id; + return $object; } else { $this->db->rollback(); return -1; diff --git a/htdocs/modulebuilder/template/core/boxes/README.md b/htdocs/modulebuilder/template/core/boxes/README.md new file mode 100644 index 00000000000..b641e7136bc --- /dev/null +++ b/htdocs/modulebuilder/template/core/boxes/README.md @@ -0,0 +1 @@ +Directory where widgets files are stored. \ No newline at end of file diff --git a/htdocs/modulebuilder/template/core/modules/mailings/mailinglist_mymodule_myobject.modules.php b/htdocs/modulebuilder/template/core/modules/mailings/mailinglist_mymodule_myobject.modules.php new file mode 100644 index 00000000000..b3f2a36efab --- /dev/null +++ b/htdocs/modulebuilder/template/core/modules/mailings/mailinglist_mymodule_myobject.modules.php @@ -0,0 +1,201 @@ + + * + * This file is an example to follow to add your own email selector inside + * the Dolibarr email tool. + * Follow instructions given in README file to know what to change to build + * your own emailing list selector. + * Code that need to be changed in this file are marked by "CHANGE THIS" tag. + */ + +include_once DOL_DOCUMENT_ROOT.'/core/modules/mailings/modules_mailings.php'; +dol_include_once("/mymodule/class/myobject.class.php"); + + +/** + * mailing_mailinglist_mymodule + */ +class mailing_mailinglist_mymodule_myobject extends MailingTargets +{ + // CHANGE THIS: Put here a name not already used + var $name='mailinglist_mymodule_myobject'; + // CHANGE THIS: Put here a description of your selector module + var $desc='My object emailing target selector'; + // CHANGE THIS: Set to 1 if selector is available for admin users only + var $require_admin=0; + + var $enabled=0; + var $require_module=array(); + var $picto='mymodule@mymodule'; + var $db; + + + /** + * Constructor + * + * @param DoliDB $db Database handler + */ + function __construct($db) + { + global $conf; + + $this->db=$db; + if (is_array($conf->modules)) + { + $this->enabled=in_array('mymodule',$conf->modules); + } + } + + + /** + * Affiche formulaire de filtre qui apparait dans page de selection des destinataires de mailings + * + * @return string Retourne zone select + */ + function formFilter() + { + global $langs; + $langs->load("members"); + + $form=new Form($this->db); + + $arraystatus=array(1=>'Option 1', 2=>'Option 2'); + + $s=''; + $s.=$langs->trans("Status").': '; + $s.=''; + $s.='
    '; + + return $s; + } + + + /** + * Renvoie url lien vers fiche de la source du destinataire du mailing + * + * @param int $id ID + * @return string Url lien + */ + function url($id) + { + return ''.img_object('',"generic").''; + } + + + /** + * This is the main function that returns the array of emails + * + * @param int $mailing_id Id of emailing + * @param array $filtersarray Requete sql de selection des destinataires + * @return int <0 if error, number of emails added if ok + */ + function add_to_target($mailing_id,$filtersarray=array()) + { + $target = array(); + $cibles = array(); + $j = 0; + + + $sql = " select rowid as id, email, firstname, lastname, plan, partner"; + $sql.= " from ".MAIN_DB_PREFIX."myobject"; + $sql.= " where email IS NOT NULL AND email != ''"; + if (! empty($_POST['filter']) && $_POST['filter'] != 'none') $sql.= " AND status = '".$this->db->escape($_POST['filter'])."'"; + $sql.= " ORDER BY email"; + + // Stocke destinataires dans cibles + $result=$this->db->query($sql); + if ($result) + { + $num = $this->db->num_rows($result); + $i = 0; + + dol_syslog("mailinglist_mymodule_myobject.modules.php: mailing ".$num." targets found"); + + $old = ''; + while ($i < $num) + { + $obj = $this->db->fetch_object($result); + if ($old <> $obj->email) + { + $cibles[$j] = array( + 'email' => $obj->email, + 'name' => $obj->lastname, + 'id' => $obj->id, + 'firstname' => $obj->firstname, + 'other' => $obj->plan.';'.$obj->partner, + 'source_url' => $this->url($obj->id), + 'source_id' => $obj->id, + 'source_type' => 'dolicloud' + ); + $old = $obj->email; + $j++; + } + + $i++; + } + } + else + { + dol_syslog($this->db->error()); + $this->error=$this->db->error(); + return -1; + } + + // You must fill the $target array with record like this + // $target[0]=array('email'=>'email_0','name'=>'name_0','firstname'=>'firstname_0'); + // ... + // $target[n]=array('email'=>'email_n','name'=>'name_n','firstname'=>'firstname_n'); + + // Example: $target[0]=array('email'=>'myemail@mydomain.com','name'=>'Doe','firstname'=>'John'); + + // ----- Your code end here ----- + + return parent::add_to_target($mailing_id, $cibles); + } + + + /** + * On the main mailing area, there is a box with statistics. + * If you want to add a line in this report you must provide an + * array of SQL request that returns two field: + * One called "label", One called "nb". + * + * @return array + */ + function getSqlArrayForStats() + { + // CHANGE THIS: Optionnal + + //var $statssql=array(); + //$this->statssql[0]="SELECT field1 as label, count(distinct(email)) as nb FROM mytable WHERE email IS NOT NULL"; + + return array(); + } + + + /** + * Return here number of distinct emails returned by your selector. + * For example if this selector is used to extract 500 different + * emails from a text file, this function must return 500. + * + * @param string $filter Filter + * @param string $option Options + * @return int Nb of recipients + */ + function getNbOfRecipients($filter=1,$option='') + { + $a=parent::getNbOfRecipients("select count(distinct(email)) as nb from ".MAIN_DB_PREFIX."myobject as p where email IS NOT NULL AND email != ''"); + + if ($a < 0 || $b < 0) return -1; + if ($option == '') return $a; + return ($a+$b); + } + +} + diff --git a/htdocs/modulebuilder/template/core/modules/modMyModule.class.php b/htdocs/modulebuilder/template/core/modules/modMyModule.class.php index 0806bcce8d9..00199f1d3a4 100644 --- a/htdocs/modulebuilder/template/core/modules/modMyModule.class.php +++ b/htdocs/modulebuilder/template/core/modules/modMyModule.class.php @@ -95,7 +95,7 @@ class modMyModule extends DolibarrModules 'models' => 0, // Set this to 1 if module has its own models directory (core/modules/xxx) 'css' => array('/mymodule/css/mymodule.css.php'), // Set this to relative path of css file if module has its own css file 'js' => array('/mymodule/js/mymodule.js.php'), // Set this to relative path of js file if module must load a js on all pages - 'hooks' => array('hookcontext1','hookcontext2') // Set here all hooks context managed by module. You can also set hook context 'all' + 'hooks' => array('hookcontext1','hookcontext2') // Set here all hooks context managed by module. To find available hook context, make a "grep -r '>initHooks(' *" on source code. You can also set hook context 'all' ); // Data directories to create when module is enabled. @@ -305,15 +305,19 @@ class modMyModule extends DolibarrModules */ public function init($options='') { - $sql = array(); - $this->_load_tables('/mymodule/sql/'); // Create extrafields include_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; $extrafields = new ExtraFields($this->db); - //$result1=$extrafields->addExtraField('myattr1', "New Attr 1 label", 'boolean', 1, 3, 'thirdparty'); - //$result2=$extrafields->addExtraField('myattr2', "New Attr 2 label", 'string', 1, 10, 'project'); + + //$result1=$extrafields->addExtraField('myattr1', "New Attr 1 label", 'boolean', 1, 3, 'thirdparty', 0, 0, '', '', 1, '', 0, 0, '', '', 'mymodule@mymodule'); + //$result2=$extrafields->addExtraField('myattr2', "New Attr 2 label", 'varchar', 1, 10, 'project', 0, 0, '', '', 1, '', 0, 0, '', '', 'mymodule@mymodule'); + //$result3=$extrafields->addExtraField('myattr3', "New Attr 3 label", 'varchar', 1, 10, 'bank_account', 0, 0, '', '', 1, '', 0, 0, '', '', 'mymodule@mymodule'); + //$result4=$extrafields->addExtraField('myattr4', "New Attr 4 label", 'select', 1, 3, 'thirdparty', 0, 1, '', array('options'=>array('code1'=>'Val1','code2'=>'Val2','code3'=>'Val3')), 1); + //$result5=$extrafields->addExtraField('myattr5', "New Attr 5 label", 'text', 1, 10, 'user', 0, 0, '', '', 1, '', 0, 0, '', '', 'mymodule@mymodule'); + + $sql = array(); return $this->_init($sql, $options); } diff --git a/htdocs/modulebuilder/template/core/triggers/README.md b/htdocs/modulebuilder/template/core/triggers/README.md new file mode 100644 index 00000000000..38d1b1d8961 --- /dev/null +++ b/htdocs/modulebuilder/template/core/triggers/README.md @@ -0,0 +1 @@ +Directory where triggers files are stored. \ No newline at end of file diff --git a/htdocs/modulebuilder/template/langs/en_US/mymodule.lang b/htdocs/modulebuilder/template/langs/en_US/mymodule.lang index e09e396dce0..a37d8e0c241 100644 --- a/htdocs/modulebuilder/template/langs/en_US/mymodule.lang +++ b/htdocs/modulebuilder/template/langs/en_US/mymodule.lang @@ -28,6 +28,11 @@ ModuleMyModuleDesc = My module description MyModuleSetup = My module setup Settings = Settings MyModuleSetupPage = My module setup page +MYMODULE_MYPARAM1 = My param 1 +MYMODULE_MYPARAM1Tooltip = My param 1 tooltip +MYMODULE_MYPARAM2=My param 2 +MYMODULE_MYPARAM2Tooltip=My param 2 tooltip + # # About page diff --git a/htdocs/modulebuilder/template/myobject_list.php b/htdocs/modulebuilder/template/myobject_list.php index 81e0612cea5..d599c563912 100644 --- a/htdocs/modulebuilder/template/myobject_list.php +++ b/htdocs/modulebuilder/template/myobject_list.php @@ -228,7 +228,7 @@ foreach ($search_array_options as $key => $val) $typ=$extrafields->attribute_type[$tmpkey]; $mode=0; if (in_array($typ, array('int','double','real'))) $mode=1; // Search on a numeric - if ($val && ( ($crit != '' && ! in_array($typ, array('select'))) || ! empty($crit))) + if ($crit != '' && (! in_array($typ, array('select')) || $crit != '0')) { $sql .= natural_search('ef.'.$tmpkey, $crit, $mode); } diff --git a/htdocs/product/admin/product.php b/htdocs/product/admin/product.php index 172bdd9354c..78829e489a6 100644 --- a/htdocs/product/admin/product.php +++ b/htdocs/product/admin/product.php @@ -46,7 +46,7 @@ if (! $user->admin || (empty($conf->product->enabled) && empty($conf->service->e $action = GETPOST('action','alpha'); $value = GETPOST('value','alpha'); $label = GETPOST('label','alpha'); -$scandir = GETPOST('scandir','alpha'); +$scandir = GETPOST('scan_dir','alpha'); $type='product'; // Pricing Rules @@ -460,7 +460,7 @@ foreach ($dirmodels as $reldir) else { print ''."\n"; - print 'scandir.'&label='.urlencode($module->name).'">'.img_picto($langs->trans("Disabled"),'switch_off').''; + print 'scandir.'&label='.urlencode($module->name).'">'.img_picto($langs->trans("Disabled"),'switch_off').''; print ""; } @@ -472,7 +472,7 @@ foreach ($dirmodels as $reldir) } else { - print 'scandir.'&label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"),'off').''; + print 'scandir.'&label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"),'off').''; } print ''; diff --git a/htdocs/product/card.php b/htdocs/product/card.php index 318d19e10b3..53d553aca16 100644 --- a/htdocs/product/card.php +++ b/htdocs/product/card.php @@ -110,7 +110,7 @@ if (! empty($canvas)) // Security check $fieldvalue = (! empty($id) ? $id : (! empty($ref) ? $ref : '')); -$fieldtype = (! empty($ref) ? 'ref' : 'rowid'); +$fieldtype = (! empty($id) ? 'rowid' : 'ref'); $result=restrictedArea($user,'produit|service',$fieldvalue,'product&product','','',$fieldtype,$objcanvas); // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index 14b60473687..2596e6ac2ea 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -4022,31 +4022,7 @@ class Product extends CommonObject $filearray=array_merge($filearray, $filearrayold); } - $filearrayindatabase = dol_dir_list_in_database($relativedir, '', null, 'name', SORT_ASC); - - //var_dump($filearray); - //var_dump($filearrayindatabase); - - // Complete filearray with properties found into $filearrayindatabase - foreach($filearray as $key => $val) - { - $found=0; - // Search if it exists into $filearrayindatabase - foreach($filearrayindatabase as $key2 => $val2) - { - if ($filearrayindatabase[$key2]['name'] == $filearray[$key]['name']) - { - $filearray[$key]['position_name']=($filearrayindatabase[$key2]['position']?$filearrayindatabase[$key2]['position']:'0').'_'.$filearrayindatabase[$key2]['name']; - $filearray[$key]['position']=$filearrayindatabase[$key2]['position']; - $filearray[$key]['cover']=$filearrayindatabase[$key2]['cover']; - $filearray[$key]['acl']=$filearrayindatabase[$key2]['acl']; - $filearray[$key]['rowid']=$filearrayindatabase[$key2]['rowid']; - $filearray[$key]['label']=$filearrayindatabase[$key2]['label']; - $found=1; - break; - } - } - } + completeFileArrayWithDatabaseInfo($filearray, $relativedir); if (count($filearray)) { diff --git a/htdocs/product/class/productcustomerprice.class.php b/htdocs/product/class/productcustomerprice.class.php index 6a488c87e2b..f8ca6366ddc 100644 --- a/htdocs/product/class/productcustomerprice.class.php +++ b/htdocs/product/class/productcustomerprice.class.php @@ -169,12 +169,12 @@ class Productcustomerprice extends CommonObject $sql .= " " . (empty($this->price_min_ttc) ? '0' : "'" . $this->price_min_ttc . "'") . ","; $sql .= " " . (! isset($this->price_base_type) ? 'NULL' : "'" . $this->db->escape($this->price_base_type) . "'") . ","; $sql .= " ".($this->default_vat_code ? "'".$this->db->escape($this->default_vat_code)."'" : "null").","; - $sql .= " " . (! isset($this->tva_tx) ? 'NULL' : "'" . $this->tva_tx . "'") . ","; + $sql .= " " . (! isset($this->tva_tx) ? 'NULL' : (empty($this->tva_tx)?0:$this->tva_tx)) . ","; $sql .= " " . (! isset($this->recuperableonly) ? 'NULL' : "'" . $this->recuperableonly . "'") . ","; $sql .= " " . (empty($this->localtax1_type) ? "'0'" : "'" . $this->localtax1_type . "'") . ","; - $sql .= " " . (! isset($this->localtax1_tx) ? 'NULL' : "'" . $this->localtax1_tx . "'") . ","; + $sql .= " " . (! isset($this->localtax1_tx) ? 'NULL' : (empty($this->localtax1_tx)?0:$this->localtax1_tx)) . ","; $sql .= " " . (empty($this->localtax2_type) ? "'0'" : "'" . $this->localtax2_type . "'") . ","; - $sql .= " " . (! isset($this->localtax2_tx) ? 'NULL' : "'" . $this->localtax2_tx . "'") . ","; + $sql .= " " . (! isset($this->localtax2_tx) ? 'NULL' : (empty($this->localtax2_tx)?0:$this->localtax2_tx)) . ","; $sql .= " " . $user->id . ","; $sql .= " " . (! isset($this->import_key) ? 'NULL' : "'" . $this->db->escape($this->import_key) . "'") . ""; $sql .= ")"; @@ -656,10 +656,10 @@ class Productcustomerprice extends CommonObject $sql .= " price_min_ttc=" . (isset($this->price_min_ttc) ? $this->price_min_ttc : "null") . ","; $sql .= " price_base_type=" . (isset($this->price_base_type) ? "'" . $this->db->escape($this->price_base_type) . "'" : "null") . ","; $sql .= " default_vat_code = ".($this->default_vat_code ? "'".$this->db->escape($this->default_vat_code)."'" : "null").","; - $sql .= " tva_tx=" . (isset($this->tva_tx) ? $this->tva_tx : "null") . ","; + $sql .= " tva_tx=" . (isset($this->tva_tx) ? (empty($this->tva_tx)?0:$this->tva_tx) : "null") . ","; $sql .= " recuperableonly=" . (isset($this->recuperableonly) ? $this->recuperableonly : "null") . ","; - $sql .= " localtax1_tx=" . (isset($this->localtax1_tx) ? $this->localtax1_tx : "null") . ","; - $sql .= " localtax2_tx=" . (isset($this->localtax2_tx) ? $this->localtax2_tx : "null") . ","; + $sql .= " localtax1_tx=" . (isset($this->localtax1_tx) ? (empty($this->localtax1_tx)?0:$this->localtax1_tx) : "null") . ","; + $sql .= " localtax2_tx=" . (isset($this->localtax2_tx) ? (empty($this->localtax2_tx)?0:$this->localtax2_tx) : "null") . ","; $sql .= " localtax1_type=" . (! empty($this->localtax1_type) ? "'".$this->localtax1_type."'": "'0'") . ","; $sql .= " localtax2_type=" . (! empty($this->localtax2_type) ? "'".$this->localtax2_type."'": "'0'") . ","; $sql .= " fk_user=" . $user->id . ","; @@ -676,15 +676,12 @@ class Productcustomerprice extends CommonObject if (! $error) { if (! $notrigger) { - // Uncomment this and change MYOBJECT to your own tag if you - // want this action calls a trigger. - - // // Call triggers - // include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; - // $interface=new Interfaces($this->db); - // $result=$interface->run_triggers('MYOBJECT_MODIFY',$this,$user,$langs,$conf); - // if ($result < 0) { $error++; $this->errors=$interface->errors; } - // // End call triggers + // Call triggers + include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; + $interface=new Interfaces($this->db); + $result=$interface->run_triggers('PRODUCT_CUSTOMER_PRICE_UPDATE',$this,$user,$langs,$conf); + if ($result < 0) { $error++; $this->errors=$interface->errors; } + // End call triggers } } diff --git a/htdocs/product/list.php b/htdocs/product/list.php index f772f8d4f0c..bd7e1c0d51d 100644 --- a/htdocs/product/list.php +++ b/htdocs/product/list.php @@ -853,7 +853,7 @@ else print ''; if ($obj->tobuy) { - if (($productFournList = $product_fourn->list_product_fournisseur_price($product_fourn->id)) > 0) + if (count($productFournList = $product_fourn->list_product_fournisseur_price($obj->rowid)) > 0) { $htmltext=$product_fourn->display_price_product_fournisseur(1, 1, 0, 1, $productFournList); print $form->textwithpicto(count($productFournList),$htmltext); diff --git a/htdocs/product/price.php b/htdocs/product/price.php index 949711b4a1b..b03a8763770 100644 --- a/htdocs/product/price.php +++ b/htdocs/product/price.php @@ -1171,6 +1171,9 @@ if ($action == 'edit_price' && $object->getRights()->creer) } print ''; print ''; + + $parameters=array('colspan' => 2); + $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook $parameters=array('colspan' => 2); $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook diff --git a/htdocs/projet/activity/perday.php b/htdocs/projet/activity/perday.php index 45d7aa237ad..73197025df6 100644 --- a/htdocs/projet/activity/perday.php +++ b/htdocs/projet/activity/perday.php @@ -439,10 +439,10 @@ print '
    '; print ''."\n"; print ''; -print ''; -print ''; print ''; if (! empty($conf->global->PROJECT_LINES_PERDAY_SHOW_THIRDPARTY)) print ''; +print ''; +print ''; print ''; print ''; print ''; @@ -458,13 +458,13 @@ print ''; print "\n"; print ''; -print ''; -print ''; print ''; if (! empty($conf->global->PROJECT_LINES_PERDAY_SHOW_THIRDPARTY)) { print ''; } +print ''; +print ''; print ''; print ''; /*print ''; diff --git a/htdocs/projet/activity/perweek.php b/htdocs/projet/activity/perweek.php index b4fcd68a3c9..01e4b71eda8 100644 --- a/htdocs/projet/activity/perweek.php +++ b/htdocs/projet/activity/perweek.php @@ -434,10 +434,10 @@ print '
    '; print '
    '.$langs->trans("RefTask").''.$langs->trans("LabelTask").''.$langs->trans("ProjectRef").''.$langs->trans("ThirdParty").''.$langs->trans("RefTask").''.$langs->trans("LabelTask").''.$langs->trans("PlannedWorkload").''.$langs->trans("ProgressDeclared").''.$langs->trans("TimeSpent").'
    '."\n"; print ''; -print ''; -print ''; print ''; if (! empty($conf->global->PROJECT_LINES_PERWEEK_SHOW_THIRDPARTY)) print ''; +print ''; +print ''; print ''; print ''; print ''; @@ -454,13 +454,13 @@ print ''; print "\n"; print ''; -print ''; -print ''; print ''; if (! empty($conf->global->PROJECT_LINES_PERWEEK_SHOW_THIRDPARTY)) { print ''; } +print ''; +print ''; print ''; print ''; /*print ''; diff --git a/htdocs/projet/admin/project.php b/htdocs/projet/admin/project.php index 9e35ea77e0b..744e52e0f2f 100644 --- a/htdocs/projet/admin/project.php +++ b/htdocs/projet/admin/project.php @@ -43,7 +43,7 @@ if (!$user->admin) accessforbidden(); $value = GETPOST('value','alpha'); $action = GETPOST('action','alpha'); $label = GETPOST('label','alpha'); -$scandir = GETPOST('scandir','alpha'); +$scandir = GETPOST('scan_dir','alpha'); $type='project'; @@ -645,7 +645,7 @@ foreach ($dirmodels as $reldir) if (in_array($name, $def)) { print ""; @@ -653,7 +653,7 @@ foreach ($dirmodels as $reldir) else { print ""; } @@ -665,7 +665,7 @@ foreach ($dirmodels as $reldir) } else { - print 'scandir.'&label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"),'off').''; + print 'scandir.'&label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"),'off').''; } print ''; @@ -804,7 +804,7 @@ if (empty($conf->global->PROJECT_HIDE_TASKS)) if (in_array($name, $def)) { print ""; @@ -812,7 +812,7 @@ if (empty($conf->global->PROJECT_HIDE_TASKS)) else { print ""; } @@ -824,7 +824,7 @@ if (empty($conf->global->PROJECT_HIDE_TASKS)) } else { - print 'scandir.'&label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"),'off').''; + print 'scandir.'&label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"),'off').''; } print ''; diff --git a/htdocs/projet/ganttview.php b/htdocs/projet/ganttview.php index ca3c0ba35e6..16f719a3a8f 100644 --- a/htdocs/projet/ganttview.php +++ b/htdocs/projet/ganttview.php @@ -307,9 +307,14 @@ if (count($tasksarray)>0) $dateformatinput2="%m/%d/%Y"; // How the date for data are formated //var_dump($dateformatinput); //var_dump($dateformatinput2); + + print '
    '; + print '
    '."\n"; include_once DOL_DOCUMENT_ROOT.'/projet/ganttchart.inc.php'; print '
    '."\n"; + + print '
    '; } else { diff --git a/htdocs/projet/tasks.php b/htdocs/projet/tasks.php index 112c2697706..204b393cc6d 100644 --- a/htdocs/projet/tasks.php +++ b/htdocs/projet/tasks.php @@ -494,6 +494,7 @@ else if ($id > 0 || ! empty($ref)) include DOL_DOCUMENT_ROOT.'/core/tpl/ajaxrow.tpl.php'; } + print '
    '; print '
    '.$langs->trans("RefTask").''.$langs->trans("LabelTask").''.$langs->trans("ProjectRef").''.$langs->trans("ThirdParty").''.$langs->trans("RefTask").''.$langs->trans("LabelTask").''.$langs->trans("PlannedWorkload").''.$langs->trans("ProgressDeclared").''.$langs->trans("TimeSpent").'\n"; - print 'scandir.'&label='.urlencode($module->name).'">'; + print 'scandir.'&label='.urlencode($module->name).'">'; print img_picto($langs->trans("Enabled"),'switch_on'); print ''; print "\n"; - print 'scandir.'&label='.urlencode($module->name).'">'.img_picto($langs->trans("Disabled"),'switch_off').''; + print 'scandir.'&label='.urlencode($module->name).'">'.img_picto($langs->trans("Disabled"),'switch_off').''; print "\n"; - print 'scandir.'&label='.urlencode($module->name).'">'; + print 'scandir.'&label='.urlencode($module->name).'">'; print img_picto($langs->trans("Enabled"),'switch_on'); print ''; print "\n"; - print 'scandir.'&label='.urlencode($module->name).'">'.img_picto($langs->trans("Disabled"),'switch_off').''; + print 'scandir.'&label='.urlencode($module->name).'">'.img_picto($langs->trans("Disabled"),'switch_off').''; print "
    '; if (count($tasksarray) > 0) @@ -536,6 +537,7 @@ else if ($id > 0 || ! empty($ref)) } print "
    "; + print '
    '; print ''; diff --git a/htdocs/public/websites/index.php b/htdocs/public/websites/index.php index 81b5f985186..c82ff9975d0 100644 --- a/htdocs/public/websites/index.php +++ b/htdocs/public/websites/index.php @@ -190,7 +190,7 @@ if (! file_exists($original_file_osencoded)) // Output page content define('USEDOLIBARRSERVER', 1); -print ''."\n"; +print ''."\n"; include_once $original_file_osencoded; diff --git a/htdocs/resource/add.php b/htdocs/resource/add.php index a294dfb94db..a6cd75cccf8 100644 --- a/htdocs/resource/add.php +++ b/htdocs/resource/add.php @@ -66,64 +66,72 @@ $extrafields = new ExtraFields($db); // fetch optionals attributes and labels $extralabels=$extrafields->fetch_name_optionals_label($object->table_element); -if ($action == 'confirm_add_resource') +$hookmanager->initHooks(array('resource_card_add','globalcard')); +$parameters=array(); +$reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks +if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + +if (empty($reshook)) { - if (! $cancel) - { - $error=''; - $ref=GETPOST('ref','alpha'); - $description=GETPOST('description','alpha'); - $fk_code_type_resource=GETPOST('fk_code_type_resource','alpha'); - - if (empty($ref)) - { - $mesg=$langs->trans("ErrorFieldRequired",$langs->transnoentities("Ref")); - setEventMessages($mesg, null, 'errors'); - $error++; - } - - if (! $error) - { - $object=new Dolresource($db); - $object->ref=$ref; - $object->description=$description; - $object->fk_code_type_resource=$fk_code_type_resource; - - // Fill array 'array_options' with data from add form - $ret = $extrafields->setOptionalsFromPost($extralabels, $object); - if ($ret < 0) { - $error ++; - } - - $result=$object->create($user); - if ($result > 0) - { - // Creation OK - $db->commit(); - setEventMessages($langs->trans('ResourceCreatedWithSuccess'), null, 'mesgs'); - Header("Location: card.php?id=" . $object->id); - return; - } - else - { - // Creation KO - setEventMessages($object->error, $object->errors, 'errors'); - $action = ''; - } - } - else - { - $action = ''; - } - } - else - { - Header("Location: list.php"); - } + if ($action == 'confirm_add_resource') + { + if (! $cancel) + { + $error=''; + + $ref=GETPOST('ref','alpha'); + $description=GETPOST('description','alpha'); + $fk_code_type_resource=GETPOST('fk_code_type_resource','alpha'); + + if (empty($ref)) + { + $mesg=$langs->trans("ErrorFieldRequired",$langs->transnoentities("Ref")); + setEventMessages($mesg, null, 'errors'); + $error++; + } + + if (! $error) + { + $object=new Dolresource($db); + $object->ref=$ref; + $object->description=$description; + $object->fk_code_type_resource=$fk_code_type_resource; + + // Fill array 'array_options' with data from add form + $ret = $extrafields->setOptionalsFromPost($extralabels, $object); + if ($ret < 0) { + $error ++; + } + + $result=$object->create($user); + if ($result > 0) + { + // Creation OK + $db->commit(); + setEventMessages($langs->trans('ResourceCreatedWithSuccess'), null, 'mesgs'); + Header("Location: card.php?id=" . $object->id); + return; + } + else + { + // Creation KO + setEventMessages($object->error, $object->errors, 'errors'); + $action = ''; + } + } + else + { + $action = ''; + } + } + else + { + Header("Location: list.php"); + } + } } - /* * View */ diff --git a/htdocs/resource/card.php b/htdocs/resource/card.php index 02d38c2b924..db6eed63b3b 100644 --- a/htdocs/resource/card.php +++ b/htdocs/resource/card.php @@ -54,10 +54,13 @@ if ($user->societe_id > 0) accessforbidden(); } -if( ! $user->rights->resource->read) +if (! $user->rights->resource->read) accessforbidden(); $object = new Dolresource($db); +$objectFetchRes = $object->fetch($id); +if (! ($objectFetchRes > 0)) dol_print_error($db, $object->error); + $extrafields = new ExtraFields($db); @@ -162,7 +165,7 @@ llxHeader('',$pagetitle,''); $form = new Form($db); $formresource = new FormResource($db); -if ( $object->fetch($id) > 0 ) +if ( $objectFetchRes > 0 ) { $head=resource_prepare_head($object); diff --git a/htdocs/societe/admin/societe.php b/htdocs/societe/admin/societe.php index 5c84be25521..89ef7d0323d 100644 --- a/htdocs/societe/admin/societe.php +++ b/htdocs/societe/admin/societe.php @@ -108,7 +108,7 @@ if ($action == 'updateoptions') if ($action == 'set') { $label = GETPOST('label','alpha'); - $scandir = GETPOST('scandir','alpha'); + $scandir = GETPOST('scan_dir','alpha'); $type='company'; $sql = "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity, libelle, description)"; @@ -135,7 +135,7 @@ if ($action== 'del') if ($action == 'setdoc') { $label = GETPOST('label','alpha'); - $scandir = GETPOST('scandir','alpha'); + $scandir = GETPOST('scan_dir','alpha'); $db->begin(); @@ -521,7 +521,7 @@ foreach ($dirsociete as $dirroot) print "\n"; //if ($conf->global->COMPANY_ADDON_PDF != "$name") //{ - print 'scandir.'&label='.urlencode($module->name).'">'; + print 'scandir.'&label='.urlencode($module->name).'">'; print img_picto($langs->trans("Enabled"),'switch_on'); print ''; //} @@ -542,7 +542,7 @@ foreach ($dirsociete as $dirroot) else { print "\n"; - print 'scandir.'&label='.urlencode($module->name).'">'.img_picto($langs->trans("Disabled"),'switch_off').''; + print 'scandir.'&label='.urlencode($module->name).'">'.img_picto($langs->trans("Disabled"),'switch_off').''; print ""; } } diff --git a/htdocs/societe/card.php b/htdocs/societe/card.php index 7f12893984e..53c5a1add14 100644 --- a/htdocs/societe/card.php +++ b/htdocs/societe/card.php @@ -168,12 +168,17 @@ if (empty($reshook)) } // Merge extrafields - foreach ($soc_origin->array_options as $key => $val) + if (is_array($soc_origin->array_options)) { - if (empty($object->array_options[$key])) $object->array_options[$key] = $val; + foreach ($soc_origin->array_options as $key => $val) + { + if (empty($object->array_options[$key])) $object->array_options[$key] = $val; + } } // TODO Merge categories + + $object->update($object->id, $user); // Move links diff --git a/htdocs/societe/list.php b/htdocs/societe/list.php index 94fc46f5734..c7ede7c5e3f 100644 --- a/htdocs/societe/list.php +++ b/htdocs/societe/list.php @@ -35,7 +35,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; require_once DOL_DOCUMENT_ROOT.'/societe/class/client.class.php'; -$langs->loadLangs(array("companies", "commercial", "customers", "suppliers", "bills", "compta", "commercial")); +$langs->loadLangs(array("companies", "commercial", "customers", "suppliers", "bills", "compta", "categories")); $action=GETPOST('action','alpha'); $massaction=GETPOST('massaction','alpha'); @@ -73,7 +73,8 @@ $search_idprof4=trim(GETPOST('search_idprof4')); $search_idprof5=trim(GETPOST('search_idprof5')); $search_idprof6=trim(GETPOST('search_idprof6')); $search_sale=trim(GETPOST("search_sale",'int')); -$search_categ=trim(GETPOST("search_categ",'int')); +$search_categ_cus=trim(GETPOST("search_categ_cus",'int')); +$search_categ_sup=trim(GETPOST("search_categ_sup",'int')); $search_country=GETPOST("search_country",'intcomma'); $search_type_thirdparty=GETPOST("search_type_thirdparty",'int'); $search_status=GETPOST("search_status",'int'); @@ -220,7 +221,8 @@ if (empty($reshook)) $search_id=''; $search_nom=''; $search_alias=''; - $search_categ=0; + $search_categ_cus=0; + $search_categ_sup=0; $search_sale=''; $search_barcode=""; $search_customer_code=''; @@ -389,7 +391,8 @@ $sql.= " state.code_departement as state_code, state.nom as state_name"; // We'll need these fields in order to filter by sale (including the case where the user can only see his prospects) if ($search_sale) $sql .= ", sc.fk_soc, sc.fk_user"; // We'll need these fields in order to filter by categ -if ($search_categ) $sql .= ", cs.fk_categorie, cs.fk_soc"; +if ($search_categ_cus) $sql .= ", cc.fk_categorie, cc.fk_soc"; +if ($search_categ_sup) $sql .= ", cs.fk_categorie, cs.fk_soc"; // Add fields from extrafields foreach ($extrafields->attribute_label as $key => $val) $sql.=($extrafields->attribute_type[$key] != 'separate' ? ",ef.".$key.' as options_'.$key : ''); // Add fields from hooks @@ -402,7 +405,8 @@ $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as country on (country.rowid = s. $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_typent as typent on (typent.id = s.fk_typent)"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_departements as state on (state.rowid = s.fk_departement)"; // We'll need this table joined to the select in order to filter by categ -if (! empty($search_categ)) $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX."categorie_".($type=='f'?"fournisseur":"societe")." as cs ON s.rowid = cs.fk_soc"; // We'll need this table joined to the select in order to filter by categ +if (! empty($search_categ_cus)) $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX."categorie_societe as cc ON s.rowid = cc.fk_soc"; // We'll need this table joined to the select in order to filter by categ +if (! empty($search_categ_sup)) $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX."categorie_fournisseur as cs ON s.rowid = cs.fk_soc"; // We'll need this table joined to the select in order to filter by categ $sql.= " ,".MAIN_DB_PREFIX."c_stcomm as st"; // We'll need this table joined to the select in order to filter by sale if ($search_sale || (!$user->rights->societe->client->voir && !$socid)) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; @@ -413,8 +417,10 @@ if ($socid) $sql.= " AND s.rowid = ".$socid; if ($search_sale) $sql.= " AND s.rowid = sc.fk_soc"; // Join for the needed table to filter by sale if (! $user->rights->fournisseur->lire) $sql.=" AND (s.fournisseur <> 1 OR s.client <> 0)"; // client=0, fournisseur=0 must be visible if ($search_sale) $sql.= " AND sc.fk_user = ".$db->escape($search_sale); -if ($search_categ > 0) $sql.= " AND cs.fk_categorie = ".$db->escape($search_categ); -if ($search_categ == -2) $sql.= " AND cs.fk_categorie IS NULL"; +if ($search_categ_cus > 0) $sql.= " AND cc.fk_categorie = ".$db->escape($search_categ_cus); +if ($search_categ_sup > 0) $sql.= " AND cs.fk_categorie = ".$db->escape($search_categ_sup); +if ($search_categ_cus == -2) $sql.= " AND cc.fk_categorie IS NULL"; +if ($search_categ_sup == -2) $sql.= " AND cs.fk_categorie IS NULL"; if ($search_all) $sql.= natural_search(array_keys($fieldstosearchall), $search_all); if (strlen($search_cti)) $sql.= natural_search('s.phone', $search_cti); @@ -457,8 +463,8 @@ foreach ($search_array_options as $key => $val) $tmpkey=preg_replace('/search_options_/','',$key); $typ=$extrafields->attribute_type[$tmpkey]; $mode=0; - if (in_array($typ, array('int','double'))) $mode=1; // Search on a numeric - if ($val && ( ($crit != '' && ! in_array($typ, array('select'))) || ! empty($crit))) + if (in_array($typ, array('int','double','real'))) $mode=1; // Search on a numeric + if ($crit != '' && (! in_array($typ, array('select')) || $crit != '0')) { $sql .= natural_search('ef.'.$tmpkey, $crit, $mode); } @@ -507,7 +513,8 @@ if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&con if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit; if ($search_all != '') $param = "&sall=".urlencode($search_all); if ($sall != '') $param .= "&sall=".urlencode($sall); -if ($search_categ > 0) $param.='&search_categ='.urlencode($search_categ); +if ($search_categ_cus > 0) $param.='&search_categ_cus='.urlencode($search_categ_cus); +if ($search_categ_sup > 0) $param.='&search_categ_sup='.urlencode($search_categ_sup); if ($search_sale > 0) $param.='&search_sale='.urlencode($search_sale); if ($search_id > 0) $param.= "&search_id=".urlencode($search_id); if ($search_nom != '') $param.= "&search_nom=".urlencode($search_nom); @@ -594,25 +601,25 @@ if ($search_all) // Filter on categories $moreforfilter=''; -if ($type == 'c' || $type == 'p') +if (empty($type) || $type == 'c' || $type == 'p') { if (! empty($conf->categorie->enabled)) { require_once DOL_DOCUMENT_ROOT . '/categories/class/categorie.class.php'; $moreforfilter.='
    '; - $moreforfilter.=$langs->trans('Categories'). ': '; - $moreforfilter.=$formother->select_categories('customer',$search_categ,'search_categ',1); + $moreforfilter.=$langs->trans('CustomersProspectsCategoriesShort').': '; + $moreforfilter.=$formother->select_categories('customer',$search_categ_cus,'search_categ_cus',1); $moreforfilter.='
    '; } } -if ($type == 'f') +if (empty($type) || $type == 'f') { if (! empty($conf->categorie->enabled)) { require_once DOL_DOCUMENT_ROOT . '/categories/class/categorie.class.php'; $moreforfilter.='
    '; - $moreforfilter.=$langs->trans('Categories'). ': '; - $moreforfilter.=$formother->select_categories('supplier',$search_categ,'search_categ',1); + $moreforfilter.=$langs->trans('SuppliersCategoriesShort').': '; + $moreforfilter.=$formother->select_categories('supplier',$search_categ_sup,'search_categ_sup',1); $moreforfilter.='
    '; } } diff --git a/htdocs/supplier_proposal/card.php b/htdocs/supplier_proposal/card.php index 5c39f910b66..cfb8ca52234 100644 --- a/htdocs/supplier_proposal/card.php +++ b/htdocs/supplier_proposal/card.php @@ -574,7 +574,7 @@ if (empty($reshook)) { $productsupplier = new ProductFournisseur($db); - if (empty($conf->global->SUPPLIER_PROPOSAL_WITH_NOPRICEDEFINED)) + if (empty($conf->global->SUPPLIER_PROPOSAL_WITH_NOPRICEDEFINED)) // TODO this test seems useless { $idprod=0; if (GETPOST('idprodfournprice') == -1 || GETPOST('idprodfournprice') == '') $idprod=-99; // Same behaviour than with combolist. When not select idprodfournprice is now -99 (to avoid conflict with next action that may return -1, -2, ...) @@ -589,8 +589,9 @@ if (empty($reshook)) } elseif (GETPOST('idprodfournprice') > 0) { - //$idprod=$productsupplier->get_buyprice(GETPOST('idprodfournprice'), $qty); // Just to see if a price exists for the quantity. Not used to found vat. - $idprod=$productsupplier->get_buyprice(GETPOST('idprodfournprice'), -1); // We force qty to -1 to be sure to find if a supplier price exist + //$qtytosearch=$qty; // Just to see if a price exists for the quantity. Not used to found vat. + $qtytosearch=-1; // We force qty to -1 to be sure to find if a supplier price exist + $idprod=$productsupplier->get_buyprice(GETPOST('idprodfournprice'), $qtytosearch); $res=$productsupplier->fetch($idprod); } @@ -600,7 +601,7 @@ if (empty($reshook)) $price_base_type = $productsupplier->fourn_price_base_type; $type = $productsupplier->type; $label = $productsupplier->label; - $desc = $productsupplier->description; + $desc = $productsupplier->description; if (trim($product_desc) != trim($desc)) $desc = dol_concatdesc($desc, $product_desc); $tva_tx = get_default_tva($object->thirdparty, $mysoc, $productsupplier->id, GETPOST('idprodfournprice')); diff --git a/htdocs/supplier_proposal/info.php b/htdocs/supplier_proposal/info.php index 718b79ce4ae..8cee304e3bb 100644 --- a/htdocs/supplier_proposal/info.php +++ b/htdocs/supplier_proposal/info.php @@ -43,6 +43,8 @@ $result = restrictedArea($user, 'supplier_proposal', $id); * View */ +$form = new Form($db); + llxHeader('',$langs->trans('CommRequest'),'EN:Ask_Price_Supplier|FR:Demande_de_prix_fournisseur'); $object = new SupplierProposal($db); @@ -57,8 +59,8 @@ dol_fiche_head($head, 'info', $langs->trans('CommRequest'), -1, 'supplier_propos // Supplier proposal card $linkback = '' . $langs->trans("BackToList") . ''; - - + + $morehtmlref='
    '; // Ref supplier //$morehtmlref.=$form->editfieldkey("RefSupplier", 'ref_supplier', $object->ref_supplier, $object, $user->rights->fournisseur->commande->creer, 'string', '', 0, 1); @@ -99,11 +101,11 @@ if (! empty($conf->projet->enabled)) } } $morehtmlref.='
    '; - - + + dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref); - + print '
    '; print '
    '; diff --git a/htdocs/support/index.php b/htdocs/support/index.php index 0e27107ef54..ab5d62df39e 100644 --- a/htdocs/support/index.php +++ b/htdocs/support/index.php @@ -70,12 +70,12 @@ print ''; print ''; print '