From 696628ed539a600a9faf228452999a1f3418bf2e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 10 May 2023 05:03:57 +0200 Subject: [PATCH 01/14] css --- htdocs/eventorganization/class/conferenceorbooth.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/eventorganization/class/conferenceorbooth.class.php b/htdocs/eventorganization/class/conferenceorbooth.class.php index db6bbf7175e..7e8572af226 100644 --- a/htdocs/eventorganization/class/conferenceorbooth.class.php +++ b/htdocs/eventorganization/class/conferenceorbooth.class.php @@ -106,7 +106,7 @@ class ConferenceOrBooth extends ActionComm 'id' => array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>'1', 'position'=>1, 'notnull'=>1, 'visible'=>0, 'noteditable'=>'1', 'index'=>1, 'css'=>'left', 'comment'=>"Id"), 'ref' => array('type'=>'integer', 'label'=>'Ref', 'enabled'=>'1', 'position'=>1, 'notnull'=>1, 'visible'=>2, 'noteditable'=>'1', 'index'=>1, 'css'=>'left', 'csslist'=>'left', 'comment'=>"Id"), 'label' => array('type'=>'varchar(255)', 'label'=>'Label', 'enabled'=>'1', 'position'=>30, 'notnull'=>1, 'visible'=>1, 'searchall'=>1, 'css'=>'minwidth300', 'csslist'=>'tdoverflowmax125', 'help'=>"OrganizationEvenLabelName", 'showoncombobox'=>'1', 'autofocusoncreate'=>1), - 'fk_project' => array('type'=>'integer:Project:projet/class/project.class.php:1:(t.usage_organize_event:=:1)', 'label'=>'Project', 'enabled'=>"isModEnabled('project')", 'position'=>52, 'notnull'=>-1, 'visible'=>1, 'index'=>1, 'picto'=>'project', 'css'=>'tdoverflowmax150 maxwidth500', 'csslist'=>'width100'), + 'fk_project' => array('type'=>'integer:Project:projet/class/project.class.php:1:(t.usage_organize_event:=:1)', 'label'=>'Project', 'enabled'=>"isModEnabled('project')", 'position'=>52, 'notnull'=>-1, 'visible'=>1, 'index'=>1, 'picto'=>'project', 'css'=>'maxwidth500', 'csslist'=>'tdoverflowmax100'), 'fk_soc' => array('type'=>'integer:Societe:societe/class/societe.class.php:1:((status:=:1) AND (entity:IN:__SHARED_ENTITIES__))', 'label'=>'ThirdParty', 'enabled'=>'$conf->societe->enabled', 'position'=>50, 'notnull'=>-1, 'visible'=>1, 'index'=>1, 'help'=>"OrganizationEventLinkToThirdParty", 'picto'=>'company', 'csslist'=>'tdoverflowmax125', 'css'=>'maxwidth500'), 'note' => array('type'=>'text', 'label'=>'Description', 'enabled'=>'1', 'position'=>60, 'notnull'=>0, 'visible'=>3), 'fk_action' => array('type'=>'sellist:c_actioncomm:libelle:id::module LIKE (\'%@eventorganization\')', 'label'=>'Format', 'enabled'=>'1', 'position'=>60, 'notnull'=>1, 'visible'=>1, 'css'=>'width100', 'csslist'=>'tdoverflowmax100'), From c6423a4a5544db11964b277146b79d2f1ab3fb51 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 10 May 2023 11:28:17 +0200 Subject: [PATCH 02/14] Fix label --- htdocs/public/project/suggestbooth.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/public/project/suggestbooth.php b/htdocs/public/project/suggestbooth.php index d59cba09779..e6a844ac587 100644 --- a/htdocs/public/project/suggestbooth.php +++ b/htdocs/public/project/suggestbooth.php @@ -557,7 +557,7 @@ print '
'; // Sub banner print '
'; -print load_fiche_titre($langs->trans("NewSuggestionOfConference"), '', '', 0, 0, 'center'); +print load_fiche_titre($langs->trans("NewSuggestionOfBooth"), '', '', 0, 0, 'center'); // Welcome message print ''.$langs->trans("EvntOrgRegistrationWelcomeMessage").''; print '
'; From 91ad17787aece1a36783b430cdd990731dbe9a92 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 10 May 2023 12:28:51 +0200 Subject: [PATCH 03/14] Fix filter on regex with ^ and $ --- htdocs/admin/translation.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/htdocs/admin/translation.php b/htdocs/admin/translation.php index abb5ebfd6ba..5493741c0d8 100644 --- a/htdocs/admin/translation.php +++ b/htdocs/admin/translation.php @@ -463,7 +463,11 @@ if ($mode == 'searchkey') { } else { // Now search into translation array foreach ($newlang->tab_translate as $key => $val) { - if ($transkey && !preg_match('/'.preg_quote($transkey, '/').'/i', $key)) { + $newtranskey = preg_replace('/\$$/', '', preg_replace('/^\^/', '', $transkey)); + $newtranskeystart = preg_match('/^\^/', $transkey); + $newtranskeyend = preg_match('/\$$/', $transkey); + $regexstring = ($newtranskeystart ? '^' : '').preg_quote($newtranskey, '/').($newtranskeyend ? '$' : ''); + if ($transkey && !preg_match('/'.$regexstring.'/i', $key)) { continue; } if ($transvalue && !preg_match('/'.preg_quote($transvalue, '/').'/i', $val)) { From cd1523218e44c264a3775b4175aaa21f9d07e622 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 10 May 2023 13:09:44 +0200 Subject: [PATCH 04/14] Debug v17 (export of attendees of an event) --- htdocs/core/modules/modAgenda.class.php | 2 +- htdocs/core/modules/modCategorie.class.php | 2 +- .../modules/modEventOrganization.class.php | 96 ++++++++++++++++++- htdocs/core/modules/modResource.class.php | 2 +- .../class/conferenceorboothattendee.class.php | 6 +- htdocs/exports/export.php | 8 +- 6 files changed, 105 insertions(+), 11 deletions(-) diff --git a/htdocs/core/modules/modAgenda.class.php b/htdocs/core/modules/modAgenda.class.php index d9858a017e0..a164371812e 100644 --- a/htdocs/core/modules/modAgenda.class.php +++ b/htdocs/core/modules/modAgenda.class.php @@ -51,7 +51,7 @@ class modAgenda extends DolibarrModules $this->numero = 2400; $this->family = "projects"; - $this->module_position = '15'; + $this->module_position = '16'; // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module) $this->name = preg_replace('/^mod/i', '', get_class($this)); $this->description = "Follow events or rendez-vous. Record manual events into Agendas or let application record automatic events for log tracking."; diff --git a/htdocs/core/modules/modCategorie.class.php b/htdocs/core/modules/modCategorie.class.php index 4a8680502ae..51033660920 100644 --- a/htdocs/core/modules/modCategorie.class.php +++ b/htdocs/core/modules/modCategorie.class.php @@ -47,7 +47,7 @@ class modCategorie extends DolibarrModules $this->numero = 1780; $this->family = "technic"; - $this->module_position = '20'; + $this->module_position = '25'; // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module) $this->name = preg_replace('/^mod/i', '', get_class($this)); $this->description = "Gestion des categories (produits, clients, fournisseurs...)"; diff --git a/htdocs/core/modules/modEventOrganization.class.php b/htdocs/core/modules/modEventOrganization.class.php index f037f26176c..8fb48dcceb6 100644 --- a/htdocs/core/modules/modEventOrganization.class.php +++ b/htdocs/core/modules/modEventOrganization.class.php @@ -40,7 +40,8 @@ class modEventOrganization extends DolibarrModules */ public function __construct($db) { - global $langs, $conf; + global $conf, $langs; + $this->db = $db; $this->numero = 2450; @@ -49,7 +50,7 @@ class modEventOrganization extends DolibarrModules $this->family = "projects"; - $this->module_position = '20'; + $this->module_position = '15'; $this->name = preg_replace('/^mod/i', '', get_class($this)); @@ -306,9 +307,100 @@ class modEventOrganization extends DolibarrModules 'user'=>2, // 0=Menu for internal users, 1=external users, 2=both ); /* END MODULEBUILDER LEFTMENU CONFERENCEORBOOTH */ + // Exports profiles provided by this module $r = 1; + + /* BEGIN MODULEBUILDER EXPORT CONFERENCEORBOOTHATTENDEES */ + $langs->load("eventorganization"); + $this->export_code[$r]=$this->rights_class.'_'.$r; + $this->export_label[$r]='ListOfAttendeesOfEvent'; // Translation key (used only if key ExportDataset_xxx_z not found) + $this->export_icon[$r]=$this->picto; + // Define $this->export_fields_array, $this->export_TypeFields_array and $this->export_entities_array + $keyforclass = 'ConferenceOrBoothAttendee'; $keyforclassfile='/eventorganization/class/conferenceorboothattendee.class.php'; $keyforelement='conferenceorboothattendee'; + include DOL_DOCUMENT_ROOT.'/core/commonfieldsinexport.inc.php'; + $this->export_entities_array[$r]['t.fk_invoice'] = 'invoice'; + unset($this->export_fields_array[$r]['t.fk_project']); // Remove field so we can add it at end just after + $this->export_fields_array[$r]['t.fk_project'] = 'ProjectId'; + $this->export_fields_array[$r]['p.ref'] = 'ProjectRef'; + $this->export_entities_array[$r]['t.fk_project'] = 'project'; + $this->export_entities_array[$r]['p.ref'] = 'project'; + $this->export_TypeFields_array[$r]['t.fk_project'] = 'Numeric'; + $this->export_TypeFields_array[$r]['p.ref'] = 'Text'; + //$this->export_fields_array[$r]['t.fieldtoadd']='FieldToAdd'; $this->export_TypeFields_array[$r]['t.fieldtoadd']='Text'; + //unset($this->export_fields_array[$r]['t.fieldtoremove']); + $keyforselect='conferenceorboothattendee'; $keyforaliasextra='extra'; $keyforelement='conferenceorboothattendee'; + include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php'; + //$this->export_dependencies_array[$r] = array('aaaline'=>array('tl.rowid','tl.ref')); // To force to activate one or several fields if we select some fields that need same (like to select a unique key if we ask a field of a child to avoid the DISTINCT to discard them, or for computed field than need several other fields) + //$this->export_special_array[$r] = array('t.field'=>'...'); + //$this->export_examplevalues_array[$r] = array('t.field'=>'Example'); + //$this->export_help_array[$r] = array('t.field'=>'FieldDescHelp'); + $this->export_sql_start[$r]='SELECT DISTINCT '; + $this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'eventorganization_conferenceorboothattendee as t, '.MAIN_DB_PREFIX.'projet as p'; + $this->export_sql_end[$r] .=' WHERE t.fk_project = p.rowid'; + $this->export_sql_end[$r] .=' AND p.entity IN ('.getEntity('conferenceorboothattendee').')'; + $r++; + /* END MODULEBUILDER EXPORT CONFERENCEORBOOTHATTENDEES */ + /* BEGIN MODULEBUILDER EXPORT CONFERENCEORBOOTH */ + /* + $r++; + $this->export_code[$r] = $this->rights_class.'_'.$r; + $this->export_label[$r] = "ExportDataset_event1"; + $this->export_permission[$r] = array(array("agenda", "export")); + $this->export_fields_array[$r] = array('ac.id'=>"IdAgenda", 'ac.ref_ext'=>"ExternalRef", 'ac.datec'=>"DateCreation", 'ac.datep'=>"DateActionBegin", + 'ac.datep2'=>"DateActionEnd", 'ac.label'=>"Title", 'ac.note'=>"Note", 'ac.percent'=>"Percent", 'ac.durationp'=>"Duration", + 'cac.libelle'=>"ActionType", + 's.rowid'=>"IdCompany", 's.nom'=>'CompanyName', 's.address'=>'Address', 's.zip'=>'Zip', 's.town'=>'Town', + 'co.code'=>'CountryCode', 's.phone'=>'Phone', 's.siren'=>'ProfId1', 's.siret'=>'ProfId2', 's.ape'=>'ProfId3', 's.idprof4'=>'ProfId4', 's.idprof5'=>'ProfId5', 's.idprof6'=>'ProfId6', + 's.code_compta'=>'CustomerAccountancyCode', 's.code_compta_fournisseur'=>'SupplierAccountancyCode', 's.tva_intra'=>'VATIntra', + 'p.ref' => 'ProjectRef', + ); + $this->export_TypeFields_array[$r] = array('ac.ref_ext'=>"Text", 'ac.datec'=>"Date", 'ac.datep'=>"Date", + 'ac.datep2'=>"Date", 'ac.label'=>"Text", 'ac.note'=>"Text", 'ac.percent'=>"Numeric", + 'ac.durationp'=>"Duree", + 'cac.libelle'=>"List:c_actioncomm:libelle:libelle", + 's.nom'=>'Text', 's.address'=>'Text', 's.zip'=>'Text', 's.town'=>'Text', + 'co.code'=>'Text', 's.phone'=>'Text', 's.siren'=>'Text', 's.siret'=>'Text', 's.ape'=>'Text', 's.idprof4'=>'Text', 's.idprof5'=>'Text', 's.idprof6'=>'Text', + 's.code_compta'=>'Text', 's.code_compta_fournisseur'=>'Text', 's.tva_intra'=>'Text', + 'p.ref' => 'Text', + ); + $this->export_entities_array[$r] = array('ac.id'=>"action", 'ac.ref_ext'=>"action", 'ac.datec'=>"action", 'ac.datep'=>"action", + 'ac.datep2'=>"action", 'ac.label'=>"action", 'ac.note'=>"action", 'ac.percent'=>"action", 'ac.durationp'=>"action", + 'cac.libelle'=>"action", + 's.rowid'=>"company", 's.nom'=>'company', 's.address'=>'company', 's.zip'=>'company', 's.town'=>'company', + 'co.code'=>'company', 's.phone'=>'company', 's.siren'=>'company', 's.siret'=>'company', 's.ape'=>'company', 's.idprof4'=>'company', 's.idprof5'=>'company', 's.idprof6'=>'company', + 's.code_compta'=>'company', 's.code_compta_fournisseur'=>'company', 's.tva_intra'=>'company', + 'p.ref' => 'project', + ); + + $keyforselect = 'actioncomm'; $keyforelement = 'action'; $keyforaliasextra = 'extra'; + include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php'; + + $this->export_sql_start[$r] = 'SELECT DISTINCT '; + $this->export_sql_end[$r] = ' FROM '.MAIN_DB_PREFIX.'actioncomm as ac'; + $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'actioncomm_extrafields as extra ON ac.id = extra.fk_object'; + $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_actioncomm as cac on ac.fk_action = cac.id'; + if (!empty($user) && empty($user->rights->agenda->allactions->read)) { + $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'actioncomm_resources acr on ac.id = acr.fk_actioncomm'; + } + $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'socpeople as sp on ac.fk_contact = sp.rowid'; + $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe as s on ac.fk_soc = s.rowid'; + if (!empty($user) && empty($user->rights->societe->client->voir)) { + $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe_commerciaux as sc ON sc.fk_soc = s.rowid'; + } + $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_country as co on s.fk_pays = co.rowid'; + $this->export_sql_end[$r] .= " LEFT JOIN ".MAIN_DB_PREFIX."projet as p ON p.rowid = ac.fk_project"; + $this->export_sql_end[$r] .= " WHERE ac.entity IN (".getEntity('agenda').")"; + $this->export_sql_end[$r] .= " AND ac.code = 'AC_EO_INDOORCONF'"; + if (empty($user->rights->societe->client->voir)) { + $this->export_sql_end[$r] .= ' AND (sc.fk_user = '.(empty($user) ? 0 : $user->id).' OR ac.fk_soc IS NULL)'; + } + if (empty($user->rights->agenda->allactions->read)) { + $this->export_sql_end[$r] .= ' AND acr.fk_element = '.(empty($user) ? 0 : $user->id); + } + $this->export_sql_order[$r] = ' ORDER BY ac.datep'; + */ /* END MODULEBUILDER EXPORT CONFERENCEORBOOTH */ // Imports profiles provided by this module diff --git a/htdocs/core/modules/modResource.class.php b/htdocs/core/modules/modResource.class.php index 59dc7878161..143d1fd2161 100644 --- a/htdocs/core/modules/modResource.class.php +++ b/htdocs/core/modules/modResource.class.php @@ -55,7 +55,7 @@ class modResource extends DolibarrModules // Family can be 'crm','financial','hr','projects','products','ecm','technic','other' // It is used to group modules in module setup page $this->family = "projects"; - $this->module_position = '16'; + $this->module_position = '20'; // Module label (no space allowed) // used if translation string 'ModuleXXXName' not found // (where XXX is value of numeric property 'numero' of module) diff --git a/htdocs/eventorganization/class/conferenceorboothattendee.class.php b/htdocs/eventorganization/class/conferenceorboothattendee.class.php index 062de3ef8d7..9a31de19d10 100644 --- a/htdocs/eventorganization/class/conferenceorboothattendee.class.php +++ b/htdocs/eventorganization/class/conferenceorboothattendee.class.php @@ -51,7 +51,7 @@ class ConferenceOrBoothAttendee extends CommonObject * @var int Does this object support multicompany module ? * 0=No test on entity, 1=Test with field entity, 'field@table'=Test with link by field@table */ - public $ismultientitymanaged = 0; + public $ismultientitymanaged = 'fk_project@projet'; /** * @var int Does object support extrafields ? 0=No, 1=Yes @@ -103,7 +103,7 @@ class ConferenceOrBoothAttendee extends CommonObject public $fields = array( 'rowid' => array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>'1', 'position'=>1, 'notnull'=>1, 'visible'=>0, 'noteditable'=>'1', 'index'=>1, 'css'=>'left', 'comment'=>"Id"), 'ref' => array('type'=>'varchar(128)', 'label'=>'Ref', 'enabled'=>'1', 'position'=>10, 'notnull'=>1, 'visible'=>2, 'index'=>1, 'comment'=>"Reference of object"), - 'fk_actioncomm' => array('type'=>'integer:ActionComm:comm/action/class/actioncomm.class.php:1', 'label'=>'ConferenceOrBooth', 'enabled'=>'1', 'position'=>15, 'notnull'=>0, 'visible'=>0, 'index'=>1, 'picto'=>'agenda'), + //'fk_actioncomm' => array('type'=>'integer:ActionComm:comm/action/class/actioncomm.class.php:1', 'label'=>'ConferenceOrBooth', 'enabled'=>'1', 'position'=>15, 'notnull'=>0, 'visible'=>0, 'index'=>1, 'picto'=>'agenda'), 'fk_project' => array('type'=>'integer:Project:projet/class/project.class.php:1', 'label'=>'Project', 'enabled'=>"isModEnabled('project')", 'position'=>20, 'notnull'=>1, 'visible'=>0, 'index'=>1, 'picto'=>'project', 'css'=>'tdoverflowmax150 maxwidth500'), 'email' => array('type'=>'mail', 'label'=>'EmailAttendee', 'enabled'=>'1', 'position'=>30, 'notnull'=>1, 'visible'=>1, 'index'=>1, 'autofocusoncreate'=>1, 'searchall'=>1), 'firstname' => array('type'=>'varchar(100)', 'label'=>'Firstname', 'enabled'=>'1', 'position'=>31, 'notnull'=>0, 'visible'=>1, 'index'=>1, 'searchall'=>1), @@ -122,8 +122,8 @@ class ConferenceOrBoothAttendee extends CommonObject 'last_main_doc' => array('type'=>'varchar(255)', 'label'=>'LastMainDoc', 'enabled'=>'1', 'position'=>600, 'notnull'=>0, 'visible'=>0,), 'import_key' => array('type'=>'varchar(14)', 'label'=>'ImportId', 'enabled'=>'1', 'position'=>1000, 'notnull'=>-1, 'visible'=>-2,), 'model_pdf' => array('type'=>'varchar(255)', 'label'=>'Model pdf', 'enabled'=>'1', 'position'=>1010, 'notnull'=>-1, 'visible'=>0,), + 'ip' => array('type'=>'varchar(250)', 'label'=>'IPAddress', 'enabled'=>'1', 'position'=>900, 'notnull'=>-1, 'visible'=>-2,), 'status' => array('type'=>'smallint', 'label'=>'Status', 'enabled'=>'1', 'position'=>1000, 'default'=>0, 'notnull'=>1, 'visible'=>1, 'index'=>1, 'arrayofkeyval'=>array('0'=>'Draft', '1'=>'Validated', '9'=>'Canceled'),), - 'ip' => array('type'=>'varchar(250)', 'label'=>'Ip', 'enabled'=>'1', 'position'=>1000, 'notnull'=>-1, 'visible'=>-2,), ); public $rowid; public $ref; diff --git a/htdocs/exports/export.php b/htdocs/exports/export.php index 4591ccd0bf3..c7671a2a893 100644 --- a/htdocs/exports/export.php +++ b/htdocs/exports/export.php @@ -76,7 +76,8 @@ $entitytoicon = array( 'contract_line' => 'contract', 'translation' => 'generic', 'bomm' => 'bom', - 'bomline' => 'bom' + 'bomline' => 'bom', + 'conferenceorboothattendee' => 'contact' ); // Translation code, array duplicated in import.php, was not synchronized, TODO put it somewhere only once @@ -125,7 +126,8 @@ $entitytolang = array( 'contract_line'=> 'ContractLine', 'translation' => 'Translation', 'bom' => 'BOM', - 'bomline' => 'BOMLine' + 'bomline' => 'BOMLine', + 'conferenceorboothattendee' => 'Attendee' ); $array_selected = isset($_SESSION["export_selected_fields"]) ? $_SESSION["export_selected_fields"] : array(); @@ -527,7 +529,7 @@ if ($step == 2 && $datatoexport) { print '
'; // You can use div-table-responsive-no-min if you dont need reserved height for your table print ''; print ''; - print ''; + print ''; print ''; print '
'.$langs->trans("Entities").''.$langs->trans("Object").''.$langs->trans("ExportableFields").''; print ''.$langs->trans("All").""; From 5239f3c1331af5a1306dc23f4d2915b2c57c6af2 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 10 May 2023 13:23:07 +0200 Subject: [PATCH 05/14] Debug v17 --- htdocs/core/modules/modEventOrganization.class.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/htdocs/core/modules/modEventOrganization.class.php b/htdocs/core/modules/modEventOrganization.class.php index 8fb48dcceb6..ec68c1eaa92 100644 --- a/htdocs/core/modules/modEventOrganization.class.php +++ b/htdocs/core/modules/modEventOrganization.class.php @@ -321,12 +321,18 @@ class modEventOrganization extends DolibarrModules include DOL_DOCUMENT_ROOT.'/core/commonfieldsinexport.inc.php'; $this->export_entities_array[$r]['t.fk_invoice'] = 'invoice'; unset($this->export_fields_array[$r]['t.fk_project']); // Remove field so we can add it at end just after + unset($this->export_fields_array[$r]['t.fk_soc']); // Remove field so we can add it at end just after + $this->export_fields_array[$r]['t.fk_invoice'] = 'InvoiceId'; $this->export_fields_array[$r]['t.fk_project'] = 'ProjectId'; $this->export_fields_array[$r]['p.ref'] = 'ProjectRef'; + $this->export_fields_array[$r]['t.fk_soc'] = 'IdThirdParty'; $this->export_entities_array[$r]['t.fk_project'] = 'project'; $this->export_entities_array[$r]['p.ref'] = 'project'; + $this->export_entities_array[$r]['t.fk_soc'] = 'company'; $this->export_TypeFields_array[$r]['t.fk_project'] = 'Numeric'; + $this->export_TypeFields_array[$r]['t.fk_invoice'] = 'Numeric'; $this->export_TypeFields_array[$r]['p.ref'] = 'Text'; + $this->export_TypeFields_array[$r]['t.fk_soc'] = 'Numeric'; //$this->export_fields_array[$r]['t.fieldtoadd']='FieldToAdd'; $this->export_TypeFields_array[$r]['t.fieldtoadd']='Text'; //unset($this->export_fields_array[$r]['t.fieldtoremove']); $keyforselect='conferenceorboothattendee'; $keyforaliasextra='extra'; $keyforelement='conferenceorboothattendee'; From fc4aeccf211dc512c8cf43e58461319db5b0be52 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 10 May 2023 13:44:15 +0200 Subject: [PATCH 06/14] Fix opensurvey --- htdocs/opensurvey/results.php | 21 ++++++++++++--------- htdocs/public/opensurvey/studs.php | 4 ++-- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/htdocs/opensurvey/results.php b/htdocs/opensurvey/results.php index d8405c31027..7d68f54023b 100644 --- a/htdocs/opensurvey/results.php +++ b/htdocs/opensurvey/results.php @@ -37,7 +37,7 @@ if (empty($user->rights->opensurvey->read)) { // Init vars $action = GETPOST('action', 'aZ09'); -$numsondage = GETPOST("id"); +$numsondage = GETPOST("id", 'alphanohtml'); $object = new Opensurveysondage($db); $result = $object->fetch(0, $numsondage); @@ -53,8 +53,8 @@ $nblines = $object->fetch_lines(); */ // Return to the results -if (GETPOST('retoursondage')) { - header('Location: results.php?id='.(GETPOSTISSET('id_sondage') ? GETPOST('id_sondage', 'aZ09') : GETPOST('id', 'int'))); +if (GETPOST('cancel')) { + header('Location: results.php?id='.(GETPOSTISSET('id_sondage') ? GETPOST('id_sondage', 'aZ09') : GETPOST('id', 'alphanohtml'))); exit; } @@ -427,6 +427,7 @@ $title = $object->title." - ".$langs->trans('Card'); $helpurl = ''; $arrayofjs = array(); $arrayofcss = array('/opensurvey/css/style.css'); + llxHeader('', $title, $helpurl, 0, 0, 0, $arrayofjs, $arrayofcss); @@ -443,6 +444,7 @@ $toutsujet = str_replace("°", "'", $toutsujet); print '
'."\n"; print ''; +print ''; $head = opensurvey_prepare_head($object); @@ -508,7 +510,6 @@ print '
'; print ''; - // Expire date print ''."\n"; + print ''."\n"; $colspan = 1; } diff --git a/htdocs/public/opensurvey/studs.php b/htdocs/public/opensurvey/studs.php index 34f8ecd9400..b3459f7e36e 100644 --- a/htdocs/public/opensurvey/studs.php +++ b/htdocs/public/opensurvey/studs.php @@ -424,10 +424,10 @@ if ($object->format == "D") { } else { $next = intval($toutsujet[$i + 1]); } - if ($next && dol_print_date($cur, "%a %e") == dol_print_date($next, "%a %e") && dol_print_date($cur, "%B") == dol_print_date($next, "%B")) { + if ($next && dol_print_date($cur, "%a %d") == dol_print_date($next, "%a %d") && dol_print_date($cur, "%B") == dol_print_date($next, "%B")) { $colspan++; } else { - print ''."\n"; + print ''."\n"; $colspan = 1; } } From 4ab54898845c4d0e706fa9c69dd01ea3ec23e288 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 10 May 2023 16:33:07 +0200 Subject: [PATCH 07/14] Clean code --- htdocs/core/lib/admin.lib.php | 2 +- htdocs/core/modules/DolibarrModules.class.php | 4 ++-- htdocs/core/modules/modEventOrganization.class.php | 7 +++++++ 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/htdocs/core/lib/admin.lib.php b/htdocs/core/lib/admin.lib.php index b3ee5dc259a..008aa7d2670 100644 --- a/htdocs/core/lib/admin.lib.php +++ b/htdocs/core/lib/admin.lib.php @@ -161,7 +161,7 @@ function versiondolibarrarray() * @param int $nocommentremoval Do no try to remove comments (in such a case, we consider that each line is a request, so use also $linelengthlimit=0) * @param int $offsetforchartofaccount Offset to use to load chart of account table to update sql on the fly to add offset to rowid and account_parent value * @param int $colspan 2=Add a colspan=2 on td - * @param int $onlysqltoimportwebsite Only sql resquests used to import a website template is allowed + * @param int $onlysqltoimportwebsite Only sql resquests used to import a website template are allowed * @return int <=0 if KO, >0 if OK */ function run_sql($sqlfile, $silent = 1, $entity = '', $usesavepoint = 1, $handler = '', $okerror = 'default', $linelengthlimit = 32768, $nocommentremoval = 0, $offsetforchartofaccount = 0, $colspan = 0, $onlysqltoimportwebsite = 0) diff --git a/htdocs/core/modules/DolibarrModules.class.php b/htdocs/core/modules/DolibarrModules.class.php index 96c8d14da31..7423b434842 100644 --- a/htdocs/core/modules/DolibarrModules.class.php +++ b/htdocs/core/modules/DolibarrModules.class.php @@ -1721,7 +1721,7 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it $val = ''; } - $sql = "SELECT count(*)"; + $sql = "SELECT count(*) as nb"; $sql .= " FROM ".MAIN_DB_PREFIX."const"; $sql .= " WHERE ".$this->db->decrypt('name')." = '".$this->db->escape($name)."'"; $sql .= " AND entity = ".((int) $entity); @@ -1745,7 +1745,7 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it $err++; } } else { - dol_syslog(get_class($this)."::insert_const constant '".$name."' already exists", LOG_WARNING); + dol_syslog(get_class($this)."::insert_const constant '".$name."' already exists", LOG_DEBUG); } } else { $err++; diff --git a/htdocs/core/modules/modEventOrganization.class.php b/htdocs/core/modules/modEventOrganization.class.php index ec68c1eaa92..0fe4cbc3b53 100644 --- a/htdocs/core/modules/modEventOrganization.class.php +++ b/htdocs/core/modules/modEventOrganization.class.php @@ -427,6 +427,13 @@ class modEventOrganization extends DolibarrModules { global $conf, $langs, $user; + /*$result = run_sql(DOL_DOCUMENT_ROOT.'/install/mysql/data/llx_c_email_templates.sql', 1, '', 1); + if ($result <= 0) { + return -1; // Do not activate module if error 'not allowed' returned when loading module SQL queries (the _load_table run sql with run_sql with the error allowed parameter set to 'default') + } + TODO Instead use the array merge of the sql found into llx_c_email_templates for this module + */ + // Permissions $this->remove($options); From 7d4312d574691e80285d5c9239ccf85d47123c9a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 10 May 2023 16:51:31 +0200 Subject: [PATCH 08/14] Debug v17 --- htdocs/install/mysql/data/llx_c_email_templates.sql | 2 ++ htdocs/public/project/suggestbooth.php | 4 ++-- htdocs/public/project/suggestconference.php | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/htdocs/install/mysql/data/llx_c_email_templates.sql b/htdocs/install/mysql/data/llx_c_email_templates.sql index d2886631942..5ad37ffa8e0 100644 --- a/htdocs/install/mysql/data/llx_c_email_templates.sql +++ b/htdocs/install/mysql/data/llx_c_email_templates.sql @@ -35,7 +35,9 @@ INSERT INTO llx_c_email_templates (entity, module, type_template, lang, private, INSERT INTO llx_c_email_templates (entity, module, type_template, lang, private, fk_user, datec, label, position, enabled, active, topic, content, content_lines, joinfiles) VALUES (0, 'recruitment','recruitmentcandidature_send','',0,null,null,'(AnswerCandidature)' ,100,'isModEnabled("recruitment")',1,'[__[MAIN_INFO_SOCIETE_NOM]__] __(YourCandidature)__', '__(Hello)__ __CANDIDATE_FULLNAME__,

