From 554e449e407c4caec9bd203e67cab380acc4b53d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Tue, 23 Feb 2021 22:03:23 +0100 Subject: [PATCH] code syntax core directory --- htdocs/core/actions_addupdatedelete.inc.php | 207 +- htdocs/core/actions_builddoc.inc.php | 73 +- .../core/actions_changeselectedfields.inc.php | 10 +- htdocs/core/actions_comments.inc.php | 27 +- htdocs/core/actions_dellink.inc.php | 10 +- htdocs/core/actions_extrafields.inc.php | 130 +- htdocs/core/actions_fetchobject.inc.php | 15 +- htdocs/core/actions_lineupdown.inc.php | 22 +- htdocs/core/actions_linkedfiles.inc.php | 124 +- htdocs/core/actions_massactions.inc.php | 836 ++-- htdocs/core/actions_printing.inc.php | 19 +- htdocs/core/actions_setmoduleoptions.inc.php | 69 +- htdocs/core/actions_setnotes.inc.php | 44 +- htdocs/core/ajax/ajaxdirpreview.php | 269 +- htdocs/core/ajax/ajaxdirtree.php | 217 +- htdocs/core/ajax/bankconciliate.php | 32 +- htdocs/core/ajax/box.php | 39 +- htdocs/core/ajax/check_notifications.php | 64 +- htdocs/core/ajax/constantonoff.php | 40 +- htdocs/core/ajax/contacts.php | 19 +- htdocs/core/ajax/extraparams.php | 23 +- htdocs/core/ajax/fileupload.php | 16 +- htdocs/core/ajax/getaccountcurrency.php | 15 +- htdocs/core/ajax/loadinplace.php | 59 +- htdocs/core/ajax/objectonoff.php | 28 +- htdocs/core/ajax/pingresult.php | 33 +- htdocs/core/ajax/price.php | 22 +- htdocs/core/ajax/row.php | 37 +- htdocs/core/ajax/saveinplace.php | 63 +- htdocs/core/ajax/security.php | 30 +- htdocs/core/ajax/selectobject.php | 41 +- htdocs/core/ajax/selectsearchbox.php | 117 +- htdocs/core/ajax/vatrates.php | 18 +- htdocs/core/ajax/ziptown.php | 58 +- htdocs/core/antispamimage.php | 30 +- .../box_accountancy_last_manual_entries.php | 9 +- .../box_accountancy_suspense_account.php | 9 +- htdocs/core/boxes/box_actions.php | 47 +- htdocs/core/boxes/box_activity.php | 39 +- htdocs/core/boxes/box_birthdays.php | 19 +- htdocs/core/boxes/box_birthdays_members.php | 23 +- htdocs/core/boxes/box_boms.php | 13 +- htdocs/core/boxes/box_bookmarks.php | 10 +- htdocs/core/boxes/box_clients.php | 31 +- htdocs/core/boxes/box_commandes.php | 36 +- htdocs/core/boxes/box_comptes.php | 6 +- htdocs/core/boxes/box_contacts.php | 21 +- htdocs/core/boxes/box_contracts.php | 31 +- ...box_customers_outstanding_bill_reached.php | 34 +- .../core/boxes/box_dolibarr_state_board.php | 4 +- htdocs/core/boxes/box_external_rss.php | 50 +- htdocs/core/boxes/box_factures.php | 25 +- htdocs/core/boxes/box_factures_fourn.php | 28 +- htdocs/core/boxes/box_factures_fourn_imp.php | 24 +- htdocs/core/boxes/box_factures_imp.php | 27 +- htdocs/core/boxes/box_ficheinter.php | 27 +- htdocs/core/boxes/box_fournisseurs.php | 23 +- htdocs/core/boxes/box_goodcustomers.php | 23 +- .../boxes/box_graph_invoices_permonth.php | 89 +- .../box_graph_invoices_supplier_permonth.php | 93 +- .../core/boxes/box_graph_orders_permonth.php | 89 +- .../box_graph_orders_supplier_permonth.php | 83 +- .../boxes/box_graph_product_distribution.php | 153 +- .../boxes/box_graph_propales_permonth.php | 89 +- .../core/boxes/box_last_modified_ticket.php | 4 +- htdocs/core/boxes/box_lastlogin.php | 7 +- htdocs/core/boxes/box_mos.php | 13 +- .../core/boxes/box_produits_alerte_stock.php | 36 +- htdocs/core/boxes/box_project.php | 17 +- htdocs/core/boxes/box_prospect.php | 25 +- htdocs/core/boxes/box_services_contracts.php | 36 +- htdocs/core/boxes/box_services_expired.php | 28 +- htdocs/core/boxes/box_shipments.php | 28 +- htdocs/core/boxes/box_supplier_orders.php | 28 +- ...box_supplier_orders_awaiting_reception.php | 28 +- htdocs/core/boxes/box_task.php | 8 +- htdocs/core/boxes/box_validated_projects.php | 15 +- htdocs/core/boxes/modules_boxes.php | 180 +- htdocs/core/class/CSMSFile.class.php | 57 +- htdocs/core/class/antivir.class.php | 22 +- htdocs/core/class/canvas.class.php | 43 +- htdocs/core/class/ccountry.class.php | 109 +- .../core/class/commondocgenerator.class.php | 276 +- htdocs/core/class/commonincoterm.class.php | 21 +- htdocs/core/class/commoninvoice.class.php | 190 +- htdocs/core/class/commonobject.class.php | 3121 +++++++------ htdocs/core/class/commonobjectline.class.php | 14 +- .../class/commonstickergenerator.class.php | 4 +- htdocs/core/class/conf.class.php | 408 +- htdocs/core/class/coreobject.class.php | 156 +- htdocs/core/class/cproductnature.class.php | 35 +- htdocs/core/class/cstate.class.php | 79 +- htdocs/core/class/ctypent.class.php | 103 +- htdocs/core/class/ctyperesource.class.php | 10 +- htdocs/core/class/cunits.class.php | 128 +- htdocs/core/class/discount.class.php | 192 +- htdocs/core/class/doleditor.class.php | 64 +- htdocs/core/class/dolgeoip.class.php | 89 +- htdocs/core/class/dolgraph.class.php | 221 +- htdocs/core/class/dolreceiptprinter.class.php | 34 +- .../core/class/emailsenderprofile.class.php | 35 +- htdocs/core/class/evalmath.class.php | 51 +- htdocs/core/class/events.class.php | 23 +- htdocs/core/class/extrafields.class.php | 625 +-- htdocs/core/class/extralanguages.class.php | 22 +- htdocs/core/class/fileupload.class.php | 55 +- htdocs/core/class/fiscalyear.class.php | 148 +- htdocs/core/class/hookmanager.class.php | 98 +- htdocs/core/class/html.form.class.php | 3477 ++++++++------- .../core/class/html.formaccounting.class.php | 72 +- htdocs/core/class/html.formactions.class.php | 153 +- htdocs/core/class/html.formadmin.class.php | 208 +- htdocs/core/class/html.formbarcode.class.php | 15 +- htdocs/core/class/html.formcategory.class.php | 3 +- htdocs/core/class/html.formcompany.class.php | 348 +- htdocs/core/class/html.formcontract.class.php | 57 +- .../class/html.formexpensereport.class.php | 42 +- htdocs/core/class/html.formfile.class.php | 944 ++-- .../class/html.formintervention.class.php | 42 +- htdocs/core/class/html.formmargin.class.php | 81 +- htdocs/core/class/html.formorder.class.php | 7 +- htdocs/core/class/html.formother.class.php | 492 ++- htdocs/core/class/html.formprojet.class.php | 283 +- htdocs/core/class/html.formpropal.class.php | 32 +- htdocs/core/class/html.formsms.class.php | 94 +- .../class/html.formsocialcontrib.class.php | 35 +- htdocs/core/class/html.formticket.class.php | 68 +- htdocs/core/class/html.formwebsite.class.php | 88 +- htdocs/core/class/infobox.class.php | 43 +- htdocs/core/class/interfaces.class.php | 150 +- htdocs/core/class/ldap.class.php | 344 +- htdocs/core/class/lessc.class.php | 2939 +++++++------ htdocs/core/class/link.class.php | 73 +- htdocs/core/class/menu.class.php | 7 +- htdocs/core/class/menubase.class.php | 127 +- htdocs/core/class/notify.class.php | 38 +- htdocs/core/class/openid.class.php | 93 +- htdocs/core/class/rssparser.class.php | 273 +- htdocs/core/class/smtps.class.php | 481 +- htdocs/core/class/stats.class.php | 280 +- htdocs/core/class/translate.class.php | 444 +- htdocs/core/class/utils.class.php | 500 ++- htdocs/core/class/vcard.class.php | 107 +- htdocs/core/commonfieldsinexport.inc.php | 13 +- htdocs/core/customreports.php | 105 +- htdocs/core/datepicker.php | 132 +- htdocs/core/db/DoliDB.class.php | 50 +- htdocs/core/db/mysqli.class.php | 327 +- htdocs/core/db/pgsql.class.php | 399 +- htdocs/core/db/sqlite3.class.php | 436 +- htdocs/core/extrafieldsinexport.inc.php | 22 +- .../browser/default/frmresourceslist.php | 22 +- .../filemanagerdol/connectors/php/basexml.php | 12 +- .../connectors/php/commands.php | 115 +- .../filemanagerdol/connectors/php/config.php | 28 +- .../connectors/php/connector.php | 24 +- .../core/filemanagerdol/connectors/php/io.php | 70 +- .../filemanagerdol/connectors/php/upload.php | 9 +- .../filemanagerdol/connectors/php/util.php | 36 +- htdocs/core/get_info.php | 65 +- htdocs/core/get_menudiv.php | 72 +- htdocs/core/js/lib_gravatar.js.php | 243 +- htdocs/core/js/lib_head.js.php | 301 +- htdocs/core/js/lib_notification.js.php | 213 +- htdocs/core/js/timepicker.js.php | 39 +- htdocs/core/lib/accounting.lib.php | 55 +- htdocs/core/lib/admin.lib.php | 6 +- htdocs/core/lib/agenda.lib.php | 94 +- htdocs/core/lib/ajax.lib.php | 57 +- htdocs/core/lib/asset.lib.php | 16 +- htdocs/core/lib/bank.lib.php | 65 +- htdocs/core/lib/barcode.lib.php | 162 +- htdocs/core/lib/categories.lib.php | 3 +- htdocs/core/lib/company.lib.php | 398 +- htdocs/core/lib/contact.lib.php | 19 +- htdocs/core/lib/contract.lib.php | 29 +- htdocs/core/lib/cron.lib.php | 18 +- htdocs/core/lib/date.lib.php | 357 +- htdocs/core/lib/doc.lib.php | 85 +- htdocs/core/lib/doleditor.lib.php | 68 +- htdocs/core/lib/donation.lib.php | 16 +- htdocs/core/lib/ecm.lib.php | 18 +- htdocs/core/lib/emailing.lib.php | 10 +- htdocs/core/lib/expedition.lib.php | 25 +- htdocs/core/lib/expensereport.lib.php | 29 +- htdocs/core/lib/fichinter.lib.php | 37 +- htdocs/core/lib/files.lib.php | 1468 +++---- htdocs/core/lib/format_cards.lib.php | 9 +- htdocs/core/lib/fourn.lib.php | 75 +- htdocs/core/lib/functions.lib.php | 3862 ++++++++++------- htdocs/core/lib/functions2.lib.php | 1368 +++--- htdocs/core/lib/functions_ch.lib.php | 3 +- htdocs/core/lib/functionsnumtoword.lib.php | 46 +- htdocs/core/lib/geturl.lib.php | 42 +- htdocs/core/lib/holiday.lib.php | 4 +- htdocs/core/lib/images.lib.php | 206 +- htdocs/core/lib/import.lib.php | 7 +- htdocs/core/lib/invoice.lib.php | 44 +- htdocs/core/lib/invoice2.lib.php | 209 +- htdocs/core/lib/json.lib.php | 124 +- htdocs/core/lib/ldap.lib.php | 75 +- htdocs/core/lib/loan.lib.php | 8 +- htdocs/core/lib/member.lib.php | 42 +- htdocs/core/lib/memory.lib.php | 43 +- htdocs/core/lib/modulebuilder.lib.php | 202 +- htdocs/core/lib/multicurrency.lib.php | 3 +- htdocs/core/lib/oauth.lib.php | 3 +- htdocs/core/lib/order.lib.php | 64 +- htdocs/core/lib/parsemd.lib.php | 15 +- htdocs/core/lib/payments.lib.php | 229 +- htdocs/core/lib/pdf.lib.php | 1106 ++--- htdocs/core/lib/prelevement.lib.php | 20 +- htdocs/core/lib/price.lib.php | 156 +- htdocs/core/lib/product.lib.php | 171 +- htdocs/core/lib/project.lib.php | 1253 +++--- htdocs/core/lib/propal.lib.php | 37 +- htdocs/core/lib/receiptprinter.lib.php | 3 +- htdocs/core/lib/reception.lib.php | 28 +- htdocs/core/lib/report.lib.php | 34 +- htdocs/core/lib/resource.lib.php | 29 +- htdocs/core/lib/salaries.lib.php | 4 +- htdocs/core/lib/security.lib.php | 446 +- htdocs/core/lib/security2.lib.php | 161 +- htdocs/core/lib/sendings.lib.php | 176 +- htdocs/core/lib/signature.lib.php | 27 +- htdocs/core/lib/stock.lib.php | 3 +- htdocs/core/lib/supplier_proposal.lib.php | 26 +- htdocs/core/lib/takepos.lib.php | 3 +- htdocs/core/lib/tax.lib.php | 485 ++- htdocs/core/lib/ticket.lib.php | 135 +- htdocs/core/lib/treeview.lib.php | 87 +- htdocs/core/lib/usergroups.lib.php | 426 +- htdocs/core/lib/vat.lib.php | 4 +- htdocs/core/lib/website.lib.php | 261 +- htdocs/core/lib/website2.lib.php | 96 +- htdocs/core/lib/ws.lib.php | 32 +- htdocs/core/lib/xcal.lib.php | 170 +- htdocs/core/login/functions_dolibarr.php | 51 +- htdocs/core/login/functions_forceuser.php | 8 +- htdocs/core/login/functions_googleoauth.php | 37 +- htdocs/core/login/functions_http.php | 3 +- htdocs/core/login/functions_ldap.php | 102 +- htdocs/core/login/functions_openid.php | 24 +- htdocs/core/menus/standard/auguria.lib.php | 294 +- htdocs/core/menus/standard/auguria_menu.php | 182 +- htdocs/core/modules/DolibarrModules.class.php | 255 +- htdocs/core/modules/action/modules_action.php | 32 +- htdocs/core/modules/action/rapport.pdf.php | 80 +- .../core/modules/bank/doc/pdf_ban.modules.php | 107 +- .../bank/doc/pdf_sepamandate.modules.php | 171 +- .../barcode/doc/phpbarcode.modules.php | 47 +- .../barcode/doc/tcpdfbarcode.modules.php | 8 +- .../barcode/mod_barcode_product_standard.php | 118 +- .../modules/barcode/modules_barcode.class.php | 65 +- .../bom/doc/doc_generic_bom_odt.modules.php | 140 +- htdocs/core/modules/bom/mod_bom_advanced.php | 10 +- htdocs/core/modules/bom/mod_bom_standard.php | 29 +- htdocs/core/modules/bom/modules_bom.php | 16 +- .../modules/cheque/doc/pdf_blochet.class.php | 67 +- .../modules/cheque/mod_chequereceipt_mint.php | 29 +- .../cheque/mod_chequereceipt_thyme.php | 8 +- .../modules/cheque/modules_chequereceipts.php | 28 +- .../doc/doc_generic_order_odt.modules.php | 134 +- .../commande/doc/pdf_einstein.modules.php | 473 +- .../commande/doc/pdf_eratosthene.modules.php | 581 ++- .../modules/commande/mod_commande_marbre.php | 29 +- .../modules/commande/mod_commande_saphir.php | 10 +- .../modules/commande/modules_commande.php | 16 +- .../doc/doc_generic_contract_odt.modules.php | 120 +- .../contract/doc/pdf_strato.modules.php | 174 +- .../modules/contract/mod_contract_magre.php | 10 +- .../modules/contract/mod_contract_olive.php | 6 +- .../modules/contract/mod_contract_serpis.php | 29 +- .../modules/contract/modules_contract.php | 16 +- .../delivery/doc/pdf_storm.modules.php | 293 +- .../delivery/doc/pdf_typhon.modules.php | 209 +- .../modules/delivery/mod_delivery_jade.php | 28 +- .../modules/delivery/mod_delivery_saphir.php | 8 +- .../modules/delivery/modules_delivery.php | 16 +- .../modules/dons/html_cerfafr.modules.php | 99 +- htdocs/core/modules/dons/modules_don.php | 16 +- .../doc/doc_generic_shipment_odt.modules.php | 195 +- .../expedition/doc/pdf_espadon.modules.php | 388 +- .../expedition/doc/pdf_merou.modules.php | 123 +- .../expedition/doc/pdf_rouget.modules.php | 370 +- .../expedition/mod_expedition_ribera.php | 10 +- .../expedition/mod_expedition_safor.php | 29 +- .../modules/expedition/modules_expedition.php | 16 +- .../doc/pdf_standard.modules.php | 199 +- .../expensereport/mod_expensereport_jade.php | 43 +- .../expensereport/mod_expensereport_sand.php | 22 +- .../expensereport/modules_expensereport.php | 16 +- .../modules/export/export_csv.modules.php | 54 +- .../export/export_excel2007.modules.php | 97 +- .../modules/export/export_tsv.modules.php | 27 +- htdocs/core/modules/export/modules_export.php | 12 +- .../doc/doc_generic_invoice_odt.modules.php | 135 +- .../modules/facture/doc/pdf_crabe.modules.php | 626 +-- .../facture/doc/pdf_sponge.modules.php | 650 ++- .../core/modules/facture/mod_facture_mars.php | 78 +- .../modules/facture/mod_facture_mercure.php | 26 +- .../modules/facture/mod_facture_terre.php | 85 +- .../core/modules/facture/modules_facture.php | 16 +- .../fichinter/doc/pdf_soleil.modules.php | 157 +- htdocs/core/modules/fichinter/mod_arctic.php | 10 +- htdocs/core/modules/fichinter/mod_pacific.php | 29 +- .../modules/fichinter/modules_fichinter.php | 48 +- .../holiday/mod_holiday_immaculate.php | 10 +- .../modules/holiday/mod_holiday_madonna.php | 29 +- .../core/modules/holiday/modules_holiday.php | 16 +- .../modules/import/import_csv.modules.php | 285 +- .../modules/import/import_xlsx.modules.php | 180 +- htdocs/core/modules/import/modules_import.php | 9 +- .../mailings/advthirdparties.modules.php | 47 +- .../modules/mailings/contacts1.modules.php | 189 +- .../core/modules/mailings/example.modules.php | 2 +- .../core/modules/mailings/fraise.modules.php | 56 +- .../modules/mailings/modules_mailings.php | 73 +- .../core/modules/mailings/pomme.modules.php | 25 +- .../modules/mailings/thirdparties.modules.php | 56 +- .../thirdparties_services_expired.modules.php | 32 +- .../modules/mailings/xinputfile.modules.php | 37 +- .../modules/mailings/xinputuser.modules.php | 12 +- .../doc/doc_generic_member_odt.class.php | 55 +- .../modules/member/doc/pdf_standard.class.php | 169 +- htdocs/core/modules/member/modules_cards.php | 40 +- htdocs/core/modules/modAdherent.class.php | 36 +- htdocs/core/modules/modAgenda.class.php | 26 +- htdocs/core/modules/modApi.class.php | 3 +- htdocs/core/modules/modAsset.class.php | 3 +- htdocs/core/modules/modBanque.class.php | 3 +- htdocs/core/modules/modBlockedLog.class.php | 25 +- htdocs/core/modules/modBom.class.php | 49 +- htdocs/core/modules/modCategorie.class.php | 71 +- htdocs/core/modules/modCollab.class.php | 28 +- htdocs/core/modules/modCommande.class.php | 17 +- htdocs/core/modules/modContrat.class.php | 6 +- htdocs/core/modules/modDataPolicy.class.php | 44 +- htdocs/core/modules/modDav.class.php | 29 +- htdocs/core/modules/modDeplacement.class.php | 15 +- .../core/modules/modEmailCollector.class.php | 45 +- htdocs/core/modules/modExpedition.class.php | 25 +- htdocs/core/modules/modExternalRss.class.php | 9 +- htdocs/core/modules/modFacture.class.php | 40 +- htdocs/core/modules/modFournisseur.class.php | 122 +- htdocs/core/modules/modHoliday.class.php | 2 +- htdocs/core/modules/modIncoterm.class.php | 3 +- .../core/modules/modIntracommreport.class.php | 3 +- htdocs/core/modules/modMrp.class.php | 116 +- .../core/modules/modMultiCurrency.class.php | 39 +- htdocs/core/modules/modOauth.class.php | 10 +- htdocs/core/modules/modPaypal.class.php | 28 +- htdocs/core/modules/modProduct.class.php | 272 +- htdocs/core/modules/modProductBatch.class.php | 3 +- htdocs/core/modules/modProjet.class.php | 31 +- htdocs/core/modules/modPropale.class.php | 21 +- htdocs/core/modules/modReception.class.php | 25 +- htdocs/core/modules/modRecruitment.class.php | 14 +- htdocs/core/modules/modResource.class.php | 6 +- htdocs/core/modules/modService.class.php | 312 +- htdocs/core/modules/modSociete.class.php | 48 +- htdocs/core/modules/modStock.class.php | 23 +- htdocs/core/modules/modStripe.class.php | 28 +- .../modules/modSupplierProposal.class.php | 8 +- htdocs/core/modules/modTakePos.class.php | 29 +- htdocs/core/modules/modTicket.class.php | 6 +- htdocs/core/modules/modUser.class.php | 9 +- htdocs/core/modules/modVariants.class.php | 3 +- htdocs/core/modules/modWebsite.class.php | 13 +- htdocs/core/modules/modWorkflow.class.php | 64 +- htdocs/core/modules/modWorkstation.class.php | 54 +- htdocs/core/modules/modZapier.class.php | 112 +- .../movement/doc/pdf_standard.modules.php | 428 +- .../mrp/doc/doc_generic_mo_odt.modules.php | 137 +- htdocs/core/modules/mrp/mod_mo_advanced.php | 10 +- htdocs/core/modules/mrp/mod_mo_standard.php | 29 +- htdocs/core/modules/mrp/modules_mo.php | 16 +- .../modules/oauth/github_oauthcallback.php | 16 +- .../modules/oauth/google_oauthcallback.php | 16 +- .../oauth/stripelive_oauthcallback.php | 17 +- .../oauth/stripetest_oauthcallback.php | 17 +- .../core/modules/payment/mod_payment_ant.php | 10 +- .../modules/payment/mod_payment_cicada.php | 29 +- .../core/modules/payment/modules_payment.php | 16 +- .../modules/printing/modules_printing.php | 7 +- .../modules/printing/printgcp.modules.php | 37 +- .../modules/printing/printipp.modules.php | 15 +- .../doc/pdf_standardlabel.class.php | 128 +- .../printsheet/doc/pdf_tcpdflabel.class.php | 114 +- .../modules/printsheet/modules_labels.php | 55 +- .../doc/doc_generic_product_odt.modules.php | 117 +- .../product/doc/pdf_standard.modules.php | 248 +- .../product/mod_codeproduct_elephant.php | 85 +- .../product/mod_codeproduct_leopard.php | 6 +- .../doc/doc_generic_project_odt.modules.php | 286 +- .../project/doc/pdf_baleine.modules.php | 189 +- .../project/doc/pdf_beluga.modules.php | 174 +- .../project/doc/pdf_timespent.modules.php | 189 +- .../modules/project/mod_project_simple.php | 29 +- .../modules/project/mod_project_universal.php | 6 +- .../core/modules/project/modules_project.php | 16 +- .../task/doc/doc_generic_task_odt.modules.php | 213 +- .../modules/project/task/mod_task_simple.php | 29 +- .../modules/project/task/modules_task.php | 12 +- .../doc/doc_generic_proposal_odt.modules.php | 144 +- .../modules/propale/doc/pdf_azur.modules.php | 552 ++- .../modules/propale/doc/pdf_cyan.modules.php | 562 ++- .../modules/propale/mod_propale_marbre.php | 29 +- .../modules/propale/mod_propale_saphir.php | 10 +- .../core/modules/propale/modules_propale.php | 16 +- .../modules/rapport/pdf_paiement.class.php | 137 +- .../doc/doc_generic_reception_odt.modules.php | 139 +- .../reception/doc/pdf_squille.modules.php | 337 +- .../modules/reception/mod_reception_beryl.php | 29 +- .../reception/mod_reception_moonstone.php | 10 +- .../modules/reception/modules_reception.php | 13 +- .../generate/modGeneratePassPerso.class.php | 7 +- .../modGeneratePassStandard.class.php | 10 +- .../societe/doc/doc_generic_odt.modules.php | 125 +- .../societe/mod_codeclient_elephant.php | 66 +- .../societe/mod_codeclient_leopard.php | 6 +- .../modules/societe/mod_codeclient_monkey.php | 52 +- .../societe/mod_codecompta_aquarium.php | 60 +- .../societe/mod_codecompta_digitaria.php | 60 +- .../societe/mod_codecompta_panicum.php | 7 +- .../doc/doc_generic_stock_odt.modules.php | 120 +- .../stock/doc/pdf_standard.modules.php | 196 +- .../doc/pdf_canelle.modules.php | 348 +- .../mod_facture_fournisseur_cactus.php | 82 +- .../mod_facture_fournisseur_tulip.php | 25 +- .../modules_facturefournisseur.php | 16 +- ...doc_generic_supplier_order_odt.modules.php | 137 +- .../supplier_order/doc/pdf_cornas.modules.php | 474 +- .../doc/pdf_muscadet.modules.php | 415 +- .../mod_commande_fournisseur_muguet.php | 37 +- .../mod_commande_fournisseur_orchidee.php | 6 +- .../modules_commandefournisseur.php | 16 +- .../doc/pdf_standard.modules.php | 172 +- .../mod_supplier_payment_brodator.php | 10 +- .../mod_supplier_payment_bronan.php | 29 +- .../modules_supplier_payment.php | 13 +- ..._generic_supplier_proposal_odt.modules.php | 141 +- .../doc/pdf_aurore.modules.php | 6 +- .../mod_supplier_proposal_marbre.php | 29 +- .../mod_supplier_proposal_saphir.php | 10 +- .../modules_supplier_proposal.php | 16 +- .../core/modules/syslog/mod_syslog_file.php | 43 +- .../core/modules/syslog/mod_syslog_syslog.php | 22 +- .../takepos/mod_takepos_ref_simple.php | 39 +- .../core/modules/takepos/modules_takepos.php | 16 +- .../doc/doc_generic_ticket_odt.modules.php | 96 +- .../user/doc/doc_generic_user_odt.modules.php | 102 +- .../doc/doc_generic_usergroup_odt.modules.php | 126 +- .../workstation/mod_workstation_advanced.php | 6 +- .../workstation/mod_workstation_standard.php | 27 +- .../workstation/modules_workstation.php | 16 +- htdocs/core/photos_resize.php | 316 +- htdocs/core/search.php | 95 +- htdocs/core/search_page.php | 36 +- htdocs/core/tools.php | 4 +- htdocs/core/tpl/admin_extrafields_add.tpl.php | 127 +- .../core/tpl/admin_extrafields_edit.tpl.php | 156 +- .../core/tpl/admin_extrafields_view.tpl.php | 20 +- htdocs/core/tpl/advtarget.tpl.php | 6 +- htdocs/core/tpl/ajax/fileupload_main.tpl.php | 31 +- htdocs/core/tpl/ajax/fileupload_view.tpl.php | 103 +- .../tpl/ajax/objectlinked_lineimport.tpl.php | 90 +- htdocs/core/tpl/ajaxrow.tpl.php | 23 +- htdocs/core/tpl/bloc_comment.tpl.php | 33 +- htdocs/core/tpl/bloc_showhide.tpl.php | 11 +- htdocs/core/tpl/card_presend.tpl.php | 48 +- htdocs/core/tpl/commonfields_add.tpl.php | 62 +- htdocs/core/tpl/commonfields_edit.tpl.php | 55 +- htdocs/core/tpl/commonfields_view.tpl.php | 98 +- htdocs/core/tpl/contacts.tpl.php | 74 +- .../tpl/document_actions_post_headers.tpl.php | 39 +- htdocs/core/tpl/extrafields_add.tpl.php | 11 +- htdocs/core/tpl/extrafields_edit.tpl.php | 7 +- .../tpl/extrafields_list_array_fields.tpl.php | 17 +- .../tpl/extrafields_list_print_fields.tpl.php | 51 +- .../tpl/extrafields_list_search_input.tpl.php | 42 +- .../tpl/extrafields_list_search_param.tpl.php | 17 +- .../tpl/extrafields_list_search_sql.tpl.php | 55 +- .../tpl/extrafields_list_search_title.tpl.php | 31 +- htdocs/core/tpl/extrafields_view.tpl.php | 129 +- htdocs/core/tpl/filemanager.tpl.php | 76 +- htdocs/core/tpl/list_print_total.tpl.php | 25 +- htdocs/core/tpl/login.tpl.php | 138 +- htdocs/core/tpl/massactions_pre.tpl.php | 47 +- htdocs/core/tpl/notes.tpl.php | 26 +- htdocs/core/tpl/object_discounts.tpl.php | 7 +- htdocs/core/tpl/objectline_create.tpl.php | 235 +- htdocs/core/tpl/objectline_edit.tpl.php | 130 +- htdocs/core/tpl/objectline_title.tpl.php | 41 +- htdocs/core/tpl/objectline_view.tpl.php | 147 +- htdocs/core/tpl/onlinepaymentlinks.tpl.php | 51 +- htdocs/core/tpl/originproductline.tpl.php | 13 +- htdocs/core/tpl/passwordforgotten.tpl.php | 89 +- htdocs/core/tpl/resource_add.tpl.php | 3 +- htdocs/core/tpl/resource_view.tpl.php | 15 +- .../core/triggers/dolibarrtriggers.class.php | 2 +- .../interface_20_all_Logevents.class.php | 26 +- ...e_20_modWorkflow_WorkflowManager.class.php | 46 +- ...terface_50_modAgenda_ActionsAuto.class.php | 344 +- ..._modBlockedlog_ActionsBlockedLog.class.php | 17 +- ...interface_50_modLdap_Ldapsynchro.class.php | 68 +- ...odMailmanspip_Mailmanspipsynchro.class.php | 20 +- ..._50_modNotification_Notification.class.php | 37 +- ...terface_50_modTicket_TicketEmail.class.php | 28 +- .../interface_80_modStripe_Stripe.class.php | 40 +- ...rface_90_modSociete_ContactRoles.class.php | 6 +- htdocs/core/website.inc.php | 58 +- 512 files changed, 34726 insertions(+), 28660 deletions(-) diff --git a/htdocs/core/actions_addupdatedelete.inc.php b/htdocs/core/actions_addupdatedelete.inc.php index 1c874fd2418..d7dcbf699c8 100644 --- a/htdocs/core/actions_addupdatedelete.inc.php +++ b/htdocs/core/actions_addupdatedelete.inc.php @@ -30,18 +30,17 @@ // $backtopage may be defined // $triggermodname may be defined -if (!empty($permissionedit) && empty($permissiontoadd)) $permissiontoadd = $permissionedit; // For backward compatibility +if (!empty($permissionedit) && empty($permissiontoadd)) { + $permissiontoadd = $permissionedit; // For backward compatibility +} -if ($cancel) -{ +if ($cancel) { /*var_dump($cancel); var_dump($backtopage);exit;*/ - if (!empty($backtopageforcancel)) - { + if (!empty($backtopageforcancel)) { header("Location: ".$backtopageforcancel); exit; - } elseif (!empty($backtopage)) - { + } elseif (!empty($backtopage)) { header("Location: ".$backtopage); exit; } @@ -50,19 +49,25 @@ if ($cancel) // Action to add record -if ($action == 'add' && !empty($permissiontoadd)) -{ - foreach ($object->fields as $key => $val) - { +if ($action == 'add' && !empty($permissiontoadd)) { + foreach ($object->fields as $key => $val) { if ($object->fields[$key]['type'] == 'duration') { - if (GETPOST($key.'hour') == '' && GETPOST($key.'min') == '') continue; // The field was not submited to be edited + if (GETPOST($key.'hour') == '' && GETPOST($key.'min') == '') { + continue; // The field was not submited to be edited + } } else { - if (!GETPOSTISSET($key)) continue; // The field was not submited to be edited + if (!GETPOSTISSET($key)) { + continue; // The field was not submited to be edited + } } // Ignore special fields - if (in_array($key, array('rowid', 'entity', 'import_key'))) continue; + if (in_array($key, array('rowid', 'entity', 'import_key'))) { + continue; + } if (in_array($key, array('date_creation', 'tms', 'fk_user_creat', 'fk_user_modif'))) { - if (!in_array(abs($val['visible']), array(1, 3))) continue; // Only 1 and 3 that are case to create + if (!in_array(abs($val['visible']), array(1, 3))) { + continue; // Only 1 and 3 that are case to create + } } // Set value to insert @@ -84,17 +89,19 @@ if ($action == 'add' && !empty($permissiontoadd)) } else { $value = GETPOST($key, 'alphanohtml'); } - if (preg_match('/^integer:/i', $object->fields[$key]['type']) && $value == '-1') $value = ''; // This is an implicit foreign key field - if (!empty($object->fields[$key]['foreignkey']) && $value == '-1') $value = ''; // This is an explicit foreign key field + if (preg_match('/^integer:/i', $object->fields[$key]['type']) && $value == '-1') { + $value = ''; // This is an implicit foreign key field + } + if (!empty($object->fields[$key]['foreignkey']) && $value == '-1') { + $value = ''; // This is an explicit foreign key field + } //var_dump($key.' '.$value.' '.$object->fields[$key]['type']); $object->$key = $value; - if ($val['notnull'] > 0 && $object->$key == '' && !is_null($val['default']) && $val['default'] == '(PROV)') - { + if ($val['notnull'] > 0 && $object->$key == '' && !is_null($val['default']) && $val['default'] == '(PROV)') { $object->$key = '(PROV)'; } - if ($val['notnull'] > 0 && $object->$key == '' && is_null($val['default'])) - { + if ($val['notnull'] > 0 && $object->$key == '' && is_null($val['default'])) { $error++; setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv($val['label'])), null, 'errors'); } @@ -103,14 +110,14 @@ if ($action == 'add' && !empty($permissiontoadd)) // Fill array 'array_options' with data from add form if (!$error) { $ret = $extrafields->setOptionalsFromPost(null, $object); - if ($ret < 0) $error++; + if ($ret < 0) { + $error++; + } } - if (!$error) - { + if (!$error) { $result = $object->create($user); - if ($result > 0) - { + if ($result > 0) { // Creation OK $urltogo = $backtopage ? str_replace('__ID__', $result, $backtopage) : $backurlforlist; $urltogo = preg_replace('/--IDFORBACKTOPAGE--/', $object->id, $urltogo); // New method to autoselect project after a New on another form object creation @@ -118,8 +125,11 @@ if ($action == 'add' && !empty($permissiontoadd)) exit; } else { // Creation KO - if (!empty($object->errors)) setEventMessages(null, $object->errors, 'errors'); - else setEventMessages($object->error, null, 'errors'); + if (!empty($object->errors)) { + setEventMessages(null, $object->errors, 'errors'); + } else { + setEventMessages($object->error, null, 'errors'); + } $action = 'create'; } } else { @@ -128,25 +138,31 @@ if ($action == 'add' && !empty($permissiontoadd)) } // Action to update record -if ($action == 'update' && !empty($permissiontoadd)) -{ - foreach ($object->fields as $key => $val) - { +if ($action == 'update' && !empty($permissiontoadd)) { + foreach ($object->fields as $key => $val) { // Check if field was submited to be edited if ($object->fields[$key]['type'] == 'duration') { - if (!GETPOSTISSET($key.'hour') || !GETPOSTISSET($key.'min')) continue; // The field was not submited to be edited + if (!GETPOSTISSET($key.'hour') || !GETPOSTISSET($key.'min')) { + continue; // The field was not submited to be edited + } } elseif ($object->fields[$key]['type'] == 'boolean') { if (!GETPOSTISSET($key)) { $object->$key = 0; // use 0 instead null if the field is defined as not null continue; } } else { - if (!GETPOSTISSET($key)) continue; // The field was not submited to be edited + if (!GETPOSTISSET($key)) { + continue; // The field was not submited to be edited + } } // Ignore special fields - if (in_array($key, array('rowid', 'entity', 'import_key'))) continue; + if (in_array($key, array('rowid', 'entity', 'import_key'))) { + continue; + } if (in_array($key, array('date_creation', 'tms', 'fk_user_creat', 'fk_user_modif'))) { - if (!in_array(abs($val['visible']), array(1, 3, 4))) continue; // Only 1 and 3 and 4 that are case to update + if (!in_array(abs($val['visible']), array(1, 3, 4))) { + continue; // Only 1 and 3 and 4 that are case to update + } } // Set value to update @@ -176,12 +192,15 @@ if ($action == 'update' && !empty($permissiontoadd)) } else { $value = GETPOST($key, 'alpha'); } - if (preg_match('/^integer:/i', $object->fields[$key]['type']) && $value == '-1') $value = ''; // This is an implicit foreign key field - if (!empty($object->fields[$key]['foreignkey']) && $value == '-1') $value = ''; // This is an explicit foreign key field + if (preg_match('/^integer:/i', $object->fields[$key]['type']) && $value == '-1') { + $value = ''; // This is an implicit foreign key field + } + if (!empty($object->fields[$key]['foreignkey']) && $value == '-1') { + $value = ''; // This is an explicit foreign key field + } $object->$key = $value; - if ($val['notnull'] > 0 && $object->$key == '' && is_null($val['default'])) - { + if ($val['notnull'] > 0 && $object->$key == '' && is_null($val['default'])) { $error++; setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv($val['label'])), null, 'errors'); } @@ -190,14 +209,14 @@ if ($action == 'update' && !empty($permissiontoadd)) // Fill array 'array_options' with data from add form if (!$error) { $ret = $extrafields->setOptionalsFromPost(null, $object, '@GETPOSTISSET'); - if ($ret < 0) $error++; + if ($ret < 0) { + $error++; + } } - if (!$error) - { + if (!$error) { $result = $object->update($user); - if ($result > 0) - { + if ($result > 0) { $action = 'view'; } else { // Creation KO @@ -210,8 +229,7 @@ if ($action == 'update' && !empty($permissiontoadd)) } // Action to update one extrafield -if ($action == "update_extras" && !empty($permissiontoadd)) -{ +if ($action == "update_extras" && !empty($permissiontoadd)) { $object->fetch(GETPOST('id', 'int')); $attributekey = GETPOST('attribute', 'alpha'); @@ -226,8 +244,7 @@ if ($action == "update_extras" && !empty($permissiontoadd)) } $result = $object->insertExtraFields(empty($triggermodname) ? '' : $triggermodname, $user); - if ($result > 0) - { + if ($result > 0) { setEventMessages($langs->trans('RecordSaved'), null, 'mesgs'); $action = 'view'; } else { @@ -237,46 +254,42 @@ if ($action == "update_extras" && !empty($permissiontoadd)) } // Action to delete -if ($action == 'confirm_delete' && !empty($permissiontodelete)) -{ - if (!($object->id > 0)) - { +if ($action == 'confirm_delete' && !empty($permissiontodelete)) { + if (!($object->id > 0)) { dol_print_error('', 'Error, object must be fetched before being deleted'); exit; } $result = $object->delete($user); - if ($result > 0) - { + if ($result > 0) { // Delete OK setEventMessages("RecordDeleted", null, 'mesgs'); header("Location: ".$backurlforlist); exit; } else { - if (!empty($object->errors)) setEventMessages(null, $object->errors, 'errors'); - else setEventMessages($object->error, null, 'errors'); + if (!empty($object->errors)) { + setEventMessages(null, $object->errors, 'errors'); + } else { + setEventMessages($object->error, null, 'errors'); + } } } // Remove a line -if ($action == 'confirm_deleteline' && $confirm == 'yes' && !empty($permissiontoadd)) -{ +if ($action == 'confirm_deleteline' && $confirm == 'yes' && !empty($permissiontoadd)) { if (method_exists($object, 'deleteline')) { $result = $object->deleteline($user, $lineid); // For backward compatibility } else { $result = $object->deleteLine($user, $lineid); } - if ($result > 0) - { + if ($result > 0) { // Define output language $outputlangs = $langs; $newlang = ''; - if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) - { + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) { $newlang = GETPOST('lang_id', 'aZ09'); } - if ($conf->global->MAIN_MULTILANGS && empty($newlang) && is_object($object->thirdparty)) - { + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && is_object($object->thirdparty)) { $newlang = $object->thirdparty->default_lang; } if (!empty($newlang)) { @@ -299,18 +312,20 @@ if ($action == 'confirm_deleteline' && $confirm == 'yes' && !empty($permissionto } // Action validate object -if ($action == 'confirm_validate' && $confirm == 'yes' && $permissiontoadd) -{ +if ($action == 'confirm_validate' && $confirm == 'yes' && $permissiontoadd) { $result = $object->validate($user); - if ($result >= 0) - { + if ($result >= 0) { // Define output language if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { if (method_exists($object, 'generateDocument')) { $outputlangs = $langs; $newlang = ''; - if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) $newlang = GETPOST('lang_id', 'aZ09'); - if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang; + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) { + $newlang = GETPOST('lang_id', 'aZ09'); + } + if ($conf->global->MAIN_MULTILANGS && empty($newlang)) { + $newlang = $object->thirdparty->default_lang; + } if (!empty($newlang)) { $outputlangs = new Translate("", $conf); $outputlangs->setDefaultLang($newlang); @@ -332,18 +347,20 @@ if ($action == 'confirm_validate' && $confirm == 'yes' && $permissiontoadd) } // Action close object -if ($action == 'confirm_close' && $confirm == 'yes' && $permissiontoadd) -{ +if ($action == 'confirm_close' && $confirm == 'yes' && $permissiontoadd) { $result = $object->cancel($user); - if ($result >= 0) - { + if ($result >= 0) { // Define output language if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { if (method_exists($object, 'generateDocument')) { $outputlangs = $langs; $newlang = ''; - if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) $newlang = GETPOST('lang_id', 'aZ09'); - if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang; + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) { + $newlang = GETPOST('lang_id', 'aZ09'); + } + if ($conf->global->MAIN_MULTILANGS && empty($newlang)) { + $newlang = $object->thirdparty->default_lang; + } if (!empty($newlang)) { $outputlangs = new Translate("", $conf); $outputlangs->setDefaultLang($newlang); @@ -360,11 +377,9 @@ if ($action == 'confirm_close' && $confirm == 'yes' && $permissiontoadd) } // Action setdraft object -if ($action == 'confirm_setdraft' && $confirm == 'yes' && $permissiontoadd) -{ +if ($action == 'confirm_setdraft' && $confirm == 'yes' && $permissiontoadd) { $result = $object->setDraft($user); - if ($result >= 0) - { + if ($result >= 0) { // Nothing else done } else { setEventMessages($object->error, $object->errors, 'errors'); @@ -372,18 +387,20 @@ if ($action == 'confirm_setdraft' && $confirm == 'yes' && $permissiontoadd) } // Action reopen object -if ($action == 'confirm_reopen' && $confirm == 'yes' && $permissiontoadd) -{ +if ($action == 'confirm_reopen' && $confirm == 'yes' && $permissiontoadd) { $result = $object->reopen($user); - if ($result >= 0) - { + if ($result >= 0) { // Define output language if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { if (method_exists($object, 'generateDocument')) { $outputlangs = $langs; $newlang = ''; - if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) $newlang = GETPOST('lang_id', 'aZ09'); - if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang; + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) { + $newlang = GETPOST('lang_id', 'aZ09'); + } + if ($conf->global->MAIN_MULTILANGS && empty($newlang)) { + $newlang = $object->thirdparty->default_lang; + } if (!empty($newlang)) { $outputlangs = new Translate("", $conf); $outputlangs->setDefaultLang($newlang); @@ -400,21 +417,21 @@ if ($action == 'confirm_reopen' && $confirm == 'yes' && $permissiontoadd) } // Action clone object -if ($action == 'confirm_clone' && $confirm == 'yes' && !empty($permissiontoadd)) -{ - if (1 == 0 && !GETPOST('clone_content') && !GETPOST('clone_receivers')) - { +if ($action == 'confirm_clone' && $confirm == 'yes' && !empty($permissiontoadd)) { + if (1 == 0 && !GETPOST('clone_content') && !GETPOST('clone_receivers')) { setEventMessages($langs->trans("NoCloneOptionsSpecified"), null, 'errors'); } else { $objectutil = dol_clone($object, 1); // To avoid to denaturate loaded object when setting some properties for clone or if createFromClone modifies the object. We use native clone to keep this->db valid. //$objectutil->date = dol_mktime(12, 0, 0, GETPOST('newdatemonth', 'int'), GETPOST('newdateday', 'int'), GETPOST('newdateyear', 'int')); // ... $result = $objectutil->createFromClone($user, (($object->id > 0) ? $object->id : $id)); - if (is_object($result) || $result > 0) - { + if (is_object($result) || $result > 0) { $newid = 0; - if (is_object($result)) $newid = $result->id; - else $newid = $result; + if (is_object($result)) { + $newid = $result->id; + } else { + $newid = $result; + } header("Location: ".$_SERVER['PHP_SELF'].'?id='.$newid); // Open record of new object exit; } else { diff --git a/htdocs/core/actions_builddoc.inc.php b/htdocs/core/actions_builddoc.inc.php index 4ae83829fa4..63cac253976 100644 --- a/htdocs/core/actions_builddoc.inc.php +++ b/htdocs/core/actions_builddoc.inc.php @@ -29,27 +29,26 @@ // $upload_dir must be defined (example $conf->projet->dir_output . "/";) // $hidedetails, $hidedesc, $hideref and $moreparams may have been set or not. -if (!empty($permissioncreate) && empty($permissiontoadd)) $permissiontoadd = $permissioncreate; // For backward compatibility +if (!empty($permissioncreate) && empty($permissiontoadd)) { + $permissiontoadd = $permissioncreate; // For backward compatibility +} // Build doc -if ($action == 'builddoc' && $permissiontoadd) -{ - if (is_numeric(GETPOST('model', 'alpha'))) - { +if ($action == 'builddoc' && $permissiontoadd) { + if (is_numeric(GETPOST('model', 'alpha'))) { $error = $langs->trans("ErrorFieldRequired", $langs->transnoentities("Model")); } else { - // Reload to get all modified line records and be ready for hooks + // Reload to get all modified line records and be ready for hooks $ret = $object->fetch($id); $ret = $object->fetch_thirdparty(); /*if (empty($object->id) || ! $object->id > 0) - { - dol_print_error('Object must have been loaded by a fetch'); - exit; - }*/ + { + dol_print_error('Object must have been loaded by a fetch'); + exit; + }*/ // Save last template used to generate document - if (GETPOST('model', 'alpha')) - { + if (GETPOST('model', 'alpha')) { $object->setDocModel($user, GETPOST('model', 'alpha')); } @@ -67,29 +66,40 @@ if ($action == 'builddoc' && $permissiontoadd) $outputlangs = $langs; $newlang = ''; - if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) $newlang = GETPOST('lang_id', 'aZ09'); - if ($conf->global->MAIN_MULTILANGS && empty($newlang) && isset($object->thirdparty->default_lang)) $newlang = $object->thirdparty->default_lang; // for proposal, order, invoice, ... - if ($conf->global->MAIN_MULTILANGS && empty($newlang) && isset($object->default_lang)) $newlang = $object->default_lang; // for thirdparty - if (!empty($newlang)) - { + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) { + $newlang = GETPOST('lang_id', 'aZ09'); + } + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && isset($object->thirdparty->default_lang)) { + $newlang = $object->thirdparty->default_lang; // for proposal, order, invoice, ... + } + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && isset($object->default_lang)) { + $newlang = $object->default_lang; // for thirdparty + } + if (!empty($newlang)) { $outputlangs = new Translate("", $conf); $outputlangs->setDefaultLang($newlang); } // To be sure vars is defined - if (empty($hidedetails)) $hidedetails = 0; - if (empty($hidedesc)) $hidedesc = 0; - if (empty($hideref)) $hideref = 0; - if (empty($moreparams)) $moreparams = null; + if (empty($hidedetails)) { + $hidedetails = 0; + } + if (empty($hidedesc)) { + $hidedesc = 0; + } + if (empty($hideref)) { + $hideref = 0; + } + if (empty($moreparams)) { + $moreparams = null; + } $result = $object->generateDocument($object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref, $moreparams); - if ($result <= 0) - { + if ($result <= 0) { setEventMessages($object->error, $object->errors, 'errors'); $action = ''; } else { - if (empty($donotredirect)) // This is set when include is done by bulk action "Bill Orders" - { + if (empty($donotredirect)) { // This is set when include is done by bulk action "Bill Orders" setEventMessages($langs->trans("FileGenerated"), null); $urltoredirect = $_SERVER['REQUEST_URI']; @@ -104,13 +114,11 @@ if ($action == 'builddoc' && $permissiontoadd) } // Delete file in doc form -if ($action == 'remove_file' && $permissiontoadd) -{ +if ($action == 'remove_file' && $permissiontoadd) { if (!empty($upload_dir)) { require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; - if (empty($object->id) || !$object->id > 0) - { + if (empty($object->id) || !$object->id > 0) { // Reload to get all modified line records and be ready for hooks $ret = $object->fetch($id); $ret = $object->fetch_thirdparty(); @@ -120,8 +128,11 @@ if ($action == 'remove_file' && $permissiontoadd) $filetodelete = GETPOST('file', 'alpha'); $file = $upload_dir.'/'.$filetodelete; $ret = dol_delete_file($file, 0, 0, 0, $object); - if ($ret) setEventMessages($langs->trans("FileWasRemoved", $filetodelete), null, 'mesgs'); - else setEventMessages($langs->trans("ErrorFailToDeleteFile", $filetodelete), null, 'errors'); + if ($ret) { + setEventMessages($langs->trans("FileWasRemoved", $filetodelete), null, 'mesgs'); + } else { + setEventMessages($langs->trans("ErrorFailToDeleteFile", $filetodelete), null, 'errors'); + } // Make a redirect to avoid to keep the remove_file into the url that create side effects $urltoredirect = $_SERVER['REQUEST_URI']; diff --git a/htdocs/core/actions_changeselectedfields.inc.php b/htdocs/core/actions_changeselectedfields.inc.php index 4daf53891cf..f0ead24e6b1 100644 --- a/htdocs/core/actions_changeselectedfields.inc.php +++ b/htdocs/core/actions_changeselectedfields.inc.php @@ -28,14 +28,16 @@ // $object must be defined (object is loaded in this file with fetch) // Save selection -if (GETPOST('formfilteraction', 'alphanohtml') == 'listafterchangingselectedfields') -{ +if (GETPOST('formfilteraction', 'alphanohtml') == 'listafterchangingselectedfields') { $tabparam = array(); $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage; - if (GETPOST("selectedfields")) $tabparam["MAIN_SELECTEDFIELDS_".$varpage] = GETPOST("selectedfields"); - else $tabparam["MAIN_SELECTEDFIELDS_".$varpage] = ''; + if (GETPOST("selectedfields")) { + $tabparam["MAIN_SELECTEDFIELDS_".$varpage] = GETPOST("selectedfields"); + } else { + $tabparam["MAIN_SELECTEDFIELDS_".$varpage] = ''; + } include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; diff --git a/htdocs/core/actions_comments.inc.php b/htdocs/core/actions_comments.inc.php index f590adee197..fc6bf11a115 100644 --- a/htdocs/core/actions_comments.inc.php +++ b/htdocs/core/actions_comments.inc.php @@ -33,19 +33,16 @@ $comment = new Comment($db); * Actions */ -if ($action == 'addcomment') -{ +if ($action == 'addcomment') { $description = GETPOST('comment_description', 'restricthtml'); - if (!empty($description)) - { + if (!empty($description)) { $comment->description = $description; $comment->datec = time(); $comment->fk_element = GETPOST('id', 'int'); $comment->element_type = GETPOST('comment_element_type', 'alpha'); $comment->fk_user_author = $user->id; $comment->entity = $conf->entity; - if ($comment->create($user) > 0) - { + if ($comment->create($user) > 0) { setEventMessages($langs->trans("CommentAdded"), null, 'mesgs'); header('Location: '.$varpage.'?id='.$id.($withproject ? '&withproject=1' : '')); exit; @@ -55,13 +52,10 @@ if ($action == 'addcomment') } } } -if ($action === 'updatecomment') -{ - if ($comment->fetch($idcomment) >= 0) - { +if ($action === 'updatecomment') { + if ($comment->fetch($idcomment) >= 0) { $comment->description = GETPOST('comment_description', 'restricthtml'); - if ($comment->update($user) > 0) - { + if ($comment->update($user) > 0) { setEventMessages($langs->trans("CommentAdded"), null, 'mesgs'); header('Location: '.$varpage.'?id='.$id.($withproject ? '&withproject=1#comment' : '')); exit; @@ -71,12 +65,9 @@ if ($action === 'updatecomment') } } } -if ($action == 'deletecomment') -{ - if ($comment->fetch($idcomment) >= 0) - { - if ($comment->delete($user) > 0) - { +if ($action == 'deletecomment') { + if ($comment->fetch($idcomment) >= 0) { + if ($comment->delete($user) > 0) { setEventMessages($langs->trans("CommentDeleted"), null, 'mesgs'); header('Location: '.$varpage.'?id='.$id.($withproject ? '&withproject=1' : '')); exit; diff --git a/htdocs/core/actions_dellink.inc.php b/htdocs/core/actions_dellink.inc.php index 2dd2588ca48..a7ac035506f 100644 --- a/htdocs/core/actions_dellink.inc.php +++ b/htdocs/core/actions_dellink.inc.php @@ -30,16 +30,16 @@ $dellinkid = GETPOST('dellinkid', 'int'); $addlinkid = GETPOST('idtolinkto', 'int'); // Link invoice to order -if ($action == 'addlink' && !empty($permissiondellink) && !GETPOST('cancel', 'alpha') && $id > 0 && $addlinkid > 0) -{ +if ($action == 'addlink' && !empty($permissiondellink) && !GETPOST('cancel', 'alpha') && $id > 0 && $addlinkid > 0) { $object->fetch($id); $object->fetch_thirdparty(); $result = $object->add_object_linked(GETPOST('addlink', 'alpha'), $addlinkid); } // Delete link -if ($action == 'dellink' && !empty($permissiondellink) && !GETPOST('cancel', 'alpha') && $dellinkid > 0) -{ +if ($action == 'dellink' && !empty($permissiondellink) && !GETPOST('cancel', 'alpha') && $dellinkid > 0) { $result = $object->deleteObjectLinked(0, '', 0, '', $dellinkid); - if ($result < 0) setEventMessages($object->error, $object->errors, 'errors'); + if ($result < 0) { + setEventMessages($object->error, $object->errors, 'errors'); + } } diff --git a/htdocs/core/actions_extrafields.inc.php b/htdocs/core/actions_extrafields.inc.php index 7ba4d7d64b9..b03c2c3d192 100644 --- a/htdocs/core/actions_extrafields.inc.php +++ b/htdocs/core/actions_extrafields.inc.php @@ -31,91 +31,85 @@ $extrasize = GETPOST('size', 'intcomma'); $type = GETPOST('type', 'alpha'); $param = GETPOST('param', 'alpha'); -if ($type == 'double' && strpos($extrasize, ',') === false) $extrasize = '24,8'; -if ($type == 'date') $extrasize = ''; -if ($type == 'datetime') $extrasize = ''; -if ($type == 'select') $extrasize = ''; +if ($type == 'double' && strpos($extrasize, ',') === false) { + $extrasize = '24,8'; +} +if ($type == 'date') { + $extrasize = ''; +} +if ($type == 'datetime') { + $extrasize = ''; +} +if ($type == 'select') { + $extrasize = ''; +} // Add attribute -if ($action == 'add') -{ - if (GETPOST("button") != $langs->trans("Cancel")) - { +if ($action == 'add') { + if (GETPOST("button") != $langs->trans("Cancel")) { // Check values - if (!$type) - { + if (!$type) { $error++; $langs->load("errors"); $mesg[] = $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Type")); $action = 'create'; } - if ($type == 'varchar' && $extrasize <= 0) - { + if ($type == 'varchar' && $extrasize <= 0) { $error++; $langs->load("errors"); $mesg[] = $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Size")); $action = 'edit'; } - if ($type == 'varchar' && $extrasize > $maxsizestring) - { + if ($type == 'varchar' && $extrasize > $maxsizestring) { $error++; $langs->load("errors"); $mesg[] = $langs->trans("ErrorSizeTooLongForVarcharType", $maxsizestring); $action = 'create'; } - if ($type == 'int' && $extrasize > $maxsizeint) - { + if ($type == 'int' && $extrasize > $maxsizeint) { $error++; $langs->load("errors"); $mesg[] = $langs->trans("ErrorSizeTooLongForIntType", $maxsizeint); $action = 'create'; } - if ($type == 'select' && !$param) - { + if ($type == 'select' && !$param) { $error++; $langs->load("errors"); $mesg[] = $langs->trans("ErrorNoValueForSelectType"); $action = 'create'; } - if ($type == 'sellist' && !$param) - { + if ($type == 'sellist' && !$param) { $error++; $langs->load("errors"); $mesg[] = $langs->trans("ErrorNoValueForSelectListType"); $action = 'create'; } - if ($type == 'checkbox' && !$param) - { + if ($type == 'checkbox' && !$param) { $error++; $langs->load("errors"); $mesg[] = $langs->trans("ErrorNoValueForCheckBoxType"); $action = 'create'; } - if ($type == 'link' && !$param) - { + if ($type == 'link' && !$param) { $error++; $langs->load("errors"); $mesg[] = $langs->trans("ErrorNoValueForLinkType"); $action = 'create'; } - if ($type == 'radio' && !$param) - { + if ($type == 'radio' && !$param) { $error++; $langs->load("errors"); $mesg[] = $langs->trans("ErrorNoValueForRadioType"); $action = 'create'; } - if ((($type == 'radio') || ($type == 'checkbox')) && $param) - { + if ((($type == 'radio') || ($type == 'checkbox')) && $param) { // Construct array for parameter (value of select list) $parameters = $param; $parameters_array = explode("\r\n", $parameters); - foreach ($parameters_array as $param_ligne) - { + foreach ($parameters_array as $param_ligne) { if (!empty($param_ligne)) { - if (preg_match_all('/,/', $param_ligne, $matches)) - { + if (preg_match_all('/,/', $param_ligne, $matches)) { if (count($matches[0]) > 1) { $error++; $langs->load("errors"); @@ -160,14 +154,12 @@ if ($action == 'add') $parameters_array = explode("\r\n", $parameters); //In sellist we have only one line and it can have come to do SQL expression if ($type == 'sellist' || $type == 'chkbxlst') { - foreach ($parameters_array as $param_ligne) - { + foreach ($parameters_array as $param_ligne) { $params['options'] = array($parameters=>null); } } else { // Else it's separated key/value and coma list - foreach ($parameters_array as $param_ligne) - { + foreach ($parameters_array as $param_ligne) { list($key, $value) = explode(',', $param_ligne); $params['options'][$key] = $value; } @@ -175,7 +167,9 @@ if ($action == 'add') // Visibility: -1=not visible by default in list, 1=visible, 0=hidden $visibility = GETPOST('list', 'alpha'); - if ($type == 'separate') $visibility = 3; + if ($type == 'separate') { + $visibility = 3; + } $result = $extrafields->addExtraField( GETPOST('attrname', 'aZ09'), @@ -199,8 +193,7 @@ if ($action == 'add') (GETPOST('totalizable', 'alpha') ? 1 : 0), GETPOST('printable', 'alpha') ); - if ($result > 0) - { + if ($result > 0) { setEventMessages($langs->trans('SetupSaved'), null, 'mesgs'); header("Location: ".$_SERVER["PHP_SELF"]); exit; @@ -223,77 +216,64 @@ if ($action == 'add') } // Rename field -if ($action == 'update') -{ - if (GETPOST("button") != $langs->trans("Cancel")) - { +if ($action == 'update') { + if (GETPOST("button") != $langs->trans("Cancel")) { // Check values - if (!$type) - { + if (!$type) { $error++; $langs->load("errors"); $mesg[] = $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Type")); $action = 'edit'; } - if ($type == 'varchar' && $extrasize <= 0) - { + if ($type == 'varchar' && $extrasize <= 0) { $error++; $langs->load("errors"); $mesg[] = $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Size")); $action = 'edit'; } - if ($type == 'varchar' && $extrasize > $maxsizestring) - { + if ($type == 'varchar' && $extrasize > $maxsizestring) { $error++; $langs->load("errors"); $mesg[] = $langs->trans("ErrorSizeTooLongForVarcharType", $maxsizestring); $action = 'edit'; } - if ($type == 'int' && $extrasize > $maxsizeint) - { + if ($type == 'int' && $extrasize > $maxsizeint) { $error++; $langs->load("errors"); $mesg[] = $langs->trans("ErrorSizeTooLongForIntType", $maxsizeint); $action = 'edit'; } - if ($type == 'select' && !$param) - { + if ($type == 'select' && !$param) { $error++; $langs->load("errors"); $mesg[] = $langs->trans("ErrorNoValueForSelectType"); $action = 'edit'; } - if ($type == 'sellist' && !$param) - { + if ($type == 'sellist' && !$param) { $error++; $langs->load("errors"); $mesg[] = $langs->trans("ErrorNoValueForSelectListType"); $action = 'edit'; } - if ($type == 'checkbox' && !$param) - { + if ($type == 'checkbox' && !$param) { $error++; $langs->load("errors"); $mesg[] = $langs->trans("ErrorNoValueForCheckBoxType"); $action = 'edit'; } - if ($type == 'radio' && !$param) - { + if ($type == 'radio' && !$param) { $error++; $langs->load("errors"); $mesg[] = $langs->trans("ErrorNoValueForRadioType"); $action = 'edit'; } - if ((($type == 'radio') || ($type == 'checkbox')) && $param) - { + if ((($type == 'radio') || ($type == 'checkbox')) && $param) { // Construct array for parameter (value of select list) $parameters = $param; $parameters_array = explode("\r\n", $parameters); - foreach ($parameters_array as $param_ligne) - { + foreach ($parameters_array as $param_ligne) { if (!empty($param_ligne)) { - if (preg_match_all('/,/', $param_ligne, $matches)) - { + if (preg_match_all('/,/', $param_ligne, $matches)) { if (count($matches[0]) > 1) { $error++; $langs->load("errors"); @@ -329,24 +309,20 @@ if ($action == 'update') } } - if (!$error) - { - if (GETPOSTISSET("attrname") && preg_match("/^\w[a-zA-Z0-9-_]*$/", GETPOST('attrname', 'aZ09')) && !is_numeric(GETPOST('attrname', 'aZ09'))) - { + if (!$error) { + if (GETPOSTISSET("attrname") && preg_match("/^\w[a-zA-Z0-9-_]*$/", GETPOST('attrname', 'aZ09')) && !is_numeric(GETPOST('attrname', 'aZ09'))) { $pos = GETPOST('pos', 'int'); // Construct array for parameter (value of select list) $parameters = $param; $parameters_array = explode("\r\n", $parameters); //In sellist we have only one line and it can have come to do SQL expression if ($type == 'sellist' || $type == 'chkbxlst') { - foreach ($parameters_array as $param_ligne) - { + foreach ($parameters_array as $param_ligne) { $params['options'] = array($parameters=>null); } } else { //Esle it's separated key/value and coma list - foreach ($parameters_array as $param_ligne) - { + foreach ($parameters_array as $param_ligne) { list($key, $value) = explode(',', $param_ligne); $params['options'][$key] = $value; } @@ -354,7 +330,9 @@ if ($action == 'update') // Visibility: -1=not visible by default in list, 1=visible, 0=hidden $visibility = GETPOST('list', 'alpha'); - if ($type == 'separate') $visibility = 3; + if ($type == 'separate') { + $visibility = 3; + } // Example: is_object($object) ? ($object->id < 10 ? round($object->id / 2, 2) : (2 * $user->id) * (int) substr($mysoc->zip, 1, 2)) : 'objnotdefined' $computedvalue = GETPOST('computed_value', 'nohtml'); @@ -409,7 +387,9 @@ if ($action == 'delete') { if ($result >= 0) { header("Location: ".$_SERVER["PHP_SELF"]); exit; - } else $mesg = $extrafields->error; + } else { + $mesg = $extrafields->error; + } } else { $error++; $langs->load("errors"); diff --git a/htdocs/core/actions_fetchobject.inc.php b/htdocs/core/actions_fetchobject.inc.php index c881b335f18..3ca797a9bb3 100644 --- a/htdocs/core/actions_fetchobject.inc.php +++ b/htdocs/core/actions_fetchobject.inc.php @@ -28,20 +28,15 @@ // $cancel must be defined // $id or $ref must be defined (object is loaded in this file with fetch) -if (($id > 0 || (!empty($ref) && !in_array($action, array('create', 'createtask', 'add')))) && (empty($cancel) || $id > 0)) -{ - if (($id > 0 && is_numeric($id)) || !empty($ref)) // To discard case when id is list of ids like '1,2,3...' - { +if (($id > 0 || (!empty($ref) && !in_array($action, array('create', 'createtask', 'add')))) && (empty($cancel) || $id > 0)) { + if (($id > 0 && is_numeric($id)) || !empty($ref)) { // To discard case when id is list of ids like '1,2,3...' $ret = $object->fetch($id, $ref); - if ($ret > 0) - { + if ($ret > 0) { $object->fetch_thirdparty(); $id = $object->id; } else { - if (empty($object->error) && !count($object->errors)) - { - if ($ret < 0) // if $ret == 0, it means not found. - { + if (empty($object->error) && !count($object->errors)) { + if ($ret < 0) { // if $ret == 0, it means not found. setEventMessages('Fetch on object (type '.get_class($object).') return an error without filling $object->error nor $object->errors', null, 'errors'); } } else { diff --git a/htdocs/core/actions_lineupdown.inc.php b/htdocs/core/actions_lineupdown.inc.php index e5507eeafc0..5aee952292b 100644 --- a/htdocs/core/actions_lineupdown.inc.php +++ b/htdocs/core/actions_lineupdown.inc.php @@ -28,15 +28,18 @@ // $langs must be defined // $hidedetails, $hidedesc, $hideref must de defined -if ($action == 'up' && $permissiontoedit) -{ +if ($action == 'up' && $permissiontoedit) { $object->line_up(GETPOST('rowid')); // Define output language $outputlangs = $langs; $newlang = ''; - if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) $newlang = GETPOST('lang_id', 'aZ09'); - if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang; + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) { + $newlang = GETPOST('lang_id', 'aZ09'); + } + if ($conf->global->MAIN_MULTILANGS && empty($newlang)) { + $newlang = $object->thirdparty->default_lang; + } if (!empty($newlang)) { $outputlangs = new Translate("", $conf); $outputlangs->setDefaultLang($newlang); @@ -50,15 +53,18 @@ if ($action == 'up' && $permissiontoedit) exit(); } -if ($action == 'down' && $permissiontoedit) -{ +if ($action == 'down' && $permissiontoedit) { $object->line_down(GETPOST('rowid')); // Define output language $outputlangs = $langs; $newlang = ''; - if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) $newlang = GETPOST('lang_id', 'aZ09'); - if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang; + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) { + $newlang = GETPOST('lang_id', 'aZ09'); + } + if ($conf->global->MAIN_MULTILANGS && empty($newlang)) { + $newlang = $object->thirdparty->default_lang; + } if (!empty($newlang)) { $outputlangs = new Translate("", $conf); $outputlangs->setDefaultLang($newlang); diff --git a/htdocs/core/actions_linkedfiles.inc.php b/htdocs/core/actions_linkedfiles.inc.php index b0671bbf555..af60583118d 100644 --- a/htdocs/core/actions_linkedfiles.inc.php +++ b/htdocs/core/actions_linkedfiles.inc.php @@ -27,17 +27,16 @@ // Submit file/link -if (GETPOST('sendit', 'alpha') && !empty($conf->global->MAIN_UPLOAD_DOC)) -{ - if (!empty($_FILES)) - { - if (is_array($_FILES['userfile']['tmp_name'])) $userfiles = $_FILES['userfile']['tmp_name']; - else $userfiles = array($_FILES['userfile']['tmp_name']); +if (GETPOST('sendit', 'alpha') && !empty($conf->global->MAIN_UPLOAD_DOC)) { + if (!empty($_FILES)) { + if (is_array($_FILES['userfile']['tmp_name'])) { + $userfiles = $_FILES['userfile']['tmp_name']; + } else { + $userfiles = array($_FILES['userfile']['tmp_name']); + } - foreach ($userfiles as $key => $userfile) - { - if (empty($_FILES['userfile']['tmp_name'][$key])) - { + foreach ($userfiles as $key => $userfile) { + if (empty($_FILES['userfile']['tmp_name'][$key])) { $error++; if ($_FILES['userfile']['error'][$key] == 1 || $_FILES['userfile']['error'][$key] == 2) { setEventMessages($langs->trans('ErrorFileSizeTooLarge'), null, 'errors'); @@ -47,27 +46,24 @@ if (GETPOST('sendit', 'alpha') && !empty($conf->global->MAIN_UPLOAD_DOC)) } } - if (!$error) - { + if (!$error) { // Define if we have to generate thumbs or not $generatethumbs = 1; - if (GETPOST('section_dir', 'alpha')) $generatethumbs = 0; + if (GETPOST('section_dir', 'alpha')) { + $generatethumbs = 0; + } $allowoverwrite = (GETPOST('overwritefile', 'int') ? 1 : 0); - if (!empty($upload_dirold) && !empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO)) - { + if (!empty($upload_dirold) && !empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO)) { $result = dol_add_file_process($upload_dirold, $allowoverwrite, 1, 'userfile', GETPOST('savingdocmask', 'alpha'), null, '', $generatethumbs, $object); - } elseif (!empty($upload_dir)) - { + } elseif (!empty($upload_dir)) { $result = dol_add_file_process($upload_dir, $allowoverwrite, 1, 'userfile', GETPOST('savingdocmask', 'alpha'), null, '', $generatethumbs, $object); } } } -} elseif (GETPOST('linkit', 'restricthtml') && !empty($conf->global->MAIN_UPLOAD_DOC)) -{ +} elseif (GETPOST('linkit', 'restricthtml') && !empty($conf->global->MAIN_UPLOAD_DOC)) { $link = GETPOST('link', 'alpha'); - if ($link) - { + if ($link) { if (substr($link, 0, 7) != 'http://' && substr($link, 0, 8) != 'https://' && substr($link, 0, 7) != 'file://') { $link = 'http://'.$link; } @@ -77,17 +73,18 @@ if (GETPOST('sendit', 'alpha') && !empty($conf->global->MAIN_UPLOAD_DOC)) // Delete file/link -if ($action == 'confirm_deletefile' && $confirm == 'yes') -{ +if ($action == 'confirm_deletefile' && $confirm == 'yes') { $urlfile = GETPOST('urlfile', 'alpha', 0, null, null, 1); // Do not use urldecode here ($_GET and $_REQUEST are already decoded by PHP). if (GETPOST('section', 'alpha')) { // For a delete from the ECM module, upload_dir is ECM root dir and urlfile contains relative path from upload_dir $file = $upload_dir.(preg_match('/\/$/', $upload_dir) ? '' : '/').$urlfile; } else // For a delete from the file manager into another module, or from documents pages, upload_dir contains already path to file from module dir, so we clean path into urlfile. { - $urlfile = basename($urlfile); - $file = $upload_dir.(preg_match('/\/$/', $upload_dir) ? '' : '/').$urlfile; - if (!empty($upload_dirold)) $fileold = $upload_dirold."/".$urlfile; + $urlfile = basename($urlfile); + $file = $upload_dir.(preg_match('/\/$/', $upload_dir) ? '' : '/').$urlfile; + if (!empty($upload_dirold)) { + $fileold = $upload_dirold."/".$urlfile; + } } $linkid = GETPOST('linkid', 'int'); @@ -97,21 +94,20 @@ if ($action == 'confirm_deletefile' && $confirm == 'yes') $dirthumb = $dir.'/thumbs/'; // Chemin du dossier contenant la vignette (if file is an image) $ret = dol_delete_file($file, 0, 0, 0, (is_object($object) ? $object : null)); - if (!empty($fileold)) dol_delete_file($fileold, 0, 0, 0, (is_object($object) ? $object : null)); // Delete file using old path + if (!empty($fileold)) { + dol_delete_file($fileold, 0, 0, 0, (is_object($object) ? $object : null)); // Delete file using old path + } // If it exists, remove thumb. $regs = array(); - if (preg_match('/(\.jpg|\.jpeg|\.bmp|\.gif|\.png|\.tiff)$/i', $file, $regs)) - { + if (preg_match('/(\.jpg|\.jpeg|\.bmp|\.gif|\.png|\.tiff)$/i', $file, $regs)) { $photo_vignette = basename(preg_replace('/'.$regs[0].'/i', '', $file).'_small'.$regs[0]); - if (file_exists(dol_osencode($dirthumb.$photo_vignette))) - { + if (file_exists(dol_osencode($dirthumb.$photo_vignette))) { dol_delete_file($dirthumb.$photo_vignette); } $photo_vignette = basename(preg_replace('/'.$regs[0].'/i', '', $file).'_mini'.$regs[0]); - if (file_exists(dol_osencode($dirthumb.$photo_vignette))) - { + if (file_exists(dol_osencode($dirthumb.$photo_vignette))) { dol_delete_file($dirthumb.$photo_vignette); } } @@ -149,33 +145,27 @@ if ($action == 'confirm_deletefile' && $confirm == 'yes') exit; } } -} elseif ($action == 'confirm_updateline' && GETPOST('save', 'alpha') && GETPOST('link', 'alpha')) -{ +} elseif ($action == 'confirm_updateline' && GETPOST('save', 'alpha') && GETPOST('link', 'alpha')) { require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php'; $langs->load('link'); $link = new Link($db); $f = $link->fetch(GETPOST('linkid', 'int')); - if ($f) - { + if ($f) { $link->url = GETPOST('link', 'alpha'); - if (substr($link->url, 0, 7) != 'http://' && substr($link->url, 0, 8) != 'https://' && substr($link->url, 0, 7) != 'file://') - { + if (substr($link->url, 0, 7) != 'http://' && substr($link->url, 0, 8) != 'https://' && substr($link->url, 0, 7) != 'file://') { $link->url = 'http://'.$link->url; } $link->label = GETPOST('label', 'alphanohtml'); $res = $link->update($user); - if (!$res) - { + if (!$res) { setEventMessages($langs->trans("ErrorFailedToUpdateLink", $link->label), null, 'mesgs'); } } else { //error fetching } -} elseif ($action == 'renamefile' && GETPOST('renamefilesave', 'alpha')) -{ +} elseif ($action == 'renamefile' && GETPOST('renamefilesave', 'alpha')) { // For documents pages, upload_dir contains already path to file from module dir, so we clean path into urlfile. - if (!empty($upload_dir)) - { + if (!empty($upload_dir)) { $filenamefrom = dol_sanitizeFileName(GETPOST('renamefilefrom', 'alpha'), '_', 0); // Do not remove accents $filenameto = dol_sanitizeFileName(GETPOST('renamefileto', 'alpha'), '_', 0); // Do not remove accents @@ -183,24 +173,23 @@ if ($action == 'confirm_deletefile' && $confirm == 'yes') // this function is also applied when we upload and when we make try to download file (by the GETPOST(filename, 'alphanohtml') call). $filenameto = dol_string_nohtmltag($filenameto); - if ($filenamefrom != $filenameto) - { + if ($filenamefrom != $filenameto) { // Security: // Disallow file with some extensions. We rename them. // Because if we put the documents directory into a directory inside web root (very bad), this allows to execute on demand arbitrary code. - if (isAFileWithExecutableContent($filenameto) && empty($conf->global->MAIN_DOCUMENT_IS_OUTSIDE_WEBROOT_SO_NOEXE_NOT_REQUIRED)) - { + if (isAFileWithExecutableContent($filenameto) && empty($conf->global->MAIN_DOCUMENT_IS_OUTSIDE_WEBROOT_SO_NOEXE_NOT_REQUIRED)) { // $upload_dir ends with a slash, so be must be sure the medias dir to compare to ends with slash too. $publicmediasdirwithslash = $conf->medias->multidir_output[$conf->entity]; - if (!preg_match('/\/$/', $publicmediasdirwithslash)) $publicmediasdirwithslash .= '/'; + if (!preg_match('/\/$/', $publicmediasdirwithslash)) { + $publicmediasdirwithslash .= '/'; + } if (strpos($upload_dir, $publicmediasdirwithslash) !== 0) { // We never add .noexe on files into media directory $filenameto .= '.noexe'; } } - if ($filenamefrom && $filenameto) - { + if ($filenamefrom && $filenameto) { $srcpath = $upload_dir.'/'.$filenamefrom; $destpath = $upload_dir.'/'.$filenameto; @@ -208,26 +197,24 @@ if ($action == 'confirm_deletefile' && $confirm == 'yes') $parameters = array('filenamefrom' => $filenamefrom, 'filenameto' => $filenameto, 'upload_dir' => $upload_dir); $reshook = $hookmanager->executeHooks('renameUploadedFile', $parameters, $object); - if (empty($reshook)) - { + if (empty($reshook)) { if (preg_match('/^\./', $filenameto)) { $langs->load("errors"); // lang must be loaded because we can't rely on loading during output, we need var substitution to be done now. setEventMessages($langs->trans("ErrorFilenameCantStartWithDot", $filenameto), null, 'errors'); } elseif (!file_exists($destpath)) { $result = dol_move($srcpath, $destpath); - if ($result) - { + if ($result) { // Define if we have to generate thumbs or not $generatethumbs = 1; // When we rename a file from the file manager in ecm, we must not regenerate thumbs (not a problem, we do pass here) // When we rename a file from the website module, we must not regenerate thumbs (module = medias in such a case) // but when we rename from a tab "Documents", we must regenerate thumbs - if (GETPOST('modulepart') == 'medias') $generatethumbs = 0; + if (GETPOST('modulepart') == 'medias') { + $generatethumbs = 0; + } - if ($generatethumbs) - { - if ($object->id) - { + if ($generatethumbs) { + if ($object->id) { $object->addThumbs($destpath); } @@ -250,19 +237,15 @@ if ($action == 'confirm_deletefile' && $confirm == 'yes') } // Update properties in ECM table - if (GETPOST('ecmfileid', 'int') > 0) - { + if (GETPOST('ecmfileid', 'int') > 0) { $shareenabled = GETPOST('shareenabled', 'alpha'); include_once DOL_DOCUMENT_ROOT.'/ecm/class/ecmfiles.class.php'; $ecmfile = new EcmFiles($db); $result = $ecmfile->fetch(GETPOST('ecmfileid', 'int')); - if ($result > 0) - { - if ($shareenabled) - { - if (empty($ecmfile->share)) - { + if ($result > 0) { + if ($shareenabled) { + if (empty($ecmfile->share)) { require_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php'; $ecmfile->share = getRandomPassword(true); } @@ -270,8 +253,7 @@ if ($action == 'confirm_deletefile' && $confirm == 'yes') $ecmfile->share = ''; } $result = $ecmfile->update($user); - if ($result < 0) - { + if ($result < 0) { setEventMessages($ecmfile->error, $ecmfile->errors, 'warnings'); } } diff --git a/htdocs/core/actions_massactions.inc.php b/htdocs/core/actions_massactions.inc.php index 892cb8ae4e0..057443d09b4 100644 --- a/htdocs/core/actions_massactions.inc.php +++ b/htdocs/core/actions_massactions.inc.php @@ -37,37 +37,38 @@ // Protection -if (empty($objectclass) || empty($uploaddir)) -{ +if (empty($objectclass) || empty($uploaddir)) { dol_print_error(null, 'include of actions_massactions.inc.php is done but var $objectclass or $uploaddir was not defined'); exit; } // For backward compatibility -if (!empty($permtoread) && empty($permissiontoread)) $permissiontoread = $permtoread; -if (!empty($permtocreate) && empty($permissiontoadd)) $permissiontoadd = $permtocreate; -if (!empty($permtodelete) && empty($permissiontodelete)) $permissiontodelete = $permtodelete; +if (!empty($permtoread) && empty($permissiontoread)) { + $permissiontoread = $permtoread; +} +if (!empty($permtocreate) && empty($permissiontoadd)) { + $permissiontoadd = $permtocreate; +} +if (!empty($permtodelete) && empty($permissiontodelete)) { + $permissiontodelete = $permtodelete; +} // Mass actions. Controls on number of lines checked. $maxformassaction = (empty($conf->global->MAIN_LIMIT_FOR_MASS_ACTIONS) ? 1000 : $conf->global->MAIN_LIMIT_FOR_MASS_ACTIONS); -if (!empty($massaction) && is_array($toselect) && count($toselect) < 1) -{ +if (!empty($massaction) && is_array($toselect) && count($toselect) < 1) { $error++; setEventMessages($langs->trans("NoRecordSelected"), null, "warnings"); } -if (!$error && is_array($toselect) && count($toselect) > $maxformassaction) -{ +if (!$error && is_array($toselect) && count($toselect) > $maxformassaction) { setEventMessages($langs->trans('TooManyRecordForMassAction', $maxformassaction), null, 'errors'); $error++; } -if (!$error && $massaction == 'confirm_presend' && !GETPOST('sendmail')) // If we do not choose button send (for example when we change template or limit), we must not send email, but keep on send email form -{ +if (!$error && $massaction == 'confirm_presend' && !GETPOST('sendmail')) { // If we do not choose button send (for example when we change template or limit), we must not send email, but keep on send email form $massaction = 'presend'; } -if (!$error && $massaction == 'confirm_presend') -{ +if (!$error && $massaction == 'confirm_presend') { $resaction = ''; $nbsent = 0; $nbignored = 0; @@ -82,27 +83,36 @@ if (!$error && $massaction == 'confirm_presend') $attachedfilesThirdpartyObj = array(); $oneemailperrecipient = (GETPOST('oneemailperrecipient') == 'on' ? 1 : 0); - if (!$error) - { + if (!$error) { $thirdparty = new Societe($db); $objecttmp = new $objectclass($db); - if ($objecttmp->element == 'expensereport') $thirdparty = new User($db); - if ($objecttmp->element == 'holiday') $thirdparty = new User($db); + if ($objecttmp->element == 'expensereport') { + $thirdparty = new User($db); + } + if ($objecttmp->element == 'holiday') { + $thirdparty = new User($db); + } - foreach ($toselect as $toselectid) - { + foreach ($toselect as $toselectid) { $objecttmp = new $objectclass($db); // we must create new instance because instance is saved into $listofobjectref array for future use $result = $objecttmp->fetch($toselectid); - if ($result > 0) - { + if ($result > 0) { $listofobjectid[$toselectid] = $toselectid; $thirdpartyid = ($objecttmp->fk_soc ? $objecttmp->fk_soc : $objecttmp->socid); - if ($objecttmp->element == 'societe') $thirdpartyid = $objecttmp->id; - if ($objecttmp->element == 'expensereport') $thirdpartyid = $objecttmp->fk_user_author; - if ($objecttmp->element == 'holiday') $thirdpartyid = $objecttmp->fk_user; - if (empty($thirdpartyid)) $thirdpartyid = 0; + if ($objecttmp->element == 'societe') { + $thirdpartyid = $objecttmp->id; + } + if ($objecttmp->element == 'expensereport') { + $thirdpartyid = $objecttmp->fk_user_author; + } + if ($objecttmp->element == 'holiday') { + $thirdpartyid = $objecttmp->fk_user; + } + if (empty($thirdpartyid)) { + $thirdpartyid = 0; + } if ($objectclass == 'Facture') { $tmparraycontact = array(); @@ -121,41 +131,37 @@ if (!$error && $massaction == 'confirm_presend') } // Check mandatory parameters - if (GETPOST('fromtype', 'alpha') === 'user' && empty($user->email)) - { + if (GETPOST('fromtype', 'alpha') === 'user' && empty($user->email)) { $error++; setEventMessages($langs->trans("NoSenderEmailDefined"), null, 'warnings'); $massaction = 'presend'; } $receiver = $_POST['receiver']; - if (!is_array($receiver)) - { - if (empty($receiver) || $receiver == '-1') $receiver = array(); - else $receiver = array($receiver); + if (!is_array($receiver)) { + if (empty($receiver) || $receiver == '-1') { + $receiver = array(); + } else { + $receiver = array($receiver); + } } - if (!trim($_POST['sendto']) && count($receiver) == 0 && count($listofobjectthirdparties) == 1) // if only one recipient, receiver is mandatory - { - $error++; - setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Recipient")), null, 'warnings'); - $massaction = 'presend'; + if (!trim($_POST['sendto']) && count($receiver) == 0 && count($listofobjectthirdparties) == 1) { // if only one recipient, receiver is mandatory + $error++; + setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Recipient")), null, 'warnings'); + $massaction = 'presend'; } - if (!GETPOST('subject', 'restricthtml')) - { + if (!GETPOST('subject', 'restricthtml')) { $error++; setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("MailTopic")), null, 'warnings'); $massaction = 'presend'; } // Loop on each recipient/thirdparty - if (!$error) - { - foreach ($listofobjectthirdparties as $thirdpartyid) - { + if (!$error) { + foreach ($listofobjectthirdparties as $thirdpartyid) { $result = $thirdparty->fetch($thirdpartyid); - if ($result < 0) - { + if ($result < 0) { dol_print_error($db); exit; } @@ -167,21 +173,16 @@ if (!$error && $massaction == 'confirm_presend') // Define $sendto $tmparray = array(); - if (trim($_POST['sendto'])) - { + if (trim($_POST['sendto'])) { // Recipients are provided into free text $tmparray[] = trim($_POST['sendto']); } - if (count($receiver) > 0) - { - foreach ($receiver as $key=>$val) - { + if (count($receiver) > 0) { + foreach ($receiver as $key => $val) { // Recipient was provided from combo list - if ($val == 'thirdparty') // Id of third party or user - { + if ($val == 'thirdparty') { // Id of third party or user $tmparray[] = $thirdparty->name.' <'.$thirdparty->email.'>'; - } elseif ($val && method_exists($thirdparty, 'contact_get_property')) // Id of contact - { + } elseif ($val && method_exists($thirdparty, 'contact_get_property')) { // Id of contact $tmparray[] = $thirdparty->contact_get_property((int) $val, 'email'); $sendtoid[] = $val; } @@ -191,26 +192,23 @@ if (!$error && $massaction == 'confirm_presend') // Define $sendtocc $receivercc = $_POST['receivercc']; - if (!is_array($receivercc)) - { - if ($receivercc == '-1') $receivercc = array(); - else $receivercc = array($receivercc); + if (!is_array($receivercc)) { + if ($receivercc == '-1') { + $receivercc = array(); + } else { + $receivercc = array($receivercc); + } } $tmparray = array(); - if (trim($_POST['sendtocc'])) - { + if (trim($_POST['sendtocc'])) { $tmparray[] = trim($_POST['sendtocc']); } - if (count($receivercc) > 0) - { - foreach ($receivercc as $key=>$val) - { + if (count($receivercc) > 0) { + foreach ($receivercc as $key => $val) { // Recipient was provided from combo list - if ($val == 'thirdparty') // Id of third party - { + if ($val == 'thirdparty') { // Id of third party $tmparray[] = $thirdparty->name.' <'.$thirdparty->email.'>'; - } elseif ($val) // Id du contact - { + } elseif ($val) { // Id du contact $tmparray[] = $thirdparty->contact_get_property((int) $val, 'email'); //$sendtoid[] = $val; TODO Add also id of contact in CC ? } @@ -223,25 +221,21 @@ if (!$error && $massaction == 'confirm_presend') $listofqualifiedref = array(); $thirdpartywithoutemail = array(); - foreach ($listofobjectref[$thirdpartyid] as $objectid => $objectobj) - { + foreach ($listofobjectref[$thirdpartyid] as $objectid => $objectobj) { //var_dump($thirdpartyid.' - '.$objectid.' - '.$objectobj->statut); - if ($objectclass == 'Propal' && $objectobj->statut == Propal::STATUS_DRAFT) - { + if ($objectclass == 'Propal' && $objectobj->statut == Propal::STATUS_DRAFT) { $langs->load("errors"); $nbignored++; $resaction .= '
'.$langs->trans('ErrorOnlyProposalNotDraftCanBeSentInMassAction', $objectobj->ref).'

