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

develop
This commit is contained in:
Laurent Destailleur 2023-09-02 20:54:10 +02:00
commit 247ab6a93e
16 changed files with 132 additions and 114 deletions

View File

@ -82,6 +82,11 @@ class Commande extends CommonOrder
*/
public $ismultientitymanaged = 1;
/**
* @var int Does object support extrafields ? 0=No, 1=Yes
*/
public $isextrafieldmanaged = 1;
/**
* 0=Default, 1=View may be restricted to sales representative only if no permission to see all or to company of external user if external user
* @var integer

View File

@ -90,6 +90,11 @@ class Facture extends CommonInvoice
*/
public $ismultientitymanaged = 1;
/**
* @var int Does object support extrafields ? 0=No, 1=Yes
*/
public $isextrafieldmanaged = 1;
/**
* 0=Default, 1=View may be restricted to sales representative only if no permission to see all or to company of external user if external user
* @var integer

View File

@ -60,6 +60,11 @@ class Contact extends CommonObject
*/
public $ismultientitymanaged = 1;
/**
* @var int Does object support extrafields ? 0=No, 1=Yes
*/
public $isextrafieldmanaged = 1;
/**
* @var string String with name of icon for myobject. Must be the part after the 'object_' into object_myobject.png
*/

View File

@ -4315,6 +4315,9 @@ abstract class CommonObject
if (empty($fk_object_where) || empty($field_where) || empty($table_element)) {
return -1;
}
if (!preg_match('/^[_a-zA-Z0-9]+$/', $field_select)) {
dol_syslog('Invalid value $field_select for parameter '.$field_select.' in call to getAllItemsLinkedByObjectID(). Must be a single field name.', LOG_ERR);
}
global $db;
@ -4331,6 +4334,35 @@ abstract class CommonObject
return $TRes;
}
/**
* Count items linked to an object id in association table
*
* @param int $fk_object_where id of object we need to get linked items
* @param string $field_where name of field of object we need to get linked items
* @param string $table_element name of association table
* @return array|int Array of record, -1 if empty
*/
public static function getCountOfItemsLinkedByObjectID($fk_object_where, $field_where, $table_element)
{
if (empty($fk_object_where) || empty($field_where) || empty($table_element)) {
return -1;
}
global $db;
$sql = "SELECT COUNT(*) as nb FROM ".$db->prefix().$table_element." WHERE ".$field_where." = ".((int) $fk_object_where);
$resql = $db->query($sql);
$n = 0;
if ($resql) {
$res = $db->fetch_object($resql);
if ($res) {
$n = $res->nb;
}
}
return $n;
}
/**
* Function used to remove all items linked to an object id in association table
*

View File

@ -287,7 +287,6 @@ class Conf
$this->commande = new stdClass();
$this->propal = new stdClass();
$this->facture = new stdClass();
$this->contrat = new stdClass();
$this->user = new stdClass();
$this->adherent = new stdClass();
$this->bank = new stdClass();

View File

@ -6606,7 +6606,7 @@ class Form
* @param int $disabled Disable input fields
* @param int $fullday When a checkbox with this html name is on, hour and day are set with 00:00 or 23:59
* @param string $addplusone Add a link "+1 hour". Value must be name of another select_date field.
* @param datetime $adddateof Add a link "Date of invoice" using the following date.
* @param int|string $adddateof Add a link "Date of invoice" using the following date.
* @return string '' or HTML component string if nooutput is 1
* @deprecated
* @see selectDate(), form_date(), select_month(), select_year(), select_dayofweek()
@ -6614,6 +6614,7 @@ class Form
public function select_date($set_time = '', $prefix = 're', $h = 0, $m = 0, $empty = 0, $form_name = "", $d = 1, $addnowlink = 0, $nooutput = 0, $disabled = 0, $fullday = '', $addplusone = '', $adddateof = '')
{
// phpcs:enable
dol_syslog(__METHOD__ . ': using select_date is deprecated. Use selectDate instead.', LOG_WARNING);
$retstring = $this->selectDate($set_time, $prefix, $h, $m, $empty, $form_name, $d, $addnowlink, $disabled, $fullday, $addplusone, $adddateof);
if (!empty($nooutput)) {
return $retstring;
@ -6668,7 +6669,7 @@ class Form
* @param int $disabled Disable input fields
* @param int $fullday When a checkbox with id #fullday is checked, hours are set with 00:00 (if value if 'fulldaystart') or 23:59 (if value is 'fulldayend')
* @param string $addplusone Add a link "+1 hour". Value must be name of another selectDate field.
* @param datetime|string|array $adddateof Add a link "Date of ..." using the following date. Must be array(array('adddateof'=>..., 'labeladddateof'=>...))
* @param int|string|array $adddateof Add a link "Date of ..." using the following date. Must be array(array('adddateof'=>..., 'labeladddateof'=>...))
* @param string $openinghours Specify hour start and hour end for the select ex 8,20
* @param int $stepminutes Specify step for minutes between 1 and 30
* @param string $labeladddateof Label to use for the $adddateof parameter. Deprecated. Used only when $adddateof is not an array.
@ -8055,6 +8056,9 @@ class Form
// Search data
$sql = "SELECT t.rowid, " . $fieldstoshow . " FROM " . $this->db->prefix() . $objecttmp->table_element . " as t";
if (!empty($objecttmp->isextrafieldmanaged)) {
$sql .= " LEFT JOIN " . $this->db->prefix() . $objecttmp->table_element . "_extrafields as e ON t.rowid=e.fk_object";
}
if (isset($objecttmp->ismultientitymanaged)) {
if (!is_numeric($objecttmp->ismultientitymanaged)) {
$tmparray = explode('@', $objecttmp->ismultientitymanaged);

View File

@ -134,6 +134,7 @@ class FormMail extends Form
public $withtocc;
public $withtoccc;
public $withtopic;
public $witherrorsto;
/**
* @var int 0=No attaches files, 1=Show attached files, 2=Can add new attached files
@ -150,13 +151,21 @@ class FormMail extends Form
public $withreplytoreadonly;
public $withtoreadonly;
public $withtoccreadonly;
public $witherrorstoreadonly;
public $withtocccreadonly;
public $withtopicreadonly;
public $withbodyreadonly;
public $withfilereadonly;
public $withdeliveryreceipt;
public $withcancel;
public $withdeliveryreceiptreadonly;
public $withfckeditor;
/**
* @var string ckeditortoolbar
*/
public $ckeditortoolbar;
public $substit = array();
public $substit_lines = array();
public $param = array();

