Merge branch '20.0' into 20.0-discount

This commit is contained in:
Laurent Destailleur 2025-02-02 02:01:26 +01:00 committed by GitHub
commit cafdcc8a0e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
20 changed files with 167 additions and 47 deletions

View File

@ -285,6 +285,40 @@ class Categorie extends CommonObject
*/
public $imgHeight;
/**
* '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)"
* 'label' the translation key.
* 'enabled' is a condition when the field must be managed (Example: 1 or 'getDolGlobalString("MY_SETUP_PARAM")'
* 'position' is the sort order of field.
* 'notnull' is set to 1 if not null in database. Set to -1 if we must set data to null if empty ('' or 0).
* 'visible' says if field is visible in list (Examples: 0=Not visible, 1=Visible on list and create/update/view forms, 2=Visible on list only, 3=Visible on create/update/view form only (not list), 4=Visible on list and update/view form only (not create). 5=Visible on list and view only (not create/not update). Using a negative value means field is not shown by default on list but can be selected for viewing)
* 'noteditable' says if field is not editable (1 or 0)
* 'default' is a default value for creation (can still be overwrote by the Setup of Default Values if field is editable in creation form). Note: If default is set to '(PROV)' and field is 'ref', the default value will be set to '(PROVid)' where id is rowid when a new record is created.
* 'index' if we want an index in database.
* 'foreignkey'=>'tablename.field' if the field is a foreign key (it is recommended to name the field fk_...).
* 'searchall' is 1 if we want to search in this field when making a search from the quick search button.
* 'isameasure' must be set to 1 if you want to have a total on list for this field. Field type must be summable like integer or double(24,8).
* 'css' is the CSS style to use on field. For example: 'maxwidth200'
* 'help' is a string visible as a tooltip on field
* 'showoncombobox' if value of the field must be visible into the label of the combobox that list record
* 'disabled' is 1 if we want to have the field locked by a 'disabled' attribute. In most cases, this is never set into the definition of $fields into class, but is set dynamically by some part of code.
* 'arrayofkeyval' to set list of value if type is a list of predefined values. For example: array("0"=>"Draft","1"=>"Active","-1"=>"Cancel")
* 'autofocusoncreate' to have field having the focus on a create form. Only 1 field should have this property set to 1.
* 'comment' is not used. You can store here any text of your choice. It is not used by application.
*
* Note: To have value dynamic, you can set value to 0 in definition and edit the value on the fly into the constructor.
*/
/**
* @var array<string,array{type:string,label:string,enabled:int<0,2>|string,position:int,notnull?:int,visible:int,noteditable?:int,default?:string,index?:int,foreignkey?:string,searchall?:int,isameasure?:int,css?:string,csslist?:string,help?:string,showoncombobox?:int,disabled?:int,arrayofkeyval?:array<int,string>,comment?:string}> Array with all fields and their property. Do not use it as a static var. It may be modified by constructor.
*/
public $fields = array(
'rowid' => array('type' => 'integer', 'label' => 'TechnicalID', 'enabled' => 1, 'visible' => -2, 'notnull' => 1, 'index' => 1, 'position' => 1, 'comment' => 'Id'),
'entity' => array('type' => 'integer', 'label' => 'Entity', 'enabled' => 1, 'visible' => 0, 'default' => '1', 'notnull' => 1, 'index' => 1, 'position' => 5),
'label' => array('type' => 'varchar(255)', 'label' => 'Label', 'enabled' => 1, 'visible' => 1, 'showoncombobox' => 1, 'position' => 15, 'csslist' => 'tdoverflowmax250'),
);
/**
* Constructor
*
@ -1751,9 +1785,9 @@ class Categorie extends CommonObject
}
// Check contrast with background and correct text color
$forced_color = 'categtextwhite';
$forced_color = 'categtextwhite'; // We want color white because the background is dark (grey or other)
if ($this->color) {
if (colorIsLight($this->color)) {
if (colorIsLight($this->color)) { // If color is light, we force color to dark
$forced_color = 'categtextblack';
}
}

View File

@ -449,20 +449,19 @@ $sql .= " FROM ".MAIN_DB_PREFIX."actioncomm as a";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."actioncomm_extrafields as ef ON (a.id = ef.fk_object)";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON a.fk_soc = s.rowid";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."socpeople as sp ON a.fk_contact = sp.rowid";
$sql .= " ,".MAIN_DB_PREFIX."c_actioncomm as c";
$sql .= " INNER JOIN ".MAIN_DB_PREFIX."c_actioncomm as c ON c.id = a.fk_action";
// We must filter on resource table
if ($resourceid > 0) {
$sql .= ", ".MAIN_DB_PREFIX."element_resources as r";
$sql .= " INNER JOIN ".MAIN_DB_PREFIX."element_resources as r ON r.element_type = 'action' AND r.element_id = a.id";
}
// We must filter on assignment table
if ($filtert > 0 || $usergroup > 0) {
$sql .= ", ".MAIN_DB_PREFIX."actioncomm_resources as ar";
$sql .= " INNER JOIN ".MAIN_DB_PREFIX."actioncomm_resources as ar ON ar.fk_actioncomm = a.id AND ar.element_type='user'";
}
if ($usergroup > 0) {
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."usergroup_user as ugu ON ugu.fk_user = ar.fk_element";
}
$sql .= " WHERE c.id = a.fk_action";
$sql .= ' AND a.entity IN ('.getEntity('agenda').')';
$sql .= " WHERE a.entity IN (".getEntity('agenda').")";
// Condition on actioncode
if (!empty($actioncode)) {
if (!getDolGlobalString('AGENDA_USE_EVENT_TYPE')) {
@ -493,7 +492,7 @@ if (!empty($actioncode)) {
}
}
if ($resourceid > 0) {
$sql .= " AND r.element_type = 'action' AND r.element_id = a.id AND r.resource_id = ".((int) $resourceid);
$sql .= " AND r.resource_id = ".((int) $resourceid);
}
if ($pid) {
$sql .= " AND a.fk_project=".((int) $pid);
@ -512,13 +511,9 @@ if ($search_sale && $search_sale != '-1') {
}
}
// Search on socid
if ($socid) {
if ($socid > 0) {
$sql .= " AND a.fk_soc = ".((int) $socid);
}
// We must filter on assignment table
if ($filtert > 0 || $usergroup > 0) {
$sql .= " AND ar.fk_actioncomm = a.id AND ar.element_type='user'";
}
if ($type) {
$sql .= " AND c.id = ".((int) $type);
}

View File

@ -145,6 +145,13 @@ class FactureRec extends CommonInvoice
public $cond_reglement_code; // Code in llx_c_paiement
public $mode_reglement_code; // Code in llx_c_paiement
public $fk_multicurrency;
public $multicurrency_code;
public $multicurrency_tx;
public $multicurrency_total_ht;
public $multicurrency_total_tva;
public $multicurrency_total_ttc;
public $suspended; // status
public $auto_validate; // 0 to create in draft, 1 to create and validate the new invoice

View File

@ -3870,7 +3870,7 @@ class Facture extends CommonInvoice
if (empty($fk_prev_id)) {
$fk_prev_id = 'null';
}
if (!isset($situation_percent) || $situation_percent > 100 || (string) $situation_percent == '') {
if (!isset($situation_percent) || $situation_percent > 100 || (string) $situation_percent == '' || $situation_percent == null) {
$situation_percent = 100;
}
if (empty($ref_ext)) {
@ -4131,7 +4131,7 @@ class Facture extends CommonInvoice
if (empty($special_code) || $special_code == 3) {
$special_code = 0;
}
if (!isset($situation_percent) || $situation_percent > 100 || (string) $situation_percent == '') {
if (!isset($situation_percent) || $situation_percent > 100 || (string) $situation_percent == '' || $situation_percent == null) {
$situation_percent = 100;
}
if (empty($ref_ext)) {

View File

@ -3317,7 +3317,7 @@ class ContratLigne extends CommonObjectLine
$sql .= " t.label,"; // This field is not used. Only label of product
$sql .= " p.ref as product_ref,";
$sql .= " p.label as product_label,";
$sql .= " p.description as product_desc,";
$sql .= " p.description as product_description,";
$sql .= " p.fk_product_type as product_type,";
$sql .= " t.description,";
$sql .= " t.date_commande,";

View File

@ -390,6 +390,13 @@ if (!empty($filter_opcloture) && $filter_opcloture == ' BETWEEN ') {
// Add where from extra fields
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php';
// Add where from hooks
$parameters = array();
$reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
$sql .= $hookmanager->resPrint;
$sql .= $db->order($sortfield, $sortorder);
//print $sql;
// Count total nb of records
@ -502,6 +509,10 @@ if ($filter_datecloture_start != '') {
}
// Add $param from extra fields
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
// Add $param from hooks
$parameters = array();
$reshook = $hookmanager->executeHooks('printFieldListSearchParam', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
$param .= $hookmanager->resPrint;
// List of mass actions available
$arrayofmassactions = array(

View File

@ -6774,7 +6774,7 @@ class Form
// Keep only the VAT qualified for $type_vat
$arrayofvatrates = array();
foreach ($this->cache_vatrates as $cachevalue) {
if (empty($cachevalue['type_vat']) || $cachevalue['type_vat'] != $type_vat) {
if (empty($cachevalue['type_vat']) || $cachevalue['type_vat'] == $type_vat) {
$arrayofvatrates[] = $cachevalue;
}
}

View File

@ -1562,6 +1562,7 @@ function dol_delete_file($file, $disableglob = 0, $nophperrors = 0, $nohook = 0,
}
}
} else {
$ok = false; // to avoid false positive
dol_syslog("No files to delete found", LOG_DEBUG);
}
} else {

View File

@ -280,7 +280,7 @@ class pdf_soleil extends ModelePDFFicheinter
$desc = dol_htmlentitiesbr($text, 1);
//print $outputlangs->convToOutputCharset($desc); exit;
$pdf->writeHTMLCell(180, 3, 10, $tab_top + 5, $outputlangs->convToOutputCharset($desc), 0, 1);
$pdf->writeHTMLCell(180, 3, $this->posxdesc - 1, $tab_top + 5, $outputlangs->convToOutputCharset($desc), 0, 1);
$nexY = $pdf->GetY();
$pdf->line($this->marge_gauche, $nexY, $this->page_largeur - $this->marge_droite, $nexY);

View File

@ -467,6 +467,14 @@ class doc_generic_task_odt extends ModelePDFTask
return -1;
}
// Add odtgeneration hook
if (!is_object($hookmanager)) {
include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
$hookmanager = new HookManager($this->db);
}
$hookmanager->initHooks(array('odtgeneration'));
global $action;
if (!is_object($outputlangs)) {
$outputlangs = $langs;
}

View File

@ -222,6 +222,7 @@ class doc_generic_odt extends ModeleThirdPartyDoc
$hookmanager = new HookManager($this->db);
}
$hookmanager->initHooks(array('odtgeneration'));
global $action;
if (!is_object($outputlangs)) {
$outputlangs = $langs;

View File

@ -159,6 +159,9 @@ if (empty($reshook) && !empty($object->table_element) && isset($extrafields->att
if ($object->element == 'product') {
$keyforperm = 'produit';
}
if ($object->element == 'project') {
$keyforperm = 'projet';
}
if (isset($user->rights->$keyforperm)) {
$permok = $user->hasRight($keyforperm, 'creer') || $user->hasRight($keyforperm, 'create') || $user->hasRight($keyforperm, 'write');
}

View File

@ -2872,7 +2872,7 @@ class EmailCollector extends CommonObject
$this->errors = $actioncomm->errors;
} else {
if ($fk_element_type == "ticket" && is_object($objectemail)) {
if ($objectemail->status == Ticket::STATUS_CLOSED || $objectemail->status == Ticket::STATUS_CANCELED) {
if ($objectemail->status == Ticket::STATUS_CLOSED || $objectemail->status == Ticket::STATUS_CANCELED || $objectemail->status == Ticket::STATUS_NEED_MORE_INFO || $objectemail->status == Ticket::STATUS_WAITING) {
if ($objectemail->fk_user_assign != null) {
$res = $objectemail->setStatut(Ticket::STATUS_ASSIGNED);
} else {
@ -3345,6 +3345,13 @@ class EmailCollector extends CommonObject
$tickettocreate->context['actionmsg'] = $langs->trans("ActionAC_EMAIL_IN").' - '.$langs->trans("TICKET_CREATEInDolibarr");
//$tickettocreate->email_fields_no_propagate_in_actioncomm = 0;
// Add sender to context array to make sure that confirmation e-mail can be sent by trigger script
$sender_contact = new Contact($this->db);
$sender_contact->fetch(0, null, '', $from);
if (!empty($sender_contact->id)) {
$tickettocreate->context['contactid'] = $sender_contact->id;
}
$result = $tickettocreate->create($user);
if ($result <= 0) {
$errorforactions++;
@ -3360,7 +3367,7 @@ class EmailCollector extends CommonObject
foreach ($attachments as $attachment) {
// $attachment->save($destdir.'/');
$typeattachment = (string) $attachment->getDisposition();
$filename = $attachment->getFilename();
$filename = $attachment->getName();
$content = $attachment->getContent();
$this->saveAttachment($destdir, $filename, $content);
}

View File

@ -2381,35 +2381,52 @@ class CommandeFournisseur extends CommonOrder
}
$main = $this->db->prefix().'commande_fournisseurdet';
$ef = $main."_extrafields";
$sql = "DELETE FROM $ef WHERE fk_object IN (SELECT rowid FROM $main WHERE fk_commande = ".((int) $this->id).")";
dol_syslog(get_class($this)."::delete extrafields lines", LOG_DEBUG);
if (!$this->db->query($sql)) {
$this->error = $this->db->lasterror();
$this->errors[] = $this->db->lasterror();
$error++;
if (!$error) {
$sql1 = "UPDATE ".$this->db->prefix()."commandedet SET fk_commandefourndet = NULL WHERE fk_commandefourndet IN (SELECT rowid FROM ".$main." WHERE fk_commande = ".((int) $this->id).")";
dol_syslog(__METHOD__." linked order lines", LOG_DEBUG);
if (!$this->db->query($sql1)) {
$error++;
$this->error = $this->db->lasterror();
$this->errors[] = $this->db->lasterror();
}
}
$sql = "DELETE FROM ".$this->db->prefix()."commande_fournisseurdet WHERE fk_commande =".((int) $this->id);
dol_syslog(get_class($this)."::delete", LOG_DEBUG);
if (!$this->db->query($sql)) {
$this->error = $this->db->lasterror();
$this->errors[] = $this->db->lasterror();
$error++;
}
$sql = "DELETE FROM ".$this->db->prefix()."commande_fournisseur WHERE rowid =".((int) $this->id);
dol_syslog(get_class($this)."::delete", LOG_DEBUG);
if ($resql = $this->db->query($sql)) {
if ($this->db->affected_rows($resql) < 1) {
if (!$error) {
$ef = $main."_extrafields";
$sql = "DELETE FROM $ef WHERE fk_object IN (SELECT rowid FROM $main WHERE fk_commande = ".((int) $this->id).")";
dol_syslog(get_class($this)."::delete extrafields lines", LOG_DEBUG);
if (!$this->db->query($sql)) {
$this->error = $this->db->lasterror();
$this->errors[] = $this->db->lasterror();
$error++;
}
}
if (!$error) {
$sql = "DELETE FROM ".$this->db->prefix()."commande_fournisseurdet WHERE fk_commande =".((int) $this->id);
dol_syslog(get_class($this)."::delete", LOG_DEBUG);
if (!$this->db->query($sql)) {
$this->error = $this->db->lasterror();
$this->errors[] = $this->db->lasterror();
$error++;
}
}
if (!$error) {
$sql = "DELETE FROM ".$this->db->prefix()."commande_fournisseur WHERE rowid =".((int) $this->id);
dol_syslog(get_class($this)."::delete", LOG_DEBUG);
if ($resql = $this->db->query($sql)) {
if ($this->db->affected_rows($resql) < 1) {
$this->error = $this->db->lasterror();
$this->errors[] = $this->db->lasterror();
$error++;
}
} else {
$this->error = $this->db->lasterror();
$this->errors[] = $this->db->lasterror();
$error++;
}
} else {
$this->error = $this->db->lasterror();
$this->errors[] = $this->db->lasterror();
$error++;
}
// Remove extrafields
@ -4091,6 +4108,7 @@ class CommandeFournisseurLigne extends CommonOrderLine
return -2;
}
}
/**
* Update the line object into db
*

View File

@ -97,7 +97,7 @@ class Position extends CommonObject
'date_creation' => array('type' => 'datetime', 'label' => 'DateCreation', 'enabled' => 1, 'position' => 500, 'notnull' => 1, 'visible' => -2,),
'tms' => array('type' => 'timestamp', 'label' => 'DateModification', 'enabled' => 1, 'position' => 501, 'notnull' => 0, 'visible' => -2,),
'fk_contrat' => array('type' => 'integer:Contrat:contrat/class/contrat.class.php', 'label' => 'fk_contrat', 'enabled' => 'isModEnabled("contract")', 'position' => 50, 'notnull' => 0, 'visible' => 0,),
'fk_user' => array('type' => 'integer:User:user/class/user.class.php:0:(t.statut:=:1)', 'label' => 'Employee', 'enabled' => 1, 'position' => 55, 'notnull' => 1, 'visible' => 1, 'default' => '0', 'picto' => 'user', 'css' => 'maxwidth300 widthcentpercentminusxx', 'csslist' => 'tdoverflowmax150'),
'fk_user' => array('type' => 'integer:User:user/class/user.class.php:0', 'label' => 'Employee', 'enabled' => 1, 'position' => 55, 'notnull' => 1, 'visible' => 1, 'default' => '0', 'picto' => 'user', 'css' => 'maxwidth300 widthcentpercentminusxx', 'csslist' => 'tdoverflowmax150'),
'fk_job' => array('type' => 'integer:Job:/hrm/class/job.class.php', 'label' => 'JobProfile', 'enabled' => 1, 'position' => 56, 'notnull' => 1, 'visible' => 1, 'picto' => 'jobprofile', 'css' => 'maxwidth300 widthcentpercentminusxx', 'csslist' => 'tdoverflowmax150'),
'date_start' => array('type' => 'date', 'label' => 'DateStart', 'enabled' => 1, 'position' => 101, 'notnull' => 1, 'visible' => 1,),
'date_end' => array('type' => 'date', 'label' => 'DateEnd', 'enabled' => 1, 'position' => 102, 'notnull' => 0, 'visible' => 1,),

View File

@ -235,7 +235,12 @@ class doc_generic_myobject_odt extends ModelePDFMyObject
}
// Add odtgeneration hook
if (!is_object($hookmanager)) {
include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
$hookmanager = new HookManager($this->db);
}
$hookmanager->initHooks(array('odtgeneration'));
global $action;
if (!is_object($outputlangs)) {
$outputlangs = $langs;

View File

@ -553,6 +553,30 @@ if (empty($reshook)) {
}
}
// Quick edit for extrafields
if ($action == 'update_extras' && $permissiontoadd) {
$object->oldcopy = dol_clone($object, 2);
// Fill array 'array_options' with data from update form
$ret = $extrafields->setOptionalsFromPost(null, $object, GETPOST('attribute', 'restricthtml'));
if ($ret < 0) {
$error++;
}
if (!$error) {
// Actions on extra fields
$result = $object->insertExtraFields('PROJECT_MODIFY');
if ($result < 0) {
setEventMessages($object->error, $object->errors, 'errors');
$error++;
}
}
if ($error) {
$action = 'edit_extras';
}
}
// Actions to send emails
$triggersendname = 'PROJECT_SENTBYMAIL';
$paramname = 'id';

View File

@ -243,9 +243,9 @@ if ($action == 'remove_file' && $user->hasRight('projet', 'creer')) {
$ret = dol_delete_file($file);
if ($ret) {
setEventMessages($langs->trans("FileWasRemoved", GETPOST('urlfile')), null, 'mesgs');
setEventMessages($langs->trans("FileWasRemoved", GETPOST('file')), null, 'mesgs');
} else {
setEventMessages($langs->trans("ErrorFailToDeleteFile", GETPOST('urlfile')), null, 'errors');
setEventMessages($langs->trans("ErrorFailToDeleteFile", GETPOST('file')), null, 'errors');
}
}
@ -253,6 +253,7 @@ if ($action == 'remove_file' && $user->hasRight('projet', 'creer')) {
/*
* View
*/
$form = new Form($db);
$formother = new FormOther($db);
$formfile = new FormFile($db);