'; continue; // Payment done or started or canceled } - if ($objectclass == 'Commande' && $objectobj->statut == Commande::STATUS_DRAFT) - { + if ($objectclass == 'Commande' && $objectobj->statut == Commande::STATUS_DRAFT) { $langs->load("errors"); $nbignored++; $resaction .= '
'.$langs->trans('ErrorOnlyOrderNotDraftCanBeSentInMassAction', $objectobj->ref).'

'; continue; } - if ($objectclass == 'Facture' && $objectobj->statut == Facture::STATUS_DRAFT) - { + if ($objectclass == 'Facture' && $objectobj->statut == Facture::STATUS_DRAFT) { $langs->load("errors"); $nbignored++; $resaction .= '
'.$langs->trans('ErrorOnlyInvoiceValidatedCanBeSentInMassAction', $objectobj->ref).'

'; @@ -249,23 +243,18 @@ if (!$error && $massaction == 'confirm_presend') } // Test recipient - if (empty($sendto)) // For the case, no recipient were set (multi thirdparties send) - { - if ($objectobj->element == 'societe') - { + if (empty($sendto)) { // For the case, no recipient were set (multi thirdparties send) + if ($objectobj->element == 'societe') { $sendto = $objectobj->email; - } elseif ($objectobj->element == 'expensereport') - { + } elseif ($objectobj->element == 'expensereport') { $fuser = new User($db); $fuser->fetch($objectobj->fk_user_author); $sendto = $fuser->email; - } elseif ($objectobj->element == 'holiday') - { + } elseif ($objectobj->element == 'holiday') { $fuser = new User($db); $fuser->fetch($objectobj->fk_user); $sendto = $fuser->email; - } elseif ($objectobj->element == 'facture' && !empty($listofobjectcontacts[$objectid])) - { + } elseif ($objectobj->element == 'facture' && !empty($listofobjectcontacts[$objectid])) { $emails_to_sends = array(); $objectobj->fetch_thirdparty(); $contactidtosend = array(); @@ -284,25 +273,22 @@ if (!$error && $massaction == 'confirm_presend') } } - if (empty($sendto)) - { + if (empty($sendto)) { if ($objectobj->element == 'societe') { $objectobj->thirdparty = $objectobj; // Hack so following code is comaptible when objectobj is a thirdparty } - //print "No recipient for thirdparty ".$objectobj->thirdparty->name; - $nbignored++; - if (empty($thirdpartywithoutemail[$objectobj->thirdparty->id])) - { + //print "No recipient for thirdparty ".$objectobj->thirdparty->name; + $nbignored++; + if (empty($thirdpartywithoutemail[$objectobj->thirdparty->id])) { $resaction .= '
'.$langs->trans('NoRecipientEmail', $objectobj->thirdparty->name).'