View File

@ -62,6 +62,7 @@ class FormSms
public $withreplytoreadonly;
public $withtoreadonly;
public $withtopicreadonly;
public $withbodyreadonly;
public $withcancel;
public $substit = array();

View File

@ -214,7 +214,7 @@ function project_prepare_head(Project $project, $moreparam = '')
if (isModEnabled('ticket') && $user->hasRight('ticket', 'read')) {
require_once DOL_DOCUMENT_ROOT.'/ticket/class/ticket.class.php';
$Tickettatic = new Ticket($db);
$nbTicket = count($Tickettatic->getAllItemsLinkedByObjectID($project->id, '*', 'fk_project', 'ticket'));
$nbTicket = $Tickettatic->getCountOfItemsLinkedByObjectID($project->id, 'fk_project', 'ticket');
$head[$h][0] = DOL_URL_ROOT.'/ticket/list.php?projectid='.((int) $project->id);
$head[$h][1] = $langs->trans("Ticket");
if ($nbTicket > 0) {

View File

@ -329,6 +329,34 @@ class doc_generic_invoice_odt extends ModelePDFFactures
}
}
// and determine category of operation
$categoryOfOperation = 0;
$nbProduct = 0;
$nbService = 0;
foreach ($object->lines as $line) {
// determine category of operation
if ($categoryOfOperation < 2) {
$lineProductType = $line->product_type;
if ($lineProductType == Product::TYPE_PRODUCT) {
$nbProduct++;
} elseif ($lineProductType == Product::TYPE_SERVICE) {
$nbService++;
}
if ($nbProduct > 0 && $nbService > 0) {
// mixed products and services
$categoryOfOperation = 2;
}
}
}
// determine category of operation
if ($categoryOfOperation <= 0) {
// only services
if ($nbProduct == 0 && $nbService > 0) {
$categoryOfOperation = 1;
}
}
// Make substitution
$substitutionarray = array(
'__FROM_NAME__' => $this->emetteur->name,
@ -402,6 +430,7 @@ class doc_generic_invoice_odt extends ModelePDFFactures
// TODO Search all tags {object_...:xxxx} into template then loop on this found tags to analyze them and the the corresponding
// property of object and use the xxxx to know how to format it.
// Before that, we hard code this substitution as if we have found them into the template.
$tmparray['object_PREVIOUS_MONTH'] = dol_print_date(dol_time_plus_duree($object->date, -1, 'm'), '%m');
$tmparray['object_MONTH'] = dol_print_date($object->date, '%m');
$tmparray['object_NEXT_MONTH'] = dol_print_date(dol_time_plus_duree($object->date, 1, 'm'), '%m');
@ -411,6 +440,8 @@ class doc_generic_invoice_odt extends ModelePDFFactures
$tmparray['object_PREVIOUS_YEAR'] = dol_print_date(dol_time_plus_duree($object->date, -1, 'y'), '%Y');
$tmparray['object_YEAR'] = dol_print_date($object->date, '%Y');
$tmparray['object_NEXT_YEAR'] = dol_print_date(dol_time_plus_duree($object->date, 1, 'y'), '%Y');
$tmparray['object_productorservice_operation'] = $outputlangs->transnoentities("MentionCategoryOfOperations" . $categoryOfOperation);
// Call the ODTSubstitution hook
$parameters = array('odfHandler'=>&$odfHandler, 'file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$tmparray);

View File

@ -79,6 +79,11 @@ class Expedition extends CommonObject
*/
public $ismultientitymanaged = 1;
/**
* @var int Does object support extrafields ? 0=No, 1=Yes
*/
public $isextrafieldmanaged = 1;
/**
* @var string String with name of icon for myobject. Must be the part after the 'object_' into object_myobject.png
*/

View File

@ -3,7 +3,7 @@
* Copyright (C) 2004-2007 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2009 Regis Houssin <regis.houssin@inodbox.com>
* Copyright (C) 2008 Raphael Bertrand (Resultic) <raphael.bertrand@resultic.fr>
* Copyright (C) 2019 Frédéric France <frederic.france@netlogic.fr>
* Copyright (C) 2019-2023 Frédéric France <frederic.france@netlogic.fr>
*
* 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
@ -26,7 +26,7 @@
* \brief File containing class for advanced numbering model of Partnership
*/
dol_include_once('/partnership/core/modules/partnership/modules_partnership.php');
require_once DOL_DOCUMENT_ROOT.'/partnership/core/modules/partnership/modules_partnership.php';
/**
@ -54,22 +54,23 @@ class mod_partnership_advanced extends ModeleNumRefPartnership
/**
* Returns the description of the numbering model
*
* @param Translate $langs Lang object to use for output
* @return string Descriptive text
*/
public function info()
public function info($langs)
{
global $conf, $langs, $db;
global $db;
$langs->load("bills");
$form = new Form($db);
$texte = $langs->trans('GenericNumRefModelDesc')."<br>\n";
$texte .= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
$texte .= '<input type="hidden" name="token" value="'.newToken().'">';
$texte .= '<input type="hidden" name="action" value="updateMask">';
$texte .= '<input type="hidden" name="maskconst" value="PARTNERSHIP_ADVANCED_MASK">';
$texte .= '<table class="nobordernopadding" width="100%">';
$text = $langs->trans('GenericNumRefModelDesc')."<br>\n";
$text .= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
$text .= '<input type="hidden" name="token" value="'.newToken().'">';
$text .= '<input type="hidden" name="action" value="updateMask">';
$text .= '<input type="hidden" name="maskconst" value="PARTNERSHIP_ADVANCED_MASK">';
$text .= '<table class="nobordernopadding" width="100%">';
$tooltip = $langs->trans("GenericMaskCodes", $langs->transnoentities("Partnership"), $langs->transnoentities("Partnership"));
$tooltip .= $langs->trans("GenericMaskCodes2");
@ -78,17 +79,17 @@ class mod_partnership_advanced extends ModeleNumRefPartnership
$tooltip .= $langs->trans("GenericMaskCodes5");
// Parametrage du prefix
$texte .= '<tr><td>'.$langs->trans("Mask").':</td>';
$texte .= '<td class="right">'.$form->textwithpicto('<input type="text" class="flat minwidth175" name="maskPartnership" value="'.getDolGlobalString('PARTNERSHIP_ADVANCED_MASK').'">', $tooltip, 1, 1).'</td>';
$text .= '<tr><td>'.$langs->trans("Mask").':</td>';
$text .= '<td class="right">'.$form->textwithpicto('<input type="text" class="flat minwidth175" name="maskPartnership" value="'.getDolGlobalString('PARTNERSHIP_ADVANCED_MASK').'">', $tooltip, 1, 1).'</td>';
$texte .= '<td class="left" rowspan="2">&nbsp; <input type="submit" class="button button-edit" name="Button"value="'.$langs->trans("Modify").'"></td>';
$text .= '<td class="left" rowspan="2">&nbsp; <input type="submit" class="button button-edit" name="Button"value="'.$langs->trans("Modify").'"></td>';
$texte .= '</tr>';
$text .= '</tr>';
$texte .= '</table>';
$texte .= '</form>';
$text .= '</table>';
$text .= '</form>';
return $texte;
return $text;
}
/**

View File

@ -22,7 +22,7 @@
* \ingroup partnership
* \brief File of class to manage Partnership numbering rules standard
*/
dol_include_once('/partnership/core/modules/partnership/modules_partnership.php');
require_once DOL_DOCUMENT_ROOT.'/partnership/core/modules/partnership/modules_partnership.php';
/**
@ -52,11 +52,11 @@ class mod_partnership_standard extends ModeleNumRefPartnership
/**
* Return description of numbering module
*
* @return string Text with description
* @param Translate $langs Lang object to use for output
* @return string Text with description
*/
public function info()
public function info($langs)
{
global $langs;
return $langs->trans("SimpleNumRefModelDesc", $this->prefix);
}

View File

@ -29,6 +29,7 @@
*/
require_once DOL_DOCUMENT_ROOT.'/core/class/commondocgenerator.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/commonnumrefgenerator.class.php';
require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; // required for use by classes that inherit
@ -66,93 +67,7 @@ abstract class ModelePDFPartnership extends CommonDocGenerator
/**
* Parent class to manage numbering of Partnership
*/
abstract class ModeleNumRefPartnership
abstract class ModeleNumRefPartnership extends CommonNumRefGenerator
{
/**
* @var string Error code (or message)
*/
public $error = '';
/**
* Return if a module can be used or not
*
* @return boolean true if module can be used
*/
public function isEnabled()
{
return true;
}
/**
* Returns the default description of the numbering template
*
* @return string Descriptive text
*/
public function info()
{
global $langs;
$langs->load("partnership");
return $langs->trans("NoDescription");
}
/**
* Returns an example of numbering
*
* @return string Example
*/
public function getExample()
{
global $langs;
$langs->load("partnership");
return $langs->trans("NoExample");
}
/**
* Checks if the numbers already in the database do not
* cause conflicts that would prevent this numbering working.
*
* @param Object $object Object we need next value for
* @return boolean false if conflict, true if ok
*/
public function canBeActivated($object)
{
return true;
}
/**
* Returns next assigned value
*
* @param Object $object Object we need next value for
* @return string Valeur
*/
public function getNextValue($object)
{
global $langs;
return $langs->trans("NotAvailable");
}
/**
* Returns version of numbering module
*
* @return string Valeur
*/
public function getVersion()
{
global $langs;
$langs->load("admin");
if ($this->version == 'development') {
return $langs->trans("VersionDevelopment");
}
if ($this->version == 'experimental') {
return $langs->trans("VersionExperimental");
}
if ($this->version == 'dolibarr') {
return DOL_VERSION;
}
if ($this->version) {
return $this->version;
}
return $langs->trans("NotAvailable");
}
// No overload code
}

View File

@ -145,7 +145,7 @@ function print_paypal_redirect($paymentAmount, $currencyCodeType, $paymentType,
$ErrorSeverityCode = urldecode($resArray["L_SEVERITYCODE0"]);
if ($ErrorCode == 10729) {
$mesg .= "PayPal can't accept payments for this thirdparty. An address is defined but is not complete (missing State).<br>Ask system administrator to fix address or to setup Paypal module to accept payments even on not complete addresses (remove option PAYPAL_REQUIRE_VALID_SHIPPING_ADDRESS).<br>\n";
$mesg = "PayPal can't accept payments for this thirdparty. An address is defined but is not complete (missing State).<br>Ask system administrator to fix address or to setup Paypal module to accept payments even on not complete addresses (remove option PAYPAL_REQUIRE_VALID_SHIPPING_ADDRESS).<br>\n";
} else {
$mesg = $langs->trans('SetExpressCheckoutAPICallFailed')."<br>\n";
$mesg .= $langs->trans('DetailedErrorMessage').": ".$ErrorLongMsg."<br>\n";

View File

@ -93,6 +93,7 @@ class Reception extends CommonObject
public $depth_units;
// A denormalized value
public $trueSize;
public $size_units;
public $date_delivery; // Date delivery planed
@ -121,6 +122,11 @@ class Reception extends CommonObject
public $meths;
public $listmeths; // List of carriers
/**
* @var CommandeFournisseur
*/
public $commandeFournisseur;
/**
* @var CommandeFournisseurDispatch[]
*/