Merge github.com:Dolibarr/dolibarr into dev_new_add_desc_when_select_product

This commit is contained in:
Florian HENRY 2020-10-28 17:17:52 +01:00
commit 4b7707cc7c
25 changed files with 312 additions and 318 deletions

View File

@ -20,6 +20,9 @@ RUN apt-get update -y \
unzip \ unzip \
curl \ curl \
apt-utils \ apt-utils \
msmtp \
msmtp-mta \
mailutils \
&& apt-get autoremove -y \ && apt-get autoremove -y \
&& rm -rf /var/lib/apt/lists/* \ && rm -rf /var/lib/apt/lists/* \
&& docker-php-ext-configure gd --with-png-dir=/usr --with-jpeg-dir=/usr \ && docker-php-ext-configure gd --with-png-dir=/usr --with-jpeg-dir=/usr \
@ -44,7 +47,17 @@ RUN echo 'xdebug.remote_port=9000' >> ${PHP_INI_DIR}/php.ini
RUN echo 'xdebug.remote_connect_back=1' >> ${PHP_INI_DIR}/php.ini RUN echo 'xdebug.remote_connect_back=1' >> ${PHP_INI_DIR}/php.ini
RUN echo 'xdebug.profiler_enable=0' >> ${PHP_INI_DIR}/php.ini RUN echo 'xdebug.profiler_enable=0' >> ${PHP_INI_DIR}/php.ini
RUN echo 'xdebug.remote_log="/tmp/xdebug.log"' >> ${PHP_INI_DIR}/php.ini RUN echo 'xdebug.remote_log="/tmp/xdebug.log"' >> ${PHP_INI_DIR}/php.ini
#RUN echo '172.17.0.1 docker.host' >> /etc/hosts #RUN echo 'localhost docker.host' >> /etc/hosts
# set up sendmail config, to use maildev
RUN echo "account default" > /etc/msmtprc
RUN echo "auth off" >> /etc/msmtprc
RUN echo "port 25" >> /etc/msmtprc
RUN echo "host mail" >> /etc/msmtprc
RUN echo "from local@localdomain.com" >> /etc/msmtprc
RUN echo "domain localhost.localdomain" >> /etc/msmtprc
RUN echo "sendmail_path=/usr/bin/msmtp -t" >> /usr/local/etc/php/conf.d/php-sendmail.ini
RUN echo "localhost localhost.localdomain" >> /etc/hosts
EXPOSE 80 EXPOSE 80

View File

@ -16,7 +16,7 @@ And then, you can run :
docker-compose up docker-compose up
This will run 3 container Docker : Dolibarr, MariaDB and PhpMyAdmin. This will run 4 containers Docker : Dolibarr, MariaDB, PhpMyAdmin and MailDev.
The URL to go to the Dolibarr is : The URL to go to the Dolibarr is :
@ -25,7 +25,10 @@ The URL to go to the Dolibarr is :
The URL to go to PhpMyAdmin is (login/password is root/root) : The URL to go to PhpMyAdmin is (login/password is root/root) :
http://0.0.0.0:8080 http://0.0.0.0:8080
In Dolibarr configuration Email let PHP mail function, To see all mail send by Dolibarr go to maildev
Setup the database connection during the installation process, please use mariad http://0.0.0.0:8081
b (name of the database container) as database host.
Setup the database connection during the installation process, please use mariadb (name of the database container) as database host.
Setup documents folder, during the installation process, to /var/documents Setup documents folder, during the installation process, to /var/documents

View File

@ -52,3 +52,6 @@ services:
ports: ports:
- "8081:80" - "8081:80"
- "25:25" - "25:25"
networks:
- internal-pod
- external-pod

View File

@ -17,6 +17,7 @@
<exclude-pattern type="relative">*/nltechno*</exclude-pattern> <exclude-pattern type="relative">*/nltechno*</exclude-pattern>
<exclude-pattern type="relative">*/htdocs/includes</exclude-pattern> <exclude-pattern type="relative">*/htdocs/includes</exclude-pattern>
<exclude-pattern type="relative">*/htdocs/includes</exclude-pattern> <exclude-pattern type="relative">*/htdocs/includes</exclude-pattern>
<exclude-pattern type="relative">.git</exclude-pattern>
<!-- List of all tests --> <!-- List of all tests -->

View File

@ -1530,14 +1530,14 @@ class BookKeeping extends CommonObject
$this->label_compte = 'Customer'; $this->label_compte = 'Customer';
$this->label_operation = 'Sales of pea'; $this->label_operation = 'Sales of pea';
$this->debit = 99.9; $this->debit = 99.9;
$this->credit = ''; $this->credit = 0.0;
$this->montant = ''; $this->amount = 0.0;
$this->sens = 'D'; $this->sens = 'D';
$this->fk_user_author = $user->id; $this->fk_user_author = $user->id;
$this->import_key = ''; $this->import_key = '20201027';
$this->code_journal = 'VT'; $this->code_journal = 'VT';
$this->journal_label = 'Journal de vente'; $this->journal_label = 'Journal de vente';
$this->piece_num = ''; $this->piece_num = 1234;
$this->date_creation = $now; $this->date_creation = $now;
} }

View File

@ -589,8 +589,9 @@ class Adherent extends CommonObject
$this->town = ($this->town ? $this->town : $this->town); $this->town = ($this->town ? $this->town : $this->town);
$this->country_id = ($this->country_id > 0 ? $this->country_id : $this->country_id); $this->country_id = ($this->country_id > 0 ? $this->country_id : $this->country_id);
$this->state_id = ($this->state_id > 0 ? $this->state_id : $this->state_id); $this->state_id = ($this->state_id > 0 ? $this->state_id : $this->state_id);
if (!empty($conf->global->MAIN_FIRST_TO_UPPER)) $this->lastname = ucwords(trim($this->lastname)); if (!empty($conf->global->MAIN_FIRST_TO_UPPER)) $this->lastname = dol_ucwords(dol_strtolower($this->lastname));
if (!empty($conf->global->MAIN_FIRST_TO_UPPER)) $this->firstname = ucwords(trim($this->firstname)); if (!empty($conf->global->MAIN_ALL_TO_UPPER)) $this->lastname = dol_strtoupper($this->lastname);
if (!empty($conf->global->MAIN_FIRST_TO_UPPER)) $this->firstname = dol_ucwords(dol_strtolower($this->firstname));
$this->note_public = ($this->note_public ? $this->note_public : $this->note_public); $this->note_public = ($this->note_public ? $this->note_public : $this->note_public);
$this->note_private = ($this->note_private ? $this->note_private : $this->note_private); $this->note_private = ($this->note_private ? $this->note_private : $this->note_private);

View File