\n\n__(YourCandidatureAnswerMessage)__
__ONLINE_INTERVIEW_SCHEDULER_TEXT_AND_URL__\n

\n__(Sincerely)__
__USER_SIGNATURE__',null, 0); -- Event organization +-- Message for default setup of EVENTORGANIZATION_TEMPLATE_EMAIL_ASK_CONF INSERT INTO llx_c_email_templates (entity, module, type_template, lang, private, fk_user, datec, label, position, active, topic, content, content_lines, enabled, joinfiles) values (0, '', 'conferenceorbooth', '', 0, null, null, '(EventOrganizationEmailAskConf)', 10, 1, '[__[MAIN_INFO_SOCIETE_NOM]__] __(EventOrganizationEmailAskConf)__', '__(Hello)__,

__(OrganizationEventConfRequestWasReceived)__


__(Sincerely)__
__USER_SIGNATURE__', null, '1', null); +-- Message for default setup of EVENTORGANIZATION_TEMPLATE_EMAIL_ASK_BOOTH INSERT INTO llx_c_email_templates (entity, module, type_template, lang, private, fk_user, datec, label, position, active, topic, content, content_lines, enabled, joinfiles) values (0, '', 'conferenceorbooth', '', 0, null, null, '(EventOrganizationEmailAskBooth)', 20, 1, '[__[MAIN_INFO_SOCIETE_NOM]__] __(EventOrganizationEmailAskBooth)__', '__(Hello)__,

