Skip to content

Commit

Permalink
Merge branch 'develop' into patch-10
Browse files Browse the repository at this point in the history
  • Loading branch information
frederic34 authored Nov 12, 2024
2 parents ef800a1 + 4054448 commit 0c590fb
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 22 deletions.
6 changes: 3 additions & 3 deletions htdocs/barcode/printsheet.php
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@
// Get encoder (barcode_type_coder) from barcode type id (barcode_type)
$stdobject = new GenericObject($db);
$stdobject->barcode_type = $fk_barcode_type;
$result = $stdobject->fetch_barcode();
$result = $stdobject->fetchBarCode();
if ($result <= 0) {
$error++;
setEventMessages('Failed to get bar code type information '.$stdobject->error, $stdobject->errors, 'errors');
Expand All @@ -171,8 +171,8 @@

if (!$error && $stdobject !== null) {
$code = $forbarcode;
$generator = $stdobject->barcode_type_coder; // coder (loaded by fetch_barcode). Engine.
$encoding = strtoupper($stdobject->barcode_type_code); // code (loaded by fetch_barcode). Example 'ean', 'isbn', ...
$generator = $stdobject->barcode_type_coder; // coder (loaded by fetchBarCode). Engine.
$encoding = strtoupper($stdobject->barcode_type_code); // code (loaded by fetchBarCode). Example 'ean', 'isbn', ...

$diroutput = $conf->barcode->dir_temp;
dol_mkdir($diroutput);
Expand Down
4 changes: 3 additions & 1 deletion htdocs/compta/facture/class/facture-rec.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -203,8 +203,10 @@ class FactureRec extends CommonInvoice
*/
public $fk_societe_rib;


const PAYMENTCODETOEDITSOCIETERIB = "PRE";


/**
* 'type' if the field format ('integer', 'integer:ObjectClass:PathToClass[:AddCreateButtonOrNot[:Filter]]', 'varchar(x)', 'double(24,8)', 'real', 'price', 'text', 'html', 'date', 'datetime', 'timestamp', 'duration', 'mail', 'phone', 'url', 'password')
* Note: Filter can be a string like "(t.ref:like:'SO-%') or (t.date_creation:<:'20160101') or (t.nature:is:NULL)"
Expand Down Expand Up @@ -567,7 +569,7 @@ public function update(User $user, $notrigger = 0)
$sql .= " localtax1 = ".((float) $this->total_localtax1).",";
$sql .= " localtax2 = ".((float) $this->total_localtax2).",";
$sql .= " total_ht = ".((float) $this->total_ht).",";
$sql .= " total_ttc = ".((float) $this->total_ttc);
$sql .= " total_ttc = ".((float) $this->total_ttc).",";
$sql .= " fk_societe_rib = ".((int) $this->fk_societe_rib);
// TODO Add missing fields
$sql .= " WHERE rowid = ".((int) $this->id);
Expand Down
34 changes: 22 additions & 12 deletions htdocs/core/class/commonobject.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -425,25 +425,25 @@ abstract class CommonObject

/**
* @var int Barcode type
* @see fetch_barcode()
* @see fetchBarCode()
*/
public $barcode_type;

/**
* @var string Code of the barcode type
* @see fetch_barcode(), barcode_type
* @see fetchBarCode(), barcode_type
*/
public $barcode_type_code;

/**
* @var string Label of the barcode type
* @see fetch_barcode(), barcode_type
* @see fetchBarCode(), barcode_type
*/
public $barcode_type_label;

/**
* @var string
* @see fetch_barcode(), barcode_type
* @see fetchBarCode(), barcode_type
*/
public $barcode_type_coder;

Expand Down Expand Up @@ -1631,7 +1631,7 @@ public function swapContactStatus($rowid)
* @param int<0,1> $option 0=Return array id->label, 1=Return array code->label, 2=Return complete array
* @param int<0,1> $activeonly 0=all status of contact, 1=only the active
* @param string $code Type of contact (Example: 'CUSTOMER', 'SERVICE')
* @return array<int,string>|array<string,string>|array<int,array>|null Array list of type of contacts (id->label if option=0, code->label if option=1), or null if error
* @return array<int,string>|array<string,string>|array<int,array{id:int,code:string,label:string}>|null Array list of type of contacts (id->label if option=0, code->label if option=1), or null if error
*/
public function liste_type_contact($source = 'internal', $order = 'position', $option = 0, $activeonly = 0, $code = '')
{
Expand Down Expand Up @@ -1702,7 +1702,7 @@ public function liste_type_contact($source = 'internal', $order = 'position', $o
*/
public function listeTypeContacts($source = 'internal', $option = 0, $activeonly = 0, $code = '', $element = '', $excludeelement = '')
{
global $langs, $conf;
global $langs;

$langs->loadLangs(array('bills', 'contracts', 'interventions', 'orders', 'projects', 'propal', 'ticket', 'agenda'));

Expand Down Expand Up @@ -1784,8 +1784,6 @@ public function listeTypeContacts($source = 'internal', $option = 0, $activeonly
*/
public function getIdContact($source, $code, $status = 0)
{
global $conf;

$result = array();
$i = 0;
// Particular case for shipping
Expand Down Expand Up @@ -1952,13 +1950,24 @@ public function fetchOneLike($ref)
* if it is not defined, ->element must be defined to know default barcode type.
*
* @return int<-1,1> Return integer <0 if KO, 0 if can't guess type of barcode (ISBN, EAN13...), >0 if OK (all barcode properties loaded)
* @deprecated Use fetchBarCode()
*/
public function fetch_barcode()
{
// phpcs:enable
global $conf;
return fetchBarCode();

Check failure on line 1958 in htdocs/core/class/commonobject.class.php

View workflow job for this annotation

GitHub Actions / phpstan / php-stan (8.2)

Function fetchBarCode not found.

Check failure on line 1958 in htdocs/core/class/commonobject.class.php

View workflow job for this annotation

GitHub Actions / phan / Run phan

commonobject.class.php: PhanUndeclaredFunction: Call to undeclared function \fetchBarCode()
}

dol_syslog(get_class($this).'::fetch_barcode this->element='.$this->element.' this->barcode_type='.$this->barcode_type);
/**
* Load data for barcode into properties ->barcode_type*
* Properties ->barcode_type that is id of barcode. Type is used to find other properties, but
* if it is not defined, ->element must be defined to know default barcode type.
*
* @return int<-1,1> Return integer <0 if KO, 0 if can't guess type of barcode (ISBN, EAN13...), >0 if OK (all barcode properties loaded)
*/
public function fetchBarCode()
{
dol_syslog(get_class($this).'::fetchBarCode this->element='.$this->element.' this->barcode_type='.$this->barcode_type);

$idtype = $this->barcode_type;
if (empty($idtype) && $idtype != '0') { // If type of barcode no set, we try to guess. If set to '0' it means we forced to have type remain not defined
Expand All @@ -1967,7 +1976,7 @@ public function fetch_barcode()
} elseif ($this->element == 'societe') {
$idtype = getDolGlobalString('GENBARCODE_BARCODETYPE_THIRDPARTY');
} else {
dol_syslog('Call fetch_barcode with barcode_type not defined and cannot be guessed', LOG_WARNING);
dol_syslog('Call fetchBarCode with barcode_type not defined and cannot be guessed', LOG_WARNING);
}
}

Expand All @@ -1976,10 +1985,11 @@ public function fetch_barcode()
$sql = "SELECT rowid, code, libelle as label, coder";
$sql .= " FROM ".$this->db->prefix()."c_barcode_type";
$sql .= " WHERE rowid = ".((int) $idtype);
dol_syslog(get_class($this).'::fetch_barcode', LOG_DEBUG);

$resql = $this->db->query($sql);
if ($resql) {
$obj = $this->db->fetch_object($resql);

$this->barcode_type = $obj->rowid;
$this->barcode_type_code = $obj->code;
$this->barcode_type_label = $obj->label;
Expand Down
4 changes: 2 additions & 2 deletions htdocs/core/class/html.form.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -10290,8 +10290,8 @@ public function showbarcode(&$object, $width = 100, $morecss = '')
// Complete object if not complete
if (empty($object->barcode_type_code) || empty($object->barcode_type_coder)) {
// @phan-suppress-next-line PhanPluginUnknownObjectMethodCall
$result = $object->fetch_barcode();
//Check if fetch_barcode() failed
$result = $object->fetchBarCode();
//Check if fetchBarCode() failed
if ($result < 1) {
return '<!-- ErrorFetchBarcode -->';
}
Expand Down
6 changes: 3 additions & 3 deletions htdocs/product/card.php
Original file line number Diff line number Diff line change
Expand Up @@ -590,7 +590,7 @@
$stdobject = new GenericObject($db);
$stdobject->element = 'product';
$stdobject->barcode_type = GETPOSTINT('fk_barcode_type');
$result = $stdobject->fetch_barcode();
$result = $stdobject->fetchBarCode();
if ($result < 0) {
$error++;
$mesg = 'Failed to get bar code type information ';
Expand Down Expand Up @@ -835,7 +835,7 @@
$stdobject = new GenericObject($db);
$stdobject->element = 'product';
$stdobject->barcode_type = GETPOSTINT('fk_barcode_type');
$result = $stdobject->fetch_barcode();
$result = $stdobject->fetchBarCode();
if ($result < 0) {
$error++;
$mesg = 'Failed to get bar code type information ';
Expand Down Expand Up @@ -2555,7 +2555,7 @@
print $formbarcode->formBarcodeType($_SERVER['PHP_SELF'].'?id='.$object->id, $object->barcode_type, 'fk_barcode_type');
$fk_barcode_type = $object->barcode_type;
} else {
$object->fetch_barcode();
$object->fetchBarCode();
$fk_barcode_type = $object->barcode_type;
print $object->barcode_type_label ? $object->barcode_type_label : ($object->barcode ? '<div class="warning">'.$langs->trans("SetDefaultBarcodeType").'<div>' : '');
}
Expand Down
2 changes: 1 addition & 1 deletion htdocs/product/price_suppliers.php
Original file line number Diff line number Diff line change
Expand Up @@ -1260,7 +1260,7 @@ function edit_price_from_multicurrency() {
if (!empty($arrayfields['pfp.fk_barcode_type']['checked'])) {
print '<td class="center">';
$productfourn->barcode_type = !empty($productfourn->supplier_fk_barcode_type) ? $productfourn->supplier_fk_barcode_type : 0;
$productfourn->fetch_barcode();
$productfourn->fetchBarCode();
print $productfourn->barcode_type_label ? $productfourn->barcode_type_label : ($productfourn->supplier_barcode ? '<div class="warning">'.$langs->trans("SetDefaultBarcodeType").'<div>' : '');
print '</td>';
}
Expand Down

0 comments on commit 0c590fb

Please sign in to comment.