@ -616,6 +616,12 @@ class Documents extends DolibarrApi
require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php';
$object = new Adherent($this->db); $object = new Adherent($this->db);
} }
elseif ($modulepart == 'proposal' || $modulepart == 'propal' || $modulepart == 'propale')
{
$modulepart = 'propale';
require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php';
$object = new Propal($this->db);
}
// TODO Implement additional moduleparts // TODO Implement additional moduleparts
else else
{ {

View File

@ -29,7 +29,7 @@
* \brief List of bank transactions * \brief List of bank transactions
*/ */
if (!defined('NOREQUIREMENU')) define('NOREQUIREMENU','1'); // If there is no need to load and show top and left menu if (!defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1'); // If there is no need to load and show top and left menu
if (!defined('NOBROWSERNOTIF')) define('NOBROWSERNOTIF', '1'); // Disable browser notification if (!defined('NOBROWSERNOTIF')) define('NOBROWSERNOTIF', '1'); // Disable browser notification
require '../../main.inc.php'; require '../../main.inc.php';
@ -125,8 +125,7 @@ elseif ($syear && $smonth && $sday) $sql .= " AND datef BETWEEN '".$db->idate(
else dol_print_error('', 'Year not defined'); else dol_print_error('', 'Year not defined');
$resql = $db->query($sql); $resql = $db->query($sql);
if ($resql) if ($resql) {
{
$num = $db->num_rows($resql); $num = $db->num_rows($resql);
$i = 0; $i = 0;
@ -166,12 +165,10 @@ if ($resql)
$totalarray = array(); $totalarray = array();
$cachebankaccount = array(); $cachebankaccount = array();
$amountpertype = array(); $amountpertype = array();
while ($i < $num) while ($i < $num) {
{
$objp = $db->fetch_object($resql); $objp = $db->fetch_object($resql);
if (empty($cachebankaccount[$objp->bankid])) if (empty($cachebankaccount[$objp->bankid])) {
{
$bankaccounttmp = new Account($db); $bankaccounttmp = new Account($db);
$bankaccounttmp->fetch($objp->bankid); $bankaccounttmp->fetch($objp->bankid);
$cachebankaccount[$objp->bankid] = $bankaccounttmp; $cachebankaccount[$objp->bankid] = $bankaccounttmp;
@ -235,8 +232,7 @@ if ($resql)
// Debit // Debit
print '<td class="right">'; print '<td class="right">';
if ($objp->amount < 0) if ($objp->amount < 0) {
{
print price($objp->amount * -1); print price($objp->amount * -1);
$totalarray['val']['totaldebfield'] += $objp->amount; $totalarray['val']['totaldebfield'] += $objp->amount;
$amountpertype[$objp->code] += $objp->amount; $amountpertype[$objp->code] += $objp->amount;
@ -247,8 +243,7 @@ if ($resql)
// Credit // Credit
print '<td class="right">'; print '<td class="right">';
if ($objp->amount > 0) if ($objp->amount > 0) {
{
print price($objp->amount); print price($objp->amount);
$totalarray['val']['totalcredfield'] += $objp->amount; $totalarray['val']['totalcredfield'] += $objp->amount;
$amountpertype[$objp->code] -= $objp->amount; $amountpertype[$objp->code] -= $objp->amount;

View File

@ -353,9 +353,9 @@ class Contact extends CommonObject
// Clean parameters // Clean parameters
$this->lastname = $this->lastname ?trim($this->lastname) : trim($this->name); $this->lastname = $this->lastname ?trim($this->lastname) : trim($this->name);
$this->firstname = trim($this->firstname); $this->firstname = trim($this->firstname);
if (!empty($conf->global->MAIN_FIRST_TO_UPPER)) $this->lastname = ucwords(strtolower($this->lastname)); if (!empty($conf->global->MAIN_FIRST_TO_UPPER)) $this->lastname = dol_ucwords(dol_strtolower($this->lastname));
if (!empty($conf->global->MAIN_ALL_TO_UPPER)) $this->lastname = strtoupper($this->lastname); if (!empty($conf->global->MAIN_ALL_TO_UPPER)) $this->lastname = dol_strtoupper($this->lastname);
if (!empty($conf->global->MAIN_FIRST_TO_UPPER)) $this->firstname = ucwords(strtolower($this->firstname)); if (!empty($conf->global->MAIN_FIRST_TO_UPPER)) $this->firstname = dol_ucwords(dol_strtolower($this->firstname));
if (empty($this->socid)) $this->socid = 0; if (empty($this->socid)) $this->socid = 0;
if (empty($this->priv)) $this->priv = 0; if (empty($this->priv)) $this->priv = 0;
if (empty($this->statut)) $this->statut = 0; // This is to convert '' into '0' to avoid bad sql request if (empty($this->statut)) $this->statut = 0; // This is to convert '' into '0' to avoid bad sql request
@ -464,9 +464,9 @@ class Contact extends CommonObject
$this->entity = ((isset($this->entity) && is_numeric($this->entity)) ? $this->entity : $conf->entity); $this->entity = ((isset($this->entity) && is_numeric($this->entity)) ? $this->entity : $conf->entity);
// Clean parameters // Clean parameters
if (!empty($conf->global->MAIN_FIRST_TO_UPPER)) $this->lastname = ucwords(strtolower($this->lastname)); if (!empty($conf->global->MAIN_FIRST_TO_UPPER)) $this->lastname = dol_ucwords(dol_strtolower($this->lastname));
if (!empty($conf->global->MAIN_ALL_TO_UPPER)) $this->lastname = strtoupper($this->lastname); if (!empty($conf->global->MAIN_ALL_TO_UPPER)) $this->lastname = dol_strtoupper($this->lastname);
if (!empty($conf->global->MAIN_FIRST_TO_UPPER)) $this->firstname = ucwords(strtolower($this->firstname)); if (!empty($conf->global->MAIN_FIRST_TO_UPPER)) $this->firstname = dol_ucwords(dol_strtolower($this->firstname));
$this->lastname = trim($this->lastname) ?trim($this->lastname) : trim($this->lastname); $this->lastname = trim($this->lastname) ?trim($this->lastname) : trim($this->lastname);
$this->firstname = trim($this->firstname); $this->firstname = trim($this->firstname);

View File

@ -50,10 +50,8 @@ function societe_prepare_head(Societe $object)
$head[$h][2] = 'card'; $head[$h][2] = 'card';
$h++; $h++;
if (empty($conf->global->MAIN_SUPPORT_SHARED_CONTACT_BETWEEN_THIRDPARTIES)) if (empty($conf->global->MAIN_SUPPORT_SHARED_CONTACT_BETWEEN_THIRDPARTIES)) {
{ if (empty($conf->global->MAIN_DISABLE_CONTACTS_TAB) && $user->rights->societe->contact->lire) {
if (empty($conf->global->MAIN_DISABLE_CONTACTS_TAB) && $user->rights->societe->contact->lire)
{
//$nbContact = count($object->liste_contact(-1,'internal')) + count($object->liste_contact(-1,'external')); //$nbContact = count($object->liste_contact(-1,'internal')) + count($object->liste_contact(-1,'external'));
$nbContact = 0; // TODO $nbContact = 0; // TODO
@ -61,8 +59,7 @@ function societe_prepare_head(Societe $object)
$sql .= " FROM ".MAIN_DB_PREFIX."socpeople as p"; $sql .= " FROM ".MAIN_DB_PREFIX."socpeople as p";
$sql .= " WHERE p.fk_soc = ".$object->id; $sql .= " WHERE p.fk_soc = ".$object->id;
$resql = $db->query($sql); $resql = $db->query($sql);
if ($resql) if ($resql) {
{
$obj = $db->fetch_object($resql); $obj = $db->fetch_object($resql);
if ($obj) $nbContact = $obj->nb; if ($obj) $nbContact = $obj->nb;
} }
@ -82,8 +79,7 @@ function societe_prepare_head(Societe $object)
$h++; $h++;
} }
if ($object->client == 1 || $object->client == 2 || $object->client == 3) if ($object->client == 1 || $object->client == 2 || $object->client == 3) {
{
$head[$h][0] = DOL_URL_ROOT.'/comm/card.php?socid='.$object->id; $head[$h][0] = DOL_URL_ROOT.'/comm/card.php?socid='.$object->id;
$head[$h][1] = ''; $head[$h][1] = '';
if (empty($conf->global->SOCIETE_DISABLE_PROSPECTS) && ($object->client == 2 || $object->client == 3)) $head[$h][1] .= $langs->trans("Prospect"); if (empty($conf->global->SOCIETE_DISABLE_PROSPECTS) && ($object->client == 2 || $object->client == 3)) $head[$h][1] .= $langs->trans("Prospect");
@ -92,8 +88,7 @@ function societe_prepare_head(Societe $object)
$head[$h][2] = 'customer'; $head[$h][2] = 'customer';
$h++; $h++;
if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES)) if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES)) {
{
$langs->load("products"); $langs->load("products");
// price // price
$head[$h][0] = DOL_URL_ROOT.'/societe/price.php?socid='.$object->id; $head[$h][0] = DOL_URL_ROOT.'/societe/price.php?socid='.$object->id;
@ -104,16 +99,14 @@ function societe_prepare_head(Societe $object)
} }
$supplier_module_enabled = 0; $supplier_module_enabled = 0;
if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || !empty($conf->supplier_proposal->enabled) || !empty($conf->supplier_order->enabled) || !empty($conf->supplier_invoice->enabled)) $supplier_module_enabled = 1; if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || !empty($conf->supplier_proposal->enabled) || !empty($conf->supplier_order->enabled) || !empty($conf->supplier_invoice->enabled)) $supplier_module_enabled = 1;
if ($supplier_module_enabled == 1 && $object->fournisseur && !empty($user->rights->fournisseur->lire)) if ($supplier_module_enabled == 1 && $object->fournisseur && !empty($user->rights->fournisseur->lire)) {
{
$head[$h][0] = DOL_URL_ROOT.'/fourn/card.php?socid='.$object->id; $head[$h][0] = DOL_URL_ROOT.'/fourn/card.php?socid='.$object->id;
$head[$h][1] = $langs->trans("Supplier"); $head[$h][1] = $langs->trans("Supplier");
$head[$h][2] = 'supplier'; $head[$h][2] = 'supplier';
$h++; $h++;
} }
if (!empty($conf->projet->enabled) && (!empty($user->rights->projet->lire))) if (!empty($conf->projet->enabled) && (!empty($user->rights->projet->lire))) {
{
$head[$h][0] = DOL_URL_ROOT.'/societe/project.php?socid='.$object->id; $head[$h][0] = DOL_URL_ROOT.'/societe/project.php?socid='.$object->id;
$head[$h][1] = $langs->trans("Projects"); $head[$h][1] = $langs->trans("Projects");
$nbNote = 0; $nbNote = 0;
@ -122,12 +115,10 @@ function societe_prepare_head(Societe $object)
$sql .= " WHERE fk_soc = ".$object->id; $sql .= " WHERE fk_soc = ".$object->id;
$sql .= " AND entity IN (".getEntity('project').")"; $sql .= " AND entity IN (".getEntity('project').")";
$resql = $db->query($sql); $resql = $db->query($sql);
if ($resql) if ($resql) {
{
$num = $db->num_rows($resql); $num = $db->num_rows($resql);
$i = 0; $i = 0;
while ($i < $num) while ($i < $num) {
{
$obj = $db->fetch_object($resql); $obj = $db->fetch_object($resql);
$nbNote = $obj->nb; $nbNote = $obj->nb;
$i++; $i++;
@ -141,19 +132,16 @@ function societe_prepare_head(Societe $object)
} }
// Tab to link resources // Tab to link resources
if (!empty($conf->resource->enabled) && !empty($conf->global->RESOURCE_ON_THIRDPARTIES)) if (!empty($conf->resource->enabled) && !empty($conf->global->RESOURCE_ON_THIRDPARTIES)) {
{
$head[$h][0] = DOL_URL_ROOT.'/resource/element_resource.php?element=societe&element_id='.$object->id; $head[$h][0] = DOL_URL_ROOT.'/resource/element_resource.php?element=societe&element_id='.$object->id;
$head[$h][1] = $langs->trans("Resources"); $head[$h][1] = $langs->trans("Resources");
$head[$h][2] = 'resources'; $head[$h][2] = 'resources';
$h++; $h++;
} }
if (!empty($conf->global->ACCOUNTING_ENABLE_LETTERING)) if (!empty($conf->global->ACCOUNTING_ENABLE_LETTERING)) {
{
// Tab to accountancy // Tab to accountancy
if (!empty($conf->accounting->enabled) && $object->client > 0) if (!empty($conf->accounting->enabled) && $object->client > 0) {
{
$head[$h][0] = DOL_URL_ROOT.'/accountancy/bookkeeping/thirdparty_lettering_customer.php?socid='.$object->id; $head[$h][0] = DOL_URL_ROOT.'/accountancy/bookkeeping/thirdparty_lettering_customer.php?socid='.$object->id;
$head[$h][1] = $langs->trans("TabLetteringCustomer"); $head[$h][1] = $langs->trans("TabLetteringCustomer");
$head[$h][2] = 'lettering_customer'; $head[$h][2] = 'lettering_customer';
@ -161,8 +149,7 @@ function societe_prepare_head(Societe $object)
} }
// Tab to accountancy // Tab to accountancy
if (!empty($conf->accounting->enabled) && $object->fournisseur > 0) if (!empty($conf->accounting->enabled) && $object->fournisseur > 0) {
{
$head[$h][0] = DOL_URL_ROOT.'/accountancy/bookkeeping/thirdparty_lettering_supplier.php?socid='.$object->id; $head[$h][0] = DOL_URL_ROOT.'/accountancy/bookkeeping/thirdparty_lettering_supplier.php?socid='.$object->id;
$head[$h][1] = $langs->trans("TabLetteringSupplier"); $head[$h][1] = $langs->trans("TabLetteringSupplier");
$head[$h][2] = 'lettering_supplier'; $head[$h][2] = 'lettering_supplier';
@ -172,8 +159,7 @@ function societe_prepare_head(Societe $object)
// Related items // Related items
if ((!empty($conf->commande->enabled) || !empty($conf->propal->enabled) || !empty($conf->facture->enabled) || !empty($conf->ficheinter->enabled) || !empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_order->enabled) || !empty($conf->supplier_invoice->enabled)) if ((!empty($conf->commande->enabled) || !empty($conf->propal->enabled) || !empty($conf->facture->enabled) || !empty($conf->ficheinter->enabled) || !empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_order->enabled) || !empty($conf->supplier_invoice->enabled))
&& empty($conf->global->THIRPARTIES_DISABLE_RELATED_OBJECT_TAB)) && empty($conf->global->THIRPARTIES_DISABLE_RELATED_OBJECT_TAB)) {
{
$head[$h][0] = DOL_URL_ROOT.'/societe/consumption.php?socid='.$object->id; $head[$h][0] = DOL_URL_ROOT.'/societe/consumption.php?socid='.$object->id;
$head[$h][1] = $langs->trans("Referers"); $head[$h][1] = $langs->trans("Referers");
$head[$h][2] = 'consumption'; $head[$h][2] = 'consumption';
@ -181,8 +167,7 @@ function societe_prepare_head(Societe $object)
} }
// Bank accounts // Bank accounts
if (empty($conf->global->SOCIETE_DISABLE_BANKACCOUNT)) if (empty($conf->global->SOCIETE_DISABLE_BANKACCOUNT)) {
{
$nbBankAccount = 0; $nbBankAccount = 0;
$foundonexternalonlinesystem = 0; $foundonexternalonlinesystem = 0;
$langs->load("banks"); $langs->load("banks");
@ -190,8 +175,7 @@ function societe_prepare_head(Societe $object)
//$title = $langs->trans("BankAccounts"); //$title = $langs->trans("BankAccounts");
$title = $langs->trans("PaymentInformation"); $title = $langs->trans("PaymentInformation");
if (!empty($conf->stripe->enabled)) if (!empty($conf->stripe->enabled)) {
{
//$langs->load("stripe"); //$langs->load("stripe");
//$title = $langs->trans("BankAccountsAndGateways"); //$title = $langs->trans("BankAccountsAndGateways");
@ -214,12 +198,10 @@ function societe_prepare_head(Societe $object)
} }
$resql = $db->query($sql); $resql = $db->query($sql);
if ($resql) if ($resql) {
{
$num = $db->num_rows($resql); $num = $db->num_rows($resql);
$i = 0; $i = 0;
while ($i < $num) while ($i < $num) {
{
$obj = $db->fetch_object($resql); $obj = $db->fetch_object($resql);
$nbBankAccount = $obj->nb; $nbBankAccount = $obj->nb;
$i++; $i++;
@ -238,8 +220,7 @@ function societe_prepare_head(Societe $object)
$h++; $h++;
} }
if (!empty($conf->website->enabled) && (!empty($conf->global->WEBSITE_USE_WEBSITE_ACCOUNTS)) && (!empty($user->rights->societe->lire))) if (!empty($conf->website->enabled) && (!empty($conf->global->WEBSITE_USE_WEBSITE_ACCOUNTS)) && (!empty($user->rights->societe->lire))) {
{
$head[$h][0] = DOL_URL_ROOT.'/societe/website.php?id='.$object->id; $head[$h][0] = DOL_URL_ROOT.'/societe/website.php?id='.$object->id;
$head[$h][1] = $langs->trans("WebSiteAccounts"); $head[$h][1] = $langs->trans("WebSiteAccounts");
$nbNote = 0; $nbNote = 0;
@ -247,12 +228,10 @@ function societe_prepare_head(Societe $object)
$sql .= " FROM ".MAIN_DB_PREFIX."societe_account as n"; $sql .= " FROM ".MAIN_DB_PREFIX."societe_account as n";
$sql .= " WHERE fk_soc = ".$object->id.' AND fk_website > 0'; $sql .= " WHERE fk_soc = ".$object->id.' AND fk_website > 0';
$resql = $db->query($sql); $resql = $db->query($sql);
if ($resql) if ($resql) {
{
$num = $db->num_rows($resql); $num = $db->num_rows($resql);
$i = 0; $i = 0;
while ($i < $num) while ($i < $num) {
{
$obj = $db->fetch_object($resql); $obj = $db->fetch_object($resql);
$nbNote = $obj->nb; $nbNote = $obj->nb;
$i++; $i++;
@ -271,22 +250,18 @@ function societe_prepare_head(Societe $object)
// $this->tabs = array('entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to remove a tab // $this->tabs = array('entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to remove a tab
complete_head_from_modules($conf, $langs, $object, $head, $h, 'thirdparty'); complete_head_from_modules($conf, $langs, $object, $head, $h, 'thirdparty');
if ($user->socid == 0) if ($user->socid == 0) {
{
// Notifications // Notifications
if (!empty($conf->notification->enabled)) if (!empty($conf->notification->enabled)) {
{
$nbNote = 0; $nbNote = 0;
$sql = "SELECT COUNT(n.rowid) as nb"; $sql = "SELECT COUNT(n.rowid) as nb";
$sql .= " FROM ".MAIN_DB_PREFIX."notify_def as n"; $sql .= " FROM ".MAIN_DB_PREFIX."notify_def as n";
$sql .= " WHERE fk_soc = ".$object->id; $sql .= " WHERE fk_soc = ".$object->id;
$resql = $db->query($sql); $resql = $db->query($sql);
if ($resql) if ($resql) {
{
$num = $db->num_rows($resql); $num = $db->num_rows($resql);
$i = 0; $i = 0;
while ($i < $num) while ($i < $num) {
{
$obj = $db->fetch_object($resql); $obj = $db->fetch_object($resql);
$nbNote = $obj->nb; $nbNote = $obj->nb;
$i++; $i++;
@ -328,8 +303,7 @@ function societe_prepare_head(Societe $object)
$head[$h][0] = DOL_URL_ROOT.'/societe/agenda.php?socid='.$object->id; $head[$h][0] = DOL_URL_ROOT.'/societe/agenda.php?socid='.$object->id;
$head[$h][1] .= $langs->trans("Events"); $head[$h][1] .= $langs->trans("Events");
if (!empty($conf->agenda->enabled) && (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read))) if (!empty($conf->agenda->enabled) && (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read))) {
{
$head[$h][1] .= '/'; $head[$h][1] .= '/';
$head[$h][1] .= $langs->trans("Agenda"); $head[$h][1] .= $langs->trans("Agenda");
} }
@ -437,8 +411,7 @@ function getCountry($searchkey, $withcode = '', $dbtouse = 0, $outputlangs = '',
$result = ''; $result = '';
// Check parameters // Check parameters
if (empty($searchkey) && empty($searchlabel)) if (empty($searchkey) && empty($searchlabel)) {
{
if ($withcode === 'all') return array('id'=>'', 'code'=>'', 'label'=>''); if ($withcode === 'all') return array('id'=>'', 'code'=>'', 'label'=>'');
else return ''; else return '';
} }
@ -451,14 +424,11 @@ function getCountry($searchkey, $withcode = '', $dbtouse = 0, $outputlangs = '',
else $sql .= " WHERE label='".$db->escape($searchlabel)."'"; else $sql .= " WHERE label='".$db->escape($searchlabel)."'";
$resql = $dbtouse->query($sql); $resql = $dbtouse->query($sql);
if ($resql) if ($resql) {
{
$obj = $dbtouse->fetch_object($resql); $obj = $dbtouse->fetch_object($resql);
if ($obj) if ($obj) {
{
$label = ((!empty($obj->label) && $obj->label != '-') ? $obj->label : ''); $label = ((!empty($obj->label) && $obj->label != '-') ? $obj->label : '');
if (is_object($outputlangs)) if (is_object($outputlangs)) {
{
$outputlangs->load("dict"); $outputlangs->load("dict");
if ($entconv) $label = ($obj->code && ($outputlangs->trans("Country".$obj->code) != "Country".$obj->code)) ? $outputlangs->trans("Country".$obj->code) : $label; if ($entconv) $label = ($obj->code && ($outputlangs->trans("Country".$obj->code) != "Country".$obj->code)) ? $outputlangs->trans("Country".$obj->code) : $label;
else $label = ($obj->code && ($outputlangs->transnoentitiesnoconv("Country".$obj->code) != "Country".$obj->code)) ? $outputlangs->transnoentitiesnoconv("Country".$obj->code) : $label; else $label = ($obj->code && ($outputlangs->transnoentitiesnoconv("Country".$obj->code) != "Country".$obj->code)) ? $outputlangs->transnoentitiesnoconv("Country".$obj->code) : $label;
@ -506,14 +476,11 @@ function getState($id, $withcode = '', $dbtouse = 0, $withregion = 0, $outputlan
dol_syslog("Company.lib::getState", LOG_DEBUG); dol_syslog("Company.lib::getState", LOG_DEBUG);
$resql = $dbtouse->query($sql); $resql = $dbtouse->query($sql);
if ($resql) if ($resql) {
{
$obj = $dbtouse->fetch_object($resql); $obj = $dbtouse->fetch_object($resql);
if ($obj) if ($obj) {
{
$label = ((!empty($obj->name) && $obj->name != '-') ? $obj->name : ''); $label = ((!empty($obj->name) && $obj->name != '-') ? $obj->name : '');
if (is_object($outputlangs)) if (is_object($outputlangs)) {
{
$outputlangs->load("dict"); $outputlangs->load("dict");
if ($entconv) $label = ($obj->code && ($outputlangs->trans("State".$obj->code) != "State".$obj->code)) ? $outputlangs->trans("State".$obj->code) : $label; if ($entconv) $label = ($obj->code && ($outputlangs->trans("State".$obj->code) != "State".$obj->code)) ? $outputlangs->trans("State".$obj->code) : $label;
else $label = ($obj->code && ($outputlangs->transnoentitiesnoconv("State".$obj->code) != "State".$obj->code)) ? $outputlangs->transnoentitiesnoconv("State".$obj->code) : $label; else $label = ($obj->code && ($outputlangs->transnoentitiesnoconv("State".$obj->code) != "State".$obj->code)) ? $outputlangs->transnoentitiesnoconv("State".$obj->code) : $label;
@ -567,8 +534,7 @@ function currency_name($code_iso, $withcode = '', $outputlangs = null)
$outputlangs->load("dict"); $outputlangs->load("dict");
// If there is a translation, we can send immediatly the label // If there is a translation, we can send immediatly the label
if ($outputlangs->trans("Currency".$code_iso) != "Currency".$code_iso) if ($outputlangs->trans("Currency".$code_iso) != "Currency".$code_iso) {
{
return ($withcode ? $code_iso.' - ' : '').$outputlangs->trans("Currency".$code_iso); return ($withcode ? $code_iso.' - ' : '').$outputlangs->trans("Currency".$code_iso);
} }
@ -577,12 +543,10 @@ function currency_name($code_iso, $withcode = '', $outputlangs = null)
$sql .= " WHERE code_iso='".$db->escape($code_iso)."'"; $sql .= " WHERE code_iso='".$db->escape($code_iso)."'";
$resql = $db->query($sql); $resql = $db->query($sql);
if ($resql) if ($resql) {
{
$num = $db->num_rows($resql); $num = $db->num_rows($resql);
if ($num) if ($num) {
{
$obj = $db->fetch_object($resql); $obj = $db->fetch_object($resql);
$label = ($obj->label != '-' ? $obj->label : ''); $label = ($obj->label != '-' ? $obj->label : '');
if ($withcode) return ($label == $code_iso) ? "$code_iso" : "$code_iso - $label"; if ($withcode) return ($label == $code_iso) ? "$code_iso" : "$code_iso - $label";
@ -611,12 +575,10 @@ function getFormeJuridiqueLabel($code)
dol_syslog("Company.lib::getFormeJuridiqueLabel", LOG_DEBUG); dol_syslog("Company.lib::getFormeJuridiqueLabel", LOG_DEBUG);
$resql = $db->query($sql); $resql = $db->query($sql);
if ($resql) if ($resql) {
{
$num = $db->num_rows($resql); $num = $db->num_rows($resql);
if ($num) if ($num) {
{
$obj = $db->fetch_object($resql); $obj = $db->fetch_object($resql);
$label = ($obj->libelle != '-' ? $obj->libelle : ''); $label = ($obj->libelle != '-' ? $obj->libelle : '');
return $label; return $label;
@ -675,8 +637,7 @@ function getCountriesInEEC()
//'CH', // Switzerland - No. Swizerland in not in EEC //'CH', // Switzerland - No. Swizerland in not in EEC
); );
if (!empty($conf->global->MAIN_COUNTRIES_IN_EEC)) if (!empty($conf->global->MAIN_COUNTRIES_IN_EEC)) {
{
// For example MAIN_COUNTRIES_IN_EEC = 'AT,BE,BG,CY,CZ,DE,DK,EE,ES,FI,FR,GB,GR,HR,NL,HU,IE,IM,IT,LT,LU,LV,MC,MT,PL,PT,RO,SE,SK,SI,UK' // For example MAIN_COUNTRIES_IN_EEC = 'AT,BE,BG,CY,CZ,DE,DK,EE,ES,FI,FR,GB,GR,HR,NL,HU,IE,IM,IT,LT,LU,LV,MC,MT,PL,PT,RO,SE,SK,SI,UK'
$country_code_in_EEC = explode(',', $conf->global->MAIN_COUNTRIES_IN_EEC); $country_code_in_EEC = explode(',', $conf->global->MAIN_COUNTRIES_IN_EEC);
} }
@ -719,13 +680,11 @@ function show_projects($conf, $langs, $db, $object, $backtopage = '', $nocreatel
$i = -1; $i = -1;
if (!empty($conf->projet->enabled) && $user->rights->projet->lire) if (!empty($conf->projet->enabled) && $user->rights->projet->lire) {
{
$langs->load("projects"); $langs->load("projects");
$newcardbutton = ''; $newcardbutton = '';
if (!empty($conf->projet->enabled) && $user->rights->projet->creer && empty($nocreatelink)) if (!empty($conf->projet->enabled) && $user->rights->projet->creer && empty($nocreatelink)) {
{
$newcardbutton .= dolGetButtonTitle($langs->trans('AddProject'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/projet/card.php?socid='.$object->id.'&amp;action=create&amp;backtopage='.urlencode($backtopage)); $newcardbutton .= dolGetButtonTitle($langs->trans('AddProject'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/projet/card.php?socid='.$object->id.'&amp;action=create&amp;backtopage='.urlencode($backtopage));
} }
@ -743,8 +702,7 @@ function show_projects($conf, $langs, $db, $object, $backtopage = '', $nocreatel
$sql .= " ORDER BY p.dateo DESC"; $sql .= " ORDER BY p.dateo DESC";
$result = $db->query($sql); $result = $db->query($sql);
if ($result) if ($result) {
{
$num = $db->num_rows($result); $num = $db->num_rows($result);
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
@ -758,24 +716,21 @@ function show_projects($conf, $langs, $db, $object, $backtopage = '', $nocreatel
print '<td class="right">'.$langs->trans("Status").'</td>'; print '<td class="right">'.$langs->trans("Status").'</td>';
print '</tr>'; print '</tr>';
if ($num > 0) if ($num > 0) {
{
require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
$projecttmp = new Project($db); $projecttmp = new Project($db);
$i = 0; $i = 0;
while ($i < $num) while ($i < $num) {
{
$obj = $db->fetch_object($result); $obj = $db->fetch_object($result);
$projecttmp->fetch($obj->id); $projecttmp->fetch($obj->id);
// To verify role of users // To verify role of users
$userAccess = $projecttmp->restrictedProjectArea($user); $userAccess = $projecttmp->restrictedProjectArea($user);
if ($user->rights->projet->lire && $userAccess > 0) if ($user->rights->projet->lire && $userAccess > 0) {
{
print '<tr class="oddeven">'; print '<tr class="oddeven">';
// Ref // Ref
@ -791,8 +746,7 @@ function show_projects($conf, $langs, $db, $object, $backtopage = '', $nocreatel
print '<td class="center">'.dol_print_date($db->jdate($obj->de), "day").'</td>'; print '<td class="center">'.dol_print_date($db->jdate($obj->de), "day").'</td>';
// Opp amount // Opp amount
print '<td class="right">'; print '<td class="right">';
if ($obj->opp_status_code) if ($obj->opp_status_code) {
{
print price($obj->opp_amount, 1, '', 1, -1, -1, ''); print price($obj->opp_amount, 1, '', 1, -1, -1, '');
} }
print '</td>'; print '</td>';
@ -889,8 +843,7 @@ function show_contacts($conf, $langs, $db, $object, $backtopage = '')
if (!$sortorder) $sortorder = "ASC"; if (!$sortorder) $sortorder = "ASC";
if (!$sortfield) $sortfield = "t.lastname"; if (!$sortfield) $sortfield = "t.lastname";
if (!empty($conf->clicktodial->enabled)) if (!empty($conf->clicktodial->enabled)) {
{
$user->fetch_clicktodial(); // lecture des infos de clicktodial du user $user->fetch_clicktodial(); // lecture des infos de clicktodial du user
} }
@ -917,10 +870,8 @@ function show_contacts($conf, $langs, $db, $object, $backtopage = '')
't.statut'=>array('label'=>"Status", 'checked'=>1, 'position'=>50, 'class'=>'center'), 't.statut'=>array('label'=>"Status", 'checked'=>1, 'position'=>50, 'class'=>'center'),
); );
// Extra fields // Extra fields
if (is_array($extrafields->attributes[$contactstatic->table_element]['label']) && count($extrafields->attributes[$contactstatic->table_element]['label'])) if (is_array($extrafields->attributes[$contactstatic->table_element]['label']) && count($extrafields->attributes[$contactstatic->table_element]['label'])) {
{ foreach ($extrafields->attributes[$contactstatic->table_element]['label'] as $key => $val) {
foreach ($extrafields->attributes[$contactstatic->table_element]['label'] as $key => $val)
{
if (!empty($extrafields->attributes[$contactstatic->table_element]['list'][$key])) { if (!empty($extrafields->attributes[$contactstatic->table_element]['list'][$key])) {
$arrayfields["ef.".$key] = array( $arrayfields["ef.".$key] = array(
'label'=>$extrafields->attributes[$contactstatic->table_element]['label'][$key], 'label'=>$extrafields->attributes[$contactstatic->table_element]['label'][$key],
@ -933,8 +884,7 @@ function show_contacts($conf, $langs, $db, $object, $backtopage = '')
// Initialize array of search criterias // Initialize array of search criterias
$search = array(); $search = array();
foreach ($arrayfields as $key => $val) foreach ($arrayfields as $key => $val) {
{
$queryName = 'search_'.substr($key, 2); $queryName = 'search_'.substr($key, 2);
if (GETPOST($queryName, 'alpha')) { if (GETPOST($queryName, 'alpha')) {
$search[substr($key, 2)] = GETPOST($queryName, 'alpha'); $search[substr($key, 2)] = GETPOST($queryName, 'alpha');
@ -943,8 +893,7 @@ function show_contacts($conf, $langs, $db, $object, $backtopage = '')
$search_array_options = $extrafields->getOptionalsFromPost($contactstatic->table_element, '', 'search_'); $search_array_options = $extrafields->getOptionalsFromPost($contactstatic->table_element, '', 'search_');
// Purge search criteria // 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 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_status = ''; $search_status = '';
$search_name = ''; $search_name = '';
$search_roles = array(); $search_roles = array();
@ -953,8 +902,7 @@ function show_contacts($conf, $langs, $db, $object, $backtopage = '')
$search = array(); $search = array();
$search_array_options = array(); $search_array_options = array();
foreach ($contactstatic->fields as $key => $val) foreach ($contactstatic->fields as $key => $val) {
{
$search[$key] = ''; $search[$key] = '';
} }
} }
@ -963,8 +911,7 @@ function show_contacts($conf, $langs, $db, $object, $backtopage = '')
$arrayfields = dol_sort_array($arrayfields, 'position'); $arrayfields = dol_sort_array($arrayfields, 'position');
$newcardbutton = ''; $newcardbutton = '';
if ($user->rights->societe->contact->creer) if ($user->rights->societe->contact->creer) {
{
$addcontact = (!empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) ? $langs->trans("AddContact") : $langs->trans("AddContactAddress")); $addcontact = (!empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) ? $langs->trans("AddContact") : $langs->trans("AddContactAddress"));
$newcardbutton .= dolGetButtonTitle($addcontact, '', 'fa fa-plus-circle', DOL_URL_ROOT.'/contact/card.php?socid='.$object->id.'&amp;action=create&amp;backtopage='.urlencode($backtopage)); $newcardbutton .= dolGetButtonTitle($addcontact, '', 'fa fa-plus-circle', DOL_URL_ROOT.'/contact/card.php?socid='.$object->id.'&amp;action=create&amp;backtopage='.urlencode($backtopage));
} }
@ -1030,14 +977,12 @@ function show_contacts($conf, $langs, $db, $object, $backtopage = '')
// Fields title search // Fields title search
// -------------------------------------------------------------------- // --------------------------------------------------------------------
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
foreach ($contactstatic->fields as $key => $val) foreach ($contactstatic->fields as $key => $val) {
{
$align = ''; $align = '';
if (in_array($val['type'], array('date', 'datetime', 'timestamp'))) $align .= ($align ? ' ' : '').'center'; if (in_array($val['type'], array('date', 'datetime', 'timestamp'))) $align .= ($align ? ' ' : '').'center';
if (in_array($val['type'], array('timestamp'))) $align .= ($align ? ' ' : '').'nowrap'; if (in_array($val['type'], array('timestamp'))) $align .= ($align ? ' ' : '').'nowrap';
if ($key == 'status' || $key == 'statut') $align .= ($align ? ' ' : '').'center'; if ($key == 'status' || $key == 'statut') $align .= ($align ? ' ' : '').'center';
if (!empty($arrayfields['t.'.$key]['checked']) || !empty($arrayfields['sc.'.$key]['checked'])) if (!empty($arrayfields['t.'.$key]['checked']) || !empty($arrayfields['sc.'.$key]['checked'])) {
{
print '<td class="liste_titre'.($align ? ' '.$align : '').'">'; print '<td class="liste_titre'.($align ? ' '.$align : '').'">';
if (in_array($key, array('statut'))) { if (in_array($key, array('statut'))) {
print $form->selectarray('search_status', array('-1'=>'', '0'=>$contactstatic->LibStatut(0, 1), '1'=>$contactstatic->LibStatut(1, 1)), $search_status); print $form->selectarray('search_status', array('-1'=>'', '0'=>$contactstatic->LibStatut(0, 1), '1'=>$contactstatic->LibStatut(1, 1)), $search_status);
@ -1067,8 +1012,7 @@ function show_contacts($conf, $langs, $db, $object, $backtopage = '')
// Fields title label // Fields title label
// -------------------------------------------------------------------- // --------------------------------------------------------------------
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
foreach ($contactstatic->fields as $key => $val) foreach ($contactstatic->fields as $key => $val) {
{
$align = ''; $align = '';
if (in_array($val['type'], array('date', 'datetime', 'timestamp'))) $align .= ($align ? ' ' : '').'center'; if (in_array($val['type'], array('date', 'datetime', 'timestamp'))) $align .= ($align ? ' ' : '').'center';
if (in_array($val['type'], array('timestamp'))) $align .= ($align ? ' ' : '').'nowrap'; if (in_array($val['type'], array('timestamp'))) $align .= ($align ? ' ' : '').'nowrap';
@ -1091,12 +1035,10 @@ function show_contacts($conf, $langs, $db, $object, $backtopage = '')
$i = -1; $i = -1;
if ($num || (GETPOST('button_search') || GETPOST('button_search.x') || GETPOST('button_search_x'))) if ($num || (GETPOST('button_search') || GETPOST('button_search.x') || GETPOST('button_search_x'))) {
{
$i = 0; $i = 0;
while ($i < $num) while ($i < $num) {
{
$obj = $db->fetch_object($result); $obj = $db->fetch_object($result);
$contactstatic->id = $obj->rowid; $contactstatic->id = $obj->rowid;
@ -1129,10 +1071,8 @@ function show_contacts($conf, $langs, $db, $object, $backtopage = '')
setEventMessages(null, $contactstatic->errors, 'errors'); setEventMessages(null, $contactstatic->errors, 'errors');
} }
if (is_array($contactstatic->array_options)) if (is_array($contactstatic->array_options)) {
{ foreach ($contactstatic->array_options as $key => $val) {
foreach ($contactstatic->array_options as $key => $val)
{
$obj->$key = $val; $obj->$key = $val;
} }
} }
@ -1140,16 +1080,14 @@ function show_contacts($conf, $langs, $db, $object, $backtopage = '')
print '<tr class="oddeven">'; print '<tr class="oddeven">';
// ID // ID
if (!empty($arrayfields['t.rowid']['checked'])) if (!empty($arrayfields['t.rowid']['checked'])) {
{
print '<td>'; print '<td>';
print $contactstatic->id; print $contactstatic->id;
print '</td>'; print '</td>';
} }
// Photo - Name // Photo - Name
if (!empty($arrayfields['t.name']['checked'])) if (!empty($arrayfields['t.name']['checked'])) {
{
print '<td>'; print '<td>';
print $form->showphoto('contact', $contactstatic, 0, 0, 0, 'photorefnoborder valignmiddle marginrightonly', 'small', 1, 0, 1); print $form->showphoto('contact', $contactstatic, 0, 0, 0, 'photorefnoborder valignmiddle marginrightonly', 'small', 1, 0, 1);
print $contactstatic->getNomUrl(0, '', 0, '&backtopage='.urlencode($backtopage)); print $contactstatic->getNomUrl(0, '', 0, '&backtopage='.urlencode($backtopage));
@ -1157,32 +1095,28 @@ function show_contacts($conf, $langs, $db, $object, $backtopage = '')
} }
// Job position // Job position
if (!empty($arrayfields['t.poste']['checked'])) if (!empty($arrayfields['t.poste']['checked'])) {
{
print '<td>'; print '<td>';
if ($obj->poste) print $obj->poste; if ($obj->poste) print $obj->poste;
print '</td>'; print '</td>';
} }
// Address - Phone - Email // Address - Phone - Email
if (!empty($arrayfields['t.address']['checked'])) if (!empty($arrayfields['t.address']['checked'])) {
{
print '<td>'; print '<td>';
print $contactstatic->getBannerAddress('contact', $object); print $contactstatic->getBannerAddress('contact', $object);
print '</td>'; print '</td>';
} }
// Role // Role
if (!empty($arrayfields['sc.role']['checked'])) if (!empty($arrayfields['sc.role']['checked'])) {
{
print '<td>'; print '<td>';
print $formcompany->showRoles("roles", $contactstatic, 'view'); print $formcompany->showRoles("roles", $contactstatic, 'view');
print '</td>'; print '</td>';
} }
// Status // Status
if (!empty($arrayfields['t.statut']['checked'])) if (!empty($arrayfields['t.statut']['checked'])) {
{
print '<td class="center">'.$contactstatic->getLibStatut(5).'</td>'; print '<td class="center">'.$contactstatic->getLibStatut(5).'</td>';
} }
@ -1194,16 +1128,14 @@ function show_contacts($conf, $langs, $db, $object, $backtopage = '')
print '<td align="right">'; print '<td align="right">';
// Add to agenda // Add to agenda
if (!empty($conf->agenda->enabled) && $user->rights->agenda->myactions->create) if (!empty($conf->agenda->enabled) && $user->rights->agenda->myactions->create) {
{
print '<a href="'.DOL_URL_ROOT.'/comm/action/card.php?action=create&actioncode=&contactid='.$obj->rowid.'&socid='.$object->id.'&backtopage='.urlencode($backtopage).'">'; print '<a href="'.DOL_URL_ROOT.'/comm/action/card.php?action=create&actioncode=&contactid='.$obj->rowid.'&socid='.$object->id.'&backtopage='.urlencode($backtopage).'">';
print img_object($langs->trans("Event"), "action"); print img_object($langs->trans("Event"), "action");
print '</a> &nbsp; '; print '</a> &nbsp; ';
} }
// Edit // Edit
if ($user->rights->societe->contact->creer) if ($user->rights->societe->contact->creer) {
{
print '<a class="editfielda paddingleft" href="'.DOL_URL_ROOT.'/contact/card.php?action=edit&id='.$obj->rowid.'&backtopage='.urlencode($backtopage).'">'; print '<a class="editfielda paddingleft" href="'.DOL_URL_ROOT.'/contact/card.php?action=edit&id='.$obj->rowid.'&backtopage='.urlencode($backtopage).'">';
print img_edit(); print img_edit();
print '</a>'; print '</a>';
@ -1288,8 +1220,7 @@ function show_actions_done($conf, $langs, $db, $filterobj, $objcon = '', $noprin
$search_end = $end_year.'-'.$end_month.'-'.$end_day.' 23:59:59'; $search_end = $end_year.'-'.$end_month.'-'.$end_day.' 23:59:59';
$tms_end = strtotime($search_end); $tms_end = strtotime($search_end);
} }
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 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_start = ''; $search_start = '';
$tms_start = ''; $tms_start = '';
$search_end = ''; $search_end = '';
@ -1316,8 +1247,7 @@ function show_actions_done($conf, $langs, $db, $filterobj, $objcon = '', $noprin
$sql = ''; $sql = '';
if (!empty($conf->agenda->enabled)) if (!empty($conf->agenda->enabled)) {
{
// Recherche histo sur actioncomm // Recherche histo sur actioncomm
if (is_object($objcon) && $objcon->id > 0) { if (is_object($objcon) && $objcon->id > 0) {
$sql = "SELECT DISTINCT a.id, a.label as label,"; $sql = "SELECT DISTINCT a.id, a.label as label,";
@ -1370,32 +1300,25 @@ function show_actions_done($conf, $langs, $db, $filterobj, $objcon = '', $noprin
if (is_object($filterobj) && in_array(get_class($filterobj), array('Societe', 'Client', 'Fournisseur')) && $filterobj->id) $sql .= " AND a.fk_soc = ".$filterobj->id; if (is_object($filterobj) && in_array(get_class($filterobj), array('Societe', 'Client', 'Fournisseur')) && $filterobj->id) $sql .= " AND a.fk_soc = ".$filterobj->id;
elseif (is_object($filterobj) && get_class($filterobj) == 'Dolresource') { /* Nothing */ } elseif (is_object($filterobj) && get_class($filterobj) == 'Dolresource') { /* Nothing */ }
elseif (is_object($filterobj) && get_class($filterobj) == 'Project' && $filterobj->id) $sql .= " AND a.fk_project = ".$filterobj->id; elseif (is_object($filterobj) && get_class($filterobj) == 'Project' && $filterobj->id) $sql .= " AND a.fk_project = ".$filterobj->id;
elseif (is_object($filterobj) && get_class($filterobj) == 'Adherent') elseif (is_object($filterobj) && get_class($filterobj) == 'Adherent') {
{
$sql .= " AND a.fk_element = m.rowid AND a.elementtype = 'member'"; $sql .= " AND a.fk_element = m.rowid AND a.elementtype = 'member'";
if ($filterobj->id) $sql .= " AND a.fk_element = ".$filterobj->id; if ($filterobj->id) $sql .= " AND a.fk_element = ".$filterobj->id;
} elseif (is_object($filterobj) && get_class($filterobj) == 'CommandeFournisseur') } elseif (is_object($filterobj) && get_class($filterobj) == 'CommandeFournisseur') {
{
$sql .= " AND a.fk_element = o.rowid AND a.elementtype = 'order_supplier'"; $sql .= " AND a.fk_element = o.rowid AND a.elementtype = 'order_supplier'";
if ($filterobj->id) $sql .= " AND a.fk_element = ".$filterobj->id; if ($filterobj->id) $sql .= " AND a.fk_element = ".$filterobj->id;
} elseif (is_object($filterobj) && get_class($filterobj) == 'Product') } elseif (is_object($filterobj) && get_class($filterobj) == 'Product') {
{
$sql .= " AND a.fk_element = o.rowid AND a.elementtype = 'product'"; $sql .= " AND a.fk_element = o.rowid AND a.elementtype = 'product'";
if ($filterobj->id) $sql .= " AND a.fk_element = ".$filterobj->id; if ($filterobj->id) $sql .= " AND a.fk_element = ".$filterobj->id;
} elseif (is_object($filterobj) && get_class($filterobj) == 'Ticket') } elseif (is_object($filterobj) && get_class($filterobj) == 'Ticket') {
{
$sql .= " AND a.fk_element = o.rowid AND a.elementtype = 'ticket'"; $sql .= " AND a.fk_element = o.rowid AND a.elementtype = 'ticket'";
if ($filterobj->id) $sql .= " AND a.fk_element = ".$filterobj->id; if ($filterobj->id) $sql .= " AND a.fk_element = ".$filterobj->id;
} elseif (is_object($filterobj) && get_class($filterobj) == 'BOM') } elseif (is_object($filterobj) && get_class($filterobj) == 'BOM') {
{
$sql .= " AND a.fk_element = o.rowid AND a.elementtype = 'bom'"; $sql .= " AND a.fk_element = o.rowid AND a.elementtype = 'bom'";
if ($filterobj->id) $sql .= " AND a.fk_element = ".$filterobj->id; if ($filterobj->id) $sql .= " AND a.fk_element = ".$filterobj->id;
} elseif (is_object($filterobj) && get_class($filterobj) == 'Contrat') } elseif (is_object($filterobj) && get_class($filterobj) == 'Contrat') {
{
$sql .= " AND a.fk_element = o.rowid AND a.elementtype = 'contract'"; $sql .= " AND a.fk_element = o.rowid AND a.elementtype = 'contract'";
if ($filterobj->id) $sql .= " AND a.fk_element = ".$filterobj->id; if ($filterobj->id) $sql .= " AND a.fk_element = ".$filterobj->id;
} elseif (is_object($filterobj) && is_array($filterobj->fields) && is_array($filterobj->fields['rowid']) && is_array($filterobj->fields['ref']) && $filterobj->table_element && $filterobj->element) } elseif (is_object($filterobj) && is_array($filterobj->fields) && is_array($filterobj->fields['rowid']) && is_array($filterobj->fields['ref']) && $filterobj->table_element && $filterobj->element) {
{
// Generic case // Generic case
$sql .= " AND a.fk_element = o.rowid AND a.elementtype = '".$db->escape($filterobj->element).($module ? '@'.$module : '')."'"; $sql .= " AND a.fk_element = o.rowid AND a.elementtype = '".$db->escape($filterobj->element).($module ? '@'.$module : '')."'";
if ($filterobj->id) $sql .= " AND a.fk_element = ".$filterobj->id; if ($filterobj->id) $sql .= " AND a.fk_element = ".$filterobj->id;
@ -1445,18 +1368,15 @@ function show_actions_done($conf, $langs, $db, $filterobj, $objcon = '', $noprin
} }
//TODO Add limit in nb of results //TODO Add limit in nb of results
if ($sql) if ($sql) {
{
$sql .= $db->order($sortfield_new, $sortorder); $sql .= $db->order($sortfield_new, $sortorder);
dol_syslog("company.lib::show_actions_done", LOG_DEBUG); dol_syslog("company.lib::show_actions_done", LOG_DEBUG);
$resql = $db->query($sql); $resql = $db->query($sql);
if ($resql) if ($resql) {
{
$i = 0; $i = 0;
$num = $db->num_rows($resql); $num = $db->num_rows($resql);
while ($i < $num) while ($i < $num) {
{
$obj = $db->fetch_object($resql); $obj = $db->fetch_object($resql);
if ($obj->type == 'action') { if ($obj->type == 'action') {
@ -1527,8 +1447,7 @@ function show_actions_done($conf, $langs, $db, $filterobj, $objcon = '', $noprin
} }
} }
if (!empty($conf->agenda->enabled) || (!empty($conf->mailing->enabled) && !empty($objcon->email))) if (!empty($conf->agenda->enabled) || (!empty($conf->mailing->enabled) && !empty($objcon->email))) {
{
$delay_warning = $conf->global->MAIN_DELAY_ACTIONS_TODO * 24 * 60 * 60; $delay_warning = $conf->global->MAIN_DELAY_ACTIONS_TODO * 24 * 60 * 60;
require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php'; require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php';
@ -1540,13 +1459,14 @@ function show_actions_done($conf, $langs, $db, $filterobj, $objcon = '', $noprin
$actionstatic = new ActionComm($db); $actionstatic = new ActionComm($db);
$userstatic = new User($db); $userstatic = new User($db);
$userlinkcache = array();
$contactstatic = new Contact($db); $contactstatic = new Contact($db);
$elementlinkcache = array();
$out .= '<form name="listactionsfilter" class="listactionsfilter" action="'.$_SERVER["PHP_SELF"].'" method="POST">'; $out .= '<form name="listactionsfilter" class="listactionsfilter" action="'.$_SERVER["PHP_SELF"].'" method="POST">';
$out .= '<input type="hidden" name="token" value="'.newToken().'">'; $out .= '<input type="hidden" name="token" value="'.newToken().'">';
if ($objcon && get_class($objcon) == 'Contact' && if ($objcon && get_class($objcon) == 'Contact' &&
(is_null($filterobj) || get_class($filterobj) == 'Societe')) (is_null($filterobj) || get_class($filterobj) == 'Societe')) {
{
$out .= '<input type="hidden" name="id" value="'.$objcon->id.'" />'; $out .= '<input type="hidden" name="id" value="'.$objcon->id.'" />';
} else { } else {
$out .= '<input type="hidden" name="id" value="'.$filterobj->id.'" />'; $out .= '<input type="hidden" name="id" value="'.$filterobj->id.'" />';
@ -1559,8 +1479,7 @@ function show_actions_done($conf, $langs, $db, $filterobj, $objcon = '', $noprin
$out .= '<table class="noborder centpercent">'; $out .= '<table class="noborder centpercent">';
$out .= '<tr class="liste_titre">'; $out .= '<tr class="liste_titre">';
if ($donetodo) if ($donetodo) {
{
$out .= '<td class="liste_titre"></td>'; $out .= '<td class="liste_titre"></td>';
} }
$out .= '<td class="liste_titre"></td>'; $out .= '<td class="liste_titre"></td>';
@ -1581,8 +1500,7 @@ function show_actions_done($conf, $langs, $db, $filterobj, $objcon = '', $noprin
$out .= '</tr>'; $out .= '</tr>';
$out .= '<tr class="liste_titre">'; $out .= '<tr class="liste_titre">';
if ($donetodo) if ($donetodo) {
{
$tmp = ''; $tmp = '';
if (get_class($filterobj) == 'Societe') $tmp .= '<a href="'.DOL_URL_ROOT.'/comm/action/list.php?action=show_list&socid='.$filterobj->id.'&status=done">'; if (get_class($filterobj) == 'Societe') $tmp .= '<a href="'.DOL_URL_ROOT.'/comm/action/list.php?action=show_list&socid='.$filterobj->id.'&status=done">';
$tmp .= ($donetodo != 'done' ? $langs->trans("ActionsToDoShort") : ''); $tmp .= ($donetodo != 'done' ? $langs->trans("ActionsToDoShort") : '');
@ -1607,8 +1525,7 @@ function show_actions_done($conf, $langs, $db, $filterobj, $objcon = '', $noprin
$caction = new CActionComm($db); $caction = new CActionComm($db);
$arraylist = $caction->liste_array(1, 'code', '', (empty($conf->global->AGENDA_USE_EVENT_TYPE) ? 1 : 0), '', 1); $arraylist = $caction->liste_array(1, 'code', '', (empty($conf->global->AGENDA_USE_EVENT_TYPE) ? 1 : 0), '', 1);
foreach ($histo as $key => $value) foreach ($histo as $key => $value) {
{
$actionstatic->fetch($histo[$key]['id']); // TODO Do we need this, we already have a lot of data of line into $histo $actionstatic->fetch($histo[$key]['id']); // TODO Do we need this, we already have a lot of data of line into $histo
$actionstatic->type_picto = $histo[$key]['apicto']; $actionstatic->type_picto = $histo[$key]['apicto'];
@ -1617,8 +1534,7 @@ function show_actions_done($conf, $langs, $db, $filterobj, $objcon = '', $noprin
$out .= '<tr class="oddeven">'; $out .= '<tr class="oddeven">';
// Done or todo // Done or todo
if ($donetodo) if ($donetodo) {
{
$out .= '<td class="nowrap">'; $out .= '<td class="nowrap">';
$out .= '</td>'; $out .= '</td>';
} }
@ -1639,19 +1555,23 @@ function show_actions_done($conf, $langs, $db, $filterobj, $objcon = '', $noprin
//$userstatic->id=$histo[$key]['userid']; //$userstatic->id=$histo[$key]['userid'];
//$userstatic->login=$histo[$key]['login']; //$userstatic->login=$histo[$key]['login'];
//$out.=$userstatic->getLoginUrl(1); //$out.=$userstatic->getLoginUrl(1);
if ($histo[$key]['userid'] > 0) if ($histo[$key]['userid'] > 0) {
{ if (isset($userlinkcache[$histo[$key]['userid']])) {
$userstatic->fetch($histo[$key]['userid']); // TODO Introduce a cache on users fetched $link = $userlinkcache[$histo[$key]['userid']];
$out .= $userstatic->getNomUrl(-1, '', 0, 0, 16, 0, 'firstelselast', ''); } else {
} $userstatic->fetch($histo[$key]['userid']);
$link = $userstatic->getNomUrl(-1, '', 0, 0, 16, 0, 'firstelselast', '');
$userlinkcache[$histo[$key]['userid']] = $link;
}
$out .= $link;
}
$out .= '</td>'; $out .= '</td>';
// Type // Type
$out .= '<td>'; $out .= '<td>';
// TODO Code common with code into showactions // TODO Code common with code into showactions
$imgpicto = ''; $imgpicto = '';
if (!empty($conf->global->AGENDA_USE_EVENT_TYPE)) if (!empty($conf->global->AGENDA_USE_EVENT_TYPE)) {
{
if ($actionstatic->type_picto) { if ($actionstatic->type_picto) {
$imgpicto .= img_picto('', $actionstatic->type_picto); $imgpicto .= img_picto('', $actionstatic->type_picto);
} }
@ -1679,8 +1599,7 @@ function show_actions_done($conf, $langs, $db, $filterobj, $objcon = '', $noprin
// Title // Title
$out .= '<td>'; $out .= '<td>';
if (isset($histo[$key]['type']) && $histo[$key]['type'] == 'action') if (isset($histo[$key]['type']) && $histo[$key]['type'] == 'action') {
{
$transcode = $langs->trans("Action".$histo[$key]['acode']); $transcode = $langs->trans("Action".$histo[$key]['acode']);
$libelle = ($transcode != "Action".$histo[$key]['acode'] ? $transcode : $histo[$key]['alabel']); $libelle = ($transcode != "Action".$histo[$key]['acode'] ? $transcode : $histo[$key]['alabel']);
//$actionstatic->libelle=$libelle; //$actionstatic->libelle=$libelle;
@ -1688,8 +1607,7 @@ function show_actions_done($conf, $langs, $db, $filterobj, $objcon = '', $noprin
$actionstatic->id = $histo[$key]['id']; $actionstatic->id = $histo[$key]['id'];
$out .= dol_trunc($libelle, 120); $out .= dol_trunc($libelle, 120);
} }
if (isset($histo[$key]['type']) && $histo[$key]['type'] == 'mailing') if (isset($histo[$key]['type']) && $histo[$key]['type'] == 'mailing') {
{
$out .= '<a href="'.DOL_URL_ROOT.'/comm/mailing/card.php?id='.$histo[$key]['id'].'">'.img_object($langs->trans("ShowEMailing"), "email").' '; $out .= '<a href="'.DOL_URL_ROOT.'/comm/mailing/card.php?id='.$histo[$key]['id'].'">'.img_object($langs->trans("ShowEMailing"), "email").' ';
$transcode = $langs->trans("Action".$histo[$key]['acode']); $transcode = $langs->trans("Action".$histo[$key]['acode']);
$libelle = ($transcode != "Action".$histo[$key]['acode'] ? $transcode : 'Send mass mailing'); $libelle = ($transcode != "Action".$histo[$key]['acode'] ? $transcode : 'Send mass mailing');
@ -1700,8 +1618,7 @@ function show_actions_done($conf, $langs, $db, $filterobj, $objcon = '', $noprin
// Date // Date
$out .= '<td class="center nowrap">'; $out .= '<td class="center nowrap">';
$out .= dol_print_date($histo[$key]['datestart'], 'dayhour', 'tzuserrel'); $out .= dol_print_date($histo[$key]['datestart'], 'dayhour', 'tzuserrel');
if ($histo[$key]['dateend'] && $histo[$key]['dateend'] != $histo[$key]['datestart']) if ($histo[$key]['dateend'] && $histo[$key]['dateend'] != $histo[$key]['datestart']) {
{
$tmpa = dol_getdate($histo[$key]['datestart'], true); $tmpa = dol_getdate($histo[$key]['datestart'], true);
$tmpb = dol_getdate($histo[$key]['dateend'], true); $tmpb = dol_getdate($histo[$key]['dateend'], true);
if ($tmpa['mday'] == $tmpb['mday'] && $tmpa['mon'] == $tmpb['mon'] && $tmpa['year'] == $tmpb['year']) $out .= '-'.dol_print_date($histo[$key]['dateend'], 'hour', 'tzuserrel'); if ($tmpa['mday'] == $tmpb['mday'] && $tmpa['mon'] == $tmpb['mon'] && $tmpa['year'] == $tmpb['year']) $out .= '-'.dol_print_date($histo[$key]['dateend'], 'hour', 'tzuserrel');
@ -1720,15 +1637,24 @@ function show_actions_done($conf, $langs, $db, $filterobj, $objcon = '', $noprin
// Linked object // Linked object
$out .= '<td class="nowraponall">'; $out .= '<td class="nowraponall">';
if (isset($histo[$key]['elementtype']) && !empty($histo[$key]['fk_element'])) if (isset($histo[$key]['elementtype']) && !empty($histo[$key]['fk_element'])) {
{ if (isset($elementlinkcache[$histo[$key]['elementtype']]) && isset($elementlinkcache[$histo[$key]['elementtype']][$histo[$key]['fk_element']])) {
$out .= dolGetElementUrl($histo[$key]['fk_element'], $histo[$key]['elementtype'], 1); $link = $elementlinkcache[$histo[$key]['elementtype']][$histo[$key]['fk_element']];
} else $out .= '&nbsp;'; } else {
if (!isset($elementlinkcache[$histo[$key]['elementtype']])) {
$elementlinkcache[$histo[$key]['elementtype']] = array();
}
$link = dolGetElementUrl($histo[$key]['fk_element'], $histo[$key]['elementtype'], 1);
$elementlinkcache[$histo[$key]['elementtype']][$histo[$key]['fk_element']] = $link;
}
$out .= $link;
} else {
$out .= '&nbsp;';
}
$out .= '</td>'; $out .= '</td>';
// Contact(s) for action // Contact(s) for action
if (empty($objcon->id) && isset($histo[$key]['contact_id']) && $histo[$key]['contact_id'] > 0) if (empty($objcon->id) && isset($histo[$key]['contact_id']) && $histo[$key]['contact_id'] > 0) {
{
$contactstatic->lastname = $histo[$key]['lastname']; $contactstatic->lastname = $histo[$key]['lastname'];
$contactstatic->firstname = $histo[$key]['firstname']; $contactstatic->firstname = $histo[$key]['firstname'];
$contactstatic->id = $histo[$key]['contact_id']; $contactstatic->id = $histo[$key]['contact_id'];
@ -1799,8 +1725,7 @@ function show_subsidiaries($conf, $langs, $db, $object)
$result = $db->query($sql); $result = $db->query($sql);
$num = $db->num_rows($result); $num = $db->num_rows($result);
if ($num) if ($num) {
{
$socstatic = new Societe($db); $socstatic = new Societe($db);
print load_fiche_titre($langs->trans("Subsidiaries"), '', ''); print load_fiche_titre($langs->trans("Subsidiaries"), '', '');
@ -1814,8 +1739,7 @@ function show_subsidiaries($conf, $langs, $db, $object)
$i = 0; $i = 0;
while ($i < $num) while ($i < $num) {
{
$obj = $db->fetch_object($result); $obj = $db->fetch_object($result);
$socstatic->id = $obj->rowid; $socstatic->id = $obj->rowid;
@ -1873,8 +1797,7 @@ function addEventTypeSQL(&$sql, $actioncode, $donetodo, $now, $filters, $sqlANDO
global $conf, $db; global $conf, $db;
// Condition on actioncode // Condition on actioncode
if (empty($conf->global->AGENDA_USE_EVENT_TYPE)) if (empty($conf->global->AGENDA_USE_EVENT_TYPE)) {
{
if ($actioncode == 'AC_NON_AUTO') $sql .= " $sqlANDOR c.type != 'systemauto'"; if ($actioncode == 'AC_NON_AUTO') $sql .= " $sqlANDOR c.type != 'systemauto'";
elseif ($actioncode == 'AC_ALL_AUTO') $sql .= " $sqlANDOR c.type = 'systemauto'"; elseif ($actioncode == 'AC_ALL_AUTO') $sql .= " $sqlANDOR c.type = 'systemauto'";
else { else {
@ -1896,12 +1819,12 @@ function addEventTypeSQL(&$sql, $actioncode, $donetodo, $now, $filters, $sqlANDO
} }
/** /**
* Add Mailing Event Type SQL * Add Mailing Event Type SQL
* *
* @param string $actioncode Action code * @param string $actioncode Action code
* @param string $objcon objcon * @param Object $objcon objcon
* @param Object $filterobj filterobj * @param Object $filterobj filterobj
* @return string * @return string
*/ */
function addMailingEventTypeSQL($actioncode, $objcon, $filterobj) function addMailingEventTypeSQL($actioncode, $objcon, $filterobj)
{ {

View File

@ -1086,29 +1086,69 @@ function dol_escape_htmltag($stringtoescape, $keepb = 0, $keepn = 0, $keepmoreta
} }
} }
/** /**
* Convert a string to lower. Never use strtolower because it does not works with UTF8 strings. * Convert a string to lower. Never use strtolower because it does not works with UTF8 strings.
* *
* @param string $utf8_string String to encode * @param string $string String to encode
* @param string $encoding Character set encoding
* @return string String converted * @return string String converted
*/ */
function dol_strtolower($utf8_string) function dol_strtolower($string, $encoding = "UTF-8")
{ {
return mb_strtolower($utf8_string, "UTF-8"); if (function_exists('mb_strtolower')) {
return mb_strtolower($string, $encoding);
} else {
return strtolower($string);
}
} }
/** /**
* Convert a string to upper. Never use strtolower because it does not works with UTF8 strings. * Convert a string to upper. Never use strtolower because it does not works with UTF8 strings.
* *
* @param string $utf8_string String to encode * @param string $string String to encode
* @param string $encoding Character set encoding
* @return string String converted * @return string String converted
*/ */
function dol_strtoupper($utf8_string) function dol_strtoupper($string, $encoding = "UTF-8")
{ {
return mb_strtoupper($utf8_string, "UTF-8"); if (function_exists('mb_strtoupper')) {
return mb_strtoupper($string, $encoding);
} else {
return strtoupper($string);
}
} }
/**
* Convert first character of the first word of a string to upper. Never use ucfirst because it does not works with UTF8 strings.
*
* @param string $string String to encode
* @param string $encoding Character set encodign
* @return string String converted
*/
function dol_ucfirst($string, $encoding = "UTF-8")
{
if (function_exists('mb_substr')) {
return mb_strtoupper(mb_substr($string, 0, 1, $encoding), $encoding) . mb_substr($string, 1, null, $encoding);
} else {
return ucfirst($string);
}
}
/**
* Convert first character of all the words of a string to upper. Never use ucfirst because it does not works with UTF8 strings.
*
* @param string $string String to encode
* @param string $encoding Character set encodign
* @return string String converted
*/
function dol_ucwords($string, $encoding = "UTF-8")
{
if (function_exists('mb_convert_case')) {
return mb_convert_case($string, MB_CASE_TITLE, $encoding);
} else {
return ucwords($string);
}
}
/** /**
* Write log message into outputs. Possible outputs can be: * Write log message into outputs. Possible outputs can be:

View File

@ -76,7 +76,7 @@ function getURLContent($url, $postorget = 'GET', $param = '', $followlocation =
// Restrict use to some protocols only // Restrict use to some protocols only
$protocols = 0; $protocols = 0;
if (is_array($allowedschemes)) { if (is_array($allowedschemes)) {
foreach($allowedschemes as $allowedscheme) { foreach ($allowedschemes as $allowedscheme) {
if ($allowedscheme == 'http') $protocols |= CURLPROTO_HTTP; if ($allowedscheme == 'http') $protocols |= CURLPROTO_HTTP;
if ($allowedscheme == 'https') $protocols |= CURLPROTO_HTTPS; if ($allowedscheme == 'https') $protocols |= CURLPROTO_HTTPS;
} }
@ -129,8 +129,7 @@ function getURLContent($url, $postorget = 'GET', $param = '', $followlocation =
$info = array(); $info = array();
$response = ''; $response = '';
do do {
{
if ($maxRedirection < 1) break; if ($maxRedirection < 1) break;
curl_setopt($ch, CURLOPT_URL, $newUrl); curl_setopt($ch, CURLOPT_URL, $newUrl);
@ -187,7 +186,7 @@ function getURLContent($url, $postorget = 'GET', $param = '', $followlocation =
$http_code = 0; $http_code = 0;
} }
} }
while($http_code); while ($http_code);
$request = curl_getinfo($ch, CURLINFO_HEADER_OUT); // Reading of request must be done after sending request $request = curl_getinfo($ch, CURLINFO_HEADER_OUT); // Reading of request must be done after sending request
@ -196,8 +195,7 @@ function getURLContent($url, $postorget = 'GET', $param = '', $followlocation =
dol_syslog("getURLContent response size=".strlen($response)); // This may contains binary data, so we dont output it dol_syslog("getURLContent response size=".strlen($response)); // This may contains binary data, so we dont output it
$rep = array(); $rep = array();
if (curl_errno($ch)) if (curl_errno($ch)) {
{
// Ad keys to $rep // Ad keys to $rep
$rep['content'] = $response; $rep['content'] = $response;
@ -240,14 +238,12 @@ function getDomainFromURL($url, $mode = 0)
{ {
$tmpdomain = preg_replace('/^https?:\/\//i', '', $url); // Remove http(s):// $tmpdomain = preg_replace('/^https?:\/\//i', '', $url); // Remove http(s)://
$tmpdomain = preg_replace('/\/.*$/i', '', $tmpdomain); // Remove part after domain $tmpdomain = preg_replace('/\/.*$/i', '', $tmpdomain); // Remove part after domain
if ($mode == 2) if ($mode == 2) {
{
$tmpdomain = preg_replace('/^.*\.([^\.]+)\.([^\.]+)\.([^\.]+)$/', '\1.\2.\3', $tmpdomain); // Remove part 'www.' before 'abc.mydomain.com' $tmpdomain = preg_replace('/^.*\.([^\.]+)\.([^\.]+)\.([^\.]+)$/', '\1.\2.\3', $tmpdomain); // Remove part 'www.' before 'abc.mydomain.com'
} else { } else {
$tmpdomain = preg_replace('/^.*\.([^\.]+)\.([^\.]+)$/', '\1.\2', $tmpdomain); // Remove part 'www.abc.' before 'mydomain.com' $tmpdomain = preg_replace('/^.*\.([^\.]+)\.([^\.]+)$/', '\1.\2', $tmpdomain); // Remove part 'www.abc.' before 'mydomain.com'
} }
if (empty($mode)) if (empty($mode)) {
{
$tmpdomain = preg_replace('/\.[^\.]+$/', '', $tmpdomain); // Remove first level domain (.com, .net, ...) $tmpdomain = preg_replace('/\.[^\.]+$/', '', $tmpdomain); // Remove first level domain (.com, .net, ...)
} }

View File

@ -107,7 +107,7 @@ function product_prepare_head($object)
$prodcomb = new ProductCombination($db); $prodcomb = new ProductCombination($db);
if ($prodcomb->fetchByFkProductChild($object->id) == -1) if ($prodcomb->fetchByFkProductChild($object->id) <= 0)
{ {
$head[$h][0] = DOL_URL_ROOT."/variants/combinations.php?id=".$object->id; $head[$h][0] = DOL_URL_ROOT."/variants/combinations.php?id=".$object->id;
$head[$h][1] = $langs->trans('ProductCombinations'); $head[$h][1] = $langs->trans('ProductCombinations');

View File

@ -1356,6 +1356,7 @@ class Fichinter extends CommonObject
$line->datei = $this->db->jdate($objp->date); $line->datei = $this->db->jdate($objp->date);
$line->rang = $objp->rang; $line->rang = $objp->rang;
$line->product_type = 1; $line->product_type = 1;
$line->fetch_optionals();
$this->lines[$i] = $line; $this->lines[$i] = $line;

View File

@ -3187,14 +3187,16 @@ class Product extends CommonObject
/** /**
* Return an array formated for showing graphs * Return an array formated for showing graphs
* *
* @param string $sql Request to execute * @param string $sql Request to execute
* @param string $mode 'byunit'=number of unit, 'bynumber'=nb of entities * @param string $mode 'byunit'=number of unit, 'bynumber'=nb of entities
* @param int $year Year (0=current year) * @param int $year Year (0=current year, -1=all years)
* @return array <0 if KO, result[month]=array(valuex,valuey) where month is 0 to 11 * @return array <0 if KO, result[month]=array(valuex,valuey) where month is 0 to 11
*/ */
private function _get_stats($sql, $mode, $year = 0) private function _get_stats($sql, $mode, $year = 0)
{ {
// phpcs:enable // phpcs:enable
$tab = array();
$resql = $this->db->query($sql); $resql = $this->db->query($sql);
if ($resql) { if ($resql) {
$num = $this->db->num_rows($resql); $num = $this->db->num_rows($resql);
@ -3202,12 +3204,16 @@ class Product extends CommonObject
while ($i < $num) while ($i < $num)
{ {
$arr = $this->db->fetch_array($resql); $arr = $this->db->fetch_array($resql);
if ($mode == 'byunit') { $keyfortab = (string) $arr[1];
$tab[$arr[1]] = $arr[0]; // 1st field if ($year == -1) {
} $keyfortab = substr($keyfortab, -2);
if ($mode == 'bynumber') { }
$tab[$arr[1]] = $arr[2]; // 3rd field
} if ($mode == 'byunit') {
$tab[$keyfortab] = (empty($tab[$keyfortab]) ? 0 : $tab[$keyfortab]) + $arr[0]; // 1st field
} elseif ($mode == 'bynumber') {
$tab[$keyfortab] = (empty($tab[$keyfortab]) ? 0 : $tab[$keyfortab]) + $arr[2]; // 3rd field
}
$i++; $i++;
} }
} else { } else {
@ -3215,21 +3221,26 @@ class Product extends CommonObject
return -1; return -1;
} }
if (empty($year)) { if (empty($year)) {
$year = strftime('%Y', time()); $year = strftime('%Y', time());
$month = strftime('%m', time()); $month = strftime('%m', time());
} else { } elseif ($year == -1) {
$month = 12; // We imagine we are at end of year, so we get last 12 month before, so all correct year. $year = '';
} $month = 12; // We imagine we are at end of year, so we get last 12 month before, so all correct year.
$result = array(); } else {
$month = 12; // We imagine we are at end of year, so we get last 12 month before, so all correct year.
}
for ($j = 0; $j < 12; $j++) $result = array();
{
//$idx = ucfirst(dol_trunc(dol_print_date(dol_mktime(12, 0, 0, $month, 1, $year), "%b"), 3, 'right', 'UTF-8', 1));
$idx = ucfirst(dol_trunc(dol_print_date(dol_mktime(12, 0, 0, $month, 1, $year), "%b"), 1, 'right', 'UTF-8', 1));
$result[$j] = array($idx, isset($tab[$year.$month]) ? $tab[$year.$month] : 0); for ($j = 0; $j < 12; $j++)
// $result[$j] = array($monthnum,isset($tab[$year.$month])?$tab[$year.$month]:0); {
// $ids is 'D', 'N', 'O', 'S', ... (First letter of month in user language)
$idx = ucfirst(dol_trunc(dol_print_date(dol_mktime(12, 0, 0, $month, 1, 1970), "%b"), 1, 'right', 'UTF-8', 1));
//print $idx.'-'.$year.'-'.$month.'<br>';
$result[$j] = array($idx, isset($tab[$year.$month]) ? $tab[$year.$month] : 0);
// $result[$j] = array($monthnum,isset($tab[$year.$month])?$tab[$year.$month]:0);
$month = "0".($month - 1); $month = "0".($month - 1);
if (dol_strlen($month) == 3) { if (dol_strlen($month) == 3) {
@ -3252,9 +3263,9 @@ class Product extends CommonObject
* @param int $socid Limit count on a particular third party id * @param int $socid Limit count on a particular third party id
* @param string $mode 'byunit'=number of unit, 'bynumber'=nb of entities * @param string $mode 'byunit'=number of unit, 'bynumber'=nb of entities
* @param int $filteronproducttype 0=To filter on product only, 1=To filter on services only * @param int $filteronproducttype 0=To filter on product only, 1=To filter on services only
* @param int $year Year (0=last 12 month) * @param int $year Year (0=last 12 month, -1=all years)
* @param string $morefilter More sql filters * @param string $morefilter More sql filters
* @return array <0 if KO, result[month]=array(valuex,valuey) where month is 0 to 11 * @return array <0 if KO, result[month]=array(valuex,valuey) where month is 0 to 11
*/ */
public function get_nb_vente($socid, $mode, $filteronproducttype = -1, $year = 0, $morefilter = '') public function get_nb_vente($socid, $mode, $filteronproducttype = -1, $year = 0, $morefilter = '')
{ {
@ -3305,9 +3316,9 @@ class Product extends CommonObject
* @param int $socid Limit count on a particular third party id * @param int $socid Limit count on a particular third party id
* @param string $mode 'byunit'=number of unit, 'bynumber'=nb of entities * @param string $mode 'byunit'=number of unit, 'bynumber'=nb of entities
* @param int $filteronproducttype 0=To filter on product only, 1=To filter on services only * @param int $filteronproducttype 0=To filter on product only, 1=To filter on services only
* @param int $year Year (0=last 12 month) * @param int $year Year (0=last 12 month, -1=all years)
* @param string $morefilter More sql filters * @param string $morefilter More sql filters
* @return array <0 if KO, result[month]=array(valuex,valuey) where month is 0 to 11 * @return array <0 if KO, result[month]=array(valuex,valuey) where month is 0 to 11
*/ */
public function get_nb_achat($socid, $mode, $filteronproducttype = -1, $year = 0, $morefilter = '') public function get_nb_achat($socid, $mode, $filteronproducttype = -1, $year = 0, $morefilter = '')
{ {
@ -3352,20 +3363,19 @@ class Product extends CommonObject
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/** /**
* Return nb of units in proposals in which product is included * Return nb of units in proposals in which product is included
* *
* @param int $socid Limit count on a particular third party id * @param int $socid Limit count on a particular third party id
* @param string $mode 'byunit'=number of unit, 'bynumber'=nb of entities * @param string $mode 'byunit'=number of unit, 'bynumber'=nb of entities
* @param int $filteronproducttype 0=To filter on product only, 1=To filter on services only * @param int $filteronproducttype 0=To filter on product only, 1=To filter on services only
* @param int $year Year (0=last 12 month) * @param int $year Year (0=last 12 month, -1=all years)
* @param string $morefilter More sql filters * @param string $morefilter More sql filters
* @return array <0 if KO, result[month]=array(valuex,valuey) where month is 0 to 11 * @return array <0 if KO, result[month]=array(valuex,valuey) where month is 0 to 11
*/ */
public function get_nb_propal($socid, $mode, $filteronproducttype = -1, $year = 0, $morefilter = '') public function get_nb_propal($socid, $mode, $filteronproducttype = -1, $year = 0, $morefilter = '')
{ {
// phpcs:enable // phpcs:enable
global $conf; global $conf, $user;
global $user;
$sql = "SELECT sum(d.qty), date_format(p.datep, '%Y%m')"; $sql = "SELECT sum(d.qty), date_format(p.datep, '%Y%m')";
if ($mode == 'bynumber') { if ($mode == 'bynumber') {
@ -3409,9 +3419,9 @@ class Product extends CommonObject
* @param int $socid Limit count on a particular third party id * @param int $socid Limit count on a particular third party id
* @param string $mode 'byunit'=number of unit, 'bynumber'=nb of entities * @param string $mode 'byunit'=number of unit, 'bynumber'=nb of entities
* @param int $filteronproducttype 0=To filter on product only, 1=To filter on services only * @param int $filteronproducttype 0=To filter on product only, 1=To filter on services only
* @param int $year Year (0=last 12 month) * @param int $year Year (0=last 12 month, -1=all years)
* @param string $morefilter More sql filters * @param string $morefilter More sql filters
* @return array <0 if KO, result[month]=array(valuex,valuey) where month is 0 to 11 * @return array <0 if KO, result[month]=array(valuex,valuey) where month is 0 to 11
*/ */
public function get_nb_propalsupplier($socid, $mode, $filteronproducttype = -1, $year = 0, $morefilter = '') public function get_nb_propalsupplier($socid, $mode, $filteronproducttype = -1, $year = 0, $morefilter = '')
{ {
@ -3461,9 +3471,9 @@ class Product extends CommonObject
* @param int $socid Limit count on a particular third party id * @param int $socid Limit count on a particular third party id
* @param string $mode 'byunit'=number of unit, 'bynumber'=nb of entities * @param string $mode 'byunit'=number of unit, 'bynumber'=nb of entities
* @param int $filteronproducttype 0=To filter on product only, 1=To filter on services only * @param int $filteronproducttype 0=To filter on product only, 1=To filter on services only
* @param int $year Year (0=last 12 month) * @param int $year Year (0=last 12 month, -1=all years)
* @param string $morefilter More sql filters * @param string $morefilter More sql filters
* @return array <0 if KO, result[month]=array(valuex,valuey) where month is 0 to 11 * @return array <0 if KO, result[month]=array(valuex,valuey) where month is 0 to 11
*/ */
public function get_nb_order($socid, $mode, $filteronproducttype = -1, $year = 0, $morefilter = '') public function get_nb_order($socid, $mode, $filteronproducttype = -1, $year = 0, $morefilter = '')
{ {
@ -3512,9 +3522,9 @@ class Product extends CommonObject
* @param int $socid Limit count on a particular third party id * @param int $socid Limit count on a particular third party id
* @param string $mode 'byunit'=number of unit, 'bynumber'=nb of entities * @param string $mode 'byunit'=number of unit, 'bynumber'=nb of entities
* @param int $filteronproducttype 0=To filter on product only, 1=To filter on services only * @param int $filteronproducttype 0=To filter on product only, 1=To filter on services only
* @param int $year Year (0=last 12 month) * @param int $year Year (0=last 12 month, -1=all years)
* @param string $morefilter More sql filters * @param string $morefilter More sql filters
* @return array <0 if KO, result[month]=array(valuex,valuey) where month is 0 to 11 * @return array <0 if KO, result[month]=array(valuex,valuey) where month is 0 to 11
*/ */
public function get_nb_ordersupplier($socid, $mode, $filteronproducttype = -1, $year = 0, $morefilter = '') public function get_nb_ordersupplier($socid, $mode, $filteronproducttype = -1, $year = 0, $morefilter = '')
{ {
@ -3563,9 +3573,9 @@ class Product extends CommonObject
* @param int $socid Limit count on a particular third party id * @param int $socid Limit count on a particular third party id
* @param string $mode 'byunit'=number of unit, 'bynumber'=nb of entities * @param string $mode 'byunit'=number of unit, 'bynumber'=nb of entities
* @param int $filteronproducttype 0=To filter on product only, 1=To filter on services only * @param int $filteronproducttype 0=To filter on product only, 1=To filter on services only
* @param int $year Year (0=last 12 month) * @param int $year Year (0=last 12 month, -1=all years)
* @param string $morefilter More sql filters * @param string $morefilter More sql filters
* @return array <0 if KO, result[month]=array(valuex,valuey) where month is 0 to 11 * @return array <0 if KO, result[month]=array(valuex,valuey) where month is 0 to 11
*/ */
public function get_nb_contract($socid, $mode, $filteronproducttype = -1, $year = 0, $morefilter = '') public function get_nb_contract($socid, $mode, $filteronproducttype = -1, $year = 0, $morefilter = '')
{ {
@ -3617,9 +3627,9 @@ class Product extends CommonObject
* @param int $socid Limit count on a particular third party id * @param int $socid Limit count on a particular third party id
* @param string $mode 'byunit'=number of unit, 'bynumber'=nb of entities * @param string $mode 'byunit'=number of unit, 'bynumber'=nb of entities
* @param int $filteronproducttype 0=To filter on product only, 1=To filter on services only * @param int $filteronproducttype 0=To filter on product only, 1=To filter on services only
* @param int $year Year (0=last 12 month) * @param int $year Year (0=last 12 month, -1=all years)
* @param string $morefilter More sql filters * @param string $morefilter More sql filters
* @return array <0 if KO, result[month]=array(valuex,valuey) where month is 0 to 11 * @return array <0 if KO, result[month]=array(valuex,valuey) where month is 0 to 11
*/ */
public function get_nb_mos($socid, $mode, $filteronproducttype = -1, $year = 0, $morefilter = '') public function get_nb_mos($socid, $mode, $filteronproducttype = -1, $year = 0, $morefilter = '')
{ {

View File

@ -162,6 +162,7 @@ if (empty($id) && empty($ref)) {
if ($result || empty($id)) { if ($result || empty($id)) {
print '<form name="stats" method="POST" action="'.$_SERVER["PHP_SELF"].'">'; print '<form name="stats" method="POST" action="'.$_SERVER["PHP_SELF"].'">';
print '<input type="hidden" name="token" value="'.newToken().'">';
print '<input type="hidden" name="id" value="'.$id.'">'; print '<input type="hidden" name="id" value="'.$id.'">';
print '<table class="noborder centpercent">'; print '<table class="noborder centpercent">';
@ -188,13 +189,14 @@ if ($result || empty($id)) {
// Year // Year
print '<tr><td class="titlefield">'.$langs->trans("Year").'</td><td>'; print '<tr><td class="titlefield">'.$langs->trans("Year").'</td><td>';
$arrayyears = array(); $arrayyears = array();
for ($year = $currentyear - 10; $year < $currentyear + 10; $year++) { for ($year = $currentyear - 25; $year < $currentyear; $year++)
$arrayyears[$year] = $year; {
$arrayyears[$year] = $year;
} }
if (!in_array($year, $arrayyears)) $arrayyears[$year] = $year; if (!in_array($year, $arrayyears)) $arrayyears[$year] = $year;
if (!in_array($nowyear, $arrayyears)) $arrayyears[$nowyear] = $nowyear; if (!in_array($currentyear, $arrayyears)) $arrayyears[$currentyear] = $currentyear;
arsort($arrayyears); arsort($arrayyears);
print $form->selectarray('search_year', $arrayyears, $search_year, 0); print $form->selectarray('search_year', $arrayyears, $search_year, 1);
print '</td></tr>'; print '</td></tr>';
print '</table>'; print '</table>';
print '<div class="center"><input type="submit" name="submit" class="button" value="'.$langs->trans("Refresh").'"></div>'; print '<div class="center"><input type="submit" name="submit" class="button" value="'.$langs->trans("Refresh").'"></div>';
@ -240,49 +242,49 @@ if ($result || empty($id)) {
if ($conf->propal->enabled) { if ($conf->propal->enabled) {
$graphfiles['propal'] = array('modulepart'=>'productstats_proposals', $graphfiles['propal'] = array('modulepart'=>'productstats_proposals',
'file' => $object->id.'/propal12m'.((string) $type != '' ? '_type'.$type : '').'_'.$mode.($search_year ? '_year'.$search_year : '').'.png', 'file' => $object->id.'/propal12m'.((string) $type != '' ? '_type'.$type : '').'_'.$mode.($search_year > 0 ? '_year'.$search_year : '').'.png',
'label' => ($mode == 'byunit' ? $langs->transnoentitiesnoconv("NumberOfUnitsProposals") : $langs->transnoentitiesnoconv("NumberOfProposals"))); 'label' => ($mode == 'byunit' ? $langs->transnoentitiesnoconv("NumberOfUnitsProposals") : $langs->transnoentitiesnoconv("NumberOfProposals")));
} }
if ($conf->supplier_proposal->enabled) { if ($conf->supplier_proposal->enabled) {
$graphfiles['proposalssuppliers'] = array('modulepart'=>'productstats_proposalssuppliers', $graphfiles['proposalssuppliers'] = array('modulepart'=>'productstats_proposalssuppliers',
'file' => $object->id.'/proposalssuppliers12m'.((string) $type != '' ? '_type'.$type : '').'_'.$mode.($search_year ? '_year'.$search_year : '').'.png', 'file' => $object->id.'/proposalssuppliers12m'.((string) $type != '' ? '_type'.$type : '').'_'.$mode.($search_year > 0 ? '_year'.$search_year : '').'.png',
'label' => ($mode == 'byunit' ? $langs->transnoentitiesnoconv("NumberOfUnitsSupplierProposals") : $langs->transnoentitiesnoconv("NumberOfSupplierProposals"))); 'label' => ($mode == 'byunit' ? $langs->transnoentitiesnoconv("NumberOfUnitsSupplierProposals") : $langs->transnoentitiesnoconv("NumberOfSupplierProposals")));
} }
if ($conf->order->enabled) { if ($conf->order->enabled) {
$graphfiles['orders'] = array('modulepart'=>'productstats_orders', $graphfiles['orders'] = array('modulepart'=>'productstats_orders',
'file' => $object->id.'/orders12m'.((string) $type != '' ? '_type'.$type : '').'_'.$mode.($search_year ? '_year'.$search_year : '').'.png', 'file' => $object->id.'/orders12m'.((string) $type != '' ? '_type'.$type : '').'_'.$mode.($search_year > 0 ? '_year'.$search_year : '').'.png',
'label' => ($mode == 'byunit' ? $langs->transnoentitiesnoconv("NumberOfUnitsCustomerOrders") : $langs->transnoentitiesnoconv("NumberOfCustomerOrders"))); 'label' => ($mode == 'byunit' ? $langs->transnoentitiesnoconv("NumberOfUnitsCustomerOrders") : $langs->transnoentitiesnoconv("NumberOfCustomerOrders")));
} }
if ($conf->supplier_order->enabled) { if ($conf->supplier_order->enabled) {
$graphfiles['orderssuppliers'] = array('modulepart'=>'productstats_orderssuppliers', $graphfiles['orderssuppliers'] = array('modulepart'=>'productstats_orderssuppliers',
'file' => $object->id.'/orderssuppliers12m'.((string) $type != '' ? '_type'.$type : '').'_'.$mode.($search_year ? '_year'.$search_year : '').'.png', 'file' => $object->id.'/orderssuppliers12m'.((string) $type != '' ? '_type'.$type : '').'_'.$mode.($search_year > 0 ? '_year'.$search_year : '').'.png',
'label' => ($mode == 'byunit' ? $langs->transnoentitiesnoconv("NumberOfUnitsSupplierOrders") : $langs->transnoentitiesnoconv("NumberOfSupplierOrders"))); 'label' => ($mode == 'byunit' ? $langs->transnoentitiesnoconv("NumberOfUnitsSupplierOrders") : $langs->transnoentitiesnoconv("NumberOfSupplierOrders")));
} }
if ($conf->facture->enabled) { if ($conf->facture->enabled) {
$graphfiles['invoices'] = array('modulepart'=>'productstats_invoices', $graphfiles['invoices'] = array('modulepart'=>'productstats_invoices',
'file' => $object->id.'/invoices12m'.((string) $type != '' ? '_type'.$type : '').'_'.$mode.($search_year ? '_year'.$search_year : '').'.png', 'file' => $object->id.'/invoices12m'.((string) $type != '' ? '_type'.$type : '').'_'.$mode.($search_year > 0 ? '_year'.$search_year : '').'.png',
'label' => ($mode == 'byunit' ? $langs->transnoentitiesnoconv("NumberOfUnitsCustomerInvoices") : $langs->transnoentitiesnoconv("NumberOfCustomerInvoices"))); 'label' => ($mode == 'byunit' ? $langs->transnoentitiesnoconv("NumberOfUnitsCustomerInvoices") : $langs->transnoentitiesnoconv("NumberOfCustomerInvoices")));
} }
if ($conf->supplier_invoice->enabled) { if ($conf->supplier_invoice->enabled) {
$graphfiles['invoicessuppliers'] = array('modulepart'=>'productstats_invoicessuppliers', $graphfiles['invoicessuppliers'] = array('modulepart'=>'productstats_invoicessuppliers',
'file' => $object->id.'/invoicessuppliers12m'.((string) $type != '' ? '_type'.$type : '').'_'.$mode.($search_year ? '_year'.$search_year : '').'.png', 'file' => $object->id.'/invoicessuppliers12m'.((string) $type != '' ? '_type'.$type : '').'_'.$mode.($search_year > 0 ? '_year'.$search_year : '').'.png',
'label' => ($mode == 'byunit' ? $langs->transnoentitiesnoconv("NumberOfUnitsSupplierInvoices") : $langs->transnoentitiesnoconv("NumberOfSupplierInvoices"))); 'label' => ($mode == 'byunit' ? $langs->transnoentitiesnoconv("NumberOfUnitsSupplierInvoices") : $langs->transnoentitiesnoconv("NumberOfSupplierInvoices")));
} }
if ($conf->contrat->enabled) { if ($conf->contrat->enabled) {
$graphfiles['contracts'] = array('modulepart'=>'productstats_contracts', $graphfiles['contracts'] = array('modulepart'=>'productstats_contracts',
'file' => $object->id.'/contracts12m'.((string) $type != '' ? '_type'.$type : '').'_'.$mode.($search_year ? '_year'.$search_year : '').'.png', 'file' => $object->id.'/contracts12m'.((string) $type != '' ? '_type'.$type : '').'_'.$mode.($search_year > 0 ? '_year'.$search_year : '').'.png',
'label' => ($mode == 'byunit' ? $langs->transnoentitiesnoconv("NumberOfUnitsContracts") : $langs->transnoentitiesnoconv("NumberOfContracts"))); 'label' => ($mode == 'byunit' ? $langs->transnoentitiesnoconv("NumberOfUnitsContracts") : $langs->transnoentitiesnoconv("NumberOfContracts")));
} }
if ($conf->mrp->enabled) { if ($conf->mrp->enabled) {
$graphfiles['mrp'] = array('modulepart'=>'productstats_mrp', $graphfiles['mrp'] = array('modulepart'=>'productstats_mrp',
'file' => $object->id.'/mos12m'.((string) $type != '' ? '_type'.$type : '').'_'.$mode.($search_year ? '_year'.$search_year : '').'.png', 'file' => $object->id.'/mos12m'.((string) $type != '' ? '_type'.$type : '').'_'.$mode.($search_year > 0 ? '_year'.$search_year : '').'.png',
'label' => ($mode == 'byunit' ? $langs->transnoentitiesnoconv("NumberOfUnitsMos") : $langs->transnoentitiesnoconv("NumberOfMos"))); 'label' => ($mode == 'byunit' ? $langs->transnoentitiesnoconv("NumberOfUnitsMos") : $langs->transnoentitiesnoconv("NumberOfMos")));
} }

View File

@ -59,7 +59,7 @@ $pageprev = $page - 1;
$pagenext = $page + 1; $pagenext = $page + 1;
if (!$sortorder) $sortorder = "DESC"; if (!$sortorder) $sortorder = "DESC";
if (!$sortfield) $sortfield = "c.date_commande"; if (!$sortfield) $sortfield = "c.date_commande";
$search_month = GETPOST('search_month', 'alpha'); $search_month = GETPOST('search_month', 'int');
$search_year = GETPOST('search_year', 'int'); $search_year = GETPOST('search_year', 'int');
if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter', 'alpha')) {

View File

@ -61,7 +61,7 @@ if (!$sortorder)
$sortorder = "DESC"; $sortorder = "DESC";
if (!$sortfield) if (!$sortfield)
$sortfield = "c.date_commande"; $sortfield = "c.date_commande";
$search_month = GETPOST('search_month', 'alpha'); $search_month = GETPOST('search_month', 'int');
$search_year = GETPOST('search_year', 'int'); $search_year = GETPOST('search_year', 'int');
if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter', 'alpha')) {

View File

@ -61,7 +61,7 @@ $pagenext = $page + 1;
if (!$sortorder) $sortorder = "DESC"; if (!$sortorder) $sortorder = "DESC";
if (!$sortfield) $sortfield = "f.datef"; if (!$sortfield) $sortfield = "f.datef";
$search_month = GETPOST('search_month', 'alpha'); $search_month = GETPOST('search_month', 'int');
$search_year = GETPOST('search_year', 'int'); $search_year = GETPOST('search_year', 'int');
if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter', 'alpha')) {

View File

@ -60,7 +60,7 @@ $pageprev = $page - 1;
$pagenext = $page + 1; $pagenext = $page + 1;
if (!$sortorder) $sortorder = "DESC"; if (!$sortorder) $sortorder = "DESC";
if (!$sortfield) $sortfield = "f.datef"; if (!$sortfield) $sortfield = "f.datef";
$search_month = GETPOST('search_month', 'alpha'); $search_month = GETPOST('search_month', 'int');
$search_year = GETPOST('search_year', 'int'); $search_year = GETPOST('search_year', 'int');
if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter', 'alpha')) {

View File

@ -60,7 +60,7 @@ $pagenext = $page + 1;
if (!$sortorder) $sortorder = "DESC"; if (!$sortorder) $sortorder = "DESC";
if (!$sortfield) $sortfield = "p.datep"; if (!$sortfield) $sortfield = "p.datep";
$search_month = GETPOST('search_month', 'alpha'); $search_month = GETPOST('search_month', 'int');
$search_year = GETPOST('search_year', 'int'); $search_year = GETPOST('search_year', 'int');
if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter', 'alpha')) {

View File

@ -60,7 +60,7 @@ $pagenext = $page + 1;
if (!$sortorder) $sortorder = "DESC"; if (!$sortorder) $sortorder = "DESC";
if (!$sortfield) $sortfield = "p.date_valid"; if (!$sortfield) $sortfield = "p.date_valid";
$search_month = GETPOST('search_month', 'alpha'); $search_month = GETPOST('search_month', 'int');
$search_year = GETPOST('search_year', 'int'); $search_year = GETPOST('search_year', 'int');
if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter', 'alpha')) {

View File

@ -789,8 +789,8 @@ class Societe extends CommonObject
// Clean parameters // Clean parameters
if (empty($this->status)) $this->status = 0; if (empty($this->status)) $this->status = 0;
$this->name = $this->name ?trim($this->name) : trim($this->nom); $this->name = $this->name ?trim($this->name) : trim($this->nom);
if (!empty($conf->global->MAIN_FIRST_TO_UPPER)) $this->name = ucwords($this->name); if (!empty($conf->global->MAIN_FIRST_TO_UPPER)) $this->name = dol_ucwords(dol_strtolower($this->name));
if (!empty($conf->global->MAIN_ALL_TO_UPPER)) $this->name = strtoupper($this->name); if (!empty($conf->global->MAIN_ALL_TO_UPPER)) $this->name = dol_strtoupper($this->name);
$this->nom = $this->name; // For backward compatibility $this->nom = $this->name; // For backward compatibility
if (empty($this->client)) $this->client = 0; if (empty($this->client)) $this->client = 0;
if (empty($this->fournisseur)) $this->fournisseur = 0; if (empty($this->fournisseur)) $this->fournisseur = 0;
@ -1094,8 +1094,8 @@ class Societe extends CommonObject
$now = dol_now(); $now = dol_now();
if (!empty($conf->global->MAIN_FIRST_TO_UPPER)) $this->name = ucwords($this->name); if (!empty($conf->global->MAIN_FIRST_TO_UPPER)) $this->name = dol_ucwords(dol_strtolower($this->name));
if (!empty($conf->global->MAIN_ALL_TO_UPPER)) $this->name = strtoupper($this->name); if (!empty($conf->global->MAIN_ALL_TO_UPPER)) $this->name = dol_strtoupper($this->name);
// Clean parameters // Clean parameters
$this->id = $id; $this->id = $id;
$this->entity = ((isset($this->entity) && is_numeric($this->entity)) ? $this->entity : $conf->entity); $this->entity = ((isset($this->entity) && is_numeric($this->entity)) ? $this->entity : $conf->entity);

View File

@ -1123,9 +1123,9 @@ class User extends CommonObject
// Clean parameters // Clean parameters
if (!empty($conf->global->MAIN_FIRST_TO_UPPER)) $this->lastname = ucwords($this->lastname); if (!empty($conf->global->MAIN_FIRST_TO_UPPER)) $this->lastname = dol_ucwords(dol_strtolower($this->lastname));
if (!empty($conf->global->MAIN_ALL_TO_UPPER)) $this->lastname = strtoupper($this->lastname); if (!empty($conf->global->MAIN_ALL_TO_UPPER)) $this->lastname = dol_strtoupper($this->lastname);
if (!empty($conf->global->MAIN_FIRST_TO_UPPER)) $this->firstname = ucwords($this->firstname); if (!empty($conf->global->MAIN_FIRST_TO_UPPER)) $this->firstname = dol_ucwords(dol_strtolower($this->firstname));
$this->login = trim($this->login); $this->login = trim($this->login);
if (!isset($this->entity)) $this->entity = $conf->entity; // If not defined, we use default value if (!isset($this->entity)) $this->entity = $conf->entity; // If not defined, we use default value
@ -1468,9 +1468,9 @@ class User extends CommonObject
// Clean parameters // Clean parameters
if (!empty($conf->global->MAIN_FIRST_TO_UPPER)) $this->lastname = ucwords($this->lastname); if (!empty($conf->global->MAIN_FIRST_TO_UPPER)) $this->lastname = dol_ucwords(dol_strtolower($this->lastname));
if (!empty($conf->global->MAIN_ALL_TO_UPPER)) $this->lastname = strtoupper($this->lastname); if (!empty($conf->global->MAIN_ALL_TO_UPPER)) $this->lastname = dol_strtoupper($this->lastname);
if (!empty($conf->global->MAIN_FIRST_TO_UPPER)) $this->firstname = ucwords($this->firstname); if (!empty($conf->global->MAIN_FIRST_TO_UPPER)) $this->firstname = dol_ucwords(dol_strtolower($this->firstname));
$this->lastname = trim($this->lastname); $this->lastname = trim($this->lastname);
$this->firstname = trim($this->firstname); $this->firstname = trim($this->firstname);

View File

@ -171,7 +171,7 @@ class RestAPIDocumentTest extends PHPUnit\Framework\TestCase
'fileencoding'=>"" 'fileencoding'=>""
); );
$result = getURLContent($url, 'POST', $data, 1,array(), array('http', 'https'), 2); $result = getURLContent($url, 'POST', $data, 1, array(), array('http', 'https'), 2);
echo __METHOD__.' Result for sending document: '.var_export($result, true)."\n"; echo __METHOD__.' Result for sending document: '.var_export($result, true)."\n";
echo __METHOD__.' curl_error_no: '.$result['curl_error_no']."\n"; echo __METHOD__.' curl_error_no: '.$result['curl_error_no']."\n";
$object = json_decode($result['content'], true); $object = json_decode($result['content'], true);