'; } dol_syslog('No recipient for thirdparty: '.$objectobj->thirdparty->name, LOG_WARNING); $thirdpartywithoutemail[$objectobj->thirdparty->id] = 1; - continue; + continue; } - if ($_POST['addmaindocfile']) - { + if ($_POST['addmaindocfile']) { // TODO Use future field $objectobj->fullpathdoc to know where is stored default file // TODO If not defined, use $objectobj->model_pdf (or defaut invoice config) to know what is template to use to regenerate doc. $filename = dol_sanitizeFileName($objectobj->ref).'.pdf'; @@ -313,16 +299,14 @@ if (!$error && $massaction == 'confirm_presend') $file = $filedir.'/'.$filename; // For supplier invoices, we use the file provided by supplier, not the one we generate - if ($objectobj->element == 'invoice_supplier') - { + if ($objectobj->element == 'invoice_supplier') { $fileparams = dol_most_recent_file($uploaddir.'/'.get_exdir($objectobj->id, 2, 0, 0, $objectobj, $objectobj->element).$objectobj->ref, preg_quote($objectobj->ref, '/').'([^\-])+'); $file = $fileparams['fullname']; } $mime = dol_mimetype($file); - if (dol_is_file($file)) - { + if (dol_is_file($file)) { // Create form object $attachedfilesThirdpartyObj[$thirdpartyid][$objectid] = array( 'paths'=>array($file), @@ -347,8 +331,7 @@ if (!$error && $massaction == 'confirm_presend') } // Send email if there is at least one qualified object for current thirdparty - if (count($listofqualifiedobj) > 0) - { + if (count($listofqualifiedobj) > 0) { $langs->load("commercial"); $reg = array(); @@ -367,8 +350,7 @@ if (!$error && $massaction == 'confirm_presend') $sql = 'SELECT rowid, label, email FROM '.MAIN_DB_PREFIX.'c_email_senderprofile WHERE rowid = '.(int) $reg[1]; $resql = $db->query($sql); $obj = $db->fetch_object($resql); - if ($obj) - { + if ($obj) { $from = $obj->label.' <'.$obj->email.'>'; } } else { @@ -380,22 +362,34 @@ if (!$error && $massaction == 'confirm_presend') $message = GETPOST('message', 'restricthtml'); $sendtobcc = GETPOST('sendtoccc'); - if ($objectclass == 'Propal') $sendtobcc .= (empty($conf->global->MAIN_MAIL_AUTOCOPY_PROPOSAL_TO) ? '' : (($sendtobcc ? ", " : "").$conf->global->MAIN_MAIL_AUTOCOPY_PROPOSAL_TO)); - if ($objectclass == 'Commande') $sendtobcc .= (empty($conf->global->MAIN_MAIL_AUTOCOPY_ORDER_TO) ? '' : (($sendtobcc ? ", " : "").$conf->global->MAIN_MAIL_AUTOCOPY_ORDER_TO)); - if ($objectclass == 'Facture') $sendtobcc .= (empty($conf->global->MAIN_MAIL_AUTOCOPY_INVOICE_TO) ? '' : (($sendtobcc ? ", " : "").$conf->global->MAIN_MAIL_AUTOCOPY_INVOICE_TO)); - if ($objectclass == 'Supplier_Proposal') $sendtobcc .= (empty($conf->global->MAIN_MAIL_AUTOCOPY_SUPPLIER_PROPOSAL_TO) ? '' : (($sendtobcc ? ", " : "").$conf->global->MAIN_MAIL_AUTOCOPY_SUPPLIER_PROPOSAL_TO)); - if ($objectclass == 'CommandeFournisseur') $sendtobcc .= (empty($conf->global->MAIN_MAIL_AUTOCOPY_SUPPLIER_ORDER_TO) ? '' : (($sendtobcc ? ", " : "").$conf->global->MAIN_MAIL_AUTOCOPY_SUPPLIER_ORDER_TO)); - if ($objectclass == 'FactureFournisseur') $sendtobcc .= (empty($conf->global->MAIN_MAIL_AUTOCOPY_SUPPLIER_INVOICE_TO) ? '' : (($sendtobcc ? ", " : "").$conf->global->MAIN_MAIL_AUTOCOPY_SUPPLIER_INVOICE_TO)); - if ($objectclass == 'Project') $sendtobcc .= (empty($conf->global->MAIN_MAIL_AUTOCOPY_PROJECT_TO) ? '' : (($sendtobcc ? ", " : "").$conf->global->MAIN_MAIL_AUTOCOPY_PROJECT_TO)); + if ($objectclass == 'Propal') { + $sendtobcc .= (empty($conf->global->MAIN_MAIL_AUTOCOPY_PROPOSAL_TO) ? '' : (($sendtobcc ? ", " : "").$conf->global->MAIN_MAIL_AUTOCOPY_PROPOSAL_TO)); + } + if ($objectclass == 'Commande') { + $sendtobcc .= (empty($conf->global->MAIN_MAIL_AUTOCOPY_ORDER_TO) ? '' : (($sendtobcc ? ", " : "").$conf->global->MAIN_MAIL_AUTOCOPY_ORDER_TO)); + } + if ($objectclass == 'Facture') { + $sendtobcc .= (empty($conf->global->MAIN_MAIL_AUTOCOPY_INVOICE_TO) ? '' : (($sendtobcc ? ", " : "").$conf->global->MAIN_MAIL_AUTOCOPY_INVOICE_TO)); + } + if ($objectclass == 'Supplier_Proposal') { + $sendtobcc .= (empty($conf->global->MAIN_MAIL_AUTOCOPY_SUPPLIER_PROPOSAL_TO) ? '' : (($sendtobcc ? ", " : "").$conf->global->MAIN_MAIL_AUTOCOPY_SUPPLIER_PROPOSAL_TO)); + } + if ($objectclass == 'CommandeFournisseur') { + $sendtobcc .= (empty($conf->global->MAIN_MAIL_AUTOCOPY_SUPPLIER_ORDER_TO) ? '' : (($sendtobcc ? ", " : "").$conf->global->MAIN_MAIL_AUTOCOPY_SUPPLIER_ORDER_TO)); + } + if ($objectclass == 'FactureFournisseur') { + $sendtobcc .= (empty($conf->global->MAIN_MAIL_AUTOCOPY_SUPPLIER_INVOICE_TO) ? '' : (($sendtobcc ? ", " : "").$conf->global->MAIN_MAIL_AUTOCOPY_SUPPLIER_INVOICE_TO)); + } + if ($objectclass == 'Project') { + $sendtobcc .= (empty($conf->global->MAIN_MAIL_AUTOCOPY_PROJECT_TO) ? '' : (($sendtobcc ? ", " : "").$conf->global->MAIN_MAIL_AUTOCOPY_PROJECT_TO)); + } // $listofqualifiedobj is array with key = object id and value is instance of qualified objects, for the current thirdparty (but thirdparty property is not loaded yet) // $looparray will be an array with number of email to send for the current thirdparty (so 1 or n if n object for same thirdparty) $looparray = array(); - if (!$oneemailperrecipient) - { + if (!$oneemailperrecipient) { $looparray = $listofqualifiedobj; - foreach ($looparray as $key => $objecttmp) - { + foreach ($looparray as $key => $objecttmp) { $looparray[$key]->thirdparty = $thirdparty; // Force thirdparty on object } } else { @@ -406,11 +400,9 @@ if (!$error && $massaction == 'confirm_presend') //var_dump($looparray);exit; dol_syslog("We have set an array of ".count($looparray)." emails to send. oneemailperrecipient=".$oneemailperrecipient); //var_dump($oneemailperrecipient); var_dump($listofqualifiedobj); var_dump($listofqualifiedref); - foreach ($looparray as $objectid => $objecttmp) // $objecttmp is a real object or an empty object if we choose to send one email per thirdparty instead of one per object - { + foreach ($looparray as $objectid => $objecttmp) { // $objecttmp is a real object or an empty object if we choose to send one email per thirdparty instead of one per object // Make substitution in email content - if (!empty($conf->projet->enabled) && method_exists($objecttmp, 'fetch_projet') && is_null($objecttmp->project)) - { + if (!empty($conf->projet->enabled) && method_exists($objecttmp, 'fetch_projet') && is_null($objecttmp->project)) { $objecttmp->fetch_projet(); } $substitutionarray = getCommonSubstitutionArray($langs, 0, null, $objecttmp); @@ -434,12 +426,10 @@ if (!$error && $massaction == 'confirm_presend') $messagereplaced = make_substitutions($message, $substitutionarray); $attachedfiles = array('paths'=>array(), 'names'=>array(), 'mimes'=>array()); - if ($oneemailperrecipient) - { + if ($oneemailperrecipient) { // if "one email per recipient" is check we must collate $attachedfiles by thirdparty - if (is_array($attachedfilesThirdpartyObj[$thirdparty->id]) && count($attachedfilesThirdpartyObj[$thirdparty->id])) - { - foreach ($attachedfilesThirdpartyObj[$thirdparty->id] as $keyObjId => $objAttachedFiles) { + if (is_array($attachedfilesThirdpartyObj[$thirdparty->id]) && count($attachedfilesThirdpartyObj[$thirdparty->id])) { + foreach ($attachedfilesThirdpartyObj[$thirdparty->id] as $keyObjId => $objAttachedFiles) { // Create form object $attachedfiles = array( 'paths'=>array_merge($attachedfiles['paths'], $objAttachedFiles['paths']), @@ -459,20 +449,37 @@ if (!$error && $massaction == 'confirm_presend') $mimetype = $attachedfiles['mimes']; // Define the trackid when emails sent from the mass action - if ($oneemailperrecipient) - { + if ($oneemailperrecipient) { $trackid = 'thi'.$thirdparty->id; - if ($objecttmp->element == 'expensereport') $trackid = 'use'.$thirdparty->id; - if ($objecttmp->element == 'holiday') $trackid = 'use'.$thirdparty->id; + if ($objecttmp->element == 'expensereport') { + $trackid = 'use'.$thirdparty->id; + } + if ($objecttmp->element == 'holiday') { + $trackid = 'use'.$thirdparty->id; + } } else { $trackid = strtolower(get_class($objecttmp)); - if (get_class($objecttmp) == 'Contrat') $trackid = 'con'; - if (get_class($objecttmp) == 'Propal') $trackid = 'pro'; - if (get_class($objecttmp) == 'Commande') $trackid = 'ord'; - if (get_class($objecttmp) == 'Facture') $trackid = 'inv'; - if (get_class($objecttmp) == 'Supplier_Proposal') $trackid = 'spr'; - if (get_class($objecttmp) == 'CommandeFournisseur') $trackid = 'sor'; - if (get_class($objecttmp) == 'FactureFournisseur') $trackid = 'sin'; + if (get_class($objecttmp) == 'Contrat') { + $trackid = 'con'; + } + if (get_class($objecttmp) == 'Propal') { + $trackid = 'pro'; + } + if (get_class($objecttmp) == 'Commande') { + $trackid = 'ord'; + } + if (get_class($objecttmp) == 'Facture') { + $trackid = 'inv'; + } + if (get_class($objecttmp) == 'Supplier_Proposal') { + $trackid = 'spr'; + } + if (get_class($objecttmp) == 'CommandeFournisseur') { + $trackid = 'sor'; + } + if (get_class($objecttmp) == 'FactureFournisseur') { + $trackid = 'sin'; + } $trackid .= $objecttmp->id; } @@ -480,40 +487,42 @@ if (!$error && $massaction == 'confirm_presend') //var_dump($trackid);exit; //var_dump($subjectreplaced); - if (empty($sendcontext)) $sendcontext = 'standard'; + if (empty($sendcontext)) { + $sendcontext = 'standard'; + } // Send mail (substitutionarray must be done just before this) require_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php'; $mailfile = new CMailFile($subjectreplaced, $sendto, $from, $messagereplaced, $filepath, $mimetype, $filename, $sendtocc, $sendtobcc, $deliveryreceipt, -1, '', '', $trackid, '', $sendcontext); - if ($mailfile->error) - { + if ($mailfile->error) { $resaction .= '
'.$mailfile->error.'
'; } else { $result = $mailfile->sendfile(); - if ($result) - { + if ($result) { $resaction .= $langs->trans('MailSuccessfulySent', $mailfile->getValidAddress($from, 2), $mailfile->getValidAddress($sendto, 2)).'
'; // Must not contain " $error = 0; // Insert logs into agenda - foreach ($listofqualifiedobj as $objid2 => $objectobj2) - { - if ((!$oneemailperrecipient) && $objid2 != $objectid) continue; // We discard this pass to avoid duplicate with other pass in looparray at higher level + foreach ($listofqualifiedobj as $objid2 => $objectobj2) { + if ((!$oneemailperrecipient) && $objid2 != $objectid) { + continue; // We discard this pass to avoid duplicate with other pass in looparray at higher level + } dol_syslog("Try to insert email event into agenda for objid=".$objid2." => objectobj=".get_class($objectobj2)); /*if ($objectclass == 'Propale') $actiontypecode='AC_PROP'; - if ($objectclass == 'Commande') $actiontypecode='AC_COM'; - if ($objectclass == 'Facture') $actiontypecode='AC_FAC'; - if ($objectclass == 'Supplier_Proposal') $actiontypecode='AC_SUP_PRO'; - if ($objectclass == 'CommandeFournisseur') $actiontypecode='AC_SUP_ORD'; - if ($objectclass == 'FactureFournisseur') $actiontypecode='AC_SUP_INV';*/ + if ($objectclass == 'Commande') $actiontypecode='AC_COM'; + if ($objectclass == 'Facture') $actiontypecode='AC_FAC'; + if ($objectclass == 'Supplier_Proposal') $actiontypecode='AC_SUP_PRO'; + if ($objectclass == 'CommandeFournisseur') $actiontypecode='AC_SUP_ORD'; + if ($objectclass == 'FactureFournisseur') $actiontypecode='AC_SUP_INV';*/ $actionmsg = $langs->transnoentities('MailSentBy').' '.$from.' '.$langs->transnoentities('To').' '.$sendto; - if ($message) - { - if ($sendtocc) $actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('Bcc').": ".$sendtocc); + if ($message) { + if ($sendtocc) { + $actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('Bcc').": ".$sendtocc); + } $actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('MailTopic').": ".$subjectreplaced); $actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('TextUsedInTheMessageBody').":"); $actionmsg = dol_concatdesc($actionmsg, $messagereplaced); @@ -528,24 +537,40 @@ if (!$error && $massaction == 'confirm_presend') $objectobj2->elementtype = $objectobj2->element; $triggername = strtoupper(get_class($objectobj2)).'_SENTBYMAIL'; - if ($triggername == 'SOCIETE_SENTBYMAIL') $triggername = 'COMPANY_SENTBYMAIL'; - if ($triggername == 'CONTRAT_SENTBYMAIL') $triggername = 'CONTRACT_SENTBYMAIL'; - if ($triggername == 'COMMANDE_SENTBYMAIL') $triggername = 'ORDER_SENTBYMAIL'; - if ($triggername == 'FACTURE_SENTBYMAIL') $triggername = 'BILL_SENTBYMAIL'; - if ($triggername == 'EXPEDITION_SENTBYMAIL') $triggername = 'SHIPPING_SENTBYMAIL'; - if ($triggername == 'COMMANDEFOURNISSEUR_SENTBYMAIL') $triggername = 'ORDER_SUPPLIER_SENTBYMAIL'; - if ($triggername == 'FACTUREFOURNISSEUR_SENTBYMAIL') $triggername = 'BILL_SUPPLIER_SENTBYMAIL'; - if ($triggername == 'SUPPLIERPROPOSAL_SENTBYMAIL') $triggername = 'PROPOSAL_SUPPLIER_SENTBYMAIL'; + if ($triggername == 'SOCIETE_SENTBYMAIL') { + $triggername = 'COMPANY_SENTBYMAIL'; + } + if ($triggername == 'CONTRAT_SENTBYMAIL') { + $triggername = 'CONTRACT_SENTBYMAIL'; + } + if ($triggername == 'COMMANDE_SENTBYMAIL') { + $triggername = 'ORDER_SENTBYMAIL'; + } + if ($triggername == 'FACTURE_SENTBYMAIL') { + $triggername = 'BILL_SENTBYMAIL'; + } + if ($triggername == 'EXPEDITION_SENTBYMAIL') { + $triggername = 'SHIPPING_SENTBYMAIL'; + } + if ($triggername == 'COMMANDEFOURNISSEUR_SENTBYMAIL') { + $triggername = 'ORDER_SUPPLIER_SENTBYMAIL'; + } + if ($triggername == 'FACTUREFOURNISSEUR_SENTBYMAIL') { + $triggername = 'BILL_SUPPLIER_SENTBYMAIL'; + } + if ($triggername == 'SUPPLIERPROPOSAL_SENTBYMAIL') { + $triggername = 'PROPOSAL_SUPPLIER_SENTBYMAIL'; + } - if (!empty($triggername)) - { + if (!empty($triggername)) { // Call trigger $result = $objectobj2->call_trigger($triggername, $user); - if ($result < 0) $error++; + if ($result < 0) { + $error++; + } // End call triggers - if ($error) - { + if ($error) { setEventMessages($db->lasterror(), $errors, 'errors'); dol_syslog("Error in trigger ".$triggername.' '.$db->lasterror(), LOG_ERR); } @@ -555,8 +580,7 @@ if (!$error && $massaction == 'confirm_presend') } } else { $langs->load("other"); - if ($mailfile->error) - { + if ($mailfile->error) { $resaction .= $langs->trans('ErrorFailedToSendMail', $from, $sendto); $resaction .= '
'.$mailfile->error.'
'; } else { @@ -574,8 +598,7 @@ if (!$error && $massaction == 'confirm_presend') $resaction .= $langs->trans("NbIgnored").': '.($nbignored ? $nbignored : 0)."\n
"; $resaction .= $langs->trans("NbSent").': '.($nbsent ? $nbsent : 0)."\n
"; - if ($nbsent) - { + if ($nbsent) { $action = ''; // Do not show form post if there was at least one successfull sent //setEventMessages($langs->trans("EMailSentToNRecipients", $nbsent.'/'.count($toselect)), null, 'mesgs'); setEventMessages($langs->trans("EMailSentForNElements", $nbsent.'/'.count($toselect)), null, 'mesgs'); @@ -591,8 +614,7 @@ if (!$error && $massaction == 'confirm_presend') } // TODO Move this action into commande/list.php if called only by this page. -if ($massaction == 'confirm_createbills') // Create bills from orders. -{ +if ($massaction == 'confirm_createbills') { // Create bills from orders. $orders = GETPOST('toselect', 'array'); $createbills_onebythird = GETPOST('createbills_onebythird', 'int'); $validate_invoices = GETPOST('validate_invoices', 'int'); @@ -606,10 +628,11 @@ if ($massaction == 'confirm_createbills') // Create bills from orders. $db->begin(); - foreach ($orders as $id_order) - { + foreach ($orders as $id_order) { $cmd = new Commande($db); - if ($cmd->fetch($id_order) <= 0) continue; + if ($cmd->fetch($id_order) <= 0) { + continue; + } $objecttmp = new Facture($db); if (!empty($createbills_onebythird) && !empty($TFactThird[$cmd->socid])) { @@ -624,11 +647,12 @@ if ($massaction == 'confirm_createbills') // Create bills from orders. $objecttmp->mode_reglement_id = $cmd->mode_reglement_id; $objecttmp->fk_project = $cmd->fk_project; $objecttmp->multicurrency_code = $cmd->multicurrency_code; - if (empty($createbills_onebythird)) $objecttmp->ref_client = $cmd->ref_client; + if (empty($createbills_onebythird)) { + $objecttmp->ref_client = $cmd->ref_client; + } $datefacture = dol_mktime(12, 0, 0, GETPOST('remonth', 'int'), GETPOST('reday', 'int'), GETPOST('reyear', 'int')); - if (empty($datefacture)) - { + if (empty($datefacture)) { $datefacture = dol_now(); } @@ -647,8 +671,7 @@ if ($massaction == 'confirm_createbills') // Create bills from orders. } } - if ($objecttmp->id > 0) - { + if ($objecttmp->id > 0) { $sql = "INSERT INTO ".MAIN_DB_PREFIX."element_element ("; $sql .= "fk_source"; $sql .= ", sourcetype"; @@ -661,16 +684,13 @@ if ($massaction == 'confirm_createbills') // Create bills from orders. $sql .= ", '".$db->escape($objecttmp->element)."'"; $sql .= ")"; - if (!$db->query($sql)) - { + if (!$db->query($sql)) { $error++; } - if (!$error) - { + if (!$error) { $lines = $cmd->lines; - if (empty($lines) && method_exists($cmd, 'fetch_lines')) - { + if (empty($lines) && method_exists($cmd, 'fetch_lines')) { $cmd->fetch_lines(); $lines = $cmd->lines; } @@ -678,17 +698,14 @@ if ($massaction == 'confirm_createbills') // Create bills from orders. $fk_parent_line = 0; $num = count($lines); - for ($i = 0; $i < $num; $i++) - { + for ($i = 0; $i < $num; $i++) { $desc = ($lines[$i]->desc ? $lines[$i]->desc : ''); // If we build one invoice for several order, we must put the invoice of order on the line - if (!empty($createbills_onebythird)) - { + if (!empty($createbills_onebythird)) { $desc = dol_concatdesc($desc, $langs->trans("Order").' '.$cmd->ref.' - '.dol_print_date($cmd->date, 'day')); } - if ($lines[$i]->subprice < 0) - { + if ($lines[$i]->subprice < 0) { // Negative line, we create a discount line $discount = new DiscountAbsolute($db); $discount->fk_soc = $objecttmp->socid; @@ -699,8 +716,7 @@ if ($massaction == 'confirm_createbills') // Create bills from orders. $discount->fk_user = $user->id; $discount->description = $desc; $discountid = $discount->create($user); - if ($discountid > 0) - { + if ($discountid > 0) { $result = $objecttmp->insert_discount($discountid); //$result=$discount->link_to_invoice($lineid,$id); } else { @@ -713,17 +729,28 @@ if ($massaction == 'confirm_createbills') // Create bills from orders. $product_type = ($lines[$i]->product_type ? $lines[$i]->product_type : 0); // Date start $date_start = false; - if ($lines[$i]->date_debut_prevue) $date_start = $lines[$i]->date_debut_prevue; - if ($lines[$i]->date_debut_reel) $date_start = $lines[$i]->date_debut_reel; - if ($lines[$i]->date_start) $date_start = $lines[$i]->date_start; + if ($lines[$i]->date_debut_prevue) { + $date_start = $lines[$i]->date_debut_prevue; + } + if ($lines[$i]->date_debut_reel) { + $date_start = $lines[$i]->date_debut_reel; + } + if ($lines[$i]->date_start) { + $date_start = $lines[$i]->date_start; + } //Date end $date_end = false; - if ($lines[$i]->date_fin_prevue) $date_end = $lines[$i]->date_fin_prevue; - if ($lines[$i]->date_fin_reel) $date_end = $lines[$i]->date_fin_reel; - if ($lines[$i]->date_end) $date_end = $lines[$i]->date_end; + if ($lines[$i]->date_fin_prevue) { + $date_end = $lines[$i]->date_fin_prevue; + } + if ($lines[$i]->date_fin_reel) { + $date_end = $lines[$i]->date_fin_reel; + } + if ($lines[$i]->date_end) { + $date_end = $lines[$i]->date_end; + } // Reset fk_parent_line for no child products and special product - if (($lines[$i]->product_type != 9 && empty($lines[$i]->fk_parent_line)) || $lines[$i]->product_type == 9) - { + if (($lines[$i]->product_type != 9 && empty($lines[$i]->fk_parent_line)) || $lines[$i]->product_type == 9) { $fk_parent_line = 0; } @@ -762,9 +789,8 @@ if ($massaction == 'confirm_createbills') // Create bills from orders. 100, 0, $lines[$i]->fk_unit - ); - if ($result > 0) - { + ); + if ($result > 0) { $lineid = $result; } else { $lineid = 0; @@ -772,8 +798,7 @@ if ($massaction == 'confirm_createbills') // Create bills from orders. break; } // Defined the new fk_parent_line - if ($result > 0 && $lines[$i]->product_type == 9) - { + if ($result > 0 && $lines[$i]->product_type == 9) { $fk_parent_line = $result; } } @@ -783,23 +808,23 @@ if ($massaction == 'confirm_createbills') // Create bills from orders. //$cmd->classifyBilled($user); // Disabled. This behavior must be set or not using the workflow module. - if (!empty($createbills_onebythird) && empty($TFactThird[$cmd->socid])) $TFactThird[$cmd->socid] = $objecttmp; - else $TFact[$objecttmp->id] = $objecttmp; + if (!empty($createbills_onebythird) && empty($TFactThird[$cmd->socid])) { + $TFactThird[$cmd->socid] = $objecttmp; + } else { + $TFact[$objecttmp->id] = $objecttmp; + } } // Build doc with all invoices $TAllFact = empty($createbills_onebythird) ? $TFact : $TFactThird; $toselect = array(); - if (!$error && $validate_invoices) - { + if (!$error && $validate_invoices) { $massaction = $action = 'builddoc'; - foreach ($TAllFact as &$objecttmp) - { + foreach ($TAllFact as &$objecttmp) { $result = $objecttmp->validate($user); - if ($result <= 0) - { + if ($result <= 0) { $error++; setEventMessages($objecttmp->error, $objecttmp->errors, 'errors'); break; @@ -815,7 +840,7 @@ if ($massaction == 'confirm_createbills') // Create bills from orders. // Call action to build doc $savobject = $object; - $object = $objecttmp; + $object = $objecttmp; include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php'; $object = $savobject; } @@ -823,8 +848,7 @@ if ($massaction == 'confirm_createbills') // Create bills from orders. $massaction = $action = 'confirm_createbills'; } - if (!$error) - { + if (!$error) { $db->commit(); if ($nb_bills_created == 1) { @@ -837,29 +861,75 @@ if ($massaction == 'confirm_createbills') // Create bills from orders. // Make a redirect to avoid to bill twice if we make a refresh or back $param = ''; - if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage); - if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit); - if ($sall) $param .= '&sall='.urlencode($sall); - if ($socid > 0) $param .= '&socid='.urlencode($socid); - if ($search_status != '') $param .= '&search_status='.urlencode($search_status); - if ($search_orderday) $param .= '&search_orderday='.urlencode($search_orderday); - if ($search_ordermonth) $param .= '&search_ordermonth='.urlencode($search_ordermonth); - if ($search_orderyear) $param .= '&search_orderyear='.urlencode($search_orderyear); - if ($search_deliveryday) $param .= '&search_deliveryday='.urlencode($search_deliveryday); - if ($search_deliverymonth) $param .= '&search_deliverymonth='.urlencode($search_deliverymonth); - if ($search_deliveryyear) $param .= '&search_deliveryyear='.urlencode($search_deliveryyear); - if ($search_ref) $param .= '&search_ref='.urlencode($search_ref); - if ($search_company) $param .= '&search_company='.urlencode($search_company); - if ($search_ref_customer) $param .= '&search_ref_customer='.urlencode($search_ref_customer); - if ($search_user > 0) $param .= '&search_user='.urlencode($search_user); - if ($search_sale > 0) $param .= '&search_sale='.urlencode($search_sale); - if ($search_total_ht != '') $param .= '&search_total_ht='.urlencode($search_total_ht); - if ($search_total_vat != '') $param .= '&search_total_vat='.urlencode($search_total_vat); - if ($search_total_ttc != '') $param .= '&search_total_ttc='.urlencode($search_total_ttc); - if ($search_project_ref >= 0) $param .= "&search_project_ref=".urlencode($search_project_ref); - if ($show_files) $param .= '&show_files='.urlencode($show_files); - if ($optioncss != '') $param .= '&optioncss='.urlencode($optioncss); - if ($billed != '') $param .= '&billed='.urlencode($billed); + if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) { + $param .= '&contextpage='.urlencode($contextpage); + } + if ($limit > 0 && $limit != $conf->liste_limit) { + $param .= '&limit='.urlencode($limit); + } + if ($sall) { + $param .= '&sall='.urlencode($sall); + } + if ($socid > 0) { + $param .= '&socid='.urlencode($socid); + } + if ($search_status != '') { + $param .= '&search_status='.urlencode($search_status); + } + if ($search_orderday) { + $param .= '&search_orderday='.urlencode($search_orderday); + } + if ($search_ordermonth) { + $param .= '&search_ordermonth='.urlencode($search_ordermonth); + } + if ($search_orderyear) { + $param .= '&search_orderyear='.urlencode($search_orderyear); + } + if ($search_deliveryday) { + $param .= '&search_deliveryday='.urlencode($search_deliveryday); + } + if ($search_deliverymonth) { + $param .= '&search_deliverymonth='.urlencode($search_deliverymonth); + } + if ($search_deliveryyear) { + $param .= '&search_deliveryyear='.urlencode($search_deliveryyear); + } + if ($search_ref) { + $param .= '&search_ref='.urlencode($search_ref); + } + if ($search_company) { + $param .= '&search_company='.urlencode($search_company); + } + if ($search_ref_customer) { + $param .= '&search_ref_customer='.urlencode($search_ref_customer); + } + if ($search_user > 0) { + $param .= '&search_user='.urlencode($search_user); + } + if ($search_sale > 0) { + $param .= '&search_sale='.urlencode($search_sale); + } + if ($search_total_ht != '') { + $param .= '&search_total_ht='.urlencode($search_total_ht); + } + if ($search_total_vat != '') { + $param .= '&search_total_vat='.urlencode($search_total_vat); + } + if ($search_total_ttc != '') { + $param .= '&search_total_ttc='.urlencode($search_total_ttc); + } + if ($search_project_ref >= 0) { + $param .= "&search_project_ref=".urlencode($search_project_ref); + } + if ($show_files) { + $param .= '&show_files='.urlencode($show_files); + } + if ($optioncss != '') { + $param .= '&optioncss='.urlencode($optioncss); + } + if ($billed != '') { + $param .= '&billed='.urlencode($billed); + } header("Location: ".$_SERVER['PHP_SELF'].'?'.$param); exit; @@ -873,22 +943,20 @@ if ($massaction == 'confirm_createbills') // Create bills from orders. } } -if (!$error && $massaction == 'cancelorders') -{ +if (!$error && $massaction == 'cancelorders') { $db->begin(); $nbok = 0; $orders = GETPOST('toselect', 'array'); - foreach ($orders as $id_order) - { + foreach ($orders as $id_order) { $cmd = new Commande($db); - if ($cmd->fetch($id_order) <= 0) + if ($cmd->fetch($id_order) <= 0) { continue; + } - if ($cmd->statut != Commande::STATUS_VALIDATED) - { + if ($cmd->statut != Commande::STATUS_VALIDATED) { $langs->load('errors'); setEventMessages($langs->trans("ErrorObjectMustHaveStatusValidToBeCanceled", $cmd->ref), null, 'errors'); $error++; @@ -898,18 +966,20 @@ if (!$error && $massaction == 'cancelorders') $result = $cmd->cancel(); } - if ($result < 0) - { + if ($result < 0) { setEventMessages($cmd->error, $cmd->errors, 'errors'); $error++; break; - } else $nbok++; + } else { + $nbok++; + } } - if (!$error) - { - if ($nbok > 1) + if (!$error) { + if ($nbok > 1) { setEventMessages($langs->trans("RecordsModified", $nbok), null, 'mesgs'); - else setEventMessages($langs->trans("RecordsModified", $nbok), null, 'mesgs'); + } else { + setEventMessages($langs->trans("RecordsModified", $nbok), null, 'mesgs'); + } $db->commit(); } else { $db->rollback(); @@ -917,10 +987,8 @@ if (!$error && $massaction == 'cancelorders') } -if (!$error && $massaction == "builddoc" && $permissiontoread && !GETPOST('button_search')) -{ - if (empty($diroutputmassaction)) - { +if (!$error && $massaction == "builddoc" && $permissiontoread && !GETPOST('button_search')) { + if (empty($diroutputmassaction)) { dol_print_error(null, 'include of actions_massactions.inc.php is done but var $diroutputmassaction was not defined'); exit; } @@ -933,12 +1001,10 @@ if (!$error && $massaction == "builddoc" && $permissiontoread && !GETPOST('butto $listofobjectid = array(); $listofobjectthirdparties = array(); $listofobjectref = array(); - foreach ($toselect as $toselectid) - { + foreach ($toselect as $toselectid) { $objecttmp = new $objectclass($db); // must create new instance because instance is saved into $listofobjectref array for future use $result = $objecttmp->fetch($toselectid); - if ($result > 0) - { + if ($result > 0) { $listofobjectid[$toselectid] = $toselectid; $thirdpartyid = $objecttmp->fk_soc ? $objecttmp->fk_soc : $objecttmp->socid; $listofobjectthirdparties[$thirdpartyid] = $thirdpartyid; @@ -947,19 +1013,20 @@ if (!$error && $massaction == "builddoc" && $permissiontoread && !GETPOST('butto } $arrayofinclusion = array(); - foreach ($listofobjectref as $tmppdf) $arrayofinclusion[] = '^'.preg_quote(dol_sanitizeFileName($tmppdf), '/').'\.pdf$'; - foreach ($listofobjectref as $tmppdf) $arrayofinclusion[] = '^'.preg_quote(dol_sanitizeFileName($tmppdf), '/').'_[a-zA-Z0-9-_]+\.pdf$'; // To include PDF generated from ODX files + foreach ($listofobjectref as $tmppdf) { + $arrayofinclusion[] = '^'.preg_quote(dol_sanitizeFileName($tmppdf), '/').'\.pdf$'; + } + foreach ($listofobjectref as $tmppdf) { + $arrayofinclusion[] = '^'.preg_quote(dol_sanitizeFileName($tmppdf), '/').'_[a-zA-Z0-9-_]+\.pdf$'; // To include PDF generated from ODX files + } $listoffiles = dol_dir_list($uploaddir, 'all', 1, implode('|', $arrayofinclusion), '\.meta$|\.png', 'date', SORT_DESC, 0, true); // build list of files with full path $files = array(); - foreach ($listofobjectref as $basename) - { + foreach ($listofobjectref as $basename) { $basename = dol_sanitizeFileName($basename); - foreach ($listoffiles as $filefound) - { - if (strstr($filefound["name"], $basename)) - { + foreach ($listoffiles as $filefound) { + if (strstr($filefound["name"], $basename)) { $files[] = $uploaddir.'/'.$basename.'/'.$filefound["name"]; break; } @@ -969,15 +1036,18 @@ if (!$error && $massaction == "builddoc" && $permissiontoread && !GETPOST('butto // Define output language (Here it is not used because we do only merging existing PDF) $outputlangs = $langs; $newlang = ''; - if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) $newlang = GETPOST('lang_id', 'aZ09'); - if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $objecttmp->thirdparty->default_lang; + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) { + $newlang = GETPOST('lang_id', 'aZ09'); + } + if ($conf->global->MAIN_MULTILANGS && empty($newlang)) { + $newlang = $objecttmp->thirdparty->default_lang; + } if (!empty($newlang)) { $outputlangs = new Translate("", $conf); $outputlangs->setDefaultLang($newlang); } - if (!empty($conf->global->USE_PDFTK_FOR_PDF_CONCAT)) - { + if (!empty($conf->global->USE_PDFTK_FOR_PDF_CONCAT)) { // Create output dir if not exists dol_mkdir($diroutputmassaction); @@ -986,16 +1056,21 @@ if (!$error && $massaction == "builddoc" && $permissiontoread && !GETPOST('butto $filename = preg_replace('/\s/', '_', $filename); // Save merged file - if (in_array($objecttmp->element, array('facture', 'facture_fournisseur')) && $search_status == Facture::STATUS_VALIDATED) - { - if ($option == 'late') $filename .= '_'.strtolower(dol_sanitizeFileName($langs->transnoentities("Unpaid"))).'_'.strtolower(dol_sanitizeFileName($langs->transnoentities("Late"))); - else $filename .= '_'.strtolower(dol_sanitizeFileName($langs->transnoentities("Unpaid"))); + if (in_array($objecttmp->element, array('facture', 'facture_fournisseur')) && $search_status == Facture::STATUS_VALIDATED) { + if ($option == 'late') { + $filename .= '_'.strtolower(dol_sanitizeFileName($langs->transnoentities("Unpaid"))).'_'.strtolower(dol_sanitizeFileName($langs->transnoentities("Late"))); + } else { + $filename .= '_'.strtolower(dol_sanitizeFileName($langs->transnoentities("Unpaid"))); + } + } + if ($year) { + $filename .= '_'.$year; + } + if ($month) { + $filename .= '_'.$month; } - if ($year) $filename .= '_'.$year; - if ($month) $filename .= '_'.$month; - if (count($files) > 0) - { + if (count($files) > 0) { $now = dol_now(); $file = $diroutputmassaction.'/'.$filename.'_'.dol_print_date($now, 'dayhourlog').'.pdf'; @@ -1009,8 +1084,9 @@ if (!$error && $massaction == "builddoc" && $permissiontoread && !GETPOST('butto // check if pdftk is installed if (file_exists($file)) { - if (!empty($conf->global->MAIN_UMASK)) + if (!empty($conf->global->MAIN_UMASK)) { @chmod($file, octdec($conf->global->MAIN_UMASK)); + } $langs->load("exports"); setEventMessages($langs->trans('FileSuccessfullyBuilt', $filename.'_'.dol_print_date($now, 'dayhourlog')), null, 'mesgs'); @@ -1029,22 +1105,21 @@ if (!$error && $massaction == "builddoc" && $permissiontoread && !GETPOST('butto $pdf = pdf_getInstance($format); - if (class_exists('TCPDF')) - { + if (class_exists('TCPDF')) { $pdf->setPrintHeader(false); $pdf->setPrintFooter(false); } $pdf->SetFont(pdf_getPDFFont($outputlangs)); - if (!empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false); + if (!empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) { + $pdf->SetCompression(false); + } // Add all others - foreach ($files as $file) - { + foreach ($files as $file) { // Charge un document PDF depuis un fichier. $pagecount = $pdf->setSourceFile($file); - for ($i = 1; $i <= $pagecount; $i++) - { + for ($i = 1; $i <= $pagecount; $i++) { $tplidx = $pdf->importPage($i); $s = $pdf->getTemplatesize($tplidx); $pdf->AddPage($s['h'] > $s['w'] ? 'P' : 'L'); @@ -1060,20 +1135,26 @@ if (!$error && $massaction == "builddoc" && $permissiontoread && !GETPOST('butto $filename = preg_replace('/\s/', '_', $filename); // Save merged file - if (in_array($objecttmp->element, array('facture', 'facture_fournisseur')) && $search_status == Facture::STATUS_VALIDATED) - { - if ($option == 'late') $filename .= '_'.strtolower(dol_sanitizeFileName($langs->transnoentities("Unpaid"))).'_'.strtolower(dol_sanitizeFileName($langs->transnoentities("Late"))); - else $filename .= '_'.strtolower(dol_sanitizeFileName($langs->transnoentities("Unpaid"))); + if (in_array($objecttmp->element, array('facture', 'facture_fournisseur')) && $search_status == Facture::STATUS_VALIDATED) { + if ($option == 'late') { + $filename .= '_'.strtolower(dol_sanitizeFileName($langs->transnoentities("Unpaid"))).'_'.strtolower(dol_sanitizeFileName($langs->transnoentities("Late"))); + } else { + $filename .= '_'.strtolower(dol_sanitizeFileName($langs->transnoentities("Unpaid"))); + } } - if ($year) $filename .= '_'.$year; - if ($month) $filename .= '_'.$month; - if ($pagecount) - { + if ($year) { + $filename .= '_'.$year; + } + if ($month) { + $filename .= '_'.$month; + } + if ($pagecount) { $now = dol_now(); $file = $diroutputmassaction.'/'.$filename.'_'.dol_print_date($now, 'dayhourlog').'.pdf'; $pdf->Output($file, 'F'); - if (!empty($conf->global->MAIN_UMASK)) + if (!empty($conf->global->MAIN_UMASK)) { @chmod($file, octdec($conf->global->MAIN_UMASK)); + } $langs->load("exports"); setEventMessages($langs->trans('FileSuccessfullyBuilt', $filename.'_'.dol_print_date($now, 'dayhourlog')), null, 'mesgs'); @@ -1084,47 +1165,43 @@ if (!$error && $massaction == "builddoc" && $permissiontoread && !GETPOST('butto } // Remove a file from massaction area -if ($action == 'remove_file') -{ +if ($action == 'remove_file') { require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; $langs->load("other"); $upload_dir = $diroutputmassaction; $file = $upload_dir.'/'.GETPOST('file'); $ret = dol_delete_file($file); - if ($ret) setEventMessages($langs->trans("FileWasRemoved", GETPOST('file')), null, 'mesgs'); - else setEventMessages($langs->trans("ErrorFailToDeleteFile", GETPOST('file')), null, 'errors'); + if ($ret) { + setEventMessages($langs->trans("FileWasRemoved", GETPOST('file')), null, 'mesgs'); + } else { + setEventMessages($langs->trans("ErrorFailToDeleteFile", GETPOST('file')), null, 'errors'); + } $action = ''; } // Validate records -if (!$error && $massaction == 'validate' && $permissiontoadd) -{ +if (!$error && $massaction == 'validate' && $permissiontoadd) { $objecttmp = new $objectclass($db); - if (($objecttmp->element == 'facture' || $objecttmp->element == 'invoice') && !empty($conf->stock->enabled) && !empty($conf->global->STOCK_CALCULATE_ON_BILL)) - { + if (($objecttmp->element == 'facture' || $objecttmp->element == 'invoice') && !empty($conf->stock->enabled) && !empty($conf->global->STOCK_CALCULATE_ON_BILL)) { $langs->load("errors"); setEventMessages($langs->trans('ErrorMassValidationNotAllowedWhenStockIncreaseOnAction'), null, 'errors'); $error++; } - if ($objecttmp->element == 'invoice_supplier' && !empty($conf->stock->enabled) && !empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_BILL)) - { + if ($objecttmp->element == 'invoice_supplier' && !empty($conf->stock->enabled) && !empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_BILL)) { $langs->load("errors"); setEventMessages($langs->trans('ErrorMassValidationNotAllowedWhenStockIncreaseOnAction'), null, 'errors'); $error++; } - if (!$error) - { + if (!$error) { $db->begin(); $nbok = 0; - foreach ($toselect as $toselectid) - { + foreach ($toselect as $toselectid) { $result = $objecttmp->fetch($toselectid); - if ($result > 0) - { + if ($result > 0) { $result = $objecttmp->validate($user); if ($result == 0) { $langs->load("errors"); @@ -1174,10 +1251,12 @@ if (!$error && $massaction == 'validate' && $permissiontoadd) } } - if (!$error) - { - if ($nbok > 1) setEventMessages($langs->trans("RecordsModified", $nbok), null, 'mesgs'); - else setEventMessages($langs->trans("RecordsModified", $nbok), null, 'mesgs'); + if (!$error) { + if ($nbok > 1) { + setEventMessages($langs->trans("RecordsModified", $nbok), null, 'mesgs'); + } else { + setEventMessages($langs->trans("RecordsModified", $nbok), null, 'mesgs'); + } $db->commit(); } else { $db->rollback(); @@ -1200,7 +1279,9 @@ if (!$error && $massaction == 'closed' && $objectclass == "Propal" && $permissio setEventMessages($objecttmp->error, $objecttmp->errors, 'errors'); $error++; break; - } else $nbok++; + } else { + $nbok++; + } } else { setEventMessages($objecttmp->error, $objecttmp->errors, 'errors'); $error++; @@ -1209,9 +1290,11 @@ if (!$error && $massaction == 'closed' && $objectclass == "Propal" && $permissio } if (!$error) { - if ($nbok > 1) + if ($nbok > 1) { setEventMessages($langs->trans("RecordsModified", $nbok), null, 'mesgs'); - else setEventMessages($langs->trans("RecordsModified", $nbok), null, 'mesgs'); + } else { + setEventMessages($langs->trans("RecordsModified", $nbok), null, 'mesgs'); + } $db->commit(); } else { $db->rollback(); @@ -1221,47 +1304,45 @@ if (!$error && $massaction == 'closed' && $objectclass == "Propal" && $permissio //var_dump($_POST);var_dump($massaction);exit; // Delete record from mass action (massaction = 'delete' for direct delete, action/confirm='delete'/'yes' with a confirmation step before) -if (!$error && ($massaction == 'delete' || ($action == 'delete' && $confirm == 'yes')) && $permissiontodelete) -{ +if (!$error && ($massaction == 'delete' || ($action == 'delete' && $confirm == 'yes')) && $permissiontodelete) { $db->begin(); $objecttmp = new $objectclass($db); $nbok = 0; - foreach ($toselect as $toselectid) - { + foreach ($toselect as $toselectid) { $result = $objecttmp->fetch($toselectid); - if ($result > 0) - { + if ($result > 0) { // Refuse deletion for some objects/status - if ($objectclass == 'Facture' && empty($conf->global->INVOICE_CAN_ALWAYS_BE_REMOVED) && $objecttmp->status != Facture::STATUS_DRAFT) - { + if ($objectclass == 'Facture' && empty($conf->global->INVOICE_CAN_ALWAYS_BE_REMOVED) && $objecttmp->status != Facture::STATUS_DRAFT) { $langs->load("errors"); $nbignored++; $resaction .= '
'.$langs->trans('ErrorOnlyDraftStatusCanBeDeletedInMassAction', $objecttmp->ref).'

'; continue; } - if ($objectclass == "Task" && $objecttmp->hasChildren() > 0) - { + if ($objectclass == "Task" && $objecttmp->hasChildren() > 0) { $sql = "UPDATE ".MAIN_DB_PREFIX."projet_task SET fk_task_parent = 0 WHERE fk_task_parent = ".$objecttmp->id; $res = $db->query($sql); - if (!$res) - { + if (!$res) { setEventMessage('ErrorRecordParentingNotModified', 'errors'); $error++; } } - if (in_array($objecttmp->element, array('societe', 'member'))) $result = $objecttmp->delete($objecttmp->id, $user, 1); - else $result = $objecttmp->delete($user); + if (in_array($objecttmp->element, array('societe', 'member'))) { + $result = $objecttmp->delete($objecttmp->id, $user, 1); + } else { + $result = $objecttmp->delete($user); + } - if ($result <= 0) - { + if ($result <= 0) { setEventMessages($objecttmp->error, $objecttmp->errors, 'errors'); $error++; break; - } else $nbok++; + } else { + $nbok++; + } } else { setEventMessages($objecttmp->error, $objecttmp->errors, 'errors'); $error++; @@ -1269,10 +1350,12 @@ if (!$error && ($massaction == 'delete' || ($action == 'delete' && $confirm == ' } } - if (!$error) - { - if ($nbok > 1) setEventMessages($langs->trans("RecordsDeleted", $nbok), null, 'mesgs'); - else setEventMessages($langs->trans("RecordDeleted", $nbok), null, 'mesgs'); + if (!$error) { + if ($nbok > 1) { + setEventMessages($langs->trans("RecordsDeleted", $nbok), null, 'mesgs'); + } else { + setEventMessages($langs->trans("RecordDeleted", $nbok), null, 'mesgs'); + } $db->commit(); } else { $db->rollback(); @@ -1282,43 +1365,54 @@ if (!$error && ($massaction == 'delete' || ($action == 'delete' && $confirm == ' // Generate document foreach object according to model linked to object // @todo : propose model selection -if (!$error && $massaction == 'generate_doc' && $permissiontoread) -{ +if (!$error && $massaction == 'generate_doc' && $permissiontoread) { $db->begin(); $objecttmp = new $objectclass($db); $nbok = 0; - foreach ($toselect as $toselectid) - { + foreach ($toselect as $toselectid) { $result = $objecttmp->fetch($toselectid); - if ($result > 0) - { + if ($result > 0) { $outputlangs = $langs; $newlang = ''; - if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) $newlang = GETPOST('lang_id', 'aZ09'); - if ($conf->global->MAIN_MULTILANGS && empty($newlang) && isset($objecttmp->thirdparty->default_lang)) $newlang = $objecttmp->thirdparty->default_lang; // for proposal, order, invoice, ... - if ($conf->global->MAIN_MULTILANGS && empty($newlang) && isset($objecttmp->default_lang)) $newlang = $objecttmp->default_lang; // for thirdparty - if (!empty($newlang)) - { + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) { + $newlang = GETPOST('lang_id', 'aZ09'); + } + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && isset($objecttmp->thirdparty->default_lang)) { + $newlang = $objecttmp->thirdparty->default_lang; // for proposal, order, invoice, ... + } + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && isset($objecttmp->default_lang)) { + $newlang = $objecttmp->default_lang; // for thirdparty + } + if (!empty($newlang)) { $outputlangs = new Translate("", $conf); $outputlangs->setDefaultLang($newlang); } // To be sure vars is defined - if (empty($hidedetails)) $hidedetails = 0; - if (empty($hidedesc)) $hidedesc = 0; - if (empty($hideref)) $hideref = 0; - if (empty($moreparams)) $moreparams = null; + if (empty($hidedetails)) { + $hidedetails = 0; + } + if (empty($hidedesc)) { + $hidedesc = 0; + } + if (empty($hideref)) { + $hideref = 0; + } + if (empty($moreparams)) { + $moreparams = null; + } $result = $objecttmp->generateDocument($objecttmp->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref, $moreparams); - if ($result <= 0) - { + if ($result <= 0) { setEventMessages($objecttmp->error, $objecttmp->errors, 'errors'); $error++; break; - } else $nbok++; + } else { + $nbok++; + } } else { setEventMessages($objecttmp->error, $objecttmp->errors, 'errors'); $error++; @@ -1326,10 +1420,12 @@ if (!$error && $massaction == 'generate_doc' && $permissiontoread) } } - if (!$error) - { - if ($nbok > 1) setEventMessages($langs->trans("RecordsGenerated", $nbok), null, 'mesgs'); - else setEventMessages($langs->trans("RecordGenerated", $nbok), null, 'mesgs'); + if (!$error) { + if ($nbok > 1) { + setEventMessages($langs->trans("RecordsGenerated", $nbok), null, 'mesgs'); + } else { + setEventMessages($langs->trans("RecordGenerated", $nbok), null, 'mesgs'); + } $db->commit(); } else { $db->rollback(); @@ -1383,10 +1479,12 @@ if (!$error && ($action == 'affecttag' && $confirm == 'yes') && $permissiontoadd } } - if (!$error) - { - if ($nbok > 1) setEventMessages($langs->trans("RecordsModified", $nbok), null); - else setEventMessages($langs->trans("RecordsModified", $nbok), null); + if (!$error) { + if ($nbok > 1) { + setEventMessages($langs->trans("RecordsModified", $nbok), null); + } else { + setEventMessages($langs->trans("RecordsModified", $nbok), null); + } $db->commit(); $toselect=array(); } else { @@ -1400,4 +1498,6 @@ $parameters['massaction'] = $massaction; $parameters['diroutputmassaction'] = $diroutputmassaction; $reshook = $hookmanager->executeHooks('doMassActions', $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 ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); +} diff --git a/htdocs/core/actions_printing.inc.php b/htdocs/core/actions_printing.inc.php index 3838e6963ab..de415bb4ba3 100644 --- a/htdocs/core/actions_printing.inc.php +++ b/htdocs/core/actions_printing.inc.php @@ -55,16 +55,15 @@ if ($action == 'print_file' && $user->rights->printing->read) { $subdir = ''; $module = GETPOST('printer', 'alpha'); - switch ($module) - { - case 'livraison' : + switch ($module) { + case 'livraison': $subdir = 'receipt'; $module = 'expedition'; break; - case 'expedition' : + case 'expedition': $subdir = 'sending'; break; - case 'commande_fournisseur' : + case 'commande_fournisseur': $module = 'fournisseur'; $subdir = 'commande'; break; @@ -75,20 +74,20 @@ if ($action == 'print_file' && $user->rights->printing->read) { //print '
'.print_r($printer->errors, true).'
'; setEventMessages($printer->error, $printer->errors, 'errors'); } - if ($ret == 0) - { + if ($ret == 0) { //print '
'.print_r($printer->errors, true).'
'; setEventMessages($printer->error, $printer->errors); setEventMessages($langs->transnoentitiesnoconv("FileWasSentToPrinter", basename(GETPOST('file', 'alpha'))).' '.$langs->transnoentitiesnoconv("ViaModule").' '.$printer->name, null); } - } catch (Exception $e) - { + } catch (Exception $e) { $ret = 1; setEventMessages($e->getMessage(), null, 'errors'); } } } - if ($printerfound == 0) setEventMessages($langs->trans("NoActivePrintingModuleFound", $langs->transnoentities("Module64000Name")), null, 'warnings'); + if ($printerfound == 0) { + setEventMessages($langs->trans("NoActivePrintingModuleFound", $langs->transnoentities("Module64000Name")), null, 'warnings'); + } } else { setEventMessages($langs->trans("NoModuleFound"), null, 'warnings'); } diff --git a/htdocs/core/actions_setmoduleoptions.inc.php b/htdocs/core/actions_setmoduleoptions.inc.php index d662d3c85c9..e56c4a95dcd 100644 --- a/htdocs/core/actions_setmoduleoptions.inc.php +++ b/htdocs/core/actions_setmoduleoptions.inc.php @@ -27,66 +27,60 @@ // $nomessageinupdate can be set to 1 // $nomessageinsetmoduleoptions can be set to 1 -if ($action == 'update' && is_array($arrayofparameters)) -{ +if ($action == 'update' && is_array($arrayofparameters)) { $db->begin(); - foreach ($arrayofparameters as $key => $val) - { + foreach ($arrayofparameters as $key => $val) { // Modify constant only if key was posted (avoid resetting key to the null value) - if (GETPOSTISSET($key)) - { + if (GETPOSTISSET($key)) { $result = dolibarr_set_const($db, $key, GETPOST($key, 'alpha'), 'chaine', 0, '', $conf->entity); - if ($result < 0) - { + if ($result < 0) { $error++; break; } } } - if (!$error) - { + if (!$error) { $db->commit(); - if (empty($nomessageinupdate)) setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); + if (empty($nomessageinupdate)) { + setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); + } } else { $db->rollback(); - if (empty($nomessageinupdate)) setEventMessages($langs->trans("SetupNotSaved"), null, 'errors'); + if (empty($nomessageinupdate)) { + setEventMessages($langs->trans("SetupNotSaved"), null, 'errors'); + } } } // Define constants for submodules that contains parameters (forms with param1, param2, ... and value1, value2, ...) -if ($action == 'setModuleOptions') -{ +if ($action == 'setModuleOptions') { $db->begin(); // Process common param fields - if (is_array($_POST)) - { - foreach ($_POST as $key => $val) - { + if (is_array($_POST)) { + foreach ($_POST as $key => $val) { $reg = array(); - if (preg_match('/^param(\d*)$/', $key, $reg)) // Works for POST['param'], POST['param1'], POST['param2'], ... - { + if (preg_match('/^param(\d*)$/', $key, $reg)) { // Works for POST['param'], POST['param1'], POST['param2'], ... $param = GETPOST("param".$reg[1], 'alpha'); $value = GETPOST("value".$reg[1], 'alpha'); - if ($param) - { + if ($param) { $res = dolibarr_set_const($db, $param, $value, 'chaine', 0, '', $conf->entity); - if (!($res > 0)) $error++; + if (!($res > 0)) { + $error++; + } } } } } // Process upload fields - if (GETPOST('upload', 'alpha') && GETPOST('keyforuploaddir', 'aZ09')) - { + if (GETPOST('upload', 'alpha') && GETPOST('keyforuploaddir', 'aZ09')) { include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; $keyforuploaddir = GETPOST('keyforuploaddir', 'aZ09'); $listofdir = explode(',', preg_replace('/[\r\n]+/', ',', trim($conf->global->$keyforuploaddir))); - foreach ($listofdir as $key=>$tmpdir) - { + foreach ($listofdir as $key => $tmpdir) { $tmpdir = trim($tmpdir); $tmpdir = preg_replace('/DOL_DATA_ROOT/', DOL_DATA_ROOT, $tmpdir); if (!$tmpdir) { @@ -96,24 +90,27 @@ if ($action == 'setModuleOptions') if (empty($nomessageinsetmoduleoptions)) { setEventMessages($langs->trans("ErrorDirNotFound", $tmpdir), null, 'warnings'); } - } - else { + } else { $upload_dir = $tmpdir; } } - if ($upload_dir) - { + if ($upload_dir) { $result = dol_add_file_process($upload_dir, 1, 1, 'uploadfile', ''); - if ($result <= 0) $error++; + if ($result <= 0) { + $error++; + } } } - if (!$error) - { + if (!$error) { $db->commit(); - if (empty($nomessageinsetmoduleoptions)) setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); + if (empty($nomessageinsetmoduleoptions)) { + setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); + } } else { $db->rollback(); - if (empty($nomessageinsetmoduleoptions)) setEventMessages($langs->trans("SetupNotSaved"), null, 'errors'); + if (empty($nomessageinsetmoduleoptions)) { + setEventMessages($langs->trans("SetupNotSaved"), null, 'errors'); + } } } diff --git a/htdocs/core/actions_setnotes.inc.php b/htdocs/core/actions_setnotes.inc.php index b9dd4194268..f2426f6523f 100644 --- a/htdocs/core/actions_setnotes.inc.php +++ b/htdocs/core/actions_setnotes.inc.php @@ -28,23 +28,29 @@ // $id must be defined (object is loaded in this file with fetch) // Set public note -if ($action == 'setnote_public' && !empty($permissionnote) && !GETPOST('cancel', 'alpha')) -{ - if (empty($action) || !is_object($object) || empty($id)) dol_print_error('', 'Include of actions_setnotes.inc.php was done but required variable was not set before'); - if (empty($object->id)) $object->fetch($id); // Fetch may not be already done +if ($action == 'setnote_public' && !empty($permissionnote) && !GETPOST('cancel', 'alpha')) { + if (empty($action) || !is_object($object) || empty($id)) { + dol_print_error('', 'Include of actions_setnotes.inc.php was done but required variable was not set before'); + } + if (empty($object->id)) { + $object->fetch($id); // Fetch may not be already done + } $result_update = $object->update_note(dol_html_entity_decode(GETPOST('note_public', 'restricthtml'), ENT_QUOTES | ENT_HTML5, 'UTF-8', 1), '_public'); - if ($result_update < 0) setEventMessages($object->error, $object->errors, 'errors'); - elseif (in_array($object->table_element, array('supplier_proposal', 'propal', 'commande_fournisseur', 'commande', 'facture_fourn', 'facture'))) - { + if ($result_update < 0) { + setEventMessages($object->error, $object->errors, 'errors'); + } elseif (in_array($object->table_element, array('supplier_proposal', 'propal', 'commande_fournisseur', 'commande', 'facture_fourn', 'facture'))) { // Define output language - if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) - { + if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { $outputlangs = $langs; $newlang = ''; - if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) $newlang = GETPOST('lang_id', 'aZ09'); - if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang; + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) { + $newlang = GETPOST('lang_id', 'aZ09'); + } + if ($conf->global->MAIN_MULTILANGS && empty($newlang)) { + $newlang = $object->thirdparty->default_lang; + } if (!empty($newlang)) { $outputlangs = new Translate("", $conf); $outputlangs->setDefaultLang($newlang); @@ -56,13 +62,21 @@ if ($action == 'setnote_public' && !empty($permissionnote) && !GETPOST('cancel', $result = $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref); - if ($result < 0) dol_print_error($db, $result); + if ($result < 0) { + dol_print_error($db, $result); + } } } } elseif ($action == 'setnote_private' && !empty($permissionnote) && !GETPOST('cancel', 'alpha')) { // Set public note - if (empty($action) || !is_object($object) || empty($id)) dol_print_error('', 'Include of actions_setnotes.inc.php was done but required variable was not set before'); - if (empty($object->id)) $object->fetch($id); // Fetch may not be already done + if (empty($action) || !is_object($object) || empty($id)) { + dol_print_error('', 'Include of actions_setnotes.inc.php was done but required variable was not set before'); + } + if (empty($object->id)) { + $object->fetch($id); // Fetch may not be already done + } $result = $object->update_note(dol_html_entity_decode(GETPOST('note_private', 'restricthtml'), ENT_QUOTES | ENT_HTML5), '_private'); - if ($result < 0) setEventMessages($object->error, $object->errors, 'errors'); + if ($result < 0) { + setEventMessages($object->error, $object->errors, 'errors'); + } } diff --git a/htdocs/core/ajax/ajaxdirpreview.php b/htdocs/core/ajax/ajaxdirpreview.php index 9575208f485..43438c66dc4 100644 --- a/htdocs/core/ajax/ajaxdirpreview.php +++ b/htdocs/core/ajax/ajaxdirpreview.php @@ -27,13 +27,20 @@ * ajaxdirpreview.php?mode=nojs&action=preview&module=ecm§ion=0&file=xxx */ -if (!defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', 1); // Disables token renewal -if (!defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1'); -if (!defined('NOREQUIREHTML')) define('NOREQUIREHTML', '1'); -if (!defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1'); +if (!defined('NOTOKENRENEWAL')) { + define('NOTOKENRENEWAL', 1); // Disables token renewal +} +if (!defined('NOREQUIREMENU')) { + define('NOREQUIREMENU', '1'); +} +if (!defined('NOREQUIREHTML')) { + define('NOREQUIREHTML', '1'); +} +if (!defined('NOREQUIREAJAX')) { + define('NOREQUIREAJAX', '1'); +} -if (!isset($mode) || $mode != 'noajax') // For ajax call -{ +if (!isset($mode) || $mode != 'noajax') { // For ajax call require_once '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; @@ -50,12 +57,18 @@ if (!isset($mode) || $mode != 'noajax') // For ajax call $sortfield = GETPOST("sortfield", 'alpha'); $sortorder = GETPOST("sortorder", 'alpha'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); - if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 + if (empty($page) || $page == -1) { + $page = 0; + } // If $page is not defined, or '' or -1 $offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; - if (!$sortorder) $sortorder = "ASC"; - if (!$sortfield) $sortfield = "name"; + if (!$sortorder) { + $sortorder = "ASC"; + } + if (!$sortfield) { + $sortfield = "name"; + } $rootdirfordoc = $conf->ecm->dir_output; @@ -64,8 +77,7 @@ if (!isset($mode) || $mode != 'noajax') // For ajax call $ecmdir = new EcmDirectory($db); if ($section > 0) { $result = $ecmdir->fetch($section); - if (!$result > 0) - { + if (!$result > 0) { //dol_print_error($db,$ecmdir->error); //exit; } @@ -76,18 +88,15 @@ if (!isset($mode) || $mode != 'noajax') // For ajax call $ecmdir = new EcmDirectory($db); $relativepath = ''; - if ($section > 0) - { + if ($section > 0) { $result = $ecmdir->fetch($section); - if (!$result > 0) - { + if (!$result > 0) { dol_print_error($db, $ecmdir->error); exit; } $relativepath = $ecmdir->getRelativePath(); // Example 'mydir/' - } elseif (GETPOST('section_dir')) - { + } elseif (GETPOST('section_dir')) { $relativepath = GETPOST('section_dir'); } //var_dump($section.'-'.GETPOST('section_dir').'-'.$relativepath); @@ -95,24 +104,27 @@ if (!isset($mode) || $mode != 'noajax') // For ajax call $upload_dir = $rootdirfordoc.'/'.$relativepath; } -if (empty($url)) -{ - if (GETPOSTISSET('website')) $url = DOL_URL_ROOT.'/website/index.php'; - else $url = DOL_URL_ROOT.'/ecm/index.php'; +if (empty($url)) { + if (GETPOSTISSET('website')) { + $url = DOL_URL_ROOT.'/website/index.php'; + } else { + $url = DOL_URL_ROOT.'/ecm/index.php'; + } } // Load translation files required by the page $langs->loadLangs(array("ecm", "companies", "other")); // Security check -if ($user->socid > 0) $socid = $user->socid; +if ($user->socid > 0) { + $socid = $user->socid; +} //print 'xxx'.$upload_dir; // Security: // On interdit les remontees de repertoire ainsi que les pipe dans les noms de fichiers. -if (preg_match('/\.\./', $upload_dir) || preg_match('/[<>|]/', $upload_dir)) -{ +if (preg_match('/\.\./', $upload_dir) || preg_match('/[<>|]/', $upload_dir)) { dol_syslog("Refused to deliver file ".$upload_dir); // Do no show plain path in shown error message dol_print_error(0, $langs->trans("ErrorFileNameInvalid", $upload_dir)); @@ -120,12 +132,12 @@ if (preg_match('/\.\./', $upload_dir) || preg_match('/[<>|]/', $upload_dir)) } // Check permissions -if ($modulepart == 'ecm') -{ - if (!$user->rights->ecm->read) accessforbidden(); +if ($modulepart == 'ecm') { + if (!$user->rights->ecm->read) { + accessforbidden(); + } } -if ($modulepart == 'medias') -{ +if ($modulepart == 'medias') { // Always allowed } @@ -142,8 +154,7 @@ if ($modulepart == 'medias') * View */ -if (!isset($mode) || $mode != 'noajax') -{ +if (!isset($mode) || $mode != 'noajax') { // Ajout directives pour resoudre bug IE header('Cache-Control: Public, must-revalidate'); header('Pragma: public'); @@ -154,25 +165,27 @@ if (!isset($mode) || $mode != 'noajax') $type = 'directory'; // This test if file exists should be useless. We keep it to find bug more easily -if (!dol_is_dir($upload_dir)) -{ +if (!dol_is_dir($upload_dir)) { //dol_mkdir($upload_dir); /*$langs->load("install"); - dol_print_error(0,$langs->trans("ErrorDirDoesNotExists",$upload_dir)); - exit;*/ + dol_print_error(0,$langs->trans("ErrorDirDoesNotExists",$upload_dir)); + exit;*/ } print ''."\n"; //print ''."\n"; $param = ($sortfield ? '&sortfield='.urlencode($sortfield) : '').($sortorder ? '&sortorder='.urlencode($sortorder) : ''); -if (!empty($websitekey)) $param .= '&website='.urlencode($websitekey); -if (!empty($pageid)) $param .= '&pageid='.urlencode($pageid); +if (!empty($websitekey)) { + $param .= '&website='.urlencode($websitekey); +} +if (!empty($pageid)) { + $param .= '&pageid='.urlencode($pageid); +} // Dir scan -if ($type == 'directory') -{ +if ($type == 'directory') { $formfile = new FormFile($db); $maxlengthname = 40; @@ -203,31 +216,48 @@ if ($type == 'directory') $parameters = array('modulepart'=>$module); $reshook = $hookmanager->executeHooks('addSectionECMAuto', $parameters); - if ($reshook > 0 && is_array($hookmanager->resArray) && count($hookmanager->resArray)>0) - { + if ($reshook > 0 && is_array($hookmanager->resArray) && count($hookmanager->resArray)>0) { $automodules[]=$hookmanager->resArray['module']; } // TODO change for multicompany sharing - if ($module == 'company') $upload_dir = $conf->societe->dir_output; - elseif ($module == 'invoice') $upload_dir = $conf->facture->dir_output; - elseif ($module == 'invoice_supplier') $upload_dir = $conf->fournisseur->facture->dir_output; - elseif ($module == 'propal') $upload_dir = $conf->propal->dir_output; - elseif ($module == 'supplier_proposal') $upload_dir = $conf->supplier_proposal->dir_output; - elseif ($module == 'order') $upload_dir = $conf->commande->dir_output; - elseif ($module == 'order_supplier') $upload_dir = $conf->fournisseur->commande->dir_output; - elseif ($module == 'contract') $upload_dir = $conf->contrat->dir_output; - elseif ($module == 'product') $upload_dir = $conf->product->dir_output; - elseif ($module == 'tax') $upload_dir = $conf->tax->dir_output; - elseif ($module == 'project') $upload_dir = $conf->projet->dir_output; - elseif ($module == 'fichinter') $upload_dir = $conf->ficheinter->dir_output; - elseif ($module == 'user') $upload_dir = $conf->user->dir_output; - elseif ($module == 'expensereport') $upload_dir = $conf->expensereport->dir_output; - elseif ($module == 'holiday') $upload_dir = $conf->holiday->dir_output; - elseif ($module == 'recruitment-recruitmentcandidature') $upload_dir = $conf->recruitment->dir_output.'/recruitmentcandidature'; - elseif ($module == 'banque') $upload_dir = $conf->bank->dir_output; - elseif ($module == 'mrp-mo') $upload_dir = $conf->mrp->dir_output.'/mo'; - else { + if ($module == 'company') { + $upload_dir = $conf->societe->dir_output; + } elseif ($module == 'invoice') { + $upload_dir = $conf->facture->dir_output; + } elseif ($module == 'invoice_supplier') { + $upload_dir = $conf->fournisseur->facture->dir_output; + } elseif ($module == 'propal') { + $upload_dir = $conf->propal->dir_output; + } elseif ($module == 'supplier_proposal') { + $upload_dir = $conf->supplier_proposal->dir_output; + } elseif ($module == 'order') { + $upload_dir = $conf->commande->dir_output; + } elseif ($module == 'order_supplier') { + $upload_dir = $conf->fournisseur->commande->dir_output; + } elseif ($module == 'contract') { + $upload_dir = $conf->contrat->dir_output; + } elseif ($module == 'product') { + $upload_dir = $conf->product->dir_output; + } elseif ($module == 'tax') { + $upload_dir = $conf->tax->dir_output; + } elseif ($module == 'project') { + $upload_dir = $conf->projet->dir_output; + } elseif ($module == 'fichinter') { + $upload_dir = $conf->ficheinter->dir_output; + } elseif ($module == 'user') { + $upload_dir = $conf->user->dir_output; + } elseif ($module == 'expensereport') { + $upload_dir = $conf->expensereport->dir_output; + } elseif ($module == 'holiday') { + $upload_dir = $conf->holiday->dir_output; + } elseif ($module == 'recruitment-recruitmentcandidature') { + $upload_dir = $conf->recruitment->dir_output.'/recruitmentcandidature'; + } elseif ($module == 'banque') { + $upload_dir = $conf->bank->dir_output; + } elseif ($module == 'mrp-mo') { + $upload_dir = $conf->mrp->dir_output.'/mo'; + } else { $parameters = array('modulepart'=>$module); $reshook = $hookmanager->executeHooks('addSectionECMAuto', $parameters); if ($reshook > 0 && is_array($hookmanager->resArray) && count($hookmanager->resArray) > 0) { @@ -236,14 +266,17 @@ if ($type == 'directory') } // Automatic list - if (in_array($module, $automodules)) - { + if (in_array($module, $automodules)) { $param .= '&module='.$module; - if (isset($search_doc_ref) && $search_doc_ref != '') $param .= '&search_doc_ref='.urlencode($search_doc_ref); + if (isset($search_doc_ref) && $search_doc_ref != '') { + $param .= '&search_doc_ref='.urlencode($search_doc_ref); + } $textifempty = ($section ? $langs->trans("NoFileFound") : ($showonrightsize == 'featurenotyetavailable' ? $langs->trans("FeatureNotYetAvailable") : $langs->trans("NoFileFound"))); - if ($module == 'company') $excludefiles[] = '^contact$'; // The subdir 'contact' contains files of contacts with no id of thirdparty. + if ($module == 'company') { + $excludefiles[] = '^contact$'; // The subdir 'contact' contains files of contacts with no id of thirdparty. + } $filter = preg_quote($search_doc_ref, '/'); $filearray = dol_dir_list($upload_dir, "files", 1, $filter, $excludefiles, $sortfield, $sorting, 1); @@ -254,11 +287,10 @@ if ($type == 'directory') } // Manual list else { - if ($module == 'medias') - { + if ($module == 'medias') { /* - $_POST is array like - 'token' => string '062380e11b7dcd009d07318b57b71750' (length=32) + $_POST is array like + 'token' => string '062380e11b7dcd009d07318b57b71750' (length=32) 'action' => string 'file_manager' (length=12) 'website' => string 'template' (length=8) 'pageid' => string '124' (length=3) @@ -266,15 +298,20 @@ if ($type == 'directory') 'section_id' => string '0' (length=1) 'max_file_size' => string '2097152' (length=7) 'sendit' => string 'Envoyer fichier' (length=15) - */ + */ $relativepath = GETPOST('file', 'alpha') ?GETPOST('file', 'alpha') : GETPOST('section_dir', 'alpha'); - if ($relativepath && $relativepath != '/') $relativepath .= '/'; + if ($relativepath && $relativepath != '/') { + $relativepath .= '/'; + } $upload_dir = $dolibarr_main_data_root.'/'.$module.'/'.$relativepath; - if (GETPOSTISSET('website') || GETPOSTISSET('file_manager')) - { + if (GETPOSTISSET('website') || GETPOSTISSET('file_manager')) { $param .= '&file_manager=1'; - if (!preg_match('/website=/', $param)) $param .= '&website='.urlencode(GETPOST('website', 'alpha')); - if (!preg_match('/pageid=/', $param)) $param .= '&pageid='.urlencode(GETPOST('pageid', 'int')); + if (!preg_match('/website=/', $param)) { + $param .= '&website='.urlencode(GETPOST('website', 'alpha')); + } + if (!preg_match('/pageid=/', $param)) { + $param .= '&pageid='.urlencode(GETPOST('pageid', 'int')); + } //if (!preg_match('/backtopage=/',$param)) $param.='&backtopage='.urlencode($_SERVER["PHP_SELF"].'?file_manager=1&website='.$websitekey.'&pageid='.$pageid); } } else { @@ -283,47 +320,46 @@ if ($type == 'directory') } // If $section defined with value 0 - if (($section === '0' || empty($section)) && ($module != 'medias')) - { + if (($section === '0' || empty($section)) && ($module != 'medias')) { $filearray = array(); } else { $filearray = dol_dir_list($upload_dir, "files", 0, '', array('^\.', '(\.meta|_preview.*\.png)$', '^temp$', '^CVS$'), $sortfield, $sorting, 1); } - if ($section) - { + if ($section) { $param .= '§ion='.$section; - if (isset($search_doc_ref) && $search_doc_ref != '') $param .= '&search_doc_ref='.$search_doc_ref; + if (isset($search_doc_ref) && $search_doc_ref != '') { + $param .= '&search_doc_ref='.$search_doc_ref; + } $textifempty = $langs->trans('NoFileFound'); - } elseif ($section === '0') - { - if ($module == 'ecm') $textifempty = '
'.$langs->trans("DirNotSynchronizedSyncFirst").'

'; - else $textifempty = $langs->trans('NoFileFound'); - } else $textifempty = ($showonrightsize == 'featurenotyetavailable' ? $langs->trans("FeatureNotYetAvailable") : $langs->trans("ECMSelectASection")); + } elseif ($section === '0') { + if ($module == 'ecm') { + $textifempty = '
'.$langs->trans("DirNotSynchronizedSyncFirst").'

'; + } else { + $textifempty = $langs->trans('NoFileFound'); + } + } else { + $textifempty = ($showonrightsize == 'featurenotyetavailable' ? $langs->trans("FeatureNotYetAvailable") : $langs->trans("ECMSelectASection")); + } - if ($module == 'medias') - { + if ($module == 'medias') { $useinecm = 6; $modulepart = 'medias'; $perm = ($user->rights->website->write || $user->rights->emailing->creer); $title = 'none'; - } elseif ($module == 'ecm') // DMS/ECM -> manual structure - { - if ($user->rights->ecm->read) - { + } elseif ($module == 'ecm') { // DMS/ECM -> manual structure + if ($user->rights->ecm->read) { // Buttons: Preview $useinecm = 2; } - if ($user->rights->ecm->upload) - { + if ($user->rights->ecm->upload) { // Buttons: Preview + Delete $useinecm = 4; } - if ($user->rights->ecm->setup) - { + if ($user->rights->ecm->setup) { // Buttons: Preview + Delete + Edit $useinecm = 5; } @@ -349,18 +385,27 @@ if ($type == 'directory') // Bottom of page $useajax = 1; -if (!empty($conf->dol_use_jmobile)) $useajax = 0; -if (empty($conf->use_javascript_ajax)) $useajax = 0; -if (!empty($conf->global->MAIN_ECM_DISABLE_JS)) $useajax = 0; +if (!empty($conf->dol_use_jmobile)) { + $useajax = 0; +} +if (empty($conf->use_javascript_ajax)) { + $useajax = 0; +} +if (!empty($conf->global->MAIN_ECM_DISABLE_JS)) { + $useajax = 0; +} //$param.=($param?'?':'').(preg_replace('/^&/','',$param)); -if ($useajax || $action == 'delete') -{ +if ($useajax || $action == 'delete') { $urlfile = ''; - if ($action == 'delete') $urlfile = GETPOST('urlfile', 'alpha'); + if ($action == 'delete') { + $urlfile = GETPOST('urlfile', 'alpha'); + } - if (empty($section_dir)) $section_dir = GETPOST("file", "alpha"); + if (empty($section_dir)) { + $section_dir = GETPOST("file", "alpha"); + } $section_id = $section; require_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php'; @@ -372,22 +417,26 @@ if ($useajax || $action == 'delete') $formquestion['section_dir'] = array('type'=>'hidden', 'value'=>$section_dir, 'name'=>'section_dir'); // We must always put field, even if empty because it is filled by javascript later $formquestion['sortfield'] = array('type'=>'hidden', 'value'=>$sortfield, 'name'=>'sortfield'); // We must always put field, even if empty because it is filled by javascript later $formquestion['sortorder'] = array('type'=>'hidden', 'value'=>$sortorder, 'name'=>'sortorder'); // We must always put field, even if empty because it is filled by javascript later - if (!empty($action) && $action == 'file_manager') $formquestion['file_manager'] = array('type'=>'hidden', 'value'=>1, 'name'=>'file_manager'); - if (!empty($websitekey)) $formquestion['website'] = array('type'=>'hidden', 'value'=>$websitekey, 'name'=>'website'); - if (!empty($pageid) && $pageid > 0) $formquestion['pageid'] = array('type'=>'hidden', 'value'=>$pageid, 'name'=>'pageid'); + if (!empty($action) && $action == 'file_manager') { + $formquestion['file_manager'] = array('type'=>'hidden', 'value'=>1, 'name'=>'file_manager'); + } + if (!empty($websitekey)) { + $formquestion['website'] = array('type'=>'hidden', 'value'=>$websitekey, 'name'=>'website'); + } + if (!empty($pageid) && $pageid > 0) { + $formquestion['pageid'] = array('type'=>'hidden', 'value'=>$pageid, 'name'=>'pageid'); + } print $form->formconfirm($url, $langs->trans("DeleteFile"), $langs->trans("ConfirmDeleteFile"), 'confirm_deletefile', $formquestion, "no", ($useajax ? 'deletefile' : 0)); } -if ($useajax) -{ +if ($useajax) { print ''."\n"; } - if (empty($found)) - { + if (empty($found)) { $out .= 'Error, unknown value for tool '.$this->tool.' in DolEditor Create function.'; } - if ($noprint) return $out; - else print $out; + if ($noprint) { + return $out; + } else { + print $out; + } } } diff --git a/htdocs/core/class/dolgeoip.class.php b/htdocs/core/class/dolgeoip.class.php index 98fbe62e4c5..0eecbbf6d36 100644 --- a/htdocs/core/class/dolgeoip.class.php +++ b/htdocs/core/class/dolgeoip.class.php @@ -46,54 +46,48 @@ class DolGeoIP global $conf; $geoipversion = '2'; // 'php', or '2' - if (!empty($conf->global->GEOIP_VERSION)) $geoipversion = $conf->global->GEOIP_VERSION; + if (!empty($conf->global->GEOIP_VERSION)) { + $geoipversion = $conf->global->GEOIP_VERSION; + } - if ($type == 'country') - { + if ($type == 'country') { // geoip may have been already included with PEAR - if ($geoipversion == '2' || ($geoipversion != 'php' && !function_exists('geoip_country_code_by_name'))) - { + if ($geoipversion == '2' || ($geoipversion != 'php' && !function_exists('geoip_country_code_by_name'))) { require_once DOL_DOCUMENT_ROOT.'/includes/geoip2/geoip2.phar'; } - } elseif ($type == 'city') - { + } elseif ($type == 'city') { // geoip may have been already included with PEAR - if ($geoipversion == '2' || ($geoipversion != 'php' && !function_exists('geoip_country_code_by_name'))) - { + if ($geoipversion == '2' || ($geoipversion != 'php' && !function_exists('geoip_country_code_by_name'))) { require_once DOL_DOCUMENT_ROOT.'/includes/geoip2/geoip2.phar'; } - } else { print 'ErrorBadParameterInConstructor'; return 0; } + } else { + print 'ErrorBadParameterInConstructor'; return 0; + } // Here, function exists (embedded into PHP or exists because we made include) - if (empty($type) || empty($datfile)) - { + if (empty($type) || empty($datfile)) { $this->errorlabel = 'Constructor was called with no datafile parameter'; dol_syslog('DolGeoIP '.$this->errorlabel, LOG_ERR); return 0; } - if (!file_exists($datfile) || !is_readable($datfile)) - { + if (!file_exists($datfile) || !is_readable($datfile)) { $this->error = 'ErrorGeoIPClassNotInitialized'; $this->errorlabel = "Datafile ".$datfile." not found"; dol_syslog('DolGeoIP '.$this->errorlabel, LOG_ERR); return 0; } - if ($geoipversion == '2') - { + if ($geoipversion == '2') { try { $this->gi = new GeoIp2\Database\Reader($datfile); // '/usr/local/share/GeoIP/GeoIP2-City.mmdb' - } catch (Exception $e) - { + } catch (Exception $e) { $this->error = $e->getMessage(); dol_syslog('DolGeoIP '.$this->errorlabel, LOG_ERR); return 0; } - } elseif (function_exists('geoip_open')) - { + } elseif (function_exists('geoip_open')) { $this->gi = geoip_open($datfile, GEOIP_STANDARD); - } - elseif (function_exists('geoip_country_code_by_name')) { + } elseif (function_exists('geoip_country_code_by_name')) { $this->gi = 'NOGI'; // We are using embedded php geoip functions //print 'function_exists(geoip_country_code_by_name))='.function_exists('geoip_country_code_by_name'); //print geoip_database_info(); @@ -113,21 +107,19 @@ class DolGeoIP global $conf; $geoipversion = '2'; // 'php', or '2' - if (!empty($conf->global->GEOIP_VERSION)) $geoipversion = $conf->global->GEOIP_VERSION; + if (!empty($conf->global->GEOIP_VERSION)) { + $geoipversion = $conf->global->GEOIP_VERSION; + } - if (empty($this->gi)) - { + if (empty($this->gi)) { return ''; } - if ($this->gi == 'NOGI') - { + if ($this->gi == 'NOGI') { // geoip_country_code_by_addr does not exists return strtolower(geoip_country_code_by_name($ip)); } else { - if (preg_match('/^[0-9]+.[0-9]+\.[0-9]+\.[0-9]+/', $ip)) - { - if ($geoipversion == '2') - { + if (preg_match('/^[0-9]+.[0-9]+\.[0-9]+\.[0-9]+/', $ip)) { + if ($geoipversion == '2') { try { $record = $this->gi->country($ip); return strtolower($record->country->isoCode); @@ -136,12 +128,13 @@ class DolGeoIP return ''; } } else { - if (!function_exists('geoip_country_code_by_addr')) return strtolower(geoip_country_code_by_name($this->gi, $ip)); + if (!function_exists('geoip_country_code_by_addr')) { + return strtolower(geoip_country_code_by_name($this->gi, $ip)); + } return strtolower(geoip_country_code_by_addr($this->gi, $ip)); } } else { - if ($geoipversion == '2') - { + if ($geoipversion == '2') { try { $record = $this->gi->country($ip); return strtolower($record->country->isoCode); @@ -150,7 +143,9 @@ class DolGeoIP return ''; } } else { - if (!function_exists('geoip_country_code_by_addr_v6')) return strtolower(geoip_country_code_by_name_v6($this->gi, $ip)); + if (!function_exists('geoip_country_code_by_addr_v6')) { + return strtolower(geoip_country_code_by_name_v6($this->gi, $ip)); + } return strtolower(geoip_country_code_by_addr_v6($this->gi, $ip)); } } @@ -168,15 +163,15 @@ class DolGeoIP global $conf; $geoipversion = '2'; // 'php', or '2' - if (!empty($conf->global->GEOIP_VERSION)) $geoipversion = $conf->global->GEOIP_VERSION; + if (!empty($conf->global->GEOIP_VERSION)) { + $geoipversion = $conf->global->GEOIP_VERSION; + } - if (empty($this->gi)) - { + if (empty($this->gi)) { return ''; } - if ($geoipversion == '2') - { + if ($geoipversion == '2') { try { $record = $this->gi->country($name); return $record->country->isoCode; @@ -199,12 +194,16 @@ class DolGeoIP global $conf; $geoipversion = '2'; // 'php', or '2' - if (!empty($conf->global->GEOIP_VERSION)) $geoipversion = $conf->global->GEOIP_VERSION; + if (!empty($conf->global->GEOIP_VERSION)) { + $geoipversion = $conf->global->GEOIP_VERSION; + } - if ($geoipversion == 'php') - { - if ($this->gi == 'NOGI') return geoip_database_info(); - else return 'geoip_database_info() function not available'; + if ($geoipversion == 'php') { + if ($this->gi == 'NOGI') { + return geoip_database_info(); + } else { + return 'geoip_database_info() function not available'; + } } return 'Not available (not using PHP internal geo functions - We are using embedded Geoip v'.$geoipversion.')'; diff --git a/htdocs/core/class/dolgraph.class.php b/htdocs/core/class/dolgraph.class.php index fada0975938..607993dc325 100644 --- a/htdocs/core/class/dolgraph.class.php +++ b/htdocs/core/class/dolgraph.class.php @@ -114,9 +114,15 @@ class DolGraph $color_file = DOL_DOCUMENT_ROOT . '/theme/' . $conf->theme . '/theme_vars.inc.php'; if (is_readable($color_file)) { include_once $color_file; - if (isset($theme_bordercolor)) $this->bordercolor = $theme_bordercolor; - if (isset($theme_datacolor)) $this->datacolor = $theme_datacolor; - if (isset($theme_bgcolor)) $this->bgcolor = $theme_bgcolor; + if (isset($theme_bordercolor)) { + $this->bordercolor = $theme_bordercolor; + } + if (isset($theme_datacolor)) { + $this->datacolor = $theme_datacolor; + } + if (isset($theme_bgcolor)) { + $this->bgcolor = $theme_bgcolor; + } } //print 'bgcolor: '.join(',',$this->bgcolor).'
'; @@ -597,7 +603,9 @@ class DolGraph public function GetMaxValueInData() { // phpcs:enable - if (!is_array($this->data)) return 0; + if (!is_array($this->data)) { + return 0; + } $k = 0; $vals = array(); @@ -624,7 +632,9 @@ class DolGraph public function GetMinValueInData() { // phpcs:enable - if (!is_array($this->data)) return 0; + if (!is_array($this->data)) { + return 0; + } $k = 0; $vals = array(); @@ -652,7 +662,9 @@ class DolGraph { // phpcs:enable $max = $this->GetMaxValueInData(); - if ($max != 0) $max++; + if ($max != 0) { + $max++; + } $size = dol_strlen(abs(ceil($max))); $factor = 1; for ($i = 0; $i < ($size - 1); $i++) { @@ -660,7 +672,9 @@ class DolGraph } $res = 0; - if (is_numeric($max)) $res = ceil($max / $factor) * $factor; + if (is_numeric($max)) { + $res = ceil($max / $factor) * $factor; + } //print "max=".$max." res=".$res; return $res; @@ -676,8 +690,12 @@ class DolGraph { // phpcs:enable $min = $this->GetMinValueInData(); - if ($min == '') $min = 0; - if ($min != 0) $min--; + if ($min == '') { + $min = 0; + } + if ($min != 0) { + $min--; + } $size = dol_strlen(abs(floor($min))); $factor = 1; for ($i = 0; $i < ($size - 1); $i++) { @@ -751,22 +769,22 @@ class DolGraph if (is_array($this->data) && is_array($this->data[0])) { $nblot = count($this->data[0]) - 1; // -1 to remove legend } - if ($nblot < 0) dol_syslog('Bad value for property ->data. Must be set by mydolgraph->SetData before calling mydolgrapgh->draw', LOG_WARNING); + if ($nblot < 0) { + dol_syslog('Bad value for property ->data. Must be set by mydolgraph->SetData before calling mydolgrapgh->draw', LOG_WARNING); + } $firstlot = 0; // Works with line but not with bars //if ($nblot > 2) $firstlot = ($nblot - 2); // We limit nblot to 2 because jflot can't manage more than 2 bars on same x $i = $firstlot; $serie = array(); - while ($i < $nblot) // Loop on each serie - { + while ($i < $nblot) { // Loop on each serie $values = array(); // Array with horizontal y values (specific values of a serie) for each abscisse x $serie[$i] = "var d" . $i . " = [];\n"; // Fill array $values $x = 0; - foreach ($this->data as $valarray) // Loop on each x - { + foreach ($this->data as $valarray) { // Loop on each x $legends[$x] = $valarray[0]; $values[$x] = (is_numeric($valarray[$i + 1]) ? $valarray[$i + 1] : null); $x++; @@ -774,11 +792,15 @@ class DolGraph if (isset($this->type[$firstlot]) && in_array($this->type[$firstlot], array('pie', 'piesemicircle', 'polar'))) { foreach ($values as $x => $y) { - if (isset($y)) $serie[$i] .= 'd' . $i . '.push({"label":"' . dol_escape_js($legends[$x]) . '", "data":' . $y . '});' . "\n"; + if (isset($y)) { + $serie[$i] .= 'd' . $i . '.push({"label":"' . dol_escape_js($legends[$x]) . '", "data":' . $y . '});' . "\n"; + } } } else { foreach ($values as $x => $y) { - if (isset($y)) $serie[$i] .= 'd' . $i . '.push([' . $x . ', ' . $y . ']);' . "\n"; + if (isset($y)) { + $serie[$i] .= 'd' . $i . '.push([' . $x . ', ' . $y . ']);' . "\n"; + } } } @@ -788,7 +810,9 @@ class DolGraph $tag = dol_escape_htmltag(dol_string_unaccent(dol_string_nospecial(basename($file), '_', array('-', '.')))); $this->stringtoshow = '' . "\n"; - if (!empty($this->title)) $this->stringtoshow .= '
' . $this->title . '
'; + if (!empty($this->title)) { + $this->stringtoshow .= '
' . $this->title . '
'; + } if (!empty($this->shownographyet)) { $this->stringtoshow .= '
'; $this->stringtoshow .= '
' . $langs->trans("NotEnoughDataYet") . '...
'; @@ -797,7 +821,9 @@ class DolGraph // Start the div that will contains all the graph $dolxaxisvertical = ''; - if (count($this->data) > 20) $dolxaxisvertical = 'dol-xaxis-vertical'; + if (count($this->data) > 20) { + $dolxaxisvertical = 'dol-xaxis-vertical'; + } $this->stringtoshow .= '
' . "\n"; $this->stringtoshow .= '";*/ + $retstring.=img_object($langs->trans("SelectDate"),'calendarday','id="'.$prefix.'id" class="datecallink"'); + $retstring.="";*/ } else { $retstringbutton = ''; $retsring = $retstringbutton.$retstring; @@ -5818,27 +6148,23 @@ class Form // Day $retstring .= ''; - if ($emptydate || $set_time == -1) - { + if ($emptydate || $set_time == -1) { $retstring .= ''; } - for ($day = 1; $day <= 31; $day++) - { + for ($day = 1; $day <= 31; $day++) { $retstring .= ''; } $retstring .= ""; $retstring .= ''; - if ($emptydate || $set_time == -1) - { + if ($emptydate || $set_time == -1) { $retstring .= ''; } // Month - for ($month = 1; $month <= 12; $month++) - { + for ($month = 1; $month <= 12; $month++) { $retstring .= '"; @@ -5846,14 +6172,12 @@ class Form $retstring .= ""; // Year - if ($emptydate || $set_time == -1) - { + if ($emptydate || $set_time == -1) { $retstring .= ''; } else { $retstring .= ''; - for ($year = $syear - 10; $year < $syear + 10; $year++) - { + for ($year = $syear - 10; $year < $syear + 10; $year++) { $retstring .= ''; } $retstring .= "\n"; @@ -5866,39 +6190,47 @@ class Form $retstring .= ''; } - if ($h) - { + if ($h) { $hourstart = 0; $hourend = 24; if ($openinghours != '') { $openinghours = explode(',', $openinghours); $hourstart = $openinghours[0]; $hourend = $openinghours[1]; - if ($hourend < $hourstart) $hourend = $hourstart; + if ($hourend < $hourstart) { + $hourend = $hourstart; + } } // Show hour $retstring .= ''; - if ($emptyhours) $retstring .= ''; - for ($hour = $hourstart; $hour < $hourend; $hour++) - { - if (strlen($hour) < 2) $hour = "0".$hour; + if ($emptyhours) { + $retstring .= ''; + } + for ($hour = $hourstart; $hour < $hourend; $hour++) { + if (strlen($hour) < 2) { + $hour = "0".$hour; + } $retstring .= ''; } $retstring .= ''; //if ($m && empty($conf->dol_optimize_smallscreen)) $retstring .= ":"; - if ($m) $retstring .= ":"; + if ($m) { + $retstring .= ":"; + } } - if ($m) - { + if ($m) { // Show minutes $retstring .= ''; - if ($emptyhours) $retstring .= ''; - for ($min = 0; $min < 60; $min += $stepminutes) - { - if (strlen($min) < 2) $min = "0".$min; + if ($emptyhours) { + $retstring .= ''; + } + for ($min = 0; $min < 60; $min += $stepminutes) { + if (strlen($min) < 2) { + $min = "0".$min; + } $retstring .= ''; } $retstring .= ''; @@ -5911,8 +6243,7 @@ class Form } // Add a "Now" link - if ($conf->use_javascript_ajax && $addnowlink) - { + if ($conf->use_javascript_ajax && $addnowlink) { // Script which will be inserted in the onClick of the "Now" link $reset_scripts = ""; if ($addnowlink == 2) { // local computer time @@ -5933,64 +6264,65 @@ class Form $reset_scripts .= 'jQuery(\'#'.$prefix.'year\').val(\''.dol_print_date($nowgmt, '%Y', 'tzuserrel').'\');'; } elseif ($addnowlink == 2) { /* Disabled because the output does not use the string format defined by FormatDateShort key to forge the value into #prefix. - * This break application for foreign languages. - $reset_scripts .= 'jQuery(\'#'.$prefix.'\').val(d.toLocaleDateString(\''.str_replace('_', '-', $langs->defaultlang).'\'));'; - $reset_scripts .= 'jQuery(\'#'.$prefix.'day\').val(d.getDate().pad());'; - $reset_scripts .= 'jQuery(\'#'.$prefix.'month\').val(parseInt(d.getMonth().pad()) + 1);'; - $reset_scripts .= 'jQuery(\'#'.$prefix.'year\').val(d.getFullYear());'; - */ + * This break application for foreign languages. + $reset_scripts .= 'jQuery(\'#'.$prefix.'\').val(d.toLocaleDateString(\''.str_replace('_', '-', $langs->defaultlang).'\'));'; + $reset_scripts .= 'jQuery(\'#'.$prefix.'day\').val(d.getDate().pad());'; + $reset_scripts .= 'jQuery(\'#'.$prefix.'month\').val(parseInt(d.getMonth().pad()) + 1);'; + $reset_scripts .= 'jQuery(\'#'.$prefix.'year\').val(d.getFullYear());'; + */ $reset_scripts .= 'jQuery(\'#'.$prefix.'\').val(\''.dol_print_date($nowgmt, 'day', 'tzuserrel').'\');'; $reset_scripts .= 'jQuery(\'#'.$prefix.'day\').val(\''.dol_print_date($nowgmt, '%d', 'tzuserrel').'\');'; $reset_scripts .= 'jQuery(\'#'.$prefix.'month\').val(\''.dol_print_date($nowgmt, '%m', 'tzuserrel').'\');'; $reset_scripts .= 'jQuery(\'#'.$prefix.'year\').val(\''.dol_print_date($nowgmt, '%Y', 'tzuserrel').'\');'; } /*if ($usecalendar == "eldy") - { - $base=DOL_URL_ROOT.'/core/'; - $reset_scripts .= 'resetDP(\''.$base.'\',\''.$prefix.'\',\''.$langs->trans("FormatDateShortJavaInput").'\',\''.$langs->defaultlang.'\');'; - } - else - { - $reset_scripts .= 'this.form.elements[\''.$prefix.'day\'].value=formatDate(new Date(), \'d\'); '; - $reset_scripts .= 'this.form.elements[\''.$prefix.'month\'].value=formatDate(new Date(), \'M\'); '; - $reset_scripts .= 'this.form.elements[\''.$prefix.'year\'].value=formatDate(new Date(), \'yyyy\'); '; - }*/ - // Update the hour part - if ($h) { - if ($fullday) $reset_scripts .= " if (jQuery('#fullday:checked').val() == null) {"; + $base=DOL_URL_ROOT.'/core/'; + $reset_scripts .= 'resetDP(\''.$base.'\',\''.$prefix.'\',\''.$langs->trans("FormatDateShortJavaInput").'\',\''.$langs->defaultlang.'\');'; + } + else + { + $reset_scripts .= 'this.form.elements[\''.$prefix.'day\'].value=formatDate(new Date(), \'d\'); '; + $reset_scripts .= 'this.form.elements[\''.$prefix.'month\'].value=formatDate(new Date(), \'M\'); '; + $reset_scripts .= 'this.form.elements[\''.$prefix.'year\'].value=formatDate(new Date(), \'yyyy\'); '; + }*/ + // Update the hour part + if ($h) { + if ($fullday) { + $reset_scripts .= " if (jQuery('#fullday:checked').val() == null) {"; + } //$reset_scripts .= 'this.form.elements[\''.$prefix.'hour\'].value=formatDate(new Date(), \'HH\'); '; - if ($addnowlink == 1) - { + if ($addnowlink == 1) { $reset_scripts .= 'jQuery(\'#'.$prefix.'hour\').val(\''.dol_print_date($nowgmt, '%H', 'tzuserrel').'\');'; $reset_scripts .= 'jQuery(\'#'.$prefix.'hour\').change();'; - } elseif ($addnowlink == 2) - { + } elseif ($addnowlink == 2) { $reset_scripts .= 'jQuery(\'#'.$prefix.'hour\').val(d.getHours().pad());'; $reset_scripts .= 'jQuery(\'#'.$prefix.'hour\').change();'; } - if ($fullday) $reset_scripts .= ' } '; + if ($fullday) { + $reset_scripts .= ' } '; + } } // Update the minute part - if ($m) - { - if ($fullday) $reset_scripts .= " if (jQuery('#fullday:checked').val() == null) {"; + if ($m) { + if ($fullday) { + $reset_scripts .= " if (jQuery('#fullday:checked').val() == null) {"; + } //$reset_scripts .= 'this.form.elements[\''.$prefix.'min\'].value=formatDate(new Date(), \'mm\'); '; - if ($addnowlink == 1) - { + if ($addnowlink == 1) { $reset_scripts .= 'jQuery(\'#'.$prefix.'min\').val(\''.dol_print_date($nowgmt, '%M', 'tzuserrel').'\');'; $reset_scripts .= 'jQuery(\'#'.$prefix.'min\').change();'; - } elseif ($addnowlink == 2) - { + } elseif ($addnowlink == 2) { $reset_scripts .= 'jQuery(\'#'.$prefix.'min\').val(d.getMinutes().pad());'; $reset_scripts .= 'jQuery(\'#'.$prefix.'min\').change();'; } - if ($fullday) $reset_scripts .= ' } '; + if ($fullday) { + $reset_scripts .= ' } '; + } } // If reset_scripts is not empty, print the link with the reset_scripts in the onClick - if ($reset_scripts && empty($conf->dol_optimize_smallscreen)) - { + if ($reset_scripts && empty($conf->dol_optimize_smallscreen)) { $retstring .= ' '; @@ -5998,8 +6330,7 @@ class Form } // Add a "Plus one hour" link - if ($conf->use_javascript_ajax && $addplusone) - { + if ($conf->use_javascript_ajax && $addplusone) { // Script which will be inserted in the onClick of the "Add plusone" link $reset_scripts = ""; @@ -6009,22 +6340,27 @@ class Form $reset_scripts .= 'jQuery(\'#'.$prefix.'month\').val(\''.dol_print_date($nowgmt, '%m', 'tzuserrel').'\');'; $reset_scripts .= 'jQuery(\'#'.$prefix.'year\').val(\''.dol_print_date($nowgmt, '%Y', 'tzuserrel').'\');'; // Update the hour part - if ($h) - { - if ($fullday) $reset_scripts .= " if (jQuery('#fullday:checked').val() == null) {"; + if ($h) { + if ($fullday) { + $reset_scripts .= " if (jQuery('#fullday:checked').val() == null) {"; + } $reset_scripts .= 'jQuery(\'#'.$prefix.'hour\').val(\''.dol_print_date($nowgmt, '%H', 'tzuserrel').'\');'; - if ($fullday) $reset_scripts .= ' } '; + if ($fullday) { + $reset_scripts .= ' } '; + } } // Update the minute part - if ($m) - { - if ($fullday) $reset_scripts .= " if (jQuery('#fullday:checked').val() == null) {"; + if ($m) { + if ($fullday) { + $reset_scripts .= " if (jQuery('#fullday:checked').val() == null) {"; + } $reset_scripts .= 'jQuery(\'#'.$prefix.'min\').val(\''.dol_print_date($nowgmt, '%M', 'tzuserrel').'\');'; - if ($fullday) $reset_scripts .= ' } '; + if ($fullday) { + $reset_scripts .= ' } '; + } } // If reset_scripts is not empty, print the link with the reset_scripts in the onClick - if ($reset_scripts && empty($conf->dol_optimize_smallscreen)) - { + if ($reset_scripts && empty($conf->dol_optimize_smallscreen)) { $retstring .= ' '; @@ -6032,10 +6368,11 @@ class Form } // Add a link to set data - if ($conf->use_javascript_ajax && $adddateof) - { + if ($conf->use_javascript_ajax && $adddateof) { $tmparray = dol_getdate($adddateof); - if (empty($labeladddateof)) $labeladddateof = $langs->trans("DateInvoice"); + if (empty($labeladddateof)) { + $labeladddateof = $langs->trans("DateInvoice"); + } $retstring .= ' -