2
0
forked from Wavyzz/dolibarr

Merge branch 'develop' of git@github.com:Dolibarr/dolibarr.git into develop

This commit is contained in:
Laurent Destailleur
2022-01-24 12:50:35 +01:00
15 changed files with 199 additions and 66 deletions

View File

@@ -1163,9 +1163,13 @@ if ($rowid > 0) {
print dol_get_fiche_end(); print dol_get_fiche_end();
print '<div class="center">'; print '<div class="center">';
$parameters = array();
$reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action);
if (empty($reshook)) {
print '<input type="submit" class="button" name="add" value="'.$langs->trans("AddSubscription").'">'; print '<input type="submit" class="button" name="add" value="'.$langs->trans("AddSubscription").'">';
print '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'; print '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
print '<input type="submit" class="button button-cancel" name="cancel" value="'.$langs->trans("Cancel").'">'; print '<input type="submit" class="button button-cancel" name="cancel" value="'.$langs->trans("Cancel").'">';
}
print '</div>'; print '</div>';
print '</form>'; print '</form>';

View File

@@ -490,7 +490,8 @@ class Commande extends CommonOrder
$sql .= " SET ref = '".$this->db->escape($num)."',"; $sql .= " SET ref = '".$this->db->escape($num)."',";
$sql .= " fk_statut = ".self::STATUS_VALIDATED.","; $sql .= " fk_statut = ".self::STATUS_VALIDATED.",";
$sql .= " date_valid='".$this->db->idate($now)."',"; $sql .= " date_valid='".$this->db->idate($now)."',";
$sql .= " fk_user_valid = ".((int) $user->id); $sql .= " fk_user_valid = ".((int) $user->id).",";
$sql .= " fk_user_modif = ".((int) $user->id);
$sql .= " WHERE rowid = ".((int) $this->id); $sql .= " WHERE rowid = ".((int) $this->id);
dol_syslog(get_class($this)."::valid", LOG_DEBUG); dol_syslog(get_class($this)."::valid", LOG_DEBUG);
@@ -620,7 +621,8 @@ class Commande extends CommonOrder
$this->db->begin(); $this->db->begin();
$sql = "UPDATE ".MAIN_DB_PREFIX."commande"; $sql = "UPDATE ".MAIN_DB_PREFIX."commande";
$sql .= " SET fk_statut = ".self::STATUS_DRAFT; $sql .= " SET fk_statut = ".self::STATUS_DRAFT."',";
$sql .= " fk_user_modif = ".((int) $user->id);
$sql .= " WHERE rowid = ".((int) $this->id); $sql .= " WHERE rowid = ".((int) $this->id);
if ($this->db->query($sql)) { if ($this->db->query($sql)) {
@@ -694,7 +696,8 @@ class Commande extends CommonOrder
$this->db->begin(); $this->db->begin();
$sql = 'UPDATE '.MAIN_DB_PREFIX.'commande'; $sql = 'UPDATE '.MAIN_DB_PREFIX.'commande';
$sql .= ' SET fk_statut='.self::STATUS_VALIDATED.', facture=0'; $sql .= ' SET fk_statut='.self::STATUS_VALIDATED.', facture=0,';
$sql .= " fk_user_modif = ".((int) $user->id);
$sql .= " WHERE rowid = ".((int) $this->id); $sql .= " WHERE rowid = ".((int) $this->id);
dol_syslog(get_class($this)."::set_reopen", LOG_DEBUG); dol_syslog(get_class($this)."::set_reopen", LOG_DEBUG);
@@ -755,7 +758,8 @@ class Commande extends CommonOrder
$sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element; $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element;
$sql .= ' SET fk_statut = '.self::STATUS_CLOSED.','; $sql .= ' SET fk_statut = '.self::STATUS_CLOSED.',';
$sql .= ' fk_user_cloture = '.((int) $user->id).','; $sql .= ' fk_user_cloture = '.((int) $user->id).',';
$sql .= " date_cloture = '".$this->db->idate($now)."'"; $sql .= " date_cloture = '".$this->db->idate($now)."',";
$sql .= " fk_user_modif = ".((int) $user->id);
$sql .= " WHERE rowid = ".((int) $this->id).' AND fk_statut > '.self::STATUS_DRAFT; $sql .= " WHERE rowid = ".((int) $this->id).' AND fk_statut > '.self::STATUS_DRAFT;
if ($this->db->query($sql)) { if ($this->db->query($sql)) {
@@ -803,7 +807,8 @@ class Commande extends CommonOrder
$this->db->begin(); $this->db->begin();
$sql = "UPDATE ".MAIN_DB_PREFIX."commande"; $sql = "UPDATE ".MAIN_DB_PREFIX."commande";
$sql .= " SET fk_statut = ".self::STATUS_CANCELED; $sql .= " SET fk_statut = ".self::STATUS_CANCELED.",";
$sql .= " fk_user_modif = ".((int) $user->id);
$sql .= " WHERE rowid = ".((int) $this->id); $sql .= " WHERE rowid = ".((int) $this->id);
$sql .= " AND fk_statut = ".self::STATUS_VALIDATED; $sql .= " AND fk_statut = ".self::STATUS_VALIDATED;
@@ -1779,7 +1784,7 @@ class Commande extends CommonOrder
return -1; return -1;
} }
$sql = 'SELECT c.rowid, c.entity, c.date_creation, c.ref, c.fk_soc, c.fk_user_author, c.fk_user_valid, c.fk_statut'; $sql = 'SELECT c.rowid, c.entity, c.date_creation, c.ref, c.fk_soc, c.fk_user_author, c.fk_user_valid, c.fk_user_modif, c.fk_statut';
$sql .= ', c.amount_ht, c.total_ht, c.total_ttc, c.total_tva, c.localtax1 as total_localtax1, c.localtax2 as total_localtax2, c.fk_cond_reglement, c.fk_mode_reglement, c.fk_availability, c.fk_input_reason'; $sql .= ', c.amount_ht, c.total_ht, c.total_ttc, c.total_tva, c.localtax1 as total_localtax1, c.localtax2 as total_localtax2, c.fk_cond_reglement, c.fk_mode_reglement, c.fk_availability, c.fk_input_reason';
$sql .= ', c.fk_account'; $sql .= ', c.fk_account';
$sql .= ', c.date_commande, c.date_valid, c.tms'; $sql .= ', c.date_commande, c.date_valid, c.tms';
@@ -1844,6 +1849,7 @@ class Commande extends CommonOrder
$this->user_author_id = $obj->fk_user_author; $this->user_author_id = $obj->fk_user_author;
$this->user_valid = $obj->fk_user_valid; $this->user_valid = $obj->fk_user_valid;
$this->user_modification = $obj->fk_user_modif;
$this->total_ht = $obj->total_ht; $this->total_ht = $obj->total_ht;
$this->total_tva = $obj->total_tva; $this->total_tva = $obj->total_tva;
$this->total_localtax1 = $obj->total_localtax1; $this->total_localtax1 = $obj->total_localtax1;

View File

@@ -130,6 +130,7 @@ $usercanread = $user->rights->facture->lire;
$usercancreate = $user->rights->facture->creer; $usercancreate = $user->rights->facture->creer;
$usercanissuepayment = $user->rights->facture->paiement; $usercanissuepayment = $user->rights->facture->paiement;
$usercandelete = $user->rights->facture->supprimer; $usercandelete = $user->rights->facture->supprimer;
$usercancreatecontract = $user->rights->contrat->creer;
$usercanvalidate = ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $usercancreate) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->facture->invoice_advance->validate))); $usercanvalidate = ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $usercancreate) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->facture->invoice_advance->validate)));
$usercansend = (empty($conf->global->MAIN_USE_ADVANCED_PERMS) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->facture->invoice_advance->send))); $usercansend = (empty($conf->global->MAIN_USE_ADVANCED_PERMS) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->facture->invoice_advance->send)));
$usercanreopen = ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $usercancreate) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->facture->invoice_advance->reopen))); $usercanreopen = ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $usercancreate) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->facture->invoice_advance->reopen)));
@@ -3417,6 +3418,10 @@ if ($action == 'create') {
$optionsav .= '<option value="'.$key.'"'; $optionsav .= '<option value="'.$key.'"';
if ($key == GETPOST('fac_avoir')) { if ($key == GETPOST('fac_avoir')) {
$optionsav .= ' selected'; $optionsav .= ' selected';
// pre-filled extra fields with selected credit note
$newinvoice_static->fetch_optionals($key);
$object->array_options = $newinvoice_static->array_options;
} }
$optionsav .= '>'; $optionsav .= '>';
$optionsav .= $newinvoice_static->ref; $optionsav .= $newinvoice_static->ref;
@@ -5378,6 +5383,17 @@ if ($action == 'create') {
} }
} }
// Create contract
if (!empty($conf->global->CONTRACT_CREATE_FROM_INVOICE)) {
if ($conf->contrat->enabled && $object->statut == Facture::STATUS_VALIDATED) {
$langs->load("contracts");
if ($usercancreatecontract) {
print '<a class="butAction" href="' . DOL_URL_ROOT . '/contrat/card.php?action=create&amp;origin=' . $object->element . '&amp;originid=' . $object->id . '&amp;socid=' . $object->socid . '">' . $langs->trans('AddContract') . '</a>';
}
}
}
// Validate // Validate
if ($object->statut == Facture::STATUS_DRAFT && count($object->lines) > 0 && ((($object->type == Facture::TYPE_STANDARD || $object->type == Facture::TYPE_REPLACEMENT || $object->type == Facture::TYPE_DEPOSIT || $object->type == Facture::TYPE_PROFORMA || $object->type == Facture::TYPE_SITUATION) && (!empty($conf->global->FACTURE_ENABLE_NEGATIVE) || $object->total_ttc >= 0)) || ($object->type == Facture::TYPE_CREDIT_NOTE && $object->total_ttc <= 0))) { if ($object->statut == Facture::STATUS_DRAFT && count($object->lines) > 0 && ((($object->type == Facture::TYPE_STANDARD || $object->type == Facture::TYPE_REPLACEMENT || $object->type == Facture::TYPE_DEPOSIT || $object->type == Facture::TYPE_PROFORMA || $object->type == Facture::TYPE_SITUATION) && (!empty($conf->global->FACTURE_ENABLE_NEGATIVE) || $object->total_ttc >= 0)) || ($object->type == Facture::TYPE_CREDIT_NOTE && $object->total_ttc <= 0))) {
if ($usercanvalidate) { if ($usercanvalidate) {

View File

@@ -40,6 +40,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/modules/contract/modules_contract.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
if (!empty($conf->propal->enabled)) { if (!empty($conf->propal->enabled)) {
require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php';
} }
@@ -248,6 +249,10 @@ if (empty($reshook)) {
if ($element == 'propal') { if ($element == 'propal') {
$element = 'comm/propal'; $subelement = 'propal'; $element = 'comm/propal'; $subelement = 'propal';
} }
if ($element == 'invoice' || $element == 'facture') {
$element = 'compta/facture';
$subelement = 'facture';
}
$object->origin = $origin; $object->origin = $origin;
$object->origin_id = $originid; $object->origin_id = $originid;
@@ -1040,6 +1045,10 @@ if ($action == 'create') {
if ($element == 'propal') { if ($element == 'propal') {
$element = 'comm/propal'; $subelement = 'propal'; $element = 'comm/propal'; $subelement = 'propal';
} }
if ($element == 'invoice' || $element == 'facture') {
$element = 'compta/facture';
$subelement = 'facture';
}
dol_include_once('/'.$element.'/class/'.$subelement.'.class.php'); dol_include_once('/'.$element.'/class/'.$subelement.'.class.php');

View File

@@ -1215,17 +1215,20 @@ abstract class CommonObject
public function delete_linked_contact($source = '', $code = '') public function delete_linked_contact($source = '', $code = '')
{ {
// phpcs:enable // phpcs:enable
$listId = '';
$temp = array(); $temp = array();
$typeContact = $this->liste_type_contact($source, '', 0, 0, $code); $typeContact = $this->liste_type_contact($source, '', 0, 0, $code);
if (!empty($typeContact)) {
foreach ($typeContact as $key => $value) { foreach ($typeContact as $key => $value) {
array_push($temp, $key); array_push($temp, $key);
} }
$listId = implode(",", $temp); $listId = implode(",", $temp);
}
$sql = "DELETE FROM ".MAIN_DB_PREFIX."element_contact"; $sql = "DELETE FROM ".MAIN_DB_PREFIX."element_contact";
$sql .= " WHERE element_id = ".((int) $this->id); $sql .= " WHERE element_id = ".((int) $this->id);
if ($listId) { if (!empty($listId)) {
$sql .= " AND fk_c_type_contact IN (".$this->db->sanitize($listId).")"; $sql .= " AND fk_c_type_contact IN (".$this->db->sanitize($listId).")";
} }

View File

@@ -17,6 +17,7 @@
* Copyright (C) 2019 Thibault Foucart <support@ptibogxiv.net> * Copyright (C) 2019 Thibault Foucart <support@ptibogxiv.net>
* Copyright (C) 2020 Open-Dsi <support@open-dsi.fr> * Copyright (C) 2020 Open-Dsi <support@open-dsi.fr>
* Copyright (C) 2021 Gauthier VERDOL <gauthier.verdol@atm-consulting.fr> * Copyright (C) 2021 Gauthier VERDOL <gauthier.verdol@atm-consulting.fr>
* Copyright (C) 2022 Anthony Berton <anthony.berton@bb2a.fr>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@@ -6952,10 +6953,15 @@ function getCommonSubstitutionArray($outputlangs, $onlykey = 0, $exclude = null,
'__USER_ID__' => (string) $user->id, '__USER_ID__' => (string) $user->id,
'__USER_LOGIN__' => (string) $user->login, '__USER_LOGIN__' => (string) $user->login,
'__USER_EMAIL__' => (string) $user->email, '__USER_EMAIL__' => (string) $user->email,
'__USER_PHONE__' => (string) dol_print_phone($user->office_phone),
'__USER_PHONEPRO__' => (string) dol_print_phone($user->user_mobile),
'__USER_PHONEMOBILE__' => (string) dol_print_phone($user->personal_mobile),
'__USER_FAX__' => (string) $user->office_fax,
'__USER_LASTNAME__' => (string) $user->lastname, '__USER_LASTNAME__' => (string) $user->lastname,
'__USER_FIRSTNAME__' => (string) $user->firstname, '__USER_FIRSTNAME__' => (string) $user->firstname,
'__USER_FULLNAME__' => (string) $user->getFullName($outputlangs), '__USER_FULLNAME__' => (string) $user->getFullName($outputlangs),
'__USER_SUPERVISOR_ID__' => (string) ($user->fk_user ? $user->fk_user : '0'), '__USER_SUPERVISOR_ID__' => (string) ($user->fk_user ? $user->fk_user : '0'),
'__USER_JOB__' => (string) $user->job,
'__USER_REMOTE_IP__' => (string) getUserRemoteIP() '__USER_REMOTE_IP__' => (string) getUserRemoteIP()
)); ));
} }
@@ -6964,8 +6970,8 @@ function getCommonSubstitutionArray($outputlangs, $onlykey = 0, $exclude = null,
$substitutionarray = array_merge($substitutionarray, array( $substitutionarray = array_merge($substitutionarray, array(
'__MYCOMPANY_NAME__' => $mysoc->name, '__MYCOMPANY_NAME__' => $mysoc->name,
'__MYCOMPANY_EMAIL__' => $mysoc->email, '__MYCOMPANY_EMAIL__' => $mysoc->email,
'__MYCOMPANY_PHONE__' => $mysoc->phone, '__MYCOMPANY_PHONE__' => dol_print_phone($mysoc->phone),
'__MYCOMPANY_FAX__' => $mysoc->fax, '__MYCOMPANY_FAX__' => dol_print_phone($mysoc->fax),
'__MYCOMPANY_PROFID1__' => $mysoc->idprof1, '__MYCOMPANY_PROFID1__' => $mysoc->idprof1,
'__MYCOMPANY_PROFID2__' => $mysoc->idprof2, '__MYCOMPANY_PROFID2__' => $mysoc->idprof2,
'__MYCOMPANY_PROFID3__' => $mysoc->idprof3, '__MYCOMPANY_PROFID3__' => $mysoc->idprof3,
@@ -7113,9 +7119,9 @@ function getCommonSubstitutionArray($outputlangs, $onlykey = 0, $exclude = null,
$substitutionarray['__MEMBER_PHOTO__'] = (isset($object->photo) ? $object->photo : ''); $substitutionarray['__MEMBER_PHOTO__'] = (isset($object->photo) ? $object->photo : '');
$substitutionarray['__MEMBER_LOGIN__'] = (isset($object->login) ? $object->login : ''); $substitutionarray['__MEMBER_LOGIN__'] = (isset($object->login) ? $object->login : '');
$substitutionarray['__MEMBER_PASSWORD__'] = (isset($object->pass) ? $object->pass : ''); $substitutionarray['__MEMBER_PASSWORD__'] = (isset($object->pass) ? $object->pass : '');
$substitutionarray['__MEMBER_PHONE__'] = (isset($object->phone) ? $object->phone : ''); $substitutionarray['__MEMBER_PHONE__'] = (isset($object->phone) ? dol_print_phone($object->phone) : '');
$substitutionarray['__MEMBER_PHONEPRO__'] = (isset($object->phone_perso) ? $object->phone_perso : ''); $substitutionarray['__MEMBER_PHONEPRO__'] = (isset($object->phone_perso) ? dol_print_phone($object->phone_perso) : '');
$substitutionarray['__MEMBER_PHONEMOBILE__'] = (isset($object->phone_mobile) ? $object->phone_mobile : ''); $substitutionarray['__MEMBER_PHONEMOBILE__'] = (isset($object->phone_mobile) ? dol_print_phone($object->phone_mobile) : '');
$substitutionarray['__MEMBER_TYPE__'] = (isset($object->type) ? $object->type : ''); $substitutionarray['__MEMBER_TYPE__'] = (isset($object->type) ? $object->type : '');
$substitutionarray['__MEMBER_FIRST_SUBSCRIPTION_DATE__'] = dol_print_date($object->first_subscription_date, 'dayrfc'); $substitutionarray['__MEMBER_FIRST_SUBSCRIPTION_DATE__'] = dol_print_date($object->first_subscription_date, 'dayrfc');
$substitutionarray['__MEMBER_FIRST_SUBSCRIPTION_DATE_START__'] = dol_print_date($object->first_subscription_date_start, 'dayrfc'); $substitutionarray['__MEMBER_FIRST_SUBSCRIPTION_DATE_START__'] = dol_print_date($object->first_subscription_date_start, 'dayrfc');
@@ -7132,8 +7138,8 @@ function getCommonSubstitutionArray($outputlangs, $onlykey = 0, $exclude = null,
$substitutionarray['__THIRDPARTY_CODE_CLIENT__'] = (is_object($object) ? $object->code_client : ''); $substitutionarray['__THIRDPARTY_CODE_CLIENT__'] = (is_object($object) ? $object->code_client : '');
$substitutionarray['__THIRDPARTY_CODE_FOURNISSEUR__'] = (is_object($object) ? $object->code_fournisseur : ''); $substitutionarray['__THIRDPARTY_CODE_FOURNISSEUR__'] = (is_object($object) ? $object->code_fournisseur : '');
$substitutionarray['__THIRDPARTY_EMAIL__'] = (is_object($object) ? $object->email : ''); $substitutionarray['__THIRDPARTY_EMAIL__'] = (is_object($object) ? $object->email : '');
$substitutionarray['__THIRDPARTY_PHONE__'] = (is_object($object) ? $object->phone : ''); $substitutionarray['__THIRDPARTY_PHONE__'] = (is_object($object) ? dol_print_phone($object->phone) : '');
$substitutionarray['__THIRDPARTY_FAX__'] = (is_object($object) ? $object->fax : ''); $substitutionarray['__THIRDPARTY_FAX__'] = (is_object($object) ? dol_print_phone($object->fax) : '');
$substitutionarray['__THIRDPARTY_ADDRESS__'] = (is_object($object) ? $object->address : ''); $substitutionarray['__THIRDPARTY_ADDRESS__'] = (is_object($object) ? $object->address : '');
$substitutionarray['__THIRDPARTY_ZIP__'] = (is_object($object) ? $object->zip : ''); $substitutionarray['__THIRDPARTY_ZIP__'] = (is_object($object) ? $object->zip : '');
$substitutionarray['__THIRDPARTY_TOWN__'] = (is_object($object) ? $object->town : ''); $substitutionarray['__THIRDPARTY_TOWN__'] = (is_object($object) ? $object->town : '');
@@ -7155,8 +7161,8 @@ function getCommonSubstitutionArray($outputlangs, $onlykey = 0, $exclude = null,
$substitutionarray['__THIRDPARTY_CODE_CLIENT__'] = (is_object($object->thirdparty) ? $object->thirdparty->code_client : ''); $substitutionarray['__THIRDPARTY_CODE_CLIENT__'] = (is_object($object->thirdparty) ? $object->thirdparty->code_client : '');
$substitutionarray['__THIRDPARTY_CODE_FOURNISSEUR__'] = (is_object($object->thirdparty) ? $object->thirdparty->code_fournisseur : ''); $substitutionarray['__THIRDPARTY_CODE_FOURNISSEUR__'] = (is_object($object->thirdparty) ? $object->thirdparty->code_fournisseur : '');
$substitutionarray['__THIRDPARTY_EMAIL__'] = (is_object($object->thirdparty) ? $object->thirdparty->email : ''); $substitutionarray['__THIRDPARTY_EMAIL__'] = (is_object($object->thirdparty) ? $object->thirdparty->email : '');
$substitutionarray['__THIRDPARTY_PHONE__'] = (is_object($object->thirdparty) ? $object->thirdparty->phone : ''); $substitutionarray['__THIRDPARTY_PHONE__'] = (is_object($object->thirdparty) ? dol_print_phone($object->thirdparty->phone) : '');
$substitutionarray['__THIRDPARTY_FAX__'] = (is_object($object->thirdparty) ? $object->thirdparty->fax : ''); $substitutionarray['__THIRDPARTY_FAX__'] = (is_object($object->thirdparty) ? dol_print_phone($object->thirdparty->fax) : '');
$substitutionarray['__THIRDPARTY_ADDRESS__'] = (is_object($object->thirdparty) ? $object->thirdparty->address : ''); $substitutionarray['__THIRDPARTY_ADDRESS__'] = (is_object($object->thirdparty) ? $object->thirdparty->address : '');
$substitutionarray['__THIRDPARTY_ZIP__'] = (is_object($object->thirdparty) ? $object->thirdparty->zip : ''); $substitutionarray['__THIRDPARTY_ZIP__'] = (is_object($object->thirdparty) ? $object->thirdparty->zip : '');
$substitutionarray['__THIRDPARTY_TOWN__'] = (is_object($object->thirdparty) ? $object->thirdparty->town : ''); $substitutionarray['__THIRDPARTY_TOWN__'] = (is_object($object->thirdparty) ? $object->thirdparty->town : '');
@@ -7237,6 +7243,11 @@ function getCommonSubstitutionArray($outputlangs, $onlykey = 0, $exclude = null,
$substitutionarray['__EXTRAFIELD_'.strtoupper($key).'_LOCALE__'] = ($datetime != "0000-00-00 00:00:00" ? dol_print_date($datetime, 'dayhour', 'tzserver', $outputlangs) : ''); $substitutionarray['__EXTRAFIELD_'.strtoupper($key).'_LOCALE__'] = ($datetime != "0000-00-00 00:00:00" ? dol_print_date($datetime, 'dayhour', 'tzserver', $outputlangs) : '');
$substitutionarray['__EXTRAFIELD_'.strtoupper($key).'_DAY_LOCALE__'] = ($datetime != "0000-00-00 00:00:00" ? dol_print_date($datetime, 'day', 'tzserver', $outputlangs) : ''); $substitutionarray['__EXTRAFIELD_'.strtoupper($key).'_DAY_LOCALE__'] = ($datetime != "0000-00-00 00:00:00" ? dol_print_date($datetime, 'day', 'tzserver', $outputlangs) : '');
$substitutionarray['__EXTRAFIELD_'.strtoupper($key).'_RFC__'] = ($datetime != "0000-00-00 00:00:00" ? dol_print_date($datetime, 'dayhourrfc') : ''); $substitutionarray['__EXTRAFIELD_'.strtoupper($key).'_RFC__'] = ($datetime != "0000-00-00 00:00:00" ? dol_print_date($datetime, 'dayhourrfc') : '');
} elseif ($extrafields->attributes[$object->table_element]['type'][$key] == 'phone') {
$substitutionarray['__EXTRAFIELD_'.strtoupper($key).'__'] = dol_print_phone($object->array_options['options_'.$key]);
} elseif ($extrafields->attributes[$object->table_element]['type'][$key] == 'price') {
$substitutionarray['__EXTRAFIELD_'.strtoupper($key).'__'] = $object->array_options['options_'.$key];
$substitutionarray['__EXTRAFIELD_'.strtoupper($key).'_FORMATED__'] = price($object->array_options['options_'.$key]);
} }
} }
} }

View File

@@ -95,11 +95,39 @@ if ($idprod > 0) {
if (!empty($conf->stock->enabled)) { if (!empty($conf->stock->enabled)) {
// Add price for pmp // Add price for pmp
$price = $producttmp->pmp; $price = $producttmp->pmp;
if (empty($price) && !empty($conf->global->PRODUCT_USE_SUB_COST_PRICES_IF_COST_PRICE_EMPTY)) {
// get pmp for subproducts if any
$producttmp->get_sousproduits_arbo();
$prods_arbo=$producttmp->get_arbo_each_prod();
if (!empty($prods_arbo)) {
$price = 0;
foreach ($prods_arbo as $child) {
$sousprod = new Product($db);
$sousprod->fetch($child['id']);
$price += $sousprod->pmp;
}
}
}
$prices[] = array("id" => 'pmpprice', "price" => price2num($price), "label" => $langs->trans("PMPValueShort").': '.price($price, 0, $langs, 0, 0, -1, $conf->currency), "title" => $langs->trans("PMPValueShort").': '.price($price, 0, $langs, 0, 0, -1, $conf->currency)); // For price field, we must use price2num(), for label or title, price() $prices[] = array("id" => 'pmpprice', "price" => price2num($price), "label" => $langs->trans("PMPValueShort").': '.price($price, 0, $langs, 0, 0, -1, $conf->currency), "title" => $langs->trans("PMPValueShort").': '.price($price, 0, $langs, 0, 0, -1, $conf->currency)); // For price field, we must use price2num(), for label or title, price()
} }
// Add price for costprice (at end) // Add price for costprice (at end)
$price = $producttmp->cost_price; $price = $producttmp->cost_price;
if (empty($price) && ! empty($conf->global->PRODUCT_USE_SUB_COST_PRICES_IF_COST_PRICE_EMPTY)) {
// get costprice for subproducts if any
$producttmp->get_sousproduits_arbo();
$prods_arbo=$producttmp->get_arbo_each_prod();
if (!empty($prods_arbo)) {
$price = 0;
foreach ($prods_arbo as $child) {
$sousprod = new Product($db);
$sousprod->fetch($child['id']);
$price += $sousprod->cost_price;
}
}
}
$prices[] = array("id" => 'costprice', "price" => price2num($price), "label" => $langs->trans("CostPrice").': '.price($price, 0, $langs, 0, 0, -1, $conf->currency), "title" => $langs->trans("PMPValueShort").': '.price($price, 0, $langs, 0, 0, -1, $conf->currency)); // For price field, we must use price2num(), for label or title, price() $prices[] = array("id" => 'costprice', "price" => price2num($price), "label" => $langs->trans("CostPrice").': '.price($price, 0, $langs, 0, 0, -1, $conf->currency), "title" => $langs->trans("PMPValueShort").': '.price($price, 0, $langs, 0, 0, -1, $conf->currency)); // For price field, we must use price2num(), for label or title, price()
} }

View File

@@ -11,6 +11,7 @@
* Copyright (C) 2017 Alexandre Spangaro <aspangaro@open-dsi.fr> * Copyright (C) 2017 Alexandre Spangaro <aspangaro@open-dsi.fr>
* Copyright (C) 2018-2020 Frédéric France <frederic.france@netlogic.fr> * Copyright (C) 2018-2020 Frédéric France <frederic.france@netlogic.fr>
* Copyright (C) 2021 Charlene Benke <charlene@patas-monkey.com> * Copyright (C) 2021 Charlene Benke <charlene@patas-monkey.com>
* Copyright (C) 2022 Udo Tamm <dev@dolibit.de>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@@ -54,11 +55,11 @@ $day = GETPOST('day', 'int');
$month = GETPOST('month', 'int'); $month = GETPOST('month', 'int');
$year = GETPOST('year', 'int'); $year = GETPOST('year', 'int');
$search_ref = GETPOST("search_ref", "alpha"); $search_ref = GETPOST('search_ref', 'alpha');
$search_account = GETPOST("search_account", "int"); $search_account = GETPOST('search_account', 'int');
$search_paymenttype = GETPOST("search_paymenttype"); $search_paymenttype = GETPOST('search_paymenttype');
$search_amount = GETPOST("search_amount", 'alpha'); // alpha because we must be able to search on "< x" $search_amount = GETPOST('search_amount', 'alpha'); // alpha because we must be able to search on "< x"
$search_company = GETPOST("search_company", 'alpha'); $search_company = GETPOST('search_company', 'alpha');
$search_payment_num = GETPOST('search_payment_num', 'alpha'); $search_payment_num = GETPOST('search_payment_num', 'alpha');
$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
@@ -773,10 +774,13 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie
} }
} }
// Save Button // Save + Cancel Buttons
if ($action != 'add_paiement') { if ($action != 'add_paiement') {
print '<br><div class="center"><input type="checkbox" checked name="closepaidinvoices"> '.$langs->trans("ClosePaidInvoicesAutomatically"); print '<br><div class="center"><input type="checkbox" checked name="closepaidinvoices"> '.$langs->trans("ClosePaidInvoicesAutomatically");
print '<br><input type="submit" class="button" value="'.$langs->trans('ToMakePayment').'"></div>'; print '<p>&nbsp;</p>';
print '<br><input type="submit" class="button" value="'.$langs->trans('ToMakePayment').'">';
print '<p>&nbsp;</p>';
print '<br><input type="button" class="button button-cancel" value="'.$langs->trans("Cancel").'" onClick="javascript:history.go(-1)"></div>';
} }
// Form to confirm payment // Form to confirm payment

View File

@@ -11,17 +11,28 @@ use OAuth\Common\Http\Exception\TokenResponseException;
use OAuth\OAuth2\Service\Exception\InvalidAccessTypeException; use OAuth\OAuth2\Service\Exception\InvalidAccessTypeException;
use OAuth\Common\Http\Uri\Uri; use OAuth\Common\Http\Uri\Uri;
/**
* Class For WordPress OAuth
*/
class WordPress extends AbstractService class WordPress extends AbstractService
{ {
/**
* @var string
*/
protected $accessType = 'online'; protected $accessType = 'online';
public function __construct( /**
CredentialsInterface $credentials, * Construct
ClientInterface $httpClient, *
TokenStorageInterface $storage, * @param CredentialsInterface $credentials credentials
$scopes = array(), * @param ClientInterface $httpClient httpClient
UriInterface $baseApiUri = null * @param TokenStorageInterface $storage storage
) { * @param $scopes scope
* @param UriInterface|null $baseApiUri baseApiUri
* @throws Exception\InvalidScopeException
*/
public function __construct(CredentialsInterface $credentials, ClientInterface $httpClient, TokenStorageInterface $storage, $scopes = array(), UriInterface $baseApiUri = null)
{
parent::__construct($credentials, $httpClient, $storage, $scopes, $baseApiUri, true); parent::__construct($credentials, $httpClient, $storage, $scopes, $baseApiUri, true);
if (null === $baseApiUri) { if (null === $baseApiUri) {
@@ -41,7 +52,7 @@ class WordPress extends AbstractService
}*/ }*/
/** /**
* {@inheritdoc} * @return Uri
*/ */
public function getAuthorizationEndpoint() public function getAuthorizationEndpoint()
{ {
@@ -49,7 +60,7 @@ class WordPress extends AbstractService
} }
/** /**
* {@inheritdoc} * @return Uri
*/ */
public function getAccessTokenEndpoint() public function getAccessTokenEndpoint()
{ {
@@ -57,7 +68,7 @@ class WordPress extends AbstractService
} }
/** /**
* {@inheritdoc} * @return int
*/ */
protected function getAuthorizationMethod() protected function getAuthorizationMethod()
{ {
@@ -66,7 +77,9 @@ class WordPress extends AbstractService
} }
/** /**
* {@inheritdoc} * @param $responseBody responseBody
* @return StdOAuth2Token
* @throws TokenResponseException
*/ */
protected function parseAccessTokenResponse($responseBody) protected function parseAccessTokenResponse($responseBody)
{ {

View File

@@ -420,29 +420,26 @@ if (!file_exists($conffile)) {
if (GETPOST('allowupgrade')) { if (GETPOST('allowupgrade')) {
$allowupgrade = true; $allowupgrade = true;
} }
$migrationscript = array(
array('from'=>'3.0.0', 'to'=>'3.1.0'), $dir = DOL_DOCUMENT_ROOT."/install/mysql/migration/"; // We use mysql migration scripts whatever is database driver
array('from'=>'3.1.0', 'to'=>'3.2.0'), dolibarr_install_syslog("Scan sql files for migration files in ".$dir);
array('from'=>'3.2.0', 'to'=>'3.3.0'),
array('from'=>'3.3.0', 'to'=>'3.4.0'), // Get files list of migration file x.y.z-a.b.c.sql into /install/mysql/migration
array('from'=>'3.4.0', 'to'=>'3.5.0'), $migrationscript = array();
array('from'=>'3.5.0', 'to'=>'3.6.0'), $handle = opendir($dir);
array('from'=>'3.6.0', 'to'=>'3.7.0'), if (is_resource($handle)) {
array('from'=>'3.7.0', 'to'=>'3.8.0'), while (($file = readdir($handle)) !== false) {
array('from'=>'3.8.0', 'to'=>'3.9.0'), $reg = array();
array('from'=>'3.9.0', 'to'=>'4.0.0'), if (preg_match('/^(\d+\.\d+\.\d+)-(\d+\.\d+\.\d+)\.sql$/i', $file, $reg)) {
array('from'=>'4.0.0', 'to'=>'5.0.0'), if (!empty($reg[2]) && version_compare(DOL_VERSION, $reg[2])) {
array('from'=>'5.0.0', 'to'=>'6.0.0'), $migrationscript[] = array('from' => $reg[1], 'to' => $reg[2]);
array('from'=>'6.0.0', 'to'=>'7.0.0'), }
array('from'=>'7.0.0', 'to'=>'8.0.0'), }
array('from'=>'8.0.0', 'to'=>'9.0.0'), }
array('from'=>'9.0.0', 'to'=>'10.0.0'), $migrationscript = dol_sort_array($migrationscript, 'from', 'asc', 1);
array('from'=>'10.0.0', 'to'=>'11.0.0'), } else {
array('from'=>'11.0.0', 'to'=>'12.0.0'), print '<div class="error">'.$langs->trans("ErrorCanNotReadDir", $dir).'</div>';
array('from'=>'12.0.0', 'to'=>'13.0.0'), }
array('from'=>'13.0.0', 'to'=>'14.0.0'),
array('from'=>'14.0.0', 'to'=>'15.0.0'),
);
$count = 0; $count = 0;
foreach ($migrationscript as $migarray) { foreach ($migrationscript as $migarray) {

View File

@@ -39,3 +39,5 @@ UPDATE llx_rights_def SET perms = 'writeall' WHERE perms = 'writeall_advance' AN
-- v16 -- v16
-- Missing in v14 or lower
ALTER TABLE llx_projet_task_time ADD COLUMN fk_product integer NULL;

View File

@@ -24,6 +24,7 @@ create table llx_projet_task_time
task_datehour datetime, -- day + hour task_datehour datetime, -- day + hour
task_date_withhour integer DEFAULT 0, -- 0 by default, 1 if date was entered with start hour task_date_withhour integer DEFAULT 0, -- 0 by default, 1 if date was entered with start hour
task_duration double, task_duration double,
fk_product integer NULL,
fk_user integer, fk_user integer,
thm double(24,8), thm double(24,8),
invoice_id integer DEFAULT NULL, -- If we need to invoice each line of timespent, we can save invoice id here invoice_id integer DEFAULT NULL, -- If we need to invoice each line of timespent, we can save invoice id here

View File

@@ -13,7 +13,7 @@
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
/** /**
@@ -21,6 +21,18 @@
* \ingroup Intracomm report * \ingroup Intracomm report
* \brief Page to manage intracomm report export * \brief Page to manage intracomm report export
*/ */
/** Terms
*
* DEB = Declaration d'Exchanges de Biens (FR) = Declaration of Exchange of Goods (EN)
* DES = Déclaration Européenne de Services (FR) = European Declaration of Services (EN)
*
* INTRACOMM: Douanes françaises (FR) = french customs (EN) - https://www.douane.gouv.fr/professionnels/commerce-international/import-export
*
*/
require '../main.inc.php'; require '../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/functions.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/functions.lib.php';
@@ -29,7 +41,7 @@ require_once DOL_DOCUMENT_ROOT.'/intracommreport/class/intracommreport.class.php
$langs->loadLangs(array("intracommreport")); $langs->loadLangs(array("intracommreport"));
$action = GETPOST('action'); $action = GETPOST('action');
$exporttype = GETPOSTISSET('exporttype') ? GETPOST('exporttype', 'alphanohtml') : 'deb'; // DEB ou DES $exporttype = GETPOSTISSET('exporttype') ? GETPOST('exporttype', 'alphanohtml') : 'deb'; // DEB or DES
$year = GETPOSTINT('year'); $year = GETPOSTINT('year');
$month = GETPOSTINT('month'); $month = GETPOSTINT('month');
$label = (string) GETPOST('label', 'alphanohtml'); $label = (string) GETPOST('label', 'alphanohtml');

View File

@@ -1300,6 +1300,17 @@ class Mo extends CommonObject
{ {
global $langs, $hookmanager, $conf, $form; global $langs, $hookmanager, $conf, $form;
$langs->load('stocks');
$text_stock_options = $langs->trans("RealStockDesc").'<br>';
$text_stock_options .= $langs->trans("RealStockWillAutomaticallyWhen").'<br>';
$text_stock_options .= (!empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT) || !empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT_CLOSE) ? '- '.$langs->trans("DeStockOnShipment").'<br>' : '');
$text_stock_options .= (!empty($conf->global->STOCK_CALCULATE_ON_VALIDATE_ORDER) ? '- '.$langs->trans("DeStockOnValidateOrder").'<br>' : '');
$text_stock_options .= (!empty($conf->global->STOCK_CALCULATE_ON_BILL) ? '- '.$langs->trans("DeStockOnBill").'<br>' : '');
$text_stock_options .= (!empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_BILL) ? '- '.$langs->trans("ReStockOnBill").'<br>' : '');
$text_stock_options .= (!empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER) ? '- '.$langs->trans("ReStockOnValidateOrder").'<br>' : '');
$text_stock_options .= (!empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER) ? '- '.$langs->trans("ReStockOnDispatchOrder").'<br>' : '');
$text_stock_options .= (!empty($conf->global->STOCK_CALCULATE_ON_RECEPTION) || !empty($conf->global->STOCK_CALCULATE_ON_RECEPTION_CLOSE) ? '- '.$langs->trans("StockOnReception").'<br>' : '');
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
print '<td>'.$langs->trans('Ref').'</td>'; print '<td>'.$langs->trans('Ref').'</td>';
print '<td class="right">'.$langs->trans('Qty'); print '<td class="right">'.$langs->trans('Qty');
@@ -1309,6 +1320,8 @@ class Mo extends CommonObject
print ' <span class="opacitymedium">('.$langs->trans("ForAQuantityToConsumeOf", $this->bom->qty).')</span>'; print ' <span class="opacitymedium">('.$langs->trans("ForAQuantityToConsumeOf", $this->bom->qty).')</span>';
} }
print '</td>'; print '</td>';
print '<td class="center">'.$form->textwithpicto($langs->trans("PhysicalStock"), $text_stock_options, 1).'</td>';
print '<td class="center">'.$form->textwithpicto($langs->trans("VirtualStock"), $langs->trans("VirtualStockDesc")).'</td>';
print '<td class="center">'.$langs->trans('QtyFrozen').'</td>'; print '<td class="center">'.$langs->trans('QtyFrozen').'</td>';
print '<td class="center">'.$langs->trans('DisableStockChange').'</td>'; print '<td class="center">'.$langs->trans('DisableStockChange').'</td>';
//print '<td class="right">'.$langs->trans('Efficiency').'</td>'; //print '<td class="right">'.$langs->trans('Efficiency').'</td>';
@@ -1358,6 +1371,7 @@ class Mo extends CommonObject
if (!empty($line->fk_product)) { if (!empty($line->fk_product)) {
$productstatic = new Product($this->db); $productstatic = new Product($this->db);
$productstatic->fetch($line->fk_product); $productstatic->fetch($line->fk_product);
$productstatic->load_virtual_stock();
$this->tpl['label'] .= $productstatic->getNomUrl(1); $this->tpl['label'] .= $productstatic->getNomUrl(1);
//$this->tpl['label'].= ' - '.$productstatic->label; //$this->tpl['label'].= ' - '.$productstatic->label;
} else { } else {
@@ -1370,6 +1384,9 @@ class Mo extends CommonObject
$this->tpl['qty_bom'] = $this->bom->qty; $this->tpl['qty_bom'] = $this->bom->qty;
} }
$this->tpl['stock'] = $productstatic->stock_reel;
$this->tpl['seuil_stock_alerte'] = $productstatic->seuil_stock_alerte;
$this->tpl['virtual_stock'] = $productstatic->stock_theorique;
$this->tpl['qty'] = $line->qty; $this->tpl['qty'] = $line->qty;
$this->tpl['qty_frozen'] = $line->qty_frozen; $this->tpl['qty_frozen'] = $line->qty_frozen;
$this->tpl['disable_stock_change'] = $line->disable_stock_change; $this->tpl['disable_stock_change'] = $line->disable_stock_change;

View File

@@ -39,6 +39,16 @@ $qtytoconsumeforline = price2num($qtytoconsumeforline, 'MS');
print '<tr class="oddeven'.(empty($this->tpl['strike']) ? '' : ' strikefordisabled').'">'; print '<tr class="oddeven'.(empty($this->tpl['strike']) ? '' : ' strikefordisabled').'">';
print '<td>'.$this->tpl['label'].'</td>'; print '<td>'.$this->tpl['label'].'</td>';
print '<td class="right">'.$this->tpl['qty'].(($this->tpl['efficiency'] > 0 && $this->tpl['efficiency'] < 1) ? ' / '.$form->textwithpicto($this->tpl['efficiency'], $langs->trans("ValueOfMeansLoss")).' = '.$qtytoconsumeforline : '').'</td>'; print '<td class="right">'.$this->tpl['qty'].(($this->tpl['efficiency'] > 0 && $this->tpl['efficiency'] < 1) ? ' / '.$form->textwithpicto($this->tpl['efficiency'], $langs->trans("ValueOfMeansLoss")).' = '.$qtytoconsumeforline : '').'</td>';
print '<td class="center">'.(empty($this->tpl['stock']) ? 0 : price2num($this->tpl['stock'], 'MS'));
if ($this->tpl['seuil_stock_alerte'] != '' && ($this->tpl['stock'] < $this->tpl['seuil_stock_alerte'])) {
print ' '.img_warning($langs->trans("StockLowerThanLimit", $this->tpl['seuil_stock_alerte']));
}
print '</td>';
print '<td class="center">'.((empty($this->tpl['virtual_stock']) ? 0 : price2num($this->tpl['virtual_stock'], 'MS')));
if ($this->tpl['seuil_stock_alerte'] != '' && ($this->tpl['virtual_stock'] < $this->tpl['seuil_stock_alerte'])) {
print ' '.img_warning($langs->trans("StockLowerThanLimit", $this->tpl['seuil_stock_alerte']));
}
print '</td>';
print '<td class="center">'.($this->tpl['qty_frozen'] ? yn($this->tpl['qty_frozen']) : '').'</td>'; print '<td class="center">'.($this->tpl['qty_frozen'] ? yn($this->tpl['qty_frozen']) : '').'</td>';
print '<td class="center">'.($this->tpl['disable_stock_change'] ? yn($this->tpl['disable_stock_change']) : '').'</td>'; print '<td class="center">'.($this->tpl['disable_stock_change'] ? yn($this->tpl['disable_stock_change']) : '').'</td>';
//print '<td class="right">'.$this->tpl['efficiency'].'</td>'; //print '<td class="right">'.$this->tpl['efficiency'].'</td>';