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 01/11] 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 02/11] 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 03/11] 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 8d8023b405517f01c9dac02c3b3ee304717a7a3c Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Thu, 1 Nov 2018 22:32:33 +0100 Subject: [PATCH 04/11] 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 05/11] 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 06/11] 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 07/11] 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 08/11] 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 5f4d644cab8ce0336cf08ed516f275576c0a0659 Mon Sep 17 00:00:00 2001 From: Abbes Bahfir Date: Sat, 3 Nov 2018 11:05:12 +0100 Subject: [PATCH 09/11] 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 86b98db2a245d569a4e766fc6a313dd7ae08aea0 Mon Sep 17 00:00:00 2001 From: andreubisquerra Date: Sun, 4 Nov 2018 20:36:23 +0100 Subject: [PATCH 10/11] No posibility to validate if invoice not exist --- htdocs/takepos/pay.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/takepos/pay.php b/htdocs/takepos/pay.php index c0bfc35294a..898b9069ba0 100644 --- a/htdocs/takepos/pay.php +++ b/htdocs/takepos/pay.php @@ -41,7 +41,7 @@ $sql="SELECT rowid FROM ".MAIN_DB_PREFIX."facture where facnumber='(PROV-POS-".$ $resql = $db->query($sql); $row = $db->fetch_array ($resql); $placeid=$row[0]; -if (! $placeid) $placeid=0; // Developing error message with no lines +if (! $placeid) $placeid=0; // Invoice not exist else{ $invoice = new Facture($db); $invoice->fetch($placeid); @@ -101,15 +101,15 @@ $langs->loadLangs(array("main", "bills", "cashdesk")); - + - + - + From 7c3cb7d73c6847c4deb6ec57d69f55985147d273 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 5 Nov 2018 09:54:11 +0100 Subject: [PATCH 11/11] Update commonfields_add.tpl.php --- htdocs/core/tpl/commonfields_add.tpl.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/core/tpl/commonfields_add.tpl.php b/htdocs/core/tpl/commonfields_add.tpl.php index 67e118c1b72..0ea4e6fa03b 100644 --- a/htdocs/core/tpl/commonfields_add.tpl.php +++ b/htdocs/core/tpl/commonfields_add.tpl.php @@ -19,6 +19,7 @@ * $action * $conf * $langs + * $form */ // Protection to avoid direct call of template @@ -63,4 +64,4 @@ foreach($object->fields as $key => $val) } ?> - \ No newline at end of file +