From 3295498e9e49b3f67d6bf5453ebc93ab335e76ff Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 16 Sep 2017 12:50:34 +0200 Subject: [PATCH 001/132] Remove code comment --- htdocs/product/index.php | 1 - 1 file changed, 1 deletion(-) diff --git a/htdocs/product/index.php b/htdocs/product/index.php index cd1c9a4883b..3568cd4a492 100644 --- a/htdocs/product/index.php +++ b/htdocs/product/index.php @@ -367,7 +367,6 @@ function activitytrim($product_type) $result = $db->query($sql); if ($result) { - //$tmpyear=$beginyear; // FIXME $beginyear is not defined $tmpyear=0; $trim1=0; $trim2=0; From e61bcd03ed86879044e4631e15242602d7501128 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 16 Sep 2017 13:03:27 +0200 Subject: [PATCH 002/132] Fix travis --- .travis.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 7cb9db632ad..8ae2e95f0c8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -126,10 +126,10 @@ before_script: echo "Set timezone" echo 'date.timezone = "Europe/Paris"' >> ~/.phpenv/versions/$PHP_VERSION_NAME/etc/php.ini if [ "$TRAVIS_PHP_VERSION" = '5.3' ] || [ "$TRAVIS_PHP_VERSION" = '5.4' ]; then - echo - echo "Enabling APC for PHP <= 5.4" + #echo + #echo "Enabling APC for PHP <= 5.4" # Documentation says it should be available for PHP <= 5.6 but it's not for 5.5 and 5.6! - echo 'extension = apc.so' >> ~/.phpenv/versions/$PHP_VERSION_NAME/etc/php.ini + #echo 'extension = apc.so' >> ~/.phpenv/versions/$PHP_VERSION_NAME/etc/php.ini echo echo "Enabling Memcached for PHP <= 5.4" # Documentation says it should be available for all PHP versions but it's not for 5.5 and 5.6, 7.0 and nightly! From 1b054f1b363ba0a627065a4e4467acf06165ef04 Mon Sep 17 00:00:00 2001 From: Maxime Kohlhaas Date: Sat, 27 Oct 2018 09:19:02 +0200 Subject: [PATCH 003/132] Fix invoice creation from contract was invoicing closed services #9087 --- htdocs/compta/facture/card.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index 993194e0f91..daff7c95f56 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -1196,6 +1196,8 @@ if (empty($reshook)) { // Don't add lines with qty 0 when coming from a shipment including all order lines if($srcobject->element == 'shipping' && $conf->global->SHIPMENT_GETS_ALL_ORDER_PRODUCTS && $lines[$i]->qty == 0) continue; + // Don't add closed lines when coming from a contract + if($srcobject->element == 'contrat' && $lines[$i]->statut == 5) continue; $label=(! empty($lines[$i]->label)?$lines[$i]->label:''); $desc=(! empty($lines[$i]->desc)?$lines[$i]->desc:$lines[$i]->libelle); From abb343d37e043840bcfd5d295b71331ab821599f Mon Sep 17 00:00:00 2001 From: Maxime Kohlhaas Date: Sat, 27 Oct 2018 09:42:08 +0200 Subject: [PATCH 004/132] Fix missing name alias field in societe import/export #9091 --- htdocs/core/modules/modSociete.class.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/core/modules/modSociete.class.php b/htdocs/core/modules/modSociete.class.php index 0498e37bdfc..2aef12c6a1d 100644 --- a/htdocs/core/modules/modSociete.class.php +++ b/htdocs/core/modules/modSociete.class.php @@ -258,7 +258,7 @@ class modSociete extends DolibarrModules $this->export_label[$r]='ExportDataset_company_1'; $this->export_icon[$r]='company'; $this->export_permission[$r]=array(array("societe","export")); - $this->export_fields_array[$r]=array('s.rowid'=>"Id",'s.nom'=>"Name",'s.status'=>"Status",'s.client'=>"Customer",'s.fournisseur'=>"Supplier",'s.datec'=>"DateCreation",'s.tms'=>"DateLastModification",'s.code_client'=>"CustomerCode",'s.code_fournisseur'=>"SupplierCode",'s.code_compta'=>"AccountancyCode",'s.code_compta_fournisseur'=>"SupplierAccountancyCode",'s.address'=>"Address",'s.zip'=>"Zip",'s.town'=>"Town",'d.nom'=>'State','c.label'=>"Country",'c.code'=>"CountryCode",'s.phone'=>"Phone",'s.fax'=>"Fax",'s.url'=>"Url",'s.email'=>"Email",'s.default_lang'=>"DefaultLang",'s.siren'=>"ProfId1",'s.siret'=>"ProfId2",'s.ape'=>"ProfId3",'s.idprof4'=>"ProfId4",'s.idprof5'=>"ProfId5",'s.idprof6'=>"ProfId6",'s.tva_intra'=>"VATIntraShort",'s.capital'=>"Capital",'s.note_private'=>"NotePrivate",'s.note_public'=>"NotePublic",'t.libelle'=>"ThirdPartyType",'ce.code'=>"Staff","cfj.libelle"=>"JuridicalStatus",'s.fk_prospectlevel'=>'ProspectLevel','st.code'=>'ProspectStatus','payterm.libelle'=>'PaymentConditions','paymode.libelle'=>'PaymentMode'); + $this->export_fields_array[$r]=array('s.rowid'=>"Id",'s.nom'=>"Name",'s.name_alias'=>"AliasNames",'s.status'=>"Status",'s.client'=>"Customer",'s.fournisseur'=>"Supplier",'s.datec'=>"DateCreation",'s.tms'=>"DateLastModification",'s.code_client'=>"CustomerCode",'s.code_fournisseur'=>"SupplierCode",'s.code_compta'=>"AccountancyCode",'s.code_compta_fournisseur'=>"SupplierAccountancyCode",'s.address'=>"Address",'s.zip'=>"Zip",'s.town'=>"Town",'d.nom'=>'State','c.label'=>"Country",'c.code'=>"CountryCode",'s.phone'=>"Phone",'s.fax'=>"Fax",'s.url'=>"Url",'s.email'=>"Email",'s.default_lang'=>"DefaultLang",'s.siren'=>"ProfId1",'s.siret'=>"ProfId2",'s.ape'=>"ProfId3",'s.idprof4'=>"ProfId4",'s.idprof5'=>"ProfId5",'s.idprof6'=>"ProfId6",'s.tva_intra'=>"VATIntraShort",'s.capital'=>"Capital",'s.note_private'=>"NotePrivate",'s.note_public'=>"NotePublic",'t.libelle'=>"ThirdPartyType",'ce.code'=>"Staff","cfj.libelle"=>"JuridicalStatus",'s.fk_prospectlevel'=>'ProspectLevel','st.code'=>'ProspectStatus','payterm.libelle'=>'PaymentConditions','paymode.libelle'=>'PaymentMode'); if (! empty($conf->global->SOCIETE_USEPREFIX)) $this->export_fields_array[$r]['s.prefix']='Prefix'; // Add multicompany field if (! empty($conf->global->MULTICOMPANY_ENTITY_IN_EXPORT_IF_SHARED)) @@ -270,7 +270,7 @@ class modSociete extends DolibarrModules include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php'; $this->export_fields_array[$r]+=array('u.login'=>'SaleRepresentativeLogin','u.firstname'=>'SaleRepresentativeFirstname', 'u.lastname'=>'SaleRepresentativeLastname'); //$this->export_TypeFields_array[$r]=array('s.rowid'=>"List:societe:nom",'s.nom'=>"Text",'s.status'=>"Text",'s.client'=>"Boolean",'s.fournisseur'=>"Boolean",'s.datec'=>"Date",'s.tms'=>"Date",'s.code_client'=>"Text",'s.code_fournisseur'=>"Text",'s.address'=>"Text",'s.zip'=>"Text",'s.town'=>"Text",'c.label'=>"List:c_country:label:label",'c.code'=>"Text",'s.phone'=>"Text",'s.fax'=>"Text",'s.url'=>"Text",'s.email'=>"Text",'s.default_lang'=>"Text",'s.siret'=>"Text",'s.siren'=>"Text",'s.ape'=>"Text",'s.idprof4'=>"Text",'s.idprof5'=>"Text",'s.idprof6'=>"Text",'s.tva_intra'=>"Text",'s.capital'=>"Numeric",'s.note'=>"Text",'t.libelle'=>"Text",'ce.code'=>"List:c_effectif:libelle:code","cfj.libelle"=>"Text",'s.fk_prospectlevel'=>'List:c_prospectlevel:label:code','s.fk_stcomm'=>'List:c_stcomm:libelle:code','d.nom'=>'List:c_departements:nom:rowid'); - $this->export_TypeFields_array[$r]=array('s.rowid'=>"Numeric", 's.nom'=>"Text",'s.status'=>"Numeric",'s.client'=>"Numeric",'s.fournisseur'=>"Boolean",'s.datec'=>"Date",'s.tms'=>"Date",'s.code_client'=>"Text",'s.code_fournisseur'=>"Text",'s.code_compta'=>"Text",'s.code_compta_fournisseur'=>"Text",'s.address'=>"Text",'s.zip'=>"Text",'s.town'=>"Text",'c.label'=>"List:c_country:label:label",'c.code'=>"Text",'s.phone'=>"Text",'s.fax'=>"Text",'s.url'=>"Text",'s.email'=>"Text",'s.default_lang'=>"Text",'s.siret'=>"Text",'s.siren'=>"Text",'s.ape'=>"Text",'s.idprof4'=>"Text",'s.idprof5'=>"Text",'s.idprof6'=>"Text",'s.tva_intra'=>"Text",'s.capital'=>"Numeric",'s.note_private'=>"Text",'s.note_public'=>"Text",'t.libelle'=>"Text",'ce.code'=>"List:c_effectif:libelle:code","cfj.libelle"=>"Text",'s.fk_prospectlevel'=>'List:c_prospectlevel:label:code','st.code'=>'List:c_stcomm:libelle:code','d.nom'=>'Text','u.login'=>'Text','u.firstname'=>'Text','u.lastname'=>'Text','payterm.libelle'=>'Text','paymode.libelle'=>'Text','s.entity'=>'Numeric'); + $this->export_TypeFields_array[$r]=array('s.rowid'=>"Numeric", 's.nom'=>"Text",'s.name_alias'=>"Text",'s.status'=>"Numeric",'s.client'=>"Numeric",'s.fournisseur'=>"Boolean",'s.datec'=>"Date",'s.tms'=>"Date",'s.code_client'=>"Text",'s.code_fournisseur'=>"Text",'s.code_compta'=>"Text",'s.code_compta_fournisseur'=>"Text",'s.address'=>"Text",'s.zip'=>"Text",'s.town'=>"Text",'c.label'=>"List:c_country:label:label",'c.code'=>"Text",'s.phone'=>"Text",'s.fax'=>"Text",'s.url'=>"Text",'s.email'=>"Text",'s.default_lang'=>"Text",'s.siret'=>"Text",'s.siren'=>"Text",'s.ape'=>"Text",'s.idprof4'=>"Text",'s.idprof5'=>"Text",'s.idprof6'=>"Text",'s.tva_intra'=>"Text",'s.capital'=>"Numeric",'s.note_private'=>"Text",'s.note_public'=>"Text",'t.libelle'=>"Text",'ce.code'=>"List:c_effectif:libelle:code","cfj.libelle"=>"Text",'s.fk_prospectlevel'=>'List:c_prospectlevel:label:code','st.code'=>'List:c_stcomm:libelle:code','d.nom'=>'Text','u.login'=>'Text','u.firstname'=>'Text','u.lastname'=>'Text','payterm.libelle'=>'Text','paymode.libelle'=>'Text','s.entity'=>'Numeric'); $this->export_entities_array[$r]=array('u.login'=>'user','u.firstname'=>'user','u.lastname'=>'user'); // We define here only fields that use another picto $this->export_examplevalues_array[$r]=array('s.client'=>'0 (no customer no prospect)/1 (customer)/2 (prospect)/3 (customer and prospect)','s.fournisseur'=>'0 (not a supplier) or 1 (supplier)'); @@ -345,7 +345,7 @@ class modSociete extends DolibarrModules $this->import_icon[$r]='company'; $this->import_entities_array[$r]=array(); // We define here only fields that use another icon that the one defined into import_icon $this->import_tables_array[$r]=array('s'=>MAIN_DB_PREFIX.'societe','extra'=>MAIN_DB_PREFIX.'societe_extrafields'); // List of tables to insert into (insert done in same order) - $this->import_fields_array[$r]=array('s.nom'=>"Name*",'s.status'=>"Status",'s.client'=>"Customer*",'s.fournisseur'=>"Supplier*",'s.code_client'=>"CustomerCode",'s.code_fournisseur'=>"SupplierCode",'s.code_compta'=>"CustomerAccountancyCode",'s.code_compta_fournisseur'=>"SupplierAccountancyCode",'s.address'=>"Address",'s.zip'=>"Zip",'s.town'=>"Town",'s.fk_departement'=>"StateId",'s.fk_pays'=>"CountryCode",'s.phone'=>"Phone",'s.fax'=>"Fax",'s.url'=>"Url",'s.email'=>"Email",'s.siren'=>"ProfId1",'s.siret'=>"ProfId2",'s.ape'=>"ProfId3",'s.idprof4'=>"ProfId4",'s.idprof5'=>"ProfId5",'s.idprof6'=>"ProfId6",'s.tva_intra'=>"VATIntraShort",'s.capital'=>"Capital",'s.note_private'=>"NotePrivate",'s.note_public'=>"NotePublic",'s.fk_typent'=>"ThirdPartyType",'s.fk_effectif'=>"Staff","s.fk_forme_juridique"=>"JuridicalStatus",'s.fk_prospectlevel'=>'ProspectLevel','s.fk_stcomm'=>'ProspectStatus','s.default_lang'=>'DefaultLanguage','s.barcode'=>'BarCode','s.datec'=>"DateCreation"); + $this->import_fields_array[$r]=array('s.nom'=>"Name*",'s.name_alias'=>"Alias",'s.status'=>"Status",'s.client'=>"Customer*",'s.fournisseur'=>"Supplier*",'s.code_client'=>"CustomerCode",'s.code_fournisseur'=>"SupplierCode",'s.code_compta'=>"CustomerAccountancyCode",'s.code_compta_fournisseur'=>"SupplierAccountancyCode",'s.address'=>"Address",'s.zip'=>"Zip",'s.town'=>"Town",'s.fk_departement'=>"StateId",'s.fk_pays'=>"CountryCode",'s.phone'=>"Phone",'s.fax'=>"Fax",'s.url'=>"Url",'s.email'=>"Email",'s.siren'=>"ProfId1",'s.siret'=>"ProfId2",'s.ape'=>"ProfId3",'s.idprof4'=>"ProfId4",'s.idprof5'=>"ProfId5",'s.idprof6'=>"ProfId6",'s.tva_intra'=>"VATIntraShort",'s.capital'=>"Capital",'s.note_private'=>"NotePrivate",'s.note_public'=>"NotePublic",'s.fk_typent'=>"ThirdPartyType",'s.fk_effectif'=>"Staff","s.fk_forme_juridique"=>"JuridicalStatus",'s.fk_prospectlevel'=>'ProspectLevel','s.fk_stcomm'=>'ProspectStatus','s.default_lang'=>'DefaultLanguage','s.barcode'=>'BarCode','s.datec'=>"DateCreation"); // Add extra fields $sql="SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'societe' AND entity = ".$conf->entity; $resql=$this->db->query($sql); @@ -373,7 +373,7 @@ class modSociete extends DolibarrModules ); //$this->import_convertvalue_array[$r]=array('s.fk_soc'=>array('rule'=>'lastrowid',table='t'); $this->import_regex_array[$r]=array('s.status'=>'^[0|1]','s.client'=>'^[0|1|2|3]','s.fournisseur'=>'^[0|1]','s.fk_typent'=>'id@'.MAIN_DB_PREFIX.'c_typent','s.datec'=>'^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]( [0-9][0-9]:[0-9][0-9]:[0-9][0-9])?$'); - $this->import_examplevalues_array[$r]=array('s.nom'=>"MyBigCompany",'s.status'=>"0 (closed) or 1 (active)",'s.client'=>'0 (no customer no prospect)/1 (customer)/2 (prospect)/3 (customer and prospect)','s.fournisseur'=>'0 or 1','s.datec'=>dol_print_date(dol_now(),'%Y-%m-%d'),'s.code_client'=>'CU01-0001 or empty or "auto"','s.code_fournisseur'=>'SU01-0001 or empty or "auto"','s.address'=>"61 jump street",'s.zip'=>"123456",'s.town'=>"Big town",'s.fk_pays'=>'US, FR, DE...','s.phone'=>"0101010101",'s.fax'=>"0101010102",'s.url'=>"http://mycompany.com",'s.email'=>"test@mycompany.com",'s.siret'=>"",'s.siren'=>"",'s.ape'=>"",'s.idprof4'=>"",'s.idprof5'=>"",'s.idprof6'=>"",'s.tva_intra'=>"FR0123456789",'s.capital'=>"10000",'s.note_private'=>"This is an example of private note for record",'s.note_public'=>"This is an example of public note for record",'s.fk_typent'=>"2",'s.fk_effectif'=>"3","s.fk_forme_juridique"=>"1",'s.fk_prospectlevel'=>'PL_MEDIUM','s.fk_stcomm'=>'0','s.default_lang'=>'en_US','s.barcode'=>'123456789','s.datec'=>"2015-01-01 or 2015-01-01 12:30:00"); + $this->import_examplevalues_array[$r]=array('s.nom'=>"MyBigCompany",'s.name_alias'=>"MyBigAlias",'s.status'=>"0 (closed) or 1 (active)",'s.client'=>'0 (no customer no prospect)/1 (customer)/2 (prospect)/3 (customer and prospect)','s.fournisseur'=>'0 or 1','s.datec'=>dol_print_date(dol_now(),'%Y-%m-%d'),'s.code_client'=>'CU01-0001 or empty or "auto"','s.code_fournisseur'=>'SU01-0001 or empty or "auto"','s.address'=>"61 jump street",'s.zip'=>"123456",'s.town'=>"Big town",'s.fk_pays'=>'US, FR, DE...','s.phone'=>"0101010101",'s.fax'=>"0101010102",'s.url'=>"http://mycompany.com",'s.email'=>"test@mycompany.com",'s.siret'=>"",'s.siren'=>"",'s.ape'=>"",'s.idprof4'=>"",'s.idprof5'=>"",'s.idprof6'=>"",'s.tva_intra'=>"FR0123456789",'s.capital'=>"10000",'s.note_private'=>"This is an example of private note for record",'s.note_public'=>"This is an example of public note for record",'s.fk_typent'=>"2",'s.fk_effectif'=>"3","s.fk_forme_juridique"=>"1",'s.fk_prospectlevel'=>'PL_MEDIUM','s.fk_stcomm'=>'0','s.default_lang'=>'en_US','s.barcode'=>'123456789','s.datec'=>"2015-01-01 or 2015-01-01 12:30:00"); $this->import_updatekeys_array[$r]=array('s.nom'=>'Name','s.code_client'=>'CustomerCode','s.code_fournisseur'=>'SupplierCode','s.code_compta'=>'CustomerAccountancyCode','s.code_compta_fournisseur'=>'SupplierAccountancyCode'); // Import list of contact and attributes From 8911d72be84bd64c16cf5f8fa31329185d0a2b7d Mon Sep 17 00:00:00 2001 From: Marc de Lima Lucio Date: Tue, 30 Oct 2018 12:28:04 +0100 Subject: [PATCH 005/132] FIX: task time screen: prevent users with access to all project from assigning to tasks they're not allowed to do --- htdocs/core/class/html.formprojet.class.php | 37 ++++++++++++--------- htdocs/projet/activity/perday.php | 2 +- htdocs/projet/activity/perweek.php | 2 +- 3 files changed, 24 insertions(+), 17 deletions(-) diff --git a/htdocs/core/class/html.formprojet.class.php b/htdocs/core/class/html.formprojet.class.php index 616355eab28..c2d8377add5 100644 --- a/htdocs/core/class/html.formprojet.class.php +++ b/htdocs/core/class/html.formprojet.class.php @@ -295,22 +295,29 @@ class FormProjets /** * Output a combo list with projects qualified for a third party * - * @param int $socid Id third party (-1=all, 0=only projects not linked to a third party, id=projects not linked or linked to third party id) - * @param int $selected Id task preselected - * @param string $htmlname Name of HTML select - * @param int $maxlength Maximum length of label - * @param int $option_only Return only html options lines without the select tag - * @param string $show_empty Add an empty line ('1' or string to show for empty line) - * @param int $discard_closed Discard closed projects (0=Keep,1=hide completely,2=Disable) - * @param int $forcefocus Force focus on field (works with javascript only) - * @param int $disabled Disabled - * @param string $morecss More css added to the select component - * @return int Nbr of project if OK, <0 if KO + * @param int $socid Id third party (-1=all, 0=only projects not linked to a third party, id=projects not linked or linked to third party id) + * @param int $selected Id task preselected + * @param string $htmlname Name of HTML select + * @param int $maxlength Maximum length of label + * @param int $option_only Return only html options lines without the select tag + * @param string $show_empty Add an empty line ('1' or string to show for empty line) + * @param int $discard_closed Discard closed projects (0=Keep,1=hide completely,2=Disable) + * @param int $forcefocus Force focus on field (works with javascript only) + * @param int $disabled Disabled + * @param string $morecss More css added to the select component + * @param User $usertofilter User object to use for filtering + * @param int $forceuserfilter 1=Force individual task user rights even if user has right to see all + * @return int Nbr of project if OK, <0 if KO */ - function selectTasks($socid=-1, $selected='', $htmlname='taskid', $maxlength=24, $option_only=0, $show_empty='1', $discard_closed=0, $forcefocus=0, $disabled=0, $morecss='maxwidth500') + function selectTasks($socid=-1, $selected='', $htmlname='taskid', $maxlength=24, $option_only=0, $show_empty='1', $discard_closed=0, $forcefocus=0, $disabled=0, $morecss='maxwidth500', $usertofilter=null, $forceuserfilter=0) { global $user,$conf,$langs; + if(is_null($usertofilter)) + { + $usertofilter = $user; + } + require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; $out=''; @@ -319,10 +326,10 @@ class FormProjets if (! empty($conf->global->PROJECT_HIDE_UNSELECTABLES)) $hideunselectables = true; $projectsListId = false; - if (empty($user->rights->projet->all->lire)) + if (empty($usertofilter->rights->projet->all->lire) || $forceuserfilter) { $projectstatic=new Project($this->db); - $projectsListId = $projectstatic->getProjectsAuthorizedForUser($user,0,1); + $projectsListId = $projectstatic->getProjectsAuthorizedForUser($usertofilter,0,1); } // Search all projects @@ -367,7 +374,7 @@ class FormProjets { $obj = $this->db->fetch_object($resql); // If we ask to filter on a company and user has no permission to see all companies and project is linked to another company, we hide project. - if ($socid > 0 && (empty($obj->fk_soc) || $obj->fk_soc == $socid) && empty($user->rights->societe->lire)) + if ($socid > 0 && (empty($obj->fk_soc) || $obj->fk_soc == $socid) && empty($usertofilter->rights->societe->lire)) { // Do nothing } diff --git a/htdocs/projet/activity/perday.php b/htdocs/projet/activity/perday.php index b4329ac9237..b1214f0bff7 100644 --- a/htdocs/projet/activity/perday.php +++ b/htdocs/projet/activity/perday.php @@ -399,7 +399,7 @@ print '
'; $titleassigntask = $langs->trans("AssignTaskToMe"); if ($usertoprocess->id != $user->id) $titleassigntask = $langs->trans("AssignTaskToUser", $usertoprocess->getFullName($langs)); print '
'; -$formproject->selectTasks($socid?$socid:-1, $taskid, 'taskid', 32, 0, 1, 1); +$formproject->selectTasks($socid?$socid:-1, $taskid, 'taskid', 32, 0, 1, 1, 0, 0, '', $usertoprocess, 1); print '
'; print ' '; print $formcompany->selectTypeContact($object, '', 'type','internal','rowid', 0, 'maxwidth200'); diff --git a/htdocs/projet/activity/perweek.php b/htdocs/projet/activity/perweek.php index 591f8b3ab6f..d18afc573e1 100644 --- a/htdocs/projet/activity/perweek.php +++ b/htdocs/projet/activity/perweek.php @@ -402,7 +402,7 @@ print '
'; $titleassigntask = $langs->trans("AssignTaskToMe"); if ($usertoprocess->id != $user->id) $titleassigntask = $langs->trans("AssignTaskToUser", $usertoprocess->getFullName($langs)); print '
'; -$formproject->selectTasks($socid?$socid:-1, $taskid, 'taskid', 32, 0, 1, 1); +$formproject->selectTasks($socid?$socid:-1, $taskid, 'taskid', 32, 0, 1, 1, 0, 0, '', $usertoprocess, 1); print '
'; print ' '; print $formcompany->selectTypeContact($object, '', 'type','internal','rowid', 0, 'maxwidth200'); From 2fbc305683c9cacba509e4fb0a67cac4f7c98fd5 Mon Sep 17 00:00:00 2001 From: Marc de Lima Lucio Date: Tue, 30 Oct 2018 16:00:56 +0100 Subject: [PATCH 006/132] FIX: task time screen: last fix was overkill --- htdocs/core/class/html.formprojet.class.php | 5 ++--- htdocs/projet/activity/perday.php | 2 +- htdocs/projet/activity/perweek.php | 2 +- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/htdocs/core/class/html.formprojet.class.php b/htdocs/core/class/html.formprojet.class.php index c2d8377add5..cb31107c65c 100644 --- a/htdocs/core/class/html.formprojet.class.php +++ b/htdocs/core/class/html.formprojet.class.php @@ -306,10 +306,9 @@ class FormProjets * @param int $disabled Disabled * @param string $morecss More css added to the select component * @param User $usertofilter User object to use for filtering - * @param int $forceuserfilter 1=Force individual task user rights even if user has right to see all * @return int Nbr of project if OK, <0 if KO */ - function selectTasks($socid=-1, $selected='', $htmlname='taskid', $maxlength=24, $option_only=0, $show_empty='1', $discard_closed=0, $forcefocus=0, $disabled=0, $morecss='maxwidth500', $usertofilter=null, $forceuserfilter=0) + function selectTasks($socid=-1, $selected='', $htmlname='taskid', $maxlength=24, $option_only=0, $show_empty='1', $discard_closed=0, $forcefocus=0, $disabled=0, $morecss='maxwidth500', $usertofilter=null) { global $user,$conf,$langs; @@ -326,7 +325,7 @@ class FormProjets if (! empty($conf->global->PROJECT_HIDE_UNSELECTABLES)) $hideunselectables = true; $projectsListId = false; - if (empty($usertofilter->rights->projet->all->lire) || $forceuserfilter) + if (empty($usertofilter->rights->projet->all->lire)) { $projectstatic=new Project($this->db); $projectsListId = $projectstatic->getProjectsAuthorizedForUser($usertofilter,0,1); diff --git a/htdocs/projet/activity/perday.php b/htdocs/projet/activity/perday.php index b1214f0bff7..b27572790dd 100644 --- a/htdocs/projet/activity/perday.php +++ b/htdocs/projet/activity/perday.php @@ -399,7 +399,7 @@ print '
'; $titleassigntask = $langs->trans("AssignTaskToMe"); if ($usertoprocess->id != $user->id) $titleassigntask = $langs->trans("AssignTaskToUser", $usertoprocess->getFullName($langs)); print '
'; -$formproject->selectTasks($socid?$socid:-1, $taskid, 'taskid', 32, 0, 1, 1, 0, 0, '', $usertoprocess, 1); +$formproject->selectTasks($socid?$socid:-1, $taskid, 'taskid', 32, 0, 1, 1, 0, 0, '', $usertoprocess); print '
'; print ' '; print $formcompany->selectTypeContact($object, '', 'type','internal','rowid', 0, 'maxwidth200'); diff --git a/htdocs/projet/activity/perweek.php b/htdocs/projet/activity/perweek.php index d18afc573e1..3d2e638849e 100644 --- a/htdocs/projet/activity/perweek.php +++ b/htdocs/projet/activity/perweek.php @@ -402,7 +402,7 @@ print '
'; $titleassigntask = $langs->trans("AssignTaskToMe"); if ($usertoprocess->id != $user->id) $titleassigntask = $langs->trans("AssignTaskToUser", $usertoprocess->getFullName($langs)); print '
'; -$formproject->selectTasks($socid?$socid:-1, $taskid, 'taskid', 32, 0, 1, 1, 0, 0, '', $usertoprocess, 1); +$formproject->selectTasks($socid?$socid:-1, $taskid, 'taskid', 32, 0, 1, 1, 0, 0, '', $usertoprocess); print '
'; print ' '; print $formcompany->selectTypeContact($object, '', 'type','internal','rowid', 0, 'maxwidth200'); From 395e9ceae2708662f3b14c23589d55fd4a248095 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Tue, 30 Oct 2018 20:36:12 +0100 Subject: [PATCH 007/132] fix stats display expensereport --- htdocs/expensereport/stats/index.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/expensereport/stats/index.php b/htdocs/expensereport/stats/index.php index e53757be1db..c192fb83447 100644 --- a/htdocs/expensereport/stats/index.php +++ b/htdocs/expensereport/stats/index.php @@ -2,6 +2,7 @@ /* Copyright (C) 2003-2006 Rodolphe Quiedeville * Copyright (c) 2004-2012 Laurent Destailleur * Copyright (C) 2012 Marcos García + * Copyright (C) 2018 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 @@ -282,7 +283,7 @@ foreach ($data as $val) } print ''; -print '
'; +print '
'; print '
'; From 46fd3bcaf87843dd576ea11b35dac93eb00491ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Tue, 30 Oct 2018 21:15:52 +0100 Subject: [PATCH 008/132] fix display holiday month report if none --- htdocs/holiday/month_report.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/holiday/month_report.php b/htdocs/holiday/month_report.php index 6a4da422ea3..a19a193bc73 100644 --- a/htdocs/holiday/month_report.php +++ b/htdocs/holiday/month_report.php @@ -1,6 +1,7 @@ * Copyright (C) 2011 François Legastelois + * Copyright (C) 2018 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 @@ -120,7 +121,7 @@ print ''; if ($num == 0) { - print ''.$langs->trans('None').''; + print ''.$langs->trans('None').''; } else { From 3d16b05fdb647a84d83dd060b3f7cf74c528a28b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 30 Oct 2018 21:30:44 +0100 Subject: [PATCH 009/132] Fix fetch --- htdocs/fichinter/card-rec.php | 6 +++--- htdocs/langs/es_ES/cron.lang | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/fichinter/card-rec.php b/htdocs/fichinter/card-rec.php index 0113f7fbea6..4b8aa9bb43d 100644 --- a/htdocs/fichinter/card-rec.php +++ b/htdocs/fichinter/card-rec.php @@ -866,7 +866,7 @@ if ($action == 'create') { print "\n"; -// les filtres à faire ensuite + // les filtres à faire ensuite if ($num > 0) { while ($i < min($num, $limit)) { @@ -893,8 +893,8 @@ if ($action == 'create') { } if (! empty($conf->projet->enabled)) { print ''; - if ($objp->fk_project >0) { - $projectstatic->fecth($objp->fk_projet); + if ($objp->fk_project > 0) { + $projectstatic->fetch($objp->fk_projet); print $projectstatic->getNomUrl(1); } print ''; diff --git a/htdocs/langs/es_ES/cron.lang b/htdocs/langs/es_ES/cron.lang index da8ac9c00aa..50497ad0b98 100644 --- a/htdocs/langs/es_ES/cron.lang +++ b/htdocs/langs/es_ES/cron.lang @@ -64,7 +64,7 @@ CronClassFile=Nombre de archivo con clase CronModuleHelp=Nombre del directorio del módulo Dolibarr (también funciona con módulos externos).
Por ejemplo, para realizar un fetch del objeto Product /htdocs/product/class/product.class.php, el valor del módulo es product CronClassFileHelp=El nombre del archivo a cargar (la ruta es relativa al directorio raiz del servidor web).
Por ejemplo para realizar un fetch del objeto Product /htdocs/product/class/product.class.php, el valor del nombre del archivo de la clase es product.class.php CronObjectHelp=El nombre del objeto a cargar.
Por ejemplo para realizar un fetch del objeto Product /htdocs/product/class/product.class.php, el valor del nombre de la clase es Product -CronMethodHelp=El método del objeto a lanzar.
Por ejemplo para realizar un fetch del objeto Product /htdocs/product/class/product.class.php, el valor del método es fecth +CronMethodHelp=El método del objeto a lanzar.
Por ejemplo para realizar un fetch del objeto Product /htdocs/product/class/product.class.php, el valor del método es fetch CronArgsHelp=Los argumentos del método.
Por ejemplo para realizar un fetch del objeto Product /htdocs/product/class/product.class.php, los valores pueden ser 0, ProductRef CronCommandHelp=El comando en línea del sistema a ejecutar. CronCreateJob=Crear nueva tarea programada From c764d7f8d56827e09ade0ab28944707023dd1e14 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 30 Oct 2018 21:34:17 +0100 Subject: [PATCH 010/132] Fix remove var_dump --- htdocs/core/lib/admin.lib.php | 1 - 1 file changed, 1 deletion(-) diff --git a/htdocs/core/lib/admin.lib.php b/htdocs/core/lib/admin.lib.php index 34ca8e48079..f5efa5c5b7e 100644 --- a/htdocs/core/lib/admin.lib.php +++ b/htdocs/core/lib/admin.lib.php @@ -944,7 +944,6 @@ function activateModule($value,$withdeps=1) $activate = false; foreach ($modulesdir as $dir) { - var_dump($modulestring); if (file_exists($dir.$modulestring.".class.php")) { $resarray = activateModule($modulestring); From 866729cd21a56086a2aa353eb063c4136986d1f7 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 30 Oct 2018 22:32:42 +0100 Subject: [PATCH 011/132] FIX bad link in notification --- htdocs/core/class/notify.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/class/notify.class.php b/htdocs/core/class/notify.class.php index c226fb647d0..ae22728f06d 100644 --- a/htdocs/core/class/notify.class.php +++ b/htdocs/core/class/notify.class.php @@ -575,13 +575,13 @@ class Notify $mesg = $langs->transnoentitiesnoconv("EMailTextOrderValidated",$link); break; case 'PROPAL_VALIDATE': - $link='/comm/propal/card.php?id='.$object->id; + $link = '' . $newref . ''; $dir_output = $conf->propal->multidir_output[$object->entity]; $object_type = 'propal'; $mesg = $langs->transnoentitiesnoconv("EMailTextProposalValidated",$link); break; case 'PROPAL_CLOSE_SIGNED': - $link='/comm/propal/card.php?id='.$object->id; + $link = '' . $newref . ''; $dir_output = $conf->propal->multidir_output[$object->entity]; $object_type = 'propal'; $mesg = $langs->transnoentitiesnoconv("EMailTextProposalClosedSigned",$link); From c9ef298839bc57c06222cd736fde4df80cd46209 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 31 Oct 2018 11:38:04 +0100 Subject: [PATCH 012/132] Fix setup template emails --- htdocs/install/mysql/data/llx_c_email_templates.sql | 10 +++++----- htdocs/install/mysql/migration/7.0.0-8.0.0.sql | 10 +++++----- htdocs/langs/fr_FR/members.lang | 4 ++-- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/htdocs/install/mysql/data/llx_c_email_templates.sql b/htdocs/install/mysql/data/llx_c_email_templates.sql index b913fca13f3..3d1a1e7c178 100644 --- a/htdocs/install/mysql/data/llx_c_email_templates.sql +++ b/htdocs/install/mysql/data/llx_c_email_templates.sql @@ -23,10 +23,10 @@ INSERT INTO llx_c_email_templates (entity,module,type_template,lang,private,fk_user,datec,label,position,enabled,active,topic,content,content_lines) VALUES (0,'banque','thirdparty','',0,null,null,'(YourSEPAMandate)',1,1,0,'__(YourSEPAMandate)__','__(Hello)__,

\n\n__(FindYourSEPAMandate)__ :
\n__MYCOMPANY_NAME__
\n__MYCOMPANY_FULLADDRESS__

\n__(Sincerely)__
\n__USER_SIGNATURE__',null); -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,'adherent','member','',0,null,null,'(SendingEmailOnAutoSubscription)' ,10,1,1,'[__[MAIN_INFO_SOCIETE_NOM]__] __(YourMembershipRequestWasReceived)__','__(Hello)__ __MEMBER_FULLNAME__,

\n\n__(ThisIsContentOfYourMembershipRequestWasReceived)__
\n
__ONLINE_PAYMENT_TEXT_AND_URL__
\n

\n__(Sincerely)__
__USER_SIGNATURE__',null, 1); -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,'adherent','member','',0,null,null,'(SendingEmailOnMemberValidation)' ,20,1,1,'[__[MAIN_INFO_SOCIETE_NOM]__] __(YourMembershipWasValidated)__', '__(Hello)__ __MEMBER_FULLNAME__,

\n\n__(ThisIsContentOfYourMembershipWasValidated)__
__INFOS__
\n
__ONLINE_PAYMENT_TEXT_AND_URL__
\n

\n__(Sincerely)__
__USER_SIGNATURE__',null, 1); +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,'adherent','member','',0,null,null,'(SendingEmailOnAutoSubscription)' ,10,1,1,'[__[MAIN_INFO_SOCIETE_NOM]__] __(YourMembershipRequestWasReceived)__','__(Hello)__ __MEMBER_FULLNAME__,

\n\n__(ThisIsContentOfYourMembershipRequestWasReceived)__
\n
__ONLINE_PAYMENT_TEXT_AND_URL__
\n

\n__(Sincerely)__
__USER_SIGNATURE__',null, 0); +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,'adherent','member','',0,null,null,'(SendingEmailOnMemberValidation)' ,20,1,1,'[__[MAIN_INFO_SOCIETE_NOM]__] __(YourMembershipWasValidated)__', '__(Hello)__ __MEMBER_FULLNAME__,

\n\n__(ThisIsContentOfYourMembershipWasValidated)__
__INFOS__
\n
__ONLINE_PAYMENT_TEXT_AND_URL__
\n

\n__(Sincerely)__
__USER_SIGNATURE__',null, 0); 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,'adherent','member','',0,null,null,'(SendingEmailOnNewSubscription)' ,30,1,1,'[__[MAIN_INFO_SOCIETE_NOM]__] __(YourSubscriptionWasRecorded)__', '__(Hello)__ __MEMBER_FULLNAME__,

\n\n__(ThisIsContentOfYourSubscriptionWasRecorded)__
\n\n

\n__(Sincerely)__
__USER_SIGNATURE__',null, 1); -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,'adherent','member','',0,null,null,'(SendingReminderForExpiredSubscription)',40,1,1,'[__[MAIN_INFO_SOCIETE_NOM]__] __(SubscriptionReminderEmail)__', '__(Hello)__ __MEMBER_FULLNAME__,

\n\n__(ThisIsContentOfSubscriptionReminderEmail)__
\n
__ONLINE_PAYMENT_TEXT_AND_URL__
\n

\n__(Sincerely)__
__USER_SIGNATURE__',null, 1); -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,'adherent','member','',0,null,null,'(SendingEmailOnCancelation)' ,50,1,1,'[__[MAIN_INFO_SOCIETE_NOM]__] __(YourMembershipWasCanceled)__', '__(Hello)__ __MEMBER_FULLNAME__,

\n\n__(YourMembershipWasCanceled)__
\n

\n__(Sincerely)__
__USER_SIGNATURE__',null, 1); -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,'adherent','member','',0,null,null,'(SendingAnEMailToMember)' ,60,1,1,'[__[MAIN_INFO_SOCIETE_NOM]__] __(CardContent)__', '__(Hello)__,

\n\n__(ThisIsContentOfYourCard)__
\n__(ID)__ : __ID__
\n__(Civiliyty)__ : __MEMBER_CIVILITY__
\n__(Firstname)__ : __MEMBER_FIRSTNAME__
\n__(Lastname)__ : __MEMBER_LASTNAME__
\n__(Fullname)__ : __MEMBER_FULLNAME__
\n__(Company)__ : __MEMBER_COMPANY__
\n__(Address)__ : __MEMBER_ADDRESS__
\n__(Zip)__ : __MEMBER_ZIP__
\n__(Town)__ : __MEMBER_TOWN__
\n__(Country)__ : __MEMBER_COUNTRY__
\n__(Email)__ : __MEMBER_EMAIL__
\n__(Birthday)__ : __MEMBER_BIRTH__
\n__(Photo)__ : __MEMBER_PHOTO__
\n__(Login)__ : __MEMBER_LOGIN__
\n__(Password)__ : __MEMBER_PASSWORD__
\n__(Phone)__ : __MEMBER_PHONE__
\n__(PhonePerso)__ : __MEMBER_PHONEPRO__
\n__(PhoneMobile)__ : __MEMBER_PHONEMOBILE__

\n__(Sincerely)__
__USER_SIGNATURE__',null, 1); +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,'adherent','member','',0,null,null,'(SendingReminderForExpiredSubscription)',40,1,1,'[__[MAIN_INFO_SOCIETE_NOM]__] __(SubscriptionReminderEmail)__', '__(Hello)__ __MEMBER_FULLNAME__,

\n\n__(ThisIsContentOfSubscriptionReminderEmail)__
\n
__ONLINE_PAYMENT_TEXT_AND_URL__
\n

\n__(Sincerely)__
__USER_SIGNATURE__',null, 0); +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,'adherent','member','',0,null,null,'(SendingEmailOnCancelation)' ,50,1,1,'[__[MAIN_INFO_SOCIETE_NOM]__] __(YourMembershipWasCanceled)__', '__(Hello)__ __MEMBER_FULLNAME__,

\n\n__(YourMembershipWasCanceled)__
\n

\n__(Sincerely)__
__USER_SIGNATURE__',null, 0); +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,'adherent','member','',0,null,null,'(SendingAnEMailToMember)' ,60,1,1,'[__[MAIN_INFO_SOCIETE_NOM]__] __(CardContent)__', '__(Hello)__,

\n\n__(ThisIsContentOfYourCard)__
\n__(ID)__ : __ID__
\n__(Civiliyty)__ : __MEMBER_CIVILITY__
\n__(Firstname)__ : __MEMBER_FIRSTNAME__
\n__(Lastname)__ : __MEMBER_LASTNAME__
\n__(Fullname)__ : __MEMBER_FULLNAME__
\n__(Company)__ : __MEMBER_COMPANY__
\n__(Address)__ : __MEMBER_ADDRESS__
\n__(Zip)__ : __MEMBER_ZIP__
\n__(Town)__ : __MEMBER_TOWN__
\n__(Country)__ : __MEMBER_COUNTRY__
\n__(Email)__ : __MEMBER_EMAIL__
\n__(Birthday)__ : __MEMBER_BIRTH__
\n__(Photo)__ : __MEMBER_PHOTO__
\n__(Login)__ : __MEMBER_LOGIN__
\n__(Password)__ : __MEMBER_PASSWORD__
\n__(Phone)__ : __MEMBER_PHONE__
\n__(PhonePerso)__ : __MEMBER_PHONEPRO__
\n__(PhoneMobile)__ : __MEMBER_PHONEMOBILE__

\n__(Sincerely)__
__USER_SIGNATURE__',null, 0); diff --git a/htdocs/install/mysql/migration/7.0.0-8.0.0.sql b/htdocs/install/mysql/migration/7.0.0-8.0.0.sql index f29830f29e0..1a7cfd58410 100644 --- a/htdocs/install/mysql/migration/7.0.0-8.0.0.sql +++ b/htdocs/install/mysql/migration/7.0.0-8.0.0.sql @@ -419,12 +419,12 @@ ALTER TABLE llx_societe_rib MODIFY COLUMN max_total_amount_of_all_payments doubl ALTER TABLE llx_societe_rib MODIFY COLUMN total_amount_of_all_payments double(24,8); -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,'adherent','member','',0,null,null,'(SendingEmailOnAutoSubscription)' ,10,1,1,'[__[MAIN_INFO_SOCIETE_NOM]__] __(YourMembershipRequestWasReceived)__','__(Hello)__ __MEMBER_FULLNAME__,

\n\n__(ThisIsContentOfYourMembershipRequestWasReceived)__
\n
__ONLINE_PAYMENT_TEXT_AND_URL__
\n

\n__(Sincerely)__
__USER_SIGNATURE__',null, 1); -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,'adherent','member','',0,null,null,'(SendingEmailOnMemberValidation)' ,20,1,1,'[__[MAIN_INFO_SOCIETE_NOM]__] __(YourMembershipWasValidated)__', '__(Hello)__ __MEMBER_FULLNAME__,

\n\n__(ThisIsContentOfYourMembershipWasValidated)__
\n
__ONLINE_PAYMENT_TEXT_AND_URL__
\n

\n__(Sincerely)__
__USER_SIGNATURE__',null, 1); +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,'adherent','member','',0,null,null,'(SendingEmailOnAutoSubscription)' ,10,1,1,'[__[MAIN_INFO_SOCIETE_NOM]__] __(YourMembershipRequestWasReceived)__','__(Hello)__ __MEMBER_FULLNAME__,

\n\n__(ThisIsContentOfYourMembershipRequestWasReceived)__
\n
__ONLINE_PAYMENT_TEXT_AND_URL__
\n

\n__(Sincerely)__
__USER_SIGNATURE__',null, 0); +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,'adherent','member','',0,null,null,'(SendingEmailOnMemberValidation)' ,20,1,1,'[__[MAIN_INFO_SOCIETE_NOM]__] __(YourMembershipWasValidated)__', '__(Hello)__ __MEMBER_FULLNAME__,

\n\n__(ThisIsContentOfYourMembershipWasValidated)__
\n
__ONLINE_PAYMENT_TEXT_AND_URL__
\n

\n__(Sincerely)__
__USER_SIGNATURE__',null, 0); 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,'adherent','member','',0,null,null,'(SendingEmailOnNewSubscription)' ,30,1,1,'[__[MAIN_INFO_SOCIETE_NOM]__] __(YourSubscriptionWasRecorded)__', '__(Hello)__ __MEMBER_FULLNAME__,

\n\n__(ThisIsContentOfYourSubscriptionWasRecorded)__
\n\n

\n__(Sincerely)__
__USER_SIGNATURE__',null, 1); -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,'adherent','member','',0,null,null,'(SendingReminderForExpiredSubscription)',40,1,1,'[__[MAIN_INFO_SOCIETE_NOM]__] __(SubscriptionReminderEmail)__', '__(Hello)__ __MEMBER_FULLNAME__,

\n\n__(ThisIsContentOfSubscriptionReminderEmail)__
\n
__ONLINE_PAYMENT_TEXT_AND_URL__
\n

\n__(Sincerely)__
__USER_SIGNATURE__',null, 1); -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,'adherent','member','',0,null,null,'(SendingEmailOnCancelation)' ,50,1,1,'[__[MAIN_INFO_SOCIETE_NOM]__] __(YourMembershipWasCanceled)__', '__(Hello)__ __MEMBER_FULLNAME__,

\n\n__(YourMembershipWasCanceled)__
\n

\n__(Sincerely)__
__USER_SIGNATURE__',null, 1); -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,'adherent','member','',0,null,null,'(SendingAnEMailToMember)' ,60,1,1,'[__[MAIN_INFO_SOCIETE_NOM]__] __(CardContent)__', '__(Hello)__,

\n\n__(ThisIsContentOfYourCard)__
\n__(ID)__ : __ID__
\n__(Civiliyty)__ : __MEMBER_CIVILITY__
\n__(Firstname)__ : __MEMBER_FIRSTNAME__
\n__(Lastname)__ : __MEMBER_LASTNAME__
\n__(Fullname)__ : __MEMBER_FULLNAME__
\n__(Company)__ : __MEMBER_COMPANY__
\n__(Address)__ : __MEMBER_ADDRESS__
\n__(Zip)__ : __MEMBER_ZIP__
\n__(Town)__ : __MEMBER_TOWN__
\n__(Country)__ : __MEMBER_COUNTRY__
\n__(Email)__ : __MEMBER_EMAIL__
\n__(Birthday)__ : __MEMBER_BIRTH__
\n__(Photo)__ : __MEMBER_PHOTO__
\n__(Login)__ : __MEMBER_LOGIN__
\n__(Password)__ : __MEMBER_PASSWORD__
\n__(Phone)__ : __MEMBER_PHONE__
\n__(PhonePerso)__ : __MEMBER_PHONEPRO__
\n__(PhoneMobile)__ : __MEMBER_PHONEMOBILE__

\n__(Sincerely)__
__USER_SIGNATURE__',null, 1); +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,'adherent','member','',0,null,null,'(SendingReminderForExpiredSubscription)',40,1,1,'[__[MAIN_INFO_SOCIETE_NOM]__] __(SubscriptionReminderEmail)__', '__(Hello)__ __MEMBER_FULLNAME__,

\n\n__(ThisIsContentOfSubscriptionReminderEmail)__
\n
__ONLINE_PAYMENT_TEXT_AND_URL__
\n

\n__(Sincerely)__
__USER_SIGNATURE__',null, 0); +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,'adherent','member','',0,null,null,'(SendingEmailOnCancelation)' ,50,1,1,'[__[MAIN_INFO_SOCIETE_NOM]__] __(YourMembershipWasCanceled)__', '__(Hello)__ __MEMBER_FULLNAME__,

\n\n__(YourMembershipWasCanceled)__
\n

\n__(Sincerely)__
__USER_SIGNATURE__',null, 0); +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,'adherent','member','',0,null,null,'(SendingAnEMailToMember)' ,60,1,1,'[__[MAIN_INFO_SOCIETE_NOM]__] __(CardContent)__', '__(Hello)__,

\n\n__(ThisIsContentOfYourCard)__
\n__(ID)__ : __ID__
\n__(Civiliyty)__ : __MEMBER_CIVILITY__
\n__(Firstname)__ : __MEMBER_FIRSTNAME__
\n__(Lastname)__ : __MEMBER_LASTNAME__
\n__(Fullname)__ : __MEMBER_FULLNAME__
\n__(Company)__ : __MEMBER_COMPANY__
\n__(Address)__ : __MEMBER_ADDRESS__
\n__(Zip)__ : __MEMBER_ZIP__
\n__(Town)__ : __MEMBER_TOWN__
\n__(Country)__ : __MEMBER_COUNTRY__
\n__(Email)__ : __MEMBER_EMAIL__
\n__(Birthday)__ : __MEMBER_BIRTH__
\n__(Photo)__ : __MEMBER_PHOTO__
\n__(Login)__ : __MEMBER_LOGIN__
\n__(Password)__ : __MEMBER_PASSWORD__
\n__(Phone)__ : __MEMBER_PHONE__
\n__(PhonePerso)__ : __MEMBER_PHONEPRO__
\n__(PhoneMobile)__ : __MEMBER_PHONEMOBILE__

\n__(Sincerely)__
__USER_SIGNATURE__',null, 0); ALTER TABLE llx_product ADD COLUMN fk_default_warehouse integer DEFAULT NULL; ALTER TABLE llx_product ADD CONSTRAINT fk_product_default_warehouse FOREIGN KEY (fk_default_warehouse) REFERENCES llx_entrepot (rowid); diff --git a/htdocs/langs/fr_FR/members.lang b/htdocs/langs/fr_FR/members.lang index 6cd379c3cc2..a27cd5c5747 100644 --- a/htdocs/langs/fr_FR/members.lang +++ b/htdocs/langs/fr_FR/members.lang @@ -111,7 +111,7 @@ SendingAnEMailToMember=Envoi d'informations par e-mail à un adhérent SendingEmailOnAutoSubscription=Envoi d'email lors de l'auto-inscription SendingEmailOnMemberValidation=Envoie d'email à la validation d'un nouvel adhérent SendingEmailOnNewSubscription=Envoyer un email sur un nouvel abonnement -SendingReminderForExpiredSubscription=Envoi d'un rappel pour les abonnements expirés +SendingReminderForExpiredSubscription=Envoi d'un rappel pour les adhésions expirées SendingEmailOnCancelation=Envoie d'email à l'annulation # Topic of email templates YourMembershipRequestWasReceived=Votre demande d'adhésion a été reçue. @@ -124,7 +124,7 @@ CardContent=Contenu de votre fiche adhérent ThisIsContentOfYourMembershipRequestWasReceived=Nous vous informons que votre demande d'adhésion a bien été reçue.

ThisIsContentOfYourMembershipWasValidated=Nous vous informons que votre adhésion a été validé avec les informations suivantes:

ThisIsContentOfYourSubscriptionWasRecorded=Nous vous informons que votre nouvelle cotisation a été enregistrée.

-ThisIsContentOfSubscriptionReminderEmail=Nous voulons vous informer que votre abonnement est sur le point d'expirer. Nous espérons que vous pourrez le renouveler.

+ThisIsContentOfSubscriptionReminderEmail=Nous voulons vous informer que votre adhésion est sur le point d'expirer. Nous espérons que vous pourrez la renouveler, votre soutien nous ait précieux

ThisIsContentOfYourCard=Ceci est un rappel des informations que nous avons vos concernant. N'hésitez pas à nous contacter en cas d'erreur.

DescADHERENT_AUTOREGISTER_NOTIF_MAIL_SUBJECT=Sujet de l'email reçu en cas d'auto-inscription d'un invité DescADHERENT_AUTOREGISTER_NOTIF_MAIL=Email reçu en cas d'auto-inscription d'un invité From 19134e82cbcd6c01f1230bbccb6b1ce3e488b6d7 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 31 Oct 2018 12:23:53 +0100 Subject: [PATCH 013/132] Prepare 8.0.3 --- ChangeLog | 81 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 81 insertions(+) diff --git a/ChangeLog b/ChangeLog index a31b7e0ddfd..c0e3e277009 100644 --- a/ChangeLog +++ b/ChangeLog @@ -3,6 +3,87 @@ English Dolibarr ChangeLog -------------------------------------------------------------- +***** ChangeLog for 8.0.3 compared to 8.0.2 ***** +FIX: #9161 +FIX: #9432 +FIX: #9432 Assign yourself as a commercial when you don't have permission to see all thirds +FIX: #9510 +FIX: #9567 +FIX: According to french law, if seller is in France and buyer isn't in UE and isn't a company, TVA used = TVA product +FIX: Amount when using mutlicurrency on PDF +FIX: Backup of database without mysqladmin available from cron. +FIX: Bad label on delete button +FIX: bad link in notification +FIX: Bad position of hook formattachOptions call +FIX: Can't create shipping if have shipping line's extrafields +FIX: check !empty exclude select element +FIX: content lost when editing a label with " +FIX: correct migration of old postgresql unique key +FIX: credit note progression +FIX: default accounting accounts on loan creation #9643 +FIX: Delete of draft invoice +FIX: deletion on draft is allowed if we are allwoed to create +FIX: Do not show check box if not applicable +FIX: exclude element of the select +FIX: extrafields of taks not visible in creation +FIX: filter on employee +FIX: invoice stats: situation invoices were not counted +FIX: keep external module element when adding resource +FIX: langs fr +FIX: Link template invoice to contract +FIX: Look and feel v8. Missing button "Create category" +FIX: Menu to show/edit Users categories was missing +FIX: missing name alias field in societe import/export #9091 +FIX: missing symbol for indian rupies +FIX: Missing transaction around action +FIX: modify parenting before task deletion +FIX: nb of session in title +FIX: need to filter on current entity on replenish +FIX: number mailing for a contact with multicompany +FIX: Option for prof id mandatory not working with custom type of company +FIX: Option MAIN_DISABLE_NOTES_TAB #9611 +FIX: Pagination stats +FIX: pdf typhon: order reference duplicate +FIX: position 0 for emails templates +FIX: previous situation invoice selection +FIX: Product marge tabs on product card +FIX: Product margin tab and credit note +FIX: propal pdf: missing parenthesis for customs code +FIX: properties on proposal must not be modified if error +FIX: qty not visible for a lot when making shipment on a dedicated stock +FIX: Quick hack to solve pb of bad definition of public holidays +FIX: remain to pay for credit note was wrong on invoice list +FIX: replenish wasn't caring about supplier price min quantity #9561 +FIX: Required extrafield value numeric should accept '0' +FIX: ressource list with extrafields +FIX: restore last seach criteria +FIX: Selection of addmaindocfile is lost on error +FIX: Sending of reminder for expired subscriptions +FIX: shared link ko on proposals +FIX: showOptionals: column mismatches +FIX: situation invoice total with credit note +FIX: situation invoice prev percent +FIX: special code on create supplier invoice from supplier order +FIX: Symbol of currency in substitution variables +FIX: The max size for upload file was not corectly shown +FIX: the member e-mail on resign and validation. +FIX: thirdparty property of object not loaded when only one record +FIX: title +FIX: Title problem on admin RSS module +FIX: Tooltip on invoice widget +FIX: Total of timespent +FIX: trackid into email sent from member module. +FIX: translation in select unit form +FIX: use discount with multicurrency +FIX: Variable name +FIX: When we delete a product, llx_product_association rows are not deleted +FIX: when we're just admin and not super admin, if we create new user with transverse mode, we don't see it then we can't add him in usergroup +FIX: wrong function name +FIX: wrong occurence number of contract on contact card, we must only count externals +FIX: wrong value for module part and return access denied +FIX: Wrong variable name +FIX: XSS vulnerability reported by Mary Princy E + ***** ChangeLog for 8.0.2 compared to 8.0.1 ***** FIX: #8452 FIX: #9043 From 6c4a2728ca038822c2464ae93cde10608043dc09 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 31 Oct 2018 12:33:08 +0100 Subject: [PATCH 014/132] Fix build --- build/makepack-dolibarr.pl | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/build/makepack-dolibarr.pl b/build/makepack-dolibarr.pl index 1ab3269d0de..7ba988231cc 100755 --- a/build/makepack-dolibarr.pl +++ b/build/makepack-dolibarr.pl @@ -523,10 +523,17 @@ if ($nboftargetok) { $ret=`rm -f $BUILDROOT/$PROJECT/doc/images/dolibarr_screenshot12.png`; # Security to avoid to package data files + print "Remove documents dir\n"; $ret=`rm -fr $BUILDROOT/$PROJECT/document`; $ret=`rm -fr $BUILDROOT/$PROJECT/documents`; $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/document`; $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/documents`; + + print "Remove subdir of custom dir\n"; + print "find $BUILDROOT/$PROJECT/htdocs/custom/* -type d -exec rm -fr {} \\;\n"; + $ret=`find $BUILDROOT/$PROJECT/htdocs/custom/* -type d -exec rm -fr {} \\; >/dev/null 2>&1`; # For custom we want to remove all subdirs but not files + print "find $BUILDROOT/$PROJECT/htdocs/custom/* -type l -exec rm -fr {} \\;\n"; + $ret=`find $BUILDROOT/$PROJECT/htdocs/custom/* -type l -exec rm -fr {} \\; >/dev/null 2>&1`; # For custom we want to remove all subdirs, even symbolic links, but not files # Removed known external modules to avoid any error when packaging from env where external modules are tested $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/allscreens*`; @@ -592,13 +599,6 @@ if ($nboftargetok) { $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/tecnickcom/tcpdf/tools`; $ret=`rm -f $BUILDROOT/$PROJECT/htdocs/includes/tecnickcom/tcpdf/LICENSE.TXT`; $ret=`rm -f $BUILDROOT/$PROJECT/htdocs/theme/common/octicons/LICENSE`; - - - print "Remove subdir of custom dir\n"; - print "find $BUILDROOT/$PROJECT/htdocs/custom/* -type d -exec rm -fr {} \\;\n"; - $ret=`find $BUILDROOT/$PROJECT/htdocs/custom/* -type d -exec rm -fr {} \\; >/dev/null 2>&1`; # For custom we want to remove all subdirs but not files - print "find $BUILDROOT/$PROJECT/htdocs/custom/* -type l -exec rm -fr {} \\;\n"; - $ret=`find $BUILDROOT/$PROJECT/htdocs/custom/* -type l -exec rm -fr {} \\; >/dev/null 2>&1`; # For custom we want to remove all subdirs, even symbolic links, but not files } # Build package for each target From 0ca5da055fec89381aa3aaf3ba115b64d4f20ad2 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 31 Oct 2018 15:04:01 +0100 Subject: [PATCH 015/132] Debug v9 --- htdocs/core/modules/modDataPolicy.class.php | 18 ++----- htdocs/datapolicy/ChangeLog.md | 24 --------- htdocs/datapolicy/class/datapolicy.class.php | 2 +- htdocs/emailcollector/modulebuilder.txt | 3 ++ htdocs/modulebuilder/index.php | 51 ++++++++++++++------ 5 files changed, 43 insertions(+), 55 deletions(-) delete mode 100644 htdocs/datapolicy/ChangeLog.md create mode 100644 htdocs/emailcollector/modulebuilder.txt diff --git a/htdocs/core/modules/modDataPolicy.class.php b/htdocs/core/modules/modDataPolicy.class.php index ca53440a3b9..b6f4c4e0139 100644 --- a/htdocs/core/modules/modDataPolicy.class.php +++ b/htdocs/core/modules/modDataPolicy.class.php @@ -173,22 +173,10 @@ class modDataPolicy extends DolibarrModules { // 'stock' to add a tab in stock view // 'thirdparty' to add a tab in third party view // 'user' to add a tab in user view + + // Dictionaries $this->dictionaries = array(); - /* Example: - $this->dictionaries=array( - 'langs'=>'mylangfile@datapolicy', - 'tabname'=>array(MAIN_DB_PREFIX."table1",MAIN_DB_PREFIX."table2",MAIN_DB_PREFIX."table3"), // List of tables we want to see into dictonnary editor - 'tablib'=>array("Table1","Table2","Table3"), // Label of tables - 'tabsql'=>array('SELECT f.rowid as rowid, f.code, f.label, f.active FROM '.MAIN_DB_PREFIX.'table1 as f','SELECT f.rowid as rowid, f.code, f.label, f.active FROM '.MAIN_DB_PREFIX.'table2 as f','SELECT f.rowid as rowid, f.code, f.label, f.active FROM '.MAIN_DB_PREFIX.'table3 as f'), // Request to select fields - 'tabsqlsort'=>array("label ASC","label ASC","label ASC"), // Sort order - 'tabfield'=>array("code,label","code,label","code,label"), // List of fields (result of select to show dictionary) - 'tabfieldvalue'=>array("code,label","code,label","code,label"), // List of fields (list of fields to edit a record) - 'tabfieldinsert'=>array("code,label","code,label","code,label"), // List of fields (list of fields for insert) - 'tabrowid'=>array("rowid","rowid","rowid"), // Name of columns with primary key (try to always name it 'rowid') - 'tabcond'=>array($conf->datapolicy->enabled,$conf->datapolicy->enabled,$conf->datapolicy->enabled) // Condition to show each dictionary - ); - */ // Boxes/Widgets @@ -199,7 +187,7 @@ class modDataPolicy extends DolibarrModules { // Cronjobs (List of cron jobs entries to add when module is enabled) // unit_frequency must be 60 for minute, 3600 for hour, 86400 for day, 604800 for week $this->cronjobs = array( - 0 => array('label' => 'DATAPOLICY Cron', 'jobtype' => 'method', 'class' => '/datapolicy/class/datapolicyCron.class.php', 'objectname' => 'RgpdCron', 'method' => 'exec', 'parameters' => '', 'comment' => 'Comment', 'frequency' => 1, 'unitfrequency' => 86400, 'status' => 1, 'test' => true), + 0 => array('label' => 'DATAPOLICY Cron', 'jobtype' => 'method', 'class' => '/datapolicy/class/datapolicyCron.class.php', 'objectname' => 'DataPolicyCron', 'method' => 'exec', 'parameters' => '', 'comment' => 'Clean data', 'frequency' => 1, 'unitfrequency' => 86400, 'status' => 1, 'test' => true), //1 => array('label' => 'DATAPOLICY Mailing', 'jobtype' => 'method', 'class' => '/datapolicy/class/datapolicyCron.class.php', 'objectname' => 'RgpdCron', 'method' => 'sendMailing', 'parameters' => '', 'comment' => 'Comment', 'frequency' => 1, 'unitfrequency' => 86400, 'status' => 0, 'test' => true) ); // Example: $this->cronjobs=array(0=>array('label'=>'My label', 'jobtype'=>'method', 'class'=>'/dir/class/file.class.php', 'objectname'=>'MyClass', 'method'=>'myMethod', 'parameters'=>'param1, param2', 'comment'=>'Comment', 'frequency'=>2, 'unitfrequency'=>3600, 'status'=>0, 'test'=>true), diff --git a/htdocs/datapolicy/ChangeLog.md b/htdocs/datapolicy/ChangeLog.md deleted file mode 100644 index 1c149a77e39..00000000000 --- a/htdocs/datapolicy/ChangeLog.md +++ /dev/null @@ -1,24 +0,0 @@ -**2.2** -* Fix link to accept or refuse - -**2.1** -* Change IT translations - -**2.0** -* Add date of agreement -* Add possibility to send e-mail -* Save the agreement by e-mail - -**1.2** -* Bug fixed - -**1.1** -* Add some translations -* Add some type of company -* Bug fixed - - -**1.0** -* The end of the beginning - - diff --git a/htdocs/datapolicy/class/datapolicy.class.php b/htdocs/datapolicy/class/datapolicy.class.php index 4914d248490..35b618cbaca 100644 --- a/htdocs/datapolicy/class/datapolicy.class.php +++ b/htdocs/datapolicy/class/datapolicy.class.php @@ -28,7 +28,7 @@ include_once DOL_DOCUMENT_ROOT . '/adherents/class/adherent.class.php'; /** * Class DataPolicy */ -Class DataPolicy extends Contact +Class DataPolicy { /** * getAllContactNotInformed diff --git a/htdocs/emailcollector/modulebuilder.txt b/htdocs/emailcollector/modulebuilder.txt new file mode 100644 index 00000000000..24ea0d6eac5 --- /dev/null +++ b/htdocs/emailcollector/modulebuilder.txt @@ -0,0 +1,3 @@ +# DO NOT DELETE THIS FILE MANUALLY +# File to flag module built using official module template. +# When this file is present into a module directory, you can edit it with the module builder tool. Use ModuleBuilder if you want to delete module. \ No newline at end of file diff --git a/htdocs/modulebuilder/index.php b/htdocs/modulebuilder/index.php index b533c369cbd..f9c123d8db0 100644 --- a/htdocs/modulebuilder/index.php +++ b/htdocs/modulebuilder/index.php @@ -71,6 +71,11 @@ if (! empty($tmpdir[1])) $dirread=$tmpdir[1]; $forceddirread=1; } +if (GETPOST('dirins','alpha')) +{ + $dirread = $dirins = GETPOST('dirins','alpha'); + $forceddirread=1; +} $FILEFLAG='modulebuilder.txt'; @@ -911,17 +916,31 @@ $dirsincustom=dol_dir_list($dirread, 'directories'); if (is_array($dirsincustom) && count($dirsincustom) > 0) { foreach ($dirsincustom as $dircustomcursor) { $fullname = $dircustomcursor['fullname']; - if (dol_is_file($fullname . '/' . $FILEFLAG)) { + if (dol_is_file($fullname . '/' . $FILEFLAG)) + { // Get real name of module (MyModule instead of mymodule) - $descriptorfiles = dol_dir_list($fullname . '/core/modules/', 'files', 0, 'mod.*\.class\.php$'); + $dirtoscanrel = basename($fullname).'/core/modules/'; + + $descriptorfiles = dol_dir_list(dirname($fullname).'/'.$dirtoscanrel, 'files', 0, 'mod.*\.class\.php$'); + if (empty($descriptorfiles)) // If descriptor not found into module dir, we look into main module dir. + { + $dirtoscanrel = 'core/modules/'; + $descriptorfiles = dol_dir_list($fullname.'/../'.$dirtoscanrel, 'files', 0, 'mod'.strtoupper(basename($fullname)).'\.class\.php$'); + } $modulenamewithcase = ''; + $moduledescriptorrelpath = ''; + $moduledescriptorfullpath = ''; + foreach ($descriptorfiles as $descriptorcursor) { $modulenamewithcase = preg_replace('/^mod/', '', $descriptorcursor['name']); $modulenamewithcase = preg_replace('/\.class\.php$/', '', $modulenamewithcase); + $moduledescriptorrelpath = $dirtoscanrel.$descriptorcursor['name']; + $moduledescriptorfullpath = $descriptorcursor['fullname']; + //var_dump($descriptorcursor); } if ($modulenamewithcase) { - $listofmodules[$dircustomcursor['name']] = $modulenamewithcase; + $listofmodules[$dircustomcursor['name']] = array('modulenamewithcase'=>$modulenamewithcase, 'moduledescriptorrelpath'=> $moduledescriptorrelpath, 'moduledescriptorfullpath'=>$moduledescriptorfullpath); } //var_dump($listofmodules); } @@ -929,7 +948,7 @@ if (is_array($dirsincustom) && count($dirsincustom) > 0) { } if ($forceddirread && empty($listofmodules)) { - $listofmodules[strtolower($module)] = $module; + $listofmodules[strtolower($module)] = array('modulenamewithcase'=>$module, 'moduledescriptorrelpath'=> 'notyetimplemented', 'moduledescriptorfullpath'=> 'notyetimplemented'); } // Show description of content @@ -983,7 +1002,8 @@ if (! empty($module) && $module != 'initmodule' && $module != 'deletemodule') $modulelowercase=strtolower($module); // Load module - dol_include_once($modulelowercase.'/core/modules/mod'.$module.'.class.php'); + $fullpathdirtodescriptor = $listofmodules[strtolower($module)]['moduledescriptorrelpath']; + dol_include_once($fullpathdirtodescriptor); $class='mod'.$module; if (class_exists($class)) @@ -1017,11 +1037,11 @@ $head[$h][1] = $langs->trans("NewModule"); $head[$h][2] = 'initmodule'; $h++; -foreach($listofmodules as $tmpmodule => $tmpmodulewithcase) +foreach($listofmodules as $tmpmodule => $tmpmodulearray) { - $head[$h][0] = $_SERVER["PHP_SELF"].'?module='.$tmpmodulewithcase.($forceddirread?'@'.$dirread:''); - $head[$h][1] = $tmpmodulewithcase; - $head[$h][2] = $tmpmodulewithcase; + $head[$h][0] = $_SERVER["PHP_SELF"].'?module='.$tmpmodulearray['modulenamewithcase'].($forceddirread?'@'.$dirread:''); + $head[$h][1] = $tmpmodulearray['modulenamewithcase']; + $head[$h][2] = $tmpmodulearray['modulenamewithcase']; $h++; } @@ -1167,7 +1187,7 @@ elseif (! empty($module)) if ($tab == 'description') { - $pathtofile = $modulelowercase.'/core/modules/mod'.$module.'.class.php'; + $pathtofile = $listofmodules[strtolower($module)]['moduledescriptorrelpath']; $pathtofilereadme = $modulelowercase.'/README.md'; $pathtochangelog = $modulelowercase.'/ChangeLog.md'; @@ -1877,7 +1897,7 @@ elseif (! empty($module)) if ($tab == 'menus') { - $pathtofile = $modulelowercase.'/core/modules/mod'.$module.'.class.php'; + $pathtofile = $listofmodules[strtolower($module)]['moduledescriptorrelpath']; //$menus = $moduleobj->; @@ -2002,7 +2022,7 @@ elseif (! empty($module)) if ($tab == 'permissions') { - $pathtofile = $modulelowercase.'/core/modules/mod'.$module.'.class.php'; + $pathtofile = $listofmodules[strtolower($module)]['moduledescriptorrelpath']; //$perms = $moduleobj->; @@ -2132,7 +2152,7 @@ elseif (! empty($module)) print $langs->trans("HooksDefDesc").'
'; print '
'; - $pathtofile = $modulelowercase.'/core/modules/mod'.$module.'.class.php'; + $pathtofile = $listofmodules[strtolower($module)]['moduledescriptorrelpath']; print ' '.$langs->trans("DescriptorFile").' : '.$pathtofile.''; print ' '.img_picto($langs->trans("Edit"), 'edit').''; print '
'; @@ -2277,7 +2297,7 @@ elseif (! empty($module)) if ($tab == 'cron') { - $pathtofile = $modulelowercase.'/core/modules/mod'.$module.'.class.php'; + $pathtofile = $listofmodules[strtolower($module)]['moduledescriptorrelpath']; $cronjobs = $moduleobj->cronjobs; @@ -2411,7 +2431,8 @@ elseif (! empty($module)) $FILENAMEZIP=''; // Load module - dol_include_once($modulelowercase.'/core/modules/mod'.$module.'.class.php'); + $pathtofile = $listofmodules[strtolower($module)]['moduledescriptorrelpath']; + dol_include_once($pathtofile); $class='mod'.$module; if (class_exists($class)) From ca726e6c94fa0abc06375d7d79095ceeabcd494a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 31 Oct 2018 15:31:22 +0100 Subject: [PATCH 016/132] FIX Error generating ODT when option to use contact on doc on --- .../doc/doc_generic_order_odt.modules.php | 7 +-- .../doc/doc_generic_contract_odt.modules.php | 4 +- .../doc/doc_generic_invoice_odt.modules.php | 7 +-- .../doc/doc_generic_product_odt.modules.php | 11 ++-- .../doc/doc_generic_project_odt.modules.php | 61 +++++++++---------- .../doc/doc_generic_proposal_odt.modules.php | 7 +-- .../user/doc/doc_generic_user_odt.modules.php | 9 ++- .../doc/doc_generic_usergroup_odt.modules.php | 7 +-- 8 files changed, 53 insertions(+), 60 deletions(-) diff --git a/htdocs/core/modules/commande/doc/doc_generic_order_odt.modules.php b/htdocs/core/modules/commande/doc/doc_generic_order_odt.modules.php index 0fb5dbabc03..586d24541ef 100644 --- a/htdocs/core/modules/commande/doc/doc_generic_order_odt.modules.php +++ b/htdocs/core/modules/commande/doc/doc_generic_order_odt.modules.php @@ -360,10 +360,9 @@ class doc_generic_order_odt extends ModelePDFCommandes $array_thirdparty=$this->get_substitutionarray_thirdparty($socobject,$outputlangs); $array_objet=$this->get_substitutionarray_object($object,$outputlangs); $array_other=$this->get_substitutionarray_other($outputlangs); - // retrieve contact information for use in order as contact_xxx tags - $array_thirdparty_contact = array(); - if ($usecontact) - $array_thirdparty_contact=$this->get_substitutionarray_contact($contactobject,$outputlangs,'contact'); + // retrieve contact information for use in object as contact_xxx tags + $array_thirdparty_contact = array(); + if ($usecontact && is_object($contactobject)) $array_thirdparty_contact=$this->get_substitutionarray_contact($contactobject,$outputlangs,'contact'); $tmparray = array_merge($array_user,$array_soc,$array_thirdparty,$array_objet,$array_other,$array_thirdparty_contact); complete_substitutions_array($tmparray, $outputlangs, $object); diff --git a/htdocs/core/modules/contract/doc/doc_generic_contract_odt.modules.php b/htdocs/core/modules/contract/doc/doc_generic_contract_odt.modules.php index 7e308964e29..6931ea52cc6 100644 --- a/htdocs/core/modules/contract/doc/doc_generic_contract_odt.modules.php +++ b/htdocs/core/modules/contract/doc/doc_generic_contract_odt.modules.php @@ -309,9 +309,9 @@ class doc_generic_contract_odt extends ModelePDFContract $array_thirdparty=$this->get_substitutionarray_thirdparty($socobject,$outputlangs); $array_objet=$this->get_substitutionarray_object($object,$outputlangs); $array_other=$this->get_substitutionarray_other($outputlangs); - // retrieve contact information for use in contract as contact_xxx tags + // retrieve contact information for use in order as contact_xxx tags $array_thirdparty_contact = array(); - if ($usecontact) $array_thirdparty_contact=$this->get_substitutionarray_contact($contactobject,$outputlangs,'contact'); + if ($usecontact && is_object($contactobject)) $array_thirdparty_contact=$this->get_substitutionarray_contact($contactobject,$outputlangs,'contact'); $substitutionarray = array_merge($substitutionarray,$array_contract,$array_user,$array_soc,$array_thirdparty,$array_objet,$array_other,$array_thirdparty_contact); complete_substitutions_array($substitutionarray, $outputlangs, $object); diff --git a/htdocs/core/modules/facture/doc/doc_generic_invoice_odt.modules.php b/htdocs/core/modules/facture/doc/doc_generic_invoice_odt.modules.php index c9f18218d9a..5f712bba012 100644 --- a/htdocs/core/modules/facture/doc/doc_generic_invoice_odt.modules.php +++ b/htdocs/core/modules/facture/doc/doc_generic_invoice_odt.modules.php @@ -368,10 +368,9 @@ class doc_generic_invoice_odt extends ModelePDFFactures $array_objet=$this->get_substitutionarray_object($object,$outputlangs); $array_propal=is_object($propal_object)?$this->get_substitutionarray_object($propal_object,$outputlangs,'propal'):array(); $array_other=$this->get_substitutionarray_other($outputlangs); - // retrieve contact information for use in invoice as contact_xxx tags - $array_thirdparty_contact = array(); - if ($usecontact) - $array_thirdparty_contact=$this->get_substitutionarray_contact($contactobject,$outputlangs,'contact'); + // retrieve contact information for use in object as contact_xxx tags + $array_thirdparty_contact = array(); + if ($usecontact && is_object($contactobject)) $array_thirdparty_contact=$this->get_substitutionarray_contact($contactobject,$outputlangs,'contact'); $tmparray = array_merge($array_user,$array_soc,$array_thirdparty,$array_objet,$array_propal,$array_other,$array_thirdparty_contact); complete_substitutions_array($tmparray, $outputlangs, $object); diff --git a/htdocs/core/modules/product/doc/doc_generic_product_odt.modules.php b/htdocs/core/modules/product/doc/doc_generic_product_odt.modules.php index 8af397d15c1..d5917b82a82 100644 --- a/htdocs/core/modules/product/doc/doc_generic_product_odt.modules.php +++ b/htdocs/core/modules/product/doc/doc_generic_product_odt.modules.php @@ -95,7 +95,7 @@ class doc_generic_product_odt extends ModelePDFProduct function info($langs) { global $conf,$langs; - + $langs->load("companies"); $langs->load("errors"); @@ -369,7 +369,7 @@ class doc_generic_product_odt extends ModelePDFProduct catch(OdfException $e) { } - + // Make substitutions into odt $array_global = $this->get_substitutionarray_each_var_object($object, $outputlangs); $array_user=$this->get_substitutionarray_user($user,$outputlangs); @@ -377,10 +377,9 @@ class doc_generic_product_odt extends ModelePDFProduct $array_thirdparty=$this->get_substitutionarray_thirdparty($socobject,$outputlangs); //$array_objet=$this->get_substitutionarray_object($object,$outputlangs); $array_other=$this->get_substitutionarray_other($outputlangs); - // retrieve contact information for use in product as contact_xxx tags - $array_thirdparty_contact = array(); - if ($usecontact) - $array_thirdparty_contact=$this->get_substitutionarray_contact($contactobject,$outputlangs,'contact'); + // retrieve contact information for use in order as contact_xxx tags + $array_thirdparty_contact = array(); + if ($usecontact && is_object($contactobject)) $array_thirdparty_contact=$this->get_substitutionarray_contact($contactobject,$outputlangs,'contact'); $tmparray = array_merge($array_global,$array_user,$array_soc,$array_thirdparty,$array_other,$array_thirdparty_contact); complete_substitutions_array($tmparray, $outputlangs, $object); diff --git a/htdocs/core/modules/project/doc/doc_generic_project_odt.modules.php b/htdocs/core/modules/project/doc/doc_generic_project_odt.modules.php index 11fc12a19d9..a6743bf1669 100644 --- a/htdocs/core/modules/project/doc/doc_generic_project_odt.modules.php +++ b/htdocs/core/modules/project/doc/doc_generic_project_odt.modules.php @@ -136,7 +136,7 @@ class doc_generic_project_odt extends ModelePDFProjects $object->fetch_optionals($object->id,$extralabels); $resarray = $this->fill_substitutionarray_with_extrafields($object,$resarray,$extrafields,$array_key,$outputlangs); - + return $resarray; } @@ -168,16 +168,16 @@ class doc_generic_project_odt extends ModelePDFProjects 'task_note_private'=>$task->note_private, 'task_note_public'=>$task->note_public ); - + require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; $extrafields = new ExtraFields($this->db); $extralabels = $extrafields->fetch_name_optionals_label($task->table_element,true); $task->fetch_optionals($task->id,$extralabels); - + $resarray = $this->fill_substitutionarray_with_extrafields($task,$resarray,$extrafields,'task',$outputlangs); - + return $resarray; - + } /** @@ -206,13 +206,13 @@ class doc_generic_project_odt extends ModelePDFProjects if ($contact['source']=='external') { $ret[$pc.'isInternal'] = ''; // not internal - + $ct = new Contact($this->db); $ct->fetch($contact['id']); $ret[$pc.'phone_pro'] = $ct->phone_pro; $ret[$pc.'phone_perso'] = $ct->phone_perso; $ret[$pc.'phone_mobile'] = $ct->phone_mobile; - + // fetch external user extrafields require_once(DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'); $extrafields=new ExtraFields($this->db); @@ -225,7 +225,7 @@ class doc_generic_project_odt extends ModelePDFProjects } } elseif ($contact['source']=='internal') { $ret[$pc.'isInternal'] = '1'; // this is an internal user - + $ct = new User($this->db); $ct->fetch($contact['id']); $ret[$pc.'phone_pro'] = $ct->office_phone; @@ -588,10 +588,9 @@ class doc_generic_project_odt extends ModelePDFProjects $array_thirdparty=$this->get_substitutionarray_thirdparty($socobject,$outputlangs); $array_objet=$this->get_substitutionarray_object($object,$outputlangs); $array_other=$this->get_substitutionarray_other($outputlangs); - // retrieve contact information for use in project as contact_xxx tags - $array_project_contact = array(); - if ($usecontact) - $array_project_contact=$this->get_substitutionarray_contact($contactobject,$outputlangs,'contact'); + // retrieve contact information for use in order as contact_xxx tags + $array_thirdparty_contact = array(); + if ($usecontact && is_object($contactobject)) $array_thirdparty_contact=$this->get_substitutionarray_contact($contactobject,$outputlangs,'contact'); $tmparray = array_merge($array_user,$array_soc,$array_thirdparty,$array_objet,$array_other,$array_project_contact); complete_substitutions_array($tmparray, $outputlangs, $object); @@ -932,109 +931,109 @@ class doc_generic_project_odt extends ModelePDFProjects 'title' => "ListProposalsAssociatedProject", 'class' => 'Propal', 'table' => 'propal', - 'test' => $conf->propal->enabled && $user->rights->propale->lire + 'test' => $conf->propal->enabled && $user->rights->propale->lire ), 'order' => array( 'title' => "ListOrdersAssociatedProject", 'class' => 'Commande', 'table' => 'commande', - 'test' => $conf->commande->enabled && $user->rights->commande->lire + 'test' => $conf->commande->enabled && $user->rights->commande->lire ), 'invoice' => array( 'title' => "ListInvoicesAssociatedProject", 'class' => 'Facture', 'table' => 'facture', - 'test' => $conf->facture->enabled && $user->rights->facture->lire + 'test' => $conf->facture->enabled && $user->rights->facture->lire ), 'invoice_predefined' => array( 'title' => "ListPredefinedInvoicesAssociatedProject", 'class' => 'FactureRec', 'table' => 'facture_rec', - 'test' => $conf->facture->enabled && $user->rights->facture->lire + 'test' => $conf->facture->enabled && $user->rights->facture->lire ), 'proposal_supplier' => array( 'title' => "ListSupplierProposalsAssociatedProject", 'class' => 'SupplierProposal', 'table' => 'supplier_proposal', - 'test' => $conf->supplier_proposal->enabled && $user->rights->supplier_proposal->lire + 'test' => $conf->supplier_proposal->enabled && $user->rights->supplier_proposal->lire ), 'order_supplier' => array( 'title' => "ListSupplierOrdersAssociatedProject", 'table' => 'commande_fournisseur', 'class' => 'CommandeFournisseur', - 'test' => $conf->fournisseur->enabled && $user->rights->fournisseur->commande->lire + 'test' => $conf->fournisseur->enabled && $user->rights->fournisseur->commande->lire ), 'invoice_supplier' => array( 'title' => "ListSupplierInvoicesAssociatedProject", 'table' => 'facture_fourn', 'class' => 'FactureFournisseur', - 'test' => $conf->fournisseur->enabled && $user->rights->fournisseur->facture->lire + 'test' => $conf->fournisseur->enabled && $user->rights->fournisseur->facture->lire ), 'contract' => array( 'title' => "ListContractAssociatedProject", 'class' => 'Contrat', 'table' => 'contrat', - 'test' => $conf->contrat->enabled && $user->rights->contrat->lire + 'test' => $conf->contrat->enabled && $user->rights->contrat->lire ), 'intervention' => array( 'title' => "ListFichinterAssociatedProject", 'class' => 'Fichinter', 'table' => 'fichinter', 'disableamount' => 1, - 'test' => $conf->ficheinter->enabled && $user->rights->ficheinter->lire + 'test' => $conf->ficheinter->enabled && $user->rights->ficheinter->lire ), 'shipping' => array( 'title' => "ListShippingAssociatedProject", 'class' => 'Expedition', 'table' => 'expedition', 'disableamount' => 1, - 'test' => $conf->expedition->enabled && $user->rights->expedition->lire + 'test' => $conf->expedition->enabled && $user->rights->expedition->lire ), 'trip' => array( 'title' => "ListTripAssociatedProject", 'class' => 'Deplacement', 'table' => 'deplacement', 'disableamount' => 1, - 'test' => $conf->deplacement->enabled && $user->rights->deplacement->lire + 'test' => $conf->deplacement->enabled && $user->rights->deplacement->lire ), 'expensereport' => array( 'title' => "ListExpenseReportsAssociatedProject", 'class' => 'ExpenseReportLine', 'table' => 'expensereport_det', - 'test' => $conf->expensereport->enabled && $user->rights->expensereport->lire + 'test' => $conf->expensereport->enabled && $user->rights->expensereport->lire ), 'donation' => array( 'title' => "ListDonationsAssociatedProject", 'class' => 'Don', 'table' => 'don', - 'test' => $conf->don->enabled && $user->rights->don->lire + 'test' => $conf->don->enabled && $user->rights->don->lire ), 'loan' => array( 'title' => "ListLoanAssociatedProject", 'class' => 'Loan', 'table' => 'loan', - 'test' => $conf->loan->enabled && $user->rights->loan->read + 'test' => $conf->loan->enabled && $user->rights->loan->read ), 'chargesociales' => array( 'title' => "ListSocialContributionAssociatedProject", 'class' => 'ChargeSociales', 'table' => 'chargesociales', 'urlnew' => DOL_URL_ROOT . '/compta/sociales/card.php?action=create&projectid=' . $id, - 'test' => $conf->tax->enabled && $user->rights->tax->charges->lire + 'test' => $conf->tax->enabled && $user->rights->tax->charges->lire ), 'stock_mouvement' => array( 'title' => "ListMouvementStockProject", 'class' => 'MouvementStock', 'table' => 'stock_mouvement', - 'test' => ($conf->stock->enabled && $user->rights->stock->mouvement->lire && ! empty($conf->global->STOCK_MOVEMENT_INTO_PROJECT_OVERVIEW)) + 'test' => ($conf->stock->enabled && $user->rights->stock->mouvement->lire && ! empty($conf->global->STOCK_MOVEMENT_INTO_PROJECT_OVERVIEW)) ), 'agenda' => array( 'title' => "ListActionsAssociatedProject", 'class' => 'ActionComm', 'table' => 'actioncomm', 'disableamount' => 1, - 'test' => $conf->agenda->enabled && $user->rights->agenda->allactions->lire - ) + 'test' => $conf->agenda->enabled && $user->rights->agenda->allactions->lire + ) ); //Insert reference @@ -1171,7 +1170,7 @@ class doc_generic_project_odt extends ModelePDFProjects $odfHandler=null; // Destroy object $this->result = array('fullpath'=>$file); - + return 1; // Success } else diff --git a/htdocs/core/modules/propale/doc/doc_generic_proposal_odt.modules.php b/htdocs/core/modules/propale/doc/doc_generic_proposal_odt.modules.php index e8af7d87cae..cc128f3fd26 100644 --- a/htdocs/core/modules/propale/doc/doc_generic_proposal_odt.modules.php +++ b/htdocs/core/modules/propale/doc/doc_generic_proposal_odt.modules.php @@ -390,10 +390,9 @@ class doc_generic_proposal_odt extends ModelePDFPropales $array_thirdparty=$this->get_substitutionarray_thirdparty($socobject,$outputlangs); $array_objet=$this->get_substitutionarray_object($object,$outputlangs); $array_other=$this->get_substitutionarray_other($outputlangs); - // retrieve contact information for use in proposal as contact_xxx tags - $array_thirdparty_contact = array(); - if ($usecontact) - $array_thirdparty_contact=$this->get_substitutionarray_contact($contactobject,$outputlangs,'contact'); + // retrieve contact information for use in object as contact_xxx tags + $array_thirdparty_contact = array(); + if ($usecontact && is_object($contactobject)) $array_thirdparty_contact=$this->get_substitutionarray_contact($contactobject,$outputlangs,'contact'); $tmparray = array_merge($array_user,$array_soc,$array_thirdparty,$array_objet,$array_other,$array_thirdparty_contact); complete_substitutions_array($tmparray, $outputlangs, $object); diff --git a/htdocs/core/modules/user/doc/doc_generic_user_odt.modules.php b/htdocs/core/modules/user/doc/doc_generic_user_odt.modules.php index a2c15780e35..dabe1bd99a3 100644 --- a/htdocs/core/modules/user/doc/doc_generic_user_odt.modules.php +++ b/htdocs/core/modules/user/doc/doc_generic_user_odt.modules.php @@ -338,10 +338,9 @@ class doc_generic_user_odt extends ModelePDFUser $array_soc=$this->get_substitutionarray_mysoc($mysoc,$outputlangs); $array_thirdparty=$this->get_substitutionarray_thirdparty($socobject,$outputlangs); $array_other=$this->get_substitutionarray_other($outputlangs); - // retrieve contact information for use in user as contact_xxx tags - $array_thirdparty_contact = array(); - if ($usecontact) - $array_thirdparty_contact=$this->get_substitutionarray_contact($contactobject,$outputlangs,'contact'); + // retrieve contact information for use in object as contact_xxx tags + $array_thirdparty_contact = array(); + if ($usecontact && is_object($contactobject)) $array_thirdparty_contact=$this->get_substitutionarray_contact($contactobject,$outputlangs,'contact'); $tmparray = array_merge($array_user,$array_soc,$array_thirdparty,$array_other,$array_thirdparty_contact); complete_substitutions_array($tmparray, $outputlangs, $object); @@ -409,7 +408,7 @@ class doc_generic_user_odt extends ModelePDFUser $odfHandler=null; // Destroy object $this->result = array('fullpath'=>$file); - + return 1; // Success } else diff --git a/htdocs/core/modules/usergroup/doc/doc_generic_usergroup_odt.modules.php b/htdocs/core/modules/usergroup/doc/doc_generic_usergroup_odt.modules.php index 443981907e0..8f21bfc9ece 100644 --- a/htdocs/core/modules/usergroup/doc/doc_generic_usergroup_odt.modules.php +++ b/htdocs/core/modules/usergroup/doc/doc_generic_usergroup_odt.modules.php @@ -376,10 +376,9 @@ class doc_generic_usergroup_odt extends ModelePDFUserGroup $array_thirdparty=$this->get_substitutionarray_thirdparty($socobject,$outputlangs); $array_objet=$this->get_substitutionarray_each_var_object($object,$outputlangs); $array_other=$this->get_substitutionarray_other($outputlangs); - // retrieve contact information for use in user as contact_xxx tags - $array_thirdparty_contact = array(); - if ($usecontact) - $array_thirdparty_contact=$this->get_substitutionarray_contact($contactobject,$outputlangs,'contact'); + // retrieve contact information for use in object as contact_xxx tags + $array_thirdparty_contact = array(); + if ($usecontact && is_object($contactobject)) $array_thirdparty_contact=$this->get_substitutionarray_contact($contactobject,$outputlangs,'contact'); $tmparray = array_merge($array_global,$array_user,$array_soc,$array_thirdparty,$array_objet,$array_other,$array_thirdparty_contact); complete_substitutions_array($tmparray, $outputlangs, $object); From 4b402aa6d1a6c98e8b2c80a019320f80eded4c8c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 31 Oct 2018 15:41:00 +0100 Subject: [PATCH 017/132] Fix regression on name of array --- .../modules/project/doc/doc_generic_project_odt.modules.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/core/modules/project/doc/doc_generic_project_odt.modules.php b/htdocs/core/modules/project/doc/doc_generic_project_odt.modules.php index a6743bf1669..431e0ab57e3 100644 --- a/htdocs/core/modules/project/doc/doc_generic_project_odt.modules.php +++ b/htdocs/core/modules/project/doc/doc_generic_project_odt.modules.php @@ -588,9 +588,9 @@ class doc_generic_project_odt extends ModelePDFProjects $array_thirdparty=$this->get_substitutionarray_thirdparty($socobject,$outputlangs); $array_objet=$this->get_substitutionarray_object($object,$outputlangs); $array_other=$this->get_substitutionarray_other($outputlangs); - // retrieve contact information for use in order as contact_xxx tags - $array_thirdparty_contact = array(); - if ($usecontact && is_object($contactobject)) $array_thirdparty_contact=$this->get_substitutionarray_contact($contactobject,$outputlangs,'contact'); + // retrieve contact information for use in object as contact_xxx tags + $array_project_contact = array(); + if ($usecontact && is_object($contactobject)) $array_project_contact=$this->get_substitutionarray_contact($contactobject,$outputlangs,'contact'); $tmparray = array_merge($array_user,$array_soc,$array_thirdparty,$array_objet,$array_other,$array_project_contact); complete_substitutions_array($tmparray, $outputlangs, $object); From dfb20c705e2b1704cb2d52cd06e531751c62d06a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 31 Oct 2018 16:05:50 +0100 Subject: [PATCH 018/132] NEW Add hidden option EXPENSEREPORT_DEFAULT_VALIDATOR_UNCHANGEABLE --- htdocs/expensereport/card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/expensereport/card.php b/htdocs/expensereport/card.php index d16674f67d0..31482c341af 100644 --- a/htdocs/expensereport/card.php +++ b/htdocs/expensereport/card.php @@ -1390,7 +1390,7 @@ if ($action == 'create') $defaultselectuser=$user->fk_user; // Will work only if supervisor has permission to approve so is inside include_users if (! empty($conf->global->EXPENSEREPORT_DEFAULT_VALIDATOR)) $defaultselectuser=$conf->global->EXPENSEREPORT_DEFAULT_VALIDATOR; // Can force default approver if (GETPOST('fk_user_validator', 'int') > 0) $defaultselectuser=GETPOST('fk_user_validator', 'int'); - $s=$form->select_dolusers($defaultselectuser, "fk_user_validator", 1, "", 0, $include_users); + $s=$form->select_dolusers($defaultselectuser, "fk_user_validator", 1, "", ((empty($defaultselectuser) || empty($conf->global->EXPENSEREPORT_DEFAULT_VALIDATOR_UNCHANGEABLE))?0:1), $include_users); print $form->textwithpicto($s, $langs->trans("AnyOtherInThisListCanValidate")); } print ''; From e4cfc2c6cb8d923e8f1d71b597c7b392829736a8 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 31 Oct 2018 17:30:08 +0100 Subject: [PATCH 019/132] Fix public --- htdocs/modulebuilder/template/class/myobject.class.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/modulebuilder/template/class/myobject.class.php b/htdocs/modulebuilder/template/class/myobject.class.php index f5f3f582fbc..706b90f6eac 100644 --- a/htdocs/modulebuilder/template/class/myobject.class.php +++ b/htdocs/modulebuilder/template/class/myobject.class.php @@ -410,7 +410,7 @@ class MyObject extends CommonObject * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto, 6=Long label + Picto * @return string Label of status */ - function getLibStatut($mode=0) + public function getLibStatut($mode=0) { return $this->LibStatut($this->status, $mode); } @@ -423,7 +423,7 @@ class MyObject extends CommonObject * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto, 6=Long label + Picto * @return string Label of status */ - function LibStatut($status, $mode=0) + public function LibStatut($status, $mode=0) { // phpcs:enable if (empty($this->labelstatus)) @@ -475,7 +475,7 @@ class MyObject extends CommonObject * @param int $id Id of order * @return void */ - function info($id) + public function info($id) { $sql = 'SELECT rowid, date_creation as datec, tms as datem,'; $sql.= ' fk_user_creat, fk_user_modif'; From 970f501147581c1102896389cd0f7ad81e4d0dc0 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 31 Oct 2018 20:10:20 +0100 Subject: [PATCH 020/132] Debug modulebuilder --- htdocs/admin/emailcollector_card.php | 404 +++++++++++ htdocs/admin/emailcollector_list.php | 551 +++++++++++++++ htdocs/core/class/translate.class.php | 2 +- .../core/modules/modEmailCollector.class.php | 2 +- .../class/emailcollector.class.php | 641 ++++++++++++++++++ .../emailcollector/lib/emailcollector.lib.php | 85 +++ .../install/mysql/migration/8.0.0-9.0.0.sql | 43 ++ .../llx_emailcollector_emailcollector.key.sql | 26 + .../llx_emailcollector_emailcollector.sql | 42 ++ .../template/class/myobject.class.php | 15 +- .../modulebuilder/template/myobject_card.php | 1 - .../modulebuilder/template/myobject_list.php | 4 +- 12 files changed, 1808 insertions(+), 8 deletions(-) create mode 100644 htdocs/admin/emailcollector_card.php create mode 100644 htdocs/admin/emailcollector_list.php create mode 100644 htdocs/emailcollector/class/emailcollector.class.php create mode 100644 htdocs/emailcollector/lib/emailcollector.lib.php create mode 100644 htdocs/install/mysql/tables/llx_emailcollector_emailcollector.key.sql create mode 100644 htdocs/install/mysql/tables/llx_emailcollector_emailcollector.sql diff --git a/htdocs/admin/emailcollector_card.php b/htdocs/admin/emailcollector_card.php new file mode 100644 index 00000000000..2408bcbc8e6 --- /dev/null +++ b/htdocs/admin/emailcollector_card.php @@ -0,0 +1,404 @@ + + * Copyright (C) ---Put here your own copyright and developer email--- + * + * 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 + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** + * \file htdocs/admin/emailcollectore/emailcollector_card.php + * \ingroup emailcollector + * \brief Page to create/edit/view emailcollector + */ + +require '../main.inc.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/agenda.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/events.class.php'; + +include_once DOL_DOCUMENT_ROOT . '/core/class/html.formcompany.class.php'; +include_once DOL_DOCUMENT_ROOT . '/core/class/html.formfile.class.php'; +dol_include_once('/emailcollector/class/emailcollector.class.php'); +dol_include_once('/emailcollector/lib/emailcollector.lib.php'); + +if (!$user->admin) + accessforbidden(); + +// Load traductions files requiredby by page +$langs->loadLangs(array("admin", "other")); + +// Get parameters +$id = GETPOST('id', 'int'); +$ref = GETPOST('ref', 'alpha'); +$action = GETPOST('action', 'alpha'); +$confirm = GETPOST('confirm', 'alpha'); +$cancel = GETPOST('cancel', 'aZ09'); +$contextpage= GETPOST('contextpage','aZ')?GETPOST('contextpage','aZ'):'myobjectcard'; // To manage different context of search +$backtopage = GETPOST('backtopage', 'alpha'); + +// Initialize technical objects +$object = new EmailCollector($db); +$extrafields = new ExtraFields($db); +$diroutputmassaction = $conf->emailcollector->dir_output . '/temp/massgeneration/' . $user->id; +$hookmanager->initHooks(array('emailcollectorcard')); // Note that conf->hooks_modules contains array +// Fetch optionals attributes and labels +$extralabels = $extrafields->fetch_name_optionals_label('emailcollector'); +$search_array_options = $extrafields->getOptionalsFromPost($extralabels, '', 'search_'); + +// Initialize array of search criterias +$search_all = trim(GETPOST("search_all", 'alpha')); +$search = array(); +foreach ($object->fields as $key => $val) { + if (GETPOST('search_'.$key,'alpha')) $search[$key]=GETPOST('search_'.$key,'alpha'); +} + +if (empty($action) && empty($id) && empty($ref)) $action='view'; + +// Load object +include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once // Must be include, not include_once. Include fetch and fetch_thirdparty but not fetch_optionals + +// Security check - Protection if external user +//if ($user->societe_id > 0) access_forbidden(); +//if ($user->societe_id > 0) $socid = $user->societe_id; +//$isdraft = (($object->statut == MyObject::STATUS_DRAFT) ? 1 : 0); +//$result = restrictedArea($user, 'mymodule', $object->id, '', '', 'fk_soc', 'rowid', $isdraft); + + +/* + * Actions + * + * Put here all code to do according to value of "action" parameter + */ + +$parameters = array(); +$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks +if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + +if (empty($reshook)) +{ + $error = 0; + + $permissiontoadd=1; + $permissiontodelete=1; + if (empty($backtopage)) $backtopage = dol_buildpath('/emailcollector/emailcollector_card.php',1).'?id='.($id > 0 ? $id : '__ID__'); + $backurlforlist = dol_buildpath('/emailcollector/emailcollector_list.php', 1); + + // Actions cancel, add, update, delete or clone + include DOL_DOCUMENT_ROOT.'/core/actions_addupdatedelete.inc.php'; + + // Actions when linking object each other + include DOL_DOCUMENT_ROOT.'/core/actions_dellink.inc.php'; // Must be include, not include_once + + // Actions when printing a doc from card + include DOL_DOCUMENT_ROOT.'/core/actions_printing.inc.php'; +} + + + +/* + * View + * + * Put here all code to build page + */ + +$form = new Form($db); +$formfile = new FormFile($db); + +llxHeader('', 'EmailCollector', ''); + +// Example : Adding jquery code +print ''; + +// Part to create +if ($action == 'create') { + print load_fiche_titre($langs->trans("NewEmailCollector", $langs->transnoentitiesnoconv("EmailCollector"))); + + print '
'; + print ''; + print ''; + print ''; + + dol_fiche_head(array(), ''); + + print ''."\n"; + + // Common attributes + include DOL_DOCUMENT_ROOT . '/core/tpl/commonfields_add.tpl.php'; + + // Other attributes + include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_add.tpl.php'; + + print '
'."\n"; + + dol_fiche_end(); + + print '
'; + print ''; + print '  '; + print ''; // Cancel for create does not post form if we don't know the backtopage + print '
'; + + print '
'; +} + +// Part to edit record +if (($id || $ref) && $action == 'edit') +{ + print load_fiche_titre($langs->trans("EmailCollector")); + + print '
'; + print ''; + print ''; + print ''; + print ''; + + dol_fiche_head(); + + print '' . "\n"; + + // Common attributes + include DOL_DOCUMENT_ROOT . '/core/tpl/commonfields_edit.tpl.php'; + + // Other attributes + include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_edit.tpl.php'; + + print '
'; + + dol_fiche_end(); + + print '
'; + print '   '; + print '
'; + + print '
'; +} + +// Part to show record +if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'create'))) +{ + $res = $object->fetch_optionals(); + + $head = emailcollectorPrepareHead($object); + dol_fiche_head($head, 'card', $langs->trans("EmailCollector"), -1, 'emailcollector'); + + $formconfirm = ''; + + // Confirmation to delete + if ($action == 'delete') + { + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id, $langs->trans('DeleteEmailCollector'), $langs->trans('ConfirmDeleteEmailCollector'), 'confirm_delete', '', 0, 1); + } + + // Clone confirmation + if ($action == 'clone') { + // Create an array for form + $formquestion = array(); + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id, $langs->trans('CloneMyObject'), $langs->trans('ConfirmCloneMyObject', $object->ref), 'confirm_clone', $formquestion, 'yes', 1); + } + + // Confirmation of action process + if ($action == 'collect') { + $formquestion = array( + 'text' => $langs->trans("EmailCollectorConfirmCollect"), + ); + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id, $langs->trans('EmailCollectorConfirmCollectTitle'), $text, 'confirm_collect', $formquestion, 0, 1, 220); + } + + // Call Hook formConfirm + $parameters = array('lineid' => $lineid); + $reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + if (empty($reshook)) $formconfirm.=$hookmanager->resPrint; + elseif ($reshook > 0) $formconfirm=$hookmanager->resPrint; + + // Print form confirm + print $formconfirm; + + // Object card + // ------------------------------------------------------------ + $linkback = '' . $langs->trans("BackToList") . ''; + + $morehtmlref = '
'; + /* + // Ref bis + $morehtmlref.=$form->editfieldkey("RefBis", 'ref_client', $object->ref_client, $object, $user->rights->emailcollector->creer, 'string', '', 0, 1); + $morehtmlref.=$form->editfieldval("RefBis", 'ref_client', $object->ref_client, $object, $user->rights->emailcollector->creer, 'string', '', null, null, '', 1); + // Thirdparty + $morehtmlref.='
'.$langs->trans('ThirdParty') . ' : ' . $soc->getNomUrl(1); + // Project + if (! empty($conf->projet->enabled)) + { + $langs->load("projects"); + $morehtmlref.='
'.$langs->trans('Project') . ' '; + if ($user->rights->emailcollector->creer) + { + if ($action != 'classify') + { + $morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; + if ($action == 'classify') { + //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); + $morehtmlref.='
'; + $morehtmlref.=''; + $morehtmlref.=''; + $morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); + $morehtmlref.=''; + $morehtmlref.='
'; + } else { + $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); + } + } + } else { + if (! empty($object->fk_project)) { + $proj = new Project($db); + $proj->fetch($object->fk_project); + $morehtmlref.=''; + $morehtmlref.=$proj->ref; + $morehtmlref.=''; + } else { + $morehtmlref.=''; + } + } + } + */ + $morehtmlref .= '
'; + + dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref); + + print '
'; + print '
'; + print '
'; + print ''."\n"; + + // Common attributes + //$keyforbreak='fieldkeytoswithonsecondcolumn'; + include DOL_DOCUMENT_ROOT . '/core/tpl/commonfields_view.tpl.php'; + + // Other attributes + include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php'; + + print '
'; + + + if ($action == 'confirm_collect') + { + print_fiche_titre($langs->trans('MessagesFetchingResults'), '', ''); + + dol_include_once('/emailcollector/class/emailcollector.class.php'); + $emailcollector = new EmailCollector($object); + + $res = $emailcollector->collectEmails(); + if (is_array($res)) { + if (count($res['actions_done']) > 0) { + setEventMessages($langs->trans('XActionsDone', count($res['actions_done'])), null, 'info'); + } else { + setEventMessages($langs->trans('NoActionsdone'), null, 'info'); + } + } else { + setEventMessages($langs->trans('NoEmailsToProcess'), null, 'info'); + } + $action = ''; + } + print '
'; + print '
'; + + + print '

'; + + dol_fiche_end(); + + // Buttons for actions + if ($action != 'presend' && $action != 'editline') { + print '
' . "\n"; + $parameters = array(); + $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + + if (empty($reshook)) + { + print '' . $langs->trans("CollectNow") . '' . "\n"; + + print '' . $langs->trans('Delete') . '' . "\n"; + } + print '
' . "\n"; + } + + // Select mail models is same action as presend + if (GETPOST('modelselected')) { + $action = 'presend'; + } + + /* + if ($action != 'presend') { + print '
'; + print ''; // ancre + */ + // Documents + /*$objref = dol_sanitizeFileName($object->ref); + $relativepath = $comref . '/' . $comref . '.pdf'; + $filedir = $conf->emailcollector->dir_output . '/' . $objref; + $urlsource = $_SERVER["PHP_SELF"] . "?id=" . $object->id; + $genallowed = $user->rights->emailcollector->read; // If you can read, you can build the PDF to read content + $delallowed = $user->rights->emailcollector->create; // If you can create/edit, you can remove a file on card + print $formfile->showdocuments('emailcollector', $objref, $filedir, $urlsource, $genallowed, $delallowed, $object->modelpdf, 1, 0, 0, 28, 0, '', '', '', $soc->default_lang); + */ + /* + // Show links to link elements + $linktoelem = $form->showLinkToObjectBlock($object, null, array('emailcollector')); + $somethingshown = $form->showLinkedObjectBlock($object, $linktoelem); + + print '
'; + + $MAXEVENT = 10; + + $morehtmlright = ''; + $morehtmlright .= $langs->trans("SeeAll"); + $morehtmlright .= ''; + + // List of actions on element + include_once DOL_DOCUMENT_ROOT . '/core/class/html.formactions.class.php'; + $formactions = new FormActions($db); + $somethingshown = $formactions->showactions($object, 'emailcollector_emailcollector', $socid, 1, '', $MAXEVENT, '', $morehtmlright); + + print '
'; + } + */ + + //Select mail models is same action as presend + /* + if (GETPOST('modelselected')) $action = 'presend'; + + // Presend form + $modelmail='inventory'; + $defaulttopic='InformationMessage'; + $diroutput = $conf->product->dir_output.'/inventory'; + $trackid = 'stockinv'.$object->id; + + include DOL_DOCUMENT_ROOT.'/core/tpl/card_presend.tpl.php'; + */ +} + +// End of page +llxFooter(); +$db->close(); diff --git a/htdocs/admin/emailcollector_list.php b/htdocs/admin/emailcollector_list.php new file mode 100644 index 00000000000..6de67299871 --- /dev/null +++ b/htdocs/admin/emailcollector_list.php @@ -0,0 +1,551 @@ + + * + * 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 + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** + * \file htdocs/admin/emailcollector_list.php + * \ingroup emailcollector + * \brief List page for emailcollector + */ + +require '../main.inc.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/agenda.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/events.class.php'; + +require_once DOL_DOCUMENT_ROOT . '/core/class/html.formcompany.class.php'; +require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php'; +require_once DOL_DOCUMENT_ROOT . '/core/lib/company.lib.php'; +dol_include_once('/emailcollector/class/emailcollector.class.php'); + +if (!$user->admin) accessforbidden(); + +// Load traductions files requiredby by page +$langs->loadLangs(array("admin", "other")); + +$action = GETPOST('action','aZ09')?GETPOST('action','aZ09'):'view'; // The action 'add', 'create', 'edit', 'update', 'view', ... +$massaction = GETPOST('massaction','alpha'); // The bulk action (combo box choice into lists) +$show_files = GETPOST('show_files','int'); // Show files area generated by bulk actions ? +$confirm = GETPOST('confirm','alpha'); // Result of a confirmation +$cancel = GETPOST('cancel', 'alpha'); // We click on a Cancel button +$toselect = GETPOST('toselect', 'array'); // Array of ids of elements selected into a list +$contextpage= GETPOST('contextpage','aZ')?GETPOST('contextpage','aZ'):'emailcollectorlist'; // To manage different context of search +$backtopage = GETPOST('backtopage','alpha'); // Go back to a dedicated page +$optioncss = GETPOST('optioncss','aZ'); // Option for the css output (always '' except when 'print') + +$id = GETPOST('id','int'); + +// Load variable for pagination +$limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit; +$sortfield = GETPOST('sortfield','alpha'); +$sortorder = GETPOST('sortorder','alpha'); +$page = GETPOST('page','int'); +if (empty($page) || $page == -1 || GETPOST('button_search','alpha') || GETPOST('button_removefilter','alpha') || (empty($toselect) && $massaction === '0')) { $page = 0; } // If $page is not defined, or '' or -1 or if we click on clear filters or if we select empty mass action +$offset = $limit * $page; +$pageprev = $page - 1; +$pagenext = $page + 1; +//if (! $sortfield) $sortfield="p.date_fin"; +//if (! $sortorder) $sortorder="DESC"; + +// Initialize technical objects +$object = new EmailCollector($db); +$extrafields = new ExtraFields($db); +$diroutputmassaction = $conf->emailcollector->dir_output . '/temp/massgeneration/' . $user->id; +$hookmanager->initHooks(array('emailcollectorlist')); // Note that conf->hooks_modules contains array +// Fetch optionals attributes and labels +$extralabels = $extrafields->fetch_name_optionals_label('emailcollector'); +$search_array_options = $extrafields->getOptionalsFromPost($extralabels, '', 'search_'); + +// Default sort order (if not yet defined by previous GETPOST) +if (! $sortfield) $sortfield="t.".key($object->fields); // Set here default search field. By default 1st field in definition. +if (! $sortorder) $sortorder="ASC"; + +// Security check +$socid=0; +if ($user->societe_id > 0) // Protection if external user +{ + //$socid = $user->societe_id; + accessforbidden(); +} +//$result = restrictedArea($user, 'emailcollector', $id, ''); + +// Initialize array of search criterias +$search_all=trim(GETPOST("search_all",'alpha')); +$search=array(); +foreach($object->fields as $key => $val) +{ + if (GETPOST('search_'.$key,'alpha')) $search[$key]=GETPOST('search_'.$key,'alpha'); +} + +// List of fields to search into when doing a "search in all" +$fieldstosearchall = array(); +foreach($object->fields as $key => $val) +{ + if ($val['searchall']) $fieldstosearchall['t.'.$key]=$val['label']; +} + +// Definition of fields for list +$arrayfields=array(); +foreach($object->fields as $key => $val) +{ + // If $val['visible']==0, then we never show the field + if (! empty($val['visible'])) $arrayfields['t.'.$key]=array('label'=>$val['label'], 'checked'=>(($val['visible']<0)?0:1), 'enabled'=>$val['enabled'], 'position'=>$val['position']); +} +// Extra fields +if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label']) > 0) +{ + foreach($extrafields->attributes[$object->table_element]['label'] as $key => $val) + { + if (! empty($extrafields->attributes[$object->table_element]['list'][$key])) + $arrayfields["ef.".$key]=array('label'=>$extrafields->attributes[$object->table_element]['label'][$key], 'checked'=>(($extrafields->attributes[$object->table_element]['list'][$key]<0)?0:1), 'position'=>$extrafields->attributes[$object->table_element]['pos'][$key], 'enabled'=>(abs($extrafields->attributes[$object->table_element]['list'][$key])!=3 && $extrafields->attributes[$object->table_element]['perms'][$key])); + } +} +$object->fields = dol_sort_array($object->fields, 'position'); +$arrayfields = dol_sort_array($arrayfields, 'position'); + + + +/* + * Actions + * + * Put here all code to do according to value of "$action" parameter + */ + +if (GETPOST('cancel','alpha')) { $action='list'; $massaction=''; } +if (! GETPOST('confirmmassaction','alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction=''; } + +$parameters=array(); +$reshook=$hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks +if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + +if (empty($reshook)) +{ + // Selection of new fields + include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; + + // Purge search criteria + if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x','alpha') ||GETPOST('button_removefilter','alpha')) // All tests are required to be compatible with all browsers + { + foreach($object->fields as $key => $val) + { + $search[$key]=''; + } + $toselect=''; + $search_array_options=array(); + } + if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x','alpha') || GETPOST('button_removefilter','alpha') + || GETPOST('button_search_x','alpha') || GETPOST('button_search.x','alpha') || GETPOST('button_search','alpha')) + { + $massaction=''; // Protection to avoid mass action if we force a new search during a mass action confirmation + } + + // Mass actions + $objectclass='EmailCollector'; + $objectlabel='EmailCollector'; + $permtoread = $user->rights->emailcollector->read; + $permtodelete = $user->rights->emailcollector->delete; + $uploaddir = $conf->emailcollector->dir_output; + include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php'; +} + + + +/* + * View + * + * Put here all code to render page + */ + +$form=new Form($db); + +$now=dol_now(); + +//$help_url="EN:Module_EmailCollector|FR:Module_EmailCollector_FR|ES:Módulo_EmailCollector"; +$help_url=''; +$title = $langs->trans('ListOf', $langs->transnoentitiesnoconv("EmailCollector")); + + +// Build and execute select +// -------------------------------------------------------------------- +$sql = 'SELECT '; +foreach($object->fields as $key => $val) +{ + $sql.='t.'.$key.', '; +} +// Add fields from extrafields +if (! empty($extrafields->attributes[$object->table_element]['label'])) + foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) $sql.=($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? "ef.".$key.' as options_'.$key.', ' : ''); +// Add fields from hooks +$parameters=array(); +$reshook=$hookmanager->executeHooks('printFieldListSelect', $parameters, $object); // Note that $action and $object may have been modified by hook +$sql.=$hookmanager->resPrint; +$sql=preg_replace('/, $/','', $sql); +$sql.= " FROM ".MAIN_DB_PREFIX.$object->table_element." as t"; +if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (t.rowid = ef.fk_object)"; +if ($object->ismultientitymanaged == 1) $sql.= " WHERE t.entity IN (".getEntity($object->element).")"; +else $sql.=" WHERE 1 = 1"; +foreach($search as $key => $val) +{ + if ($key == 'status' && $search[$key] == -1) continue; + $mode_search=(($object->isInt($object->fields[$key]) || $object->isFloat($object->fields[$key]))?1:0); + if ($search[$key] != '') $sql.=natural_search($key, $search[$key], (($key == 'status')?2:$mode_search)); +} +if ($search_all) $sql.= natural_search(array_keys($fieldstosearchall), $search_all); +// 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); // Note that $action and $object may have been modified by hook +$sql.=$hookmanager->resPrint; + +/* If a group by is required + $sql.= " GROUP BY " + foreach($object->fields as $key => $val) + { + $sql.='t.'.$key.', '; + } + // Add fields from extrafields + if (! empty($extrafields->attributes[$object->table_element]['label'])) { + foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) $sql.=($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? "ef.".$key.', ' : ''); + // Add where from hooks + $parameters=array(); + $reshook=$hookmanager->executeHooks('printFieldListGroupBy',$parameters); // Note that $action and $object may have been modified by hook + $sql.=$hookmanager->resPrint; + $sql=preg_replace('/, $/','', $sql); + */ + +$sql.=$db->order($sortfield,$sortorder); + +// Count total nb of records +$nbtotalofrecords = ''; +if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) +{ + $resql = $db->query($sql); + $nbtotalofrecords = $db->num_rows($resql); + if (($page * $limit) > $nbtotalofrecords) // if total of record found is smaller than page * limit, goto and load page 0 + { + $page = 0; + $offset = 0; + } +} +// if total of record found is smaller than limit, no need to do paging and to restart another select with limits set. +if (is_numeric($nbtotalofrecords) && $limit > $nbtotalofrecords) +{ + $num = $nbtotalofrecords; +} +else +{ + $sql.= $db->plimit($limit+1, $offset); + + $resql=$db->query($sql); + if (! $resql) + { + dol_print_error($db); + exit; + } + + $num = $db->num_rows($resql); +} + +// Direct jump if only one record found +if ($num == 1 && ! empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $search_all) +{ + $obj = $db->fetch_object($resql); + $id = $obj->rowid; + header("Location: ".DOL_URL_ROOT.'/emailcollector/emailcollector_card.php?id='.$id); + exit; +} + + +// Output page +// -------------------------------------------------------------------- + +llxHeader('', $title, $help_url); + +// Example : Adding jquery code +print ''; + +$arrayofselected=is_array($toselect)?$toselect:array(); + +$param=''; +if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.urlencode($contextpage); +if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.urlencode($limit); +foreach($search as $key => $val) +{ + $param.= '&search_'.$key.'='.urlencode($search[$key]); +} +if ($optioncss != '') $param.='&optioncss='.urlencode($optioncss); +// Add $param from extra fields +include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; + +// List of mass actions available +$arrayofmassactions = array( +//'presend'=>$langs->trans("SendByMail"), +//'builddoc'=>$langs->trans("PDFMerge"), +); +if ($user->rights->emailcollector->delete) $arrayofmassactions['predelete']=$langs->trans("Delete"); +if (GETPOST('nomassaction','int') || in_array($massaction, array('presend','predelete'))) $arrayofmassactions=array(); +$massactionbutton=$form->selectMassAction('', $arrayofmassactions); + +print '
'; +if ($optioncss != '') print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; + +$newcardbutton=''; +//if ($user->rights->emailcollector->creer) + //{ +$newcardbutton=''.$langs->trans('New').''; +$newcardbutton.= ''; +$newcardbutton.= ''; +//} + +print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'title_companies', 0, $newcardbutton, '', $limit); + +// Add code for pre mass action (confirmation or email presend form) +include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php'; + +if ($sall) +{ + foreach($fieldstosearchall as $key => $val) $fieldstosearchall[$key]=$langs->trans($val); + print '
'.$langs->trans("FilterOnInto", $sall) . join(', ',$fieldstosearchall).'
'; +} + +$moreforfilter = ''; +/*$moreforfilter.='
'; + $moreforfilter.= $langs->trans('MyFilter') . ': '; + $moreforfilter.= '
';*/ + +$parameters=array(); +$reshook=$hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook +if (empty($reshook)) $moreforfilter .= $hookmanager->resPrint; +else $moreforfilter = $hookmanager->resPrint; + +if (! empty($moreforfilter)) +{ + print '
'; + print $moreforfilter; + print '
'; +} + +$varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage; +$selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields +$selectedfields.=(count($arrayofmassactions) ? $form->showCheckAddButtons('checkforselect', 1) : ''); + +print '
'; // You can use div-table-responsive-no-min if you dont need reserved height for your table +print ''."\n"; + + +// Fields title search +// -------------------------------------------------------------------- +print ''; +foreach($object->fields as $key => $val) +{ + $align=''; + if (in_array($val['type'], array('date','datetime','timestamp'))) $align.=($align?' ':'').'center'; + if (in_array($val['type'], array('timestamp'))) $align.=($align?' ':'').'nowrap'; + if ($key == 'status') $align.=($align?' ':'').'center'; + if (! empty($arrayfields['t.'.$key]['checked'])) print ''; +} +// Extra fields +include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php'; + +// Fields from hook +$parameters=array('arrayfields'=>$arrayfields); +$reshook=$hookmanager->executeHooks('printFieldListOption', $parameters, $object); // Note that $action and $object may have been modified by hook +print $hookmanager->resPrint; +// Action column +print ''; +print ''."\n"; + + +// Fields title label +// -------------------------------------------------------------------- +print ''; +foreach($object->fields as $key => $val) +{ + $align=''; + if (in_array($val['type'], array('date','datetime','timestamp'))) $align.=($align?' ':'').'center'; + if (in_array($val['type'], array('timestamp'))) $align.=($align?' ':'').'nowrap'; + if ($key == 'status') $align.=($align?' ':'').'center'; + if (! empty($arrayfields['t.'.$key]['checked'])) print getTitleFieldOfList($arrayfields['t.'.$key]['label'], 0, $_SERVER['PHP_SELF'], 't.'.$key, '', $param, ($align?'class="'.$align.'"':''), $sortfield, $sortorder, $align.' ')."\n"; +} +// Extra fields +include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; +// Hook fields +$parameters=array('arrayfields'=>$arrayfields,'param'=>$param,'sortfield'=>$sortfield,'sortorder'=>$sortorder); +$reshook=$hookmanager->executeHooks('printFieldListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook +print $hookmanager->resPrint; +print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"],'','','','align="center"',$sortfield,$sortorder,'maxwidthsearch ')."\n"; +print ''."\n"; + + +// Detect if we need a fetch on each output line +$needToFetchEachLine=0; +if (is_array($extrafields->attributes[$object->table_element]['computed']) && count($extrafields->attributes[$object->table_element]['computed']) > 0) +{ + foreach ($extrafields->attributes[$object->table_element]['computed'] as $key => $val) + { + if (preg_match('/\$object/',$val)) $needToFetchEachLine++; // There is at least one compute field that use $object + } +} + + +// Loop on record +// -------------------------------------------------------------------- +$i=0; +$totalarray=array(); +while ($i < min($num, $limit)) +{ + $obj = $db->fetch_object($resql); + if (empty($obj)) break; // Should not happen + + // Store properties in $object + $object->id = $obj->rowid; + foreach($object->fields as $key => $val) + { + if (isset($obj->$key)) $object->$key = $obj->$key; + } + + // Show here line of result + print ''; + foreach($object->fields as $key => $val) + { + $align=''; + if (in_array($val['type'], array('date','datetime','timestamp'))) $align.=($align?' ':'').'center'; + if (in_array($val['type'], array('timestamp'))) $align.=($align?' ':'').'nowrap'; + if ($key == 'status') $align.=($align?' ':'').'center'; + if (! empty($arrayfields['t.'.$key]['checked'])) + { + print ''; + print $object->showOutputField($val, $key, $obj->$key, ''); + print ''; + if (! $i) $totalarray['nbfield']++; + if (! empty($val['isameasure'])) + { + if (! $i) $totalarray['pos'][$totalarray['nbfield']]='t.'.$key; + $totalarray['val']['t.'.$key] += $obj->$key; + } + } + } + // Extra fields + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; + // Fields from hook + $parameters=array('arrayfields'=>$arrayfields, 'obj'=>$obj); + $reshook=$hookmanager->executeHooks('printFieldListValue', $parameters, $object); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; + // Action column + print ''; + if (! $i) $totalarray['nbfield']++; + + print ''; + + $i++; +} + +// Show total line +if (isset($totalarray['pos'])) +{ + print ''; + $i=0; + while ($i < $totalarray['nbfield']) + { + $i++; + if (! empty($totalarray['pos'][$i])) print ''; + else + { + if ($i == 1) + { + if ($num < $limit) print ''; + else print ''; + } + else print ''; + } + } + print ''; +} + +// If no record found +if ($num == 0) +{ + $colspan=1; + foreach($arrayfields as $key => $val) { if (! empty($val['checked'])) $colspan++; } + print ''; +} + + +$db->free($resql); + +$parameters=array('arrayfields'=>$arrayfields, 'sql'=>$sql); +$reshook=$hookmanager->executeHooks('printFieldListFooter', $parameters, $object); // Note that $action and $object may have been modified by hook +print $hookmanager->resPrint; + +print '
'; +$searchpicto=$form->showFilterButtons(); +print $searchpicto; +print '
'; + if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined + { + $selected=0; + if (in_array($obj->rowid, $arrayofselected)) $selected=1; + print ''; + } + print '
'.price($totalarray['val'][$totalarray['pos'][$i]]).''.$langs->trans("Total").''.$langs->trans("Totalforthispage").'
'.$langs->trans("NoRecordFound").'
'."\n"; +print '
'."\n"; + +print '
'."\n"; + +if (in_array('builddoc',$arrayofmassactions) && ($nbtotalofrecords === '' || $nbtotalofrecords)) +{ + $hidegeneratedfilelistifempty=1; + if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) $hidegeneratedfilelistifempty=0; + + require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; + $formfile = new FormFile($db); + + // Show list of available documents + $urlsource=$_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder; + $urlsource.=str_replace('&','&',$param); + + $filedir=$diroutputmassaction; + $genallowed=$user->rights->emailcollector->read; + $delallowed=$user->rights->emailcollector->create; + + print $formfile->showdocuments('massfilesarea_emailcollector','',$filedir,$urlsource,0,$delallowed,'',1,1,0,48,1,$param,$title,'','','',null,$hidegeneratedfilelistifempty); +} + +// End of page +llxFooter(); +$db->close(); diff --git a/htdocs/core/class/translate.class.php b/htdocs/core/class/translate.class.php index 2e489f6ba65..79d633027e0 100644 --- a/htdocs/core/class/translate.class.php +++ b/htdocs/core/class/translate.class.php @@ -577,7 +577,7 @@ class Translate //$newstr=$this->getLabelFromKey($db,$reg[1],'c_ordersource','code','label'); } - if (! empty($conf->global->MAIN_FEATURES_LEVEL) && $conf->global->MAIN_FEATURES_LEVEL >= 2) dol_syslog(__METHOD__." missing translation for key '".$newstr."' in ".$_SERVER["PHP_SELF"], LOG_DEBUG); + if (! empty($conf->global->MAIN_FEATURES_LEVEL) && $conf->global->MAIN_FEATURES_LEVEL >= 2) dol_syslog(__METHOD__." MAIN_FEATURES_LEVEL=DEVELOP: missing translation for key '".$newstr."' in ".$_SERVER["PHP_SELF"], LOG_DEBUG); return $newstr; } diff --git a/htdocs/core/modules/modEmailCollector.class.php b/htdocs/core/modules/modEmailCollector.class.php index 6d266fbe6f7..26d78a7fb0e 100644 --- a/htdocs/core/modules/modEmailCollector.class.php +++ b/htdocs/core/modules/modEmailCollector.class.php @@ -83,7 +83,7 @@ class modEmailCollector extends DolibarrModules $this->dirs = array(); // Config pages. Put here list of php page, stored into dav/admin directory, to use to setup module. - $this->config_page_url = array("emailcollector.php"); + $this->config_page_url = array("emailcollector_list.php"); // Dependencies $this->hidden = false; // A condition to hide module diff --git a/htdocs/emailcollector/class/emailcollector.class.php b/htdocs/emailcollector/class/emailcollector.class.php new file mode 100644 index 00000000000..4a7986e5d8a --- /dev/null +++ b/htdocs/emailcollector/class/emailcollector.class.php @@ -0,0 +1,641 @@ + + * + * 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 + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** + * \file emailcollector/class/emailcollector.class.php + * \ingroup emailcollector + * \brief This file is a CRUD class file for EmailCollector (Create/Read/Update/Delete) + */ + +// Put here all includes required by your class file +require_once DOL_DOCUMENT_ROOT . '/core/class/commonobject.class.php'; +//require_once DOL_DOCUMENT_ROOT . '/societe/class/societe.class.php'; +//require_once DOL_DOCUMENT_ROOT . '/product/class/product.class.php'; + +/** + * Class for EmailCollector + */ +class EmailCollector extends CommonObject +{ + /** + * @var string ID to identify managed object + */ + public $element = 'emailcollector'; + /** + * @var string Name of table without prefix where object is stored + */ + public $table_element = 'emailcollector_emailcollector'; + /** + * @var int Does emailcollector support multicompany module ? 0=No test on entity, 1=Test with field entity, 2=Test with link by societe + */ + public $ismultientitymanaged = 0; + /** + * @var int Does emailcollector support extrafields ? 0=No, 1=Yes + */ + public $isextrafieldmanaged = 0; + /** + * @var string String with name of icon for emailcollector. Must be the part after the 'object_' into object_emailcollector.png + */ + public $picto = 'generic'; + + + /** + * 'type' if the field format. + * 'label' the translation key. + * 'enabled' is a condition when the field must be managed. + * '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. Using a negative value means field is not shown by default on list but can be selected for viewing) + * 'notnull' is set to 1 if not null in database. Set to -1 if we must set data to null if empty ('' or 0). + * 'default' is a default value for creation (can still be replaced by the global setup of default values) + * 'index' if we want an index in database. + * 'foreignkey'=>'tablename.field' if the field is a foreign key (it is recommanded to name the field fk_...). + * 'position' is the sort order of field. + * '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 + * 'comment' is not used. You can store here any text of your choice. It is not used by application. + * 'showoncombobox' if value of the field must be visible into the label of the combobox that list record + * 'arraykeyval' to set list of value if type is a list of predefined values. For example: array("0"=>"Draft","1"=>"Active","-1"=>"Cancel") + */ + + // BEGIN MODULEBUILDER PROPERTIES + /** + * @var array 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','visible'=>2, 'enabled'=>1, 'position'=>1, 'notnull'=>1, 'index'=>1), + 'entity' =>array('type'=>'integer', 'label'=>'Entity', 'enabled'=>1, 'visible'=>0, 'default'=>1, 'notnull'=>1, 'index'=>1, 'position'=>20), + 'ref' =>array('type'=>'varchar(128)', 'label'=>'Ref', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'showoncombobox'=>1, 'index'=>1, 'position'=>10, 'searchall'=>1), + 'label' => array('type'=>'varchar(255)', 'label'=>'Label', 'visible'=>1, 'enabled'=>1, 'position'=>30, 'notnull'=>-1, 'searchall'=>1), + 'description' => array('type'=>'text', 'label'=>'Description', 'visible'=>-1, 'enabled'=>1, 'position'=>60, 'notnull'=>-1, 'searchall'=>1), + 'host' => array('type'=>'varchar(255)', 'label'=>'EMailHost', 'visible'=>1, 'enabled'=>1, 'position'=>100, 'notnull'=>1, 'searchall'=>1, 'comment'=>"IMPA server",), + 'user' => array('type'=>'varchar(128)', 'label'=>'User', 'visible'=>1, 'enabled'=>1, 'position'=>101, 'notnull'=>1, 'index'=>1, 'comment'=>"IMAP login",), + 'password' => array('type'=>'password', 'label'=>'Password', 'visible'=>-1, 'enabled'=>1, 'position'=>102, 'notnull'=>1, 'comment'=>"IMAP password",), + 'source_directory' => array('type'=>'varchar(255)', 'label'=>'MailboxSourceDirectory', 'visible'=>-1, 'enabled'=>1, 'position'=>103, 'notnull'=>-1, 'default' => 'Inbox'), + 'filter' => array('type'=>'text', 'label'=>'Filter', 'visible'=>1, 'enabled'=>1, 'position'=>105), + 'actiontodo' => array('type'=>'varchar(255)', 'label'=>'ActionToDo', 'visible'=>1, 'enabled'=>1, 'position'=>106), + 'target_directory' => array('type'=>'varchar(255)', 'label'=>'MailboxTargetDirectory', 'visible'=>1, 'enabled'=>1, 'position'=>110, 'notnull'=>1, 'comment'=>"Where to store messages once processed"), + 'datelastresult' => array('type'=>'datetime', 'label'=>'DateLastResult', 'visible'=>-2, 'enabled'=>1, 'position'=>121, 'notnull'=>-1,), + 'lastresult' => array('type'=>'varchar(255)', 'label'=>'LastResult', 'visible'=>1, 'enabled'=>1, 'position'=>122, 'notnull'=>-1,), + 'note_public' => array('type'=>'html', 'label'=>'NotePublic', 'visible'=>0, 'enabled'=>1, 'position'=>61, 'notnull'=>-1,), + 'note_private' => array('type'=>'html', 'label'=>'NotePrivate', 'visible'=>0, 'enabled'=>1, 'position'=>62, 'notnull'=>-1,), + 'date_creation' => array('type'=>'datetime', 'label'=>'DateCreation', 'visible'=>-2, 'enabled'=>1, 'position'=>500, 'notnull'=>1,), + 'tms' => array('type'=>'timestamp', 'label'=>'DateModification', 'visible'=>-2, 'enabled'=>1, 'position'=>501, 'notnull'=>1,), + //'date_validation' =>array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>1, 'visible'=>-2, 'position'=>502), + 'fk_user_creat' => array('type'=>'integer:User:user/class/user.class.php', 'label'=>'UserAuthor', 'visible'=>-2, 'enabled'=>1, 'position'=>510, 'notnull'=>1,), + 'fk_user_modif' => array('type'=>'integer:User:user/class/user.class.php', 'label'=>'UserModif', 'visible'=>-2, 'enabled'=>1, 'position'=>511, 'notnull'=>-1,), + //'fk_user_valid' =>array('type'=>'integer', 'label'=>'UserValidation', 'enabled'=>1, 'visible'=>-1, 'position'=>512), + 'import_key' => array('type'=>'varchar(14)', 'label'=>'ImportId', 'visible'=>-2, 'enabled'=>1, 'position'=>1000, 'notnull'=>-1,), + 'status' => array('type'=>'integer', 'label'=>'Status', 'visible'=>1, 'enabled'=>1, 'position'=>1000, 'notnull'=>1, 'index'=>1, 'arrayofkeyval'=>array('0'=>'Inactive', '1'=>'Active')) + ); + + + /** + * @var int ID + */ + public $rowid; + + /** + * @var string Ref + */ + public $ref; + + /** + * @var int Entity + */ + public $entity; + + /** + * @var string label + */ + public $label; + + public $amount; + + /** + * @var int Status + */ + public $status; + + public $date_creation; + public $tms; + + /** + * @var int ID + */ + public $fk_user_creat; + + /** + * @var int ID + */ + public $fk_user_modif; + + public $import_key; + + + public $host; + public $user; + public $password; + public $source_directory; + public $filter; + public $actiontodo; + public $target_directory; + public $datelastresult; + public $lastresult; + // END MODULEBUILDER PROPERTIES + + + + /** + * Constructor + * + * @param DoliDb $db Database handler + */ + public function __construct(DoliDB $db) + { + global $conf, $langs, $user; + + $this->db = $db; + + if (empty($conf->global->MAIN_SHOW_TECHNICAL_ID) && isset($this->fields['rowid'])) $this->fields['rowid']['visible']=0; + if (empty($conf->multicompany->enabled) && isset($this->fields['entity'])) $this->fields['entity']['enabled']=0; + + // Unset fields that are disabled + foreach($this->fields as $key => $val) + { + if (isset($val['enabled']) && empty($val['enabled'])) + { + unset($this->fields[$key]); + } + } + + // Translate some data of arrayofkeyval + foreach($this->fields as $key => $val) + { + if (is_array($this->fields['status']['arrayofkeyval'])) + { + foreach($this->fields['status']['arrayofkeyval'] as $key2 => $val2) + { + $this->fields['status']['arrayofkeyval'][$key2]=$langs->trans($val2); + } + } + } + } + + /** + * Create object into database + * + * @param User $user User that creates + * @param bool $notrigger false=launch triggers after, true=disable triggers + * @return int <0 if KO, Id of created object if OK + */ + public function create(User $user, $notrigger = false) + { + return $this->createCommon($user, $notrigger); + } + + /** + * Clone and object into another one + * + * @param User $user User that creates + * @param int $fromid Id of object to clone + * @return mixed New object created, <0 if KO + */ + public function createFromClone(User $user, $fromid) + { + global $langs, $hookmanager, $extrafields; + $error = 0; + + dol_syslog(__METHOD__, LOG_DEBUG); + + $object = new self($this->db); + + $this->db->begin(); + + // Load source object + $object->fetchCommon($fromid); + // Reset some properties + unset($object->id); + unset($object->fk_user_creat); + unset($object->import_key); + + // Clear fields + $object->ref = "copy_of_".$object->ref; + $object->title = $langs->trans("CopyOf")." ".$object->title; + // ... + // Clear extrafields that are unique + if (is_array($object->array_options) && count($object->array_options) > 0) + { + $extrafields->fetch_name_optionals_label($this->element); + foreach($object->array_options as $key => $option) + { + $shortkey = preg_replace('/options_/', '', $key); + if (! empty($extrafields->attributes[$this->element]['unique'][$shortkey])) + { + //var_dump($key); var_dump($clonedObj->array_options[$key]); exit; + unset($object->array_options[$key]); + } + } + } + + // Create clone + $object->context['createfromclone'] = 'createfromclone'; + $result = $object->createCommon($user); + if ($result < 0) { + $error++; + $this->error = $object->error; + $this->errors = $object->errors; + } + + // End + if (!$error) { + $this->db->commit(); + return $object; + } else { + $this->db->rollback(); + return -1; + } + } + + /** + * Load object in memory from the database + * + * @param int $id Id object + * @param string $ref Ref + * @return int <0 if KO, 0 if not found, >0 if OK + */ + public function fetch($id, $ref = null) + { + $result = $this->fetchCommon($id, $ref); + if ($result > 0 && ! empty($this->table_element_line)) $this->fetchLines(); + return $result; + } + + /** + * Load object lines in memory from the database + * + * @return int <0 if KO, 0 if not found, >0 if OK + */ + /*public function fetchLines() + { + $this->lines=array(); + + // Load lines with object EmailCollectorLine + + return count($this->lines)?1:0; + }*/ + + /** + * Fetch all account and load objects into an array + * + * @return array Array with key => EmailCollector object + * @author + */ + public function fetchAll(User $user, $activeOnly = 0, $sortfield = 's.rowid', $sortorder = 'ASC', $limit = 100, $page = 0) + { + global $langs; + + $obj_ret = array(); + + $socid = $user->societe_id ? $user->societe_id : ''; + + // If the internal user must only see his customers, force searching by him + if (! $user->rights->societe->client->voir && !$socid) { + $search_sale = $user->id; + } + $sql = "SELECT s.rowid"; + //if ((!$user->rights->societe->client->voir && !$socid) || $search_sale > 0) { + // $sql .= ", sc.fk_soc, sc.fk_user"; // We need these fields in order to filter by sale (including the case where the user can only see his prospects) + //} + $sql.= " FROM ".MAIN_DB_PREFIX."emailcollector as s"; + + //if ((!$user->rights->societe->client->voir && !$socid) || $search_sale > 0) { + // $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; // We need this table joined to the select in order to filter by sale + //} + //$sql.= ", ".MAIN_DB_PREFIX."c_stcomm as st"; + //$sql.= " WHERE s.fk_stcomm = st.id"; + + // Example of use $mode + //if ($mode == 1) $sql.= " AND s.client IN (1, 3)"; + //if ($mode == 2) $sql.= " AND s.client IN (2, 3)"; + + $sql.= ' WHERE s.entity IN ('.getEntity('emailcollector').')'; + //if ((!$user->rights->societe->client->voir && !$socid) || $search_sale > 0) { + // $sql.= " AND s.fk_soc = sc.fk_soc"; + //} + //if ($socid) { + // $sql.= " AND s.fk_soc = ".$socid; + //} + if ($activeOnly) { + $sql.= " AND s.status = 1"; + } + $sql.= $this->db->order($sortfield, $sortorder); + if ($limit) { + if ($page < 0) { + $page = 0; + } + $offset = $limit * $page; + + $sql.= $this->db->plimit($limit + 1, $offset); + } + + $result = $this->db->query($sql); + + if ($result) { + $num = $this->db->num_rows($result); + while ($i < $num) { + $obj = $this->db->fetch_object($result); + $emailcollector_static = new EmailCollector($this->db); + if ($emailcollector_static->fetch($obj->rowid)) { + $obj_ret[] = $emailcollector_static; + } + $i++; + } + } else { + dol_syslog(__METHOD__.':: Error when retrieve emailcollector list', LOG_ERR); + $ret = -1; + } + if (! count($obj_ret)) { + dol_syslog(__METHOD__.':: No emailcollector found', LOG_DEBUG); + } + + return $obj_ret; + } + + /** + * Update object into database + * + * @param User $user User that modifies + * @param bool $notrigger false=launch triggers after, true=disable triggers + * @return int <0 if KO, >0 if OK + */ + public function update(User $user, $notrigger = false) + { + return $this->updateCommon($user, $notrigger); + } + + /** + * Delete object in database + * + * @param User $user User that deletes + * @param bool $notrigger false=launch triggers after, true=disable triggers + * @return int <0 if KO, >0 if OK + */ + public function delete(User $user, $notrigger = false) + { + return $this->deleteCommon($user, $notrigger); + } + + /** + * Return a link to the object card (with optionaly the picto) + * + * @param int $withpicto Include picto in link (0=No picto, 1=Include picto into link, 2=Only picto) + * @param string $option On what the link point to ('nolink', ...) + * @param int $notooltip 1=Disable tooltip + * @param string $morecss Add more css on link + * @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking + * @return string String with URL + */ + function getNomUrl($withpicto=0, $option='', $notooltip=0, $morecss='', $save_lastsearch_value=-1) + { + global $db, $conf, $langs, $hookmanager; + global $dolibarr_main_authentication, $dolibarr_main_demo; + global $menumanager; + + if (! empty($conf->dol_no_mouse_hover)) $notooltip=1; // Force disable tooltips + + $result = ''; + $companylink = ''; + + $label = '' . $langs->trans("EmailCollector") . ''; + $label.= '
'; + $label.= '' . $langs->trans('Ref') . ': ' . $this->ref; + + $url = dol_buildpath('/admin/emailcollector_card.php', 1).'?id='.$this->id; + + if ($option != 'nolink') + { + // Add param to save lastsearch_values or not + $add_save_lastsearch_values=($save_lastsearch_value == 1 ? 1 : 0); + if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) { + $add_save_lastsearch_values=1; + } + if ($add_save_lastsearch_values) { + $url.='&save_lastsearch_values=1'; + } + } + + $linkclose=''; + if (empty($notooltip)) + { + if (! empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) + { + $label=$langs->trans("ShowEmailCollector"); + $linkclose.=' alt="'.dol_escape_htmltag($label, 1).'"'; + } + $linkclose.=' title="'.dol_escape_htmltag($label, 1).'"'; + $linkclose.=' class="classfortooltip'.($morecss?' '.$morecss:'').'"'; + + /* + $hookmanager->initHooks(array('myobjectdao')); + $parameters=array('id'=>$this->id); + $reshook=$hookmanager->executeHooks('getnomurltooltip',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks + if ($reshook > 0) $linkclose = $hookmanager->resPrint; + */ + } + else $linkclose = ($morecss?' class="'.$morecss.'"':''); + + $linkstart = ''; + $linkend=''; + + $result .= $linkstart; + if ($withpicto) $result.=img_object(($notooltip?'':$label), ($this->picto?$this->picto:'generic'), ($notooltip?(($withpicto != 2) ? 'class="paddingright"' : ''):'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip?0:1); + if ($withpicto != 2) $result.= $this->ref; + $result .= $linkend; + //if ($withpicto != 2) $result.=(($addlabel && $this->label) ? $sep . dol_trunc($this->label, ($addlabel > 1 ? $addlabel : 0)) : ''); + + global $action,$hookmanager; + $hookmanager->initHooks(array('emailcollectordao')); + $parameters=array('id'=>$this->id, 'getnomurl'=>$result); + $reshook=$hookmanager->executeHooks('getNomUrl',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks + if ($reshook > 0) $result = $hookmanager->resPrint; + else $result .= $hookmanager->resPrint; + + return $result; + } + + /** + * Return label of the status + * + * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto, 6=Long label + Picto + * @return string Label of status + */ + public function getLibStatut($mode=0) + { + return $this->LibStatut($this->status, $mode); + } + + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + /** + * Return the status + * + * @param int $status Id status + * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto, 6=Long label + Picto + * @return string Label of status + */ + public function LibStatut($status, $mode=0) + { + // phpcs:enable + if (empty($this->labelstatus)) + { + global $langs; + //$langs->load("mymodule"); + $this->labelstatus[1] = $langs->trans('Enabled'); + $this->labelstatus[0] = $langs->trans('Disabled'); + } + + if ($mode == 0) + { + return $this->labelstatus[$status]; + } + elseif ($mode == 1) + { + return $this->labelstatus[$status]; + } + elseif ($mode == 2) + { + if ($status == 1) return img_picto($this->labelstatus[$status],'statut4').' '.$this->labelstatus[$status]; + elseif ($status == 0) return img_picto($this->labelstatus[$status],'statut5').' '.$this->labelstatus[$status]; + } + elseif ($mode == 3) + { + if ($status == 1) return img_picto($this->labelstatus[$status],'statut4'); + elseif ($status == 0) return img_picto($this->labelstatus[$status],'statut5'); + } + elseif ($mode == 4) + { + if ($status == 1) return img_picto($this->labelstatus[$status],'statut4').' '.$this->labelstatus[$status]; + elseif ($status == 0) return img_picto($this->labelstatus[$status],'statut5').' '.$this->labelstatus[$status]; + } + elseif ($mode == 5) + { + if ($status == 1) return $this->labelstatus[$status].' '.img_picto($this->labelstatus[$status],'statut4'); + elseif ($status == 0) return $this->labelstatus[$status].' '.img_picto($this->labelstatus[$status],'statut5'); + } + elseif ($mode == 6) + { + if ($status == 1) return $this->labelstatus[$status].' '.img_picto($this->labelstatus[$status],'statut4'); + elseif ($status == 0) return $this->labelstatus[$status].' '.img_picto($this->labelstatus[$status],'statut5'); + } + } + + /** + * Charge les informations d'ordre info dans l'objet commande + * + * @param int $id Id of order + * @return void + */ + public function info($id) + { + $sql = 'SELECT rowid, date_creation as datec, tms as datem,'; + $sql.= ' fk_user_creat, fk_user_modif'; + $sql.= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t'; + $sql.= ' WHERE t.rowid = '.$id; + $result=$this->db->query($sql); + if ($result) + { + if ($this->db->num_rows($result)) + { + $obj = $this->db->fetch_object($result); + $this->id = $obj->rowid; + if ($obj->fk_user_author) + { + $cuser = new User($this->db); + $cuser->fetch($obj->fk_user_author); + $this->user_creation = $cuser; + } + + if ($obj->fk_user_valid) + { + $vuser = new User($this->db); + $vuser->fetch($obj->fk_user_valid); + $this->user_validation = $vuser; + } + + if ($obj->fk_user_cloture) + { + $cluser = new User($this->db); + $cluser->fetch($obj->fk_user_cloture); + $this->user_cloture = $cluser; + } + + $this->date_creation = $this->db->jdate($obj->datec); + $this->date_modification = $this->db->jdate($obj->datem); + $this->date_validation = $this->db->jdate($obj->datev); + } + + $this->db->free($result); + } + else + { + dol_print_error($this->db); + } + } + + /** + * Initialise object with example values + * Id must be 0 if object instance is a specimen + * + * @return void + */ + public function initAsSpecimen() + { + $this->initAsSpecimenCommon(); + } + + + /** + * Action executed by scheduler + * CAN BE A CRON TASK. In such a case, paramerts come from the schedule job setup field 'Parameters' + * + * @return int 0 if OK, <>0 if KO (this function is used also by cron so only 0 is OK) + */ + //public function doScheduledJob($param1, $param2, ...) + public function doScheduledJob() + { + global $conf, $langs; + + //$conf->global->SYSLOG_FILE = 'DOL_DATA_ROOT/dolibarr_mydedicatedlofile.log'; + + $error = 0; + $this->output = ''; + $this->error=''; + + dol_syslog(__METHOD__, LOG_DEBUG); + + $now = dol_now(); + + $this->db->begin(); + + // ... + + $this->db->commit(); + + return $error; + } +} diff --git a/htdocs/emailcollector/lib/emailcollector.lib.php b/htdocs/emailcollector/lib/emailcollector.lib.php new file mode 100644 index 00000000000..e7cc3bcb3a0 --- /dev/null +++ b/htdocs/emailcollector/lib/emailcollector.lib.php @@ -0,0 +1,85 @@ +. + */ + +/** + * \file emailcollector/lib/emailcollector.lib.php + * \ingroup emailcollector + * \brief Library files with common functions for EmailCollector + */ + + +/** + * Prepare array of tabs for EmailCollector + * + * @param EmailCollector $object EmailCollector + * @return array Array of tabs + */ +function emailcollectorPrepareHead($object) +{ + global $db, $langs, $conf; + + $langs->load("emailcollector@emailcollector"); + + $h = 0; + $head = array(); + + $head[$h][0] = dol_buildpath("/admin/emailcollector_card.php", 1).'?id='.$object->id; + $head[$h][1] = $langs->trans("Card"); + $head[$h][2] = 'card'; + $h++; + + /*if (isset($object->fields['note_public']) || isset($object->fields['note_private'])) + { + $nbNote = 0; + if (!empty($object->note_private)) $nbNote++; + if (!empty($object->note_public)) $nbNote++; + $head[$h][0] = dol_buildpath('/emailcollector/emailcollector_note.php', 1).'?id='.$object->id; + $head[$h][1] = $langs->trans('Notes'); + if ($nbNote > 0) $head[$h][1].= ' '.$nbNote.''; + $head[$h][2] = 'note'; + $h++; + }*/ + + /*require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; + require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php'; + $upload_dir = $conf->emailcollector->dir_output . "/emailcollector/" . dol_sanitizeFileName($object->ref); + $nbFiles = count(dol_dir_list($upload_dir,'files',0,'','(\.meta|_preview.*\.png)$')); + $nbLinks=Link::count($db, $object->element, $object->id); + $head[$h][0] = dol_buildpath("/emailcollector/emailcollector_document.php", 1).'?id='.$object->id; + $head[$h][1] = $langs->trans('Documents'); + if (($nbFiles+$nbLinks) > 0) $head[$h][1].= ' '.($nbFiles+$nbLinks).''; + $head[$h][2] = 'document'; + $h++; + + $head[$h][0] = dol_buildpath("/emailcollector/emailcollector_agenda.php", 1).'?id='.$object->id; + $head[$h][1] = $langs->trans("Events"); + $head[$h][2] = 'agenda'; + $h++; + */ + + // Show more tabs from modules + // Entries must be declared in modules descriptor with line + //$this->tabs = array( + // 'entity:+tabname:Title:@emailcollector:/emailcollector/mypage.php?id=__ID__' + //); // to add new tab + //$this->tabs = array( + // 'entity:-tabname:Title:@emailcollector:/emailcollector/mypage.php?id=__ID__' + //); // to remove a tab + complete_head_from_modules($conf, $langs, $object, $head, $h, 'emailcollector'); + + return $head; +} diff --git a/htdocs/install/mysql/migration/8.0.0-9.0.0.sql b/htdocs/install/mysql/migration/8.0.0-9.0.0.sql index a7efecbdc5f..5abc1772eef 100644 --- a/htdocs/install/mysql/migration/8.0.0-9.0.0.sql +++ b/htdocs/install/mysql/migration/8.0.0-9.0.0.sql @@ -137,3 +137,46 @@ CREATE TABLE llx_takepos_floor_tables( UPDATE llx_c_payment_term SET decalage = nbjour, nbjour = 0 where decalage IS NULL AND type_cdr = 2; UPDATE llx_holiday SET ref = rowid WHERE ref IS NULL; + + + +CREATE TABLE llx_emailcollector_emailcollector( + -- BEGIN MODULEBUILDER FIELDS + rowid integer AUTO_INCREMENT PRIMARY KEY NOT NULL, + entity integer DEFAULT 1 NOT NULL, + ref varchar(128) NOT NULL, + label varchar(255), + description text, + host varchar(255), + user varchar(128), + password varchar(128), + source_directory varchar(255), + filter text, + actiontodos varchar(255), + target_directory varchar(255), + datelastresult datetime, + lastresult varchar(255), + note_public text, + note_private text, + date_creation datetime NOT NULL, + tms timestamp NOT NULL, + fk_user_creat integer NOT NULL, + fk_user_modif integer, + import_key varchar(14), + status integer NOT NULL, + -- END MODULEBUILDER FIELDS +) ENGINE=innodb; + +-- BEGIN MODULEBUILDER INDEXES +ALTER TABLE llx_emailcollector_emailcollector ADD INDEX idx_emailcollector_rowid (rowid); +ALTER TABLE llx_emailcollector_emailcollector ADD INDEX idx_emailcollector_entity (entity); +ALTER TABLE llx_emailcollector_emailcollector ADD INDEX idx_emailcollector_status (status); +-- END MODULEBUILDER INDEXES + +--ALTER TABLE llx_emailcollector_emailcollector ADD UNIQUE INDEX uk_emailcollector_emailcollector_fieldxyz(fieldx, fieldy); + +--ALTER TABLE llx_emailcollector_emailcollector ADD CONSTRAINT llx_emailcollector_emailcollector_field_id FOREIGN KEY (fk_field) REFERENCES llx_myotherobject(rowid); + + + + diff --git a/htdocs/install/mysql/tables/llx_emailcollector_emailcollector.key.sql b/htdocs/install/mysql/tables/llx_emailcollector_emailcollector.key.sql new file mode 100644 index 00000000000..e2447c206f5 --- /dev/null +++ b/htdocs/install/mysql/tables/llx_emailcollector_emailcollector.key.sql @@ -0,0 +1,26 @@ +-- Copyright (C) 2018 Laurent Destailleur +-- +-- 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 +-- the Free Software Foundation, either version 3 of the License, or +-- (at your option) any later version. +-- +-- This program is distributed in the hope that it will be useful, +-- but WITHOUT ANY WARRANTY; without even the implied warranty of +-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +-- GNU General Public License for more details. +-- +-- You should have received a copy of the GNU General Public License +-- along with this program. If not, see http://www.gnu.org/licenses/. + + +-- BEGIN MODULEBUILDER INDEXES +ALTER TABLE llx_emailcollector_emailcollector ADD INDEX idx_emailcollector_rowid (rowid); +ALTER TABLE llx_emailcollector_emailcollector ADD INDEX idx_emailcollector_entity (entity); +ALTER TABLE llx_emailcollector_emailcollector ADD INDEX idx_emailcollector_status (status); +-- END MODULEBUILDER INDEXES + +--ALTER TABLE llx_emailcollector_emailcollector ADD UNIQUE INDEX uk_emailcollector_emailcollector_fieldxyz(fieldx, fieldy); + +--ALTER TABLE llx_emailcollector_emailcollector ADD CONSTRAINT llx_emailcollector_emailcollector_field_id FOREIGN KEY (fk_field) REFERENCES llx_myotherobject(rowid); + diff --git a/htdocs/install/mysql/tables/llx_emailcollector_emailcollector.sql b/htdocs/install/mysql/tables/llx_emailcollector_emailcollector.sql new file mode 100644 index 00000000000..98426cd85a7 --- /dev/null +++ b/htdocs/install/mysql/tables/llx_emailcollector_emailcollector.sql @@ -0,0 +1,42 @@ +-- Copyright (C) 2018 Laurent Destailleur +-- +-- 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 +-- the Free Software Foundation, either version 3 of the License, or +-- (at your option) any later version. +-- +-- This program is distributed in the hope that it will be useful, +-- but WITHOUT ANY WARRANTY; without even the implied warranty of +-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +-- GNU General Public License for more details. +-- +-- You should have received a copy of the GNU General Public License +-- along with this program. If not, see http://www.gnu.org/licenses/. + + +CREATE TABLE llx_emailcollector_emailcollector( + -- BEGIN MODULEBUILDER FIELDS + rowid integer AUTO_INCREMENT PRIMARY KEY NOT NULL, + entity integer DEFAULT 1 NOT NULL, + ref varchar(128) NOT NULL, + label varchar(255), + description text, + host varchar(255), + user varchar(128), + password varchar(128), + source_directory varchar(255), + filter text, + actiontodo varchar(255), + target_directory varchar(255), + datelastresult datetime, + lastresult varchar(255), + note_public text, + note_private text, + date_creation datetime NOT NULL, + tms timestamp NOT NULL, + fk_user_creat integer NOT NULL, + fk_user_modif integer, + import_key varchar(14), + status integer NOT NULL, + -- END MODULEBUILDER FIELDS +) ENGINE=innodb; diff --git a/htdocs/modulebuilder/template/class/myobject.class.php b/htdocs/modulebuilder/template/class/myobject.class.php index 706b90f6eac..71446c53211 100644 --- a/htdocs/modulebuilder/template/class/myobject.class.php +++ b/htdocs/modulebuilder/template/class/myobject.class.php @@ -98,7 +98,7 @@ class MyObject extends CommonObject 'fk_user_modif' =>array('type'=>'integer', 'label'=>'UserModif', 'enabled'=>1, 'visible'=>-2, 'notnull'=>-1, 'position'=>511), //'fk_user_valid' =>array('type'=>'integer', 'label'=>'UserValidation', 'enabled'=>1, 'visible'=>-1, 'position'=>512), 'import_key' =>array('type'=>'varchar(14)', 'label'=>'ImportId', 'enabled'=>1, 'visible'=>-2, 'notnull'=>-1, 'index'=>0, 'position'=>1000), - 'status' =>array('type'=>'integer', 'label'=>'Status', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'default'=>0, 'index'=>1, 'position'=>1000, 'arrayofkeyval'=>array(0=>'Draft', 1=>'Active', -1=>'Cancel')), + 'status' =>array('type'=>'integer', 'label'=>'Status', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'default'=>0, 'index'=>1, 'position'=>1000, 'arrayofkeyval'=>array(0=>'Draft', 1=>'Active', -1=>'Canceled')), ); /** @@ -198,8 +198,17 @@ class MyObject extends CommonObject } } - // Translate some data - $this->fields['status']['arrayofkeyval']=array(0=>$langs->trans('Draft'), 1=>$langs->trans('Active'), -1=>$langs->trans('Cancel')); + // Translate some data of arrayofkeyval + foreach($this->fields as $key => $val) + { + if (is_array($this->fields['status']['arrayofkeyval'])) + { + foreach($this->fields['status']['arrayofkeyval'] as $key2 => $val2) + { + $this->fields['status']['arrayofkeyval'][$key2]=$langs->trans($val2); + } + } + } } /** diff --git a/htdocs/modulebuilder/template/myobject_card.php b/htdocs/modulebuilder/template/myobject_card.php index 81715228033..2fd970a33a4 100644 --- a/htdocs/modulebuilder/template/myobject_card.php +++ b/htdocs/modulebuilder/template/myobject_card.php @@ -347,7 +347,6 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea print ''; print '
'; print '
'; - print '
'; print '

'; diff --git a/htdocs/modulebuilder/template/myobject_list.php b/htdocs/modulebuilder/template/myobject_list.php index ece26aba6cb..beb03c183a6 100644 --- a/htdocs/modulebuilder/template/myobject_list.php +++ b/htdocs/modulebuilder/template/myobject_list.php @@ -292,7 +292,7 @@ if ($num == 1 && ! empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && { $obj = $db->fetch_object($resql); $id = $obj->rowid; - header("Location: ".DOL_URL_ROOT.'/mymodule/myobject_card.php?id='.$id); + header("Location: ".dol_buildpath('/mymodule/myobject_card.php', 1).'?id='.$id); exit; } @@ -352,7 +352,7 @@ print ''; $newcardbutton=''; //if ($user->rights->mymodule->creer) //{ - $newcardbutton=''.$langs->trans('New').''; + $newcardbutton=''.$langs->trans('New').''; $newcardbutton.= ''; $newcardbutton.= ''; //} From aa8236dd9840e2e42ef359420b31329d05695a93 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Wed, 31 Oct 2018 21:33:37 +0100 Subject: [PATCH 021/132] fix phpcs --- htdocs/emailcollector/class/emailcollector.class.php | 11 ++++++++--- .../modulebuilder/template/class/myobject.class.php | 2 +- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/htdocs/emailcollector/class/emailcollector.class.php b/htdocs/emailcollector/class/emailcollector.class.php index 4a7986e5d8a..471058e6b8d 100644 --- a/htdocs/emailcollector/class/emailcollector.class.php +++ b/htdocs/emailcollector/class/emailcollector.class.php @@ -302,8 +302,13 @@ class EmailCollector extends CommonObject /** * Fetch all account and load objects into an array * - * @return array Array with key => EmailCollector object - * @author + * @param User $user User + * @param int $activeOnly filter if active + * @param string $sortfield field for sorting + * @param string $sortorder sorting order + * @param int $limit sort limit + * @param int $page page to start on + * @return array Array with key => EmailCollector object */ public function fetchAll(User $user, $activeOnly = 0, $sortfield = 's.rowid', $sortorder = 'ASC', $limit = 100, $page = 0) { @@ -490,7 +495,7 @@ class EmailCollector extends CommonObject return $this->LibStatut($this->status, $mode); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return the status * diff --git a/htdocs/modulebuilder/template/class/myobject.class.php b/htdocs/modulebuilder/template/class/myobject.class.php index 71446c53211..58dfe5924cf 100644 --- a/htdocs/modulebuilder/template/class/myobject.class.php +++ b/htdocs/modulebuilder/template/class/myobject.class.php @@ -424,7 +424,7 @@ class MyObject extends CommonObject return $this->LibStatut($this->status, $mode); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return the status * From af1305a0a878a1cc5dd9ca4c20a8557f033f9ce6 Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Thu, 1 Nov 2018 07:24:48 +0100 Subject: [PATCH 022/132] Fix Specific finename for FEC export only available on general ledger export --- htdocs/accountancy/bookkeeping/balance.php | 1 + htdocs/accountancy/class/accountancyexport.class.php | 1 + htdocs/accountancy/journal/bankjournal.php | 1 + htdocs/accountancy/journal/expensereportsjournal.php | 1 + htdocs/accountancy/journal/purchasesjournal.php | 1 + htdocs/accountancy/journal/sellsjournal.php | 1 + htdocs/accountancy/tpl/export_journal.tpl.php | 3 +-- 7 files changed, 7 insertions(+), 2 deletions(-) diff --git a/htdocs/accountancy/bookkeeping/balance.php b/htdocs/accountancy/bookkeeping/balance.php index 9feb2a7c234..9b9598074cb 100644 --- a/htdocs/accountancy/bookkeeping/balance.php +++ b/htdocs/accountancy/bookkeeping/balance.php @@ -151,6 +151,7 @@ if ($action == 'export_csv') $sep = $conf->global->ACCOUNTING_EXPORT_SEPARATORCSV; $filename = 'balance'; + $type_export = 'balance'; include DOL_DOCUMENT_ROOT . '/accountancy/tpl/export_journal.tpl.php'; $result = $object->fetchAllBalance($sortorder, $sortfield, 0, 0, $filter); diff --git a/htdocs/accountancy/class/accountancyexport.class.php b/htdocs/accountancy/class/accountancyexport.class.php index 7b832976e89..5d76a7155d6 100644 --- a/htdocs/accountancy/class/accountancyexport.class.php +++ b/htdocs/accountancy/class/accountancyexport.class.php @@ -218,6 +218,7 @@ class AccountancyExport // Define name of file to save $filename = 'general_ledger-'.$this->getFormatCode($conf->global->ACCOUNTING_EXPORT_MODELCSV); + $type_export = 'general_ledger'; include DOL_DOCUMENT_ROOT . '/accountancy/tpl/export_journal.tpl.php'; diff --git a/htdocs/accountancy/journal/bankjournal.php b/htdocs/accountancy/journal/bankjournal.php index 3b86835e927..da974af644e 100644 --- a/htdocs/accountancy/journal/bankjournal.php +++ b/htdocs/accountancy/journal/bankjournal.php @@ -750,6 +750,7 @@ if ($action == 'exportcsv') { // ISO and not UTF8 ! $sep = $conf->global->ACCOUNTING_EXPORT_SEPARATORCSV; $filename = 'journal'; + $type_export = 'journal'; include DOL_DOCUMENT_ROOT . '/accountancy/tpl/export_journal.tpl.php'; // CSV header line diff --git a/htdocs/accountancy/journal/expensereportsjournal.php b/htdocs/accountancy/journal/expensereportsjournal.php index 9c39016f008..182be61d61c 100644 --- a/htdocs/accountancy/journal/expensereportsjournal.php +++ b/htdocs/accountancy/journal/expensereportsjournal.php @@ -429,6 +429,7 @@ $userstatic = new User($db); $sep = $conf->global->ACCOUNTING_EXPORT_SEPARATORCSV; $filename = 'journal'; + $type_export = 'journal'; include DOL_DOCUMENT_ROOT . '/accountancy/tpl/export_journal.tpl.php'; // Model Cegid Expert Export diff --git a/htdocs/accountancy/journal/purchasesjournal.php b/htdocs/accountancy/journal/purchasesjournal.php index beb9891276f..034348fbee8 100644 --- a/htdocs/accountancy/journal/purchasesjournal.php +++ b/htdocs/accountancy/journal/purchasesjournal.php @@ -586,6 +586,7 @@ if ($action == 'exportcsv') { // ISO and not UTF8 ! $sep = $conf->global->ACCOUNTING_EXPORT_SEPARATORCSV; $filename = 'journal'; + $type_export = 'journal'; include DOL_DOCUMENT_ROOT . '/accountancy/tpl/export_journal.tpl.php'; $companystatic = new Fournisseur($db); diff --git a/htdocs/accountancy/journal/sellsjournal.php b/htdocs/accountancy/journal/sellsjournal.php index ee7d45d6c66..b4a364cd912 100644 --- a/htdocs/accountancy/journal/sellsjournal.php +++ b/htdocs/accountancy/journal/sellsjournal.php @@ -547,6 +547,7 @@ if ($action == 'exportcsv') { // ISO and not UTF8 ! $sep = $conf->global->ACCOUNTING_EXPORT_SEPARATORCSV; $filename = 'journal'; + $type_export = 'journal'; include DOL_DOCUMENT_ROOT . '/accountancy/tpl/export_journal.tpl.php'; $companystatic = new Client($db); diff --git a/htdocs/accountancy/tpl/export_journal.tpl.php b/htdocs/accountancy/tpl/export_journal.tpl.php index d0d902770c0..ca3c9c49ea0 100644 --- a/htdocs/accountancy/tpl/export_journal.tpl.php +++ b/htdocs/accountancy/tpl/export_journal.tpl.php @@ -35,9 +35,8 @@ $endaccountingperiod = dol_print_date(dol_now(), '%Y%m%d'); header('Content-Type: text/csv'); -if ($conf->global->ACCOUNTING_EXPORT_MODELCSV == "11") // Specific filename for FEC model export +if ($conf->global->ACCOUNTING_EXPORT_MODELCSV == "11" && $type_export == "general_ledger") // Specific filename for FEC model export into the general ledger { - // FEC format is defined here: https://www.legifrance.gouv.fr/affichCodeArticle.do?idArticle=LEGIARTI000027804775&cidTexte=LEGITEXT000006069583&dateTexte=20130802&oldAction=rechCodeArticle if (empty($search_date_end)) { From b7f5e9e6c7d0a51b6eb7fb159c509361ddf373c0 Mon Sep 17 00:00:00 2001 From: Philippe GRAND Date: Thu, 1 Nov 2018 11:50:55 +0100 Subject: [PATCH 023/132] complete comment --- htdocs/societe/class/societe.class.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index dd1aada283b..96e1ebb415f 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -13,6 +13,7 @@ * Copyright (C) 2014-2015 Marcos García * Copyright (C) 2015 Raphaël Doursenaud * Copyright (C) 2017 Rui Strecht + * Copyright (C) 2018 Philippe Grand * * 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 @@ -3827,6 +3828,7 @@ class Societe extends CommonObject * * @return int Amount in debt for thirdparty * @deprecated + * @see getOutstandingBills() */ function get_OutstandingBill() { From 114073555446e0fe6179a0a9cc1aab1e807b0e35 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 1 Nov 2018 15:20:05 +0100 Subject: [PATCH 024/132] Fix css --- htdocs/theme/eldy/style.css.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/theme/eldy/style.css.php b/htdocs/theme/eldy/style.css.php index cc1da092523..e2b87857c95 100644 --- a/htdocs/theme/eldy/style.css.php +++ b/htdocs/theme/eldy/style.css.php @@ -894,7 +894,8 @@ div.fiche { min-width: 150px; } .thumbstat150 { - min-width: 170px; + /* min-width: 170px; */ + width: 170px; } .thumbstat, .thumbstat150 { browser->name == 'ie') { ?> From d1133916e0041406b7341a8fb6888d925c74bb8f Mon Sep 17 00:00:00 2001 From: Maxime Kohlhaas Date: Thu, 1 Nov 2018 15:33:14 +0100 Subject: [PATCH 025/132] Fix tracking field in dictionnary should not be mandatory --- htdocs/admin/dict.php | 2 +- htdocs/install/mysql/migration/6.0.0-7.0.0.sql | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/htdocs/admin/dict.php b/htdocs/admin/dict.php index 72ac51e1799..c62595ea8a6 100644 --- a/htdocs/admin/dict.php +++ b/htdocs/admin/dict.php @@ -629,7 +629,7 @@ if (GETPOST('actionadd') || GETPOST('actionmodify')) if ($value == 'formula' && empty($_POST['formula'])) continue; if ($value == 'sortorder') continue; // For a column name 'sortorder', we use the field name 'position' if ((! isset($_POST[$value]) || $_POST[$value]=='') - && (! in_array($listfield[$f], array('decalage','module','accountancy_code','accountancy_code_sell','accountancy_code_buy')) // Fields that are not mandatory + && (! in_array($listfield[$f], array('decalage','module','accountancy_code','accountancy_code_sell','accountancy_code_buy','tracking')) // Fields that are not mandatory && (! ($id == 10 && $listfield[$f] == 'code')) // Code is mandatory fir table 10 ) ) diff --git a/htdocs/install/mysql/migration/6.0.0-7.0.0.sql b/htdocs/install/mysql/migration/6.0.0-7.0.0.sql index c2e17386488..354bf0743bd 100644 --- a/htdocs/install/mysql/migration/6.0.0-7.0.0.sql +++ b/htdocs/install/mysql/migration/6.0.0-7.0.0.sql @@ -716,3 +716,5 @@ ALTER TABLE llx_facture_rec_extrafields ADD INDEX idx_facture_rec_extrafields (f UPDATE llx_cronjob set entity = 1 where entity = 0 and label in ('RecurringInvoices', 'SendEmailsReminders'); UPDATE llx_cronjob set entity = 0 where entity = 1 and label in ('PurgeDeleteTemporaryFilesShort', 'MakeLocalDatabaseDumpShort'); + +ALTER TABLE llx_c_shipment_mode CHANGE COLUMN tracking tracking VARCHAR(255) DEFAULT NULL; \ No newline at end of file From 29c0448a2ed9bc78543b10b0da15778e3c3469c0 Mon Sep 17 00:00:00 2001 From: Maxime Kohlhaas Date: Thu, 1 Nov 2018 15:41:58 +0100 Subject: [PATCH 026/132] Fix parent link was not removed on societe deletion #9106 --- htdocs/societe/class/societe.class.php | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index 2a488aacf44..0a49bb80f1b 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -1518,6 +1518,19 @@ class Societe extends CommonObject dol_syslog(get_class($this)."::delete error -3 ".$this->error, LOG_ERR); } } + + // Remove links to subsidiaries companies + if (! $error) + { + $sql = "UPDATE ".MAIN_DB_PREFIX."societe"; + $sql.= " SET parent = NULL"; + $sql.= " WHERE parent = " . $id; + if (! $this->db->query($sql)) + { + $error++; + $this->errors[] = $this->db->lasterror(); + } + } // Remove third party if (! $error) From 263e8ed4afc601f80916349e5360c7b5d9a48005 Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Thu, 1 Nov 2018 20:45:08 +0100 Subject: [PATCH 027/132] Fix payout --- htdocs/public/stripe/ipn.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/public/stripe/ipn.php b/htdocs/public/stripe/ipn.php index ad6aee43bd4..ac366da9210 100644 --- a/htdocs/public/stripe/ipn.php +++ b/htdocs/public/stripe/ipn.php @@ -66,6 +66,7 @@ else { $servicestatus = 1; } } + $payload = @file_get_contents("php://input"); $sig_header = $_SERVER["HTTP_STRIPE_SIGNATURE"]; $event = null; @@ -159,7 +160,7 @@ elseif ($event->type == 'payout.paid') { $accountfrom->fetch($conf->global->STRIPE_BANK_ACCOUNT_FOR_PAYMENTS); $accountto=new Account($db); - $accountto->fetch($conf->global->STRIPE_BANK_ACCOUNT_FOR_BANKTRANFERS); + $accountto->fetch($conf->global->STRIPE_BANK_ACCOUNT_FOR_BANKTRANSFERS); if ($accountto->currency_code != $accountfrom->currency_code) { $error++; @@ -353,4 +354,3 @@ elseif ($event->type == 'customer.deleted') { $db->query($sql); $db->commit(); } - From 8d8023b405517f01c9dac02c3b3ee304717a7a3c Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Thu, 1 Nov 2018 22:32:33 +0100 Subject: [PATCH 028/132] Debug asset module --- htdocs/asset/class/asset_type.class.php | 13 +- htdocs/asset/type.php | 289 ++++-------------------- htdocs/langs/en_US/assets.lang | 7 + 3 files changed, 55 insertions(+), 254 deletions(-) diff --git a/htdocs/asset/class/asset_type.class.php b/htdocs/asset/class/asset_type.class.php index 8eb915f95eb..51d76d75155 100644 --- a/htdocs/asset/class/asset_type.class.php +++ b/htdocs/asset/class/asset_type.class.php @@ -42,7 +42,7 @@ class AssetType extends CommonObject /** * @var string String with name of icon for myobject. Must be the part after the 'object_' into object_myobject.png */ - public $picto = 'group'; + public $picto = 'invoice'; /** * 0=No test on entity, 1=Test with field entity, 2=Test with link by societe @@ -51,9 +51,9 @@ class AssetType extends CommonObject public $ismultientitymanaged = 1; /** - * @var string Asset type label - */ - public $label; + * @var string Asset type label + */ + public $label; /** @var string Accountancy code asset */ public $accountancy_code_asset; @@ -107,12 +107,14 @@ class AssetType extends CommonObject $sql.= ", accountancy_code_asset"; $sql.= ", accountancy_code_depreciation_asset"; $sql.= ", accountancy_code_depreciation_expense"; + $sql.= ", note"; $sql.= ", entity"; $sql.= ") VALUES ("; $sql.= "'".$this->db->escape($this->label)."'"; $sql.= ", '".$this->db->escape($this->accountancy_code_asset)."'"; $sql.= ", '".$this->db->escape($this->accountancy_code_depreciation_asset)."'"; $sql.= ", '".$this->db->escape($this->accountancy_code_depreciation_expense)."'"; + $sql.= ", '".$this->db->escape($this->note)."'"; $sql.= ", ".$conf->entity; $sql.= ")"; @@ -179,7 +181,8 @@ class AssetType extends CommonObject $sql.= "label = '".$this->db->escape($this->label) ."',"; $sql.= "accountancy_code_asset = '".$this->db->escape($this->accountancy_code_asset)."',"; $sql.= "accountancy_code_depreciation_asset = '".$this->db->escape($this->accountancy_code_depreciation_asset)."',"; - $sql.= "accountancy_code_depreciation_expense = '".$this->db->escape($this->accountancy_code_depreciation_expense)."'"; + $sql.= "accountancy_code_depreciation_expense = '".$this->db->escape($this->accountancy_code_depreciation_expense)."',"; + $sql.= "note = '".$this->db->escape($this->note) ."'"; $sql.= " WHERE rowid =".$this->id; $result = $this->db->query($sql); diff --git a/htdocs/asset/type.php b/htdocs/asset/type.php index 9e06c4a765d..ea8a4502264 100644 --- a/htdocs/asset/type.php +++ b/htdocs/asset/type.php @@ -49,10 +49,13 @@ $offset = $limit * $page ; $pageprev = $page - 1; $pagenext = $page + 1; if (! $sortorder) { $sortorder="DESC"; } -if (! $sortfield) { $sortfield="d.lastname"; } +if (! $sortfield) { $sortfield="a.label"; } $label=GETPOST("label","alpha"); -$comment=GETPOST("comment"); +$accountancy_code_asset=GETPOST('accountancy_code_asset','string'); +$accountancy_code_depreciation_asset=GETPOST('accountancy_code_depreciation_asset','string'); +$accountancy_code_depreciation_expense=GETPOST('accountancy_code_depreciation_expense','string'); +$comment=GETPOST('comment','string'); // Security check $result=restrictedArea($user,'asset',$rowid,'asset_type'); @@ -259,39 +262,39 @@ if (! $rowid && $action != 'create' && $action != 'edit') print ''; print ''.dol_escape_htmltag($objp->label).''; - print ''; + print ''; if (! empty($conf->accounting->enabled)) { $accountingaccount = new AccountingAccount($db); - $accountingaccount->fetch('',$object->accountancy_code_asset,1); + $accountingaccount->fetch('',$objp->accountancy_code_asset,1); - print $accountingaccount->getNomUrl(0,1,1,'',1); + print $accountingaccount->getNomUrl(0,0,0,'',0); } else { - print $object->accountancy_code_asset; + print $objp->accountancy_code_asset; } print ''; - print ''; + print ''; if (! empty($conf->accounting->enabled)) { $accountingaccount2 = new AccountingAccount($db); - $accountingaccount2->fetch('',$object->accountancy_code_depreciation_asset,1); + $accountingaccount2->fetch('',$objp->accountancy_code_depreciation_asset,1); - print $accountingaccount2->getNomUrl(0,1,1,'',1); + print $accountingaccount2->getNomUrl(0,0,0,'',0); } else { - print $object->accountancy_code_depreciation_asset; + print $objp->accountancy_code_depreciation_asset; } print ''; - print ''; + print ''; if (! empty($conf->accounting->enabled)) { $accountingaccount3 = new AccountingAccount($db); - $accountingaccount3->fetch('',$object->accountancy_code_depreciation_expense,1); + $accountingaccount3->fetch('',$objp->accountancy_code_depreciation_expense,1); - print $accountingaccount3->getNomUrl(0,1,1,'',1); + print $accountingaccount3->getNomUrl(0,0,0,'',0); } else { - print $object->accountancy_code_depreciation_expense; + print $objp->accountancy_code_depreciation_expense; } print ''; @@ -418,7 +421,7 @@ if ($rowid > 0) */ if ($action == 'delete') { - print $form->formconfirm($_SERVER['PHP_SELF']."?rowid=".$object->id,$langs->trans("DeleteAMemberType"),$langs->trans("ConfirmDeleteMemberType",$object->label),"confirm_delete", '',0,1); + print $form->formconfirm($_SERVER['PHP_SELF']."?rowid=".$object->id,$langs->trans("DeleteAnAssetType"),$langs->trans("ConfirmDeleteAssetType",$object->label),"confirm_delete", '',0,1); } $head = asset_type_prepare_head($object); @@ -427,14 +430,23 @@ if ($rowid > 0) $linkback = ''.$langs->trans("BackToList").''; - dol_banner_tab($object, 'rowid', $linkback); + $morehtmlref='
'; + // Ref asset type + $morehtmlref.=$form->editfieldkey("Label", 'label', $object->label, $object, $user->rights->asset->write, 'string', '', 0, 1); + $morehtmlref.=$form->editfieldval("Label", 'label', $object->label, $object, $user->rights->asset->write, 'string', '', null, null, '', 1); + $morehtmlref.='
'; + + dol_banner_tab($object, 'rowid', $linkback, 1, 'rowid', 'ref', $morehtmlref, '', 0, '', $morehtmlright); print '
'; print '
'; print ''; - print ''; + print ''; + print ''; + print ''; - print ''; + print ''; + print ''; - print ''; + print ''; print ''; print ''; - - print '
'; - print_barre_liste('',$page,$_SERVER["PHP_SELF"],$param,$sortfield,$sortorder,'',$num,$nbtotalofrecords); - - $moreforfilter = ''; - - print '
'; - print '
'; + print $langs->trans("AccountancyCodeAsset"); + print ''; if (! empty($conf->accounting->enabled)) { $accountingaccount = new AccountingAccount($db); @@ -445,8 +457,12 @@ if ($rowid > 0) print $object->accountancy_code_asset; } print '
'; + print '
'; + print $langs->trans("AccountancyCodeDepreciationAsset"); + print ''; if (! empty($conf->accounting->enabled)) { $accountingaccount2 = new AccountingAccount($db); @@ -457,8 +473,12 @@ if ($rowid > 0) print $object->accountancy_code_depreciation_asset; } print '
'; + print '
'; + print $langs->trans("AccountancyCodeDepreciationExpense"); + print ''; if (! empty($conf->accounting->enabled)) { $accountingaccount3 = new AccountingAccount($db); @@ -468,6 +488,7 @@ if ($rowid > 0) } else { print $object->accountancy_code_depreciation_expense; } + print '
'.$langs->trans("Description").''; @@ -493,9 +514,6 @@ if ($rowid > 0) print ''; } - // Add - print ''; - // Delete if ($user->rights->asset->write) { @@ -504,233 +522,6 @@ if ($rowid > 0) print ""; - - // Show list of assets (nearly same code than in page list.php) - $assettypestatic=new AssetType($db); - - $now=dol_now(); - - $sql = "SELECT a.rowid, d.login, d.firstname, d.lastname, d.societe, "; - $sql.= " d.datefin,"; - $sql.= " a.fk_asset_type as type_id,"; - $sql.= " t.label as type"; - $sql.= " FROM ".MAIN_DB_PREFIX."asset as a, ".MAIN_DB_PREFIX."asset_type as t"; - $sql.= " WHERE a.fk_asset_type = t.rowid"; - $sql.= " AND a.entity IN (".getEntity('asset').")"; - $sql.= " AND t.rowid = ".$object->id; - if ($sall) - { - $sql.=natural_search(array("f.firstname","d.lastname","d.societe","d.email","d.login","d.address","d.town","d.note_public","d.note_private"), $sall); - } - if ($status != '') - { - $sql.= natural_search('d.statut', $status, 2); - } - if ($action == 'search') - { - if (GETPOST('search','alpha')) - { - $sql.= natural_search(array("d.firstname","d.lastname"), GETPOST('search','alpha')); - } - } - if (! empty($search_lastname)) - { - $sql.= natural_search(array("d.firstname","d.lastname"), $search_lastname); - } - if (! empty($search_login)) - { - $sql.= natural_search("d.login", $search_login); - } - if (! empty($search_email)) - { - $sql.= natural_search("d.email", $search_email); - } - if ($filter == 'uptodate') - { - $sql.=" AND datefin >= '".$db->idate($now)."'"; - } - if ($filter == 'outofdate') - { - $sql.=" AND datefin < '".$db->idate($now)."'"; - } - - $sql.= " ".$db->order($sortfield,$sortorder); - - // Count total nb of records - $nbtotalofrecords = ''; - if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) - { - $resql = $db->query($sql); - if ($resql) $nbtotalofrecords = $db->num_rows($result); - else dol_print_error($db); - if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0 - { - $page = 0; - $offset = 0; - } - } - - $sql.= " ".$db->plimit($conf->liste_limit+1, $offset); - - $resql = $db->query($sql); - if ($resql) - { - $num = $db->num_rows($resql); - $i = 0; - - $titre=$langs->trans("AssetsList"); - if ($status != '') - { - if ($status == '-1,1') { $titre=$langs->trans("MembersListQualified"); } - else if ($status == '-1') { $titre=$langs->trans("MembersListToValid"); } - else if ($status == '1' && ! $filter) { $titre=$langs->trans("MembersListValid"); } - else if ($status == '1' && $filter=='uptodate') { $titre=$langs->trans("MembersListUpToDate"); } - else if ($status == '1' && $filter=='outofdate') { $titre=$langs->trans("MembersListNotUpToDate"); } - else if ($status == '0') { $titre=$langs->trans("MembersListResiliated"); } - } - elseif ($action == 'search') - { - $titre=$langs->trans("MembersListQualified"); - } - - if ($type > 0) - { - $assettype=new AssetType($db); - $result=$assettype->fetch($type); - $titre.=" (".$assettype->label.")"; - } - - $param="&rowid=".$object->id; - if (! empty($status)) $param.="&status=".$status; - if (! empty($search_lastname)) $param.="&search_lastname=".$search_lastname; - if (! empty($search_firstname)) $param.="&search_firstname=".$search_firstname; - if (! empty($search_login)) $param.="&search_login=".$search_login; - if (! empty($search_email)) $param.="&search_email=".$search_email; - if (! empty($filter)) $param.="&filter=".$filter; - - if ($sall) - { - print $langs->trans("Filter")." (".$langs->trans("Lastname").", ".$langs->trans("Firstname").", ".$langs->trans("EMail").", ".$langs->trans("Address")." ".$langs->trans("or")." ".$langs->trans("Town")."): ".$sall; - } - - print '
'; - print '
'."\n"; - - // Lignes des champs de filtre - print ''; - - print ''; - - print ''; - - print ''; - - print ''; - - print ''; - - print ''; - - print "\n"; - - print ''; - print_liste_field_titre( $langs->trans("Name")." / ".$langs->trans("Company"),$_SERVER["PHP_SELF"],"d.lastname",$param,"","",$sortfield,$sortorder); - print_liste_field_titre("Login",$_SERVER["PHP_SELF"],"d.login",$param,"","",$sortfield,$sortorder); - print_liste_field_titre("Nature",$_SERVER["PHP_SELF"],"d.morphy",$param,"","",$sortfield,$sortorder); - print_liste_field_titre("EMail",$_SERVER["PHP_SELF"],"d.email",$param,"","",$sortfield,$sortorder); - print_liste_field_titre("Status",$_SERVER["PHP_SELF"],"d.statut,d.datefin",$param,"","",$sortfield,$sortorder); - print_liste_field_titre("EndSubscription",$_SERVER["PHP_SELF"],"d.datefin",$param,"",'align="center"',$sortfield,$sortorder); - print_liste_field_titre("Action",$_SERVER["PHP_SELF"],"",$param,"",'width="60" align="center"',$sortfield,$sortorder); - print "\n"; - - while ($i < $num && $i < $conf->liste_limit) - { - $objp = $db->fetch_object($resql); - - $datefin=$db->jdate($objp->datefin); - - $adh=new Asset($db); - $adh->lastname=$objp->lastname; - $adh->firstname=$objp->firstname; - - // Lastname - print ''; - if ($objp->societe != '') - { - print ''."\n"; - } - else - { - print ''."\n"; - } - - // Login - print "\n"; - - // Type - /*print ''; - */ - - // Moral/Physique - print "\n"; - - // EMail - print "\n"; - - // Statut - print '"; - - // Actions - print '"; - - print "\n"; - $i++; - } - - print "
'; - print ''; - print ' '; - print ' '; - print ''; - print '  '; - print ''; - print '
'.img_object($langs->trans("ShowMember"),"user").' '.$adh->getFullName($langs,0,-1,20).' / '.dol_trunc($objp->societe,12).''.img_object($langs->trans("ShowMember"),"user").' '.$adh->getFullName($langs,0,-1,32).'".$objp->login."'; - $assettypestatic->id=$objp->type_id; - $assettypestatic->label=$objp->type; - print $assettypestatic->getNomUrl(1,12); - print '".$adh->getmorphylib($objp->morphy)."".dol_print_email($objp->email,0,0,1)."'; - print $adh->LibStatut($objp->statut,$objp->subscription,$datefin,2); - print "'; - if ($user->rights->asset->creer) - { - print ''.img_edit().''; - } - print ' '; - if ($user->rights->asset->supprimer) - { - print ''.img_picto($langs->trans("Resiliate"),'disable.png').''; - } - print "
\n"; - print '
'; - print ''; - - if ($num > $conf->liste_limit) - { - print_barre_liste('',$page,$_SERVER["PHP_SELF"],$param,$sortfield,$sortorder,'',$num,$nbtotalofrecords,''); - } - } - else - { - dol_print_error($db); - } } /* ************************************************************************** */ diff --git a/htdocs/langs/en_US/assets.lang b/htdocs/langs/en_US/assets.lang index 0f955fe19ce..b780fb6fcba 100644 --- a/htdocs/langs/en_US/assets.lang +++ b/htdocs/langs/en_US/assets.lang @@ -22,7 +22,14 @@ AccountancyCodeAsset = Accounting code (asset) AccountancyCodeDepreciationAsset = Accounting code (depreciation asset account) AccountancyCodeDepreciationExpense = Accounting code (depreciation expense account) NewAssetType=New asset type +AssetsTypeSetup=Assets type setup +AssetTypeModified=Asset type modified +AssetType=Asset type AssetsLines=Assets +DeleteType=Delete +DeleteAnAssetType=Delete an asset type +ConfirmDeleteAssetType=Are you sure you want to delete this asset type? +ShowTypeCard=Show type '%s' # Module label 'ModuleAssetsName' ModuleAssetsName = Assets From b34f78168664bc9e90be07b61ac357ac43248966 Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Thu, 1 Nov 2018 23:04:10 +0100 Subject: [PATCH 029/132] Fix ext_payment_site --- htdocs/public/payment/paymentok.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/public/payment/paymentok.php b/htdocs/public/payment/paymentok.php index 36723658946..e1cd70e4a91 100644 --- a/htdocs/public/payment/paymentok.php +++ b/htdocs/public/payment/paymentok.php @@ -631,7 +631,7 @@ if ($ispaymentok) $paiement->num_paiement = ''; $paiement->note_public = 'Online payment '.dol_print_date($now, 'standard').' from '.$ipaddress; $paiement->ext_payment_id = $TRANSACTIONID; - $paiement->ext_payment_site = $paymentmethod; + $paiement->ext_payment_site = $service; if (! $error) { From d5a910841f491d8cb09eea983f8c0d0e372e96f5 Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Thu, 1 Nov 2018 23:20:28 +0100 Subject: [PATCH 030/132] Fix various fix cmail, payout, const, connect --- htdocs/public/stripe/ipn.php | 71 +++++++++++++++++++++++------------- 1 file changed, 46 insertions(+), 25 deletions(-) diff --git a/htdocs/public/stripe/ipn.php b/htdocs/public/stripe/ipn.php index 45fd6489f92..28d809532d5 100644 --- a/htdocs/public/stripe/ipn.php +++ b/htdocs/public/stripe/ipn.php @@ -22,7 +22,9 @@ define("NOCSRFCHECK",1); // We accept to go on this page from external web site. $entity=(! empty($_GET['entity']) ? (int) $_GET['entity'] : (! empty($_POST['entity']) ? (int) $_POST['entity'] : 1)); if (is_numeric($entity)) define("DOLENTITY", $entity); -require '../../main.inc.php'; +$res=0; +if (! $res && file_exists("../../main.inc.php")) $res=@include("../../main.inc.php"); // to work if your module directory is into a subdir of root htdocs directory +if (! $res) die("Include of main fails"); if (empty($conf->stripe->enabled)) accessforbidden('',0,0,1); require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; @@ -43,13 +45,13 @@ if (isset($_GET['connect'])){ { $endpoint_secret = $conf->global->STRIPE_TEST_WEBHOOK_CONNECT_KEY; $service = 'StripeTest'; - $servicestatus = 0; + $servicestatus = 0; } else { $endpoint_secret = $conf->global->STRIPE_LIVE_WEBHOOK_CONNECT_KEY; $service = 'StripeLive'; - $servicestatus = 1; + $servicestatus = 1; } } else { @@ -57,15 +59,16 @@ else { { $endpoint_secret = $conf->global->STRIPE_TEST_WEBHOOK_KEY; $service = 'StripeTest'; - $servicestatus = 0; + $servicestatus = 0; } else { $endpoint_secret = $conf->global->STRIPE_LIVE_WEBHOOK_KEY; $service = 'StripeLive'; - $servicestatus = 1; + $servicestatus = 1; } } + $payload = @file_get_contents("php://input"); $sig_header = $_SERVER["HTTP_STRIPE_SIGNATURE"]; $event = null; @@ -127,7 +130,7 @@ $stripe=new Stripe($db); if ($event->type == 'payout.created') { $error=0; - $result=dolibarr_set_const($db, $servicestatus."_NEXTPAYOUT", date('Y-m-d H:i:s',$event->data->object->arrival_date), 'chaine', 0, '', $conf->entity); + $result=dolibarr_set_const($db, $service."_NEXTPAYOUT", date('Y-m-d H:i:s',$event->data->object->arrival_date), 'chaine', 0, '', $conf->entity); if ($result > 0) { @@ -172,7 +175,7 @@ if ($event->type == 'payout.created') { elseif ($event->type == 'payout.paid') { global $conf; $error=0; - $result=dolibarr_set_const($db, $servicestatus."_NEXTPAYOUT",null,'chaine',0,'',$conf->entity); + $result=dolibarr_set_const($db, $service."_NEXTPAYOUT",null,'chaine',0,'',$conf->entity); if ($result) { $langs->load("errors"); @@ -187,14 +190,9 @@ elseif ($event->type == 'payout.paid') { $accountfrom->fetch($conf->global->STRIPE_BANK_ACCOUNT_FOR_PAYMENTS); $accountto=new Account($db); - $accountto->fetch($conf->global->STRIPE_BANK_ACCOUNT_FOR_BANKTRANFERS); + $accountto->fetch($conf->global->STRIPE_BANK_ACCOUNT_FOR_BANKTRANSFERS); - if ($accountto->currency_code != $accountfrom->currency_code) { - $error++; - setEventMessages($langs->trans("ErrorTransferBetweenDifferentCurrencyNotPossible"), null, 'errors'); - } - - if ($accountto->id != $accountfrom->id) + if (($accountto->id != $accountfrom->id) && empty($error)) { $bank_line_id_from=0; @@ -207,21 +205,44 @@ elseif ($event->type == 'payout.paid') { if (! $error) $bank_line_id_from = $accountfrom->addline($dateo, $typefrom, $label, -1*price2num($amount), '', '', $user); if (! ($bank_line_id_from > 0)) $error++; - if ((! $error) && ($accountto->currency_code == $accountfrom->currency_code)) $bank_line_id_to = $accountto->addline($dateo, $typeto, $label, price2num($amount), '', '', $user); - if ((! $error) && ($accountto->currency_code != $accountfrom->currency_code)) $bank_line_id_to = $accountto->addline($dateo, $typeto, $label, price2num($amount_to), '', '', $user); + if (! $error) $bank_line_id_to = $accountto->addline($dateo, $typeto, $label, price2num($amount), '', '', $user); if (! ($bank_line_id_to > 0)) $error++; - if (! $error) $result=$accountfrom->add_url_line($bank_line_id_from, $bank_line_id_to, DOL_URL_ROOT.'/compta/bank/ligne.php?rowid=', '(banktransfert)', 'banktransfert'); + if (! $error) $result=$accountfrom->add_url_line($bank_line_id_from, $bank_line_id_to, DOL_URL_ROOT.'/compta/bank/ligne.php?rowid=', '(banktransfert)', 'banktransfert'); + if (! ($result > 0)) $error++; + if (! $error) $result=$accountto->add_url_line($bank_line_id_to, $bank_line_id_from, DOL_URL_ROOT.'/compta/bank/ligne.php?rowid=', '(banktransfert)', 'banktransfert'); if (! ($result > 0)) $error++; - if (! $error) $result=$accountto->add_url_line($bank_line_id_to, $bank_line_id_from, DOL_URL_ROOT.'/compta/bank/ligne.php?rowid=', '(banktransfert)', 'banktransfert'); - if (! ($result > 0)) $error++; - } - // TODO Use CMail and translation - $body = "Un virement de ".price2num($event->data->object->amount/100)." ".$event->data->object->currency." a ete effectue sur votre compte le ".date('d-m-Y H:i:s',$event->data->object->arrival_date); - $subject = '[NOTIFICATION] Virement effectué'; - $headers = 'From: "'.$conf->global->MAIN_INFO_SOCIETE_MAIL.'" <'.$conf->global->MAIN_INFO_SOCIETE_MAIL.'>'; - mail(''.$conf->global->MAIN_INFO_SOCIETE_MAIL.'', $subject, $body, $headers); + } + $subject = '[NOTIFICATION] Stripe payout done'; + if (!empty($user->email)) { + $sendto = dolGetFirstLastname($user->firstname, $user->lastname) . " <".$user->email.">"; + } else { + $sendto = $conf->global->MAIN_INFO_SOCIETE_MAIL.'" <'.$conf->global->MAIN_INFO_SOCIETE_MAIL.'>'; + } + $replyto = $sendto; + $sendtocc = ''; + if (!empty($conf->global->ONLINE_PAYMENT_SENDEMAIL)) { + $sendtocc = $conf->global->ONLINE_PAYMENT_SENDEMAIL.'" <'.$conf->global->ONLINE_PAYMENT_SENDEMAIL.'>'; + } + + $message = "A bank transfer of ".price2num($event->data->object->amount/100)." ".$event->data->object->currency." has been transfert in your account the ".dol_print_date($event->data->object->arrival_date, 'dayhour'); + + $mailfile = new CMailFile( + $subject, + $sendto, + $replyto, + $message, + array(), + array(), + array(), + $sendtocc, + '', + 0, + -1 + ); + + $ret = $mailfile->sendfile(); return 1; } From cb5988bf3006d266221a3cd8ab09412813096496 Mon Sep 17 00:00:00 2001 From: Maxime Kohlhaas Date: Fri, 2 Nov 2018 15:47:02 +0100 Subject: [PATCH 031/132] fix minor SQL error --- htdocs/install/mysql/migration/8.0.0-9.0.0.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/install/mysql/migration/8.0.0-9.0.0.sql b/htdocs/install/mysql/migration/8.0.0-9.0.0.sql index 5abc1772eef..e8d575926f1 100644 --- a/htdocs/install/mysql/migration/8.0.0-9.0.0.sql +++ b/htdocs/install/mysql/migration/8.0.0-9.0.0.sql @@ -163,7 +163,7 @@ CREATE TABLE llx_emailcollector_emailcollector( fk_user_creat integer NOT NULL, fk_user_modif integer, import_key varchar(14), - status integer NOT NULL, + status integer NOT NULL -- END MODULEBUILDER FIELDS ) ENGINE=innodb; From 1052cb0534672ac27dd5ec96d6af92553224f5e5 Mon Sep 17 00:00:00 2001 From: Maxime Kohlhaas Date: Fri, 2 Nov 2018 16:04:49 +0100 Subject: [PATCH 032/132] Also in install table --- .../install/mysql/tables/llx_emailcollector_emailcollector.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/install/mysql/tables/llx_emailcollector_emailcollector.sql b/htdocs/install/mysql/tables/llx_emailcollector_emailcollector.sql index 98426cd85a7..8f1fdf1ae7f 100644 --- a/htdocs/install/mysql/tables/llx_emailcollector_emailcollector.sql +++ b/htdocs/install/mysql/tables/llx_emailcollector_emailcollector.sql @@ -37,6 +37,6 @@ CREATE TABLE llx_emailcollector_emailcollector( fk_user_creat integer NOT NULL, fk_user_modif integer, import_key varchar(14), - status integer NOT NULL, + status integer NOT NULL -- END MODULEBUILDER FIELDS ) ENGINE=innodb; From ab53885ef8ddce927f69453fcb6770c56bd52edc Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Fri, 2 Nov 2018 17:22:42 +0100 Subject: [PATCH 033/132] Fix with new stripe payment function --- htdocs/stripe/payment.php | 45 ++++++++++++++++++++++----------------- 1 file changed, 25 insertions(+), 20 deletions(-) diff --git a/htdocs/stripe/payment.php b/htdocs/stripe/payment.php index 9a7ecfd5470..03014761f62 100644 --- a/htdocs/stripe/payment.php +++ b/htdocs/stripe/payment.php @@ -8,7 +8,7 @@ * Copyright (C) 2014 Raphaël Doursenaud * Copyright (C) 2014 Teddy Andreotti <125155@supinfo.com> * Copyright (C) 2015 Juanjo Menent - * Copyright (C) 2018 ThibaultFOUCART + * Copyright (C) 2018 Thibault FOUCART * Copyright (C) 2018 Frédéric France * * This program is free software; you can redistribute it and/or modify @@ -63,21 +63,6 @@ $addwarning=0; $multicurrency_amounts=array(); $multicurrency_amountsresttopay=array(); -if (! empty($conf->stripe->enabled)) -{ - $service = 'StripeTest'; - $servicestatus = 0; - if (! empty($conf->global->STRIPE_LIVE) && ! GETPOST('forcesandbox','alpha')) - { - $service = 'StripeLive'; - $servicestatus = 0; - } - - $stripe = new Stripe($db); - $stripeacc = $stripe->getStripeAccount($service); // Stripe OAuth connect account of dolibarr user (no network access here) - $stripecu = $stripe->getStripeCustomerAccount($object->id, $servicestatus); // Get thirdparty cu_... -} - // Security check $socid=0; if ($user->societe_id > 0) @@ -93,6 +78,20 @@ if ($facid > 0) $ret=$object->fetch($facid); } +if (! empty($conf->stripe->enabled)) +{ + $service = 'StripeTest'; + $servicestatus = 0; + if (! empty($conf->global->STRIPE_LIVE) && ! GETPOST('forcesandbox','alpha')) + { + $service = 'StripeLive'; + $servicestatus = 0; + } + +$stripe=new Stripe($db); +$stripeacc = $stripe->getStripeAccount($service); // Stripe OAuth connect account of dolibarr user (no network access here) +} + // Initialize technical object to manage hooks of paiements. Note that conf->hooks_modules contains array array $hookmanager->initHooks(array('paiementcard','globalcard')); @@ -307,12 +306,16 @@ if (empty($reshook)) $paiementcode ="CB"; } } + + $societe = new Societe($db); $societe->fetch($facture->socid); - dol_syslog("Create charge", LOG_DEBUG, 0, '_stripe'); + dol_syslog("Create charge", LOG_DEBUG, 0, '_stripe'); + + $stripecu = $stripe->getStripeCustomerAccount($societe->id, $servicestatus); // Get thirdparty cu_... - $charge=$stripe->CreatePaymentStripe($stripeamount,"EUR","invoice",$facid,$source,$customer->id,$stripe->getStripeAccount($conf->entity)); + $charge=$stripe->createPaymentStripe($stripeamount,$facture->multicurrency_code,"invoice",$facid,$source,$stripecu,$stripeacc,$servicestatus); if (!$error) { @@ -324,6 +327,8 @@ if (empty($reshook)) $paiement->paiementid = dol_getIdFromCode($db,$paiementcode,'c_paiement'); $paiement->num_paiement = $charge->message; $paiement->note = GETPOST('comment'); + $paiement->ext_payment_id = $charge->id; + $paiement->ext_payment_site = $service; } if (! $error) @@ -388,8 +393,8 @@ if (empty($reshook)) exit; } else - { - $loc = DOL_URL_ROOT.'/stripeconnect/payment.php?facid='.$facid.'&action=create&error='.$e->getMessage(); + { + $loc = DOL_URL_ROOT.'/stripe/payment.php?facid='.$facid.'&action=create&error='.$charge->message; $db->rollback(); header('Location: '.$loc); From 171d36d4fcf32b0fb6155bd3d9fd02fe7ea5d949 Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Fri, 2 Nov 2018 17:49:11 +0100 Subject: [PATCH 034/132] Update payment.php --- htdocs/stripe/payment.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/stripe/payment.php b/htdocs/stripe/payment.php index 03014761f62..51b6cee4505 100644 --- a/htdocs/stripe/payment.php +++ b/htdocs/stripe/payment.php @@ -327,8 +327,8 @@ if (empty($reshook)) $paiement->paiementid = dol_getIdFromCode($db,$paiementcode,'c_paiement'); $paiement->num_paiement = $charge->message; $paiement->note = GETPOST('comment'); - $paiement->ext_payment_id = $charge->id; - $paiement->ext_payment_site = $service; + $paiement->ext_payment_id = $charge->id; + $paiement->ext_payment_site = $service; } if (! $error) From 5f4d644cab8ce0336cf08ed516f275576c0a0659 Mon Sep 17 00:00:00 2001 From: Abbes Bahfir Date: Sat, 3 Nov 2018 11:05:12 +0100 Subject: [PATCH 035/132] New : help picto for fields in creation --- htdocs/core/tpl/commonfields_add.tpl.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/htdocs/core/tpl/commonfields_add.tpl.php b/htdocs/core/tpl/commonfields_add.tpl.php index 4c81e50c65c..67e118c1b72 100644 --- a/htdocs/core/tpl/commonfields_add.tpl.php +++ b/htdocs/core/tpl/commonfields_add.tpl.php @@ -49,6 +49,9 @@ foreach($object->fields as $key => $val) print '"'; print '>'; print $langs->trans($val['label']); + if(!empty($val['help'])){ + print $form->textwithpicto('',$langs->trans($val['help'])); + } print ''; print ''; if (in_array($val['type'], array('int', 'integer'))) $value = GETPOST($key, 'int'); From 28d5f1d50bdddc0dbffdeb32dab99691b5f7b997 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 3 Nov 2018 11:30:32 +0100 Subject: [PATCH 036/132] Fix sql syntax error --- htdocs/install/mysql/migration/8.0.0-9.0.0.sql | 2 +- .../install/mysql/tables/llx_emailcollector_emailcollector.sql | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/install/mysql/migration/8.0.0-9.0.0.sql b/htdocs/install/mysql/migration/8.0.0-9.0.0.sql index 5abc1772eef..e8d575926f1 100644 --- a/htdocs/install/mysql/migration/8.0.0-9.0.0.sql +++ b/htdocs/install/mysql/migration/8.0.0-9.0.0.sql @@ -163,7 +163,7 @@ CREATE TABLE llx_emailcollector_emailcollector( fk_user_creat integer NOT NULL, fk_user_modif integer, import_key varchar(14), - status integer NOT NULL, + status integer NOT NULL -- END MODULEBUILDER FIELDS ) ENGINE=innodb; diff --git a/htdocs/install/mysql/tables/llx_emailcollector_emailcollector.sql b/htdocs/install/mysql/tables/llx_emailcollector_emailcollector.sql index 98426cd85a7..8f1fdf1ae7f 100644 --- a/htdocs/install/mysql/tables/llx_emailcollector_emailcollector.sql +++ b/htdocs/install/mysql/tables/llx_emailcollector_emailcollector.sql @@ -37,6 +37,6 @@ CREATE TABLE llx_emailcollector_emailcollector( fk_user_creat integer NOT NULL, fk_user_modif integer, import_key varchar(14), - status integer NOT NULL, + status integer NOT NULL -- END MODULEBUILDER FIELDS ) ENGINE=innodb; From 0229b961784a4a0cc527d0e99ed7a408ace7b319 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 3 Nov 2018 11:38:29 +0100 Subject: [PATCH 037/132] Fix family of module --- htdocs/core/modules/modDataPolicy.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/modules/modDataPolicy.class.php b/htdocs/core/modules/modDataPolicy.class.php index b6f4c4e0139..4987bec3856 100644 --- a/htdocs/core/modules/modDataPolicy.class.php +++ b/htdocs/core/modules/modDataPolicy.class.php @@ -57,9 +57,9 @@ class modDataPolicy extends DolibarrModules { // Family can be 'base' (core modules),'crm','financial','hr','projects','products','ecm','technic' (transverse modules),'interface' (link with external tools),'other','...' // It is used to group modules by family in module setup page - $this->family = "hr"; + $this->family = "technic"; // Module position in the family on 2 digits ('01', '10', '20', ...) - $this->module_position = '70'; + $this->module_position = '81'; // Gives the possibility to the module, to provide his own family info and position of this family (Overwrite $this->family and $this->module_position. Avoid this) //$this->familyinfo = array('myownfamily' => array('position' => '01', 'label' => $langs->trans("MyOwnFamily"))); // Module label (no space allowed), used if translation string 'ModuledatapolicyName' not found (MyModue is name of module). From 64b5e432c244055a207179efdade34aa5cfd53bb Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 3 Nov 2018 11:40:43 +0100 Subject: [PATCH 038/132] 2 remind of expired subscription by default --- htdocs/core/modules/modAdherent.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/modules/modAdherent.class.php b/htdocs/core/modules/modAdherent.class.php index e6a3f294c82..8fa19e44e0c 100644 --- a/htdocs/core/modules/modAdherent.class.php +++ b/htdocs/core/modules/modAdherent.class.php @@ -355,7 +355,7 @@ class modAdherent extends DolibarrModules 'jobtype'=>'method', 'class'=>'adherents/class/adherent.class.php', 'objectname'=>'Adherent', 'method'=>'sendReminderForExpiredSubscription', - 'parameters'=>'10', + 'parameters'=>'10,0', 'comment'=>'SendReminderForExpiredSubscription', 'frequency'=>1, 'unitfrequency'=> 3600 * 24, From 7e55701774a0f90d9afa036cc636bc7182e2704b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 3 Nov 2018 11:41:45 +0100 Subject: [PATCH 039/132] 2 remind of subscription expired by default --- htdocs/core/modules/modAdherent.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/modules/modAdherent.class.php b/htdocs/core/modules/modAdherent.class.php index 8fa19e44e0c..30aa21c4201 100644 --- a/htdocs/core/modules/modAdherent.class.php +++ b/htdocs/core/modules/modAdherent.class.php @@ -355,7 +355,7 @@ class modAdherent extends DolibarrModules 'jobtype'=>'method', 'class'=>'adherents/class/adherent.class.php', 'objectname'=>'Adherent', 'method'=>'sendReminderForExpiredSubscription', - 'parameters'=>'10,0', + 'parameters'=>'10;0', 'comment'=>'SendReminderForExpiredSubscription', 'frequency'=>1, 'unitfrequency'=> 3600 * 24, From 68ec172798cf1032cd051f57c7ea6fbceecb297d Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 3 Nov 2018 12:37:52 +0100 Subject: [PATCH 040/132] Fix setup to enable reminder b email --- htdocs/adherents/admin/adherent_emails.php | 3 ++- htdocs/adherents/class/adherent.class.php | 12 +++++++--- htdocs/comm/action/class/actioncomm.class.php | 10 +++++++-- htdocs/core/lib/admin.lib.php | 22 ++++++++++++++----- htdocs/langs/en_US/admin.lang | 1 + 5 files changed, 37 insertions(+), 11 deletions(-) diff --git a/htdocs/adherents/admin/adherent_emails.php b/htdocs/adherents/admin/adherent_emails.php index 60e0b2c3b48..36c7091a47b 100644 --- a/htdocs/adherents/admin/adherent_emails.php +++ b/htdocs/adherents/admin/adherent_emails.php @@ -147,8 +147,9 @@ $constantes=array( 'ADHERENT_EMAIL_TEMPLATE_AUTOREGISTER' =>'emailtemplate:member', /* old was ADHERENT_AUTOREGISTER_MAIL */ 'ADHERENT_EMAIL_TEMPLATE_MEMBER_VALIDATION' =>'emailtemplate:member', /* old was ADHERENT_MAIL_VALID */ 'ADHERENT_EMAIL_TEMPLATE_SUBSCRIPTION' =>'emailtemplate:member', /* old was ADHERENT_MAIL_COTIS */ - 'ADHERENT_EMAIL_TEMPLATE_REMIND_EXPIRATION' =>'emailtemplate:member', 'ADHERENT_EMAIL_TEMPLATE_CANCELATION' =>'emailtemplate:member', /* old was ADHERENT_MAIL_RESIL */ + 'MEMBER_REMINDER_EMAIL'=>array('type'=>'yesno', 'label'=>$langs->trans('MEMBER_REMINDER_EMAIL', $langs->transnoentities("Module2300Name"))), + 'ADHERENT_EMAIL_TEMPLATE_REMIND_EXPIRATION' =>'emailtemplate:member', ); $helptext='*'.$langs->trans("FollowingConstantsWillBeSubstituted").'
'; diff --git a/htdocs/adherents/class/adherent.class.php b/htdocs/adherents/class/adherent.class.php index 3df36ef3eda..4277b274a1d 100644 --- a/htdocs/adherents/class/adherent.class.php +++ b/htdocs/adherents/class/adherent.class.php @@ -2644,13 +2644,19 @@ class Adherent extends CommonObject $blockingerrormsg = ''; - /*if (empty($conf->global->MEMBER_REMINDER_EMAIL)) + if (empty($conf->adherent->enabled)) // Should not happen. If module disabled, cron job should not be visible. + { + $langs->load("agenda"); + $this->output = $langs->trans('ModuleNotEnabled', $langs->transnoentitiesnoconv("Adherent")); + return 0; + } + if (empty($conf->global->MEMBER_REMINDER_EMAIL)) { $langs->load("agenda"); $this->output = $langs->trans('EventRemindersByEmailNotEnabled', $langs->transnoentitiesnoconv("Adherent")); return 0; - }*/ - + } + $now = dol_now(); $nbok = 0; $nbko = 0; diff --git a/htdocs/comm/action/class/actioncomm.class.php b/htdocs/comm/action/class/actioncomm.class.php index 92af9fef6da..e84ef93da2d 100644 --- a/htdocs/comm/action/class/actioncomm.class.php +++ b/htdocs/comm/action/class/actioncomm.class.php @@ -1679,13 +1679,19 @@ class ActionComm extends CommonObject $this->output = ''; $this->error=''; - if (empty($conf->global->AGENDA_REMINDER_EMAIL)) + if (empty($conf->agenda->enabled)) // Should not happen. If module disabled, cron job should not be visible. + { + $langs->load("agenda"); + $this->output = $langs->trans('ModuleNotEnabled', $langs->transnoentitiesnoconv("Agenda")); + return 0; + } + if (empty($conf->global->AGENDA_REMINDER_EMAIL)) { $langs->load("agenda"); $this->output = $langs->trans('EventRemindersByEmailNotEnabled', $langs->transnoentitiesnoconv("Agenda")); return 0; } - + $now = dol_now(); dol_syslog(__METHOD__, LOG_DEBUG); diff --git a/htdocs/core/lib/admin.lib.php b/htdocs/core/lib/admin.lib.php index f5efa5c5b7e..89f511c18c2 100644 --- a/htdocs/core/lib/admin.lib.php +++ b/htdocs/core/lib/admin.lib.php @@ -1353,7 +1353,8 @@ function complete_elementList_with_modules(&$elementList) /** * Show array with constants to edit * - * @param array $tableau Array of constants array('key'=>type, ) where type can be 'string', 'text', 'textarea', 'html', 'yesno', 'emailtemplate:xxx', ... + * @param array $tableau Array of constants array('key'=>array('type'=>type, 'label'=>label) + * where type can be 'string', 'text', 'textarea', 'html', 'yesno', 'emailtemplate:xxx', ... * @param int $strictw3c 0=Include form into table (deprecated), 1=Form is outside table to respect W3C (no form into table), 2=No form nor button at all * @param string $helptext Help * @return void @@ -1377,17 +1378,28 @@ function form_constantes($tableau, $strictw3c=0, $helptext='') if (empty($strictw3c)) print ''.$langs->trans("Action").''; print "\n"; + $label=''; $listofparam=array(); foreach($tableau as $key => $const) // Loop on each param { + $label=''; // $const is a const key like 'MYMODULE_ABC' - if (is_numeric($key)) { + if (is_numeric($key)) { // Very old behaviour $type = 'string'; } else { - $type = $const; - $const = $key; + if (is_array($const)) + { + $type = $const['type']; + $label = $const['label']; + $const = $key; + } + else + { + $type = $const; + $const = $key; + } } $sql = "SELECT "; @@ -1428,7 +1440,7 @@ function form_constantes($tableau, $strictw3c=0, $helptext='') print ''; print ''; - print $langs->trans('Desc'.$const); + print ($label ? $label : $langs->trans('Desc'.$const)); if ($const == 'ADHERENT_MAILMAN_URL') { diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index 190b7cded97..a59cc0eee2e 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -1282,6 +1282,7 @@ AdherentLoginRequired= Manage a Login for each member AdherentMailRequired=EMail required to create a new member MemberSendInformationByMailByDefault=Checkbox to send mail confirmation to members (validation or new subscription) is on by default VisitorCanChooseItsPaymentMode=Visitor can choose among available payment modes +MEMBER_REMINDER_EMAIL=Enable automatic reminder by emails of expired subscriptions. Note: Module %s must be enabled and correctly setup to have reminder sent. ##### LDAP setup ##### LDAPSetup=LDAP Setup LDAPGlobalParameters=Global parameters From 8ab53012b71b2dd149ea743abfd4063f5faf489c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sat, 3 Nov 2018 18:20:36 +0100 Subject: [PATCH 041/132] mode is only customer in stats fichinter --- htdocs/fichinter/stats/index.php | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/htdocs/fichinter/stats/index.php b/htdocs/fichinter/stats/index.php index 1c0ba5764ed..0dacf19c600 100644 --- a/htdocs/fichinter/stats/index.php +++ b/htdocs/fichinter/stats/index.php @@ -30,7 +30,7 @@ $WIDTH=DolGraph::getDefaultGraphSizeForStats('width'); $HEIGHT=DolGraph::getDefaultGraphSizeForStats('height'); $mode='customer'; -if ($mode == 'customer' && ! $user->rights->ficheinter->lire) accessforbidden(); +if (! $user->rights->ficheinter->lire) accessforbidden(); $userid=GETPOST('userid','int'); $socid=GETPOST('socid','int'); @@ -129,14 +129,12 @@ $data = $stats->getAmountByMonthWithPrevYear($endyear,$startyear); if (!$user->rights->societe->client->voir || $user->societe_id) { $filenameamount = $dir.'/interventionsamountinyear-'.$user->id.'-'.$year.'.png'; - if ($mode == 'customer') $fileurlamount = DOL_URL_ROOT.'/viewimage.php?modulepart=interventionstats&file=interventionsamountinyear-'.$user->id.'-'.$year.'.png'; - if ($mode == 'supplier') $fileurlamount = DOL_URL_ROOT.'/viewimage.php?modulepart=interventionstatssupplier&file=interventionsamountinyear-'.$user->id.'-'.$year.'.png'; + $fileurlamount = DOL_URL_ROOT.'/viewimage.php?modulepart=interventionstats&file=interventionsamountinyear-'.$user->id.'-'.$year.'.png'; } else { $filenameamount = $dir.'/interventionsamountinyear-'.$year.'.png'; - if ($mode == 'customer') $fileurlamount = DOL_URL_ROOT.'/viewimage.php?modulepart=interventionstats&file=interventionsamountinyear-'.$year.'.png'; - if ($mode == 'supplier') $fileurlamount = DOL_URL_ROOT.'/viewimage.php?modulepart=interventionstatssupplier&file=interventionsamountinyear-'.$year.'.png'; + $fileurlamount = DOL_URL_ROOT.'/viewimage.php?modulepart=interventionstats&file=interventionsamountinyear-'.$year.'.png'; } $px2 = new DolGraph(); @@ -171,14 +169,12 @@ $data = $stats->getAverageByMonthWithPrevYear($endyear, $startyear); if (!$user->rights->societe->client->voir || $user->societe_id) { $filename_avg = $dir.'/interventionsaverage-'.$user->id.'-'.$year.'.png'; - if ($mode == 'customer') $fileurl_avg = DOL_URL_ROOT.'/viewimage.php?modulepart=interventionstats&file=interventionsaverage-'.$user->id.'-'.$year.'.png'; - if ($mode == 'supplier') $fileurl_avg = DOL_URL_ROOT.'/viewimage.php?modulepart=interventionstatssupplier&file=interventionsaverage-'.$user->id.'-'.$year.'.png'; + $fileurl_avg = DOL_URL_ROOT.'/viewimage.php?modulepart=interventionstats&file=interventionsaverage-'.$user->id.'-'.$year.'.png'; } else { $filename_avg = $dir.'/interventionsaverage-'.$year.'.png'; - if ($mode == 'customer') $fileurl_avg = DOL_URL_ROOT.'/viewimage.php?modulepart=interventionstats&file=interventionsaverage-'.$year.'.png'; - if ($mode == 'supplier') $fileurl_avg = DOL_URL_ROOT.'/viewimage.php?modulepart=interventionstatssupplier&file=interventionsaverage-'.$year.'.png'; + $fileurl_avg = DOL_URL_ROOT.'/viewimage.php?modulepart=interventionstats&file=interventionsaverage-'.$year.'.png'; } $px3 = new DolGraph(); @@ -221,13 +217,12 @@ if (! count($arrayyears)) $arrayyears[$nowyear]=$nowyear; $h=0; $head = array(); -$head[$h][0] = DOL_URL_ROOT . '/commande/stats/index.php?mode='.$mode; +$head[$h][0] = DOL_URL_ROOT . '/fichinter/stats/index.php?mode='.$mode; $head[$h][1] = $langs->trans("ByMonthYear"); $head[$h][2] = 'byyear'; $h++; -if ($mode == 'customer') $type='order_stats'; -if ($mode == 'supplier') $type='supplier_order_stats'; +$type='fichinter_stats'; complete_head_from_modules($conf,$langs,null,$head,$h,$type); @@ -247,7 +242,6 @@ print '
'; // Company print ''.$langs->trans("ThirdParty").''; if ($mode == 'customer') $filter='s.client in (1,2,3)'; - if ($mode == 'supplier') $filter='s.fournisseur = 1'; print $form->select_company($socid,'socid',$filter,1,0,0,array(),0,'','style="width: 95%"'); print ''; // User From d6b909a28063712acfed8ba2e6b4a9d7ade4d1fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sat, 3 Nov 2018 18:26:11 +0100 Subject: [PATCH 042/132] Update index.php --- htdocs/fichinter/stats/index.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/fichinter/stats/index.php b/htdocs/fichinter/stats/index.php index 0dacf19c600..39cad7ca4f1 100644 --- a/htdocs/fichinter/stats/index.php +++ b/htdocs/fichinter/stats/index.php @@ -217,12 +217,12 @@ if (! count($arrayyears)) $arrayyears[$nowyear]=$nowyear; $h=0; $head = array(); -$head[$h][0] = DOL_URL_ROOT . '/fichinter/stats/index.php?mode='.$mode; +$head[$h][0] = DOL_URL_ROOT . '/fichinter/stats/index.php'; $head[$h][1] = $langs->trans("ByMonthYear"); $head[$h][2] = 'byyear'; $h++; -$type='fichinter_stats'; +$type = 'fichinter_stats'; complete_head_from_modules($conf,$langs,null,$head,$h,$type); From c4bf0f0e038dd41a02ce1c121122e92d981379cb Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 3 Nov 2018 18:57:18 +0100 Subject: [PATCH 043/132] CSS Flex --- htdocs/index.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/htdocs/index.php b/htdocs/index.php index 14f72774d92..a3d6a45475e 100644 --- a/htdocs/index.php +++ b/htdocs/index.php @@ -552,7 +552,8 @@ if ($showweather) $nbworkboardempty=0; if (! empty($valid_dashboardlines)) { - $boxwork.=''; + $boxwork.='
'; + foreach($valid_dashboardlines as $board) { if (empty($board->nbtodo)) $nbworkboardempty++; @@ -592,6 +593,8 @@ if (! empty($valid_dashboardlines)) $boxwork .='
'; $boxwork .='
'; $boxwork .='
'; + + $boxwork .='
'; $boxwork .=''; } else From f4346c1469e351419291bc5a1f613e192acfbe2e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 3 Nov 2018 19:24:28 +0100 Subject: [PATCH 044/132] Fix css --- htdocs/theme/eldy/style.css.php | 2 +- htdocs/theme/md/style.css.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/theme/eldy/style.css.php b/htdocs/theme/eldy/style.css.php index 8d3b21a327d..a58031b2889 100644 --- a/htdocs/theme/eldy/style.css.php +++ b/htdocs/theme/eldy/style.css.php @@ -3567,7 +3567,7 @@ div.boximport { .widthpictotitle { width: 40px; text-align: ; } .dolgraphtitle { margin-top: 6px; margin-bottom: 4px; } -.dolgraphtitlecssboxes { margin: 0px; } +.dolgraphtitlecssboxes { /* margin: 0px; */ } .legendColorBox, .legendLabel { border: none !important; } div.dolgraph div.legend, div.dolgraph div.legend div { background-color: rgba(255,255,255,0) !important; } div.dolgraph div.legend table tbody tr { height: auto; } diff --git a/htdocs/theme/md/style.css.php b/htdocs/theme/md/style.css.php index 80a79b0245a..a246786a53a 100644 --- a/htdocs/theme/md/style.css.php +++ b/htdocs/theme/md/style.css.php @@ -3486,7 +3486,7 @@ div.boximport { .widthpictotitle { width: 40px; text-align: ; } .dolgraphtitle { margin-top: 6px; margin-bottom: 4px; } -.dolgraphtitlecssboxes { margin: 0px; } +.dolgraphtitlecssboxes { /* margin: 0px; */ } .legendColorBox, .legendLabel { border: none !important; } div.dolgraph div.legend, div.dolgraph div.legend div { background-color: rgba(255,255,255,0) !important; } div.dolgraph div.legend table tbody tr { height: auto; } From c01113e28bc76e8123f2525c67d637d3a0588e42 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sat, 3 Nov 2018 22:49:30 +0100 Subject: [PATCH 045/132] typo --- htdocs/ticket/index.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/ticket/index.php b/htdocs/ticket/index.php index 9acfd66c3bb..43be6bd2f57 100644 --- a/htdocs/ticket/index.php +++ b/htdocs/ticket/index.php @@ -184,8 +184,8 @@ if ($result) { $dataseries[] = array('label' => $langs->trans("Assigned"), 'data' => round($tick['assigned'])); $dataseries[] = array('label' => $langs->trans("InProgress"), 'data' => round($tick['inprogress'])); $dataseries[] = array('label' => $langs->trans("Waiting"), 'data' => round($tick['waiting'])); - $dataseries[] = array('label' => $langs->trans("Closed"), 'data' => round($tick['Closed'])); - $dataseries[] = array('label' => $langs->trans("Deleted"), 'data' => round($tick['Deleted'])); + $dataseries[] = array('label' => $langs->trans("Closed"), 'data' => round($tick['closed'])); + $dataseries[] = array('label' => $langs->trans("Deleted"), 'data' => round($tick['deleted'])); } } else { dol_print_error($db); From 90d3b80efb7e202f1dc561041f0795af9b93391b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 3 Nov 2018 22:53:55 +0100 Subject: [PATCH 046/132] NEW Add email in event histor for reminder email of expired subsription --- htdocs/adherents/class/adherent.class.php | 53 ++++++++++++++++++- htdocs/core/actions_sendmails.inc.php | 4 ++ ...terface_50_modAgenda_ActionsAuto.class.php | 21 ++++---- 3 files changed, 68 insertions(+), 10 deletions(-) diff --git a/htdocs/adherents/class/adherent.class.php b/htdocs/adherents/class/adherent.class.php index 4277b274a1d..ea8850931dc 100644 --- a/htdocs/adherents/class/adherent.class.php +++ b/htdocs/adherents/class/adherent.class.php @@ -2742,7 +2742,58 @@ class Adherent extends CommonObject { $nbok++; - // TODO Add event email sent for member + $message = $msg; + $sendto = $to; + $sendtocc = ''; + $sendtobcc = ''; + $actioncode='EMAIL'; + $extraparams=''; + + $actionmsg=''; + $actionmsg2=$langs->transnoentities('MailSentBy').' '.CMailFile::getValidAddress($from,4,0,1).' '.$langs->transnoentities('To').' '.CMailFile::getValidAddress($sendto,4,0,1); + if ($message) + { + $actionmsg=$langs->transnoentities('MailFrom').': '.dol_escape_htmltag($from); + $actionmsg=dol_concatdesc($actionmsg, $langs->transnoentities('MailTo').': '.dol_escape_htmltag($sendto)); + if ($sendtocc) $actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('Bcc') . ": " . dol_escape_htmltag($sendtocc)); + $actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('MailTopic') . ": " . $subject); + $actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('TextUsedInTheMessageBody') . ":"); + $actionmsg = dol_concatdesc($actionmsg, $message); + } + + require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php'; + + // Insert record of emails sent + $actioncomm = new ActionComm($this->db); + + $actioncomm->type_code = 'AC_OTH_AUTO'; // Type of event ('AC_OTH', 'AC_OTH_AUTO', 'AC_XXX'...) + $actioncomm->code = 'AC_'.$actioncode; + $actioncomm->label = $actionmsg2; + $actioncomm->note = $actionmsg; + $actioncomm->fk_project = 0; + $actioncomm->datep = $now; + $actioncomm->datef = $now; + $actioncomm->percentage = -1; // Not applicable + $actioncomm->socid = $adherent->thirdparty->id; + $actioncomm->contactid = 0; + $actioncomm->authorid = $user->id; // User saving action + $actioncomm->userownerid = $user->id; // Owner of action + // Fields when action is en email (content should be added into note) + $actioncomm->email_msgid = $cmail->msgid; + $actioncomm->email_from = $from; + $actioncomm->email_sender= ''; + $actioncomm->email_to = $to; + $actioncomm->email_tocc = $sendtocc; + $actioncomm->email_tobcc = $sendtobcc; + $actioncomm->email_subject = $subject; + $actioncomm->errors_to = ''; + + $actioncomm->fk_element = $adherent->id; + $actioncomm->elementtype = $adherent->element; + + $actioncomm->extraparams = $extraparams; + + $actioncomm->create($user); } } else diff --git a/htdocs/core/actions_sendmails.inc.php b/htdocs/core/actions_sendmails.inc.php index 0715a78495e..61c4b636758 100644 --- a/htdocs/core/actions_sendmails.inc.php +++ b/htdocs/core/actions_sendmails.inc.php @@ -439,6 +439,10 @@ if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_PO $object->sendtouserid = $sendtouserid; } + // TODO Set object->email_xxx properties + $object->email_msgid = $mailfile->msgid; + //... + // Call of triggers if (! empty($trigger_name)) { diff --git a/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php b/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php index 938b63d90f3..0823a536cbf 100644 --- a/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php +++ b/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php @@ -818,7 +818,7 @@ class InterfaceActionsAuto extends DolibarrTriggers $actioncomm->type_code = $object->actiontypecode; // Type of event ('AC_OTH', 'AC_OTH_AUTO', 'AC_XXX'...) $actioncomm->code = 'AC_'.$action; $actioncomm->label = $object->actionmsg2; - $actioncomm->note = $object->actionmsg; // TODO Replace with $actioncomm->email_msgid ? $object->email_content : $object->actionmsg + $actioncomm->note = $object->actionmsg; // TODO Replace with ($actioncomm->email_msgid ? $object->email_content : $object->actionmsg) $actioncomm->fk_project = $projectid; $actioncomm->datep = $now; $actioncomm->datef = $now; @@ -831,19 +831,22 @@ class InterfaceActionsAuto extends DolibarrTriggers $actioncomm->contactid = $contactforaction->id; $actioncomm->authorid = $user->id; // User saving action $actioncomm->userownerid = $user->id; // Owner of action - // Fields when action is en email (content should be added into note) - $actioncomm->email_msgid = $object->email_msgid; - $actioncomm->email_from = $object->email_from; - $actioncomm->email_sender= $object->email_sender; - $actioncomm->email_to = $object->email_to; - $actioncomm->email_tocc = $object->email_tocc; - $actioncomm->email_tobcc = $object->email_tobcc; + // Fields defined when action is an email (content should be into object->actionmsg to be added into note, subject into object->actionms2 to be added into label) + $actioncomm->email_msgid = $object->email_msgid; + $actioncomm->email_from = $object->email_from; + $actioncomm->email_sender = $object->email_sender; + $actioncomm->email_to = $object->email_to; + $actioncomm->email_tocc = $object->email_tocc; + $actioncomm->email_tobcc = $object->email_tobcc; $actioncomm->email_subject = $object->email_subject; - $actioncomm->errors_to = $object->errors_to; + $actioncomm->errors_to = $object->errors_to; $actioncomm->fk_element = $elementid; $actioncomm->elementtype = $elementtype; + if (property_exists($object,'attachedfiles') && is_array($object->attachedfiles) && count($object->attachedfiles)>0) { + $actioncomm->attachedfiles=$object->attachedfiles; + } if (property_exists($object,'sendtouserid') && is_array($object->sendtouserid) && count($object->sendtouserid)>0) { $actioncomm->userassigned=$object->sendtouserid; } From 488ac8c8f0b1fd5a08b6a3eea5452eb4e109095b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sat, 3 Nov 2018 23:44:25 +0100 Subject: [PATCH 047/132] Update index.php --- htdocs/ticket/index.php | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/htdocs/ticket/index.php b/htdocs/ticket/index.php index 43be6bd2f57..1f01e335a7c 100644 --- a/htdocs/ticket/index.php +++ b/htdocs/ticket/index.php @@ -191,8 +191,7 @@ if ($result) { dol_print_error($db); } -$stringtoshow = ''; -$stringtoshow .= ''."\n"; // MAX_FILE_SIZE doit précéder le champ input de type file print ''; } - print ' '; + print ' '; print ''; From c4db549f94ee80b12ddc52ee10ddee18b82055b9 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 6 Nov 2018 19:49:52 +0100 Subject: [PATCH 077/132] Work on emailcollector --- htdocs/admin/emailcollector_card.php | 84 +++++++++++++++++-- .../class/emailcollector.class.php | 48 ++++++----- htdocs/langs/en_US/admin.lang | 1 + 3 files changed, 104 insertions(+), 29 deletions(-) diff --git a/htdocs/admin/emailcollector_card.php b/htdocs/admin/emailcollector_card.php index 611f7578193..d34964d9892 100644 --- a/htdocs/admin/emailcollector_card.php +++ b/htdocs/admin/emailcollector_card.php @@ -1,6 +1,5 @@ - * Copyright (C) ---Put here your own copyright and developer email--- +/* Copyright (C) 2018 Laurent Destailleur * * 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 @@ -17,7 +16,7 @@ */ /** - * \file htdocs/admin/emailcollectore/emailcollector_card.php + * \file htdocs/admin/emailcollector_card.php * \ingroup emailcollector * \brief Page to create/edit/view emailcollector */ @@ -27,10 +26,12 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/agenda.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/events.class.php'; -include_once DOL_DOCUMENT_ROOT . '/core/class/html.formcompany.class.php'; -include_once DOL_DOCUMENT_ROOT . '/core/class/html.formfile.class.php'; -dol_include_once('/emailcollector/class/emailcollector.class.php'); -dol_include_once('/emailcollector/lib/emailcollector.lib.php'); +include_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; +include_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; +include_once DOL_DOCUMENT_ROOT.'/emailcollector/class/emailcollector.class.php'; +include_once DOL_DOCUMENT_ROOT.'/emailcollector/class/emailcollectorfilter.class.php'; +include_once DOL_DOCUMENT_ROOT.'/emailcollector/class/emailcollectoraction.lib.php'; +include_once DOL_DOCUMENT_ROOT.'/emailcollector/lib/emailcollector.lib.php'; if (!$user->admin) accessforbidden(); @@ -219,6 +220,9 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea { $res = $object->fetch_optionals(); + $object->fetchFilters(); + $object->fetchActions(); + $head = emailcollectorPrepareHead($object); dol_fiche_head($head, 'card', $langs->trans("EmailCollector"), -1, 'emailcollector'); @@ -318,6 +322,72 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea print ''; + // Filters + print ''; + print ''; + print ''; + print ''; + // Add filter + print ''; + print ''; + print ''; + print ''; + // List filters + foreach($object->filters as $rulefilter) + { + $rulefilterobj=new EmailCollectorFilter($db); + $rulefilterobj->fetch($rulefilter['id']); + + print ''; + print ''; + print ''; + print ''; + print ''; + } + + print ''; + print '
'.$langs->trans("Filters").'
'; + $arrayoftypes=array('to'=>'To', 'cc'=>'Cc', 'bcc'=>'Bcc', 'from'=>'From', 'subject'=>'Subject', 'body'=>'Body', 'seen'=>'AlreadyRead', 'unseen'=>'NotRead'); + print $form->selectarray('filtertype', $arrayoftypes, '', 1); + print ''; + print ''; + print '
'.$rulefilter['type'].''.$rulefilter['rulevalue'].''.$rulefilterobj->getLibStatut(3).'
'; + + print '

'; + + // Operations + print ''; + print ''; + print ''; + print ''; + // Add operation + print ''; + print ''; + print ''; + print ''; + // List operations + foreach($object->actions as $ruleaction) + { + $ruleactionobj=new EmailcollectorAction($db); + $ruleactionobj->fetch($ruleaction['id']); + + print ''; + print ''; + print ''; + print ''; + print ''; + } + + print ''; + print '
'.$langs->trans("EmailcollectorOperations").'
'; + $arrayoftypes=array('recordevent'=>'RecordEvent'); + if ($conf->projet->enabled) $arrayoftypes['project']='CreateLeadAndThirdParty'; + print $form->selectarray('operationtype', $arrayoftypes, '', 1); + print ''; + print ''; + print '
'.$ruleactionobj['type'].''.$ruleactionobj['actionparam'].''.$ruleactionobj->getLibStatut(3).'
'; + + print '
'; print '
'; diff --git a/htdocs/emailcollector/class/emailcollector.class.php b/htdocs/emailcollector/class/emailcollector.class.php index f925b271853..358b7a278e7 100644 --- a/htdocs/emailcollector/class/emailcollector.class.php +++ b/htdocs/emailcollector/class/emailcollector.class.php @@ -155,7 +155,7 @@ class EmailCollector extends CommonObject public $lastresult; // END MODULEBUILDER PROPERTIES - public $rules; + public $filters; public $actions; @@ -613,15 +613,15 @@ class EmailCollector extends CommonObject } /** - * Fetch rules + * Fetch filters * * @return int <0 if KO, >0 if OK */ - public function fetch_rules() + public function fetchFilters() { $this->rules = array(); - $sql='SELECT type, rulevalue FROM '.MAIN_DB_PREFIX.'emailcollector_emailcollectorfilter WHERE status = 1 AND fk_emailcollector = '.$this->id; + $sql='SELECT rowid, type, rulevalue, status FROM '.MAIN_DB_PREFIX.'emailcollector_emailcollectorfilter WHERE fk_emailcollector = '.$this->id; $resql = $this->db->query($sql); if ($resql) @@ -631,7 +631,7 @@ class EmailCollector extends CommonObject while($i < $num) { $obj=$this->db->fetch_object($resql); - $this->rules[]=array('type'=>$obj->type, 'rulevalue'=>$obj->rulevalue); + $this->filters[$obj->rowid]=array('id'=>$obj->rowid, 'type'=>$obj->type, 'rulevalue'=>$obj->rulevalue, 'status'=>$obj->status); } $this->db->free($resql); } @@ -644,11 +644,11 @@ class EmailCollector extends CommonObject * * @return int <0 if KO, >0 if OK */ - public function fetch_actions() + public function fetchActions() { $this->actions = array(); - $sql='SELECT type, actionparam FROM '.MAIN_DB_PREFIX.'emailcollector_emailcollectoraction WHERE status = 1 AND fk_emailcollector = '.$this->id; + $sql='SELECT rowid, type, actionparam, status FROM '.MAIN_DB_PREFIX.'emailcollector_emailcollectoraction WHERE fk_emailcollector = '.$this->id; $resql = $this->db->query($sql); if ($resql) @@ -658,7 +658,7 @@ class EmailCollector extends CommonObject while($i < $num) { $obj=$this->db->fetch_object($resql); - $this->rules[]=array('type'=>$obj->type, 'actionparam'=>$obj->actionparam); + $this->rules[$obj->rowid]=array('id'=>$obj->rowid, 'type'=>$obj->type, 'actionparam'=>$obj->actionparam, 'status'=>$obj->status); } $this->db->free($resql); } @@ -709,8 +709,8 @@ class EmailCollector extends CommonObject return -2; } - $this->fetch_rules(); - $this->fetch_actions(); + $this->fetchFilters(); + $this->fetchActions(); $sourcedir = $this->source_directory; $targetdir = ($this->target_directory ? $server.$this->target_directory : ''); // Can be '[Gmail]/Trash' or 'mytag' @@ -735,16 +735,18 @@ class EmailCollector extends CommonObject //$search='ALL'; $search='UNDELETED'; - foreach($this->rules as $key => $rulevalue) + foreach($this->filters as $rule) { - if ($key == 'to') $search=($search?' ':'').'TO "'.str_replace('"', '', $rulevalue).'"'; - if ($key == 'bcc') $search=($search?' ':'').'BCC'; - if ($key == 'cc') $search=($search?' ':'').'CC'; - if ($key == 'from') $search=($search?' ':'').'FROM "'.str_replace('"', '', $rulevalue).'"'; - if ($key == 'subject') $search=($search?' ':'').'SUBJECT "'.str_replace('"', '', $rulevalue).'"'; - if ($key == 'body') $search=($search?' ':'').'BODY "'.str_replace('"', '', $rulevalue).'"'; - if ($key == 'seen') $search=($search?' ':'').'SEEN'; - if ($key == 'unseen') $search=($search?' ':'').'UNSEEN'; + if (empty($rule['status'])) continue; + + if ($rule['key'] == 'to') $search=($search?' ':'').'TO "'.str_replace('"', '', $rule['rulevalue']).'"'; + if ($rule['key'] == 'bcc') $search=($search?' ':'').'BCC'; + if ($rule['key'] == 'cc') $search=($search?' ':'').'CC'; + if ($rule['key'] == 'from') $search=($search?' ':'').'FROM "'.str_replace('"', '', $rule['rulevalue']).'"'; + if ($rule['key'] == 'subject') $search=($search?' ':'').'SUBJECT "'.str_replace('"', '', $rule['rulevalue']).'"'; + if ($rule['key'] == 'body') $search=($search?' ':'').'BODY "'.str_replace('"', '', $rule['rulevalue']).'"'; + if ($rule['key'] == 'seen') $search=($search?' ':'').'SEEN'; + if ($rule['key'] == 'unseen') $search=($search?' ':'').'UNSEEN'; } if (empty($targetdir)) // Use last date as filter if there is no targetdir defined. @@ -783,12 +785,14 @@ class EmailCollector extends CommonObject var_dump($message); */ - // Record email - foreach($this->actions as $actionkey => $actionvalue) + // Do operationss + foreach($this->actions as $operation) { if ($errorforactions) break; + if (empty($operation['status'])) continue; + + // Make Operation - // Make action if (! $errorforactions) diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index 2294d540b22..d38eb1d21d9 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -1819,6 +1819,7 @@ NewEmailCollector=New Email Collector EMailHost=Host of email IMAP server MailboxSourceDirectory=Mailbox source directory MailboxTargetDirectory=Mailbox target directory +EmailcollectorOperations=Operations done by collector CollectNow=Collect now DateLastResult=Date last collect LastResult=Last result From 7dd941dd51787b3e2c452ad3af70307a225a63db Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 6 Nov 2018 19:51:16 +0100 Subject: [PATCH 078/132] Fix bad fix --- htdocs/accountancy/admin/export.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/accountancy/admin/export.php b/htdocs/accountancy/admin/export.php index 23ac96ea263..03538b759e7 100644 --- a/htdocs/accountancy/admin/export.php +++ b/htdocs/accountancy/admin/export.php @@ -41,8 +41,8 @@ if (empty($user->rights->accounting->chartofaccount)) accessforbidden(); } -$action = GETPOST('action', 'alpha'); -aZ09 +$action = GETPOST('action', 'aZ09'); + // Parameters ACCOUNTING_EXPORT_* $main_option = array ( 'ACCOUNTING_EXPORT_PREFIX_SPEC', From c1cf4fbb957f690a4371b0ef1aea3b4d5211b049 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 6 Nov 2018 20:29:58 +0100 Subject: [PATCH 079/132] Fix phpcs --- htdocs/core/modules/expedition/doc/pdf_rouget.modules.php | 5 ++--- htdocs/emailcollector/class/emailcollector.class.php | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php b/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php index ab523d3be52..28ec5935582 100644 --- a/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php +++ b/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php @@ -731,14 +731,13 @@ class pdf_rouget extends ModelePdfExpedition $pdf->MultiCell($this->posxpuht - $this->posxqtytoship, $tab2_hl, $totalToShip, 0, 'C', 1); } - if (!empty($conf->global->SHIPPING_PDF_DISPLAY_AMOUNT_HT)) { - + if (!empty($conf->global->SHIPPING_PDF_DISPLAY_AMOUNT_HT)) + { $pdf->SetXY($this->posxpuht, $tab2_top + $tab2_hl * $index); $pdf->MultiCell($this->posxtotalht - $this->posxpuht, $tab2_hl, '', 0, 'C', 1); $pdf->SetXY($this->posxtotalht, $tab2_top + $tab2_hl * $index); $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->posxtotalht, $tab2_hl, price($object->total_ht, 0, $outputlangs), 0, 'C', 1); - } if (empty($conf->global->SHIPPING_PDF_HIDE_WEIGHT_AND_VOLUME)) diff --git a/htdocs/emailcollector/class/emailcollector.class.php b/htdocs/emailcollector/class/emailcollector.class.php index 358b7a278e7..cef1c27eac9 100644 --- a/htdocs/emailcollector/class/emailcollector.class.php +++ b/htdocs/emailcollector/class/emailcollector.class.php @@ -775,7 +775,7 @@ class EmailCollector extends CommonObject $this->db->begin(); $overview = imap_fetch_overview($connection, $imapemail, 0); - $header = imap_fetchheader($connection ,$imapemail, 0); + $header = imap_fetchheader($connection, $imapemail, 0); $message = imap_body($connection, $imapemail, 0); // imap_fetchstructure($connection, $imapemail, 0); // imap_fetchbody($connection, $imapemail, 1) may be text/plain, 2 may be text/html From c76c2e0d3ec31f2bf6e5e07c1f90bd5c3f519350 Mon Sep 17 00:00:00 2001 From: madx666 Date: Wed, 7 Nov 2018 10:08:38 +0100 Subject: [PATCH 080/132] Fix newMessagePublic for ticket module --- htdocs/ticket/class/actions_ticket.class.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/ticket/class/actions_ticket.class.php b/htdocs/ticket/class/actions_ticket.class.php index 7e8ae39564a..09326b23798 100644 --- a/htdocs/ticket/class/actions_ticket.class.php +++ b/htdocs/ticket/class/actions_ticket.class.php @@ -827,6 +827,7 @@ class ActionsTicket global $mysoc, $conf, $langs; + $object = new Ticket($this->db); $error = 0; $ret = $object->fetch('', '', GETPOST('track_id','alpha')); $object->socid = $object->fk_soc; From 2ff69bb3fc315c1fa5fede5bc555d2740d23f909 Mon Sep 17 00:00:00 2001 From: madx666 Date: Wed, 7 Nov 2018 10:11:28 +0100 Subject: [PATCH 081/132] Fix viewTicketMessages for ticket module --- htdocs/ticket/class/actions_ticket.class.php | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/htdocs/ticket/class/actions_ticket.class.php b/htdocs/ticket/class/actions_ticket.class.php index 09326b23798..fc1f1a88012 100644 --- a/htdocs/ticket/class/actions_ticket.class.php +++ b/htdocs/ticket/class/actions_ticket.class.php @@ -1204,15 +1204,14 @@ class ActionsTicket public function viewTicketMessages($show_private, $show_user = true) { global $conf, $langs, $user; - global $object; // Load logs in cache - $ret = $object->loadCacheMsgsTicket(); + $ret = $this->dao->loadCacheMsgsTicket(); $action = GETPOST('action'); $this->viewTicketOriginalMessage($user, $action); - if (is_array($object->cache_msgs_ticket) && count($object->cache_msgs_ticket) > 0) { + if (is_array($this->dao->cache_msgs_ticket) && count($this->dao->cache_msgs_ticket) > 0) { print_titre($langs->trans('TicketMailExchanges')); print ''; @@ -1229,7 +1228,7 @@ class ActionsTicket print ''; } - foreach ($object->cache_msgs_ticket as $id => $arraymsgs) { + foreach ($this->dao->cache_msgs_ticket as $id => $arraymsgs) { if (!$arraymsgs['private'] || ($arraymsgs['private'] == "1" && $show_private) ) { From 9d780a172272eb834b53c1c326595300d29327f3 Mon Sep 17 00:00:00 2001 From: John BOTELLA Date: Wed, 7 Nov 2018 10:11:29 +0100 Subject: [PATCH 082/132] Fix sign --- htdocs/margin/tabs/thirdpartyMargins.php | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/htdocs/margin/tabs/thirdpartyMargins.php b/htdocs/margin/tabs/thirdpartyMargins.php index 5d80814099d..2f5ba9cc7b2 100644 --- a/htdocs/margin/tabs/thirdpartyMargins.php +++ b/htdocs/margin/tabs/thirdpartyMargins.php @@ -207,7 +207,10 @@ if ($socid > 0) $marginRate = ($objp->buying_price != 0)?(100 * $objp->marge / $objp->buying_price):'' ; $markRate = ($objp->selling_price != 0)?(100 * $objp->marge / $objp->selling_price):'' ; - + $sign = ''; + if($objp->type == Facture::TYPE_CREDIT_NOTE){ + $sign = '-'; + } print ''; print '"; print "\n"; print "\n"; - print "\n"; + print "\n"; if (! empty($conf->global->DISPLAY_MARGIN_RATES)) - print "\n"; + print "\n"; if (! empty($conf->global->DISPLAY_MARK_RATES)) - print "\n"; + print "\n"; print ''; print "\n"; $i++; From c5231112c55d9898c2c41b42c814b21b4beb6a42 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 7 Nov 2018 12:22:12 +0100 Subject: [PATCH 083/132] Fix regression with old canvas --- htdocs/societe/card.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/societe/card.php b/htdocs/societe/card.php index 5935a1d01a1..2fc046b5fb8 100644 --- a/htdocs/societe/card.php +++ b/htdocs/societe/card.php @@ -417,8 +417,8 @@ if (empty($reshook)) $object->idprof5 = trim(GETPOST('idprof5', 'alpha')); $object->idprof6 = trim(GETPOST('idprof6', 'alpha')); $object->prefix_comm = GETPOST('prefix_comm', 'alpha'); - $object->code_client = GETPOST('customer_code', 'alpha'); - $object->code_fournisseur = GETPOST('supplier_code', 'alpha'); + $object->code_client = GETPOSTISSET('customer_code')?GETPOST('customer_code', 'alpha'):GETPOST('code_client', 'alpha'); + $object->code_fournisseur = GETPOSTISSET('supplier_code')?GETPOST('supplier_code', 'alpha'):GETPOST('code_fournisseur', 'alpha'); $object->capital = GETPOST('capital', 'alpha'); $object->barcode = GETPOST('barcode', 'alpha'); From 9a0b5fb59907c0c2a33d26e37d194742702d68bb Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 7 Nov 2018 12:25:22 +0100 Subject: [PATCH 084/132] Fix extrafields --- htdocs/core/class/extrafields.class.php | 33 ++++++++++++------- htdocs/core/lib/functions.lib.php | 7 ++-- .../tpl/extrafields_list_search_sql.tpl.php | 15 ++++++--- .../modulebuilder/template/myobject_list.php | 4 +-- 4 files changed, 37 insertions(+), 22 deletions(-) diff --git a/htdocs/core/class/extrafields.class.php b/htdocs/core/class/extrafields.class.php index 9ebdbd22836..5cb88c0e2ad 100644 --- a/htdocs/core/class/extrafields.class.php +++ b/htdocs/core/class/extrafields.class.php @@ -1941,24 +1941,36 @@ class ExtraFields /** * return array_options array of data of extrafields value of object sent by a search form * - * @param array $extralabels $array of extrafields (@deprecated) - * @param string $keyprefix Prefix string to add into name and id of field (can be used to avoid duplicate names) - * @param string $keysuffix Suffix string to add into name and id of field (can be used to avoid duplicate names) - * @return array|int array_options set or 0 if no value + * @param array|string $extrafieldsobjectkey array of extrafields (old usage) or value of object->table_element (new usage) + * @param string $keyprefix Prefix string to add into name and id of field (can be used to avoid duplicate names) + * @param string $keysuffix Suffix string to add into name and id of field (can be used to avoid duplicate names) + * @return array|int array_options set or 0 if no value */ - function getOptionalsFromPost($extralabels,$keyprefix='',$keysuffix='') + function getOptionalsFromPost($extrafieldsobjectkey, $keyprefix='', $keysuffix='') { global $_POST; - if (is_array($this->attributes[$object->table_element]['label'])) $extralabels=$this->attributes[$object->table_element]['label']; + if (is_string($extrafieldsobjectkey) && is_array($this->attributes[$extrafieldsobjectkey]['label'])) + { + $extralabels = $this->attributes[$extrafieldsobjectkey]['label']; + } + else + { + $extralabels = $extrafieldsobjectkey; + } - $array_options = array(); if (is_array($extralabels)) { + $array_options = array(); + // Get extra fields foreach ($extralabels as $key => $value) { - $key_type = $this->attributes[$object->table_element]['type'][$key]; + $key_type = ''; + if (is_string($extrafieldsobjectkey)) + { + $key_type = $this->attributes[$extrafieldsobjectkey]['type'][$key]; + } if (in_array($key_type,array('date','datetime'))) { @@ -1987,8 +1999,7 @@ class ExtraFields return $array_options; } - else { - return 0; - } + + return 0; } } diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 75cc6735fe4..ff5a9fa4776 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -7288,7 +7288,8 @@ function dol_getmypid() * If param $mode is 1, can contains an operator <, > or = like "<10" or ">=100.5 < 1000" * If param $mode is 2, can contains a list of int id separated by comma like "1,3,4" * If param $mode is 3, can contains a list of string separated by comma like "a,b,c" - * @param integer $mode 0=value is list of keyword strings, 1=value is a numeric test (Example ">5.5 <10"), 2=value is a list of id separated with comma (Example '1,3,4') + * @param integer $mode 0=value is list of keyword strings, 1=value is a numeric test (Example ">5.5 <10"), 2=value is a list of ID separated with comma (Example '1,3,4') + * 3=value is list of string separated with comma (Example 'text 1,text 2'), 4=value is a list of ID separated with comma (Example '1,3,4') for search into a multiselect string ('1,2') * @param integer $nofirstand 1=Do not output the first 'AND' * @return string $res The statement to append to the SQL query */ @@ -7372,11 +7373,9 @@ function natural_search($fields, $value, $mode=0, $nofirstand=0) else if ($mode == 4) { $tmparray=explode(',',trim($crit)); - if (count($tmparray)) { $listofcodes=''; - foreach($tmparray as $val) { if ($val) @@ -7385,7 +7384,7 @@ function natural_search($fields, $value, $mode=0, $nofirstand=0) $newres .= ' OR '. $field . ' = \'' . $db->escape(trim($val)) . '\''; $newres .= ' OR '. $field . ' LIKE \'%,' . $db->escape(trim($val)) . '\''; $newres .= ' OR '. $field . ' LIKE \'%,' . $db->escape(trim($val)) . ',%\''; - $newres .= ')'; + $newres .= ')'; $i2++; } } diff --git a/htdocs/core/tpl/extrafields_list_search_sql.tpl.php b/htdocs/core/tpl/extrafields_list_search_sql.tpl.php index a8e43d6429f..d5b52085059 100644 --- a/htdocs/core/tpl/extrafields_list_search_sql.tpl.php +++ b/htdocs/core/tpl/extrafields_list_search_sql.tpl.php @@ -18,12 +18,17 @@ if (! empty($extrafieldsobjectkey)) // $extrafieldsobject is the $object->table_ $tmpkey=preg_replace('/search_options_/','',$key); $typ=$extrafields->attributes[$extrafieldsobjectkey]['type'][$tmpkey]; - $mode_search=0; - if (in_array($typ, array('int','double','real'))) $mode_search=1; // Search on a numeric - if (in_array($typ, array('sellist','link')) && $crit != '0' && $crit != '-1') $mode_search=2; // Search on a foreign key int - if (in_array($typ, array('chkbxlst','checkbox'))) $mode_search=4; // Search on a multiselect field with sql type = text - if ($crit != '' && (! in_array($typ, array('select','sellist')) || $crit != '0') && (! in_array($typ, array('link')) || $crit != '-1')) + if ($crit != '' && in_array($typ, array('date', 'datetime', 'timestamp'))) { + $sql .= " AND ef.".$tmpkey." = '".$db->idate($crit)."'"; + } + elseif ($crit != '' && (! in_array($typ, array('select','sellist')) || $crit != '0') && (! in_array($typ, array('link')) || $crit != '-1')) + { + $mode_search=0; + if (in_array($typ, array('int','double','real'))) $mode_search=1; // Search on a numeric + if (in_array($typ, array('sellist','link')) && $crit != '0' && $crit != '-1') $mode_search=2; // Search on a foreign key int + if (in_array($typ, array('chkbxlst','checkbox'))) $mode_search=4; // Search on a multiselect field with sql type = text + $sql .= natural_search('ef.'.$tmpkey, $crit, $mode_search); } } diff --git a/htdocs/modulebuilder/template/myobject_list.php b/htdocs/modulebuilder/template/myobject_list.php index beb03c183a6..8d0f89104ef 100644 --- a/htdocs/modulebuilder/template/myobject_list.php +++ b/htdocs/modulebuilder/template/myobject_list.php @@ -93,8 +93,8 @@ $extrafields = new ExtraFields($db); $diroutputmassaction=$conf->mymodule->dir_output . '/temp/massgeneration/'.$user->id; $hookmanager->initHooks(array('myobjectlist')); // Note that conf->hooks_modules contains array // Fetch optionals attributes and labels -$extralabels = $extrafields->fetch_name_optionals_label('myobject'); -$search_array_options=$extrafields->getOptionalsFromPost($extralabels,'','search_'); +$extralabels = $extrafields->fetch_name_optionals_label('myobject'); // Load $extrafields->attributes['myobject'] +$search_array_options=$extrafields->getOptionalsFromPost($object->table_element,'','search_'); // Default sort order (if not yet defined by previous GETPOST) if (! $sortfield) $sortfield="t.".key($object->fields); // Set here default search field. By default 1st field in definition. From 66ffcf287a9502fa8234234bc79e46cc10298d9f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 7 Nov 2018 12:49:17 +0100 Subject: [PATCH 085/132] Fix filter on extrafields --- htdocs/adherents/list.php | 2 +- htdocs/adherents/subscription/list.php | 4 +++- htdocs/admin/emailcollector_card.php | 2 +- htdocs/admin/emailcollector_list.php | 2 +- htdocs/admin/mails_senderprofile_list.php | 2 +- htdocs/asset/card.php | 2 +- htdocs/asset/list.php | 2 +- htdocs/comm/action/list.php | 10 +++++----- htdocs/comm/mailing/list.php | 5 +++-- htdocs/comm/propal/list.php | 2 +- htdocs/commande/list.php | 2 +- htdocs/compta/bank/bankentries_list.php | 2 +- htdocs/compta/bank/list.php | 2 +- htdocs/compta/facture/fiche-rec.php | 2 +- htdocs/compta/facture/invoicetemplate_list.php | 2 +- htdocs/compta/facture/list.php | 2 +- htdocs/contact/list.php | 2 +- htdocs/contrat/list.php | 2 +- htdocs/contrat/services_list.php | 2 +- htdocs/core/lib/company.lib.php | 2 +- .../core/modules/stock/doc/pdf_stdmovement.modules.php | 2 +- htdocs/cron/list.php | 5 +++-- htdocs/expedition/list.php | 4 +++- htdocs/expensereport/list.php | 2 +- htdocs/fichinter/card-rec.php | 4 ++-- htdocs/fichinter/card.php | 4 ++-- htdocs/fichinter/list.php | 2 +- htdocs/fourn/commande/list.php | 2 +- htdocs/fourn/facture/list.php | 2 +- htdocs/fourn/facture/paiement.php | 10 +++++----- htdocs/holiday/list.php | 2 +- htdocs/modulebuilder/template/myobject_card.php | 2 +- htdocs/product/inventory/card.php | 2 +- htdocs/product/inventory/list.php | 2 +- htdocs/product/list.php | 2 +- htdocs/product/stock/movement_list.php | 2 +- htdocs/product/stock/productlot_list.php | 2 +- htdocs/projet/list.php | 2 +- htdocs/projet/tasks/list.php | 2 +- htdocs/public/ticket/list.php | 2 +- htdocs/resource/list.php | 2 +- htdocs/societe/list.php | 2 +- htdocs/societe/website.php | 2 +- htdocs/supplier_proposal/list.php | 2 +- htdocs/takepos/customers.php | 2 +- htdocs/ticket/card.php | 2 +- htdocs/ticket/class/actions_ticket.class.php | 2 +- htdocs/ticket/list.php | 2 +- htdocs/user/list.php | 2 +- htdocs/website/websiteaccount_card.php | 2 +- 50 files changed, 68 insertions(+), 62 deletions(-) diff --git a/htdocs/adherents/list.php b/htdocs/adherents/list.php index 51e1a8b244e..39d0069ac7c 100644 --- a/htdocs/adherents/list.php +++ b/htdocs/adherents/list.php @@ -86,7 +86,7 @@ $extrafields = new ExtraFields($db); // fetch optionals attributes and labels $extralabels = $extrafields->fetch_name_optionals_label('adherent'); -$search_array_options=$extrafields->getOptionalsFromPost($extralabels,'','search_'); +$search_array_options=$extrafields->getOptionalsFromPost($object->table_element,'','search_'); // List of fields to search into when doing a "search in all" $fieldstosearchall = array( diff --git a/htdocs/adherents/subscription/list.php b/htdocs/adherents/subscription/list.php index 474082b1cfa..4ef43e8f316 100644 --- a/htdocs/adherents/subscription/list.php +++ b/htdocs/adherents/subscription/list.php @@ -53,13 +53,15 @@ $pagenext = $page + 1; if (! $sortorder) { $sortorder="DESC"; } if (! $sortfield) { $sortfield="c.dateadh"; } +$object = new Subscription($db); + // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $hookmanager->initHooks(array('subscriptionlist')); $extrafields = new ExtraFields($db); // fetch optionals attributes and labels $extralabels = $extrafields->fetch_name_optionals_label('subscription'); -$search_array_options=$extrafields->getOptionalsFromPost($extralabels,'','search_'); +$search_array_options=$extrafields->getOptionalsFromPost($object->table_element,'','search_'); // List of fields to search into when doing a "search in all" $fieldstosearchall = array( diff --git a/htdocs/admin/emailcollector_card.php b/htdocs/admin/emailcollector_card.php index d34964d9892..5c6aec59b32 100644 --- a/htdocs/admin/emailcollector_card.php +++ b/htdocs/admin/emailcollector_card.php @@ -55,7 +55,7 @@ $diroutputmassaction = $conf->emailcollector->dir_output . '/temp/massgeneration $hookmanager->initHooks(array('emailcollectorcard')); // Note that conf->hooks_modules contains array // Fetch optionals attributes and labels $extralabels = $extrafields->fetch_name_optionals_label('emailcollector'); -$search_array_options = $extrafields->getOptionalsFromPost($extralabels, '', 'search_'); +$search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_'); // Initialize array of search criterias $search_all = trim(GETPOST("search_all", 'alpha')); diff --git a/htdocs/admin/emailcollector_list.php b/htdocs/admin/emailcollector_list.php index 6de67299871..71169ddffb0 100644 --- a/htdocs/admin/emailcollector_list.php +++ b/htdocs/admin/emailcollector_list.php @@ -67,7 +67,7 @@ $diroutputmassaction = $conf->emailcollector->dir_output . '/temp/massgeneration $hookmanager->initHooks(array('emailcollectorlist')); // Note that conf->hooks_modules contains array // Fetch optionals attributes and labels $extralabels = $extrafields->fetch_name_optionals_label('emailcollector'); -$search_array_options = $extrafields->getOptionalsFromPost($extralabels, '', 'search_'); +$search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_'); // Default sort order (if not yet defined by previous GETPOST) if (! $sortfield) $sortfield="t.".key($object->fields); // Set here default search field. By default 1st field in definition. diff --git a/htdocs/admin/mails_senderprofile_list.php b/htdocs/admin/mails_senderprofile_list.php index 4914152f680..280025b3b35 100644 --- a/htdocs/admin/mails_senderprofile_list.php +++ b/htdocs/admin/mails_senderprofile_list.php @@ -61,7 +61,7 @@ $diroutputmassaction=$conf->admin->dir_output . '/temp/massgeneration/'.$user->i $hookmanager->initHooks(array('emailsenderprofilelist')); // Note that conf->hooks_modules contains array // Fetch optionals attributes and labels $extralabels = $extrafields->fetch_name_optionals_label('emailsenderprofile'); -$search_array_options=$extrafields->getOptionalsFromPost($extralabels,'','search_'); +$search_array_options=$extrafields->getOptionalsFromPost($object->table_element,'','search_'); // Default sort order (if not yet defined by previous GETPOST) if (! $sortfield) $sortfield="t.".key($object->fields); // Set here default search field. By default 1st field in definition. diff --git a/htdocs/asset/card.php b/htdocs/asset/card.php index 4f7061aed20..40b2a9365db 100644 --- a/htdocs/asset/card.php +++ b/htdocs/asset/card.php @@ -45,7 +45,7 @@ $diroutputmassaction=$conf->asset->dir_output . '/temp/massgeneration/'.$user->i $hookmanager->initHooks(array('assetcard')); // Note that conf->hooks_modules contains array // Fetch optionals attributes and labels $extralabels = $extrafields->fetch_name_optionals_label('asset'); -$search_array_options=$extrafields->getOptionalsFromPost($extralabels,'','search_'); +$search_array_options=$extrafields->getOptionalsFromPost($object->table_element,'','search_'); // Initialize array of search criterias $search_all=trim(GETPOST("search_all",'alpha')); diff --git a/htdocs/asset/list.php b/htdocs/asset/list.php index fa965aade5b..431276b67a8 100644 --- a/htdocs/asset/list.php +++ b/htdocs/asset/list.php @@ -62,7 +62,7 @@ $diroutputmassaction=$conf->asset->dir_output . '/temp/massgeneration/'.$user->i $hookmanager->initHooks(array('assetlist')); // Note that conf->hooks_modules contains array // Fetch optionals attributes and labels $extralabels = $extrafields->fetch_name_optionals_label('asset'); -$search_array_options=$extrafields->getOptionalsFromPost($extralabels,'','search_'); +$search_array_options=$extrafields->getOptionalsFromPost($object->table_element,'','search_'); // Default sort order (if not yet defined by previous GETPOST) if (! $sortfield) $sortfield="t.".key($object->fields); // Set here default search field. By default 1st field in definition. diff --git a/htdocs/comm/action/list.php b/htdocs/comm/action/list.php index 02d3a16c7f3..b34ba87d7a3 100644 --- a/htdocs/comm/action/list.php +++ b/htdocs/comm/action/list.php @@ -74,10 +74,14 @@ $filtert = GETPOST("filtert","int",3); $usergroup = GETPOST("usergroup","int",3); $showbirthday = empty($conf->use_javascript_ajax)?GETPOST("showbirthday","int"):1; +// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context +$object = new ActionComm($db); +$hookmanager->initHooks(array('agendalist')); + $extrafields = new ExtraFields($db); // fetch optionals attributes and labels $extralabels = $extrafields->fetch_name_optionals_label('actioncomm'); -$search_array_options=$extrafields->getOptionalsFromPost($extralabels,'','search_'); +$search_array_options=$extrafields->getOptionalsFromPost($object->table_element,'','search_'); // If not choice done on calendar owner, we filter on user. if (empty($filtert) && empty($conf->global->AGENDA_ALL_CALENDARS)) { @@ -117,10 +121,6 @@ if (! $user->rights->agenda->allactions->read || $filter=='mine') // If no permi $filtert=$user->id; } -// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context -$object = new ActionComm($db); -$hookmanager->initHooks(array('agendalist')); - $arrayfields=array( 'a.id'=>array('label'=>"Ref", 'checked'=>1), 'owner'=>array('label'=>"Owner", 'checked'=>1), diff --git a/htdocs/comm/mailing/list.php b/htdocs/comm/mailing/list.php index 133a354723f..eb81649a03e 100644 --- a/htdocs/comm/mailing/list.php +++ b/htdocs/comm/mailing/list.php @@ -46,20 +46,21 @@ $search_all=trim((GETPOST('search_all', 'alphanohtml')!='')?GETPOST('search_all' $search_ref=GETPOST("search_ref", "alpha") ? GETPOST("search_ref", "alpha") : GETPOST("sref", "alpha"); $filteremail=GETPOST('filteremail','alpha'); +$object = new Mailing($db); + // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $hookmanager->initHooks(array('mailinglist')); $extrafields = new ExtraFields($db); // fetch optionals attributes and labels $extralabels = $extrafields->fetch_name_optionals_label('mailing'); -$search_array_options=$extrafields->getOptionalsFromPost($extralabels,'','search_'); +$search_array_options=$extrafields->getOptionalsFromPost($object->table_element,'','search_'); // List of fields to search into when doing a "search in all" $fieldstosearchall = array( 'm.titre'=>'Ref', ); -$object = new Mailing($db); diff --git a/htdocs/comm/propal/list.php b/htdocs/comm/propal/list.php index b0cc04702db..eea0acfbe6b 100644 --- a/htdocs/comm/propal/list.php +++ b/htdocs/comm/propal/list.php @@ -129,7 +129,7 @@ $extrafields = new ExtraFields($db); // fetch optionals attributes and labels $extralabels = $extrafields->fetch_name_optionals_label('propal'); -$search_array_options=$extrafields->getOptionalsFromPost($extralabels,'','search_'); +$search_array_options=$extrafields->getOptionalsFromPost($object->table_element,'','search_'); // List of fields to search into when doing a "search in all" $fieldstosearchall = array( diff --git a/htdocs/commande/list.php b/htdocs/commande/list.php index 2a9e215faa4..c75a754d1ad 100644 --- a/htdocs/commande/list.php +++ b/htdocs/commande/list.php @@ -108,7 +108,7 @@ $extrafields = new ExtraFields($db); // fetch optionals attributes and labels $extralabels = $extrafields->fetch_name_optionals_label('commande'); -$search_array_options=$extrafields->getOptionalsFromPost($extralabels,'','search_'); +$search_array_options=$extrafields->getOptionalsFromPost($object->table_element,'','search_'); // List of fields to search into when doing a "search in all" $fieldstosearchall = array( diff --git a/htdocs/compta/bank/bankentries_list.php b/htdocs/compta/bank/bankentries_list.php index 31eaa9e8f6d..bcb7f348bdf 100644 --- a/htdocs/compta/bank/bankentries_list.php +++ b/htdocs/compta/bank/bankentries_list.php @@ -129,7 +129,7 @@ $extrafields = new ExtraFields($db); // fetch optionals attributes and labels $extralabels = $extrafields->fetch_name_optionals_label('banktransaction'); -$search_array_options=$extrafields->getOptionalsFromPost($extralabels,'','search_'); +$search_array_options=$extrafields->getOptionalsFromPost('banktransaction','','search_'); $arrayfields=array( 'b.rowid'=>array('label'=>$langs->trans("Ref"), 'checked'=>1), diff --git a/htdocs/compta/bank/list.php b/htdocs/compta/bank/list.php index 79c26adfa47..3ec4d88db2f 100644 --- a/htdocs/compta/bank/list.php +++ b/htdocs/compta/bank/list.php @@ -74,7 +74,7 @@ $extrafields = new ExtraFields($db); // fetch optionals attributes and labels $extralabels = $extrafields->fetch_name_optionals_label('bank_account'); -$search_array_options=$extrafields->getOptionalsFromPost($extralabels,'','search_'); +$search_array_options=$extrafields->getOptionalsFromPost($object->table_element,'','search_'); // List of fields to search into when doing a "search in all" $fieldstosearchall = array( diff --git a/htdocs/compta/facture/fiche-rec.php b/htdocs/compta/facture/fiche-rec.php index d9ce0137f04..2a9028b5125 100644 --- a/htdocs/compta/facture/fiche-rec.php +++ b/htdocs/compta/facture/fiche-rec.php @@ -94,7 +94,7 @@ $extrafields = new ExtraFields($db); // fetch optionals attributes and labels $extralabels = $extrafields->fetch_name_optionals_label('facture_rec'); -$search_array_options=$extrafields->getOptionalsFromPost($extralabels,'','search_'); +$search_array_options=$extrafields->getOptionalsFromPost($object->table_element,'','search_'); $permissionnote = $user->rights->facture->creer; // Used by the include of actions_setnotes.inc.php $permissiondellink=$user->rights->facture->creer; // Used by the include of actions_dellink.inc.php diff --git a/htdocs/compta/facture/invoicetemplate_list.php b/htdocs/compta/facture/invoicetemplate_list.php index c61836e1b1b..e077abedbbc 100644 --- a/htdocs/compta/facture/invoicetemplate_list.php +++ b/htdocs/compta/facture/invoicetemplate_list.php @@ -108,7 +108,7 @@ $extrafields = new ExtraFields($db); // fetch optionals attributes and labels $extralabels = $extrafields->fetch_name_optionals_label('facture_rec'); -$search_array_options=$extrafields->getOptionalsFromPost($extralabels,'','search_'); +$search_array_options=$extrafields->getOptionalsFromPost($object->table_element,'','search_'); $permissionnote = $user->rights->facture->creer; // Used by the include of actions_setnotes.inc.php $permissiondellink=$user->rights->facture->creer; // Used by the include of actions_dellink.inc.php diff --git a/htdocs/compta/facture/list.php b/htdocs/compta/facture/list.php index 553c6c9028a..fb6f769db94 100644 --- a/htdocs/compta/facture/list.php +++ b/htdocs/compta/facture/list.php @@ -134,7 +134,7 @@ $extrafields = new ExtraFields($db); // fetch optionals attributes and labels $extralabels = $extrafields->fetch_name_optionals_label('facture'); -$search_array_options=$extrafields->getOptionalsFromPost($extralabels,'','search_'); +$search_array_options=$extrafields->getOptionalsFromPost($object->table_element,'','search_'); // List of fields to search into when doing a "search in all" $fieldstosearchall = array( diff --git a/htdocs/contact/list.php b/htdocs/contact/list.php index 52a2c4bbe7f..ed237c215bf 100644 --- a/htdocs/contact/list.php +++ b/htdocs/contact/list.php @@ -133,7 +133,7 @@ $extrafields = new ExtraFields($db); // fetch optionals attributes and labels $extralabels = $extrafields->fetch_name_optionals_label('contact'); -$search_array_options=$extrafields->getOptionalsFromPost($extralabels,'','search_'); +$search_array_options=$extrafields->getOptionalsFromPost($object->table_element,'','search_'); // List of fields to search into when doing a "search in all" $fieldstosearchall = array( diff --git a/htdocs/contrat/list.php b/htdocs/contrat/list.php index 96f20fdaf67..3631effa7b8 100644 --- a/htdocs/contrat/list.php +++ b/htdocs/contrat/list.php @@ -100,7 +100,7 @@ $extrafields = new ExtraFields($db); // fetch optionals attributes and labels $extralabels = $extrafields->fetch_name_optionals_label('contrat'); -$search_array_options=$extrafields->getOptionalsFromPost($extralabels,'','search_'); +$search_array_options=$extrafields->getOptionalsFromPost($object->table_element,'','search_'); // List of fields to search into when doing a "search in all" $fieldstosearchall = array( 'c.ref'=>'Ref', diff --git a/htdocs/contrat/services_list.php b/htdocs/contrat/services_list.php index 72b45f49db5..da484b31747 100644 --- a/htdocs/contrat/services_list.php +++ b/htdocs/contrat/services_list.php @@ -84,7 +84,7 @@ $extrafields = new ExtraFields($db); // fetch optionals attributes and labels $extralabels = $extrafields->fetch_name_optionals_label('contratdet'); -$search_array_options=$extrafields->getOptionalsFromPost($extralabels,'','search_'); +$search_array_options=$extrafields->getOptionalsFromPost($object->table_element,'','search_'); // Security check $contratid = GETPOST('id','int'); diff --git a/htdocs/core/lib/company.lib.php b/htdocs/core/lib/company.lib.php index fe9d15c8322..bcf8bfe14a8 100644 --- a/htdocs/core/lib/company.lib.php +++ b/htdocs/core/lib/company.lib.php @@ -908,7 +908,7 @@ function show_contacts($conf,$langs,$db,$object,$backtopage='') { if (GETPOST('search_'.$key,'alpha')) $search[$key]=GETPOST('search_'.$key,'alpha'); } - $search_array_options=$extrafields->getOptionalsFromPost($extralabels,'','search_'); + $search_array_options=$extrafields->getOptionalsFromPost($contactstatic->table_element,'','search_'); // Purge search criteria if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x','alpha') ||GETPOST('button_removefilter','alpha')) // All tests are required to be compatible with all browsers diff --git a/htdocs/core/modules/stock/doc/pdf_stdmovement.modules.php b/htdocs/core/modules/stock/doc/pdf_stdmovement.modules.php index 3c0d62be848..222538a8554 100644 --- a/htdocs/core/modules/stock/doc/pdf_stdmovement.modules.php +++ b/htdocs/core/modules/stock/doc/pdf_stdmovement.modules.php @@ -247,7 +247,7 @@ class pdf_stdmovement extends ModelePDFMovement // fetch optionals attributes and labels $extralabels = $extrafields->fetch_name_optionals_label('movement'); - $search_array_options=$extrafields->getOptionalsFromPost($extralabels,'','search_'); + $search_array_options=$extrafields->getOptionalsFromPost('movement','','search_'); $productlot=new ProductLot($db); $productstatic=new Product($db); diff --git a/htdocs/cron/list.php b/htdocs/cron/list.php index 1f810132223..f594eb2b383 100644 --- a/htdocs/cron/list.php +++ b/htdocs/cron/list.php @@ -62,15 +62,16 @@ $securitykey = GETPOST('securitykey','alpha'); $diroutputmassaction=$conf->cronjob->dir_output . '/temp/massgeneration/'.$user->id; +$object = new Cronjob($db); + // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $hookmanager->initHooks(array('cronjoblist')); $extrafields = new ExtraFields($db); // fetch optionals attributes and labels $extralabels = $extrafields->fetch_name_optionals_label('cronjob'); -$search_array_options=$extrafields->getOptionalsFromPost($extralabels,'','search_'); +$search_array_options=$extrafields->getOptionalsFromPost($object->table_element,'','search_'); -$object = new Cronjob($db); /* diff --git a/htdocs/expedition/list.php b/htdocs/expedition/list.php index c3632ca57fd..1d29d4d6bff 100644 --- a/htdocs/expedition/list.php +++ b/htdocs/expedition/list.php @@ -69,13 +69,15 @@ $pagenext = $page + 1; $viewstatut=GETPOST('viewstatut'); +$object = new Expedition($db); + // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $hookmanager->initHooks(array('shipmentlist')); $extrafields = new ExtraFields($db); // fetch optionals attributes and labels $extralabels = $extrafields->fetch_name_optionals_label('expedition'); -$search_array_options=$extrafields->getOptionalsFromPost($extralabels,'','search_'); +$search_array_options=$extrafields->getOptionalsFromPost($object->table_element,'','search_'); // List of fields to search into when doing a "search in all" $fieldstosearchall = array( diff --git a/htdocs/expensereport/list.php b/htdocs/expensereport/list.php index d328cd21de2..1fae1950f60 100644 --- a/htdocs/expensereport/list.php +++ b/htdocs/expensereport/list.php @@ -90,7 +90,7 @@ $extrafields = new ExtraFields($db); // fetch optionals attributes and labels $extralabels = $extrafields->fetch_name_optionals_label('expensereport'); -$search_array_options=$extrafields->getOptionalsFromPost($extralabels,'','search_'); +$search_array_options=$extrafields->getOptionalsFromPost($object->table_element,'','search_'); // List of fields to search into when doing a "search in all" diff --git a/htdocs/fichinter/card-rec.php b/htdocs/fichinter/card-rec.php index 4b8aa9bb43d..e492ef0c794 100644 --- a/htdocs/fichinter/card-rec.php +++ b/htdocs/fichinter/card-rec.php @@ -152,7 +152,7 @@ if ($action == 'add') { } } } elseif ($action == 'createfrommodel') { - $newinter = new fichinter($db); + $newinter = new Fichinter($db); // on récupère les enregistrements $object->fetch($id); @@ -176,7 +176,7 @@ if ($action == 'add') { // on créer un nouvelle intervention $extrafields = new ExtraFields($db); $extralabels = $extrafields->fetch_name_optionals_label($newinter->table_element); - $array_options = $extrafields->getOptionalsFromPost($extralabels); + $array_options = $extrafields->getOptionalsFromPost($newinter->table_element); $newinter->array_options = $array_options; $newfichinterid = $newinter->create($user); diff --git a/htdocs/fichinter/card.php b/htdocs/fichinter/card.php index 5896a5c5723..fe15141c86c 100644 --- a/htdocs/fichinter/card.php +++ b/htdocs/fichinter/card.php @@ -258,7 +258,7 @@ if (empty($reshook)) // Extrafields $extrafields = new ExtraFields($db); $extralabels = $extrafields->fetch_name_optionals_label($object->table_element); - $array_options = $extrafields->getOptionalsFromPost($extralabels); + $array_options = $extrafields->getOptionalsFromPost($object->table_element); $object->array_options = $array_options; @@ -406,7 +406,7 @@ if (empty($reshook)) { // Extrafields $extralabels = $extrafields->fetch_name_optionals_label($object->table_element); - $array_options = $extrafields->getOptionalsFromPost($extralabels); + $array_options = $extrafields->getOptionalsFromPost($object->table_element); $object->array_options = $array_options; diff --git a/htdocs/fichinter/list.php b/htdocs/fichinter/list.php index 96a1199255c..1f3686a02ab 100644 --- a/htdocs/fichinter/list.php +++ b/htdocs/fichinter/list.php @@ -87,7 +87,7 @@ $extrafields = new ExtraFields($db); // fetch optionals attributes and labels $extralabels = $extrafields->fetch_name_optionals_label('fichinter'); -$search_array_options=$extrafields->getOptionalsFromPost($extralabels,'','search_'); +$search_array_options=$extrafields->getOptionalsFromPost($object->table_element,'','search_'); // List of fields to search into when doing a "search in all" $fieldstosearchall = array( diff --git a/htdocs/fourn/commande/list.php b/htdocs/fourn/commande/list.php index 7158d7b2c0e..401acab032b 100644 --- a/htdocs/fourn/commande/list.php +++ b/htdocs/fourn/commande/list.php @@ -113,7 +113,7 @@ $extrafields = new ExtraFields($db); // fetch optionals attributes and labels $extralabels = $extrafields->fetch_name_optionals_label('commande_fournisseur'); -$search_array_options=$extrafields->getOptionalsFromPost($extralabels,'','search_'); +$search_array_options=$extrafields->getOptionalsFromPost($object->table_element,'','search_'); // List of fields to search into when doing a "search in all" $fieldstosearchall = array( diff --git a/htdocs/fourn/facture/list.php b/htdocs/fourn/facture/list.php index e1bd120b0b4..b72d89f4b07 100644 --- a/htdocs/fourn/facture/list.php +++ b/htdocs/fourn/facture/list.php @@ -130,7 +130,7 @@ $extrafields = new ExtraFields($db); // fetch optionals attributes and labels $extralabels = $extrafields->fetch_name_optionals_label('facture_fourn'); -$search_array_options=$extrafields->getOptionalsFromPost($extralabels,'','search_'); +$search_array_options=$extrafields->getOptionalsFromPost($object->table_element,'','search_'); // List of fields to search into when doing a "search in all" $fieldstosearchall = array( diff --git a/htdocs/fourn/facture/paiement.php b/htdocs/fourn/facture/paiement.php index 7946f98cb66..27dc347d9d0 100644 --- a/htdocs/fourn/facture/paiement.php +++ b/htdocs/fourn/facture/paiement.php @@ -89,7 +89,7 @@ $extrafields = new ExtraFields($db); // fetch optionals attributes and labels $extralabels = $extrafields->fetch_name_optionals_label('paymentsupplier'); -$search_array_options=$extrafields->getOptionalsFromPost($extralabels,'','search_'); +$search_array_options=$extrafields->getOptionalsFromPost('paymentsupplier','','search_'); $arrayfields=array(); @@ -570,25 +570,25 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie { print ''; } - + // Date Max Payment if ($objp->dlr > 0 ) { print ''; } else { print ''; } - + // Multicurrency if (!empty($conf->multicurrency->enabled)) { diff --git a/htdocs/holiday/list.php b/htdocs/holiday/list.php index f155f513a18..aecdce1ae06 100644 --- a/htdocs/holiday/list.php +++ b/htdocs/holiday/list.php @@ -78,7 +78,7 @@ $diroutputmassaction=$conf->holiday->dir_output . '/temp/massgeneration/'.$user- $hookmanager->initHooks(array('holidaylist')); // Note that conf->hooks_modules contains array // Fetch optionals attributes and labels $extralabels = $extrafields->fetch_name_optionals_label('holiday'); -$search_array_options=$extrafields->getOptionalsFromPost($extralabels,'','search_'); +$search_array_options=$extrafields->getOptionalsFromPost($object->table_element,'','search_'); // Default sort order (if not yet defined by previous GETPOST) if (! $sortfield) $sortfield="cp.rowid"; diff --git a/htdocs/modulebuilder/template/myobject_card.php b/htdocs/modulebuilder/template/myobject_card.php index 63d1664e1ff..f9b3db7a99e 100644 --- a/htdocs/modulebuilder/template/myobject_card.php +++ b/htdocs/modulebuilder/template/myobject_card.php @@ -81,7 +81,7 @@ $diroutputmassaction=$conf->mymodule->dir_output . '/temp/massgeneration/'.$user $hookmanager->initHooks(array('myobjectcard','globalcard')); // Note that conf->hooks_modules contains array // Fetch optionals attributes and labels $extralabels = $extrafields->fetch_name_optionals_label($object->table_element); -$search_array_options=$extrafields->getOptionalsFromPost($extralabels,'','search_'); +$search_array_options=$extrafields->getOptionalsFromPost($object->table_element,'','search_'); // Initialize array of search criterias $search_all=trim(GETPOST("search_all",'alpha')); diff --git a/htdocs/product/inventory/card.php b/htdocs/product/inventory/card.php index 2784e3c303b..24848ad26c5 100644 --- a/htdocs/product/inventory/card.php +++ b/htdocs/product/inventory/card.php @@ -53,7 +53,7 @@ $diroutputmassaction=$conf->stock->dir_output . '/temp/massgeneration/'.$user->i $hookmanager->initHooks(array('inventorycard')); // Note that conf->hooks_modules contains array // Fetch optionals attributes and labels $extralabels = $extrafields->fetch_name_optionals_label('inventory'); -$search_array_options=$extrafields->getOptionalsFromPost($extralabels,'','search_'); +$search_array_options=$extrafields->getOptionalsFromPost('inventory','','search_'); // Initialize array of search criterias $search_all=trim(GETPOST("search_all",'alpha')); diff --git a/htdocs/product/inventory/list.php b/htdocs/product/inventory/list.php index a5592c87f5d..95bb82aea50 100644 --- a/htdocs/product/inventory/list.php +++ b/htdocs/product/inventory/list.php @@ -59,7 +59,7 @@ $diroutputmassaction=$conf->inventory->dir_output . '/temp/massgeneration/'.$use $hookmanager->initHooks(array('inventorylist')); // Note that conf->hooks_modules contains array // Fetch optionals attributes and labels $extralabels = $extrafields->fetch_name_optionals_label('inventory'); -$search_array_options=$extrafields->getOptionalsFromPost($extralabels,'','search_'); +$search_array_options=$extrafields->getOptionalsFromPost($object->table_element,'','search_'); // Default sort order (if not yet defined by previous GETPOST) if (! $sortfield) $sortfield="t.".key($object->fields); // Set here default search field. By default 1st field in definition. diff --git a/htdocs/product/list.php b/htdocs/product/list.php index 562d09056c7..d05b01d6ae9 100644 --- a/htdocs/product/list.php +++ b/htdocs/product/list.php @@ -99,7 +99,7 @@ $form=new Form($db); // fetch optionals attributes and labels $extralabels = $extrafields->fetch_name_optionals_label('product'); -$search_array_options=$extrafields->getOptionalsFromPost($extralabels,'','search_'); +$search_array_options=$extrafields->getOptionalsFromPost($object->table_element,'','search_'); if (empty($action)) $action='list'; diff --git a/htdocs/product/stock/movement_list.php b/htdocs/product/stock/movement_list.php index 27c50d075aa..da7a834396a 100644 --- a/htdocs/product/stock/movement_list.php +++ b/htdocs/product/stock/movement_list.php @@ -90,7 +90,7 @@ $formfile = new FormFile($db); // fetch optionals attributes and labels $extralabels = $extrafields->fetch_name_optionals_label('movement'); -$search_array_options=$extrafields->getOptionalsFromPost($extralabels,'','search_'); +$search_array_options=$extrafields->getOptionalsFromPost($object->table_element,'','search_'); $arrayfields=array( 'm.rowid'=>array('label'=>$langs->trans("Ref"), 'checked'=>1), diff --git a/htdocs/product/stock/productlot_list.php b/htdocs/product/stock/productlot_list.php index 4d9916bfa9c..6de8be264a9 100644 --- a/htdocs/product/stock/productlot_list.php +++ b/htdocs/product/stock/productlot_list.php @@ -79,7 +79,7 @@ $extrafields = new ExtraFields($db); // fetch optionals attributes and labels $extralabels = $extrafields->fetch_name_optionals_label('product_lot'); -$search_array_options=$extrafields->getOptionalsFromPost($extralabels,'','search_'); +$search_array_options=$extrafields->getOptionalsFromPost($object->table_element,'','search_'); // List of fields to search into when doing a "search in all" $fieldstosearchall = array( diff --git a/htdocs/projet/list.php b/htdocs/projet/list.php index 5a13b16560d..87d82ffe03d 100644 --- a/htdocs/projet/list.php +++ b/htdocs/projet/list.php @@ -105,7 +105,7 @@ $extrafields = new ExtraFields($db); // fetch optionals attributes and labels $extralabels = $extrafields->fetch_name_optionals_label('projet'); -$search_array_options=$extrafields->getOptionalsFromPost($extralabels,'','search_'); +$search_array_options=$extrafields->getOptionalsFromPost($object->table_element,'','search_'); // List of fields to search into when doing a "search in all" $fieldstosearchall = array( diff --git a/htdocs/projet/tasks/list.php b/htdocs/projet/tasks/list.php index 2366ccc738b..2ace542c219 100644 --- a/htdocs/projet/tasks/list.php +++ b/htdocs/projet/tasks/list.php @@ -79,7 +79,7 @@ $extrafields = new ExtraFields($db); // fetch optionals attributes and labels $extralabels = $extrafields->fetch_name_optionals_label('projet_task'); -$search_array_options=$extrafields->getOptionalsFromPost($extralabels,'','search_'); +$search_array_options=$extrafields->getOptionalsFromPost($object->table_element,'','search_'); // Security check $socid=0; diff --git a/htdocs/public/ticket/list.php b/htdocs/public/ticket/list.php index 0d67e983143..f11583ac64d 100644 --- a/htdocs/public/ticket/list.php +++ b/htdocs/public/ticket/list.php @@ -182,7 +182,7 @@ if ($action == "view_ticketlist") // fetch optionals attributes and labels $extrafields = new ExtraFields($db); $extralabels = $extrafields->fetch_name_optionals_label('ticket'); - $search_array_options = $extrafields->getOptionalsFromPost($extralabels, '', 'search_'); + $search_array_options = $extrafields->getOptionalsFromPost('ticket', '', 'search_'); $filter = array(); $param = ''; diff --git a/htdocs/resource/list.php b/htdocs/resource/list.php index 4492d74be65..55dddcc0a48 100644 --- a/htdocs/resource/list.php +++ b/htdocs/resource/list.php @@ -50,7 +50,7 @@ $extrafields = new ExtraFields($db); // fetch optionals attributes and labels $extralabels=$extrafields->fetch_name_optionals_label($object->table_element); -$search_array_options=$extrafields->getOptionalsFromPost($extralabels,'','search_'); +$search_array_options=$extrafields->getOptionalsFromPost($object->table_element,'','search_'); $search_ref=GETPOST("search_ref"); $search_type=GETPOST("search_type"); diff --git a/htdocs/societe/list.php b/htdocs/societe/list.php index 684f6f8c471..f5513cb6aa3 100644 --- a/htdocs/societe/list.php +++ b/htdocs/societe/list.php @@ -121,7 +121,7 @@ $extrafields = new ExtraFields($db); // fetch optionals attributes and labels $extralabels = $extrafields->fetch_name_optionals_label('societe'); -$search_array_options=$extrafields->getOptionalsFromPost($extralabels,'','search_'); +$search_array_options=$extrafields->getOptionalsFromPost($object->table_element,'','search_'); // List of fields to search into when doing a "search in all" $fieldstosearchall = array( diff --git a/htdocs/societe/website.php b/htdocs/societe/website.php index 760bfef4d27..086a3db6d41 100644 --- a/htdocs/societe/website.php +++ b/htdocs/societe/website.php @@ -63,7 +63,7 @@ $diroutputmassaction=$conf->website->dir_output . '/temp/massgeneration/'.$user- $hookmanager->initHooks(array('websitethirdpartylist')); // Note that conf->hooks_modules contains array // Fetch optionals attributes and labels $extralabels = $extrafields->fetch_name_optionals_label('thirdpartyaccount'); -$search_array_options=$extrafields->getOptionalsFromPost($extralabels,'','search_'); +$search_array_options=$extrafields->getOptionalsFromPost('thirdpartyaccount','','search_'); unset($objectwebsiteaccount->fields['fk_soc']); // Remove this field, we are already on the thirdparty diff --git a/htdocs/supplier_proposal/list.php b/htdocs/supplier_proposal/list.php index 2fcb296b433..8a7266a4003 100644 --- a/htdocs/supplier_proposal/list.php +++ b/htdocs/supplier_proposal/list.php @@ -117,7 +117,7 @@ $extrafields = new ExtraFields($db); // fetch optionals attributes and labels $extralabels = $extrafields->fetch_name_optionals_label('supplier_proposal'); -$search_array_options=$extrafields->getOptionalsFromPost($extralabels,'','search_'); +$search_array_options=$extrafields->getOptionalsFromPost($object->table_element,'','search_'); // List of fields to search into when doing a "search in all" diff --git a/htdocs/takepos/customers.php b/htdocs/takepos/customers.php index f5bcb8557cf..fc7fbc54d2f 100644 --- a/htdocs/takepos/customers.php +++ b/htdocs/takepos/customers.php @@ -144,7 +144,7 @@ $extrafields = new ExtraFields($db); // fetch optionals attributes and labels $extralabels = $extrafields->fetch_name_optionals_label('societe'); -$search_array_options=$extrafields->getOptionalsFromPost($extralabels,'','search_'); +$search_array_options=$extrafields->getOptionalsFromPost('societe','','search_'); // List of fields to search into when doing a "search in all" $fieldstosearchall = array( diff --git a/htdocs/ticket/card.php b/htdocs/ticket/card.php index ef78b5eff45..ab16161e844 100644 --- a/htdocs/ticket/card.php +++ b/htdocs/ticket/card.php @@ -58,7 +58,7 @@ $object = new Ticket($db); $extrafields = new ExtraFields($db); // Fetch optionals attributes and labels $extralabels = $extrafields->fetch_name_optionals_label($object->table_element); -$search_array_options=$extrafields->getOptionalsFromPost($extralabels,'','search_'); +$search_array_options=$extrafields->getOptionalsFromPost($object->table_element,'','search_'); // Initialize array of search criterias $search_all=trim(GETPOST("search_all",'alpha')); diff --git a/htdocs/ticket/class/actions_ticket.class.php b/htdocs/ticket/class/actions_ticket.class.php index 7e8ae39564a..6ee61de76b9 100644 --- a/htdocs/ticket/class/actions_ticket.class.php +++ b/htdocs/ticket/class/actions_ticket.class.php @@ -258,7 +258,7 @@ class ActionsTicket // Extrafields $extrafields = new ExtraFields($this->db); $extralabels = $extrafields->fetch_name_optionals_label($fichinter->table_element); - $array_options = $extrafields->getOptionalsFromPost($extralabels); + $array_options = $extrafields->getOptionalsFromPost($fichinter->table_element); $fichinter->array_options = $array_options; $id = $fichinter->create($user); diff --git a/htdocs/ticket/list.php b/htdocs/ticket/list.php index 1b43d0054b7..545a5fcf1ed 100644 --- a/htdocs/ticket/list.php +++ b/htdocs/ticket/list.php @@ -77,7 +77,7 @@ else $hookmanager->initHooks(array('ticketlist')); // Fetch optionals attributes and labels $extralabels = $extrafields->fetch_name_optionals_label('ticket'); -$search_array_options=$extrafields->getOptionalsFromPost($extralabels,'','search_'); +$search_array_options=$extrafields->getOptionalsFromPost($object->table_element,'','search_'); // Default sort order (if not yet defined by previous GETPOST) if (! $sortfield) $sortfield="t.".key($object->fields); // Set here default search field. By default 1st field in definition. diff --git a/htdocs/user/list.php b/htdocs/user/list.php index 64c63c05426..7d856c52891 100644 --- a/htdocs/user/list.php +++ b/htdocs/user/list.php @@ -68,7 +68,7 @@ $extrafields = new ExtraFields($db); // fetch optionals attributes and labels $extralabels = $extrafields->fetch_name_optionals_label('user'); -$search_array_options=$extrafields->getOptionalsFromPost($extralabels,'','search_'); +$search_array_options=$extrafields->getOptionalsFromPost($object->table_element,'','search_'); $userstatic=new User($db); $companystatic = new Societe($db); diff --git a/htdocs/website/websiteaccount_card.php b/htdocs/website/websiteaccount_card.php index 49965b9009a..24f87678505 100644 --- a/htdocs/website/websiteaccount_card.php +++ b/htdocs/website/websiteaccount_card.php @@ -46,7 +46,7 @@ $diroutputmassaction=$conf->website->dir_output . '/temp/massgeneration/'.$user- $hookmanager->initHooks(array('websiteaccountcard')); // Note that conf->hooks_modules contains array // Fetch optionals attributes and labels $extralabels = $extrafields->fetch_name_optionals_label('societeaccount'); -$search_array_options=$extrafields->getOptionalsFromPost($extralabels,'','search_'); +$search_array_options=$extrafields->getOptionalsFromPost($object->table_element,'','search_'); // Initialize array of search criterias $search_all=trim(GETPOST("search_all",'alpha')); From 46db246273141cbdefc24af4e2ca5d0592579bcf Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 7 Nov 2018 13:04:43 +0100 Subject: [PATCH 086/132] Look and feel v9: Autofocus on create forms --- htdocs/adherents/card.php | 2 +- htdocs/adherents/type.php | 2 +- htdocs/comm/mailing/card.php | 2 +- htdocs/loan/card.php | 2 +- htdocs/resource/card.php | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/htdocs/adherents/card.php b/htdocs/adherents/card.php index fee1848b925..db6fb35206b 100644 --- a/htdocs/adherents/card.php +++ b/htdocs/adherents/card.php @@ -907,7 +907,7 @@ else // Login if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED)) { - print ''; + print ''; } // Password diff --git a/htdocs/adherents/type.php b/htdocs/adherents/type.php index 7e69d4fbc98..6261a379049 100644 --- a/htdocs/adherents/type.php +++ b/htdocs/adherents/type.php @@ -317,7 +317,7 @@ if ($action == 'create') print '
'; @@ -219,11 +222,11 @@ if ($socid > 0) print dol_print_date($db->jdate($objp->datef),'day')."".price($objp->selling_price, null, null, null, null, $rounding)."".price(($objp->type == 2 ? -1 : 1) * $objp->buying_price, null, null, null, null, $rounding)."".price($objp->marge, null, null, null, null, $rounding)."".$sign.price($objp->marge, null, null, null, null, $rounding)."".(($marginRate === '')?'n/a':price($marginRate, null, null, null, null, $rounding)."%")."".(($marginRate === '')?'n/a':$sign.price($marginRate, null, null, null, null, $rounding)."%")."".(($markRate === '')?'n/a':price($markRate, null, null, null, null, $rounding)."%")."".(($markRate === '')?'n/a':price($markRate, null, null, null, null, $rounding)."%")."'.$invoicestatic->LibStatut($objp->paye,$objp->statut,5).'
!!!'; print dol_print_date($db->jdate($objp->dlr), 'day'); - + if ($invoice->hasDelay()) { print img_warning($langs->trans('Late')); } - + print '--
'.$langs->trans("Login").' / '.$langs->trans("Id").'login).'">
'.$langs->trans("Login").' / '.$langs->trans("Id").'login).'" autofocus="autofocus">
'; print ''; - print ''; + print ''; print ''; - print ''; + print ''; print ''; - print ''; + print ''; print ''; } @@ -389,7 +444,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea print ''; @@ -402,9 +457,14 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea $ruleactionobj->fetch($ruleaction['id']); print ''; - print ''; - print ''; - print ''; + print ''; + print ''; + print ''; print ''; } diff --git a/htdocs/emailcollector/class/emailcollector.class.php b/htdocs/emailcollector/class/emailcollector.class.php index 5131db78759..e4c0d4f588f 100644 --- a/htdocs/emailcollector/class/emailcollector.class.php +++ b/htdocs/emailcollector/class/emailcollector.class.php @@ -523,28 +523,28 @@ class EmailCollector extends CommonObject } elseif ($mode == 2) { - if ($status == 1) return img_picto($this->labelstatus[$status],'statut4').' '.$this->labelstatus[$status]; - elseif ($status == 0) return img_picto($this->labelstatus[$status],'statut5').' '.$this->labelstatus[$status]; + if ($status == 1) return img_picto($this->labelstatus[$status],'statut4', '', false, 0, 0, '', 'valignmiddle').' '.$this->labelstatus[$status]; + elseif ($status == 0) return img_picto($this->labelstatus[$status],'statut5', '', false, 0, 0, '', 'valignmiddle').' '.$this->labelstatus[$status]; } elseif ($mode == 3) { - if ($status == 1) return img_picto($this->labelstatus[$status],'statut4'); - elseif ($status == 0) return img_picto($this->labelstatus[$status],'statut5'); + if ($status == 1) return img_picto($this->labelstatus[$status],'statut4', '', false, 0, 0, '', 'valignmiddle'); + elseif ($status == 0) return img_picto($this->labelstatus[$status],'statut5', '', false, 0, 0, '', 'valignmiddle'); } elseif ($mode == 4) { - if ($status == 1) return img_picto($this->labelstatus[$status],'statut4').' '.$this->labelstatus[$status]; - elseif ($status == 0) return img_picto($this->labelstatus[$status],'statut5').' '.$this->labelstatus[$status]; + if ($status == 1) return img_picto($this->labelstatus[$status],'statut4', '', false, 0, 0, '', 'valignmiddle').' '.$this->labelstatus[$status]; + elseif ($status == 0) return img_picto($this->labelstatus[$status],'statut5', '', false, 0, 0, '', 'valignmiddle').' '.$this->labelstatus[$status]; } elseif ($mode == 5) { - if ($status == 1) return $this->labelstatus[$status].' '.img_picto($this->labelstatus[$status],'statut4'); - elseif ($status == 0) return $this->labelstatus[$status].' '.img_picto($this->labelstatus[$status],'statut5'); + if ($status == 1) return $this->labelstatus[$status].' '.img_picto($this->labelstatus[$status],'statut4', '', false, 0, 0, '', 'valignmiddle'); + elseif ($status == 0) return $this->labelstatus[$status].' '.img_picto($this->labelstatus[$status],'statut5', '', false, 0, 0, '', 'valignmiddle'); } elseif ($mode == 6) { - if ($status == 1) return $this->labelstatus[$status].' '.img_picto($this->labelstatus[$status],'statut4'); - elseif ($status == 0) return $this->labelstatus[$status].' '.img_picto($this->labelstatus[$status],'statut5'); + if ($status == 1) return $this->labelstatus[$status].' '.img_picto($this->labelstatus[$status],'statut4', '', false, 0, 0, '', 'valignmiddle'); + elseif ($status == 0) return $this->labelstatus[$status].' '.img_picto($this->labelstatus[$status],'statut5', '', false, 0, 0, '', 'valignmiddle'); } } @@ -619,7 +619,7 @@ class EmailCollector extends CommonObject */ public function fetchFilters() { - $this->rules = array(); + $this->filters = array(); $sql='SELECT rowid, type, rulevalue, status FROM '.MAIN_DB_PREFIX.'emailcollector_emailcollectorfilter WHERE fk_emailcollector = '.$this->id; @@ -636,6 +636,7 @@ class EmailCollector extends CommonObject } $this->db->free($resql); } + else dol_print_error($this->db); return 1; } @@ -659,11 +660,12 @@ class EmailCollector extends CommonObject while($i < $num) { $obj=$this->db->fetch_object($resql); - $this->rules[$obj->rowid]=array('id'=>$obj->rowid, 'type'=>$obj->type, 'actionparam'=>$obj->actionparam, 'status'=>$obj->status); + $this->actions[$obj->rowid]=array('id'=>$obj->rowid, 'type'=>$obj->type, 'actionparam'=>$obj->actionparam, 'status'=>$obj->status); $i++; } $this->db->free($resql); } + else dol_print_error($this->db); } diff --git a/htdocs/emailcollector/class/emailcollectoraction.class.php b/htdocs/emailcollector/class/emailcollectoraction.class.php index 5e0e85abdaf..42eecd097bd 100644 --- a/htdocs/emailcollector/class/emailcollectoraction.class.php +++ b/htdocs/emailcollector/class/emailcollectoraction.class.php @@ -50,7 +50,7 @@ class EmailCollectorAction extends CommonObject /** * @var int Does emailcollectoraction support extrafields ? 0=No, 1=Yes */ - public $isextrafieldmanaged = 1; + public $isextrafieldmanaged = 0; /** * @var string String with name of icon for emailcollectoraction. Must be the part after the 'object_' into object_emailcollectoraction.png @@ -181,6 +181,14 @@ class EmailCollectorAction extends CommonObject */ public function create(User $user, $notrigger = false) { + global $langs; + if (empty($this->type)) + { + $langs->load("errors"); + $this->errors[]=$langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Type")); + return -1; + } + return $this->createCommon($user, $notrigger); } @@ -414,28 +422,28 @@ class EmailCollectorAction extends CommonObject } elseif ($mode == 2) { - if ($status == 1) return img_picto($this->labelstatus[$status],'statut4').' '.$this->labelstatus[$status]; - elseif ($status == 0) return img_picto($this->labelstatus[$status],'statut5').' '.$this->labelstatus[$status]; + if ($status == 1) return img_picto($this->labelstatus[$status],'statut4', '', false, 0, 0, '', 'valignmiddle').' '.$this->labelstatus[$status]; + elseif ($status == 0) return img_picto($this->labelstatus[$status],'statut5', '', false, 0, 0, '', 'valignmiddle').' '.$this->labelstatus[$status]; } elseif ($mode == 3) { - if ($status == 1) return img_picto($this->labelstatus[$status],'statut4'); - elseif ($status == 0) return img_picto($this->labelstatus[$status],'statut5'); + if ($status == 1) return img_picto($this->labelstatus[$status],'statut4', '', false, 0, 0, '', 'valignmiddle'); + elseif ($status == 0) return img_picto($this->labelstatus[$status],'statut5', '', false, 0, 0, '', 'valignmiddle'); } elseif ($mode == 4) { - if ($status == 1) return img_picto($this->labelstatus[$status],'statut4').' '.$this->labelstatus[$status]; - elseif ($status == 0) return img_picto($this->labelstatus[$status],'statut5').' '.$this->labelstatus[$status]; + if ($status == 1) return img_picto($this->labelstatus[$status],'statut4', '', false, 0, 0, '', 'valignmiddle').' '.$this->labelstatus[$status]; + elseif ($status == 0) return img_picto($this->labelstatus[$status],'statut5', '', false, 0, 0, '', 'valignmiddle').' '.$this->labelstatus[$status]; } elseif ($mode == 5) { - if ($status == 1) return $this->labelstatus[$status].' '.img_picto($this->labelstatus[$status],'statut4'); - elseif ($status == 0) return $this->labelstatus[$status].' '.img_picto($this->labelstatus[$status],'statut5'); + if ($status == 1) return $this->labelstatus[$status].' '.img_picto($this->labelstatus[$status],'statut4', '', false, 0, 0, '', 'valignmiddle'); + elseif ($status == 0) return $this->labelstatus[$status].' '.img_picto($this->labelstatus[$status],'statut5', '', false, 0, 0, '', 'valignmiddle'); } elseif ($mode == 6) { - if ($status == 1) return $this->labelstatus[$status].' '.img_picto($this->labelstatus[$status],'statut4'); - elseif ($status == 0) return $this->labelstatus[$status].' '.img_picto($this->labelstatus[$status],'statut5'); + if ($status == 1) return $this->labelstatus[$status].' '.img_picto($this->labelstatus[$status],'statut4', '', false, 0, 0, '', 'valignmiddle'); + elseif ($status == 0) return $this->labelstatus[$status].' '.img_picto($this->labelstatus[$status],'statut5', '', false, 0, 0, '', 'valignmiddle'); } } diff --git a/htdocs/emailcollector/class/emailcollectorfilter.class.php b/htdocs/emailcollector/class/emailcollectorfilter.class.php index deb5bb88824..23c8f7a02b2 100644 --- a/htdocs/emailcollector/class/emailcollectorfilter.class.php +++ b/htdocs/emailcollector/class/emailcollectorfilter.class.php @@ -50,7 +50,7 @@ class EmailCollectorFilter extends CommonObject /** * @var int Does emailcollectorfilter support extrafields ? 0=No, 1=Yes */ - public $isextrafieldmanaged = 1; + public $isextrafieldmanaged = 0; /** * @var string String with name of icon for emailcollectorfilter. Must be the part after the 'object_' into object_emailcollectorfilter.png @@ -152,6 +152,20 @@ class EmailCollectorFilter extends CommonObject */ public function create(User $user, $notrigger = false) { + global $langs; + if (empty($this->type)) + { + $langs->load("errors"); + $this->errors[]=$langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Type")); + return -1; + } + if (empty($this->rulevalue)) + { + $langs->load("errors"); + $this->errors[]=$langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("RuleValue")); + return -1; + } + return $this->createCommon($user, $notrigger); } @@ -385,28 +399,28 @@ class EmailCollectorFilter extends CommonObject } elseif ($mode == 2) { - if ($status == 1) return img_picto($this->labelstatus[$status],'statut4').' '.$this->labelstatus[$status]; - elseif ($status == 0) return img_picto($this->labelstatus[$status],'statut5').' '.$this->labelstatus[$status]; + if ($status == 1) return img_picto($this->labelstatus[$status],'statut4', '', false, 0, 0, '', 'valignmiddle').' '.$this->labelstatus[$status]; + elseif ($status == 0) return img_picto($this->labelstatus[$status],'statut5', '', false, 0, 0, '', 'valignmiddle').' '.$this->labelstatus[$status]; } elseif ($mode == 3) { - if ($status == 1) return img_picto($this->labelstatus[$status],'statut4'); - elseif ($status == 0) return img_picto($this->labelstatus[$status],'statut5'); + if ($status == 1) return img_picto($this->labelstatus[$status],'statut4', '', false, 0, 0, '', 'valignmiddle'); + elseif ($status == 0) return img_picto($this->labelstatus[$status],'statut5', '', false, 0, 0, '', 'valignmiddle'); } elseif ($mode == 4) { - if ($status == 1) return img_picto($this->labelstatus[$status],'statut4').' '.$this->labelstatus[$status]; - elseif ($status == 0) return img_picto($this->labelstatus[$status],'statut5').' '.$this->labelstatus[$status]; + if ($status == 1) return img_picto($this->labelstatus[$status],'statut4', '', false, 0, 0, '', 'valignmiddle').' '.$this->labelstatus[$status]; + elseif ($status == 0) return img_picto($this->labelstatus[$status],'statut5', '', false, 0, 0, '', 'valignmiddle').' '.$this->labelstatus[$status]; } elseif ($mode == 5) { - if ($status == 1) return $this->labelstatus[$status].' '.img_picto($this->labelstatus[$status],'statut4'); - elseif ($status == 0) return $this->labelstatus[$status].' '.img_picto($this->labelstatus[$status],'statut5'); + if ($status == 1) return $this->labelstatus[$status].' '.img_picto($this->labelstatus[$status],'statut4', '', false, 0, 0, '', 'valignmiddle'); + elseif ($status == 0) return $this->labelstatus[$status].' '.img_picto($this->labelstatus[$status],'statut5', '', false, 0, 0, '', 'valignmiddle'); } elseif ($mode == 6) { - if ($status == 1) return $this->labelstatus[$status].' '.img_picto($this->labelstatus[$status],'statut4'); - elseif ($status == 0) return $this->labelstatus[$status].' '.img_picto($this->labelstatus[$status],'statut5'); + if ($status == 1) return $this->labelstatus[$status].' '.img_picto($this->labelstatus[$status],'statut4', '', false, 0, 0, '', 'valignmiddle'); + elseif ($status == 0) return $this->labelstatus[$status].' '.img_picto($this->labelstatus[$status],'statut5', '', false, 0, 0, '', 'valignmiddle'); } } diff --git a/htdocs/install/mysql/migration/8.0.0-9.0.0.sql b/htdocs/install/mysql/migration/8.0.0-9.0.0.sql index d1e2d87b444..05106e475cd 100644 --- a/htdocs/install/mysql/migration/8.0.0-9.0.0.sql +++ b/htdocs/install/mysql/migration/8.0.0-9.0.0.sql @@ -206,6 +206,9 @@ ALTER TABLE llx_emailcollector_emailcollectoraction ADD INDEX idx_emailcollector ALTER TABLE llx_emailcollector_emailcollectoraction ADD CONSTRAINT fk_emailcollectoraction_fk_emailcollector FOREIGN KEY (fk_emailcollector) REFERENCES llx_emailcollector_emailcollector(rowid); +ALTER TABLE llx_emailcollector_emailcollectorfilter ADD UNIQUE INDEX uk_emailcollector_emailcollectorfilter (fk_emailcollector, type, rulevalue); +ALTER TABLE llx_emailcollector_emailcollectoraction ADD UNIQUE INDEX uk_emailcollector_emailcollectoraction (fk_emailcollector, type); + diff --git a/htdocs/install/mysql/tables/llx_emailcollector_emailcollectoraction.key.sql b/htdocs/install/mysql/tables/llx_emailcollector_emailcollectoraction.key.sql index 0ef98e90b41..ef8a91b5d31 100644 --- a/htdocs/install/mysql/tables/llx_emailcollector_emailcollectoraction.key.sql +++ b/htdocs/install/mysql/tables/llx_emailcollector_emailcollectoraction.key.sql @@ -19,3 +19,4 @@ ALTER TABLE llx_emailcollector_emailcollectoraction ADD INDEX idx_emailcollector ALTER TABLE llx_emailcollector_emailcollectoraction ADD CONSTRAINT fk_emailcollectoraction_fk_emailcollector FOREIGN KEY (fk_emailcollector) REFERENCES llx_emailcollector_emailcollector(rowid); -- END MODULEBUILDER INDEXES +ALTER TABLE llx_emailcollector_emailcollectoraction ADD UNIQUE INDEX uk_emailcollector_emailcollectoraction (fk_emailcollector, type); diff --git a/htdocs/install/mysql/tables/llx_emailcollector_emailcollectorfilter.key.sql b/htdocs/install/mysql/tables/llx_emailcollector_emailcollectorfilter.key.sql index fb65963b63a..e0eb095fad1 100644 --- a/htdocs/install/mysql/tables/llx_emailcollector_emailcollectorfilter.key.sql +++ b/htdocs/install/mysql/tables/llx_emailcollector_emailcollectorfilter.key.sql @@ -19,3 +19,5 @@ ALTER TABLE llx_emailcollector_emailcollectorfilter ADD INDEX idx_emailcollector ALTER TABLE llx_emailcollector_emailcollectorfilter ADD CONSTRAINT fk_emailcollectorfilter_fk_emailcollector FOREIGN KEY (fk_emailcollector) REFERENCES llx_emailcollector_emailcollector(rowid); -- END MODULEBUILDER INDEXES +ALTER TABLE llx_emailcollector_emailcollectorfilter ADD UNIQUE INDEX uk_emailcollector_emailcollectorfilter (fk_emailcollector, type, rulevalue); + diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index e074210bd1a..d9be14b3cb7 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -1830,6 +1830,8 @@ EmailCollectorConfirmCollect=Do you want to run the collect for this collector n NoNewEmailToProcess=No new email to process NothingProcessed=Nothing done XEmailsDoneYActionsDone=%s emails analyzed, %s record/actions done by collector +RecordEvent=Record event +CreateLeadAndThirdParty=Create lead (and thirdparty if necessary) ##### Resource #### ResourceSetup=Configuration du module Resource UseSearchToSelectResource=Use a search form to choose a resource (rather than a drop-down list). diff --git a/htdocs/modulebuilder/template/class/myobject.class.php b/htdocs/modulebuilder/template/class/myobject.class.php index 58dfe5924cf..e318bfe3a00 100644 --- a/htdocs/modulebuilder/template/class/myobject.class.php +++ b/htdocs/modulebuilder/template/class/myobject.class.php @@ -453,28 +453,28 @@ class MyObject extends CommonObject } elseif ($mode == 2) { - if ($status == 1) return img_picto($this->labelstatus[$status],'statut4').' '.$this->labelstatus[$status]; - elseif ($status == 0) return img_picto($this->labelstatus[$status],'statut5').' '.$this->labelstatus[$status]; + if ($status == 1) return img_picto($this->labelstatus[$status],'statut4', '', false, 0, 0, '', 'valignmiddle').' '.$this->labelstatus[$status]; + elseif ($status == 0) return img_picto($this->labelstatus[$status],'statut5', '', false, 0, 0, '', 'valignmiddle').' '.$this->labelstatus[$status]; } elseif ($mode == 3) { - if ($status == 1) return img_picto($this->labelstatus[$status],'statut4'); - elseif ($status == 0) return img_picto($this->labelstatus[$status],'statut5'); + if ($status == 1) return img_picto($this->labelstatus[$status],'statut4', '', false, 0, 0, '', 'valignmiddle'); + elseif ($status == 0) return img_picto($this->labelstatus[$status],'statut5', '', false, 0, 0, '', 'valignmiddle'); } elseif ($mode == 4) { - if ($status == 1) return img_picto($this->labelstatus[$status],'statut4').' '.$this->labelstatus[$status]; - elseif ($status == 0) return img_picto($this->labelstatus[$status],'statut5').' '.$this->labelstatus[$status]; + if ($status == 1) return img_picto($this->labelstatus[$status],'statut4', '', false, 0, 0, '', 'valignmiddle').' '.$this->labelstatus[$status]; + elseif ($status == 0) return img_picto($this->labelstatus[$status],'statut5', '', false, 0, 0, '', 'valignmiddle').' '.$this->labelstatus[$status]; } elseif ($mode == 5) { - if ($status == 1) return $this->labelstatus[$status].' '.img_picto($this->labelstatus[$status],'statut4'); - elseif ($status == 0) return $this->labelstatus[$status].' '.img_picto($this->labelstatus[$status],'statut5'); + if ($status == 1) return $this->labelstatus[$status].' '.img_picto($this->labelstatus[$status],'statut4', '', false, 0, 0, '', 'valignmiddle'); + elseif ($status == 0) return $this->labelstatus[$status].' '.img_picto($this->labelstatus[$status],'statut5', '', false, 0, 0, '', 'valignmiddle'); } elseif ($mode == 6) { - if ($status == 1) return $this->labelstatus[$status].' '.img_picto($this->labelstatus[$status],'statut4'); - elseif ($status == 0) return $this->labelstatus[$status].' '.img_picto($this->labelstatus[$status],'statut5'); + if ($status == 1) return $this->labelstatus[$status].' '.img_picto($this->labelstatus[$status],'statut4', '', false, 0, 0, '', 'valignmiddle'); + elseif ($status == 0) return $this->labelstatus[$status].' '.img_picto($this->labelstatus[$status],'statut5', '', false, 0, 0, '', 'valignmiddle'); } } From 9dbb222a0ae66851dd2c0213b446d86e7dce3b70 Mon Sep 17 00:00:00 2001 From: AXeL-dev Date: Wed, 7 Nov 2018 18:27:41 +0100 Subject: [PATCH 094/132] remove useless line of code --- htdocs/main.inc.php | 1 - 1 file changed, 1 deletion(-) diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index 7fbb0cbb07b..7d02b39e25a 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -1382,7 +1382,6 @@ function top_htmlhead($head, $title='', $disablejs=0, $disablehead=0, $arrayofjs } else { - if (! preg_match('/^\//',$jsfile)) $jsfile='/'.$jsfile; // For backward compatibility print ''."\n"; } } From df224e4b54e0117b011f000b348e4b7d46b3f093 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Wed, 7 Nov 2018 21:51:05 +0100 Subject: [PATCH 095/132] can click on image to preview in doc list --- htdocs/core/class/html.formfile.class.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/htdocs/core/class/html.formfile.class.php b/htdocs/core/class/html.formfile.class.php index 81a288e7dce..fba539ffe7e 100644 --- a/htdocs/core/class/html.formfile.class.php +++ b/htdocs/core/class/html.formfile.class.php @@ -1219,9 +1219,13 @@ class FormFile if (! dol_is_file($file['path'].'/'.$minifile)) $minifile=getImageFileNameForSize($file['name'], '_mini', '.png'); // For backward compatibility of old thumbs that were created with filename in lower case and with .png extension //print $file['path'].'/'.$minifile.'
'; - $urlforhref=getAdvancedPreviewUrl($modulepart, $relativepath.$fileinfo['filename'].'.'.strtolower($fileinfo['extension']), 0, '&entity='.(!empty($object->entity)?$object->entity:$conf->entity)); - if (empty($urlforhref)) $urlforhref=DOL_URL_ROOT.'/viewimage.php?modulepart='.$modulepart.'&entity='.(!empty($object->entity)?$object->entity:$conf->entity).'&file='.urlencode($relativepath.$fileinfo['filename'].'.'.strtolower($fileinfo['extension'])); - print ''; + $urlforhref=getAdvancedPreviewUrl($modulepart, $relativepath.$fileinfo['filename'].'.'.strtolower($fileinfo['extension']), 1, '&entity='.(!empty($object->entity)?$object->entity:$conf->entity)); + if (empty($urlforhref)) { + $urlforhref=DOL_URL_ROOT.'/viewimage.php?modulepart='.$modulepart.'&entity='.(!empty($object->entity)?$object->entity:$conf->entity).'&file='.urlencode($relativepath.$fileinfo['filename'].'.'.strtolower($fileinfo['extension'])); + print ''; + } else { + print ''; + } print ''; print ''; } From 3ba3a47f2037b9b067bffd87fe8e78f8193d4b61 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Wed, 7 Nov 2018 22:04:55 +0100 Subject: [PATCH 096/132] close window --- htdocs/core/js/lib_head.js.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/js/lib_head.js.php b/htdocs/core/js/lib_head.js.php index 1aa9c458e39..cf8d641893a 100644 --- a/htdocs/core/js/lib_head.js.php +++ b/htdocs/core/js/lib_head.js.php @@ -918,7 +918,7 @@ function document_preview(file, type, title) { optionsbuttons = { "transnoentitiesnoconv("OriginalSize")); ?>": function() { console.log("Click on original size"); jQuery(".ui-dialog-content.ui-widget-content > object").css({ "max-height": "none" }); }, - "transnoentitiesnoconv("Close")); ?>": function() { $( this ).dialog( "close" ); } + "transnoentitiesnoconv("CloseWindow")); ?>": function() { $( this ).dialog( "close" ); } }; } From 976516a79627f6815f389e0ec2f7e52072739985 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 8 Nov 2018 09:51:46 +0100 Subject: [PATCH 097/132] Fix look and feel v8 --- htdocs/compta/index.php | 2 +- htdocs/compta/sociales/card.php | 2 +- htdocs/compta/sociales/document.php | 2 +- htdocs/compta/sociales/info.php | 2 +- .../compta/sociales/{index.php => list.php} | 29 +++++++++++-------- htdocs/core/menus/init_menu_auguria.sql | 2 +- htdocs/core/menus/standard/eldy.lib.php | 4 +-- 7 files changed, 24 insertions(+), 19 deletions(-) rename htdocs/compta/sociales/{index.php => list.php} (92%) diff --git a/htdocs/compta/index.php b/htdocs/compta/index.php index 692849d2fa6..3d6cf735999 100644 --- a/htdocs/compta/index.php +++ b/htdocs/compta/index.php @@ -636,7 +636,7 @@ if (! empty($conf->tax->enabled) && $user->rights->tax->charges->lire) print '
'.$langs->trans("Label").'
'.$langs->trans("Label").'
'.$langs->trans("SubscriptionRequired").''; print $form->selectyesno("subscription",1,1); diff --git a/htdocs/comm/mailing/card.php b/htdocs/comm/mailing/card.php index 28e49e9d171..e4f74f5c35f 100644 --- a/htdocs/comm/mailing/card.php +++ b/htdocs/comm/mailing/card.php @@ -747,7 +747,7 @@ if ($action == 'create') dol_fiche_head(); print ''; - print ''; + print ''; print ''; print ''; diff --git a/htdocs/loan/card.php b/htdocs/loan/card.php index e2491167ed8..3214ac5a971 100644 --- a/htdocs/loan/card.php +++ b/htdocs/loan/card.php @@ -264,7 +264,7 @@ if ($action == 'create') print '
'.$langs->trans("MailTitle").'
'.$langs->trans("MailTitle").'
'.$langs->trans("MailFrom").'
'.$langs->trans("MailErrorsTo").'
'; // Label - print ''; + print ''; // Bank account if (! empty($conf->banque->enabled)) diff --git a/htdocs/resource/card.php b/htdocs/resource/card.php index 49cad87e990..8fd7f5bcd13 100644 --- a/htdocs/resource/card.php +++ b/htdocs/resource/card.php @@ -250,7 +250,7 @@ if ($action == 'create' || $object->fetch($id) > 0) // Ref print ''; - print ''; + print ''; // Type print ''; From 671b4dc22703ab269534649546a8350d912f652f Mon Sep 17 00:00:00 2001 From: Philippe GRAND Date: Wed, 7 Nov 2018 14:01:49 +0100 Subject: [PATCH 087/132] fix : missing translation --- htdocs/adherents/index.php | 6 +++--- htdocs/fichinter/card.php | 2 +- htdocs/langs/en_US/interventions.lang | 1 + 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/htdocs/adherents/index.php b/htdocs/adherents/index.php index 931e9323904..ffe75df1c81 100644 --- a/htdocs/adherents/index.php +++ b/htdocs/adherents/index.php @@ -55,7 +55,7 @@ $AdherentsResilies=array(); $AdherentType=array(); -// Liste les adherents +// Members list $sql = "SELECT t.rowid, t.libelle as label, t.subscription,"; $sql.= " d.statut, count(d.rowid) as somme"; $sql.= " FROM ".MAIN_DB_PREFIX."adherent_type as t"; @@ -92,7 +92,7 @@ if ($result) $now=dol_now(); -// List members up to date +// Members up to date list // current rule: uptodate = the end date is in future whatever is type // old rule: uptodate = if type does not need payment, that end date is null, if type need payment that end date is in future) $sql = "SELECT count(*) as somme , d.fk_adherent_type"; @@ -140,7 +140,7 @@ if (! empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS)) // This is usele foreach($listofsearchfields as $key => $value) { if ($i == 0) print ''; - print ''; + print ''; print ''; if ($i == 0) print ''; print ''; diff --git a/htdocs/fichinter/card.php b/htdocs/fichinter/card.php index fe15141c86c..23ad91d8831 100644 --- a/htdocs/fichinter/card.php +++ b/htdocs/fichinter/card.php @@ -1649,7 +1649,7 @@ else if ($id > 0 || ! empty($ref)) // create interventional model if ($object->statut == Fichinter::STATUS_DRAFT && $user->rights->ficheinter->creer && (count($object->lines) > 0)) { print ''; } diff --git a/htdocs/langs/en_US/interventions.lang b/htdocs/langs/en_US/interventions.lang index 604d51c41b9..a130367b14f 100644 --- a/htdocs/langs/en_US/interventions.lang +++ b/htdocs/langs/en_US/interventions.lang @@ -4,6 +4,7 @@ Interventions=Interventions InterventionCard=Intervention card NewIntervention=New intervention AddIntervention=Create intervention +ChangeIntoRepeatableIntervention=Change to repeatable intervention ListOfInterventions=List of interventions ActionsOnFicheInter=Actions on intervention LastInterventions=Latest %s interventions From f6394e4210248cb765d80ac58bab719a3dea37b4 Mon Sep 17 00:00:00 2001 From: Philippe GRAND Date: Wed, 7 Nov 2018 15:07:57 +0100 Subject: [PATCH 088/132] fix : error 500 --- htdocs/fichinter/card.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/htdocs/fichinter/card.php b/htdocs/fichinter/card.php index 23ad91d8831..cd172888a28 100644 --- a/htdocs/fichinter/card.php +++ b/htdocs/fichinter/card.php @@ -7,6 +7,7 @@ * Copyright (C) 2014-2018 Ferran Marcet * Copyright (C) 2014-2018 Charlene Benke * Copyright (C) 2015-2016 Abbes Bahfir + * Copyright (C) 2018 Philippe Grand * * 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 @@ -1646,10 +1647,12 @@ else if ($id > 0 || ! empty($ref)) else print ''; } - // create interventional model + // create intervention model if ($object->statut == Fichinter::STATUS_DRAFT && $user->rights->ficheinter->creer && (count($object->lines) > 0)) { print ''; } From afdefa56bdffdbacff1b5bdbc4f1cb82e91db005 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20J?= Date: Wed, 7 Nov 2018 15:34:07 +0100 Subject: [PATCH 089/132] New Search Contact by Town Adding the missing SQL condition to filter contact list by user requested town --- htdocs/contact/list.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/contact/list.php b/htdocs/contact/list.php index 52a2c4bbe7f..04b12ddb4eb 100644 --- a/htdocs/contact/list.php +++ b/htdocs/contact/list.php @@ -321,6 +321,7 @@ if (strlen($search_twitter)) $sql.= natural_search('p.twitter', $search_t if (strlen($search_facebook)) $sql.= natural_search('p.facebook', $search_facebook); if (strlen($search_email)) $sql.= natural_search('p.email', $search_email); if (strlen($search_zip)) $sql.= natural_search("p.zip",$search_zip); +if (strlen($search_town)) $sql.= natural_search("p.town",$search_town); if ($search_status != '' && $search_status >= 0) $sql.= " AND p.statut = ".$db->escape($search_status); if ($search_import_key) $sql.= natural_search("p.import_key",$search_import_key); if ($type == "o") // filtre sur type From 05a679a10c3a9957ac053aabede07ffa974abc01 Mon Sep 17 00:00:00 2001 From: gauthier Date: Wed, 7 Nov 2018 16:26:25 +0100 Subject: [PATCH 090/132] FIX : OppStatusShort doesn't exists --- htdocs/projet/list.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/projet/list.php b/htdocs/projet/list.php index 6b3613a7b0a..5f683a251a2 100644 --- a/htdocs/projet/list.php +++ b/htdocs/projet/list.php @@ -533,7 +533,7 @@ if (! empty($arrayfields['p.public']['checked'])) if (! empty($arrayfields['p.fk_opp_status']['checked'])) { print ''; } if (! empty($arrayfields['p.opp_amount']['checked'])) From 70826c31912808e6ddce76783f416b245f41c3f8 Mon Sep 17 00:00:00 2001 From: gauthier Date: Wed, 7 Nov 2018 16:32:23 +0100 Subject: [PATCH 091/132] FIX : same on lines --- htdocs/projet/list.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/projet/list.php b/htdocs/projet/list.php index 5f683a251a2..86f1c2ffcad 100644 --- a/htdocs/projet/list.php +++ b/htdocs/projet/list.php @@ -742,7 +742,7 @@ while ($i < min($num,$limit)) if (! empty($arrayfields['p.fk_opp_status']['checked'])) { print ''; if (! $i) $totalarray['nbfield']++; } From 6ba78b2bb328627af52f7177368d23d3fb0eff59 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 7 Nov 2018 16:33:06 +0100 Subject: [PATCH 092/132] Work on email collector --- htdocs/admin/emailcollector_card.php | 33 ++++++++++++++++--- .../core/modules/modEmailCollector.class.php | 4 +-- htdocs/core/modules/modGravatar.class.php | 2 ++ htdocs/core/modules/modLdap.class.php | 2 ++ htdocs/core/modules/modMailing.class.php | 7 +++- htdocs/core/modules/modMailmanSpip.class.php | 4 +++ htdocs/core/modules/modNotification.class.php | 4 +++ htdocs/core/modules/modOauth.class.php | 2 +- .../core/modules/modSocialNetworks.class.php | 2 ++ .../class/emailcollector.class.php | 2 ++ htdocs/langs/en_US/admin.lang | 2 ++ htdocs/langs/en_US/main.lang | 2 ++ 12 files changed, 58 insertions(+), 8 deletions(-) diff --git a/htdocs/admin/emailcollector_card.php b/htdocs/admin/emailcollector_card.php index 5c6aec59b32..c6bf6290404 100644 --- a/htdocs/admin/emailcollector_card.php +++ b/htdocs/admin/emailcollector_card.php @@ -37,7 +37,7 @@ if (!$user->admin) accessforbidden(); // Load traductions files requiredby by page -$langs->loadLangs(array("admin", "other")); +$langs->loadLangs(array("admin", "mails", "other")); // Get parameters $id = GETPOST('id', 'int'); @@ -122,6 +122,23 @@ if ($action == 'confirm_collect') $action = ''; } +if (GETPOST('addfilter','alpha')) +{ + $emailcollectorfilter = new EmailCollectorFilter($db); + $emailcollectorfilter->type = GETPOST('filtertype','alpha'); + $emailcollectorfilter->rulevalue = GETPOST('rulevalue', 'alpha'); + $emailcollectorfilter->fk_emailcollector = $object->id; + $result = $emailcollectorfilter->create($user); + + if ($result > 0) + { + $object->fetchFilters(); + } + else + { + setEventMessages($emailcollectorfilter->errors, $emailcollectorfilter->error, 'errors'); + } +} @@ -322,6 +339,13 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea print '
'.$langs->trans("Label").'
'.$langs->trans("Label").'
'.$langs->trans("ResourceFormLabel_ref").'
'.$langs->trans("ResourceType").'
'.$langs->trans("Search").'
:
'; - print $formproject->selectOpportunityStatus('search_opp_status', $search_opp_status, 1, 1, 1, 0, 'maxwidth100'); + print $formproject->selectOpportunityStatus('search_opp_status', $search_opp_status, 1, 0, 1, 0, 'maxwidth100'); print ''; - if ($obj->opp_status_code) print $langs->trans("OppStatusShort".$obj->opp_status_code); + if ($obj->opp_status_code) print $langs->trans("OppStatus".$obj->opp_status_code); print '
'; + + print '
'; + print ''; + print ''; + print ''; + print ''; + // Filters print ''; print ''; @@ -330,8 +354,8 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea // Add filter print ''; print ''; @@ -365,7 +389,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea print ''; @@ -387,6 +411,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea print ''; print '
'; - $arrayoftypes=array('to'=>'To', 'cc'=>'Cc', 'bcc'=>'Bcc', 'from'=>'From', 'subject'=>'Subject', 'body'=>'Body', 'seen'=>'AlreadyRead', 'unseen'=>'NotRead'); - print $form->selectarray('filtertype', $arrayoftypes, '', 1); + $arrayoftypes=array('from'=>'MailFrom', 'to'=>'MailTo', 'cc'=>'Cc', 'bcc'=>'Bcc', 'subject'=>'Subject', 'body'=>'Body', 'seen'=>'AlreadyRead', 'unseen'=>'NotRead'); + print $form->selectarray('filtertype', $arrayoftypes, '', 1, 0, 0, '', 1); print ''; print ''; print ''; $arrayoftypes=array('recordevent'=>'RecordEvent'); if ($conf->projet->enabled) $arrayoftypes['project']='CreateLeadAndThirdParty'; - print $form->selectarray('operationtype', $arrayoftypes, '', 1); + print $form->selectarray('operationtype', $arrayoftypes, '', 1, 0, 0, '', 1); print ''; print ''; print '
'; + print '
'; print ''; print ''; diff --git a/htdocs/core/modules/modEmailCollector.class.php b/htdocs/core/modules/modEmailCollector.class.php index 5bad6e3e135..ef19ff49bf9 100644 --- a/htdocs/core/modules/modEmailCollector.class.php +++ b/htdocs/core/modules/modEmailCollector.class.php @@ -52,7 +52,7 @@ class modEmailCollector extends DolibarrModules // It is used to group modules by family in module setup page $this->family = "interface"; // Module position in the family on 2 digits ('01', '10', '20', ...) - $this->module_position = '75'; + $this->module_position = '12'; // Gives the possibility to the module, to provide his own family info and position of this family (Overwrite $this->family and $this->module_position. Avoid this) //$this->familyinfo = array('myownfamily' => array('position' => '01', 'label' => $langs->trans("MyOwnFamily"))); @@ -70,7 +70,7 @@ class modEmailCollector extends DolibarrModules // Name of image file used for this module. // If file is in theme/yourtheme/img directory under name object_pictovalue.png, use this->picto='pictovalue' // If file is in module/img directory under name object_pictovalue.png, use this->picto='pictovalue@module' - $this->picto='generic'; + $this->picto='email'; // Defined all module parts (triggers, login, substitutions, menus, css, etc...) // for default path (eg: /dav/core/xxxxx) (0=disable, 1=enable) diff --git a/htdocs/core/modules/modGravatar.class.php b/htdocs/core/modules/modGravatar.class.php index 44b4f8a6e80..de85e76e7ff 100644 --- a/htdocs/core/modules/modGravatar.class.php +++ b/htdocs/core/modules/modGravatar.class.php @@ -49,6 +49,8 @@ class modGravatar 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 = "interface"; + // Module position in the family on 2 digits ('01', '10', '20', ...) + $this->module_position = '75'; // 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)); // Module description, used if translation string 'ModuleXXXDesc' not found (where XXX is value of numeric property 'numero' of module) diff --git a/htdocs/core/modules/modLdap.class.php b/htdocs/core/modules/modLdap.class.php index 90577ae3ccf..9bce79dff1f 100644 --- a/htdocs/core/modules/modLdap.class.php +++ b/htdocs/core/modules/modLdap.class.php @@ -43,6 +43,8 @@ class modLdap extends DolibarrModules $this->numero = 200; $this->family = "interface"; + // Module position in the family on 2 digits ('01', '10', '20', ...) + $this->module_position = '30'; // 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 = "Synchronisation Ldap"; diff --git a/htdocs/core/modules/modMailing.class.php b/htdocs/core/modules/modMailing.class.php index 749369ee8e9..b7d83f8b771 100644 --- a/htdocs/core/modules/modMailing.class.php +++ b/htdocs/core/modules/modMailing.class.php @@ -44,7 +44,12 @@ class modMailing extends DolibarrModules $this->db = $db; $this->numero = 22; - $this->family = "technic"; + // Family can be 'base' (core modules),'crm','financial','hr','projects','products','ecm','technic' (transverse modules),'interface' (link with external tools),'other','...' + // It is used to group modules by family in module setup page + $this->family = "interface"; + // Module position in the family on 2 digits ('01', '10', '20', ...) + $this->module_position = '11'; + // 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 EMailings"; diff --git a/htdocs/core/modules/modMailmanSpip.class.php b/htdocs/core/modules/modMailmanSpip.class.php index e1a8f7c2cd6..d82c8040c02 100644 --- a/htdocs/core/modules/modMailmanSpip.class.php +++ b/htdocs/core/modules/modMailmanSpip.class.php @@ -43,7 +43,11 @@ class modMailmanSpip extends DolibarrModules $this->db = $db; $this->numero = 105; + // Family can be 'crm','financial','hr','projects','products','ecm','technic','other' + // It is used to group modules in module setup page $this->family = "interface"; + // Module position in the family on 2 digits ('01', '10', '20', ...) + $this->module_position = '70'; // 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 = "Mailman or Spip interface for member module"; diff --git a/htdocs/core/modules/modNotification.class.php b/htdocs/core/modules/modNotification.class.php index 9dbd77fae86..21d5f81eb98 100644 --- a/htdocs/core/modules/modNotification.class.php +++ b/htdocs/core/modules/modNotification.class.php @@ -41,7 +41,11 @@ class modNotification extends DolibarrModules $this->db = $db; $this->numero = 600; + // Family can be 'crm','financial','hr','projects','products','ecm','technic','other' + // It is used to group modules in module setup page $this->family = "interface"; + // Module position in the family on 2 digits ('01', '10', '20', ...) + $this->module_position = '01'; // 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 = "EMail notifications (push) on business Dolibarr events"; diff --git a/htdocs/core/modules/modOauth.class.php b/htdocs/core/modules/modOauth.class.php index f563baa9c92..086dac64bed 100644 --- a/htdocs/core/modules/modOauth.class.php +++ b/htdocs/core/modules/modOauth.class.php @@ -47,7 +47,7 @@ class modOauth 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 = "interface"; - $this->module_position = '51'; + $this->module_position = '31'; // 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)); // Module description, used if translation string 'ModuleXXXDesc' not found (where XXX is value of numeric property 'numero' of module) diff --git a/htdocs/core/modules/modSocialNetworks.class.php b/htdocs/core/modules/modSocialNetworks.class.php index 6aceeff6a70..137547bfb15 100644 --- a/htdocs/core/modules/modSocialNetworks.class.php +++ b/htdocs/core/modules/modSocialNetworks.class.php @@ -46,6 +46,8 @@ class modSocialNetworks 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 = "interface"; + // Module position in the family on 2 digits ('01', '10', '20', ...) + $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) $this->name = preg_replace('/^mod/i','',get_class($this)); $this->description = "Enable Social Networks fields into third parties and addresses (skype, twitter, facebook, ...)"; diff --git a/htdocs/emailcollector/class/emailcollector.class.php b/htdocs/emailcollector/class/emailcollector.class.php index cef1c27eac9..5131db78759 100644 --- a/htdocs/emailcollector/class/emailcollector.class.php +++ b/htdocs/emailcollector/class/emailcollector.class.php @@ -632,6 +632,7 @@ class EmailCollector extends CommonObject { $obj=$this->db->fetch_object($resql); $this->filters[$obj->rowid]=array('id'=>$obj->rowid, 'type'=>$obj->type, 'rulevalue'=>$obj->rulevalue, 'status'=>$obj->status); + $i++; } $this->db->free($resql); } @@ -659,6 +660,7 @@ class EmailCollector extends CommonObject { $obj=$this->db->fetch_object($resql); $this->rules[$obj->rowid]=array('id'=>$obj->rowid, 'type'=>$obj->type, 'actionparam'=>$obj->actionparam, 'status'=>$obj->status); + $i++; } $this->db->free($resql); } diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index d38eb1d21d9..e074210bd1a 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -1815,6 +1815,8 @@ EnableFeatureFor=Enable features for %s VATIsUsedIsOff=Note: The option to use sales Tax or VAT has been set to Off in the menu %s - %s, so Sale tax or Vat used will always be 0 for sales. SwapSenderAndRecipientOnPDF=Swap sender and recipient address on PDF FeatureSupportedOnTextFieldsOnly=Warning, feature supported on text fields only +EmailCollector=Email collector +EmailCollectorDescription=Add a scheduled job and a setup page to scan regularly email boxes (using IMAP protocol) and record emails received into your application, at the right place and/or create some record automatically (like leads). NewEmailCollector=New Email Collector EMailHost=Host of email IMAP server MailboxSourceDirectory=Mailbox source directory diff --git a/htdocs/langs/en_US/main.lang b/htdocs/langs/en_US/main.lang index fa74cfa44bc..100a249f418 100644 --- a/htdocs/langs/en_US/main.lang +++ b/htdocs/langs/en_US/main.lang @@ -635,6 +635,8 @@ SendMail=Send email EMail=E-mail NoEMail=No email Email=Email +AlreadyRead=Alreay read +NotRead=Not read NoMobilePhone=No mobile phone Owner=Owner FollowingConstantsWillBeSubstituted=The following constants will be replaced with the corresponding value. From 193b153fbf0a36dcf4345585e2aa6ccfbffff352 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 7 Nov 2018 18:02:08 +0100 Subject: [PATCH 093/132] Work on email collector --- htdocs/admin/emailcollector_card.php | 76 +++++++++++++++++-- .../class/emailcollector.class.php | 26 ++++--- .../class/emailcollectoraction.class.php | 30 +++++--- .../class/emailcollectorfilter.class.php | 36 ++++++--- .../install/mysql/migration/8.0.0-9.0.0.sql | 3 + ...mailcollector_emailcollectoraction.key.sql | 1 + ...mailcollector_emailcollectorfilter.key.sql | 2 + htdocs/langs/en_US/admin.lang | 2 + .../template/class/myobject.class.php | 20 ++--- 9 files changed, 144 insertions(+), 52 deletions(-) diff --git a/htdocs/admin/emailcollector_card.php b/htdocs/admin/emailcollector_card.php index c6bf6290404..3280492701e 100644 --- a/htdocs/admin/emailcollector_card.php +++ b/htdocs/admin/emailcollector_card.php @@ -30,7 +30,7 @@ include_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; include_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; include_once DOL_DOCUMENT_ROOT.'/emailcollector/class/emailcollector.class.php'; include_once DOL_DOCUMENT_ROOT.'/emailcollector/class/emailcollectorfilter.class.php'; -include_once DOL_DOCUMENT_ROOT.'/emailcollector/class/emailcollectoraction.lib.php'; +include_once DOL_DOCUMENT_ROOT.'/emailcollector/class/emailcollectoraction.class.php'; include_once DOL_DOCUMENT_ROOT.'/emailcollector/lib/emailcollector.lib.php'; if (!$user->admin) @@ -125,9 +125,10 @@ if ($action == 'confirm_collect') if (GETPOST('addfilter','alpha')) { $emailcollectorfilter = new EmailCollectorFilter($db); - $emailcollectorfilter->type = GETPOST('filtertype','alpha'); + $emailcollectorfilter->type = GETPOST('filtertype','az09'); $emailcollectorfilter->rulevalue = GETPOST('rulevalue', 'alpha'); $emailcollectorfilter->fk_emailcollector = $object->id; + $emailcollectorfilter->status = 1; $result = $emailcollectorfilter->create($user); if ($result > 0) @@ -140,6 +141,55 @@ if (GETPOST('addfilter','alpha')) } } +if ($action == 'deletefilter') +{ + $emailcollectorfilter = new EmailCollectorFilter($db); + $emailcollectorfilter->fetch(GETPOST('filterid','int')); + $result = $emailcollectorfilter->delete($user); + if ($result > 0) + { + $object->fetchFilters(); + } + else + { + setEventMessages($emailcollectorfilter->errors, $emailcollectorfilter->error, 'errors'); + } +} + +if (GETPOST('addoperation','alpha')) +{ + $emailcollectoroperation = new EmailCollectorAction($db); + $emailcollectoroperation->type = GETPOST('operationtype','az09'); + $emailcollectoroperation->actionparam = GETPOST('actionparam', 'alpha'); + $emailcollectoroperation->fk_emailcollector = $object->id; + $emailcollectoroperation->status = 1; + $result = $emailcollectoroperation->create($user); + + if ($result > 0) + { + $object->fetchActions(); + } + else + { + setEventMessages($emailcollectoroperation->errors, $emailcollectoroperation->error, 'errors'); + } +} + +if ($action == 'deleteoperation') +{ + $emailcollectoroperation = new EmailCollectorAction($db); + $emailcollectoroperation->fetch(GETPOST('operationid','int')); + $result = $emailcollectoroperation->delete($user); + if ($result > 0) + { + $object->fetchActions(); + } + else + { + setEventMessages($emailcollectoroperation->errors, $emailcollectoroperation->error, 'errors'); + } +} + /* @@ -368,9 +418,14 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea $rulefilterobj->fetch($rulefilter['id']); print '
'.$rulefilter['type'].''; + print $langs->trans($arrayoftypes[$rulefilter['type']]); + print ''.$rulefilter['rulevalue'].''.$rulefilterobj->getLibStatut(3).''; + //print $rulefilterobj->getLibStatut(3); + print ' '.img_delete().''; + print '
'; $arrayoftypes=array('recordevent'=>'RecordEvent'); if ($conf->projet->enabled) $arrayoftypes['project']='CreateLeadAndThirdParty'; - print $form->selectarray('operationtype', $arrayoftypes, '', 1, 0, 0, '', 1); + print $form->selectarray('operationtype', $arrayoftypes, '', 0, 0, 0, '', 1); print ''; print ''; print '
'.$ruleactionobj['type'].''.$ruleactionobj['actionparam'].''.$ruleactionobj->getLibStatut(3).''; + print $langs->trans($arrayoftypes[$ruleaction['type']]); + print ''.$ruleaction['actionparam'].''; + //print $ruleactionobj->getLibStatut(3); + print ' '.img_delete().''; + print '
'; print ''; - print ''; + print ''; print ''; print ''; print ''; diff --git a/htdocs/compta/sociales/card.php b/htdocs/compta/sociales/card.php index 4ffa1a2829f..d7d762464ee 100644 --- a/htdocs/compta/sociales/card.php +++ b/htdocs/compta/sociales/card.php @@ -481,7 +481,7 @@ if ($id > 0) } $morehtmlref.=''; - $linkback = '' . $langs->trans("BackToList") . ''; + $linkback = '' . $langs->trans("BackToList") . ''; $object->totalpaye = $totalpaye; // To give a chance to dol_banner_tab to use already paid amount to show correct status diff --git a/htdocs/compta/sociales/document.php b/htdocs/compta/sociales/document.php index b2f73768e96..6e033bccc80 100644 --- a/htdocs/compta/sociales/document.php +++ b/htdocs/compta/sociales/document.php @@ -127,7 +127,7 @@ if ($object->id) } $morehtmlref.=''; - $linkback = '' . $langs->trans("BackToList") . ''; + $linkback = '' . $langs->trans("BackToList") . ''; $object->totalpaye = $totalpaye; // To give a chance to dol_banner_tab to use already paid amount to show correct status diff --git a/htdocs/compta/sociales/info.php b/htdocs/compta/sociales/info.php index bd21db108c1..35c00766252 100644 --- a/htdocs/compta/sociales/info.php +++ b/htdocs/compta/sociales/info.php @@ -98,7 +98,7 @@ if (! empty($conf->projet->enabled)) } $morehtmlref.=''; -$linkback = '' . $langs->trans("BackToList") . ''; +$linkback = '' . $langs->trans("BackToList") . ''; $object->totalpaye = $totalpaye; // To give a chance to dol_banner_tab to use already paid amount to show correct status diff --git a/htdocs/compta/sociales/index.php b/htdocs/compta/sociales/list.php similarity index 92% rename from htdocs/compta/sociales/index.php rename to htdocs/compta/sociales/list.php index 6a0250804f1..b25ab142058 100644 --- a/htdocs/compta/sociales/index.php +++ b/htdocs/compta/sociales/list.php @@ -19,7 +19,7 @@ */ /** - * \file htdocs/compta/sociales/index.php + * \file htdocs/compta/list/index.php * \ingroup tax * \brief Page to list all social contributions */ @@ -55,19 +55,19 @@ if (! $sortorder) $sortorder="DESC"; $year=GETPOST("year",'int'); $filtre=GETPOST("filtre",'int'); -if (empty($_REQUEST['typeid'])) +if (! GETPOSTISSET('search_typeid')) { $newfiltre=str_replace('filtre=','',$filtre); $filterarray=explode('-',$newfiltre); foreach($filterarray as $val) { $part=explode(':',$val); - if ($part[0] == 'cs.fk_type') $typeid=$part[1]; + if ($part[0] == 'cs.fk_type') $search_typeid=$part[1]; } } else { - $typeid=$_REQUEST['typeid']; + $search_typeid=GETPOST('search_typeid','int'); } if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x','alpha') || GETPOST('button_removefilter','alpha')) // All test are required to be compatible with all browsers @@ -76,11 +76,12 @@ if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x', $search_label=""; $search_amount=""; $search_status=''; - $typeid=""; + $search_typeid=""; $year=""; $month=""; } + /* * View */ @@ -118,8 +119,8 @@ if ($filtre) { $filtre=str_replace(":","=",$filtre); $sql .= " AND ".$filtre; } -if ($typeid) { - $sql .= " AND cs.fk_type=".$db->escape($typeid); +if ($search_typeid) { + $sql .= " AND cs.fk_type=".$db->escape($search_typeid); } $sql.= " GROUP BY cs.rowid, cs.fk_type, cs.amount, cs.date_ech, cs.libelle, cs.paye, cs.periode, c.libelle"; $sql.= $db->order($sortfield,$sortorder); @@ -139,10 +140,14 @@ if ($resql) $i = 0; $param=''; - if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage; - if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit; - if ($year) $param.='&year='.$year; - if ($typeid) $param.='&typeid='.$typeid; + if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.urlencode($contextpage); + if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.urlencode($limit); + if ($search_ref) $param.='&search_ref='.urlencode($search_ref); + if ($search_label) $param.='&search_label='.urlencode($search_label); + if ($search_amount) $param.='&search_amount='.urlencode($search_amount); + if ($search_typeid) $param.='&search_typeid='.urlencode($search_typeid); + if ($search_status != '' && $search_status != '-1') $param.='&search_status='.urlencode($search_status); + if ($year) $param.='&year='.urlencode($year); $newcardbutton=''; if($user->rights->tax->charges->creer) @@ -193,7 +198,7 @@ if ($resql) print ''; // Type print ''; // Period end date print ''; diff --git a/htdocs/core/menus/init_menu_auguria.sql b/htdocs/core/menus/init_menu_auguria.sql index 682746b3412..3a90fd407af 100644 --- a/htdocs/core/menus/init_menu_auguria.sql +++ b/htdocs/core/menus/init_menu_auguria.sql @@ -213,7 +213,7 @@ insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, left insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->loan->enabled && $leftmenu=="tax_loan"', __HANDLER__, 'left', 2221__+MAX_llx_menu__, 'billing', '', 2220__+MAX_llx_menu__, '/loan/card.php?leftmenu=tax_loan&action=create', 'NewLoan', 2, 'loan', '$user->rights->loan->write', '', 0, 2, __ENTITY__); --insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->loan->enabled && $leftmenu=="tax_loan"', __HANDLER__, 'left', 2222__+MAX_llx_menu__, 'billing', '', 2220__+MAX_llx_menu__, '/loan/payment/list.php?leftmenu=tax_loan', 'Payments', 2, 'companies', '$user->rights->loan->read', '', 0, 3, __ENTITY__); insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->loan->enabled && $leftmenu=="tax_loan" && ! empty($conf->global->LOAN_SHOW_CALCULATOR)', __HANDLER__, 'left', 2223__+MAX_llx_menu__, 'billing', '', 2220__+MAX_llx_menu__, '/loan/calc.php?leftmenu=tax_loan', 'Calculator', 2, 'companies', '$user->rights->loan->calc', '', 0, 4, __ENTITY__); -insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->tax->enabled', __HANDLER__, 'left', 2250__+MAX_llx_menu__, 'billing', 'tax_social', 2200__+MAX_llx_menu__, '/compta/sociales/index.php?leftmenu=tax_social', 'SocialContributions', 1, '', '$user->rights->tax->charges->lire', '', 0, 1, __ENTITY__); +insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->tax->enabled', __HANDLER__, 'left', 2250__+MAX_llx_menu__, 'billing', 'tax_social', 2200__+MAX_llx_menu__, '/compta/sociales/list.php?leftmenu=tax_social', 'SocialContributions', 1, '', '$user->rights->tax->charges->lire', '', 0, 1, __ENTITY__); insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->tax->enabled && $leftmenu=="tax_social"', __HANDLER__, 'left', 2251__+MAX_llx_menu__, 'billing', '', 2250__+MAX_llx_menu__, '/compta/sociales/card.php?leftmenu=tax_social&action=create', 'MenuNewSocialContribution', 2, '', '$user->rights->tax->charges->creer', '', 0, 2, __ENTITY__); insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->tax->enabled && $leftmenu=="tax_social"', __HANDLER__, 'left', 2252__+MAX_llx_menu__, 'billing', '', 2250__+MAX_llx_menu__, '/compta/sociales/payments.php?leftmenu=tax_social&mainmenu=billing&mode=sconly', 'Payments', 2, '', '$user->rights->tax->charges->lire', '', 0, 3, __ENTITY__); insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->tax->enabled && empty($conf->global->TAX_DISABLE_VAT_MENUS)', __HANDLER__, 'left', 2300__+MAX_llx_menu__, 'billing', 'tax_vat', 2200__+MAX_llx_menu__, '/compta/tva/list.php?leftmenu=tax_vat&mainmenu=billing', 'VAT', 1, 'companies', '$user->rights->tax->charges->lire', '', 0, 7, __ENTITY__); diff --git a/htdocs/core/menus/standard/eldy.lib.php b/htdocs/core/menus/standard/eldy.lib.php index bb13a0c2265..0829cc48a00 100644 --- a/htdocs/core/menus/standard/eldy.lib.php +++ b/htdocs/core/menus/standard/eldy.lib.php @@ -906,9 +906,9 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after,&$tabMenu // Social contributions if (! empty($conf->tax->enabled)) { - $newmenu->add("/compta/sociales/index.php?leftmenu=tax_social",$langs->trans("MenuSocialContributions"),1,$user->rights->tax->charges->lire); + $newmenu->add("/compta/sociales/list.php?leftmenu=tax_social",$langs->trans("MenuSocialContributions"),1,$user->rights->tax->charges->lire); if ($usemenuhider || empty($leftmenu) || preg_match('/^tax_social/i',$leftmenu)) $newmenu->add("/compta/sociales/card.php?leftmenu=tax_social&action=create",$langs->trans("MenuNewSocialContribution"), 2, $user->rights->tax->charges->creer); - if ($usemenuhider || empty($leftmenu) || preg_match('/^tax_social/i',$leftmenu)) $newmenu->add("/compta/sociales/index.php?leftmenu=tax_social",$langs->trans("List"),2,$user->rights->tax->charges->lire); + if ($usemenuhider || empty($leftmenu) || preg_match('/^tax_social/i',$leftmenu)) $newmenu->add("/compta/sociales/list.php?leftmenu=tax_social",$langs->trans("List"),2,$user->rights->tax->charges->lire); if ($usemenuhider || empty($leftmenu) || preg_match('/^tax_social/i',$leftmenu)) $newmenu->add("/compta/sociales/payments.php?leftmenu=tax_social&mainmenu=billing&mode=sconly",$langs->trans("Payments"), 2, $user->rights->tax->charges->lire); // VAT if (empty($conf->global->TAX_DISABLE_VAT_MENUS)) From c74ad613658e20e4bbdf39984c594bb0a8a9b03a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 8 Nov 2018 10:04:25 +0100 Subject: [PATCH 098/132] Fix look and feel v8 --- htdocs/compta/resultat/clientfourn.php | 2 +- htdocs/compta/salaries/card.php | 4 +- .../salaries/class/paymentsalary.class.php | 65 ++++++++++++++++--- htdocs/compta/salaries/document.php | 2 +- htdocs/compta/salaries/info.php | 2 +- .../compta/salaries/{index.php => list.php} | 3 +- htdocs/core/menus/init_menu_auguria.sql | 6 +- htdocs/core/menus/standard/eldy.lib.php | 6 +- htdocs/loan/card.php | 2 +- htdocs/loan/document.php | 2 +- htdocs/loan/info.php | 2 +- htdocs/loan/{index.php => list.php} | 2 +- htdocs/loan/note.php | 2 +- htdocs/loan/payment/card.php | 2 +- .../template/class/myobject.class.php | 1 - htdocs/user/bank.php | 2 +- 16 files changed, 77 insertions(+), 28 deletions(-) rename htdocs/compta/salaries/{index.php => list.php} (99%) rename htdocs/loan/{index.php => list.php} (99%) diff --git a/htdocs/compta/resultat/clientfourn.php b/htdocs/compta/resultat/clientfourn.php index 4d643536388..94426ed54eb 100644 --- a/htdocs/compta/resultat/clientfourn.php +++ b/htdocs/compta/resultat/clientfourn.php @@ -773,7 +773,7 @@ else print ''; - print "\n"; + print "\n"; if ($modecompta == 'CREANCES-DETTES') print ''; print ''; diff --git a/htdocs/compta/salaries/card.php b/htdocs/compta/salaries/card.php index f50d940a51a..76ab712bffd 100644 --- a/htdocs/compta/salaries/card.php +++ b/htdocs/compta/salaries/card.php @@ -174,7 +174,7 @@ if ($action == 'delete') if ($result >= 0) { $db->commit(); - header("Location: ".DOL_URL_ROOT.'/compta/salaries/index.php'); + header("Location: ".DOL_URL_ROOT.'/compta/salaries/list.php'); exit; } else @@ -365,7 +365,7 @@ if ($id) dol_fiche_head($head, 'card', $langs->trans("SalaryPayment"), -1, 'payment'); - $linkback = ''.$langs->trans("BackToList").''; + $linkback = ''.$langs->trans("BackToList").''; $morehtmlref='
'; diff --git a/htdocs/compta/salaries/class/paymentsalary.class.php b/htdocs/compta/salaries/class/paymentsalary.class.php index 0be0f4f3694..76a8284daff 100644 --- a/htdocs/compta/salaries/class/paymentsalary.class.php +++ b/htdocs/compta/salaries/class/paymentsalary.class.php @@ -537,24 +537,73 @@ class PaymentSalary extends CommonObject /** * Send name clicable (with possibly the picto) * - * @param int $withpicto 0=No picto, 1=Include picto into link, 2=Only picto - * @param string $option link option - * @return string Chaine with URL + * @param int $withpicto 0=No picto, 1=Include picto into link, 2=Only picto + * @param string $option link option + * @param int $notooltip 1=Disable tooltip + * @param string $morecss Add more css on link + * @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking + * @return string Chaine with URL */ - function getNomUrl($withpicto=0,$option='') + function getNomUrl($withpicto=0, $option='', $notooltip=0, $morecss='', $save_lastsearch_value=-1) { - global $langs; + global $db, $conf, $langs, $hookmanager; + global $dolibarr_main_authentication, $dolibarr_main_demo; + global $menumanager; - $result=''; - $label=$langs->trans("ShowSalaryPayment").': '.$this->ref; + if (! empty($conf->dol_no_mouse_hover)) $notooltip=1; // Force disable tooltips - $linkstart = ''; + $result = ''; + + $label = '' . $langs->trans("ShowSalaryPayment") . ''; + $label.= '
'; + $label.= '' . $langs->trans('Ref') . ': ' . $this->ref; + + $url = DOL_URL_ROOT.'/compta/salaries/card.php?id='.$this->id; + + if ($option != 'nolink') + { + // Add param to save lastsearch_values or not + $add_save_lastsearch_values=($save_lastsearch_value == 1 ? 1 : 0); + if ($save_lastsearch_value == -1 && preg_match('/list\.php/',$_SERVER["PHP_SELF"])) $add_save_lastsearch_values=1; + if ($add_save_lastsearch_values) $url.='&save_lastsearch_values=1'; + } + + $linkclose=''; + if (empty($notooltip)) + { + if (! empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) + { + $label=$langs->trans("ShowMyObject"); + $linkclose.=' alt="'.dol_escape_htmltag($label, 1).'"'; + } + $linkclose.=' title="'.dol_escape_htmltag($label, 1).'"'; + $linkclose.=' class="classfortooltip'.($morecss?' '.$morecss:'').'"'; + + /* + $hookmanager->initHooks(array('myobjectdao')); + $parameters=array('id'=>$this->id); + $reshook=$hookmanager->executeHooks('getnomurltooltip',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks + if ($reshook > 0) $linkclose = $hookmanager->resPrint; + */ + } + else $linkclose = ($morecss?' class="'.$morecss.'"':''); + + $linkstart = '
'; $linkend=''; $result .= $linkstart; if ($withpicto) $result.=img_object(($notooltip?'':$label), ($this->picto?$this->picto:'generic'), ($notooltip?(($withpicto != 2) ? 'class="paddingright"' : ''):'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip?0:1); if ($withpicto != 2) $result.= $this->ref; $result .= $linkend; + //if ($withpicto != 2) $result.=(($addlabel && $this->label) ? $sep . dol_trunc($this->label, ($addlabel > 1 ? $addlabel : 0)) : ''); + + global $action,$hookmanager; + $hookmanager->initHooks(array('salarypayment')); + $parameters=array('id'=>$this->id, 'getnomurl'=>$result); + $reshook=$hookmanager->executeHooks('getNomUrl',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks + if ($reshook > 0) $result = $hookmanager->resPrint; + else $result .= $hookmanager->resPrint; return $result; } diff --git a/htdocs/compta/salaries/document.php b/htdocs/compta/salaries/document.php index 1059c765df3..493e0a3c5ee 100644 --- a/htdocs/compta/salaries/document.php +++ b/htdocs/compta/salaries/document.php @@ -99,7 +99,7 @@ if ($object->id) $totalsize+=$file['size']; } - $linkback = ''.$langs->trans("BackToList").''; + $linkback = ''.$langs->trans("BackToList").''; $morehtmlref='
'; diff --git a/htdocs/compta/salaries/info.php b/htdocs/compta/salaries/info.php index d2f02f3dc8f..87d24ceb406 100644 --- a/htdocs/compta/salaries/info.php +++ b/htdocs/compta/salaries/info.php @@ -54,7 +54,7 @@ $head = salaries_prepare_head($object); dol_fiche_head($head, 'info', $langs->trans("SalaryPayment"), -1, 'payment'); -$linkback = ''.$langs->trans("BackToList").''; +$linkback = ''.$langs->trans("BackToList").''; $morehtmlref='
'; diff --git a/htdocs/compta/salaries/index.php b/htdocs/compta/salaries/list.php similarity index 99% rename from htdocs/compta/salaries/index.php rename to htdocs/compta/salaries/list.php index a8a0b82e7d9..c7f5970723e 100644 --- a/htdocs/compta/salaries/index.php +++ b/htdocs/compta/salaries/list.php @@ -18,7 +18,7 @@ */ /** - * \file htdocs/compta/salaries/index.php + * \file htdocs/compta/salaries/list.php * \ingroup salaries * \brief List of salaries payments */ @@ -231,6 +231,7 @@ if ($result) $salstatic->id=$obj->rowid; $salstatic->ref=$obj->rowid; + // Ref print "
\n"; // Employee diff --git a/htdocs/core/menus/init_menu_auguria.sql b/htdocs/core/menus/init_menu_auguria.sql index 3a90fd407af..8792d8b762a 100644 --- a/htdocs/core/menus/init_menu_auguria.sql +++ b/htdocs/core/menus/init_menu_auguria.sql @@ -205,11 +205,11 @@ insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, left -- insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->don->enabled && $leftmenu=="donations"', __HANDLER__, 'left', 2003__+MAX_llx_menu__, 'billing', '', 2000__+MAX_llx_menu__, '/don/stats/index.php?leftmenu=donations&mainmenu=billing', 'Statistics', 1, 'donations', '$user->rights->don->lire', '', 2, 2, __ENTITY__); -- Special expenses insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->tax->enabled || $conf->salaries->enabled || $conf->loan->enabled || $conf->banque->enabled', __HANDLER__, 'left', 2200__+MAX_llx_menu__, 'billing', 'tax', 6__+MAX_llx_menu__, '/compta/charges/index.php?leftmenu=tax&mainmenu=billing', 'MenuSpecialExpenses', 0, 'compta', '(! empty($conf->tax->enabled) && $user->rights->tax->charges->lire) || (! empty($conf->salaries->enabled) && ! empty($user->rights->salaries->read)) || (! empty($conf->loan->enabled) && $user->rights->loan->read) || (! empty($conf->banque->enabled) && $user->rights->banque->lire)', '', 0, 6, __ENTITY__); -insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->salaries->enabled', __HANDLER__, 'left', 2210__+MAX_llx_menu__, 'billing', 'tax_sal', 2200__+MAX_llx_menu__, '/compta/salaries/index.php?leftmenu=tax_salary&mainmenu=billing', 'Salaries', 1, 'salaries', '$user->rights->salaries->read', '', 0, 1, __ENTITY__); +insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->salaries->enabled', __HANDLER__, 'left', 2210__+MAX_llx_menu__, 'billing', 'tax_sal', 2200__+MAX_llx_menu__, '/compta/salaries/list.php?leftmenu=tax_salary&mainmenu=billing', 'Salaries', 1, 'salaries', '$user->rights->salaries->read', '', 0, 1, __ENTITY__); insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->salaries->enabled && $leftmenu=="tax_salary"', __HANDLER__, 'left', 2211__+MAX_llx_menu__, 'billing', '', 2210__+MAX_llx_menu__, '/compta/salaries/card.php?leftmenu=tax_salary&action=create', 'NewPayment', 2, 'companies', '$user->rights->salaries->write', '', 0, 2, __ENTITY__); -insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->salaries->enabled && $leftmenu=="tax_salary"', __HANDLER__, 'left', 2212__+MAX_llx_menu__, 'billing', '', 2210__+MAX_llx_menu__, '/compta/salaries/index.php?leftmenu=tax_salary', 'Payments', 2, 'companies', '$user->rights->salaries->read', '', 0, 3, __ENTITY__); +insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->salaries->enabled && $leftmenu=="tax_salary"', __HANDLER__, 'left', 2212__+MAX_llx_menu__, 'billing', '', 2210__+MAX_llx_menu__, '/compta/salaries/list.php?leftmenu=tax_salary', 'Payments', 2, 'companies', '$user->rights->salaries->read', '', 0, 3, __ENTITY__); insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->salaries->enabled && $leftmenu=="tax_salary"', __HANDLER__, 'left', 2213__+MAX_llx_menu__, 'billing', '', 2210__+MAX_llx_menu__, '/compta/salaries/stats/index.php?leftmenu=tax_salary', 'Statistics', 2, 'companies', '$user->rights->salaries->read', '', 0, 4, __ENTITY__); -insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->loan->enabled', __HANDLER__, 'left', 2220__+MAX_llx_menu__, 'billing', 'tax_loan', 2200__+MAX_llx_menu__, '/loan/index.php?leftmenu=tax_loan&mainmenu=billing', 'Loans', 1, 'loan', '$user->rights->loan->read', '', 0, 1, __ENTITY__); +insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->loan->enabled', __HANDLER__, 'left', 2220__+MAX_llx_menu__, 'billing', 'tax_loan', 2200__+MAX_llx_menu__, '/loan/list.php?leftmenu=tax_loan&mainmenu=billing', 'Loans', 1, 'loan', '$user->rights->loan->read', '', 0, 1, __ENTITY__); insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->loan->enabled && $leftmenu=="tax_loan"', __HANDLER__, 'left', 2221__+MAX_llx_menu__, 'billing', '', 2220__+MAX_llx_menu__, '/loan/card.php?leftmenu=tax_loan&action=create', 'NewLoan', 2, 'loan', '$user->rights->loan->write', '', 0, 2, __ENTITY__); --insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->loan->enabled && $leftmenu=="tax_loan"', __HANDLER__, 'left', 2222__+MAX_llx_menu__, 'billing', '', 2220__+MAX_llx_menu__, '/loan/payment/list.php?leftmenu=tax_loan', 'Payments', 2, 'companies', '$user->rights->loan->read', '', 0, 3, __ENTITY__); insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->loan->enabled && $leftmenu=="tax_loan" && ! empty($conf->global->LOAN_SHOW_CALCULATOR)', __HANDLER__, 'left', 2223__+MAX_llx_menu__, 'billing', '', 2220__+MAX_llx_menu__, '/loan/calc.php?leftmenu=tax_loan', 'Calculator', 2, 'companies', '$user->rights->loan->calc', '', 0, 4, __ENTITY__); diff --git a/htdocs/core/menus/standard/eldy.lib.php b/htdocs/core/menus/standard/eldy.lib.php index 0829cc48a00..2c2c2d999f7 100644 --- a/htdocs/core/menus/standard/eldy.lib.php +++ b/htdocs/core/menus/standard/eldy.lib.php @@ -948,9 +948,9 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after,&$tabMenu if (! empty($conf->salaries->enabled)) { $langs->load("salaries"); - $newmenu->add("/compta/salaries/index.php?leftmenu=tax_salary&mainmenu=billing",$langs->trans("Salaries"),1,$user->rights->salaries->read, '', $mainmenu, 'tax_salary'); + $newmenu->add("/compta/salaries/list.php?leftmenu=tax_salary&mainmenu=billing",$langs->trans("Salaries"),1,$user->rights->salaries->read, '', $mainmenu, 'tax_salary'); if ($usemenuhider || empty($leftmenu) || preg_match('/^tax_salary/i',$leftmenu)) $newmenu->add("/compta/salaries/card.php?leftmenu=tax_salary&action=create",$langs->trans("NewPayment"),2,$user->rights->salaries->write); - if ($usemenuhider || empty($leftmenu) || preg_match('/^tax_salary/i',$leftmenu)) $newmenu->add("/compta/salaries/index.php?leftmenu=tax_salary",$langs->trans("Payments"),2,$user->rights->salaries->read); + if ($usemenuhider || empty($leftmenu) || preg_match('/^tax_salary/i',$leftmenu)) $newmenu->add("/compta/salaries/list.php?leftmenu=tax_salary",$langs->trans("Payments"),2,$user->rights->salaries->read); if ($usemenuhider || empty($leftmenu) || preg_match('/^tax_salary/i',$leftmenu)) $newmenu->add("/compta/salaries/stats/index.php?leftmenu=tax_salary", $langs->trans("Statistics"),2,$user->rights->salaries->read); } @@ -958,7 +958,7 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after,&$tabMenu if (! empty($conf->loan->enabled)) { $langs->load("loan"); - $newmenu->add("/loan/index.php?leftmenu=tax_loan&mainmenu=billing",$langs->trans("Loans"),1,$user->rights->loan->read, '', $mainmenu, 'tax_loan'); + $newmenu->add("/loan/list.php?leftmenu=tax_loan&mainmenu=billing",$langs->trans("Loans"),1,$user->rights->loan->read, '', $mainmenu, 'tax_loan'); if ($usemenuhider || empty($leftmenu) || preg_match('/^tax_loan/i',$leftmenu)) $newmenu->add("/loan/card.php?leftmenu=tax_loan&action=create",$langs->trans("NewLoan"),2,$user->rights->loan->write); //if (empty($leftmenu) || preg_match('/^tax_loan/i',$leftmenu)) $newmenu->add("/loan/payment/list.php?leftmenu=tax_loan",$langs->trans("Payments"),2,$user->rights->loan->read); } diff --git a/htdocs/loan/card.php b/htdocs/loan/card.php index 3214ac5a971..242472aff0a 100644 --- a/htdocs/loan/card.php +++ b/htdocs/loan/card.php @@ -434,7 +434,7 @@ if ($id > 0) // Loan card - $linkback = '' . $langs->trans("BackToList") . ''; + $linkback = '' . $langs->trans("BackToList") . ''; $morehtmlref='
'; // Ref loan diff --git a/htdocs/loan/document.php b/htdocs/loan/document.php index 2c762b624d2..553bbc258e8 100644 --- a/htdocs/loan/document.php +++ b/htdocs/loan/document.php @@ -124,7 +124,7 @@ if ($object->id) } $morehtmlref.='
'; - $linkback = '' . $langs->trans("BackToList") . ''; + $linkback = '' . $langs->trans("BackToList") . ''; $object->totalpaid = $totalpaid; // To give a chance to dol_banner_tab to use already paid amount to show correct status diff --git a/htdocs/loan/info.php b/htdocs/loan/info.php index 3a092e4cb84..cc923b17fea 100644 --- a/htdocs/loan/info.php +++ b/htdocs/loan/info.php @@ -96,7 +96,7 @@ if (! empty($conf->projet->enabled)) { } $morehtmlref.=''; -$linkback = '' . $langs->trans("BackToList") . ''; +$linkback = '' . $langs->trans("BackToList") . ''; $object->totalpaid = $totalpaid; // To give a chance to dol_banner_tab to use already paid amount to show correct status diff --git a/htdocs/loan/index.php b/htdocs/loan/list.php similarity index 99% rename from htdocs/loan/index.php rename to htdocs/loan/list.php index 5b81ebbb023..780d28df081 100644 --- a/htdocs/loan/index.php +++ b/htdocs/loan/list.php @@ -19,7 +19,7 @@ */ /** - * \file htdocs/loan/index.php + * \file htdocs/loan/list.php * \ingroup loan * \brief Page to list all loans */ diff --git a/htdocs/loan/note.php b/htdocs/loan/note.php index 2ed8e82f20b..187dbbbd1f9 100644 --- a/htdocs/loan/note.php +++ b/htdocs/loan/note.php @@ -113,7 +113,7 @@ if ($id > 0) } $morehtmlref.=''; - $linkback = '' . $langs->trans("BackToList") . ''; + $linkback = '' . $langs->trans("BackToList") . ''; $object->totalpaid = $totalpaid; // To give a chance to dol_banner_tab to use already paid amount to show correct status diff --git a/htdocs/loan/payment/card.php b/htdocs/loan/payment/card.php index 919139bd6e3..77d47e66b40 100644 --- a/htdocs/loan/payment/card.php +++ b/htdocs/loan/payment/card.php @@ -58,7 +58,7 @@ if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->loan->del if ($result > 0) { $db->commit(); - header("Location: ".DOL_URL_ROOT."/loan/index.php"); + header("Location: ".DOL_URL_ROOT."/loan/list.php"); exit; } else diff --git a/htdocs/modulebuilder/template/class/myobject.class.php b/htdocs/modulebuilder/template/class/myobject.class.php index e318bfe3a00..6e3fc1bd63f 100644 --- a/htdocs/modulebuilder/template/class/myobject.class.php +++ b/htdocs/modulebuilder/template/class/myobject.class.php @@ -357,7 +357,6 @@ class MyObject extends CommonObject if (! empty($conf->dol_no_mouse_hover)) $notooltip=1; // Force disable tooltips $result = ''; - $companylink = ''; $label = '' . $langs->trans("MyObject") . ''; $label.= '
'; diff --git a/htdocs/user/bank.php b/htdocs/user/bank.php index 13b555b6d5c..1cfb8fbb5d5 100644 --- a/htdocs/user/bank.php +++ b/htdocs/user/bank.php @@ -311,7 +311,7 @@ if ($action != 'edit' && $action != 'create') // If not bank account yet, $acco print '
'.$langs->trans("ContributionsToPay").($num?' '.$num.'':'').''.$langs->trans("ContributionsToPay").($num?' '.$num.'':'').''.$langs->trans("DateDue").''.$langs->trans("AmountTTC").''.$langs->trans("Paid").''; - $formsocialcontrib->select_type_socialcontrib($typeid,'typeid',1,0,0,'maxwidth100onsmartphone'); + $formsocialcontrib->select_type_socialcontrib($search_typeid,'search_typeid',1,0,0,'maxwidth100onsmartphone'); print ' 
 ".$langs->trans("Salary")." fk_user."\">".$obj->firstname." ".$obj->lastname."".$langs->trans("Salary")." fk_user."\">".$obj->firstname." ".$obj->lastname."'.price(-$obj->amount).''.price(-$obj->amount).'".$salstatic->getNomUrl(1)."
'; print ''; - print '
'; + print ''; print ''; From 5bbf7e8f1d0d0620ef7617b4f1922609d9adeed1 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 8 Nov 2018 10:21:43 +0100 Subject: [PATCH 099/132] Fix look and feel v8 --- htdocs/core/modules/modPaypal.class.php | 28 ++++++++++---------- htdocs/core/modules/modStripe.class.php | 4 +-- htdocs/product/stock/productlot_card.php | 5 ++-- htdocs/product/stock/productlot_document.php | 2 +- htdocs/theme/eldy/style.css.php | 2 +- 5 files changed, 20 insertions(+), 21 deletions(-) diff --git a/htdocs/core/modules/modPaypal.class.php b/htdocs/core/modules/modPaypal.class.php index a11fa41b7a6..106ea412150 100644 --- a/htdocs/core/modules/modPaypal.class.php +++ b/htdocs/core/modules/modPaypal.class.php @@ -107,21 +107,21 @@ class modPaypal extends DolibarrModules // Main menu entries $this->menus = array(); // List of menus to add $r=0; - $this->menu[$r]=array( - 'fk_menu'=>'fk_mainmenu=billing,fk_leftmenu=customers_bills_payment', // Use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode - 'mainmenu'=>'billing', - 'leftmenu'=>'customers_bills_payment_paypal', - 'type'=>'left', // This is a Left menu entry - 'titre'=>'PaypalImportPayment', - 'url'=>'/paypal/importpayments.php', - 'langs'=>'paypal', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory. - 'position'=>501, - 'enabled'=>'$conf->paypal->enabled && $conf->banque->enabled && $conf->global->MAIN_FEATURES_LEVEL >= 2', // Define condition to show or hide menu entry. Use '$conf->mymodule->enabled' if entry must be visible if module is enabled. Use '$leftmenu==\'system\'' to show if leftmenu system is selected. - 'perms'=>'$user->rights->banque->consolidate', // Use 'perms'=>'$user->rights->mymodule->level1->level2' if you want your menu with a permission rules - 'target'=>'', - 'user'=>2 + /*$this->menu[$r]=array( + 'fk_menu'=>'fk_mainmenu=billing,fk_leftmenu=customers_bills_payment', // Use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode + 'mainmenu'=>'billing', + 'leftmenu'=>'customers_bills_payment_paypal', + 'type'=>'left', // This is a Left menu entry + 'titre'=>'PaypalImportPayment', + 'url'=>'/paypal/importpayments.php', + 'langs'=>'paypal', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory. + 'position'=>501, + 'enabled'=>'$conf->paypal->enabled && $conf->banque->enabled && $conf->global->MAIN_FEATURES_LEVEL >= 2', // Define condition to show or hide menu entry. Use '$conf->mymodule->enabled' if entry must be visible if module is enabled. Use '$leftmenu==\'system\'' to show if leftmenu system is selected. + 'perms'=>'$user->rights->banque->consolidate', // Use 'perms'=>'$user->rights->mymodule->level1->level2' if you want your menu with a permission rules + 'target'=>'', + 'user'=>2 ); // 0=Menu for internal users, 1=external users, 2=both - $r++; + $r++;*/ // Add here entries to declare new menus // Example to declare the Top Menu entry: diff --git a/htdocs/core/modules/modStripe.class.php b/htdocs/core/modules/modStripe.class.php index 348b44aaa1d..9a1584da477 100644 --- a/htdocs/core/modules/modStripe.class.php +++ b/htdocs/core/modules/modStripe.class.php @@ -92,7 +92,7 @@ class modStripe extends DolibarrModules // Main menu entries $r=0; - $this->menu[$r]=array( + /* $this->menu[$r]=array( 'fk_menu'=>'fk_mainmenu=billing,fk_leftmenu=customers_bills_payment', // Use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode 'mainmenu'=>'billing', 'leftmenu'=>'customers_bills_payment_stripe', @@ -106,7 +106,7 @@ class modStripe extends DolibarrModules 'target'=>'', 'user'=>2 ); // 0=Menu for internal users, 1=external users, 2=both - $r++; + $r++;*/ $this->menu[$r] = array( 'fk_menu'=>'fk_mainmenu=bank', diff --git a/htdocs/product/stock/productlot_card.php b/htdocs/product/stock/productlot_card.php index f72a28dbc90..dff2aa8e0e0 100644 --- a/htdocs/product/stock/productlot_card.php +++ b/htdocs/product/stock/productlot_card.php @@ -1,7 +1,6 @@ +/* Copyright (C) 2007-2018 Laurent Destailleur * Copyright (C) 2018 All-3kcis - * Copyright (C) ---Put here your own copyright and developer email--- * * 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 @@ -317,7 +316,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea } - $linkback = '' . $langs->trans("BackToList") . ''; + $linkback = '' . $langs->trans("BackToList") . ''; $shownav = 1; if ($user->societe_id && ! in_array('batch', explode(',',$conf->global->MAIN_MODULES_FOR_EXTERNAL))) $shownav=0; diff --git a/htdocs/product/stock/productlot_document.php b/htdocs/product/stock/productlot_document.php index 1ce4f9ba224..b9235b72133 100644 --- a/htdocs/product/stock/productlot_document.php +++ b/htdocs/product/stock/productlot_document.php @@ -131,7 +131,7 @@ if ($object->id) } - $linkback = '' . $langs->trans("BackToList") . ''; + $linkback = '' . $langs->trans("BackToList") . ''; $shownav = 1; if ($user->societe_id && ! in_array('batch', explode(',',$conf->global->MAIN_MODULES_FOR_EXTERNAL))) $shownav=0; diff --git a/htdocs/theme/eldy/style.css.php b/htdocs/theme/eldy/style.css.php index 6022c13a895..f9f64483e42 100644 --- a/htdocs/theme/eldy/style.css.php +++ b/htdocs/theme/eldy/style.css.php @@ -331,7 +331,7 @@ input, select { } /* Focus definitions must be after standard definition */ -textarea:focus, button:focus { +textarea:focus { /* v6 box-shadow: 0 0 4px #8091BF; */ border: 1px solid #aaa !important; } From 22170ac1c1f7c99d5eda928a510a588f9b31cbf8 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 8 Nov 2018 10:45:39 +0100 Subject: [PATCH 100/132] FIX Crop of large files was selecting wrong image area. --- htdocs/core/class/html.formfile.class.php | 2 +- htdocs/core/photos_resize.php | 29 +++++++++++++++++++---- 2 files changed, 26 insertions(+), 5 deletions(-) diff --git a/htdocs/core/class/html.formfile.class.php b/htdocs/core/class/html.formfile.class.php index 81a288e7dce..41b74079948 100644 --- a/htdocs/core/class/html.formfile.class.php +++ b/htdocs/core/class/html.formfile.class.php @@ -1018,7 +1018,7 @@ class FormFile global $form; $disablecrop=1; - if (in_array($modulepart, array('societe','product','produit','service','expensereport','holiday','member','project','ticket','user'))) $disablecrop=0; + if (in_array($modulepart, array('expensereport','holiday','member','project','product','produit','service','societe','tax','ticket','user'))) $disablecrop=0; // Define relative path used to store the file if (empty($relativepath)) diff --git a/htdocs/core/photos_resize.php b/htdocs/core/photos_resize.php index f4f178031de..b7e774bcd4d 100644 --- a/htdocs/core/photos_resize.php +++ b/htdocs/core/photos_resize.php @@ -83,6 +83,12 @@ elseif ($modulepart == 'societe') if (! $user->rights->societe->lire) accessforbidden(); $accessallowed=1; } +elseif ($modulepart == 'tax') +{ + $result=restrictedArea($user, 'tax', $id, 'chargesociales','charges'); + if (! $user->rights->tax->charges->lire) accessforbidden(); + $accessallowed=1; +} elseif ($modulepart == 'ticket') { $result=restrictedArea($user,'ticket',$id,'ticket'); @@ -177,6 +183,17 @@ elseif ($modulepart == 'expensereport') $dir=$conf->expensereport->dir_output; // By default } } +elseif ($modulepart == 'tax') +{ + require_once DOL_DOCUMENT_ROOT.'/compta/sociales/class/chargesociales.class.php'; + $object = new ChargeSociales($db); + if ($id > 0) + { + $result = $object->fetch($id); + if ($result <= 0) dol_print_error($db,'Failed to load object'); + $dir=$conf->tax->dir_output; // By default + } +} elseif ($modulepart == 'ticket') { require_once DOL_DOCUMENT_ROOT.'/ticket/class/ticket.class.php'; @@ -200,7 +217,8 @@ if (empty($backtourl)) else if (in_array($modulepart, array('member'))) $backtourl=DOL_URL_ROOT."/adherents/document.php?id=".$id.'&file='.urldecode($_POST["file"]); else if (in_array($modulepart, array('project'))) $backtourl=DOL_URL_ROOT."/projet/document.php?id=".$id.'&file='.urldecode($_POST["file"]); else if (in_array($modulepart, array('societe'))) $backtourl=DOL_URL_ROOT."/societe/document.php?id=".$id.'&file='.urldecode($_POST["file"]); - else if (in_array($modulepart, array('ticket'))) $backtourl=DOL_URL_ROOT."/ticket/document.php?id=".$id.'&file='.urldecode($_POST["file"]); + else if (in_array($modulepart, array('tax'))) $backtourl=DOL_URL_ROOT."/compta/sociales/document.php?id=".$id.'&file='.urldecode($_POST["file"]); + else if (in_array($modulepart, array('ticket'))) $backtourl=DOL_URL_ROOT."/ticket/document.php?id=".$id.'&file='.urldecode($_POST["file"]); else if (in_array($modulepart, array('user'))) $backtourl=DOL_URL_ROOT."/user/document.php?id=".$id.'&file='.urldecode($_POST["file"]); } @@ -226,6 +244,7 @@ if ($cancel) if ($action == 'confirm_resize' && (isset($_POST["file"]) != "") && (isset($_POST["sizex"]) != "") && (isset($_POST["sizey"]) != "")) { $fullpath=$dir."/".$original_file; + $result=dol_imageResizeOrCrop($fullpath,0,$_POST['sizex'],$_POST['sizey']); if ($result == $fullpath) @@ -294,6 +313,8 @@ if ($action == 'confirm_resize' && (isset($_POST["file"]) != "") && (isset($_POS if ($action == 'confirm_crop') { $fullpath=$dir."/".$original_file; + + //var_dump($_POST['w'].'x'.$_POST['h'].'-'.$_POST['x'].'x'.$_POST['y']);exit; $result=dol_imageResizeOrCrop($fullpath,1,$_POST['w'],$_POST['h'],$_POST['x'],$_POST['y']); if ($result == $fullpath) @@ -419,9 +440,9 @@ if (! empty($conf->use_javascript_ajax)) // If image is too large, we use another scale. if (! empty($_SESSION['dol_screenwidth']) && ($widthforcrop > round($_SESSION['dol_screenwidth']/2))) { - $widthforcrop=round($_SESSION['dol_screenwidth']/2); + $ratioforcrop=2; + $widthforcrop=round($_SESSION['dol_screenwidth'] / $ratioforcrop); $refsizeforcrop='screenwidth'; - $ratioforcrop=1; } print ''."\n"; @@ -448,7 +469,7 @@ if (! empty($conf->use_javascript_ajax)) - +
From c55f83b0b7ee4661d24fb401c4bd68564f60180a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 8 Nov 2018 11:25:29 +0100 Subject: [PATCH 101/132] Fix multicompany filter missing --- htdocs/core/lib/company.lib.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/core/lib/company.lib.php b/htdocs/core/lib/company.lib.php index 758c0803a10..3bc519e028a 100644 --- a/htdocs/core/lib/company.lib.php +++ b/htdocs/core/lib/company.lib.php @@ -740,11 +740,12 @@ function show_projects($conf, $langs, $db, $object, $backtopage='', $nocreatelin print '
'; print "\n".'
'.$langs->trans("LastSalaries",($num<=$MAXLIST?"":$MAXLIST)).''.$langs->trans("AllSalaries").' '.$num.''; print '
'.$langs->trans("LastSalaries",($num<=$MAXLIST?"":$MAXLIST)).''.$langs->trans("AllSalaries").' '.$num.'
'; - $sql = "SELECT p.rowid as id, p.title, p.ref, p.public, p.dateo as do, p.datee as de, p.fk_statut as status, p.fk_opp_status, p.opp_amount, p.opp_percent, p.tms as date_update, p.budget_amount"; + $sql = "SELECT p.rowid as id, p.entity, p.title, p.ref, p.public, p.dateo as do, p.datee as de, p.fk_statut as status, p.fk_opp_status, p.opp_amount, p.opp_percent, p.tms as date_update, p.budget_amount"; $sql .= ", cls.code as opp_status_code"; $sql .= " FROM ".MAIN_DB_PREFIX."projet as p"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_lead_status as cls on p.fk_opp_status = cls.rowid"; $sql .= " WHERE p.fk_soc = ".$object->id; + $sql .= " AND p.entity IN (".getEntity('project').")"; $sql .= " ORDER BY p.dateo DESC"; $result=$db->query($sql); From 224d37cfebe3ae1041ffb6656c2c35f6e62b2208 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 8 Nov 2018 12:12:08 +0100 Subject: [PATCH 102/132] Add bootstrap-iso class --- htdocs/website/index.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/website/index.php b/htdocs/website/index.php index 4f969851ad4..71b71e241a1 100644 --- a/htdocs/website/index.php +++ b/htdocs/website/index.php @@ -2735,7 +2735,7 @@ if ($action == 'preview' || $action == 'createfromclone' || $action == 'createpa $out.="\n"; - $out.='
'."\n"; + $out.='
'."\n"; // REPLACEMENT OF LINKS When page called by website editor From 7c4dad27280fa0d07914c1a76a18ac58a818ccfe Mon Sep 17 00:00:00 2001 From: John BOTELLA Date: Thu, 8 Nov 2018 12:12:45 +0100 Subject: [PATCH 103/132] FIX Warning: count() --- htdocs/projet/tasks.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/projet/tasks.php b/htdocs/projet/tasks.php index 94a51ef3d01..09e067a57fe 100644 --- a/htdocs/projet/tasks.php +++ b/htdocs/projet/tasks.php @@ -468,7 +468,7 @@ if ($action == 'create' && $user->rights->projet->creer && (empty($object->third print '
'; From 8bb1545ed012e38c3f7a2c664c2a2d8f05651fc6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Thu, 8 Nov 2018 12:16:05 +0100 Subject: [PATCH 105/132] Update index.php --- htdocs/fichinter/stats/index.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/fichinter/stats/index.php b/htdocs/fichinter/stats/index.php index 9bbbea09141..3551d8baab3 100644 --- a/htdocs/fichinter/stats/index.php +++ b/htdocs/fichinter/stats/index.php @@ -233,8 +233,8 @@ print '
'; print '
'; // Company print ''; // User print ''; // Opp status print ''; // Opp percent print ''; if (! $i) $totalarray['nbfield']++; } From 0d6709c9f723c6df0631d83eb851c01cd8a88828 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 9 Nov 2018 01:20:57 +0100 Subject: [PATCH 116/132] Update phpcs config --- dev/setup/codesniffer/ruleset.xml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/dev/setup/codesniffer/ruleset.xml b/dev/setup/codesniffer/ruleset.xml index 32a938662e6..8332338353d 100644 --- a/dev/setup/codesniffer/ruleset.xml +++ b/dev/setup/codesniffer/ruleset.xml @@ -25,19 +25,19 @@ - + 0 - + 0 - + 0 - + 0 - + 0 From aad0b700d44a4a498520edfd3a720c3e322a661c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 9 Nov 2018 01:22:56 +0100 Subject: [PATCH 117/132] Fix travis --- dev/setup/codesniffer/ruleset.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dev/setup/codesniffer/ruleset.xml b/dev/setup/codesniffer/ruleset.xml index 8332338353d..7e010eae927 100644 --- a/dev/setup/codesniffer/ruleset.xml +++ b/dev/setup/codesniffer/ruleset.xml @@ -28,7 +28,7 @@ 0 - + 0 @@ -37,7 +37,7 @@ 0 - + 0 From f1193ad3ddcaae17cef4730e2592b87327356b40 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 9 Nov 2018 10:29:22 +0100 Subject: [PATCH 118/132] FIX: Missing date creation and modification of supplier price --- htdocs/fourn/class/fournisseur.product.class.php | 9 +++++---- htdocs/product/fournisseurs.php | 12 ++++++++---- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/htdocs/fourn/class/fournisseur.product.class.php b/htdocs/fourn/class/fournisseur.product.class.php index a86e728e028..c9d269dcbe3 100644 --- a/htdocs/fourn/class/fournisseur.product.class.php +++ b/htdocs/fourn/class/fournisseur.product.class.php @@ -560,10 +560,9 @@ class ProductFournisseur extends Product $sql = "SELECT s.nom as supplier_name, s.rowid as fourn_id,"; $sql.= " pfp.rowid as product_fourn_pri_id, pfp.ref_fourn, pfp.desc_fourn, pfp.fk_product as product_fourn_id, pfp.fk_supplier_price_expression,"; - $sql.= " pfp.price, pfp.quantity, pfp.unitprice, pfp.remise_percent, pfp.remise, pfp.tva_tx, pfp.fk_availability, pfp.charges, pfp.info_bits, pfp.delivery_time_days, pfp.supplier_reputation"; - $sql.= " ,pfp.multicurrency_price, pfp.multicurrency_unitprice, pfp.multicurrency_tx, pfp.fk_multicurrency, pfp.multicurrency_code"; - $sql.= " FROM ".MAIN_DB_PREFIX."product_fournisseur_price as pfp"; - $sql.= ", ".MAIN_DB_PREFIX."societe as s"; + $sql.= " pfp.price, pfp.quantity, pfp.unitprice, pfp.remise_percent, pfp.remise, pfp.tva_tx, pfp.fk_availability, pfp.charges, pfp.info_bits, pfp.delivery_time_days, pfp.supplier_reputation,"; + $sql.= " pfp.multicurrency_price, pfp.multicurrency_unitprice, pfp.multicurrency_tx, pfp.fk_multicurrency, pfp.multicurrency_code, pfp.datec, pfp.tms"; + $sql.= " FROM ".MAIN_DB_PREFIX."product_fournisseur_price as pfp, ".MAIN_DB_PREFIX."societe as s"; $sql.= " WHERE pfp.entity IN (".getEntity('productsupplierprice').")"; $sql.= " AND pfp.fk_soc = s.rowid"; $sql.= " AND s.status=1"; // only enabled company selected @@ -603,6 +602,8 @@ class ProductFournisseur extends Product $prodfourn->fourn_tva_npr = $record["info_bits"]; $prodfourn->fk_supplier_price_expression = $record["fk_supplier_price_expression"]; $prodfourn->supplier_reputation = $record["supplier_reputation"]; + $prodfourn->date_creation = $this->db->jdate($record['datec']); + $prodfourn->date_modification = $this->db->jdate($record['tms']); $prodfourn->fourn_multicurrency_price = $record["multicurrency_price"]; $prodfourn->fourn_multicurrency_unitprice = $record["multicurrency_unitprice"]; diff --git a/htdocs/product/fournisseurs.php b/htdocs/product/fournisseurs.php index 7ad740eab0a..df40f000c19 100644 --- a/htdocs/product/fournisseurs.php +++ b/htdocs/product/fournisseurs.php @@ -751,16 +751,17 @@ SCRIPT; $num = count($product_fourn_list); if (($num + ($offset * $limit)) < $nbtotalofrecords) $num++; - print_barre_liste($langs->trans('SupplierPrices'), $page, $_SERVEUR ['PHP_SELF'], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'title_accountancy.png', 0, '', '', $limit, 1); + print_barre_liste($langs->trans('SupplierPrices'), $page, $_SERVEUR ['PHP_SELF'], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'title_accountancy.png', 0, '', '', $limit, 1); // Suppliers list title - print '
'; - print '
'.$langs->trans("AffectedTo").''; $contactsofproject=(! empty($object->id)?$object->getListContactId('internal'):''); - if (count($contactsofproject)) + if (is_array($contactsofproject) && count($contactsofproject)) { print $form->select_dolusers($user->id, 'userid', 0, '', 0, '', $contactsofproject, 0, 0, 0, '', 0, '', 'maxwidth300'); } From 670eed1e688dce5464d43bd031137a525fc1a399 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Thu, 8 Nov 2018 12:13:07 +0100 Subject: [PATCH 104/132] Update index.php --- htdocs/fichinter/stats/index.php | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/htdocs/fichinter/stats/index.php b/htdocs/fichinter/stats/index.php index 39cad7ca4f1..9bbbea09141 100644 --- a/htdocs/fichinter/stats/index.php +++ b/htdocs/fichinter/stats/index.php @@ -49,10 +49,7 @@ $endyear=$year; $object_status=GETPOST('object_status'); -$langs->load('interventions'); -$langs->load('companies'); -$langs->load('other'); -$langs->load('suppliers'); +$langs->loadLangs(array('interventions', 'companies', 'other', 'suppliers')); /* @@ -62,11 +59,8 @@ $langs->load('suppliers'); $form=new Form($db); $objectstatic=new FichInter($db); -if ($mode == 'customer') -{ - $title=$langs->trans("InterventionStatistics"); - $dir=$conf->ficheinter->dir_temp; -} +$title=$langs->trans("InterventionStatistics"); +$dir=$conf->ficheinter->dir_temp; llxHeader('', $title); @@ -79,19 +73,18 @@ if ($object_status != '' && $object_status > -1) $stats->where .= ' AND c.fk_sta // Build graphic number of object $data = $stats->getNbByMonthWithPrevYear($endyear,$startyear); -//var_dump($data); // $data = array(array('Lib',val1,val2,val3),...) if (!$user->rights->societe->client->voir || $user->societe_id) { $filenamenb = $dir.'/interventionsnbinyear-'.$user->id.'-'.$year.'.png'; - if ($mode == 'customer') $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=interventionstats&file=interventionsnbinyear-'.$user->id.'-'.$year.'.png'; + $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=interventionstats&file=interventionsnbinyear-'.$user->id.'-'.$year.'.png'; } else { $filenamenb = $dir.'/interventionsnbinyear-'.$year.'.png'; - if ($mode == 'customer') $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=interventionstats&file=interventionsnbinyear-'.$year.'.png'; + $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=interventionstats&file=interventionsnbinyear-'.$year.'.png'; } $px1 = new DolGraph(); @@ -123,7 +116,6 @@ if (! $mesg) // Build graphic amount of object $data = $stats->getAmountByMonthWithPrevYear($endyear,$startyear); -//var_dump($data); // $data = array(array('Lib',val1,val2,val3),...) if (!$user->rights->societe->client->voir || $user->societe_id) @@ -283,7 +275,8 @@ foreach ($data as $val) { $year = $val['year']; while (! empty($year) && $oldyear > $year+1) - { // If we have empty year + { + // If we have empty year $oldyear--; print '
'.$langs->trans("Filter").'
'.$langs->trans("ThirdParty").''; - if ($mode == 'customer') $filter='s.client in (1,2,3)'; - print $form->select_company($socid,'socid',$filter,1,0,0,array(),0,'','style="width: 95%"'); + $filter = 's.client in (1,2,3)'; + print $form->select_company($socid, 'socid', $filter, 1, 0, 0, array(), 0, '', 'style="width: 95%"'); print '
'.$langs->trans("CreatedBy").''; From 87274352165bc2a9beaba3617c18ae8e0417c1cc Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Thu, 8 Nov 2018 13:58:37 +0100 Subject: [PATCH 106/132] Update API for download more infos for easiest & better use of the generated file by API --- htdocs/api/class/api_documents.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/api/class/api_documents.class.php b/htdocs/api/class/api_documents.class.php index 66c293f2cb0..23ed35428d3 100644 --- a/htdocs/api/class/api_documents.class.php +++ b/htdocs/api/class/api_documents.class.php @@ -103,7 +103,7 @@ class Documents extends DolibarrApi } $file_content=file_get_contents($original_file_osencoded); - return array('filename'=>$filename, 'content'=>base64_encode($file_content), 'encoding'=>'MIME base64 (base64_encode php function, http://php.net/manual/en/function.base64-encode.php)' ); + return array('filename'=>$filename, 'content-type' => mime_content_type($original_file),'content'=>base64_encode($file_content), 'encoding'=>'base64' ); } From 98548337ae465849d316a01e20594586d0d882a0 Mon Sep 17 00:00:00 2001 From: John BOTELLA Date: Thu, 8 Nov 2018 15:38:25 +0100 Subject: [PATCH 107/132] FIX supplier order list keep socid --- htdocs/commande/list.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/htdocs/commande/list.php b/htdocs/commande/list.php index a9da48fd626..4841e9be410 100644 --- a/htdocs/commande/list.php +++ b/htdocs/commande/list.php @@ -467,7 +467,9 @@ if ($resql) print ''; print ''; print ''; - + print ''; + + print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'title_commercial.png', 0, $newcardbutton, '', $limit); $topicmail="SendOrderRef"; From 6401a7ab06e2b1ebc6cdc99a7d657f37a3b00961 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 8 Nov 2018 16:03:10 +0100 Subject: [PATCH 108/132] Fix css --- htdocs/theme/eldy/style.css.php | 1 + htdocs/theme/md/style.css.php | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/theme/eldy/style.css.php b/htdocs/theme/eldy/style.css.php index f9f64483e42..ce2d5c28555 100644 --- a/htdocs/theme/eldy/style.css.php +++ b/htdocs/theme/eldy/style.css.php @@ -3316,6 +3316,7 @@ ul.noborder li:nth-child(even):not(.liste_titre) { .thumbstat150 { flex: 1 1 110px; margin-bottom: 8px; + width: 160px; } .dashboardlineindicator { float: left; diff --git a/htdocs/theme/md/style.css.php b/htdocs/theme/md/style.css.php index a246786a53a..9d5a518c4bf 100644 --- a/htdocs/theme/md/style.css.php +++ b/htdocs/theme/md/style.css.php @@ -3249,7 +3249,7 @@ div .tdtop { margin: 3px; border: 1px solid #ddd; box-shadow: none; - background: #ddd; + background: #eee; } .thumbstat { flex: 1 1 110px; From 360eb6eed68499c5cdd15ed1900cc18747ef47db Mon Sep 17 00:00:00 2001 From: Laurent BOUQUET Date: Thu, 8 Nov 2018 16:24:31 +0100 Subject: [PATCH 109/132] Fix syntax error in 'htdocs\accountancy\admin\export.php' : Delete 'aZ09' text in line 45 --- htdocs/accountancy/admin/export.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/accountancy/admin/export.php b/htdocs/accountancy/admin/export.php index eccb9b0c06f..03538b759e7 100644 --- a/htdocs/accountancy/admin/export.php +++ b/htdocs/accountancy/admin/export.php @@ -41,7 +41,7 @@ if (empty($user->rights->accounting->chartofaccount)) accessforbidden(); } -$action = GETPOST('action', 'alpha'); +$action = GETPOST('action', 'aZ09'); // Parameters ACCOUNTING_EXPORT_* $main_option = array ( From 320e7adef7fdebcc86783dc28b7e9fac0a9d5013 Mon Sep 17 00:00:00 2001 From: Laurent BOUQUET Date: Thu, 8 Nov 2018 17:09:54 +0100 Subject: [PATCH 110/132] Fix blank lines and whitespace at end of lines --- htdocs/core/modules/DolibarrModules.class.php | 20 +++++++++---------- htdocs/product/class/product.class.php | 8 ++++---- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/htdocs/core/modules/DolibarrModules.class.php b/htdocs/core/modules/DolibarrModules.class.php index d52adb6522d..8a7895a2c68 100644 --- a/htdocs/core/modules/DolibarrModules.class.php +++ b/htdocs/core/modules/DolibarrModules.class.php @@ -377,7 +377,7 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it * @param string $options String with options when disabling module: * - 'noboxes' = Do not insert boxes - * 'newboxdefonly' = For boxes, insert def of - * boxes only and not boxes activation + * boxes only and not boxes activation * * @return int 1 if OK, 0 if KO */ @@ -470,7 +470,7 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it * Disable function. Deletes the module constants and boxes from the database. * * @param string[] $array_sql SQL requests to be executed when module is disabled - * @param string $options Options when disabling module: + * @param string $options Options when disabling module: * * @return int 1 if OK, 0 if KO */ @@ -1352,13 +1352,13 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it if (! $err) { $sql = "INSERT INTO ".MAIN_DB_PREFIX."cronjob (module_name, datec, datestart, dateend, label, jobtype, classesname, objectname, methodename, command, params, note,"; - if(is_int($frequency)) { $sql.= ' frequency,'; + if(is_int($frequency)) { $sql.= ' frequency,'; } - if(is_int($unitfrequency)) { $sql.= ' unitfrequency,'; + if(is_int($unitfrequency)) { $sql.= ' unitfrequency,'; } - if(is_int($priority)) { $sql.= ' priority,'; + if(is_int($priority)) { $sql.= ' priority,'; } - if(is_int($status)) { $sql.= ' status,'; + if(is_int($status)) { $sql.= ' status,'; } $sql.= " entity, test)"; $sql.= " VALUES ("; @@ -1374,13 +1374,13 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it $sql.= ($command?"'".$this->db->escape($command)."'":"null").","; $sql.= ($parameters?"'".$this->db->escape($parameters)."'":"null").","; $sql.= ($comment?"'".$this->db->escape($comment)."'":"null").","; - if(is_int($frequency)) { $sql.= "'".$this->db->escape($frequency)."', "; + if(is_int($frequency)) { $sql.= "'".$this->db->escape($frequency)."', "; } - if(is_int($unitfrequency)) { $sql.= "'".$this->db->escape($unitfrequency)."', "; + if(is_int($unitfrequency)) { $sql.= "'".$this->db->escape($unitfrequency)."', "; } if(is_int($priority)) {$sql.= "'".$this->db->escape($priority)."', "; } - if(is_int($status)) { $sql.= "'".$this->db->escape($status)."', "; + if(is_int($status)) { $sql.= "'".$this->db->escape($status)."', "; } $sql.= $entity.","; $sql.= "'".$this->db->escape($test)."'"; @@ -2201,7 +2201,7 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it * * @param string $options Options when enabling module ('', 'newboxdefonly', 'noboxes') * 'noboxes' = Do not insert boxes 'newboxdefonly' = For boxes, - * insert def of boxes only and not boxes activation + * insert def of boxes only and not boxes activation * @return int 1 if OK, 0 if KO */ public function init($options = '') diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index 7594b9cc204..5ee8b3a9948 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -654,7 +654,7 @@ class Product extends CommonObject if (! $error && ! $notrigger) { // Call trigger $result=$this->call_trigger('PRODUCT_CREATE', $user); - if ($result < 0) { $error++; + if ($result < 0) { $error++; } // End call triggers } @@ -975,7 +975,7 @@ class Product extends CommonObject if (! $error && ! $notrigger) { // Call trigger $result=$this->call_trigger('PRODUCT_MODIFY', $user); - if ($result < 0) { $error++; + if ($result < 0) { $error++; } // End call triggers } @@ -1089,7 +1089,7 @@ class Product extends CommonObject if (! $error && empty($notrigger)) { // Call trigger $result=$this->call_trigger('PRODUCT_DELETE', $user); - if ($result < 0) { $error++; + if ($result < 0) { $error++; } // End call triggers } @@ -4085,7 +4085,7 @@ class Product extends CommonObject * This function need a lot of load. If you use it on list, use a cache to execute it once for each product id. * If ENTREPOT_EXTRA_STATUS set, filtering on warehouse status possible. * - * @param string $option '' = Load all stock info, also from closed and internal warehouses, + * @param string $option '' = Load all stock info, also from closed and internal warehouses, * @return int < 0 if KO, > 0 if OK * @see load_virtual_stock(), loadBatchInfo() */ From e92a63ba734d8debd0bb797c88d88b7d217357c2 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 8 Nov 2018 17:15:35 +0100 Subject: [PATCH 111/132] FIX If we change customer/supplier rule we can't edit old thirdparty. --- htdocs/societe/class/societe.class.php | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index 0a49bb80f1b..eaf62bc89ca 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -872,6 +872,24 @@ class Societe extends CommonObject // We don't check when update called during a create because verify was already done. // For a merge, we suppose source data is clean and a customer code of a deleted thirdparty must be accepted into a target thirdparty with empty code without duplicate error $result = $this->verify(); + + // If there is only one error and error is ErrorBadCustomerCodeSyntax and we don't change customer code, we allow the update + // So we can update record that were using and old numbering rule. + if (is_array($this->errors)) + { + if (in_array('ErrorBadCustomerCodeSyntax', $this->errors) && is_object($this->oldcopy) && $this->oldcopy->code_client == $this->code_client) + { + if (($key = array_search('ErrorBadCustomerCodeSyntax', $this->errors)) !== false) unset($this->errors[$key]); // Remove error message + } + if (in_array('ErrorBadSupplierCodeSyntax', $this->errors) && is_object($this->oldcopy) && $this->oldcopy->code_fournisseur == $this->code_fournisseur) + { + if (($key = array_search('ErrorBadSupplierCodeSyntax', $this->errors)) !== false) unset($this->errors[$key]); // Remove error message + } + if (empty($this->errors)) // If there is no more error, we can make like if there is no error at all + { + $result = 0; + } + } } if ($result >= 0) @@ -1518,7 +1536,7 @@ class Societe extends CommonObject dol_syslog(get_class($this)."::delete error -3 ".$this->error, LOG_ERR); } } - + // Remove links to subsidiaries companies if (! $error) { From cf688a894b5579bcde526252fa160f5b7fe6eb42 Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Thu, 8 Nov 2018 17:20:12 +0100 Subject: [PATCH 112/132] Update api_documents.class.php --- htdocs/api/class/api_documents.class.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/htdocs/api/class/api_documents.class.php b/htdocs/api/class/api_documents.class.php index 23ed35428d3..8db471855d6 100644 --- a/htdocs/api/class/api_documents.class.php +++ b/htdocs/api/class/api_documents.class.php @@ -103,7 +103,7 @@ class Documents extends DolibarrApi } $file_content=file_get_contents($original_file_osencoded); - return array('filename'=>$filename, 'content-type' => mime_content_type($original_file),'content'=>base64_encode($file_content), 'encoding'=>'base64' ); + return array('filename'=>$filename, 'content-type' => dol_mimetype($filename), 'filesize'=>filesize($original_file), 'content'=>base64_encode($file_content), 'encoding'=>'base64' ); } @@ -224,10 +224,9 @@ class Documents extends DolibarrApi } $file_content=file_get_contents($original_file_osencoded); - return array('filename'=>$filename, 'content'=>base64_encode($file_content), 'langcode'=>$outputlangs->defaultlang, 'template'=>$templateused, 'encoding'=>'MIME base64 (base64_encode php function, http://php.net/manual/en/function.base64-encode.php)' ); + return array('filename'=>$filename, 'content-type' => dol_mimetype($filename), 'filesize'=>filesize($original_file), 'content'=>base64_encode($file_content), 'langcode'=>$outputlangs->defaultlang, 'template'=>$templateused, 'encoding'=>'base64' ); } - /** * Return the list of documents of a dedicated element (from its ID or Ref) * From 588de2cc860e6e587a8315a9689650d651e127a6 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 8 Nov 2018 18:45:02 +0100 Subject: [PATCH 113/132] Fix filter on entity on project --- htdocs/core/lib/company.lib.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/core/lib/company.lib.php b/htdocs/core/lib/company.lib.php index 3bc519e028a..c504a01c63d 100644 --- a/htdocs/core/lib/company.lib.php +++ b/htdocs/core/lib/company.lib.php @@ -120,6 +120,7 @@ function societe_prepare_head(Societe $object) $sql = "SELECT COUNT(n.rowid) as nb"; $sql.= " FROM ".MAIN_DB_PREFIX."projet as n"; $sql.= " WHERE fk_soc = ".$object->id; + $sql.= " AND entity IN (".getEntity('project').")"; $resql=$db->query($sql); if ($resql) { From be788e6167bfc9862c3b521c557974c335217354 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 8 Nov 2018 19:57:31 +0100 Subject: [PATCH 114/132] FIX responsive --- htdocs/comm/remx.php | 80 ++++++++++++++++++++++++-------------------- 1 file changed, 44 insertions(+), 36 deletions(-) diff --git a/htdocs/comm/remx.php b/htdocs/comm/remx.php index 3eec109e6b3..a66e8e66500 100644 --- a/htdocs/comm/remx.php +++ b/htdocs/comm/remx.php @@ -254,7 +254,7 @@ if ($socid > 0) print '
'; print '
'; - + if(! $isCustomer && ! $isSupplier) { print '

'.$langs->trans('ThirdpartyIsNeitherCustomerNorClientSoCannotHaveDiscounts').'

'; @@ -266,8 +266,8 @@ if ($socid > 0) $db->close(); exit; } - - + + print ''; if($isCustomer) { // Calcul avoirs client en cours @@ -293,7 +293,7 @@ if ($socid > 0) print ''; print ''; - + if (! empty($user->fk_soc)) // No need to show this for external users { print ''; @@ -322,10 +322,10 @@ if ($socid > 0) { dol_print_error($db); } - + print ''; print ''; - + if (! empty($user->fk_soc)) // No need to show this for external users { print ''; @@ -344,11 +344,11 @@ if ($socid > 0) print load_fiche_titre($langs->trans("NewGlobalDiscount"),'',''); print '
'; - + if($isCustomer && ! $isSupplier) { print ''; } - + if(! $isCustomer && $isSupplier) { print ''; } @@ -356,8 +356,8 @@ if ($socid > 0) print '
'.$langs->trans("CustomerAbsoluteDiscountAllUsers").''.$remise_all.' '.$langs->trans("Currency".$conf->currency).' '.$langs->trans("HT").'
'.$langs->trans("CustomerAbsoluteDiscountMy").'
'.$langs->trans("SupplierAbsoluteDiscountAllUsers").''.$remise_all.' '.$langs->trans("Currency".$conf->currency).' '.$langs->trans("HT").'
'.$langs->trans("SupplierAbsoluteDiscountMy").'
'; if($isCustomer && $isSupplier) { print ''; - print ''; } print ''; @@ -401,7 +401,7 @@ if ($socid > 0) /* * Liste remises fixes client restant en cours (= liees a aucune facture ni ligne de facture) */ - + print load_fiche_titre($langs->trans("DiscountStillRemaining")); if($isCustomer) { @@ -424,10 +424,11 @@ if ($socid > 0) $sql.= " AND rc.discount_type = 0"; // Eliminate supplier discounts $sql.= " AND (rc.fk_facture_line IS NULL AND rc.fk_facture IS NULL)"; $sql.= " ORDER BY rc.datec DESC"; - + $resql=$db->query($sql); if ($resql) { + print '
'; print '
'.$langs->trans('DiscountType').' '; - print ' '; + print ' '; + print '   '; print '
'.$langs->trans("AmountHT").'
'; print ''; print ''; // Need 120+ for format with AM/PM @@ -439,9 +440,9 @@ if ($socid > 0) print ''; print ''; print ''; - + $showconfirminfo=array(); - + $i = 0; $num = $db->num_rows($resql); if ($num > 0) @@ -449,7 +450,7 @@ if ($socid > 0) while ($i < $num) { $obj = $db->fetch_object($resql); - + print ''; print ''; if (preg_match('/\(CREDIT_NOTE\)/',$obj->description)) @@ -502,7 +503,7 @@ if ($socid > 0) } else print ''; print ''; - + if ($_GET["action"]=='split' && GETPOST('remid') == $obj->rowid) { $showconfirminfo['rowid']=$obj->rowid; @@ -517,7 +518,8 @@ if ($socid > 0) } $db->free($resql); print "
'.$langs->trans("Date").''.$langs->trans("DiscountOfferedBy").' 
'.dol_print_date($db->jdate($obj->dc),'dayhour').' 
"; - + print '
'; + if (count($showconfirminfo)) { $amount1=price2num($showconfirminfo['amount_ttc']/2,'MT'); @@ -561,10 +563,11 @@ if ($socid > 0) $sql.= " AND rc.discount_type = 1"; // Eliminate customer discounts $sql.= " AND (rc.fk_invoice_supplier IS NULL AND rc.fk_invoice_supplier_line IS NULL)"; $sql.= " ORDER BY rc.datec DESC"; - + $resql=$db->query($sql); if ($resql) { + print '
'; print ''; print ''; print ''; // Need 120+ for format with AM/PM @@ -576,9 +579,9 @@ if ($socid > 0) print ''; print ''; print ''; - + $showconfirminfo=array(); - + $i = 0; $num = $db->num_rows($resql); if ($num > 0) @@ -586,7 +589,7 @@ if ($socid > 0) while ($i < $num) { $obj = $db->fetch_object($resql); - + print ''; print ''; if (preg_match('/\(CREDIT_NOTE\)/',$obj->description)) @@ -639,7 +642,7 @@ if ($socid > 0) } else print ''; print ''; - + if ($_GET["action"]=='split' && GETPOST('remid') == $obj->rowid) { $showconfirminfo['rowid']=$obj->rowid; @@ -654,7 +657,8 @@ if ($socid > 0) } $db->free($resql); print "
'.$langs->trans("Date").''.$langs->trans("DiscountOfferedBy").' 
'.dol_print_date($db->jdate($obj->dc),'dayhour').' 
"; - + print '
'; + if (count($showconfirminfo)) { $amount1=price2num($showconfirminfo['amount_ttc']/2,'MT'); @@ -673,19 +677,19 @@ if ($socid > 0) dol_print_error($db); } - if($isCustomer) { + if ($isCustomer) { print ''; // class="ficheaddleft" print ''; // class="fichehalfright" print ''; // class="fichecenter" } } - print '
'; + print '

'; /* * List discount consumed (=liees a une ligne de facture ou facture) */ - + print load_fiche_titre($langs->trans("DiscountAlreadyCounted")); if($isCustomer) { @@ -730,12 +734,13 @@ if ($socid > 0) $sql2.= " AND rc.fk_user = u.rowid"; $sql2.= " AND rc.discount_type = 0"; // Eliminate supplier discounts $sql2.= " ORDER BY dc DESC"; - + $resql=$db->query($sql); $resql2=null; if ($resql) $resql2=$db->query($sql2); if ($resql2) { + print '
'; print ''; print ''; print ''; // Need 120+ for format with AM/PM @@ -747,7 +752,7 @@ if ($socid > 0) print ''; print ''; print ''; - + $tab_sqlobj=array(); $tab_sqlobjOrder=array(); $num = $db->num_rows($resql); @@ -761,7 +766,7 @@ if ($socid > 0) } } $db->free($resql); - + $num = $db->num_rows($resql2); for ($i = 0;$i < $num;$i++) { @@ -771,7 +776,7 @@ if ($socid > 0) } $db->free($resql2); array_multisort($tab_sqlobjOrder,SORT_DESC,$tab_sqlobj); - + $num = count($tab_sqlobj); if ($num > 0) { @@ -830,8 +835,9 @@ if ($socid > 0) { print ''; } - + print "
'.$langs->trans("Date").''.$langs->trans("Author").' 
'.$langs->trans("None").'
"; + print '
'; } else { @@ -882,12 +888,13 @@ if ($socid > 0) $sql2.= " AND rc.fk_user = u.rowid"; $sql2.= " AND rc.discount_type = 1"; // Eliminate customer discounts $sql2.= " ORDER BY dc DESC"; - + $resql=$db->query($sql); $resql2=null; if ($resql) $resql2=$db->query($sql2); if ($resql2) { + print '
'; print ''; print ''; print ''; // Need 120+ for format with AM/PM @@ -899,7 +906,7 @@ if ($socid > 0) print ''; print ''; print ''; - + $tab_sqlobj=array(); $tab_sqlobjOrder=array(); $num = $db->num_rows($resql); @@ -913,7 +920,7 @@ if ($socid > 0) } } $db->free($resql); - + $num = $db->num_rows($resql2); for ($i = 0;$i < $num;$i++) { @@ -923,7 +930,7 @@ if ($socid > 0) } $db->free($resql2); array_multisort($tab_sqlobjOrder,SORT_DESC,$tab_sqlobj); - + $num = count($tab_sqlobj); if ($num > 0) { @@ -982,8 +989,9 @@ if ($socid > 0) { print ''; } - + print "
'.$langs->trans("Date").''.$langs->trans("Author").' 
'.$langs->trans("None").'
"; + print '
'; } else { From 9a31a61c9d22f61fce1f3fafcf444e1e2d8c8883 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 8 Nov 2018 20:05:01 +0100 Subject: [PATCH 115/132] FIX #9971 --- htdocs/core/class/html.formprojet.class.php | 2 +- htdocs/core/class/translate.class.php | 4 ---- htdocs/core/lib/company.lib.php | 2 +- htdocs/projet/list.php | 2 +- 4 files changed, 3 insertions(+), 7 deletions(-) diff --git a/htdocs/core/class/html.formprojet.class.php b/htdocs/core/class/html.formprojet.class.php index 7d74ac308b9..42ea2d216aa 100644 --- a/htdocs/core/class/html.formprojet.class.php +++ b/htdocs/core/class/html.formprojet.class.php @@ -631,7 +631,7 @@ class FormProjets $sellist .= '>'; if ($useshortlabel) { - $finallabel = ($langs->transnoentitiesnoconv("OppStatusShort".$obj->code) != "OppStatusShort".$obj->code ? $langs->transnoentitiesnoconv("OppStatusShort".$obj->code) : $obj->label); + $finallabel = ($langs->transnoentitiesnoconv("OppStatus".$obj->code) != "OppStatus".$obj->code ? $langs->transnoentitiesnoconv("OppStatus".$obj->code) : $obj->label); } else { diff --git a/htdocs/core/class/translate.class.php b/htdocs/core/class/translate.class.php index bdcae2e33ea..04867db0e7a 100644 --- a/htdocs/core/class/translate.class.php +++ b/htdocs/core/class/translate.class.php @@ -562,10 +562,6 @@ class Translate elseif (preg_match('/^PaymentTypeShort([0-9A-Z]+)$/i',$key,$reg)) { $newstr=$this->getLabelFromKey($db,$reg[1],'c_paiement','code','libelle','',1); - } - elseif (preg_match('/^OppStatusShort([0-9A-Z]+)$/i',$key,$reg)) - { - $newstr=$this->getLabelFromKey($db,$reg[1],'c_lead_status','code','label'); } elseif (preg_match('/^OppStatus([0-9A-Z]+)$/i',$key,$reg)) { diff --git a/htdocs/core/lib/company.lib.php b/htdocs/core/lib/company.lib.php index c504a01c63d..c00d4469b05 100644 --- a/htdocs/core/lib/company.lib.php +++ b/htdocs/core/lib/company.lib.php @@ -802,7 +802,7 @@ function show_projects($conf, $langs, $db, $object, $backtopage='', $nocreatelin print '
'; - if ($obj->opp_status_code) print $langs->trans("OppStatusShort".$obj->opp_status_code); + if ($obj->opp_status_code) print $langs->trans("OppStatus".$obj->opp_status_code); print ''; diff --git a/htdocs/projet/list.php b/htdocs/projet/list.php index aa0c4b0d8fe..bc29cd26f45 100644 --- a/htdocs/projet/list.php +++ b/htdocs/projet/list.php @@ -804,7 +804,7 @@ while ($i < min($num,$limit)) if (! empty($arrayfields['p.fk_opp_status']['checked'])) { print ''; - if ($obj->opp_status_code) print $langs->trans("OppStatusShort".$obj->opp_status_code); + if ($obj->opp_status_code) print $langs->trans("OppStatus".$obj->opp_status_code); print '
'; + print '
'; + print '
'; if ($object->isProduct()) $nblignefour=4; else $nblignefour=4; $param="&id=".$object->id; print ''; + print_liste_field_titre("AppliedPricesFrom",$_SERVER["PHP_SELF"],"pfp.datec","",$param,"",$sortfield,$sortorder); print_liste_field_titre("Suppliers",$_SERVER["PHP_SELF"],"s.nom","",$param,"",$sortfield,$sortorder); print_liste_field_titre("SupplierRef",$_SERVER["PHP_SELF"],"","",$param,"",$sortfield,$sortorder); if (!empty($conf->global->FOURN_PRODUCT_AVAILABILITY)) print_liste_field_titre("Availability",$_SERVER["PHP_SELF"],"pfp.fk_availability","",$param,"",$sortfield,$sortorder); @@ -788,10 +789,13 @@ SCRIPT; { print ''; + // Date from + print ''; + // Supplier print ''; - // Supplier + // Supplier ref print ''; // Availability From 5d1d77a966dc26032d172450d772f8311a1bf70a Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Fri, 9 Nov 2018 10:25:00 +0100 Subject: [PATCH 119/132] FIX missing action "edit" for the hook --- htdocs/categories/edit.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/categories/edit.php b/htdocs/categories/edit.php index b420847f6fd..1cde5e62adc 100644 --- a/htdocs/categories/edit.php +++ b/htdocs/categories/edit.php @@ -35,7 +35,7 @@ $langs->load("categories"); $id=GETPOST('id','int'); $ref=GETPOST('ref'); $type=GETPOST('type'); -$action=GETPOST('action','aZ09'); +$action=(GETPOST('action','aZ09')?GETPOST('action','aZ09'):'edit'); $confirm=GETPOST('confirm'); $cancel=GETPOST('cancel','alpha'); From ee06f36f4c82f8b51624ceed78ef79a20dd7f61b Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Fri, 9 Nov 2018 11:36:20 +0100 Subject: [PATCH 120/132] FIX missing field "visible" --- htdocs/categories/class/categorie.class.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/categories/class/categorie.class.php b/htdocs/categories/class/categorie.class.php index 70b2108dd4c..3de9bdfab0a 100644 --- a/htdocs/categories/class/categorie.class.php +++ b/htdocs/categories/class/categorie.class.php @@ -1043,7 +1043,7 @@ class Categorie extends CommonObject $current_lang = $langs->getDefaultLang(); // Init $this->cats array - $sql = "SELECT DISTINCT c.rowid, c.label, c.description, c.color, c.fk_parent"; // Distinct reduce pb with old tables with duplicates + $sql = "SELECT DISTINCT c.rowid, c.label, c.description, c.color, c.fk_parent, c.visible"; // Distinct reduce pb with old tables with duplicates if (! empty($conf->global->MAIN_MULTILANGS)) $sql.= ", t.label as label_trans, t.description as description_trans"; $sql.= " FROM ".MAIN_DB_PREFIX."categorie as c"; if (! empty($conf->global->MAIN_MULTILANGS)) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."categorie_lang as t ON t.fk_category=c.rowid AND t.lang='".$current_lang."'"; @@ -1063,6 +1063,7 @@ class Categorie extends CommonObject $this->cats[$obj->rowid]['label'] = ! empty($obj->label_trans) ? $obj->label_trans : $obj->label; $this->cats[$obj->rowid]['description'] = ! empty($obj->description_trans) ? $obj->description_trans : $obj->description; $this->cats[$obj->rowid]['color'] = $obj->color; + $this->cats[$obj->rowid]['visible'] = $obj->visible; $i++; } } From 773e2da4ccef4d45982c305fde9602c029ccadf1 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 9 Nov 2018 11:41:27 +0100 Subject: [PATCH 121/132] Fix example of number for holiday --- htdocs/admin/holiday.php | 8 ++++---- htdocs/holiday/class/holiday.class.php | 2 ++ 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/htdocs/admin/holiday.php b/htdocs/admin/holiday.php index c1c5fe58b45..82037fa85d1 100644 --- a/htdocs/admin/holiday.php +++ b/htdocs/admin/holiday.php @@ -75,8 +75,8 @@ else if ($action == 'specimen') // For contract { $modele= GETPOST('module','alpha'); - $contract = new Contrat($db); - $contract->initAsSpecimen(); + $holiday = new Holiday($db); + $holiday->initAsSpecimen(); // Search template files $file=''; $classname=''; $filefound=0; @@ -98,7 +98,7 @@ else if ($action == 'specimen') // For contract $module = new $classname($db); - if ($module->write_file($contract,$langs) > 0) + if ($module->write_file($holiday,$langs) > 0) { header("Location: ".DOL_URL_ROOT."/document.php?modulepart=holiday&file=SPECIMEN.pdf"); return; @@ -271,7 +271,7 @@ foreach ($dirmodels as $reldir) // Info $htmltooltip=''; $htmltooltip.=''.$langs->trans("Version").': '.$module->getVersion().'
'; - $nextval=$module->getNextValue($mysoc,$contract); + $nextval=$module->getNextValue($mysoc,$holiday); if ("$nextval" != $langs->trans("NotAvailable")) { // Keep " on nextval $htmltooltip.=''.$langs->trans("NextValue").': '; if ($nextval) { diff --git a/htdocs/holiday/class/holiday.class.php b/htdocs/holiday/class/holiday.class.php index 6dd49b52a93..9c87f7d32fd 100644 --- a/htdocs/holiday/class/holiday.class.php +++ b/htdocs/holiday/class/holiday.class.php @@ -2171,8 +2171,10 @@ class Holiday extends CommonObject $this->description='SPECIMEN description'; $this->date_debut=dol_now(); $this->date_fin=dol_now()+(24*3600); + $this->date_valid=dol_now(); $this->fk_validator=1; $this->halfday=0; $this->fk_type=1; + $this->statut=Holiday::STATUS_VALIDATED; } } From 1fd398234fc0e7d08e0bed0068c9b9adde8adf05 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Fri, 9 Nov 2018 15:29:49 +0100 Subject: [PATCH 122/132] remove warning --- htdocs/modulebuilder/template/core/boxes/mymodulewidget1.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/htdocs/modulebuilder/template/core/boxes/mymodulewidget1.php b/htdocs/modulebuilder/template/core/boxes/mymodulewidget1.php index 85592006a14..0f0e3c91a11 100644 --- a/htdocs/modulebuilder/template/core/boxes/mymodulewidget1.php +++ b/htdocs/modulebuilder/template/core/boxes/mymodulewidget1.php @@ -1,5 +1,6 @@ +/* Copyright (C) 2004-2017 Laurent Destailleur + * Copyright (C) 2018 Frédéric France * Copyright (C) ---Put here your own copyright and developer email--- * * This program is free software: you can redistribute it and/or modify @@ -200,7 +201,7 @@ class mymodulewidget1 extends ModeleBoxes * @param array $contents Array with properties of box lines * @return void */ - public function showBox($head = null, $contents = null) + public function showBox($head = null, $contents = null, $nooutput = 0) { // You may make your own code here… // … or use the parent's class function using the provided head and contents templates From 6cd27d8c8076610a2db4593cce775a0169e0b256 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Fri, 9 Nov 2018 18:08:06 +0100 Subject: [PATCH 123/132] add admin dkim translation --- htdocs/langs/en_US/admin.lang | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index d9be14b3cb7..4ccfb04983f 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -277,8 +277,12 @@ MAIN_MAIL_ENABLED_USER_DEST_SELECT=Add employee users with email into allowed re MAIN_MAIL_SENDMODE=Email sending method MAIN_MAIL_SMTPS_ID=SMTP ID (if sending server requires authentication) MAIN_MAIL_SMTPS_PW=SMTP Password (if sending server requires authentication) -MAIN_MAIL_EMAIL_TLS= Use TLS (SSL) encryption -MAIN_MAIL_EMAIL_STARTTLS= Use TLS (STARTTLS) encryption +MAIN_MAIL_EMAIL_TLS=Use TLS (SSL) encryption +MAIN_MAIL_EMAIL_STARTTLS=Use TLS (STARTTLS) encryption +MAIN_MAIL_EMAIL_DKIM_ENABLED=Use DKIM to generate email signature +MAIN_MAIL_EMAIL_DKIM_DOMAIN=Email Domain for use with dkim +MAIN_MAIL_EMAIL_DKIM_SELECTOR=Name of dkim selector +MAIN_MAIL_EMAIL_DKIM_PRIVATE_KEY=Private key for dkim signing MAIN_DISABLE_ALL_SMS=Disable all SMS sending (for test purposes or demos) MAIN_SMS_SENDMODE=Method to use to send SMS MAIN_MAIL_SMS_FROM=Default sender phone number for SMS sending @@ -1816,7 +1820,7 @@ VATIsUsedIsOff=Note: The option to use sales Tax or VAT has been set to SwapSenderAndRecipientOnPDF=Swap sender and recipient address on PDF FeatureSupportedOnTextFieldsOnly=Warning, feature supported on text fields only EmailCollector=Email collector -EmailCollectorDescription=Add a scheduled job and a setup page to scan regularly email boxes (using IMAP protocol) and record emails received into your application, at the right place and/or create some record automatically (like leads). +EmailCollectorDescription=Add a scheduled job and a setup page to scan regularly email boxes (using IMAP protocol) and record emails received into your application, at the right place and/or create some record automatically (like leads). NewEmailCollector=New Email Collector EMailHost=Host of email IMAP server MailboxSourceDirectory=Mailbox source directory From 172468587d386f76d46c2194ee33df231d8fc26a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Fri, 9 Nov 2018 18:13:13 +0100 Subject: [PATCH 124/132] Update mymodulewidget1.php --- htdocs/modulebuilder/template/core/boxes/mymodulewidget1.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/htdocs/modulebuilder/template/core/boxes/mymodulewidget1.php b/htdocs/modulebuilder/template/core/boxes/mymodulewidget1.php index 0f0e3c91a11..edd2f627bb5 100644 --- a/htdocs/modulebuilder/template/core/boxes/mymodulewidget1.php +++ b/htdocs/modulebuilder/template/core/boxes/mymodulewidget1.php @@ -197,8 +197,9 @@ class mymodulewidget1 extends ModeleBoxes /** * Method to show box. Called by Dolibarr eatch time it wants to display the box. * - * @param array $head Array with properties of box title - * @param array $contents Array with properties of box lines + * @param array $head Array with properties of box title + * @param array $contents Array with properties of box lines + * @param int $nooutput No print, only return string * @return void */ public function showBox($head = null, $contents = null, $nooutput = 0) From f1287578f3eb79c46c2aef8b55cc2b85c7115d72 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 9 Nov 2018 18:18:17 +0100 Subject: [PATCH 125/132] Work on emailcollector --- htdocs/admin/emailcollector_card.php | 64 +++++++++++++------ .../class/emailcollector.class.php | 58 ++++++++++------- .../install/mysql/migration/8.0.0-9.0.0.sql | 1 + .../llx_emailcollector_emailcollector.sql | 1 + htdocs/langs/en_US/admin.lang | 4 +- 5 files changed, 84 insertions(+), 44 deletions(-) diff --git a/htdocs/admin/emailcollector_card.php b/htdocs/admin/emailcollector_card.php index 3280492701e..f9ba71cc858 100644 --- a/htdocs/admin/emailcollector_card.php +++ b/htdocs/admin/emailcollector_card.php @@ -103,25 +103,6 @@ if (empty($reshook)) include DOL_DOCUMENT_ROOT.'/core/actions_printing.inc.php'; } - -if ($action == 'confirm_collect') -{ - dol_include_once('/emailcollector/class/emailcollector.class.php'); - - $res = $object->doCollect(); - - if ($res == 0) - { - setEventMessages($object->output, null, 'mesgs'); - } - else - { - setEventMessages($object->error, null, 'errors'); - } - - $action = ''; -} - if (GETPOST('addfilter','alpha')) { $emailcollectorfilter = new EmailCollectorFilter($db); @@ -190,6 +171,25 @@ if ($action == 'deleteoperation') } } +if ($action == 'confirm_collect') +{ + dol_include_once('/emailcollector/class/emailcollector.class.php'); + + $res = $object->doCollect(); + + if ($res == 0) + { + setEventMessages($object->output, null, 'mesgs'); + } + else + { + setEventMessages($object->error, null, 'errors'); + } + + $action = ''; +} + + /* @@ -373,7 +373,29 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea */ $morehtmlref .= ''; - dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref); + $morehtml = $langs->trans("NbOfEmailsInInbox").' : '; + + $sourcedir = $object->source_directory; + $targetdir = ($object->target_directory ? $object->target_directory : ''); // Can be '[Gmail]/Trash' or 'mytag' + + $connectstringserver = $object->getConnectStringIMAP(); + $connectstringsource = $connectstringserver.imap_utf7_encode($sourcedir); + $connectstringtarget = $connectstringserver.imap_utf7_encode($targetdir); + + $connection = imap_open($connectstringsource, $object->user, $object->password); + if (! $connection) + { + $morehtml .= 'Failed to open IMAP connection '.$connectstringsource; + } + else + { + //$morehtmlstatus .= imap_num_msg($connection).'
'; + $morehtml .= imap_num_msg($connection); + } + + imap_close($connection); + + dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref.'
'.$morehtml.'
', '', 0, '', '', 0, ''); print '
'; print '
'; @@ -474,7 +496,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea print ''; print '
'; - print '
'; + print '
'; // End
print '

'; diff --git a/htdocs/emailcollector/class/emailcollector.class.php b/htdocs/emailcollector/class/emailcollector.class.php index e4c0d4f588f..b68639ebf5e 100644 --- a/htdocs/emailcollector/class/emailcollector.class.php +++ b/htdocs/emailcollector/class/emailcollector.class.php @@ -90,7 +90,8 @@ class EmailCollector extends CommonObject //'actiontodo' => array('type'=>'varchar(255)', 'label'=>'ActionToDo', 'visible'=>1, 'enabled'=>1, 'position'=>106), 'target_directory' => array('type'=>'varchar(255)', 'label'=>'MailboxTargetDirectory', 'visible'=>1, 'enabled'=>1, 'position'=>110, 'notnull'=>0, 'comment'=>"Where to store messages once processed"), 'datelastresult' => array('type'=>'datetime', 'label'=>'DateLastResult', 'visible'=>1, 'enabled'=>'$action != "create" && $action != "edit"', 'position'=>121, 'notnull'=>-1,), - 'lastresult' => array('type'=>'varchar(255)', 'label'=>'LastResult', 'visible'=>1, 'enabled'=>'$action != "create" && $action != "edit"', 'position'=>122, 'notnull'=>-1,), + 'codelastresult' => array('type'=>'varchar(16)', 'label'=>'CodeLastResult', 'visible'=>1, 'enabled'=>'$action != "create" && $action != "edit"', 'position'=>122, 'notnull'=>-1,), + 'lastresult' => array('type'=>'varchar(255)', 'label'=>'LastResult', 'visible'=>1, 'enabled'=>'$action != "create" && $action != "edit"', 'position'=>123, 'notnull'=>-1,), 'note_public' => array('type'=>'html', 'label'=>'NotePublic', 'visible'=>0, 'enabled'=>1, 'position'=>61, 'notnull'=>-1,), 'note_private' => array('type'=>'html', 'label'=>'NotePrivate', 'visible'=>0, 'enabled'=>1, 'position'=>62, 'notnull'=>-1,), 'date_creation' => array('type'=>'datetime', 'label'=>'DateCreation', 'visible'=>-2, 'enabled'=>1, 'position'=>500, 'notnull'=>1,), @@ -717,23 +718,16 @@ class EmailCollector extends CommonObject $this->fetchActions(); $sourcedir = $this->source_directory; - $targetdir = ($this->target_directory ? $server.$this->target_directory : ''); // Can be '[Gmail]/Trash' or 'mytag' + $targetdir = ($this->target_directory ? $this->target_directory : ''); // Can be '[Gmail]/Trash' or 'mytag' - // Connect to IMAP - $flags ='/service=imap'; // IMAP - $flags.='/ssl'; // '/tls' - $flags.='/novalidate-cert'; - //$flags.='/readonly'; - //$flags.='/debug'; - - $connectstringserver = '{'.$this->host.':993'.$flags.'}'; - $connectstring = $connectstringserver.imap_utf7_encode($sourcedir); + $connectstringserver = $this->getConnectStringIMAP(); + $connectstringsource = $connectstringserver.imap_utf7_encode($sourcedir); $connectstringtarget = $connectstringserver.imap_utf7_encode($targetdir); - $connection = imap_open($connectstring, $this->user, $this->password); + $connection = imap_open($connectstringsource, $this->user, $this->password); if (! $connection) { - $this->error = 'Failed to open IMAP connection '.$connectstring; + $this->error = 'Failed to open IMAP connection '.$connectstringsource; return -3; } @@ -743,23 +737,24 @@ class EmailCollector extends CommonObject { if (empty($rule['status'])) continue; - if ($rule['key'] == 'to') $search=($search?' ':'').'TO "'.str_replace('"', '', $rule['rulevalue']).'"'; - if ($rule['key'] == 'bcc') $search=($search?' ':'').'BCC'; - if ($rule['key'] == 'cc') $search=($search?' ':'').'CC'; - if ($rule['key'] == 'from') $search=($search?' ':'').'FROM "'.str_replace('"', '', $rule['rulevalue']).'"'; - if ($rule['key'] == 'subject') $search=($search?' ':'').'SUBJECT "'.str_replace('"', '', $rule['rulevalue']).'"'; - if ($rule['key'] == 'body') $search=($search?' ':'').'BODY "'.str_replace('"', '', $rule['rulevalue']).'"'; - if ($rule['key'] == 'seen') $search=($search?' ':'').'SEEN'; - if ($rule['key'] == 'unseen') $search=($search?' ':'').'UNSEEN'; + if ($rule['type'] == 'to') $search.=($search?' ':'').'TO "'.str_replace('"', '', $rule['rulevalue']).'"'; + if ($rule['type'] == 'bcc') $search.=($search?' ':'').'BCC'; + if ($rule['type'] == 'cc') $search.=($search?' ':'').'CC'; + if ($rule['type'] == 'from') $search.=($search?' ':'').'FROM "'.str_replace('"', '', $rule['rulevalue']).'"'; + if ($rule['type'] == 'subject') $search.=($search?' ':'').'SUBJECT "'.str_replace('"', '', $rule['rulevalue']).'"'; + if ($rule['type'] == 'body') $search.=($search?' ':'').'BODY "'.str_replace('"', '', $rule['rulevalue']).'"'; + if ($rule['type'] == 'seen') $search.=($search?' ':'').'SEEN'; + if ($rule['type'] == 'unseen') $search.=($search?' ':'').'UNSEEN'; } if (empty($targetdir)) // Use last date as filter if there is no targetdir defined. { $fromdate=0; - if ($this->datelastresult) $fromdate = $this->datelastresult; + if ($this->datelastresult && $this->codelastresult == 'OK') $fromdate = $this->datelastresult; if ($fromdate > 0) $search.=($search?' ':'').'SINCE '.dol_print_date($fromdate - 1,'dayhourrfc'); } dol_syslog("search string = ".$search); + //var_dump($search);exit; $nbemailprocessed=0; $nbactiondone=0; @@ -841,4 +836,23 @@ class EmailCollector extends CommonObject return $error; } + + /** + * Return the connectstring to use with IMAP connection function + * + * @return string + */ + function getConnectStringIMAP() + { + // Connect to IMAP + $flags ='/service=imap'; // IMAP + $flags.='/ssl'; // '/tls' + $flags.='/novalidate-cert'; + //$flags.='/readonly'; + //$flags.='/debug'; + + $connectstringserver = '{'.$this->host.':993'.$flags.'}'; + + return $connectstringserver; + } } diff --git a/htdocs/install/mysql/migration/8.0.0-9.0.0.sql b/htdocs/install/mysql/migration/8.0.0-9.0.0.sql index 05106e475cd..8f51d9f00c4 100644 --- a/htdocs/install/mysql/migration/8.0.0-9.0.0.sql +++ b/htdocs/install/mysql/migration/8.0.0-9.0.0.sql @@ -153,6 +153,7 @@ CREATE TABLE llx_emailcollector_emailcollector( source_directory varchar(255) NOT NULL, target_directory varchar(255), datelastresult datetime, + codelastresult varchar(16), lastresult varchar(255), note_public text, note_private text, diff --git a/htdocs/install/mysql/tables/llx_emailcollector_emailcollector.sql b/htdocs/install/mysql/tables/llx_emailcollector_emailcollector.sql index 2db5e693427..750c2b24e84 100644 --- a/htdocs/install/mysql/tables/llx_emailcollector_emailcollector.sql +++ b/htdocs/install/mysql/tables/llx_emailcollector_emailcollector.sql @@ -27,6 +27,7 @@ CREATE TABLE llx_emailcollector_emailcollector( source_directory varchar(255) NOT NULL, target_directory varchar(255), datelastresult datetime, + codelastresult varchar(16), lastresult varchar(255), note_public text, note_private text, diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index d9be14b3cb7..259d8920744 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -1827,11 +1827,13 @@ DateLastResult=Date last collect LastResult=Last result EmailCollectorConfirmCollectTitle=Email collect confirmation EmailCollectorConfirmCollect=Do you want to run the collect for this collector now ? -NoNewEmailToProcess=No new email to process +NoNewEmailToProcess=No new email (matching filters) to process NothingProcessed=Nothing done XEmailsDoneYActionsDone=%s emails analyzed, %s record/actions done by collector RecordEvent=Record event CreateLeadAndThirdParty=Create lead (and thirdparty if necessary) +CodeLastResult=Result code of last collect +NbOfEmailsInInbox=Number of email in source directory ##### Resource #### ResourceSetup=Configuration du module Resource UseSearchToSelectResource=Use a search form to choose a resource (rather than a drop-down list). From e86e3ec7ace65c9b10b81b67854987ede7d590aa Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 9 Nov 2018 19:30:44 +0100 Subject: [PATCH 126/132] Work on email collector --- htdocs/admin/emailcollector_card.php | 4 +- .../core/modules/modEmailCollector.class.php | 5 +- htdocs/cron/list.php | 2 +- .../class/emailcollector.class.php | 76 ++++++++++--------- .../class/emailcollectorfilter.class.php | 4 +- htdocs/langs/en_US/admin.lang | 2 +- .../core/modules/modMyModule.class.php | 6 +- 7 files changed, 50 insertions(+), 49 deletions(-) diff --git a/htdocs/admin/emailcollector_card.php b/htdocs/admin/emailcollector_card.php index f9ba71cc858..08656a9ee27 100644 --- a/htdocs/admin/emailcollector_card.php +++ b/htdocs/admin/emailcollector_card.php @@ -175,9 +175,9 @@ if ($action == 'confirm_collect') { dol_include_once('/emailcollector/class/emailcollector.class.php'); - $res = $object->doCollect(); + $res = $object->doCollectOneCollector(); - if ($res == 0) + if ($res > 0) { setEventMessages($object->output, null, 'mesgs'); } diff --git a/htdocs/core/modules/modEmailCollector.class.php b/htdocs/core/modules/modEmailCollector.class.php index ef19ff49bf9..042dc0c82f2 100644 --- a/htdocs/core/modules/modEmailCollector.class.php +++ b/htdocs/core/modules/modEmailCollector.class.php @@ -174,11 +174,8 @@ class modEmailCollector extends DolibarrModules // Cronjobs (List of cron jobs entries to add when module is enabled) // unit_frequency must be 60 for minute, 3600 for hour, 86400 for day, 604800 for week $this->cronjobs = array( - 0=>array('label'=>'Email collector', 'jobtype'=>'method', 'class'=>'/emailcollector/class/emailcollector.class.php', 'objectname'=>'EmailCollector', 'method'=>'doCollect', 'parameters'=>'', 'comment'=>'Comment', 'frequency'=>5, 'unitfrequency'=>60, 'status'=>1, 'test'=>'$conf->emailcollector->enabled') + 0=>array('label'=>'Email collector', 'priority'=>50, 'jobtype'=>'method', 'class'=>'/emailcollector/class/emailcollector.class.php', 'objectname'=>'EmailCollector', 'method'=>'doCollect', 'parameters'=>'', 'comment'=>'Comment', 'frequency'=>5, 'unitfrequency'=>60, 'status'=>1, 'test'=>'$conf->emailcollector->enabled') ); - // Example: $this->cronjobs=array(0=>array('label'=>'My label', 'jobtype'=>'method', 'class'=>'/dir/class/file.class.php', 'objectname'=>'MyClass', 'method'=>'myMethod', 'parameters'=>'param1, param2', 'comment'=>'Comment', 'frequency'=>2, 'unitfrequency'=>3600, 'status'=>0, 'test'=>true), - // 1=>array('label'=>'My label', 'jobtype'=>'command', 'command'=>'', 'parameters'=>'param1, param2', 'comment'=>'Comment', 'frequency'=>1, 'unitfrequency'=>3600*24, 'status'=>0, 'test'=>true) - // ); // Permissions diff --git a/htdocs/cron/list.php b/htdocs/cron/list.php index f594eb2b383..2ddfbee5e8c 100644 --- a/htdocs/cron/list.php +++ b/htdocs/cron/list.php @@ -192,7 +192,7 @@ if (empty($reshook)) $result = 0; if ($massaction == 'disable') $result = $tmpcron->setStatut(Cronjob::STATUS_DISABLED); elseif ($massaction == 'enable') $result = $tmpcron->setStatut(Cronjob::STATUS_ENABLED); - else dol_print_error($db, 'Bad value for massaction'); + //else dol_print_error($db, 'Bad value for massaction'); if ($result < 0) setEventMessages($tmpcron->error, $tmpcron->errors, 'errors'); } else diff --git a/htdocs/emailcollector/class/emailcollector.class.php b/htdocs/emailcollector/class/emailcollector.class.php index b68639ebf5e..8769e0a70c9 100644 --- a/htdocs/emailcollector/class/emailcollector.class.php +++ b/htdocs/emailcollector/class/emailcollector.class.php @@ -85,7 +85,7 @@ class EmailCollector extends CommonObject 'host' => array('type'=>'varchar(255)', 'label'=>'EMailHost', 'visible'=>1, 'enabled'=>1, 'position'=>100, 'notnull'=>1, 'searchall'=>1, 'comment'=>"IMAP server", 'help'=>'Example: imap.gmail.com'), 'user' => array('type'=>'varchar(128)', 'label'=>'Login', 'visible'=>1, 'enabled'=>1, 'position'=>101, 'notnull'=>1, 'index'=>1, 'comment'=>"IMAP login", 'help'=>'Example: myacount@gmail.com'), 'password' => array('type'=>'password', 'label'=>'Password', 'visible'=>-1, 'enabled'=>1, 'position'=>102, 'notnull'=>1, 'comment'=>"IMAP password"), - 'source_directory' => array('type'=>'varchar(255)', 'label'=>'MailboxSourceDirectory', 'visible'=>-1, 'enabled'=>1, 'position'=>103, 'notnull'=>1, 'default' => 'Inbox'), + 'source_directory' => array('type'=>'varchar(255)', 'label'=>'MailboxSourceDirectory', 'visible'=>-1, 'enabled'=>1, 'position'=>103, 'notnull'=>1, 'default' => 'Inbox', 'help'=>'Example: INBOX'), //'filter' => array('type'=>'text', 'label'=>'Filter', 'visible'=>1, 'enabled'=>1, 'position'=>105), //'actiontodo' => array('type'=>'varchar(255)', 'label'=>'ActionToDo', 'visible'=>1, 'enabled'=>1, 'position'=>106), 'target_directory' => array('type'=>'varchar(255)', 'label'=>'MailboxTargetDirectory', 'visible'=>1, 'enabled'=>1, 'position'=>110, 'notnull'=>0, 'comment'=>"Where to store messages once processed"), @@ -318,33 +318,9 @@ class EmailCollector extends CommonObject $socid = $user->societe_id ? $user->societe_id : ''; - // If the internal user must only see his customers, force searching by him - if (! $user->rights->societe->client->voir && !$socid) { - $search_sale = $user->id; - } $sql = "SELECT s.rowid"; - //if ((!$user->rights->societe->client->voir && !$socid) || $search_sale > 0) { - // $sql .= ", sc.fk_soc, sc.fk_user"; // We need these fields in order to filter by sale (including the case where the user can only see his prospects) - //} - $sql.= " FROM ".MAIN_DB_PREFIX."emailcollector as s"; - - //if ((!$user->rights->societe->client->voir && !$socid) || $search_sale > 0) { - // $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; // We need this table joined to the select in order to filter by sale - //} - //$sql.= ", ".MAIN_DB_PREFIX."c_stcomm as st"; - //$sql.= " WHERE s.fk_stcomm = st.id"; - - // Example of use $mode - //if ($mode == 1) $sql.= " AND s.client IN (1, 3)"; - //if ($mode == 2) $sql.= " AND s.client IN (2, 3)"; - + $sql.= " FROM ".MAIN_DB_PREFIX."emailcollector_emailcollector as s"; $sql.= ' WHERE s.entity IN ('.getEntity('emailcollector').')'; - //if ((!$user->rights->societe->client->voir && !$socid) || $search_sale > 0) { - // $sql.= " AND s.fk_soc = sc.fk_soc"; - //} - //if ($socid) { - // $sql.= " AND s.fk_soc = ".$socid; - //} if ($activeOnly) { $sql.= " AND s.status = 1"; } @@ -359,10 +335,10 @@ class EmailCollector extends CommonObject } $result = $this->db->query($sql); - if ($result) { $num = $this->db->num_rows($result); - while ($i < $num) { + while ($i < $num) + { $obj = $this->db->fetch_object($result); $emailcollector_static = new EmailCollector($this->db); if ($emailcollector_static->fetch($obj->rowid)) { @@ -371,11 +347,12 @@ class EmailCollector extends CommonObject $i++; } } else { - dol_syslog(__METHOD__.':: Error when retrieve emailcollector list', LOG_ERR); + $this->errors[] = 'EmailCollector::fetchAll Error when retrieve emailcollector list'; + dol_syslog('EmailCollector::fetchAll Error when retrieve emailcollector list', LOG_ERR); $ret = -1; } if (! count($obj_ret)) { - dol_syslog(__METHOD__.':: No emailcollector found', LOG_DEBUG); + dol_syslog('EmailCollector::fetchAll No emailcollector found', LOG_DEBUG); } return $obj_ret; @@ -676,14 +653,40 @@ class EmailCollector extends CommonObject * * @return int 0 if OK, <>0 if KO (this function is used also by cron so only 0 is OK) */ - //public function doScheduledJob($param1, $param2, ...) public function doCollect() + { + global $user; + + $nberror = 0; + + $arrayofcollectors = $this->fetchAll($user, 1); + + // Loop on each collector + foreach($arrayofcollectors as $emailcollector) + { + $result = $emailcollector->doCollectOneCollector(); + dol_syslog("doCollect result = ".$result." for emailcollector->id = ".$emailcollector->id); + + $this->error.='EmailCollector ID '.$emailcollector->id.':'.$emailcollector->error.'
'; + if (! empty($emailcollector->errors)) $this->error.=join('
', $emailcollector->errors); + $this->output.='EmailCollector ID '.$emailcollector->id.': '.$emailcollector->output.'
'; + } + + return $nberror; + } + + /** + * Execute collect for current collector loaded previously with fetch. + * + * @return int <0 if KO, >0 if OK + */ + public function doCollectOneCollector() { global $conf, $langs, $user; //$conf->global->SYSLOG_FILE = 'DOL_DATA_ROOT/dolibarr_mydedicatedlofile.log'; - dol_syslog("EmailCollector::doCollect start", LOG_DEBUG); + dol_syslog("EmailCollector::doCollectOneCollector start", LOG_DEBUG); $error = 0; $this->output = ''; @@ -803,11 +806,11 @@ class EmailCollector extends CommonObject // Move email if (! $errorforactions && $targetdir) { - dol_syslog("EmailCollector::doCollect move message ".$imapemail." to ".$connectstringtarget, LOG_DEBUG); + dol_syslog("EmailCollector::doCollectOneCollector move message ".$imapemail." to ".$connectstringtarget, LOG_DEBUG); $res = imap_mail_move($connection, $imapemail, $targetdir, 0); if ($res == false) { $error++; - $this->errors = imap_last_error(); + $this->error = imap_last_error(); dol_syslog(imap_last_error()); } } @@ -830,11 +833,12 @@ class EmailCollector extends CommonObject $this->datelastresult = $now; $this->lastresult = $this->output; + $this->codelastresult = ($error ? 'KO' : 'OK'); $this->update($user); - dol_syslog("EmailCollector::doCollect end", LOG_DEBUG); + dol_syslog("EmailCollector::doCollectOneCollector end", LOG_DEBUG); - return $error; + return $error?-1:1; } /** diff --git a/htdocs/emailcollector/class/emailcollectorfilter.class.php b/htdocs/emailcollector/class/emailcollectorfilter.class.php index 23c8f7a02b2..c4e94b5e4bb 100644 --- a/htdocs/emailcollector/class/emailcollectorfilter.class.php +++ b/htdocs/emailcollector/class/emailcollectorfilter.class.php @@ -159,10 +159,10 @@ class EmailCollectorFilter extends CommonObject $this->errors[]=$langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Type")); return -1; } - if (empty($this->rulevalue)) + if (! in_array($this->type, array('seen','unseen')) && empty($this->rulevalue)) { $langs->load("errors"); - $this->errors[]=$langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("RuleValue")); + $this->errors[]=$langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("StringToFilter")); return -1; } diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index 259d8920744..86815ca70c2 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -1821,7 +1821,7 @@ NewEmailCollector=New Email Collector EMailHost=Host of email IMAP server MailboxSourceDirectory=Mailbox source directory MailboxTargetDirectory=Mailbox target directory -EmailcollectorOperations=Operations done by collector +EmailcollectorOperations=Operations to do by collector CollectNow=Collect now DateLastResult=Date last collect LastResult=Last result diff --git a/htdocs/modulebuilder/template/core/modules/modMyModule.class.php b/htdocs/modulebuilder/template/core/modules/modMyModule.class.php index 8d34b0e63a3..8c4f933b31f 100644 --- a/htdocs/modulebuilder/template/core/modules/modMyModule.class.php +++ b/htdocs/modulebuilder/template/core/modules/modMyModule.class.php @@ -197,10 +197,10 @@ class modMyModule extends DolibarrModules // Cronjobs (List of cron jobs entries to add when module is enabled) // unit_frequency must be 60 for minute, 3600 for hour, 86400 for day, 604800 for week $this->cronjobs = array( - 0=>array('label'=>'MyJob label', 'jobtype'=>'method', 'class'=>'/mymodule/class/myobject.class.php', 'objectname'=>'MyObject', 'method'=>'doScheduledJob', 'parameters'=>'', 'comment'=>'Comment', 'frequency'=>2, 'unitfrequency'=>3600, 'status'=>0, 'test'=>'$conf->mymodule->enabled') + 0=>array('label'=>'MyJob label', 'jobtype'=>'method', 'class'=>'/mymodule/class/myobject.class.php', 'objectname'=>'MyObject', 'method'=>'doScheduledJob', 'parameters'=>'', 'comment'=>'Comment', 'frequency'=>2, 'unitfrequency'=>3600, 'status'=>0, 'test'=>'$conf->mymodule->enabled', 'priority'=>50) ); - // Example: $this->cronjobs=array(0=>array('label'=>'My label', 'jobtype'=>'method', 'class'=>'/dir/class/file.class.php', 'objectname'=>'MyClass', 'method'=>'myMethod', 'parameters'=>'param1, param2', 'comment'=>'Comment', 'frequency'=>2, 'unitfrequency'=>3600, 'status'=>0, 'test'=>'$conf->mymodule->enabled'), - // 1=>array('label'=>'My label', 'jobtype'=>'command', 'command'=>'', 'parameters'=>'param1, param2', 'comment'=>'Comment', 'frequency'=>1, 'unitfrequency'=>3600*24, 'status'=>0, 'test'=>'$conf->mymodule->enabled') + // Example: $this->cronjobs=array(0=>array('label'=>'My label', 'jobtype'=>'method', 'class'=>'/dir/class/file.class.php', 'objectname'=>'MyClass', 'method'=>'myMethod', 'parameters'=>'param1, param2', 'comment'=>'Comment', 'frequency'=>2, 'unitfrequency'=>3600, 'status'=>0, 'test'=>'$conf->mymodule->enabled', 'priority'=>50), + // 1=>array('label'=>'My label', 'jobtype'=>'command', 'command'=>'', 'parameters'=>'param1, param2', 'comment'=>'Comment', 'frequency'=>1, 'unitfrequency'=>3600*24, 'status'=>0, 'test'=>'$conf->mymodule->enabled', 'priority'=>50) // ); From b271e1a3b0517a2441f8371524c64f744f3b72bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sat, 10 Nov 2018 07:27:20 +0100 Subject: [PATCH 127/132] The variable $i seems to be never defined. --- htdocs/product/class/api_products.class.php | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/htdocs/product/class/api_products.class.php b/htdocs/product/class/api_products.class.php index 30940c95509..6d84a6d1352 100644 --- a/htdocs/product/class/api_products.class.php +++ b/htdocs/product/class/api_products.class.php @@ -110,7 +110,7 @@ class Products extends DolibarrApi * @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.tobuy:=:0) and (t.tosell:=:1)" * @return array Array of product objects */ - function index($sortfield = "t.ref", $sortorder = 'ASC', $limit = 100, $page = 0, $mode=0, $category=0, $sqlfilters = '') + function index($sortfield = "t.ref", $sortorder = 'ASC', $limit = 100, $page = 0, $mode = 0, $category = 0, $sqlfilters = '') { global $db, $conf; @@ -129,11 +129,12 @@ class Products extends DolibarrApi $sql.= " AND c.fk_categorie = ".$db->escape($category); $sql.= " AND c.fk_product = t.rowid "; } - // Show products - if ($mode == 1) { $sql.= " AND t.fk_product_type = 0"; - } - // Show services - if ($mode == 2) { $sql.= " AND t.fk_product_type = 1"; + if ($mode == 1) { + // Show only products + $sql.= " AND t.fk_product_type = 0"; + } elseif ($mode == 2) { + // Show only services + $sql.= " AND t.fk_product_type = 1"; } // Add sql filters if ($sqlfilters) { @@ -158,6 +159,7 @@ class Products extends DolibarrApi if ($result) { $num = $db->num_rows($result); $min = min($num, ($limit <= 0 ? $num : $limit)); + $i = 0; while ($i < $min) { $obj = $db->fetch_object($result); From 2514cf4a9629b7203ec33393e34cceb6aab10e64 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sat, 10 Nov 2018 07:32:22 +0100 Subject: [PATCH 128/132] Update actions_ticket.class.php --- htdocs/ticket/class/actions_ticket.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/ticket/class/actions_ticket.class.php b/htdocs/ticket/class/actions_ticket.class.php index bf1e73404f1..c53496b674c 100644 --- a/htdocs/ticket/class/actions_ticket.class.php +++ b/htdocs/ticket/class/actions_ticket.class.php @@ -849,7 +849,7 @@ class ActionsTicket $id = $object->createTicketMessage($user); if ($id <= 0) { $error++; - $this->errors = $object->error; + $this->error = $object->error; $this->errors = $object->errors; $action = 'add_message'; } From c2ee9ba9dba0974f9e276b659b1a9bed98b83e88 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sat, 10 Nov 2018 07:38:55 +0100 Subject: [PATCH 129/132] Update actions_ticket.class.php --- htdocs/ticket/class/actions_ticket.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/ticket/class/actions_ticket.class.php b/htdocs/ticket/class/actions_ticket.class.php index c53496b674c..8f3c6985ac3 100644 --- a/htdocs/ticket/class/actions_ticket.class.php +++ b/htdocs/ticket/class/actions_ticket.class.php @@ -845,7 +845,7 @@ class ActionsTicket } if (!$error) { - $object->message = GETPOST("message"); + $object->message = (string) GETPOST("message"); $id = $object->createTicketMessage($user); if ($id <= 0) { $error++; From 20acf440a3cfcb84c72412359547f3054fbd02e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sat, 10 Nov 2018 07:55:01 +0100 Subject: [PATCH 130/132] Update api_products.class.php --- htdocs/product/class/api_products.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/product/class/api_products.class.php b/htdocs/product/class/api_products.class.php index 6d84a6d1352..afacbb158b5 100644 --- a/htdocs/product/class/api_products.class.php +++ b/htdocs/product/class/api_products.class.php @@ -132,7 +132,7 @@ class Products extends DolibarrApi if ($mode == 1) { // Show only products $sql.= " AND t.fk_product_type = 0"; - } elseif ($mode == 2) { + } elseif ($mode == 2) { // Show only services $sql.= " AND t.fk_product_type = 1"; } From 8893d8d59fcf08637e9465d5f3b0a4c3a0c6590d Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 10 Nov 2018 11:56:23 +0100 Subject: [PATCH 131/132] Fix compatiblity with new version of PHP --- htdocs/exports/class/export.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/exports/class/export.class.php b/htdocs/exports/class/export.class.php index 7ab55fd4e53..8e3e3b04767 100644 --- a/htdocs/exports/class/export.class.php +++ b/htdocs/exports/class/export.class.php @@ -131,11 +131,11 @@ class Export //print_r("$perm[0]-$perm[1]-$perm[2]
"); if (! empty($perm[2])) { - $bool=$user->rights->$perm[0]->$perm[1]->$perm[2]; + $bool=$user->rights->{$perm[0]}->{$perm[1]}->{$perm[2]}; } else { - $bool=$user->rights->$perm[0]->$perm[1]; + $bool=$user->rights->{$perm[0]}->{$perm[1]}; } if ($perm[0]=='user' && $user->admin) $bool=true; if (! $bool) break; From ed3a333436f6293c0298c540bee1df727c63d74c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 10 Nov 2018 13:11:18 +0100 Subject: [PATCH 132/132] Fix phpcs --- htdocs/accountancy/admin/export.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/accountancy/admin/export.php b/htdocs/accountancy/admin/export.php index 03538b759e7..6ef4bdda90b 100644 --- a/htdocs/accountancy/admin/export.php +++ b/htdocs/accountancy/admin/export.php @@ -44,7 +44,7 @@ if (empty($user->rights->accounting->chartofaccount)) $action = GETPOST('action', 'aZ09'); // Parameters ACCOUNTING_EXPORT_* -$main_option = array ( +$main_option = array( 'ACCOUNTING_EXPORT_PREFIX_SPEC', );
'.dol_print_date($productfourn->date_creation, 'dayhour').''.$productfourn->getSocNomUrl(1,'supplier').''.$productfourn->fourn_ref.'