diff --git a/htdocs/commande/contact.php b/htdocs/commande/contact.php index 7df7dbea130..add4244d7dc 100644 --- a/htdocs/commande/contact.php +++ b/htdocs/commande/contact.php @@ -3,6 +3,7 @@ * Copyright (C) 2005-2011 Laurent Destailleur * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2011-2015 Philippe Grand + * Copyright (C) 2021 Frédéric France * * 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 @@ -128,23 +129,17 @@ $userstatic = new User($db); /* */ /* *************************************************************************** */ -if ($id > 0 || !empty($ref)) -{ - $langs->trans("OrderCard"); - - if ($object->fetch($id, $ref) > 0) - { +if ($id > 0 || !empty($ref)) { + if ($object->fetch($id, $ref) > 0) { $object->fetch_thirdparty(); $head = commande_prepare_head($object); print dol_get_fiche_head($head, 'contact', $langs->trans("CustomerOrder"), -1, 'order'); - // Order card $linkback = ''.$langs->trans("BackToList").''; - $morehtmlref = '
'; // Ref customer $morehtmlref .= $form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', 0, 1); diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 3e7890a2d51..b442345199f 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -6301,7 +6301,7 @@ class Form */ public function selectForFormsList($objecttmp, $htmlname, $preselectedvalue, $showempty = '', $searchkey = '', $placeholder = '', $morecss = '', $moreparams = '', $forcecombo = 0, $outputmode = 0, $disabled = 0) { - global $conf, $langs, $user; + global $conf, $langs, $user, $hookmanager; //print "$objecttmp->filter, $htmlname, $preselectedvalue, $showempty = '', $searchkey = '', $placeholder = '', $morecss = '', $moreparams = '', $forcecombo = 0, $outputmode = 0, $disabled"; @@ -6347,27 +6347,34 @@ class Form } if ($objecttmp->ismultientitymanaged == 'fk_soc@societe') if (!$user->rights->societe->client->voir && !$user->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql .= " WHERE 1=1"; - if (isset($objecttmp->ismultientitymanaged) && $objecttmp->ismultientitymanaged == 1) $sql .= " AND t.entity IN (".getEntity($objecttmp->table_element).")"; - if (isset($objecttmp->ismultientitymanaged) && !is_numeric($objecttmp->ismultientitymanaged)) { - $sql .= ' AND parenttable.entity = t.'.$tmparray[0]; - } - if ($objecttmp->ismultientitymanaged == 1 && !empty($user->socid)) { - if ($objecttmp->element == 'societe') $sql .= " AND t.rowid = ".$user->socid; - else $sql .= " AND t.fk_soc = ".$user->socid; - } - if ($searchkey != '') $sql .= natural_search(explode(',', $fieldstoshow), $searchkey); - if ($objecttmp->ismultientitymanaged == 'fk_soc@societe') { - if (!$user->rights->societe->client->voir && !$user->socid) $sql .= " AND t.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; - } - if ($objecttmp->filter) { // Syntax example "(t.ref:like:'SO-%') and (t.date_creation:<:'20160101')" - /*if (! DolibarrApi::_checkFilters($objecttmp->filter)) - { - throw new RestException(503, 'Error when validating parameter sqlfilters '.$objecttmp->filter); - }*/ - $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; - $sql .= " AND (".preg_replace_callback('/'.$regexstring.'/', 'Form::forgeCriteriaCallback', $objecttmp->filter).")"; - } + + // Add where from hooks + $parameters = array(); + $reshook = $hookmanager->executeHooks('selectForFormsListWhere', $parameters); // Note that $action and $object may have been modified by hook + if (!empty($hookmanager->resPrint)) $sql .= $hookmanager->resPrint; + else { + $sql .= " WHERE 1=1"; + if (isset($objecttmp->ismultientitymanaged) && $objecttmp->ismultientitymanaged == 1) $sql .= " AND t.entity IN (".getEntity($objecttmp->table_element).")"; + if (isset($objecttmp->ismultientitymanaged) && !is_numeric($objecttmp->ismultientitymanaged)) { + $sql .= ' AND parenttable.entity = t.'.$tmparray[0]; + } + if ($objecttmp->ismultientitymanaged == 1 && !empty($user->socid)) { + if ($objecttmp->element == 'societe') $sql .= " AND t.rowid = ".$user->socid; + else $sql .= " AND t.fk_soc = ".$user->socid; + } + if ($searchkey != '') $sql .= natural_search(explode(',', $fieldstoshow), $searchkey); + if ($objecttmp->ismultientitymanaged == 'fk_soc@societe') { + if (!$user->rights->societe->client->voir && !$user->socid) $sql .= " AND t.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; + } + if ($objecttmp->filter) { // Syntax example "(t.ref:like:'SO-%') and (t.date_creation:<:'20160101')" + /*if (! DolibarrApi::_checkFilters($objecttmp->filter)) + { + throw new RestException(503, 'Error when validating parameter sqlfilters '.$objecttmp->filter); + }*/ + $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; + $sql .= " AND (".preg_replace_callback('/'.$regexstring.'/', 'Form::forgeCriteriaCallback', $objecttmp->filter).")"; + } + } $sql .= $this->db->order($fieldstoshow, "ASC"); //$sql.=$this->db->plimit($limit, 0); //print $sql; diff --git a/htdocs/langs/en_US/eventorganization.lang b/htdocs/langs/en_US/eventorganization.lang index 8a0475758e5..247663135db 100644 --- a/htdocs/langs/en_US/eventorganization.lang +++ b/htdocs/langs/en_US/eventorganization.lang @@ -18,7 +18,7 @@ # ModuleEventOrganizationName = Event Organization -EventOrganizationDescription = Event Organization +EventOrganizationDescription = Event Organization through Module Project EventOrganizationDescriptionLong= Manage Event organization for conference, attendees, speaker, and attendees, with public subcription page # @@ -42,7 +42,7 @@ EVENTORGANIZATION_TEMPLATE_EMAIL_BULK_ATTENDES = Template of email of massaction # Object # EventOrganizationConfOrBooth= Conference Or Booth - +ManageOrganizeEvent = Manage event organisation # # Template Mail diff --git a/htdocs/langs/en_US/projects.lang b/htdocs/langs/en_US/projects.lang index 3fbcbb0dca7..33a0fafb5dc 100644 --- a/htdocs/langs/en_US/projects.lang +++ b/htdocs/langs/en_US/projects.lang @@ -269,5 +269,6 @@ OneLinePerPeriod=One line per period RefTaskParent=Ref. Parent Task ProfitIsCalculatedWith=Profit is calculated using AddPersonToTask=Add also to tasks +UsageOrganizeEvent=Usage: Event Organization PROJECT_CLASSIFY_CLOSED_WHEN_ALL_TASKS_DONE=Classify project as closed when all its tasks are completed (100%% progress) PROJECT_CLASSIFY_CLOSED_WHEN_ALL_TASKS_DONE_help=Note: existing projects with all tasks at 100 %% progress won't be affected: you will have to close them manually. This option only affects open projects. diff --git a/htdocs/projet/card.php b/htdocs/projet/card.php index 364cb30633a..0462f9d3391 100644 --- a/htdocs/projet/card.php +++ b/htdocs/projet/card.php @@ -35,7 +35,12 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; // Load translation files required by the page -$langs->loadLangs(array('projects', 'companies')); +$langsLoad=array('projects', 'companies'); +if (!empty($conf->eventorganization->enabled)) { + $langsLoad[]='eventorganization'; +} + +$langs->loadLangs($langsLoad); $id = GETPOST('id', 'int'); $ref = GETPOST('ref', 'alpha'); @@ -569,10 +574,14 @@ if ($action == 'create' && $user->rights->projet->creer) print ''; print '
'; } - /* - print ' '; - $htmltext = $langs->trans("OrganizeEvent"); - print $form->textwithpicto($langs->trans("OrganizeEvent"), $htmltext);*/ + + if (!empty($conf->eventorganization->enabled)) + { + print ' '; + $htmltext = $langs->trans("EventOrganizationDescriptionLong"); + print $form->textwithpicto($langs->trans("ManageOrganizeEvent"), $htmltext); + } + print ''; print ''; @@ -855,6 +864,12 @@ if ($action == 'create' && $user->rights->projet->creer) print $form->textwithpicto($langs->trans("BillTime"), $htmltext); print '
'; } + if (!empty($conf->eventorganization->enabled)) + { + print ' '; + $htmltext = $langs->trans("EventOrganizationDescriptionLong"); + print $form->textwithpicto($langs->trans("ManageOrganizeEvent"), $htmltext); + } print ''; // Thirdparty @@ -1020,6 +1035,13 @@ if ($action == 'create' && $user->rights->projet->creer) print $form->textwithpicto($langs->trans("BillTime"), $htmltext); print '
'; } + + if (!empty($conf->eventorganization->enabled)) + { + print 'usage_organize_event ? ' checked="checked"' : '')).'"> '; + $htmltext = $langs->trans("EventOrganizationDescriptionLong"); + print $form->textwithpicto($langs->trans("ManageOrganizeEvent"), $htmltext); + } print ''; // Visibility diff --git a/htdocs/projet/class/project.class.php b/htdocs/projet/class/project.class.php index c942b68cfe2..ff4be5e8d77 100644 --- a/htdocs/projet/class/project.class.php +++ b/htdocs/projet/class/project.class.php @@ -200,7 +200,7 @@ class Project extends CommonObject 'usage_bill_time' =>array('type'=>'integer', 'label'=>'UsageBillTimeShort', 'enabled'=>1, 'visible'=>-1, 'position'=>130), 'usage_opportunity' =>array('type'=>'integer', 'label'=>'UsageOpportunity', 'enabled'=>1, 'visible'=>-1, 'position'=>135), 'usage_task' =>array('type'=>'integer', 'label'=>'UsageTasks', 'enabled'=>1, 'visible'=>-1, 'position'=>140), - 'usage_organize_event' =>array('type'=>'integer', 'label'=>'Usage organize event', 'enabled'=>1, 'visible'=>-1, 'position'=>145), + 'usage_organize_event' =>array('type'=>'integer', 'label'=>'UsageOrganizeEvent', 'enabled'=>1, 'visible'=>-1, 'position'=>145), 'datec' =>array('type'=>'datetime', 'label'=>'DateCreationShort', 'enabled'=>1, 'visible'=>-2, 'position'=>200), 'tms' =>array('type'=>'timestamp', 'label'=>'DateModificationShort', 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'position'=>205), 'fk_user_creat' =>array('type'=>'integer', 'label'=>'UserCreation', 'enabled'=>1, 'visible'=>0, 'notnull'=>1, 'position'=>210), @@ -232,6 +232,8 @@ class Project extends CommonObject */ public function __construct($db) { + global $conf; + $this->db = $db; $this->statuts_short = array(0 => 'Draft', 1 => 'Opened', 2 => 'Closed'); @@ -248,12 +250,12 @@ class Project extends CommonObject $this->fields['usage_opportunity']['enabled'] = 0; } - if (empty($conf->global->PROJECT_HIDE_TASKS)) { + if (!empty($conf->global->PROJECT_HIDE_TASKS)) { $this->fields['usage_bill_time']['visible'] = 0; $this->fields['usage_task']['visible'] = 0; } - if (empty($conf->global->PROJECT_ORGANIZE_EVENTS)) { + if (empty($conf->eventorganization->enabled)) { $this->fields['usage_organize_event']['visible'] = 0; } } diff --git a/htdocs/projet/class/task.class.php b/htdocs/projet/class/task.class.php index a2e670906ca..39a572e6510 100644 --- a/htdocs/projet/class/task.class.php +++ b/htdocs/projet/class/task.class.php @@ -390,7 +390,7 @@ class Task extends CommonObject } } - if (!$error && $conf->global->PROJECT_CLASSIFY_CLOSED_WHEN_ALL_TASKS_DONE) { + if (!$error && !empty($conf->global->PROJECT_CLASSIFY_CLOSED_WHEN_ALL_TASKS_DONE)) { // Close the parent project if it is open (validated) and its tasks are 100% completed $project = new Project($this->db); if ($project->fetch($this->fk_project) > 0 && $project->statut == Project::STATUS_VALIDATED) { diff --git a/htdocs/projet/list.php b/htdocs/projet/list.php index ad8418dfc0e..c51713d1cce 100644 --- a/htdocs/projet/list.php +++ b/htdocs/projet/list.php @@ -92,6 +92,7 @@ $search_sale = GETPOST('search_sale', 'int'); $search_usage_opportunity = GETPOST('search_usage_opportunity', 'int'); $search_usage_task = GETPOST('search_usage_task', 'int'); $search_usage_bill_time = GETPOST('search_usage_bill_time', 'int'); +$search_usage_event_organization = GETPOST('search_usage_event_organization', 'int'); $optioncss = GETPOST('optioncss', 'alpha'); $mine = $_REQUEST['mode'] == 'mine' ? 1 : 0; @@ -207,6 +208,7 @@ if (empty($reshook)) $search_usage_opportunity = ''; $search_usage_task = ''; $search_usage_bill_time = ''; + $search_usage_event_organization = ''; $toselect = ''; $search_array_options = array(); $search_category_array = array(); @@ -300,7 +302,8 @@ if (count($listofprojectcontacttype) == 0) $listofprojectcontacttype[0] = '0'; / $distinct = 'DISTINCT'; // We add distinct until we are added a protection to be sure a contact of a project and task is only once. $sql = "SELECT ".$distinct." p.rowid as id, p.ref, p.title, p.fk_statut as status, p.fk_opp_status, p.public, p.fk_user_creat"; -$sql .= ", p.datec as date_creation, p.dateo as date_start, p.datee as date_end, p.opp_amount, p.opp_percent, (p.opp_amount*p.opp_percent/100) as opp_weighted_amount, p.tms as date_update, p.budget_amount, p.usage_opportunity, p.usage_task, p.usage_bill_time"; +$sql .= ", p.datec as date_creation, p.dateo as date_start, p.datee as date_end, p.opp_amount, p.opp_percent, (p.opp_amount*p.opp_percent/100) as opp_weighted_amount, p.tms as date_update, p.budget_amount "; +$sql .= ", p.usage_opportunity, p.usage_task, p.usage_bill_time, p.usage_organize_event"; $sql .= ", s.rowid as socid, s.nom as name, s.email"; $sql .= ", cls.code as opp_status_code"; // Add fields from extrafields @@ -369,6 +372,7 @@ if ($search_budget_amount != '') $sql .= natural_search('p.budget_amount', $sear if ($search_usage_opportunity != '' && $search_usage_opportunity >= 0) $sql .= natural_search('p.usage_opportunity', $search_usage_opportunity, 2); if ($search_usage_task != '' && $search_usage_task >= 0) $sql .= natural_search('p.usage_task', $search_usage_task, 2); if ($search_usage_bill_time != '' && $search_usage_bill_time >= 0) $sql .= natural_search('p.usage_bill_time', $search_usage_bill_time, 2); +if ($search_usage_event_organization != '' && $search_usage_event_organization >= 0) $sql .= natural_search('p.usage_organize_event', $search_usage_event_organization, 2); // Add where from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php'; // Add where from hooks @@ -443,6 +447,9 @@ if ($search_project_user != '') $param .= '&search_project_user='.urlencode($s if ($search_sale > 0) $param .= '&search_sale='.urlencode($search_sale); if ($search_opp_amount != '') $param .= '&search_opp_amount='.urlencode($search_opp_amount); if ($search_budget_amount != '') $param .= '&search_budget_amount='.urlencode($search_budget_amount); +if ($search_usage_task != '') $param .= '&search_usage_task='.urlencode($search_usage_task); +if ($search_usage_bill_time != '') $param .= '&search_usage_opportunity='.urlencode($search_usage_bill_time); +if ($search_usage_event_organization != '') $param .= '&search_usage_event_organization='.urlencode($search_usage_event_organization); if ($optioncss != '') $param .= '&optioncss='.urlencode($optioncss); // Add $param from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; @@ -650,6 +657,12 @@ if (!empty($arrayfields['p.usage_bill_time']['checked'])) print $form->selectyesno('search_usage_bill_time', $search_usage_bill_time, 1, false, 1); print ''; } +if (!empty($arrayfields['p.usage_organize_event']['checked'])) +{ + print ''; + print $form->selectyesno('search_usage_event_organization', $search_usage_event_organization, 1, false, 1); + print ''; +} // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php'; @@ -703,6 +716,7 @@ if (!empty($arrayfields['p.budget_amount']['checked'])) print_liste_field_titre( if (!empty($arrayfields['p.usage_opportunity']['checked'])) print_liste_field_titre($arrayfields['p.usage_opportunity']['label'], $_SERVER["PHP_SELF"], 'p.usage_opportunity', "", $param, '', $sortfield, $sortorder, 'right '); if (!empty($arrayfields['p.usage_task']['checked'])) print_liste_field_titre($arrayfields['p.usage_task']['label'], $_SERVER["PHP_SELF"], 'p.usage_task', "", $param, '', $sortfield, $sortorder, 'right '); if (!empty($arrayfields['p.usage_bill_time']['checked'])) print_liste_field_titre($arrayfields['p.usage_bill_time']['label'], $_SERVER["PHP_SELF"], 'p.usage_bill_time', "", $param, '', $sortfield, $sortorder, 'right '); +if (!empty($arrayfields['p.usage_organize_event']['checked'])) print_liste_field_titre($arrayfields['p.usage_organize_event']['label'], $_SERVER["PHP_SELF"], 'p.usage_organize_event', "", $param, '', $sortfield, $sortorder, 'right '); // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; // Hook fields @@ -927,6 +941,17 @@ while ($i < min($num, $limit)) print ''; if (!$i) $totalarray['nbfield']++; } + // Event Organization + if (!empty($arrayfields['p.usage_organize_event']['checked'])) + { + print ''; + if ($obj->usage_event_organization) + { + print yn($obj->usage_event_organization); + } + print ''; + if (!$i) $totalarray['nbfield']++; + } // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; // Fields from hook diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index c4d355ab62c..f855a80ef7f 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -984,6 +984,7 @@ class Societe extends CommonObject $contact->email = $this->email; $contact->zip = $this->zip; $contact->town = $this->town; + $this->setUpperOrLowerCase(); $contact->phone_pro = $this->phone; $contactId = $contact->create($user); diff --git a/htdocs/user/class/user.class.php b/htdocs/user/class/user.class.php index 8f8f8c67ca8..8712bcc4615 100644 --- a/htdocs/user/class/user.class.php +++ b/htdocs/user/class/user.class.php @@ -1402,6 +1402,7 @@ class User extends CommonObject $this->address = $contact->address; $this->zip = $contact->zip; $this->town = $contact->town; + $this->setUpperOrLowerCase(); $this->state_id = $contact->state_id; $this->country_id = $contact->country_id; $this->employee = 0; @@ -1474,12 +1475,13 @@ class User extends CommonObject $this->civility_code = $member->civility_id; $this->lastname = $member->lastname; $this->firstname = $member->firstname; - $this->gender = $member->gender; + $this->gender = $member->gender; $this->email = $member->email; $this->fk_member = $member->id; $this->address = $member->address; $this->zip = $member->zip; $this->town = $member->town; + $this->setUpperOrLowerCase(); $this->state_id = $member->state_id; $this->country_id = $member->country_id; $this->socialnetworks = $member->socialnetworks; @@ -1637,6 +1639,7 @@ class User extends CommonObject $this->address = empty($this->address) ? '' : $this->address; $this->zip = empty($this->zip) ? '' : $this->zip; $this->town = empty($this->town) ? '' : $this->town; + $this->setUpperOrLowerCase(); $this->accountancy_code = trim($this->accountancy_code); $this->color = empty($this->color) ? '' : $this->color; $this->dateemployment = empty($this->dateemployment) ? '' : $this->dateemployment;