__(OrganizationEventBoothRequestWasReceived)__


__(Sincerely)__
__USER_SIGNATURE__', null, '1', null); -- TODO Add message for registration only to event __ONLINE_PAYMENT_TEXT_AND_URL__ INSERT INTO llx_c_email_templates (entity, module, type_template, lang, private, fk_user, datec, label, position, active, topic, content, content_lines, enabled, joinfiles) values (0, '', 'conferenceorbooth', '', 0, null, null, '(EventOrganizationEmailBoothPayment)', 30, 1, '[__[MAIN_INFO_SOCIETE_NOM]__] __(EventOrganizationEmailBoothPayment)__', '__(Hello)__,

__(OrganizationEventPaymentOfBoothWasReceived)__


__(Sincerely)__
__USER_SIGNATURE__', null, '1', null); diff --git a/htdocs/public/project/suggestbooth.php b/htdocs/public/project/suggestbooth.php index e6a844ac587..c56f1fea04c 100644 --- a/htdocs/public/project/suggestbooth.php +++ b/htdocs/public/project/suggestbooth.php @@ -495,11 +495,11 @@ if (empty($reshook) && $action == 'add') { $outputlangs = new Translate('', $conf); $outputlangs->setDefaultLang(empty($thirdparty->default_lang) ? $mysoc->default_lang : $thirdparty->default_lang); // Load traductions files required by page - $outputlangs->loadLangs(array("main", "members")); + $outputlangs->loadLangs(array("main", "members", "eventorganization")); // Get email content from template $arraydefaultmessage = null; - $labeltouse = $conf->global->EVENTORGANIZATION_TEMPLATE_EMAIL_ASK_BOOTH; + $labeltouse = getDolGlobalString('EVENTORGANIZATION_TEMPLATE_EMAIL_ASK_BOOTH'); if (!empty($labeltouse)) { $arraydefaultmessage = $formmail->getEMailTemplate($db, 'conferenceorbooth', $user, $outputlangs, $labeltouse, 1, ''); } diff --git a/htdocs/public/project/suggestconference.php b/htdocs/public/project/suggestconference.php index 8fe19b940d8..6538347904b 100644 --- a/htdocs/public/project/suggestconference.php +++ b/htdocs/public/project/suggestconference.php @@ -426,7 +426,7 @@ if (empty($reshook) && $action == 'add') { $outputlangs = new Translate('', $conf); $outputlangs->setDefaultLang(empty($thirdparty->default_lang) ? $mysoc->default_lang : $thirdparty->default_lang); // Load traductions files required by page - $outputlangs->loadLangs(array("main", "members")); + $outputlangs->loadLangs(array("main", "members", "eventorganization")); // Get email content from template $arraydefaultmessage = null; From a3a9d1ac9fb1f550e74ffaef7119e16a3df3f9ed Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 10 May 2023 18:56:17 +0200 Subject: [PATCH 09/14] Fix SQL error --- htdocs/comm/card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/comm/card.php b/htdocs/comm/card.php index f20a70f87dd..15d1a0b2dcd 100644 --- a/htdocs/comm/card.php +++ b/htdocs/comm/card.php @@ -1428,7 +1428,7 @@ if ($object->id > 0) { $sql .= " WHERE f.fk_soc = s.rowid AND s.rowid = ".((int) $object->id); $sql .= " AND f.entity IN (".getEntity('invoice').")"; $sql .= ' GROUP BY f.rowid, f.ref, f.type, f.total_ht, f.total_tva, f.total_ttc,'; - $sql .= ' f.entity, f.datef, f.datec, f.paye, f.fk_statut,'; + $sql .= ' f.entity, f.date_lim_reglement, f.datef, f.datec, f.paye, f.fk_statut,'; $sql .= ' s.nom, s.rowid'; $sql .= " ORDER BY f.datef DESC, f.datec DESC"; From 9674d234ba050778fc10ab5f2f3f4d8c09e67a72 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 10 May 2023 19:56:55 +0200 Subject: [PATCH 10/14] FIX On company change, we must reuse the company parameters --- htdocs/comm/propal/card.php | 6 +++--- htdocs/commande/card.php | 19 ++++++++++--------- 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/htdocs/comm/propal/card.php b/htdocs/comm/propal/card.php index d76c28ed813..4fe93ad4df7 100644 --- a/htdocs/comm/propal/card.php +++ b/htdocs/comm/propal/card.php @@ -1844,7 +1844,7 @@ if ($action == 'create') { // Source / Channel - What trigger creation print '
'; // Delivery delay @@ -1854,7 +1854,7 @@ if ($action == 'create') { } print ''; // Shipping Method @@ -1864,7 +1864,7 @@ if ($action == 'create') { } print ''; } diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php index 3edfe0fafc5..fdfd57a5cf6 100644 --- a/htdocs/commande/card.php +++ b/htdocs/commande/card.php @@ -1651,10 +1651,10 @@ if ($action == 'create' && $usercancreate) { if (!$remise_percent) { $remise_percent = $soc->remise_percent; } - if (!$dateorder) { + /*if (!$dateorder) { // Do not set 0 here (0 for a date is 1970) - $dateorder = (empty($dateinvoice) ? (empty($conf->global->MAIN_AUTOFILL_DATE_ODER) ?-1 : '') : $dateorder); - } + $dateorder = (empty($dateinvoice) ? (empty($conf->global->MAIN_AUTOFILL_DATE_ORDER) ?-1 : '') : $dateorder); + }*/ } else { // For compatibility if ($element == 'order' || $element == 'commande') { @@ -1753,7 +1753,7 @@ if ($action == 'create' && $usercancreate) { print ''; print ''; print ''; - print ''."\n"; + print ''; // will be set to 1 by javascript so we know post is done after a company change print ''; print ''; print ''; @@ -1797,6 +1797,7 @@ if ($action == 'create' && $usercancreate) { var socid = $(this).val(); // reload page $("input[name=action]").val("create"); + $("input[name=changecompany]").val("1"); $("form[name=crea_commande]").submit(); }); }); @@ -1844,25 +1845,25 @@ if ($action == 'create' && $usercancreate) { // Delivery delay print ''; // Terms of payment print ''; // Payment mode print ''; // Bank Account if (!empty($conf->global->BANK_ASK_PAYMENT_BANK_DURING_ORDER) && isModEnabled("banque")) { print ''; } @@ -1870,7 +1871,7 @@ if ($action == 'create' && $usercancreate) { if (isModEnabled('expedition')) { print ''; } From f3f67c2f6fb5128ba30e6bd0737f843bb675f100 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 10 May 2023 22:52:31 +0200 Subject: [PATCH 11/14] Debug v17 --- htdocs/compta/facture/list.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/htdocs/compta/facture/list.php b/htdocs/compta/facture/list.php index 335330cd8e2..0a1820bb9ee 100644 --- a/htdocs/compta/facture/list.php +++ b/htdocs/compta/facture/list.php @@ -2411,15 +2411,15 @@ if ($resql) { print ''; if (!$i) { $totalarray['nbfield']++; + $totalarray['pos'][$totalarray['nbfield']] = 'total_pa'; } + $totalarray['val']['total_pa'] += $marginInfo['pa_total']; } // Total margin if (!empty($arrayfields['total_margin']['checked'])) { print ''; if (!$i) { $totalarray['nbfield']++; - } - if (!$i) { $totalarray['pos'][$totalarray['nbfield']] = 'total_margin'; } $totalarray['val']['total_margin'] += $marginInfo['total_margin']; @@ -2549,6 +2549,7 @@ if ($resql) { } // Use correct digits number for totals + $totalarray['val']['total_pa'] = (isset($totalarray['val']['total_pa']) ? price2num($totalarray['val']['total_pa'], 'MT') : null); $totalarray['val']['total_margin'] = (isset($totalarray['val']['total_margin']) ? price2num($totalarray['val']['total_margin'], 'MT') : null); // Show total line From afe64323d2e0127a1a1152919c4e2507803c248b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 10 May 2023 23:55:50 +0200 Subject: [PATCH 12/14] FIX Margin calculation for credit notes on margin reports --- htdocs/core/class/html.formmargin.class.php | 3 ++- htdocs/margin/agentMargins.php | 6 ++++-- htdocs/margin/customerMargins.php | 18 ++++++++++++------ htdocs/margin/productMargins.php | 8 +++++--- 4 files changed, 23 insertions(+), 12 deletions(-) diff --git a/htdocs/core/class/html.formmargin.class.php b/htdocs/core/class/html.formmargin.class.php index 9dde241d56d..db01c54d5c7 100644 --- a/htdocs/core/class/html.formmargin.class.php +++ b/htdocs/core/class/html.formmargin.class.php @@ -98,7 +98,8 @@ class FormMargin } $pv = $line->total_ht; - $pa_ht = (($pv < 0 || ($pv == 0 && in_array($object->element, array('facture', 'facture_fourn')) && $object->type == $object::TYPE_CREDIT_NOTE)) ? -$line->pa_ht : $line->pa_ht); // We choosed to have line->pa_ht always positive in database, so we guess the correct sign + // We choosed to have line->pa_ht always positive in database, so we guess the correct sign + $pa_ht = (($pv < 0 || ($pv == 0 && in_array($object->element, array('facture', 'facture_fourn')) && $object->type == $object::TYPE_CREDIT_NOTE)) ? -$line->pa_ht : $line->pa_ht); if (getDolGlobalInt('INVOICE_USE_SITUATION') == 1) { // Special case for old situation mode if (($object->element == 'facture' && $object->type == $object::TYPE_SITUATION) || ($object->element == 'facture' && $object->type == $object::TYPE_CREDIT_NOTE && getDolGlobalInt('INVOICE_USE_SITUATION_CREDIT_NOTE') && $object->situation_counter > 0)) { diff --git a/htdocs/margin/agentMargins.php b/htdocs/margin/agentMargins.php index c209fb1f957..f369f1889c2 100644 --- a/htdocs/margin/agentMargins.php +++ b/htdocs/margin/agentMargins.php @@ -151,8 +151,10 @@ $sql .= " s.rowid as socid, s.nom as name, s.code_client, s.client,"; $sql .= " u.rowid as agent, u.login, u.lastname, u.firstname,"; $sql .= " sum(d.total_ht) as selling_price,"; // Note: qty and buy_price_ht is always positive (if not your database may be corrupted, you can update this) -$sql .= " sum(".$db->ifsql('d.total_ht < 0', 'd.qty * d.buy_price_ht * -1 * (d.situation_percent / 100)', 'd.qty * d.buy_price_ht * (d.situation_percent / 100)').") as buying_price,"; -$sql .= " sum(".$db->ifsql('d.total_ht < 0', '-1 * (abs(d.total_ht) - (d.buy_price_ht * d.qty * (d.situation_percent / 100)))', 'd.total_ht - (d.buy_price_ht * d.qty * (d.situation_percent / 100))').") as marge"; + +$sql .= " sum(".$db->ifsql('(d.total_ht < 0 OR (d.total_ht = 0 AND f.type = 2))', '-1 * d.qty * d.buy_price_ht * (d.situation_percent / 100)', 'd.qty * d.buy_price_ht * (d.situation_percent / 100)').") as buying_price,"; +$sql .= " sum(".$db->ifsql('(d.total_ht < 0 OR (d.total_ht = 0 AND f.type = 2))', '-1 * (abs(d.total_ht) - (d.buy_price_ht * d.qty * (d.situation_percent / 100)))', 'd.total_ht - (d.buy_price_ht * d.qty * (d.situation_percent / 100))').") as marge"; + $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; $sql .= ", ".MAIN_DB_PREFIX."facture as f"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."element_contact e ON e.element_id = f.rowid and e.statut = 4 and e.fk_c_type_contact = ".(empty($conf->global->AGENT_CONTACT_TYPE) ?-1 : $conf->global->AGENT_CONTACT_TYPE); diff --git a/htdocs/margin/customerMargins.php b/htdocs/margin/customerMargins.php index df040e68bdb..ef0de2908da 100644 --- a/htdocs/margin/customerMargins.php +++ b/htdocs/margin/customerMargins.php @@ -215,12 +215,14 @@ $invoice_status_except_list = array(Facture::STATUS_DRAFT, Facture::STATUS_ABAND $sql = "SELECT"; $sql .= " s.rowid as socid, s.nom as name, s.code_client, s.client,"; if ($client) { - $sql .= " f.rowid as facid, f.ref, f.total_ht, f.datef, f.paye, f.fk_statut as statut,"; + $sql .= " f.rowid as facid, f.ref, f.total_ht, f.datef, f.paye, f.type, f.fk_statut as statut,"; } $sql .= " sum(d.total_ht) as selling_price,"; // Note: qty and buy_price_ht is always positive (if not, your database may be corrupted, you can update this) -$sql .= " sum(".$db->ifsql('d.total_ht < 0', 'd.qty * d.buy_price_ht * -1 * (d.situation_percent / 100)', 'd.qty * d.buy_price_ht * (d.situation_percent / 100)').") as buying_price,"; -$sql .= " sum(".$db->ifsql('d.total_ht < 0', '-1 * (abs(d.total_ht) - (d.buy_price_ht * d.qty * (d.situation_percent / 100)))', 'd.total_ht - (d.buy_price_ht * d.qty * (d.situation_percent / 100))').") as marge"; + +$sql .= " sum(".$db->ifsql('(d.total_ht < 0 OR (d.total_ht = 0 AND f.type = 2))', '-1 * d.qty * d.buy_price_ht * (d.situation_percent / 100)', 'd.qty * d.buy_price_ht * (d.situation_percent / 100)').") as buying_price,"; +$sql .= " sum(".$db->ifsql('(d.total_ht < 0 OR (d.total_ht = 0 AND f.type = 2))', '-1 * (abs(d.total_ht) - (d.buy_price_ht * d.qty * (d.situation_percent / 100)))', 'd.total_ht - (d.buy_price_ht * d.qty * (d.situation_percent / 100))').") as marge"; + $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; $sql .= ", ".MAIN_DB_PREFIX."facture as f"; $sql .= ", ".MAIN_DB_PREFIX."facturedet as d"; @@ -262,7 +264,7 @@ if (isset($conf->global->ForceBuyingPriceIfNull) && $conf->global->ForceBuyingPr $sql .= " AND d.buy_price_ht <> 0"; } if ($client) { - $sql .= " GROUP BY s.rowid, s.nom, s.code_client, s.client, f.rowid, f.ref, f.total_ht, f.datef, f.paye, f.fk_statut"; + $sql .= " GROUP BY s.rowid, s.nom, s.code_client, s.client, f.rowid, f.ref, f.total_ht, f.datef, f.paye, f.type, f.fk_statut"; } else { $sql .= " GROUP BY s.rowid, s.nom, s.code_client, s.client"; } @@ -353,9 +355,12 @@ if ($result) { print ''; if ($client) { - print ''; print ''; } @@ -400,7 +406,7 @@ if ($result) { print ''; if ($client) { - print '
'.$langs->trans('ExpireDate').''; if ($action == 'edit') { @@ -575,9 +576,11 @@ if (GETPOST('ajoutsujet')) { accessforbidden(); } - print ''."\n"; + print ''."\n"; print ''; print ''; + print ''; + print ''; print '
'."\n"; print "

