From 8c8afa4b46400d2641dd78df89427c5e02d02b13 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Mon, 13 Apr 2020 09:15:01 +0200 Subject: [PATCH 1/7] Update api_thirdparties.class.php --- .../societe/class/api_thirdparties.class.php | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/htdocs/societe/class/api_thirdparties.class.php b/htdocs/societe/class/api_thirdparties.class.php index d9214a538a2..e4228b9e63e 100644 --- a/htdocs/societe/class/api_thirdparties.class.php +++ b/htdocs/societe/class/api_thirdparties.class.php @@ -1120,7 +1120,7 @@ class Thirdparties extends DolibarrApi * @param int $id ID of thirdparty * @param array $request_data Request data * - * @return object ID of thirdparty + * @return object BankAccount of thirdparty * * @url POST {id}/bankaccounts */ @@ -1129,7 +1129,9 @@ class Thirdparties extends DolibarrApi if (!DolibarrApiAccess::$user->rights->societe->creer) { throw new RestException(401); } - + if ($this->company->fetch($id) <= 0) { + throw new RestException(404, 'Error creating Company Bank account, Company doesn\'t exists'); + } $account = new CompanyBankAccount($this->db); $account->socid = $id; @@ -1141,6 +1143,12 @@ class Thirdparties extends DolibarrApi if ($account->create(DolibarrApiAccess::$user) < 0) throw new RestException(500, 'Error creating Company Bank account'); + if (empty($account->rum)) { + require_once DOL_DOCUMENT_ROOT.'/compta/prelevement/class/bonprelevement.class.php'; + $prelevement = new BonPrelevement($this->db); + $account->rum = $prelevement->buildRumNumber($this->company->code_client, $account->datec, $account->id); + $account->date_rum = dol_now(); + } if ($account->update(DolibarrApiAccess::$user) < 0) throw new RestException(500, 'Error updating values'); @@ -1155,7 +1163,7 @@ class Thirdparties extends DolibarrApi * @param int $bankaccount_id ID of CompanyBankAccount * @param array $request_data Request data * - * @return object ID of thirdparty + * @return object BankAccount of thirdparty * * @url PUT {id}/bankaccounts/{bankaccount_id} */ @@ -1164,7 +1172,9 @@ class Thirdparties extends DolibarrApi if (!DolibarrApiAccess::$user->rights->societe->creer) { throw new RestException(401); } - + if ($this->company->fetch($id) <= 0) { + throw new RestException(404, 'Error creating Company Bank account, Company doesn\'t exists'); + } $account = new CompanyBankAccount($this->db); $account->fetch($bankaccount_id, $id, -1, ''); From 1114f0ee3db16409b2f95ee81f31471993abf841 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Mon, 13 Apr 2020 09:25:06 +0200 Subject: [PATCH 2/7] Update api_thirdparties.class.php --- htdocs/societe/class/api_thirdparties.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/societe/class/api_thirdparties.class.php b/htdocs/societe/class/api_thirdparties.class.php index e4228b9e63e..3a351dddec3 100644 --- a/htdocs/societe/class/api_thirdparties.class.php +++ b/htdocs/societe/class/api_thirdparties.class.php @@ -1153,7 +1153,7 @@ class Thirdparties extends DolibarrApi if ($account->update(DolibarrApiAccess::$user) < 0) throw new RestException(500, 'Error updating values'); - return $account; + return $this->_cleanObjectDatas($account); } /** @@ -1191,7 +1191,7 @@ class Thirdparties extends DolibarrApi if ($account->update(DolibarrApiAccess::$user) < 0) throw new RestException(500, 'Error updating values'); - return $account; + return $this->_cleanObjectDatas($account); } /** From 5933d2282cc48ed76c3310a63023d306b4fe9900 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Mon, 13 Apr 2020 09:39:31 +0200 Subject: [PATCH 3/7] Update api_thirdparties.class.php --- htdocs/societe/class/api_thirdparties.class.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/htdocs/societe/class/api_thirdparties.class.php b/htdocs/societe/class/api_thirdparties.class.php index 3a351dddec3..5206e345193 100644 --- a/htdocs/societe/class/api_thirdparties.class.php +++ b/htdocs/societe/class/api_thirdparties.class.php @@ -1188,6 +1188,13 @@ class Thirdparties extends DolibarrApi $account->$field = $value; } + if (empty($account->rum)) { + require_once DOL_DOCUMENT_ROOT.'/compta/prelevement/class/bonprelevement.class.php'; + $prelevement = new BonPrelevement($this->db); + $account->rum = $prelevement->buildRumNumber($this->company->code_client, $account->datec, $account->id); + $account->date_rum = dol_now(); + } + if ($account->update(DolibarrApiAccess::$user) < 0) throw new RestException(500, 'Error updating values'); From e130faf0121e517b0c24c40d895b309bb5f756af Mon Sep 17 00:00:00 2001 From: "Sekan, Tobias" Date: Mon, 13 Apr 2020 10:36:24 +0200 Subject: [PATCH 4/7] Show active box state of a RSS feed --- htdocs/admin/external_rss.php | 40 ++++++++++++++++++++++++++++++++--- htdocs/langs/en_US/admin.lang | 2 ++ 2 files changed, 39 insertions(+), 3 deletions(-) diff --git a/htdocs/admin/external_rss.php b/htdocs/admin/external_rss.php index f2412175880..ec77cb32184 100644 --- a/htdocs/admin/external_rss.php +++ b/htdocs/admin/external_rss.php @@ -6,6 +6,7 @@ * Copyright (C) 2004 Benoit Mortier * Copyright (C) 2005-2011 Regis Houssin * Copyright (C) 2011 Juanjo Menent + * Copyright (C) 2020 Tobias Sekan * * 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 @@ -30,6 +31,7 @@ require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/rssparser.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/infobox.class.php'; // Load translation files required by the page $langs->load("admin"); @@ -222,10 +224,14 @@ print '
'; print ''; print ''; print ''; -print '


'; +print ''; print ''; +print '
'.$langs->trans('RssNote'); +print '
'.$langs->trans('JumpToBoxes').''; + +print '

'; $sql = "SELECT rowid, file, note FROM ".MAIN_DB_PREFIX."boxes_def"; $sql .= " WHERE file = 'box_external_rss.php'"; @@ -235,8 +241,9 @@ dol_syslog("select rss boxes", LOG_DEBUG); $resql = $db->query($sql); if ($resql) { - $num = $db->num_rows($resql); - $i = 0; + $boxlist = InfoBox::listBoxes($db, 'activated', -1, null); + $num = $db->num_rows($resql); + $i = 0; while ($i < $num) { @@ -312,6 +319,13 @@ if ($resql) print ""; } + // Active + $active = _isInBoxList($idrss, $boxlist) ? 'yes' : 'no'; + print ''; + print ''.$langs->trans('Active').''; + print ''.$langs->trans($active).''; + print ""; + print ''; print ""; @@ -327,3 +341,23 @@ else // End of page llxFooter(); $db->close(); + +/** + * Check if the given RSS feed if inside the list of boxes/widgets + * + * @param int $idrss The id of the RSS feed + * @param array $boxlist A list with boxes/widgets + * @return bool true if the rss feed is inside the box/widget list, otherwise false + */ +function _isInBoxList($idrss, array $boxlist) +{ + foreach($boxlist as $box) + { + if($box->boxcode === "lastrssinfos" && strpos($box->note, $idrss) !== FALSE) + { + return true; + } + } + + return false; +} diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index 62a7c82437d..8776c673a8b 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -1990,3 +1990,5 @@ EmailTemplate=Template for email EMailsWillHaveMessageID=Emails will have a tag 'References' matching this syntax PDF_USE_ALSO_LANGUAGE_CODE=If you want to have some texts in your PDF duplicated in 2 different languages in the same generated PDF, you must set here this second language so generated PDF will contains 2 different languages in same page, the one chosen when generating PDF and this one (only few PDF templates support this). Keep empty for 1 language per PDF. FafaIconSocialNetworksDesc=Enter here the code of a FontAwesome icon. If you don't know what is FontAwesome, you can use the generic value fa-address-book. +RssNote=Note: Each RSS feed must be separate activate as a widget to show it for a user. +JumpToBoxes=Jump to Setup -> Widgets From cfbb4e9ef6ba30a60172b78352a06c281efe466e Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Mon, 13 Apr 2020 08:55:33 +0000 Subject: [PATCH 5/7] Fixing style errors. --- htdocs/admin/external_rss.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/admin/external_rss.php b/htdocs/admin/external_rss.php index ec77cb32184..7f8007ca22d 100644 --- a/htdocs/admin/external_rss.php +++ b/htdocs/admin/external_rss.php @@ -353,7 +353,7 @@ function _isInBoxList($idrss, array $boxlist) { foreach($boxlist as $box) { - if($box->boxcode === "lastrssinfos" && strpos($box->note, $idrss) !== FALSE) + if($box->boxcode === "lastrssinfos" && strpos($box->note, $idrss) !== false) { return true; } From 387ea73bf37d8db719a9743816de4e91ce11d089 Mon Sep 17 00:00:00 2001 From: Scrutinizer Auto-Fixer Date: Mon, 13 Apr 2020 11:24:42 +0000 Subject: [PATCH 6/7] Scrutinizer Auto-Fixes This commit consists of patches automatically generated for this project on https://scrutinizer-ci.com --- htdocs/admin/events.php | 2 +- htdocs/categories/class/categorie.class.php | 2 +- htdocs/comm/action/class/actioncomm.class.php | 2 +- htdocs/compta/bank/class/account.class.php | 2 +- htdocs/takepos/invoice.php | 10 +++---- htdocs/user/bank.php | 30 +++++++++---------- htdocs/website/index.php | 8 ++--- 7 files changed, 28 insertions(+), 28 deletions(-) diff --git a/htdocs/admin/events.php b/htdocs/admin/events.php index c3b9b372915..75976f0b07b 100644 --- a/htdocs/admin/events.php +++ b/htdocs/admin/events.php @@ -37,7 +37,7 @@ $langs->loadLangs(array("users", "admin", "other")); $action = GETPOST('action', 'aZ09'); $contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'myobjectlist'; // To manage different context of search -$optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print') +$optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print') // Load variable for pagination $limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit; diff --git a/htdocs/categories/class/categorie.class.php b/htdocs/categories/class/categorie.class.php index ab4d4531566..9c0985078e7 100644 --- a/htdocs/categories/class/categorie.class.php +++ b/htdocs/categories/class/categorie.class.php @@ -544,7 +544,7 @@ class Categorie extends CommonObject } $sql .= ", visible = '".$this->db->escape($this->visible)."'"; $sql .= ", fk_parent = ".$this->fk_parent; - $sql .= ", fk_user_modif = ". (int) $user->id; + $sql .= ", fk_user_modif = ".(int) $user->id; $sql .= " WHERE rowid = ".$this->id; dol_syslog(get_class($this)."::update", LOG_DEBUG); diff --git a/htdocs/comm/action/class/actioncomm.class.php b/htdocs/comm/action/class/actioncomm.class.php index 66df0ea1ae3..8c1e2051a81 100644 --- a/htdocs/comm/action/class/actioncomm.class.php +++ b/htdocs/comm/action/class/actioncomm.class.php @@ -921,7 +921,7 @@ class ActionComm extends CommonObject $res = $this->db->query($sql); if (!$res) { - $this->error=$this->db->lasterror(); + $this->error = $this->db->lasterror(); $error++; } } diff --git a/htdocs/compta/bank/class/account.class.php b/htdocs/compta/bank/class/account.class.php index d8b4424661a..cbda53affed 100644 --- a/htdocs/compta/bank/class/account.class.php +++ b/htdocs/compta/bank/class/account.class.php @@ -243,7 +243,7 @@ class Account extends CommonObject /** * @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( + public $fields = array( 'rowid' =>array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>10), 'ref' =>array('type'=>'varchar(12)', 'label'=>'Ref', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'showoncombobox'=>1, 'position'=>25), 'label' =>array('type'=>'varchar(30)', 'label'=>'Label', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>30), diff --git a/htdocs/takepos/invoice.php b/htdocs/takepos/invoice.php index e925c5aae9b..77254be543f 100644 --- a/htdocs/takepos/invoice.php +++ b/htdocs/takepos/invoice.php @@ -536,13 +536,13 @@ if ($action == "order" and $placeid != 0) } if ($conf->global->TAKEPOS_PRINT_METHOD == "receiptprinter" && $linestoprint > 0) { $invoice->fetch($placeid); //Reload object before send to printer - $printer->orderprinter=1; + $printer->orderprinter = 1; $ret = $printer->sendToPrinter($invoice, $conf->global->{'TAKEPOS_TEMPLATE_TO_USE_FOR_ORDERS'.$_SESSION["takeposterminal"]}, $conf->global->{'TAKEPOS_ORDER_PRINTER1_TO_USE'.$_SESSION["takeposterminal"]}); // PRINT TO PRINTER 1 } $sql = "UPDATE ".MAIN_DB_PREFIX."facturedet set special_code='4' where special_code='1' and fk_facture=".$invoice->id; // Set as printed $db->query($sql); $invoice->fetch($placeid); //Reload object after set lines as printed - $linestoprint=0; + $linestoprint = 0; foreach ($invoice->lines as $line) { @@ -564,7 +564,7 @@ if ($action == "order" and $placeid != 0) } if ($conf->global->TAKEPOS_PRINT_METHOD == "receiptprinter" && $linestoprint > 0) { $invoice->fetch($placeid); //Reload object before send to printer - $printer->orderprinter=2; + $printer->orderprinter = 2; $ret = $printer->sendToPrinter($invoice, $conf->global->{'TAKEPOS_TEMPLATE_TO_USE_FOR_ORDERS'.$_SESSION["takeposterminal"]}, $conf->global->{'TAKEPOS_ORDER_PRINTER2_TO_USE'.$_SESSION["takeposterminal"]}); // PRINT TO PRINTER 2 } $sql = "UPDATE ".MAIN_DB_PREFIX."facturedet set special_code='4' where special_code='2' and fk_facture=".$invoice->id; // Set as printed @@ -712,8 +712,8 @@ function TakeposPrinting(id){ function TakeposConnector(id){ var invoice=''; $.ajax({ diff --git a/htdocs/user/bank.php b/htdocs/user/bank.php index 10441299e2b..65951e9f2de 100644 --- a/htdocs/user/bank.php +++ b/htdocs/user/bank.php @@ -378,7 +378,7 @@ if ($action != 'edit' && $action != 'create') // If not bank account yet, $acco $morehtmlright = ''; if ($account->id == 0) { - $morehtmlright = dolGetButtonTitle($langs->trans('Add'), '', 'fa fa-plus-circle', $_SERVER["PHP_SELF"] . '?id=' . $object->id . '&action=create'); + $morehtmlright = dolGetButtonTitle($langs->trans('Add'), '', 'fa fa-plus-circle', $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=create'); } print load_fiche_titre($langs->trans("BankAccounts"), $morehtmlright, 'bank_account'); @@ -395,49 +395,49 @@ if ($action != 'edit' && $action != 'create') // If not bank account yet, $acco print_liste_field_titre('', $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'maxwidthsearch '); print "\n"; - if($account->id > 0) { + if ($account->id > 0) { print ''; // Label - print '' . $account->label . ''; + print ''.$account->label.''; // Bank name - print '' . $account->bank . ''; + print ''.$account->bank.''; // Account number print ''; $string = ''; foreach ($account->getFieldsToShow() as $val) { if ($val == 'BankCode') { - $string .= $account->code_banque . ' '; + $string .= $account->code_banque.' '; } elseif ($val == 'BankAccountNumber') { - $string .= $account->number . ' '; + $string .= $account->number.' '; } elseif ($val == 'DeskCode') { - $string .= $account->code_guichet . ' '; + $string .= $account->code_guichet.' '; } elseif ($val == 'BankAccountNumberKey') { - $string .= $account->cle_rib . ' '; + $string .= $account->cle_rib.' '; } } if (!empty($account->label) && $account->number) { if (!checkBanForAccount($account)) { - $string .= ' ' . img_picto($langs->trans("ValueIsNotValid"), 'warning'); + $string .= ' '.img_picto($langs->trans("ValueIsNotValid"), 'warning'); } else { - $string .= ' ' . img_picto($langs->trans("ValueIsValid"), 'info'); + $string .= ' '.img_picto($langs->trans("ValueIsValid"), 'info'); } } print $string; print ''; // IBAN - print '' . $account->iban; + print ''.$account->iban; if (!empty($account->iban)) { if (!checkIbanForAccount($account)) { - print ' ' . img_picto($langs->trans("IbanNotValid"), 'warning'); + print ' '.img_picto($langs->trans("IbanNotValid"), 'warning'); } } print ''; // BIC - print '' . $account->bic; + print ''.$account->bic; if (!empty($account->bic)) { if (!checkSwiftForAccount($account)) { - print ' ' . img_picto($langs->trans("SwiftNotValid"), 'warning'); + print ' '.img_picto($langs->trans("SwiftNotValid"), 'warning'); } } print ''; @@ -445,7 +445,7 @@ if ($action != 'edit' && $action != 'create') // If not bank account yet, $acco // Edit/Delete print ''; if ($user->rights->hrm->employee->write || $user->rights->user->creer) { - print '
'; + print ''; print img_picto($langs->trans("Modify"), 'edit'); print ''; } diff --git a/htdocs/website/index.php b/htdocs/website/index.php index b327549ac50..d4620786ad6 100644 --- a/htdocs/website/index.php +++ b/htdocs/website/index.php @@ -360,7 +360,7 @@ if ($action == 'unsetshowsubcontainers') exit; } -if (($action == 'replacesite' || $action == 'replacesiteconfirm') && ! $searchkey) +if (($action == 'replacesite' || $action == 'replacesiteconfirm') && !$searchkey) { $action = 'replacesite'; } @@ -373,13 +373,13 @@ if ($massaction == 'replace' && GETPOST('confirmmassaction', 'alpha')) if (empty($user->rights->website->writephp)) { setEventMessages("NotAllowedToAddDynamicContent", null, 'errors'); } - elseif (! $replacestring) { + elseif (!$replacestring) { setEventMessages("ErrorReplaceStringEmpty", null, 'errors'); } else { $nbreplacement = 0; - foreach($toselect as $keyselected) { + foreach ($toselect as $keyselected) { $objectpage = $listofpages['list'][$keyselected]; if ($objectpage->pageurl) { dol_syslog("Replace string into page ".$objectpage->pageurl); @@ -3543,7 +3543,7 @@ if ($action == 'replacesite' || $action == 'replacesiteconfirm' || $massaction = $massactionbutton .= ''; + $massactionbutton .= ''; $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage; //$selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields From 36669739f39f5ad5f12bb086ad903b2e19aa4a0f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 13 Apr 2020 13:29:23 +0200 Subject: [PATCH 7/7] Update external_rss.php --- htdocs/admin/external_rss.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/admin/external_rss.php b/htdocs/admin/external_rss.php index 7f8007ca22d..fdfbdf1f1dd 100644 --- a/htdocs/admin/external_rss.php +++ b/htdocs/admin/external_rss.php @@ -322,8 +322,8 @@ if ($resql) // Active $active = _isInBoxList($idrss, $boxlist) ? 'yes' : 'no'; print ''; - print ''.$langs->trans('Active').''; - print ''.$langs->trans($active).''; + print ''.$langs->trans('WidgetEnabled').''; + print ''.yesno($active).''; print ""; print '';