View File

@ -233,7 +233,12 @@ class doc_generic_recruitmentjobposition_odt extends ModelePDFRecruitmentJobPosi
}
// Add odtgeneration hook
if (!is_object($hookmanager)) {
include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
$hookmanager = new HookManager($this->db);
}
$hookmanager->initHooks(array('odtgeneration'));
global $action;
if (!is_object($outputlangs)) {
$outputlangs = $langs;

View File

@ -1578,7 +1578,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($canvasdisplayactio
// Vat is used
print '<tr><td>'.$form->editfieldkey('VATIsUsed', 'assujtva_value', '', $object, 0).'</td>';
print '<td>';
print '<input id="assujtva_value" name="assujtva_value" type="checkbox" ' . (GETPOSTISSET('assujtva_value') ? (GETPOST('assujtva', 'alpha') != '' ? ' checked="checked"' : '') : 'checked="checked"') . ' value="1">'; // Assujeti par default en creation
print '<input id="assujtva_value" name="assujtva_value" type="checkbox" ' . (GETPOSTISSET('assujtva_value') ? (GETPOST('assujtva_value', 'alpha') != '' ? ' checked="checked"' : '') : 'checked="checked"') . ' value="1">'; // Assujeti par default en creation
print '</td>';
if ($conf->browser->layout == 'phone') {
print '</tr><tr>';