\n"; @@ -591,7 +594,7 @@ if (GETPOST('ajoutsujet')) { print ''; print ''; print '     '; - print ''; + print ''; print '

'."\n"; } else { require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; @@ -644,7 +647,7 @@ if (GETPOST('ajoutsujet')) { print '

'; print' '."\n"; print '   '; - print ''; + print ''; } print ''."\n"; @@ -757,10 +760,10 @@ if ($object->format == "D") { } else { $next = intval($toutsujet[$i + 1]); } - if ($next && dol_print_date($cur, "%a %e") == dol_print_date($next, "%a %e") && dol_print_date($cur, "%B") == dol_print_date($next, "%B")) { + if ($next && dol_print_date($cur, "%a %d") == dol_print_date($next, "%a %d") && dol_print_date($cur, "%B") == dol_print_date($next, "%B")) { $colspan++; } else { - print '
'.dol_print_date($cur, "%a %e").''.dol_print_date($cur, "%a %d").''.dol_print_date($cur, "%a %e").''.dol_print_date($cur, "%a %d").'
'.$langs->trans('Source').''; print img_picto('', 'question', 'class="pictofixedwidth"'); - $form->selectInputReason('', 'demand_reason_id', "SRC_PROP", 1, 'maxwidth200 widthcentpercentminusx'); + $form->selectInputReason((GETPOSTISSET('demand_reason_id') ? GETPOST('demand_reason_id', 'int') : ''), 'demand_reason_id', "SRC_PROP", 1, 'maxwidth200 widthcentpercentminusx'); print '
'; print img_picto('', 'clock', 'class="pictofixedwidth"'); - $form->selectAvailabilityDelay('', 'availability_id', '', 1, 'maxwidth200 widthcentpercentminusx'); + $form->selectAvailabilityDelay((GETPOSTISSET('availability_id') ? GETPOST('availability_id', 'int') : ''), 'availability_id', '', 1, 'maxwidth200 widthcentpercentminusx'); print '
'.$langs->trans('SendingMethod').''; print img_picto('', 'object_dollyrevert', 'class="pictofixedwidth"'); - $form->selectShippingMethod($shipping_method_id, 'shipping_method_id', '', 1, '', 0, 'maxwidth200 widthcentpercentminusx'); + $form->selectShippingMethod((GETPOSTISSET('shipping_method_id') ? GETPOST('shipping_method_id', 'int') : $shipping_method_id), 'shipping_method_id', '', 1, '', 0, 'maxwidth200 widthcentpercentminusx'); print '
'.$langs->trans('AvailabilityPeriod').''; print img_picto('', 'clock', 'class="pictofixedwidth"'); - $form->selectAvailabilityDelay((GETPOSTISSET('availability_id')?GETPOST('availability_id'):$availability_id), 'availability_id', '', 1, 'maxwidth200 widthcentpercentminusx'); + $form->selectAvailabilityDelay((GETPOSTISSET('availability_id') ? GETPOST('availability_id') : $availability_id), 'availability_id', '', 1, 'maxwidth200 widthcentpercentminusx'); print '
'.$langs->trans('PaymentConditionsShort').''; print img_picto('', 'payment', 'class="pictofixedwidth"'); - print $form->getSelectConditionsPaiements((GETPOSTISSET('cond_reglement_id')?GETPOST('cond_reglement_id'):$cond_reglement_id), 'cond_reglement_id', 1, 1, 0, 'maxwidth200 widthcentpercentminusx', $deposit_percent); + print $form->getSelectConditionsPaiements(((GETPOSTISSET('cond_reglement_id') && GETPOST('cond_reglement_id', 'int') != 0) ? GETPOST('cond_reglement_id') : $cond_reglement_id), 'cond_reglement_id', 1, 1, 0, 'maxwidth200 widthcentpercentminusx', $deposit_percent); print '
'.$langs->trans('PaymentMode').''; print img_picto('', 'bank', 'class="pictofixedwidth"'); - print $form->select_types_paiements((GETPOSTISSET('mode_reglement_id')?GETPOST('mode_reglement_id'):$mode_reglement_id), 'mode_reglement_id', 'CRDT', 0, 1, 0, 0, 1, 'maxwidth200 widthcentpercentminusx', 1); + print $form->select_types_paiements(((GETPOSTISSET('mode_reglement_id') && GETPOST('mode_reglement_id', 'int') != 0) ? GETPOST('mode_reglement_id') : $mode_reglement_id), 'mode_reglement_id', 'CRDT', 0, 1, 0, 0, 1, 'maxwidth200 widthcentpercentminusx', 1); print '
'.$langs->trans('BankAccount').''; - print img_picto('', 'bank_account', 'class="pictofixedwidth"').$form->select_comptes((GETPOSTISSET('fk_account')?GETPOST('fk_account'):$fk_account), 'fk_account', 0, '', 1, '', 0, 'maxwidth200 widthcentpercentminusx', 1); + print img_picto('', 'bank_account', 'class="pictofixedwidth"').$form->select_comptes(((GETPOSTISSET('fk_account') && GETPOST('fk_account', 'int') != 0) ? GETPOST('fk_account') : $fk_account), 'fk_account', 0, '', 1, '', 0, 'maxwidth200 widthcentpercentminusx', 1); print '
'.$langs->trans('SendingMethod').''; print img_picto('', 'object_dolly', 'class="pictofixedwidth"'); - $form->selectShippingMethod((GETPOSTISSET('shipping_method_id')?GETPOST('shipping_method_id'):$shipping_method_id), 'shipping_method_id', '', 1, '', 0, 'maxwidth200 widthcentpercentminusx'); + $form->selectShippingMethod(((GETPOSTISSET('shipping_method_id') && GETPOST('shipping_method_id', 'int') != 0) ? GETPOST('shipping_method_id') : $shipping_method_id), 'shipping_method_id', '', 1, '', 0, 'maxwidth200 widthcentpercentminusx'); print '
'.price($marginInfo['pa_total'], 0, $langs, 1, -1, 'MT').''.price($marginInfo['total_margin'], 0, $langs, 1, -1, 'MT').'
'; $invoicestatic->id = $objp->facid; $invoicestatic->ref = $objp->ref; + $invoicestatic->statut = $objp->statut; + $invoicestatic->type = $objp->type; + + print ''; print $invoicestatic->getNomUrl(1); print ''; @@ -364,6 +369,7 @@ if ($result) { $companystatic->id = $objp->socid; $companystatic->name = $objp->name; $companystatic->client = $objp->client; + print ''.$companystatic->getNomUrl(1, 'margin').'
'; + print ''; } else { print ''; } diff --git a/htdocs/margin/productMargins.php b/htdocs/margin/productMargins.php index 634d0ca50ca..fc19d7280b4 100644 --- a/htdocs/margin/productMargins.php +++ b/htdocs/margin/productMargins.php @@ -185,10 +185,12 @@ if ($id > 0) { $sql .= " f.rowid as facid, f.ref, f.total_ht, f.datef, f.paye, f.fk_statut as statut,"; } $sql .= " SUM(d.total_ht) as selling_price,"; -// Note: qty and buy_price_ht is always positive (if not your database may be corrupted, you can update this) $sql .= " SUM(d.qty) as product_qty,"; -$sql .= " SUM(".$db->ifsql('d.total_ht < 0', 'd.qty * d.buy_price_ht * -1 * (d.situation_percent / 100)', 'd.qty * d.buy_price_ht * (d.situation_percent / 100)').") as buying_price,"; -$sql .= " SUM(".$db->ifsql('d.total_ht < 0', '-1 * (abs(d.total_ht) - (d.buy_price_ht * d.qty * (d.situation_percent / 100)))', 'd.total_ht - (d.buy_price_ht * d.qty * (d.situation_percent / 100))').") as marge"; + +// Note: qty and buy_price_ht is always positive (if not your database may be corrupted, you can update this) +$sql .= " SUM(".$db->ifsql('(d.total_ht < 0 OR (d.total_ht = 0 AND f.type = 2))', '-1 * d.qty * d.buy_price_ht * (d.situation_percent / 100)', 'd.qty * d.buy_price_ht * (d.situation_percent / 100)').") as buying_price,"; +$sql .= " SUM(".$db->ifsql('(d.total_ht < 0 OR (d.total_ht = 0 AND f.type = 2))', '-1 * (abs(d.total_ht) - (d.buy_price_ht * d.qty * (d.situation_percent / 100)))', 'd.total_ht - (d.buy_price_ht * d.qty * (d.situation_percent / 100))').") as marge"; + $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; $sql .= ", ".MAIN_DB_PREFIX."facture as f"; $sql .= ", ".MAIN_DB_PREFIX."facturedet as d"; From f88f5cd7c6dec6f79e3249076f1d14e811f75fd7 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 11 May 2023 02:09:39 +0200 Subject: [PATCH 13/14] Fix css --- htdocs/projet/tasks/list.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/projet/tasks/list.php b/htdocs/projet/tasks/list.php index 72c5eb25874..f293b1772a3 100644 --- a/htdocs/projet/tasks/list.php +++ b/htdocs/projet/tasks/list.php @@ -161,8 +161,8 @@ $arrayfields = array( 't.datee'=>array('label'=>"Deadline", 'checked'=>1, 'position'=>101), 'p.ref'=>array('label'=>"ProjectRef", 'checked'=>1), 'p.title'=>array('label'=>"ProjectLabel", 'checked'=>0), - 's.nom'=>array('label'=>"ThirdParty", 'checked'=>0), - 's.name_alias'=>array('label'=>"AliasNameShort", 'checked'=>1), + 's.nom'=>array('label'=>"ThirdParty", 'checked'=>0, 'csslist'=>'tdoverflowmax125'), + 's.name_alias'=>array('label'=>"AliasNameShort", 'checked'=>1, 'csslist'=>'tdoverflowmax125'), 'p.fk_statut'=>array('label'=>"ProjectStatus", 'checked'=>1), 't.planned_workload'=>array('label'=>"PlannedWorkload", 'checked'=>1, 'position'=>102), 't.duration_effective'=>array('label'=>"TimeSpent", 'checked'=>1, 'position'=>103), From 2f6b95c0733024e4e95185abf8bcef30247e7e40 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 11 May 2023 18:42:56 +0200 Subject: [PATCH 14/14] FIX Sending email from attendee list --- htdocs/core/actions_massactions.inc.php | 38 ++++++++++++++--------- htdocs/core/class/html.formmail.class.php | 4 +++ htdocs/core/lib/functions.lib.php | 7 ++++- 3 files changed, 33 insertions(+), 16 deletions(-) diff --git a/htdocs/core/actions_massactions.inc.php b/htdocs/core/actions_massactions.inc.php index 5fbc305b58b..3ef0b96c1e8 100644 --- a/htdocs/core/actions_massactions.inc.php +++ b/htdocs/core/actions_massactions.inc.php @@ -88,9 +88,10 @@ if (!$error && $massaction == 'confirm_presend') { $oneemailperrecipient = (GETPOST('oneemailperrecipient', 'int') ? 1 : 0); if (!$error) { - $thirdparty = new Societe($db); - $objecttmp = new $objectclass($db); + + // Define object $thirdparty (Societe or User, Adherent, ConferenceOrBoothAttendee...) + $thirdparty = new Societe($db); if ($objecttmp->element == 'expensereport') { $thirdparty = new User($db); } @@ -100,28 +101,33 @@ if (!$error && $massaction == 'confirm_presend') { if ($objecttmp->element == 'holiday') { $thirdparty = new User($db); } + if ($objecttmp->element == 'conferenceorboothattendee') { + $thirdparty = new ConferenceOrBoothAttendee($db); + } foreach ($toselect as $toselectid) { $objecttmp = new $objectclass($db); // we must create new instance because instance is saved into $listofobjectref array for future use $result = $objecttmp->fetch($toselectid); if ($result > 0) { $listofobjectid[$toselectid] = $toselectid; - - $thirdpartyid = ($objecttmp->fk_soc ? $objecttmp->fk_soc : $objecttmp->socid); + $tmpobjectid = ($objecttmp->fk_soc ? $objecttmp->fk_soc : $objecttmp->socid); if ($objecttmp->element == 'societe') { - $thirdpartyid = $objecttmp->id; + $tmpobjectid = $objecttmp->id; } if ($objecttmp->element == 'expensereport') { - $thirdpartyid = $objecttmp->fk_user_author; + $tmpobjectid = $objecttmp->fk_user_author; } if ($objecttmp->element == 'partnership' && getDolGlobalString('PARTNERSHIP_IS_MANAGED_FOR') == 'member') { - $thirdpartyid = $objecttmp->fk_member; + $tmpobjectid = $objecttmp->fk_member; } if ($objecttmp->element == 'holiday') { - $thirdpartyid = $objecttmp->fk_user; + $tmpobjectid = $objecttmp->fk_user; } - if (empty($thirdpartyid)) { - $thirdpartyid = 0; + if ($objecttmp->element == 'conferenceorboothattendee') { + $tmpobjectid = $objecttmp->id; + } + if (empty($tmpobjectid)) { + $tmpobjectid = 0; } if ($objectclass == 'Facture') { @@ -142,8 +148,8 @@ if (!$error && $massaction == 'confirm_presend') { } } - $listofobjectthirdparties[$thirdpartyid] = $thirdpartyid; - $listofobjectref[$thirdpartyid][$toselectid] = $objecttmp; + $listofobjectthirdparties[$tmpobjectid] = $tmpobjectid; + $listofobjectref[$tmpobjectid][$toselectid] = $objecttmp; } } } @@ -175,7 +181,7 @@ if (!$error && $massaction == 'confirm_presend') { $massaction = 'presend'; } - // Loop on each recipient/thirdparty + // Loop on each recipient (may be a thirdparty but also a user, a conferenceorboothattendee, ...) if (!$error) { foreach ($listofobjectthirdparties as $thirdpartyid) { $result = $thirdparty->fetch($thirdpartyid); @@ -187,7 +193,7 @@ if (!$error && $massaction == 'confirm_presend') { $sendto = ''; $sendtocc = ''; $sendtobcc = ''; - $sendtoid = array(); + //$sendtoid = array(); // Define $sendto $tmparray = array(); @@ -202,7 +208,7 @@ if (!$error && $massaction == 'confirm_presend') { $tmparray[] = $thirdparty->name.' <'.$thirdparty->email.'>'; } elseif ($val && method_exists($thirdparty, 'contact_get_property')) { // Id of contact $tmparray[] = $thirdparty->contact_get_property((int) $val, 'email'); - $sendtoid[] = $val; + //$sendtoid[] = $val; } } } @@ -302,6 +308,8 @@ if (!$error && $massaction == 'confirm_presend') { if (count($emails_to_sends) > 0) { $sendto = implode(',', $emails_to_sends); } + } elseif ($objectobj->element == 'conferenceorboothattendee') { + $sendto = $objectobj->email; } else { $objectobj->fetch_thirdparty(); $sendto = $objectobj->thirdparty->email; diff --git a/htdocs/core/class/html.formmail.class.php b/htdocs/core/class/html.formmail.class.php index 665ec68c85f..5a031849964 100644 --- a/htdocs/core/class/html.formmail.class.php +++ b/htdocs/core/class/html.formmail.class.php @@ -543,6 +543,10 @@ class FormMail extends Form $helpforsubstitution .= $langs->trans('AvailableVariables').' :
'."\n"; } foreach ($this->substit as $key => $val) { + // Do not show deprecated variables into the tooltip help of substitution variables + if (in_array($key, array('__NEWREF__', '__REFCLIENT__', '__REFSUPPLIER__', '__SUPPLIER_ORDER_DATE_DELIVERY__', '__SUPPLIER_ORDER_DELAY_DELIVERY__'))) { + continue; + } $helpforsubstitution .= $key.' -> '.$langs->trans(dol_string_nohtmltag(dolGetFirstLineOfText($val))).'
'; } if (!empty($this->withsubstit)) { // Unset or set ->withsubstit=0 to disable this. diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 7a6bb97c0f9..03783e37561 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -7747,7 +7747,7 @@ function getCommonSubstitutionArray($outputlangs, $onlykey = 0, $exclude = null, $substitutionarray['__DATE_DELIVERY_MM__'] = (isset($object->date_livraison) ? dol_print_date($object->date_livraison, "%M") : ''); $substitutionarray['__DATE_DELIVERY_SS__'] = (isset($object->date_livraison) ? dol_print_date($object->date_livraison, "%S") : ''); - // For backward compatibility + // For backward compatibility (deprecated) $substitutionarray['__REFCLIENT__'] = (isset($object->ref_client) ? $object->ref_client : (isset($object->ref_customer) ? $object->ref_customer : null)); $substitutionarray['__REFSUPPLIER__'] = (isset($object->ref_supplier) ? $object->ref_supplier : null); $substitutionarray['__SUPPLIER_ORDER_DATE_DELIVERY__'] = (isset($object->date_livraison) ? dol_print_date($object->date_livraison, 'day', 0, $outputlangs) : ''); @@ -7841,6 +7841,11 @@ function getCommonSubstitutionArray($outputlangs, $onlykey = 0, $exclude = null, $substitutionarray['__CANDIDATE_FIRSTNAME__'] = isset($object->firstname) ? $object->firstname : ''; $substitutionarray['__CANDIDATE_LASTNAME__'] = isset($object->lastname) ? $object->lastname : ''; } + if (is_object($object) && $object->element == 'conferenceorboothattendee') { + $substitutionarray['__ATTENDEE_FULLNAME__'] = $object->getFullName($outputlangs); + $substitutionarray['__ATTENDEE_FIRSTNAME__'] = isset($object->firstname) ? $object->firstname : ''; + $substitutionarray['__ATTENDEE_LASTNAME__'] = isset($object->lastname) ? $object->lastname : ''; + } if (is_object($object->project)) { $substitutionarray['__PROJECT_ID__'] = (is_object($object->project) ? $object->project->id : '');