diff --git a/.travis.yml b/.travis.yml index 688d706331d..f7903361b02 100644 --- a/.travis.yml +++ b/.travis.yml @@ -291,7 +291,7 @@ script: # Ensure we catch errors set -e # Exclusions are defined in the ruleset.xml file - #phpcs -s -n -p -d memory_limit=-1 --colors --tab-width=4 --standard=dev/setup/codesniffer/ruleset.xml --encoding=utf-8 . + #phpcs -s -p -d memory_limit=-1 --extensions=php --colors --tab-width=4 --standard=dev/setup/codesniffer/ruleset.xml --encoding=utf-8 --runtime-set ignore_warnings_on_exit true . if [ "$TRAVIS_PULL_REQUEST" = "false" ]; then phpcs -s -p -d memory_limit=-1 --extensions=php --colors --tab-width=4 --standard=dev/setup/codesniffer/ruleset.xml --encoding=utf-8 --runtime-set ignore_warnings_on_exit true .; fi set +e echo @@ -404,6 +404,10 @@ script: php upgrade.php 11.0.0 12.0.0 ignoredbversion > $TRAVIS_BUILD_DIR/upgrade11001200.log php upgrade2.php 11.0.0 12.0.0 > $TRAVIS_BUILD_DIR/upgrade11001200-2.log php step5.php 11.0.0 12.0.0 > $TRAVIS_BUILD_DIR/upgrade11001200-3.log + php upgrade.php 12.0.0 13.0.0 ignoredbversion > $TRAVIS_BUILD_DIR/upgrade12001300.log + php upgrade2.php 12.0.0 13.0.0 > $TRAVIS_BUILD_DIR/upgrade12001300-2.log + php step5.php 12.0.0 13.0.0 > $TRAVIS_BUILD_DIR/upgrade12001300-3.log + # Enable modules not enabled into original dump php upgrade2.php 0.0.0 0.0.0 MAIN_MODULE_API,MAIN_MODULE_SUPPLIERPROPOSAL,MAIN_MODULE_WEBSITE,MAIN_MODULE_TICKETSUP,MAIN_MODULE_ACCOUNTING > $TRAVIS_BUILD_DIR/enablemodule.log echo $? diff --git a/ChangeLog b/ChangeLog index 68cd7695057..7e8ce042bf3 100644 --- a/ChangeLog +++ b/ChangeLog @@ -3,32 +3,311 @@ English Dolibarr ChangeLog -------------------------------------------------------------- -***** ChangeLog for 12.0.0 compared to 11.0.0 ***** -For Users: -NEW: Module MO (Manufacturing Order) is available as stable module. -NEW: Add option MAIN_VIEW_LINE_NUMBER_IN_LIST for some lists. +***** ChangeLog for 12.0 compared to 11.0 ***** +For users: -For Developers or integrators: -* A new way to navigate between pages in list is available. To use it, you must - - replace $page = GETPOST('page', 'int') with $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); - - remove input field in form '';' - - add parameter $pagenavastextinput to value 1 when calling print_barre_liste -* UserGroup class has been refactored with new architecture. Triggers of class UserGroup are now USERGROUP_CREATE, USERGROUP_MODIFY, USERGROUP_DELETE +NEW: Module MO (Manufacturing Order) is available as stable module. +NEW: Receipt printer module moved from 'development' to 'experimental' +NEW: Add option MAIN_VIEW_LINE_NUMBER_IN_LIST for some lists. +NEW: add numbering module for TakePOS module +NEW: 2 new options when creating an invoice from time spent on a project : by period or by task +NEW: Accountancy add column thirdparty on binding page +NEW: Accountancy - Add Export for Fiducial Winfic eWinfic WinSis Compta +NEW: Accountancy - Add Export LD compta version 10 +NEW: Accountancy - Add mode intra & export for product or service bought +NEW: Accountancy - Add possibility to manage a short alternative label for account - Use to simplify accountancy +NEW: Accountancy - General ledger - Add an option to search not reconciled lines +NEW: Add accountancy code of thirdparty in contact and supplier export +NEW: add a link to notes in members list +NEW: add a parameter to group same products in TakePOS +NEW: add a parameter to sort product by label in TakePOS +NEW: Add a profil to import contact categories +NEW: Add company extrafields into order export +NEW: add const CASHDESK_FORCE_DECREASE_STOCK to force batch decrementation +NEW: add const TAKEPOS_NUMPAD_USE_PAYMENT_ICON to use icons on payment buttons +NEW: add csv separator setup in module admin +NEW: add dedicated substitutions keys for extrafields of type date and datetime +NEW: add default warehouse for dispatch +NEW: Add due date in feature "Export accounting documents" +NEW: Add duration information for fichinter +NEW: Start support of Dark theme into ELDY theme +NEW: Add field author public alias for blog post on website module +NEW: Add "finished" field on product list +NEW: Add French association chart of accounts 2018 +NEW: Add French farm chart of accounts 2014 +NEW: Add French foundation chart of accounts 2018 +NEW: add global reduction in cash desk +NEW: Add graph type 'piesemicircle' +NEW: Add hook getInputIdProf. Better solution for #13228 +NEW: Add hook on margin list page +NEW: add icon on payment buttons in cash desk +NEW: Add include various payments and loans in accounting report with simplfified accountancy +NEW: Add invoice stat graph and categ search +NEW: Addition of delivery times in substitution variables +NEW: add member to validate on dashboard +NEW: Add method to add social network sharing buttons on blog posts +NEW: add multicurrency columns to document lists +NEW: add numbering module for cash desk +NEW: add Opening Balance column to balance.php +NEW: add opportunity status in project stats +NEW: Add option PDF_USE_ALSO_LANGUAGE_CODE to generate PDF in 2 languages +NEW: Add option to hide all inactive users into combo list of users. +NEW: add PDF certificate if present on document folder +NEW: add product if only one found +NEW: Add product on key "Enter" in search bar +NEW: add professional ID 1 in sepamandate document +NEW: Add Project Ref Column on list of social/fiscal contributions +NEW: add Project Ref in events export +NEW: add public and private notes in propal list +NEW: Add social networks of the company +NEW: Add sorting for contacts of ... pages +NEW: Add subtitution variables for url of document in backoffice +NEW: Add tel and fax in warehouse card +NEW: add total of value in product stat +NEW: add total weighted amount in project list +NEW: add units in product list +NEW: add VAT ID in sepamandate document +NEW: add VAT rates in free zone for product/service in TakePOS +NEW: add weighted amount on project/opportunity +NEW: add width and height measures in product list +NEW: add WYSiWYG on member type's description +NEW: [Allow constants values to be overridden by environment variables] +NEW: Allow custom module class origine type in Mouvementstock +NEW: allow display extrafields on pdf +NEW: Allow extrafields on pdf : extend to line desc +NEW: allow time consumed to be linked to another task +NEW: Another way to navigate between pages for some lists +NEW: Add author column in the client/supplier invoice lists and into order list +NEW: bank account tags for invoice ODT template +NEW: Bar Restaurant tab and Auto order +NEW: better filter on shipment list as other list +NEW: Better php module view admin +NEW: Bookkeeping - Add link to document & pdf +NEW: Bookmarks are now in top menu bar +NEW: Can check all events in one click in setup of audited events +NEW: Can create an deposit from order using a percentage of qty. +NEW: Can edit option PDF_USE_ALSO_LANGUAGE_CODE from PDF setup page +NEW: Can enter and edit stripe credit card using the Stripe card ID +NEW: Can filter on donation status in list +NEW: Can replace a string into all pages in website module +NEW: Can select several fields to personalize list before submit. +NEW: Can select which element to export in export accounting documents. +NEW: can update contact in import model +NEW: Cash Fence in TakePOS +NEW: Categories and subcategories sorted by label in TakePOS +NEW: Categories for actioncomm +NEW: Category filter for bank and warehouse list +NEW: Chart of accounts to Ecuador +NEW: class tool for converting units +NEW: Close #13011 Add button create thirdparty when creating intervention +NEW: Colorful theme for TakePOS +NEW: columns units in product list +NEW: compatibility of translabel with more dict +NEW: Confirm file delete on fracture card +NEW: "contact_civility" for ODT templates +NEW: CUPS printing compatibility for TakePOS +NEW: Customer command list - Add date start & date end +NEW: display weight in shipment list +NEW: Documentation about PHP support in Dolibarr +NEW: Donation - Update FR CERFA to 11580*04 +NEW: Easier way to setup the different types of tax. Better visibility. +NEW: enable put for agendaevents api +NEW: Expedition list - Add date start & date end +NEW: Experiment supplier packaging with option PRODUCT_USE_SUPPLIER_PACKAGING: Using price according to the minimum quantity +NEW: Export module, add extrafields for Contract and Contract line +NEW: Extend retained warranty to be available for all invoices +NEW: filter by product on supplier order API +NEW: French new regions +NEW: get documents for categories with RESP API +NEW: get proposal by ref with API +NEW: Hidden option MAIN_TEMP_DIR +NEW: hook and data id +NEW: hook on ics generation to add more events in eventarray +NEW: hook on product load stats +NEW: If $dolibarr_main_force_https is set, the flag 'secure' on session +NEW: ignore dir for apple pay with stripe +NEW: Invoice list - Add date start & date end +NEW: invoice list: enable multicurrency columns +NEW: labels on reduction buttons in cash desk +NEW: Minimum sell prices taking into account in TakePOS +NEW: monthly view to enter time +NEW: Multiple sales in TakePOS +NEW: multiselect categorie client stats facturation +NEW: no confirm discard ticket if paid +NEW: not show linked table on add message action +NEW: only auto print paid ticket in cash desk +NEW: only show units columns in product list (not in service list) +NEW: order list: enable multicurrency columns +NEW: Overwrite tpl with module_part['tpl'] is deprecated. USe hooks +NEW: possibility to defined rounding rules by currency +NEW: possibility to show society info when print page +NEW: Povide a RSS Feed for blogposts +NEW: PRODUCT_SHOW_ORIGIN_IN_COMBO +NEW: Project task list, add column selector and extrafields +NEW: Propal list - Add date start & date end +NEW: propal list: enable multicurrency columns +NEW: RECEIPT_PRINTER_NB_CHARACT_BY_LINE and FIX: product label +NEW: Restore version of application on main screen (for screenshots) +NEW: Salaries list - Add date start & date end +NEW: search on key code "enter" if defined in TakePOS +NEW: set payment method on paid ticket in TakePOS +NEW: Show active widget state of a RSS feed +NEW: Show count of each category elements in category card +NEW: Show creator, last update user of category/tag in the information tab +NEW: Show list of users in the user category card +NEW: show messages on ticket card +NEW: show "New category" button in top of sub categories list +NEW: show project label in project index +NEW: Show units of products in stocks and hide total units if content is of diffents units +NEW: sorting elements on project overview +NEW: special option MAIN_CREATEFROM_KEEP_LINE_ORIGIN_INFORMATION to store in document line created form other documents lines the id of original lines and origin class line rather than origin object id and origin object type +NEW: stats invoice graph with 3 bars (3 years instead of 2) +NEW: supplier invoice list: enable multicurrency columns +NEW: supplier order list: enable multicurrency columns +NEW: supplier proposal list: enable multicurrency columns +NEW: Support of tag {line_pos} for line numbers for tables in ODT templates +NEW: Support some HTML contents into ODT documents +NEW: Parameters for Bar Restaurant are grouped in same tab +NEW: Takepos : Sort products by reference +NEW: Takepos supplements are supported. +NEW: The info_admin() can show text after click on other text +NEW: The module selection uses a KanBan view by default. +NEW: tooltip for Unit_type and scale in "Dictionary setup - Measuring Units" +NEW: tooltip notes with first public note and then private note +NEW: Tree view for sub-categories +NEW: Truncate columns names when too long and show full title as popup +NEW: upload odt models for invoices, order, proposal, thirdparties and shipments. +NEW: Use native --convert-to feature to convert to pdf +NEW: Add user on order list +NEW: Various payment list - Add search date start & date end & subledger account +NEW: visu FROM day TO day in permonth view +NEW: Website logs are now into a separated log file. +NEW: X-Axis on graph are shown verticaly when there is a lot of values. +NEW: Can force ref of a variant product + +For developers or integrators: + +NEW: Add a method $form->widgetForTranslation to allow any field of a form to be entered into different languages. +NEW: Add API to get types of expense reports +NEW: API filter bankaccounts by category +NEW: API filter contacts by category +NEW: API filter members by category +NEW: API filter projects by category +NEW: API filter thirdpartie by category +NEW: API filter thirdparty by category +NEW: API filter user by category +NEW: API filter warehouses by categorie +NEW: api for get user's documents +NEW: api invoice get by ref +NEW: API to update purchase price. +NEW: Move engine to build charts from jflot to chart.js +NEW: Upgrade ace to 1.4.8 - Upgrade select2 to 4.0.13 +NEW: Upgrade Stripe library to 6.43.1 +NEW: Bookkeeping by account - Add selectfields & hook +NEW: Can force position of legend of graph on right (instead of top) +NEW: Can change destination of "Back to list" using a "backtolist" parameter +NEW: add more category types from hook WARNING: Following changes may create regressions for some external modules, but were necessary to make Dolibarr better: * PHP 5.5 is no more supported. Minimum PHP is now 5.6+. -* Default mode for GETPOST function is now 'alphanohtml' instead of 'none'. So check when you make POST or GET requests - with HTML content that you make a GETPOST('myparam', 'restricthtml') or GETPOST('myparam', 'none') if you really need posted content without sanitizing - the HTML into content (in such a case, sanitize data later) +* Default mode for GETPOST function is now 'alphanohtml' instead of 'none'. So check when you make POST or GET requests with + HTML content that you make a GETPOST('myparam', 'restricthtml') or GETPOST('myparam', 'none') if you really need posted content without sanitizing + the HTML code of content (in such a case, sanitize data later) * Removed hidden constant MAIN_EXTRAFIELDS_IN_ONE_TD that was useless. * Reference of object including a "/" are no more allowed. It is never used by default but to support setup that introduced it, the "/" will be replaced by a "_" automatically when a reference (with a custom numbering mask that use it) is generated. -* Library jflot (replace with chartjs) and geoip (replaced with geoip2) were removed. -* Hidden constant COMMANDE_VALID_AFTER_CLOSE_PROPAL were renamed into ORDER_VALID_AFTER_CLOSE_PROPAL. +* Library jflot (replace with chartjs) was removed. +* Library geoip (replaced with geoip2) was removed. +* Hidden constant COMMANDE_VALID_AFTER_CLOSE_PROPAL was renamed into ORDER_VALID_AFTER_CLOSE_PROPAL. +* Object field ref_int is deprecated and set to 'not used', method to fetch object by only ref_int is not supported anymore. +* UserGroup class has been refactored with new architecture. Triggers of class UserGroup are now USERGROUP_CREATE, USERGROUP_MODIFY, USERGROUP_DELETE +* A new way to navigate between pages in list is available. To use it (not mandatory), you must: + - replace line $page = GETPOST('page', 'int') with $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); + - remove input field in form '';' + - add parameter $pagenavastextinput to value 1 when calling print_barre_liste() + +***** ChangeLog for 11.0.4 compared to 11.0.3 ***** +FIX: #13749 +FIX: #7594 Expense report multi pagebreak +FIX: Access to undeclared static property: Contact::$table_element +FIX: actions on supplier proposal not saved (bad trigger name) +FIX: Add function "completeTabsHead" to "addreplace" type hook. +FIX: All forms must use newToken() +FIX: Another "Access to undeclared static property: Contact::$table_element" && "Societe::$table_element" +FIX: author search supplier proposal list +FIX: A variable was erased by a temporary variable +FIX: Avoid infinite loop when a fetch is inside a compute field. +FIX: Backto link +FIX: Bad position of total in column +FIX: bad value in currency into discount created from down payment +FIX: buyprice extrafield langfile and tooltip +FIX: Buyprice was updated only if min price for this qty had same qty +FIX: Can switch from double to price type for extrafields +FIX: Can use decimal value in virtual products +FIX: child categories only with good entity rights +FIX: cloning of emailing when no content selected +FIX: closing tags +FIX: Combo list of available users to filter on the list of leaves. +FIX: Compatibility with multicompany, bad numerotation of task. +FIX: consistency of price w/wo vat wrong when price entered with tax +FIX: default value of selectMasssAction broken +FIX: draftordered replenish virtual stock +FIX: Error update SQL into stock reception +FIX: expensereport status in generated pdf +FIX: extra date field incorrect check +FIX: Extrafields of type price must be '' and not '0' if not defined +FIX: Foreign currency lost when splitting a discount +FIX: get remain to pay with rounding decimals +FIX: gzip and bzip2 must use option -f +FIX: IHM, unexpected quote +FIX: keep viewstatut for doli 3.5 +FIX: Link missing into email of some notification +FIX: Look and feel v11 +FIX: md stylesheet to be included by external modules like eldy +FIX: missing array option +FIX: missing default accountancy product buy code +FIX: missing fk_bank during export of suppliers invoices +FIX: missing member entity +FIX: missing selectedlines on supplier order but checkbox are displayed +FIX: Missing token and take into account max date when it can. +FIX: model export list must be sorted by label +FIX: multicurrency manage on hidden conf SUPPLIER_PROPOSAL_UPDATE_PRICE_ON_SUPPlIER_PROPOSAL +FIX: Must escape shell +FIX: Must exclude logs and some dirs for compressed backup +FIX: ordered stock already in $stock +FIX: picture migration script from doli 9.0 +FIX: print pictures on shipment docs +FIX: product get purchase prices +FIX: product purchase prices +FIX: Protection when database has a corrupted product id +FIX: remove unused var, $usercancreate can be change by Multicompany +FIX: replenish stock to buy +FIX: Sanitizing menu parameter +FIX: Send email from bulk action of list of thirdparties +FIX: setup of suggested payment mode on proposals and orders +FIX: Several pb in export of documents +FIX: Situation invoice take into account the credit notes. +FIX: some others modules (like subtotal) use other product_type than 0 or 1 AND must not be considered in this report +FIX: sort by default role makes no sense +FIX: sort on company on member list +FIX: TakePOS buying price +FIX: text version of html emailing (removed the body style) +FIX: The "test smtp connectivity" failed on page to setup mass emailing +FIX: Error logs an Orderline::delete error, but this is an Orderline::insert error +FIX: Translation of tooltips of extrafields +FIX: Use getNomURL instead of hard coded link. Fix limit. +FIX: Use of image into free text for PDF if DOL_DATA_DIR is outside of +FIX: viewstatut to search status +FIX: we must export company mail address on contact vcard only if contact email address is empty +FIX: when we filter a list on a view status, we want this filter to be on bookmark that we create +FIX: Wrong Sql on getListOfTowns api method +FIX: wrong user right's name to top menu "commercial" +FIX: XSS Vulnerability reported by Mehmet Kelepçe / Gais Cyber Security + ***** ChangeLog for 11.0.3 compared to 11.0.2 ***** FIX: unit price for selected supplier products not set. NaN was used. FIX: use bad var to check if total is positive for each VAT rate when validating an invoice diff --git a/build/docker/Dockerfile b/build/docker/Dockerfile index 4b1df7e0876..9264eed5ef2 100644 --- a/build/docker/Dockerfile +++ b/build/docker/Dockerfile @@ -3,7 +3,7 @@ FROM php:7.2-apache ENV HOST_USER_ID 33 ENV PHP_INI_DATE_TIMEZONE 'UTC' -RUN apt-get update && apt-get install -y libpng-dev libjpeg-dev libldap2-dev libzip-dev zlib1g-dev libicu-dev g++\ +RUN apt-get update && apt-get install -y libpng16-16 libpng-dev libjpeg62-turbo libjpeg62-turbo-dev libldap2-dev zlib1g-dev libicu-dev g++\ && rm -rf /var/lib/apt/lists/* \ && docker-php-ext-configure gd --with-png-dir=/usr --with-jpeg-dir=/usr \ && docker-php-ext-install gd \ @@ -14,7 +14,7 @@ RUN apt-get update && apt-get install -y libpng-dev libjpeg-dev libldap2-dev lib && docker-php-ext-install calendar \ && docker-php-ext-configure intl \ && docker-php-ext-install intl \ - && apt-get autoremove --purge -y libjpeg-dev libldap2-dev zlib1g-dev libicu-dev g++ + && apt-get autoremove --purge -y libpng-dev libjpeg62-turbo-dev libldap2-dev zlib1g-dev libicu-dev g++ RUN mkdir /var/documents RUN chown www-data /var/documents diff --git a/build/docker/docker-compose.yml b/build/docker/docker-compose.yml index 3fe6125a874..cc839810e7f 100644 --- a/build/docker/docker-compose.yml +++ b/build/docker/docker-compose.yml @@ -21,5 +21,12 @@ web: - ../../htdocs:/var/www/html links: - mariadb + - mail ports: - "80:80" + +mail: + image: maildev/maildev + ports: + - "8081:80" + - "25:25" \ No newline at end of file diff --git a/build/generate_filelist_xml.php b/build/generate_filelist_xml.php index 976f2cb6ba3..581353b758b 100755 --- a/build/generate_filelist_xml.php +++ b/build/generate_filelist_xml.php @@ -110,7 +110,7 @@ print "Working on files into : ".DOL_DOCUMENT_ROOT."\n"; print "Include custom in signature : ".$includecustom."\n"; print "Include constants in signature : "; foreach ($includeconstants as $countrycode => $tmp) { - foreach($tmp as $constname => $constvalue) { + foreach ($tmp as $constname => $constvalue) { print $constname.'='.$constvalue." "; } } @@ -130,7 +130,7 @@ fputs($fp, ''."\n"); - foreach($tmp as $constname => $constvalue) { + foreach ($tmp as $constname => $constvalue) { $valueforchecksum=(empty($constvalue)?'0':$constvalue); $checksumconcat[]=$valueforchecksum; fputs($fp, ' '.$valueforchecksum.''."\n"); diff --git a/build/makepack-dolibarr.pl b/build/makepack-dolibarr.pl index c06dc51aec1..24b32dcff91 100755 --- a/build/makepack-dolibarr.pl +++ b/build/makepack-dolibarr.pl @@ -19,7 +19,7 @@ use Term::ANSIColor; # Change this to defined target for option 98 and 99 $PROJECT="dolibarr"; $PUBLISHSTABLE="eldy,dolibarr\@frs.sourceforge.net:/home/frs/project/dolibarr"; -$PUBLISHBETARC="dolibarr\@vmprod1.dolibarr.org:/home/dolibarr/dolibarr.org/httpdocs/files"; +$PUBLISHBETARC="dolibarr\@vmprod1.dolibarr.org:/home/dolibarr/asso.dolibarr.org/dolibarr_documents/website/www.dolibarr.org/files"; #@LISTETARGET=("TGZ","ZIP","RPM_GENERIC","RPM_FEDORA","RPM_MANDRIVA","RPM_OPENSUSE","DEB","EXEDOLIWAMP","SNAPSHOT"); # Possible packages diff --git a/dev/examples/code/create_invoice.php b/dev/examples/code/create_invoice.php index 1b212e0a5d7..1acf181a4ba 100755 --- a/dev/examples/code/create_invoice.php +++ b/dev/examples/code/create_invoice.php @@ -87,14 +87,11 @@ if ($idobject > 0) // Change status to validated $result=$obj->validate($user); if ($result > 0) print "OK Object created with id ".$idobject."\n"; - else - { + else { $error++; dol_print_error($db, $obj->error); } -} -else -{ +} else { $error++; dol_print_error($db, $obj->error); } @@ -106,9 +103,7 @@ if (! $error) { $db->commit(); print '--- end ok'."\n"; -} -else -{ +} else { print '--- end error code='.$error."\n"; $db->rollback(); } diff --git a/dev/examples/code/create_order.php b/dev/examples/code/create_order.php index 703254ad5e9..7fe1a82251a 100755 --- a/dev/examples/code/create_order.php +++ b/dev/examples/code/create_order.php @@ -85,14 +85,11 @@ if ($idobject > 0) // Change status to validated $result=$com->valid($user); if ($result > 0) print "OK Object created with id ".$idobject."\n"; - else - { + else { $error++; dol_print_error($db, $com->error); } -} -else -{ +} else { $error++; dol_print_error($db, $com->error); } @@ -104,9 +101,7 @@ if (! $error) { $db->commit(); print '--- end ok'."\n"; -} -else -{ +} else { print '--- end error code='.$error."\n"; $db->rollback(); } diff --git a/dev/examples/code/create_product.php b/dev/examples/code/create_product.php index 234658388df..20b898a92aa 100755 --- a/dev/examples/code/create_product.php +++ b/dev/examples/code/create_product.php @@ -82,9 +82,7 @@ $idobject = $myproduct->create($user); if ($idobject > 0) { print "OK Object created with id ".$idobject."\n"; -} -else -{ +} else { $error++; dol_print_error($db, $myproduct->error); } @@ -95,9 +93,7 @@ if (! $error) { $db->commit(); print '--- end ok'."\n"; -} -else -{ +} else { print '--- end error code='.$error."\n"; $db->rollback(); } diff --git a/dev/examples/code/create_user.php b/dev/examples/code/create_user.php index 96d369085d2..d585b490a9c 100755 --- a/dev/examples/code/create_user.php +++ b/dev/examples/code/create_user.php @@ -74,18 +74,14 @@ if ($idobject > 0) // Change status to validated $result=$obj->setStatut(1); if ($result > 0) print "OK Object created with id ".$idobject."\n"; - else - { + else { $error++; dol_print_error($db, $obj->error); } -} -elseif ($obj->error == 'ErrorLoginAlreadyExists') +} elseif ($obj->error == 'ErrorLoginAlreadyExists') { print "User with login ".$obj->login." already exists\n"; -} -else -{ +} else { $error++; dol_print_error($db, $obj->error); } @@ -97,9 +93,7 @@ if (! $error) { $db->commit(); print '--- end ok'."\n"; -} -else -{ +} else { print '--- end error code='.$error."\n"; $db->rollback(); } diff --git a/dev/initdata/dbf/importdb-products.php b/dev/initdata/dbf/importdb-products.php index 845064f0688..2c06c07e103 100644 --- a/dev/initdata/dbf/importdb-products.php +++ b/dev/initdata/dbf/importdb-products.php @@ -227,8 +227,7 @@ while ($fields = $db->fetch_array($resql)) { $error++; // $errorrecord will be reset } $j++; -} else - die("error : $sql"); +} else die("error : $sql"); diff --git a/dev/initdata/dbf/importdb-thirdparties.php b/dev/initdata/dbf/importdb-thirdparties.php index 8f0eb0635f0..a6b2697eed8 100644 --- a/dev/initdata/dbf/importdb-thirdparties.php +++ b/dev/initdata/dbf/importdb-thirdparties.php @@ -179,8 +179,7 @@ while ($fields = $db->fetch_array($resql)) { $object->town = trim($fields['FVILLE']); if ($fields['FPAYS']) $object->country_id = dol_getIdFromCode($db, trim(ucwords(strtolower($fields['FPAYS']))), 'c_country', 'label', 'rowid'); - else - $object->country_id = 1; + else $object->country_id = 1; $object->phone = trim($fields['FTEL']) ? trim($fields['FTEL']) : trim($fields['FCONTACT']); $object->phone = substr($object->phone, 0, 20); $object->fax = trim($fields['FFAX']) ? trim($fields['FFAX']) : trim($fields['FCONTACT']); @@ -299,8 +298,7 @@ while ($fields = $db->fetch_array($resql)) { $contact->town = trim($fields['LVILLE']); if ($fields['FPAYS']) $contact->country_id = dol_getIdFromCode($db, trim(ucwords(strtolower($fields['LPAYS']))), 'c_country', 'label', 'rowid'); - else - $contact->country_id = 1; + else $contact->country_id = 1; $contact->email = $fields['LMAIL']; $contact->phone = trim($fields['LTEL']) ? trim($fields['LTEL']) : trim($fields['LCONTACT']); $contact->fax = trim($fields['LFAX']) ? trim($fields['LFAX']) : trim($fields['LCONTACT']); @@ -340,8 +338,7 @@ while ($fields = $db->fetch_array($resql)) { $error++; // $errorrecord will be reset } $j++; -} else - die("error : $sql"); +} else die("error : $sql"); $db->commit(); diff --git a/dev/initdata/dbf/includes/dbase.class.php b/dev/initdata/dbf/includes/dbase.class.php index 0c2f6820a96..e70f18087c4 100644 --- a/dev/initdata/dbf/includes/dbase.class.php +++ b/dev/initdata/dbf/includes/dbase.class.php @@ -207,8 +207,7 @@ class DBase $value = true; elseif ($value == 'f' || $value == 'n') $value = false; - else - $value = null; + else $value = null; } $record[$i] = $value; } @@ -295,8 +294,7 @@ class DBase $i = unpack("S$n", $data); if ($n == 1) return (int) $i[1]; - else - return array_merge($i); + else return array_merge($i); } private static function putInt16($fd, $value) @@ -310,8 +308,7 @@ class DBase $i = unpack("L$n", $data); if ($n == 1) return (int) $i[1]; - else - return array_merge($i); + else return array_merge($i); } private static function putInt32($fd, $value) diff --git a/dev/initdata/generate-invoice.php b/dev/initdata/generate-invoice.php index 3fe058e8d3e..c35fe2440ef 100755 --- a/dev/initdata/generate-invoice.php +++ b/dev/initdata/generate-invoice.php @@ -179,14 +179,10 @@ while ($i < GEN_NUMBER_FACTURE && $result >= 0) if ($result) { print " OK with ref ".$object->ref."\n";; - } - else - { + } else { dol_print_error($db, $object->error); } - } - else - { + } else { dol_print_error($db, $object->error); } } diff --git a/dev/initdata/generate-order.php b/dev/initdata/generate-order.php index 1dc56aa5582..c421e39ffe3 100755 --- a/dev/initdata/generate-order.php +++ b/dev/initdata/generate-order.php @@ -124,8 +124,7 @@ if ($resql) { $row = $db->fetch_row($resql); $societesid[$i] = $row[0]; } -} -else { print "err"; } +} else { print "err"; } $commandesid = array(); $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."commande"; @@ -138,8 +137,7 @@ if ($resql) { $row = $db->fetch_row($resql); $commandesid[$i] = $row[0]; } -} -else { print "err"; } +} else { print "err"; } $prodids = array(); $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."product WHERE tosell=1"; @@ -206,16 +204,12 @@ for ($s = 0 ; $s < GEN_NUMBER_COMMANDE ; $s++) { $db->commit(); print " OK with ref ".$object->ref."\n"; - } - else - { + } else { print " KO\n"; $db->rollback(); dol_print_error($db, $object->error); } - } - else - { + } else { print " KO\n"; $db->rollback(); dol_print_error($db, $object->error); diff --git a/dev/initdata/generate-proposal.php b/dev/initdata/generate-proposal.php index 4c5d70aadc4..42c0c4098f2 100755 --- a/dev/initdata/generate-proposal.php +++ b/dev/initdata/generate-proposal.php @@ -210,16 +210,12 @@ while ($i < GEN_NUMBER_PROPAL && $result >= 0) { $db->commit(); print " OK with ref ".$object->ref."\n"; - } - else - { + } else { print " KO\n"; $db->rollback(); dol_print_error($db, $object->error); } - } - else - { + } else { dol_print_error($db, $object->error); } } diff --git a/dev/initdata/generate-thirdparty.php b/dev/initdata/generate-thirdparty.php index 05ac6416aa3..a13e2351e9c 100755 --- a/dev/initdata/generate-thirdparty.php +++ b/dev/initdata/generate-thirdparty.php @@ -136,9 +136,7 @@ for ($s = 0 ; $s < GEN_NUMBER_SOCIETE ; $s++) } print "Company ".$s." created nom=".$soc->name."\n"; - } - else - { + } else { print "Error: ".$soc->error."\n"; } } diff --git a/dev/initdata/import-products.php b/dev/initdata/import-products.php index 4288c5bf3b1..fb07143f972 100755 --- a/dev/initdata/import-products.php +++ b/dev/initdata/import-products.php @@ -163,9 +163,7 @@ while ($fields=fgetcsv($fhandle, $linelength, $delimiter, $enclosure, $escape)) { print " - Error in create result code = ".$ret." - ".$produit->errorsToString(); $errorrecord++; - } - else - { + } else { print " - Creation OK with ref ".$produit->ref." - id = ".$ret; } @@ -180,9 +178,7 @@ while ($fields=fgetcsv($fhandle, $linelength, $delimiter, $enclosure, $escape)) { print " - Error in updatePrice result code = ".$ret1." ".$ret2." - ".$produit->errorsToString(); $errorrecord++; - } - else - { + } else { print " - updatePrice OK"; } } @@ -200,9 +196,7 @@ while ($fields=fgetcsv($fhandle, $linelength, $delimiter, $enclosure, $escape)) { print " - Error in setMultiLangs result code = ".$ret." - ".$produit->errorsToString(); $errorrecord++; - } - else - { + } else { print " - setMultiLangs OK"; } } @@ -227,9 +221,7 @@ if ($mode != 'confirmforced' && ($error || $mode != 'confirm')) { print "Rollback any changes.\n"; $db->rollback(); -} -else -{ +} else { print "Commit all changes.\n"; $db->commit(); } diff --git a/dev/initdata/import-thirdparties.php b/dev/initdata/import-thirdparties.php index ef1dfcc99ab..a0ddaac7674 100755 --- a/dev/initdata/import-thirdparties.php +++ b/dev/initdata/import-thirdparties.php @@ -181,9 +181,7 @@ while ($fields=fgetcsv($fhandle, $linelength, $delimiter, $enclosure, $escape)) { print " - Error in create result code = ".$ret." - ".$object->errorsToString(); $errorrecord++; - } - else - { + } else { print " - Creation OK with name ".$object->name." - id = ".$ret; } } @@ -212,9 +210,7 @@ while ($fields=fgetcsv($fhandle, $linelength, $delimiter, $enclosure, $escape)) { print " - Error in create link with sale representative result code = ".$result." - ".$object->errorsToString(); $errorrecord++; - } - else - { + } else { print " - create link sale representative OK"; } } @@ -243,9 +239,7 @@ while ($fields=fgetcsv($fhandle, $linelength, $delimiter, $enclosure, $escape)) { print " - Error in create contact result code = ".$ret1." ".$ret2." - ".$object->errorsToString(); $errorrecord++; - } - else - { + } else { print " - create contact OK"; } } @@ -277,9 +271,7 @@ while ($fields=fgetcsv($fhandle, $linelength, $delimiter, $enclosure, $escape)) { print " - Error in create contact result code = ".$ret1." ".$ret2." - ".$object->errorsToString(); $errorrecord++; - } - else - { + } else { print " - create contact OK"; } } @@ -305,9 +297,7 @@ if ($mode != 'confirmforced' && ($error || $mode != 'confirm')) { print "Rollback any changes.\n"; $db->rollback(); -} -else -{ +} else { print "Commit all changes.\n"; $db->commit(); } diff --git a/dev/initdata/import-users.php b/dev/initdata/import-users.php index 4247415288c..8e4878577a1 100755 --- a/dev/initdata/import-users.php +++ b/dev/initdata/import-users.php @@ -142,9 +142,7 @@ while ($fields=fgetcsv($fhandle, $linelength, $delimiter, $enclosure, $escape)) { print " - Error in create result code = ".$ret." - ".$object->errorsToString(); $errorrecord++; - } - else - { + } else { print " - Creation OK with login ".$object->login." - id = ".$ret; } @@ -168,9 +166,7 @@ if ($mode != 'confirmforced' && ($error || $mode != 'confirm')) { print "Rollback any changes.\n"; $db->rollback(); -} -else -{ +} else { print "Commit all changes.\n"; $db->commit(); } diff --git a/dev/initdata/purge-data.php b/dev/initdata/purge-data.php index b1aadd56ed8..183140af202 100755 --- a/dev/initdata/purge-data.php +++ b/dev/initdata/purge-data.php @@ -198,7 +198,7 @@ if (empty($option)) if ($option != 'all') { $listofoptions=explode(',', $option); - foreach($listofoptions as $cursoroption) + foreach ($listofoptions as $cursoroption) { if (! in_array($cursoroption, array_keys($sqls))) { print "Usage: $script_file (test|confirm) (all|option) (all|YYYY-MM-DD) [dbtype dbhost dbuser dbpassword dbname dbport]\n"; @@ -264,7 +264,7 @@ function processfamily($family, $date) global $db, $sqls; $error=0; - foreach($sqls[$family] as $sql) + foreach ($sqls[$family] as $sql) { if (preg_match('/^@/', $sql)) { @@ -302,10 +302,10 @@ function processfamily($family, $date) $db->begin(); $listofoptions=explode(',', $option); -foreach($listofoptions as $cursoroption) +foreach ($listofoptions as $cursoroption) { $oldfamily=''; - foreach($sqls as $family => $familysql) + foreach ($sqls as $family => $familysql) { if ($cursoroption && $cursoroption != 'all' && $cursoroption != $family) continue; @@ -325,9 +325,7 @@ if ($error || $mode != 'confirm') { print "\nRollback any changes.\n"; $db->rollback(); -} -else -{ +} else { print "Commit all changes.\n"; $db->commit(); } diff --git a/dev/initdemo/sftpget_and_loaddump.php b/dev/initdemo/sftpget_and_loaddump.php index 5b16d3afe9b..4da5ffaad58 100755 --- a/dev/initdemo/sftpget_and_loaddump.php +++ b/dev/initdemo/sftpget_and_loaddump.php @@ -95,8 +95,7 @@ if ($connection) dol_syslog("Could not authenticate with username ".$login." . and password ".preg_replace('/./', '*', $password), LOG_ERR); exit(-5); } - else - { + else { //$stream = ssh2_exec($connection, '/usr/bin/php -i'); /* print "Generate dump ".$filesys1.'.bz2'."\n"; @@ -125,14 +124,13 @@ if ($connection) $return_var=0; print strftime("%Y%m%d-%H%M%S").' '.$fullcommand."\n"; exec($fullcommand, $output, $return_var); - foreach($output as $line) print $line."\n"; + foreach ($output as $line) print $line."\n"; //ssh2_sftp_unlink($sftp, $fileinstalllock); //print $output; } } -else -{ +else { print 'Failed to connect to ssh2 to '.$server; exit(-6); } diff --git a/dev/initdemo/updatedemo.php b/dev/initdemo/updatedemo.php index 0cc43a18a9d..95d5ad12c83 100755 --- a/dev/initdemo/updatedemo.php +++ b/dev/initdemo/updatedemo.php @@ -87,7 +87,7 @@ while ($year <= $currentyear) if ($delta1) { - foreach($tables as $tablekey => $tableval) + foreach ($tables as $tablekey => $tableval) { print "Correct ".$tablekey." for year ".$year." and move them to current year ".$currentyear." "; $sql="select rowid from ".MAIN_DB_PREFIX.$tablekey." where ".$tableval[0]." between '".$year."-01-01' and '".$year."-12-31' and ".$tableval[0]." < DATE_ADD(NOW(), INTERVAL -1 YEAR)"; @@ -105,7 +105,7 @@ while ($year <= $currentyear) print "."; $sql2="UPDATE ".MAIN_DB_PREFIX.$tablekey." set "; $j=0; - foreach($tableval as $field) + foreach ($tableval as $field) { if ($j) $sql2.=", "; $sql2.= $field." = ".$db->ifsql("DATE_ADD(".$field.", INTERVAL ".$delta1." YEAR) > NOW()", "DATE_ADD(".$field.", INTERVAL ".$delta2." YEAR)", "DATE_ADD(".$field.", INTERVAL ".$delta1." YEAR)"); diff --git a/dev/resources/iso-normes/Accountancy-format_Winfic-eWinfic-WinSisCompta.pdf b/dev/resources/iso-normes/Accountancy-format_Winfic-eWinfic-WinSisCompta.pdf new file mode 100644 index 00000000000..2fbaad04699 Binary files /dev/null and b/dev/resources/iso-normes/Accountancy-format_Winfic-eWinfic-WinSisCompta.pdf differ diff --git a/dev/setup/codesniffer/ruleset.xml b/dev/setup/codesniffer/ruleset.xml index ad26c7f0bdc..03104270dcf 100644 --- a/dev/setup/codesniffer/ruleset.xml +++ b/dev/setup/codesniffer/ruleset.xml @@ -27,7 +27,7 @@ - + @@ -101,7 +101,7 @@ - --> + --> 0 @@ -117,7 +117,7 @@ --> - + @@ -188,8 +188,8 @@ - @@ -213,6 +213,10 @@ + + + + @@ -272,12 +276,7 @@ - - - - - - + 0 @@ -310,20 +309,21 @@ - - + 0 - - + + 0 + - 0 + 0 - + + 0 @@ -332,27 +332,25 @@ - + 0 - + + 0 - - 0 - + + + - 0 + 0 - - 0 - - - 0 - + + + @@ -361,26 +359,26 @@ 0 + - 0 + 0 - + 0 + - - 0 - + 0 0 - + 0 @@ -391,16 +389,16 @@ + + 0 + - - - - + 0 @@ -411,7 +409,6 @@ 0 - 0 @@ -421,15 +418,17 @@ - - - - - + + + + + + + diff --git a/dev/tools/dolibarr-postgres2mysql.php b/dev/tools/dolibarr-postgres2mysql.php index f2794455ca3..c17a73dfe12 100644 --- a/dev/tools/dolibarr-postgres2mysql.php +++ b/dev/tools/dolibarr-postgres2mysql.php @@ -76,14 +76,12 @@ function getfieldname($l) if (preg_match("/`(.*)`/", $l, $regs)) { if ($regs[1]) return $regs[1]; - else - return null; + else return null; } // if its not in quotes, then it should (we hope!) be the first "word" on the line, up to the first space. elseif (preg_match("/([^\ ]*)/", trim($l), $regs)) { if ($regs[1]) return $regs[1]; - else - return null; + else return null; } } @@ -102,8 +100,7 @@ function formatsize($s) return sprintf("%.1f", round($s / 1024, 1)) . "K"; elseif ($s < pow(2, 30)) return sprintf("%.1f", round($s / 1024 / 1024, 1)) . "M"; - else - return sprintf("%.1f", round($s / 1024 / 1024 / 1024, 1)) . "G"; + else return sprintf("%.1f", round($s / 1024 / 1024 / 1024, 1)) . "G"; } /** @@ -146,8 +143,7 @@ function pg2mysql_large($infilename, $outfilename) if ($c % 2 != 0) { if ($inquotes) $inquotes = false; - else - $inquotes = true; + else $inquotes = true; } if ($linenum % 10000 == 0) { @@ -329,8 +325,7 @@ function pg2mysql(&$input, &$arrayofprimaryalreadyintabledef, $header = true) $num = $regs[1]; if ($num <= 255) $line = preg_replace("/ character varying\([0-9]*\)/", " varchar($num)", $line); - else - $line = preg_replace("/ character varying\([0-9]*\)/", " text", $line); + else $line = preg_replace("/ character varying\([0-9]*\)/", " text", $line); } // character varying with no size, we will default to varchar(255) if (preg_match("/ character varying/", $line)) { @@ -352,8 +347,7 @@ function pg2mysql(&$input, &$arrayofprimaryalreadyintabledef, $header = true) $num = $regs[1]; if ($num <= 255) $line = preg_replace("/ character\([0-9]*\)/", " varchar($num)", $line); - else - $line = preg_replace("/ character\([0-9]*\)/", " text", $line); + else $line = preg_replace("/ character\([0-9]*\)/", " text", $line); } // timestamps $line = str_replace(" timestamp with time zone", " datetime", $line); @@ -465,8 +459,7 @@ function pg2mysql(&$input, &$arrayofprimaryalreadyintabledef, $header = true) if ($c % 2 != 0) { if ($inquotes) $inquotes = false; - else - $inquotes = true; + else $inquotes = true; // echo "inquotes=$inquotes\n"; } } while (substr($lines[$linenumber], - 3, - 1) != ");" || $inquotes); diff --git a/dev/translation/autotranslator.class.php b/dev/translation/autotranslator.class.php index f9657482c86..b51515a42cb 100644 --- a/dev/translation/autotranslator.class.php +++ b/dev/translation/autotranslator.class.php @@ -77,7 +77,7 @@ class autoTranslator $files = $this->getTranslationFilesArray($this->_refLang); $counter = 1; - foreach($files as $file) + foreach ($files as $file) { if ($this->_limittofile && $this->_limittofile != $file) continue; $counter++; @@ -94,7 +94,7 @@ class autoTranslator // If we must process all languages $arraytmp=dol_dir_list($this->_langDir, 'directories', 0); - foreach($arraytmp as $dirtmp) + foreach ($arraytmp as $dirtmp) { if ($dirtmp['name'] === $this->_refLang) continue; // We discard source language $tmppart=explode('_', $dirtmp['name']); @@ -112,7 +112,7 @@ class autoTranslator } // Process translation of source file for each target languages - foreach($targetlangs as $my_destlang) + foreach ($targetlangs as $my_destlang) { $this->_translatedFiles = array(); @@ -124,15 +124,14 @@ class autoTranslator echo "File not found: " . $destPath . ". We generate it.
\n"; $this->createTranslationFile($destPath, $my_destlang); } - else - { + else { echo "Updating file: " . $destPath . "
\n"; } // Translate lines $fileContentDest = file($destPath, FILE_IGNORE_NEW_LINES|FILE_SKIP_EMPTY_LINES); $newlines=0; - foreach($fileContent as $line){ + foreach ($fileContent as $line){ $key = $this->getLineKey($line); $value = $this->getLineValue($line); if ($key && $value) @@ -167,7 +166,7 @@ class autoTranslator fwrite($fp, "\n"); fwrite($fp, "// START - Lines generated via autotranslator.php tool (".$this->_time.").\n"); fwrite($fp, "// Reference language: ".$this->_refLang." -> ".$my_destlang."\n"); - foreach($this->_translatedFiles[$file] as $line) { + foreach ($this->_translatedFiles[$file] as $line) { fwrite($fp, $line . "\n"); } fwrite($fp, "// STOP - Lines generated via autotranslator.php tool (".$this->_time_end.").\n"); @@ -209,7 +208,7 @@ class autoTranslator { //print "key =".$key."\n"; - foreach($content as $line) { + foreach ($content as $line) { $destKey = $this->getLineKey($line); $destValue = $this->getLineValue($line); // If translated return @@ -273,8 +272,8 @@ class autoTranslator private function getTranslationFilesArray($lang) { $dir = new DirectoryIterator($this->_langDir.$lang); - while($dir->valid()) { - if(!$dir->isDot() && $dir->isFile() && ! preg_match('/^\./', $dir->getFilename())) { + while ($dir->valid()) { + if (!$dir->isDot() && $dir->isFile() && ! preg_match('/^\./', $dir->getFilename())) { $files[] = $dir->getFilename(); } $dir->next(); diff --git a/dev/translation/sanity_check_en_langfiles.php b/dev/translation/sanity_check_en_langfiles.php index f568ba2b04b..0268fc94ed8 100755 --- a/dev/translation/sanity_check_en_langfiles.php +++ b/dev/translation/sanity_check_en_langfiles.php @@ -360,16 +360,14 @@ if ((! empty($_REQUEST['unused']) && $_REQUEST['unused'] == 'true') || (isset($a $unused[$value] = $line; echo $line; // $trad contains the \n } - else - { + else { unset($output); //print 'X'.$output.'Y'; } } if (empty($unused)) print "No string not used found.\n"; - else - { + else { $filetosave='/tmp/'.($argv[2]?$argv[2]:"").'notused.lang'; print "Strings in en_US that are never used are saved into file ".$filetosave.":\n"; file_put_contents($filetosave, implode("", $unused)); diff --git a/dev/translation/strip_language_file.php b/dev/translation/strip_language_file.php index ce28ca5de63..adc5a706d06 100755 --- a/dev/translation/strip_language_file.php +++ b/dev/translation/strip_language_file.php @@ -80,8 +80,8 @@ $aEnglish = array(); if ($filesToProcess == 'all') { $dir = new DirectoryIterator('htdocs/langs/'.$lPrimary); - while($dir->valid()) { - if(!$dir->isDot() && $dir->isFile() && ! preg_match('/^\./', $dir->getFilename())) { + while ($dir->valid()) { + if (!$dir->isDot() && $dir->isFile() && ! preg_match('/^\./', $dir->getFilename())) { $files[] = $dir->getFilename(); } $dir->next(); @@ -94,7 +94,7 @@ else $filesToProcess=explode(',', $filesToProcess); // Loop on each file -foreach($filesToProcess as $fileToProcess) +foreach ($filesToProcess as $fileToProcess) { $lPrimaryFile = 'htdocs/langs/'.$lPrimary.'/'.$fileToProcess; $lSecondaryFile = 'htdocs/langs/'.$lSecondary.'/'.$fileToProcess; @@ -250,11 +250,11 @@ foreach($filesToProcess as $fileToProcess) { if ( ! $oh = fopen($output, 'w') ) { - print "ERROR in writing to file $output\n"; + print "ERROR in writing to file ".$output."\n"; exit; } - print "Read Primary File $lPrimaryFile and write ".$output.":\n"; + print "Read Primary File ".$lPrimaryFile." and write ".$output.":\n"; fwrite($oh, "# Dolibarr language file - Source file is en_US - ".(preg_replace('/\.lang$/', '', $fileToProcess))."\n"); @@ -285,8 +285,7 @@ foreach($filesToProcess as $fileToProcess) print "Key $key is redundant in file $lPrimaryFile (line: $cnt) - Already found into ".$fileFirstFound[$key]." (line: ".$lineFirstFound[$key].").\n"; continue; } - else - { + else { $fileFirstFound[$key] = $fileToProcess; $lineFirstFound[$key] = $cnt; } diff --git a/dev/translation/txpull.sh b/dev/translation/txpull.sh index fcccae98221..65d5af3689b 100755 --- a/dev/translation/txpull.sh +++ b/dev/translation/txpull.sh @@ -33,8 +33,16 @@ if [ "x$1" = "xall" ] then if [ "x$2" = "x" ] then - echo "tx pull" - tx pull + echo "tx pull -a" + tx pull -a + + echo "Remove some language directories (not enough translated)" + rm -fr htdocs/langs/ach + rm -fr htdocs/langs/br_FR + rm -fr htdocs/langs/en + rm -fr htdocs/langs/frp + rm -fr htdocs/langs/fy_NL + else for dir in `find htdocs/langs/* -type d` do diff --git a/htdocs/accountancy/admin/account.php b/htdocs/accountancy/admin/account.php index 86981e5b5de..f6a4adac21e 100644 --- a/htdocs/accountancy/admin/account.php +++ b/htdocs/accountancy/admin/account.php @@ -119,8 +119,7 @@ if (empty($reshook)) { $obj = $db->fetch_object($resql); $country_code = $obj->code; - } - else dol_print_error($db); + } else dol_print_error($db); // Try to load sql file if ($country_code) @@ -143,9 +142,7 @@ if (empty($reshook)) if ($result > 0) { setEventMessages($langs->trans("ChartLoaded"), null, 'mesgs'); - } - else - { + } else { setEventMessages($langs->trans("ErrorDuringChartLoad"), null, 'warnings'); } } @@ -161,7 +158,7 @@ if (empty($reshook)) if ($action == 'disable') { if ($accounting->fetch($id)) { $mode = GETPOST('mode', 'int'); - $result = $accounting->account_desactivate($id, $mode); + $result = $accounting->accountDeactivate($id, $mode); } $action = 'update'; @@ -235,8 +232,7 @@ if (strlen(trim($search_account))) { } $sql .= " AND (aa.account_number LIKE '".$startchar.$search_account_tmp_clean."'"; $sql .= " OR aa.account_number LIKE '".$startchar.$search_account_clean."%')"; - } - else $sql .= natural_search("aa.account_number", $search_account_tmp); + } else $sql .= natural_search("aa.account_number", $search_account_tmp); } } if (strlen(trim($search_label))) $sql .= natural_search("aa.label", $search_label); @@ -267,7 +263,7 @@ if ($resql) { $num = $db->num_rows($resql); - $param = ''; + $param = ''; if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.$contextpage; if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.$limit; if ($search_account) $param .= '&search_account='.urlencode($search_account); @@ -328,8 +324,7 @@ if ($resql) $i++; } - } - else dol_print_error($db); + } else dol_print_error($db); print ""; print ajax_combobox("chartofaccounts"); print ''; @@ -431,9 +426,7 @@ if ($resql) print $accountparent->getNomUrl(1); print "\n"; if (!$i) $totalarray['nbfield']++; - } - else - { + } else { print ' '; if (!$i) $totalarray['nbfield']++; } diff --git a/htdocs/accountancy/admin/accountmodel.php b/htdocs/accountancy/admin/accountmodel.php index b31cd23dfa4..9794198332e 100644 --- a/htdocs/accountancy/admin/accountmodel.php +++ b/htdocs/accountancy/admin/accountmodel.php @@ -228,8 +228,7 @@ if (GETPOST('actionadd', 'alpha') || GETPOST('actionmodify', 'alpha')) { if ($value == 'price' || preg_match('/^amount/i', $value) || $value == 'taux') { $_POST[$listfieldvalue[$i]] = price2num($_POST[$listfieldvalue[$i]], 'MU'); - } - elseif ($value == 'entity') { + } elseif ($value == 'entity') { $_POST[$listfieldvalue[$i]] = $conf->entity; } if ($i) $sql .= ","; @@ -245,13 +244,10 @@ if (GETPOST('actionadd', 'alpha') || GETPOST('actionmodify', 'alpha')) { setEventMessages($langs->transnoentities("RecordSaved"), null, 'mesgs'); $_POST = array('id'=>$id); // Clean $_POST array, we keep only - } - else - { + } else { if ($db->errno() == 'DB_ERROR_RECORD_ALREADY_EXISTS') { setEventMessages($langs->transnoentities("ErrorRecordAlreadyExists"), null, 'errors'); - } - else { + } else { dol_print_error($db); } } @@ -260,8 +256,7 @@ if (GETPOST('actionadd', 'alpha') || GETPOST('actionmodify', 'alpha')) // Si verif ok et action modify, on modifie la ligne if ($ok && GETPOST('actionmodify', 'alpha')) { - if ($tabrowid[$id]) { $rowidcol = $tabrowid[$id]; } - else { $rowidcol = "rowid"; } + if ($tabrowid[$id]) { $rowidcol = $tabrowid[$id]; } else { $rowidcol = "rowid"; } // Modify entry $sql = "UPDATE ".$tabname[$id]." SET "; @@ -276,8 +271,7 @@ if (GETPOST('actionadd', 'alpha') || GETPOST('actionmodify', 'alpha')) { if ($field == 'price' || preg_match('/^amount/i', $field) || $field == 'taux') { $_POST[$listfieldvalue[$i]] = price2num($_POST[$listfieldvalue[$i]], 'MU'); - } - elseif ($field == 'entity') { + } elseif ($field == 'entity') { $_POST[$listfieldvalue[$i]] = $conf->entity; } if ($i) $sql .= ","; @@ -306,8 +300,7 @@ if (GETPOST('actioncancel', 'alpha')) if ($action == 'confirm_delete' && $confirm == 'yes') // delete { - if ($tabrowid[$id]) { $rowidcol = $tabrowid[$id]; } - else { $rowidcol = "rowid"; } + if ($tabrowid[$id]) { $rowidcol = $tabrowid[$id]; } else { $rowidcol = "rowid"; } $sql = "DELETE from ".$tabname[$id]." WHERE ".$rowidcol."='".$rowid."'"; @@ -318,9 +311,7 @@ if ($action == 'confirm_delete' && $confirm == 'yes') // delete if ($db->errno() == 'DB_ERROR_CHILD_EXISTS') { setEventMessages($langs->transnoentities("ErrorRecordIsUsedByChild"), null, 'errors'); - } - else - { + } else { dol_print_error($db); } } @@ -329,13 +320,11 @@ if ($action == 'confirm_delete' && $confirm == 'yes') // delete // activate if ($action == $acts[0]) { - if ($tabrowid[$id]) { $rowidcol = $tabrowid[$id]; } - else { $rowidcol = "rowid"; } + if ($tabrowid[$id]) { $rowidcol = $tabrowid[$id]; } else { $rowidcol = "rowid"; } if ($rowid) { $sql = "UPDATE ".$tabname[$id]." SET active = 1 WHERE ".$rowidcol."='".$rowid."'"; - } - elseif ($code) { + } elseif ($code) { $sql = "UPDATE ".$tabname[$id]." SET active = 1 WHERE code='".$code."'"; } @@ -349,13 +338,11 @@ if ($action == $acts[0]) // disable if ($action == $acts[1]) { - if ($tabrowid[$id]) { $rowidcol = $tabrowid[$id]; } - else { $rowidcol = "rowid"; } + if ($tabrowid[$id]) { $rowidcol = $tabrowid[$id]; } else { $rowidcol = "rowid"; } if ($rowid) { $sql = "UPDATE ".$tabname[$id]." SET active = 0 WHERE ".$rowidcol."='".$rowid."'"; - } - elseif ($code) { + } elseif ($code) { $sql = "UPDATE ".$tabname[$id]." SET active = 0 WHERE code='".$code."'"; } @@ -369,13 +356,11 @@ if ($action == $acts[1]) // favorite if ($action == 'activate_favorite') { - if ($tabrowid[$id]) { $rowidcol = $tabrowid[$id]; } - else { $rowidcol = "rowid"; } + if ($tabrowid[$id]) { $rowidcol = $tabrowid[$id]; } else { $rowidcol = "rowid"; } if ($rowid) { $sql = "UPDATE ".$tabname[$id]." SET favorite = 1 WHERE ".$rowidcol."='".$rowid."'"; - } - elseif ($code) { + } elseif ($code) { $sql = "UPDATE ".$tabname[$id]." SET favorite = 1 WHERE code='".$code."'"; } @@ -389,13 +374,11 @@ if ($action == 'activate_favorite') // disable favorite if ($action == 'disable_favorite') { - if ($tabrowid[$id]) { $rowidcol = $tabrowid[$id]; } - else { $rowidcol = "rowid"; } + if ($tabrowid[$id]) { $rowidcol = $tabrowid[$id]; } else { $rowidcol = "rowid"; } if ($rowid) { $sql = "UPDATE ".$tabname[$id]." SET favorite = 0 WHERE ".$rowidcol."='".$rowid."'"; - } - elseif ($code) { + } elseif ($code) { $sql = "UPDATE ".$tabname[$id]." SET favorite = 0 WHERE code='".$code."'"; } @@ -581,9 +564,7 @@ if ($id) print ''; print $form->select_country($search_country_id, 'search_country_id', '', 28, 'maxwidth200 maxwidthonsmartphone'); print ''; - } - else - { + } else { print ''; } } @@ -629,9 +610,7 @@ if ($id) print ' '; print ' '; - } - else - { + } else { $tmpaction = 'view'; $parameters = array('var'=>$var, 'fieldlist'=>$fieldlist, 'tabname'=>$tabname[$id]); $reshook = $hookmanager->executeHooks('viewDictionaryFieldlist', $parameters, $obj, $tmpaction); // Note that $action and $object may have been modified by some hooks @@ -652,26 +631,20 @@ if ($id) if ($value == 'element') { $valuetoshow = isset($elementList[$valuetoshow]) ? $elementList[$valuetoshow] : $valuetoshow; - } - elseif ($value == 'source') + } elseif ($value == 'source') { $valuetoshow = isset($sourceList[$valuetoshow]) ? $sourceList[$valuetoshow] : $valuetoshow; - } - elseif ($valuetoshow == 'all') { + } elseif ($valuetoshow == 'all') { $valuetoshow = $langs->trans('All'); - } - elseif ($fieldlist[$field] == 'country') { + } elseif ($fieldlist[$field] == 'country') { if (empty($obj->country_code)) { $valuetoshow = '-'; - } - else - { + } else { $key = $langs->trans("Country".strtoupper($obj->country_code)); $valuetoshow = ($key != "Country".strtoupper($obj->country_code) ? $obj->country_code." - ".$key : $obj->country); } - } - elseif ($fieldlist[$field] == 'country_id') { + } elseif ($fieldlist[$field] == 'country_id') { $showfield = 0; } @@ -708,8 +681,7 @@ if ($id) $i++; } } - } - else { + } else { dol_print_error($db); } @@ -761,8 +733,7 @@ function fieldListAccountModel($fieldlist, $obj = '', $tabname = '', $context = $fieldname = 'country'; print $form->select_country((!empty($obj->country_code) ? $obj->country_code : (!empty($obj->country) ? $obj->country : '')), $fieldname, '', 28, 'maxwidth200 maxwidthonsmartphone'); print ''; - } - elseif ($fieldlist[$field] == 'country_id') + } elseif ($fieldlist[$field] == 'country_id') { if (!in_array('country', $fieldlist)) // If there is already a field country, we don't show country_id (avoid duplicate) { @@ -771,8 +742,7 @@ function fieldListAccountModel($fieldlist, $obj = '', $tabname = '', $context = print ''; print ''; } - } - elseif ($fieldlist[$field] == 'type_cdr') { + } elseif ($fieldlist[$field] == 'type_cdr') { if ($fieldlist[$field] == 'type_cdr') print ''; else print ''; if ($fieldlist[$field] == 'type_cdr') { @@ -781,12 +751,9 @@ function fieldListAccountModel($fieldlist, $obj = '', $tabname = '', $context = print $form->selectyesno($fieldlist[$field], (!empty($obj->{$fieldlist[$field]}) ? $obj->{$fieldlist[$field]}:''), 1); } print ''; - } - elseif ($fieldlist[$field] == 'code' && isset($obj->{$fieldlist[$field]})) { + } elseif ($fieldlist[$field] == 'code' && isset($obj->{$fieldlist[$field]})) { print ''; - } - else - { + } else { print ''; $size = ''; $class = ''; if ($fieldlist[$field] == 'code') $size = 'size="8" '; diff --git a/htdocs/accountancy/admin/card.php b/htdocs/accountancy/admin/card.php index 708165fc757..bc695da0203 100644 --- a/htdocs/accountancy/admin/card.php +++ b/htdocs/accountancy/admin/card.php @@ -75,18 +75,14 @@ if ($action == 'add' && $user->rights->accounting->chartofaccount) if ($conf->global->ACCOUNTING_MANAGE_ZERO == 1) { $account_number = GETPOST('account_number', 'string'); - } - else - { + } else { $account_number = clean_account(GETPOST('account_number', 'string')); } if (GETPOST('account_parent', 'int') <= 0) { $account_parent = 0; - } - else - { + } else { $account_parent = GETPOST('account_parent', 'int'); } @@ -104,13 +100,11 @@ if ($action == 'add' && $user->rights->accounting->chartofaccount) $error = 1; $action = "create"; setEventMessages($object->error, $object->errors, 'errors'); - } - elseif ($res == - 4) { + } elseif ($res == - 4) { $error = 2; $action = "create"; setEventMessages($object->error, $object->errors, 'errors'); - } - elseif ($res < 0) + } elseif ($res < 0) { $error++; setEventMessages($object->error, $object->errors, 'errors'); @@ -140,18 +134,14 @@ if ($action == 'add' && $user->rights->accounting->chartofaccount) if ($conf->global->ACCOUNTING_MANAGE_ZERO == 1) { $account_number = GETPOST('account_number', 'string'); - } - else - { + } else { $account_number = clean_account(GETPOST('account_number', 'string')); } if (GETPOST('account_parent', 'int') <= 0) { $account_parent = 0; - } - else - { + } else { $account_parent = GETPOST('account_parent', 'int'); } @@ -269,8 +259,7 @@ if ($action == 'create') { print ''; print ''; -} -elseif ($id > 0 || $ref) { +} elseif ($id > 0 || $ref) { $result = $object->fetch($id, $ref, 1); if ($result > 0) { diff --git a/htdocs/accountancy/admin/categories_list.php b/htdocs/accountancy/admin/categories_list.php index 1b2733e2045..ddd4240a073 100644 --- a/htdocs/accountancy/admin/categories_list.php +++ b/htdocs/accountancy/admin/categories_list.php @@ -235,13 +235,10 @@ if (GETPOST('actionadd', 'alpha') || GETPOST('actionmodify', 'alpha')) { setEventMessages($langs->transnoentities("RecordSaved"), null, 'mesgs'); $_POST = array('id'=>$id); // Clean $_POST array, we keep only - } - else - { + } else { if ($db->errno() == 'DB_ERROR_RECORD_ALREADY_EXISTS') { setEventMessages($langs->transnoentities("ErrorRecordAlreadyExists"), null, 'errors'); - } - else { + } else { dol_print_error($db); } } @@ -250,8 +247,7 @@ if (GETPOST('actionadd', 'alpha') || GETPOST('actionmodify', 'alpha')) // Si verif ok et action modify, on modifie la ligne if ($ok && GETPOST('actionmodify', 'alpha')) { - if ($tabrowid[$id]) { $rowidcol = $tabrowid[$id]; } - else { $rowidcol = "rowid"; } + if ($tabrowid[$id]) { $rowidcol = $tabrowid[$id]; } else { $rowidcol = "rowid"; } // Modify entry $sql = "UPDATE ".$tabname[$id]." SET "; @@ -266,8 +262,7 @@ if (GETPOST('actionadd', 'alpha') || GETPOST('actionmodify', 'alpha')) { if ($field == 'fk_country' && $_POST['country'] > 0) { $_POST[$listfieldvalue[$i]] = $_POST['country']; - } - elseif ($field == 'entity') { + } elseif ($field == 'entity') { $_POST[$listfieldvalue[$i]] = $conf->entity; } if ($i) $sql .= ","; @@ -296,8 +291,7 @@ if (GETPOST('actioncancel', 'alpha')) if ($action == 'confirm_delete' && $confirm == 'yes') // delete { - if ($tabrowid[$id]) { $rowidcol = $tabrowid[$id]; } - else { $rowidcol = "rowid"; } + if ($tabrowid[$id]) { $rowidcol = $tabrowid[$id]; } else { $rowidcol = "rowid"; } $sql = "DELETE from ".$tabname[$id]." WHERE ".$rowidcol." = '".$db->escape($rowid)."'"; @@ -308,9 +302,7 @@ if ($action == 'confirm_delete' && $confirm == 'yes') // delete if ($db->errno() == 'DB_ERROR_CHILD_EXISTS') { setEventMessages($langs->transnoentities("ErrorRecordIsUsedByChild"), null, 'errors'); - } - else - { + } else { dol_print_error($db); } } @@ -319,13 +311,11 @@ if ($action == 'confirm_delete' && $confirm == 'yes') // delete // activate if ($action == $acts[0]) { - if ($tabrowid[$id]) { $rowidcol = $tabrowid[$id]; } - else { $rowidcol = "rowid"; } + if ($tabrowid[$id]) { $rowidcol = $tabrowid[$id]; } else { $rowidcol = "rowid"; } if ($rowid) { $sql = "UPDATE ".$tabname[$id]." SET active = 1 WHERE ".$rowidcol." = '".$db->escape($rowid)."'"; - } - elseif ($code) { + } elseif ($code) { $sql = "UPDATE ".$tabname[$id]." SET active = 1 WHERE code = '".$db->escape($code)."'"; } @@ -339,13 +329,11 @@ if ($action == $acts[0]) // disable if ($action == $acts[1]) { - if ($tabrowid[$id]) { $rowidcol = $tabrowid[$id]; } - else { $rowidcol = "rowid"; } + if ($tabrowid[$id]) { $rowidcol = $tabrowid[$id]; } else { $rowidcol = "rowid"; } if ($rowid) { $sql = "UPDATE ".$tabname[$id]." SET active = 0 WHERE ".$rowidcol." = '".$db->escape($rowid)."'"; - } - elseif ($code) { + } elseif ($code) { $sql = "UPDATE ".$tabname[$id]." SET active = 0 WHERE code = '".$db->escape($code)."'"; } @@ -359,13 +347,11 @@ if ($action == $acts[1]) // favorite if ($action == 'activate_favorite') { - if ($tabrowid[$id]) { $rowidcol = $tabrowid[$id]; } - else { $rowidcol = "rowid"; } + if ($tabrowid[$id]) { $rowidcol = $tabrowid[$id]; } else { $rowidcol = "rowid"; } if ($rowid) { $sql = "UPDATE ".$tabname[$id]." SET favorite = 1 WHERE ".$rowidcol." = '".$db->escape($rowid)."'"; - } - elseif ($code) { + } elseif ($code) { $sql = "UPDATE ".$tabname[$id]." SET favorite = 1 WHERE code = '".$db->escape($code)."'"; } @@ -379,13 +365,11 @@ if ($action == 'activate_favorite') // disable favorite if ($action == 'disable_favorite') { - if ($tabrowid[$id]) { $rowidcol = $tabrowid[$id]; } - else { $rowidcol = "rowid"; } + if ($tabrowid[$id]) { $rowidcol = $tabrowid[$id]; } else { $rowidcol = "rowid"; } if ($rowid) { $sql = "UPDATE ".$tabname[$id]." SET favorite = 0 WHERE ".$rowidcol." = '".$db->escape($rowid)."'"; - } - elseif ($code) { + } elseif ($code) { $sql = "UPDATE ".$tabname[$id]." SET favorite = 0 WHERE code = '".$db->escape($code)."'"; } @@ -597,9 +581,7 @@ if ($id) print $form->select_country($search_country_id, 'search_country_id', '', 28, 'maxwidth200 maxwidthonsmartphone'); print ''; $filterfound++; - } - else - { + } else { print ''; } } @@ -726,10 +708,8 @@ if ($id) print ''; print ''; print ''; - } - else - { - $tmpaction = 'view'; + } else { + $tmpaction = 'view'; $parameters = array('var'=>$var, 'fieldlist'=>$fieldlist, 'tabname'=>$tabname[$id]); $reshook = $hookmanager->executeHooks('viewDictionaryFieldlist', $parameters, $obj, $tmpaction); // Note that $action and $object may have been modified by some hooks @@ -745,35 +725,27 @@ if ($id) if ($value == 'category_type') { $valuetoshow = yn($valuetoshow); - } - elseif ($valuetoshow == 'all') { + } elseif ($valuetoshow == 'all') { $valuetoshow = $langs->trans('All'); - } - elseif ($fieldlist[$field] == 'country') { + } elseif ($fieldlist[$field] == 'country') { if (empty($obj->country_code)) { $valuetoshow = '-'; - } - else - { + } else { $key = $langs->trans("Country".strtoupper($obj->country_code)); $valuetoshow = ($key != "Country".strtoupper($obj->country_code) ? $obj->country_code." - ".$key : $obj->country); } - } - elseif ($fieldlist[$field] == 'label' && $tabname[$id] == MAIN_DB_PREFIX.'c_country') { + } elseif ($fieldlist[$field] == 'label' && $tabname[$id] == MAIN_DB_PREFIX.'c_country') { $key = $langs->trans("Country".strtoupper($obj->code)); $valuetoshow = ($obj->code && $key != "Country".strtoupper($obj->code) ? $key : $obj->{$fieldlist[$field]}); - } - elseif ($fieldlist[$field] == 'label' && $tabname[$id] == MAIN_DB_PREFIX.'c_availability') { + } elseif ($fieldlist[$field] == 'label' && $tabname[$id] == MAIN_DB_PREFIX.'c_availability') { $langs->loadLangs(array("propal")); $key = $langs->trans("AvailabilityType".strtoupper($obj->code)); $valuetoshow = ($obj->code && $key != "AvailabilityType".strtoupper($obj->code) ? $key : $obj->{$fieldlist[$field]}); - } - elseif ($fieldlist[$field] == 'libelle' && $tabname[$id] == MAIN_DB_PREFIX.'c_actioncomm') { + } elseif ($fieldlist[$field] == 'libelle' && $tabname[$id] == MAIN_DB_PREFIX.'c_actioncomm') { $key = $langs->trans("Action".strtoupper($obj->code)); $valuetoshow = ($obj->code && $key != "Action".strtoupper($obj->code) ? $key : $obj->{$fieldlist[$field]}); - } - elseif ($fieldlist[$field] == 'region_id' || $fieldlist[$field] == 'country_id') { + } elseif ($fieldlist[$field] == 'region_id' || $fieldlist[$field] == 'country_id') { $showfield = 0; } @@ -799,8 +771,7 @@ if ($id) // Active print ''; if ($canbedisabled) print ''.$actl[$obj->active].''; - else - { + else { print $langs->trans("AlwaysActive"); } print ""; @@ -816,8 +787,7 @@ if ($id) if ($user->admin) print ''.img_delete().''; //else print ''.img_delete().''; // Some dictionary can be edited by other profile than admin print ''; - } - else print ' '; + } else print ' '; // Link to setup the group print ''; @@ -833,8 +803,7 @@ if ($id) $i++; } } - } - else { + } else { dol_print_error($db); } @@ -882,14 +851,11 @@ function fieldListAccountingCategories($fieldlist, $obj = '', $tabname = '', $co { $fieldname = 'country_id'; print $form->select_country(GETPOST('country_id', 'int'), $fieldname, '', 28, 'maxwidth200 maxwidthonsmartphone'); - } - else - { + } else { print $form->select_country((!empty($obj->country_code) ? $obj->country_code : (!empty($obj->country) ? $obj->country : $mysoc->country_code)), $fieldname, '', 28, 'maxwidth200 maxwidthonsmartphone'); } print ''; - } - elseif ($fieldlist[$field] == 'country_id') + } elseif ($fieldlist[$field] == 'country_id') { if (!in_array('country', $fieldlist)) // If there is already a field country, we don't show country_id (avoid duplicate) { @@ -898,17 +864,13 @@ function fieldListAccountingCategories($fieldlist, $obj = '', $tabname = '', $co print ''; print ''; } - } - elseif ($fieldlist[$field] == 'category_type') { + } elseif ($fieldlist[$field] == 'category_type') { print ''; print $form->selectyesno($fieldlist[$field], (!empty($obj->{$fieldlist[$field]}) ? $obj->{$fieldlist[$field]}:''), 1); print ''; - } - elseif ($fieldlist[$field] == 'code' && isset($obj->{$fieldlist[$field]})) { + } elseif ($fieldlist[$field] == 'code' && isset($obj->{$fieldlist[$field]})) { print ''; - } - else - { + } else { print ''; $size = ''; $class = ''; if ($fieldlist[$field] == 'code') $class = 'maxwidth100'; diff --git a/htdocs/accountancy/admin/defaultaccounts.php b/htdocs/accountancy/admin/defaultaccounts.php index ad22a88f415..96303f36b1d 100644 --- a/htdocs/accountancy/admin/defaultaccounts.php +++ b/htdocs/accountancy/admin/defaultaccounts.php @@ -193,8 +193,7 @@ foreach ($list_account as $key) { $reg = array(); if (preg_match('/---(.*)---/', $key, $reg)) { print ''.$langs->trans($reg[1]).''; - } - else { + } else { print ''; // Param $label = $langs->trans($key); diff --git a/htdocs/accountancy/admin/fiscalyear_card.php b/htdocs/accountancy/admin/fiscalyear_card.php index 88890aa004f..27ef1ea7bd1 100644 --- a/htdocs/accountancy/admin/fiscalyear_card.php +++ b/htdocs/accountancy/admin/fiscalyear_card.php @@ -71,9 +71,7 @@ if ($action == 'confirm_delete' && $confirm == "yes") { } else { setEventMessages($object->error, $object->errors, 'errors'); } -} - -elseif ($action == 'add') { +} elseif ($action == 'add') { if (!GETPOST('cancel', 'alpha')) { $error = 0; diff --git a/htdocs/accountancy/admin/journals_list.php b/htdocs/accountancy/admin/journals_list.php index e34ce8094dd..74247c5fccd 100644 --- a/htdocs/accountancy/admin/journals_list.php +++ b/htdocs/accountancy/admin/journals_list.php @@ -238,13 +238,10 @@ if (GETPOST('actionadd', 'alpha') || GETPOST('actionmodify', 'alpha')) { setEventMessages($langs->transnoentities("RecordSaved"), null, 'mesgs'); $_POST = array('id'=>$id); // Clean $_POST array, we keep only - } - else - { + } else { if ($db->errno() == 'DB_ERROR_RECORD_ALREADY_EXISTS') { setEventMessages($langs->transnoentities("ErrorRecordAlreadyExists"), null, 'errors'); - } - else { + } else { dol_print_error($db); } } @@ -253,8 +250,7 @@ if (GETPOST('actionadd', 'alpha') || GETPOST('actionmodify', 'alpha')) // Si verif ok et action modify, on modifie la ligne if ($ok && GETPOST('actionmodify', 'alpha')) { - if ($tabrowid[$id]) { $rowidcol = $tabrowid[$id]; } - else { $rowidcol = "rowid"; } + if ($tabrowid[$id]) { $rowidcol = $tabrowid[$id]; } else { $rowidcol = "rowid"; } // Modify entry $sql = "UPDATE ".$tabname[$id]." SET "; @@ -269,8 +265,7 @@ if (GETPOST('actionadd', 'alpha') || GETPOST('actionmodify', 'alpha')) { if ($field == 'price' || preg_match('/^amount/i', $field) || $field == 'taux') { $_POST[$listfieldvalue[$i]] = price2num($_POST[$listfieldvalue[$i]], 'MU'); - } - elseif ($field == 'entity') { + } elseif ($field == 'entity') { $_POST[$listfieldvalue[$i]] = $conf->entity; } if ($i) $sql .= ","; @@ -300,8 +295,7 @@ if (GETPOST('actionadd', 'alpha') || GETPOST('actionmodify', 'alpha')) if ($action == 'confirm_delete' && $confirm == 'yes') // delete { - if ($tabrowid[$id]) { $rowidcol = $tabrowid[$id]; } - else { $rowidcol = "rowid"; } + if ($tabrowid[$id]) { $rowidcol = $tabrowid[$id]; } else { $rowidcol = "rowid"; } $sql = "DELETE from ".$tabname[$id]." WHERE ".$rowidcol."='".$rowid."'"; $sql .= " AND entity = ".$conf->entity; @@ -313,9 +307,7 @@ if ($action == 'confirm_delete' && $confirm == 'yes') // delete if ($db->errno() == 'DB_ERROR_CHILD_EXISTS') { setEventMessages($langs->transnoentities("ErrorRecordIsUsedByChild"), null, 'errors'); - } - else - { + } else { dol_print_error($db); } } @@ -324,13 +316,11 @@ if ($action == 'confirm_delete' && $confirm == 'yes') // delete // activate if ($action == $acts[0]) { - if ($tabrowid[$id]) { $rowidcol = $tabrowid[$id]; } - else { $rowidcol = "rowid"; } + if ($tabrowid[$id]) { $rowidcol = $tabrowid[$id]; } else { $rowidcol = "rowid"; } if ($rowid) { $sql = "UPDATE ".$tabname[$id]." SET active = 1 WHERE ".$rowidcol."='".$rowid."'"; - } - elseif ($code) { + } elseif ($code) { $sql = "UPDATE ".$tabname[$id]." SET active = 1 WHERE code='".$code."'"; } $sql .= " AND entity = ".$conf->entity; @@ -345,13 +335,11 @@ if ($action == $acts[0]) // disable if ($action == $acts[1]) { - if ($tabrowid[$id]) { $rowidcol = $tabrowid[$id]; } - else { $rowidcol = "rowid"; } + if ($tabrowid[$id]) { $rowidcol = $tabrowid[$id]; } else { $rowidcol = "rowid"; } if ($rowid) { $sql = "UPDATE ".$tabname[$id]." SET active = 0 WHERE ".$rowidcol."='".$rowid."'"; - } - elseif ($code) { + } elseif ($code) { $sql = "UPDATE ".$tabname[$id]." SET active = 0 WHERE code='".$code."'"; } $sql .= " AND entity = ".$conf->entity; @@ -595,9 +583,7 @@ if ($id) print ''; print '
'; print ''; - } - else - { + } else { $tmpaction = 'view'; $parameters = array('var'=>$var, 'fieldlist'=>$fieldlist, 'tabname'=>$tabname[$id]); $reshook = $hookmanager->executeHooks('viewDictionaryFieldlist', $parameters, $obj, $tmpaction); // Note that $action and $object may have been modified by some hooks @@ -614,12 +600,10 @@ if ($id) $valuetoshow = $obj->{$fieldlist[$field]}; if ($valuetoshow == 'all') { $valuetoshow = $langs->trans('All'); - } - elseif ($fieldlist[$field] == 'nature' && $tabname[$id] == MAIN_DB_PREFIX.'accounting_journal') { + } elseif ($fieldlist[$field] == 'nature' && $tabname[$id] == MAIN_DB_PREFIX.'accounting_journal') { $key = $langs->trans("AccountingJournalType".strtoupper($obj->nature)); $valuetoshow = ($obj->nature && $key != "AccountingJournalType".strtoupper($langs->trans($obj->nature)) ? $key : $obj->{$fieldlist[$field]}); - } - elseif ($fieldlist[$field] == 'label' && $tabname[$id] == MAIN_DB_PREFIX.'accounting_journal') { + } elseif ($fieldlist[$field] == 'label' && $tabname[$id] == MAIN_DB_PREFIX.'accounting_journal') { $valuetoshow = $langs->trans($obj->label); } @@ -667,8 +651,7 @@ if ($id) if ($user->admin) print ''.img_delete().''; //else print ''.img_delete().''; // Some dictionary can be edited by other profile than admin print ''; - } - else print ' '; + } else print ' '; print ''; @@ -679,8 +662,7 @@ if ($id) $i++; } } - } - else { + } else { dol_print_error($db); } @@ -724,12 +706,9 @@ function fieldListJournal($fieldlist, $obj = '', $tabname = '', $context = '') print ''; print $form->selectarray('nature', $sourceList, (!empty($obj->{$fieldlist[$field]}) ? $obj->{$fieldlist[$field]}:'')); print ''; - } - elseif ($fieldlist[$field] == 'code' && isset($obj->{$fieldlist[$field]})) { + } elseif ($fieldlist[$field] == 'code' && isset($obj->{$fieldlist[$field]})) { print ''; - } - else - { + } else { print ''; $size = ''; $class = ''; if ($fieldlist[$field] == 'code') $class = 'maxwidth100'; diff --git a/htdocs/accountancy/admin/productaccount.php b/htdocs/accountancy/admin/productaccount.php index e32e47b169d..b6465b95355 100644 --- a/htdocs/accountancy/admin/productaccount.php +++ b/htdocs/accountancy/admin/productaccount.php @@ -252,25 +252,19 @@ $sql .= " FROM ".MAIN_DB_PREFIX."product as p"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa ON"; if ($accounting_product_mode == 'ACCOUNTANCY_BUY') { $sql .= " p.accountancy_code_buy = aa.account_number AND aa.fk_pcg_version = '".$pcgvercode."'"; -} -elseif ($accounting_product_mode == 'ACCOUNTANCY_BUY_INTRA') +} elseif ($accounting_product_mode == 'ACCOUNTANCY_BUY_INTRA') { $sql .= " p.accountancy_code_buy_intra = aa.account_number AND aa.fk_pcg_version = '".$pcgvercode."'"; -} -elseif ($accounting_product_mode == 'ACCOUNTANCY_BUY_EXPORT') +} elseif ($accounting_product_mode == 'ACCOUNTANCY_BUY_EXPORT') { $sql .= " p.accountancy_code_buy_export = aa.account_number AND aa.fk_pcg_version = '".$pcgvercode."'"; -} -elseif ($accounting_product_mode == 'ACCOUNTANCY_SELL') +} elseif ($accounting_product_mode == 'ACCOUNTANCY_SELL') { $sql .= " p.accountancy_code_sell = aa.account_number AND aa.fk_pcg_version = '".$pcgvercode."'"; -} -elseif ($accounting_product_mode == 'ACCOUNTANCY_SELL_INTRA') +} elseif ($accounting_product_mode == 'ACCOUNTANCY_SELL_INTRA') { $sql .= " p.accountancy_code_sell_intra = aa.account_number AND aa.fk_pcg_version = '".$pcgvercode."'"; -} -else -{ +} else { $sql .= " p.accountancy_code_sell_export = aa.account_number AND aa.fk_pcg_version = '".$pcgvercode."'"; } $sql .= ' WHERE p.entity IN ('.getEntity('product').')'; @@ -290,13 +284,11 @@ if ($accounting_product_mode == 'ACCOUNTANCY_BUY') { if (strlen(trim($search_current_account))) { $sql .= natural_search("p.accountancy_code_sell", $search_current_account); } -} -elseif ($accounting_product_mode == 'ACCOUNTANCY_SELL_INTRA') { +} elseif ($accounting_product_mode == 'ACCOUNTANCY_SELL_INTRA') { if (strlen(trim($search_current_account))) { $sql .= natural_search("p.accountancy_code_sell_intra", $search_current_account); } -} -else { +} else { if (strlen(trim($search_current_account))) { $sql .= natural_search("p.accountancy_code_sell_export", $search_current_account); } @@ -492,34 +484,27 @@ if ($result) if ($accounting_product_mode == 'ACCOUNTANCY_SELL') { $compta_prodsell = (!empty($conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT : $langs->trans("CodeNotDef")); $compta_prodsell_id = $aarowid_prodsell; - } - elseif ($accounting_product_mode == 'ACCOUNTANCY_SELL_INTRA') { + } elseif ($accounting_product_mode == 'ACCOUNTANCY_SELL_INTRA') { $compta_prodsell = (!empty($conf->global->ACCOUNTING_PRODUCT_SOLD_INTRA_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_SOLD_INTRA_ACCOUNT : $langs->trans("CodeNotDef")); $compta_prodsell_id = $aarowid_prodsell_intra; - } - elseif ($accounting_product_mode == 'ACCOUNTANCY_SELL_EXPORT') { + } elseif ($accounting_product_mode == 'ACCOUNTANCY_SELL_EXPORT') { $compta_prodsell = (!empty($conf->global->ACCOUNTING_PRODUCT_SOLD_EXPORT_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_SOLD_EXPORT_ACCOUNT : $langs->trans("CodeNotDef")); $compta_prodsell_id = $aarowid_prodsell_export; - } - else { + } else { $compta_prodsell = (!empty($conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT : $langs->trans("CodeNotDef")); $compta_prodsell_id = $aarowid_prodsell; } - } - else { + } else { if ($accounting_product_mode == 'ACCOUNTANCY_SELL') { $compta_prodsell = (!empty($conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT : $langs->trans("CodeNotDef")); $compta_prodsell_id = $aarowid_servsell; - } - elseif ($accounting_product_mode == 'ACCOUNTANCY_SELL_INTRA') { + } elseif ($accounting_product_mode == 'ACCOUNTANCY_SELL_INTRA') { $compta_prodsell = (!empty($conf->global->ACCOUNTING_SERVICE_SOLD_INTRA_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_SOLD_INTRA_ACCOUNT : $langs->trans("CodeNotDef")); $compta_prodsell_id = $aarowid_servsell_intra; - } - elseif ($accounting_product_mode == 'ACCOUNTANCY_SELL_EXPORT') { + } elseif ($accounting_product_mode == 'ACCOUNTANCY_SELL_EXPORT') { $compta_prodsell = (!empty($conf->global->ACCOUNTING_SERVICE_SOLD_EXPORT_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_SOLD_EXPORT_ACCOUNT : $langs->trans("CodeNotDef")); $compta_prodsell_id = $aarowid_servsell_export; - } - else { + } else { $compta_prodsell = (!empty($conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT : $langs->trans("CodeNotDef")); $compta_prodsell_id = $aarowid_servsell; } @@ -530,34 +515,27 @@ if ($result) if ($accounting_product_mode == 'ACCOUNTANCY_BUY') { $compta_prodbuy = (!empty($conf->global->ACCOUNTING_PRODUCT_BUY_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_BUY_ACCOUNT : $langs->trans("CodeNotDef")); $compta_prodbuy_id = $aarowid_prodbuy; - } - elseif ($accounting_product_mode == 'ACCOUNTANCY_BUY_INTRA') { + } elseif ($accounting_product_mode == 'ACCOUNTANCY_BUY_INTRA') { $compta_prodbuy = (!empty($conf->global->ACCOUNTING_PRODUCT_BUY_INTRA_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_BUY_INTRA_ACCOUNT : $langs->trans("CodeNotDef")); $compta_prodbuy_id = $aarowid_prodbuy_intra; - } - elseif ($accounting_product_mode == 'ACCOUNTANCY_BUY_EXPORT') { + } elseif ($accounting_product_mode == 'ACCOUNTANCY_BUY_EXPORT') { $compta_prodbuy = (!empty($conf->global->ACCOUNTING_PRODUCT_BUY_EXPORT_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_BUY_EXPORT_ACCOUNT : $langs->trans("CodeNotDef")); $compta_prodbuy_id = $aarowid_prodbuy_export; - } - else { + } else { $compta_prodbuy = (!empty($conf->global->ACCOUNTING_PRODUCT_BUY_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_BUY_ACCOUNT : $langs->trans("CodeNotDef")); $compta_prodbuy_id = $aarowid_prodbuy; } - } - else { + } else { if ($accounting_product_mode == 'ACCOUNTANCY_BUY') { $compta_prodbuy = (!empty($conf->global->ACCOUNTING_SERVICE_BUY_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_BUY_ACCOUNT : $langs->trans("CodeNotDef")); $compta_prodbuy_id = $aarowid_servbuy; - } - elseif ($accounting_product_mode == 'ACCOUNTANCY_BUY_INTRA') { + } elseif ($accounting_product_mode == 'ACCOUNTANCY_BUY_INTRA') { $compta_prodbuy = (!empty($conf->global->ACCOUNTING_SERVICE_BUY_INTRA_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_BUY_INTRA_ACCOUNT : $langs->trans("CodeNotDef")); $compta_prodbuy_id = $aarowid_servbuy_intra; - } - elseif ($accounting_product_mode == 'ACCOUNTANCY_BUY_EXPORT') { + } elseif ($accounting_product_mode == 'ACCOUNTANCY_BUY_EXPORT') { $compta_prodbuy = (!empty($conf->global->ACCOUNTING_SERVICE_BUY_EXPORT_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_BUY_EXPORT_ACCOUNT : $langs->trans("CodeNotDef")); $compta_prodbuy_id = $aarowid_servbuy_export; - } - else { + } else { $compta_prodbuy = (!empty($conf->global->ACCOUNTING_SERVICE_BUY_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_BUY_ACCOUNT : $langs->trans("CodeNotDef")); $compta_prodbuy_id = $aarowid_servbuy; } @@ -620,7 +598,7 @@ if ($result) if (!empty($obj->aaid)) $defaultvalue = ''; // Do not suggest default new value is code is already valid print $form->select_account($defaultvalue, 'codeventil_'.$product_static->id, 1, array(), 1); print ''; - } elseif ($accounting_product_mode == 'ACCOUNTANCY_BUY_INTRA') { + } elseif ($accounting_product_mode == 'ACCOUNTANCY_BUY_INTRA') { // Accounting account buy intra (In EEC) print ''; //$defaultvalue=GETPOST('codeventil_' . $product_static->id,'alpha'); This is id and we need a code @@ -630,7 +608,7 @@ if ($result) if (!empty($obj->aaid)) $defaultvalue = ''; // Do not suggest default new value is code is already valid print $form->select_account($defaultvalue, 'codeventil_'.$product_static->id, 1, array(), 1); print ''; - } elseif ($accounting_product_mode == 'ACCOUNTANCY_BUY_EXPORT') { + } elseif ($accounting_product_mode == 'ACCOUNTANCY_BUY_EXPORT') { // Accounting account buy export (Out of EEC) print ''; //$defaultvalue=GETPOST('codeventil_' . $product_static->id,'alpha'); This is id and we need a code diff --git a/htdocs/accountancy/bookkeeping/balance.php b/htdocs/accountancy/bookkeeping/balance.php index b2a25b00ce2..4de2be6fcbb 100644 --- a/htdocs/accountancy/bookkeeping/balance.php +++ b/htdocs/accountancy/bookkeeping/balance.php @@ -55,7 +55,7 @@ $pagenext = $page + 1; //if (! $sortfield) $sortfield="p.date_fin"; //if (! $sortorder) $sortorder="DESC"; - +$show_subgroup = GETPOST('show_subgroup', 'alpha'); $search_date_start = dol_mktime(0, 0, 0, GETPOST('date_startmonth', 'int'), GETPOST('date_startday', 'int'), GETPOST('date_startyear', 'int')); $search_date_end = dol_mktime(23, 59, 59, GETPOST('date_endmonth', 'int'), GETPOST('date_endday', 'int'), GETPOST('date_endyear', 'int')); @@ -130,10 +130,11 @@ if (!empty($search_accountancy_code_end)) { if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // All tests are required to be compatible with all browsers { - $search_accountancy_code_start = ''; - $search_accountancy_code_end = ''; + $show_subgroup = ''; $search_date_start = ''; $search_date_end = ''; + $search_accountancy_code_start = ''; + $search_accountancy_code_end = ''; $filter = array(); } @@ -223,6 +224,12 @@ if ($action != 'export_csv') $moreforfilter .= $form->selectDate($search_date_start ? $search_date_start : -1, 'date_start', 0, 0, 1, '', 1, 0); $moreforfilter .= $langs->trans('DateEnd').': '; $moreforfilter .= $form->selectDate($search_date_end ? $search_date_end : -1, 'date_end', 0, 0, 1, '', 1, 0); + + $moreforfilter .= ' - '; + $moreforfilter .= $langs->trans('ShowSubtotalByGroup').': '; + $moreforfilter .= ''; + + $moreforfilter .= ''; if (!empty($moreforfilter)) { @@ -289,26 +296,31 @@ if ($action != 'export_csv') } print ''; - // Permet d'afficher le compte comptable - if (empty($displayed_account) || $root_account_description != $displayed_account) + if (!empty($show_subgroup)) { - // Affiche un Sous-Total par compte comptable - if ($displayed_account != "") { - print ''.$langs->trans("SubTotal").':'.price($sous_total_debit).''.price($sous_total_credit).''.price(price2num($sous_total_credit - $sous_total_debit)).''; - print " \n"; + // Show accounting account + if (empty($displayed_account) || $root_account_description != $displayed_account) { + // Show subtotal per accounting account + if ($displayed_account != "") { + print ''; + print ''.$langs->trans("SubTotal").':'; + print ''.price($sous_total_debit).''; + print ''.price($sous_total_credit).''; + print ''.price(price2num($sous_total_credit - $sous_total_debit)).''; + print "\n"; + print ''; + } + + // Show first line of a break + print ''; + print ''.$line->numero_compte.($root_account_description ? ' - '.$root_account_description : '').''; print ''; + + $displayed_account = $root_account_description; + $sous_total_debit = 0; + $sous_total_credit = 0; } - - // Show first line of a break - print ''; - print ''.$line->numero_compte.($root_account_description ? ' - '.$root_account_description : '').''; - print ''; - - $displayed_account = $root_account_description; - $sous_total_debit = 0; - $sous_total_credit = 0; } - // $object->get_compte_racine($line->numero_compte); print ''.length_accountg($line->numero_compte).''; @@ -326,12 +338,15 @@ if ($action != 'export_csv') $sous_total_credit += $line->credit; } - print ''.$langs->trans("SubTotal").':'.price($sous_total_debit).''.price($sous_total_credit).''.price(price2num($sous_total_debit - $sous_total_credit)).''; - print " \n"; - print ''; + if (!empty($show_subgroup)) + { + print ''.$langs->trans("SubTotal").':'.price($sous_total_debit).''.price($sous_total_credit).''.price(price2num($sous_total_debit - $sous_total_credit)).''; + print "\n"; + print ''; + } print ''.$langs->trans("AccountBalance").':'.price($total_debit).''.price($total_credit).''.price(price2num($total_debit - $total_credit)).''; - print " \n"; + print "\n"; print ''; print ""; diff --git a/htdocs/accountancy/bookkeeping/card.php b/htdocs/accountancy/bookkeeping/card.php index 26476119cca..1fcce431b24 100644 --- a/htdocs/accountancy/bookkeeping/card.php +++ b/htdocs/accountancy/bookkeeping/card.php @@ -138,9 +138,7 @@ if ($action == "confirm_update") { } } } -} - -elseif ($action == "add") { +} elseif ($action == "add") { $error = 0; if ((floatval($debit) != 0.0) && (floatval($credit) != 0.0)) @@ -199,9 +197,7 @@ elseif ($action == "add") { $action = ''; } } -} - -elseif ($action == "confirm_delete") { +} elseif ($action == "confirm_delete") { $object = new BookKeeping($db); $result = $object->fetch($id, null, $mode); @@ -216,9 +212,7 @@ elseif ($action == "confirm_delete") { } } $action = ''; -} - -elseif ($action == "confirm_create") { +} elseif ($action == "confirm_create") { $error = 0; $object = new BookKeeping($db); @@ -438,7 +432,7 @@ if ($action == 'create') print $langs->trans('Docdate'); print ''; if ($action != 'editdate') - print 'piece_num.'&mode='.$mode.'">'.img_edit($langs->transnoentitiesnoconv('SetDate'), 1).''; + print 'piece_num.'&mode='.$mode.'">'.img_edit($langs->transnoentitiesnoconv('SetDate'), 1).''; print ''; print ''; if ($action == 'editdate') { @@ -462,7 +456,7 @@ if ($action == 'create') print $langs->trans('Codejournal'); print ''; if ($action != 'editjournal') - print 'piece_num.'&mode='.$mode.'">'.img_edit($langs->transnoentitiesnoconv('Edit'), 1).''; + print 'piece_num.'&mode='.$mode.'">'.img_edit($langs->transnoentitiesnoconv('Edit'), 1).''; print ''; print ''; if ($action == 'editjournal') { @@ -486,7 +480,7 @@ if ($action == 'create') print $langs->trans('Piece'); print ''; if ($action != 'editdocref') - print 'piece_num.'&mode='.$mode.'">'.img_edit($langs->transnoentitiesnoconv('Edit'), 1).''; + print 'piece_num.'&mode='.$mode.'">'.img_edit($langs->transnoentitiesnoconv('Edit'), 1).''; print ''; print ''; if ($action == 'editdocref') { @@ -628,9 +622,7 @@ if ($action == 'create') if (!empty($conf->global->ACCOUNTANCY_COMBO_FOR_AUX)) { print $formaccounting->select_auxaccount((GETPOSTISSET("subledger_account") ? GETPOST("subledger_account", "alpha") : $line->subledger_account), 'subledger_account', 1); - } - else - { + } else { print 'subledger_account).'">'; } print ''; @@ -650,8 +642,8 @@ if ($action == 'create') print ''.price($line->credit).''; print ''; - print 'id.'&piece_num='.$line->piece_num.'&mode='.$mode.'">'; - print img_edit(); + print 'id.'&piece_num='.$line->piece_num.'&mode='.$mode.'">'; + print img_edit('', 0, 'class="marginrightonly"'); print '  '; $actiontodelete = 'delete'; @@ -685,9 +677,7 @@ if ($action == 'create') if (!empty($conf->global->ACCOUNTANCY_COMBO_FOR_AUX)) { print $formaccounting->select_auxaccount('', 'subledger_account', 1); - } - else - { + } else { print ''; } print ''; @@ -707,9 +697,7 @@ if ($action == 'create') if ($total_debit == $total_credit) { print ''.$langs->trans("ValidTransaction").''; - } - else - { + } else { print ''; } diff --git a/htdocs/accountancy/bookkeeping/list.php b/htdocs/accountancy/bookkeeping/list.php index 545ac855b29..3282f7f363f 100644 --- a/htdocs/accountancy/bookkeeping/list.php +++ b/htdocs/accountancy/bookkeeping/list.php @@ -351,18 +351,14 @@ if ($action == 'delbookkeepingyearconfirm' && $user->rights->accounting->mouveme $result = $object->deleteByYearAndJournal($delyear, $deljournal, '', ($delmonth > 0 ? $delmonth : 0)); if ($result < 0) { setEventMessages($object->error, $object->errors, 'errors'); - } - else - { + } else { setEventMessages("RecordDeleted", null, 'mesgs'); } // Make a redirect to avoid to launch the delete later after a back button header("Location: list.php".($param ? '?'.$param : '')); exit; - } - else - { + } else { setEventMessages("NoRecordDeleted", null, 'warnings'); } } @@ -373,9 +369,7 @@ if ($action == 'delmouvconfirm' && $user->rights->accounting->mouvements->suppri $result = $object->deleteMvtNum($mvt_num); if ($result < 0) { setEventMessages($object->error, $object->errors, 'errors'); - } - else - { + } else { setEventMessages($langs->trans("RecordDeleted"), null, 'mesgs'); } @@ -480,9 +474,7 @@ if ($action == 'export_file' && $user->rights->accounting->mouvements->export) { if ($result < 0) { setEventMessages($object->error, $object->errors, 'errors'); - } - else - { + } else { // Export files $accountancyexport = new AccountancyExport($db); $accountancyexport->export($object->lines, $formatexportset); @@ -490,9 +482,7 @@ if ($action == 'export_file' && $user->rights->accounting->mouvements->export) { if (!empty($accountancyexport->errors)) { setEventMessages('', $accountancyexport->errors, 'errors'); - } - else - { + } else { // Specify as export : update field date_export $error = 0; $db->begin(); @@ -521,9 +511,7 @@ if ($action == 'export_file' && $user->rights->accounting->mouvements->export) { { $db->commit(); // setEventMessages($langs->trans("AllExportedMovementsWereRecordedAsExported"), null, 'mesgs'); - } - else - { + } else { $error++; $db->rollback(); setEventMessages($langs->trans("NotAllExportedMovementsCouldBeRecordedAsExported"), null, 'errors'); @@ -559,9 +547,7 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) if (is_numeric($nbtotalofrecords) && $limit > $nbtotalofrecords) { $num = $nbtotalofrecords; -} -else -{ +} else { $sql .= $db->plimit($limit + 1, $offset); $resql = $db->query($sql); @@ -721,9 +707,7 @@ if (!empty($arrayfields['t.subledger_account']['checked'])) if (!empty($conf->global->ACCOUNTANCY_COMBO_FOR_AUX)) { print $formaccounting->select_auxaccount($search_accountancy_aux_code_start, 'search_accountancy_aux_code_start', 1); - } - else - { + } else { print ''; } print ''; @@ -734,9 +718,7 @@ if (!empty($arrayfields['t.subledger_account']['checked'])) if (!empty($conf->global->ACCOUNTANCY_COMBO_FOR_AUX)) { print $formaccounting->select_auxaccount($search_accountancy_aux_code_end, 'search_accountancy_aux_code_end', 1); - } - else - { + } else { print ''; } print ''; @@ -929,8 +911,7 @@ while ($i < min($num, $limit)) $filedir = $conf->facture->dir_output.'/'.dol_sanitizeFileName($line->doc_ref); $urlsource = $_SERVER['PHP_SELF'].'?id='.$objectstatic->id; $documentlink = $formfile->getDocumentsLink($objectstatic->element, $filename, $filedir); - } - elseif ($line->doc_type == 'supplier_invoice') + } elseif ($line->doc_type == 'supplier_invoice') { $langs->loadLangs(array('bills')); @@ -943,8 +924,7 @@ while ($i < min($num, $limit)) $filedir = $conf->fournisseur->facture->dir_output.'/'.get_exdir($line->fk_doc, 2, 0, 0, $objectstatic, $modulepart).dol_sanitizeFileName($line->doc_ref); $subdir = get_exdir($objectstatic->id, 2, 0, 0, $objectstatic, $modulepart).dol_sanitizeFileName($line->doc_ref); $documentlink = $formfile->getDocumentsLink($objectstatic->element, $subdir, $filedir); - } - elseif ($line->doc_type == 'expense_report') + } elseif ($line->doc_type == 'expense_report') { $langs->loadLangs(array('trips')); @@ -957,9 +937,7 @@ while ($i < min($num, $limit)) $filedir = $conf->expensereport->dir_output.'/'.dol_sanitizeFileName($line->doc_ref); $urlsource = $_SERVER['PHP_SELF'].'?id='.$objectstatic->id; $documentlink = $formfile->getDocumentsLink($objectstatic->element, $filename, $filedir); - } - else - { + } else { // Other type } @@ -1039,7 +1017,7 @@ while ($i < min($num, $limit)) } // Fields from hook - $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$obj); + $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray); $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; diff --git a/htdocs/accountancy/bookkeeping/listbyaccount.php b/htdocs/accountancy/bookkeeping/listbyaccount.php index 78f29e97595..1f4ac513806 100644 --- a/htdocs/accountancy/bookkeeping/listbyaccount.php +++ b/htdocs/accountancy/bookkeeping/listbyaccount.php @@ -57,6 +57,12 @@ $search_direction = GETPOST('search_direction', 'alpha'); $search_ledger_code = GETPOST('search_ledger_code', 'alpha'); $search_debit = GETPOST('search_debit', 'alpha'); $search_credit = GETPOST('search_credit', 'alpha'); +$search_lettering_code = GETPOST('search_lettering_code', 'alpha'); +$search_not_reconciled = GETPOST('search_reconciled_option', 'alpha'); + +if (GETPOST("button_delmvt_x") || GETPOST("button_delmvt.x") || GETPOST("button_delmvt")) { + $action = 'delbookkeepingyear'; +} // Load variable for pagination $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : (empty($conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION) ? $conf->liste_limit : $conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION); @@ -70,6 +76,13 @@ $pagenext = $page + 1; if ($sortorder == "") $sortorder = "ASC"; if ($sortfield == "") $sortfield = "t.doc_date,t.rowid"; +// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context +$object = new BookKeeping($db); +$hookmanager->initHooks(array('bookkeepingbyaccountlist')); + +$formaccounting = new FormAccounting($db); +$form = new Form($db); + if (empty($search_date_start) && empty($search_date_end) && GETPOSTISSET('search_date_startday') && GETPOSTISSET('search_date_startmonth') && GETPOSTISSET('search_date_starthour')) { $sql = "SELECT date_start, date_end from ".MAIN_DB_PREFIX."accounting_fiscalyear "; $sql .= " where date_start < '".$db->idate(dol_now())."' and date_end > '".$db->idate(dol_now())."'"; @@ -96,98 +109,175 @@ if (empty($search_date_start) && empty($search_date_end) && GETPOSTISSET('search } } -$object = new BookKeeping($db); +$arrayfields = array( + // 't.subledger_account'=>array('label'=>$langs->trans("SubledgerAccount"), 'checked'=>1), + 't.code_journal'=>array('label'=>$langs->trans("Codejournal"), 'checked'=>1), + 't.piece_num'=>array('label'=>$langs->trans("TransactionNumShort"), 'checked'=>1), + 't.doc_date'=>array('label'=>$langs->trans("Docdate"), 'checked'=>1), + 't.doc_ref'=>array('label'=>$langs->trans("Piece"), 'checked'=>1), + 't.label_operation'=>array('label'=>$langs->trans("Label"), 'checked'=>1), + 't.debit'=>array('label'=>$langs->trans("Debit"), 'checked'=>1), + 't.credit'=>array('label'=>$langs->trans("Credit"), 'checked'=>1), + 't.lettering_code'=>array('label'=>$langs->trans("LetteringCode"), 'checked'=>1), +); + +if (empty($conf->global->ACCOUNTING_ENABLE_LETTERING)) unset($arrayfields['t.lettering_code']); /* * Action */ -if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // All tests are required to be compatible with all browsers +if (GETPOST('cancel', 'alpha')) { $action = 'list'; $massaction = ''; } +if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction = ''; } + +$parameters = array('socid'=>$socid); +$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks +if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + +if (empty($reshook)) { - $search_doc_date = ''; - $search_accountancy_code = ''; - $search_accountancy_code_start = ''; - $search_accountancy_code_end = ''; - $search_label_account = ''; - $search_doc_ref = ''; - $search_label_operation = ''; - $search_direction = ''; - $search_ledger_code = ''; - $search_date_start = ''; - $search_date_end = ''; - $search_date_startyear = ''; - $search_date_startmonth = ''; - $search_date_startday = ''; - $search_date_endyear = ''; - $search_date_endmonth = ''; - $search_date_endday = ''; - $search_debit = ''; - $search_credit = ''; + include DOL_DOCUMENT_ROOT . '/core/actions_changeselectedfields.inc.php'; + + if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // All tests are required to be compatible with all browsers + { + $search_doc_date = ''; + $search_accountancy_code = ''; + $search_accountancy_code_start = ''; + $search_accountancy_code_end = ''; + $search_label_account = ''; + $search_doc_ref = ''; + $search_label_operation = ''; + $search_direction = ''; + $search_ledger_code = ''; + $search_date_start = ''; + $search_date_end = ''; + $search_date_startyear = ''; + $search_date_startmonth = ''; + $search_date_startday = ''; + $search_date_endyear = ''; + $search_date_endmonth = ''; + $search_date_endday = ''; + $search_debit = ''; + $search_credit = ''; + $search_lettering_code = ''; + $search_not_reconciled = ''; + } + + // Must be after the remove filter action, before the export. + $param = ''; + $filter = array(); + + if (!empty($search_date_start)) { + $filter['t.doc_date>='] = $search_date_start; + $param .= '&search_date_startmonth=' . GETPOST('search_date_startmonth', 'int') . '&search_date_startday=' . GETPOST('search_date_startday', 'int') . '&search_date_startyear=' . GETPOST('search_date_startyear', 'int'); + } + if (!empty($search_date_end)) { + $filter['t.doc_date<='] = $search_date_end; + $param .= '&search_date_endmonth=' . GETPOST('search_date_endmonth', 'int') . '&search_date_endday=' . GETPOST('search_date_endday', 'int') . '&search_date_endyear=' . GETPOST('search_date_endyear', 'int'); + } + if (!empty($search_doc_date)) { + $filter['t.doc_date'] = $search_doc_date; + $param .= '&doc_datemonth=' . GETPOST('doc_datemonth', 'int') . '&doc_dateday=' . GETPOST('doc_dateday', 'int') . '&doc_dateyear=' . GETPOST('doc_dateyear', 'int'); + } + if (!empty($search_accountancy_code_start)) { + $filter['t.numero_compte>='] = $search_accountancy_code_start; + $param .= '&search_accountancy_code_start=' . urlencode($search_accountancy_code_start); + } + if (!empty($search_accountancy_code_end)) { + $filter['t.numero_compte<='] = $search_accountancy_code_end; + $param .= '&search_accountancy_code_end=' . urlencode($search_accountancy_code_end); + } + if (!empty($search_label_account)) { + $filter['t.label_compte'] = $search_label_account; + $param .= '&search_label_compte=' . urlencode($search_label_account); + } + if (!empty($search_doc_ref)) { + $filter['t.doc_ref'] = $search_doc_ref; + $param .= '&search_doc_ref=' . urlencode($search_doc_ref); + } + if (!empty($search_label_operation)) { + $filter['t.label_operation'] = $search_label_operation; + $param .= '&search_label_operation=' . urlencode($search_label_operation); + } + if (!empty($search_direction)) { + $filter['t.sens'] = $search_direction; + $param .= '&search_direction=' . urlencode($search_direction); + } + if (!empty($search_ledger_code)) { + $filter['t.code_journal'] = $search_ledger_code; + $param .= '&search_ledger_code=' . urlencode($search_ledger_code); + } + if (!empty($search_debit)) { + $filter['t.debit'] = $search_debit; + $param .= '&search_debit=' . urlencode($search_debit); + } + if (!empty($search_credit)) { + $filter['t.credit'] = $search_credit; + $param .= '&search_credit=' . urlencode($search_credit); + } + if (!empty($search_lettering_code)) { + $filter['t.lettering_code'] = $search_lettering_code; + $param .= '&search_lettering_code='.urlencode($search_lettering_code); + } + if (!empty($search_not_reconciled)) { + $filter['t.reconciled_option'] = $search_not_reconciled; + $param .= '&search_not_reconciled='.urlencode($search_not_reconciled); + } } -// Must be after the remove filter action, before the export. -$param = ''; -$filter = array(); +if ($action == 'delbookkeeping' && $user->rights->accounting->mouvements->supprimer) { + $import_key = GETPOST('importkey', 'alpha'); -if (!empty($search_date_start)) { - $filter['t.doc_date>='] = $search_date_start; - $param .= '&search_date_startmonth='.GETPOST('search_date_startmonth', 'int').'&search_date_startday='.GETPOST('search_date_startday', 'int').'&search_date_startyear='.GETPOST('search_date_startyear', 'int'); -} -if (!empty($search_date_end)) { - $filter['t.doc_date<='] = $search_date_end; - $param .= '&search_date_endmonth='.GETPOST('search_date_endmonth', 'int').'&search_date_endday='.GETPOST('search_date_endday', 'int').'&search_date_endyear='.GETPOST('search_date_endyear', 'int'); -} -if (!empty($search_doc_date)) { - $filter['t.doc_date'] = $search_doc_date; - $param .= '&doc_datemonth='.GETPOST('doc_datemonth', 'int').'&doc_dateday='.GETPOST('doc_dateday', 'int').'&doc_dateyear='.GETPOST('doc_dateyear', 'int'); -} -if (!empty($search_accountancy_code_start)) { - $filter['t.numero_compte>='] = $search_accountancy_code_start; - $param .= '&search_accountancy_code_start='.urlencode($search_accountancy_code_start); -} -if (!empty($search_accountancy_code_end)) { - $filter['t.numero_compte<='] = $search_accountancy_code_end; - $param .= '&search_accountancy_code_end='.urlencode($search_accountancy_code_end); -} -if (!empty($search_label_account)) { - $filter['t.label_compte'] = $search_label_account; - $param .= '&search_label_compte='.urlencode($search_label_account); -} -if (!empty($search_doc_ref)) { - $filter['t.doc_ref'] = $search_doc_ref; - $param .= '&search_doc_ref='.urlencode($search_doc_ref); -} -if (!empty($search_label_operation)) { - $filter['t.label_operation'] = $search_label_operation; - $param .= '&search_label_operation='.urlencode($search_label_operation); -} -if (!empty($search_direction)) { - $filter['t.sens'] = $search_direction; - $param .= '&search_direction='.urlencode($search_direction); -} -if (!empty($search_ledger_code)) { - $filter['t.code_journal'] = $search_ledger_code; - $param .= '&search_ledger_code='.urlencode($search_ledger_code); -} -if (!empty($search_debit)) { - $filter['t.debit'] = $search_debit; - $param .= '&search_debit='.urlencode($search_debit); -} -if (!empty($search_credit)) { - $filter['t.credit'] = $search_credit; - $param .= '&search_credit='.urlencode($search_credit); -} + if (!empty($import_key)) { + $result = $object->deleteByImportkey($import_key); + if ($result < 0) { + setEventMessages($object->error, $object->errors, 'errors'); + } + // Make a redirect to avoid to launch the delete later after a back button + header("Location: listbyaccount.php".($param ? '?'.$param : '')); + exit; + } +} +if ($action == 'delbookkeepingyearconfirm' && $user->rights->accounting->mouvements->supprimer_tous) { + $delmonth = GETPOST('delmonth', 'int'); + $delyear = GETPOST('delyear', 'int'); + if ($delyear == -1) { + $delyear = 0; + } + $deljournal = GETPOST('deljournal', 'alpha'); + if ($deljournal == -1) { + $deljournal = 0; + } -if ($action == 'delmouvconfirm') { + if (!empty($delmonth) || !empty($delyear) || !empty($deljournal)) + { + $result = $object->deleteByYearAndJournal($delyear, $deljournal, '', ($delmonth > 0 ? $delmonth : 0)); + if ($result < 0) { + setEventMessages($object->error, $object->errors, 'errors'); + } else { + setEventMessages("RecordDeleted", null, 'mesgs'); + } + + // Make a redirect to avoid to launch the delete later after a back button + header("Location: listbyaccount.php".($param ? '?'.$param : '')); + exit; + } else { + setEventMessages("NoRecordDeleted", null, 'warnings'); + } +} +if ($action == 'delmouvconfirm' && $user->rights->accounting->mouvements->supprimer) { $mvt_num = GETPOST('mvt_num', 'int'); if (!empty($mvt_num)) { $result = $object->deleteMvtNum($mvt_num); if ($result < 0) { setEventMessages($object->error, $object->errors, 'errors'); + } else { + setEventMessages($langs->trans("RecordDeleted"), null, 'mesgs'); } - Header("Location: listbyaccount.php"); - exit(); + + header("Location: listbyaccount.php?noreset=1".($param ? '&'.$param : '')); + exit; } } @@ -229,22 +319,42 @@ if ($action == 'delmouv') { } if ($action == 'delbookkeepingyear') { $form_question = array(); - $delyear = GETPOST('delyear'); + $delyear = GETPOST('delyear', 'int'); + $deljournal = GETPOST('deljournal', 'alpha'); if (empty($delyear)) { $delyear = dol_print_date(dol_now(), '%Y'); } + $month_array = array(); + for ($i = 1; $i <= 12; $i++) { + $month_array[$i] = $langs->trans("Month".sprintf("%02d", $i)); + } $year_array = $formaccounting->selectyear_accountancy_bookkepping($delyear, 'delyear', 0, 'array'); + $journal_array = $formaccounting->select_journal($deljournal, 'deljournal', '', 1, 1, 1, '', 0, 1); + $form_question['delmonth'] = array( + 'name' => 'delmonth', + 'type' => 'select', + 'label' => $langs->trans('DelMonth'), + 'values' => $month_array, + 'default' => '' + ); $form_question['delyear'] = array( - 'name' => 'delyear', - 'type' => 'select', - 'label' => $langs->trans('DelYear'), - 'values' => $year_array, - 'default' => $delyear + 'name' => 'delyear', + 'type' => 'select', + 'label' => $langs->trans('DelYear'), + 'values' => $year_array, + 'default' => $delyear + ); + $form_question['deljournal'] = array( + 'name' => 'deljournal', + 'type' => 'other', // We don't use select here, the journal_array is already a select html component + 'label' => $langs->trans('DelJournal'), + 'value' => $journal_array, + 'default' => $deljournal ); - $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"], $langs->trans('DeleteMvt'), $langs->trans('ConfirmDeleteMvt'), 'delbookkeepingyearconfirm', $form_question, 0, 1, 250); + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?'.$param, $langs->trans('DeleteMvt'), $langs->trans('ConfirmDeleteMvt'), 'delbookkeepingyearconfirm', $form_question, '', 1, 300); print $formconfirm; } @@ -267,53 +377,115 @@ if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($l print_barre_liste($title_page, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $result, $nbtotalofrecords, 'title_accountancy', 0, $viewflat.$newcardbutton, '', $limit); +$varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage; +$selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields +if ($massactionbutton) $selectedfields .= $form->showCheckAddButtons('checkforselect', 1); + // Reverse sort order if (preg_match('/^asc/i', $sortorder)) $sortorder = "asc"; else $sortorder = "desc"; -print '
'; -print ''; +$moreforfilter = ''; -print ''; -print ''; -print ''; + +print '
'; +print '
'; -print '
'; -print $langs->trans('From').' '; -print $formaccounting->select_account($search_accountancy_code_start, 'search_accountancy_code_start', 1, array(), 1, 1, 'maxwidth200'); +// Accountancy account +$moreforfilter .= '
'; +$moreforfilter .= $langs->trans('AccountAccounting').': '; +$moreforfilter .= '
'; +$moreforfilter .= $langs->trans('From').' '; +$moreforfilter .= $formaccounting->select_account($search_accountancy_code_start, 'search_accountancy_code_start', 1, array(), 1, 1, 'maxwidth200'); +$moreforfilter .= $langs->trans('to').' '; +$moreforfilter .= $formaccounting->select_account($search_accountancy_code_end, 'search_accountancy_code_end', 1, array(), 1, 1, 'maxwidth200'); +$moreforfilter .= '
'; +$moreforfilter .= '
'; + +$parameters = array(); +$reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook +if (empty($reshook)) $moreforfilter .= $hookmanager->resPrint; +else $moreforfilter = $hookmanager->resPrint; + +print '
'; +print $moreforfilter; print '
'; -print '
'; -print $langs->trans('to').' '; -print $formaccounting->select_account($search_accountancy_code_end, 'search_accountancy_code_end', 1, array(), 1, 1, 'maxwidth200'); -print '
'; -print '
'; + +// Filters lines +print ''; + +// Code journal +if (!empty($arrayfields['t.code_journal']['checked'])) { + print ''; +} +// Date document +if (!empty($arrayfields['t.doc_date']['checked'])) { + print ''; +} +// Movement number +if (!empty($arrayfields['t.piece_num']['checked'])) +{ + print ''; +} +// Ref document +if (!empty($arrayfields['t.doc_ref']['checked'])) { + print ''; +} +// Label operation +if (!empty($arrayfields['t.label_operation']['checked'])) { + print ''; +} +// Debit +if (!empty($arrayfields['t.debit']['checked'])) { + print ''; +} +// Credit +if (!empty($arrayfields['t.credit']['checked'])) { + print ''; +} +// Lettering code +if (!empty($arrayfields['t.lettering_code']['checked'])) +{ + print ''; +} + +// Fields from hook +$parameters = array('arrayfields'=>$arrayfields); +$reshook = $hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook +print $hookmanager->resPrint; + +// Action column print ''; -print ''; -print ''; -print ''; -print ''; -print ''; -print ''; -print ''; +print "\n"; print ''; -print_liste_field_titre("AccountAccountingShort", $_SERVER['PHP_SELF']); -print_liste_field_titre("TransactionNumShort", $_SERVER['PHP_SELF'], "t.piece_num", "", $param, '', $sortfield, $sortorder, 'right '); -print_liste_field_titre("Docdate", $_SERVER['PHP_SELF'], "t.doc_date", "", $param, '', $sortfield, $sortorder, 'center '); -print_liste_field_titre("Piece", $_SERVER['PHP_SELF'], "t.doc_ref", "", $param, "", $sortfield, $sortorder); -print_liste_field_titre("Label"); -print_liste_field_titre("Debit", $_SERVER['PHP_SELF'], "t.debit", "", $param, '', $sortfield, $sortorder, 'right '); -print_liste_field_titre("Credit", $_SERVER['PHP_SELF'], "t.credit", "", $param, '', $sortfield, $sortorder, 'right '); -print_liste_field_titre("Codejournal", $_SERVER['PHP_SELF'], "t.code_journal", "", $param, '', $sortfield, $sortorder, 'center '); -print_liste_field_titre('', $_SERVER["PHP_SELF"], "", $param, "", 'width="60"', $sortfield, $sortorder, 'center '); +if (!empty($arrayfields['t.code_journal']['checked'])) print_liste_field_titre($arrayfields['t.code_journal']['label'], $_SERVER['PHP_SELF'], "t.code_journal", "", $param, '', $sortfield, $sortorder, 'center '); +if (!empty($arrayfields['t.doc_date']['checked'])) print_liste_field_titre($arrayfields['t.doc_date']['label'], $_SERVER['PHP_SELF'], "t.doc_date", "", $param, '', $sortfield, $sortorder, 'center '); +if (!empty($arrayfields['t.piece_num']['checked'])) print_liste_field_titre($arrayfields['t.piece_num']['label'], $_SERVER['PHP_SELF'], "t.piece_num", "", $param, '', $sortfield, $sortorder); +if (!empty($arrayfields['t.doc_ref']['checked'])) print_liste_field_titre($arrayfields['t.doc_ref']['label'], $_SERVER['PHP_SELF'], "t.doc_ref", "", $param, "", $sortfield, $sortorder); +if (!empty($arrayfields['t.label_operation']['checked'])) print_liste_field_titre($arrayfields['t.label_operation']['label'], $_SERVER['PHP_SELF'], "t.label_operation", "", $param, "", $sortfield, $sortorder); +if (!empty($arrayfields['t.debit']['checked'])) print_liste_field_titre($arrayfields['t.debit']['label'], $_SERVER['PHP_SELF'], "t.debit", "", $param, '', $sortfield, $sortorder, 'right '); +if (!empty($arrayfields['t.credit']['checked'])) print_liste_field_titre($arrayfields['t.credit']['label'], $_SERVER['PHP_SELF'], "t.credit", "", $param, '', $sortfield, $sortorder, 'right '); +if (!empty($arrayfields['t.lettering_code']['checked'])) print_liste_field_titre($arrayfields['t.lettering_code']['label'], $_SERVER['PHP_SELF'], "t.lettering_code", "", $param, '', $sortfield, $sortorder, 'center '); +// Hook fields +$parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder); +$reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters); // Note that $action and $object may have been modified by hook +print $hookmanager->resPrint; +print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch '); print "\n"; @@ -323,7 +495,10 @@ $sous_total_debit = 0; $sous_total_credit = 0; $displayed_account_number = null; // Start with undefined to be able to distinguish with empty +// Loop on record +// -------------------------------------------------------------------- $i = 0; +$totalarray = array(); while ($i < min($num, $limit)) { $line = $object->lines[$i]; @@ -336,18 +511,39 @@ while ($i < min($num, $limit)) // Is it a break ? if ($accountg != $displayed_account_number || !isset($displayed_account_number)) { - // Affiche un Sous-Total par compte comptable + $colspan = $totalarray['nbfield'] - 3; + $colspanend = $totalarray['nbfield'] - 7; + // Show a subtotal by accounting account if (isset($displayed_account_number)) { - print ''; - print "\n"; - print "\n"; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + // Show balance of last shown account + $balance = $sous_total_debit - $sous_total_credit; + print ''; + print ''; + if ($balance > 0 ) + { + print ''; + print ''; + } else { + print ''; + print ''; + } + print ''; print ''; } // Show the break account - $colspan = 9; print ""; - print ''; @@ -357,72 +553,206 @@ while ($i < min($num, $limit)) //if (empty($displayed_account_number)) $displayed_account_number='-'; $sous_total_debit = 0; $sous_total_credit = 0; + + $colspan = 0; } print ''; - print ''; - print ''; - print ''; - // TODO Add a link according to doc_type and fk_doc - print ''; + if (!$i) $totalarray['nbfield']++; + } + + // Document date + if (!empty($arrayfields['t.doc_date']['checked'])) + { + print ''; + if (!$i) $totalarray['nbfield']++; + } + + // Piece number + if (!empty($arrayfields['t.piece_num']['checked'])) + { + print ''; + if (!$i) $totalarray['nbfield']++; + } + + // Document ref + if (!empty($arrayfields['t.doc_ref']['checked'])) + { + if ($line->doc_type == 'customer_invoice') + { + $langs->loadLangs(array('bills')); + + require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; + $objectstatic = new Facture($db); + $objectstatic->fetch($line->fk_doc); + //$modulepart = 'facture'; + + $filename = dol_sanitizeFileName($line->doc_ref); + $filedir = $conf->facture->dir_output.'/'.dol_sanitizeFileName($line->doc_ref); + $urlsource = $_SERVER['PHP_SELF'].'?id='.$objectstatic->id; + $documentlink = $formfile->getDocumentsLink($objectstatic->element, $filename, $filedir); + } elseif ($line->doc_type == 'supplier_invoice') + { + $langs->loadLangs(array('bills')); + + require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php'; + $objectstatic = new FactureFournisseur($db); + $objectstatic->fetch($line->fk_doc); + //$modulepart = 'invoice_supplier'; + + $filename = dol_sanitizeFileName($line->doc_ref); + $filedir = $conf->fournisseur->facture->dir_output.'/'.get_exdir($line->fk_doc, 2, 0, 0, $objectstatic, $modulepart).dol_sanitizeFileName($line->doc_ref); + $subdir = get_exdir($objectstatic->id, 2, 0, 0, $objectstatic, $modulepart).dol_sanitizeFileName($line->doc_ref); + $documentlink = $formfile->getDocumentsLink($objectstatic->element, $subdir, $filedir); + } elseif ($line->doc_type == 'expense_report') + { + $langs->loadLangs(array('trips')); + + require_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport.class.php'; + $objectstatic = new ExpenseReport($db); + $objectstatic->fetch($line->fk_doc); + //$modulepart = 'expensereport'; + + $filename = dol_sanitizeFileName($line->doc_ref); + $filedir = $conf->expensereport->dir_output.'/'.dol_sanitizeFileName($line->doc_ref); + $urlsource = $_SERVER['PHP_SELF'].'?id='.$objectstatic->id; + $documentlink = $formfile->getDocumentsLink($objectstatic->element, $filename, $filedir); + } else { + // Other type + } + + print '\n"; + if (!$i) $totalarray['nbfield']++; + } + + // Label operation + if (!empty($arrayfields['t.label_operation']['checked'])) { + // Affiche un lien vers la facture client/fournisseur + $doc_ref = preg_replace('/\(.*\)/', '', $line->doc_ref); + print strlen(length_accounta($line->subledger_account)) == 0 ? '' : ''; + if (!$i) $totalarray['nbfield']++; + } + + // Amount debit + if (!empty($arrayfields['t.debit']['checked'])) + { + print ''; + if (!$i) $totalarray['nbfield']++; + if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 'totaldebit'; + $totalarray['val']['totaldebit'] += $line->debit; + } + + // Amount credit + if (!empty($arrayfields['t.credit']['checked'])) { + print ''; + if (!$i) $totalarray['nbfield']++; + if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 'totalcredit'; + $totalarray['val']['totalcredit'] += $line->credit; + } + + // Lettering code + if (!empty($arrayfields['t.lettering_code']['checked'])) + { + print ''; + if (!$i) $totalarray['nbfield']++; + } + + // Fields from hook + $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$obj); + $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; + + // Action column + print ''; - - // Affiche un lien vers la facture client/fournisseur - $doc_ref = preg_replace('/\(.*\)/', '', $line->doc_ref); - print strlen(length_accounta($line->subledger_account)) == 0 ? '' : ''; - - - print ''; - print ''; - - $accountingjournal = new AccountingJournal($db); - $result = $accountingjournal->fetch('', $line->code_journal); - $journaltoshow = (($result > 0) ? $accountingjournal->getNomUrl(0, 0, 0, '', 0) : $line->code_journal); - print ''; - - print ''; - print "\n"; + if (!$i) $totalarray['nbfield']++; // Comptabilise le sous-total $sous_total_debit += $line->debit; $sous_total_credit += $line->credit; + print "\n"; + $i++; } // Show sub-total of last shown account +$colspan = $totalarray['nbfield'] - 3; +$colspanend = $totalarray['nbfield'] - 8; print ''; -print ''; -print ''; -print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +// Show balance of last shown account +$balance = $sous_total_debit - $sous_total_credit; +print ''; +print ''; +if ($balance > 0 ) +{ + print ''; + print ''; +} else { + print ''; + print ''; +} +print ''; print ''; +// Show total line +include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php'; -// Show total -print ''; -print ''; -print ''; -print ''; -print ''; -print ''; -print ''; print "
'; + print '
'; + print $langs->trans('From') . ': '; + print $form->selectDate($search_date_start, 'search_date_start', 0, 0, 1); + print '
'; + print '
'; + print $langs->trans('to') . ': '; + print $form->selectDate($search_date_end, 'search_date_end', 0, 0, 1); + print '
'; + print '
'; + print ''; + print '
'.$langs->trans("NotReconciled").''; + print '
'; -print $langs->trans('From').': '; -print $form->selectDate($search_date_start, 'search_date_start', 0, 0, 1); -print '
'; -print $langs->trans('to').': '; -print $form->selectDate($search_date_end, 'search_date_end', 0, 0, 1); -print '
'; -$searchpicto = $form->showFilterAndCheckAddButtons(0); +$searchpicto = $form->showFilterButtons(); print $searchpicto; print '
'.$langs->trans("SubTotal").':'.price($sous_total_debit).''.price($sous_total_credit).'  
'.$langs->trans("TotalForAccount").' '.length_accountg($displayed_account_number).':'.price($sous_total_debit).''.price($sous_total_credit).'
'.$langs->trans("Balance").':'; + print price($sous_total_debit - $sous_total_credit); + print ''; + print price($sous_total_credit - $sous_total_debit); + print '
'; + print ''; if ($line->numero_compte != "" && $line->numero_compte != '-1') print length_accountg($line->numero_compte).' : '.$object->get_compte_desc($line->numero_compte); else print ''.$langs->trans("Unknown").''; print '
 '.$line->piece_num.''.dol_print_date($line->doc_date, 'day').''; - //if ($line->doc_type == 'supplier_invoice') - //if ($line->doc_type == 'customer_invoice') - print $line->doc_ref; + // Journal code + if (!empty($arrayfields['t.code_journal']['checked'])) + { + $accountingjournal = new AccountingJournal($db); + $result = $accountingjournal->fetch('', $line->code_journal); + $journaltoshow = (($result > 0) ? $accountingjournal->getNomUrl(0, 0, 0, '', 0) : $line->code_journal); + print ''.$journaltoshow.''.dol_print_date($line->doc_date, 'day').''; + $object->id = $line->id; + $object->piece_num = $line->piece_num; + print $object->getNomUrl(1, '', 0, '', 1); + print ''; + + print ''; + // Picto + Ref + print '
'; + + if ($line->doc_type == 'customer_invoice' || $line->doc_type == 'supplier_invoice' || $line->doc_type == 'expense_report') + { + print $objectstatic->getNomUrl(1, '', 0, 0, '', 0, -1, 1); + print $documentlink; + } else { + print $line->doc_ref; + } + print '
'; + + print "
' . $line->label_operation . '' . $line->label_operation . '
(' . length_accounta($line->subledger_account) . ')
'.($line->debit ? price($line->debit) : '').'' . ($line->credit ? price($line->credit) : '') . ''.$line->lettering_code.''; + if (empty($line->date_export)) { + if ($user->rights->accounting->mouvements->creer) { + print ''.img_edit().''; + } + if ($user->rights->accounting->mouvements->supprimer) { + print ' '.img_delete().''; + } + } print ''.$line->label_operation.''.$line->label_operation.'
('.length_accounta($line->subledger_account).')
'.($line->debit ? price($line->debit) : '').''.($line->credit ? price($line->credit) : '').''.$journaltoshow.''; - print ''.img_edit().' '; - print ''.img_delete().''; - print '
'.$langs->trans("SubTotal").':'.price($sous_total_debit).''.price($sous_total_credit).''; -print price($sous_total_debit - $sous_total_credit); -print ''.$langs->trans("TotalForAccount").' '.$accountg.':'.price($sous_total_debit).''.price($sous_total_credit).'
'.$langs->trans("Balance").':'; + print price($sous_total_debit - $sous_total_credit); + print ''; + print price($sous_total_credit - $sous_total_debit); + print '
'.$langs->trans("Total").':'; -print price($total_debit); -print ''; -print price($total_credit); -print '
"; print '
'; +// TODO Replace this with mass delete action +if ($user->rights->accounting->mouvements->supprimer_tous) { + print '
'."\n"; + print ''.$langs->trans("DeleteMvt").''; + print '
'; +} + print ''; // End of page diff --git a/htdocs/accountancy/class/accountancycategory.class.php b/htdocs/accountancy/class/accountancycategory.class.php index cc93232dcdc..c7f7f8cf68c 100644 --- a/htdocs/accountancy/class/accountancycategory.class.php +++ b/htdocs/accountancy/class/accountancycategory.class.php @@ -209,9 +209,7 @@ class AccountancyCategory // extends CommonObject } $this->db->rollback(); return -1 * $error; - } - else - { + } else { $this->db->commit(); return $this->id; } @@ -241,8 +239,7 @@ class AccountancyCategory // extends CommonObject $sql .= " t.active"; $sql .= " FROM ".MAIN_DB_PREFIX."c_accounting_category as t"; if ($id) $sql .= " WHERE t.rowid = ".$id; - else - { + else { $sql .= " WHERE t.entity IN (".getEntity('c_accounting_category').")"; // Dont't use entity if you use rowid if ($code) $sql .= " AND t.code = '".$this->db->escape($code)."'"; elseif ($label) $sql .= " AND t.label = '".$this->db->escape($label)."'"; @@ -270,9 +267,7 @@ class AccountancyCategory // extends CommonObject $this->db->free($resql); return 1; - } - else - { + } else { $this->error = "Error ".$this->db->lasterror(); return -1; } @@ -335,9 +330,7 @@ class AccountancyCategory // extends CommonObject } $this->db->rollback(); return -1 * $error; - } - else - { + } else { $this->db->commit(); return 1; } @@ -375,9 +368,7 @@ class AccountancyCategory // extends CommonObject } $this->db->rollback(); return -1 * $error; - } - else - { + } else { $this->db->commit(); return 1; } @@ -709,9 +700,7 @@ class AccountancyCategory // extends CommonObject $listofaccount .= "'".$cptcursor."'"; } $sql .= " AND t.numero_compte IN (".$listofaccount.")"; - } - else - { + } else { $sql .= " AND t.numero_compte = '".$this->db->escape($cpt)."'"; } if (!empty($date_start) && !empty($date_end) && (empty($month) || empty($year))) // If month/year provided, it is stronger than filter date_start/date_end @@ -833,9 +822,7 @@ class AccountancyCategory // extends CommonObject $sql .= " WHERE t.fk_accounting_category = ".$cat_id; $sql .= " AND t.entity = ".$conf->entity; $sql .= " ORDER BY t.account_number"; - } - else - { + } else { $sql = "SELECT t.rowid, t.account_number, t.label as account_label"; $sql .= " FROM ".MAIN_DB_PREFIX."accounting_account as t"; $sql .= " WHERE ".$predefinedgroupwhere; diff --git a/htdocs/accountancy/class/accountancyexport.class.php b/htdocs/accountancy/class/accountancyexport.class.php index 1e641564de4..1c76d0408da 100644 --- a/htdocs/accountancy/class/accountancyexport.class.php +++ b/htdocs/accountancy/class/accountancyexport.class.php @@ -5,11 +5,12 @@ * Copyright (C) 2015 Florian Henry * Copyright (C) 2015 Raphaël Doursenaud * Copyright (C) 2016 Pierre-Henry Favre - * Copyright (C) 2016-2019 Alexandre Spangaro + * Copyright (C) 2016-2020 Alexandre Spangaro * Copyright (C) 2013-2017 Olivier Geffroy * Copyright (C) 2017 Elarifr. Ari Elbaz * Copyright (C) 2017-2019 Frédéric France * Copyright (C) 2017 André Schild + * Copyright (C) 2020 Guillaume Alexandre * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -52,6 +53,7 @@ class AccountancyExport public static $EXPORT_TYPE_SAGE50_SWISS = 45; public static $EXPORT_TYPE_CHARLEMAGNE = 50; public static $EXPORT_TYPE_QUADRATUS = 60; + public static $EXPORT_TYPE_WINFIC = 70; public static $EXPORT_TYPE_OPENCONCERTO = 100; public static $EXPORT_TYPE_LDCOMPTA = 110; public static $EXPORT_TYPE_LDCOMPTA10 = 120; @@ -105,6 +107,7 @@ class AccountancyExport self::$EXPORT_TYPE_BOB50 => $langs->trans('Modelcsv_bob50'), self::$EXPORT_TYPE_CIEL => $langs->trans('Modelcsv_ciel'), self::$EXPORT_TYPE_QUADRATUS => $langs->trans('Modelcsv_quadratus'), + self::$EXPORT_TYPE_WINFIC => $langs->trans('Modelcsv_winfic'), self::$EXPORT_TYPE_EBP => $langs->trans('Modelcsv_ebp'), self::$EXPORT_TYPE_COGILOG => $langs->trans('Modelcsv_cogilog'), self::$EXPORT_TYPE_AGIRIS => $langs->trans('Modelcsv_agiris'), @@ -136,6 +139,7 @@ class AccountancyExport self::$EXPORT_TYPE_BOB50 => 'bob50', self::$EXPORT_TYPE_CIEL => 'ciel', self::$EXPORT_TYPE_QUADRATUS => 'quadratus', + self::$EXPORT_TYPE_WINFIC => 'winfic', self::$EXPORT_TYPE_EBP => 'ebp', self::$EXPORT_TYPE_COGILOG => 'cogilog', self::$EXPORT_TYPE_AGIRIS => 'agiris', @@ -184,6 +188,10 @@ class AccountancyExport 'label' => $langs->trans('Modelcsv_quadratus'), 'ACCOUNTING_EXPORT_FORMAT' => 'txt', ), + self::$EXPORT_TYPE_WINFIC => array( + 'label' => $langs->trans('Modelcsv_winfic'), + 'ACCOUNTING_EXPORT_FORMAT' => 'txt', + ), self::$EXPORT_TYPE_EBP => array( 'label' => $langs->trans('Modelcsv_ebp'), ), @@ -246,7 +254,7 @@ class AccountancyExport $filename = 'general_ledger-'.$this->getFormatCode($formatexportset); $type_export = 'general_ledger'; - global $db; // The tpl file use $db + global $db; // The tpl file use $db include DOL_DOCUMENT_ROOT.'/accountancy/tpl/export_journal.tpl.php'; @@ -269,6 +277,9 @@ class AccountancyExport case self::$EXPORT_TYPE_QUADRATUS : $this->exportQuadratus($TData); break; + case self::$EXPORT_TYPE_WINFIC : + $this->exportWinfic($TData); + break; case self::$EXPORT_TYPE_EBP : $this->exportEbp($TData); break; @@ -351,7 +362,7 @@ class AccountancyExport if ($line->sens == 'D') { print price($line->montant).$separator; print ''.$separator; - }elseif ($line->sens == 'C') { + } elseif ($line->sens == 'C') { print ''.$separator; print price($line->montant).$separator; } @@ -507,11 +518,12 @@ class AccountancyExport $Tab['contrepartie'] = str_repeat(' ', 8); // elarifr: date format must be fixed format : 6 char ddmmyy = %d%m%yand not defined by user / dolibarr setting - if (!empty($data->date_echeance)) + if (!empty($data->date_echeance)) { //$Tab['date_echeance'] = dol_print_date($data->date_echeance, $conf->global->ACCOUNTING_EXPORT_DATE); $Tab['date_echeance'] = dol_print_date($data->date_echeance, '%d%m%y'); // elarifr: format must be ddmmyy - else + } else { $Tab['date_echeance'] = '000000'; + } //elarifr please keep quadra named field lettrage(2) + codestat(3) instead of fake lettrage(5) //$Tab['lettrage'] = str_repeat(' ', 5); @@ -548,6 +560,85 @@ class AccountancyExport } } + /** + * Export format : WinFic - eWinfic - WinSis Compta + * + * + * @param array $TData data + * @return void + */ + public function exportWinfic(&$TData) + { + global $conf; + + $end_line = "\r\n"; + + //We should use dol_now function not time however this is wrong date to transfert in accounting + //$date_ecriture = dol_print_date(dol_now(), $conf->global->ACCOUNTING_EXPORT_DATE); // format must be ddmmyy + //$date_ecriture = dol_print_date(time(), $conf->global->ACCOUNTING_EXPORT_DATE); // format must be ddmmyy + foreach ($TData as $data) { + $code_compta = $data->numero_compte; + if (!empty($data->subledger_account)) + $code_compta = $data->subledger_account; + + $Tab = array(); + //$Tab['type_ligne'] = 'M'; + $Tab['code_journal'] = str_pad(self::trunc($data->code_journal, 2), 2); + + //We use invoice date $data->doc_date not $date_ecriture which is the transfert date + //maybe we should set an option for customer who prefer to keep in accounting software the tranfert date instead of invoice date ? + //$Tab['date_ecriture'] = $date_ecriture; + $Tab['date_operation'] = dol_print_date($data->doc_date, '%d%m%Y'); + + $Tab['folio'] = ' 1'; + + $Tab['num_ecriture'] = str_pad(self::trunc($data->piece_num, 6), 6, ' ', STR_PAD_LEFT); + + $Tab['jour_ecriture'] = dol_print_date($data->doc_date, '%d%m%y'); + + $Tab['num_compte'] = str_pad(self::trunc($code_compta, 6), 6, '0'); + + if ($data->sens == 'D') { + $Tab['montant_debit'] = str_pad(number_format(abs($data->montant), 2, ',', ''), 13, ' ', STR_PAD_LEFT); + + $Tab['montant_crebit'] = str_pad(number_format(0, 2, ',', ''), 13, ' ', STR_PAD_LEFT); + } else { + $Tab['montant_debit'] = str_pad(number_format(0, 2, ',', ''), 13, ' ', STR_PAD_LEFT); + + $Tab['montant_crebit'] = str_pad(number_format(abs($data->montant), 2, ',', ''), 13, ' ', STR_PAD_LEFT); + } + + $Tab['libelle_ecriture'] = str_pad(self::trunc(dol_string_unaccent($data->doc_ref).' '.dol_string_unaccent($data->label_operation), 30), 30); + + $Tab['lettrage'] = str_repeat(' ', 2); + + $Tab['code_piece'] = str_repeat(' ', 5); + + $Tab['code_stat'] = str_repeat(' ', 4); + + if (!empty($data->date_echeance)) { + //$Tab['date_echeance'] = dol_print_date($data->date_echeance, $conf->global->ACCOUNTING_EXPORT_DATE); + $Tab['date_echeance'] = dol_print_date($data->date_echeance, '%d%m%Y'); + } else { + $Tab['date_echeance'] = dol_print_date($data->doc_date, '%d%m%Y'); + } + + $Tab['monnaie'] = '1'; + + $Tab['filler'] = ' '; + + $Tab['ind_compteur'] = ' '; + + $Tab['quantite'] = '0,000000000'; + + $Tab['code_pointage'] = str_repeat(' ', 2); + + $Tab['end_line'] = $end_line; + + print implode('|', $Tab); + } + } + /** * Export format : EBP @@ -807,12 +898,10 @@ class AccountancyExport if ($aIndex - 2 >= 0 && $objectLines[$aIndex - 2]->piece_num == $line->piece_num) { $sammelBuchung = true; - } - elseif ($aIndex + 2 < $aSize && $objectLines[$aIndex + 2]->piece_num == $line->piece_num) + } elseif ($aIndex + 2 < $aSize && $objectLines[$aIndex + 2]->piece_num == $line->piece_num) { $sammelBuchung = true; - } - elseif ($aIndex + 1 < $aSize + } elseif ($aIndex + 1 < $aSize && $objectLines[$aIndex + 1]->piece_num == $line->piece_num && $aIndex - 1 < $aSize && $objectLines[$aIndex - 1]->piece_num == $line->piece_num @@ -834,9 +923,7 @@ class AccountancyExport if ($line->sens == 'D') { print 'S'.$this->separator; - } - else - { + } else { print 'H'.$this->separator; } //Grp @@ -847,14 +934,10 @@ class AccountancyExport if ($line->piece_num == $thisPieceNum) { print length_accounta($thisPieceAccountNr).$this->separator; - } - else - { + } else { print "div".$this->separator; } - } - else - { + } else { print length_accounta($line->code_tiers).$this->separator; } //SId @@ -870,9 +953,7 @@ class AccountancyExport if ($sammelBuchung) { print "2".$this->separator; - } - else - { + } else { print "1".$this->separator; } // Code @@ -881,9 +962,7 @@ class AccountancyExport if ($line->montant >= 0) { print $line->montant.$this->separator; - } - else - { + } else { print ($line->montant * -1).$this->separator; } // Steuer @@ -930,7 +1009,7 @@ class AccountancyExport } /** - * Export format : LD Compta version 9 & higher + * Export format : LD Compta version 9 * http://www.ldsysteme.fr/fileadmin/telechargement/np/ldcompta/Documentation/IntCptW9.pdf * * @param array $objectLines data @@ -1368,7 +1447,9 @@ class AccountancyExport print self::trunc($line->code_journal, 6).$separator; //Journal code if (!empty($line->subledger_account)) $account = $line->subledger_account; - else $account = $line->numero_compte; + else { + $account = $line->numero_compte; + } print self::trunc($account, 15).$separator; //Account number print self::trunc($line->label_compte, 60).$separator; //Account label diff --git a/htdocs/accountancy/class/accountingaccount.class.php b/htdocs/accountancy/class/accountingaccount.class.php index a32918cc5bf..6a3fa8e7998 100644 --- a/htdocs/accountancy/class/accountingaccount.class.php +++ b/htdocs/accountancy/class/accountingaccount.class.php @@ -553,24 +553,19 @@ class AccountingAccount extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** - * Account deactivated + * Deactivate an account (for status active or status reconcilable) * * @param int $id Id - * @param int $mode 0=field active, 1=field active_customer_list, 2=field_active_supplier_list + * @param int $mode 0=field active, 1=field reconcilable * @return int <0 if KO, >0 if OK */ - public function account_desactivate($id, $mode = 0) + public function accountDeactivate($id, $mode = 0) { - // phpcs:enable $result = $this->checkUsage(); - if ($mode == 0) - { - $fieldtouse = 'active'; - } - elseif ($mode == 1) + $fieldtouse = 'active'; + if ($mode == 1) { $fieldtouse = 'reconcilable'; } @@ -582,7 +577,7 @@ class AccountingAccount extends CommonObject $sql .= "SET ".$fieldtouse." = '0'"; $sql .= " WHERE rowid = ".$this->db->escape($id); - dol_syslog(get_class($this)."::account_desactivate ".$fieldtouse." sql=".$sql, LOG_DEBUG); + dol_syslog(get_class($this)."::accountDeactivate ".$fieldtouse." sql=".$sql, LOG_DEBUG); $result = $this->db->query($sql); if ($result) { @@ -614,8 +609,7 @@ class AccountingAccount extends CommonObject if ($mode == 0) { $fieldtouse = 'active'; - } - elseif ($mode == 1) + } elseif ($mode == 1) { $fieldtouse = 'reconcilable'; } @@ -666,28 +660,23 @@ class AccountingAccount extends CommonObject { if ($status == 1) return $langs->trans('Enabled'); elseif ($status == 0) return $langs->trans('Disabled'); - } - elseif ($mode == 1) + } elseif ($mode == 1) { if ($status == 1) return $langs->trans('Enabled'); elseif ($status == 0) return $langs->trans('Disabled'); - } - elseif ($mode == 2) + } elseif ($mode == 2) { if ($status == 1) return img_picto($langs->trans('Enabled'), 'statut4').' '.$langs->trans('Enabled'); elseif ($status == 0) return img_picto($langs->trans('Disabled'), 'statut5').' '.$langs->trans('Disabled'); - } - elseif ($mode == 3) + } elseif ($mode == 3) { if ($status == 1) return img_picto($langs->trans('Enabled'), 'statut4'); elseif ($status == 0) return img_picto($langs->trans('Disabled'), 'statut5'); - } - elseif ($mode == 4) + } elseif ($mode == 4) { if ($status == 1) return img_picto($langs->trans('Enabled'), 'statut4').' '.$langs->trans('Enabled'); elseif ($status == 0) return img_picto($langs->trans('Disabled'), 'statut5').' '.$langs->trans('Disabled'); - } - elseif ($mode == 5) + } elseif ($mode == 5) { if ($status == 1) return $langs->trans('Enabled').' '.img_picto($langs->trans('Enabled'), 'statut4'); elseif ($status == 0) return $langs->trans('Disabled').' '.img_picto($langs->trans('Disabled'), 'statut5'); diff --git a/htdocs/accountancy/class/accountingjournal.class.php b/htdocs/accountancy/class/accountingjournal.class.php index 727e68346fa..6067f557cfb 100644 --- a/htdocs/accountancy/class/accountingjournal.class.php +++ b/htdocs/accountancy/class/accountingjournal.class.php @@ -109,8 +109,7 @@ class AccountingJournal extends CommonObject $sql .= " WHERE"; if ($rowid) { $sql .= " rowid = ".(int) $rowid; - } - elseif ($journal_code) + } elseif ($journal_code) { $sql .= " code = '".$this->db->escape($journal_code)."'"; $sql .= " AND entity = ".$conf->entity; @@ -136,9 +135,7 @@ class AccountingJournal extends CommonObject } else { return 0; } - } - else - { + } else { $this->error = "Error ".$this->db->lasterror(); $this->errors[] = "Error ".$this->db->lasterror(); } @@ -311,8 +308,7 @@ class AccountingJournal extends CommonObject elseif ($nature == 3) return $langs->trans('AccountingJournalType3'); elseif ($nature == 2) return $langs->trans('AccountingJournalType2'); elseif ($nature == 1) return $langs->trans('AccountingJournalType1'); - } - elseif ($mode == 1) + } elseif ($mode == 1) { if ($nature == 9) return $langs->trans('AccountingJournalType9'); elseif ($nature == 5) return $langs->trans('AccountingJournalType5'); diff --git a/htdocs/accountancy/class/bookkeeping.class.php b/htdocs/accountancy/class/bookkeeping.class.php index 0162a98394e..713d5175d31 100644 --- a/htdocs/accountancy/class/bookkeeping.class.php +++ b/htdocs/accountancy/class/bookkeeping.class.php @@ -258,9 +258,7 @@ class BookKeeping extends CommonObject if (in_array($this->doc_type, array('bank', 'expense_report'))) { $this->errors[] = $langs->trans('ErrorFieldAccountNotDefinedForBankLine', $this->fk_docdet, $this->doc_type); - } - else - { + } else { //$this->errors[]=$langs->trans('ErrorFieldAccountNotDefinedForInvoiceLine', $this->doc_ref, $this->label_compte); $mesg = $this->doc_ref.', '.$langs->trans("AccountAccounting").': '.$this->numero_compte; if ($this->subledger_account && $this->subledger_account != $this->numero_compte) @@ -477,8 +475,7 @@ class BookKeeping extends CommonObject } $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"'; $linkclose .= ' class="classfortooltip'.($morecss ? ' '.$morecss : '').'"'; - } - else $linkclose = ($morecss ? ' class="'.$morecss.'"' : ''); + } else $linkclose = ($morecss ? ' class="'.$morecss.'"' : ''); $linkstart = ''; diff --git a/htdocs/accountancy/closure/index.php b/htdocs/accountancy/closure/index.php index 39ed325b5fe..ed8fc8ecc7e 100644 --- a/htdocs/accountancy/closure/index.php +++ b/htdocs/accountancy/closure/index.php @@ -42,8 +42,7 @@ if (!$user->rights->accounting->fiscalyear->write) $month_start = ($conf->global->SOCIETE_FISCAL_MONTH_START ? ($conf->global->SOCIETE_FISCAL_MONTH_START) : 1); if (GETPOST("year", 'int')) $year_start = GETPOST("year", 'int'); -else -{ +else { $year_start = dol_print_date(dol_now(), '%Y'); if (dol_print_date(dol_now(), '%m') < $month_start) $year_start--; // If current month is lower that starting fiscal month, we start last year } diff --git a/htdocs/accountancy/closure/validate.php b/htdocs/accountancy/closure/validate.php index fe7fda5054f..808ccfba0ef 100644 --- a/htdocs/accountancy/closure/validate.php +++ b/htdocs/accountancy/closure/validate.php @@ -42,8 +42,7 @@ if ($user->socid > 0) $month_start = ($conf->global->SOCIETE_FISCAL_MONTH_START ? ($conf->global->SOCIETE_FISCAL_MONTH_START) : 1); if (GETPOST("year", 'int')) $year_start = GETPOST("year", 'int'); -else -{ +else { $year_start = dol_print_date(dol_now(), '%Y'); if (dol_print_date(dol_now(), '%m') < $month_start) $year_start--; // If current month is lower that starting fiscal month, we start last year } diff --git a/htdocs/accountancy/customer/card.php b/htdocs/accountancy/customer/card.php index 0a39fbc8254..4d24110f7e6 100644 --- a/htdocs/accountancy/customer/card.php +++ b/htdocs/accountancy/customer/card.php @@ -59,9 +59,7 @@ if ($action == 'ventil' && $user->rights->accounting->bind->write) $resql = $db->query($sql); if (!$resql) { setEventMessages($db->lasterror(), null, 'errors'); - } - else - { + } else { setEventMessages($langs->trans("RecordModifiedSuccessfully"), null, 'mesgs'); if ($backtopage) { diff --git a/htdocs/accountancy/customer/index.php b/htdocs/accountancy/customer/index.php index eff348816fb..425e8aecc81 100644 --- a/htdocs/accountancy/customer/index.php +++ b/htdocs/accountancy/customer/index.php @@ -47,8 +47,7 @@ if (!$user->rights->accounting->bind->write) $month_start = ($conf->global->SOCIETE_FISCAL_MONTH_START ? ($conf->global->SOCIETE_FISCAL_MONTH_START) : 1); if (GETPOST("year", 'int')) $year_start = GETPOST("year", 'int'); -else -{ +else { $year_start = dol_print_date(dol_now(), '%Y'); if (dol_print_date(dol_now(), '%m') < $month_start) $year_start--; // If current month is lower that starting fiscal month, we start last year } @@ -202,8 +201,7 @@ if ($action == 'validatehistory') { if ($error) { $db->rollback(); - } - else { + } else { $db->commit(); setEventMessages($langs->trans('AutomaticBindingDone'), null, 'mesgs'); } @@ -278,15 +276,13 @@ if ($resql) { if ($row[0] == 'tobind') { print $langs->trans("Unknown"); - } - else print length_accountg($row[0]); + } else print length_accountg($row[0]); print ''; print ''; if ($row[0] == 'tobind') { print $langs->trans("UseMenuToSetBindindManualy", DOL_URL_ROOT.'/accountancy/customer/list.php?search_year='.$y, $langs->transnoentitiesnoconv("ToBind")); - } - else print $row[1]; + } else print $row[1]; print ''; for ($i = 2; $i <= 12; $i++) { print ''.price($row[$i]).''; @@ -353,16 +349,14 @@ if ($resql) { if ($row[0] == 'tobind') { print $langs->trans("Unknown"); - } - else print length_accountg($row[0]); + } else print length_accountg($row[0]); print ''; print ''; if ($row[0] == 'tobind') { print $langs->trans("UseMenuToSetBindindManualy", DOL_URL_ROOT.'/accountancy/customer/list.php?search_year='.$y, $langs->transnoentitiesnoconv("ToBind")); - } - else print $row[1]; + } else print $row[1]; print ''; for ($i = 2; $i <= 12; $i++) { diff --git a/htdocs/accountancy/customer/lines.php b/htdocs/accountancy/customer/lines.php index 45b0c909016..af98dc14653 100644 --- a/htdocs/accountancy/customer/lines.php +++ b/htdocs/accountancy/customer/lines.php @@ -31,6 +31,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; +require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingaccount.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; @@ -342,37 +343,41 @@ if ($result) { print_liste_field_titre("ThirdParty", $_SERVER["PHP_SELF"], "s.nom", "", $param, '', $sortfield, $sortorder); print_liste_field_titre("Country", $_SERVER["PHP_SELF"], "co.label", "", $param, '', $sortfield, $sortorder); print_liste_field_titre("VATIntra", $_SERVER["PHP_SELF"], "s.tva_intra", "", $param, '', $sortfield, $sortorder); - print_liste_field_titre("Account", $_SERVER["PHP_SELF"], "aa.account_number", "", $param, '', $sortfield, $sortorder); + print_liste_field_titre("AccountAccounting", $_SERVER["PHP_SELF"], "aa.account_number", "", $param, '', $sortfield, $sortorder); $clickpicto = $form->showCheckAddButtons(); print_liste_field_titre($clickpicto, '', '', '', '', '', '', '', 'center '); print "\n"; - $thirdpartystatic=new Societe($db); - $facture_static = new Facture($db); - $product_static = new Product($db); + $thirdpartystatic=new Societe($db); + $facturestatic = new Facture($db); + $productstatic = new Product($db); + $accountingaccountstatic = new AccountingAccount($db); - while ($objp = $db->fetch_object($result)) { - $codecompta = length_accountg($objp->account_number).' - '.$objp->label_compte.''; + while ($objp = $db->fetch_object($result)) + { + $accountingaccountstatic->account_number = $objp->account_number; + $accountingaccountstatic->label = $objp->label_account; + $accountingaccountstatic->labelshort = $objp->labelshort_account; - $facture_static->ref = $objp->ref; - $facture_static->id = $objp->facid; - $facture_static->type = $objp->ftype; + $facturestatic->ref = $objp->ref; + $facturestatic->id = $objp->facid; + $facturestatic->type = $objp->ftype; - $thirdpartystatic->id = $objp->socid; - $thirdpartystatic->name = $objp->name; - $thirdpartystatic->client = $objp->client; - $thirdpartystatic->fournisseur = $objp->fournisseur; - $thirdpartystatic->code_client = $objp->code_client; - $thirdpartystatic->code_compta_client = $objp->code_compta_client; - $thirdpartystatic->code_fournisseur = $objp->code_fournisseur; - $thirdpartystatic->code_compta_fournisseur = $objp->code_compta_fournisseur; - $thirdpartystatic->email = $objp->email; - $thirdpartystatic->country_code = $objp->country_code; + $thirdpartystatic->id = $objp->socid; + $thirdpartystatic->name = $objp->name; + $thirdpartystatic->client = $objp->client; + $thirdpartystatic->fournisseur = $objp->fournisseur; + $thirdpartystatic->code_client = $objp->code_client; + $thirdpartystatic->code_compta_client = $objp->code_compta_client; + $thirdpartystatic->code_fournisseur = $objp->code_fournisseur; + $thirdpartystatic->code_compta_fournisseur = $objp->code_compta_fournisseur; + $thirdpartystatic->email = $objp->email; + $thirdpartystatic->country_code = $objp->country_code; - $product_static->ref = $objp->product_ref; - $product_static->id = $objp->product_id; - $product_static->label = $objp->product_label; - $product_static->type = $objp->line_type; + $productstatic->ref = $objp->product_ref; + $productstatic->id = $objp->product_id; + $productstatic->label = $objp->product_label; + $productstatic->type = $objp->line_type; print ''; @@ -380,15 +385,15 @@ if ($result) { print ''.$objp->rowid.''; // Ref Invoice - print ''.$facture_static->getNomUrl(1).''; + print ''.$facturestatic->getNomUrl(1).''; // Date invoice print ''.dol_print_date($db->jdate($objp->datef), 'day').''; // Ref Product print ''; - if ($product_static->id > 0) print $product_static->getNomUrl(1); - if ($product_static->id > 0 && $objp->product_label) print '
'; + if ($productstatic->id > 0) print $productstatic->getNomUrl(1); + if ($productstatic->id > 0 && $objp->product_label) print '
'; if ($objp->product_label) print ''.$objp->product_label.''; print ''; @@ -415,8 +420,9 @@ if ($result) { print ''.$objp->tva_intra.''; - print ''; - print $codecompta.'
'; + print ''; + print $accountingaccountstatic->getNomUrl(0, 1, 1, '', 1); + print ' '; print img_edit(); print ''; print ''; diff --git a/htdocs/accountancy/customer/list.php b/htdocs/accountancy/customer/list.php index 1d93a0fea17..bf28da1d5d2 100644 --- a/htdocs/accountancy/customer/list.php +++ b/htdocs/accountancy/customer/list.php @@ -159,9 +159,7 @@ if ($massaction == 'ventil') { { $msg .= '
'.$langs->trans("Lineofinvoice").' '.$monId.' - '.$langs->trans("NoAccountSelected").'
'; $ko++; - } - else - { + } else { $sql = " UPDATE ".MAIN_DB_PREFIX."facturedet"; $sql .= " SET fk_code_ventilation = ".$monCompte; $sql .= " WHERE rowid = ".$monId; @@ -629,8 +627,7 @@ if ($result) { $suggestedid = $tmpaccount->id; } $accountingaccount_codetotid_cache[$objp->code_sell_l] = $tmpaccount->id; - } - else { + } else { $suggestedid = $accountingaccount_codetotid_cache[$objp->code_sell_l]; } } diff --git a/htdocs/accountancy/expensereport/card.php b/htdocs/accountancy/expensereport/card.php index 36d587e0c99..8b04ca74c81 100644 --- a/htdocs/accountancy/expensereport/card.php +++ b/htdocs/accountancy/expensereport/card.php @@ -63,9 +63,7 @@ if ($action == 'ventil' && $user->rights->accounting->bind->write) $resql = $db->query($sql); if (!$resql) { setEventMessages($db->lasterror(), null, 'errors'); - } - else - { + } else { setEventMessages($langs->trans("RecordModifiedSuccessfully"), null, 'mesgs'); if ($backtopage) { diff --git a/htdocs/accountancy/expensereport/index.php b/htdocs/accountancy/expensereport/index.php index 387cfd0fb8e..9fe07b18a37 100644 --- a/htdocs/accountancy/expensereport/index.php +++ b/htdocs/accountancy/expensereport/index.php @@ -43,8 +43,7 @@ if (!$user->rights->accounting->bind->write) $month_start = ($conf->global->SOCIETE_FISCAL_MONTH_START ? ($conf->global->SOCIETE_FISCAL_MONTH_START) : 1); if (GETPOST("year", 'int')) $year_start = GETPOST("year", 'int'); -else -{ +else { $year_start = dol_print_date(dol_now(), '%Y'); if (dol_print_date(dol_now(), '%m') < $month_start) $year_start--; // If current month is lower that starting fiscal month, we start last year } @@ -190,15 +189,13 @@ if ($resql) { if ($row[0] == 'tobind') { print $langs->trans("Unknown"); - } - else print length_accountg($row[0]); + } else print length_accountg($row[0]); print ''; print ''; if ($row[0] == 'tobind') { print $langs->trans("UseMenuToSetBindindManualy", DOL_URL_ROOT.'/accountancy/expensereport/list.php?search_year='.$y, $langs->transnoentitiesnoconv("ToBind")); - } - else print $row[1]; + } else print $row[1]; print ''; for ($i = 2; $i <= 12; $i++) { print ''.price($row[$i]).''; @@ -261,16 +258,14 @@ if ($resql) { if ($row[0] == 'tobind') { print $langs->trans("Unknown"); - } - else print length_accountg($row[0]); + } else print length_accountg($row[0]); print ''; print ''; if ($row[0] == 'tobind') { print $langs->trans("UseMenuToSetBindindManualy", DOL_URL_ROOT.'/accountancy/expensereport/list.php?search_year='.$y, $langs->transnoentitiesnoconv("ToBind")); - } - else print $row[1]; + } else print $row[1]; print ''; for ($i = 2; $i <= 12; $i++) { print ''.price($row[$i]).''; diff --git a/htdocs/accountancy/expensereport/lines.php b/htdocs/accountancy/expensereport/lines.php index 4cd51fb3a63..7ffbb9518f8 100644 --- a/htdocs/accountancy/expensereport/lines.php +++ b/htdocs/accountancy/expensereport/lines.php @@ -28,19 +28,22 @@ require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php'; require_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport.class.php'; +require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingaccount.class.php'; +require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; // Load translation files required by the page -$langs->loadLangs(array("compta", "bills", "other", "accountancy", "trips", "productbatch")); +$langs->loadLangs(array("compta", "bills", "other", "accountancy", "trips", "productbatch", "hrm")); $optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print') $account_parent = GETPOST('account_parent', 'int'); $changeaccount = GETPOST('changeaccount'); // Search Getpost +$search_login = GETPOST('search_login', 'alpha'); $search_expensereport = GETPOST('search_expensereport', 'alpha'); $search_label = GETPOST('search_label', 'alpha'); $search_desc = GETPOST('search_desc', 'alpha'); @@ -84,7 +87,8 @@ $formaccounting = new FormAccounting($db); // Purge search criteria if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // Both test are required to be compatible with all browsers { - $search_expensereport = ''; + $search_login = ''; + $search_expensereport = ''; $search_label = ''; $search_desc = ''; $search_amount = ''; @@ -162,14 +166,21 @@ print ''."\n"; } - if (is_object($objsoc) && $objsoc->id > 0) - { + if (is_object($objsoc) && $objsoc->id > 0) { $this->tpl['company'] = $objsoc->getNomUrl(1); $this->tpl['company_id'] = $objsoc->id; - } - else - { + } else { $this->tpl['company'] = $form->select_company($this->object->socid, 'socid', '', 1); } @@ -128,8 +122,7 @@ abstract class ActionsAdherentCardCommon $this->tpl['select_civility'] = $formcompany->select_civility($this->object->civility_id); // Predefined with third party - if ((isset($objsoc->typent_code) && $objsoc->typent_code == 'TE_PRIVATE')) - { + if ((isset($objsoc->typent_code) && $objsoc->typent_code == 'TE_PRIVATE')) { if (dol_strlen(trim($this->object->address)) == 0) $this->tpl['address'] = $objsoc->address; if (dol_strlen(trim($this->object->zip)) == 0) $this->object->zip = $objsoc->zip; if (dol_strlen(trim($this->object->town)) == 0) $this->object->town = $objsoc->town; @@ -161,38 +154,30 @@ abstract class ActionsAdherentCardCommon $this->tpl['select_morphy'] = $form->selectarray('morphy', $selectarray, $this->object->morphy, 0); } - if ($action == 'view' || $action == 'edit' || $action == 'delete') - { + if ($action == 'view' || $action == 'edit' || $action == 'delete') { // Emailing - if (!empty($conf->mailing->enabled)) - { + if (!empty($conf->mailing->enabled)) { $langs->load("mails"); $this->tpl['nb_emailing'] = $this->object->getNbOfEMailings(); } // Dolibarr user - if ($this->object->user_id) - { + if ($this->object->user_id) { $dolibarr_user = new User($this->db); $result = $dolibarr_user->fetch($this->object->user_id); $this->tpl['dolibarr_user'] = $dolibarr_user->getLoginUrl(1); - } - else $this->tpl['dolibarr_user'] = $langs->trans("NoDolibarrAccess"); + } else $this->tpl['dolibarr_user'] = $langs->trans("NoDolibarrAccess"); } - if ($action == 'view' || $action == 'delete') - { + if ($action == 'view' || $action == 'delete') { $this->tpl['showrefnav'] = $form->showrefnav($this->object, 'id'); - if ($this->object->socid > 0) - { + if ($this->object->socid > 0) { $objsoc = new Societe($this->db); $objsoc->fetch($this->object->socid); $this->tpl['company'] = $objsoc->getNomUrl(1); - } - else - { + } else { $this->tpl['company'] = $langs->trans("AdherentNotLinkedToThirdParty"); } @@ -214,8 +199,7 @@ abstract class ActionsAdherentCardCommon $this->tpl['note'] = nl2br($this->object->note); } - if ($action == 'create_user') - { + if ($action == 'create_user') { // Full firstname and lastname separated with a dot : firstname.lastname include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php'; @@ -263,19 +247,15 @@ abstract class ActionsAdherentCardCommon $this->object->canvas = $_POST["canvas"]; // We set country_id, and country_code label of the chosen country - if ($this->object->country_id) - { + if ($this->object->country_id) { $sql = "SELECT code, label FROM ".MAIN_DB_PREFIX."c_country WHERE rowid = ".$this->object->country_id; $resql = $this->db->query($sql); - if ($resql) - { + if ($resql) { $obj = $this->db->fetch_object($resql); $this->object->country_code = $obj->code; $this->object->country = $langs->trans("Country".$obj->code) ? $langs->trans("Country".$obj->code) : $obj->libelle; - } - else - { + } else { dol_print_error($this->db); } } diff --git a/htdocs/adherents/canvas/default/actions_adherentcard_default.class.php b/htdocs/adherents/canvas/default/actions_adherentcard_default.class.php index 60bb2ecd034..db2473c55d9 100644 --- a/htdocs/adherents/canvas/default/actions_adherentcard_default.class.php +++ b/htdocs/adherents/canvas/default/actions_adherentcard_default.class.php @@ -90,8 +90,7 @@ class ActionsAdherentCardDefault extends ActionsAdherentCardCommon $this->tpl['error'] = $this->error; $this->tpl['errors'] = $this->errors; - if ($action == 'view') - { + if ($action == 'view') { // Card header $head = member_prepare_head($this->object); $title = $this->getTitle($action); @@ -105,18 +104,14 @@ class ActionsAdherentCardDefault extends ActionsAdherentCardCommon $this->tpl['actionstodo'] = show_actions_todo($conf, $langs, $db, $objsoc, $this->object, 1); $this->tpl['actionsdone'] = show_actions_done($conf, $langs, $db, $objsoc, $this->object, 1); - } - else - { + } else { // Confirm delete contact - if ($action == 'delete' && $user->rights->adherent->supprimer) - { + if ($action == 'delete' && $user->rights->adherent->supprimer) { $this->tpl['action_delete'] = $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$this->object->id, $langs->trans("DeleteAdherent"), $langs->trans("ConfirmDeleteAdherent"), "confirm_delete", '', 0, 1); } } - if ($action == 'list') - { + if ($action == 'list') { $this->LoadListDatas($limit, $offset, $sortfield, $sortorder); } } diff --git a/htdocs/adherents/canvas/default/tpl/adherentcard_create.tpl.php b/htdocs/adherents/canvas/default/tpl/adherentcard_create.tpl.php index 92f1e11d7a2..b6c0b542d27 100644 --- a/htdocs/adherents/canvas/default/tpl/adherentcard_create.tpl.php +++ b/htdocs/adherents/canvas/default/tpl/adherentcard_create.tpl.php @@ -17,8 +17,7 @@ */ // Protection to avoid direct call of template -if (empty($conf) || !is_object($conf)) -{ +if (empty($conf) || !is_object($conf)) { print "Error, template page can't be called as URL"; exit; } diff --git a/htdocs/adherents/canvas/default/tpl/adherentcard_edit.tpl.php b/htdocs/adherents/canvas/default/tpl/adherentcard_edit.tpl.php index 36e2deab14c..92a4fbddd38 100644 --- a/htdocs/adherents/canvas/default/tpl/adherentcard_edit.tpl.php +++ b/htdocs/adherents/canvas/default/tpl/adherentcard_edit.tpl.php @@ -17,8 +17,7 @@ */ // Protection to avoid direct call of template -if (empty($conf) || !is_object($conf)) -{ +if (empty($conf) || !is_object($conf)) { print "Error, template page can't be called as URL"; exit; } diff --git a/htdocs/adherents/canvas/default/tpl/adherentcard_view.tpl.php b/htdocs/adherents/canvas/default/tpl/adherentcard_view.tpl.php index b738f549247..8789b2fcb34 100644 --- a/htdocs/adherents/canvas/default/tpl/adherentcard_view.tpl.php +++ b/htdocs/adherents/canvas/default/tpl/adherentcard_view.tpl.php @@ -17,8 +17,7 @@ */ // Protection to avoid direct call of template -if (empty($conf) || !is_object($conf)) -{ +if (empty($conf) || !is_object($conf)) { print "Error, template page can't be called as URL"; exit; } diff --git a/htdocs/adherents/card.php b/htdocs/adherents/card.php index c913d6a1b49..727a99e060c 100644 --- a/htdocs/adherents/card.php +++ b/htdocs/adherents/card.php @@ -55,8 +55,7 @@ $typeid = GETPOST('typeid', 'int'); $userid = GETPOST('userid', 'int'); $socid = GETPOST('socid', 'int'); -if (!empty($conf->mailmanspip->enabled)) -{ +if (!empty($conf->mailmanspip->enabled)) { include_once DOL_DOCUMENT_ROOT.'/mailmanspip/class/mailmanspip.class.php'; $langs->load('mailmanspip'); @@ -76,8 +75,7 @@ $socialnetworks = getArrayOfSocialNetworks(); $object->getCanvas($id); $canvas = $object->canvas ? $object->canvas : GETPOST("canvas"); $objcanvas = null; -if (!empty($canvas)) -{ +if (!empty($canvas)) { require_once DOL_DOCUMENT_ROOT.'/core/class/canvas.class.php'; $objcanvas = new Canvas($db, $action); $objcanvas->getCanvas('adherent', 'membercard', $canvas); @@ -86,16 +84,14 @@ if (!empty($canvas)) // Security check $result = restrictedArea($user, 'adherent', $id, '', '', 'socid', 'rowid', $objcanvas); -if ($id > 0) -{ +if ($id > 0) { // Load member $result = $object->fetch($id); // Define variables to know what current user can do on users $canadduser = ($user->admin || $user->rights->user->user->creer); // Define variables to know what current user can do on properties of user linked to edited member - if ($object->user_id) - { + if ($object->user_id) { // $User is the user who edits, $object->user_id is the id of the related user in the edited member $caneditfielduser = ((($user->id == $object->user_id) && $user->rights->user->self->creer) || (($user->id != $object->user_id) && $user->rights->user->user->creer)); @@ -107,8 +103,7 @@ if ($id > 0) // Define variables to determine what the current user can do on the members $canaddmember = $user->rights->adherent->creer; // Define variables to determine what the current user can do on the properties of a member -if ($id) -{ +if ($id) { $caneditfieldmember = $user->rights->adherent->creer; } @@ -125,34 +120,26 @@ $parameters = array('id'=>$id, 'rowid'=>$id, 'objcanvas'=>$objcanvas, 'confirm'= $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); -if (empty($reshook)) -{ - if ($cancel) - { - if (!empty($backtopage)) - { +if (empty($reshook)) { + if ($cancel) { + if (!empty($backtopage)) { header("Location: ".$backtopage); exit; } $action = ''; } - if ($action == 'setuserid' && ($user->rights->user->self->creer || $user->rights->user->user->creer)) - { + if ($action == 'setuserid' && ($user->rights->user->self->creer || $user->rights->user->user->creer)) { $error = 0; - if (empty($user->rights->user->user->creer)) // If can edit only itself user, we can link to itself only - { - if ($userid != $user->id && $userid != $object->user_id) - { + if (empty($user->rights->user->user->creer)) { // If can edit only itself user, we can link to itself only + if ($userid != $user->id && $userid != $object->user_id) { $error++; setEventMessages($langs->trans("ErrorUserPermissionAllowsToLinksToItselfOnly"), null, 'errors'); } } - if (!$error) - { - if ($userid != $object->user_id) // If link differs from currently in database - { + if (!$error) { + if ($userid != $object->user_id) { // If link differs from currently in database $result = $object->setUserId($userid); if ($result < 0) dol_print_error($object->db, $object->error); $action = ''; @@ -160,22 +147,17 @@ if (empty($reshook)) } } - if ($action == 'setsocid') - { + if ($action == 'setsocid') { $error = 0; - if (!$error) - { - if ($socid != $object->socid) // If link differs from currently in database - { + if (!$error) { + if ($socid != $object->socid) { // If link differs from currently in database $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."adherent"; $sql .= " WHERE socid = '".$socid."'"; $sql .= " AND entity = ".$conf->entity; $resql = $db->query($sql); - if ($resql) - { + if ($resql) { $obj = $db->fetch_object($resql); - if ($obj && $obj->rowid > 0) - { + if ($obj && $obj->rowid > 0) { $othermember = new Adherent($db); $othermember->fetch($obj->rowid); $thirdparty = new Societe($db); @@ -185,8 +167,7 @@ if (empty($reshook)) } } - if (!$error) - { + if (!$error) { $result = $object->setThirdPartyId($socid); if ($result < 0) dol_print_error($object->db, $object->error); $action = ''; @@ -196,57 +177,45 @@ if (empty($reshook)) } // Create user from a member - if ($action == 'confirm_create_user' && $confirm == 'yes' && $user->rights->user->user->creer) - { - if ($result > 0) - { + if ($action == 'confirm_create_user' && $confirm == 'yes' && $user->rights->user->user->creer) { + if ($result > 0) { // Creation user $nuser = new User($db); $result = $nuser->create_from_member($object, GETPOST('login', 'alphanohtml')); - if ($result < 0) - { + if ($result < 0) { $langs->load("errors"); setEventMessages($langs->trans($nuser->error), null, 'errors'); } - } - else - { + } else { setEventMessages($object->error, $object->errors, 'errors'); } } // Create third party from a member - if ($action == 'confirm_create_thirdparty' && $confirm == 'yes' && $user->rights->societe->creer) - { - if ($result > 0) - { + if ($action == 'confirm_create_thirdparty' && $confirm == 'yes' && $user->rights->societe->creer) { + if ($result > 0) { // User creation $company = new Societe($db); $result = $company->create_from_member($object, GETPOST('companyname', 'alpha'), GETPOST('companyalias', 'alpha')); - if ($result < 0) - { + if ($result < 0) { $langs->load("errors"); setEventMessages($langs->trans($company->error), null, 'errors'); setEventMessages($company->error, $company->errors, 'errors'); } - } - else - { + } else { setEventMessages($object->error, $object->errors, 'errors'); } } - if ($action == 'update' && !$cancel && $user->rights->adherent->creer) - { + if ($action == 'update' && !$cancel && $user->rights->adherent->creer) { require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; $birthdate = ''; if (isset($_POST["birthday"]) && $_POST["birthday"] && isset($_POST["birthmonth"]) && $_POST["birthmonth"] - && isset($_POST["birthyear"]) && $_POST["birthyear"]) - { + && isset($_POST["birthyear"]) && $_POST["birthyear"]) { $birthdate = dol_mktime(12, 0, 0, $_POST["birthmonth"], $_POST["birthday"], $_POST["birthyear"]); } $lastname = $_POST["lastname"]; @@ -271,16 +240,14 @@ if (empty($reshook)) setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Company")), null, 'errors'); } // Check if the login already exists - if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED)) - { + if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED)) { if (empty($login)) { $error++; setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Login")), null, 'errors'); } } // Create new object - if ($result > 0 && !$error) - { + if ($result > 0 && !$error) { $object->oldcopy = clone $object; // Change values @@ -333,32 +300,27 @@ if (empty($reshook)) // Check if we need to also synchronize user information $nosyncuser = 0; - if ($object->user_id) // If linked to a user - { + if ($object->user_id) { // If linked to a user if ($user->id != $object->user_id && empty($user->rights->user->user->creer)) $nosyncuser = 1; // Disable synchronizing } // Check if we need to also synchronize password information $nosyncuserpass = 0; - if ($object->user_id) // If linked to a user - { + if ($object->user_id) { // If linked to a user if ($user->id != $object->user_id && empty($user->rights->user->user->password)) $nosyncuserpass = 1; // Disable synchronizing } $result = $object->update($user, 0, $nosyncuser, $nosyncuserpass); - if ($result >= 0 && !count($object->errors)) - { + if ($result >= 0 && !count($object->errors)) { $categories = GETPOST('memcats', 'array'); $object->setCategories($categories); // Logo/Photo save $dir = $conf->adherent->dir_output.'/'.get_exdir(0, 0, 0, 1, $object, 'member').'/photos'; $file_OK = is_uploaded_file($_FILES['photo']['tmp_name']); - if ($file_OK) - { - if (GETPOST('deletephoto')) - { + if ($file_OK) { + if (GETPOST('deletephoto')) { require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; $fileimg = $conf->adherent->dir_output.'/'.get_exdir(0, 0, 0, 1, $object, 'member').'/photos/'.$object->photo; $dirthumbs = $conf->adherent->dir_output.'/'.get_exdir(0, 0, 0, 1, $object, 'member').'/photos/thumbs'; @@ -366,33 +328,23 @@ if (empty($reshook)) dol_delete_dir_recursive($dirthumbs); } - if (image_format_supported($_FILES['photo']['name']) > 0) - { + if (image_format_supported($_FILES['photo']['name']) > 0) { dol_mkdir($dir); - if (@is_dir($dir)) - { + if (@is_dir($dir)) { $newfile = $dir.'/'.dol_sanitizeFileName($_FILES['photo']['name']); - if (!dol_move_uploaded_file($_FILES['photo']['tmp_name'], $newfile, 1, 0, $_FILES['photo']['error']) > 0) - { + if (!dol_move_uploaded_file($_FILES['photo']['tmp_name'], $newfile, 1, 0, $_FILES['photo']['error']) > 0) { setEventMessages($langs->trans("ErrorFailedToSaveFile"), null, 'errors'); - } - else - { + } else { // Create thumbs $object->addThumbs($newfile); } } - } - else - { + } else { setEventMessages("ErrorBadImageFormat", null, 'errors'); } - } - else - { - switch ($_FILES['photo']['error']) - { + } else { + switch ($_FILES['photo']['error']) { case 1: //uploaded file exceeds the upload_max_filesize directive in php.ini case 2: //uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the html form $errors[] = "ErrorFileSizeTooLarge"; @@ -407,37 +359,29 @@ if (empty($reshook)) $id = $object->id; $action = ''; - if (!empty($backtopage)) - { + if (!empty($backtopage)) { header("Location: ".$backtopage); exit; } - } - else - { + } else { setEventMessages($object->error, $object->errors, 'errors'); $action = ''; } - } - else - { + } else { $action = 'edit'; } } - if ($action == 'add' && $user->rights->adherent->creer) - { + if ($action == 'add' && $user->rights->adherent->creer) { if ($canvas) $object->canvas = $canvas; $birthdate = ''; if (isset($_POST["birthday"]) && $_POST["birthday"] && isset($_POST["birthmonth"]) && $_POST["birthmonth"] - && isset($_POST["birthyear"]) && $_POST["birthyear"]) - { + && isset($_POST["birthyear"]) && $_POST["birthyear"]) { $birthdate = dol_mktime(12, 0, 0, $_POST["birthmonth"], $_POST["birthday"], $_POST["birthyear"]); } $datesubscription = ''; - if (isset($_POST["reday"]) && isset($_POST["remonth"]) && isset($_POST["reyear"])) - { + if (isset($_POST["reday"]) && isset($_POST["remonth"]) && isset($_POST["reyear"])) { $datesubscription = dol_mktime(12, 0, 0, $_POST["remonth"], $_POST["reday"], $_POST["reyear"]); } @@ -522,13 +466,11 @@ if (empty($reshook)) setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("MemberNature")), null, 'errors'); } // Tests if the login already exists - if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED)) - { + if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED)) { if (empty($login)) { $error++; setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Login")), null, 'errors'); - } - else { + } else { $sql = "SELECT login FROM ".MAIN_DB_PREFIX."adherent WHERE login='".$db->escape($login)."'"; $result = $db->query($sql); if ($result) { @@ -572,14 +514,12 @@ if (empty($reshook)) $public = 0; if (isset($public)) $public = 1; - if (!$error) - { + if (!$error) { $db->begin(); // Email about right and login does not exist $result = $object->create($user); - if ($result > 0) - { + if ($result > 0) { // Foundation categories $memcats = GETPOST('memcats', 'array'); $object->setCategories($memcats); @@ -588,9 +528,7 @@ if (empty($reshook)) $rowid = $object->id; $id = $object->id; $action = ''; - } - else - { + } else { $db->rollback(); if ($object->error) { @@ -601,36 +539,27 @@ if (empty($reshook)) $action = 'create'; } - } - else { + } else { $action = 'create'; } } - if ($user->rights->adherent->supprimer && $action == 'confirm_delete' && $confirm == 'yes') - { + if ($user->rights->adherent->supprimer && $action == 'confirm_delete' && $confirm == 'yes') { $result = $object->delete($id, $user); - if ($result > 0) - { - if (!empty($backtopage)) - { + if ($result > 0) { + if (!empty($backtopage)) { header("Location: ".$backtopage); exit; - } - else - { + } else { header("Location: list.php"); exit; } - } - else - { + } else { $errmesg = $object->error; } } - if ($user->rights->adherent->creer && $action == 'confirm_valid' && $confirm == 'yes') - { + if ($user->rights->adherent->creer && $action == 'confirm_valid' && $confirm == 'yes') { $error = 0; $db->begin(); @@ -640,11 +569,9 @@ if (empty($reshook)) $result = $object->validate($user); - if ($result >= 0 && !count($object->errors)) - { + if ($result >= 0 && !count($object->errors)) { // Send confirmation email (according to parameters of member type. Otherwise generic) - if ($object->email && GETPOST("send_mail")) - { + if ($object->email && GETPOST("send_mail")) { $subject = ''; $msg = ''; @@ -662,8 +589,7 @@ if (empty($reshook)) if (!empty($labeltouse)) $arraydefaultmessage = $formmail->getEMailTemplate($db, 'member', $user, $outputlangs, 0, 1, $labeltouse); - if (!empty($labeltouse) && is_object($arraydefaultmessage) && $arraydefaultmessage->id > 0) - { + if (!empty($labeltouse) && is_object($arraydefaultmessage) && $arraydefaultmessage->id > 0) { $subject = $arraydefaultmessage->topic; $msg = $arraydefaultmessage->content; } @@ -672,8 +598,7 @@ if (empty($reshook)) //fallback on the old configuration. setEventMessages('WarningMandatorySetupNotComplete', null, 'errors'); $error++; - } - else { + } else { $substitutionarray = getCommonSubstitutionArray($outputlangs, 0, null, $object); complete_substitutions_array($substitutionarray, $outputlangs, $object); $subjecttosend = make_substitutions($subject, $substitutionarray, $outputlangs); @@ -682,16 +607,13 @@ if (empty($reshook)) $moreinheader = 'X-Dolibarr-Info: send_an_email by adherents/card.php'."\r\n"; $result = $object->send_an_email($texttosend, $subjecttosend, array(), array(), array(), "", "", 0, -1, '', $moreinheader); - if ($result < 0) - { + if ($result < 0) { $error++; setEventMessages($object->error, $object->errors, 'errors'); } } } - } - else - { + } else { $error++; if ($object->error) { setEventMessages($object->error, $object->errors, 'errors'); @@ -700,32 +622,25 @@ if (empty($reshook)) } } - if (!$error) - { + if (!$error) { $db->commit(); - } - else - { + } else { $db->rollback(); } $action = ''; } - if ($user->rights->adherent->supprimer && $action == 'confirm_resign') - { + if ($user->rights->adherent->supprimer && $action == 'confirm_resign') { $error = 0; - if ($confirm == 'yes') - { + if ($confirm == 'yes') { $adht = new AdherentType($db); $adht->fetch($object->typeid); $result = $object->resiliate($user); - if ($result >= 0 && !count($object->errors)) - { - if ($object->email && GETPOST("send_mail")) - { + if ($result >= 0 && !count($object->errors)) { + if ($object->email && GETPOST("send_mail")) { $subject = ''; $msg = ''; @@ -743,8 +658,7 @@ if (empty($reshook)) if (!empty($labeltouse)) $arraydefaultmessage = $formmail->getEMailTemplate($db, 'member', $user, $outputlangs, 0, 1, $labeltouse); - if (!empty($labeltouse) && is_object($arraydefaultmessage) && $arraydefaultmessage->id > 0) - { + if (!empty($labeltouse) && is_object($arraydefaultmessage) && $arraydefaultmessage->id > 0) { $subject = $arraydefaultmessage->topic; $msg = $arraydefaultmessage->content; } @@ -753,8 +667,7 @@ if (empty($reshook)) //fallback on the old configuration. setEventMessages('WarningMandatorySetupNotComplete', null, 'errors'); $error++; - } - else { + } else { $substitutionarray = getCommonSubstitutionArray($outputlangs, 0, null, $object); complete_substitutions_array($substitutionarray, $outputlangs, $object); $subjecttosend = make_substitutions($subject, $substitutionarray, $outputlangs); @@ -763,16 +676,13 @@ if (empty($reshook)) $moreinheader = 'X-Dolibarr-Info: send_an_email by adherents/card.php'."\r\n"; $result = $object->send_an_email($texttosend, $subjecttosend, array(), array(), array(), "", "", 0, -1, '', $moreinheader); - if ($result < 0) - { + if ($result < 0) { $error++; setEventMessages($object->error, $object->errors, 'errors'); } } } - } - else - { + } else { $error++; if ($object->error) { @@ -783,31 +693,24 @@ if (empty($reshook)) $action = ''; } } - if (!empty($backtopage) && !$error) - { + if (!empty($backtopage) && !$error) { header("Location: ".$backtopage); exit; } } // SPIP Management - if ($user->rights->adherent->supprimer && $action == 'confirm_del_spip' && $confirm == 'yes') - { - if (!count($object->errors)) - { - if (!$mailmanspip->del_to_spip($object)) - { + if ($user->rights->adherent->supprimer && $action == 'confirm_del_spip' && $confirm == 'yes') { + if (!count($object->errors)) { + if (!$mailmanspip->del_to_spip($object)) { setEventMessages($langs->trans('DeleteIntoSpipError').': '.$mailmanspip->error, null, 'errors'); } } } - if ($user->rights->adherent->creer && $action == 'confirm_add_spip' && $confirm == 'yes') - { - if (!count($object->errors)) - { - if (!$mailmanspip->add_to_spip($object)) - { + if ($user->rights->adherent->creer && $action == 'confirm_add_spip' && $confirm == 'yes') { + if (!count($object->errors)) { + if (!$mailmanspip->add_to_spip($object)) { setEventMessages($langs->trans('AddIntoSpipError').': '.$mailmanspip->error, null, 'errors'); } } @@ -844,28 +747,23 @@ llxHeader('', $title, $help_url); $countrynotdefined = $langs->trans("ErrorSetACountryFirst").' ('.$langs->trans("SeeAbove").')'; -if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) -{ +if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { // ----------------------------------------- // When used with CANVAS // ----------------------------------------- - if (empty($object->error) && $id) - { + if (empty($object->error) && $id) { $object = new Adherent($db); $result = $object->fetch($id); if ($result <= 0) dol_print_error('', $object->error); } $objcanvas->assign_values($action, $object->id, $object->ref); // Set value for templates $objcanvas->display_canvas($action); // Show template -} -else -{ +} else { // ----------------------------------------- // When used in standard mode // ----------------------------------------- - if ($action == 'create') - { + if ($action == 'create') { /* ************************************************************************** */ /* */ /* Creation mode */ @@ -876,8 +774,7 @@ else // We set country_id, country_code and country for the selected country $object->country_id = GETPOST('country_id', 'int') ?GETPOST('country_id', 'int') : $mysoc->country_id; - if ($object->country_id) - { + if ($object->country_id) { $tmparray = getCountry($object->country_id, 'all'); $object->country_code = $tmparray['code']; $object->country = $tmparray['label']; @@ -887,8 +784,7 @@ else $object = new Societe($db); if ($socid > 0) $object->fetch($socid); - if (!($object->id > 0)) - { + if (!($object->id > 0)) { $langs->load("errors"); print($langs->trans('ErrorRecordNotFound')); exit; @@ -899,8 +795,7 @@ else print load_fiche_titre($langs->trans("NewMember"), '', 'members'); - if ($conf->use_javascript_ajax) - { + if ($conf->use_javascript_ajax) { print "\n".''); -} -else -{ +} else { echo (''); diff --git a/htdocs/cashdesk/index_verif.php b/htdocs/cashdesk/index_verif.php index 251b3f2e997..204af8f51f7 100644 --- a/htdocs/cashdesk/index_verif.php +++ b/htdocs/cashdesk/index_verif.php @@ -116,14 +116,10 @@ if ($retour >= 0) header('Location: '.DOL_URL_ROOT.'/cashdesk/affIndex.php?menutpl=facturation&id=NOUV'); exit; - } - else - { + } else { dol_print_error($db); } -} -else -{ +} else { // Load translation files required by the page $langs->loadLangs(array("other", "errors")); $retour = $langs->trans("ErrorBadLoginPassword"); diff --git a/htdocs/cashdesk/tpl/facturation1.tpl.php b/htdocs/cashdesk/tpl/facturation1.tpl.php index f1e19b4df20..0d81f6e947e 100644 --- a/htdocs/cashdesk/tpl/facturation1.tpl.php +++ b/htdocs/cashdesk/tpl/facturation1.tpl.php @@ -169,24 +169,21 @@ for ($i = 0; $i < $nbtoshow; $i++) { $langs->load("errors"); print 'transnoentitiesnoconv("CashDesk"))).'" />'; - } - else print ''; + } else print ''; print ''; print '
'; if (empty($_SESSION['CASHDESK_ID_BANKACCOUNT_CB']) || $_SESSION['CASHDESK_ID_BANKACCOUNT_CB'] < 0) { $langs->load("errors"); print 'transnoentitiesnoconv("CashDesk"))).'" />'; - } - else print ''; + } else print ''; print '
'; print '
'; if (empty($_SESSION['CASHDESK_ID_BANKACCOUNT_CHEQUE']) || $_SESSION['CASHDESK_ID_BANKACCOUNT_CHEQUE'] < 0) { $langs->load("errors"); print 'transnoentitiesnoconv("CashDesk")).'" />'; - } - else print ''; + } else print ''; print '
'; print '
'; print '
'; diff --git a/htdocs/cashdesk/tpl/liste_articles.tpl.php b/htdocs/cashdesk/tpl/liste_articles.tpl.php index 6fffbd3ed52..bd73954f6a0 100644 --- a/htdocs/cashdesk/tpl/liste_articles.tpl.php +++ b/htdocs/cashdesk/tpl/liste_articles.tpl.php @@ -49,8 +49,7 @@ $tab = (!empty($_SESSION['poscart']) ? $_SESSION['poscart'] : array()); $tab_size = count($tab); if ($tab_size <= 0) print '
'.$langs->trans("NoArticle").'

'; -else -{ +else { for ($i = 0; $i < $tab_size; $i++) { echo ('
'."\n"); diff --git a/htdocs/cashdesk/tpl/validation1.tpl.php b/htdocs/cashdesk/tpl/validation1.tpl.php index 3b38aba3159..6fe42b35aa4 100644 --- a/htdocs/cashdesk/tpl/validation1.tpl.php +++ b/htdocs/cashdesk/tpl/validation1.tpl.php @@ -40,9 +40,7 @@ $langs->loadLangs(array("main", "bills", "banks")); // Affichage de la tva par taux if ($obj_facturation->montantTva()) { echo (''.$langs->trans("VAT").''.price(price2num($obj_facturation->montantTva(), 'MT'), 0, $langs, 0, 0, -1, $conf->currency).''); -} -else -{ +} else { echo (''.$langs->trans("VAT").''.$langs->trans("NoVAT").''); } ?> diff --git a/htdocs/cashdesk/validation_verif.php b/htdocs/cashdesk/validation_verif.php index bc67350bbf1..b2711479596 100644 --- a/htdocs/cashdesk/validation_verif.php +++ b/htdocs/cashdesk/validation_verif.php @@ -96,9 +96,7 @@ switch ($action) $encaisse = $obj_facturation->montantEncaisse(); $obj_facturation->montantRendu($encaisse - $total); - } - else - { + } else { //$txtDatePaiement=$_POST['txtDatePaiement']; $datePaiement = dol_mktime(0, 0, 0, $_POST['txtDatePaiementmonth'], $_POST['txtDatePaiementday'], $_POST['txtDatePaiementyear']); $txtDatePaiement = dol_print_date($datePaiement, 'dayrfc'); @@ -252,17 +250,13 @@ switch ($action) } } } - } - else - { + } else { setEventMessages($invoice->error, $invoice->errors, 'errors'); $error++; } $id = $invoice->id; - } - else - { + } else { $resultcreate = $invoice->create($user, 0, 0); if ($resultcreate > 0) { @@ -330,15 +324,11 @@ switch ($action) //print 'set paid';exit; } } - } - else - { + } else { setEventMessages($invoice->error, $invoice->errors, 'errors'); $error++; } - } - else - { + } else { setEventMessages($invoice->error, $invoice->errors, 'errors'); $error++; } @@ -349,9 +339,7 @@ switch ($action) { $db->commit(); $redirection = 'affIndex.php?menutpl=validation_ok&facid='.$id; // Ajout de l'id de la facture, pour l'inclure dans un lien pointant directement vers celle-ci dans Dolibarr - } - else - { + } else { $db->rollback(); $redirection = 'affIndex.php?facid='.$id.'&error=1&mesg=ErrorFailedToCreateInvoice'; // Ajout de l'id de la facture, pour l'inclure dans un lien pointant directement vers celle-ci dans Dolibarr } diff --git a/htdocs/categories/admin/categorie.php b/htdocs/categories/admin/categorie.php index 6dd313692db..eb8af1ee44a 100644 --- a/htdocs/categories/admin/categorie.php +++ b/htdocs/categories/admin/categorie.php @@ -47,9 +47,7 @@ if (preg_match('/set_([a-z0-9_\-]+)/i', $action, $reg)) { header("Location: ".$_SERVER["PHP_SELF"]); exit; - } - else - { + } else { setEventMessages($db->lasterror(), null, 'errors'); } } @@ -61,9 +59,7 @@ if (preg_match('/del_([a-z0-9_\-]+)/i', $action, $reg)) { header("Location: ".$_SERVER["PHP_SELF"]); exit; - } - else - { + } else { setEventMessages($db->lasterror(), null, 'errors'); } } @@ -107,15 +103,11 @@ print ''; if ($conf->use_javascript_ajax) { print ajax_constantonoff('CATEGORIE_RECURSIV_ADD'); -} -else -{ +} else { if (empty($conf->global->CATEGORIE_RECURSIV_ADD)) { print ''.img_picto($langs->trans("Disabled"), 'off').''; - } - else - { + } else { print ''.img_picto($langs->trans("Enabled"), 'on').''; } } diff --git a/htdocs/categories/card.php b/htdocs/categories/card.php index 67adacb5aae..8eb6c3d8eda 100644 --- a/htdocs/categories/card.php +++ b/htdocs/categories/card.php @@ -88,39 +88,31 @@ if ($action == 'add' && $user->rights->categorie->creer) { header("Location: ".$urlfrom); exit; - } - elseif ($idProdOrigin) + } elseif ($idProdOrigin) { header("Location: ".DOL_URL_ROOT.'/categories/viewcat.php?id='.$idProdOrigin.'&type='.$type); exit; - } - elseif ($idCompanyOrigin) + } elseif ($idCompanyOrigin) { header("Location: ".DOL_URL_ROOT.'/categories/viewcat.php?id='.$idCompanyOrigin.'&type='.$type); exit; - } - elseif ($idSupplierOrigin) + } elseif ($idSupplierOrigin) { header("Location: ".DOL_URL_ROOT.'/categories/viewcat.php?id='.$idSupplierOrigin.'&type='.$type); exit; - } - elseif ($idMemberOrigin) + } elseif ($idMemberOrigin) { header("Location: ".DOL_URL_ROOT.'/categories/viewcat.php?id='.$idMemberOrigin.'&type='.$type); exit; - } - elseif ($idContactOrigin) + } elseif ($idContactOrigin) { header("Location: ".DOL_URL_ROOT.'/categories/viewcat.php?id='.$idContactOrigin.'&type='.$type); exit; - } - elseif ($idProjectOrigin) + } elseif ($idProjectOrigin) { header("Location: ".DOL_URL_ROOT.'/categories/viewcat.php?id='.$idProjectOrigin.'&type='.$type); exit; - } - else - { + } else { header("Location: ".DOL_URL_ROOT.'/categories/index.php?leftmenu=cat&type='.$type); exit; } @@ -155,9 +147,7 @@ if ($action == 'add' && $user->rights->categorie->creer) { $action = 'confirmed'; $_POST["addcat"] = ''; - } - else - { + } else { setEventMessages($object->error, $object->errors, 'errors'); } } @@ -173,38 +163,31 @@ if (($action == 'add' || $action == 'confirmed') && $user->rights->categorie->cr { header("Location: ".$urlfrom); exit; - } - elseif ($backtopage) + } elseif ($backtopage) { header("Location: ".$backtopage); exit; - } - elseif ($idProdOrigin) + } elseif ($idProdOrigin) { header("Location: ".DOL_URL_ROOT.'/categories/viewcat.php?id='.$idProdOrigin.'&type='.$type.'&mesg='.urlencode($langs->trans("CatCreated"))); exit; - } - elseif ($idCompanyOrigin) + } elseif ($idCompanyOrigin) { header("Location: ".DOL_URL_ROOT.'/categories/viewcat.php?id='.$idCompanyOrigin.'&type='.$type.'&mesg='.urlencode($langs->trans("CatCreated"))); exit; - } - elseif ($idSupplierOrigin) + } elseif ($idSupplierOrigin) { header("Location: ".DOL_URL_ROOT.'/categories/viewcat.php?id='.$idSupplierOrigin.'&type='.$type.'&mesg='.urlencode($langs->trans("CatCreated"))); exit; - } - elseif ($idMemberOrigin) + } elseif ($idMemberOrigin) { header("Location: ".DOL_URL_ROOT.'/categories/viewcat.php?id='.$idMemberOrigin.'&type='.$type.'&mesg='.urlencode($langs->trans("CatCreated"))); exit; - } - elseif ($idContactOrigin) + } elseif ($idContactOrigin) { header("Location: ".DOL_URL_ROOT.'/categories/viewcat.php?id='.$idContactOrigin.'&type='.$type.'&mesg='.urlencode($langs->trans("CatCreated"))); exit; - } - elseif ($idProjectOrigin) + } elseif ($idProjectOrigin) { header("Location: ".DOL_URL_ROOT.'/categories/viewcat.php?id='.$idProjectOrigin.'&type='.$type.'&mesg='.urlencode($langs->trans("CatCreated"))); exit; diff --git a/htdocs/categories/class/api_categories.class.php b/htdocs/categories/class/api_categories.class.php index d6eff682908..1cbaf4cbe14 100644 --- a/htdocs/categories/class/api_categories.class.php +++ b/htdocs/categories/class/api_categories.class.php @@ -179,8 +179,7 @@ class Categories extends DolibarrApi } $i++; } - } - else { + } else { throw new RestException(503, 'Error when retrieve category list : '.$db->lasterror()); } if (!count($obj_ret)) { @@ -243,9 +242,7 @@ class Categories extends DolibarrApi if ($this->category->update(DolibarrApiAccess::$user) > 0) { return $this->get($id); - } - else - { + } else { throw new RestException(500, $this->category->error); } } diff --git a/htdocs/categories/class/categorie.class.php b/htdocs/categories/class/categorie.class.php index dc451855c0a..3076b9ecacd 100644 --- a/htdocs/categories/class/categorie.class.php +++ b/htdocs/categories/class/categorie.class.php @@ -64,9 +64,7 @@ class Categorie extends CommonObject /** - * @var array ID mapping from type string - * - * @note This array should be removed in future, once previous constants are moved to the string value. Deprecated + * @var array Table of mapping between type string and ID used for field 'type' in table llx_categories */ protected $MAP_ID = array( 'product' => 0, @@ -79,7 +77,8 @@ class Categorie extends CommonObject 'user' => 7, 'bank_line' => 8, 'warehouse' => 9, - 'actioncomm' => 10 + 'actioncomm' => 10, + 'website_page' => 11 ); /** @@ -316,13 +315,10 @@ class Categorie extends CommonObject if ($id > 0) { $sql .= " WHERE rowid = ".$id; - } - elseif (!empty($ref_ext)) + } elseif (!empty($ref_ext)) { $sql .= " WHERE ref_ext LIKE '".$this->db->escape($ref_ext)."'"; - } - else - { + } else { $sql .= " WHERE label = '".$this->db->escape($label)."' AND entity IN (".getEntity('category').")"; if (!is_null($type)) $sql .= " AND type = ".$this->db->escape($type); } @@ -361,14 +357,10 @@ class Categorie extends CommonObject if (!empty($conf->global->MAIN_MULTILANGS)) $this->getMultiLangs(); return 1; - } - else - { + } else { return 0; } - } - else - { + } else { dol_print_error($this->db); return -1; } @@ -482,21 +474,15 @@ class Categorie extends CommonObject { $this->db->commit(); return $id; - } - else - { + } else { $this->db->rollback(); return -3; } - } - else - { + } else { $this->db->rollback(); return -2; } - } - else - { + } else { $this->error = $this->db->error(); $this->db->rollback(); return -1; @@ -573,9 +559,7 @@ class Categorie extends CommonObject $this->db->commit(); return 1; - } - else - { + } else { $this->db->rollback(); dol_print_error($this->db); return -1; @@ -660,9 +644,7 @@ class Categorie extends CommonObject { $this->db->commit(); return 1; - } - else - { + } else { $this->db->rollback(); return -1; } @@ -673,10 +655,10 @@ class Categorie extends CommonObject * Link an object to the category * * @param CommonObject $obj Object to link to category - * @param string $type Type of category ('product', ...) + * @param string $type Type of category ('product', ...). Use '' to take $obj->element. * @return int 1 : OK, -1 : erreur SQL, -2 : id not defined, -3 : Already linked */ - public function add_type($obj, $type) + public function add_type($obj, $type = '') { // phpcs:enable global $user, $langs, $conf; @@ -685,6 +667,8 @@ class Categorie extends CommonObject if ($this->id == -1) return -2; + if (empty($type)) $type = $obj->element; + $this->db->begin(); $sql = "INSERT INTO ".MAIN_DB_PREFIX."categorie_".(empty($this->MAP_CAT_TABLE[$type]) ? $type : $this->MAP_CAT_TABLE[$type]); @@ -721,9 +705,7 @@ class Categorie extends CommonObject } } } - } - else - { + } else { $error++; $this->error = $this->db->lasterror(); } @@ -747,23 +729,17 @@ class Categorie extends CommonObject { $this->db->commit(); return 1; - } - else - { + } else { $this->db->rollback(); return -2; } - } - else - { + } else { $this->db->rollback(); if ($this->db->lasterrno() == 'DB_ERROR_RECORD_ALREADY_EXISTS') { $this->error = $this->db->lasterrno(); return -3; - } - else - { + } else { $this->error = $this->db->lasterror(); } return -1; @@ -814,15 +790,11 @@ class Categorie extends CommonObject { $this->db->commit(); return 1; - } - else - { + } else { $this->db->rollback(); return -2; } - } - else - { + } else { $this->db->rollback(); $this->error = $this->db->lasterror(); return -1; @@ -873,18 +845,14 @@ class Categorie extends CommonObject if ($onlyids) { $objs[] = $rec['fk_'.(empty($this->MAP_CAT_FK[$type]) ? $type : $this->MAP_CAT_FK[$type])]; - } - else - { + } else { $obj = new $this->MAP_OBJ_CLASS[$type]($this->db); $obj->fetch($rec['fk_'.(empty($this->MAP_CAT_FK[$type]) ? $type : $this->MAP_CAT_FK[$type])]); $objs[] = $obj; } } return $objs; - } - else - { + } else { $this->error = $this->db->error().' sql='.$sql; return -1; } @@ -1009,8 +977,7 @@ class Categorie extends CommonObject } $i++; } - } - else { + } else { $this->error = $this->db->lasterror(); return -1; } @@ -1045,9 +1012,7 @@ class Categorie extends CommonObject $cats[] = $cat; } return $cats; - } - else - { + } else { dol_print_error($this->db); return -1; } @@ -1079,9 +1044,7 @@ class Categorie extends CommonObject $this->motherof[$obj->id_son] = $obj->id_parent; } return 1; - } - else - { + } else { dol_print_error($this->db); return -1; } @@ -1113,23 +1076,23 @@ class Categorie extends CommonObject global $conf, $langs; if (!is_numeric($type)) $type = $this->MAP_ID[$type]; + if (is_null($type)) { + $this->error = 'BadValueForParameterType'; + return -1; + } if (is_string($markafterid)) { $markafterid = explode(',', $markafterid); - } - elseif (is_numeric($markafterid)) + } elseif (is_numeric($markafterid)) { if ($markafterid > 0) { $markafterid = array($markafterid); - } - else - { + } else { $markafterid = array(); } - } - elseif (!is_array($markafterid)) + } elseif (!is_array($markafterid)) { $markafterid = array(); } @@ -1165,9 +1128,7 @@ class Categorie extends CommonObject $this->cats[$obj->rowid]['ref_ext'] = $obj->ref_ext; $i++; } - } - else - { + } else { dol_print_error($this->db); return -1; } @@ -1311,9 +1272,7 @@ class Categorie extends CommonObject $cats[$rec['rowid']] = $cat; } return $cats; - } - else - { + } else { dol_print_error($this->db); return -1; } @@ -1375,9 +1334,7 @@ class Categorie extends CommonObject } dol_syslog(get_class($this)."::already_exists no category with same name=".$this->label." and same parent ".$this->fk_parent." than category id=".$this->id, LOG_DEBUG); return 0; - } - else - { + } else { $this->error = $this->db->error(); return -1; } @@ -1429,9 +1386,7 @@ class Categorie extends CommonObject $link = ''; $linkend = ''; $w[] = $link.($addpicto ? img_object('', 'category', 'class="paddingright"') : '').$cat->label.$linkend; - } - else - { + } else { $w[] = "".($addpicto ? img_object('', 'category') : '').$cat->label.""; } } @@ -1472,9 +1427,7 @@ class Categorie extends CommonObject } } return $parents; - } - else - { + } else { dol_print_error($this->db); return -1; } @@ -1553,15 +1506,11 @@ class Categorie extends CommonObject $cats[] = $cat; } } - } - else - { + } else { dol_print_error($this->db); return -1; } - } - else - { + } else { $sql = "SELECT ct.fk_categorie, c.label, c.rowid"; $sql .= " FROM ".MAIN_DB_PREFIX."categorie_".(empty($this->MAP_CAT_TABLE[$type]) ? $type : $this->MAP_CAT_TABLE[$type])." as ct, ".MAIN_DB_PREFIX."categorie as c"; $sql .= " WHERE ct.fk_categorie = c.rowid AND ct.fk_".(empty($this->MAP_CAT_FK[$type]) ? $type : $this->MAP_CAT_FK[$type])." = ".(int) $id." AND c.type = ".$this->MAP_ID[$type]; @@ -1582,9 +1531,7 @@ class Categorie extends CommonObject $cats[] = $cat; } } - } - else - { + } else { dol_print_error($this->db); return -1; } @@ -1632,8 +1579,7 @@ class Categorie extends CommonObject $nom = '%'.str_replace('*', '%', $nom).'%'; if (!$case) $sql .= " AND label LIKE '".$this->db->escape($nom)."'"; - else - $sql .= " AND label LIKE BINARY '".$this->db->escape($nom)."'"; + else $sql .= " AND label LIKE BINARY '".$this->db->escape($nom)."'"; } if ($id) { @@ -1651,9 +1597,7 @@ class Categorie extends CommonObject } return $cats; - } - else - { + } else { $this->error = $this->db->error().' sql='.$sql; return -1; } @@ -1878,9 +1822,7 @@ class Categorie extends CommonObject $sql2 .= " SET label='".$this->db->escape($this->label)."',"; $sql2 .= " description='".$this->db->escape($this->description)."'"; $sql2 .= " WHERE fk_category=".$this->id." AND lang='".$this->db->escape($key)."'"; - } - else - { + } else { $sql2 = "INSERT INTO ".MAIN_DB_PREFIX."categorie_lang (fk_category, lang, label, description)"; $sql2 .= " VALUES(".$this->id.",'".$key."','".$this->db->escape($this->label); $sql2 .= "','".$this->db->escape($this->multilangs["$key"]["description"])."')"; @@ -1891,8 +1833,7 @@ class Categorie extends CommonObject $this->error = $this->db->lasterror(); return -1; } - } - elseif (isset($this->multilangs["$key"])) + } elseif (isset($this->multilangs["$key"])) { if ($this->db->num_rows($result)) // si aucune ligne dans la base { @@ -1900,9 +1841,7 @@ class Categorie extends CommonObject $sql2 .= " SET label='".$this->db->escape($this->multilangs["$key"]["label"])."',"; $sql2 .= " description='".$this->db->escape($this->multilangs["$key"]["description"])."'"; $sql2 .= " WHERE fk_category=".$this->id." AND lang='".$this->db->escape($key)."'"; - } - else - { + } else { $sql2 = "INSERT INTO ".MAIN_DB_PREFIX."categorie_lang (fk_category, lang, label, description)"; $sql2 .= " VALUES(".$this->id.",'".$key."','".$this->db->escape($this->multilangs["$key"]["label"]); $sql2 .= "','".$this->db->escape($this->multilangs["$key"]["description"])."')"; @@ -1960,9 +1899,7 @@ class Categorie extends CommonObject $this->multilangs["$obj->lang"]["description"] = $obj->description; } return 1; - } - else - { + } else { $this->error = $langs->trans("Error")." : ".$this->db->error()." - ".$sql; return -1; } @@ -2054,8 +1991,7 @@ class Categorie extends CommonObject if (intval($searchCategory) == -2) { $searchCategorySqlList[] = " cp.fk_categorie IS NULL"; - } - elseif (intval($searchCategory) > 0) + } elseif (intval($searchCategory) > 0) { $searchCategorySqlList[] = " ".$rowIdName ." IN (SELECT fk_".$type." FROM ".MAIN_DB_PREFIX."categorie_".$type @@ -2066,9 +2002,7 @@ class Categorie extends CommonObject if (!empty($searchCategorySqlList)) { return " AND (".implode(' AND ', $searchCategorySqlList).")"; - } - else - { + } else { return ""; } } diff --git a/htdocs/categories/edit.php b/htdocs/categories/edit.php index 48bd82b9326..53a343046b7 100644 --- a/htdocs/categories/edit.php +++ b/htdocs/categories/edit.php @@ -90,8 +90,7 @@ if ($action == 'update' && $user->rights->categorie->creer) if ($parent != "-1") $object->fk_parent = $parent; - else - $object->fk_parent = ""; + else $object->fk_parent = ""; if (empty($object->label)) @@ -109,14 +108,10 @@ if ($action == 'update' && $user->rights->categorie->creer) { header('Location: '.DOL_URL_ROOT.'/categories/viewcat.php?id='.$object->id.'&type='.$type); exit; - } - else - { + } else { setEventMessages($object->error, $object->errors, 'errors'); } - } - else - { + } else { setEventMessages($object->error, $object->errors, 'errors'); } } diff --git a/htdocs/categories/index.php b/htdocs/categories/index.php index b36101750f2..ccdd8be58b9 100644 --- a/htdocs/categories/index.php +++ b/htdocs/categories/index.php @@ -54,7 +54,10 @@ $typetext = $type; if ($type == Categorie::TYPE_ACCOUNT) $title = $langs->trans('AccountsCategoriesArea'); elseif ($type == Categorie::TYPE_WAREHOUSE) $title = $langs->trans('StocksCategoriesArea'); elseif ($type == Categorie::TYPE_ACTIONCOMM) $title = $langs->trans('ActionCommCategoriesArea'); -else $title = $langs->trans(ucfirst($type).'sCategoriesArea'); +elseif ($type == Categorie::TYPE_WEBSITE_PAGE) $title = $langs->trans('WebsitePagesCategoriesArea'); +else { + $title = $langs->trans(ucfirst($type).'sCategoriesArea'); +} $arrayofjs = array('/includes/jquery/plugins/jquerytreeview/jquery.treeview.js', '/includes/jquery/plugins/jquerytreeview/lib/jquery.cookie.js'); $arrayofcss = array('/includes/jquery/plugins/jquerytreeview/jquery.treeview.css'); @@ -69,8 +72,6 @@ if (!empty($user->rights->categorie->creer)) { print load_fiche_titre($title, $newcardbutton, 'object_category'); -//print ''; -//print ''; print ''; print ''; -/* -// faire une rech dans une sous categorie uniquement -print ''; -print ''; -*/ - print '
'; print '
'; @@ -88,20 +89,9 @@ print '
'.$langs->trans("Search").'
'; print $langs->trans("Name").':
'; -print $langs->trans("SubCatOf").':'; - -print $form->select_all_categories('','subcatof'); -print '
'; -//print ''; print '
'; @@ -134,11 +124,9 @@ if ($catname || $id > 0) print "\t\n"; } print ""; -} -else print ' '; +} else print ' '; -//print ''; print '
'; print '

'; @@ -206,9 +194,7 @@ if ($nbofentries > 0) print ''; tree_recur($data, $data[0], 0); print ''; -} -else -{ +} else { print ''; print ''; print '\n"; } - } - else - { + } else { print ''; } print "
'.img_picto_common('', 'treemenu/branchbottom.gif').''; diff --git a/htdocs/categories/info.php b/htdocs/categories/info.php index 644886c7387..bef54f9dd6b 100644 --- a/htdocs/categories/info.php +++ b/htdocs/categories/info.php @@ -60,10 +60,10 @@ llxHeader('', $langs->trans('Categories'), ''); //$object->info($object->id); -$head = categories_prepare_head($object, $type); - $title = Categorie::$MAP_TYPE_TITLE_AREA[$type]; +$head = categories_prepare_head($object, $type); + dol_fiche_head($head, 'info', $langs->trans($title), -1, 'category'); $backtolist = (GETPOST('backtolist') ? GETPOST('backtolist') : DOL_URL_ROOT.'/categories/index.php?leftmenu=cat&type='.$type); $linkback = ''.$langs->trans("BackToList").''; @@ -78,14 +78,21 @@ $morehtmlref .= ''; dol_banner_tab($object, 'label', $linkback, ($user->socid ? 0 : 1), 'label', 'label', $morehtmlref, '&type='.$type, 0, '', '', 1); +print '
'; + print '
'; print '
'; print '
'; -print ''; + +print '
'; +print ''; + +print '
'; dol_print_object_info($object); -print '
'; +print '
'; + print '
'; dol_fiche_end(); diff --git a/htdocs/categories/photos.php b/htdocs/categories/photos.php index 07e5d56d268..e8b3da0a525 100644 --- a/htdocs/categories/photos.php +++ b/htdocs/categories/photos.php @@ -144,7 +144,7 @@ if ($object->id) print '
'; print '
'; - print ''; + print '
'; // Description print '\n"; } - } - else - { + } else { print ''; } print "
'; @@ -179,9 +179,7 @@ if ($object->id) { print ''; print $langs->trans("AddPhoto").''; - } - else - { + } else { print ''; print $langs->trans("AddPhoto").''; } @@ -231,9 +229,7 @@ if ($object->id) if ($obj['photo_vignette']) { $filename = $obj['photo_vignette']; - } - else - { + } else { $filename = $obj['photo']; } @@ -280,9 +276,7 @@ if ($object->id) print '
'.$langs->trans("NoPhotoYet")."
"; } } -} -else -{ +} else { print $langs->trans("ErrorUnknown"); } diff --git a/htdocs/categories/traduction.php b/htdocs/categories/traduction.php index c3f87e404b7..a8f3510c31b 100644 --- a/htdocs/categories/traduction.php +++ b/htdocs/categories/traduction.php @@ -22,7 +22,7 @@ /** * \file htdocs/product/traduction.php * \ingroup product - * \brief Page de traduction des produits + * \brief Page of translation of products */ require '../main.inc.php'; @@ -167,12 +167,12 @@ $cancel != $langs->trans("Cancel") && * View */ -llxHeader("", "", $langs->trans("Translation")); - $form = new Form($db); $formadmin = new FormAdmin($db); $formother = new FormOther($db); +llxHeader("", "", $langs->trans("Translation")); + $title = Categorie::$MAP_TYPE_TITLE_AREA[$type]; $head = categories_prepare_head($object, $type); @@ -194,8 +194,7 @@ $object->next_prev_filter = ' type = '.$object->type; $object->ref = $object->label; $morehtmlref = '
'.$langs->trans("Root").' >> '; $ways = $object->print_all_ways(" >> ", '', 1); -foreach ($ways as $way) -{ +foreach ($ways as $way) { $morehtmlref .= $way."
\n"; } $morehtmlref .= '
'; @@ -207,7 +206,7 @@ print '
'; print '
'; print '
'; -print ''; +print '
'; // Description print ''; print "\n"; } - } - else - { + } else { print ''; } print "
'; @@ -292,8 +291,7 @@ if ($action == 'edit') print ''; print ''; -} -elseif ($action != 'add') +} elseif ($action != 'add') { if ($cnt_trans) print '
'; diff --git a/htdocs/categories/viewcat.php b/htdocs/categories/viewcat.php index c4366ebf19c..0e5b50085c9 100644 --- a/htdocs/categories/viewcat.php +++ b/htdocs/categories/viewcat.php @@ -103,47 +103,40 @@ if ($id > 0 && $removeelem > 0) $tmpobject = new Product($db); $result = $tmpobject->fetch($removeelem); $elementtype = 'product'; - } - elseif ($type == Categorie::TYPE_SUPPLIER && $user->rights->societe->creer) + } elseif ($type == Categorie::TYPE_SUPPLIER && $user->rights->societe->creer) { $tmpobject = new Societe($db); $result = $tmpobject->fetch($removeelem); $elementtype = 'supplier'; - } - elseif ($type == Categorie::TYPE_CUSTOMER && $user->rights->societe->creer) + } elseif ($type == Categorie::TYPE_CUSTOMER && $user->rights->societe->creer) { $tmpobject = new Societe($db); $result = $tmpobject->fetch($removeelem); $elementtype = 'customer'; - } - elseif ($type == Categorie::TYPE_MEMBER && $user->rights->adherent->creer) + } elseif ($type == Categorie::TYPE_MEMBER && $user->rights->adherent->creer) { require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; $tmpobject = new Adherent($db); $result = $tmpobject->fetch($removeelem); $elementtype = 'member'; - } - elseif ($type == Categorie::TYPE_CONTACT && $user->rights->societe->creer) { + } elseif ($type == Categorie::TYPE_CONTACT && $user->rights->societe->creer) { require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php'; $tmpobject = new Contact($db); $result = $tmpobject->fetch($removeelem); $elementtype = 'contact'; - } - elseif ($type == Categorie::TYPE_ACCOUNT && $user->rights->banque->configurer) + } elseif ($type == Categorie::TYPE_ACCOUNT && $user->rights->banque->configurer) { require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; $tmpobject = new Account($db); $result = $tmpobject->fetch($removeelem); $elementtype = 'account'; - } - elseif ($type == Categorie::TYPE_PROJECT && $user->rights->projet->creer) + } elseif ($type == Categorie::TYPE_PROJECT && $user->rights->projet->creer) { require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; $tmpobject = new Project($db); $result = $tmpobject->fetch($removeelem); $elementtype = 'project'; - } - elseif ($type == Categorie::TYPE_USER && $user->rights->user->user->creer) + } elseif ($type == Categorie::TYPE_USER && $user->rights->user->user->creer) { require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php'; $tmpobject = new User($db); @@ -161,9 +154,7 @@ if ($user->rights->categorie->supprimer && $action == 'confirm_delete' && $confi { header("Location: ".DOL_URL_ROOT.'/categories/index.php?type='.$type); exit; - } - else - { + } else { setEventMessages($object->error, $object->errors, 'errors'); } } @@ -180,15 +171,11 @@ if ($type == Categorie::TYPE_PRODUCT && $elemid && $action == 'addintocategory' if ($result >= 0) { setEventMessages($langs->trans("WasAddedSuccessfully", $newobject->ref), null, 'mesgs'); - } - else - { + } else { if ($cat->error == 'DB_ERROR_RECORD_ALREADY_EXISTS') { setEventMessages($langs->trans("ObjectAlreadyLinkedToCategory"), null, 'warnings'); - } - else - { + } else { setEventMessages($object->error, $object->errors, 'errors'); } } @@ -241,7 +228,7 @@ print '
'; print '
'; print '
'; -print ''; +print '
'; // Description print ''; print ''; print ''; -} -else -{ +} else { $categstatic = new Categorie($db); $fulltree = $categstatic->get_full_arbo($type, $object->id, 1); @@ -407,9 +391,7 @@ else print ''; print ''; - } - else - { + } else { print ''; print '\n"; } - } - else - { + } else { print ''; } print "
'; @@ -330,15 +317,12 @@ $cats = $object->get_filles(); if ($cats < 0) { dol_print_error($db, $cats->error, $cats->errors); -} -elseif (count($cats) < 1) +} elseif (count($cats) < 1) { print '
'.$langs->trans("NoSubCat").'
'; print ''; @@ -450,9 +432,7 @@ if ($type == Categorie::TYPE_PRODUCT) if ($prods < 0) { dol_print_error($db, $prods->error, $prods->errors); - } - else - { + } else { // Form to add record into a category $showclassifyform = 1; if ($showclassifyform) @@ -514,9 +494,7 @@ if ($type == Categorie::TYPE_PRODUCT) print ''; print "\n"; } - } - else - { + } else { print ''; } print "
'.$langs->trans("ThisCategoryHasNoItems").'
\n"; @@ -533,9 +511,7 @@ if ($type == Categorie::TYPE_SUPPLIER) if ($socs < 0) { dol_print_error($db, $socs->error, $socs->errors); - } - else - { + } else { print '
'; print ''; print ''; @@ -575,9 +551,7 @@ if ($type == Categorie::TYPE_SUPPLIER) print "
'.$langs->trans("ThisCategoryHasNoItems").'
\n"; @@ -594,9 +568,7 @@ if ($type == Categorie::TYPE_CUSTOMER) if ($socs < 0) { dol_print_error($db, $socs->error, $socs->errors); - } - else - { + } else { print ''; print ''; print ''; @@ -635,9 +607,7 @@ if ($type == Categorie::TYPE_CUSTOMER) print '
'.$langs->trans("ThisCategoryHasNoItems").'
\n"; @@ -657,9 +627,7 @@ if ($type == Categorie::TYPE_MEMBER) if ($prods < 0) { dol_print_error($db, $prods->error, $prods->errors); - } - else - { + } else { print ''; print ''; print ''; @@ -700,9 +668,7 @@ if ($type == Categorie::TYPE_MEMBER) } print "
'.$langs->trans("ThisCategoryHasNoItems").'
\n"; @@ -720,9 +686,7 @@ if ($type == Categorie::TYPE_CONTACT) if ($contacts < 0) { dol_print_error($db, $contacts->error, $contacts->errors); - } - else - { + } else { print ''; print ''; print ''; @@ -735,7 +699,7 @@ if ($type == Categorie::TYPE_CONTACT) $num = count($contacts); $nbtotalofrecords = ''; $newcardbutton = ''; - print_barre_liste($langs->trans("Contact"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'contacts', 0, $newcardbutton, '', $limit); + print_barre_liste($langs->trans("Contact"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'contact', 0, $newcardbutton, '', $limit); print ''."\n"; print ''."\n"; @@ -764,9 +728,7 @@ if ($type == Categorie::TYPE_CONTACT) print ''; print "\n"; } - } - else - { + } else { print ''; } print "
'.$langs->trans("Ref").'
'.$langs->trans("ThisCategoryHasNoItems").'
\n"; @@ -786,9 +748,7 @@ if ($type == Categorie::TYPE_ACCOUNT) if ($accounts < 0) { dol_print_error($db, $accounts->error, $accounts->errors); - } - else - { + } else { print ''; print ''; print ''; @@ -828,9 +788,7 @@ if ($type == Categorie::TYPE_ACCOUNT) } print "
'.$langs->trans("ThisCategoryHasNoItems").'
\n"; @@ -850,9 +808,7 @@ if ($type == Categorie::TYPE_PROJECT) if ($objects < 0) { dol_print_error($db, $object->error, $object->errors); - } - else - { + } else { print ''; print ''; print ''; @@ -893,9 +849,7 @@ if ($type == Categorie::TYPE_PROJECT) } print "\n"; } - } - else - { + } else { print ''.$langs->trans("ThisCategoryHasNoItems").''; } print "\n"; @@ -913,9 +867,7 @@ if ($type == Categorie::TYPE_USER) if ($users < 0) { dol_print_error($db, $object->error, $object->errors); - } - else - { + } else { print ''; print ''; print ''; @@ -953,9 +905,7 @@ if ($type == Categorie::TYPE_USER) } print "\n"; } - } - else - { + } else { print ''.$langs->trans("ThisCategoryHasNoItems").''; } print "\n"; @@ -976,9 +926,7 @@ if ($type == Categorie::TYPE_WAREHOUSE) if ($objects < 0) { dol_print_error($db, $object->error, $object->errors); - } - else - { + } else { print ''; print ''; print ''; @@ -989,7 +937,7 @@ if ($type == Categorie::TYPE_WAREHOUSE) print '
'; $param = '&limit='.$limit.'&id='.$id.'&type='.$type; $num = count($objects); $nbtotalofrecords = ''; $newcardbutton = ''; - print_barre_liste($langs->trans("Warehouses"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'generic', 0, $newcardbutton, '', $limit); + print_barre_liste($langs->trans("Warehouses"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'stock', 0, $newcardbutton, '', $limit); print "\n"; print ''."\n"; @@ -1019,9 +967,7 @@ if ($type == Categorie::TYPE_WAREHOUSE) } print "\n"; } - } - else - { + } else { print ''; } print "
'.$langs->trans("Ref").'
'.$langs->trans("ThisCategoryHasNoItems").'
\n"; diff --git a/htdocs/collab/index.php b/htdocs/collab/index.php index c570e12ba31..0c457fb6f47 100644 --- a/htdocs/collab/index.php +++ b/htdocs/collab/index.php @@ -94,9 +94,7 @@ if ($action == 'add') $db->commit(); setEventMessages($langs->trans("PageAdded", $objectpage->pageurl), null, 'mesgs'); $action = ''; - } - else - { + } else { $db->rollback(); } @@ -129,14 +127,10 @@ if ($action == 'delete') header("Location: ".$_SERVER["PHP_SELF"].'?website='.$website); exit; - } - else - { + } else { $db->rollback(); } - } - else - { + } else { dol_print_error($db); } } diff --git a/htdocs/comm/action/card.php b/htdocs/comm/action/card.php index 716e02ae678..55cca00d7d7 100644 --- a/htdocs/comm/action/card.php +++ b/htdocs/comm/action/card.php @@ -172,9 +172,7 @@ if (empty($reshook) && $action == 'confirm_clone' && $confirm == 'yes') if (1 == 0 && !GETPOST('clone_content') && !GETPOST('clone_receivers')) { setEventMessages($langs->trans("NoCloneOptionsSpecified"), null, 'errors'); - } - else - { + } else { if ($id > 0) { //$object->fetch($id); if (!empty($object->socpeopleassigned)) { @@ -242,9 +240,7 @@ if (empty($reshook) && $action == 'add') $error++; $donotclearsession = 1; $action = 'create'; setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Type")), null, 'errors'); - } - else - { + } else { $object->type_code = GETPOST('actioncode', 'aZ09'); } @@ -262,14 +258,11 @@ if (empty($reshook) && $action == 'add') if (GETPOST('actioncode', 'aZ09') == 'AC_RDV' && $contact->getFullName($langs)) { $object->label = $langs->transnoentitiesnoconv("TaskRDVWith", $contact->getFullName($langs)); - } - else - { + } else { if ($langs->trans("Action".$object->type_code) != "Action".$object->type_code) { $object->label = $langs->transnoentitiesnoconv("Action".$object->type_code)."\n"; - } - else { + } else { $cactioncomm->fetch($object->type_code); $object->label = $cactioncomm->label; } @@ -389,19 +382,14 @@ if (empty($reshook) && $action == 'add') { dol_syslog("Back to ".$backtopage.($moreparam ? (preg_match('/\?/', $backtopage) ? '&'.$moreparam : '?'.$moreparam) : '')); header("Location: ".$backtopage.($moreparam ? (preg_match('/\?/', $backtopage) ? '&'.$moreparam : '?'.$moreparam) : '')); - } - elseif ($idaction) + } elseif ($idaction) { header("Location: ".DOL_URL_ROOT.'/comm/action/card.php?id='.$idaction.($moreparam ? '&'.$moreparam : '')); - } - else - { + } else { header("Location: ".DOL_URL_ROOT.'/comm/action/index.php'.($moreparam ? '?'.$moreparam : '')); } exit; - } - else - { + } else { // If error $db->rollback(); $langs->load("errors"); @@ -409,9 +397,7 @@ if (empty($reshook) && $action == 'add') setEventMessages($error, null, 'errors'); $action = 'create'; $donotclearsession = 1; } - } - else - { + } else { $db->rollback(); setEventMessages($object->error, $object->errors, 'errors'); $action = 'create'; $donotclearsession = 1; @@ -488,8 +474,7 @@ if (empty($reshook) && $action == 'update') { if ($val['id'] > 0 && $val['id'] != $assignedtouser) $listofuserid[$val['id']] = $val; } - } - else { + } else { $assignedtouser = (!empty($object->userownerid) && $object->userownerid > 0 ? $object->userownerid : 0); if ($assignedtouser) $listofuserid[$assignedtouser] = array('id'=>$assignedtouser, 'mandatory'=>0, 'transparency'=>($user->id == $assignedtouser ? $transparency : '')); // Owner first } @@ -516,9 +501,7 @@ if (empty($reshook) && $action == 'update') $error++; $donotclearsession = 1; $action = 'edit'; setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Type")), null, 'errors'); - } - else - { + } else { $result = $cactioncomm->fetch(GETPOST('actioncode', 'aZ09')); } if (empty($object->userownerid)) @@ -606,9 +589,7 @@ if (empty($reshook) && $action == 'update') unset($_SESSION['assignedtouser']); $db->commit(); - } - else - { + } else { setEventMessages($object->error, $object->errors, 'errors'); $db->rollback(); } @@ -645,9 +626,7 @@ if (empty($reshook) && $action == 'confirm_delete' && GETPOST("confirm") == 'yes { header("Location: index.php"); exit; - } - else - { + } else { setEventMessages($object->error, $object->errors, 'errors'); } } @@ -755,9 +734,7 @@ if (empty($reshook) && GETPOST('actionmove', 'alpha') == 'mupdate') { header("Location: ".$backtopage); exit; - } - else - { + } else { $action = ''; } } @@ -957,8 +934,7 @@ if ($action == 'create') $percent = -1; if (isset($_GET['status']) || isset($_POST['status'])) $percent = GETPOST('status'); elseif (isset($_GET['percentage']) || isset($_POST['percentage'])) $percent = GETPOST('percentage'); - else - { + else { if (GETPOST('complete') == '0' || GETPOST("afaire") == 1) $percent = '0'; elseif (GETPOST('complete') == 100 || GETPOST("afaire") == 2) $percent = 100; } @@ -980,9 +956,7 @@ if ($action == 'create') if ($assignedtouser) $listofuserid[$assignedtouser] = array('id'=>$assignedtouser, 'mandatory'=>0, 'transparency'=>$object->transparency); // Owner first $listofuserid[$user->id]['transparency'] = GETPOSTISSET('transparency') ?GETPOST('transparency', 'alpha') : 1; // 1 by default at first init $_SESSION['assignedtouser'] = json_encode($listofuserid); - } - else - { + } else { if (!empty($_SESSION['assignedtouser'])) { $listofuserid = json_decode($_SESSION['assignedtouser'], true); @@ -1034,9 +1008,7 @@ if ($action == 'create') $societe->fetch(GETPOST('socid', 'int')); print $societe->getNomUrl(1); print ''; - } - else - { + } else { $events = array(); $events[] = array('method' => 'getContacts', 'url' => dol_buildpath('/core/ajax/contacts.php?showempty=1', 1), 'htmlname' => 'contactid', 'params' => array('add-customer-contact' => 'disabled')); //For external user force the company to user company @@ -1265,9 +1237,7 @@ if ($id > 0) if ($object->type_code != 'AC_OTH_AUTO') { $formactions->select_type_actions(GETPOST("actioncode", 'aZ09') ?GETPOST("actioncode", 'aZ09') : $object->type_code, "actioncode", "systemauto"); - } - else - { + } else { print ''.$langs->trans("Action".$object->type_code); } print ''; @@ -1397,9 +1367,7 @@ if ($id > 0) } } $_SESSION['assignedtouser'] = json_encode($listofuserid); - } - else - { + } else { if (!empty($_SESSION['assignedtouser'])) { $listofuserid = json_decode($_SESSION['assignedtouser'], true); @@ -1522,9 +1490,7 @@ if ($id > 0) print ''; print ''; - } - else - { + } else { print ''; print dolGetElementUrl($object->fk_element, $object->elementtype, 1); print ''; @@ -1563,9 +1529,7 @@ if ($id > 0) print '
'; print ''; - } - else - { + } else { dol_fiche_head($head, 'card', $langs->trans("Action"), -1, 'action'); @@ -1708,9 +1672,7 @@ if ($id > 0) } } $_SESSION['assignedtouser'] = json_encode($listofuserid); - } - else - { + } else { if (!empty($_SESSION['assignedtouser'])) { $listofuserid = json_decode($_SESSION['assignedtouser'], true); @@ -1796,9 +1758,7 @@ if ($id > 0) print '
'; } } - } - else - { + } else { print ''.$langs->trans("None").''; } print ''; @@ -1855,9 +1815,7 @@ if ($id > 0) (($object->authorid == $user->id || $object->userownerid == $user->id) && $user->rights->agenda->myactions->create)) { print ''; - } - else - { + } else { print ''; } @@ -1865,9 +1823,7 @@ if ($id > 0) (($object->authorid == $user->id || $object->userownerid == $user->id) && $user->rights->agenda->myactions->create)) { print ''; - } - else - { + } else { print ''; } @@ -1875,9 +1831,7 @@ if ($id > 0) (($object->authorid == $user->id || $object->userownerid == $user->id) && $user->rights->agenda->myactions->delete)) { print ''; - } - else - { + } else { print ''; } } diff --git a/htdocs/comm/action/class/actioncomm.class.php b/htdocs/comm/action/class/actioncomm.class.php index fac4dc45715..2cda34a494b 100644 --- a/htdocs/comm/action/class/actioncomm.class.php +++ b/htdocs/comm/action/class/actioncomm.class.php @@ -177,12 +177,6 @@ class ActionComm extends CommonObject */ public $fulldayevent = 0; - /** - * @var int Milestone - * @deprecated Milestone is already event with end date = start date - */ - public $punctual = 1; - /** * @var integer Percentage */ @@ -343,6 +337,20 @@ class ActionComm extends CommonObject */ public $errors_to; + /** + * Typical value for a event that is in a todo state + */ + const EVENT_TODO = 0; + + /** + * Typical value for a event that is in a progress state + */ + const EVENT_IN_PROGRESS = 50; + + /** + * Typical value for a event that is in a finished state + */ + const EVENT_FINISHED = 100; /** * Constructor @@ -384,7 +392,6 @@ class ActionComm extends CommonObject if (empty($this->percentage)) $this->percentage = 0; if (empty($this->priority) || !is_numeric($this->priority)) $this->priority = 0; if (empty($this->fulldayevent)) $this->fulldayevent = 0; - if (empty($this->punctual)) $this->punctual = 0; if (empty($this->transparency)) $this->transparency = 0; if ($this->percentage > 100) $this->percentage = 100; //if ($this->percentage == 100 && ! $this->dateend) $this->dateend = $this->date; @@ -405,7 +412,6 @@ class ActionComm extends CommonObject $this->userassigned[$tmpid] = array('id'=>$tmpid, 'transparency'=>$this->transparency); } - $userownerid = $this->userownerid; $userdoneid = $this->userdoneid; @@ -425,14 +431,11 @@ class ActionComm extends CommonObject { $this->type_id = $cactioncomm->id; $this->type_code = $cactioncomm->code; - } - elseif ($result == 0) + } elseif ($result == 0) { $this->error = 'Failed to get record with id '.$this->type_id.' code '.$this->type_code.' from dictionary "type of events"'; return -1; - } - else - { + } else { $this->error = $cactioncomm->error; return -1; } @@ -463,7 +466,7 @@ class ActionComm extends CommonObject $sql .= "fk_user_author,"; $sql .= "fk_user_action,"; $sql .= "fk_user_done,"; - $sql .= "label,percent,priority,fulldayevent,location,punctual,"; + $sql .= "label,percent,priority,fulldayevent,location,"; $sql .= "transparency,"; $sql .= "fk_element,"; $sql .= "elementtype,"; @@ -484,7 +487,7 @@ class ActionComm extends CommonObject $sql .= (strval($this->datef) != '' ? "'".$this->db->idate($this->datef)."'" : "null").", "; $sql .= ((isset($this->durationp) && $this->durationp >= 0 && $this->durationp != '') ? "'".$this->db->escape($this->durationp)."'" : "null").", "; // deprecated $sql .= (isset($this->type_id) ? $this->type_id : "null").","; - $sql .= ($code ? ("'".$code."'") : "null").", "; + $sql .= ($code ? ("'".$this->db->escape($code)."'") : "null").", "; $sql .= ($this->ref_ext ? ("'".$this->db->idate($this->ref_ext)."'") : "null").", "; $sql .= ((isset($this->socid) && $this->socid > 0) ? $this->socid : "null").", "; $sql .= ((isset($this->fk_project) && $this->fk_project > 0) ? $this->fk_project : "null").", "; @@ -493,7 +496,7 @@ class ActionComm extends CommonObject $sql .= (isset($user->id) && $user->id > 0 ? $user->id : "null").", "; $sql .= ($userownerid > 0 ? $userownerid : "null").", "; $sql .= ($userdoneid > 0 ? $userdoneid : "null").", "; - $sql .= "'".$this->db->escape($this->label)."','".$this->db->escape($this->percentage)."','".$this->db->escape($this->priority)."','".$this->db->escape($this->fulldayevent)."','".$this->db->escape($this->location)."','".$this->db->escape($this->punctual)."', "; + $sql .= "'".$this->db->escape($this->label)."','".$this->db->escape($this->percentage)."','".$this->db->escape($this->priority)."','".$this->db->escape($this->fulldayevent)."','".$this->db->escape($this->location)."', "; $sql .= "'".$this->db->escape($this->transparency)."', "; $sql .= (!empty($this->fk_element) ? $this->fk_element : "null").", "; $sql .= (!empty($this->elementtype) ? "'".$this->db->escape($this->elementtype)."'" : "null").", "; @@ -586,15 +589,11 @@ class ActionComm extends CommonObject { $this->db->commit(); return $this->id; - } - else - { + } else { $this->db->rollback(); return -1; } - } - else - { + } else { $this->db->rollback(); $this->error = $this->db->lasterror(); return -1; @@ -658,9 +657,7 @@ class ActionComm extends CommonObject { $this->db->commit(); return $this->id; - } - else - { + } else { $this->db->rollback(); return -1; } @@ -680,6 +677,7 @@ class ActionComm extends CommonObject $sql = "SELECT a.id,"; $sql .= " a.id as ref,"; + $sql .= " a.entity,"; $sql .= " a.ref_ext,"; $sql .= " a.datep,"; $sql .= " a.datep2,"; @@ -693,7 +691,7 @@ class ActionComm extends CommonObject $sql .= " a.fk_user_action, a.fk_user_done,"; $sql .= " a.fk_contact, a.percent as percentage,"; $sql .= " a.fk_element as elementid, a.elementtype,"; - $sql .= " a.priority, a.fulldayevent, a.location, a.punctual, a.transparency,"; + $sql .= " a.priority, a.fulldayevent, a.location, a.transparency,"; $sql .= " c.id as type_id, c.code as type_code, c.libelle as type_label, c.color as type_color, c.picto as type_picto,"; $sql .= " s.nom as socname,"; $sql .= " u.firstname, u.lastname as lastname"; @@ -716,6 +714,7 @@ class ActionComm extends CommonObject $obj = $this->db->fetch_object($resql); $this->id = $obj->id; + $this->entity = $obj->entity; $this->ref = $obj->ref; $this->ref_ext = $obj->ref_ext; @@ -757,7 +756,6 @@ class ActionComm extends CommonObject $this->fulldayevent = $obj->fulldayevent; $this->location = $obj->location; $this->transparency = $obj->transparency; - $this->punctual = $obj->punctual; // deprecated $this->socid = $obj->fk_soc; // To have fetch_thirdparty method working $this->contactid = $obj->fk_contact; // To have fetch_contact method working @@ -773,9 +771,7 @@ class ActionComm extends CommonObject $this->fetchResources(); } $this->db->free($resql); - } - else - { + } else { $this->error = $this->db->lasterror(); return -1; } @@ -820,9 +816,7 @@ class ActionComm extends CommonObject } return 1; - } - else - { + } else { dol_print_error($this->db); return -1; } @@ -875,9 +869,7 @@ class ActionComm extends CommonObject } return 1; - } - else - { + } else { dol_print_error($this->db); return -1; } @@ -959,15 +951,11 @@ class ActionComm extends CommonObject { $this->db->commit(); return 1; - } - else - { + } else { $this->db->rollback(); return -2; } - } - else - { + } else { $this->db->rollback(); $this->error = $this->db->lasterror(); return -1; @@ -1113,16 +1101,12 @@ class ActionComm extends CommonObject { $this->db->commit(); return 1; - } - else - { + } else { $this->db->rollback(); dol_syslog(get_class($this)."::update ".join(',', $this->errors), LOG_ERR); return -2; } - } - else - { + } else { $this->db->rollback(); $this->error = $this->db->lasterror(); return -1; @@ -1181,9 +1165,7 @@ class ActionComm extends CommonObject } $db->free($resql); return $resarray; - } - else - { + } else { return $db->lasterror(); } } @@ -1242,9 +1224,7 @@ class ActionComm extends CommonObject $this->db->free($resql); if (empty($load_state_board)) return $response; else return 1; - } - else - { + } else { dol_print_error($this->db); $this->error = $this->db->error(); return -1; @@ -1294,9 +1274,7 @@ class ActionComm extends CommonObject if (!empty($obj->fk_user_mod)) $this->date_modification = $this->db->jdate($obj->datem); } $this->db->free($result); - } - else - { + } else { dol_print_error($this->db); } } @@ -1425,16 +1403,14 @@ class ActionComm extends CommonObject $reshook=$hookmanager->executeHooks('getnomurltooltip',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks $linkclose = ($hookmanager->resPrint ? $hookmanager->resPrint : $linkclose); */ - } - else $linkclose .= ' class="'.$classname.'"'; + } else $linkclose .= ' class="'.$classname.'"'; $url = ''; if ($option == 'birthday') $url = DOL_URL_ROOT.'/contact/perso.php?id='.$this->id; elseif ($option == 'holiday') $url = DOL_URL_ROOT.'/holiday/card.php?id='.$this->id; - else - $url = DOL_URL_ROOT.'/comm/action/card.php?id='.$this->id; + else $url = DOL_URL_ROOT.'/comm/action/card.php?id='.$this->id; if ($option !== 'nolink') { // Add param to save lastsearch_values or not @@ -1457,9 +1433,7 @@ class ActionComm extends CommonObject $libelle = $label; if (!empty($conf->global->AGENDA_USE_EVENT_TYPE)) $libelle = $labeltype; $libelleshort = ''; - } - else - { + } else { $libelle = (empty($this->libelle) ? $label : $this->libelle.(($label && $label != $this->libelle) ? ' '.$label : '')); if (!empty($conf->global->AGENDA_USE_EVENT_TYPE) && empty($libelle)) $libelle = $labeltype; if ($maxlength < 0) $libelleshort = $this->ref; @@ -1611,7 +1585,7 @@ class ActionComm extends CommonObject $sql .= " a.fk_user_action,"; $sql .= " a.fk_contact, a.percent as percentage,"; $sql .= " a.fk_element, a.elementtype,"; - $sql .= " a.priority, a.fulldayevent, a.location, a.punctual, a.transparency,"; + $sql .= " a.priority, a.fulldayevent, a.location, a.transparency,"; $sql .= " u.firstname, u.lastname, u.email,"; $sql .= " s.nom as socname,"; $sql .= " c.id as type_id, c.code as type_code, c.libelle as type_label"; @@ -1700,9 +1674,7 @@ class ActionComm extends CommonObject { $dateend = $this->db->jdate($obj->datep2) - (empty($conf->global->AGENDA_EXPORT_FIX_TZ) ? 0 : ($conf->global->AGENDA_EXPORT_FIX_TZ * 3600)); - } - else - { + } else { // use start date as fall-back to avoid import erros on empty end date $dateend = $datestart; } @@ -1718,7 +1690,6 @@ class ActionComm extends CommonObject $event['fulldayevent'] = $obj->fulldayevent; $event['location'] = $obj->location; $event['transparency'] = (($obj->transparency > 0) ? 'OPAQUE' : 'TRANSPARENT'); // OPAQUE (busy) or TRANSPARENT (not busy) - $event['punctual'] = $obj->punctual; $event['category'] = $obj->type_label; $event['email'] = $obj->email; // Define $urlwithroot @@ -1759,9 +1730,7 @@ class ActionComm extends CommonObject { $eventarray = $hookmanager->resArray; } - } - else - { + } else { $this->error = $this->db->lasterror(); return -1; } @@ -1794,16 +1763,13 @@ class ActionComm extends CommonObject $timestampStart = dol_stringtotime($obj->date_start." 00:00:00", 0); $timestampEnd = dol_stringtotime($obj->date_end." 12:00:00", 0); - } - elseif ($obj->halfday == 1) + } elseif ($obj->halfday == 1) { $event['fulldayevent'] = false; $timestampStart = dol_stringtotime($obj->date_start." 12:00:00", 0); $timestampEnd = dol_stringtotime($obj->date_end." 23:59:59", 0); - } - else - { + } else { $event['fulldayevent'] = true; $timestampStart = dol_stringtotime($obj->date_start." 00:00:00", 0); @@ -1837,9 +1803,7 @@ class ActionComm extends CommonObject { // 2 = leave wait for approval $event['summary'] = $title." - ".$obj->lastname." (wait for approval)"; - } - else - { + } else { // 3 = leave approved $event['summary'] = $title." - ".$obj->lastname; } @@ -1864,9 +1828,7 @@ class ActionComm extends CommonObject $title = 'Dolibarr actions '.$mysoc->name.' - '.$more; $desc = $more; $desc .= ' ('.$mysoc->name.' - built by Dolibarr)'; - } - else - { + } else { $title = 'Dolibarr actions '.$mysoc->name; $desc = $langs->transnoentities('ListOfActions'); $desc .= ' ('.$mysoc->name.' - built by Dolibarr)'; @@ -1884,16 +1846,13 @@ class ActionComm extends CommonObject if ($result >= 0) { if (dol_move($outputfiletmp, $outputfile, 0, 1)) $result = 1; - else - { + else { $this->error = 'Failed to rename '.$outputfiletmp.' into '.$outputfile; dol_syslog(get_class($this)."::build_exportfile ".$this->error, LOG_ERR); dol_delete_file($outputfiletmp, 0, 1); $result = -1; } - } - else - { + } else { dol_syslog(get_class($this)."::build_exportfile build_xxxfile function fails to for format=".$format." outputfiletmp=".$outputfile, LOG_ERR); dol_delete_file($outputfiletmp, 0, 1); $langs->load("errors"); @@ -1928,11 +1887,7 @@ class ActionComm extends CommonObject $this->datem = $now; $this->datep = $now; $this->datef = $now; - $this->author = $user; - $this->usermod = $user; - $this->usertodo = $user; $this->fulldayevent = 0; - $this->punctual = 0; $this->percentage = 0; $this->location = 'Location'; $this->transparency = 1; // 1 means opaque @@ -2020,4 +1975,30 @@ class ActionComm extends CommonObject return $error; } + + /** + * Udpate the percent value of a event with the given id + * + * @param int $id The id of the event + * @param int $percent The new percent value for the event + * @return int 1 when update of the event was suscessfull, otherwise -1 + */ + public function updatePercent($id, $percent) + { + $this->db->begin(); + + $sql = "UPDATE ".MAIN_DB_PREFIX."actioncomm "; + $sql .= " SET percent = ".(int) $percent; + $sql .= " WHERE id=".$id; + + if ($this->db->query($sql)) + { + $this->db->commit(); + return 1; + } else { + $this->db->rollback(); + $this->error = $this->db->lasterror(); + return -1; + } + } } diff --git a/htdocs/comm/action/class/actioncommreminder.class.php b/htdocs/comm/action/class/actioncommreminder.class.php index f987d551766..d3f4fb3f238 100644 --- a/htdocs/comm/action/class/actioncommreminder.class.php +++ b/htdocs/comm/action/class/actioncommreminder.class.php @@ -200,28 +200,23 @@ class ActionCommReminder extends CommonObject { if ($status == 1) return $langs->trans('Done'); elseif ($status == 0) return $langs->trans('ToDo'); - } - elseif ($mode == 2) + } elseif ($mode == 2) { if ($status == 1) return img_picto($langs->trans('Done'), 'statut4').' '.$langs->trans('Done'); elseif ($status == 0) return img_picto($langs->trans('ToDo'), 'statut5').' '.$langs->trans('ToDo'); - } - elseif ($mode == 3) + } elseif ($mode == 3) { if ($status == 1) return img_picto($langs->trans('Done'), 'statut4'); elseif ($status == 0) return img_picto($langs->trans('ToDo'), 'statut5'); - } - elseif ($mode == 4) + } elseif ($mode == 4) { if ($status == 1) return img_picto($langs->trans('Done'), 'statut4').' '.$langs->trans('Done'); elseif ($status == 0) return img_picto($langs->trans('ToDo'), 'statut5').' '.$langs->trans('ToDo'); - } - elseif ($mode == 5) + } elseif ($mode == 5) { if ($status == 1) return $langs->trans('Done').' '.img_picto($langs->trans('Done'), 'statut4'); elseif ($status == 0) return $langs->trans('ToDo').' '.img_picto($langs->trans('ToDo'), 'statut5'); - } - elseif ($mode == 6) + } elseif ($mode == 6) { if ($status == 1) return $langs->trans('Done').' '.img_picto($langs->trans('Done'), 'statut4'); elseif ($status == 0) return $langs->trans('ToDo').' '.img_picto($langs->trans('ToDo'), 'statut5'); diff --git a/htdocs/comm/action/class/api_agendaevents.class.php b/htdocs/comm/action/class/api_agendaevents.class.php index a8cb6b5de8f..20b88dd73d7 100644 --- a/htdocs/comm/action/class/api_agendaevents.class.php +++ b/htdocs/comm/action/class/api_agendaevents.class.php @@ -175,8 +175,7 @@ class AgendaEvents extends DolibarrApi } $i++; } - } - else { + } else { throw new RestException(503, 'Error when retrieve Agenda Event list : '.$db->lasterror()); } if (!count($obj_ret)) { diff --git a/htdocs/comm/action/class/cactioncomm.class.php b/htdocs/comm/action/class/cactioncomm.class.php index c8041c4ea16..147a6ff7ef0 100644 --- a/htdocs/comm/action/class/cactioncomm.class.php +++ b/htdocs/comm/action/class/cactioncomm.class.php @@ -104,15 +104,11 @@ class CActionComm $this->db->free($resql); return 1; - } - else - { + } else { $this->db->free($resql); return 0; } - } - else - { + } else { $this->error = $this->db->error(); return -1; } @@ -208,9 +204,7 @@ class CActionComm if ($idorcode == 'id') $this->liste_array = $repid; if ($idorcode == 'code') $this->liste_array = $repcode; return $this->liste_array; - } - else - { + } else { $this->error = $this->db->lasterror(); return -1; } diff --git a/htdocs/comm/action/class/ical.class.php b/htdocs/comm/action/class/ical.class.php index e985b8ea09e..b806dde94f9 100644 --- a/htdocs/comm/action/class/ical.class.php +++ b/htdocs/comm/action/class/ical.class.php @@ -179,16 +179,13 @@ class ICal $tmpkey = ''; $tmpvalue = ''; } - } - elseif (preg_match('/^ENCODING=QUOTED-PRINTABLE:/i', $value)) + } elseif (preg_match('/^ENCODING=QUOTED-PRINTABLE:/i', $value)) { if (preg_match('/=$/', $value)) { $tmpkey = $key; $tmpvalue = $tmpvalue.preg_replace('/=$/', "", $value); // We must wait to have next line to have complete message - } - else - { + } else { $value = quotedPrintDecode(preg_replace('/^ENCODING=QUOTED-PRINTABLE:/i', '', $tmpvalue.$value)); } } //$value=quotedPrintDecode($tmpvalue.$value); @@ -236,9 +233,7 @@ class ICal if (stristr($key, "DTSTART;VALUE=DATE") || stristr($key, "DTEND;VALUE=DATE")) { list($key, $value) = array($key, $value); - } - else - { + } else { list($key, $value) = $this->ical_dt_date($key, $value); } } @@ -377,9 +372,7 @@ class ICal { usort($temp, array(&$this, "ical_dtstart_compare")); return $temp; - } - else - { + } else { return false; } } diff --git a/htdocs/comm/action/document.php b/htdocs/comm/action/document.php index 9e770f70a93..fa4387b0861 100644 --- a/htdocs/comm/action/document.php +++ b/htdocs/comm/action/document.php @@ -215,9 +215,7 @@ if ($object->id > 0) } } $_SESSION['assignedtouser'] = json_encode($listofuserid); - } - else - { + } else { if (!empty($_SESSION['assignedtouser'])) { $listofuserid = json_decode($_SESSION['assignedtouser'], true); @@ -263,9 +261,7 @@ if ($object->id > 0) $permission = $user->rights->agenda->myactions->create || $user->rights->agenda->allactions->create; $param = '&id='.$object->id; include_once DOL_DOCUMENT_ROOT.'/core/tpl/document_actions_post_headers.tpl.php'; -} -else -{ +} else { print $langs->trans("ErrorUnknown"); } diff --git a/htdocs/comm/action/index.php b/htdocs/comm/action/index.php index b480586bc6a..e0ded511928 100644 --- a/htdocs/comm/action/index.php +++ b/htdocs/comm/action/index.php @@ -95,9 +95,7 @@ if (GETPOST('search_actioncode', 'array')) { $actioncode = GETPOST('search_actioncode', 'array', 3); if (!count($actioncode)) $actioncode = '0'; -} -else -{ +} else { $actioncode = GETPOST("search_actioncode", "alpha", 3) ?GETPOST("search_actioncode", "alpha", 3) : (GETPOST("search_actioncode") == '0' ? '0' : (empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE) ? '' : $conf->global->AGENDA_DEFAULT_FILTER_TYPE)); } if ($actioncode == '' && empty($actioncodearray)) $actioncode = (empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE) ? '' : $conf->global->AGENDA_DEFAULT_FILTER_TYPE); @@ -460,13 +458,11 @@ if (!empty($conf->use_javascript_ajax)) // If javascript on if (empty($reshook)) { $s .= $hookmanager->resPrint; - } - elseif ($reshook > 1) + } elseif ($reshook > 1) { $s = $hookmanager->resPrint; } -} -else // If javascript off +} else // If javascript off { $newparam = $param; // newparam is for birthday links $newparam = preg_replace('/showbirthday=[0-1]/i', 'showbirthday='.(empty($showbirthday) ? 1 : 0), $newparam); @@ -512,24 +508,18 @@ if (!empty($actioncode)) { if ($actioncode == 'AC_NON_AUTO') $sql .= " AND ca.type != 'systemauto'"; elseif ($actioncode == 'AC_ALL_AUTO') $sql .= " AND ca.type = 'systemauto'"; - else - { + else { if ($actioncode == 'AC_OTH') $sql .= " AND ca.type != 'systemauto'"; if ($actioncode == 'AC_OTH_AUTO') $sql .= " AND ca.type = 'systemauto'"; } - } - else - { + } else { if ($actioncode == 'AC_NON_AUTO') $sql .= " AND ca.type != 'systemauto'"; elseif ($actioncode == 'AC_ALL_AUTO') $sql .= " AND ca.type = 'systemauto'"; - else - { + else { if (is_array($actioncode)) { $sql .= " AND ca.code IN ('".implode("','", $actioncode)."')"; - } - else - { + } else { $sql .= " AND ca.code IN ('".implode("','", explode(',', $actioncode))."')"; } } @@ -553,9 +543,7 @@ if ($action == 'show_day') $sql .= " (a.datep < '".$db->idate(dol_mktime(0, 0, 0, $month, $day, $year))."'"; $sql .= " AND a.datep2 > '".$db->idate(dol_mktime(23, 59, 59, $month, $day, $year))."')"; $sql .= ')'; -} -else -{ +} else { // To limit array $sql .= " AND ("; $sql .= " (a.datep BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $month, 1, $year) - (60 * 60 * 24 * 7))."'"; // Start 7 days before @@ -651,9 +639,7 @@ if ($resql) $event->date_start_in_calendar >= $lastdaytoshow) { // This record is out of visible range - } - else - { + } else { if ($event->date_start_in_calendar < $firstdaytoshow) $event->date_start_in_calendar = $firstdaytoshow; if ($event->date_end_in_calendar >= $lastdaytoshow) $event->date_end_in_calendar = ($lastdaytoshow - 1); @@ -666,8 +652,7 @@ if ($resql) // Loop on each day covered by action to prepare an index to show on calendar $loop = true; $j = 0; $daykey = dol_mktime(0, 0, 0, $mois, $jour, $annee); - do - { + do { //if ($event->id==408) print 'daykey='.$daykey.' '.$event->datep.' '.$event->datef.'
'; $eventarray[$daykey][] = $event; @@ -675,17 +660,14 @@ if ($resql) $daykey += 60 * 60 * 24; if ($daykey > $event->date_end_in_calendar) $loop = false; - } - while ($loop); + } while ($loop); //print 'Event '.$i.' id='.$event->id.' (start='.dol_print_date($event->datep).'-end='.dol_print_date($event->datef); //print ' startincalendar='.dol_print_date($event->date_start_in_calendar).'-endincalendar='.dol_print_date($event->date_end_in_calendar).') was added in '.$j.' different index key of array
'; } $i++; } -} -else -{ +} else { dol_print_error($db); } @@ -701,9 +683,7 @@ if ($showbirthday) { $sql .= ' AND MONTH(birthday) = '.$month; $sql .= ' AND DAY(birthday) = '.$day; - } - else - { + } else { $sql .= ' AND MONTH(birthday) = '.$month; } $sql .= ' ORDER BY birthday'; @@ -741,18 +721,14 @@ if ($showbirthday) $loop = true; $daykey = dol_mktime(0, 0, 0, $mois, $jour, $annee); - do - { + do { $eventarray[$daykey][] = $event; $daykey += 60 * 60 * 24; if ($daykey > $event->date_end_in_calendar) $loop = false; - } - while ($loop); + } while ($loop); $i++; } - } - else - { + } else { dol_print_error($db); } } @@ -769,12 +745,10 @@ if ($conf->global->AGENDA_SHOW_HOLIDAYS) { // Request only leaves for the current selected day $sql .= " AND '".$year."-".$month."-".$day."' BETWEEN x.date_debut AND x.date_fin"; - } - elseif ($action == 'show_week') + } elseif ($action == 'show_week') { // TODO: Add filter to reduce database request - } - elseif ($action == 'show_month') + } elseif ($action == 'show_month') { // TODO: Add filter to reduce database request } @@ -807,8 +781,7 @@ if ($conf->global->AGENDA_SHOW_HOLIDAYS) { // Show no symbol for leave with state "leave approved" $event->percentage = -1; - } - elseif ($obj->status == 2) + } elseif ($obj->status == 2) { // Show TO-DO symbol for leave with state "leave wait for approval" $event->percentage = 0; @@ -817,13 +790,10 @@ if ($conf->global->AGENDA_SHOW_HOLIDAYS) if ($obj->halfday == 1) { $event->label = $obj->lastname.' ('.$langs->trans("Morning").')'; - } - elseif ($obj->halfday == -1) + } elseif ($obj->halfday == -1) { $event->label = $obj->lastname.' ('.$langs->trans("Afternoon").')'; - } - else - { + } else { $event->label = $obj->lastname; } @@ -832,14 +802,11 @@ if ($conf->global->AGENDA_SHOW_HOLIDAYS) $jour = date('d', $event->date_start_in_calendar); $daykey = dol_mktime(0, 0, 0, $mois, $jour, $annee); - do - { + do { $eventarray[$daykey][] = $event; $daykey += 60 * 60 * 24; - } - - while ($daykey <= $event->date_end_in_calendar); + } while ($daykey <= $event->date_end_in_calendar); $i++; } @@ -881,8 +848,7 @@ if (count($listofextcals)) { $datecurstart = dol_stringtotime($icalevent['DTSTART;VALUE=DATE'], 1); $datecurend = dol_stringtotime($icalevent['DTEND;VALUE=DATE'], 1) - 1; // We remove one second to get last second of day - } - elseif (is_array($icalevent['DTSTART']) && !empty($icalevent['DTSTART']['unixtime'])) + } elseif (is_array($icalevent['DTSTART']) && !empty($icalevent['DTSTART']['unixtime'])) { $datecurstart = $icalevent['DTSTART']['unixtime']; $datecurend = $icalevent['DTEND']['unixtime']; @@ -902,9 +868,7 @@ if (count($listofextcals)) } // datecurstart and datecurend are now GMT date //var_dump($datecurstart); var_dump($datecurend); exit; - } - else - { + } else { // Not a recongized record dol_syslog("Found a not recognized repeatable record with unknown date start", LOG_ERR); continue; @@ -928,9 +892,7 @@ if (count($listofextcals)) { $newevent['DTSTART;VALUE=DATE'] = dol_print_date($datecurstart, '%Y%m%d'); $newevent['DTEND;VALUE=DATE'] = dol_print_date($datecurend + 1, '%Y%m%d'); - } - else - { + } else { $newevent['DTSTART'] = $datecurstart; $newevent['DTEND'] = $datecurend; } @@ -948,13 +910,11 @@ if (count($listofextcals)) { $datecurstart = dol_time_plus_duree($datecurstart, $interval, 'w'); $datecurend = dol_time_plus_duree($datecurend, $interval, 'w'); - } - elseif ($icalevent['RRULE']['FREQ'] == 'MONTHLY') + } elseif ($icalevent['RRULE']['FREQ'] == 'MONTHLY') { $datecurstart = dol_time_plus_duree($datecurstart, $interval, 'm'); $datecurend = dol_time_plus_duree($datecurend, $interval, 'm'); - } - elseif ($icalevent['RRULE']['FREQ'] == 'YEARLY') + } elseif ($icalevent['RRULE']['FREQ'] == 'YEARLY') { $datecurstart = dol_time_plus_duree($datecurstart, $interval, 'y'); $datecurend = dol_time_plus_duree($datecurend, $interval, 'y'); @@ -991,8 +951,7 @@ if (count($listofextcals)) //print dol_print_date($dateend,'dayhour','gmt'); $event->fulldayevent = 1; $addevent = true; - } - elseif (!is_array($icalevent['DTSTART'])) // not fullday event (DTSTART is not array. It is a value like '19700101T000000Z' for 00:00 in greenwitch) + } elseif (!is_array($icalevent['DTSTART'])) // not fullday event (DTSTART is not array. It is a value like '19700101T000000Z' for 00:00 in greenwitch) { $datestart = $icalevent['DTSTART']; $dateend = $icalevent['DTEND']; @@ -1003,8 +962,7 @@ if (count($listofextcals)) $addevent = true; //var_dump($offsettz); //var_dump(dol_print_date($datestart, 'dayhour', 'gmt')); - } - elseif (isset($icalevent['DTSTART']['unixtime'])) // File contains a local timezone + a TZ (for example when using bluemind) + } elseif (isset($icalevent['DTSTART']['unixtime'])) // File contains a local timezone + a TZ (for example when using bluemind) { $datestart = $icalevent['DTSTART']['unixtime']; $dateend = $icalevent['DTEND']['unixtime']; @@ -1066,9 +1024,7 @@ if (count($listofextcals)) //print 'x'.$datestart.'-'.$dateend;exit; //print 'x'.$datestart.'-'.$dateend;exit; // This record is out of visible range - } - else - { + } else { if ($event->date_start_in_calendar < $firstdaytoshow) $event->date_start_in_calendar = $firstdaytoshow; if ($event->date_end_in_calendar >= $lastdaytoshow) $event->date_end_in_calendar = ($lastdaytoshow - 1); @@ -1083,14 +1039,12 @@ if (count($listofextcals)) // daykey must be date that represent day box in calendar so must be a user time $daykey = dol_mktime(0, 0, 0, $mois, $jour, $annee); $daykeygmt = dol_mktime(0, 0, 0, $mois, $jour, $annee, true, 0); - do - { + do { //if ($event->fulldayevent) print dol_print_date($daykeygmt,'dayhour','gmt').'-'.dol_print_date($daykey,'dayhour','gmt').'-'.dol_print_date($event->date_end_in_calendar,'dayhour','gmt').' '; $eventarray[$daykey][] = $event; $daykey += 60 * 60 * 24; $daykeygmt += 60 * 60 * 24; // Add one day if (($event->fulldayevent ? $daykeygmt : $daykey) > $event->date_end_in_calendar) $loop = false; - } - while ($loop); + } while ($loop); } } } @@ -1159,8 +1113,7 @@ if (empty($action) || $action == 'show_month') // View by month { $labelshort = array(0=>'SundayMin', 1=>'MondayMin', 2=>'TuesdayMin', 3=>'WednesdayMin', 4=>'ThursdayMin', 5=>'FridayMin', 6=>'SaturdayMin'); print $langs->trans($labelshort[$numdayinweek]); - } - else print $langs->trans("Day".$numdayinweek); + } else print $langs->trans("Day".$numdayinweek); print ' '."\n"; $i++; } @@ -1171,23 +1124,18 @@ if (empty($action) || $action == 'show_month') // View by month // In loops, tmpday contains day nb in current month (can be zero or negative for days of previous month) //var_dump($eventarray); - for ($iter_week = 0; $iter_week < 6; $iter_week++) - { + for ($iter_week = 0; $iter_week < 6; $iter_week++) { echo " \n"; - for ($iter_day = 0; $iter_day < 7; $iter_day++) - { - /* Show days before the beginning of the current month (previous month) */ - if ($tmpday <= 0) - { + for ($iter_day = 0; $iter_day < 7; $iter_day++) { + if ($tmpday <= 0) { + /* Show days before the beginning of the current month (previous month) */ $style = 'cal_other_month cal_past'; - if ($iter_day == 6) $style .= ' cal_other_month_right'; + if ($iter_day == 6) $style .= ' cal_other_month_right'; echo ' '; show_day_events($db, $max_day_in_prev_month + $tmpday, $prev_month, $prev_year, $month, $style, $eventarray, $maxprint, $maxnbofchar, $newparam); echo " \n"; - } - /* Show days of the current month */ - elseif ($tmpday <= $max_day_in_month) - { + } elseif ($tmpday <= $max_day_in_month) { + /* Show days of the current month */ $curtime = dol_mktime(0, 0, 0, $month, $tmpday, $year); $style = 'cal_current_month'; if ($iter_day == 6) $style .= ' cal_current_month_right'; @@ -1199,10 +1147,8 @@ if (empty($action) || $action == 'show_month') // View by month echo ' '; show_day_events($db, $tmpday, $month, $year, $month, $style, $eventarray, $maxprint, $maxnbofchar, $newparam); echo " \n"; - } - /* Show days after the current month (next month) */ - else - { + } else { + /* Show days after the current month (next month) */ $style = 'cal_other_month'; if ($iter_day == 6) $style .= ' cal_other_month_right'; echo ' '; @@ -1219,9 +1165,8 @@ if (empty($action) || $action == 'show_month') // View by month print ''; print ''; print ''; -} -elseif ($action == 'show_week') // View by week -{ +} elseif ($action == 'show_week') { + // View by week $newparam = $param; // newparam is for birthday links $newparam = preg_replace('/showbirthday=/i', 'showbirthday_=', $newparam); // To avoid replacement when replace day= is done $newparam = preg_replace('/action=show_month&?/i', '', $newparam); @@ -1237,8 +1182,7 @@ elseif ($action == 'show_week') // View by week print ''; print ' '; $i = 0; - while ($i < 7) - { + while ($i < 7) { echo ' \n"; $i++; } @@ -1246,8 +1190,7 @@ elseif ($action == 'show_week') // View by week echo " \n"; - for ($iter_day = 0; $iter_day < 7; $iter_day++) - { + for ($iter_day = 0; $iter_day < 7; $iter_day++) { // Show days of the current week $curtime = dol_time_plus_duree($firstdaytoshow, $iter_day, 'd'); $tmparray = dol_getdate($curtime, true); @@ -1274,8 +1217,7 @@ elseif ($action == 'show_week') // View by week echo ''; echo ''; echo ''; -} -else // View by day +} else // View by day { $newparam = $param; // newparam is for birthday links $newparam = preg_replace('/action=show_month&?/i', '', $newparam); @@ -1349,9 +1291,7 @@ else // View by day show_day_events($db, $day, $month, $year, $month, $style, $eventarray, 0, $maxnbofchar, $newparam, 1, 300, 1); print ''; - } - else - { + } else { print '
'; // You can use div-table-responsive-no-min if you dont need reserved height for your table show_day_events($db, $day, $month, $year, $month, $style, $eventarray, 0, $maxnbofchar, $newparam, 1, 300, 0); @@ -1472,8 +1412,7 @@ function show_day_events($db, $day, $month, $year, $monthshown, $style, &$eventa // We decide to choose color of owner of event (event->userownerid is user id of owner, event->userassigned contains all users assigned to event) if (!empty($cacheusers[$event->userownerid]->color)) $color = $cacheusers[$event->userownerid]->color; - } - elseif ($event->type_code == 'ICALEVENT') // Event come from external ical file + } elseif ($event->type_code == 'ICALEVENT') // Event come from external ical file { $numical++; if (!empty($event->icalname)) { @@ -1485,13 +1424,10 @@ function show_day_events($db, $day, $month, $year, $monthshown, $style, &$eventa $color = ($event->icalcolor ? $event->icalcolor : -1); $cssclass = (!empty($event->icalname) ? 'family_ext'.md5($event->icalname) : 'family_other'); - } - elseif ($event->type_code == 'BIRTHDAY') + } elseif ($event->type_code == 'BIRTHDAY') { $numbirthday++; $colorindex = 2; $cssclass = 'family_birthday unmovable'; $color = sprintf("%02x%02x%02x", $theme_datacolor[$colorindex][0], $theme_datacolor[$colorindex][1], $theme_datacolor[$colorindex][2]); - } - else - { + } else { $numother++; $color = ($event->icalcolor ? $event->icalcolor : -1); $cssclass = (!empty($event->icalname) ? 'family_ext'.md5($event->icalname) : 'family_other'); @@ -1515,9 +1451,7 @@ function show_day_events($db, $day, $month, $year, $monthshown, $style, &$eventa if (isset($colorindexused[$idusertouse])) { $colorindex = $colorindexused[$idusertouse]; // Color already assigned to this user - } - else - { + } else { $colorindex = $nextindextouse; $colorindexused[$idusertouse] = $colorindex; if (!empty($theme_datacolor[$nextindextouse + 1])) $nextindextouse++; // Prepare to use next color @@ -1532,8 +1466,7 @@ function show_day_events($db, $day, $month, $year, $monthshown, $style, &$eventa if ($event->type_code == 'AC_OTH_AUTO') { $cssclass .= " unmovable"; - } - elseif ($event->type_code == 'ICALEVENT') + } elseif ($event->type_code == 'ICALEVENT') { $cssclass .= " unmovable"; } elseif ($event->date_end_in_calendar && date('Ymd', $event->date_start_in_calendar) != date('Ymd', $event->date_end_in_calendar)) { @@ -1544,8 +1477,7 @@ function show_day_events($db, $day, $month, $year, $monthshown, $style, &$eventa { $cssclass .= " unmovable"; } - } - else { + } else { if ($user->rights->agenda->allactions->create || (($event->authorid == $user->id || $event->userownerid == $user->id) && $user->rights->agenda->myactions->create)) { @@ -1579,9 +1511,7 @@ function show_day_events($db, $day, $month, $year, $monthshown, $style, &$eventa if (empty($event->transparency) && empty($conf->global->AGENDA_NO_TRANSPARENT_ON_NOT_BUSY)) { print 'border: 2px solid #'.$colortouse.';'; - } - else - { + } else { print 'background: #'.$colortouse.';'; print 'background: -webkit-gradient(linear, left top, left bottom, from(#'.dol_color_minus($colortouse, -3).'), to(#'.dol_color_minus($colortouse, -1).'));'; } @@ -1600,12 +1530,10 @@ function show_day_events($db, $day, $month, $year, $monthshown, $style, &$eventa if ($event->type_code == 'BIRTHDAY') // It's a birthday { print $event->getNomUrl(1, $maxnbofchar, 'cal_event', 'birthday', 'contact'); - } - elseif ($event->type_code == 'HOLIDAY') + } elseif ($event->type_code == 'HOLIDAY') { print $event->getNomUrl(1, $maxnbofchar, 'cal_event', 'holiday', 'user'); - } - elseif ($event->type_code != 'BIRTHDAY' && $event->type_code != 'HOLIDAY') + } elseif ($event->type_code != 'BIRTHDAY' && $event->type_code != 'HOLIDAY') { // Picto if (empty($event->fulldayevent)) @@ -1648,9 +1576,7 @@ function show_day_events($db, $day, $month, $year, $monthshown, $style, &$eventa if ($tmpyearend == $annee && $tmpmonthend == $mois && $tmpdayend == $jour) $daterange .= dol_print_date($event->date_end_in_calendar, '%H:%M'); // Il faudrait utiliser ici tzuser, mais si on ne peut pas car qd on rentre un date dans fiche action, en input la conversion local->gmt se base sur le TZ server et non user } - } - else - { + } else { if ($showinfo) { print $langs->trans("EventOnFullDay")."
\n"; @@ -1705,8 +1631,7 @@ function show_day_events($db, $day, $month, $year, $monthshown, $style, &$eventa $thirdparty = new Societe($db); $thirdparty->fetch($thirdparty_id); $cachethirdparties[$thirdparty_id] = $thirdparty; - } - else $thirdparty = $cachethirdparties[$thirdparty_id]; + } else $thirdparty = $cachethirdparties[$thirdparty_id]; if (!empty($thirdparty->id)) $linerelatedto .= $thirdparty->getNomUrl(1, '', 0); } if (!empty($contact_id) && $contact_id > 0) @@ -1716,8 +1641,7 @@ function show_day_events($db, $day, $month, $year, $monthshown, $style, &$eventa $contact = new Contact($db); $contact->fetch($contact_id); $cachecontacts[$contact_id] = $contact; - } - else $contact = $cachecontacts[$contact_id]; + } else $contact = $cachecontacts[$contact_id]; if ($linerelatedto) $linerelatedto .= ' '; if (!empty($contact->id)) $linerelatedto .= $contact->getNomUrl(1, '', 0); } @@ -1754,9 +1678,7 @@ function show_day_events($db, $day, $month, $year, $monthshown, $style, &$eventa print '
'.$langs->trans("Day".(($i + (isset($conf->global->MAIN_START_WEEK) ? $conf->global->MAIN_START_WEEK : 1)) % 7))."
'; print '
'."\n"; $i++; - } - else - { + } else { print 'global->AGENDA_DEFAULT_FILTER_TYPE) ? '' : $conf->global->AGENDA_DEFAULT_FILTER_TYPE)); } if ($actioncode == '' && empty($actioncodearray)) $actioncode = (empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE) ? '' : $conf->global->AGENDA_DEFAULT_FILTER_TYPE); @@ -185,9 +187,42 @@ if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x' $datestart = ''; $dateend = ''; $search_status = ''; + $toselect = ''; $search_array_options = array(); } +if (empty($reshook) && !empty($massaction)) +{ + unset($percent); + + switch ($massaction) + { + case 'set_all_events_to_todo': + $percent = ActionComm::EVENT_TODO; + break; + + case 'set_all_events_to_in_progress': + $percent = ActionComm::EVENT_IN_PROGRESS; + break; + + case 'set_all_events_to_finished': + $percent = ActionComm::EVENT_FINISHED; + break; + } + + if (isset($percent)) + { + foreach ($toselect as $toselectid) + { + $result = $object->updatePercent($toselectid, $percent); + if ($result < 0) + { + dol_print_error($db); + break; + } + } + } +} /* * View @@ -239,10 +274,19 @@ if ($optioncss != '') $param .= '&optioncss='.urlencode($optioncss); // Add $param from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; +// List of mass actions available +$arrayofmassactions = array( + 'set_all_events_to_todo' => $langs->trans("SetAllEventsToTodo"), + 'set_all_events_to_in_progress' => $langs->trans("SetAllEventsToInProgress"), + 'set_all_events_to_finished' => $langs->trans("SetAllEventsToFinished"), +); + +$massactionbutton = $form->selectMassAction('', $arrayofmassactions); + $sql = "SELECT"; if ($usergroup > 0) $sql .= " DISTINCT"; $sql .= " s.nom as societe, s.rowid as socid, s.client, s.email as socemail,"; -$sql .= " a.id, a.label, a.note, a.datep as dp, a.datep2 as dp2, a.fulldayevent, a.location,"; +$sql .= " a.id, a.code, a.label, a.note, a.datep as dp, a.datep2 as dp2, a.fulldayevent, a.location,"; $sql .= ' a.fk_user_author,a.fk_user_action,'; $sql .= " a.fk_contact, a.note, a.percent as percent,"; $sql .= " a.fk_element, a.elementtype, a.datec, a.tms as datem,"; @@ -279,24 +323,18 @@ if (!empty($actioncode)) { if ($actioncode == 'AC_NON_AUTO') $sql .= " AND c.type != 'systemauto'"; elseif ($actioncode == 'AC_ALL_AUTO') $sql .= " AND c.type = 'systemauto'"; - else - { + else { if ($actioncode == 'AC_OTH') $sql .= " AND c.type != 'systemauto'"; if ($actioncode == 'AC_OTH_AUTO') $sql .= " AND c.type = 'systemauto'"; } - } - else - { + } else { if ($actioncode == 'AC_NON_AUTO') $sql .= " AND c.type != 'systemauto'"; elseif ($actioncode == 'AC_ALL_AUTO') $sql .= " AND c.type = 'systemauto'"; - else - { + else { if (is_array($actioncode)) { $sql .= " AND c.code IN ('".implode("','", $actioncode)."')"; - } - else - { + } else { $sql .= " AND c.code IN ('".implode("','", explode(',', $actioncode))."')"; } } @@ -366,6 +404,8 @@ if ($resql) $num = $db->num_rows($resql); + $arrayofselected = is_array($toselect) ? $toselect : array(); + // Local calendar $newtitle = '
'.$langs->trans("LocalAgenda").'  
'; //$newtitle=$langs->trans($title); @@ -385,14 +425,8 @@ if ($resql) print ''; $nav = ''; - //if ($actioncode) $nav.=''; - //if ($resourceid) $nav.=''; if ($filter) $nav .= ''; - //if ($filtert) $nav.=''; - //if ($socid) $nav.=''; if ($showbirthday) $nav .= ''; - //if ($pid) $nav.=''; - //if ($usergroup) $nav.=''; print $nav; dol_fiche_head($head, $tabactive, $langs->trans('Agenda'), 0, 'action'); @@ -424,8 +458,7 @@ if ($resql) if (empty($reshook)) { $s .= $hookmanager->resPrint; - } - elseif ($reshook > 1) + } elseif ($reshook > 1) { $s = $hookmanager->resPrint; } @@ -442,7 +475,7 @@ if ($resql) $newcardbutton .= dolGetButtonTitle($langs->trans('AddAction'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/comm/action/card.php?action=create&datep='.sprintf("%04d%02d%02d", $tmpforcreatebutton['year'], $tmpforcreatebutton['mon'], $tmpforcreatebutton['mday']).$hourminsec.'&backtopage='.urlencode($_SERVER["PHP_SELF"].($newparam ? '?'.$newparam : ''))); } - print_barre_liste($s, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, -1 * $nbtotalofrecords, '', 0, $nav.$newcardbutton, '', $limit, 0, 0, 1); + print_barre_liste($s, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, -1 * $nbtotalofrecords, '', 0, $nav.$newcardbutton, '', $limit, 0, 0, 1); $moreforfilter = ''; @@ -548,6 +581,7 @@ if ($resql) $actionstatic->id = $obj->id; $actionstatic->ref = $obj->id; + $actionstatic->code = $obj->code; $actionstatic->type_code = $obj->type_code; $actionstatic->type_label = $obj->type_label; $actionstatic->type_picto = $obj->type_picto; @@ -574,8 +608,7 @@ if ($resql) { $userstatic->fetch($obj->fk_user_action); print $userstatic->getNomUrl(-1); - } - else print ' '; + } else print ' '; print ''; } @@ -583,21 +616,30 @@ if ($resql) if (!empty($arrayfields['c.libelle']['checked'])) { print ''; + $actioncomm = $actionstatic; + // TODO Code common with code into showactions + $imgpicto = ''; if (!empty($conf->global->AGENDA_USE_EVENT_TYPE)) { - if ($actionstatic->type_picto) print img_picto('', $actionstatic->type_picto); - else { - if ($actionstatic->type_code == 'AC_RDV') print img_picto('', 'object_group', '', false, 0, 0, '', '').' '; - elseif ($actionstatic->type_code == 'AC_TEL') print img_picto('', 'object_phoning', '', false, 0, 0, '', '').' '; - elseif ($actionstatic->type_code == 'AC_FAX') print img_picto('', 'object_phoning_fax', '', false, 0, 0, '', '').' '; - elseif ($actionstatic->type_code == 'AC_EMAIL') print img_picto('', 'object_email', '', false, 0, 0, '', '').' '; - elseif ($actionstatic->type_code == 'AC_INT') print img_picto('', 'object_intervention', '', false, 0, 0, '', '').' '; - elseif (!preg_match('/_AUTO/', $actionstatic->type_code)) print img_picto('', 'object_other', '', false, 0, 0, '', '').' '; - } + if ($actioncomm->type_picto) { + $imgpicto = img_picto('', $actioncomm->type_picto); + } else { + if ($actioncomm->type_code == 'AC_RDV') $imgpicto = img_picto('', 'object_group', '', false, 0, 0, '', 'paddingright').' '; + elseif ($actioncomm->type_code == 'AC_TEL') $imgpicto = img_picto('', 'object_phoning', '', false, 0, 0, '', 'paddingright').' '; + elseif ($actioncomm->type_code == 'AC_FAX') $imgpicto = img_picto('', 'object_phoning_fax', '', false, 0, 0, '', 'paddingright').' '; + elseif ($actioncomm->type_code == 'AC_EMAIL') $imgpicto = img_picto('', 'object_email', '', false, 0, 0, '', 'paddingright').' '; + elseif ($actioncomm->type_code == 'AC_INT') $imgpicto = img_picto('', 'object_intervention', '', false, 0, 0, '', 'paddingright').' '; + elseif ($actioncomm->type_code == 'AC_OTH' && $actioncomm->code == 'TICKET_MSG') $imgpicto = img_picto('', 'object_conversation', '', false, 0, 0, '', 'paddingright').' '; + elseif (!preg_match('/_AUTO/', $actioncomm->type_code)) $imgpicto = img_picto('', 'object_other', '', false, 0, 0, '', 'paddingright').' '; + } } + print $imgpicto; + $labeltype = $obj->type_code; if (empty($conf->global->AGENDA_USE_EVENT_TYPE) && empty($arraylist[$labeltype])) $labeltype = 'AC_OTH'; - if (!empty($arraylist[$labeltype])) $labeltype = $arraylist[$labeltype]; + if ($actioncomm->type_code == 'AC_OTH' && $actioncomm->code == 'TICKET_MSG') { + $labeltype = $langs->trans("Message"); + } elseif (!empty($arraylist[$labeltype])) $labeltype = $arraylist[$labeltype]; print dol_trunc($labeltype, 28); print ''; } @@ -620,7 +662,7 @@ if ($resql) $formatToUse = $obj->fulldayevent ? 'day' : 'dayhour'; // Start date if (!empty($arrayfields['a.datep']['checked'])) { - print ''; + print ''; print dol_print_date($db->jdate($obj->dp), $formatToUse); $late = 0; if ($obj->percent == 0 && $obj->dp && $db->jdate($obj->dp) < ($now - $delay_warning)) $late = 1; @@ -633,7 +675,7 @@ if ($resql) // End date if (!empty($arrayfields['a.datep2']['checked'])) { - print ''; + print ''; print dol_print_date($db->jdate($obj->dp2), $formatToUse); print ''; } @@ -649,8 +691,7 @@ if ($resql) $societestatic->email = $obj->socemail; print $societestatic->getNomUrl(1, '', 28); - } - else print ' '; + } else print ' '; print ''; } @@ -672,8 +713,7 @@ if ($resql) $contactListCache[$socpeopleassigned['id']] = $contact->getNomUrl(1, '', 0); $contactList[] = $contact->getNomUrl(1, '', 0); } - } - else { + } else { // use cache $contactList[] = $contactListCache[$socpeopleassigned['id']]; } @@ -681,8 +721,7 @@ if ($resql) if (!empty($contactList)) { print implode(', ', $contactList); } - } - elseif ($obj->fk_contact > 0) //keep for retrocompatibility with faraway event + } elseif ($obj->fk_contact > 0) //keep for retrocompatibility with faraway event { $contactstatic->id = $obj->fk_contact; $contactstatic->email = $obj->email; @@ -693,9 +732,7 @@ if ($resql) $contactstatic->phone_perso = $obj->phone_perso; $contactstatic->country_id = $obj->country_id; print $contactstatic->getNomUrl(1, '', 0); - } - else - { + } else { print " "; } print ''; @@ -717,7 +754,7 @@ if ($resql) // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; // Fields from hook - $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$obj); + $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray); $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; @@ -735,7 +772,15 @@ if ($resql) $datep = $db->jdate($obj->datep); print ''.$actionstatic->LibStatut($obj->percent, 5, 0, $datep).''; } - print ''; + // Action column + print ''; + if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined + { + $selected = 0; + if (in_array($obj->id, $arrayofselected)) $selected = 1; + print ''; + } + print ''; print "\n"; $i++; @@ -745,9 +790,7 @@ if ($resql) print ''; $db->free($resql); -} -else -{ +} else { dol_print_error($db); } diff --git a/htdocs/comm/action/pertype.php b/htdocs/comm/action/pertype.php index 6dfbc6c7f9c..a769d709c4d 100644 --- a/htdocs/comm/action/pertype.php +++ b/htdocs/comm/action/pertype.php @@ -93,9 +93,7 @@ if (GETPOST('actioncode', 'array')) { $actioncode = GETPOST('actioncode', 'array', 3); if (!count($actioncode)) $actioncode = '0'; -} -else -{ +} else { $actioncode = GETPOST("actioncode", "alpha", 3) ?GETPOST("actioncode", "alpha", 3) : (GETPOST("actioncode", "alpha") == '0' ? '0' : (empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE) ? '' : $conf->global->AGENDA_DEFAULT_FILTER_TYPE)); } if ($actioncode == '' && empty($actioncodearray)) $actioncode = (empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE) ? '' : $conf->global->AGENDA_DEFAULT_FILTER_TYPE); @@ -329,8 +327,7 @@ if ($conf->use_javascript_ajax) if (empty($reshook)) { $s .= $hookmanager->resPrint; - } - elseif ($reshook > 1) + } elseif ($reshook > 1) { $s = $hookmanager->resPrint; } @@ -372,18 +369,14 @@ if (!empty($actioncode)) { if ($actioncode == 'AC_NON_AUTO') $sql .= " AND ca.type != 'systemauto'"; elseif ($actioncode == 'AC_ALL_AUTO') $sql .= " AND ca.type = 'systemauto'"; - else - { + else { if ($actioncode == 'AC_OTH') $sql .= " AND ca.type != 'systemauto'"; if ($actioncode == 'AC_OTH_AUTO') $sql .= " AND ca.type = 'systemauto'"; } - } - else - { + } else { if ($actioncode == 'AC_NON_AUTO') $sql .= " AND ca.type != 'systemauto'"; elseif ($actioncode == 'AC_ALL_AUTO') $sql .= " AND ca.type = 'systemauto'"; - else - { + else { $sql .= " AND ca.code IN ('".implode("','", explode(',', $actioncode))."')"; } } @@ -406,9 +399,7 @@ if ($action == 'show_day') $sql .= " (a.datep < '".$db->idate(dol_mktime(0, 0, 0, $month, $day, $year))."'"; $sql .= " AND a.datep2 > '".$db->idate(dol_mktime(23, 59, 59, $month, $day, $year))."')"; $sql .= ')'; -} -else -{ +} else { // To limit array $sql .= " AND ("; $sql .= " (a.datep BETWEEN '".$db->idate(dol_mktime(0, 0, 0, 1, 1, $year) - (60 * 60 * 24 * 7))."'"; // Start 7 days before @@ -490,9 +481,7 @@ if ($resql) $event->date_start_in_calendar = $datep; if ($datep2 != '' && $datep2 >= $datep) $event->date_end_in_calendar = $datep2; else $event->date_end_in_calendar = $datep; - } - else - { + } else { $event->date_start_in_calendar = $datep; if ($datep2 != '' && $datep2 >= $datep) $event->date_end_in_calendar = $datep2; else $event->date_end_in_calendar = $datep; @@ -509,9 +498,7 @@ if ($resql) { // This record is out of visible range unset($event); - } - else - { + } else { //print $i.' - '.dol_print_date($this->date_start_in_calendar, 'dayhour').' - '.dol_print_date($this->date_end_in_calendar, 'dayhour').'
'."\n"; $event->fetch_userassigned(); // This load $event->userassigned @@ -527,8 +514,7 @@ if ($resql) // Loop on each day covered by action to prepare an index to show on calendar $loop = true; $j = 0; $daykey = dol_mktime(0, 0, 0, $mois, $jour, $annee); - do - { + do { //if ($event->id==408) print 'daykey='.$daykey.' '.$event->datep.' '.$event->datef.'
'; $eventarray[$daykey][] = $event; @@ -536,17 +522,14 @@ if ($resql) $daykey += 60 * 60 * 24; if ($daykey > $event->date_end_in_calendar) $loop = false; - } - while ($loop); + } while ($loop); //print 'Event '.$i.' id='.$event->id.' (start='.dol_print_date($event->datep).'-end='.dol_print_date($event->datef); //print ' startincalendar='.dol_print_date($event->date_start_in_calendar).'-endincalendar='.dol_print_date($event->date_end_in_calendar).') was added in '.$j.' different index key of array
'; } $i++; } -} -else -{ +} else { dol_print_error($db); } @@ -808,8 +791,7 @@ function show_day_events_pertype($username, $day, $month, $year, $monthshown, $s { $nummytasks++; $cssclass = 'family_mytasks'; if (!empty($conf->global->AGENDA_USE_EVENT_TYPE)) $color = $event->type_color; - } - elseif ($event->type_code == 'ICALEVENT') + } elseif ($event->type_code == 'ICALEVENT') { $numical++; if (!empty($event->icalname)) @@ -822,13 +804,10 @@ function show_day_events_pertype($username, $day, $month, $year, $monthshown, $s $color = $event->icalcolor; $cssclass = (!empty($event->icalname) ? 'family_ext'.md5($event->icalname) : 'family_other unsortable'); - } - elseif ($event->type_code == 'BIRTHDAY') + } elseif ($event->type_code == 'BIRTHDAY') { $numbirthday++; $colorindex = 2; $cssclass = 'family_birthday unsortable'; $color = sprintf("%02x%02x%02x", $theme_datacolor[$colorindex][0], $theme_datacolor[$colorindex][1], $theme_datacolor[$colorindex][2]); - } - else - { + } else { $numother++; $cssclass = 'family_other'; if (!empty($conf->global->AGENDA_USE_EVENT_TYPE)) $color = $event->type_color; } @@ -840,9 +819,7 @@ function show_day_events_pertype($username, $day, $month, $year, $monthshown, $s if (isset($colorindexused[$idusertouse])) { $colorindex = $colorindexused[$idusertouse]; // Color already assigned to this user - } - else - { + } else { $colorindex = $nextindextouse; $colorindexused[$idusertouse] = $colorindex; if (!empty($theme_datacolor[$nextindextouse + 1])) $nextindextouse++; // Prepare to use next color @@ -960,9 +937,7 @@ function show_day_events_pertype($username, $day, $month, $year, $monthshown, $s $cases2[$h][$event->id]['string'] .= ', '.$cachecontacts[$event->contactid]->getFullName($langs); } } - } - else - { + } else { $busy = $event->transparency; $cases1[$h][$event->id]['busy'] = $busy; $cases2[$h][$event->id]['busy'] = $busy; @@ -1025,8 +1000,7 @@ function show_day_events_pertype($username, $day, $month, $year, $monthshown, $s $title1 = $langs->trans("Ref").' '.$ids1.($title1 ? ' - '.$title1 : ''); if ($output[0]['string']) $title1 .= ($title1 ? ' - ' : '').$output[0]['string']; if ($output[0]['color']) $color1 = $output[0]['color']; - } - elseif (count($cases1[$h]) > 1) + } elseif (count($cases1[$h]) > 1) { $title1 = $langs->trans("Ref").' '.$ids1.($title1 ? ' - '.$title1 : ''); $color1 = '222222'; @@ -1038,8 +1012,7 @@ function show_day_events_pertype($username, $day, $month, $year, $monthshown, $s $title2 = $langs->trans("Ref").' '.$ids2.($title2 ? ' - '.$title2 : ''); if ($output[0]['string']) $title2 .= ($title2 ? ' - ' : '').$output[0]['string']; if ($output[0]['color']) $color2 = $output[0]['color']; - } - elseif (count($cases2[$h]) > 1) + } elseif (count($cases2[$h]) > 1) { $title2 = $langs->trans("Ref").' '.$ids2.($title2 ? ' - '.$title2 : ''); $color2 = '222222'; diff --git a/htdocs/comm/action/peruser.php b/htdocs/comm/action/peruser.php index f2cce5c8023..ef2c60e5ae6 100644 --- a/htdocs/comm/action/peruser.php +++ b/htdocs/comm/action/peruser.php @@ -94,9 +94,7 @@ if (GETPOST('search_actioncode', 'array')) { $actioncode = GETPOST('search_actioncode', 'array', 3); if (!count($actioncode)) $actioncode = '0'; -} -else -{ +} else { $actioncode = GETPOST("search_actioncode", "alpha", 3) ?GETPOST("search_actioncode", "alpha", 3) : (GETPOST("search_actioncode", "alpha") == '0' ? '0' : (empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE) ? '' : $conf->global->AGENDA_DEFAULT_FILTER_TYPE)); } if ($actioncode == '' && empty($actioncodearray)) $actioncode = (empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE) ? '' : $conf->global->AGENDA_DEFAULT_FILTER_TYPE); @@ -376,8 +374,7 @@ if ($conf->use_javascript_ajax) if (empty($reshook)) { $s .= $hookmanager->resPrint; - } - elseif ($reshook > 1) + } elseif ($reshook > 1) { $s = $hookmanager->resPrint; } @@ -431,24 +428,18 @@ if (!empty($actioncode)) { if ($actioncode == 'AC_NON_AUTO') $sql .= " AND ca.type != 'systemauto'"; elseif ($actioncode == 'AC_ALL_AUTO') $sql .= " AND ca.type = 'systemauto'"; - else - { + else { if ($actioncode == 'AC_OTH') $sql .= " AND ca.type != 'systemauto'"; if ($actioncode == 'AC_OTH_AUTO') $sql .= " AND ca.type = 'systemauto'"; } - } - else - { + } else { if ($actioncode == 'AC_NON_AUTO') $sql .= " AND ca.type != 'systemauto'"; elseif ($actioncode == 'AC_ALL_AUTO') $sql .= " AND ca.type = 'systemauto'"; - else - { + else { if (is_array($actioncode)) { $sql .= " AND ca.code IN ('".implode("','", $actioncode)."')"; - } - else - { + } else { $sql .= " AND ca.code IN ('".implode("','", explode(',', $actioncode))."')"; } } @@ -472,9 +463,7 @@ if ($action == 'show_day') $sql .= " (a.datep < '".$db->idate(dol_mktime(0, 0, 0, $month, $day, $year))."'"; $sql .= " AND a.datep2 > '".$db->idate(dol_mktime(23, 59, 59, $month, $day, $year))."')"; $sql .= ')'; -} -else -{ +} else { // To limit array $sql .= " AND ("; $sql .= " (a.datep BETWEEN '".$db->idate($firstdaytoshow - (60 * 60 * 24 * 2))."'"; // Start 2 day before $firstdaytoshow @@ -557,9 +546,7 @@ if ($resql) $event->date_start_in_calendar = $datep; if ($datep2 != '' && $datep2 >= $datep) $event->date_end_in_calendar = $datep2; else $event->date_end_in_calendar = $datep; - } - else - { + } else { $event->date_start_in_calendar = $datep; if ($datep2 != '' && $datep2 >= $datep) $event->date_end_in_calendar = $datep2; else $event->date_end_in_calendar = $datep; @@ -576,9 +563,7 @@ if ($resql) { // This record is out of visible range unset($event); - } - else - { + } else { //print $i.' - '.dol_print_date($this->date_start_in_calendar, 'dayhour').' - '.dol_print_date($this->date_end_in_calendar, 'dayhour').'
'."\n"; $event->fetch_userassigned(); // This load $event->userassigned @@ -594,8 +579,7 @@ if ($resql) // Loop on each day covered by action to prepare an index to show on calendar $loop = true; $j = 0; $daykey = dol_mktime(0, 0, 0, $mois, $jour, $annee); - do - { + do { //if ($event->id==408) print 'daykey='.$daykey.' '.$event->datep.' '.$event->datef.'
'; $eventarray[$daykey][] = $event; @@ -603,8 +587,7 @@ if ($resql) $daykey += 60 * 60 * 24; if ($daykey > $event->date_end_in_calendar) $loop = false; - } - while ($loop); + } while ($loop); //print 'Event '.$i.' id='.$event->id.' (start='.dol_print_date($event->datep).'-end='.dol_print_date($event->datef); //print ' startincalendar='.dol_print_date($event->date_start_in_calendar).'-endincalendar='.dol_print_date($event->date_end_in_calendar).') was added in '.$j.' different index key of array
'; @@ -612,9 +595,7 @@ if ($resql) $i++; } $db->free($resql); -} -else -{ +} else { dol_print_error($db); } @@ -713,16 +694,13 @@ while ($currentdaytoshow < $lastdaytoshow) { { $event->fetch_userassigned(); $listofuserid = $event->userassigned; - foreach ($listofuserid as $userid => $tmp) - { + foreach ($listofuserid as $userid => $tmp) { if (!in_array($userid, $usernamesid)) $usernamesid[$userid] = $userid; } } } - } - /* Use this list to have for all users */ - else - { + } else { + /* Use this list to have for all users */ $sql = "SELECT u.rowid, u.lastname as lastname, u.firstname, u.statut, u.login, u.admin, u.entity"; $sql .= " FROM ".MAIN_DB_PREFIX."user as u"; if ($usergroup > 0) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."usergroup_user as ug ON u.rowid = ug.fk_user"; @@ -730,8 +708,7 @@ while ($currentdaytoshow < $lastdaytoshow) { if ($usergroup > 0) $sql .= " AND ug.fk_usergroup = ".$usergroup; //print $sql; $resql = $db->query($sql); - if ($resql) - { + if ($resql) { $num = $db->num_rows($resql); $i = 0; if ($num) @@ -743,8 +720,7 @@ while ($currentdaytoshow < $lastdaytoshow) { $i++; } } - } - else dol_print_error($db); + } else dol_print_error($db); } //var_dump($usernamesid); foreach ($usernamesid as $id) @@ -992,8 +968,7 @@ function show_day_events2($username, $day, $month, $year, $monthshown, $style, & if (!empty($cacheusers[$event->userownerid]->color)) $color = $cacheusers[$event->userownerid]->color; if (!empty($conf->global->AGENDA_USE_COLOR_PER_EVENT_TYPE)) $color = $event->type_color; - } - elseif ($event->type_code == 'ICALEVENT') + } elseif ($event->type_code == 'ICALEVENT') { $numical++; if (!empty($event->icalname)) @@ -1006,13 +981,10 @@ function show_day_events2($username, $day, $month, $year, $monthshown, $style, & $color = $event->icalcolor; $cssclass = (!empty($event->icalname) ? 'family_ext'.md5($event->icalname) : 'family_other unsortable'); - } - elseif ($event->type_code == 'BIRTHDAY') + } elseif ($event->type_code == 'BIRTHDAY') { $numbirthday++; $colorindex = 2; $cssclass = 'family_birthday unsortable'; $color = sprintf("%02x%02x%02x", $theme_datacolor[$colorindex][0], $theme_datacolor[$colorindex][1], $theme_datacolor[$colorindex][2]); - } - else - { + } else { $numother++; $color = ($event->icalcolor ? $event->icalcolor : -1); $cssclass = (!empty($event->icalname) ? 'family_ext'.md5($event->icalname) : 'family_other'); @@ -1038,9 +1010,7 @@ function show_day_events2($username, $day, $month, $year, $monthshown, $style, & if (isset($colorindexused[$idusertouse])) { $colorindex = $colorindexused[$idusertouse]; // Color already assigned to this user - } - else - { + } else { $colorindex = $nextindextouse; $colorindexused[$idusertouse] = $colorindex; if (!empty($theme_datacolor[$nextindextouse + 1])) $nextindextouse++; // Prepare to use next color @@ -1158,9 +1128,7 @@ function show_day_events2($username, $day, $month, $year, $monthshown, $style, & $cases2[$h][$event->id]['string'] .= ', '.$cachecontacts[$event->contactid]->getFullName($langs); } } - } - else - { + } else { $busy = $event->transparency; $cases1[$h][$event->id]['busy'] = $busy; $cases2[$h][$event->id]['busy'] = $busy; @@ -1224,8 +1192,7 @@ function show_day_events2($username, $day, $month, $year, $monthshown, $style, & $title1 = $langs->trans("Ref").' '.$ids1.($title1 ? ' - '.$title1 : ''); if ($output[0]['string']) $title1 .= ($title1 ? ' - ' : '').$output[0]['string']; if ($output[0]['color']) $color1 = $output[0]['color']; - } - elseif (is_array($cases1[$h]) && count($cases1[$h]) > 1) + } elseif (is_array($cases1[$h]) && count($cases1[$h]) > 1) { $title1 = $langs->trans("Ref").' '.$ids1.($title1 ? ' - '.$title1 : ''); $color1 = '222222'; @@ -1237,8 +1204,7 @@ function show_day_events2($username, $day, $month, $year, $monthshown, $style, & $title2 = $langs->trans("Ref").' '.$ids2.($title2 ? ' - '.$title2 : ''); if ($output[0]['string']) $title2 .= ($title2 ? ' - ' : '').$output[0]['string']; if ($output[0]['color']) $color2 = $output[0]['color']; - } - elseif (is_array($cases2[$h]) && count($cases2[$h]) > 1) + } elseif (is_array($cases2[$h]) && count($cases2[$h]) > 1) { $title2 = $langs->trans("Ref").' '.$ids2.($title2 ? ' - '.$title2 : ''); $color2 = '222222'; diff --git a/htdocs/comm/action/rapport/index.php b/htdocs/comm/action/rapport/index.php index 82477d307fc..35c0f7a890e 100644 --- a/htdocs/comm/action/rapport/index.php +++ b/htdocs/comm/action/rapport/index.php @@ -186,8 +186,7 @@ if ($resql) print ''; print ''.dol_print_date(dol_filemtime($file), 'dayhour').''; print ''.dol_print_size(dol_filesize($file)).''; - } - else { + } else { print ' '; print ' '; print ' '; @@ -202,9 +201,7 @@ if ($resql) print ''; $db->free($resql); -} -else -{ +} else { dol_print_error($db); } diff --git a/htdocs/comm/card.php b/htdocs/comm/card.php index 7c6335d146b..b3b11a95a36 100644 --- a/htdocs/comm/card.php +++ b/htdocs/comm/card.php @@ -5,7 +5,7 @@ * Copyright (C) 2006 Andre Cianfarani * Copyright (C) 2005-2017 Regis Houssin * Copyright (C) 2008 Raphael Bertrand (Resultic) - * Copyright (C) 2010-2014 Juanjo Menent + * Copyright (C) 2010-2020 Juanjo Menent * Copyright (C) 2013 Alexandre Spangaro * Copyright (C) 2015-2019 Frédéric France * Copyright (C) 2015 Marcos García @@ -330,9 +330,7 @@ if ($object->id > 0) if ($action == 'editconditions') { $form->form_conditions_reglement($_SERVER['PHP_SELF'].'?socid='.$object->id, $object->cond_reglement_id, 'cond_reglement_id', 1); - } - else - { + } else { $form->form_conditions_reglement($_SERVER['PHP_SELF'].'?socid='.$object->id, $object->cond_reglement_id, 'none'); } print ""; @@ -349,9 +347,7 @@ if ($object->id > 0) if ($action == 'editmode') { $form->form_modes_reglement($_SERVER['PHP_SELF'].'?socid='.$object->id, $object->mode_reglement_id, 'mode_reglement_id', 'CRDT', 1, 1); - } - else - { + } else { $form->form_modes_reglement($_SERVER['PHP_SELF'].'?socid='.$object->id, $object->mode_reglement_id, 'none'); } print ""; @@ -370,9 +366,7 @@ if ($object->id > 0) if ($action == 'editbankaccount') { $form->formSelectAccount($_SERVER['PHP_SELF'].'?socid='.$object->id, $object->fk_account, 'fk_account', 1); - } - else - { + } else { $form->formSelectAccount($_SERVER['PHP_SELF'].'?socid='.$object->id, $object->fk_account, 'none'); } print ""; @@ -478,9 +472,7 @@ if ($object->id > 0) if ($action == 'editshipping') { $form->formSelectShippingMethod($_SERVER['PHP_SELF'].'?socid='.$object->id, $object->shipping_method_id, 'shipping_method_id', 1); - } - else - { + } else { $form->formSelectShippingMethod($_SERVER['PHP_SELF'].'?socid='.$object->id, $object->shipping_method_id, 'none'); } print ""; @@ -517,9 +509,7 @@ if ($object->id > 0) { $adh->ref = $adh->getFullName($langs); print $adh->getNomUrl(1); - } - else - { + } else { print ''.$langs->trans("ThirdpartyNotLinkedToMember").''; } print ''; @@ -546,9 +536,7 @@ if ($object->id > 0) if ($action == 'editlevel') { $formcompany->form_prospect_level($_SERVER['PHP_SELF'].'?socid='.$object->id, $object->fk_prospectlevel, 'prospect_level_id', 1); - } - else - { + } else { print $object->getLibProspLevel(); } print ""; @@ -582,7 +570,7 @@ if ($object->id > 0) $boxstat .= ''; $boxstat .= '
'; - if (!empty($conf->propal->enabled)) + if (!empty($conf->propal->enabled) && $user->rights->propal->lire) { // Box proposals $tmp = $object->getOutstandingProposals(); @@ -600,7 +588,7 @@ if ($object->id > 0) if ($link) $boxstat .= ''; } - if (!empty($conf->commande->enabled)) + if (!empty($conf->commande->enabled) && $user->rights->commande->lire) { // Box commandes $tmp = $object->getOutstandingOrders(); @@ -618,7 +606,7 @@ if ($object->id > 0) if ($link) $boxstat .= ''; } - if (!empty($conf->facture->enabled)) + if (!empty($conf->facture->enabled) && $user->rights->facture->lire) { // Box factures $tmp = $object->getOutstandingBills(); @@ -731,9 +719,7 @@ if ($object->id > 0) print "
"; print ''; } - } - else - { + } else { dol_print_error($db); } } @@ -817,9 +803,7 @@ if ($object->id > 0) print ""; print ''; } - } - else - { + } else { dol_print_error($db); } } @@ -960,9 +944,7 @@ if ($object->id > 0) print ""; print ''; } - } - else - { + } else { dol_print_error($db); } } @@ -1021,9 +1003,7 @@ if ($object->id > 0) print ""; print ''; } - } - else - { + } else { dol_print_error($db); } } @@ -1092,15 +1072,11 @@ if ($object->id > 0) if ($objp->frequency && $objp->date_last_gen > 0) { print ''.dol_print_date($db->jdate($objp->date_last_gen), 'day').''; - } - else - { + } else { if ($objp->dc > 0) { print ''.dol_print_date($db->jdate($objp->dc), 'day').''; - } - else - { + } else { print '!!!'; } } @@ -1129,9 +1105,7 @@ if ($object->id > 0) print ""; print ''; } - } - else - { + } else { dol_print_error($db); } } @@ -1194,9 +1168,7 @@ if ($object->id > 0) if ($objp->df > 0) { print ''.dol_print_date($db->jdate($objp->df), 'day').''; - } - else - { + } else { print '!!!'; } print ''; @@ -1221,9 +1193,7 @@ if ($object->id > 0) print ""; print ''; } - } - else - { + } else { dol_print_error($db); } } @@ -1288,9 +1258,7 @@ if ($object->id > 0) if (empty($user->rights->facture->creer)) { print '
'; - } - else - { + } else { $langs->load("bills"); $langs->load("orders"); @@ -1300,8 +1268,7 @@ if ($object->id > 0) { if (!empty($orders2invoice) && $orders2invoice > 0) print ''; else print ''; - } - else print ''; + } else print ''; } if ($object->client != 0 && $object->client != 2) print ''; @@ -1316,9 +1283,7 @@ if ($object->id > 0) if ($user->rights->agenda->myactions->create) { print ''; - } - else - { + } else { print ''; } } @@ -1342,9 +1307,7 @@ if ($object->id > 0) // List of done actions show_actions_done($conf, $langs, $db, $object); } -} -else -{ +} else { $langs->load("errors"); print $langs->trans('ErrorRecordNotFound'); } diff --git a/htdocs/comm/contact.php b/htdocs/comm/contact.php index 8c9a63d97e2..d3075916367 100644 --- a/htdocs/comm/contact.php +++ b/htdocs/comm/contact.php @@ -170,9 +170,7 @@ if ($resql) print ''; $db->free($resql); -} -else -{ +} else { dol_print_error($db); } diff --git a/htdocs/comm/index.php b/htdocs/comm/index.php index af5b4ac41a5..b542a110832 100644 --- a/htdocs/comm/index.php +++ b/htdocs/comm/index.php @@ -209,22 +209,17 @@ if (!empty($conf->propal->enabled) && $user->rights->propal->lire) if ($num > $nbofloop) { print ''.$langs->trans("XMoreLines", ($num - $nbofloop)).""; - } - elseif ($total > 0) + } elseif ($total > 0) { print ''.$langs->trans("Total").''.price($total).""; } - } - else - { + } else { print ''.$langs->trans("NoProposal").''; } print "
"; $db->free($resql); - } - else - { + } else { dol_print_error($db); } } @@ -297,22 +292,17 @@ if (!empty($conf->supplier_proposal->enabled) && $user->rights->supplier_proposa if ($num > $nbofloop) { print ''.$langs->trans("XMoreLines", ($num - $nbofloop)).""; - } - elseif ($total > 0) + } elseif ($total > 0) { print ''.$langs->trans("Total").''.price($total).""; } - } - else - { + } else { print ''.$langs->trans("NoProposal").''; } print "
"; $db->free($resql); - } - else - { + } else { dol_print_error($db); } } @@ -379,8 +369,7 @@ if (!empty($conf->commande->enabled) && $user->rights->commande->lire) print ''; if (!empty($conf->global->MAIN_DASHBOARD_USE_TOTAL_HT)) { print ''.price($obj->total_ht).''; - } - else { + } else { print ''.price($obj->total_ttc).''; } $i++; @@ -389,23 +378,18 @@ if (!empty($conf->commande->enabled) && $user->rights->commande->lire) if ($num > $nbofloop) { print ''.$langs->trans("XMoreLines", ($num - $nbofloop)).""; - } - elseif ($total > 0) + } elseif ($total > 0) { print ''.$langs->trans("Total").''.price($total).""; } - } - else - { + } else { print ''.$langs->trans("NoOrder").''; } print ""; print "
"; $db->free($resql); - } - else - { + } else { dol_print_error($db); } } @@ -472,8 +456,7 @@ if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SU print ''; if (!empty($conf->global->MAIN_DASHBOARD_USE_TOTAL_HT)) { print ''.price($obj->total_ht).''; - } - else { + } else { print ''.price($obj->total_ttc).''; } $i++; @@ -482,14 +465,11 @@ if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SU if ($num > $nbofloop) { print ''.$langs->trans("XMoreLines", ($num - $nbofloop)).""; - } - elseif ($total > 0) + } elseif ($total > 0) { print ''.$langs->trans("Total").''.price($total).""; } - } - else - { + } else { print ''.$langs->trans("NoSupplierOrder").''; } print ""; @@ -570,9 +550,7 @@ if (!empty($conf->societe->enabled) && $user->rights->societe->lire) } $db->free($resql); - } - else - { + } else { print ''.$langs->trans("None").''; } print ""; @@ -629,9 +607,7 @@ if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SU $i++; } - } - else - { + } else { print ''.$langs->trans("None").''; } print ''; @@ -717,9 +693,7 @@ if (!empty($conf->contrat->enabled) && $user->rights->contrat->lire && 0) // TOD print ""; print "
"; } - } - else - { + } else { dol_print_error($db); } } @@ -805,8 +779,7 @@ if (!empty($conf->propal->enabled) && $user->rights->propal->lire) print dol_print_date($db->jdate($obj->dp), 'day').''."\n"; if (!empty($conf->global->MAIN_DASHBOARD_USE_TOTAL_HT)) { print ''.price($obj->total_ht).''; - } - else { + } else { print ''.price($obj->total_ttc).''; } print ''.$propalstatic->LibStatut($obj->fk_statut, 3).''."\n"; @@ -817,17 +790,14 @@ if (!empty($conf->propal->enabled) && $user->rights->propal->lire) if ($num > $nbofloop) { print ''.$langs->trans("XMoreLines", ($num - $nbofloop)).""; - } - elseif ($total > 0) + } elseif ($total > 0) { print ''.$langs->trans("Total")."".price($total)." "; } print ""; print "
"; } - } - else - { + } else { dol_print_error($db); } } @@ -913,8 +883,7 @@ if (!empty($conf->commande->enabled) && $user->rights->commande->lire) print dol_print_date($db->jdate($obj->dp), 'day').''."\n"; if (!empty($conf->global->MAIN_DASHBOARD_USE_TOTAL_HT)) { print ''.price($obj->total_ht).''; - } - else { + } else { print ''.price($obj->total_ttc).''; } print ''.$orderstatic->LibStatut($obj->fk_statut, $obj->billed, 3).''."\n"; @@ -925,17 +894,14 @@ if (!empty($conf->commande->enabled) && $user->rights->commande->lire) if ($num > $nbofloop) { print ''.$langs->trans("XMoreLines", ($num - $nbofloop)).""; - } - elseif ($total > 0) + } elseif ($total > 0) { print ''.$langs->trans("Total")."".price($total)." "; } print ""; print "
"; } - } - else - { + } else { dol_print_error($db); } } diff --git a/htdocs/comm/mailing/advtargetemailing.php b/htdocs/comm/mailing/advtargetemailing.php index d4db9fc6ea9..da24f7bcb4f 100644 --- a/htdocs/comm/mailing/advtargetemailing.php +++ b/htdocs/comm/mailing/advtargetemailing.php @@ -87,9 +87,7 @@ if (empty($template_id)) { if ($result < 0) { setEventMessages($advTarget->error, $advTarget->errors, 'errors'); -} -else -{ +} else { if (!empty($advTarget->id)) { $array_query = json_decode($advTarget->filtervalue, true); } diff --git a/htdocs/comm/mailing/card.php b/htdocs/comm/mailing/card.php index 68a6b8db331..ea81c4e35b9 100644 --- a/htdocs/comm/mailing/card.php +++ b/htdocs/comm/mailing/card.php @@ -93,17 +93,13 @@ if (empty($reshook)) if (!GETPOST("clone_content", 'alpha') && !GETPOST("clone_receivers", 'alpha')) { setEventMessages($langs->trans("NoCloneOptionsSpecified"), null, 'errors'); - } - else - { + } else { $result = $object->createFromClone($user, $object->id, GETPOST("clone_content", 'alpha'), GETPOST("clone_receivers", 'alpha')); if ($result > 0) { header("Location: ".$_SERVER['PHP_SELF'].'?id='.$result); exit; - } - else - { + } else { setEventMessages($object->error, $object->errors, 'errors'); } } @@ -120,14 +116,11 @@ if (empty($reshook)) setEventMessages('', null, 'warnings'); setEventMessages($langs->trans("MailingNeedCommand2"), null, 'warnings'); $action = ''; - } - elseif ($conf->global->MAILING_LIMIT_SENDBYWEB < 0) + } elseif ($conf->global->MAILING_LIMIT_SENDBYWEB < 0) { setEventMessages($langs->trans("NotEnoughPermissions"), null, 'warnings'); $action = ''; - } - else - { + } else { $upload_dir = $conf->mailing->dir_output."/".get_exdir($object->id, 2, 0, 1, $object, 'mailing'); if ($object->statut == 0) @@ -235,9 +228,7 @@ if (empty($reshook)) $substitutionarray['__SECUREKEYPAYMENT_ORDER__'] = dol_hash($conf->global->PAYMENT_SECURITY_TOKEN, 2); $substitutionarray['__SECUREKEYPAYMENT_INVOICE__'] = dol_hash($conf->global->PAYMENT_SECURITY_TOKEN, 2); $substitutionarray['__SECUREKEYPAYMENT_CONTRACTLINE__'] = dol_hash($conf->global->PAYMENT_SECURITY_TOKEN, 2); - } - else - { + } else { $substitutionarray['__SECUREKEYPAYMENT_MEMBER__'] = dol_hash($conf->global->PAYMENT_SECURITY_TOKEN.'membersubscription'.$obj->source_id, 2); $substitutionarray['__SECUREKEYPAYMENT_ORDER__'] = dol_hash($conf->global->PAYMENT_SECURITY_TOKEN.'order'.$obj->source_id, 2); $substitutionarray['__SECUREKEYPAYMENT_INVOICE__'] = dol_hash($conf->global->PAYMENT_SECURITY_TOKEN.'invoice'.$obj->source_id, 2); @@ -316,9 +307,7 @@ if (empty($reshook)) if (!$resql2) { dol_print_error($db); - } - else - { + } else { //if cheack read is use then update prospect contact status if (strpos($message, '__CHECK_READ__') !== false) { @@ -350,9 +339,7 @@ if (empty($reshook)) } //test if CHECK READ change statut prospect contact - } - else - { + } else { // Mail failed $nbko++; @@ -369,9 +356,7 @@ if (empty($reshook)) $i++; } - } - else - { + } else { setEventMessages($langs->transnoentitiesnoconv("NoMoreRecipientToSendTo"), null, 'mesgs'); } @@ -381,16 +366,12 @@ if (empty($reshook)) $statut = 2; // Status 'sent partially' (because at least one error) if ($nbok > 0) setEventMessages($langs->transnoentitiesnoconv("EMailSentToNRecipients", $nbok), null, 'mesgs'); else setEventMessages($langs->transnoentitiesnoconv("EMailSentToNRecipients", $nbok), null, 'mesgs'); - } - else - { + } else { if ($nbok >= $num) { $statut = 3; // Send to everybody setEventMessages($langs->transnoentitiesnoconv("EMailSentToNRecipients", $nbok), null, 'mesgs'); - } - else - { + } else { $statut = 2; // Status 'sent partially' (because not send to everybody) setEventMessages($langs->transnoentitiesnoconv("EMailSentToNRecipients", $nbok), null, 'mesgs'); } @@ -403,9 +384,7 @@ if (empty($reshook)) { dol_print_error($db); } - } - else - { + } else { dol_syslog($db->error()); dol_print_error($db); } @@ -472,9 +451,7 @@ if (empty($reshook)) { setEventMessages($langs->trans("MailSuccessfulySent", $mailfile->getValidAddress($object->email_from, 2), $mailfile->getValidAddress($object->sendto, 2)), null, 'mesgs'); $action = ''; - } - else - { + } else { setEventMessages($langs->trans("ResultKo").'
'.$mailfile->error.' '.$result, null, 'errors'); $action = 'test'; } @@ -611,9 +588,7 @@ if (empty($reshook)) setEventMessages($mesg, $mesgs, 'errors'); $action = "edit"; - } - else - { + } else { $action = "edit"; } } @@ -627,9 +602,7 @@ if (empty($reshook)) setEventMessages($langs->trans("MailingSuccessfullyValidated"), null, 'mesgs'); header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); exit; - } - else - { + } else { dol_print_error($db); } } @@ -645,14 +618,10 @@ if (empty($reshook)) //setEventMessages($langs->trans("MailingSuccessfullyValidated"), null, 'mesgs'); header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); exit; - } - else - { + } else { setEventMessages($object->error, $object->errors, 'errors'); } - } - else - { + } else { dol_print_error($db); } } @@ -675,15 +644,11 @@ if (empty($reshook)) $db->commit(); header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); exit; - } - else - { + } else { setEventMessages($object->error, $object->errors, 'errors'); $db->rollback(); } - } - else - { + } else { dol_print_error($db); } } @@ -742,7 +707,7 @@ if ($action == 'create') // Print mail form - print load_fiche_titre($langs->trans("NewMailing"), $availablelink, 'generic'); + print load_fiche_titre($langs->trans("NewMailing"), $availablelink, 'object_email'); dol_fiche_head(); @@ -783,9 +748,7 @@ if ($action == 'create') print '
'; print ''; -} -else -{ +} else { if ($object->id > 0) { $upload_dir = $conf->mailing->dir_output."/".get_exdir($object->id, 2, 0, 1, $object, 'mailing'); @@ -801,13 +764,11 @@ else if ($action == 'valid') { print $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$object->id, $langs->trans("ValidMailing"), $langs->trans("ConfirmValidMailing"), "confirm_valid", '', '', 1); - } - // Confirm reset + } // Confirm reset elseif ($action == 'reset') { print $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$object->id, $langs->trans("ResetMailing"), $langs->trans("ConfirmResetMailing", $object->ref), "confirm_reset", '', '', 2); - } - // Confirm delete + } // Confirm delete elseif ($action == 'delete') { print $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$object->id.(!empty($urlfrom) ? '&urlfrom='.urlencode($urlfrom) : ''), $langs->trans("DeleteAMailing"), $langs->trans("ConfirmDeleteMailing"), "confirm_delete", '', '', 1); @@ -841,8 +802,7 @@ else setEventMessages($langs->trans("MailSendSetupIs2", $linktoadminemailbefore, $linktoadminemailend, $langs->transnoentitiesnoconv("MAIN_MAIL_SENDMODE"), $listofmethods['smtps']), null, 'warnings'); if (!empty($conf->global->MAILING_SMTP_SETUP_EMAILS_FOR_QUESTIONS)) setEventMessages($langs->trans("MailSendSetupIs3", $conf->global->MAILING_SMTP_SETUP_EMAILS_FOR_QUESTIONS), null, 'warnings'); $_GET["action"] = ''; - } - elseif ($conf->global->MAILING_LIMIT_SENDBYWEB < 0) + } elseif ($conf->global->MAILING_LIMIT_SENDBYWEB < 0) { if (!empty($conf->global->MAILING_LIMIT_WARNING_PHPMAIL) && $sendingmode == 'mail') setEventMessages($langs->transnoentitiesnoconv($conf->global->MAILING_LIMIT_WARNING_PHPMAIL), null, 'warnings'); if (!empty($conf->global->MAILING_LIMIT_WARNING_NOPHPMAIL) && $sendingmode != 'mail') setEventMessages($langs->transnoentitiesnoconv($conf->global->MAILING_LIMIT_WARNING_NOPHPMAIL), null, 'warnings'); @@ -855,9 +815,7 @@ else setEventMessages($langs->trans("MailingNeedCommand2"), null, 'warnings'); // You can send online with constant... } $_GET["action"] = ''; - } - else - { + } else { if (!empty($conf->global->MAILING_LIMIT_WARNING_PHPMAIL) && $sendingmode == 'mail') setEventMessages($langs->transnoentitiesnoconv($conf->global->MAILING_LIMIT_WARNING_PHPMAIL), null, 'warnings'); if (!empty($conf->global->MAILING_LIMIT_WARNING_NOPHPMAIL) && $sendingmode != 'mail') setEventMessages($langs->transnoentitiesnoconv($conf->global->MAILING_LIMIT_WARNING_NOPHPMAIL), null, 'warnings'); @@ -939,9 +897,7 @@ else if ($conf->global->MAILING_LIMIT_SENDBYWEB > 0) { $text .= $langs->trans('LimitSendingEmailing', $conf->global->MAILING_LIMIT_SENDBYWEB); - } - else - { + } else { $text .= $langs->trans('SendingFromWebInterfaceIsNotAllowed'); } } @@ -949,9 +905,7 @@ else if ($text) { print $form->textwithpicto($nbemail, $text, 1, 'warning'); - } - else - { + } else { print $nbemail; } } @@ -998,9 +952,7 @@ else if (!empty($conf->fckeditor->enabled) && !empty($conf->global->FCKEDITOR_ENABLE_MAILING)) { print ''.$langs->trans("EditWithEditor").''; - } - else - { + } else { print ''.$langs->trans("EditWithTextEditor").''; } @@ -1012,9 +964,7 @@ else if (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !$user->rights->mailing->mailing_advance->send) { print ''.$langs->trans("TestMailing").''; - } - else - { + } else { print ''.$langs->trans("TestMailing").''; } @@ -1023,13 +973,10 @@ else if ($object->nbemail <= 0) { print ''.$langs->trans("ValidMailing").''; - } - elseif (empty($user->rights->mailing->valider)) + } elseif (empty($user->rights->mailing->valider)) { print ''.$langs->trans("ValidMailing").''; - } - else - { + } else { print ''.$langs->trans("ValidMailing").''; } } @@ -1039,13 +986,10 @@ else if ($conf->global->MAILING_LIMIT_SENDBYWEB < 0) { print ''.$langs->trans("SendMailing").''; - } - elseif (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !$user->rights->mailing->mailing_advance->send) + } elseif (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !$user->rights->mailing->mailing_advance->send) { print ''.$langs->trans("SendMailing").''; - } - else - { + } else { print ''.$langs->trans("SendMailing").''; } } @@ -1060,9 +1004,7 @@ else if (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !$user->rights->mailing->mailing_advance->send) { print ''.$langs->trans("ResetMailing").''; - } - else - { + } else { print ''.$langs->trans("ResetMailing").''; } } @@ -1072,9 +1014,7 @@ else if ($object->statut > 0 && (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !$user->rights->mailing->mailing_advance->delete)) { print ''.$langs->trans("DeleteMailing").''; - } - else - { + } else { print ''.$langs->trans("DeleteMailing").''; } } @@ -1153,9 +1093,7 @@ else print img_mime($listofpaths[$key]['name']).' '.$listofpaths[$key]['name']; print '
'; } - } - else - { + } else { print ''.$langs->trans("NoAttachedFiles").'
'; } print ''; @@ -1176,14 +1114,11 @@ else require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; $doleditor = new DolEditor('bodyemail', $object->body, '', 600, 'dolibarr_mailings', '', false, true, empty($conf->global->FCKEDITOR_ENABLE_MAILING) ? 0 : 1, 20, '90%', $readonly); $doleditor->Create(); - } - else print dol_htmlentitiesbr($object->body); + } else print dol_htmlentitiesbr($object->body); print ''; dol_fiche_end(); - } - else - { + } else { /* * Mailing en mode edition (CKeditor or HTML source) */ @@ -1229,9 +1164,7 @@ else if ($conf->global->MAILING_LIMIT_SENDBYWEB > 0) { $text .= $langs->trans('LimitSendingEmailing', $conf->global->MAILING_LIMIT_SENDBYWEB); - } - else - { + } else { $text .= $langs->trans('SendingFromWebInterfaceIsNotAllowed'); } } @@ -1239,9 +1172,7 @@ else if ($text) { print $form->textwithpicto($nbemail, $text, 1, 'warning'); - } - else - { + } else { print $nbemail; } } @@ -1315,9 +1246,7 @@ else $out .= ' '; $out .= '
'; } - } - else - { + } else { $out .= $langs->trans("NoAttachedFiles").'
'; } // Add link to add file @@ -1366,9 +1295,7 @@ else print ''; print '
'; } - } - else - { + } else { dol_print_error($db, $object->error); } } diff --git a/htdocs/comm/mailing/cibles.php b/htdocs/comm/mailing/cibles.php index d8d9873b88b..27e0c2e5b0c 100644 --- a/htdocs/comm/mailing/cibles.php +++ b/htdocs/comm/mailing/cibles.php @@ -160,9 +160,7 @@ if (GETPOST('exportcsv', 'int')) } exit; - } - else - { + } else { dol_print_error($db); } exit; @@ -181,15 +179,11 @@ if ($action == 'delete') $obj->update_nb($id); setEventMessages($langs->trans("RecordDeleted"), null, 'mesgs'); - } - else - { + } else { header("Location: list.php"); exit; } - } - else - { + } else { dol_print_error($db); } } @@ -293,9 +287,7 @@ if ($object->fetch($id) >= 0) if ($conf->global->MAILING_LIMIT_SENDBYWEB > 0) { $text .= $langs->trans('LimitSendingEmailing', $conf->global->MAILING_LIMIT_SENDBYWEB); - } - else - { + } else { $text .= $langs->trans('SendingFromWebInterfaceIsNotAllowed'); } } @@ -303,9 +295,7 @@ if ($object->fetch($id) >= 0) if ($text) { print $form->textwithpicto($nbemail, $text, 1, 'warning'); - } - else - { + } else { print $nbemail; } } @@ -405,9 +395,7 @@ if ($object->fetch($id) >= 0) { print '
'; print ''; - } - else - { + } else { print '
'; } @@ -420,8 +408,7 @@ if ($object->fetch($id) >= 0) try { $nbofrecipient = $obj->getNbOfRecipients(''); - } - catch (Exception $e) + } catch (Exception $e) { dol_syslog($e->getMessage(), LOG_ERR); } @@ -430,9 +417,7 @@ if ($object->fetch($id) >= 0) if ($nbofrecipient >= 0) { print $nbofrecipient; - } - else - { + } else { print $langs->trans("Error").' '.img_error($obj->error); } print '
'; @@ -442,8 +427,7 @@ if ($object->fetch($id) >= 0) { try { $filter = $obj->formFilter(); - } - catch (Exception $e) + } catch (Exception $e) { dol_syslog($e->getMessage(), LOG_ERR); } @@ -456,9 +440,7 @@ if ($object->fetch($id) >= 0) if ($allowaddtarget) { print ''; - } - else - { + } else { print ''; //print $langs->trans("MailNoChangePossible"); print " "; @@ -632,31 +614,24 @@ if ($object->fetch($id) >= 0) if (empty($obj->source_id) || empty($obj->source_type)) { print empty($obj->source_url) ? '' : $obj->source_url; // For backward compatibility - } - else - { + } else { if ($obj->source_type == 'member') { $objectstaticmember->fetch($obj->source_id); print $objectstaticmember->getNomUrl(1); - } - elseif ($obj->source_type == 'user') + } elseif ($obj->source_type == 'user') { $objectstaticuser->fetch($obj->source_id); print $objectstaticuser->getNomUrl(1); - } - elseif ($obj->source_type == 'thirdparty') + } elseif ($obj->source_type == 'thirdparty') { $objectstaticcompany->fetch($obj->source_id); print $objectstaticcompany->getNomUrl(1); - } - elseif ($obj->source_type == 'contact') + } elseif ($obj->source_type == 'contact') { $objectstaticcontact->fetch($obj->source_id); print $objectstaticcontact->getNomUrl(1); - } - else - { + } else { print $obj->source_url; } } @@ -676,9 +651,7 @@ if ($object->fetch($id) >= 0) print ''; print $object::libStatutDest($obj->statut, 2, ''); print ''; - } - else - { + } else { // Date sent print ''.$obj->date_envoi.''; @@ -704,9 +677,7 @@ if ($object->fetch($id) >= 0) $i++; } - } - else - { + } else { if ($object->statut < 2) { print ''; @@ -720,9 +691,7 @@ if ($object->fetch($id) >= 0) print '
'; $db->free($resql); - } - else - { + } else { dol_print_error($db); } diff --git a/htdocs/comm/mailing/class/advtargetemailing.class.php b/htdocs/comm/mailing/class/advtargetemailing.class.php index 7700ca6ee43..983ad374980 100644 --- a/htdocs/comm/mailing/class/advtargetemailing.class.php +++ b/htdocs/comm/mailing/class/advtargetemailing.class.php @@ -165,9 +165,7 @@ class AdvanceTargetingMailing extends CommonObject } $this->db->rollback(); return -1 * $error; - } - else - { + } else { $this->db->commit(); return $this->id; } @@ -221,9 +219,7 @@ class AdvanceTargetingMailing extends CommonObject $this->db->free($resql); return 1; - } - else - { + } else { $this->error = "Error ".$this->db->lasterror(); dol_syslog(get_class($this)."::fetch ".$this->error, LOG_ERR); return -1; @@ -284,9 +280,7 @@ class AdvanceTargetingMailing extends CommonObject $this->db->free($resql); return 1; - } - else - { + } else { $this->error = "Error ".$this->db->lasterror(); dol_syslog(get_class($this)."::fetch ".$this->error, LOG_ERR); return -1; @@ -351,9 +345,7 @@ class AdvanceTargetingMailing extends CommonObject $this->db->free($resql); return 1; - } - else - { + } else { $this->error = "Error ".$this->db->lasterror(); dol_syslog(get_class($this)."::fetch ".$this->error, LOG_ERR); return -1; @@ -411,9 +403,7 @@ class AdvanceTargetingMailing extends CommonObject } $this->db->rollback(); return -1 * $error; - } - else - { + } else { $this->db->commit(); return 1; } @@ -453,9 +443,7 @@ class AdvanceTargetingMailing extends CommonObject } $this->db->rollback(); return -1 * $error; - } - else - { + } else { $this->db->commit(); return 1; } @@ -689,9 +677,7 @@ class AdvanceTargetingMailing extends CommonObject if (!empty($arrayquery['contact_no_email'])) { $tmpwhere .= "(t.email IN (SELECT email FROM ".MAIN_DB_PREFIX."mailing_unsubscribe WHERE t.entity IN (".getEntity('mailing').") AND email = '".$this->db->escape($arrayquery['contact_no_email'])."'))"; - } - else - { + } else { $tmpwhere .= "(t.email NOT IN (SELECT email FROM ".MAIN_DB_PREFIX."mailing_unsubscribe WHERE t.entity IN (".getEntity('mailing').") AND email = '".$this->db->escape($arrayquery['contact_no_email'])."'))"; } $sqlwhere[] = $tmpwhere; diff --git a/htdocs/comm/mailing/class/html.formadvtargetemailing.class.php b/htdocs/comm/mailing/class/html.formadvtargetemailing.class.php index b9782515735..e6f928d539f 100644 --- a/htdocs/comm/mailing/class/html.formadvtargetemailing.class.php +++ b/htdocs/comm/mailing/class/html.formadvtargetemailing.class.php @@ -314,9 +314,7 @@ class FormAdvTargetEmailing extends Form $i++; } } - } - else - { + } else { dol_print_error($this->db); } @@ -400,9 +398,7 @@ class FormAdvTargetEmailing extends Form $i++; } } - } - else - { + } else { dol_print_error($this->db); } diff --git a/htdocs/comm/mailing/class/mailing.class.php b/htdocs/comm/mailing/class/mailing.class.php index 56a115a2fea..1bb4864876c 100644 --- a/htdocs/comm/mailing/class/mailing.class.php +++ b/htdocs/comm/mailing/class/mailing.class.php @@ -144,18 +144,14 @@ class Mailing extends CommonObject if ($this->update($user) > 0) { $this->db->commit(); - } - else - { + } else { $this->error = $this->db->lasterror(); $this->db->rollback(); return -1; } return $this->id; - } - else - { + } else { $this->error = $this->db->lasterror(); $this->db->rollback(); return -1; @@ -186,9 +182,7 @@ class Mailing extends CommonObject if ($result) { return 1; - } - else - { + } else { $this->error = $this->db->lasterror(); return -1; } @@ -253,15 +247,11 @@ class Mailing extends CommonObject $this->extraparams = (array) json_decode($obj->extraparams, true); return 1; - } - else - { + } else { dol_syslog(get_class($this)."::fetch Erreur -1"); return -1; } - } - else - { + } else { dol_syslog(get_class($this)."::fetch Erreur -2"); return -2; } @@ -368,9 +358,7 @@ class Mailing extends CommonObject ); } } - } - else - { + } else { $this->error = $this->db->lasterror(); return -1; } @@ -386,9 +374,7 @@ class Mailing extends CommonObject { $this->db->commit(); return $object->id; - } - else - { + } else { $this->db->rollback(); return -1; } @@ -412,9 +398,7 @@ class Mailing extends CommonObject if ($this->db->query($sql)) { return 1; - } - else - { + } else { $this->error = $this->db->lasterror(); return -1; } @@ -437,9 +421,7 @@ class Mailing extends CommonObject if ($resql) { return $this->delete_targets(); - } - else - { + } else { $this->error = $this->db->lasterror(); return -1; } @@ -462,9 +444,7 @@ class Mailing extends CommonObject if ($resql) { return 1; - } - else - { + } else { $this->error = $this->db->lasterror(); return 0; } @@ -490,9 +470,7 @@ class Mailing extends CommonObject if ($resql) { return 1; - } - else - { + } else { $this->error = $this->db->lasterror(); return -1; } @@ -512,8 +490,7 @@ class Mailing extends CommonObject if ($mode == 'alreadysent') $sql .= " AND statut <> 0"; elseif ($mode == 'alreadysentok') $sql .= " AND statut > 0"; elseif ($mode == 'alreadysentko') $sql .= " AND statut = -1"; - else - { + else { $this->error = 'BadValueForParameterMode'; return -2; } @@ -523,9 +500,7 @@ class Mailing extends CommonObject { $obj = $this->db->fetch_object($resql); if ($obj) return $obj->nb; - } - else - { + } else { $this->error = $this->db->lasterror(); return -1; } @@ -585,8 +560,7 @@ class Mailing extends CommonObject $reshook=$hookmanager->executeHooks('getnomurltooltip',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks if ($reshook > 0) $linkclose = $hookmanager->resPrint; */ - } - else $linkclose = ($morecss ? ' class="'.$morecss.'"' : ''); + } else $linkclose = ($morecss ? ' class="'.$morecss.'"' : ''); $linkstart = ''; diff --git a/htdocs/comm/mailing/index.php b/htdocs/comm/mailing/index.php index 61187f2e647..cf439e4314b 100644 --- a/htdocs/comm/mailing/index.php +++ b/htdocs/comm/mailing/index.php @@ -129,9 +129,7 @@ if (is_resource($handle)) } $db->free($result); - } - else - { + } else { dol_print_error($db); } print ''; @@ -157,6 +155,7 @@ print '
'; $limit = 10; $sql = "SELECT m.rowid, m.titre, m.nbemail, m.statut, m.date_creat"; $sql .= " FROM ".MAIN_DB_PREFIX."mailing as m"; +$sql .= " WHERE m.entity = ".$conf->entity; $sql .= " ORDER BY m.date_creat DESC"; $sql .= " LIMIT ".$limit; $result = $db->query($sql); @@ -190,16 +189,12 @@ if ($result) { print ''; $i++; } - } - else - { + } else { print ''.$langs->trans("None").''; } print "

"; $db->free($result); -} -else -{ +} else { dol_print_error($db); } diff --git a/htdocs/comm/mailing/list.php b/htdocs/comm/mailing/list.php index 8feaa5a4d93..d22dd130507 100644 --- a/htdocs/comm/mailing/list.php +++ b/htdocs/comm/mailing/list.php @@ -130,9 +130,7 @@ if ($filteremail) if ($search_all) $sql .= " AND (m.titre like '%".$db->escape($search_all)."%' OR m.sujet like '%".$db->escape($search_all)."%' OR m.body like '%".$db->escape($search_all)."%')"; if (!$sortorder) $sortorder = "ASC"; if (!$sortfield) $sortfield = "m.rowid"; -} -else -{ +} else { $sql = "SELECT m.rowid, m.titre, m.nbemail, m.statut, m.date_creat as datec, m.date_envoi as date_envoi"; $sql .= " FROM ".MAIN_DB_PREFIX."mailing as m"; $sql .= " WHERE m.entity = ".$conf->entity; @@ -188,7 +186,7 @@ if ($resql) print ''; print ''; - print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'generic', 0, $newcardbutton, '', $limit, 0, 0, 1); + print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'object_email', 0, $newcardbutton, '', $limit, 0, 0, 1); $moreforfilter = ''; @@ -274,9 +272,7 @@ if ($resql) if ($filteremail) { print $email::libStatutDest($obj->sendstatut, 2); - } - else - { + } else { print $email->LibStatut($obj->statut, 5); } print ''; @@ -297,9 +293,7 @@ if ($resql) print ''; $db->free($resql); -} -else -{ +} else { dol_print_error($db); } diff --git a/htdocs/comm/multiprix.php b/htdocs/comm/multiprix.php index 6d80626242d..cd5d5c9ace9 100644 --- a/htdocs/comm/multiprix.php +++ b/htdocs/comm/multiprix.php @@ -152,9 +152,7 @@ if ($_socid > 0) } $db->free($resql); print ""; - } - else - { + } else { dol_print_error($db); } } diff --git a/htdocs/comm/propal/card.php b/htdocs/comm/propal/card.php index bd5430c440a..e737aa1d8c3 100644 --- a/htdocs/comm/propal/card.php +++ b/htdocs/comm/propal/card.php @@ -161,9 +161,7 @@ if (empty($reshook)) if (!GETPOST('socid', 3)) { setEventMessages($langs->trans("NoCloneOptionsSpecified"), null, 'errors'); - } - else - { + } else { if ($object->id > 0) { if (!empty($conf->global->PROPAL_CLONE_DATE_DELIVERY)) { //Get difference between old and new delivery date and change lines according to difference @@ -204,9 +202,7 @@ if (empty($reshook)) } } } - } - - // Delete proposal + } // Delete proposal elseif ($action == 'confirm_delete' && $confirm == 'yes' && $usercandelete) { $result = $object->delete($user); @@ -217,9 +213,7 @@ if (empty($reshook)) $langs->load("errors"); setEventMessages($object->error, $object->errors, 'errors'); } - } - - // Remove line + } // Remove line elseif ($action == 'confirm_deleteline' && $confirm == 'yes' && $usercancreate) { $result = $object->deleteline($lineid); @@ -241,9 +235,7 @@ if (empty($reshook)) header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id); exit(); - } - - // Validation + } // Validation elseif ($action == 'confirm_validate' && $confirm == 'yes' && $usercanvalidate) { $result = $object->valid($user); @@ -269,9 +261,7 @@ if (empty($reshook)) if (count($object->errors) > 0) setEventMessages($object->error, $object->errors, 'errors'); else setEventMessages($langs->trans($object->error), null, 'errors'); } - } - - elseif ($action == 'setdate' && $usercancreate) + } elseif ($action == 'setdate' && $usercancreate) { $datep = dol_mktime(12, 0, 0, $_POST['remonth'], $_POST['reday'], $_POST['reyear']); @@ -285,21 +275,17 @@ if (empty($reshook)) if ($result < 0) dol_print_error($db, $object->error); } - } - elseif ($action == 'setecheance' && $usercancreate) + } elseif ($action == 'setecheance' && $usercancreate) { $result = $object->set_echeance($user, dol_mktime(12, 0, 0, $_POST['echmonth'], $_POST['echday'], $_POST['echyear'])); if ($result < 0) dol_print_error($db, $object->error); - } - elseif ($action == 'setdate_livraison' && $usercancreate) + } elseif ($action == 'setdate_livraison' && $usercancreate) { $result = $object->set_date_livraison($user, dol_mktime(12, 0, 0, $_POST['date_livraisonmonth'], $_POST['date_livraisonday'], $_POST['date_livraisonyear'])); if ($result < 0) dol_print_error($db, $object->error); - } - - // Positionne ref client + } // Positionne ref client elseif ($action == 'setref_client' && $usercancreate) { $result = $object->set_ref_client($user, GETPOST('ref_client')); @@ -307,15 +293,11 @@ if (empty($reshook)) { setEventMessages($object->error, $object->errors, 'errors'); } - } - - // Set incoterm + } // Set incoterm elseif ($action == 'set_incoterms' && !empty($conf->incoterm->enabled) && $usercancreate) { $result = $object->setIncoterms(GETPOST('incoterm_id', 'int'), GETPOST('location_incoterms', 'alpha')); - } - - // Create proposal + } // Create proposal elseif ($action == 'add' && $usercancreate) { $object->socid = $socid; @@ -549,9 +531,8 @@ if (empty($reshook)) setEventMessages($object->error, $object->errors, 'errors'); $error++; } - } // Standard creation - else - { + } // Standard creation + else { $id = $object->create($user); } @@ -602,24 +583,18 @@ if (empty($reshook)) header('Location: '.$_SERVER["PHP_SELF"].'?id='.$id); exit(); - } - else - { + } else { $db->rollback(); $action = 'create'; } - } - else - { + } else { setEventMessages($object->error, $object->errors, 'errors'); $db->rollback(); $action = 'create'; } } } - } - - // Classify billed + } // Classify billed elseif ($action == 'classifybilled' && $usercanclose) { $db->begin(); @@ -634,14 +609,10 @@ if (empty($reshook)) if (!$error) { $db->commit(); - } - else - { + } else { $db->rollback(); } - } - - // Close proposal + } // Close proposal elseif ($action == 'setstatut' && $usercanclose && !GETPOST('cancel', 'alpha')) { if (!(GETPOST('statut', 'int') > 0)) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("CloseAs")), null, 'errors'); @@ -662,16 +633,12 @@ if (empty($reshook)) if (!$error) { $db->commit(); - } - else - { + } else { $db->rollback(); } } } - } - - // Reopen proposal + } // Reopen proposal elseif ($action == 'confirm_reopen' && $usercanclose && !GETPOST('cancel', 'alpha')) { // prevent browser refresh from reopening proposal several times if ($object->statut == Propal::STATUS_SIGNED || $object->statut == Propal::STATUS_NOTSIGNED || $object->statut == Propal::STATUS_BILLED) @@ -688,15 +655,11 @@ if (empty($reshook)) if (!$error) { $db->commit(); - } - else - { + } else { $db->rollback(); } } - } - - // add lines from objectlinked + } // add lines from objectlinked elseif ($action == 'import_lines_from_object' && $user->rights->propal->creer && $object->statut == Propal::STATUS_DRAFT @@ -712,8 +675,7 @@ if (empty($reshook)) { dol_include_once('/'.$fromElement.'/class/'.$fromElement.'.class.php'); $lineClassName = 'OrderLine'; - } - elseif ($fromElement == 'propal') + } elseif ($fromElement == 'propal') { dol_include_once('/comm/'.$fromElement.'/class/'.$fromElement.'.class.php'); $lineClassName = 'PropaleLigne'; @@ -765,8 +727,7 @@ if (empty($reshook)) } else { $error++; } - } - else { + } else { $error++; } } @@ -805,9 +766,7 @@ if (empty($reshook)) $ret = $object->fetch($id); // Reload to get new records $object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); } - } - - elseif ($action == "setabsolutediscount" && $usercancreate) { + } elseif ($action == "setabsolutediscount" && $usercancreate) { if ($_POST["remise_id"]) { if ($object->id > 0) { $result = $object->insert_discount($_POST["remise_id"]); @@ -816,9 +775,7 @@ if (empty($reshook)) } } } - } - - // Add line + } // Add line elseif ($action == 'addline' && $usercancreate) { // Set if we used free entry or predefined product $predef = ''; @@ -830,9 +787,7 @@ if (empty($reshook)) { $idprod = 0; $tva_tx = (GETPOST('tva_tx') ? GETPOST('tva_tx') : 0); - } - else - { + } else { $idprod = GETPOST('idprod', 'int'); $tva_tx = ''; } @@ -924,8 +879,7 @@ if (empty($reshook)) if (isset($prod->multiprices_tva_tx[$object->thirdparty->price_level])) $tva_tx = $prod->multiprices_tva_tx[$object->thirdparty->price_level]; if (isset($prod->multiprices_recuperableonly[$object->thirdparty->price_level])) $tva_npr = $prod->multiprices_recuperableonly[$object->thirdparty->price_level]; } - } - // If price per customer + } // If price per customer elseif (!empty($conf->global->PRODUIT_CUSTOMER_PRICES)) { require_once DOL_DOCUMENT_ROOT.'/product/class/productcustomerprice.class.php'; @@ -947,8 +901,7 @@ if (empty($reshook)) if (empty($tva_tx)) $tva_npr = 0; } } - } - // If price per quantity + } // If price per quantity elseif (!empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY)) { if ($prod->prices_by_qty[0]) // yes, this product has some prices per quantity @@ -964,17 +917,14 @@ if (empty($reshook)) if ($priceforthequantityarray['price_base_type'] == 'HT') { $pu_ht = $priceforthequantityarray['unitprice']; - } - else - { + } else { $pu_ttc = $priceforthequantityarray['unitprice']; } // Note: the remise_percent or price by qty is used to set data on form, so we will use value from POST. break; } } - } - // If price per quantity and customer + } // If price per quantity and customer elseif (!empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES)) { if ($prod->prices_by_qty[$object->thirdparty->price_level]) // yes, this product has some prices per quantity @@ -990,9 +940,7 @@ if (empty($reshook)) if ($priceforthequantityarray['price_base_type'] == 'HT') { $pu_ht = $priceforthequantityarray['unitprice']; - } - else - { + } else { $pu_ttc = $priceforthequantityarray['unitprice']; } // Note: the remise_percent or price by qty is used to set data on form, so we will use value from POST. @@ -1008,8 +956,7 @@ if (empty($reshook)) if (!empty($price_ht)) { $pu_ht = price2num($price_ht, 'MU'); $pu_ttc = price2num($pu_ht * (1 + ($tmpvat / 100)), 'MU'); - } - // On reevalue prix selon taux tva car taux tva transaction peut etre different + } // On reevalue prix selon taux tva car taux tva transaction peut etre different // de ceux du produit par defaut (par exemple si pays different entre vendeur et acheteur). elseif ($tmpvat != $tmpprodvat) { if ($price_base_type != 'HT') { @@ -1180,9 +1127,7 @@ if (empty($reshook)) } } } - } - - // Update a line within proposal + } // Update a line within proposal elseif ($action == 'updateline' && $usercancreate && GETPOST('save')) { // Define info_bits @@ -1319,62 +1264,38 @@ if (empty($reshook)) } elseif ($action == 'updateline' && $usercancreate && GETPOST('cancel', 'alpha')) { header('Location: '.$_SERVER['PHP_SELF'].'?id='.$object->id); // Pour reaffichage de la fiche en cours d'edition exit(); - } - - elseif ($action == 'classin' && $usercancreate) { + } elseif ($action == 'classin' && $usercancreate) { // Set project $object->setProject(GETPOST('projectid', 'int')); - } - - // Delivery time + } // Delivery time elseif ($action == 'setavailability' && $usercancreate) { $result = $object->set_availability($user, GETPOST('availability_id', 'int')); - } - - // Origin of the commercial proposal + } // Origin of the commercial proposal elseif ($action == 'setdemandreason' && $usercancreate) { $result = $object->set_demand_reason($user, GETPOST('demand_reason_id', 'int')); - } - - // Terms of payment + } // Terms of payment elseif ($action == 'setconditions' && $usercancreate) { $result = $object->setPaymentTerms(GETPOST('cond_reglement_id', 'int')); - } - - elseif ($action == 'setremisepercent' && $usercancreate) { + } elseif ($action == 'setremisepercent' && $usercancreate) { $result = $object->set_remise_percent($user, $_POST['remise_percent']); - } - - elseif ($action == 'setremiseabsolue' && $usercancreate) { + } elseif ($action == 'setremiseabsolue' && $usercancreate) { $result = $object->set_remise_absolue($user, $_POST['remise_absolue']); - } - - // Payment choice + } // Payment choice elseif ($action == 'setmode' && $usercancreate) { $result = $object->setPaymentMethods(GETPOST('mode_reglement_id', 'int')); - } - - // Multicurrency Code + } // Multicurrency Code elseif ($action == 'setmulticurrencycode' && $usercancreate) { $result = $object->setMulticurrencyCode(GETPOST('multicurrency_code', 'alpha')); - } - - // Multicurrency rate + } // Multicurrency rate elseif ($action == 'setmulticurrencyrate' && $usercancreate) { $result = $object->setMulticurrencyRate(price2num(GETPOST('multicurrency_tx'))); - } - - // bank account + } // bank account elseif ($action == 'setbankaccount' && $usercancreate) { $result = $object->setBankAccount(GETPOST('fk_account', 'int')); - } - - // shipping method + } // shipping method elseif ($action == 'setshippingmethod' && $usercancreate) { $result = $object->setShippingMethod(GETPOST('shipping_method_id', 'int')); - } - - elseif ($action == 'update_extras') { + } elseif ($action == 'update_extras') { $object->oldcopy = dol_clone($object); // Fill array 'array_options' with data from update form @@ -1412,18 +1333,14 @@ if (empty($reshook)) setEventMessages($object->error, $object->errors, 'errors'); } } - } - - // Toggle the status of a contact + } // Toggle the status of a contact elseif ($action == 'swapstatut') { if ($object->fetch($id) > 0) { $result = $object->swapContactStatus(GETPOST('ligne')); } else { dol_print_error($db); } - } - - // Delete a contact + } // Delete a contact elseif ($action == 'deletecontact') { $object->fetch($id); $result = $object->delete_contact($lineid); @@ -1533,9 +1450,7 @@ if ($action == 'create') if (!empty($conf->global->MULTICURRENCY_USE_ORIGIN_TX) && !empty($objectsrc->multicurrency_tx)) $currency_tx = $objectsrc->multicurrency_tx; } } - } - else - { + } else { if (!empty($conf->multicurrency->enabled) && !empty($soc->multicurrency_code)) $currency_code = $soc->multicurrency_code; } @@ -1908,24 +1823,16 @@ if ($action == 'create') } $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('SetAcceptedRefused'), $text, 'setstatut', $formquestion, '', 1, 250); - } - - // Confirm delete + } // Confirm delete elseif ($action == 'delete') { $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('DeleteProp'), $langs->trans('ConfirmDeleteProp', $object->ref), 'confirm_delete', '', 0, 1); - } - - // Confirm reopen + } // Confirm reopen elseif ($action == 'reopen') { $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ReOpen'), $langs->trans('ConfirmReOpenProp', $object->ref), 'confirm_reopen', '', 0, 1); - } - - // Confirmation delete product/service line + } // Confirmation delete product/service line elseif ($action == 'ask_deleteline') { $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&lineid='.$lineid, $langs->trans('DeleteProductLine'), $langs->trans('ConfirmDeleteProductLine'), 'confirm_deleteline', '', 0, 1); - } - - // Confirm validate proposal + } // Confirm validate proposal elseif ($action == 'validate') { $error = 0; @@ -2309,9 +2216,7 @@ if ($action == 'create') if ($action != 'editincoterm') { print $form->textwithpicto($object->display_incoterms(), $object->label_incoterms, 1); - } - else - { + } else { print $form->select_incoterms((!empty($object->fk_incoterms) ? $object->fk_incoterms : ''), (!empty($object->location_incoterms) ? $object->location_incoterms : ''), $_SERVER['PHP_SELF'].'?id='.$object->id); } print ''; @@ -2478,9 +2383,7 @@ if ($action == 'create') if ($usercanvalidate) { print '
'.$langs->trans('Validate').''; - } - else - print ''.$langs->trans('Validate').''; + } else print ''.$langs->trans('Validate').''; } // Create event /*if ($conf->agenda->enabled && ! empty($conf->global->MAIN_ADD_EVENT_ON_ELEMENT_CARD)) // Add hidden condition because this is not a "workflow" action so should appears somewhere else on page. @@ -2503,8 +2406,7 @@ if ($action == 'create') if ($object->statut == Propal::STATUS_VALIDATED || $object->statut == Propal::STATUS_SIGNED || !empty($conf->global->PROPOSAL_SENDBYEMAIL_FOR_ALL_STATUS)) { if ($usercansend) { print ''.$langs->trans('SendMail').''; - } else - print ''.$langs->trans('SendMail').''; + } else print ''.$langs->trans('SendMail').''; } } @@ -2556,9 +2458,7 @@ if ($action == 'create') if ($usercanclose) { print 'socid.'">'.$langs->trans("ClassifyBilled").''; - } - else - { + } else { print ''.$langs->trans("ClassifyBilled").''; } } @@ -2596,13 +2496,13 @@ if ($action == 'create') /* * Documents generes */ - $filename = dol_sanitizeFileName($object->ref); + $objref = dol_sanitizeFileName($object->ref); $filedir = $conf->propal->multidir_output[$object->entity]."/".dol_sanitizeFileName($object->ref); $urlsource = $_SERVER["PHP_SELF"]."?id=".$object->id; $genallowed = $usercanread; $delallowed = $usercancreate; - print $formfile->showdocuments('propal', $filename, $filedir, $urlsource, $genallowed, $delallowed, $object->modelpdf, 1, 0, 0, 28, 0, '', 0, '', $soc->default_lang, '', $object); + print $formfile->showdocuments('propal', $objref, $filedir, $urlsource, $genallowed, $delallowed, $object->modelpdf, 1, 0, 0, 28, 0, '', 0, '', $soc->default_lang, '', $object); // Show links to link elements $linktoelem = $form->showLinkToObjectBlock($object, null, array('propal')); diff --git a/htdocs/comm/propal/class/api_proposals.class.php b/htdocs/comm/propal/class/api_proposals.class.php index 87c91d0f621..8efc4aa5c19 100644 --- a/htdocs/comm/propal/class/api_proposals.class.php +++ b/htdocs/comm/propal/class/api_proposals.class.php @@ -220,8 +220,7 @@ class Proposals extends DolibarrApi } $i++; } - } - else { + } else { throw new RestException(503, 'Error when retrieve propal list : '.$db->lasterror()); } if (!count($obj_ret)) { @@ -456,9 +455,7 @@ class Proposals extends DolibarrApi $updateRes = $this->propal->deleteline($lineid); if ($updateRes > 0) { return $this->get($id); - } - else - { + } else { throw new RestException(405, $this->propal->error); } } @@ -588,9 +585,7 @@ class Proposals extends DolibarrApi if ($this->propal->update(DolibarrApiAccess::$user) > 0) { return $this->get($id); - } - else - { + } else { throw new RestException(500, $this->propal->error); } } diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index 3c7cfe0006c..63e3864245b 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -390,9 +390,7 @@ class Propal extends CommonObject if ($conf->global->PRODUIT_MULTIPRICES && $this->thirdparty->price_level) { $price = $prod->multiprices[$this->thirdparty->price_level]; - } - else - { + } else { $price = $prod->price; } @@ -473,22 +471,16 @@ class Propal extends CommonObject { $this->db->commit(); return 1; - } - else - { + } else { $this->db->rollback(); return -1; } - } - else - { + } else { $this->error = $line->error; $this->db->rollback(); return -2; } - } - else - { + } else { $this->db->rollback(); return -2; } @@ -561,9 +553,7 @@ class Propal extends CommonObject if ($price_base_type == 'HT') { $pu = $pu_ht; - } - else - { + } else { $pu = $pu_ttc; } @@ -715,23 +705,17 @@ class Propal extends CommonObject { $this->db->commit(); return $this->line->id; - } - else - { + } else { $this->error = $this->db->error(); $this->db->rollback(); return -1; } - } - else - { + } else { $this->error = $this->line->error; $this->db->rollback(); return -2; } - } - else - { + } else { dol_syslog(get_class($this)."::addline status of proposal must be Draft to allow use of ->addline()", LOG_ERR); return -3; } @@ -917,17 +901,13 @@ class Propal extends CommonObject $this->db->commit(); return $result; - } - else - { + } else { $this->error = $this->line->error; $this->db->rollback(); return -1; } - } - else - { + } else { dol_syslog(get_class($this)."::updateline Erreur -2 Propal en mode incompatible pour cette action"); return -2; } @@ -959,15 +939,11 @@ class Propal extends CommonObject $this->db->commit(); return 1; - } - else - { + } else { $this->db->rollback(); return -1; } - } - else - { + } else { $this->error = 'ErrorDeleteLineNotAllowedByObjectStatus'; return -2; } @@ -1141,8 +1117,7 @@ class Propal extends CommonObject $error++; } } - } - else // Old behaviour, if linked_object has only one link per type, so is something like array('contract'=>id1)) + } else // Old behaviour, if linked_object has only one link per type, so is something like array('contract'=>id1)) { $origin_id = $tmp_origin_id; $ret = $this->add_object_linked($origin, $origin_id); @@ -1169,9 +1144,7 @@ class Propal extends CommonObject if (!is_object($this->lines[$i])) // If this->lines is not array of objects, coming from REST API { // Convert into object this->lines[$i]. $line = (object) $this->lines[$i]; - } - else - { + } else { $line = $this->lines[$i]; } // Reset fk_parent_line for line that are not child lines or special product @@ -1267,16 +1240,12 @@ class Propal extends CommonObject if ($result < 0) { $error++; } // End call triggers } - } - else - { + } else { $this->error = $this->db->lasterror(); $error++; } } - } - else - { + } else { $this->error = $this->db->lasterror(); $error++; } @@ -1286,15 +1255,11 @@ class Propal extends CommonObject $this->db->commit(); dol_syslog(get_class($this)."::create done id=".$this->id); return $this->id; - } - else - { + } else { $this->db->rollback(); return -2; } - } - else - { + } else { $this->error = $this->db->lasterror(); $this->db->rollback(); return -1; @@ -1374,9 +1339,7 @@ class Propal extends CommonObject $object->ref_client = ''; // TODO Change product price if multi-prices - } - else - { + } else { $objsoc->fetch($object->socid); } @@ -1444,9 +1407,7 @@ class Propal extends CommonObject { $this->db->commit(); return $object->id; - } - else - { + } else { $this->db->rollback(); return -1; } @@ -1500,8 +1461,7 @@ class Propal extends CommonObject if ($ref) { $sql .= " WHERE p.entity IN (".getEntity('propal').")"; // Dont't use entity if you use rowid $sql .= " AND p.ref='".$this->db->escape($ref)."'"; - } - else $sql .= " WHERE p.rowid=".$rowid; + } else $sql .= " WHERE p.rowid=".$rowid; dol_syslog(get_class($this)."::fetch", LOG_DEBUG); $resql = $this->db->query($sql); @@ -1611,9 +1571,7 @@ class Propal extends CommonObject $this->error = "Record Not Found"; return 0; - } - else - { + } else { $this->error = $this->db->lasterror(); return -1; } @@ -1707,9 +1665,7 @@ class Propal extends CommonObject } $this->db->rollback(); return -1 * $error; - } - else - { + } else { $this->db->commit(); return 1; } @@ -1837,9 +1793,7 @@ class Propal extends CommonObject $this->db->free($result); return $num; - } - else - { + } else { $this->error = $this->db->lasterror(); return -3; } @@ -1887,9 +1841,7 @@ class Propal extends CommonObject if (!$error && (preg_match('/^[\(]?PROV/i', $this->ref) || empty($this->ref))) // empty should not happened, but when it occurs, the test save life { $num = $this->getNextNumRef($soc); - } - else - { + } else { $num = $this->ref; } $this->newref = dol_sanitizeFileName($num); @@ -1962,9 +1914,7 @@ class Propal extends CommonObject $this->db->commit(); return 1; - } - else - { + } else { $this->db->rollback(); return -1; } @@ -2026,9 +1976,7 @@ class Propal extends CommonObject { $this->db->commit(); return 1; - } - else - { + } else { foreach ($this->errors as $errmsg) { dol_syslog(__METHOD__.' Error: '.$errmsg, LOG_ERR); @@ -2088,9 +2036,7 @@ class Propal extends CommonObject { $this->db->commit(); return 1; - } - else - { + } else { foreach ($this->errors as $errmsg) { dol_syslog(__METHOD__.' Error: '.$errmsg, LOG_ERR); @@ -2150,9 +2096,7 @@ class Propal extends CommonObject { $this->db->commit(); return 1; - } - else - { + } else { foreach ($this->errors as $errmsg) { dol_syslog(__METHOD__.' Error: '.$errmsg, LOG_ERR); @@ -2213,9 +2157,7 @@ class Propal extends CommonObject { $this->db->commit(); return 1; - } - else - { + } else { foreach ($this->errors as $errmsg) { dol_syslog(__METHOD__.' Error: '.$errmsg, LOG_ERR); @@ -2224,9 +2166,7 @@ class Propal extends CommonObject $this->db->rollback(); return -1 * $error; } - } - else - { + } else { $error_str = 'Propal status do not meet requirement '.$this->statut; dol_syslog(__METHOD__.$error_str, LOG_ERR); $this->error = $error_str; @@ -2286,9 +2226,7 @@ class Propal extends CommonObject { $this->db->commit(); return 1; - } - else - { + } else { foreach ($this->errors as $errmsg) { dol_syslog(__METHOD__.' Error: '.$errmsg, LOG_ERR); @@ -2297,9 +2235,7 @@ class Propal extends CommonObject $this->db->rollback(); return -1 * $error; } - } - else - { + } else { $error_str = 'Propal status do not meet requirement '.$this->statut; dol_syslog(__METHOD__.$error_str, LOG_ERR); $this->error = $error_str; @@ -2355,9 +2291,7 @@ class Propal extends CommonObject { $this->db->commit(); return 1; - } - else - { + } else { foreach ($this->errors as $errmsg) { dol_syslog(__METHOD__.' Error: '.$errmsg, LOG_ERR); @@ -2366,9 +2300,7 @@ class Propal extends CommonObject $this->db->rollback(); return -1 * $error; } - } - else - { + } else { return -1; } } @@ -2425,9 +2357,7 @@ class Propal extends CommonObject { $this->db->commit(); return 1; - } - else - { + } else { foreach ($this->errors as $errmsg) { dol_syslog(__METHOD__.' Error: '.$errmsg, LOG_ERR); @@ -2493,9 +2423,7 @@ class Propal extends CommonObject { $this->db->commit(); return 1; - } - else - { + } else { foreach ($this->errors as $errmsg) { dol_syslog(__METHOD__.' Error: '.$errmsg, LOG_ERR); @@ -2561,9 +2489,7 @@ class Propal extends CommonObject } $this->db->rollback(); return -1 * $error; - } - else - { + } else { $this->db->commit(); return 1; } @@ -2656,9 +2582,7 @@ class Propal extends CommonObject { $this->db->commit(); return 1; - } - else - { + } else { $this->statut = $this->oldcopy->statut; $this->date_cloture = $this->oldcopy->date_cloture; $this->note_private = $this->oldcopy->note_private; @@ -2666,9 +2590,7 @@ class Propal extends CommonObject $this->db->rollback(); return -1; } - } - else - { + } else { $this->error = $this->db->lasterror(); $this->db->rollback(); return -1; @@ -2717,9 +2639,7 @@ class Propal extends CommonObject { $this->db->commit(); return 1; - } - else - { + } else { foreach ($this->errors as $errmsg) { dol_syslog(__METHOD__.' Error: '.$errmsg, LOG_ERR); @@ -2784,9 +2704,7 @@ class Propal extends CommonObject $this->db->commit(); return 1; - } - else - { + } else { foreach ($this->errors as $errmsg) { dol_syslog(__METHOD__.' Error: '.$errmsg, LOG_ERR); @@ -2852,13 +2770,10 @@ class Propal extends CommonObject if ($shortlist == 1) { $ga[$obj->propalid] = $obj->ref; - } - elseif ($shortlist == 2) + } elseif ($shortlist == 2) { $ga[$obj->propalid] = $obj->ref.' ('.$obj->name.')'; - } - else - { + } else { $ga[$i]['id'] = $obj->propalid; $ga[$i]['ref'] = $obj->ref; $ga[$i]['name'] = $obj->name; @@ -2868,9 +2783,7 @@ class Propal extends CommonObject } } return $ga; - } - else - { + } else { dol_print_error($this->db); return -1; } @@ -2910,10 +2823,8 @@ class Propal extends CommonObject if ($objecttype == 'facture') { $linkedInvoices[] = $object; - } - // Cas des factures liees par un autre objet (ex: commande) - else - { + } // Cas des factures liees par un autre objet (ex: commande) + else { $this->fetchObjectLinked($object, $objecttype); foreach ($this->linkedObjectsIds as $subobjecttype => $subobjectid) { @@ -2964,13 +2875,10 @@ class Propal extends CommonObject } } return $ga; - } - else - { + } else { return -1; } - } - else return $ga; + } else return $ga; } /** @@ -3067,30 +2975,22 @@ class Propal extends CommonObject dol_syslog(get_class($this)."::delete ".$this->id." by ".$user->id, LOG_DEBUG); $this->db->commit(); return 1; - } - else - { + } else { $this->error = $this->db->lasterror(); $this->db->rollback(); return 0; } - } - else - { + } else { $this->error = $this->db->lasterror(); $this->db->rollback(); return -3; } - } - else - { + } else { $this->error = $this->db->lasterror(); $this->db->rollback(); return -2; } - } - else - { + } else { $this->db->rollback(); return -1; } @@ -3144,9 +3044,7 @@ class Propal extends CommonObject { $this->db->commit(); return 1; - } - else - { + } else { foreach ($this->errors as $errmsg) { dol_syslog(__METHOD__.' Error: '.$errmsg, LOG_ERR); @@ -3155,9 +3053,7 @@ class Propal extends CommonObject $this->db->rollback(); return -1 * $error; } - } - else - { + } else { $error_str = 'Propal status do not meet requirement '.$this->statut; dol_syslog(__METHOD__.$error_str, LOG_ERR); $this->error = $error_str; @@ -3216,9 +3112,7 @@ class Propal extends CommonObject { $this->db->commit(); return 1; - } - else - { + } else { foreach ($this->errors as $errmsg) { dol_syslog(__METHOD__.' Error: '.$errmsg, LOG_ERR); @@ -3227,9 +3121,7 @@ class Propal extends CommonObject $this->db->rollback(); return -1 * $error; } - } - else - { + } else { $error_str = 'Propal status do not meet requirement '.$this->statut; dol_syslog(__METHOD__.$error_str, LOG_ERR); $this->error = $error_str; @@ -3286,9 +3178,7 @@ class Propal extends CommonObject } } $this->db->free($result); - } - else - { + } else { dol_print_error($this->db); } } @@ -3423,9 +3313,7 @@ class Propal extends CommonObject } return $response; - } - else - { + } else { $this->error = $this->db->error(); return -1; } @@ -3503,9 +3391,7 @@ class Propal extends CommonObject $line->total_ttc = 60; $line->total_tva = 10; $line->remise_percent = 50; - } - else - { + } else { $line->total_ht = 100; $line->total_ttc = 120; $line->total_tva = 20; @@ -3564,9 +3450,7 @@ class Propal extends CommonObject } $this->db->free($resql); return 1; - } - else - { + } else { dol_print_error($this->db); $this->error = $this->db->error(); return -1; @@ -3616,16 +3500,12 @@ class Propal extends CommonObject if ($numref != "") { return $numref; - } - else - { + } else { $this->error = $obj->error; //dol_print_error($db,"Propale::getNextNumRef ".$obj->error); return ""; } - } - else - { + } else { $langs->load("errors"); print $langs->trans("Error")." ".$langs->trans("ErrorModuleSetupNotComplete", $langs->transnoentitiesnoconv("Proposal")); return ""; @@ -3673,14 +3553,11 @@ class Propal extends CommonObject if ($option == '') { $url = DOL_URL_ROOT.'/comm/propal/card.php?id='.$this->id.$get_params; - } - elseif ($option == 'compta') { // deprecated + } elseif ($option == 'compta') { // deprecated $url = DOL_URL_ROOT.'/comm/propal/card.php?id='.$this->id.$get_params; - } - elseif ($option == 'expedition') { + } elseif ($option == 'expedition') { $url = DOL_URL_ROOT.'/expedition/propal.php?id='.$this->id.$get_params; - } - elseif ($option == 'document') { + } elseif ($option == 'document') { $url = DOL_URL_ROOT.'/comm/propal/document.php?id='.$this->id.$get_params; } @@ -4028,14 +3905,10 @@ class PropaleLigne extends CommonObjectLine $this->db->free($result); return 1; - } - else - { + } else { return 0; } - } - else - { + } else { return -1; } } @@ -4084,9 +3957,7 @@ class PropaleLigne extends CommonObjectLine if (($result = $this->defineBuyPrice($this->subprice, $this->remise_percent, $this->fk_product)) < 0) { return $result; - } - else - { + } else { $this->pa_ht = $result; } } @@ -4173,9 +4044,7 @@ class PropaleLigne extends CommonObjectLine $this->db->commit(); return 1; - } - else - { + } else { $this->error = $this->db->error()." sql=".$sql; $this->db->rollback(); return -1; @@ -4227,9 +4096,7 @@ class PropaleLigne extends CommonObjectLine $this->db->commit(); return 1; - } - else - { + } else { $this->error = $this->db->error()." sql=".$sql; $this->db->rollback(); return -1; @@ -4276,9 +4143,7 @@ class PropaleLigne extends CommonObjectLine if (($result = $this->defineBuyPrice($this->subprice, $this->remise_percent, $this->fk_product)) < 0) { return $result; - } - else - { + } else { $this->pa_ht = $result; } } @@ -4355,9 +4220,7 @@ class PropaleLigne extends CommonObjectLine $this->db->commit(); return 1; - } - else - { + } else { $this->error = $this->db->error(); $this->db->rollback(); return -2; @@ -4390,9 +4253,7 @@ class PropaleLigne extends CommonObjectLine { $this->db->commit(); return 1; - } - else - { + } else { $this->error = $this->db->error(); $this->db->rollback(); return -2; diff --git a/htdocs/comm/propal/contact.php b/htdocs/comm/propal/contact.php index da86625b78f..c2f60516f1c 100644 --- a/htdocs/comm/propal/contact.php +++ b/htdocs/comm/propal/contact.php @@ -55,8 +55,7 @@ if ($id > 0 || !empty($ref)) $langs->load("errors"); setEventMessages($langs->trans('ErrorRecordNotFound'), null, 'errors'); $error++; - } - elseif ($ret < 0) + } elseif ($ret < 0) { setEventMessages($object->error, $object->errors, 'errors'); $error++; @@ -65,9 +64,7 @@ if ($id > 0 || !empty($ref)) if (!$error) { $object->fetch_thirdparty(); -} -else -{ +} else { header('Location: '.DOL_URL_ROOT.'/comm/propal/list.php'); exit; } @@ -89,31 +86,23 @@ if ($action == 'addcontact' && $user->rights->propale->creer) { header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); exit; - } - else - { + } else { if ($object->error == 'DB_ERROR_RECORD_ALREADY_EXISTS') { $langs->load("errors"); setEventMessages($langs->trans("ErrorThisContactIsAlreadyDefinedAsThisType"), null, 'errors'); - } - else - { + } else { setEventMessages($object->error, $object->errors, 'errors'); } } -} - -// Toggle the status of a contact +} // Toggle the status of a contact elseif ($action == 'swapstatut' && $user->rights->propale->creer) { if ($object->id > 0) { $result = $object->swapContactStatus(GETPOST('ligne')); } -} - -// Deletes a contact +} // Deletes a contact elseif ($action == 'deletecontact' && $user->rights->propale->creer) { $result = $object->delete_contact($lineid); @@ -122,9 +111,7 @@ elseif ($action == 'deletecontact' && $user->rights->propale->creer) { header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); exit; - } - else - { + } else { dol_print_error($db); } } diff --git a/htdocs/comm/propal/document.php b/htdocs/comm/propal/document.php index d9d12c5efb4..70c67566091 100644 --- a/htdocs/comm/propal/document.php +++ b/htdocs/comm/propal/document.php @@ -179,9 +179,7 @@ if ($object->id > 0) $permtoedit = $user->rights->propal->creer; $param = '&id='.$object->id; include_once DOL_DOCUMENT_ROOT.'/core/tpl/document_actions_post_headers.tpl.php'; -} -else -{ +} else { print $langs->trans("ErrorUnknown"); } diff --git a/htdocs/comm/propal/index.php b/htdocs/comm/propal/index.php index a320d2b83b9..9e138c52cbe 100644 --- a/htdocs/comm/propal/index.php +++ b/htdocs/comm/propal/index.php @@ -163,9 +163,7 @@ if ($resql) //print ''.$langs->trans("Total").' ('.$langs->trans("CustomersOrdersRunning").')'.$totalinprocess.''; print ''.$langs->trans("Total").''.$total.''; print "

"; -} -else -{ +} else { dol_print_error($db); } @@ -220,8 +218,7 @@ if (!empty($conf->propal->enabled)) if ($num > $nbofloop) { print ''.$langs->trans("XMoreLines", ($num - $nbofloop)).""; - } - elseif ($total > 0) + } elseif ($total > 0) { print ''.$langs->trans("Total").''.price($total).""; } @@ -310,8 +307,7 @@ if ($resql) } print ""; print "
"; -} -else dol_print_error($db); +} else dol_print_error($db); /* @@ -394,17 +390,14 @@ if (!empty($conf->propal->enabled) && $user->rights->propale->lire) if ($num > $nbofloop) { print ''.$langs->trans("XMoreLines", ($num - $nbofloop)).""; - } - elseif ($total > 0) + } elseif ($total > 0) { print ''.$langs->trans("Total")."".price($total)." "; } print ""; print "
"; } - } - else - { + } else { dol_print_error($db); } } diff --git a/htdocs/comm/propal/list.php b/htdocs/comm/propal/list.php index 360fe5a911c..6710ac56b58 100644 --- a/htdocs/comm/propal/list.php +++ b/htdocs/comm/propal/list.php @@ -414,9 +414,7 @@ if ($resql) $soc->fetch($socid); $title = $langs->trans('ListOfProposals').' - '.$soc->name; if (empty($search_societe)) $search_societe = $soc->name; - } - else - { + } else { $title = $langs->trans('ListOfProposals'); } @@ -499,7 +497,7 @@ if ($resql) print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'propal', 0, $newcardbutton, '', $limit, 0, 0, 1); $topicmail = "SendPropalRef"; - $modelmail = "proposal_send"; + $modelmail = "propal_send"; $objecttmp = new Propal($db); $trackid = 'pro'.$object->id; include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php'; @@ -1028,9 +1026,7 @@ if ($resql) { print ''.dol_print_date($db->jdate($obj->dfv), 'day'); print ''; - } - else - { + } else { print ' '; } if (!$i) $totalarray['nbfield']++; @@ -1042,9 +1038,7 @@ if ($resql) { print ''.dol_print_date($db->jdate($obj->ddelivery), 'day'); print ''; - } - else - { + } else { print ' '; } if (!$i) $totalarray['nbfield']++; @@ -1169,8 +1163,7 @@ if ($resql) if ($nbofsalesrepresentative > 3) // We print only number { print $nbofsalesrepresentative; - } - elseif ($nbofsalesrepresentative > 0) + } elseif ($nbofsalesrepresentative > 0) { $userstatic = new User($db); $j = 0; @@ -1192,9 +1185,7 @@ if ($resql) } } //else print $langs->trans("NoSalesRepresentativeAffected"); - } - else - { + } else { print ' '; } print ''; @@ -1204,7 +1195,7 @@ if ($resql) // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; // Fields from hook - $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$obj, 'i'=>$i); + $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray); $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; // Date creation @@ -1279,9 +1270,7 @@ if ($resql) $delallowed = $user->rights->propal->creer; print $formfile->showdocuments('massfilesarea_proposals', '', $filedir, $urlsource, 0, $delallowed, '', 1, 1, 0, 48, 1, $param, $title, '', '', '', null, $hidegeneratedfilelistifempty); -} -else -{ +} else { dol_print_error($db); } diff --git a/htdocs/comm/propal/stats/index.php b/htdocs/comm/propal/stats/index.php index add31f13f08..00a79f3c1be 100644 --- a/htdocs/comm/propal/stats/index.php +++ b/htdocs/comm/propal/stats/index.php @@ -112,9 +112,7 @@ if (!$user->rights->societe->client->voir || $user->socid) { $filenamenb = $dir.'/proposalsnbinyear-'.$user->id.'-'.$year.'.png'; $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=propalstats&file=proposalsnbinyear-'.$user->id.'-'.$year.'.png'; -} -else -{ +} else { $filenamenb = $dir.'/proposalsnbinyear-'.$year.'.png'; $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=propalstats&file=proposalsnbinyear-'.$year.'.png'; } @@ -152,9 +150,7 @@ if (!$user->rights->societe->client->voir || $user->socid) { $filenameamount = $dir.'/proposalsamountinyear-'.$user->id.'-'.$year.'.png'; $fileurlamount = DOL_URL_ROOT.'/viewimage.php?modulepart=propalstats&file=proposalsamountinyear-'.$user->id.'-'.$year.'.png'; -} -else -{ +} else { $filenameamount = $dir.'/proposalsamountinyear-'.$year.'.png'; $fileurlamount = DOL_URL_ROOT.'/viewimage.php?modulepart=propalstats&file=proposalsamountinyear-'.$year.'.png'; } @@ -192,9 +188,7 @@ if (!$user->rights->societe->client->voir || $user->socid) $filename_avg = $dir.'/ordersaverage-'.$user->id.'-'.$year.'.png'; if ($mode == 'customer') $fileurl_avg = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstats&file=ordersaverage-'.$user->id.'-'.$year.'.png'; if ($mode == 'supplier') $fileurl_avg = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstatssupplier&file=ordersaverage-'.$user->id.'-'.$year.'.png'; -} -else -{ +} else { $filename_avg = $dir.'/ordersaverage-'.$year.'.png'; if ($mode == 'customer') $fileurl_avg = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstats&file=ordersaverage-'.$year.'.png'; if ($mode == 'supplier') $fileurl_avg = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstatssupplier&file=ordersaverage-'.$year.'.png'; @@ -347,8 +341,7 @@ print '
'; // Show graphs print '
'; -if ($mesg) { print $mesg; } -else { +if ($mesg) { print $mesg; } else { print $px1->show(); print "
\n"; print $px2->show(); diff --git a/htdocs/comm/prospect/index.php b/htdocs/comm/prospect/index.php index ff0beef4037..b49f334dadd 100644 --- a/htdocs/comm/prospect/index.php +++ b/htdocs/comm/prospect/index.php @@ -223,9 +223,7 @@ if (!empty($conf->propal->enabled) && $user->rights->propale->lire) } print "

"; } - } - else - { + } else { dol_print_error($db); } } diff --git a/htdocs/comm/prospect/recap-prospect.php b/htdocs/comm/prospect/recap-prospect.php index b3b852c591a..e393f5fce56 100644 --- a/htdocs/comm/prospect/recap-prospect.php +++ b/htdocs/comm/prospect/recap-prospect.php @@ -83,9 +83,7 @@ if ($socid > 0) print $langs->trans("FeatureNotYetAvailable"); -} -else -{ +} else { dol_print_error($db); } diff --git a/htdocs/comm/recap-client.php b/htdocs/comm/recap-client.php index 09f5e46f94b..284c248f1f0 100644 --- a/htdocs/comm/recap-client.php +++ b/htdocs/comm/recap-client.php @@ -83,9 +83,7 @@ if ($socid > 0) print $langs->trans("FeatureNotYetAvailable"); -} -else -{ +} else { dol_print_error($db); } diff --git a/htdocs/comm/remise.php b/htdocs/comm/remise.php index dc41845516a..a7517c9cb60 100644 --- a/htdocs/comm/remise.php +++ b/htdocs/comm/remise.php @@ -70,15 +70,11 @@ if (GETPOST('action', 'aZ09') == 'setremise') { header("Location: ".$backtopage); exit; - } - else - { + } else { header("Location: remise.php?id=".$_GET["id"]); exit; } - } - else - { + } else { setEventMessages($object->error, $object->errors, 'errors'); } } @@ -252,16 +248,12 @@ if ($socid > 0) print ''; $i++; } - } - else - { + } else { print ''.$langs->trans("None").''; } $db->free($resql); print ""; - } - else - { + } else { dol_print_error($db); } } @@ -311,16 +303,12 @@ if ($socid > 0) print ''; $i++; } - } - else - { + } else { print ''.$langs->trans("None").''; } $db->free($resql); print ""; - } - else - { + } else { dol_print_error($db); } diff --git a/htdocs/comm/remx.php b/htdocs/comm/remx.php index c312591aeec..ffd4c1738c0 100644 --- a/htdocs/comm/remx.php +++ b/htdocs/comm/remx.php @@ -105,9 +105,7 @@ if ($action == 'confirm_split' && GETPOST("confirm", "alpha") == 'yes') { $newdiscount1->description = $discount->description; $newdiscount2->description = $discount->description; - } - else - { + } else { $newdiscount1->description = $discount->description.' (1)'; $newdiscount2->description = $discount->description.' (2)'; } @@ -150,9 +148,7 @@ if ($action == 'confirm_split' && GETPOST("confirm", "alpha") == 'yes') $db->commit(); header("Location: ".$_SERVER["PHP_SELF"].'?id='.$id.($backtopage ? '&backtopage='.urlencode($backtopage) : '')); // To avoid pb whith back exit; - } - else - { + } else { $db->rollback(); } } @@ -189,22 +185,16 @@ if ($action == 'setremise' && $user->rights->societe->creer) { header("Location: ".$backtopage.'&discountid='.$discountid); exit; - } - else - { + } else { header("Location: remx.php?id=".$id); exit; } - } - else - { + } else { $error++; setEventMessages($soc->error, $soc->errors, 'errors'); } } - } - else - { + } else { setEventMessages($langs->trans("ErrorFieldFormat", $langs->transnoentitiesnoconv("AmountHT")), null, 'errors'); } } @@ -224,9 +214,7 @@ if (GETPOST('action', 'aZ09') == 'confirm_remove' && GETPOST("confirm") == 'yes' $db->commit(); header("Location: ".$_SERVER["PHP_SELF"].'?id='.$id); // To avoid pb whith back exit; - } - else - { + } else { setEventMessages($discount->error, $discount->errors, 'errors'); $db->rollback(); } @@ -300,9 +288,7 @@ if ($socid > 0) $obj = $db->fetch_object($resql); $remise_all += $obj->amount; if ($obj->fk_user == $user->id) $remise_user += $obj->amount; - } - else - { + } else { dol_print_error($db); } @@ -332,9 +318,7 @@ if ($socid > 0) $obj = $db->fetch_object($resql); $remise_all += $obj->amount; if ($obj->fk_user == $user->id) $remise_user += $obj->amount; - } - else - { + } else { dol_print_error($db); } @@ -489,8 +473,7 @@ if ($socid > 0) $facturestatic->type = $obj->type; print preg_replace('/\(CREDIT_NOTE\)/', $langs->trans("CreditNote"), $obj->description).' '.$facturestatic->getNomURl(1); print ''; - } - elseif (preg_match('/\(DEPOSIT\)/', $obj->description)) + } elseif (preg_match('/\(DEPOSIT\)/', $obj->description)) { print ''; $facturestatic->id = $obj->fk_facture_source; @@ -498,8 +481,7 @@ if ($socid > 0) $facturestatic->type = $obj->type; print preg_replace('/\(DEPOSIT\)/', $langs->trans("InvoiceDeposit"), $obj->description).' '.$facturestatic->getNomURl(1); print ''; - } - elseif (preg_match('/\(EXCESS RECEIVED\)/', $obj->description)) + } elseif (preg_match('/\(EXCESS RECEIVED\)/', $obj->description)) { print ''; $facturestatic->id = $obj->fk_facture_source; @@ -507,9 +489,7 @@ if ($socid > 0) $facturestatic->type = $obj->type; print preg_replace('/\(EXCESS RECEIVED\)/', $langs->trans("ExcessReceived"), $obj->description).' '.$facturestatic->getNomURl(1); print ''; - } - else - { + } else { print ''; print $obj->description; print ''; @@ -535,8 +515,7 @@ if ($socid > 0) print 'rowid.($backtopage ? '&backtopage='.urlencode($backtopage) : '').'">'.img_split($langs->trans("SplitDiscount")).''; print 'rowid.($backtopage ? '&backtopage='.urlencode($backtopage) : '').'">'.img_delete($langs->trans("RemoveDiscount")).''; print ''; - } - else print ' '; + } else print ' '; print ''; if ($_GET["action"] == 'split' && GETPOST('remid') == $obj->rowid) @@ -546,9 +525,7 @@ if ($socid > 0) } $i++; } - } - else - { + } else { $colspan = 8; if (!empty($conf->multicurrency->enabled)) $colspan += 2; print ''.$langs->trans("None").''; @@ -569,9 +546,7 @@ if ($socid > 0) $langs->load("dict"); print $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&remid='.$showconfirminfo['rowid'].($backtopage ? '&backtopage='.urlencode($backtopage) : ''), $langs->trans('SplitDiscount'), $langs->trans('ConfirmSplitDiscount', price($showconfirminfo['amount_ttc']), $langs->transnoentities("Currency".$conf->currency)), 'confirm_split', $formquestion, '', 0); } - } - else - { + } else { dol_print_error($db); } } @@ -646,8 +621,7 @@ if ($socid > 0) $facturefournstatic->type = $obj->type; print preg_replace('/\(CREDIT_NOTE\)/', $langs->trans("CreditNote"), $obj->description).' '.$facturefournstatic->getNomURl(1); print ''; - } - elseif (preg_match('/\(DEPOSIT\)/', $obj->description)) + } elseif (preg_match('/\(DEPOSIT\)/', $obj->description)) { print ''; $facturefournstatic->id = $obj->fk_invoice_supplier_source; @@ -655,8 +629,7 @@ if ($socid > 0) $facturefournstatic->type = $obj->type; print preg_replace('/\(DEPOSIT\)/', $langs->trans("InvoiceDeposit"), $obj->description).' '.$facturefournstatic->getNomURl(1); print ''; - } - elseif (preg_match('/\(EXCESS PAID\)/', $obj->description)) + } elseif (preg_match('/\(EXCESS PAID\)/', $obj->description)) { print ''; $facturefournstatic->id = $obj->fk_invoice_supplier_source; @@ -664,9 +637,7 @@ if ($socid > 0) $facturefournstatic->type = $obj->type; print preg_replace('/\(EXCESS PAID\)/', $langs->trans("ExcessPaid"), $obj->description).' '.$facturefournstatic->getNomURl(1); print ''; - } - else - { + } else { print ''; print $obj->description; print ''; @@ -692,8 +663,7 @@ if ($socid > 0) print 'rowid.($backtopage ? '&backtopage='.urlencode($backtopage) : '').'">'.img_split($langs->trans("SplitDiscount")).''; print 'rowid.($backtopage ? '&backtopage='.urlencode($backtopage) : '').'">'.img_delete($langs->trans("RemoveDiscount")).''; print ''; - } - else print ' '; + } else print ' '; print ''; if ($_GET["action"] == 'split' && GETPOST('remid') == $obj->rowid) @@ -703,9 +673,7 @@ if ($socid > 0) } $i++; } - } - else - { + } else { $colspan = 8; if (!empty($conf->multicurrency->enabled)) $colspan += 2; print ''.$langs->trans("None").''; @@ -726,9 +694,7 @@ if ($socid > 0) $langs->load("dict"); print $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&remid='.$showconfirminfo['rowid'].($backtopage ? '&backtopage='.urlencode($backtopage) : ''), $langs->trans('SplitDiscount'), $langs->trans('ConfirmSplitDiscount', price($showconfirminfo['amount_ttc']), $langs->transnoentities("Currency".$conf->currency)), 'confirm_split', $formquestion, 0, 0); } - } - else - { + } else { dol_print_error($db); } @@ -857,8 +823,7 @@ if ($socid > 0) $facturestatic->type = $obj->type; print preg_replace('/\(CREDIT_NOTE\)/', $langs->trans("CreditNote"), $obj->description).' '.$facturestatic->getNomURl(1); print ''; - } - elseif (preg_match('/\(DEPOSIT\)/', $obj->description)) + } elseif (preg_match('/\(DEPOSIT\)/', $obj->description)) { print ''; $facturestatic->id = $obj->fk_facture_source; @@ -866,8 +831,7 @@ if ($socid > 0) $facturestatic->type = $obj->type; print preg_replace('/\(DEPOSIT\)/', $langs->trans("InvoiceDeposit"), $obj->description).' '.$facturestatic->getNomURl(1); print ''; - } - elseif (preg_match('/\(EXCESS RECEIVED\)/', $obj->description)) + } elseif (preg_match('/\(EXCESS RECEIVED\)/', $obj->description)) { print ''; $facturestatic->id = $obj->fk_facture_source; @@ -875,9 +839,7 @@ if ($socid > 0) $facturestatic->type = $obj->type; print preg_replace('/\(EXCESS RECEIVED\)/', $langs->trans("Invoice"), $obj->description).' '.$facturestatic->getNomURl(1); print ''; - } - else - { + } else { print ''; print $obj->description; print ''; @@ -906,9 +868,7 @@ if ($socid > 0) print ''; $i++; } - } - else - { + } else { $colspan = 8; if (!empty($conf->multicurrency->enabled)) $colspan += 2; print ''.$langs->trans("None").''; @@ -916,9 +876,7 @@ if ($socid > 0) print ""; print '
'; - } - else - { + } else { dol_print_error($db); } } @@ -1035,8 +993,7 @@ if ($socid > 0) $facturefournstatic->type = $obj->type; print preg_replace('/\(CREDIT_NOTE\)/', $langs->trans("CreditNote"), $obj->description).' '.$facturefournstatic->getNomURl(1); print ''; - } - elseif (preg_match('/\(DEPOSIT\)/', $obj->description)) + } elseif (preg_match('/\(DEPOSIT\)/', $obj->description)) { print ''; $facturefournstatic->id = $obj->fk_invoice_supplier_source; @@ -1044,8 +1001,7 @@ if ($socid > 0) $facturefournstatic->type = $obj->type; print preg_replace('/\(DEPOSIT\)/', $langs->trans("InvoiceDeposit"), $obj->description).' '.$facturefournstatic->getNomURl(1); print ''; - } - elseif (preg_match('/\(EXCESS PAID\)/', $obj->description)) + } elseif (preg_match('/\(EXCESS PAID\)/', $obj->description)) { print ''; $facturefournstatic->id = $obj->fk_invoice_supplier_source; @@ -1053,9 +1009,7 @@ if ($socid > 0) $facturefournstatic->type = $obj->type; print preg_replace('/\(EXCESS PAID\)/', $langs->trans("Invoice"), $obj->description).' '.$facturefournstatic->getNomURl(1); print ''; - } - else - { + } else { print ''; print $obj->description; print ''; @@ -1083,9 +1037,7 @@ if ($socid > 0) print ''; $i++; } - } - else - { + } else { $colspan = 8; if (!empty($conf->multicurrency->enabled)) $colspan += 2; print ''.$langs->trans("None").''; @@ -1093,9 +1045,7 @@ if ($socid > 0) print ""; print '
'; - } - else - { + } else { dol_print_error($db); } diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php index 4764b53a5c9..3efb94855a7 100644 --- a/htdocs/commande/card.php +++ b/htdocs/commande/card.php @@ -154,9 +154,7 @@ if (empty($reshook)) if (1 == 0 && !GETPOST('clone_content') && !GETPOST('clone_receivers')) { setEventMessages($langs->trans("NoCloneOptionsSpecified"), null, 'errors'); - } - else - { + } else { if ($object->id > 0) { // Because createFromClone modifies the object, we must clone it so that we can restore it later @@ -167,9 +165,7 @@ if (empty($reshook)) { header("Location: ".$_SERVER['PHP_SELF'].'?id='.$result); exit; - } - else - { + } else { setEventMessages($object->error, $object->errors, 'errors'); $object = $orig; $action = ''; @@ -187,9 +183,7 @@ if (empty($reshook)) if ($result > 0) { setEventMessages($langs->trans('OrderReopened', $object->ref), null); - } - else - { + } else { setEventMessages($object->error, $object->errors, 'errors'); } } @@ -203,9 +197,7 @@ if (empty($reshook)) { header('Location: list.php?restore_lastsearch_values=1'); exit; - } - else - { + } else { setEventMessages($object->error, $object->errors, 'errors'); } } @@ -234,9 +226,7 @@ if (empty($reshook)) header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id); exit; - } - else - { + } else { setEventMessages($object->error, $object->errors, 'errors'); } } @@ -502,17 +492,14 @@ if (empty($reshook)) setEventMessages($object->error, $object->errors, 'errors'); } } - } - - elseif ($action == 'classifybilled' && $usercancreate) + } elseif ($action == 'classifybilled' && $usercancreate) { $ret = $object->classifyBilled($user); if ($ret < 0) { setEventMessages($object->error, $object->errors, 'errors'); } - } - elseif ($action == 'classifyunbilled' && $usercancreate) + } elseif ($action == 'classifyunbilled' && $usercancreate) { $ret = $object->classifyUnBilled(); if ($ret < 0) { @@ -527,17 +514,13 @@ if (empty($reshook)) { setEventMessages($object->error, $object->errors, 'errors'); } - } - - elseif ($action == 'setremise' && $usercancreate) { + } elseif ($action == 'setremise' && $usercancreate) { $result = $object->set_remise($user, GETPOST('remise')); if ($result < 0) { setEventMessages($object->error, $object->errors, 'errors'); } - } - - elseif ($action == 'setabsolutediscount' && $usercancreate) { + } elseif ($action == 'setabsolutediscount' && $usercancreate) { if (GETPOST('remise_id')) { if ($object->id > 0) { $object->insert_discount(GETPOST('remise_id')); @@ -545,9 +528,7 @@ if (empty($reshook)) dol_print_error($db, $object->error); } } - } - - elseif ($action == 'setdate' && $usercancreate) { + } elseif ($action == 'setdate' && $usercancreate) { // print "x ".$_POST['liv_month'].", ".$_POST['liv_day'].", ".$_POST['liv_year']; $date = dol_mktime(0, 0, 0, GETPOST('order_month'), GETPOST('order_day'), GETPOST('order_year')); @@ -555,19 +536,16 @@ if (empty($reshook)) if ($result < 0) { setEventMessages($object->error, $object->errors, 'errors'); } - } + } elseif ($action == 'setdate_livraison' && $usercancreate) { + // print "x ".$_POST['liv_month'].", ".$_POST['liv_day'].", ".$_POST['liv_year']; + $datedelivery = dol_mktime(GETPOST('liv_hour', 'int'), GETPOST('liv_min', 'int'), 0, GETPOST('liv_month', 'int'), GETPOST('liv_day', 'int'), GETPOST('liv_year', 'int')); - elseif ($action == 'setdate_livraison' && $usercancreate) { - // print "x ".$_POST['liv_month'].", ".$_POST['liv_day'].", ".$_POST['liv_year']; - $datelivraison = dol_mktime(0, 0, 0, GETPOST('liv_month'), GETPOST('liv_day'), GETPOST('liv_year')); - - $result = $object->set_date_livraison($user, $datelivraison); - if ($result < 0) { - setEventMessages($object->error, $object->errors, 'errors'); - } - } - - elseif ($action == 'setmode' && $usercancreate) { + $object->fetch($id); + $result = $object->set_date_livraison($user, $datedelivery); + if ($result < 0) { + setEventMessages($object->error, $object->errors, 'errors'); + } + } elseif ($action == 'setmode' && $usercancreate) { $result = $object->setPaymentMethods(GETPOST('mode_reglement_id', 'int')); if ($result < 0) setEventMessages($object->error, $object->errors, 'errors'); @@ -581,21 +559,15 @@ if (empty($reshook)) // Multicurrency rate elseif ($action == 'setmulticurrencyrate' && $usercancreate) { $result = $object->setMulticurrencyRate(price2num(GETPOST('multicurrency_tx'))); - } - - elseif ($action == 'setavailability' && $usercancreate) { + } elseif ($action == 'setavailability' && $usercancreate) { $result = $object->availability(GETPOST('availability_id')); if ($result < 0) setEventMessages($object->error, $object->errors, 'errors'); - } - - elseif ($action == 'setdemandreason' && $usercancreate) { + } elseif ($action == 'setdemandreason' && $usercancreate) { $result = $object->demand_reason(GETPOST('demand_reason_id')); if ($result < 0) setEventMessages($object->error, $object->errors, 'errors'); - } - - elseif ($action == 'setconditions' && $usercancreate) { + } elseif ($action == 'setconditions' && $usercancreate) { $result = $object->setPaymentTerms(GETPOST('cond_reglement_id', 'int')); if ($result < 0) { dol_print_error($db, $object->error); @@ -648,13 +620,9 @@ if (empty($reshook)) if ($result < 0) { setEventMessages($object->error, $object->errors, 'errors'); } - } - - elseif ($action == 'setremisepercent' && $usercancreate) { + } elseif ($action == 'setremisepercent' && $usercancreate) { $result = $object->set_remise($user, GETPOST('remise_percent')); - } - - elseif ($action == 'setremiseabsolue' && $usercancreate) { + } elseif ($action == 'setremiseabsolue' && $usercancreate) { $result = $object->set_remise_absolue($user, GETPOST('remise_absolue')); } @@ -674,9 +642,7 @@ if (empty($reshook)) { $idprod = 0; $tva_tx = (GETPOST('tva_tx') ? GETPOST('tva_tx') : 0); - } - else - { + } else { $idprod = GETPOST('idprod', 'int'); $tva_tx = ''; } @@ -724,9 +690,7 @@ if (empty($reshook)) if ($res = $prodcomb->fetchByProductCombination2ValuePairs($idprod, $combinations)) { $idprod = $res->fk_product_child; - } - else - { + } else { setEventMessages($langs->trans('ErrorProductCombinationNotFound'), null, 'errors'); $error++; } @@ -794,9 +758,7 @@ if (empty($reshook)) $tva_npr = $prodcustprice->lines[0]->recuperableonly; if (empty($tva_tx)) $tva_npr = 0; } - } - else - { + } else { setEventMessages($prodcustprice->error, $prodcustprice->errors, 'errors'); } } @@ -816,9 +778,7 @@ if (empty($reshook)) if ($priceforthequantityarray['price_base_type'] == 'HT') { $pu_ht = $priceforthequantityarray['unitprice']; - } - else - { + } else { $pu_ttc = $priceforthequantityarray['unitprice']; } // Note: the remise_percent or price by qty is used to set data on form, so we will use value from POST. @@ -841,9 +801,7 @@ if (empty($reshook)) if ($priceforthequantityarray['price_base_type'] == 'HT') { $pu_ht = $priceforthequantityarray['unitprice']; - } - else - { + } else { $pu_ttc = $priceforthequantityarray['unitprice']; } // Note: the remise_percent or price by qty is used to set data on form, so we will use value from POST. @@ -1156,9 +1114,7 @@ if (empty($reshook)) } elseif ($action == 'updateline' && $usercancreate && GETPOST('cancel', 'alpha') == $langs->trans('Cancel')) { header('Location: '.$_SERVER['PHP_SELF'].'?id='.$object->id); // Pour reaffichage de la fiche en cours d'edition exit(); - } - - elseif ($action == 'confirm_validate' && $confirm == 'yes' && $usercanvalidate) + } elseif ($action == 'confirm_validate' && $confirm == 'yes' && $usercanvalidate) { $idwarehouse = GETPOST('idwarehouse'); @@ -1166,9 +1122,7 @@ if (empty($reshook)) if (empty($conf->global->STOCK_SUPPORTS_SERVICES)) { $qualified_for_stock_change = $object->hasProductsOrServices(2); - } - else - { + } else { $qualified_for_stock_change = $object->hasProductsOrServices(1); } @@ -1203,9 +1157,7 @@ if (empty($reshook)) $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref); } - } - else - { + } else { setEventMessages($object->error, $object->errors, 'errors'); } } @@ -1219,9 +1171,7 @@ if (empty($reshook)) if (empty($conf->global->STOCK_SUPPORTS_SERVICES)) { $qualified_for_stock_change = $object->hasProductsOrServices(2); - } - else - { + } else { $qualified_for_stock_change = $object->hasProductsOrServices(1); } @@ -1258,16 +1208,12 @@ if (empty($reshook)) } } } - } - - elseif ($action == 'confirm_shipped' && $confirm == 'yes' && $usercanclose) { + } elseif ($action == 'confirm_shipped' && $confirm == 'yes' && $usercanclose) { $result = $object->cloture($user); if ($result < 0) { setEventMessages($object->error, $object->errors, 'errors'); } - } - - elseif ($action == 'confirm_cancel' && $confirm == 'yes' && $usercanvalidate) + } elseif ($action == 'confirm_cancel' && $confirm == 'yes' && $usercanvalidate) { $idwarehouse = GETPOST('idwarehouse'); @@ -1275,9 +1221,7 @@ if (empty($reshook)) if (empty($conf->global->STOCK_SUPPORTS_SERVICES)) { $qualified_for_stock_change = $object->hasProductsOrServices(2); - } - else - { + } else { $qualified_for_stock_change = $object->hasProductsOrServices(1); } @@ -1348,8 +1292,7 @@ if (empty($reshook)) { dol_include_once('/'.$fromElement.'/class/'.$fromElement.'.class.php'); $lineClassName = 'OrderLine'; - } - elseif ($fromElement == 'propal') + } elseif ($fromElement == 'propal') { dol_include_once('/comm/'.$fromElement.'/class/'.$fromElement.'.class.php'); $lineClassName = 'PropaleLigne'; @@ -1401,8 +1344,7 @@ if (empty($reshook)) } else { $error++; } - } - else { + } else { $error++; } } @@ -1532,12 +1474,10 @@ if ($action == 'create' && $usercancreate) // For compatibility if ($element == 'order' || $element == 'commande') { $element = $subelement = 'commande'; - } - elseif ($element == 'propal') { + } elseif ($element == 'propal') { $element = 'comm/propal'; $subelement = 'propal'; - } - elseif ($element == 'contract') { + } elseif ($element == 'contract') { $element = $subelement = 'contrat'; } @@ -1583,9 +1523,7 @@ if ($action == 'create' && $usercancreate) // Object source contacts list $srccontactslist = $objectsrc->liste_contact(-1, 'external', 1); } - } - else - { + } else { $cond_reglement_id = $soc->cond_reglement_id; $mode_reglement_id = $soc->mode_reglement_id; $fk_account = $soc->fk_account; @@ -1623,8 +1561,7 @@ if ($action == 'create' && $usercancreate) print ''.$langs->trans('RefCustomer').''; if (!empty($conf->global->MAIN_USE_PROPAL_REFCLIENT_FOR_ORDER) && !empty($origin) && !empty($originid)) print ''; - else - print ''; + else print ''; print ''; // Thirdparty @@ -1681,15 +1618,14 @@ if ($action == 'create' && $usercancreate) print $form->selectDate('', 're', '', '', '', "crea_commande", 1, 1); // Always autofill date with current date print ''; - // Delivery date planed - print "".$langs->trans("DateDeliveryPlanned").''; - if (empty($datedelivery)) - { - if (!empty($conf->global->DATE_LIVRAISON_WEEK_DELAY)) $datedelivery = time() + ((7 * $conf->global->DATE_LIVRAISON_WEEK_DELAY) * 24 * 60 * 60); - else $datedelivery = empty($conf->global->MAIN_AUTOFILL_DATE_DELIVERY) ?-1 : ''; - } - print $form->selectDate($datedelivery, 'liv_', '', '', '', "crea_commande", 1, 1); - print ""; + // Date delivery planned + print ''.$langs->trans("DateDeliveryPlanned").''; + print ''; + //print dol_print_date($object->date_livraison, "day"); // date_livraison come from order and will be stored into date_delivery planed. + $date_delivery = ($date_delivery ? $date_delivery : $object->date_livraison); // $date_delivery comes from GETPOST + print $form->selectDate($date_delivery ? $date_delivery : -1, 'date_delivery', 1, 1, 1); + print "\n"; + print ''; // terms of the settlement print ''.$langs->trans('PaymentConditionsShort').''; @@ -1957,9 +1893,7 @@ if ($action == 'create' && $usercancreate) if (empty($conf->global->STOCK_SUPPORTS_SERVICES)) { $qualified_for_stock_change = $object->hasProductsOrServices(2); - } - else - { + } else { $qualified_for_stock_change = $object->hasProductsOrServices(1); } @@ -1989,9 +1923,7 @@ if ($action == 'create' && $usercancreate) if (empty($conf->global->STOCK_SUPPORTS_SERVICES)) { $qualified_for_stock_change = $object->hasProductsOrServices(2); - } - else - { + } else { $qualified_for_stock_change = $object->hasProductsOrServices(1); } @@ -2031,9 +1963,7 @@ if ($action == 'create' && $usercancreate) if (empty($conf->global->STOCK_SUPPORTS_SERVICES)) { $qualified_for_stock_change = $object->hasProductsOrServices(2); - } - else - { + } else { $qualified_for_stock_change = $object->hasProductsOrServices(1); } @@ -2209,11 +2139,11 @@ if ($action == 'create' && $usercancreate) print '
'; print ''; print ''; - print $form->selectDate($object->date_livraison ? $object->date_livraison : - 1, 'liv_', '', '', '', "setdate_livraison"); + print $form->selectDate($object->date_livraison ? $object->date_livraison : -1, 'liv_', 1, 1, '', "setdate_livraison", 1, 0); print ''; print '
'; } else { - print $object->date_livraison ? dol_print_date($object->date_livraison, 'daytext') : ' '; + print $object->date_livraison ? dol_print_date($object->date_livraison, 'dayhour') : ' '; if ($object->hasDelay() && !empty($object->date_livraison)) { print ' '.img_picto($langs->trans("Late").' : '.$object->showDelay(), "warning"); } @@ -2387,9 +2317,7 @@ if ($action == 'create' && $usercancreate) if ($action != 'editincoterm') { print $form->textwithpicto($object->display_incoterms(), $object->label_incoterms, 1); - } - else - { + } else { print $form->select_incoterms((!empty($object->fk_incoterms) ? $object->fk_incoterms : ''), (!empty($object->location_incoterms) ? $object->location_incoterms : ''), $_SERVER['PHP_SELF'].'?id='.$object->id); } print ''; @@ -2561,8 +2489,7 @@ if ($action == 'create' && $usercancreate) if ($object->statut > Commande::STATUS_DRAFT || !empty($conf->global->COMMANDE_SENDBYEMAIL_FOR_ALL_STATUS)) { if ($usercansend) { print ''.$langs->trans('SendMail').''; - } else - print ''.$langs->trans('SendMail').''; + } else print ''.$langs->trans('SendMail').''; } } @@ -2688,13 +2615,13 @@ if ($action == 'create' && $usercancreate) print '
'; print ''; // ancre // Documents - $comref = dol_sanitizeFileName($object->ref); - $relativepath = $comref.'/'.$comref.'.pdf'; - $filedir = $conf->commande->multidir_output[$object->entity].'/'.$comref; + $objref = dol_sanitizeFileName($object->ref); + $relativepath = $objref.'/'.$objref.'.pdf'; + $filedir = $conf->commande->multidir_output[$object->entity].'/'.$objref; $urlsource = $_SERVER["PHP_SELF"]."?id=".$object->id; $genallowed = $usercanread; $delallowed = $usercancreate; - print $formfile->showdocuments('commande', $comref, $filedir, $urlsource, $genallowed, $delallowed, $object->modelpdf, 1, 0, 0, 28, 0, '', '', '', $soc->default_lang, '', $object); + print $formfile->showdocuments('commande', $objref, $filedir, $urlsource, $genallowed, $delallowed, $object->modelpdf, 1, 0, 0, 28, 0, '', '', '', $soc->default_lang, '', $object); // Show links to link elements diff --git a/htdocs/commande/class/api_orders.class.php b/htdocs/commande/class/api_orders.class.php index ab0abb3d151..cc7db3db852 100644 --- a/htdocs/commande/class/api_orders.class.php +++ b/htdocs/commande/class/api_orders.class.php @@ -223,8 +223,7 @@ class Orders extends DolibarrApi } $i++; } - } - else { + } else { throw new RestException(503, 'Error when retrieve commande list : '.$db->lasterror()); } if (!count($obj_ret)) { @@ -569,9 +568,7 @@ class Orders extends DolibarrApi if ($this->commande->update(DolibarrApiAccess::$user) > 0) { return $this->get($id); - } - else - { + } else { throw new RestException(500, $this->commande->error); } } @@ -699,7 +696,7 @@ class Orders extends DolibarrApi $result = $this->commande->set_reopen(DolibarrApiAccess::$user); if ($result < 0) { throw new RestException(405, $this->commande->error); - }elseif ($result == 0) { + } elseif ($result == 0) { throw new RestException(304); } diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index b911a03e3ad..1c3c44dce93 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -406,16 +406,12 @@ class Commande extends CommonOrder if ($numref != "") { return $numref; - } - else - { + } else { $this->error = $obj->error; //dol_print_error($this->db,get_class($this)."::getNextNumRef ".$obj->error); return ""; } - } - else - { + } else { print $langs->trans("Error")." ".$langs->trans("Error_COMMANDE_ADDON_NotDefined"); return ""; } @@ -468,9 +464,7 @@ class Commande extends CommonOrder if (!$error && (preg_match('/^[\(]?PROV/i', $this->ref) || empty($this->ref))) // empty should not happened, but when it occurs, the test save life { $num = $this->getNextNumRef($soc); - } - else - { + } else { $num = $this->ref; } $this->newref = dol_sanitizeFileName($num); @@ -581,9 +575,7 @@ class Commande extends CommonOrder { $this->db->commit(); return 1; - } - else - { + } else { $this->db->rollback(); return -1; } @@ -668,9 +660,7 @@ class Commande extends CommonOrder $this->db->rollback(); return -1; } - } - else - { + } else { $this->error = $this->db->error(); $this->db->rollback(); return -1; @@ -711,9 +701,7 @@ class Commande extends CommonOrder $result = $this->call_trigger('ORDER_REOPEN', $user); if ($result < 0) $error++; // End call triggers - } - else - { + } else { $error++; $this->error = $this->db->lasterror(); dol_print_error($this->db); @@ -726,9 +714,7 @@ class Commande extends CommonOrder $this->db->commit(); return 1; - } - else - { + } else { foreach ($this->errors as $errmsg) { dol_syslog(get_class($this)."::set_reopen ".$errmsg, LOG_ERR); @@ -783,15 +769,11 @@ class Commande extends CommonOrder $this->db->commit(); return 1; - } - else - { + } else { $this->db->rollback(); return -1; } - } - else - { + } else { $this->error = $this->db->lasterror(); $this->db->rollback(); @@ -861,9 +843,7 @@ class Commande extends CommonOrder $this->statut = self::STATUS_CANCELED; $this->db->commit(); return 1; - } - else - { + } else { foreach ($this->errors as $errmsg) { dol_syslog(get_class($this)."::cancel ".$errmsg, LOG_ERR); @@ -872,9 +852,7 @@ class Commande extends CommonOrder $this->db->rollback(); return -1 * $error; } - } - else - { + } else { $this->error = $this->db->error(); $this->db->rollback(); return -1; @@ -1100,8 +1078,7 @@ class Commande extends CommonOrder $error++; } } - } - else // Old behaviour, if linked_object has only one link per type, so is something like array('contract'=>id1)) + } else // Old behaviour, if linked_object has only one link per type, so is something like array('contract'=>id1)) { $origin_id = $tmp_origin_id; $ret = $this->add_object_linked($origin, $origin_id); @@ -1147,8 +1124,7 @@ class Commande extends CommonOrder //print $objcontact->code.'-'.$objcontact->source.'-'.$objcontact->fk_socpeople."\n"; $this->add_contact($objcontact->fk_socpeople, $objcontact->code, $objcontact->source); // May failed because of duplicate key or because code of contact type does not exists for new object } - } - else dol_print_error($resqlcontact); + } else dol_print_error($resqlcontact); } if (!$error) @@ -1169,23 +1145,17 @@ class Commande extends CommonOrder { $this->db->commit(); return $this->id; - } - else - { + } else { $this->db->rollback(); return -1 * $error; } - } - else - { + } else { $this->error = $this->db->lasterror(); $this->db->rollback(); return -1; } } - } - else - { + } else { dol_print_error($this->db); $this->db->rollback(); return -1; @@ -1288,9 +1258,7 @@ class Commande extends CommonOrder { $this->db->commit(); return $this->id; - } - else - { + } else { $this->db->rollback(); return -1; } @@ -1421,10 +1389,8 @@ class Commande extends CommonOrder $this->valid($user); } return $ret; - } - else return -1; - } - else return -1; + } else return -1; + } else return -1; } @@ -1504,9 +1470,7 @@ class Commande extends CommonOrder if ($price_base_type == 'HT') { $pu = $pu_ht; - } - else - { + } else { $pu = $pu_ttc; } $label = trim($label); @@ -1665,23 +1629,17 @@ class Commande extends CommonOrder { $this->db->commit(); return $this->line->id; - } - else - { + } else { $this->db->rollback(); return -1; } - } - else - { + } else { $this->error = $this->line->error; dol_syslog(get_class($this)."::addline error=".$this->error, LOG_ERR); $this->db->rollback(); return -2; } - } - else - { + } else { dol_syslog(get_class($this)."::addline status of order must be Draft to allow use of ->addline()", LOG_ERR); return -3; } @@ -1920,15 +1878,11 @@ class Commande extends CommonOrder return -3; } return 1; - } - else - { + } else { $this->error = 'Order with id '.$id.' not found sql='.$sql; return 0; } - } - else - { + } else { $this->error = $this->db->error(); return -1; } @@ -1992,22 +1946,16 @@ class Commande extends CommonOrder { $this->db->commit(); return 1; - } - else - { + } else { $this->db->rollback(); return -1; } - } - else - { + } else { $this->error = $line->error; $this->db->rollback(); return -2; } - } - else - { + } else { $this->db->rollback(); return -2; } @@ -2018,7 +1966,7 @@ class Commande extends CommonOrder /** * Load array lines * - * @param int $only_product Return only physical products + * @param int $only_product Return only physical products, not services * @param int $loadalsotranslation Return translation for products * @return int <0 if KO, >0 if OK */ @@ -2132,9 +2080,7 @@ class Commande extends CommonOrder $this->db->free($result); return 1; - } - else - { + } else { $this->error = $this->db->error(); return -3; } @@ -2197,9 +2143,7 @@ class Commande extends CommonOrder $this->db->free($resql); return $nb; - } - else - { + } else { $this->error = $this->db->lasterror(); return -1; } @@ -2244,9 +2188,7 @@ class Commande extends CommonOrder } $this->db->free($resql); return $num; - } - else - { + } else { $this->error = $this->db->lasterror(); return -1; } @@ -2275,8 +2217,7 @@ class Commande extends CommonOrder { $row = $this->db->fetch_row($resql); return $row[0]; - } - else dol_print_error($this->db); + } else dol_print_error($this->db); } // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps @@ -2362,36 +2303,26 @@ class Commande extends CommonOrder { $this->db->commit(); return 1; - } - else - { + } else { $this->db->rollback(); $this->error = $this->db->lasterror(); return -1; } - } - else - { + } else { $this->db->rollback(); $this->error = $line->error; return -1; } - } - else - { + } else { $this->db->rollback(); return 0; } - } - else - { + } else { $this->db->rollback(); $this->error = $this->db->lasterror(); return -1; } - } - else - { + } else { $this->error = 'ErrorDeleteLineNotAllowedByObjectStatus'; return -1; } @@ -2450,9 +2381,7 @@ class Commande extends CommonOrder { $this->db->commit(); return 1; - } - else - { + } else { foreach ($this->errors as $errmsg) { dol_syslog(__METHOD__.' Error: '.$errmsg, LOG_ERR); @@ -2518,9 +2447,7 @@ class Commande extends CommonOrder { $this->db->commit(); return 1; - } - else - { + } else { foreach ($this->errors as $errmsg) { dol_syslog(__METHOD__.' Error: '.$errmsg, LOG_ERR); @@ -2581,9 +2508,7 @@ class Commande extends CommonOrder { $this->db->commit(); return 1; - } - else - { + } else { foreach ($this->errors as $errmsg) { dol_syslog(__METHOD__.' Error: '.$errmsg, LOG_ERR); @@ -2592,9 +2517,7 @@ class Commande extends CommonOrder $this->db->rollback(); return -1 * $error; } - } - else - { + } else { return -2; } } @@ -2647,9 +2570,7 @@ class Commande extends CommonOrder { $this->db->commit(); return 1; - } - else - { + } else { foreach ($this->errors as $errmsg) { dol_syslog(__METHOD__.' Error: '.$errmsg, LOG_ERR); @@ -2658,9 +2579,7 @@ class Commande extends CommonOrder $this->db->rollback(); return -1 * $error; } - } - else - { + } else { return -2; } } @@ -2717,13 +2636,10 @@ class Commande extends CommonOrder if ($shortlist == 1) { $ga[$obj->cid] = $obj->ref; - } - elseif ($shortlist == 2) + } elseif ($shortlist == 2) { $ga[$obj->cid] = $obj->ref.' ('.$obj->name.')'; - } - else - { + } else { $ga[$i]['id'] = $obj->cid; $ga[$i]['ref'] = $obj->ref; $ga[$i]['name'] = $obj->name; @@ -2732,9 +2648,7 @@ class Commande extends CommonOrder } } return $ga; - } - else - { + } else { dol_print_error($this->db); return -1; } @@ -2788,9 +2702,7 @@ class Commande extends CommonOrder { $this->db->commit(); return 1; - } - else - { + } else { foreach ($this->errors as $errmsg) { dol_syslog(__METHOD__.' Error: '.$errmsg, LOG_ERR); @@ -2799,9 +2711,7 @@ class Commande extends CommonOrder $this->db->rollback(); return -1 * $error; } - } - else - { + } else { $error_str = 'Command status do not meet requirement '.$this->statut; dol_syslog(__METHOD__.$error_str, LOG_ERR); $this->error = $error_str; @@ -2860,9 +2770,7 @@ class Commande extends CommonOrder { $this->db->commit(); return 1; - } - else - { + } else { foreach ($this->errors as $errmsg) { dol_syslog(__METHOD__.' Error: '.$errmsg, LOG_ERR); @@ -2871,9 +2779,7 @@ class Commande extends CommonOrder $this->db->rollback(); return -1 * $error; } - } - else - { + } else { $error_str = 'order status do not meet requirement '.$this->statut; dol_syslog(__METHOD__.$error_str, LOG_ERR); $this->error = $error_str; @@ -2929,9 +2835,7 @@ class Commande extends CommonOrder { $this->db->commit(); return 1; - } - else - { + } else { foreach ($this->errors as $errmsg) { dol_syslog(__METHOD__.' Error: '.$errmsg, LOG_ERR); @@ -2940,9 +2844,7 @@ class Commande extends CommonOrder $this->db->rollback(); return -1 * $error; } - } - else - { + } else { return -1; } } @@ -2984,9 +2886,7 @@ class Commande extends CommonOrder { $this->db->commit(); return 1; - } - else - { + } else { foreach ($this->errors as $errmsg) { dol_syslog(get_class($this)."::classifyBilled ".$errmsg, LOG_ERR); @@ -2995,9 +2895,7 @@ class Commande extends CommonOrder $this->db->rollback(); return -1 * $error; } - } - else - { + } else { $this->error = $this->db->error(); $this->db->rollback(); return -1; @@ -3039,9 +2937,7 @@ class Commande extends CommonOrder $this->db->commit(); return 1; - } - else - { + } else { foreach ($this->errors as $errmsg) { dol_syslog(get_class($this)."::classifyUnBilled ".$errmsg, LOG_ERR); @@ -3050,9 +2946,7 @@ class Commande extends CommonOrder $this->db->rollback(); return -1 * $error; } - } - else - { + } else { $this->error = $this->db->error(); $this->db->rollback(); return -1; @@ -3160,9 +3054,7 @@ class Commande extends CommonOrder if ($price_base_type == 'TTC') { $subprice = $pu_ttc; - } - else - { + } else { $subprice = $pu_ht; } $remise = 0; @@ -3265,17 +3157,13 @@ class Commande extends CommonOrder $this->db->commit(); return $result; - } - else - { + } else { $this->error = $this->line->error; $this->db->rollback(); return -1; } - } - else - { + } else { $this->error = get_class($this)."::updateline Order status makes operation forbidden"; $this->errors = array('OrderStatusMakeOperationForbidden'); return -2; @@ -3369,9 +3257,7 @@ class Commande extends CommonOrder } $this->db->rollback(); return -1 * $error; - } - else - { + } else { $this->db->commit(); return 1; } @@ -3503,9 +3389,7 @@ class Commande extends CommonOrder { $this->db->commit(); return 1; - } - else - { + } else { foreach ($this->errors as $errmsg) { $this->error .= ($this->error ? ', '.$errmsg : $errmsg); @@ -3570,9 +3454,7 @@ class Commande extends CommonOrder } return $response; - } - else - { + } else { $this->error = $this->db->error(); return -1; } @@ -3626,38 +3508,31 @@ class Commande extends CommonOrder $labelStatus = $langs->trans('StatusOrderCanceled'); $labelStatusShort = $langs->trans('StatusOrderCanceledShort'); $statusType = 'status9'; - } - elseif ($status == self::STATUS_DRAFT) { + } elseif ($status == self::STATUS_DRAFT) { $labelStatus = $langs->trans('StatusOrderDraft'); $labelStatusShort = $langs->trans('StatusOrderDraftShort'); $statusType = 'status0'; - } - elseif ($status == self::STATUS_VALIDATED) { + } elseif ($status == self::STATUS_VALIDATED) { $labelStatus = $langs->trans('StatusOrderValidated').$billedtext; $labelStatusShort = $langs->trans('StatusOrderValidatedShort').$billedtext; $statusType = 'status1'; - } - elseif ($status == self::STATUS_SHIPMENTONPROCESS) { + } elseif ($status == self::STATUS_SHIPMENTONPROCESS) { $labelStatus = $langs->trans('StatusOrderSentShort').$billedtext; $labelStatusShort = $langs->trans('StatusOrderSentShort').$billedtext; $statusType = 'status4'; - } - elseif ($status == self::STATUS_CLOSED && (!$billed && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) { + } elseif ($status == self::STATUS_CLOSED && (!$billed && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) { $labelStatus = $langs->trans('StatusOrderToBill'); $labelStatusShort = $langs->trans('StatusOrderToBillShort'); $statusType = 'status4'; - } - elseif ($status == self::STATUS_CLOSED && ($billed && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) { + } elseif ($status == self::STATUS_CLOSED && ($billed && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) { $labelStatus = $langs->trans('StatusOrderProcessed').$billedtext; $labelStatusShort = $langs->trans('StatusOrderProcessed').$billedtext; $statusType = 'status6'; - } - elseif ($status == self::STATUS_CLOSED && (!empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) { + } elseif ($status == self::STATUS_CLOSED && (!empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) { $labelStatus = $langs->trans('StatusOrderDelivered'); $labelStatusShort = $langs->trans('StatusOrderDelivered'); $statusType = 'status6'; - } - else { + } else { $labelStatus = $langs->trans('Unknown'); $labelStatusShort = ''; $statusType = ''; @@ -3819,9 +3694,7 @@ class Commande extends CommonOrder } $this->db->free($result); - } - else - { + } else { dol_print_error($this->db); } } @@ -3895,9 +3768,7 @@ class Commande extends CommonOrder $line->total_ttc = 60; $line->total_tva = 10; $line->remise_percent = 50; - } - else - { + } else { $line->total_ht = 100; $line->total_ttc = 120; $line->total_tva = 20; @@ -3955,9 +3826,7 @@ class Commande extends CommonOrder } $this->db->free($resql); return 1; - } - else - { + } else { dol_print_error($this->db); $this->error = $this->db->error(); return -1; @@ -4208,9 +4077,7 @@ class OrderLine extends CommonOrderLine $this->db->free($result); return 1; - } - else - { + } else { $this->error = $this->db->lasterror(); return -1; } @@ -4296,9 +4163,7 @@ class OrderLine extends CommonOrderLine } $this->db->rollback(); return -1 * $error; - } - else - { + } else { $this->error = $this->db->lasterror(); return -1; } @@ -4343,9 +4208,7 @@ class OrderLine extends CommonOrderLine if (($result = $this->defineBuyPrice($this->subprice, $this->remise_percent, $this->fk_product)) < 0) { return $result; - } - else - { + } else { $this->pa_ht = $result; } } @@ -4440,9 +4303,7 @@ class OrderLine extends CommonOrderLine } $this->db->rollback(); return -1 * $error; - } - else - { + } else { $this->error = $this->db->error(); $this->db->rollback(); return -2; @@ -4489,9 +4350,7 @@ class OrderLine extends CommonOrderLine if (($result = $this->defineBuyPrice($this->subprice, $this->remise_percent, $this->fk_product)) < 0) { return $result; - } - else - { + } else { $this->pa_ht = $result; } } @@ -4574,9 +4433,7 @@ class OrderLine extends CommonOrderLine } $this->db->rollback(); return -1 * $error; - } - else - { + } else { $this->error = $this->db->error(); $this->db->rollback(); return -2; @@ -4615,9 +4472,7 @@ class OrderLine extends CommonOrderLine { $this->db->commit(); return 1; - } - else - { + } else { $this->error = $this->db->error(); $this->db->rollback(); return -2; diff --git a/htdocs/commande/class/commandestats.class.php b/htdocs/commande/class/commandestats.class.php index cbb93b940de..5af5fb23060 100644 --- a/htdocs/commande/class/commandestats.class.php +++ b/htdocs/commande/class/commandestats.class.php @@ -78,8 +78,7 @@ class CommandeStats extends Stats $this->field = 'total_ht'; $this->field_line = 'total_ht'; $this->where .= " c.fk_statut > 0"; // Not draft and not cancelled - } - elseif ($mode == 'supplier') + } elseif ($mode == 'supplier') { $object = new CommandeFournisseur($this->db); $this->from = MAIN_DB_PREFIX.$object->table_element." as c"; diff --git a/htdocs/commande/contact.php b/htdocs/commande/contact.php index 6b9e3ae039a..2d11feeeee2 100644 --- a/htdocs/commande/contact.php +++ b/htdocs/commande/contact.php @@ -63,16 +63,12 @@ if ($action == 'addcontact' && $user->rights->commande->creer) { header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); exit; - } - else - { + } else { if ($object->error == 'DB_ERROR_RECORD_ALREADY_EXISTS') { $langs->load("errors"); setEventMessages($langs->trans("ErrorThisContactIsAlreadyDefinedAsThisType"), null, 'errors'); - } - else - { + } else { setEventMessages($object->error, $object->errors, 'errors'); } } @@ -84,9 +80,7 @@ elseif ($action == 'swapstatut' && $user->rights->commande->creer) if ($object->fetch($id)) { $result = $object->swapContactStatus(GETPOST('ligne')); - } - else - { + } else { dol_print_error($db); } } @@ -101,8 +95,7 @@ elseif ($action == 'deletecontact' && $user->rights->commande->creer) { header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); exit; - } - else { + } else { dol_print_error($db); } } @@ -206,9 +199,7 @@ if ($id > 0 || !empty($ref)) $res = @include dol_buildpath($reldir.'/contacts.tpl.php'); if ($res) break; } - } - else - { + } else { // Contact not found print "ErrorRecordNotFound"; } diff --git a/htdocs/commande/customer.php b/htdocs/commande/customer.php index 1e445a602f7..f78d6ce2e84 100644 --- a/htdocs/commande/customer.php +++ b/htdocs/commande/customer.php @@ -184,9 +184,7 @@ if ($resql) print ''; $db->free($resql); -} -else -{ +} else { dol_print_error($db); } diff --git a/htdocs/commande/document.php b/htdocs/commande/document.php index 9d188cda104..27d38378bcb 100644 --- a/htdocs/commande/document.php +++ b/htdocs/commande/document.php @@ -182,14 +182,10 @@ if ($id > 0 || !empty($ref)) $permtoedit = $user->rights->commande->creer; $param = '&id='.$object->id.'&entity='.(!empty($object->entity) ? $object->entity : $conf->entity); include_once DOL_DOCUMENT_ROOT.'/core/tpl/document_actions_post_headers.tpl.php'; - } - else - { + } else { dol_print_error($db); } -} -else -{ +} else { header('Location: index.php'); exit; } diff --git a/htdocs/commande/index.php b/htdocs/commande/index.php index 13d67c942ed..96476caeeed 100644 --- a/htdocs/commande/index.php +++ b/htdocs/commande/index.php @@ -173,9 +173,7 @@ if ($resql) //if ($totalinprocess != $total) print ''.$langs->trans("Total").''.$total.''; print "

"; -} -else -{ +} else { dol_print_error($db); } @@ -232,9 +230,7 @@ if (!empty($conf->commande->enabled)) print ''; $i++; } - } - else - { + } else { print ''.$langs->trans("NoOrder").''; } print "

"; @@ -323,8 +319,7 @@ if ($resql) } } print "
"; -} -else dol_print_error($db); +} else dol_print_error($db); $max = 10; @@ -410,8 +405,7 @@ if (!empty($conf->commande->enabled)) } print "
"; - } - else dol_print_error($db); + } else dol_print_error($db); } /* @@ -495,8 +489,7 @@ if (!empty($conf->commande->enabled)) } } print "
"; - } - else dol_print_error($db); + } else dol_print_error($db); } diff --git a/htdocs/commande/info.php b/htdocs/commande/info.php index 6de602c22d4..9b45bf66312 100644 --- a/htdocs/commande/info.php +++ b/htdocs/commande/info.php @@ -20,7 +20,7 @@ /** * \file htdocs/commande/info.php * \ingroup commande - * \brief Page des informations d'une commande + * \brief Sale Order info page */ require '../main.inc.php'; diff --git a/htdocs/commande/list.php b/htdocs/commande/list.php index 5bcff277ef6..5770df78a82 100644 --- a/htdocs/commande/list.php +++ b/htdocs/commande/list.php @@ -395,9 +395,7 @@ if ($resql) $soc->fetch($socid); $title = $langs->trans('ListOfOrders').' - '.$soc->name; if (empty($search_company)) $search_company = $soc->name; - } - else - { + } else { $title = $langs->trans('ListOfOrders'); } if (strval($search_status) == '0') @@ -541,9 +539,7 @@ if ($resql) { print $form->selectyesno('validate_invoices', 0, 1, 1); print ' ('.$langs->trans("AutoValidationNotPossibleWhenStockIsDecreasedOnInvoiceValidation").')'; - } - else - { + } else { print $form->selectyesno('validate_invoices', 0, 1); } if (!empty($conf->workflow->enabled) && !empty($conf->global->WORKFLOW_INVOICE_AMOUNT_CLASSIFY_BILLED_ORDER)) print '     '.$langs->trans("IfValidateInvoiceIsNoOrderStayUnbilled").''; @@ -962,8 +958,7 @@ if ($resql) { $notshippable++; } - } - else { // Detailed code, looks bugged + } else { // Detailed code, looks bugged // stock order and stock order_supplier $stock_order = 0; $stock_order_supplier = 0; @@ -1147,7 +1142,7 @@ if ($resql) if (!empty($arrayfields['c.date_delivery']['checked'])) { print ''; - print dol_print_date($db->jdate($obj->date_delivery), 'day'); + print dol_print_date($db->jdate($obj->date_delivery), 'dayhour'); print ''; if (!$i) $totalarray['nbfield']++; } @@ -1226,7 +1221,7 @@ if ($resql) // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; // Fields from hook - $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$obj, 'i'=>$i); + $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray); $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; // Date creation @@ -1310,9 +1305,7 @@ if ($resql) $delallowed = $user->rights->commande->creer; print $formfile->showdocuments('massfilesarea_orders', '', $filedir, $urlsource, 0, $delallowed, '', 1, 1, 0, 48, 1, $param, $title, '', '', '', null, $hidegeneratedfilelistifempty); -} -else -{ +} else { dol_print_error($db); } diff --git a/htdocs/commande/orderstoinvoice.php b/htdocs/commande/orderstoinvoice.php index f230f7935a5..c3d82821249 100644 --- a/htdocs/commande/orderstoinvoice.php +++ b/htdocs/commande/orderstoinvoice.php @@ -83,9 +83,7 @@ if ($action == 'create') { $error++; setEventMessages($langs->trans('Error_OrderNotChecked'), null, 'errors'); - } - else - { + } else { $origin = GETPOST('origin'); $originid = GETPOST('originid'); } @@ -209,9 +207,7 @@ if (($action == 'create' || $action == 'add') && !$error) if ($db->query($sql)) { $db->commit(); - } - else - { + } else { $db->rollback(); } } @@ -256,16 +252,12 @@ if (($action == 'create' || $action == 'add') && !$error) { $result = $object->insert_discount($discountid); //$result=$discount->link_to_invoice($lineid,$id); - } - else - { + } else { setEventMessages($discount->error, $discount->errors, 'errors'); $error++; break; } - } - else - { + } else { // Positive line $product_type = ($lines[$i]->product_type ? $lines[$i]->product_type : 0); // Date start @@ -320,9 +312,7 @@ if (($action == 'create' || $action == 'add') && !$error) if ($result > 0) { $lineid = $result; - } - else - { + } else { $lineid = 0; $error++; break; @@ -334,17 +324,13 @@ if (($action == 'create' || $action == 'add') && !$error) } } } - } - else - { + } else { setEventMessages($objectsrc->error, $objectsrc->errors, 'errors'); $error++; } $ii++; } - } - else - { + } else { setEventMessages($object->error, $object->errors, 'errors'); $error++; } @@ -358,9 +344,7 @@ if (($action == 'create' || $action == 'add') && !$error) $db->commit(); header('Location: '.DOL_URL_ROOT.'/compta/facture/card.php?facid='.$id); exit; - } - else - { + } else { $db->rollback(); $action = 'create'; $_GET["origin"] = $_POST["origin"]; @@ -729,9 +713,7 @@ if (($action != 'create' && $action != 'add') || ($action == 'create' && $error) print ''; $db->free($resql); - } - else - { + } else { dol_print_error($db); } } diff --git a/htdocs/commande/stats/index.php b/htdocs/commande/stats/index.php index 4e7ed481882..0910e4ee7ad 100644 --- a/htdocs/commande/stats/index.php +++ b/htdocs/commande/stats/index.php @@ -114,9 +114,7 @@ if (!$user->rights->societe->client->voir || $user->socid) $filenamenb = $dir.'/ordersnbinyear-'.$user->id.'-'.$year.'.png'; if ($mode == 'customer') $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstats&file=ordersnbinyear-'.$user->id.'-'.$year.'.png'; if ($mode == 'supplier') $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstatssupplier&file=ordersnbinyear-'.$user->id.'-'.$year.'.png'; -} -else -{ +} else { $filenamenb = $dir.'/ordersnbinyear-'.$year.'.png'; if ($mode == 'customer') $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstats&file=ordersnbinyear-'.$year.'.png'; if ($mode == 'supplier') $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstatssupplier&file=ordersnbinyear-'.$year.'.png'; @@ -157,9 +155,7 @@ if (!$user->rights->societe->client->voir || $user->socid) $filenameamount = $dir.'/ordersamountinyear-'.$user->id.'-'.$year.'.png'; if ($mode == 'customer') $fileurlamount = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstats&file=ordersamountinyear-'.$user->id.'-'.$year.'.png'; if ($mode == 'supplier') $fileurlamount = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstatssupplier&file=ordersamountinyear-'.$user->id.'-'.$year.'.png'; -} -else -{ +} else { $filenameamount = $dir.'/ordersamountinyear-'.$year.'.png'; if ($mode == 'customer') $fileurlamount = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstats&file=ordersamountinyear-'.$year.'.png'; if ($mode == 'supplier') $fileurlamount = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstatssupplier&file=ordersamountinyear-'.$year.'.png'; @@ -198,9 +194,7 @@ if (!$user->rights->societe->client->voir || $user->socid) $filename_avg = $dir.'/ordersaverage-'.$user->id.'-'.$year.'.png'; if ($mode == 'customer') $fileurl_avg = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstats&file=ordersaverage-'.$user->id.'-'.$year.'.png'; if ($mode == 'supplier') $fileurl_avg = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstatssupplier&file=ordersaverage-'.$user->id.'-'.$year.'.png'; -} -else -{ +} else { $filename_avg = $dir.'/ordersaverage-'.$year.'.png'; if ($mode == 'customer') $fileurl_avg = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstats&file=ordersaverage-'.$year.'.png'; if ($mode == 'supplier') $fileurl_avg = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstatssupplier&file=ordersaverage-'.$year.'.png'; @@ -381,8 +375,7 @@ print '
'; // Show graphs print ''; - } - else - { + } else { // Sort array by date ASC to calculate balance - $totalET = 0; - $totalIT = 0; - $totalVAT = 0; - $totalDebit = 0; - $totalCredit = 0; + $totalET_debit = 0; + $totalIT_debit = 0; + $totalVAT_debit = 0; + $totalET_credit = 0; + $totalIT_credit = 0; + $totalVAT_credit = 0; // Display array foreach ($TData as $data) @@ -592,25 +652,49 @@ if (!empty($date_start) && !empty($date_stop)) // Ref print ''; // File link print '\n"; @@ -619,11 +703,11 @@ if (!empty($date_start) && !empty($date_stop)) print ''; // Total ET - print '\n"; + print '\n"; // Total IT - print '\n"; + print '\n"; // Total VAT - print '\n"; + print '\n"; print '\n"; @@ -633,42 +717,42 @@ if (!empty($date_start) && !empty($date_stop)) print '\n"; - // Debit - //print '\n"; - // Credit - //print '\n"; - - $totalET += $data['amount_ht']; - $totalIT += $data['amount_ttc']; - $totalVAT += $data['amount_vat']; - - $totalDebit += ($data['amount_ttc'] > 0) ? abs($data['amount_ttc']) : 0; - $totalCredit += ($data['amount_ttc'] > 0) ? 0 : abs($data['amount_ttc']); - - // Balance - //print '\n"; + if ($data['sens']) { + $totalET_credit += $data['amount_ht']; + $totalIT_credit += $data['amount_ttc']; + $totalVAT_credit += $data['amount_vat']; + } else { + $totalET_debit -= $data['amount_ht']; + $totalIT_debit -= $data['amount_ttc']; + $totalVAT_debit -= $data['amount_vat']; + } print "\n"; } + // Total credits print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - /*print ''; - print ''; - print ''; - */ + print ''; + print ''; + print ''; + print ''; + print ''; + print "\n"; + // Total debits + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print "\n"; + // Balance + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; print "\n"; } } diff --git a/htdocs/compta/ajaxpayment.php b/htdocs/compta/ajaxpayment.php index f380d8b4ee5..0129d1e5f43 100644 --- a/htdocs/compta/ajaxpayment.php +++ b/htdocs/compta/ajaxpayment.php @@ -81,13 +81,11 @@ if ($currentInvId) // Here to breakdown $remainAmount = $currentRemain - $currentAmount; // To keep value between curRemain and curAmount $result += $remainAmount; // result must be deduced by $currentAmount += $remainAmount; // curAmount put to curRemain - } else - { + } else { $currentAmount = $currentRemain; $result += $currentRemain; } - } else - { + } else { // Reset the substraction for this amount $result += price2num($currentAmount); $currentAmount = 0; diff --git a/htdocs/compta/bank/account_statement_document.php b/htdocs/compta/bank/account_statement_document.php index 05f89e1bc6f..767c8f8709b 100644 --- a/htdocs/compta/bank/account_statement_document.php +++ b/htdocs/compta/bank/account_statement_document.php @@ -138,12 +138,10 @@ if ($id > 0 || !empty($ref)) { $moreparam = '&num='.urlencode($num); ; $relativepathwithnofile = $id."/statement/".dol_sanitizeFileName($num)."/"; include_once DOL_DOCUMENT_ROOT.'/core/tpl/document_actions_post_headers.tpl.php'; - } - else { + } else { dol_print_error($db); } -} -else { +} else { Header('Location: index.php'); exit; } diff --git a/htdocs/compta/bank/annuel.php b/htdocs/compta/bank/annuel.php index 1f6e5e6620c..72a7e33d3f2 100644 --- a/htdocs/compta/bank/annuel.php +++ b/htdocs/compta/bank/annuel.php @@ -50,9 +50,7 @@ if (!$year_start) { $year_start = $year_current - 2; $year_end = $year_current; -} -else -{ +} else { $year_end = $year_start + 2; } @@ -107,9 +105,7 @@ if ($resql) $encaiss[$row[1]] = $row[0]; $i++; } -} -else -{ +} else { dol_print_error($db); } @@ -135,9 +131,7 @@ if ($resql) $decaiss[$row[1]] = -$row[0]; $i++; } -} -else -{ +} else { dol_print_error($db); } @@ -157,9 +151,7 @@ if (!empty($id)) if (!preg_match('/,/', $id)) { dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref, '', 0, '', '', 1); - } - else - { + } else { $bankaccount = new Account($db); $listid = explode(',', $id); foreach ($listid as $key => $aId) @@ -170,9 +162,7 @@ if (!empty($id)) if ($key < (count($listid) - 1)) print ', '; } } -} -else -{ +} else { print $langs->trans("AllAccounts"); } @@ -257,8 +247,7 @@ if ($resql) { $obj = $db->fetch_object($resql); if ($obj) $balance = $obj->total; -} -else { +} else { dol_print_error($db); } @@ -280,9 +269,7 @@ if ($result < 0) $langs->load("errors"); $error++; setEventMessages($langs->trans("ErrorFailedToCreateDir"), null, 'errors'); -} -else -{ +} else { // Calcul de $min et $max $sql = "SELECT MIN(b.datev) as min, MAX(b.datev) as max"; $sql .= " FROM ".MAIN_DB_PREFIX."bank as b"; @@ -298,9 +285,7 @@ else $obj = $db->fetch_object($resql); $min = $db->jdate($obj->min); $max = $db->jdate($obj->max); - } - else - { + } else { dol_print_error($db); } $log = "graph.php: min=".$min." max=".$max; @@ -338,9 +323,7 @@ else $i++; } $db->free($resql); - } - else - { + } else { dol_print_error($db); } } @@ -425,9 +408,7 @@ else $i++; } $db->free($resql); - } - else - { + } else { dol_print_error($db); } } diff --git a/htdocs/compta/bank/bankentries_list.php b/htdocs/compta/bank/bankentries_list.php index 7d059734126..0af1f84d9f6 100644 --- a/htdocs/compta/bank/bankentries_list.php +++ b/htdocs/compta/bank/bankentries_list.php @@ -68,9 +68,7 @@ if ($fielvalue) { if ($user->socid) $socid = $user->socid; $result = restrictedArea($user, 'banque', $fieldvalue, 'bank_account&bank_account', '', '', $fieldtype); -} -else -{ +} else { if ($user->socid) $socid = $user->socid; $result = restrictedArea($user, 'banque'); } @@ -241,16 +239,12 @@ if ((GETPOST('confirm_savestatement', 'alpha') || GETPOST('confirm_reconcile', ' } } } - } - else - { + } else { $error++; $langs->load("errors"); setEventMessages($langs->trans("NoRecordSelected"), null, 'errors'); } - } - else - { + } else { $error++; $langs->load("errors"); setEventMessages($langs->trans("ErrorPleaseTypeBankTransactionReportName"), null, 'errors'); @@ -286,9 +280,7 @@ if (GETPOST('save') && !$cancel && $user->rights->banque->modifier) if (price2num($_POST["addcredit"]) > 0) { $amount = price2num($_POST["addcredit"]); - } - else - { + } else { $amount = - price2num($_POST["adddebit"]); } @@ -337,14 +329,10 @@ if (GETPOST('save') && !$cancel && $user->rights->banque->modifier) setEventMessages($langs->trans("RecordSaved"), null, 'mesgs'); header("Location: ".$_SERVER['PHP_SELF'].($id ? "?id=".$id : '')); exit; - } - else - { + } else { setEventMessages($object->error, $object->errors, 'errors'); } - } - else - { + } else { $action = 'addline'; } } @@ -468,9 +456,7 @@ if ($id > 0 || !empty($ref)) } } } -} -else -{ +} else { llxHeader('', $langs->trans("BankTransactions"), '', '', 0, 0, array(), array(), $param); } @@ -674,9 +660,7 @@ if ($resql) if ($numr >= $nbmax) $liste = "...   ".$liste; print $liste; if ($numr <= 0) print ''.$langs->trans("None").''; - } - else - { + } else { dol_print_error($db); } @@ -792,14 +776,11 @@ if ($resql) if (empty($conf->global->BANK_USE_OLD_VARIOUS_PAYMENT)) // If direct entries is done using miscellaneous payments { $newcardbutton = dolGetButtonTitle($langs->trans('AddBankRecord'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/compta/bank/various_payment/card.php?action=create&accountid='.$search_account.'&backtopage='.urlencode($_SERVER['PHP_SELF'].'?id='.urlencode($search_account)), '', $user->rights->banque->modifier); - } - else // If direct entries is not done using miscellaneous payments + } else // If direct entries is not done using miscellaneous payments { $newcardbutton = dolGetButtonTitle($langs->trans('AddBankRecord'), '', 'fa fa-plus-circle', $_SERVER["PHP_SELF"].'?action=addline&page='.$page.$param, '', $user->rights->banque->modifier); } - } - else - { + } else { $newcardbutton = dolGetButtonTitle($langs->trans('AddBankRecord'), '', 'fa fa-plus-circle', $_SERVER["PHP_SELF"].'?action=addline&page='.$page.$param, '', -1); } } @@ -1039,15 +1020,12 @@ if ($resql) if ($sortfield == 'b.datev,b.dateo,b.rowid' && $sortorder == 'desc,desc,desc') { $balancebefore = $objforbalance->previoustotal + ($sign * $objp->amount); - } - // If sort is asc,asc,asc then total of previous date is balance of line before the next line to show - else - { + } // If sort is asc,asc,asc then total of previous date is balance of line before the next line to show + else { $balance = $objforbalance->previoustotal; } } - } - else dol_print_error($db); + } else dol_print_error($db); $balancecalculated = true; @@ -1128,9 +1106,7 @@ if ($resql) { $balance = price2num($balancebefore, 'MT'); // balance = balancebefore of previous line (sort is desc) $balancebefore = price2num($balancebefore - ($sign * $objp->amount), 'MT'); - } - else - { + } else { $balancebefore = price2num($balance, 'MT'); // balancebefore = balance of previous line (sort is asc) $balance = price2num($balance + ($sign * $objp->amount), 'MT'); } @@ -1141,9 +1117,7 @@ if ($resql) $bankaccounttmp->fetch($objp->bankid); $cachebankaccount[$objp->bankid] = $bankaccounttmp; $bankaccount = $bankaccounttmp; - } - else - { + } else { $bankaccount = $cachebankaccount[$objp->bankid]; } @@ -1207,63 +1181,53 @@ if ($resql) $banktransferstatic->id = $links[$key]['url_id']; $banktransferstatic->ref = $links[$key]['label']; print ' '.$banktransferstatic->getNomUrl(0); - } - elseif ($links[$key]['type'] == 'payment') + } elseif ($links[$key]['type'] == 'payment') { $paymentstatic->id = $links[$key]['url_id']; $paymentstatic->ref = $links[$key]['url_id']; // FIXME This is id, not ref of payment print ' '.$paymentstatic->getNomUrl(2); - } - elseif ($links[$key]['type'] == 'payment_supplier') + } elseif ($links[$key]['type'] == 'payment_supplier') { $paymentsupplierstatic->id = $links[$key]['url_id']; $paymentsupplierstatic->ref = $links[$key]['url_id']; // FIXME This is id, not ref of payment print ' '.$paymentsupplierstatic->getNomUrl(2); - } - elseif ($links[$key]['type'] == 'payment_sc') + } elseif ($links[$key]['type'] == 'payment_sc') { print ''; print ' '.img_object($langs->trans('ShowPayment'), 'payment').' '; //print $langs->trans("SocialContributionPayment"); print ''; - } - elseif ($links[$key]['type'] == 'payment_vat') + } elseif ($links[$key]['type'] == 'payment_vat') { $paymentvatstatic->id = $links[$key]['url_id']; $paymentvatstatic->ref = $links[$key]['url_id']; print ' '.$paymentvatstatic->getNomUrl(2); - } - elseif ($links[$key]['type'] == 'payment_salary') + } elseif ($links[$key]['type'] == 'payment_salary') { $paymentsalstatic->id = $links[$key]['url_id']; $paymentsalstatic->ref = $links[$key]['url_id']; print ' '.$paymentsalstatic->getNomUrl(2); - } - elseif ($links[$key]['type'] == 'payment_loan') + } elseif ($links[$key]['type'] == 'payment_loan') { print ''; print ' '.img_object($langs->trans('ShowPayment'), 'payment').' '; print ''; - } - elseif ($links[$key]['type'] == 'payment_donation') + } elseif ($links[$key]['type'] == 'payment_donation') { print ''; print ' '.img_object($langs->trans('ShowPayment'), 'payment').' '; print ''; - } - elseif ($links[$key]['type'] == 'payment_expensereport') + } elseif ($links[$key]['type'] == 'payment_expensereport') { $paymentexpensereportstatic->id = $links[$key]['url_id']; $paymentexpensereportstatic->ref = $links[$key]['url_id']; print ' '.$paymentexpensereportstatic->getNomUrl(2); - } - elseif ($links[$key]['type'] == 'payment_various') + } elseif ($links[$key]['type'] == 'payment_various') { $paymentvariousstatic->id = $links[$key]['url_id']; $paymentvariousstatic->ref = $links[$key]['url_id']; print ' '.$paymentvariousstatic->getNomUrl(2); - } - elseif ($links[$key]['type'] == 'banktransfert') + } elseif ($links[$key]['type'] == 'banktransfert') { // Do not show link to transfer since there is no transfer card (avoid confusion). Can already be accessed from transaction detail. if ($objp->amount > 0) @@ -1278,9 +1242,7 @@ if ($resql) $bankstatic->label = $objp->bankref; print $bankstatic->getNomUrl(1, ''); print ')'; - } - else - { + } else { $bankstatic->id = $objp->bankid; $bankstatic->label = $objp->bankref; print ' ('.$langs->trans("TransferFrom").' '; @@ -1293,21 +1255,15 @@ if ($resql) print ')'; } //var_dump($links); - } - elseif ($links[$key]['type'] == 'company') + } elseif ($links[$key]['type'] == 'company') { - } - elseif ($links[$key]['type'] == 'user') + } elseif ($links[$key]['type'] == 'user') { - } - elseif ($links[$key]['type'] == 'member') + } elseif ($links[$key]['type'] == 'member') { - } - elseif ($links[$key]['type'] == 'sc') - { - } - else + } elseif ($links[$key]['type'] == 'sc') { + } else { // Show link with label $links[$key]['label'] if (!empty($objp->label) && !empty($links[$key]['label'])) print ' - '; print ''; @@ -1316,9 +1272,7 @@ if ($resql) // Label generique car entre parentheses. On l'affiche en le traduisant if ($reg[1] == 'paiement') $reg[1] = 'Payment'; print ' '.$langs->trans($reg[1]); - } - else - { + } else { print ' '.$links[$key]['label']; } print ''; @@ -1395,9 +1349,7 @@ if ($resql) $companystatic->code_compta = $objp->code_compta; $companystatic->code_compta_fournisseur = $objp->code_compta_fournisseur; print $companystatic->getNomUrl(1); - } - else - { + } else { print ' '; } print ''; @@ -1449,14 +1401,10 @@ if ($resql) if ($balancebefore >= 0) { print ''; - } - else - { + } else { print ''; } - } - else - { + } else { print ''; } if (!$i) $totalarray['nbfield']++; @@ -1469,14 +1417,10 @@ if ($resql) if ($balance >= 0) { print ''; - } - else - { + } else { print ''; } - } - else - { + } else { print ''; } if (!$i) $totalarray['nbfield']++; @@ -1522,17 +1466,13 @@ if ($resql) print ''; print img_edit(); print ''; - } - else - { + } else { if ($user->rights->banque->modifier || $user->rights->banque->consolidate) { print ''; print img_edit(); print ''; - } - else - { + } else { print ''; print img_view(); print ''; @@ -1582,16 +1522,14 @@ if ($resql) { if ($num < $limit && empty($offset)) print ''; else print ''; - } - elseif ($totalarray['totaldebfield'] == $i) print ''; + } elseif ($totalarray['totaldebfield'] == $i) print ''; elseif ($totalarray['totalcredfield'] == $i) print ''; elseif ($i == $posconciliatecol) { print ''; - } - else print ''; + } else print ''; } print ''; } @@ -1609,9 +1547,7 @@ if ($resql) print ''; $db->free($resql); -} -else -{ +} else { dol_print_error($db); } diff --git a/htdocs/compta/bank/budget.php b/htdocs/compta/bank/budget.php index 042117808d5..8559096477d 100644 --- a/htdocs/compta/bank/budget.php +++ b/htdocs/compta/bank/budget.php @@ -89,9 +89,7 @@ if ($result) print ''; print ''; print ''; -} -else -{ +} else { dol_print_error($db); } print "
'; -if ($mesg) { print $mesg; } -else { +if ($mesg) { print $mesg; } else { print $px1->show(); print "
\n"; print $px2->show(); diff --git a/htdocs/compta/accounting-files.php b/htdocs/compta/accounting-files.php index 471637461f6..0c20e46e316 100644 --- a/htdocs/compta/accounting-files.php +++ b/htdocs/compta/accounting-files.php @@ -2,6 +2,7 @@ /* Copyright (C) 2001-2006 Rodolphe Quiedeville * Copyright (C) 2004-2019 Laurent Destailleur * Copyright (C) 2017 Pierre-Henry Favre + * Copyright (C) 2020 Maxime DEMAREST * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -37,8 +38,16 @@ require_once DOL_DOCUMENT_ROOT.'/compta/sociales/class/chargesociales.class.php' require_once DOL_DOCUMENT_ROOT.'/don/class/don.class.php'; require_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport.class.php'; require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php'; +require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php'; +require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/paymentvarious.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; +require_once DOL_DOCUMENT_ROOT.'/loan/class/paymentloan.class.php'; -$langs->loadLangs(array("accountancy", "bills", "companies", "salaries", "compta", "trips")); +// Constant to define payment sens +const PAY_DEBIT = 0; +const PAY_CREDIT = 1; + +$langs->loadLangs(array("accountancy", "bills", "companies", "salaries", "compta", "trips", "banks", "loan")); $date_start = GETPOST('date_start', 'alpha'); $date_startDay = GETPOST('date_startday', 'int'); @@ -140,7 +149,7 @@ if (($action == 'searchfiles' || $action == 'dl')) { // Customer invoices if (GETPOST('selectinvoices')) { if (!empty($sql)) $sql .= " UNION ALL"; - $sql .= "SELECT t.rowid as id, t.entity, t.ref, t.paye as paid, t.total as total_ht, t.total_ttc, t.tva as total_vat, t.fk_soc, t.datef as date, t.date_lim_reglement as date_due, 'Invoice' as item, s.nom as thirdparty_name, s.code_client as thirdparty_code, c.code as country_code, s.tva_intra as vatnum"; + $sql .= "SELECT t.rowid as id, t.entity, t.ref, t.paye as paid, t.total as total_ht, t.total_ttc, t.tva as total_vat, t.fk_soc, t.datef as date, t.date_lim_reglement as date_due, 'Invoice' as item, s.nom as thirdparty_name, s.code_client as thirdparty_code, c.code as country_code, s.tva_intra as vatnum, ".PAY_CREDIT." as sens"; $sql .= " FROM ".MAIN_DB_PREFIX."facture as t LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = t.fk_soc LEFT JOIN ".MAIN_DB_PREFIX."c_country as c ON c.rowid = s.fk_pays"; $sql .= " WHERE datef between ".$wheretail; $sql .= " AND t.entity IN (".($entity == 1 ? '0,1' : $entity).')'; @@ -149,7 +158,7 @@ if (($action == 'searchfiles' || $action == 'dl')) { // Vendor invoices if (GETPOST('selectsupplierinvoices')) { if (!empty($sql)) $sql .= " UNION ALL"; - $sql .= " SELECT t.rowid as id, t.entity, t.ref, t.paye as paid, t.total_ht, t.total_ttc, t.total_tva as total_vat, t.fk_soc, t.datef as date, t.date_lim_reglement as date_due, 'SupplierInvoice' as item, s.nom as thirdparty_name, s.code_fournisseur as thirdparty_code, c.code as country_code, s.tva_intra as vatnum"; + $sql .= " SELECT t.rowid as id, t.entity, t.ref, t.paye as paid, t.total_ht, t.total_ttc, t.total_tva as total_vat, t.fk_soc, t.datef as date, t.date_lim_reglement as date_due, 'SupplierInvoice' as item, s.nom as thirdparty_name, s.code_fournisseur as thirdparty_code, c.code as country_code, s.tva_intra as vatnum, ".PAY_DEBIT." as sens"; $sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn as t LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = t.fk_soc LEFT JOIN ".MAIN_DB_PREFIX."c_country as c ON c.rowid = s.fk_pays"; $sql .= " WHERE datef between ".$wheretail; $sql .= " AND t.entity IN (".($entity == 1 ? '0,1' : $entity).')'; @@ -158,7 +167,7 @@ if (($action == 'searchfiles' || $action == 'dl')) { // Expense reports if (GETPOST('selectexpensereports')) { if (!empty($sql)) $sql .= " UNION ALL"; - $sql .= " SELECT t.rowid as id, t.entity, t.ref, t.paid, t.total_ht, t.total_ttc, t.total_tva as total_vat, t.fk_user_author as fk_soc, t.date_fin as date, t.date_fin as date_due, 'ExpenseReport' as item, CONCAT(CONCAT(u.lastname, ' '), u.firstname) as thirdparty_name, '' as thirdparty_code, c.code as country_code, '' as vatnum"; + $sql .= " SELECT t.rowid as id, t.entity, t.ref, t.paid, t.total_ht, t.total_ttc, t.total_tva as total_vat, t.fk_user_author as fk_soc, t.date_fin as date, t.date_fin as date_due, 'ExpenseReport' as item, CONCAT(CONCAT(u.lastname, ' '), u.firstname) as thirdparty_name, '' as thirdparty_code, c.code as country_code, '' as vatnum, ".PAY_DEBIT." as sens"; $sql .= " FROM ".MAIN_DB_PREFIX."expensereport as t LEFT JOIN ".MAIN_DB_PREFIX."user as u ON u.rowid = t.fk_user_author LEFT JOIN ".MAIN_DB_PREFIX."c_country as c ON c.rowid = u.fk_country"; $sql .= " WHERE date_fin between ".$wheretail; $sql .= " AND t.entity IN (".($entity == 1 ? '0,1' : $entity).')'; @@ -167,7 +176,7 @@ if (($action == 'searchfiles' || $action == 'dl')) { // Donations if (GETPOST('selectdonations')) { if (!empty($sql)) $sql .= " UNION ALL"; - $sql .= " SELECT t.rowid as id, t.entity, t.ref, paid, amount as total_ht, amount as total_ttc, 0 as total_vat, 0 as fk_soc, t.datedon as date, t.datedon as date_due, 'Donation' as item, t.societe as thirdparty_name, '' as thirdparty_code, c.code as country_code, '' as vatnum"; + $sql .= " SELECT t.rowid as id, t.entity, t.ref, paid, amount as total_ht, amount as total_ttc, 0 as total_vat, 0 as fk_soc, t.datedon as date, t.datedon as date_due, 'Donation' as item, t.societe as thirdparty_name, '' as thirdparty_code, c.code as country_code, '' as vatnum, ".PAY_CREDIT." as sens"; $sql .= " FROM ".MAIN_DB_PREFIX."don as t LEFT JOIN ".MAIN_DB_PREFIX."c_country as c ON c.rowid = t.fk_country"; $sql .= " WHERE datedon between ".$wheretail; $sql .= " AND t.entity IN (".($entity == 1 ? '0,1' : $entity).')'; @@ -176,7 +185,7 @@ if (($action == 'searchfiles' || $action == 'dl')) { // Paiements of salaries if (GETPOST('selectpaymentsofsalaries')) { if (!empty($sql)) $sql .= " UNION ALL"; - $sql .= " SELECT t.rowid as id, t.entity, t.ref as ref, 1 as paid, amount as total_ht, amount as total_ttc, 0 as total_vat, t.fk_user as fk_soc, t.datep as date, t.dateep as date_due, 'SalaryPayment' as item, CONCAT(CONCAT(u.lastname, ' '), u.firstname) as thirdparty_name, '' as thirdparty_code, c.code as country_code, '' as vatnum"; + $sql .= " SELECT t.rowid as id, t.entity, t.label as ref, 1 as paid, amount as total_ht, amount as total_ttc, 0 as total_vat, t.fk_user as fk_soc, t.datep as date, t.dateep as date_due, 'SalaryPayment' as item, CONCAT(CONCAT(u.lastname, ' '), u.firstname) as thirdparty_name, '' as thirdparty_code, c.code as country_code, '' as vatnum, ".PAY_DEBIT." as sens"; $sql .= " FROM ".MAIN_DB_PREFIX."payment_salary as t LEFT JOIN ".MAIN_DB_PREFIX."user as u ON u.rowid = t.fk_user LEFT JOIN ".MAIN_DB_PREFIX."c_country as c ON c.rowid = u.fk_country"; $sql .= " WHERE datep between ".$wheretail; $sql .= " AND t.entity IN (".($entity == 1 ? '0,1' : $entity).')'; @@ -185,12 +194,28 @@ if (($action == 'searchfiles' || $action == 'dl')) { // Social contributions if (GETPOST('selectsocialcontributions')) { if (!empty($sql)) $sql .= " UNION ALL"; - $sql .= " SELECT t.rowid as id, t.entity, t.libelle as ref, t.paye as paid, t.amount as total_ht, t.amount as total_ttc, 0 as total_tva, 0 as fk_soc, t.date_creation as date, t.date_ech as date_due, 'SocialContributions' as item, '' as thirdparty_name, '' as thirdparty_code, '' as country_code, '' as vatnum"; + $sql .= " SELECT t.rowid as id, t.entity, t.libelle as ref, t.paye as paid, t.amount as total_ht, t.amount as total_ttc, 0 as total_tva, 0 as fk_soc, t.date_ech as date, t.periode as date_due, 'SocialContributions' as item, '' as thirdparty_name, '' as thirdparty_code, '' as country_code, '' as vatnum, ".PAY_DEBIT." as sens"; $sql .= " FROM ".MAIN_DB_PREFIX."chargesociales as t"; - $sql .= " WHERE date_creation between ".$wheretail; + $sql .= " WHERE t.date_ech between ".$wheretail; $sql .= " AND t.entity IN (".($entity == 1 ? '0,1' : $entity).')'; //$sql.=" AND fk_statut <> ".ChargeSociales::STATUS_DRAFT; } + // Various payments + if (GETPOST('selectvariouspayment')) { + if (!empty($sql)) $sql .= " UNION ALL"; + $sql .= " SELECT t.rowid as id, t.entity, t.label as ref, 1 as paid, t.amount as total_ht, t.amount as total_ttc, 0 as total_tva, 0 as fk_soc, t.datep as date, t.datep as date_due, 'VariousPayment' as item, '' as thirdparty_name, '' as thirdparty_code, '' as country_code, '' as vatnum, sens"; + $sql .= " FROM ".MAIN_DB_PREFIX."payment_various as t"; + $sql .= " WHERE datep between ".$wheretail; + $sql .= " AND t.entity IN (".($entity == 1 ? '0,1' : $entity).')'; + } + // Loan payments + if (GETPOST('selectloanspayment')) { + if (!empty($sql)) $sql .= " UNION ALL"; + $sql .= " SELECT t.rowid as id, l.entity, l.label as ref, 1 as paid, (t.amount_capital+t.amount_insurance+t.amount_interest) as total_ht, (t.amount_capital+t.amount_insurance+t.amount_interest) as total_ttc, 0 as total_tva, 0 as fk_soc, t.datep as date, t.datep as date_due, 'LoanPayment' as item, '' as thirdparty_name, '' as thirdparty_code, '' as country_code, '' as vatnum, ".PAY_DEBIT." as sens"; + $sql .= " FROM ".MAIN_DB_PREFIX."payment_loan as t LEFT JOIN ".MAIN_DB_PREFIX."loan as l ON l.rowid = t.fk_loan"; + $sql .= " WHERE datep between ".$wheretail; + $sql .= " AND l.entity IN (".($entity == 1 ? '0,1' : $entity).')'; + } if ($sql) { $sql .= $db->order($sortfield, $sortorder); @@ -221,6 +246,7 @@ if (($action == 'searchfiles' || $action == 'dl')) { $subdir .= ($subdir ? '/' : '').dol_sanitizeFileName($objd->ref); $upload_dir = $conf->facture->dir_output.'/'.$subdir; $link = "document.php?modulepart=facture&file=".str_replace('/', '%2F', $subdir).'%2F'; + $modulepart = "facture"; break; case "SupplierInvoice": $tmpinvoicesupplier->fetch($objd->id); @@ -228,18 +254,21 @@ if (($action == 'searchfiles' || $action == 'dl')) { $subdir .= ($subdir ? '/' : '').dol_sanitizeFileName($objd->ref); $upload_dir = $conf->fournisseur->facture->dir_output.'/'.$subdir; $link = "document.php?modulepart=facture_fournisseur&file=".str_replace('/', '%2F', $subdir).'%2F'; + $modulepart = "facture_fournisseur"; break; case "ExpenseReport": $subdir = ''; $subdir .= ($subdir ? '/' : '').dol_sanitizeFileName($objd->ref); $upload_dir = $conf->expensereport->dir_output.'/'.$subdir; $link = "document.php?modulepart=expensereport&file=".str_replace('/', '%2F', $subdir).'%2F'; + $modulepart = "expensereport"; break; case "SalaryPayment": $subdir = ''; $subdir .= ($subdir ? '/' : '').dol_sanitizeFileName($objd->id); $upload_dir = $conf->salaries->dir_output.'/'.$subdir; $link = "document.php?modulepart=salaries&file=".str_replace('/', '%2F', $subdir).'%2F'; + $modulepart = "salaries"; break; case "Donation": $tmpdonation->fetch($objp->id); @@ -247,12 +276,28 @@ if (($action == 'searchfiles' || $action == 'dl')) { $subdir .= ($subdir ? '/' : '').dol_sanitizeFileName($objd->id); $upload_dir = $conf->don->dir_output.'/'.$subdir; $link = "document.php?modulepart=don&file=".str_replace('/', '%2F', $subdir).'%2F'; + $modulepart = "don"; break; case "SocialContributions": $subdir = ''; $subdir .= ($subdir ? '/' : '').dol_sanitizeFileName($objd->id); $upload_dir = $conf->tax->dir_output.'/'.$subdir; $link = "document.php?modulepart=tax&file=".str_replace('/', '%2F', $subdir).'%2F'; + $modulepart = "tax"; + break; + case "VariousPayment": + $subdir = ''; + $subdir .= ($subdir ? '/' : '').dol_sanitizeFileName($objd->id); + $upload_dir = $conf->bank->dir_output.'/'.$subdir; + $link = "document.php?modulepart=banque&file=".str_replace('/', '%2F', $subdir).'%2F'; + $modulepart = "banque"; + break; + case "LoanPayment": + // Loan payment has no linked file + $subdir = ''; + $upload_dir = $conf->loan->dir_output.'/'.$subdir; + $link = ""; + $modulepart = ""; break; default: $subdir = ''; @@ -286,11 +331,10 @@ if (($action == 'searchfiles' || $action == 'dl')) { $nofile['thirdparty_code'] = $objd->thirdparty_code; $nofile['country_code'] = $objd->country_code; $nofile['vatnum'] = $objd->vatnum; + $nofile['sens'] = $objd->sens; $filesarray[$nofile['item'].'_'.$nofile['id']] = $nofile; - } - else - { + } else { foreach ($files as $key => $file) { $file['id'] = $objd->id; @@ -304,11 +348,11 @@ if (($action == 'searchfiles' || $action == 'dl')) { $file['ref'] = ($objd->ref ? $objd->ref : $objd->id); $file['fk'] = $objd->fk_soc; $file['item'] = $objd->item; - $file['thirdparty_name'] = $objd->thirdparty_name; $file['thirdparty_code'] = $objd->thirdparty_code; $file['country_code'] = $objd->country_code; $file['vatnum'] = $objd->vatnum; + $file['sens'] = $objd->sens; // Save record into array (only the first time it is found) if (empty($filesarray[$file['item'].'_'.$file['id']])) { @@ -319,7 +363,16 @@ if (($action == 'searchfiles' || $action == 'dl')) { if (empty($filesarray[$file['item'].'_'.$file['id']]['files'])) { $filesarray[$file['item'].'_'.$file['id']]['files'] = array(); } - $filesarray[$file['item'].'_'.$file['id']]['files'][] = array('link' => $link.$file['name'], 'name'=>$file['name'], 'ref'=>$file['ref'], 'fullname' => $file['fullname'], 'relpathnamelang' => $langs->trans($file['item']).'/'.$file['name']); + $filesarray[$file['item'].'_'.$file['id']]['files'][] = array( + 'link' => $link.urlencode($file['name']), + 'name'=>$file['name'], + 'ref'=>$file['ref'], + 'fullname' => $file['fullname'], + 'relpath' => '/'.$file['name'], + 'relpathnamelang' => $langs->trans($file['item']).'/'.$file['name'], + 'modulepart' => $modulepart, + 'subdir' => $subdir, + ); //var_dump($file['item'].'_'.$file['id']); //var_dump($filesarray[$file['item'].'_'.$file['id']]['files']); } @@ -328,15 +381,12 @@ if (($action == 'searchfiles' || $action == 'dl')) { $i++; } - } - else - { + } else { dol_print_error($db); } $db->free($resd); - } - else { + } else { setEventMessages($langs->trans("ErrorSelectAtLeastOne"), null, 'errors'); $error++; } @@ -383,7 +433,8 @@ if ($result && $action == "dl" && !$error) $log .= ','.$langs->transnoentitiesnoconv("ThirdParty"); $log .= ','.$langs->transnoentitiesnoconv("Code"); $log .= ','.$langs->transnoentitiesnoconv("Country"); - $log .= ','.$langs->transnoentitiesnoconv("VATIntra")."\n"; + $log .= ','.$langs->transnoentitiesnoconv("VATIntra"); + $log .= ','.$langs->transnoentitiesnoconv("Sens")."\n"; $zipname = $dirfortmpfile.'/'.dol_print_date($date_start, 'dayrfc')."-".dol_print_date($date_stop, 'dayrfc').'_export.zip'; dol_delete_file($zipname); @@ -394,11 +445,13 @@ if ($result && $action == "dl" && !$error) { foreach ($filesarray as $key => $file) { - foreach ($file['files'] as $filecursor) { - if (file_exists($filecursor["fullname"])) { - $zip->addFile($filecursor["fullname"], $filecursor["relpathnamelang"]); - } - } + if (!empty($file['files'])) { + foreach ($file['files'] as $filecursor) { + if (file_exists($filecursor["fullname"])) { + $zip->addFile($filecursor["fullname"], $filecursor["relpathnamelang"]); + } + } + } $log .= '"'.$langs->trans($file['item']).'"'; if (!empty($conf->multicompany->enabled) && is_object($mc)) @@ -418,6 +471,7 @@ if ($result && $action == "dl" && !$error) $log .= ',"'.$file['thirdparty_code'].'"'; $log .= ',"'.$file['country_code'].'"'; $log .= ',"'.$file['vatnum'].'"'; + $log .= ',"'.$file['sens'].'"'; $log .= "\n"; } $zip->addFromString('transactions.csv', $log); @@ -432,9 +486,7 @@ if ($result && $action == "dl" && !$error) dol_delete_file($zipname); exit(); - } - else - { + } else { setEventMessages($langs->trans("FailedToOpenFile", $zipname), null, 'errors'); } } @@ -444,10 +496,17 @@ if ($result && $action == "dl" && !$error) * View */ -$form = new Form($db); +$form = new form($db); +$formfile = new FormFile($db); $userstatic = new User($db); $invoice = new Facture($db); $supplier_invoice = new FactureFournisseur($db); +$expensereport = new ExpenseReport($db); +$don = new Don($db); +$salary_payment = new PaymentSalary($db); +$charge_sociales = new ChargeSociales($db); +$various_payment = new PaymentVarious($db); +$payment_loan = new PaymentLoan($db); $title = $langs->trans("ComptaFiles").' - '.$langs->trans("List"); $help_url = ''; @@ -492,7 +551,9 @@ $listofchoices = array( 'selectexpensereports'=>array('label'=>'ExpenseReports', 'lang'=>'trips'), 'selectdonations'=>array('label'=>'Donations', 'lang'=>'donation'), 'selectpaymentsofsalaries'=>array('label'=>'SalariesPayments', 'lang'=>'salaries'), - 'selectsocialcontributions'=>array('label'=>'SocialContributions') + 'selectsocialcontributions'=>array('label'=>'SocialContributions'), + 'selectvariouspayment'=>array('label'=>'VariousPayment'), + 'selectloanspayment'=>array('label'=>'PaymentLoan'), ); foreach ($listofchoices as $choice => $val) { $checked = (((!GETPOSTISSET('search') && $action != 'searchfiles') || GETPOST($choice)) ? ' checked="checked"' : ''); @@ -557,16 +618,15 @@ if (!empty($date_start) && !empty($date_stop)) if (empty($TData)) { print '
'.$langs->trans("NoItem").'
'; - if ($data['item'] == 'Invoice') { - $invoice->id = $data['id']; + if ($data['item'] == 'Invoice') { + $invoice->id = $data['id']; $invoice->ref = $data['ref']; print $invoice->getNomUrl(1, '', 0, 0, '', 0, 0, 0); - } elseif ($data['item'] == 'SupplierInvoice') { + } elseif ($data['item'] == 'SupplierInvoice') { $supplier_invoice->id = $data['id']; $supplier_invoice->ref = $data['ref']; print $supplier_invoice->getNomUrl(1, '', 0, 0, '', 0, 0, 0); - } else { + } elseif ($data['item'] == 'ExpenseReport') { + $expensereport->id = $data['id']; + $expensereport->ref = $data['ref']; + print $expensereport->getNomUrl(1, 0, 0, '', 0, 0); + } elseif ($data['item'] == 'SalaryPayment') { + $salary_payment->id = $data['id']; + $salary_payment->ref = $data['ref']; + print $salary_payment->getNomUrl(1, '', 0, '', 0); + } elseif ($data['item'] == 'Donation') { + $don->id = $data['id']; + $don->ref = $data['ref']; + print $don->getNomUrl(1, 0, '', 0); + } elseif ($data['item'] == 'SocialContributions') { + $charge_sociales->id = $data['id']; + $charge_sociales->ref = $data['ref']; + print $charge_sociales->getNomUrl(1, 0, 0, 0, 0); + } elseif ($data['item'] == 'VariousPayment') { + $various_payment->id = $data['id']; + $various_payment->ref = $data['ref']; + print $various_payment->getNomUrl(1, '', 0, 0); + } elseif ($data['item'] == 'LoanPayment') { + $payment_loan->id = $data['id']; + $payment_loan->ref = $data['ref']; + print $payment_loan->getNomUrl(1, 0, 0, '', 0); + } else { print $data['ref']; - } + } print ''; if (!empty($data['files'])) { - foreach ($data['files'] as $filecursor) { - print ''.($filecursor['name'] ? $filecursor['name'] : $filecursor['ref']).'
'; + foreach ($data['files'] as $id=>$filecursor) { + print ''.($filecursor['name'] ? $filecursor['name'] : $filecursor['ref']).' '.$formfile->showPreview($filecursor, $filecursor['modulepart'], $filecursor['subdir'].'/'.$filecursor['name']).'
'; } } print "
'.$data['paid'].''.price($data['amount_ht'])."'.price($data['sens'] ? $data['amount_ht'] : -$data['amount_ht'])."'.price($data['amount_ttc'])."'.price($data['sens'] ? $data['amount_ttc'] : -$data['amount_ttc'])."'.price($data['amount_vat'])."'.price($data['sens'] ? $data['amount_vat'] : -$data['amount_vat'])."'.$data['thirdparty_name']."'.$data['vatnum']."'.(($data['amount_ttc'] > 0) ? price(abs($data['amount_ttc'])) : '')."'.(($data['amount_ttc'] > 0) ? '' : price(abs($data['amount_ttc'])))."'.price($data['balance'])."
'.price(price2num($totalET, 'MT')).''.price(price2num($totalIT, 'MT')).''.price(price2num($totalVAT, 'MT')).''.price($totalDebit).''.price($totalCredit).''.price(price2num($totalDebit - $totalCredit, 'MT')).''.$langs->trans('Total').' '.$langs->trans('Income').''.price(price2num($totalET_credit, 'MT')).''.price(price2num($totalIT_credit, 'MT')).''.price(price2num($totalVAT_credit, 'MT')).'
'.$langs->trans('Total').' '.$langs->trans('Outcome').''.price(price2num($totalET_debit, 'MT')).''.price(price2num($totalIT_debit, 'MT')).''.price(price2num($totalVAT_debit, 'MT')).'
'.$langs->trans('Total').''.price(price2num($totalET_credit + $totalET_debit, 'MT')).''.price(price2num($totalIT_credit + $totalIT_debit, 'MT')).''.price(price2num($totalVAT_credit + $totalVAT_debit, 'MT')).'
 '.price($balancebefore).' '.price($balancebefore).'- '.price($balance).' '.price($balance).'-'.$langs->trans("Total").''.$langs->trans("Totalforthispage").''.price(-1 * $totalarray['totaldeb']).''.price(-1 * $totalarray['totaldeb']).''.price($totalarray['totalcred']).''; if ($user->rights->banque->consolidate && $action == 'reconcile') print ''; print '
'.$langs->trans("Total").''.price($total).''.price($totalnb ?price2num($total / $totalnb, 'MT') : 0).'
"; diff --git a/htdocs/compta/bank/card.php b/htdocs/compta/bank/card.php index 593893878e0..c99f303210b 100644 --- a/htdocs/compta/bank/card.php +++ b/htdocs/compta/bank/card.php @@ -99,9 +99,7 @@ if ($action == 'add') if (empty($account_number) || $account_number == '-1') { $object->account_number = ''; - } - else - { + } else { $object->account_number = $account_number; } $fk_accountancy_journal = GETPOST('fk_accountancy_journal', 'int'); @@ -155,8 +153,7 @@ if ($action == 'add') $_GET["id"] = $id; // Force chargement page en mode visu $action = ''; - } - else { + } else { $error++; setEventMessages($object->error, $object->errors, 'errors'); @@ -167,9 +164,7 @@ if ($action == 'add') if (!$error) { $db->commit(); - } - else - { + } else { $db->rollback(); } } @@ -205,9 +200,7 @@ if ($action == 'update') if (empty($account_number) || $account_number == '-1') { $object->account_number = ''; - } - else - { + } else { $object->account_number = $account_number; } $fk_accountancy_journal = GETPOST('fk_accountancy_journal', 'int'); @@ -259,9 +252,7 @@ if ($action == 'update') $object->setCategories($categories); $_GET["id"] = $_POST["id"]; // Force chargement page en mode visu - } - else - { + } else { $error++; setEventMessages($object->error, $object->errors, 'errors'); $action = 'edit'; // Force chargement page edition @@ -271,9 +262,7 @@ if ($action == 'update') if (!$error) { $db->commit(); - } - else - { + } else { $db->rollback(); } } @@ -290,9 +279,7 @@ if ($action == 'confirm_delete' && $_POST["confirm"] == "yes" && $user->rights-> setEventMessages($langs->trans("RecordDeleted"), null, 'mesgs'); header("Location: ".DOL_URL_ROOT."/compta/bank/list.php"); exit; - } - else - { + } else { setEventMessages($object->error, $object->errors, 'errors'); $action = ''; } @@ -383,8 +370,7 @@ if ($action == 'create') if (isset($_POST["account_country_id"])) { $selectedcode = $_POST["account_country_id"] ? $_POST["account_country_id"] : $object->country_code; - } - elseif (empty($selectedcode)) $selectedcode = $mysoc->country_code; + } elseif (empty($selectedcode)) $selectedcode = $mysoc->country_code; $object->country_code = getCountry($selectedcode, 2); // Force country code on account to have following field on bank fields matching country rules print ''.$langs->trans("BankAccountCountry").''; @@ -398,9 +384,7 @@ if ($action == 'create') if ($selectedcode) { $formcompany->select_departement(isset($_POST["account_state_id"]) ? $_POST["account_state_id"] : '', $selectedcode, 'account_state_id'); - } - else - { + } else { print $countrynotdefined; } print ''; @@ -544,9 +528,7 @@ if ($action == 'create') print ''; print $formaccounting->select_account($object->account_number, 'account_number', 1, '', 1, 1); print ''; - } - else - { + } else { print ''.$langs->trans("AccountancyCode").''; print 'account_number).'">'; } @@ -571,16 +553,14 @@ if ($action == 'create') print '
'; print ''; -} -/* ************************************************************************** */ -/* */ -/* Visu et edition */ -/* */ -/* ************************************************************************** */ -else -{ - if (($_GET["id"] || $_GET["ref"]) && $action != 'edit') - { +} else { + /* ************************************************************************** */ + /* */ + /* Visu et edition */ + /* */ + /* ************************************************************************** */ + + if (($_GET["id"] || $_GET["ref"]) && $action != 'edit') { $object = new Account($db); if ($_GET["id"]) { @@ -886,9 +866,7 @@ else if ($selectedcode) { print $formcompany->select_state(isset($_POST["account_state_id"]) ? $_POST["account_state_id"] : $object->state_id, $selectedcode, 'account_state_id'); - } - else - { + } else { print $countrynotdefined; } print ''; diff --git a/htdocs/compta/bank/categ.php b/htdocs/compta/bank/categ.php index 29701f57c59..0f71134d08a 100644 --- a/htdocs/compta/bank/categ.php +++ b/htdocs/compta/bank/categ.php @@ -131,15 +131,12 @@ if ($result) print ''; print ''; print ''; - print ""; - } - else - { + } else { print "".$objp->label.""; - print ''; - print ''.img_edit().'  '; - print ''.img_delete().''; + print ''; + print ''.img_edit().''; + print ''.img_delete().''; print ''; } print ""; diff --git a/htdocs/compta/bank/class/account.class.php b/htdocs/compta/bank/class/account.class.php index 58115537b1f..adb170ee81d 100644 --- a/htdocs/compta/bank/class/account.class.php +++ b/htdocs/compta/bank/class/account.class.php @@ -343,9 +343,9 @@ class Account extends CommonObject $string .= $this->code_guichet.' '; } elseif ($val == 'BankAccountNumberKey') { $string .= $this->cle_rib.' '; - }elseif ($val == 'BIC') { + } elseif ($val == 'BIC') { $string .= $this->bic.' '; - }elseif ($val == 'IBAN') { + } elseif ($val == 'IBAN') { $string .= $this->iban.' '; } } @@ -403,9 +403,7 @@ class Account extends CommonObject { $rowid = $this->db->last_insert_id(MAIN_DB_PREFIX."bank_url"); return $rowid; - } - else - { + } else { $this->error = $this->db->lasterror(); return -1; } @@ -437,8 +435,7 @@ class Account extends CommonObject $sql .= " FROM ".MAIN_DB_PREFIX."bank_url"; if ($fk_bank > 0) { $sql .= " WHERE fk_bank = ".$fk_bank; - } - else { $sql .= " WHERE url_id = ".$url_id." AND type = '".$type."'"; + } else { $sql .= " WHERE url_id = ".$url_id." AND type = '".$type."'"; } $sql .= " ORDER BY type, label"; @@ -464,8 +461,7 @@ class Account extends CommonObject $lines[$i]['fk_bank'] = $obj->fk_bank; $i++; } - } - else dol_print_error($this->db); + } else dol_print_error($this->db); return $lines; } @@ -509,9 +505,7 @@ class Account extends CommonObject { $obj = $this->db->fetch_object($resql); $oper = $obj->code; - } - else - { + } else { dol_print_error($this->db, 'Failed to get payment type code'); return -1; } @@ -720,20 +714,15 @@ class Account extends CommonObject if ($result < 0) $error++; // End call triggers } - } - else - { + } else { $error++; } - } - else - { + } else { if ($this->db->errno() == 'DB_ERROR_RECORD_ALREADY_EXISTS') { $this->error = $langs->trans("ErrorBankLabelAlreadyExists"); $error++; - } - else { + } else { $this->error = $this->db->error()." sql=".$sql; $error++; } @@ -743,9 +732,7 @@ class Account extends CommonObject { $this->db->commit(); return $this->id; - } - else - { + } else { $this->db->rollback(); return -1 * $error; } @@ -836,9 +823,7 @@ class Account extends CommonObject if ($result < 0) $error++; // End call triggers } - } - else - { + } else { $error++; $this->error = $this->db->lasterror(); dol_print_error($this->db); @@ -848,9 +833,7 @@ class Account extends CommonObject { $this->db->commit(); return $this->id; - } - else - { + } else { $this->db->rollback(); return -1 * $error; } @@ -907,9 +890,7 @@ class Account extends CommonObject if ($result) { return 1; - } - else - { + } else { $this->error = $this->db->lasterror(); dol_print_error($this->db); return -1; @@ -1006,14 +987,10 @@ class Account extends CommonObject $this->fetch_optionals(); return 1; - } - else - { + } else { return 0; } - } - else - { + } else { $this->error = $this->db->lasterror; $this->errors[] = $this->error; return -1; @@ -1113,9 +1090,7 @@ class Account extends CommonObject dol_syslog(get_class($this)."::delete error -4 ".$this->error, LOG_ERR); } } - } - else - { + } else { $error++; $this->error = "Error ".$this->db->lasterror(); } @@ -1125,9 +1100,7 @@ class Account extends CommonObject { $this->db->commit(); return 1; - } - else - { + } else { $this->db->rollback(); return -1; } @@ -1192,8 +1165,7 @@ class Account extends CommonObject if ($resql) { $obj = $this->db->fetch_object($resql); if ($obj->nb <= 1) $can_be_deleted = true; // Juste le solde - } - else { + } else { dol_print_error($this->db); } return $can_be_deleted; @@ -1291,9 +1263,7 @@ class Account extends CommonObject } return $response; - } - else - { + } else { dol_print_error($this->db); $this->error = $this->db->error(); return -1; @@ -1330,9 +1300,7 @@ class Account extends CommonObject $this->nb["banklines"] = $obj->nb; } $this->db->free($resql); - } - else - { + } else { dol_print_error($this->db); $this->error = $this->db->error(); return -1; @@ -1366,8 +1334,7 @@ class Account extends CommonObject { $obj = $db->fetch_object($resql); $nb = $obj->nb; - } - else dol_print_error($db); + } else dol_print_error($db); return $nb; } @@ -1414,8 +1381,7 @@ class Account extends CommonObject if ($mode == 'transactions') { $url = DOL_URL_ROOT.'/compta/bank/bankentries_list.php?id='.$this->id; - } - elseif ($mode == 'receipts') + } elseif ($mode == 'receipts') { $url = DOL_URL_ROOT.'/compta/bank/releve.php?account='.$this->id; } @@ -1475,9 +1441,7 @@ class Account extends CommonObject if ($this->error_number == 0) { return 1; - } - else - { + } else { return 0; } } @@ -1672,8 +1636,7 @@ class Account extends CommonObject //Replace the old AccountNumber key with the new BankAccountNumber key $fieldlists = explode( ' ', - preg_replace('/ ?[^Bank]AccountNumber ?/', 'BankAccountNumber', - $conf->global->BANK_SHOW_ORDER_OPTION) + preg_replace('/ ?[^Bank]AccountNumber ?/', 'BankAccountNumber', $conf->global->BANK_SHOW_ORDER_OPTION) ); } } @@ -1897,9 +1860,7 @@ class AccountLine extends CommonObject } $this->db->free($result); return $ret; - } - else - { + } else { return -1; } } @@ -1986,8 +1947,7 @@ class AccountLine extends CommonObject $this->db->rollback(); return -1; } - } - else { + } else { $this->error = $this->db->lasterror(); $this->db->rollback(); return -1; @@ -2015,9 +1975,7 @@ class AccountLine extends CommonObject { $this->db->commit(); return 1; - } - else - { + } else { $this->db->rollback(); return -$nbko; } @@ -2054,9 +2012,7 @@ class AccountLine extends CommonObject { $this->db->commit(); return 1; - } - else - { + } else { $this->db->rollback(); return -$nbko; } @@ -2086,9 +2042,7 @@ class AccountLine extends CommonObject { $this->db->commit(); return 1; - } - else - { + } else { $this->db->rollback(); $this->error = $this->db->error(); return -1; @@ -2152,9 +2106,7 @@ class AccountLine extends CommonObject $this->db->commit(); return 1; - } - else - { + } else { $this->db->rollback(); return -1; } @@ -2190,14 +2142,11 @@ class AccountLine extends CommonObject { return 1; } - } - else - { + } else { dol_print_error($this->db); return 0; } - } - else dol_print_error($this->db); + } else dol_print_error($this->db); return 0; } @@ -2257,14 +2206,11 @@ class AccountLine extends CommonObject { return 1; } - } - else - { + } else { dol_print_error($this->db); return 0; } - } - else dol_print_error($this->db); + } else dol_print_error($this->db); return 0; } @@ -2334,9 +2280,7 @@ class AccountLine extends CommonObject //$this->date_rappro = $obj->daterappro; // Not yet managed } $this->db->free($result); - } - else - { + } else { dol_print_error($this->db); } } @@ -2477,9 +2421,7 @@ class AccountLine extends CommonObject { $alreadydispatched = $obj->nb; } - } - else - { + } else { $this->error = $this->db->lasterror(); return -1; } diff --git a/htdocs/compta/bank/class/api_bankaccounts.class.php b/htdocs/compta/bank/class/api_bankaccounts.class.php index ad75559b362..3293f746033 100644 --- a/htdocs/compta/bank/class/api_bankaccounts.class.php +++ b/htdocs/compta/bank/class/api_bankaccounts.class.php @@ -225,9 +225,7 @@ class BankAccounts extends DolibarrApi if ($accountto->currency_code == $accountfrom->currency_code) { $amount_to = $amount; - } - else - { + } else { if (!$amount_to || empty($amount_to)) { throw new RestException(422, 'You must provide amount_to value since bankaccount_from and bankaccount_to does not share the same currency.'); @@ -303,9 +301,7 @@ class BankAccounts extends DolibarrApi 'message' => 'Internal wire transfer created successfully.' ) ); - } - else - { + } else { $this->db->rollback(); throw new RestException(500, $accountfrom->error.' '.$accountto->error); } @@ -338,9 +334,7 @@ class BankAccounts extends DolibarrApi if ($account->update(DolibarrApiAccess::$user) > 0) { return $this->get($id); - } - else - { + } else { throw new RestException(500, $account->error); } } diff --git a/htdocs/compta/bank/class/paymentvarious.class.php b/htdocs/compta/bank/class/paymentvarious.class.php index 6af394ad4b4..65c7e7ce2ea 100644 --- a/htdocs/compta/bank/class/paymentvarious.class.php +++ b/htdocs/compta/bank/class/paymentvarious.class.php @@ -169,9 +169,7 @@ class PaymentVarious extends CommonObject { $this->db->commit(); return 1; - } - else - { + } else { $this->db->rollback(); return -1; } @@ -244,9 +242,7 @@ class PaymentVarious extends CommonObject $this->db->free($resql); return 1; - } - else - { + } else { $this->error = "Error ".$this->db->lasterror(); return -1; } @@ -430,9 +426,7 @@ class PaymentVarious extends CommonObject if ($bank_line_id > 0) { $this->update_fk_bank($bank_line_id); - } - else - { + } else { $this->error = $acc->error; $error++; } @@ -461,22 +455,17 @@ class PaymentVarious extends CommonObject $result = $this->call_trigger('PAYMENT_VARIOUS_CREATE', $user); if ($result < 0) $error++; // End call triggers - } - else $error++; + } else $error++; if (!$error) { $this->db->commit(); return $this->id; - } - else - { + } else { $this->db->rollback(); return -2; } - } - else - { + } else { $this->error = $this->db->error(); $this->db->rollback(); return -1; @@ -499,9 +488,7 @@ class PaymentVarious extends CommonObject if ($result) { return 1; - } - else - { + } else { dol_print_error($this->db); return -1; } @@ -535,30 +522,25 @@ class PaymentVarious extends CommonObject if ($mode == 0) { return $langs->trans($this->statuts[$status]); - } - elseif ($mode == 1) + } elseif ($mode == 1) { return $langs->trans($this->statuts_short[$status]); - } - elseif ($mode == 2) + } elseif ($mode == 2) { if ($status == 0) return img_picto($langs->trans($this->statuts_short[$status]), 'statut0').' '.$langs->trans($this->statuts_short[$status]); elseif ($status == 1) return img_picto($langs->trans($this->statuts_short[$status]), 'statut4').' '.$langs->trans($this->statuts_short[$status]); elseif ($status == 2) return img_picto($langs->trans($this->statuts_short[$status]), 'statut6').' '.$langs->trans($this->statuts_short[$status]); - } - elseif ($mode == 3) + } elseif ($mode == 3) { if ($status == 0 && !empty($this->statuts_short[$status])) return img_picto($langs->trans($this->statuts_short[$status]), 'statut0'); elseif ($status == 1 && !empty($this->statuts_short[$status])) return img_picto($langs->trans($this->statuts_short[$status]), 'statut4'); elseif ($status == 2 && !empty($this->statuts_short[$status])) return img_picto($langs->trans($this->statuts_short[$status]), 'statut6'); - } - elseif ($mode == 4) + } elseif ($mode == 4) { if ($status == 0 && !empty($this->statuts_short[$status])) return img_picto($langs->trans($this->statuts_short[$status]), 'statut0').' '.$langs->trans($this->statuts[$status]); elseif ($status == 1 && !empty($this->statuts_short[$status])) return img_picto($langs->trans($this->statuts_short[$status]), 'statut4').' '.$langs->trans($this->statuts[$status]); elseif ($status == 2 && !empty($this->statuts_short[$status])) return img_picto($langs->trans($this->statuts_short[$status]), 'statut6').' '.$langs->trans($this->statuts[$status]); - } - elseif ($mode == 5) + } elseif ($mode == 5) { if ($status == 0 && !empty($this->statuts_short[$status])) return $langs->trans($this->statuts_short[$status]).' '.img_picto($langs->trans($this->statuts_short[$status]), 'statut0'); elseif ($status == 1 && !empty($this->statuts_short[$status])) return $langs->trans($this->statuts_short[$status]).' '.img_picto($langs->trans($this->statuts_short[$status]), 'statut4'); @@ -616,8 +598,7 @@ class PaymentVarious extends CommonObject $reshook=$hookmanager->executeHooks('getnomurltooltip',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks if ($reshook > 0) $linkclose = $hookmanager->resPrint; */ - } - else $linkclose = ($morecss ? ' class="'.$morecss.'"' : ''); + } else $linkclose = ($morecss ? ' class="'.$morecss.'"' : ''); $linkstart = ''; @@ -676,9 +657,7 @@ class PaymentVarious extends CommonObject $this->date_modif = $this->db->jdate($obj->tms); } $this->db->free($result); - } - else - { + } else { dol_print_error($this->db); } } @@ -705,9 +684,7 @@ class PaymentVarious extends CommonObject { $alreadydispatched = $obj->nb; } - } - else - { + } else { $this->error = $this->db->lasterror(); return -1; } diff --git a/htdocs/compta/bank/document.php b/htdocs/compta/bank/document.php index d003463e5af..09cd81d4198 100644 --- a/htdocs/compta/bank/document.php +++ b/htdocs/compta/bank/document.php @@ -137,12 +137,10 @@ if ($id > 0 || !empty($ref)) { $permtoedit = $user->rights->banque->modifier; $param = '&id='.$object->id; include_once DOL_DOCUMENT_ROOT.'/core/tpl/document_actions_post_headers.tpl.php'; - } - else { + } else { dol_print_error($db); } -} -else { +} else { Header('Location: index.php'); exit; } diff --git a/htdocs/compta/bank/graph.php b/htdocs/compta/bank/graph.php index 347353be84f..296211bf35c 100644 --- a/htdocs/compta/bank/graph.php +++ b/htdocs/compta/bank/graph.php @@ -84,9 +84,7 @@ if ($result < 0) $langs->load("errors"); $error++; setEventMessages($langs->trans("ErrorFailedToCreateDir"), null, 'errors'); -} -else -{ +} else { // Calcul $min and $max $sql = "SELECT MIN(b.datev) as min, MAX(b.datev) as max"; $sql .= " FROM ".MAIN_DB_PREFIX."bank as b"; @@ -102,9 +100,7 @@ else $obj = $db->fetch_object($resql); $min = $db->jdate($obj->min); $max = $db->jdate($obj->max); - } - else - { + } else { dol_print_error($db); } if (empty($min)) $min = dol_now() - 3600 * 24; @@ -151,9 +147,7 @@ else $i++; } $db->free($resql); - } - else - { + } else { dol_print_error($db); } @@ -174,9 +168,7 @@ else $row = $db->fetch_row($resql); $solde = $row[0]; $db->free($resql); - } - else - { + } else { dol_print_error($db); } @@ -199,9 +191,7 @@ else if ($day > time()) { $datas[$i] = ''; // Valeur speciale permettant de ne pas tracer le graph - } - else - { + } else { $datas[$i] = $solde + $subtotal; } $datamin[$i] = $object->min_desired; @@ -294,9 +284,7 @@ else $i++; } $db->free($resql); - } - else - { + } else { dol_print_error($db); } @@ -317,9 +305,7 @@ else $row = $db->fetch_row($resql); $solde = $row[0]; $db->free($resql); - } - else - { + } else { dol_print_error($db); } @@ -343,9 +329,7 @@ else if ($day > $now) { $datas[$i] = ''; // Valeur speciale permettant de ne pas tracer le graph - } - else - { + } else { $datas[$i] = $solde + $subtotal; } $datamin[$i] = $object->min_desired; @@ -431,9 +415,7 @@ else $amounts[$row[0]] = $row[1]; $i++; } - } - else - { + } else { dol_print_error($db); } @@ -459,9 +441,7 @@ else if ($day > ($max + 86400)) { $datas[$i] = ''; // Valeur speciale permettant de ne pas tracer le graph - } - else - { + } else { $datas[$i] = 0 + $solde + $subtotal; } $datamin[$i] = $object->min_desired; @@ -557,9 +537,7 @@ else $i++; } $db->free($resql); - } - else - { + } else { dol_print_error($db); } @@ -591,9 +569,7 @@ else $debits[$row[0]] = abs($row[1]); } $db->free($resql); - } - else - { + } else { dol_print_error($db); } @@ -674,9 +650,7 @@ else $i++; } $db->free($resql); - } - else - { + } else { dol_print_error($db); } $sql = "SELECT date_format(b.datev,'%m')"; @@ -699,9 +673,7 @@ else $debits[$row[0]] = abs($row[1]); } $db->free($resql); - } - else - { + } else { dol_print_error($db); } @@ -770,16 +742,12 @@ if ($account) { $morehtml = ''.$langs->trans("ShowAllAccounts").''; dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', '', $moreparam, 0, '', '', 1); - } - else - { + } else { $morehtml = ''.$langs->trans("BackToAccount").''; print $langs->trans("AllAccounts"); //print $morehtml; } - } - else - { + } else { $bankaccount = new Account($db); $listid = explode(',', $account); foreach ($listid as $key => $id) @@ -790,9 +758,7 @@ if ($account) if ($key < (count($listid) - 1)) print ', '; } } -} -else -{ +} else { print $langs->trans("AllAccounts"); } @@ -808,9 +774,7 @@ if ($mode == 'showalltime') print ''; print $langs->trans("GoBack"); print ''; -} -else -{ +} else { print ''; print $langs->trans("ShowAllTimeBalance"); print ''; diff --git a/htdocs/compta/bank/info.php b/htdocs/compta/bank/info.php index abab3b4ff9c..6f6d7236f15 100644 --- a/htdocs/compta/bank/info.php +++ b/htdocs/compta/bank/info.php @@ -46,7 +46,7 @@ $object->info($id); $h = 0; $head[$h][0] = DOL_URL_ROOT.'/compta/bank/line.php?rowid='.$id; -$head[$h][1] = $langs->trans("Card"); +$head[$h][1] = $langs->trans("BankTransaction"); $h++; $head[$h][0] = DOL_URL_ROOT.'/compta/bank/info.php?rowid='.$id; diff --git a/htdocs/compta/bank/line.php b/htdocs/compta/bank/line.php index 6e53dd00c37..d2b3e6099dd 100644 --- a/htdocs/compta/bank/line.php +++ b/htdocs/compta/bank/line.php @@ -76,15 +76,15 @@ if ($user->rights->banque->consolidate && $action == 'donext') { $al = new AccountLine($db); $al->dateo_next($_GET["rowid"]); -}elseif ($user->rights->banque->consolidate && $action == 'doprev') +} elseif ($user->rights->banque->consolidate && $action == 'doprev') { $al = new AccountLine($db); $al->dateo_previous($_GET["rowid"]); -}elseif ($user->rights->banque->consolidate && $action == 'dvnext') +} elseif ($user->rights->banque->consolidate && $action == 'dvnext') { $al = new AccountLine($db); $al->datev_next($_GET["rowid"]); -}elseif ($user->rights->banque->consolidate && $action == 'dvprev') +} elseif ($user->rights->banque->consolidate && $action == 'dvprev') { $al = new AccountLine($db); $al->datev_previous($_GET["rowid"]); @@ -99,9 +99,7 @@ if ($action == 'confirm_delete_categ' && $confirm == "yes" && $user->rights->ban { dol_print_error($db); } - } - else - { + } else { setEventMessages($langs->trans("MissingIds"), null, 'errors'); } } @@ -120,9 +118,7 @@ if ($user->rights->banque->modifier && $action == "update") if (GETPOST('accountid', 'int') > 0 && !$acline->rappro && !$acline->getVentilExportCompta()) // We ask to change bank account { $actarget->fetch(GETPOST('accountid', 'int')); - } - else - { + } else { $actarget->fetch($id); } @@ -191,9 +187,7 @@ if ($user->rights->banque->modifier && $action == "update") { setEventMessages($langs->trans("RecordSaved"), null, 'mesgs'); $db->commit(); - } - else - { + } else { $db->rollback(); dol_print_error($db); } @@ -229,9 +223,7 @@ if ($user->rights->banque->consolidate && ($action == 'num_releve' || $action == { setEventMessages($langs->trans("RecordSaved"), null, 'mesgs'); $db->commit(); - } - else - { + } else { $db->rollback(); dol_print_error($db); } @@ -257,7 +249,7 @@ foreach ($cats as $cat) { $tabs = array( array( DOL_URL_ROOT.'/compta/bank/line.php?rowid='.$rowid, - $langs->trans('Card') + $langs->trans('BankTransaction') ), array( DOL_URL_ROOT.'/compta/bank/info.php?rowid='.$rowid, @@ -324,9 +316,7 @@ if ($result) if (!$objp->rappro && !$bankline->getVentilExportCompta()) { $form->select_comptes($acct->id, 'accountid', 0, '', 0); - } - else - { + } else { print $acct->getNomUrl(1, 'transactions', 'reflabel'); } print ''; @@ -350,8 +340,7 @@ if ($result) print $langs->trans("Payment"); print '';*/ print $paymenttmp->getNomUrl(1); - } - elseif ($links[$key]['type'] == 'payment_supplier') { + } elseif ($links[$key]['type'] == 'payment_supplier') { require_once DOL_DOCUMENT_ROOT.'/fourn/class/paiementfourn.class.php'; $paymenttmp = new PaiementFourn($db); $paymenttmp->fetch($links[$key]['url_id']); @@ -361,79 +350,66 @@ if ($result) print $langs->trans("Payment"); print '';*/ print $paymenttmp->getNomUrl(1); - } - elseif ($links[$key]['type'] == 'company') { + } elseif ($links[$key]['type'] == 'company') { $societe = new Societe($db); $societe->fetch($links[$key]['url_id']); print $societe->getNomUrl(1); - } - elseif ($links[$key]['type'] == 'sc') { + } elseif ($links[$key]['type'] == 'sc') { print ''; print img_object($langs->trans('SocialContribution'), 'bill').' '; print $langs->trans("SocialContribution").($links[$key]['label'] ? ' - '.$links[$key]['label'] : ''); print ''; - } - elseif ($links[$key]['type'] == 'payment_sc') { + } elseif ($links[$key]['type'] == 'payment_sc') { print ''; print img_object($langs->trans('Payment'), 'payment').' '; print $langs->trans("SocialContributionPayment"); print ''; - } - elseif ($links[$key]['type'] == 'payment_vat') { + } elseif ($links[$key]['type'] == 'payment_vat') { print ''; print img_object($langs->trans('VAT'), 'payment').' '; print $langs->trans("VATPayment"); print ''; - } - elseif ($links[$key]['type'] == 'payment_salary') { + } elseif ($links[$key]['type'] == 'payment_salary') { print ''; print img_object($langs->trans('PaymentSalary'), 'payment').' '; print $langs->trans("SalaryPayment"); print ''; - } - elseif ($links[$key]['type'] == 'payment_loan') { + } elseif ($links[$key]['type'] == 'payment_loan') { print ''; print img_object($langs->trans('LoanPayment'), 'payment').' '; print $langs->trans("PaymentLoan"); print ''; - } - elseif ($links[$key]['type'] == 'loan') { + } elseif ($links[$key]['type'] == 'loan') { print ''; print img_object($langs->trans('Loan'), 'bill').' '; print $langs->trans("Loan"); print ''; - } - elseif ($links[$key]['type'] == 'member') { + } elseif ($links[$key]['type'] == 'member') { print ''; print img_object($langs->trans('Member'), 'user').' '; print $links[$key]['label']; print ''; - } - elseif ($links[$key]['type'] == 'payment_donation') { + } elseif ($links[$key]['type'] == 'payment_donation') { print ''; print img_object($langs->trans('Donation'), 'payment').' '; print $langs->trans("DonationPayment"); print ''; - } - elseif ($links[$key]['type'] == 'banktransfert') { + } elseif ($links[$key]['type'] == 'banktransfert') { print ''; print img_object($langs->trans('Transaction'), 'payment').' '; print $langs->trans("TransactionOnTheOtherAccount"); print ''; - } - elseif ($links[$key]['type'] == 'user') { + } elseif ($links[$key]['type'] == 'user') { print ''; print img_object($langs->trans('User'), 'user').' '; print $langs->trans("User"); print ''; - } - elseif ($links[$key]['type'] == 'payment_various') { + } elseif ($links[$key]['type'] == 'payment_various') { print ''; print img_object($langs->trans('VariousPayment'), 'payment').' '; print $langs->trans("VariousPayment"); print ''; - } - else { + } else { print ''; print img_object('', 'generic').' '; print $links[$key]['label']; @@ -463,9 +439,7 @@ if ($result) print '     '.$langs->trans("CheckReceipt").': '.$receipt->getNomUrl(2); } print ''; - } - else - { + } else { print ''.$objp->fk_type.' '.$objp->num_chq.''; } print ""; @@ -479,9 +453,7 @@ if ($result) print ''; print ''; print ''; - } - else - { + } else { print ''.$objp->emetteur.''; } print ""; @@ -495,9 +467,7 @@ if ($result) print ''; print ''; print ''; - } - else - { + } else { print ''.$objp->banque.''; } print ""; @@ -517,9 +487,7 @@ if ($result) print img_edit_add().""; } print ''; - } - else - { + } else { print ''; print dol_print_date($db->jdate($objp->do), "day"); print ''; @@ -541,9 +509,7 @@ if ($result) print img_edit_add().""; } print ''; - } - else - { + } else { print ''; print dol_print_date($db->jdate($objp->dv), "day"); print ''; @@ -560,24 +526,18 @@ if ($result) { // Label generique car entre parentheses. On l'affiche en le traduisant print $langs->trans($reg[1]); - } - else - { + } else { print $objp->label; } print '">'; print ''; - } - else - { + } else { print ''; if (preg_match('/^\((.*)\)$/i', $objp->label, $reg)) { // Label generique car entre parentheses. On l'affiche en le traduisant print $langs->trans($reg[1]); - } - else - { + } else { print $objp->label; } print ''; @@ -591,9 +551,7 @@ if ($result) print ''; print 'rappro ? ' disabled' : '').' value="'.price($objp->amount).'"> '.$langs->trans("Currency".$acct->currency_code); print ''; - } - else - { + } else { print ''; print price($objp->amount); print ''; @@ -649,16 +607,12 @@ if ($result) { print $langs->trans("AccountStatement").' rappro ? ' disabled' : '').'>'; print ''; - } - else - { + } else { print $langs->trans("AccountStatement").' rappro ? ' disabled' : '').'>'; } if ($objp->num_releve) print '   ('.$langs->trans("AccountStatement").' '.$objp->num_releve.')'; print ''; - } - else - { + } else { print ''.$objp->num_releve.' '; } print ''; @@ -669,9 +623,7 @@ if ($result) print ''; print 'rappro ? ' checked="checked"' : '')).'">'; print ''; - } - else - { + } else { print ''.yn($objp->rappro).''; } print ''; @@ -694,8 +646,7 @@ if ($result) } $db->free($result); -} -else dol_print_error($db); +} else dol_print_error($db); // End of page llxFooter(); diff --git a/htdocs/compta/bank/list.php b/htdocs/compta/bank/list.php index eaefdfb6573..882244518f7 100644 --- a/htdocs/compta/bank/list.php +++ b/htdocs/compta/bank/list.php @@ -212,8 +212,7 @@ if ($resql) $i++; } $db->free($resql); -} -else dol_print_error($db); +} else dol_print_error($db); @@ -487,9 +486,7 @@ foreach ($accounts as $key=>$type) $accountingaccount = new AccountingAccount($db); $accountingaccount->fetch('', $objecttmp->account_number, 1); print $accountingaccount->getNomUrl(0, 1, 1, '', 1); - } - else - { + } else { print $objecttmp->account_number; } print ''; @@ -505,9 +502,7 @@ foreach ($accounts as $key=>$type) $accountingjournal = new AccountingJournal($db); $accountingjournal->fetch($objecttmp->fk_accountancy_journal); print $accountingjournal->getNomUrl(0, 1, 1, '', 1); - } - else - { + } else { print ''; } print ''; @@ -556,9 +551,15 @@ foreach ($accounts as $key=>$type) } // Extra fields + if (is_array($objecttmp->array_options)) { + $obj = new stdClass(); + foreach ($objecttmp->array_options as $k => $v) { + $obj->$k = $v; + } + } include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; // Fields from hook - $parameters = array('arrayfields'=>$arrayfields); + $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray); $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $objecttmp); // Note that $action and $objecttmpect may have been modified by hook print $hookmanager->resPrint; // Date creation diff --git a/htdocs/compta/bank/releve.php b/htdocs/compta/bank/releve.php index c737af4a89e..ba5896d6d7d 100644 --- a/htdocs/compta/bank/releve.php +++ b/htdocs/compta/bank/releve.php @@ -125,8 +125,7 @@ if ($_GET["rel"] == 'prev') $found = true; } } -} -elseif ($_GET["rel"] == 'next') +} elseif ($_GET["rel"] == 'next') { // Recherche valeur pour num = numero releve precedent $sql = "SELECT DISTINCT(b.num_releve) as num"; @@ -147,8 +146,7 @@ elseif ($_GET["rel"] == 'next') $found = true; } } -} -else { +} else { // On veut le releve num $found = true; } @@ -179,7 +177,7 @@ $sqlrequestforbankline = $sql; if ($action == 'confirm_editbankreceipt' && !empty($oldbankreceipt) && !empty($newbankreceipt)) { // TODO Add a test to check newbankreceipt does not exists yet - $sqlupdate = 'UPDATE '.MAIN_DB_PREFIX.'bank SET num_releve = "'.$db->escape($newbankreceipt).'" WHERE num_releve = "'.$db->escape($oldbankreceipt).'"'; + $sqlupdate = 'UPDATE '.MAIN_DB_PREFIX.'bank SET num_releve = "'.$db->escape($newbankreceipt).'" WHERE num_releve = "'.$db->escape($oldbankreceipt).'" AND fk_account = '.$id; $result = $db->query($sqlupdate); if ($result < 0) dol_print_error($db); @@ -295,17 +293,13 @@ if (empty($numref)) if (!isset($objp->numr)) { // - } - else - { + } else { print ''; print ''; if ($action != 'editbankreceipt' || $objp->numr != $brref) { print ''.$objp->numr.''; - } - else - { + } else { print ''; print ''; print ''; @@ -355,14 +349,10 @@ if (empty($numref)) print ''; print "\n
\n"; - } - else - { + } else { dol_print_error($db); } -} -else -{ +} else { /** * Show list of record into a bank statement */ @@ -488,58 +478,50 @@ else $paymentstatic->ref = $langs->trans("Payment"); print ' '.$paymentstatic->getNomUrl(1); $newline = 0; - } - elseif ($links[$key]['type'] == 'payment_supplier') + } elseif ($links[$key]['type'] == 'payment_supplier') { $paymentsupplierstatic->id = $links[$key]['url_id']; $paymentsupplierstatic->ref = $langs->trans("Payment"); print ' '.$paymentsupplierstatic->getNomUrl(1); $newline = 0; - } - elseif ($links[$key]['type'] == 'payment_sc') + } elseif ($links[$key]['type'] == 'payment_sc') { print ''; print ' '.img_object($langs->trans('ShowPayment'), 'payment').' '; print $langs->trans("SocialContributionPayment"); print ''; $newline = 0; - } - elseif ($links[$key]['type'] == 'payment_vat') + } elseif ($links[$key]['type'] == 'payment_vat') { $paymentvatstatic->id = $links[$key]['url_id']; $paymentvatstatic->ref = $langs->trans("Payment"); print ' '.$paymentvatstatic->getNomUrl(1); - } - elseif ($links[$key]['type'] == 'payment_salary') + } elseif ($links[$key]['type'] == 'payment_salary') { print ''; print ' '.img_object($langs->trans('ShowPayment'), 'payment').' '; print $langs->trans("Payment"); print ''; $newline = 0; - } - elseif ($links[$key]['type'] == 'payment_donation') + } elseif ($links[$key]['type'] == 'payment_donation') { $paymentdonationstatic->id = $links[$key]['url_id']; $paymentdonationstatic->ref = $langs->trans("Payment"); print ' '.$paymentdonationstatic->getNomUrl(1); $newline = 0; - } - elseif ($links[$key]['type'] == 'payment_loan') + } elseif ($links[$key]['type'] == 'payment_loan') { $paymentloanstatic->id = $links[$key]['url_id']; $paymentloanstatic->ref = $langs->trans("Payment"); print ' '.$paymentloanstatic->getNomUrl(1); $newline = 0; - } - elseif ($links[$key]['type'] == 'payment_various') + } elseif ($links[$key]['type'] == 'payment_various') { $paymentvariousstatic->id = $links[$key]['url_id']; $paymentvariousstatic->ref = $langs->trans("Payment"); print ' '.$paymentvariousstatic->getNomUrl(1); $newline = 0; - } - elseif ($links[$key]['type'] == 'banktransfert') { + } elseif ($links[$key]['type'] == 'banktransfert') { // Do not show link to transfer since there is no transfer card (avoid confusion). Can already be accessed from transaction detail. if ($objp->amount > 0) { @@ -553,9 +535,7 @@ else $bankstatic->label = $objp->bankref; print $bankstatic->getNomUrl(1, ''); print ')'; - } - else - { + } else { $bankstatic->id = $objp->bankid; $bankstatic->label = $objp->bankref; print ' ('.$langs->trans("from").' '; @@ -567,35 +547,30 @@ else print $bankstatic->getNomUrl(1, 'transactions'); print ')'; } - } - elseif ($links[$key]['type'] == 'company') { + } elseif ($links[$key]['type'] == 'company') { $societestatic->id = $links[$key]['url_id']; $societestatic->name = $links[$key]['label']; print $societestatic->getNomUrl(1, 'company', 24); $newline = 0; - } - elseif ($links[$key]['type'] == 'member') { + } elseif ($links[$key]['type'] == 'member') { print ''; print img_object($langs->trans('ShowMember'), 'user').' '; print $links[$key]['label']; print ''; $newline = 0; - } - elseif ($links[$key]['type'] == 'user') { + } elseif ($links[$key]['type'] == 'user') { print ''; print img_object($langs->trans('ShowUser'), 'user').' '; print $links[$key]['label']; print ''; $newline = 0; - } - elseif ($links[$key]['type'] == 'sc') { + } elseif ($links[$key]['type'] == 'sc') { print ''; print img_object($langs->trans('ShowBill'), 'bill').' '; print $langs->trans("SocialContribution"); print ''; $newline = 0; - } - else { + } else { print ''; print $links[$key]['label']; print ''; @@ -625,9 +600,7 @@ else print "
".$objc->label.""; $ii++; } - } - else - { + } else { dol_print_error($db); } } @@ -638,9 +611,7 @@ else { $totald = $totald + abs($objp->amount); print ''.price($objp->amount * -1)." \n"; - } - else - { + } else { $totalc = $totalc + abs($objp->amount); print ' '.price($objp->amount)."\n"; } @@ -652,9 +623,7 @@ else print ''; print img_edit(); print ""; - } - else - { + } else { print " "; } print ""; diff --git a/htdocs/compta/bank/transfer.php b/htdocs/compta/bank/transfer.php index aa4c39e55ee..7228c38fe50 100644 --- a/htdocs/compta/bank/transfer.php +++ b/htdocs/compta/bank/transfer.php @@ -87,9 +87,7 @@ if ($action == 'add') if ($accountto->currency_code == $accountfrom->currency_code) { $amountto = $amount; - } - else - { + } else { if (!$amountto) { $error++; @@ -130,15 +128,11 @@ if ($action == 'add') $mesgs = $langs->trans("TransferFromToDone", ''.$accountfrom->label."", ''.$accountto->label."", $amount, $langs->transnoentities("Currency".$conf->currency)); setEventMessages($mesgs, null, 'mesgs'); $db->commit(); - } - else - { + } else { setEventMessages($accountfrom->error.' '.$accountto->error, null, 'errors'); $db->rollback(); } - } - else - { + } else { $error++; setEventMessages($langs->trans("ErrorFromToAccountsMustDiffers"), null, 'errors'); } diff --git a/htdocs/compta/bank/treso.php b/htdocs/compta/bank/treso.php index b8d259cdc8d..cf494b77a90 100644 --- a/htdocs/compta/bank/treso.php +++ b/htdocs/compta/bank/treso.php @@ -72,9 +72,7 @@ if ($_REQUEST["account"] || $_REQUEST["ref"]) if ($vline) { $viewline = $vline; - } - else - { + } else { $viewline = 20; } @@ -290,8 +288,7 @@ if ($_REQUEST["account"] || $_REQUEST["ref"]) if ($obj->family == 'invoice') { $mc->getInfo($obj->entity); print "".$mc->label.""; - } - else { + } else { print ""; } } @@ -304,9 +301,7 @@ if ($_REQUEST["account"] || $_REQUEST["ref"]) $i++; } - } - else - { + } else { dol_print_error($db); } @@ -326,9 +321,7 @@ if ($_REQUEST["account"] || $_REQUEST["ref"]) print ""; print ""; -} -else -{ +} else { print $langs->trans("ErrorBankAccountNotFound"); } diff --git a/htdocs/compta/bank/various_payment/card.php b/htdocs/compta/bank/various_payment/card.php index c4fdc3be56a..071a5abf0a9 100644 --- a/htdocs/compta/bank/various_payment/card.php +++ b/htdocs/compta/bank/various_payment/card.php @@ -163,9 +163,7 @@ if (empty($reshook)) $urltogo = ($backtopage ? $backtopage : DOL_URL_ROOT.'/compta/bank/various_payment/list.php'); header("Location: ".$urltogo); exit; - } - else - { + } else { $db->rollback(); setEventMessages($object->error, $object->errors, 'errors'); $action = "create"; @@ -198,22 +196,16 @@ if (empty($reshook)) $db->commit(); header("Location: ".DOL_URL_ROOT.'/compta/bank/various_payment/list.php'); exit; - } - else - { + } else { $object->error = $accountline->error; $db->rollback(); setEventMessages($object->error, $object->errors, 'errors'); } - } - else - { + } else { $db->rollback(); setEventMessages($object->error, $object->errors, 'errors'); } - } - else - { + } else { setEventMessages('Error try do delete a line linked to a conciliated bank transaction', null, 'errors'); } } @@ -375,8 +367,7 @@ if ($action == 'create') print ''; print $formaccounting->select_account($accountancy_code, 'accountancy_code', 1, null, 1, 1); print ''; - } - else // For external software + } else // For external software { print ''.$langs->trans("AccountAccounting").''; print ''; @@ -391,14 +382,11 @@ if ($action == 'create') if (!empty($conf->global->ACCOUNTANCY_COMBO_FOR_AUX)) { print $formaccounting->select_auxaccount($subledger_account, 'subledger_account', 1, ''); - } - else - { + } else { print ''; } print ''; - } - else // For external software + } else // For external software { print ''.$langs->trans("SubledgerAccount").''; print ''; @@ -564,14 +552,10 @@ if ($id) } else { print ''; } - } - else - { + } else { print ''; } - } - else - { + } else { print ''; } diff --git a/htdocs/compta/bank/various_payment/document.php b/htdocs/compta/bank/various_payment/document.php index d81b9bdd41a..7a89fd77986 100644 --- a/htdocs/compta/bank/various_payment/document.php +++ b/htdocs/compta/bank/various_payment/document.php @@ -149,9 +149,7 @@ if ($object->id) $permission = $user->rights->banque->modifier; $param = '&id='.$object->id; include_once DOL_DOCUMENT_ROOT.'/core/tpl/document_actions_post_headers.tpl.php'; -} -else -{ +} else { print $langs->trans("ErrorUnknown"); } diff --git a/htdocs/compta/bank/various_payment/list.php b/htdocs/compta/bank/various_payment/list.php index 5f68440809c..d02f75819e4 100644 --- a/htdocs/compta/bank/various_payment/list.php +++ b/htdocs/compta/bank/various_payment/list.php @@ -75,9 +75,7 @@ if (!GETPOST('typeid')) $part = explode(':', $val); if ($part[0] == 'v.fk_typepayment') $typeid = $part[1]; } -} -else -{ +} else { $typeid = GETPOST('typeid'); } @@ -313,8 +311,7 @@ if ($result) $accountstatic->label = $obj->blabel; print $accountstatic->getNomUrl(1); - } - else print ' '; + } else print ' '; print ''; if (!$i) $totalarray['nbfield']++; } @@ -373,9 +370,7 @@ if ($result) print ''; $db->free($result); -} -else -{ +} else { dol_print_error($db); } diff --git a/htdocs/compta/cashcontrol/cashcontrol_card.php b/htdocs/compta/cashcontrol/cashcontrol_card.php index 70a26d231e1..b14b77d5264 100644 --- a/htdocs/compta/cashcontrol/cashcontrol_card.php +++ b/htdocs/compta/cashcontrol/cashcontrol_card.php @@ -107,8 +107,7 @@ if (GETPOST('cancel', 'alpha')) { if ($action == 'valid') { $action = 'view'; - } - else { + } else { $action = 'create'; } } @@ -144,8 +143,7 @@ if ($action == "start") $action = 'create'; $error++; } -} -elseif ($action == "add") +} elseif ($action == "add") { if (GETPOST('opening', 'alpha') == '') { @@ -177,9 +175,7 @@ elseif ($action == "add") { $db->commit(); $action = "view"; - } - else - { + } else { $db->rollback; $action = "view"; } @@ -217,9 +213,7 @@ if ($action == "valid") // validate = close { setEventMessages($object->error, $object->errors, 'errors'); $db->rollback(); - } - else - { + } else { setEventMessages($langs->trans("CashFenceDone"), null); $db->commit(); } @@ -253,9 +247,7 @@ if ($action == 'confirm_delete' && !empty($permissiontodelete)) setEventMessages("RecordDeleted", null, 'mesgs'); header("Location: ".$backurlforlist); exit; - } - else - { + } else { if (!empty($object->errors)) setEventMessages(null, $object->errors, 'errors'); else setEventMessages($object->error, null, 'errors'); } @@ -282,8 +274,7 @@ if ($action == "create" || $action == "start" || $action == 'close') $syear = $object->year_close; $smonth = $object->month_close; $sday = $object->day_close; - } - elseif (GETPOST('posnumber', 'alpha') != '' && GETPOST('posnumber', 'alpha') != '' && GETPOST('posnumber', 'alpha') != '-1') + } elseif (GETPOST('posnumber', 'alpha') != '' && GETPOST('posnumber', 'alpha') != '' && GETPOST('posnumber', 'alpha') != '-1') { $posmodule = GETPOST('posmodule', 'alpha'); $terminalid = GETPOST('posnumber', 'alpha'); @@ -327,11 +318,8 @@ if ($action == "create" || $action == "start" || $action == 'close') { $obj = $db->fetch_object($resql); if ($obj) $initialbalanceforterminal[$terminalid][$key] = $obj->total; - } - else dol_print_error($db); - } - else - { + } else dol_print_error($db); + } else { setEventMessages($langs->trans("SetupOfTerminalNotComplete", $terminaltouse), null, 'errors'); $error++; } @@ -350,8 +338,7 @@ if ($action == "create" || $action == "start" || $action == 'close') if ($key == 'cash') $sql .= " AND cp.code = 'LIQ'"; elseif ($key == 'cheque') $sql .= " AND cp.code = 'CHQ'"; elseif ($key == 'card') $sql .= " AND cp.code = 'CB'"; - else - { + else { dol_print_error('Value for key = '.$key.' not supported'); exit; } @@ -371,8 +358,7 @@ if ($action == "create" || $action == "start" || $action == 'close') $theoricalamountforterminal[$terminalid][$key] = price2num($theoricalamountforterminal[$terminalid][$key] + $obj->total); $theoricalnbofinvoiceforterminal[$terminalid][$key] = $obj->nb; } - } - else dol_print_error($db); + } else dol_print_error($db); } } @@ -388,14 +374,11 @@ if ($action == "create" || $action == "start" || $action == 'close') if ($action == 'start' && GETPOST('posnumber', 'int') != '' && GETPOST('posnumber', 'int') != '' && GETPOST('posnumber', 'int') != '-1') { print ''; - } - elseif ($action == 'close') + } elseif ($action == 'close') { print ''; print ''; - } - else - { + } else { print ''; } @@ -469,9 +452,7 @@ if ($action == "create" || $action == "start" || $action == 'close') if ($action == 'start' && GETPOST('posnumber') != '' && GETPOST('posnumber') != '' && GETPOST('posnumber') != '-1') { print ''; - } - else - { + } else { print ''; } print ''; @@ -569,8 +550,7 @@ if ($action == "create" || $action == "start" || $action == 'close') { $object->fetch($id); print $object->opening; - } - else print (GETPOSTISSET('opening') ?price2num(GETPOST('opening', 'alpha')) : price($initialbalanceforterminal[$terminalid]['cash'])); + } else print (GETPOSTISSET('opening') ?price2num(GETPOST('opening', 'alpha')) : price($initialbalanceforterminal[$terminalid]['cash'])); print '">'; print ''; // Amount per payment type @@ -608,11 +588,10 @@ if (empty($action) || $action == "view" || $action == "close") if ($result <= 0) { print $langs->trans("ErrorRecordNotFound"); - } - else { + } else { $head = array(); $head[0][0] = DOL_URL_ROOT.'/compta/cashcontrol/cashcontrol_card.php?id='.$object->id; - $head[0][1] = $langs->trans("Card"); + $head[0][1] = $langs->trans("CashControl"); $head[0][2] = 'cashcontrol'; dol_fiche_head($head, 'cashcontrol', $langs->trans("CashControl"), -1, 'account'); @@ -706,14 +685,11 @@ if (empty($action) || $action == "view" || $action == "close") if ($action == 'start' && GETPOST('posnumber', 'int') != '' && GETPOST('posnumber', 'int') != '' && GETPOST('posnumber', 'int') != '-1') { print ''; - } - elseif ($action == 'close') + } elseif ($action == 'close') { print ''; print ''; - } - else - { + } else { print ''; } @@ -860,8 +836,7 @@ if (empty($action) || $action == "view" || $action == "close") { $object->fetch($id); print $object->opening; - } - else print (GETPOSTISSET('opening') ?price2num(GETPOST('opening', 'alpha')) : price($initialbalanceforterminal[$terminalid]['cash'])); + } else print (GETPOSTISSET('opening') ?price2num(GETPOST('opening', 'alpha')) : price($initialbalanceforterminal[$terminalid]['cash'])); print '">'; print ''; // Amount per payment type diff --git a/htdocs/compta/cashcontrol/cashcontrol_list.php b/htdocs/compta/cashcontrol/cashcontrol_list.php index 313627016c8..0279ad5143c 100644 --- a/htdocs/compta/cashcontrol/cashcontrol_list.php +++ b/htdocs/compta/cashcontrol/cashcontrol_list.php @@ -259,9 +259,7 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) if (is_numeric($nbtotalofrecords) && $limit > $nbtotalofrecords) { $num = $nbtotalofrecords; -} -else -{ +} else { $sql .= $db->plimit($limit + 1, $offset); $resql = $db->query($sql); @@ -495,7 +493,7 @@ while ($i < min($num, $limit)) // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; // Fields from hook - $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$obj); + $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray); $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $object); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; // Action column diff --git a/htdocs/compta/cashcontrol/class/cashcontrol.class.php b/htdocs/compta/cashcontrol/class/cashcontrol.class.php index 81a19389244..0f60be3c3a8 100644 --- a/htdocs/compta/cashcontrol/class/cashcontrol.class.php +++ b/htdocs/compta/cashcontrol/class/cashcontrol.class.php @@ -404,8 +404,7 @@ class CashControl extends CommonObject $reshook=$hookmanager->executeHooks('getnomurltooltip',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks if ($reshook > 0) $linkclose = $hookmanager->resPrint; */ - } - else $linkclose = ($morecss ? ' class="'.$morecss.'"' : ''); + } else $linkclose = ($morecss ? ' class="'.$morecss.'"' : ''); $linkstart = ''; diff --git a/htdocs/compta/cashcontrol/report.php b/htdocs/compta/cashcontrol/report.php index 1ea06eba9e9..f2d8e38fb15 100644 --- a/htdocs/compta/cashcontrol/report.php +++ b/htdocs/compta/cashcontrol/report.php @@ -172,9 +172,7 @@ if ($resql) $bankaccounttmp->fetch($objp->bankid); $cachebankaccount[$objp->bankid] = $bankaccounttmp; $bankaccount = $bankaccounttmp; - } - else - { + } else { $bankaccount = $cachebankaccount[$objp->bankid]; } @@ -208,8 +206,7 @@ if ($resql) print $bankaccount->getNomUrl(1); if ($cashcontrol->posmodule == "takepos") { $var1 = 'CASHDESK_ID_BANKACCOUNT_CASH'.$cashcontrol->posnumber; - } - else { + } else { $var1 = 'CASHDESK_ID_BANKACCOUNT_CASH'; } if ($objp->code == 'CHQ') { @@ -311,9 +308,7 @@ if ($resql) print ''; $db->free($resql); -} -else -{ +} else { dol_print_error($db); } diff --git a/htdocs/compta/charges/index.php b/htdocs/compta/charges/index.php index 93065219248..968c93fd25f 100644 --- a/htdocs/compta/charges/index.php +++ b/htdocs/compta/charges/index.php @@ -89,6 +89,8 @@ if ($mode == 'sconly') $param = '&mode=sconly'; if ($sortfield) $param .= '&sortfield='.$sortfield; if ($sortorder) $param .= '&sortorder='.$sortorder; +$totalnboflines = 0; +$num = 0; print '
'; if ($optioncss != '') print ''; @@ -99,14 +101,13 @@ print ''; print ''; print ''; +$nav = ''; if ($mode != 'sconly') { - $center = ($year ? ''.img_previous($langs->trans("Previous"), 'class="valignbottom"')." ".$langs->trans("Year").' '.$year.' '.img_next($langs->trans("Next"), 'class="valignbottom"')."" : ""); - print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $center, $num, $totalnboflines, 'object_payment', 0, '', '', $limit, 1); -} -else -{ - print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $center, $num, $totalnboflines, 'object_payment', 0, '', '', $limit, 0); + $nav = ($year ? ''.img_previous($langs->trans("Previous"), 'class="valignbottom"')." ".$langs->trans("Year").' '.$year.' '.img_next($langs->trans("Next"), 'class="valignbottom"')."" : ""); + print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $totalnboflines, 'object_payment', 0, $nav, '', $limit, 1); +} else { + print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $totalnboflines, 'object_payment', 0, $nav, '', $limit, 0); } if ($year) $param .= '&year='.$year; @@ -217,8 +218,7 @@ if (!empty($conf->tax->enabled) && $user->rights->tax->charges->lire) $accountstatic->accountancy_journal = $obj->accountancy_journal; $accountstatic->label = $obj->blabel; print $accountstatic->getNomUrl(1); - } - else print ' '; + } else print ' '; print ''; } // Paid @@ -240,9 +240,7 @@ if (!empty($conf->tax->enabled) && $user->rights->tax->charges->lire) if (!empty($conf->banque->enabled)) print ''; print ''.price($totalpaye).""; print ""; - } - else - { + } else { dol_print_error($db); } print ''; @@ -334,8 +332,7 @@ if (!empty($conf->tax->enabled) && $user->rights->tax->charges->lire) $accountstatic->accountancy_journal = $obj->accountancy_journal; $accountstatic->label = $obj->blabel; print $accountstatic->getNomUrl(1); - } - else print ' '; + } else print ' '; print ''; } @@ -356,9 +353,7 @@ if (!empty($conf->tax->enabled) && $user->rights->tax->charges->lire) print ""; $db->free($result); - } - else - { + } else { dol_print_error($db); } } @@ -369,19 +364,15 @@ if ($mysoc->localtax1_assuj == "1" && $mysoc->localtax2_assuj == "1") { $j = 1; $numlt = 3; -} -elseif ($mysoc->localtax1_assuj == "1") +} elseif ($mysoc->localtax1_assuj == "1") { $j = 1; $numlt = 2; -} -elseif ($mysoc->localtax2_assuj == "1") +} elseif ($mysoc->localtax2_assuj == "1") { $j = 2; $numlt = 3; -} -else -{ +} else { $j = 0; $numlt = 0; } @@ -451,9 +442,7 @@ while ($j < $numlt) print ""; $db->free($result); - } - else - { + } else { dol_print_error($db); } } @@ -546,8 +535,7 @@ if (!empty($conf->salaries->enabled) && !empty($user->rights->salaries->read)) $accountstatic->accountancy_journal = $obj->accountancy_journal; $accountstatic->label = $obj->blabel; print $accountstatic->getNomUrl(1); - } - else print ' '; + } else print ' '; print ''; } @@ -565,9 +553,7 @@ if (!empty($conf->salaries->enabled) && !empty($user->rights->salaries->read)) $db->free($result); print "
"; - } - else - { + } else { dol_print_error($db); } } diff --git a/htdocs/compta/clients.php b/htdocs/compta/clients.php index 6c1439d5466..5632e8ebc1a 100644 --- a/htdocs/compta/clients.php +++ b/htdocs/compta/clients.php @@ -196,9 +196,7 @@ if ($resql) print '
'; $db->free($resql); -} -else -{ +} else { dol_print_error($db); } diff --git a/htdocs/compta/deplacement/card.php b/htdocs/compta/deplacement/card.php index 463d9ea699f..4d3ec6b1ee6 100644 --- a/htdocs/compta/deplacement/card.php +++ b/htdocs/compta/deplacement/card.php @@ -70,15 +70,11 @@ if ($action == 'validate' && $user->rights->deplacement->creer) { header("Location: ".$_SERVER["PHP_SELF"]."?id=".$id); exit; - } - else - { + } else { setEventMessages($object->error, $object->errors, 'errors'); } } -} - -elseif ($action == 'classifyrefunded' && $user->rights->deplacement->creer) +} elseif ($action == 'classifyrefunded' && $user->rights->deplacement->creer) { $object->fetch($id); if ($object->statut == Deplacement::STATUS_VALIDATED) @@ -88,29 +84,21 @@ elseif ($action == 'classifyrefunded' && $user->rights->deplacement->creer) { header("Location: ".$_SERVER["PHP_SELF"]."?id=".$id); exit; - } - else - { + } else { setEventMessages($object->error, $object->errors, 'errors'); } } -} - -elseif ($action == 'confirm_delete' && $confirm == "yes" && $user->rights->deplacement->supprimer) +} elseif ($action == 'confirm_delete' && $confirm == "yes" && $user->rights->deplacement->supprimer) { $result = $object->delete($id); if ($result >= 0) { header("Location: index.php"); exit; - } - else - { + } else { setEventMessages($object->error, $object->errors, 'errors'); } -} - -elseif ($action == 'add' && $user->rights->deplacement->creer) +} elseif ($action == 'add' && $user->rights->deplacement->creer) { if (!GETPOST('cancel', 'alpha')) { @@ -149,26 +137,18 @@ elseif ($action == 'add' && $user->rights->deplacement->creer) { header("Location: ".$_SERVER["PHP_SELF"]."?id=".$id); exit; - } - else - { + } else { setEventMessages($object->error, $object->errors, 'errors'); $action = 'create'; } - } - else - { + } else { $action = 'create'; } - } - else - { + } else { header("Location: index.php"); exit; } -} - -// Update record +} // Update record elseif ($action == 'update' && $user->rights->deplacement->creer) { if (!GETPOST('cancel', 'alpha')) @@ -189,36 +169,27 @@ elseif ($action == 'update' && $user->rights->deplacement->creer) { header("Location: ".$_SERVER["PHP_SELF"]."?id=".$id); exit; - } - else - { + } else { setEventMessages($object->error, $object->errors, 'errors'); } - } - else - { + } else { header("Location: ".$_SERVER["PHP_SELF"]."?id=".$id); exit; } -} - -// Set into a project +} // Set into a project elseif ($action == 'classin' && $user->rights->deplacement->creer) { $object->fetch($id); $result = $object->setProject(GETPOST('projectid', 'int')); if ($result < 0) dol_print_error($db, $object->error); -} - -// Set fields +} // Set fields elseif ($action == 'setdated' && $user->rights->deplacement->creer) { $dated = dol_mktime(GETPOST('datedhour', 'int'), GETPOST('datedmin', 'int'), GETPOST('datedsec', 'int'), GETPOST('datedmonth', 'int'), GETPOST('datedday', 'int'), GETPOST('datedyear', 'int')); $object->fetch($id); $result = $object->setValueFrom('dated', $dated, '', '', 'date', '', $user, 'DEPLACEMENT_MODIFY'); if ($result < 0) dol_print_error($db, $object->error); -} -elseif ($action == 'setkm' && $user->rights->deplacement->creer) +} elseif ($action == 'setkm' && $user->rights->deplacement->creer) { $object->fetch($id); $result = $object->setValueFrom('km', GETPOST('km', 'int'), '', null, 'text', '', $user, 'DEPLACEMENT_MODIFY'); @@ -313,8 +284,7 @@ if ($action == 'create') print ''; print ''; -} -elseif ($id) +} elseif ($id) { $result = $object->fetch($id); if ($result > 0) @@ -412,9 +382,7 @@ elseif ($id) print ''; print ''; - } - else - { + } else { /* * Confirm delete trip */ @@ -492,9 +460,7 @@ elseif ($id) if ($action == 'classify') { $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1); - } - else - { + } else { $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, 'none', 0, 0); } print ''; @@ -528,9 +494,7 @@ elseif ($id) if ($user->rights->deplacement->creer) { print ''.$langs->trans('Modify').''; - } - else - { + } else { print ''.$langs->trans('Modify').''; } } @@ -540,9 +504,7 @@ elseif ($id) if ($user->rights->deplacement->creer) { print ''.$langs->trans('Validate').''; - } - else - { + } else { print ''.$langs->trans('Validate').''; } } @@ -552,9 +514,7 @@ elseif ($id) if ($user->rights->deplacement->creer) { print ''.$langs->trans('ClassifyRefunded').''; - } - else - { + } else { print ''.$langs->trans('ClassifyRefunded').''; } } @@ -562,17 +522,13 @@ elseif ($id) if ($user->rights->deplacement->supprimer) { print ''.$langs->trans('Delete').''; - } - else - { + } else { print ''.$langs->trans('Delete').''; } print ''; } - } - else - { + } else { dol_print_error($db); } } diff --git a/htdocs/compta/deplacement/class/deplacement.class.php b/htdocs/compta/deplacement/class/deplacement.class.php index ec4610179e2..69baf710b95 100644 --- a/htdocs/compta/deplacement/class/deplacement.class.php +++ b/htdocs/compta/deplacement/class/deplacement.class.php @@ -199,16 +199,12 @@ class Deplacement extends CommonObject { $this->db->commit(); return $this->id; - } - else - { + } else { $this->error = $this->db->error(); $this->db->rollback(); return $result; } - } - else - { + } else { $this->error = $this->db->error()." sql=".$sql; $this->db->rollback(); return -1; @@ -267,9 +263,7 @@ class Deplacement extends CommonObject { $this->db->commit(); return 1; - } - else - { + } else { $this->error = $this->db->lasterror(); $this->db->rollback(); return -1; @@ -312,9 +306,7 @@ class Deplacement extends CommonObject $this->extraparams = (array) json_decode($obj->extraparams, true); return 1; - } - else - { + } else { $this->error = $this->db->error(); return -1; } @@ -338,9 +330,7 @@ class Deplacement extends CommonObject { $this->db->commit(); return 1; - } - else - { + } else { $this->error = $this->db->error(); $this->db->rollback(); return -1; @@ -375,30 +365,25 @@ class Deplacement extends CommonObject if ($mode == 0) { return $langs->trans($this->statuts[$status]); - } - elseif ($mode == 1) + } elseif ($mode == 1) { return $langs->trans($this->statuts_short[$status]); - } - elseif ($mode == 2) + } elseif ($mode == 2) { if ($status == 0) return img_picto($langs->trans($this->statuts_short[$status]), 'statut0').' '.$langs->trans($this->statuts_short[$status]); elseif ($status == 1) return img_picto($langs->trans($this->statuts_short[$status]), 'statut4').' '.$langs->trans($this->statuts_short[$status]); elseif ($status == 2) return img_picto($langs->trans($this->statuts_short[$status]), 'statut6').' '.$langs->trans($this->statuts_short[$status]); - } - elseif ($mode == 3) + } elseif ($mode == 3) { if ($status == 0 && !empty($this->statuts_short[$status])) return img_picto($langs->trans($this->statuts_short[$status]), 'statut0'); elseif ($status == 1 && !empty($this->statuts_short[$status])) return img_picto($langs->trans($this->statuts_short[$status]), 'statut4'); elseif ($status == 2 && !empty($this->statuts_short[$status])) return img_picto($langs->trans($this->statuts_short[$status]), 'statut6'); - } - elseif ($mode == 4) + } elseif ($mode == 4) { if ($status == 0 && !empty($this->statuts_short[$status])) return img_picto($langs->trans($this->statuts_short[$status]), 'statut0').' '.$langs->trans($this->statuts[$status]); elseif ($status == 1 && !empty($this->statuts_short[$status])) return img_picto($langs->trans($this->statuts_short[$status]), 'statut4').' '.$langs->trans($this->statuts[$status]); elseif ($status == 2 && !empty($this->statuts_short[$status])) return img_picto($langs->trans($this->statuts_short[$status]), 'statut6').' '.$langs->trans($this->statuts[$status]); - } - elseif ($mode == 5) + } elseif ($mode == 5) { if ($status == 0 && !empty($this->statuts_short[$status])) return $langs->trans($this->statuts_short[$status]).' '.img_picto($langs->trans($this->statuts_short[$status]), 'statut0'); elseif ($status == 1 && !empty($this->statuts_short[$status])) return $langs->trans($this->statuts_short[$status]).' '.img_picto($langs->trans($this->statuts_short[$status]), 'statut4'); @@ -460,9 +445,7 @@ class Deplacement extends CommonObject $ret[$obj->code] = (($langs->trans($obj->code) != $obj->code) ? $langs->trans($obj->code) : $obj->label); $i++; } - } - else - { + } else { dol_print_error($this->db); } @@ -507,9 +490,7 @@ class Deplacement extends CommonObject $this->date_modification = $this->db->jdate($obj->tms); } $this->db->free($result); - } - else - { + } else { dol_print_error($this->db); } } diff --git a/htdocs/compta/deplacement/document.php b/htdocs/compta/deplacement/document.php index 2cef0b3e6cd..889eb390ca2 100644 --- a/htdocs/compta/deplacement/document.php +++ b/htdocs/compta/deplacement/document.php @@ -123,9 +123,7 @@ if ($object->id) $permission = $user->rights->deplacement->creer; $param = '&id='.$object->id; include_once DOL_DOCUMENT_ROOT.'/core/tpl/document_actions_post_headers.tpl.php'; -} -else -{ +} else { print $langs->trans("ErrorUnknown"); } diff --git a/htdocs/compta/deplacement/index.php b/htdocs/compta/deplacement/index.php index 9d45bafd20f..0cea847f9ce 100644 --- a/htdocs/compta/deplacement/index.php +++ b/htdocs/compta/deplacement/index.php @@ -192,14 +192,11 @@ if ($result) $i++; } - } - else - { + } else { print ''.$langs->trans("None").''; } print '
'; -} -else dol_print_error($db); +} else dol_print_error($db); print ''; diff --git a/htdocs/compta/deplacement/list.php b/htdocs/compta/deplacement/list.php index a4cc8f24019..78c1f32556d 100644 --- a/htdocs/compta/deplacement/list.php +++ b/htdocs/compta/deplacement/list.php @@ -196,9 +196,7 @@ if ($resql) print ""; print "\n"; $db->free($resql); -} -else -{ +} else { dol_print_error($db); } diff --git a/htdocs/compta/deplacement/stats/index.php b/htdocs/compta/deplacement/stats/index.php index cf745b784fc..7707cb40786 100644 --- a/htdocs/compta/deplacement/stats/index.php +++ b/htdocs/compta/deplacement/stats/index.php @@ -167,9 +167,7 @@ if (!$user->rights->societe->client->voir || $user->socid) $filename_avg = $dir.'/ordersaverage-'.$user->id.'-'.$year.'.png'; if ($mode == 'customer') $fileurl_avg = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstats&file=ordersaverage-'.$user->id.'-'.$year.'.png'; if ($mode == 'supplier') $fileurl_avg = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstatssupplier&file=ordersaverage-'.$user->id.'-'.$year.'.png'; -} -else -{ +} else { $filename_avg = $dir.'/ordersaverage-'.$year.'.png'; if ($mode == 'customer') $fileurl_avg = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstats&file=ordersaverage-'.$year.'.png'; if ($mode == 'supplier') $fileurl_avg = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstatssupplier&file=ordersaverage-'.$year.'.png'; @@ -294,8 +292,7 @@ print '
'; // Show graphs print '"; - } - else - { + } else { print ''; } @@ -1198,14 +1148,10 @@ if ($action == 'create') print ''; print ''; print "\n"; - } - else - { + } else { dol_print_error('', "Error, no invoice ".$object->id); } -} -else -{ +} else { /* * View mode */ @@ -1328,9 +1274,7 @@ else if ($action == 'editconditions') { $form->form_conditions_reglement($_SERVER['PHP_SELF'].'?facid='.$object->id, $object->cond_reglement_id, 'cond_reglement_id'); - } - else - { + } else { $form->form_conditions_reglement($_SERVER['PHP_SELF'].'?facid='.$object->id, $object->cond_reglement_id, 'none'); } } else { @@ -1350,9 +1294,7 @@ else if ($action == 'editmode') { $form->form_modes_reglement($_SERVER['PHP_SELF'].'?facid='.$object->id, $object->mode_reglement_id, 'mode_reglement_id', 'CRDT', 1, 1); - } - else - { + } else { $form->form_modes_reglement($_SERVER['PHP_SELF'].'?facid='.$object->id, $object->mode_reglement_id, 'none'); } print ''; @@ -1459,9 +1401,7 @@ else if ($action == 'editbankaccount') { $form->formSelectAccount($_SERVER['PHP_SELF'].'?id='.$object->id, $object->fk_account, 'fk_account', 1); - } - else - { + } else { $form->formSelectAccount($_SERVER['PHP_SELF'].'?id='.$object->id, $object->fk_account, 'none'); } print ""; @@ -1486,9 +1426,7 @@ else } $select = 'select;'.implode(',', $list); print $form->editfieldval($langs->trans("Model"), 'modelpdf', $object->modelpdf, $object, $user->rights->facture->creer, $select); - } - else - { + } else { print $object->modelpdf; } print ""; @@ -1536,15 +1474,11 @@ else print ''; print ''; print '
'; -if ($mesg) { print $mesg; } -else { +if ($mesg) { print $mesg; } else { print $px1->show(); print "
\n"; print $px2->show(); diff --git a/htdocs/compta/facture/card-rec.php b/htdocs/compta/facture/card-rec.php index cad443940f4..cc3a0769e70 100644 --- a/htdocs/compta/facture/card-rec.php +++ b/htdocs/compta/facture/card-rec.php @@ -238,9 +238,7 @@ if (empty($reshook)) setEventMessages($oldinvoice->error, $oldinvoice->errors, 'errors'); $action = "create"; } - } - else - { + } else { $error++; setEventMessages($object->error, $object->errors, 'errors'); $action = "create"; @@ -252,9 +250,7 @@ if (empty($reshook)) header("Location: ".$_SERVER['PHP_SELF'].'?facid='.$object->id); exit; - } - else - { + } else { $db->rollback(); $error++; @@ -279,18 +275,15 @@ if (empty($reshook)) if ($action == 'setconditions' && $user->rights->facture->creer) { $result = $object->setPaymentTerms(GETPOST('cond_reglement_id', 'int')); - } - // Set mode + } // Set mode elseif ($action == 'setmode' && $user->rights->facture->creer) { $result = $object->setPaymentMethods(GETPOST('mode_reglement_id', 'int')); - } - // Set project + } // Set project elseif ($action == 'classin' && $user->rights->facture->creer) { $object->setProject(GETPOST('projectid', 'int')); - } - // Set bank account + } // Set bank account elseif ($action == 'setref' && $user->rights->facture->creer) { //var_dump(GETPOST('ref', 'alpha'));exit; @@ -300,47 +293,37 @@ if (empty($reshook)) $object->titre = GETPOST('ref', 'alpha'); // deprecated $object->title = GETPOST('ref', 'alpha'); $object->ref = $object->title; - } - else dol_print_error($db, $object->error, $object->errors); - } - // Set bank account + } else dol_print_error($db, $object->error, $object->errors); + } // Set bank account elseif ($action == 'setbankaccount' && $user->rights->facture->creer) { $result = $object->setBankAccount(GETPOST('fk_account', 'int')); - } - // Set frequency and unit frequency + } // Set frequency and unit frequency elseif ($action == 'setfrequency' && $user->rights->facture->creer) { $object->setFrequencyAndUnit(GETPOST('frequency', 'int'), GETPOST('unit_frequency', 'alpha')); - } - // Set next date of execution + } // Set next date of execution elseif ($action == 'setdate_when' && $user->rights->facture->creer) { $date = dol_mktime(GETPOST('date_whenhour'), GETPOST('date_whenmin'), 0, GETPOST('date_whenmonth'), GETPOST('date_whenday'), GETPOST('date_whenyear')); if (!empty($date)) $object->setNextDate($date); - } - // Set max period + } // Set max period elseif ($action == 'setnb_gen_max' && $user->rights->facture->creer) { $object->setMaxPeriod(GETPOST('nb_gen_max', 'int')); - } - // Set auto validate + } // Set auto validate elseif ($action == 'setauto_validate' && $user->rights->facture->creer) { $object->setAutoValidate(GETPOST('auto_validate', 'int')); - } - // Set generate pdf + } // Set generate pdf elseif ($action == 'setgenerate_pdf' && $user->rights->facture->creer) { $object->setGeneratepdf(GETPOST('generate_pdf', 'int')); - } - // Set model pdf + } // Set model pdf elseif ($action == 'setmodelpdf' && $user->rights->facture->creer) { $object->setModelpdf(GETPOST('modelpdf', 'alpha')); - } - - // Set status disabled + } // Set status disabled elseif ($action == 'disable' && $user->rights->facture->creer) { $db->begin(); @@ -356,15 +339,11 @@ if (empty($reshook)) if (!$error) { $db->commit(); - } - else - { + } else { $db->rollback(); setEventMessages($object->error, $object->errors, 'errors'); } - } - - // Set status enabled + } // Set status enabled elseif ($action == 'enable' && $user->rights->facture->creer) { $db->begin(); @@ -380,19 +359,14 @@ if (empty($reshook)) if (!$error) { $db->commit(); - } - else - { + } else { $db->rollback(); setEventMessages($object->error, $object->errors, 'errors'); } - } - // Multicurrency Code + } // Multicurrency Code elseif ($action == 'setmulticurrencycode' && $usercancreate) { $result = $object->setMulticurrencyCode(GETPOST('multicurrency_code', 'alpha')); - } - - // Multicurrency rate + } // Multicurrency rate elseif ($action == 'setmulticurrencyrate' && $usercancreate) { $result = $object->setMulticurrencyRate(price2num(GETPOST('multicurrency_tx')), GETPOST('calculation_mode', 'int')); } @@ -418,20 +392,15 @@ if (empty($reshook)) { $db->commit(); $object->fetch($object->id); // Reload lines - } - else - { + } else { $db->rollback(); setEventMessages($db->lasterror(), null, 'errors'); } - } - else - { + } else { $db->rollback(); setEventMessages($line->error, $line->errors, 'errors'); } - } - elseif ($action == 'update_extras') + } elseif ($action == 'update_extras') { $object->oldcopy = dol_clone($object); @@ -466,9 +435,7 @@ if (empty($reshook)) { $idprod = 0; $tva_tx = (GETPOST('tva_tx', 'alpha') ? GETPOST('tva_tx', 'alpha') : 0); - } - else - { + } else { $idprod = GETPOST('idprod', 'int'); $tva_tx = ''; } @@ -570,17 +537,14 @@ if (empty($reshook)) { $pu_ht = price2num($price_ht, 'MU'); $pu_ttc = price2num($pu_ht * (1 + ($tmpvat / 100)), 'MU'); - } - // On reevalue prix selon taux tva car taux tva transaction peut etre different + } // On reevalue prix selon taux tva car taux tva transaction peut etre different // de ceux du produit par defaut (par exemple si pays different entre vendeur et acheteur). elseif ($tmpvat != $tmpprodvat) { if ($price_base_type != 'HT') { $pu_ht = price2num($pu_ttc / (1 + ($tmpvat / 100)), 'MU'); - } - else - { + } else { $pu_ttc = price2num($pu_ht * (1 + ($tmpvat / 100)), 'MU'); } } @@ -603,9 +567,7 @@ if (empty($reshook)) } $desc = (!empty($prod->multilangs [$outputlangs->defaultlang] ["description"])) ? $prod->multilangs [$outputlangs->defaultlang] ["description"] : $prod->description; - } - else - { + } else { $desc = $prod->description; } @@ -640,9 +602,7 @@ if (empty($reshook)) $type = $prod->type; $fk_unit = $prod->fk_unit; - } - else - { + } else { $pu_ht = price2num($price_ht, 'MU'); $pu_ttc = price2num(GETPOST('price_ttc'), 'MU'); $tva_npr = (preg_match('/\*/', $tva_tx) ? 1 : 0); @@ -672,9 +632,7 @@ if (empty($reshook)) if ($usercanproductignorepricemin && (!empty($price_min) && (price2num($pu_ht) * (1 - price2num($remise_percent) / 100) < price2num($price_min)))) { $mesg = $langs->trans("CantBeLessThanMinPrice", price(price2num($price_min, 'MU'), 0, $langs, 0, 0, - 1, $conf->currency)); setEventMessages($mesg, null, 'errors'); - } - else - { + } else { // Insert line $result = $object->addline($desc, $pu_ht, $qty, $tva_tx, $localtax1_tx, $localtax2_tx, $idprod, $remise_percent, $price_base_type, $info_bits, '', $pu_ttc, $type, - 1, $special_code, $label, $fk_unit, 0, $date_start_fill, $date_end_fill, $fournprice, $buyingprice); @@ -738,18 +696,14 @@ if (empty($reshook)) unset($_POST['situations']); unset($_POST['progress']); - } - else - { + } else { setEventMessages($object->error, $object->errors, 'errors'); } $action = ''; } } - } - - elseif ($action == 'updateline' && $usercancreate && !GETPOST('cancel', 'alpha')) + } elseif ($action == 'updateline' && $usercancreate && !GETPOST('cancel', 'alpha')) { if (!$object->fetch($id) > 0) dol_print_error($db); $object->fetch_thirdparty(); @@ -947,9 +901,7 @@ if (empty($reshook)) unset($_POST['situations']); unset($_POST['progress']); - } - else - { + } else { setEventMessages($object->error, $object->errors, 'errors'); } } @@ -1144,9 +1096,7 @@ if ($action == 'create') $select = array('0'=>$langs->trans('DoNotGenerateDoc'), '1'=>$langs->trans('AutoGenerateDoc')); print $form->selectarray('generate_pdf', $select, GETPOST('generate_pdf')); print "
'; - } - else - { + } else { if ($object->frequency > 0) { print $langs->trans('FrequencyPer_'.$object->unit_frequency, $object->frequency); - } - else - { + } else { print $langs->trans("NotARecurringInvoiceTemplate"); } } @@ -1555,9 +1489,7 @@ else if ($action == 'date_when' || $object->frequency > 0) { print $form->editfieldkey($langs->trans("NextDateToExecution"), 'date_when', $object->date_when, $object, $user->rights->facture->creer, 'day'); - } - else - { + } else { print $langs->trans("NextDateToExecution"); } print ''; @@ -1569,9 +1501,7 @@ else if (!$object->isMaxNbGenReached()) { if (!$object->suspended && $action != 'editdate_when' && $object->frequency > 0 && $object->date_when && $object->date_when < $now) print img_warning($langs->trans("Late")); - } - else - { + } else { print img_info($langs->trans("MaxNumberOfGenerationReached")); } print ''; @@ -1582,18 +1512,14 @@ else if ($action == 'nb_gen_max' || $object->frequency > 0) { print $form->editfieldkey($langs->trans("MaxPeriodNumber"), 'nb_gen_max', $object->nb_gen_max, $object, $user->rights->facture->creer); - } - else - { + } else { print $langs->trans("MaxPeriodNumber"); } print ''; if ($action == 'nb_gen_max' || $object->frequency > 0) { print $form->editfieldval($langs->trans("MaxPeriodNumber"), 'nb_gen_max', $object->nb_gen_max ? $object->nb_gen_max : '', $object, $user->rights->facture->creer); - } - else - { + } else { print ''; } print ''; @@ -1603,8 +1529,7 @@ else print ''; if ($action == 'auto_validate' || $object->frequency > 0) print $form->editfieldkey($langs->trans("StatusOfGeneratedInvoices"), 'auto_validate', $object->auto_validate, $object, $user->rights->facture->creer); - else - print $langs->trans("StatusOfGeneratedInvoices"); + else print $langs->trans("StatusOfGeneratedInvoices"); print ''; $select = 'select;0:'.$langs->trans('BillStatusDraft').',1:'.$langs->trans('BillStatusValidated'); if ($action == 'auto_validate' || $object->frequency > 0) @@ -1619,8 +1544,7 @@ else print ''; if ($action == 'generate_pdf' || $object->frequency > 0) print $form->editfieldkey($langs->trans("StatusOfGeneratedDocuments"), 'generate_pdf', $object->generate_pdf, $object, $user->rights->facture->creer); - else - print $langs->trans("StatusOfGeneratedDocuments"); + else print $langs->trans("StatusOfGeneratedDocuments"); print ''; print ''; $select = 'select;0:'.$langs->trans('DoNotGenerateDoc').',1:'.$langs->trans('AutogenerateDoc'); @@ -1630,9 +1554,7 @@ else } print ''; print ''; - } - else - { + } else { print ''; } @@ -1733,21 +1655,15 @@ else if (!empty($object->frequency) && $object->nb_gen_max > 0 && ($object->nb_gen_done >= $object->nb_gen_max)) { print ''; - } - else - { + } else { if (empty($object->frequency) || $object->date_when <= $today) { print ''; - } - else - { + } else { print ''; } } - } - else - { + } else { print ''; } } @@ -1757,9 +1673,7 @@ else if (empty($object->suspended)) { print ''; - } - else - { + } else { print ''; } } diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index 300db43c10f..2f4faf93c13 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -188,9 +188,7 @@ if (empty($reshook)) setEventMessages($object->error, $object->errors, 'errors'); $action = ''; } - } - - // Change status of invoice + } // Change status of invoice elseif ($action == 'reopen' && $usercancreate) { $result = $object->fetch($id); @@ -203,9 +201,7 @@ if (empty($reshook)) setEventMessages($object->error, $object->errors, 'errors'); } } - } - - // Delete invoice + } // Delete invoice elseif ($action == 'confirm_delete' && $confirm == 'yes') { $result = $object->fetch($id); $object->fetch_thirdparty(); @@ -233,9 +229,7 @@ if (empty($reshook)) $action = ''; } } - } - - // Delete line + } // Delete line elseif ($action == 'confirm_deleteline' && $confirm == 'yes' && $usercancreate) { $object->fetch($id); @@ -267,17 +261,13 @@ if (empty($reshook)) setEventMessages($object->error, $object->errors, 'errors'); $action = ''; } - } - - // Delete link of credit note to invoice + } // Delete link of credit note to invoice elseif ($action == 'unlinkdiscount' && $usercancreate) { $discount = new DiscountAbsolute($db); $result = $discount->fetch(GETPOST("discountid")); $discount->unlink_invoice(); - } - - // Validation + } // Validation elseif ($action == 'valid' && $usercancreate) { $object->fetch($id); @@ -335,32 +325,24 @@ if (empty($reshook)) } } } - } - - elseif ($action == 'set_thirdparty' && $usercancreate) + } elseif ($action == 'set_thirdparty' && $usercancreate) { $object->fetch($id); $object->setValueFrom('fk_soc', $socid, '', null, 'int', '', $user, 'BILL_MODIFY'); header('Location: '.$_SERVER["PHP_SELF"].'?facid='.$id); exit(); - } - - elseif ($action == 'classin' && $usercancreate) + } elseif ($action == 'classin' && $usercancreate) { $object->fetch($id); $object->setProject($_POST['projectid']); - } - - elseif ($action == 'setmode' && $usercancreate) + } elseif ($action == 'setmode' && $usercancreate) { $object->fetch($id); $result = $object->setPaymentMethods(GETPOST('mode_reglement_id', 'int')); if ($result < 0) dol_print_error($db, $object->error); - } - - elseif ($action == 'setretainedwarrantyconditions' && $user->rights->facture->creer) + } elseif ($action == 'setretainedwarrantyconditions' && $user->rights->facture->creer) { $object->fetch($id); $object->retained_warranty_fk_cond_reglement = 0; // To clean property @@ -373,36 +355,25 @@ if (empty($reshook)) if ($object->retained_warranty_date_limit < $object->date) $object->retained_warranty_date_limit = $object->date; $result = $object->update($user); if ($result < 0) dol_print_error($db, $object->error); - } - - elseif ($action == 'setretainedwarranty' && $user->rights->facture->creer) + } elseif ($action == 'setretainedwarranty' && $user->rights->facture->creer) { $object->fetch($id); $result = $object->setRetainedWarranty(GETPOST('retained_warranty', 'float')); if ($result < 0) dol_print_error($db, $object->error); - } - - elseif ($action == 'setretainedwarrantydatelimit' && $user->rights->facture->creer) + } elseif ($action == 'setretainedwarrantydatelimit' && $user->rights->facture->creer) { $object->fetch($id); $result = $object->setRetainedWarrantyDateLimit(GETPOST('retained_warranty_date_limit', 'float')); if ($result < 0) dol_print_error($db, $object->error); - } - - - // Multicurrency Code + } // Multicurrency Code elseif ($action == 'setmulticurrencycode' && $usercancreate) { $result = $object->setMulticurrencyCode(GETPOST('multicurrency_code', 'alpha')); - } - - // Multicurrency rate + } // Multicurrency rate elseif ($action == 'setmulticurrencyrate' && $usercancreate) { $result = $object->setMulticurrencyRate(price2num(GETPOST('multicurrency_tx')), GETPOST('calculation_mode', 'int')); - } - - elseif ($action == 'setinvoicedate' && $usercancreate) + } elseif ($action == 'setinvoicedate' && $usercancreate) { $object->fetch($id); $old_date_lim_reglement = $object->date_lim_reglement; @@ -421,9 +392,7 @@ if (empty($reshook)) if ($result < 0) { dol_print_error($db, $object->error); } - } - - elseif ($action == 'setdate_pointoftax' && $usercancreate) + } elseif ($action == 'setdate_pointoftax' && $usercancreate) { $object->fetch($id); $date_pointoftax = dol_mktime(12, 0, 0, $_POST['date_pointoftaxmonth'], $_POST['date_pointoftaxday'], $_POST['date_pointoftaxyear']); @@ -432,9 +401,7 @@ if (empty($reshook)) if ($result < 0) { dol_print_error($db, $object->error); } - } - - elseif ($action == 'setconditions' && $usercancreate) + } elseif ($action == 'setconditions' && $usercancreate) { $object->fetch($id); $object->cond_reglement_code = 0; // To clean property @@ -450,9 +417,7 @@ if (empty($reshook)) if ($result < 0) { dol_print_error($db, $object->error); } - } - - elseif ($action == 'setpaymentterm' && $usercancreate) + } elseif ($action == 'setpaymentterm' && $usercancreate) { $object->fetch($id); $object->date_lim_reglement = dol_mktime(12, 0, 0, $_POST['paymenttermmonth'], $_POST['paymenttermday'], $_POST['paymenttermyear']); @@ -464,9 +429,7 @@ if (empty($reshook)) if ($result < 0) { dol_print_error($db, $object->error); } - } - - elseif ($action == 'setrevenuestamp' && $usercancreate) + } elseif ($action == 'setrevenuestamp' && $usercancreate) { $object->fetch($id); $object->revenuestamp = GETPOST('revenuestamp'); @@ -494,27 +457,19 @@ if (empty($reshook)) if ($result < 0) setEventMessages($object->error, $object->errors, 'errors'); } } - } - - // Set incoterm + } // Set incoterm elseif ($action == 'set_incoterms' && !empty($conf->incoterm->enabled)) { $result = $object->setIncoterms(GETPOST('incoterm_id', 'int'), GETPOST('location_incoterms', 'alpha')); - } - - // bank account + } // bank account elseif ($action == 'setbankaccount' && $usercancreate) { $result = $object->setBankAccount(GETPOST('fk_account', 'int')); - } - - elseif ($action == 'setremisepercent' && $usercancreate) + } elseif ($action == 'setremisepercent' && $usercancreate) { $object->fetch($id); $result = $object->set_remise($user, $_POST['remise_percent']); - } - - elseif ($action == "setabsolutediscount" && $usercancreate) + } elseif ($action == "setabsolutediscount" && $usercancreate) { // POST[remise_id] or POST[remise_id_for_payment] @@ -570,21 +525,15 @@ if (empty($reshook)) $result = $object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); if ($result < 0) setEventMessages($object->error, $object->errors, 'errors'); } - } - - elseif ($action == 'setref' && $usercancreate) + } elseif ($action == 'setref' && $usercancreate) { $object->fetch($id); $object->setValueFrom('ref', GETPOST('ref'), '', null, '', '', $user, 'BILL_MODIFY'); - } - - elseif ($action == 'setref_client' && $usercancreate) + } elseif ($action == 'setref_client' && $usercancreate) { $object->fetch($id); $object->set_ref_client(GETPOST('ref_client')); - } - - // Classify to validated + } // Classify to validated elseif ($action == 'confirm_valid' && $confirm == 'yes' && $usercanvalidate) { $idwarehouse = GETPOST('idwarehouse', 'int'); @@ -618,9 +567,7 @@ if (empty($reshook)) } } } - } - else - { + } else { //var_dump($conf->global->SOCIETE_EMAIL_MANDATORY); if ($key == 'EMAIL') { @@ -695,16 +642,12 @@ if (empty($reshook)) $result = $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref); if ($result < 0) setEventMessages($object->error, $object->errors, 'errors'); } - } - else - { + } else { if (count($object->errors)) setEventMessages(null, $object->errors, 'errors'); else setEventMessages($object->error, $object->errors, 'errors'); } } - } - - // Go back to draft status (unvalidate) + } // Go back to draft status (unvalidate) elseif ($action == 'confirm_modif' && $usercanunvalidate) { $idwarehouse = GETPOST('idwarehouse', 'int'); @@ -785,9 +728,7 @@ if (empty($reshook)) } } } - } - - // Classify "paid" + } // Classify "paid" elseif ($action == 'confirm_paid' && $confirm == 'yes' && $usercanissuepayment) { $object->fetch($id); @@ -816,9 +757,7 @@ if (empty($reshook)) } else { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Reason")), null, 'errors'); } - } - - // Convertir en reduc + } // Convertir en reduc elseif ($action == 'confirm_converttoreduc' && $confirm == 'yes' && $usercancreate) { $object->fetch($id); @@ -971,25 +910,19 @@ if (empty($reshook)) if ($result >= 0) { $db->commit(); - } - else - { + } else { setEventMessages($object->error, $object->errors, 'errors'); $db->rollback(); } } else { $db->commit(); } - } - else - { + } else { setEventMessages($discount->error, $discount->errors, 'errors'); $db->rollback(); } } - } - - // Delete payment + } // Delete payment elseif ($action == 'confirm_delete_paiement' && $confirm == 'yes' && $usercancreate) { $object->fetch($id); @@ -1005,9 +938,7 @@ if (empty($reshook)) setEventMessages($paiement->error, $paiement->errors, 'errors'); } } - } - - /* + } /* * Insert new invoice in database */ elseif ($action == 'add' && $usercancreate) @@ -1025,7 +956,7 @@ if (empty($reshook)) // Replacement invoice if ($_POST['type'] == Facture::TYPE_REPLACEMENT) { - $dateinvoice = dol_mktime(12, 0, 0, $_POST['remonth'], $_POST['reday'], $_POST['reyear']); + $dateinvoice = dol_mktime(12, 0, 0, GETPOST('remonth', 'int'), GETPOST('reday', 'int'), GETPOST('reyear', 'int')); if (empty($dateinvoice)) { $error++; @@ -1086,7 +1017,7 @@ if (empty($reshook)) $action = 'create'; } - $dateinvoice = dol_mktime(12, 0, 0, $_POST['remonth'], $_POST['reday'], $_POST['reyear']); + $dateinvoice = dol_mktime(12, 0, 0, GETPOST('remonth', 'int'), GETPOST('reday', 'int'), GETPOST('reyear', 'int')); if (empty($dateinvoice)) { $error++; @@ -1175,9 +1106,7 @@ if (empty($reshook)) { $searchPreviousInvoice = false; // find, exit; break; - } - else - { + } else { $lineIndex--; // go to previous invoice in cycle } } @@ -1269,7 +1198,7 @@ if (empty($reshook)) // Standard invoice or Deposit invoice, created from a Predefined template invoice if (($_POST['type'] == Facture::TYPE_STANDARD || $_POST['type'] == Facture::TYPE_DEPOSIT) && GETPOST('fac_rec', 'int') > 0) { - $dateinvoice = dol_mktime(12, 0, 0, $_POST['remonth'], $_POST['reday'], $_POST['reyear']); + $dateinvoice = dol_mktime(12, 0, 0, GETPOST('remonth', 'int'), GETPOST('reday', 'int'), GETPOST('reyear', 'int')); if (empty($dateinvoice)) { $error++; @@ -1320,7 +1249,7 @@ if (empty($reshook)) $action = 'create'; } - $dateinvoice = dol_mktime(12, 0, 0, $_POST['remonth'], $_POST['reday'], $_POST['reyear']); + $dateinvoice = dol_mktime(12, 0, 0, GETPOST('remonth', 'int'), GETPOST('reday', 'int'), GETPOST('reyear', 'int')); if (empty($dateinvoice)) { $error++; @@ -1365,8 +1294,7 @@ if (empty($reshook)) if (in_array($object->type, $retainedWarrantyInvoiceAvailableType)) { $object->retained_warranty = GETPOST('retained_warranty', 'int'); $object->retained_warranty_fk_cond_reglement = GETPOST('retained_warranty_fk_cond_reglement', 'int'); - } - else { + } else { $object->retained_warranty = 0; $object->retained_warranty_fk_cond_reglement = 0; } @@ -1469,14 +1397,11 @@ if (empty($reshook)) $amount_ttc_diff += $am; $amountdeposit[$tva] += $am / (1 + $tva / 100); // Convert into HT for the addline } - } - else - { + } else { if ($typeamount == 'amount') { $amountdeposit[0] = $valuedeposit; - } - elseif ($typeamount == 'variable') + } elseif ($typeamount == 'variable') { if ($result > 0) { @@ -1724,9 +1649,7 @@ if (empty($reshook)) setEventMessages($object->error, $object->errors, 'errors'); $error++; } - } - else - { // If some invoice's lines coming from page + } else { // If some invoice's lines coming from page $id = $object->create($user); for ($i = 1; $i <= $NBLINES; $i++) { @@ -1745,7 +1668,7 @@ if (empty($reshook)) // Situation invoices if (GETPOST('type') == Facture::TYPE_SITUATION && (!empty($_POST['situations']))) { - $datefacture = dol_mktime(12, 0, 0, $_POST['remonth'], $_POST['reday'], $_POST['reyear']); + $datefacture = dol_mktime(12, 0, 0, GETPOST('remonth', 'int'), GETPOST('reday', 'int'), GETPOST('reyear', 'int')); if (empty($datefacture)) { $error++; $mesg = $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Date")); @@ -1852,9 +1775,7 @@ if (empty($reshook)) if ($id <= 0) { $mesg = $object->error; - } - else - { + } else { $nextSituationInvoice = new Facture($db); $nextSituationInvoice->fetch($id); @@ -1894,18 +1815,14 @@ if (empty($reshook)) header('Location: '.$_SERVER["PHP_SELF"].'?facid='.$id); exit(); - } - else - { + } else { $db->rollback(); $action = 'create'; $_GET["origin"] = $_POST["origin"]; $_GET["originid"] = $_POST["originid"]; setEventMessages($object->error, $object->errors, 'errors'); } - } - - // Add a new line + } // Add a new line elseif ($action == 'addline' && $usercancreate) { $langs->load('errors'); @@ -1921,9 +1838,7 @@ if (empty($reshook)) { $idprod = 0; $tva_tx = (GETPOST('tva_tx', 'alpha') ? GETPOST('tva_tx', 'alpha') : 0); - } - else - { + } else { $idprod = GETPOST('idprod', 'int'); $tva_tx = ''; } @@ -1970,9 +1885,7 @@ if (empty($reshook)) setEventMessages($langs->trans("ErrorFieldCantBeNegativeOnInvoice", $langs->transnoentitiesnoconv("UnitPriceHT"), $langs->transnoentitiesnoconv("CustomerAbsoluteDiscountShort")), null, 'errors'); } $error++; - } - else - { + } else { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("UnitPriceHT")), null, 'errors'); $error++; } @@ -1998,9 +1911,7 @@ if (empty($reshook)) if ($res = $prodcomb->fetchByProductCombination2ValuePairs($idprod, $combinations)) { $idprod = $res->fk_product_child; - } - else - { + } else { setEventMessages($langs->trans('ErrorProductCombinationNotFound'), null, 'errors'); $error++; } @@ -2056,17 +1967,14 @@ if (empty($reshook)) { $pu_ht = price2num($price_ht, 'MU'); $pu_ttc = price2num($pu_ht * (1 + ($tmpvat / 100)), 'MU'); - } - // On reevalue prix selon taux tva car taux tva transaction peut etre different + } // On reevalue prix selon taux tva car taux tva transaction peut etre different // de ceux du produit par defaut (par exemple si pays different entre vendeur et acheteur). elseif ($tmpvat != $tmpprodvat) { if ($price_base_type != 'HT') { $pu_ht = price2num($pu_ttc / (1 + ($tmpvat / 100)), 'MU'); - } - else - { + } else { $pu_ttc = price2num($pu_ht * (1 + ($tmpvat / 100)), 'MU'); } } @@ -2233,9 +2141,7 @@ if (empty($reshook)) $action = ''; } } - } - - elseif ($action == 'updateline' && $usercancreate && !GETPOST('cancel', 'alpha')) + } elseif ($action == 'updateline' && $usercancreate && !GETPOST('cancel', 'alpha')) { if (!$object->fetch($id) > 0) dol_print_error($db); $object->fetch_thirdparty(); @@ -2292,16 +2198,14 @@ if (empty($reshook)) setEventMessages($mesg, null, 'warnings'); $error++; $result = -1; - } - elseif (GETPOST('progress') < $line->situation_percent) // TODO : use a modified $line->get_prev_progress($object->id) result + } elseif (GETPOST('progress') < $line->situation_percent) // TODO : use a modified $line->get_prev_progress($object->id) result { $mesg = $langs->trans("CantBeLessThanMinPercent"); setEventMessages($mesg, null, 'warnings'); $error++; $result = -1; } - } - elseif (GETPOST('progress') < $percent) + } elseif (GETPOST('progress') < $percent) { $mesg = '
'.$langs->trans("CantBeLessThanMinPercent").'
'; setEventMessages($mesg, null, 'warnings'); @@ -2356,9 +2260,7 @@ if (empty($reshook)) setEventMessages($langs->trans("ErrorFieldCantBeNegativeOnInvoice", $langs->transnoentitiesnoconv("UnitPriceHT"), $langs->transnoentitiesnoconv("CustomerAbsoluteDiscountShort")), null, 'errors'); } $error++; - } - else - { + } else { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("UnitPriceHT")), null, 'errors'); $error++; } @@ -2443,9 +2345,7 @@ if (empty($reshook)) setEventMessages($object->error, $object->errors, 'errors'); } } - } - - elseif ($action == 'updatealllines' && $usercancreate && $_POST['all_percent'] == $langs->trans('Modifier')) // Update all lines of situation invoice + } elseif ($action == 'updatealllines' && $usercancreate && $_POST['all_percent'] == $langs->trans('Modifier')) // Update all lines of situation invoice { if (!$object->fetch($id) > 0) dol_print_error($db); if (GETPOST('all_progress') != "") @@ -2458,18 +2358,13 @@ if (empty($reshook)) $mesg = $langs->trans("Line").' '.$i.' : '.$langs->trans("CantBeLessThanMinPercent"); setEventMessages($mesg, null, 'warnings'); $result = -1; - } else - $object->update_percent($line, $_POST['all_progress']); + } else $object->update_percent($line, $_POST['all_progress']); } } - } - - elseif ($action == 'updateline' && $usercancreate && $_POST['cancel'] == $langs->trans('Cancel')) { + } elseif ($action == 'updateline' && $usercancreate && $_POST['cancel'] == $langs->trans('Cancel')) { header('Location: '.$_SERVER["PHP_SELF"].'?facid='.$id); // To show again edited page exit(); - } - - // Outing situation invoice from cycle + } // Outing situation invoice from cycle elseif ($action == 'confirm_situationout' && $confirm == 'yes' && $usercancreate) { $object->fetch($id, '', '', '', true); @@ -2539,9 +2434,7 @@ if (empty($reshook)) { $searchPreviousInvoice = false; // find, exit; break; - } - else - { + } else { $lineIndex--; // go to previous invoice in cycle } } @@ -2568,25 +2461,17 @@ if (empty($reshook)) { setEventMessages($langs->trans('Updated'), '', 'mesgs'); header("Location: ".$_SERVER['PHP_SELF']."?id=".$id); - } - else - { + } else { setEventMessages($langs->trans('ErrorOutingSituationInvoiceCreditNote'), array(), 'errors'); } - } - else - { + } else { setEventMessages($langs->trans('ErrorOutingSituationInvoiceOnUpdate'), array(), 'errors'); } - } - else - { + } else { setEventMessages($langs->trans('ErrorFindNextSituationInvoice'), array(), 'errors'); } } - } - - // add lines from objectlinked + } // add lines from objectlinked elseif ($action == 'import_lines_from_object' && $usercancreate && $object->statut == Facture::STATUS_DRAFT @@ -2602,8 +2487,7 @@ if (empty($reshook)) { dol_include_once('/'.$fromElement.'/class/'.$fromElement.'.class.php'); $lineClassName = 'OrderLine'; - } - elseif ($fromElement == 'propal') + } elseif ($fromElement == 'propal') { dol_include_once('/comm/'.$fromElement.'/class/'.$fromElement.'.class.php'); $lineClassName = 'PropaleLigne'; @@ -2645,8 +2529,7 @@ if (empty($reshook)) $array_options = $originLine->array_options; if ($object->type == Facture::TYPE_SITUATION) { $situation_percent = 0; - } - else { + } else { $situation_percent = 100; } $fk_prev_id = ''; @@ -2660,8 +2543,7 @@ if (empty($reshook)) } else { $error++; } - } - else { + } else { $error++; } } @@ -2874,9 +2756,7 @@ if ($action == 'create') //Replicate extrafields $expesrc->fetch_optionals(); $object->array_options = $expesrc->array_options; - } - else - { + } else { $cond_reglement_id = (!empty($objectsrc->cond_reglement_id) ? $objectsrc->cond_reglement_id : (!empty($soc->cond_reglement_id) ? $soc->cond_reglement_id : 0)); $mode_reglement_id = (!empty($objectsrc->mode_reglement_id) ? $objectsrc->mode_reglement_id : (!empty($soc->mode_reglement_id) ? $soc->mode_reglement_id : 0)); $fk_account = (!empty($objectsrc->fk_account) ? $objectsrc->fk_account : (!empty($soc->fk_account) ? $soc->fk_account : 0)); @@ -2894,9 +2774,7 @@ if ($action == 'create') $object->array_options = $objectsrc->array_options; } } - } - else - { + } else { $cond_reglement_id = $soc->cond_reglement_id; $mode_reglement_id = $soc->mode_reglement_id; $fk_account = $soc->fk_account; @@ -2907,12 +2785,21 @@ if ($action == 'create') if (!empty($conf->multicurrency->enabled) && !empty($soc->multicurrency_code)) $currency_code = $soc->multicurrency_code; } + // when payment condition is empty (means not override by payment condition form a other object, like third-party), try to use default value + if (empty($cond_reglement_id)) { + $cond_reglement_id = GETPOST("cond_reglement_id"); + } + + // when payment mode is empty (means not override by payment mode form a other object, like third-party), try to use default value + if (empty($mode_reglement_id)) { + $mode_reglement_id = GETPOST("mode_reglement_id"); + } + if (!empty($soc->id)) $absolute_discount = $soc->getAvailableDiscounts(); $note_public = $object->getDefaultCreateValueFor('note_public', ((!empty($origin) && !empty($originid) && is_object($objectsrc) && !empty($conf->global->FACTURE_REUSE_NOTES_ON_CREATE_FROM)) ? $objectsrc->note_public : null)); $note_private = $object->getDefaultCreateValueFor('note_private', ((!empty($origin) && !empty($originid) && is_object($objectsrc) && !empty($conf->global->FACTURE_REUSE_NOTES_ON_CREATE_FROM)) ? $objectsrc->note_private : null)); - if (!empty($conf->use_javascript_ajax)) - { + if (!empty($conf->use_javascript_ajax)) { require_once DOL_DOCUMENT_ROOT.'/core/lib/ajax.lib.php'; print ajax_combobox('fac_replacement'); print ajax_combobox('fac_avoir'); @@ -2978,9 +2865,7 @@ if ($action == 'create') print ')'; print ''; print ''."\n"; - } - else - { + } else { print ''.$langs->trans('Customer').''; print ''; print $form->select_company($soc->id, 'socid', '((s.client = 1 OR s.client = 3) AND s.status=1)', 'SelectThirdParty', 0, 0, null, 0, 'minwidth300'); @@ -3134,10 +3019,10 @@ if ($action == 'create') print '
'; // Next situation invoice - $opt = $form->selectSituationInvoices(GETPOST('originid'), $socid); + $opt = $form->selectSituationInvoices(GETPOST('originid', 'int'), $socid); print '
'; - $tmp = ''.$langs->trans('NoSituations').'') || (GETPOST('origin') && GETPOST('origin') != 'facture' && GETPOST('origin') != 'commande')) $tmp .= ' disabled'; $tmp .= '> '; @@ -3203,9 +3088,7 @@ if ($action == 'create') print $desc; print '
'; } - } - else - { + } else { if (!empty($conf->global->INVOICE_USE_SITUATION)) { print '
'; @@ -3310,9 +3193,7 @@ if ($action == 'create') print '
'; } - } - else - { + } else { print '
'; if (empty($conf->global->INVOICE_CREDIT_NOTE_STANDALONE)) $tmp = ' '; else $tmp = ' '; @@ -3679,8 +3560,7 @@ if ($action == 'create') } print '
'; -} -elseif ($id > 0 || !empty($ref)) +} elseif ($id > 0 || !empty($ref)) { /* * Show object in view mode @@ -3789,9 +3669,7 @@ elseif ($id > 0 || !empty($ref)) array('type' => 'other', 'name' => 'idwarehouse', 'label' => $label, 'value' => $formproduct->selectWarehouses(GETPOST('idwarehouse') ?GETPOST('idwarehouse') : 'ifone', 'idwarehouse', '', 1, 0, 0, $langs->trans("NoStockAction"), 0, $forcecombo)) ); $formconfirm = $form->formconfirm($_SERVER['PHP_SELF'].'?facid='.$object->id, $langs->trans('DeleteBill'), $text, 'confirm_delete', $formquestion, "yes", 1); - } - else - { + } else { $formconfirm = $form->formconfirm($_SERVER['PHP_SELF'].'?facid='.$object->id, $langs->trans('DeleteBill'), $text, 'confirm_delete', '', 'no', 1); } } else { @@ -4128,8 +4006,7 @@ elseif ($id > 0 || !empty($ref)) foreach ($facidavoir as $id) { if ($i == 0) print ' '; - else - print ','; + else print ','; $facavoir = new Facture($db); $facavoir->fetch($id); print $facavoir->getNomUrl(1); @@ -4273,9 +4150,7 @@ elseif ($id > 0 || !empty($ref)) if ($action == 'editmode') { $form->form_modes_reglement($_SERVER['PHP_SELF'].'?facid='.$object->id, $object->mode_reglement_id, 'mode_reglement_id', 'CRDT', 1, 1); - } - else - { + } else { $form->form_modes_reglement($_SERVER['PHP_SELF'].'?facid='.$object->id, $object->mode_reglement_id, 'none', 'CRDT'); } print ''; @@ -4338,9 +4213,7 @@ elseif ($id > 0 || !empty($ref)) if ($action == 'editbankaccount') { $form->formSelectAccount($_SERVER['PHP_SELF'].'?id='.$object->id, $object->fk_account, 'fk_account', 1); - } - else - { + } else { $form->formSelectAccount($_SERVER['PHP_SELF'].'?id='.$object->id, $object->fk_account, 'none'); } print ""; @@ -4361,9 +4234,7 @@ elseif ($id > 0 || !empty($ref)) if ($action != 'editincoterm') { print $form->textwithpicto($object->display_incoterms(), $object->label_incoterms, 1); - } - else - { + } else { print $form->select_incoterms((!empty($object->fk_incoterms) ? $object->fk_incoterms : ''), (!empty($object->location_incoterms) ? $object->location_incoterms : ''), $_SERVER['PHP_SELF'].'?id='.$object->id); } print ''; @@ -4377,7 +4248,7 @@ elseif ($id > 0 || !empty($ref)) $displayWarranty = false; } - if($displayWarranty) { + if ($displayWarranty) { // Retained Warranty print ''; print ''; @@ -4432,9 +4301,7 @@ elseif ($id > 0 || !empty($ref)) $form->select_conditions_paiements($retained_warranty_fk_cond_reglement, 'retained_warranty_fk_cond_reglement', -1, 1); print ''; print ''; - } - else - { + } else { $form->form_conditions_reglement($_SERVER['PHP_SELF'].'?facid='.$object->id, $object->retained_warranty_fk_cond_reglement, 'none'); if (!$displayWarranty) { print img_picto($langs->trans('RetainedWarrantyNeed100Percent'), 'warning.png', 'class="pictowarning valignmiddle" '); @@ -4467,9 +4334,7 @@ elseif ($id > 0 || !empty($ref)) print ''; print ''; print ''; - } - else - { + } else { print dol_print_date($object->retained_warranty_date_limit, 'day'); } print ''; @@ -4831,8 +4696,7 @@ elseif ($id > 0 || !empty($ref)) print ''; $resteapayeraffiche = $resteapayer; @@ -4927,9 +4791,7 @@ elseif ($id > 0 || !empty($ref)) if ($object->type == Facture::TYPE_SITUATION) { $retainedWarranty = $total_global_ttc * $object->retained_warranty / 100; - } - else - { + } else { // Because one day retained warranty could be used on standard invoices $retainedWarranty = $object->total_ttc * $object->retained_warranty / 100; } @@ -4944,8 +4806,7 @@ elseif ($id > 0 || !empty($ref)) print !empty($object->retained_warranty_date_limit) ? ' '.$langs->trans("ToPayOn", dol_print_date($object->retained_warranty_date_limit, 'day')) : ''; print ' :'; } - } - else // Credit note + } else // Credit note { $cssforamountpaymentcomplete = 'amountpaymentneutral'; @@ -5118,9 +4979,7 @@ elseif ($id > 0 || !empty($ref)) print ''.$langs->trans('Modify').''; } } - } - else - { + } else { print ''.$langs->trans('Modify').''; } } @@ -5159,8 +5018,7 @@ elseif ($id > 0 || !empty($ref)) } else { if ($usercansend) { print ''.$langs->trans('SendMail').''; - } else - print ''.$langs->trans('SendMail').''; + } else print ''.$langs->trans('SendMail').''; } } } @@ -5178,14 +5036,10 @@ elseif ($id > 0 || !empty($ref)) } else { print ''.$langs->trans('MakeWithdrawRequest').''; } - } - else - { + } else { //print ''.$langs->trans("MakeWithdrawRequest").''; } - } - else - { + } else { //print ''.$langs->trans("MakeWithdrawRequest").''; } } @@ -5219,9 +5073,7 @@ elseif ($id > 0 || !empty($ref)) if ($resteapayer == 0) { print ''.$langs->trans('DoPaymentBack').''; - } - else - { + } else { print ''.$langs->trans('DoPaymentBack').''; } } @@ -5260,17 +5112,13 @@ elseif ($id > 0 || !empty($ref)) { // If one payment or one credit note was linked to this invoice print ''.$langs->trans('ClassifyPaidPartially').''; - } - else - { + } else { if (empty($conf->global->INVOICE_CAN_NEVER_BE_CANCELED)) { if ($objectidnext) { print ''.$langs->trans('ClassifyCanceled').''; - } - else - { + } else { print ''.$langs->trans('ClassifyCanceled').''; } } @@ -5282,7 +5130,7 @@ elseif ($id > 0 || !empty($ref)) { if (!$objectidnext) { - print ''.$langs->trans("CreateCreditNote").''; + print ''.$langs->trans("CreateCreditNote").''; } } @@ -5332,9 +5180,7 @@ elseif ($id > 0 || !empty($ref)) if (($object->total_ttc - $totalcreditnotes) == 0) { print ''.$langs->trans("RemoveSituationFromCycle").''; - } - else - { + } else { print ''.$langs->trans("RemoveSituationFromCycle").''; } } @@ -5357,26 +5203,19 @@ elseif ($id > 0 || !empty($ref)) //var_dump($isErasable); if ($isErasable == -4) { print ''.$langs->trans('Delete').''; - } - elseif ($isErasable == -3) { + } elseif ($isErasable == -3) { print ''.$langs->trans('Delete').''; - } - elseif ($isErasable == -2) { + } elseif ($isErasable == -2) { print ''.$langs->trans('Delete').''; - } - elseif ($isErasable == -1) { + } elseif ($isErasable == -1) { print ''.$langs->trans('Delete').''; - } - elseif ($isErasable <= 0) // Any other cases + } elseif ($isErasable <= 0) // Any other cases { print ''.$langs->trans('Delete').''; - } - elseif ($objectidnext) + } elseif ($objectidnext) { print ''.$langs->trans('Delete').''; - } - else - { + } else { print ''.$langs->trans('Delete').''; } } else { diff --git a/htdocs/compta/facture/class/api_invoices.class.php b/htdocs/compta/facture/class/api_invoices.class.php index 85da9cd5c37..c1ed5b809da 100644 --- a/htdocs/compta/facture/class/api_invoices.class.php +++ b/htdocs/compta/facture/class/api_invoices.class.php @@ -244,8 +244,7 @@ class Invoices extends DolibarrApi } $i++; } - } - else { + } else { throw new RestException(503, 'Error when retrieve invoice list : '.$db->lasterror()); } if (!count($obj_ret)) { @@ -548,9 +547,7 @@ class Invoices extends DolibarrApi $updateRes = $this->invoice->deleteline($lineid); if ($updateRes > 0) { return $this->get($id); - } - else - { + } else { throw new RestException(405, $this->invoice->error); } } @@ -1041,14 +1038,11 @@ class Invoices extends DolibarrApi $discount = new DiscountAbsolute($this->db); if ($this->invoice->type == Facture::TYPE_CREDIT_NOTE) { $discount->description = '(CREDIT_NOTE)'; - } - elseif ($this->invoice->type == Facture::TYPE_DEPOSIT) { + } elseif ($this->invoice->type == Facture::TYPE_DEPOSIT) { $discount->description = '(DEPOSIT)'; - } - elseif ($this->invoice->type == Facture::TYPE_STANDARD || $this->invoice->type == Facture::TYPE_REPLACEMENT || $this->invoice->type == Facture::TYPE_SITUATION) { + } elseif ($this->invoice->type == Facture::TYPE_STANDARD || $this->invoice->type == Facture::TYPE_REPLACEMENT || $this->invoice->type == Facture::TYPE_SITUATION) { $discount->description = '(EXCESS RECEIVED)'; - } - else { + } else { throw new RestException(500, 'Cant convert to reduc an Invoice of this type'); } @@ -1124,18 +1118,14 @@ class Invoices extends DolibarrApi if ($result >= 0) { $this->db->commit(); - } - else - { + } else { $this->db->rollback(); throw new RestException(500, 'Could not set paid'); } } else { $this->db->commit(); } - } - else - { + } else { $this->db->rollback(); throw new RestException(500, 'Discount creation error'); } diff --git a/htdocs/compta/facture/class/facture-rec.class.php b/htdocs/compta/facture/class/facture-rec.class.php index 71be89f30f5..581e63be08a 100644 --- a/htdocs/compta/facture/class/facture-rec.class.php +++ b/htdocs/compta/facture/class/facture-rec.class.php @@ -336,8 +336,7 @@ class FactureRec extends CommonInvoice if ($result_insert < 0) { $error++; - } - else { + } else { $objectline = new FactureLigneRec($this->db); if ($objectline->fetch($result_insert)) { @@ -377,8 +376,7 @@ class FactureRec extends CommonInvoice $error++; } } - } - else // Old behaviour, if linked_object has only one link per type, so is something like array('contract'=>id1)) + } else // Old behaviour, if linked_object has only one link per type, so is something like array('contract'=>id1)) { $origin_id = $tmp_origin_id; $ret = $this->add_object_linked($origin, $origin_id); @@ -394,22 +392,16 @@ class FactureRec extends CommonInvoice if ($error) { $this->db->rollback(); - } - else - { + } else { $this->db->commit(); return $this->id; } - } - else - { + } else { $this->error = $this->db->lasterror(); $this->db->rollback(); return -2; } - } - else - { + } else { $this->db->rollback(); return -1; } @@ -460,9 +452,7 @@ class FactureRec extends CommonInvoice } $this->db->commit(); return 1; - } - else - { + } else { $this->error = $this->db->lasterror(); $this->db->rollback(); return -2; @@ -584,16 +574,12 @@ class FactureRec extends CommonInvoice return -3; } return 1; - } - else - { + } else { $this->error = 'Bill with id '.$rowid.' or ref '.$ref.' not found sql='.$sql; dol_syslog('Facture::Fetch Error '.$this->error, LOG_ERR); return -2; } - } - else - { + } else { $this->error = $this->db->error(); return -1; } @@ -722,9 +708,7 @@ class FactureRec extends CommonInvoice $this->db->free($result); return 1; - } - else - { + } else { $this->error = $this->db->lasterror(); return -3; } @@ -766,15 +750,11 @@ class FactureRec extends CommonInvoice // Delete extrafields $res = $this->deleteExtraFields(); if ($res < 0) $error = -4; - } - else - { + } else { $this->error = $this->db->lasterror(); $error = -1; } - } - else - { + } else { $this->error = $this->db->lasterror(); $error = -2; } @@ -783,9 +763,7 @@ class FactureRec extends CommonInvoice { $this->db->commit(); return 1; - } - else - { + } else { $this->db->rollback(); return $error; } @@ -860,9 +838,7 @@ class FactureRec extends CommonInvoice if ($price_base_type == 'HT') { $pu = $pu_ht; - } - else - { + } else { $pu = $pu_ttc; } @@ -969,9 +945,7 @@ class FactureRec extends CommonInvoice $this->id = $facid; $this->update_price(); return $lineId; - } - else - { + } else { $this->error = $this->db->lasterror(); return -1; } @@ -1045,9 +1019,7 @@ class FactureRec extends CommonInvoice if ($price_base_type == 'HT') { $pu = $pu_ht; - } - else - { + } else { $pu = $pu_ttc; } @@ -1131,9 +1103,7 @@ class FactureRec extends CommonInvoice $this->id = $facid; $this->update_price(); return 1; - } - else - { + } else { $this->error = $this->db->lasterror(); return -1; } @@ -1226,8 +1196,7 @@ class FactureRec extends CommonInvoice if ($num) $this->output .= $langs->trans("FoundXQualifiedRecurringInvoiceTemplate", $num)."\n"; - else - $this->output .= $langs->trans("NoQualifiedRecurringInvoiceTemplateFound"); + else $this->output .= $langs->trans("NoQualifiedRecurringInvoiceTemplateFound"); $saventity = $conf->entity; @@ -1288,9 +1257,7 @@ class FactureRec extends CommonInvoice $error++; } } - } - else - { + } else { $error++; $this->error = "Failed to load invoice template with id=".$line->rowid.", entity=".$conf->entity."\n"; $this->errors[] = "Failed to load invoice template with id=".$line->rowid.", entity=".$conf->entity; @@ -1303,9 +1270,7 @@ class FactureRec extends CommonInvoice dol_syslog("createRecurringInvoices Process invoice template ".$facturerec->ref." is finished with a success generation"); $nb_create++; $this->output .= $langs->trans("InvoiceGeneratedFromTemplate", $facture->ref, $facturerec->ref)."\n"; - } - else - { + } else { $db->rollback("createRecurringInvoices Process invoice template id=".$facturerec->id.", ref=".$facturerec->ref); } @@ -1323,8 +1288,7 @@ class FactureRec extends CommonInvoice } $conf->entity = $saventity; // Restore entity context - } - else dol_print_error($db); + } else dol_print_error($db); $this->output = trim($this->output); @@ -1430,69 +1394,54 @@ class FactureRec extends CommonInvoice { if ($status == self::STATUS_SUSPENDED) { $labelStatus = $langs->trans('Disabled'); - } - else { + } else { $labelStatus = $langs->trans('Active'); } - } - else - { + } else { if ($status == self::STATUS_SUSPENDED) { $labelStatus = $langs->trans('Disabled'); - } - else { + } else { $labelStatus = $langs->trans("Draft"); } } - } - elseif ($mode == 1) + } elseif ($mode == 1) { $prefix = 'Short'; if ($recur) { if ($status == self::STATUS_SUSPENDED) { $labelStatus = $langs->trans('Disabled'); - } - else { + } else { $labelStatus = $langs->trans('Active'); } - } - else - { + } else { if ($status == self::STATUS_SUSPENDED) { $labelStatus = $langs->trans('Disabled'); - } - else { + } else { $labelStatus = $langs->trans("Draft"); } } - } - elseif ($mode == 2) + } elseif ($mode == 2) { if ($recur) { if ($status == self::STATUS_SUSPENDED) { $statusType = 'status6'; $labelStatus = $langs->trans('Disabled'); - } - else { + } else { $statusType = 'status4'; $labelStatus = $langs->trans('Active'); } - } - else - { + } else { if ($status == self::STATUS_SUSPENDED) { $statusType = 'status6'; $labelStatus = $langs->trans('Disabled'); - } - else { + } else { $statusType = 'status0'; $labelStatus = $langs->trans('Draft'); } } - } - elseif ($mode == 3) + } elseif ($mode == 3) { if ($recur) { @@ -1500,25 +1449,20 @@ class FactureRec extends CommonInvoice if ($status == self::STATUS_SUSPENDED) { $statusType = 'status6'; $labelStatus = $langs->trans('Disabled'); - } - else { + } else { $statusType = 'status4'; $labelStatus = $langs->trans('Active'); } - } - else - { + } else { if ($status == self::STATUS_SUSPENDED) { $statusType = 'status6'; $labelStatus = $langs->trans('Disabled'); - } - else { + } else { $statusType = 'status0'; $labelStatus = $langs->trans('Draft'); } } - } - elseif ($mode == 4) + } elseif ($mode == 4) { $prefix = ''; if ($recur) @@ -1526,25 +1470,20 @@ class FactureRec extends CommonInvoice if ($status == self::STATUS_SUSPENDED) { $statusType = 'status6'; $labelStatus = $langs->trans('Disabled'); - } - else { + } else { $statusType = 'status4'; $labelStatus = $langs->trans('Active'); } - } - else - { + } else { if ($status == self::STATUS_SUSPENDED) { $statusType = 'status6'; $labelStatus = $langs->trans('Disabled'); - } - else { + } else { $statusType = 'status0'; $labelStatus = $langs->trans('Draft'); } } - } - elseif ($mode == 5 || $mode == 6) + } elseif ($mode == 5 || $mode == 6) { $prefix = ''; if ($mode == 5) $prefix = 'Short'; @@ -1553,19 +1492,15 @@ class FactureRec extends CommonInvoice if ($status == self::STATUS_SUSPENDED) { $statusType = 'status6'; $labelStatus = $langs->trans('Disabled'); - } - else { + } else { $statusType = 'status4'; $labelStatus = $langs->trans('Active'); } - } - else - { + } else { if ($status == self::STATUS_SUSPENDED) { $statusType = 'status6'; $labelStatus = $langs->trans('Disabled'); - } - else { + } else { $statusType = 'status0'; $labelStatus = $langs->trans('Draft'); } @@ -1654,16 +1589,14 @@ class FactureRec extends CommonInvoice $line->total_ht = -100; $line->total_ttc = -119.6; $line->total_tva = -19.6; - } - elseif ($xnbp == 2) // UP is negative (free line) + } elseif ($xnbp == 2) // UP is negative (free line) { $line->subprice = -100; $line->total_ht = -100; $line->total_ttc = -119.6; $line->total_tva = -19.6; $line->remise_percent = 0; - } - elseif ($xnbp == 3) // Discount is 50% (product line) + } elseif ($xnbp == 3) // Discount is 50% (product line) { $prodid = mt_rand(1, $num_prods); $line->fk_product = $prodids[$prodid]; @@ -1671,8 +1604,7 @@ class FactureRec extends CommonInvoice $line->total_ttc = 59.8; $line->total_tva = 9.8; $line->remise_percent = 50; - } - else // (product line) + } else // (product line) { $prodid = mt_rand(1, $num_prods); $line->fk_product = $prodids[$prodid]; @@ -1761,9 +1693,7 @@ class FactureRec extends CommonInvoice $this->frequency = $frequency; if (!empty($unit)) $this->unit_frequency = $unit; return 1; - } - else - { + } else { dol_print_error($this->db); return -1; } @@ -1794,9 +1724,7 @@ class FactureRec extends CommonInvoice $this->date_when = $date; if ($increment_nb_gen_done > 0) $this->nb_gen_done++; return 1; - } - else - { + } else { dol_print_error($this->db); return -1; } @@ -1827,9 +1755,7 @@ class FactureRec extends CommonInvoice { $this->nb_gen_max = $nb; return 1; - } - else - { + } else { dol_print_error($this->db); return -1; } @@ -1858,9 +1784,7 @@ class FactureRec extends CommonInvoice { $this->auto_validate = $validate; return 1; - } - else - { + } else { dol_print_error($this->db); return -1; } @@ -1889,9 +1813,7 @@ class FactureRec extends CommonInvoice { $this->generate_pdf = $validate; return 1; - } - else - { + } else { dol_print_error($this->db); return -1; } @@ -1920,9 +1842,7 @@ class FactureRec extends CommonInvoice { $this->modelpdf = $model; return 1; - } - else - { + } else { dol_print_error($this->db); return -1; } @@ -2067,9 +1987,7 @@ class FactureLigneRec extends CommonInvoiceLine $this->db->free($result); return 1; - } - else - { + } else { $this->error = $this->db->lasterror(); return -3; } @@ -2149,9 +2067,7 @@ class FactureLigneRec extends CommonInvoiceLine } $this->db->commit(); return 1; - } - else - { + } else { $this->error = $this->db->lasterror(); $this->db->rollback(); return -2; diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 90ed560b3cf..28f0883bb90 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -678,8 +678,7 @@ class Facture extends CommonInvoice $error++; } } - } - else // Old behaviour, if linked_object has only one link per type, so is something like array('contract'=>id1)) + } else // Old behaviour, if linked_object has only one link per type, so is something like array('contract'=>id1)) { $origin_id = $tmp_origin_id; $ret = $this->add_object_linked($origin, $origin_id); @@ -726,8 +725,7 @@ class Facture extends CommonInvoice //print $objcontact->code.'-'.$objcontact->source.'-'.$objcontact->fk_socpeople."\n"; $this->add_contact($objcontact->fk_socpeople, $objcontact->code, $objcontact->source); // May failed because of duplicate key or because code of contact type does not exists for new object } - } - else dol_print_error($resqlcontact); + } else dol_print_error($resqlcontact); } /* @@ -787,8 +785,7 @@ class Facture extends CommonInvoice break; } } - } - elseif (!$error && empty($this->fac_rec)) // If this->lines is an array of invoice line arrays + } elseif (!$error && empty($this->fac_rec)) // If this->lines is an array of invoice line arrays { $fk_parent_line = 0; @@ -987,29 +984,21 @@ class Facture extends CommonInvoice { $this->db->commit(); return $this->id; - } - else - { + } else { $this->db->rollback(); return -4; } - } - else - { + } else { $this->error = $langs->trans('FailedToUpdatePrice'); $this->db->rollback(); return -3; } - } - else - { + } else { dol_syslog(get_class($this)."::create error ".$this->error, LOG_ERR); $this->db->rollback(); return -2; } - } - else - { + } else { $this->error = $this->db->error(); $this->db->rollback(); return -1; @@ -1094,8 +1083,7 @@ class Facture extends CommonInvoice { $this->error = $facture->error; $this->errors = $facture->errors; - } - elseif ($this->type == self::TYPE_SITUATION && !empty($conf->global->INVOICE_USE_SITUATION)) + } elseif ($this->type == self::TYPE_SITUATION && !empty($conf->global->INVOICE_USE_SITUATION)) { $this->fetchObjectLinked('', '', $this->id, 'facture'); @@ -1177,6 +1165,30 @@ class Facture extends CommonInvoice { unset($object->lines[$i]); unset($object->products[$i]); // Tant que products encore utilise + } + // Bloc to update dates of service (month by month only if previously filled at 1d near start or end of month) + // If it's a service with start and end dates + if (!empty($line->date_start) && !empty($line->date_end) ) { + // Get the dates + $start = dol_getdate($line->date_start); + $end = dol_getdate($line->date_end); + + // Get the first and last day of the month + $first = dol_get_first_day($start['year'], $start['mon']); + $last = dol_get_first_day($end['year'], $end['mon']); + + // Get diff betweend start/end of month and previously filled + $diffFirst = num_between_day($first, dol_mktime($start['hours'], $start['minutes'], $start['seconds'], $start['mon'], $start['mday'], $start['year'], 'user')); + $diffLast = num_between_day(dol_mktime($end['hours'], $end['minutes'], $end['seconds'], $end['mon'], $end['mday'], $end['year'], 'user'), $last); + + // If there is <= 1d (or 2?) of start/or/end of month + if ($diffFirst <= 2 && $diffLast <= 2) { + $nextMonth = dol_get_next_month($end['mon'], $end['year']); + $newFirst = dol_get_first_day($nextMonth['year'], $nextMonth['month']); + $newLast = dol_get_last_day($nextMonth['year'], $nextMonth['month']); + $object->lines[$i]->date_start = $newFirst; + $object->lines[$i]->date_end = $newLast; + } } } @@ -1216,9 +1228,7 @@ class Facture extends CommonInvoice { $this->db->commit(); return $object->id; - } - else - { + } else { $this->db->rollback(); return -1; } @@ -1343,10 +1353,8 @@ class Facture extends CommonInvoice if (!$error) { return 1; - } - else return -1; - } - else return -1; + } else return -1; + } else return -1; } /** @@ -1621,16 +1629,12 @@ class Facture extends CommonInvoice return -3; } return 1; - } - else - { + } else { $this->error = 'Invoice with id='.$rowid.' or ref='.$ref.' or ref_ext='.$ref_ext.' not found'; dol_syslog(get_class($this)."::fetch Error ".$this->error, LOG_ERR); return 0; } - } - else - { + } else { $this->error = $this->db->error(); return -1; } @@ -1751,9 +1755,7 @@ class Facture extends CommonInvoice } $this->db->free($result); return 1; - } - else - { + } else { $this->error = $this->db->error(); return -3; } @@ -1791,9 +1793,7 @@ class Facture extends CommonInvoice ) { $this->tab_previous_situation_invoice[] = $invoice; - } - else - { + } else { $this->tab_next_situation_invoice[] = $invoice; } } @@ -1909,9 +1909,7 @@ class Facture extends CommonInvoice } $this->db->rollback(); return -1 * $error; - } - else - { + } else { $this->db->commit(); return 1; } @@ -1997,23 +1995,17 @@ class Facture extends CommonInvoice $this->db->commit(); return 1; - } - else - { + } else { $this->error = $facligne->error; $this->db->rollback(); return -1; } - } - else - { + } else { $this->error = $facligne->error; $this->db->rollback(); return -2; } - } - else - { + } else { $this->db->rollback(); return -3; } @@ -2039,8 +2031,7 @@ class Facture extends CommonInvoice $sql = 'UPDATE '.MAIN_DB_PREFIX.'facture'; if (empty($ref_client)) $sql .= ' SET ref_client = NULL'; - else - $sql .= ' SET ref_client = \''.$this->db->escape($ref_client).'\''; + else $sql .= ' SET ref_client = \''.$this->db->escape($ref_client).'\''; $sql .= ' WHERE rowid = '.$this->id; dol_syslog(__METHOD__.' this->id='.$this->id.', ref_client='.$ref_client, LOG_DEBUG); @@ -2070,9 +2061,7 @@ class Facture extends CommonInvoice $this->db->commit(); return 1; - } - else - { + } else { foreach ($this->errors as $errmsg) { dol_syslog(__METHOD__.' Error: '.$errmsg, LOG_ERR); @@ -2236,23 +2225,17 @@ class Facture extends CommonInvoice $this->db->commit(); return 1; - } - else - { + } else { $this->error = $this->db->lasterror()." sql=".$sql; $this->db->rollback(); return -6; } - } - else - { + } else { $this->error = $this->db->lasterror()." sql=".$sql; $this->db->rollback(); return -4; } - } - else - { + } else { $this->db->rollback(); return -2; } @@ -2297,9 +2280,7 @@ class Facture extends CommonInvoice $result = $this->call_trigger('BILL_PAYED', $user); if ($result < 0) $error++; // End call triggers - } - else - { + } else { $error++; $this->error = $this->db->lasterror(); } @@ -2308,15 +2289,11 @@ class Facture extends CommonInvoice { $this->db->commit(); return 1; - } - else - { + } else { $this->db->rollback(); return -1; } - } - else - { + } else { return 0; } } @@ -2352,9 +2329,7 @@ class Facture extends CommonInvoice $result = $this->call_trigger('BILL_UNPAYED', $user); if ($result < 0) $error++; // End call triggers - } - else - { + } else { $error++; $this->error = $this->db->error(); dol_print_error($this->db); @@ -2364,9 +2339,7 @@ class Facture extends CommonInvoice { $this->db->commit(); return 1; - } - else - { + } else { $this->db->rollback(); return -1; } @@ -2421,16 +2394,12 @@ class Facture extends CommonInvoice $this->db->commit(); return 1; - } - else - { + } else { $this->error = $this->db->error()." sql=".$sql; $this->db->rollback(); return -1; } - } - else - { + } else { $this->error = $this->db->error()." sql=".$sql; $this->db->rollback(); return -2; @@ -2539,8 +2508,7 @@ class Facture extends CommonInvoice if ($force_number) { $num = $force_number; - } - elseif (preg_match('/^[\(]?PROV/i', $this->ref) || empty($this->ref)) // empty should not happened, but when it occurs, the test save life + } elseif (preg_match('/^[\(]?PROV/i', $this->ref) || empty($this->ref)) // empty should not happened, but when it occurs, the test save life { if (!empty($conf->global->FAC_FORCE_DATE_VALIDATION)) // If option enabled, we force invoice date { @@ -2548,9 +2516,7 @@ class Facture extends CommonInvoice $this->date_lim_reglement = $this->calculate_date_lim_reglement(); } $num = $this->getNextNumRef($this->thirdparty); - } - else - { + } else { $num = $this->ref; } $this->newref = dol_sanitizeFileName($num); @@ -2779,9 +2745,7 @@ class Facture extends CommonInvoice $this->setFinal($user); } } - } - else - { + } else { $error++; } @@ -2789,9 +2753,7 @@ class Facture extends CommonInvoice { $this->db->commit(); return 1; - } - else - { + } else { $this->db->rollback(); return -1; } @@ -2918,15 +2880,11 @@ class Facture extends CommonInvoice { $this->db->commit(); return 1; - } - else - { + } else { $this->db->rollback(); return -1; } - } - else - { + } else { $this->error = $this->db->error(); $this->db->rollback(); return -1; @@ -3045,9 +3003,7 @@ class Facture extends CommonInvoice if ($price_base_type == 'HT') { $pu = $pu_ht; - } - else - { + } else { $pu = $pu_ttc; } @@ -3188,23 +3144,17 @@ class Facture extends CommonInvoice { $this->db->commit(); return $this->line->id; - } - else - { + } else { $this->error = $this->db->lasterror(); $this->db->rollback(); return -1; } - } - else - { + } else { $this->error = $this->line->error; $this->db->rollback(); return -2; } - } - else - { + } else { dol_syslog(get_class($this)."::addline status of order must be Draft to allow use of ->addline()", LOG_ERR); return -3; } @@ -3419,16 +3369,12 @@ class Facture extends CommonInvoice $this->update_price(1); $this->db->commit(); return $result; - } - else - { + } else { $this->error = $this->line->error; $this->db->rollback(); return -1; } - } - else - { + } else { $this->error = "Invoice statut makes operation forbidden"; return -2; } @@ -3548,16 +3494,12 @@ class Facture extends CommonInvoice { $this->db->commit(); return 1; - } - else - { + } else { $this->db->rollback(); $this->error = $this->db->lasterror(); return -1; } - } - else - { + } else { $this->db->rollback(); $this->error = $line->error; return -1; @@ -3615,9 +3557,7 @@ class Facture extends CommonInvoice $this->db->commit(); return 1; - } - else - { + } else { foreach ($this->errors as $errmsg) { dol_syslog(__METHOD__.' Error: '.$errmsg, LOG_ERR); @@ -3684,9 +3624,7 @@ class Facture extends CommonInvoice { $this->db->commit(); return 1; - } - else - { + } else { foreach ($this->errors as $errmsg) { dol_syslog(__METHOD__.' Error: '.$errmsg, LOG_ERR); @@ -3844,9 +3782,7 @@ class Facture extends CommonInvoice $this->date_closing = $this->db->jdate($obj->dateclosing); } $this->db->free($result); - } - else - { + } else { dol_print_error($this->db); } } @@ -3904,13 +3840,10 @@ class Facture extends CommonInvoice if ($shortlist == 1) { $ga[$obj->fid] = $obj->ref; - } - elseif ($shortlist == 2) + } elseif ($shortlist == 2) { $ga[$obj->fid] = $obj->ref.' ('.$obj->name.')'; - } - else - { + } else { $ga[$i]['id'] = $obj->fid; $ga[$i]['ref'] = $obj->ref; $ga[$i]['name'] = $obj->name; @@ -3919,9 +3852,7 @@ class Facture extends CommonInvoice } } return $ga; - } - else - { + } else { dol_print_error($this->db); return -1; } @@ -3969,9 +3900,7 @@ class Facture extends CommonInvoice } //print_r($return); return $return; - } - else - { + } else { $this->error = $this->db->error(); return -1; } @@ -4017,9 +3946,7 @@ class Facture extends CommonInvoice $sqlSit .= " GROUP BY fs.situation_cycle_ref"; $sqlSit .= " ORDER BY fs.situation_counter"; $sql .= " AND ( f.type != ".self::TYPE_SITUATION." OR f.rowid IN (".$sqlSit.") )"; // Type non 5 si facture non avoir - } - else - { + } else { $sql .= " AND f.type != ".self::TYPE_SITUATION; // Type non 5 si facture non avoir } @@ -4044,9 +3971,7 @@ class Facture extends CommonInvoice } return $return; - } - else - { + } else { $this->error = $this->db->error(); return -1; } @@ -4122,9 +4047,7 @@ class Facture extends CommonInvoice dol_syslog(get_class($this).'::demandeprelevement Erreur'); $error++; } - } - else - { + } else { $this->error = 'WithdrawRequestErrorNilAmount'; dol_syslog(get_class($this).'::demandeprelevement WithdrawRequestErrorNilAmount'); $error++; @@ -4142,23 +4065,17 @@ class Facture extends CommonInvoice if ($error) return -1; return 1; - } - else - { + } else { $this->error = "A request already exists"; dol_syslog(get_class($this).'::demandeprelevement Impossible de creer une demande, demande deja en cours'); return 0; } - } - else - { + } else { $this->error = $this->db->error(); dol_syslog(get_class($this).'::demandeprelevement Erreur -2'); return -2; } - } - else - { + } else { $this->error = "Status of invoice does not allow this"; dol_syslog(get_class($this)."::demandeprelevement ".$this->error." $this->statut, $this->paye, $this->mode_reglement_id"); return -3; @@ -4182,9 +4099,7 @@ class Facture extends CommonInvoice if ($this->db->query($sql)) { return 0; - } - else - { + } else { $this->error = $this->db->lasterror(); dol_syslog(get_class($this).'::demande_prelevement_delete Error '.$this->error); return -1; @@ -4249,9 +4164,7 @@ class Facture extends CommonInvoice } return $response; - } - else - { + } else { dol_print_error($this->db); $this->error = $this->db->error(); return -1; @@ -4371,8 +4284,7 @@ class Facture extends CommonInvoice $line->multicurrency_total_ht = -200; $line->multicurrency_total_ttc = -239.2; $line->multicurrency_total_tva = -39.2; - } - elseif ($xnbp == 2) // UP is negative (free line) + } elseif ($xnbp == 2) // UP is negative (free line) { $line->subprice = -100; $line->total_ht = -100; @@ -4382,8 +4294,7 @@ class Facture extends CommonInvoice $line->multicurrency_total_ht = -200; $line->multicurrency_total_ttc = -239.2; $line->multicurrency_total_tva = -39.2; - } - elseif ($xnbp == 3) // Discount is 50% (product line) + } elseif ($xnbp == 3) // Discount is 50% (product line) { $prodid = mt_rand(1, $num_prods); $line->fk_product = $prodids[$prodid]; @@ -4394,8 +4305,7 @@ class Facture extends CommonInvoice $line->multicurrency_total_ttc = 119.6; $line->multicurrency_total_tva = 19.6; $line->remise_percent = 50; - } - else // (product line) + } else // (product line) { $prodid = mt_rand(1, $num_prods); $line->fk_product = $prodids[$prodid]; @@ -4481,9 +4391,7 @@ class Facture extends CommonInvoice } $this->db->free($resql); return 1; - } - else - { + } else { dol_print_error($this->db); $this->error = $this->db->error(); return -1; @@ -4644,9 +4552,7 @@ class Facture extends CommonInvoice { $this->db->commit(); return 1; - } - else - { + } else { foreach ($this->errors as $errmsg) { dol_syslog(__METHOD__.' Error: '.$errmsg, LOG_ERR); @@ -4731,13 +4637,10 @@ class Facture extends CommonInvoice if (($totalpaye < $this->total_ttc - $RetainedWarrantyAmount) && $this->date_lim_reglement < ($now - $conf->facture->client->warning_delay)) { $hasDelay = 1; - } - elseif ($totalpaye < $this->total_ttc && $this->retained_warranty_date_limit < ($now - $conf->facture->client->warning_delay)) + } elseif ($totalpaye < $this->total_ttc && $this->retained_warranty_date_limit < ($now - $conf->facture->client->warning_delay)) { $hasDelay = 1; - } - else - { + } else { $hasDelay = 0; } } @@ -4823,13 +4726,10 @@ class Facture extends CommonInvoice $total2BillWT += $this->total_ttc; $retainedWarrantyAmount = $total2BillWT * $this->retained_warranty / 100; - } - else { + } else { return -1; } - } - else - { + } else { // Because one day retained warranty could be used on standard invoices $retainedWarrantyAmount = $this->total_ttc * $this->retained_warranty / 100; } @@ -4865,16 +4765,12 @@ class Facture extends CommonInvoice { $this->retained_warranty = floatval($value); return 1; - } - else - { + } else { dol_syslog(get_class($this).'::setRetainedWarranty Erreur '.$sql.' - '.$this->db->error()); $this->error = $this->db->error(); return -1; } - } - else - { + } else { dol_syslog(get_class($this).'::setRetainedWarranty, status of the object is incompatible'); $this->error = 'Status of the object is incompatible '.$this->statut; return -2; @@ -4908,16 +4804,12 @@ class Facture extends CommonInvoice { $this->retained_warranty_date_limit = $timestamp; return 1; - } - else - { + } else { dol_syslog(get_class($this).'::setRetainedWarrantyDateLimit Erreur '.$sql.' - '.$this->db->error()); $this->error = $this->db->error(); return -1; } - } - else - { + } else { dol_syslog(get_class($this).'::setRetainedWarrantyDateLimit, status of the object is incompatible'); $this->error = 'Status of the object is incompatible '.$this->statut; return -2; @@ -5098,9 +4990,7 @@ class FactureLigne extends CommonInvoiceLine $this->db->free($result); return 1; - } - else - { + } else { $this->error = $this->db->lasterror(); return -1; } @@ -5153,9 +5043,7 @@ class FactureLigne extends CommonInvoiceLine if (($result = $this->defineBuyPrice($this->subprice, $this->remise_percent, $this->fk_product)) < 0) { return $result; - } - else - { + } else { $this->pa_ht = $result; } } @@ -5271,9 +5159,7 @@ class FactureLigne extends CommonInvoiceLine $this->db->rollback(); return -3; } - } - else - { + } else { $result = $discount->link_to_invoice($this->rowid, 0); if ($result < 0) { @@ -5283,17 +5169,13 @@ class FactureLigne extends CommonInvoiceLine return -3; } } - } - else - { + } else { $this->error = $langs->trans("ErrorADiscountThatHasBeenRemovedIsIncluded"); dol_syslog(get_class($this)."::insert Error ".$this->error, LOG_ERR); $this->db->rollback(); return -3; } - } - else - { + } else { $this->error = $discount->error; dol_syslog(get_class($this)."::insert Error ".$this->error, LOG_ERR); $this->db->rollback(); @@ -5315,9 +5197,7 @@ class FactureLigne extends CommonInvoiceLine $this->db->commit(); return $this->id; - } - else - { + } else { $this->error = $this->db->lasterror(); $this->db->rollback(); return -2; @@ -5370,9 +5250,7 @@ class FactureLigne extends CommonInvoiceLine if (($result = $this->defineBuyPrice($this->subprice, $this->remise_percent, $this->fk_product)) < 0) { return $result; - } - else - { + } else { $this->pa_ht = $result; } } @@ -5450,9 +5328,7 @@ class FactureLigne extends CommonInvoiceLine } $this->db->commit(); return 1; - } - else - { + } else { $this->error = $this->db->error(); $this->db->rollback(); return -2; @@ -5494,9 +5370,7 @@ class FactureLigne extends CommonInvoiceLine { $this->db->commit(); return 1; - } - else - { + } else { $this->error = $this->db->error()." sql=".$sql; $this->db->rollback(); return -1; @@ -5536,9 +5410,7 @@ class FactureLigne extends CommonInvoiceLine { $this->db->commit(); return 1; - } - else - { + } else { $this->error = $this->db->error(); $this->db->rollback(); return -2; diff --git a/htdocs/compta/facture/class/paymentterm.class.php b/htdocs/compta/facture/class/paymentterm.class.php index 427daf445c5..9888bd23d13 100644 --- a/htdocs/compta/facture/class/paymentterm.class.php +++ b/htdocs/compta/facture/class/paymentterm.class.php @@ -145,9 +145,7 @@ class PaymentTerm // extends CommonObject } $this->db->rollback(); return -1 * $error; - } - else - { + } else { $this->db->commit(); return $this->id; } @@ -202,9 +200,7 @@ class PaymentTerm // extends CommonObject $this->db->free($resql); return 1; - } - else - { + } else { $this->error = "Error ".$this->db->lasterror(); return -1; } @@ -239,9 +235,7 @@ class PaymentTerm // extends CommonObject } $this->db->free($resql); return $ret; - } - else - { + } else { $this->error = "Error ".$this->db->lasterror(); return -1; } @@ -305,9 +299,7 @@ class PaymentTerm // extends CommonObject } $this->db->rollback(); return -1 * $error; - } - else - { + } else { $this->db->commit(); return 1; } @@ -345,9 +337,7 @@ class PaymentTerm // extends CommonObject } $this->db->rollback(); return -1 * $error; - } - else - { + } else { $this->db->commit(); return 1; } @@ -396,9 +386,7 @@ class PaymentTerm // extends CommonObject { $this->db->commit(); return $object->id; - } - else - { + } else { $this->db->rollback(); return -1; } diff --git a/htdocs/compta/facture/contact.php b/htdocs/compta/facture/contact.php index 8eb47268186..c88fef5015c 100644 --- a/htdocs/compta/facture/contact.php +++ b/htdocs/compta/facture/contact.php @@ -69,35 +69,25 @@ if ($action == 'addcontact' && $user->rights->facture->creer) { header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); exit; - } - else - { + } else { if ($object->error == 'DB_ERROR_RECORD_ALREADY_EXISTS') { $langs->load("errors"); setEventMessages($langs->trans("ErrorThisContactIsAlreadyDefinedAsThisType"), null, 'errors'); - } - else - { + } else { setEventMessages($object->error, $object->errors, 'errors'); } } -} - -// Toggle the status of a contact +} // Toggle the status of a contact elseif ($action == 'swapstatut' && $user->rights->facture->creer) { if ($object->fetch($id)) { $result = $object->swapContactStatus(GETPOST('ligne')); - } - else - { + } else { dol_print_error($db); } -} - -// Deletes a contact +} // Deletes a contact elseif ($action == 'deletecontact' && $user->rights->facture->creer) { $object->fetch($id); @@ -107,8 +97,7 @@ elseif ($action == 'deletecontact' && $user->rights->facture->creer) { header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); exit; - } - else { + } else { dol_print_error($db); } } @@ -207,9 +196,7 @@ if ($id > 0 || !empty($ref)) $res = @include dol_buildpath($reldir.'/contacts.tpl.php'); if ($res) break; } - } - else - { + } else { // Record not found print "ErrorRecordNotFound"; } diff --git a/htdocs/compta/facture/document.php b/htdocs/compta/facture/document.php index a901b985342..ed9b032ae90 100644 --- a/htdocs/compta/facture/document.php +++ b/htdocs/compta/facture/document.php @@ -181,14 +181,10 @@ if ($id > 0 || !empty($ref)) $permtoedit = $user->rights->facture->creer; $param = '&id='.$object->id; include_once DOL_DOCUMENT_ROOT.'/core/tpl/document_actions_post_headers.tpl.php'; - } - else - { + } else { dol_print_error($db); } -} -else -{ +} else { print $langs->trans("ErrorUnknown"); } diff --git a/htdocs/compta/facture/invoicetemplate_list.php b/htdocs/compta/facture/invoicetemplate_list.php index 65e9044f4f7..dfda4a5b16d 100644 --- a/htdocs/compta/facture/invoicetemplate_list.php +++ b/htdocs/compta/facture/invoicetemplate_list.php @@ -609,9 +609,7 @@ if ($resql) if (!$invoicerectmp->isMaxNbGenReached()) { if (!$objp->suspended && $objp->frequency > 0 && $db->jdate($objp->date_when) && $db->jdate($objp->date_when) < $now) print img_warning($langs->trans("Late")); - } - else - { + } else { print img_info($langs->trans("MaxNumberOfGenerationReached")); } print ''; @@ -654,19 +652,14 @@ if ($resql) if ($invoicerectmp->isMaxNbGenReached()) { print $langs->trans("MaxNumberOfGenerationReached"); - } - elseif (empty($objp->frequency) || $db->jdate($objp->date_when) <= $today) + } elseif (empty($objp->frequency) || $db->jdate($objp->date_when) <= $today) { print ''; print $langs->trans("CreateBill").''; - } - else - { + } else { print $form->textwithpicto('', $langs->trans("DateIsNotEnough")); } - } - else - { + } else { print " "; } if (!$i) $totalarray['nbfield']++; @@ -676,9 +669,7 @@ if ($resql) $i++; } - } - else - { + } else { $colspan = 1; foreach ($arrayfields as $key => $val) { if (!empty($val['checked'])) $colspan++; } print ''; @@ -693,9 +684,7 @@ if ($resql) print ""; $db->free($resql); -} -else -{ +} else { dol_print_error($db); } diff --git a/htdocs/compta/facture/list.php b/htdocs/compta/facture/list.php index ed773b038bb..c21d19ad538 100644 --- a/htdocs/compta/facture/list.php +++ b/htdocs/compta/facture/list.php @@ -297,7 +297,14 @@ if (empty($reshook)) include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php'; } -if ($massaction == 'withdrawrequest') +if ($massaction == 'makepayment'){ + $arrayofselected=is_array($toselect)?$toselect:array(); + + $loc = dol_buildpath('/compta/paiement.php', 2).'?action=create&facids='.implode(',', $arrayofselected); + + header('Location: '.$loc); + exit; +} elseif ($massaction == 'withdrawrequest') { $langs->load("withdrawals"); @@ -305,9 +312,7 @@ if ($massaction == 'withdrawrequest') { $error++; setEventMessages($langs->trans("NotEnoughPermissions"), null, 'errors'); - } - else - { + } else { //Checking error $error = 0; @@ -355,12 +360,10 @@ if ($massaction == 'withdrawrequest') if ($numprlv > 0) { $error++; setEventMessages($objecttmp->ref.' '.$langs->trans("RequestAlreadyDone"), $objecttmp->errors, 'warnings'); - } - elseif (!empty($objecttmp->mode_reglement_code) && $objecttmp->mode_reglement_code != 'PRE') { + } elseif (!empty($objecttmp->mode_reglement_code) && $objecttmp->mode_reglement_code != 'PRE') { $error++; setEventMessages($objecttmp->ref.' '.$langs->trans("BadPaymentMethod"), $objecttmp->errors, 'errors'); - } - else { + } else { $listofbills[] = $objecttmp; // $listofbills will only contains invoices with good payment method and no request already done } } @@ -378,9 +381,7 @@ if ($massaction == 'withdrawrequest') { $db->commit(); $nbwithdrawrequestok++; - } - else - { + } else { $db->rollback(); setEventMessages($aBill->error, $aBill->errors, 'errors'); } @@ -507,9 +508,7 @@ if ($search_status != '-1' && $search_status != '') if ($search_status == '1') $sql .= " AND f.fk_statut = 1"; // unpayed if ($search_status == '2') $sql .= " AND f.fk_statut = 2"; // payed Not that some corrupted data may contains f.fk_statut = 1 AND f.paye = 1 (it means payed too but should not happend. If yes, reopen and reclassify billed) if ($search_status == '3') $sql .= " AND f.fk_statut = 3"; // abandonned - } - else - { + } else { $sql .= " AND f.fk_statut IN (".$db->escape($search_status).")"; // When search_status is '1,2' for example } } @@ -555,9 +554,7 @@ if (!$sall) if (!empty($extrafields->attributes[$object->table_element]['label'])) { foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key : ''); } -} -else -{ +} else { $sql .= natural_search(array_keys($fieldstosearchall), $sall); } @@ -657,6 +654,7 @@ if ($resql) 'generate_doc'=>$langs->trans("ReGeneratePDF"), 'builddoc'=>$langs->trans("PDFMerge"), 'presend'=>$langs->trans("SendByMail"), + //'makepayment'=>$langs->trans("InvoicePaymentsLimits"), TODO Blank page when using this ); if ($conf->prelevement->enabled) { $langs->load("withdrawals"); @@ -665,8 +663,7 @@ if ($resql) if ($user->rights->facture->supprimer) { if (!empty($conf->global->INVOICE_CAN_REMOVE_DRAFT_ONLY)) { $arrayofmassactions['predeletedraft'] = $langs->trans("Deletedraft"); - } - elseif (!empty($conf->global->INVOICE_CAN_ALWAYS_BE_REMOVED)) { // mass deletion never possible on invoices on such situation + } elseif (!empty($conf->global->INVOICE_CAN_ALWAYS_BE_REMOVED)) { // mass deletion never possible on invoices on such situation $arrayofmassactions['predelete'] = $langs->trans("Delete"); } } @@ -1210,9 +1207,7 @@ if ($resql) if ($contextpage == 'poslist') { print $obj->ref; - } - else - { + } else { print $facturestatic->getNomUrl(1, '', 200, 0, '', 0, 1); } @@ -1307,9 +1302,7 @@ if ($resql) if ($contextpage == 'poslist') { print $thirdpartystatic->name; - } - else - { + } else { print $thirdpartystatic->getNomUrl(1, 'customer'); } print ''; @@ -1530,7 +1523,7 @@ if ($resql) // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; // Fields from hook - $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$obj, 'i'=>$i); + $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray); $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; // Date creation @@ -1610,9 +1603,7 @@ if ($resql) $title = ''; print $formfile->showdocuments('massfilesarea_invoices', '', $filedir, $urlsource, 0, $delallowed, '', 1, 1, 0, 48, 1, $param, $title, '', '', '', null, $hidegeneratedfilelistifempty); -} -else -{ +} else { dol_print_error($db); } diff --git a/htdocs/compta/facture/prelevement.php b/htdocs/compta/facture/prelevement.php index 74de1c640d4..7cbe336e126 100644 --- a/htdocs/compta/facture/prelevement.php +++ b/htdocs/compta/facture/prelevement.php @@ -86,9 +86,7 @@ if (empty($reshook)) $db->commit(); setEventMessages($langs->trans("RecordSaved"), null, 'mesgs'); - } - else - { + } else { $db->rollback(); setEventMessages($object->error, $object->errors, 'errors'); } @@ -292,14 +290,10 @@ if ($object->id > 0) if ($action == 'editinvoicedate') { $form->form_date($_SERVER['PHP_SELF'].'?id='.$object->id, $object->date, 'invoicedate'); - } - else - { + } else { print dol_print_date($object->date, 'daytext'); } - } - else - { + } else { print dol_print_date($object->date, 'daytext'); } print ''; @@ -318,14 +312,10 @@ if ($object->id > 0) if ($action == 'editconditions') { $form->form_conditions_reglement($_SERVER['PHP_SELF'].'?id='.$object->id, $object->cond_reglement_id, 'cond_reglement_id'); - } - else - { + } else { $form->form_conditions_reglement($_SERVER['PHP_SELF'].'?id='.$object->id, $object->cond_reglement_id, 'none'); } - } - else - { + } else { print ' '; } print ''; @@ -343,17 +333,13 @@ if ($object->id > 0) if ($action == 'editpaymentterm') { $form->form_date($_SERVER['PHP_SELF'].'?id='.$object->id, $object->date_lim_reglement, 'paymentterm'); - } - else - { + } else { print dol_print_date($object->date_lim_reglement, 'daytext'); if ($object->hasDelay()) { print img_warning($langs->trans('Late')); } } - } - else - { + } else { print ' '; } print ''; @@ -369,9 +355,7 @@ if ($object->id > 0) if ($action == 'editmode') { $form->form_modes_reglement($_SERVER['PHP_SELF'].'?id='.$object->id, $object->mode_reglement_id, 'mode_reglement_id'); - } - else - { + } else { $form->form_modes_reglement($_SERVER['PHP_SELF'].'?id='.$object->id, $object->mode_reglement_id, 'none'); } print ''; @@ -388,9 +372,7 @@ if ($object->id > 0) if ($action == 'editbankaccount') { $form->formSelectAccount($_SERVER['PHP_SELF'].'?id='.$object->id, $object->fk_account, 'fk_account', 1); - } - else - { + } else { $form->formSelectAccount($_SERVER['PHP_SELF'].'?id='.$object->id, $object->fk_account, 'none'); } print ""; @@ -502,9 +484,7 @@ if ($object->id > 0) { $num = $db->num_rows($result_sql); $numopen = $num; - } - else - { + } else { dol_print_error($db); } @@ -520,9 +500,7 @@ if ($object->id > 0) { $obj = $db->fetch_object($result_sql); if ($obj) $pending = $obj->amount; - } - else - { + } else { dol_print_error($db); } @@ -549,25 +527,18 @@ if ($object->id > 0) print ''; print ''; print ''; - } - else - { + } else { print ''.$langs->trans("MakeWithdrawRequest").''; } - } - else - { + } else { print ''.$langs->trans("MakeWithdrawRequest").''; } - } - else - { + } else { if ($num == 0) { if ($object->statut > Facture::STATUS_DRAFT) print ''.$langs->trans("MakeWithdrawRequest").''; else print ''.$langs->trans("MakeWithdrawRequest").''; - } - else print ''.$langs->trans("MakeWithdrawRequest").''; + } else print ''.$langs->trans("MakeWithdrawRequest").''; } print "
\n"; @@ -634,9 +605,7 @@ if ($object->id > 0) } $db->free($result_sql); - } - else - { + } else { dol_print_error($db); } @@ -696,9 +665,7 @@ if ($object->id > 0) print ''; $db->free($result); - } - else - { + } else { dol_print_error($db); } diff --git a/htdocs/compta/facture/stats/index.php b/htdocs/compta/facture/stats/index.php index f5472196cc2..82ba8a33467 100644 --- a/htdocs/compta/facture/stats/index.php +++ b/htdocs/compta/facture/stats/index.php @@ -32,6 +32,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facturestats.class.php'; +if (!empty($conf->category->enabled)) require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; $WIDTH = DolGraph::getDefaultGraphSizeForStats('width'); $HEIGHT = DolGraph::getDefaultGraphSizeForStats('height'); @@ -49,6 +50,7 @@ $categ_id = GETPOST('categ_id', 'categ_id'); $userid = GETPOST('userid', 'int'); $socid = GETPOST('socid', 'int'); +$custcats = GETPOST('custcats', 'array'); // Security check if ($user->socid > 0) { @@ -58,15 +60,15 @@ if ($user->socid > 0) $nowyear = strftime("%Y", dol_now()); $year = GETPOST('year') > 0 ?GETPOST('year') : $nowyear; -//$startyear=$year-2; -$startyear = $year - 1; +if (!empty($conf->global->INVOICE_STATS_GRAPHS_SHOW_2_YEARS)) $startyear=$year-2; +else $startyear=$year-1; $endyear = $year; /* * View */ - +if (!empty($conf->category->enabled)) $langs->load('categories'); $form = new Form($db); $formcompany = new FormCompany($db); $formother = new FormOther($db); @@ -93,6 +95,10 @@ $stats = new FactureStats($db, $socid, $mode, ($userid > 0 ? $userid : 0), ($typ if ($mode == 'customer') { if ($object_status != '' && $object_status >= 0) $stats->where .= ' AND f.fk_statut IN ('.$db->escape($object_status).')'; + if (is_array($custcats) && !empty($custcats)) { + $stats->from .= ' LEFT JOIN '.MAIN_DB_PREFIX.'categorie_societe as cat ON (f.fk_soc = cat.fk_soc)'; + $stats->where .= ' AND cat.fk_categorie IN ('.implode(',', $custcats).')'; + } } if ($mode == 'supplier') { @@ -174,9 +180,7 @@ if (!$user->rights->societe->client->voir || $user->socid) $filename_avg = $dir.'/ordersaverage-'.$user->id.'-'.$year.'.png'; if ($mode == 'customer') $fileurl_avg = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstats&file=ordersaverage-'.$user->id.'-'.$year.'.png'; if ($mode == 'supplier') $fileurl_avg = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstatssupplier&file=ordersaverage-'.$user->id.'-'.$year.'.png'; -} -else -{ +} else { $filename_avg = $dir.'/ordersaverage-'.$year.'.png'; if ($mode == 'customer') $fileurl_avg = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstats&file=ordersaverage-'.$year.'.png'; if ($mode == 'supplier') $fileurl_avg = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstatssupplier&file=ordersaverage-'.$year.'.png'; @@ -256,26 +260,33 @@ if ($mode == 'customer') $filter = 's.client in (1,2,3)'; if ($mode == 'supplier') $filter = 's.fournisseur = 1'; print $form->selectarray('socid', $companies, $socid, 1, 0, 0, 'style="width: 95%"', 0, 0, 0, '', '', 1); print ''; + // ThirdParty Type print ''; + // Category -if ($mode == 'customer') -{ - $cat_type = Categorie::TYPE_CUSTOMER; - $cat_label = $langs->trans("Category").' '.lcfirst($langs->trans("Customer")); +if (! empty($conf->category->enabled)) { + if ($mode == 'customer') + { + $cat_type = Categorie::TYPE_CUSTOMER; + $cat_label = $langs->trans("Category").' '.lcfirst($langs->trans("Customer")); + } + if ($mode == 'supplier') + { + $cat_type = Categorie::TYPE_SUPPLIER; + $cat_label = $langs->trans("Category").' '.lcfirst($langs->trans("Supplier")); + } + print ''; } -if ($mode == 'supplier') -{ - $cat_type = Categorie::TYPE_SUPPLIER; - $cat_label = $langs->trans("Category").' '.lcfirst($langs->trans("Supplier")); -} -print ''; + // User print ''; print ''; print ''; - } - else - { + } else { print ''; } print "
'; @@ -4397,9 +4268,7 @@ elseif ($id > 0 || !empty($ref)) print ''; print ''; print ''; - } - else - { + } else { print price($object->retained_warranty).'%'; } print '
'; if ($object->type != Facture::TYPE_DEPOSIT) print $langs->trans('AlreadyPaidNoCreditNotesNoDeposits'); - else - print $langs->trans('AlreadyPaid'); + else print $langs->trans('AlreadyPaid'); print ' :'.price($totalpaye).' 
'.price($retainedWarranty).' 
'.$langs->trans("NoRecordFound").'
'.$langs->trans("None").'
'.$langs->trans("ThirdPartyType").''; $sortparam_typent = (empty($conf->global->SOCIETE_SORT_ON_TYPEENT) ? 'ASC' : $conf->global->SOCIETE_SORT_ON_TYPEENT); // NONE means we keep sort of original array, so we sort on position. ASC, means next function will sort on label. print $form->selectarray("typent_id", $formcompany->typent_array(0), $typent_id, 0, 0, 0, '', 0, 0, 0, $sortparam_typent); if ($user->admin) print ' '.info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); print '
'.$cat_label.''; + $cate_arbo = $form->select_all_categories(Categorie::TYPE_CUSTOMER, null, 'parent', null, null, 1); + print $form->multiselectarray('custcats', $cate_arbo, GETPOST('custcats', 'array'), null, null, null, null, "90%"); + //print $formother->select_categories($cat_type, $categ_id, 'categ_id', true); + print '
'.$cat_label.''; -print $formother->select_categories($cat_type, $categ_id, 'categ_id', true); -print '
'.$langs->trans("CreatedBy").''; print $form->select_dolusers($userid, 'userid', 1, '', 0, '', '', 0, 0, 0, '', 0, '', 'maxwidth300'); @@ -356,8 +367,7 @@ print '
'; // Show graphs print ''; print ''; print ''; - } - else - { + } else { print ''; } print "
'; -if ($mesg) { print $mesg; } -else { +if ($mesg) { print $mesg; } else { print $px1->show(); print "
\n"; print $px2->show(); diff --git a/htdocs/compta/facture/tpl/linkedobjectblock.tpl.php b/htdocs/compta/facture/tpl/linkedobjectblock.tpl.php index a02a0fc1682..ef35c03eb54 100644 --- a/htdocs/compta/facture/tpl/linkedobjectblock.tpl.php +++ b/htdocs/compta/facture/tpl/linkedobjectblock.tpl.php @@ -78,9 +78,7 @@ foreach ($linkedObjectBlock as $key => $objectlink) // If not abandonned $total = $total + $sign * $objectlink->total_ht; echo price($objectlink->total_ht); - } - else - { + } else { echo ''.price($objectlink->total_ht).''; } } diff --git a/htdocs/compta/index.php b/htdocs/compta/index.php index 00b4987ad66..d5daadcb557 100644 --- a/htdocs/compta/index.php +++ b/htdocs/compta/index.php @@ -214,16 +214,12 @@ if (!empty($conf->facture->enabled) && $user->rights->facture->lire) print '
'.$langs->trans("Total").''.price($tot_ttc).'
'.$langs->trans("NoInvoice").'

"; $db->free($resql); - } - else - { + } else { dol_print_error($db); } } @@ -302,16 +298,12 @@ if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SU print '
'.$langs->trans("Total").''.price($tot_ttc).'
'.$langs->trans("NoInvoice").'

"; $db->free($resql); - } - else - { + } else { dol_print_error($db); } } @@ -428,18 +420,14 @@ if (!empty($conf->facture->enabled) && $user->rights->facture->lire) $i++; } - } - else - { + } else { $colspan = 5; if (!empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) $colspan++; print ''.$langs->trans("NoInvoice").''; } print '

'; $db->free($resql); - } - else - { + } else { dol_print_error($db); } } @@ -529,17 +517,13 @@ if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SU $totalam += $obj->am; $i++; } - } - else - { + } else { $colspan = 5; if (!empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) $colspan++; print ''.$langs->trans("NoInvoice").''; } print '
'; - } - else - { + } else { dol_print_error($db); } } @@ -608,14 +592,11 @@ if (!empty($conf->don->enabled) && $user->rights->don->lire) $i++; } - } - else - { + } else { print ''.$langs->trans("None").''; } print '
'; - } - else dol_print_error($db); + } else dol_print_error($db); } /** @@ -686,16 +667,12 @@ if (!empty($conf->tax->enabled) && $user->rights->tax->charges->lire) print ''; print ' '; print ''; - } - else - { + } else { print ''.$langs->trans("None").''; } print "
"; $db->free($resql); - } - else - { + } else { dol_print_error($db); } } @@ -815,9 +792,7 @@ if (!empty($conf->facture->enabled) && !empty($conf->commande->enabled) && $user print '
'; } $db->free($resql); - } - else - { + } else { dol_print_error($db); } } @@ -939,18 +914,14 @@ if (!empty($conf->facture->enabled) && $user->rights->facture->lire) print ''.price($totalam).''; print ' '; print ''; - } - else - { + } else { $colspan = 6; if (!empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) $colspan++; print ''.$langs->trans("NoInvoice").''; } print '
'; $db->free($resql); - } - else - { + } else { dol_print_error($db); } } @@ -1049,17 +1020,13 @@ if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SU print ''.price($totalam).''; print ' '; print ''; - } - else - { + } else { $colspan = 6; if (!empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) $colspan++; print ''.$langs->trans("NoInvoice").''; } print '
'; - } - else - { + } else { dol_print_error($db); } } diff --git a/htdocs/compta/journal/purchasesjournal.php b/htdocs/compta/journal/purchasesjournal.php index 1459bbf2402..78ef32072d6 100644 --- a/htdocs/compta/journal/purchasesjournal.php +++ b/htdocs/compta/journal/purchasesjournal.php @@ -91,7 +91,7 @@ $exportlink = ''; $builddate = dol_now(); $description = $langs->trans("DescPurchasesJournal").'
'; if (!empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) $description .= $langs->trans("DepositsAreNotIncluded"); -else $description .= $langs->trans("DepositsAreIncluded"); +else $description .= $langs->trans("DepositsAreIncluded"); $period = $form->selectDate($date_start, 'date_start', 0, 0, 0, '', 1, 0).' - '.$form->selectDate($date_end, 'date_end', 0, 0, 0, '', 1, 0); report_header($name, '', $period, $periodlink, $description, $builddate, $exportlink); @@ -168,8 +168,7 @@ if ($result) $i++; } -} -else { +} else { dol_print_error($db); } @@ -238,9 +237,7 @@ foreach ($tabfac as $key => $val) { print ''.($mt < 0 ?price(-$mt) : '').""; print ''.($mt >= 0 ?price($mt) : '').""; - } - else - { + } else { print ''.($mt >= 0 ?price($mt) : '').""; print ''.($mt < 0 ?price(-$mt) : '').""; } diff --git a/htdocs/compta/journal/sellsjournal.php b/htdocs/compta/journal/sellsjournal.php index 98bd5e989f7..bd44f6c47cc 100644 --- a/htdocs/compta/journal/sellsjournal.php +++ b/htdocs/compta/journal/sellsjournal.php @@ -93,7 +93,7 @@ $exportlink = ''; $builddate = dol_now(); $description = $langs->trans("DescSellsJournal").'
'; if (!empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) $description .= $langs->trans("DepositsAreNotIncluded"); -else $description .= $langs->trans("DepositsAreIncluded"); +else $description .= $langs->trans("DepositsAreIncluded"); $period = $form->selectDate($date_start, 'date_start', 0, 0, 0, '', 1, 0).' - '.$form->selectDate($date_end, 'date_end', 0, 0, 0, '', 1, 0); report_header($name, '', $period, $periodlink, $description, $builddate, $exportlink); @@ -114,8 +114,7 @@ $sql .= " WHERE f.entity IN (".getEntity('invoice').")"; $sql .= " AND f.fk_statut > 0"; if (!empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) { $sql .= " AND f.type IN (".Facture::TYPE_STANDARD.",".Facture::TYPE_REPLACEMENT.",".Facture::TYPE_CREDIT_NOTE.",".Facture::TYPE_SITUATION.")"; -} -else { +} else { $sql .= " AND f.type IN (".Facture::TYPE_STANDARD.",".Facture::TYPE_STANDARD.",".Facture::TYPE_CREDIT_NOTE.",".Facture::TYPE_DEPOSIT.",".Facture::TYPE_SITUATION.")"; } @@ -195,8 +194,7 @@ if ($result) $tabcompany[$obj->rowid] = array('id'=>$obj->socid, 'name'=>$obj->name, 'client'=>$obj->client); $i++; } -} -else { +} else { dol_print_error($db); } @@ -268,9 +266,7 @@ foreach ($tabfac as $key => $val) { print ''.($mt >= 0 ?price($mt) : '').""; print ''.($mt < 0 ?price(-$mt) : '').""; - } - else - { + } else { print ''.($mt < 0 ?price(-$mt) : '').""; print ''.($mt >= 0 ?price($mt) : '').""; } diff --git a/htdocs/compta/localtax/card.php b/htdocs/compta/localtax/card.php index 51275c7159f..cd7bbfd11c2 100644 --- a/htdocs/compta/localtax/card.php +++ b/htdocs/compta/localtax/card.php @@ -80,9 +80,7 @@ if ($action == 'add' && $_POST["cancel"] <> $langs->trans("Cancel")) $db->commit(); header("Location: list.php?localTaxType=".$lttype); exit; - } - else - { + } else { $db->rollback(); setEventMessages($object->error, $object->errors, 'errors'); $_GET["action"] = "create"; @@ -113,22 +111,16 @@ if ($action == 'delete') $db->commit(); header("Location: ".DOL_URL_ROOT.'/compta/localtax/list.php?localTaxType='.$object->ltt); exit; - } - else - { + } else { $object->error = $accountline->error; $db->rollback(); setEventMessages($object->error, $object->errors, 'errors'); } - } - else - { + } else { $db->rollback(); setEventMessages($object->error, $object->errors, 'errors'); } - } - else - { + } else { $mesg = 'Error try do delete a line linked to a conciliated bank transaction'; setEventMessages($mesg, null, 'errors'); } @@ -289,9 +281,7 @@ if ($id) if ($object->rappro == 0) { print ''.$langs->trans("Delete").''; - } - else - { + } else { print ''.$langs->trans("Delete").''; } print ""; diff --git a/htdocs/compta/localtax/class/localtax.class.php b/htdocs/compta/localtax/class/localtax.class.php index 6aa7c2b1a87..1dfeb0b8930 100644 --- a/htdocs/compta/localtax/class/localtax.class.php +++ b/htdocs/compta/localtax/class/localtax.class.php @@ -137,15 +137,11 @@ class Localtax extends CommonObject { $this->db->commit(); return $this->id; - } - else - { + } else { $this->db->rollback(); return -1; } - } - else - { + } else { $this->error = "Error ".$this->db->lasterror(); $this->db->rollback(); return -1; @@ -206,9 +202,7 @@ class Localtax extends CommonObject { $this->db->commit(); return 1; - } - else - { + } else { $this->db->rollback(); return -1; } @@ -270,9 +264,7 @@ class Localtax extends CommonObject $this->db->free($resql); return 1; - } - else - { + } else { $this->error = "Error ".$this->db->lasterror(); return -1; } @@ -377,15 +369,11 @@ class Localtax extends CommonObject $ret = $obj->amount; $this->db->free($result); return $ret; - } - else - { + } else { $this->db->free($result); return 0; } - } - else - { + } else { print $this->db->lasterror(); return -1; } @@ -418,15 +406,11 @@ class Localtax extends CommonObject $ret = $obj->total_localtax; $this->db->free($result); return $ret; - } - else - { + } else { $this->db->free($result); return 0; } - } - else - { + } else { print $this->db->lasterror(); return -1; } @@ -461,15 +445,11 @@ class Localtax extends CommonObject $ret = $obj->amount; $this->db->free($result); return $ret; - } - else - { + } else { $this->db->free($result); return 0; } - } - else - { + } else { print $this->db->lasterror(); return -1; } @@ -547,9 +527,7 @@ class Localtax extends CommonObject if ($bank_line_id > 0) { $this->update_fk_bank($bank_line_id); - } - else - { + } else { $this->error = $acc->error; $ok = 0; } @@ -567,22 +545,16 @@ class Localtax extends CommonObject { $this->db->commit(); return $this->id; - } - else - { + } else { $this->db->rollback(); return -3; } - } - else - { + } else { $this->error = $this->db->lasterror(); $this->db->rollback(); return -2; } - } - else - { + } else { $this->error = $this->db->lasterror(); $this->db->rollback(); return -1; @@ -604,9 +576,7 @@ class Localtax extends CommonObject $result = $this->db->query($sql); if ($result) { return 1; - } - else - { + } else { dol_print_error($this->db); return -1; } diff --git a/htdocs/compta/localtax/clients.php b/htdocs/compta/localtax/clients.php index 61a11a042f2..10111dd7faa 100644 --- a/htdocs/compta/localtax/clients.php +++ b/htdocs/compta/localtax/clients.php @@ -53,17 +53,13 @@ if (empty($date_start) || empty($date_end)) // We define date_start and date_end $q = GETPOST("q"); if (empty($q)) { - if (GETPOST("month")) { $date_start = dol_get_first_day($year_start, GETPOST("month"), false); $date_end = dol_get_last_day($year_start, GETPOST("month"), false); } - else - { + if (GETPOST("month")) { $date_start = dol_get_first_day($year_start, GETPOST("month"), false); $date_end = dol_get_last_day($year_start, GETPOST("month"), false); } else { $date_start = dol_get_first_day($year_start, empty($conf->global->SOCIETE_FISCAL_MONTH_START) ? 1 : $conf->global->SOCIETE_FISCAL_MONTH_START, false); if (empty($conf->global->MAIN_INFO_VAT_RETURN) || $conf->global->MAIN_INFO_VAT_RETURN == 2) $date_end = dol_time_plus_duree($date_start, 3, 'm') - 1; elseif ($conf->global->MAIN_INFO_VAT_RETURN == 3) $date_end = dol_time_plus_duree($date_start, 1, 'y') - 1; elseif ($conf->global->MAIN_INFO_VAT_RETURN == 1) $date_end = dol_time_plus_duree($date_start, 1, 'm') - 1; } - } - else - { + } else { if ($q == 1) { $date_start = dol_get_first_day($year_start, 1, false); $date_end = dol_get_last_day($year_start, 3, false); } if ($q == 2) { $date_start = dol_get_first_day($year_start, 4, false); $date_end = dol_get_last_day($year_start, 6, false); } if ($q == 3) { $date_start = dol_get_first_day($year_start, 7, false); $date_end = dol_get_last_day($year_start, 9, false); } @@ -201,9 +197,7 @@ if ($calc == 0 || $calc == 2) if ($coll->assuj == '1') { $intra = $langs->trans('Unknown'); - } - else - { + } else { $intra = ''; } } @@ -229,16 +223,13 @@ if ($calc == 0 || $calc == 2) print ''.price($totalamount).''; print ''.price($total).''; print ''; - } - else - { + } else { $langs->load("errors"); if ($coll_list == -1) print ''.$langs->trans("ErrorNoAccountancyModuleLoaded").''; elseif ($coll_list == -2) print ''.$langs->trans("FeatureNotYetAvailable").''; - else - print ''.$langs->trans("Error").''; + else print ''.$langs->trans("Error").''; } } @@ -274,9 +265,7 @@ if ($calc == 0 || $calc == 1) { if ($coll->assuj == '1') { $intra = $langs->trans('Unknown'); - } - else - { + } else { $intra = ''; } } @@ -304,16 +293,13 @@ if ($calc == 0 || $calc == 1) { print ''; print ''; - } - else - { + } else { $langs->load("errors"); if ($coll_list == -1) print ''.$langs->trans("ErrorNoAccountancyModuleLoaded").''; elseif ($coll_list == -2) print ''.$langs->trans("FeatureNotYetAvailable").''; - else - print ''.$langs->trans("Error").''; + else print ''.$langs->trans("Error").''; } } diff --git a/htdocs/compta/localtax/index.php b/htdocs/compta/localtax/index.php index a08ac99d6bd..8e810495ff4 100644 --- a/htdocs/compta/localtax/index.php +++ b/htdocs/compta/localtax/index.php @@ -52,15 +52,11 @@ if (empty($date_start) || empty($date_end)) // We define date_start and date_end $q = GETPOST("q", "int"); if (empty($q)) { - if (GETPOST("month", "int")) { $date_start = dol_get_first_day($year_start, GETPOST("month", "int"), false); $date_end = dol_get_last_day($year_start, GETPOST("month", "int"), false); } - else - { + if (GETPOST("month", "int")) { $date_start = dol_get_first_day($year_start, GETPOST("month", "int"), false); $date_end = dol_get_last_day($year_start, GETPOST("month", "int"), false); } else { $date_start = dol_get_first_day($year_start, $conf->global->SOCIETE_FISCAL_MONTH_START, false); $date_end = dol_time_plus_duree($date_start, 1, 'y') - 1; } - } - else - { + } else { if ($q == 1) { $date_start = dol_get_first_day($year_start, 1, false); $date_end = dol_get_last_day($year_start, 3, false); } if ($q == 2) { $date_start = dol_get_first_day($year_start, 4, false); $date_end = dol_get_last_day($year_start, 6, false); } if ($q == 3) { $date_start = dol_get_first_day($year_start, 7, false); $date_end = dol_get_last_day($year_start, 9, false); } @@ -152,9 +148,7 @@ function pt($db, $sql, $date) $amountpaid = 0; $previousmode = ''; $previousmonth = ''; - } - else - { + } else { $previousmode = $obj->mode; $previousmonth = $obj->dm; } @@ -182,8 +176,7 @@ function pt($db, $sql, $date) print ""; $db->free($result); - } - else { + } else { dol_print_error($db); } } @@ -388,9 +381,7 @@ while ((($y < $yend) || ($y == $yend && $m <= $mend)) && $mcursor < 1000) // $mc 'localtax2' =>$x_paye[$my_paye_rate]['localtax2_list'][$id], //'link' =>$expensereport->getNomUrl(1) ); - } - else - { + } else { //$invoice_supplier->id=$x_paye[$my_paye_rate]['facid'][$id]; //$invoice_supplier->ref=$x_paye[$my_paye_rate]['facnum'][$id]; //$invoice_supplier->type=$x_paye[$my_paye_rate]['type'][$id]; diff --git a/htdocs/compta/localtax/list.php b/htdocs/compta/localtax/list.php index 47a0f44be47..a8b37c3ef93 100644 --- a/htdocs/compta/localtax/list.php +++ b/htdocs/compta/localtax/list.php @@ -95,9 +95,7 @@ if ($result) print ""; $db->free($result); -} -else -{ +} else { dol_print_error($db); } diff --git a/htdocs/compta/localtax/quadri_detail.php b/htdocs/compta/localtax/quadri_detail.php index 8e2e871251f..058f6871c7d 100644 --- a/htdocs/compta/localtax/quadri_detail.php +++ b/htdocs/compta/localtax/quadri_detail.php @@ -63,17 +63,13 @@ if (empty($date_start) || empty($date_end)) // We define date_start and date_end $q = GETPOST("q", "int"); if (empty($q)) { - if (GETPOST("month", "int")) { $date_start = dol_get_first_day($year_start, GETPOST("month", "int"), false); $date_end = dol_get_last_day($year_start, GETPOST("month", "int"), false); } - else - { + if (GETPOST("month", "int")) { $date_start = dol_get_first_day($year_start, GETPOST("month", "int"), false); $date_end = dol_get_last_day($year_start, GETPOST("month", "int"), false); } else { $date_start = dol_get_first_day($year_start, empty($conf->global->SOCIETE_FISCAL_MONTH_START) ? 1 : $conf->global->SOCIETE_FISCAL_MONTH_START, false); if (empty($conf->global->MAIN_INFO_VAT_RETURN) || $conf->global->MAIN_INFO_VAT_RETURN == 2) $date_end = dol_time_plus_duree($date_start, 3, 'm') - 1; elseif ($conf->global->MAIN_INFO_VAT_RETURN == 3) $date_end = dol_time_plus_duree($date_start, 1, 'y') - 1; elseif ($conf->global->MAIN_INFO_VAT_RETURN == 1) $date_end = dol_time_plus_duree($date_start, 1, 'm') - 1; } - } - else - { + } else { if ($q == 1) { $date_start = dol_get_first_day($year_start, 1, false); $date_end = dol_get_last_day($year_start, 3, false); } if ($q == 2) { $date_start = dol_get_first_day($year_start, 4, false); $date_end = dol_get_last_day($year_start, 6, false); } if ($q == 3) { $date_start = dol_get_first_day($year_start, 7, false); $date_end = dol_get_last_day($year_start, 9, false); } @@ -222,11 +218,8 @@ if (!is_array($x_coll) || !is_array($x_paye)) print ''.$langs->trans("ErrorNoAccountancyModuleLoaded").''; elseif ($x_coll == -2) print ''.$langs->trans("FeatureNotYetAvailable").''; - else - print ''.$langs->trans("Error").''; -} -else -{ + else print ''.$langs->trans("Error").''; +} else { $x_both = array(); //now, from these two arrays, get another array with one rate per line @@ -372,9 +365,7 @@ else $product_static->type = $fields['ptype']; print $product_static->getNomUrl(1); if (dol_string_nohtmltag($fields['descr'])) print ' - '.dol_trunc(dol_string_nohtmltag($fields['descr']), 16); - } - else - { + } else { if ($type) $text = img_object($langs->trans('Service'), 'service'); else $text = img_object($langs->trans('Product'), 'product'); if (preg_match('/^\((.*)\)$/', $fields['descr'], $reg)) @@ -416,8 +407,7 @@ else if ($type == 0) { print $langs->trans("NotUsedForGoods"); - } - else { + } else { print price($fields['payment_amount']); if (isset($fields['payment_amount'])) print ' ('.round($ratiopaymentinvoice * 100, 2).'%)'; } @@ -532,9 +522,7 @@ else $product_static->type = $fields['ptype']; print $product_static->getNomUrl(1); if (dol_string_nohtmltag($fields['descr'])) print ' - '.dol_trunc(dol_string_nohtmltag($fields['descr']), 16); - } - else - { + } else { if ($type) $text = img_object($langs->trans('Service'), 'service'); else $text = img_object($langs->trans('Product'), 'product'); print $text.' '.dol_trunc(dol_string_nohtmltag($fields['descr']), 16); @@ -572,9 +560,7 @@ else if ($type == 0) { print $langs->trans("NA"); - } - else - { + } else { print price(price2num($fields['payment_amount'], 'MT')); if (isset($fields['payment_amount'])) { print ' ('.round($ratiopaymentinvoice * 100, 2).'%)'; diff --git a/htdocs/compta/paiement.php b/htdocs/compta/paiement.php index 4a7e387987c..4eea16f706b 100644 --- a/htdocs/compta/paiement.php +++ b/htdocs/compta/paiement.php @@ -131,8 +131,7 @@ if (empty($reshook)) } $formquestion[$i++] = array('type' => 'hidden', 'name' => $key, 'value' => $_POST[$key]); - } - elseif (substr($key, 0, 21) == 'multicurrency_amount_') + } elseif (substr($key, 0, 21) == 'multicurrency_amount_') { $cursorfacid = substr($key, 21); $multicurrency_amounts[$cursorfacid] = price2num(trim(GETPOST($key))); @@ -312,9 +311,7 @@ if (empty($reshook)) else $loc = DOL_URL_ROOT.'/compta/paiement/card.php?id='.$paiement_id; header('Location: '.$loc); exit; - } - else - { + } else { $db->rollback(); } } @@ -503,9 +500,7 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie print ''; $form->select_comptes($accountid, 'accountid', 0, '', 2); print ''; - } - else - { + } else { print ' '; } print "\n"; @@ -560,9 +555,7 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie if ($facture->type != Facture::TYPE_CREDIT_NOTE) { $sql .= ' AND type IN (0,1,3,5)'; // Standard invoice, replacement, deposit, situation - } - else - { + } else { $sql .= ' AND type = 2'; // If paying back a credit note, we show all credit notes } // Sort invoices by date and serial number: the older one comes first @@ -665,9 +658,7 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie } print ''; - } - else - { + } else { print ''; } @@ -710,9 +701,7 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie print img_picto("Auto fill", 'rightarrow', "class='AutoFillAmout' data-rowname='".$namef."' data-value='".($sign * $multicurrency_remaintopay)."'"); print ''; print ''; - } - else - { + } else { print ''; print ''; } @@ -746,9 +735,7 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie print img_picto("Auto fill", 'rightarrow', "class='AutoFillAmout' data-rowname='".$namef."' data-value='".($sign * $remaintopay)."'"); print ''; print ''; - } - else - { + } else { print ''; print ''; } @@ -803,9 +790,7 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie //print "\n"; } $db->free($resql); - } - else - { + } else { dol_print_error($db); } diff --git a/htdocs/compta/paiement/card.php b/htdocs/compta/paiement/card.php index 29d6f982d59..4acfd34a53a 100644 --- a/htdocs/compta/paiement/card.php +++ b/htdocs/compta/paiement/card.php @@ -65,9 +65,7 @@ if ($action == 'setnote' && $user->rights->facture->paiement) { $db->commit(); $action = ''; - } - else - { + } else { setEventMessages($object->error, $object->errors, 'errors'); $db->rollback(); } @@ -87,15 +85,11 @@ if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->facture-> { header("Location: ".$backtopage); exit; - } - else - { + } else { header("Location: list.php"); exit; } - } - else - { + } else { $langs->load("errors"); setEventMessages($object->error, $object->errors, 'errors'); $db->rollback(); @@ -131,9 +125,7 @@ if ($action == 'confirm_valide' && $confirm == 'yes' && $user->rights->facture-> header('Location: '.$_SERVER['PHP_SELF'].'?id='.$object->id); exit; - } - else - { + } else { $langs->load("errors"); setEventMessages($object->error, $object->errors, 'errors'); $db->rollback(); @@ -147,9 +139,7 @@ if ($action == 'setnum_paiement' && !empty($_POST['num_paiement'])) if ($res === 0) { setEventMessages($langs->trans('PaymentNumberUpdateSucceeded'), null, 'mesgs'); - } - else - { + } else { setEventMessages($langs->trans('PaymentNumberUpdateFailed'), null, 'errors'); } } @@ -162,9 +152,7 @@ if ($action == 'setdatep' && !empty($_POST['datepday'])) if ($res === 0) { setEventMessages($langs->trans('PaymentDateUpdateSucceeded'), null, 'mesgs'); - } - else - { + } else { setEventMessages($langs->trans('PaymentDateUpdateFailed'), null, 'errors'); } } @@ -342,7 +330,7 @@ if ($resql) print ''; print ''.$langs->trans('Bill').''; print ''.$langs->trans('Company').''; - if ($conf->global->MULTICOMPANY_INVOICE_SHARING_ENABLED)print ''.$langs->trans('Entity').''; + if (!empty($conf->multicompany->enabled) && !empty($conf->global->MULTICOMPANY_INVOICE_SHARING_ENABLED)) print ''.$langs->trans('Entity').''; print ''.$langs->trans('ExpectedToPay').''; print ''.$langs->trans('PayedByThisPayment').''; print ''.$langs->trans('RemainderToPay').''; @@ -379,7 +367,7 @@ if ($resql) print ''; // Expected to pay - if ($conf->global->MULTICOMPANY_INVOICE_SHARING_ENABLED) { + if (!empty($conf->multicompany->enabled) && !empty($conf->global->MULTICOMPANY_INVOICE_SHARING_ENABLED)) { print ''; $mc->getInfo($objp->entity); print $mc->label; @@ -413,9 +401,7 @@ if ($resql) print ''; $db->free($resql); -} -else -{ +} else { dol_print_error($db); } @@ -445,9 +431,7 @@ if ($user->socid == 0 && $action == '') if (!$disable_delete) { print ''.$langs->trans('Delete').''; - } - else - { + } else { print ''.$langs->trans('Delete').''; } } diff --git a/htdocs/compta/paiement/cheque/card.php b/htdocs/compta/paiement/cheque/card.php index eeb578ad731..4b1c1637c89 100644 --- a/htdocs/compta/paiement/cheque/card.php +++ b/htdocs/compta/paiement/cheque/card.php @@ -79,9 +79,7 @@ if ($action == 'setdate' && $user->rights->banque->cheque) { setEventMessages($object->error, $object->errors, 'errors'); } - } - else - { + } else { setEventMessages($object->error, $object->errors, 'errors'); } } @@ -98,9 +96,7 @@ if ($action == 'setrefext' && $user->rights->banque->cheque) { setEventMessages($object->error, $object->errors, 'errors'); } - } - else - { + } else { setEventMessages($object->error, $object->errors, 'errors'); } } @@ -117,9 +113,7 @@ if ($action == 'setref' && $user->rights->banque->cheque) { setEventMessages($object->error, $object->errors, 'errors'); } - } - else - { + } else { setEventMessages($object->error, $object->errors, 'errors'); } } @@ -149,14 +143,10 @@ if ($action == 'create' && $_POST["accountid"] > 0 && $user->rights->banque->che header("Location: ".$_SERVER["PHP_SELF"]."?id=".$object->id); exit; - } - else - { + } else { setEventMessages($object->error, $object->errors, 'errors'); } - } - else - { + } else { setEventMessages($langs->trans("ErrorSelectAtLeastOne"), null, 'mesgs'); $action = 'new'; } @@ -170,9 +160,7 @@ if ($action == 'remove' && $id > 0 && $_GET["lineid"] > 0 && $user->rights->banq { header("Location: ".$_SERVER["PHP_SELF"]."?id=".$object->id); exit; - } - else - { + } else { setEventMessages($object->error, $object->errors, 'errors'); } } @@ -185,9 +173,7 @@ if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->banque->c { header("Location: index.php"); exit; - } - else - { + } else { setEventMessages($paiement->error, $paiement->errors, 'errors'); } } @@ -212,9 +198,7 @@ if ($action == 'confirm_valide' && $confirm == 'yes' && $user->rights->banque->c header("Location: ".$_SERVER["PHP_SELF"]."?id=".$object->id); exit; - } - else - { + } else { setEventMessages($object->error, $object->errors, 'errors'); } } @@ -232,9 +216,7 @@ if ($action == 'confirm_reject_check' && $confirm == 'yes' && $user->rights->ban //header("Location: ".DOL_URL_ROOT.'/compta/paiement/card.php?id='.$paiement_id); //exit; $action = ''; - } - else - { + } else { setEventMessages($object->error, $object->errors, 'errors'); $action = ''; } @@ -261,15 +243,11 @@ if ($action == 'builddoc' && $user->rights->banque->cheque) { dol_print_error($db, $object->error); exit; - } - else - { + } else { header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id.(empty($conf->global->MAIN_JUMP_TAG) ? '' : '#builddoc')); exit; } -} - -// Remove file in doc form +} // Remove file in doc form elseif ($action == 'remove_file' && $user->rights->banque->cheque) { if ($object->fetch($id) > 0) @@ -314,9 +292,7 @@ if ($action == 'new') $h++; print load_fiche_titre($langs->trans("Cheques"), '', 'bank_account'); -} -else -{ +} else { $result = $object->fetch($id, $ref); if ($result < 0) { @@ -509,9 +485,7 @@ if ($action == 'new') if ($paymentstatic->id) { print $paymentstatic->getNomUrl(1); - } - else - { + } else { print ' '; } print ''; @@ -521,9 +495,7 @@ if ($action == 'new') if ($accountlinestatic->rowid) { print $accountlinestatic->getNomUrl(1); - } - else - { + } else { print ' '; } print ''; @@ -543,17 +515,13 @@ if ($action == 'new') if ($user->rights->banque->cheque) { print ''; - } - else - { + } else { print ''.$langs->trans('NewCheckDepositOn', $account_label).''; } print '
'; print ''; } -} -else -{ +} else { $paymentstatic = new Paiement($db); $accountlinestatic = new AccountLine($db); $accountstatic = new Account($db); @@ -587,9 +555,7 @@ else print $form->selectDate($object->date_bordereau, 'datecreate_', '', '', '', "setdate"); print ''; print ''; - } - else - { + } else { print $object->date_bordereau ? dol_print_date($object->date_bordereau, 'day') : ' '; } @@ -699,9 +665,7 @@ else if ($paymentstatic->id) { print $paymentstatic->getNomUrl(1); - } - else - { + } else { print ' '; } print ''; @@ -711,9 +675,7 @@ else if ($accountlinestatic->rowid) { print $accountlinestatic->getNomUrl(1); - } - else - { + } else { print ' '; } print ''; @@ -736,9 +698,7 @@ else $i++; } - } - else - { + } else { print ''; print $langs->trans("None"); print ''; @@ -755,9 +715,7 @@ else } print ""; - } - else - { + } else { dol_print_error($db); } diff --git a/htdocs/compta/paiement/cheque/class/remisecheque.class.php b/htdocs/compta/paiement/cheque/class/remisecheque.class.php index 746065647d5..48c58dc7219 100644 --- a/htdocs/compta/paiement/cheque/class/remisecheque.class.php +++ b/htdocs/compta/paiement/cheque/class/remisecheque.class.php @@ -120,18 +120,14 @@ class RemiseCheque extends CommonObject if ($this->statut == 0) { $this->ref = "(PROV".$this->id.")"; - } - else - { + } else { $this->ref = $obj->ref; } } $this->db->free($resql); return 1; - } - else - { + } else { $this->error = $this->db->lasterror(); return -1; } @@ -227,9 +223,7 @@ class RemiseCheque extends CommonObject array_push($lines, $row[0]); } $this->db->free($resql); - } - else - { + } else { $this->errno = -1026; dol_syslog("RemiseCheque::Create Error ".$this->errno, LOG_ERR); } @@ -269,9 +263,7 @@ class RemiseCheque extends CommonObject dol_syslog("RemiseCheque::Create Error update amount ".$this->errno, LOG_ERR); } } - } - else - { + } else { $this->errno = -1; $this->error = $this->db->lasterror(); $this->errno = $this->db->lasterrno(); @@ -288,9 +280,7 @@ class RemiseCheque extends CommonObject $this->db->commit(); dol_syslog("RemiseCheque::Create end", LOG_DEBUG); return $this->id; - } - else - { + } else { $this->db->rollback(); dol_syslog("RemiseCheque::Create end", LOG_DEBUG); return $this->errno; @@ -341,9 +331,7 @@ class RemiseCheque extends CommonObject if ($this->errno === 0) { $this->db->commit(); - } - else - { + } else { $this->db->rollback(); dol_syslog("RemiseCheque::Delete ROLLBACK ($this->errno)"); } @@ -385,15 +373,11 @@ class RemiseCheque extends CommonObject { $this->ref = $numref; $this->statut = 1; - } - else - { + } else { $this->errno = -1029; dol_syslog("Remisecheque::Validate Error ".$this->errno, LOG_ERR); } - } - else - { + } else { $this->errno = -1033; dol_syslog("Remisecheque::Validate Error ".$this->errno, LOG_ERR); } @@ -404,9 +388,7 @@ class RemiseCheque extends CommonObject { $this->db->commit(); return 1; - } - else - { + } else { $this->db->rollback(); dol_syslog("RemiseCheque::Validate ".$this->errno, LOG_ERR); return $this->errno; @@ -488,9 +470,7 @@ class RemiseCheque extends CommonObject } return $numref; - } - else - { + } else { $langs->load("errors"); print $langs->trans("Error")." ".$langs->trans("ErrorModuleSetupNotComplete", $langs->transnoentitiesnoconv("Bank")); return ""; @@ -544,9 +524,7 @@ class RemiseCheque extends CommonObject } return $response; - } - else - { + } else { dol_print_error($this->db); $this->error = $this->db->error(); return -1; @@ -584,9 +562,7 @@ class RemiseCheque extends CommonObject } $this->db->free($resql); return 1; - } - else - { + } else { dol_print_error($this->db); $this->error = $this->db->error(); return -1; @@ -664,17 +640,13 @@ class RemiseCheque extends CommonObject { //$outputlangs->charset_output=$sav_charset_output; return 1; - } - else - { + } else { //$outputlangs->charset_output=$sav_charset_output; dol_syslog("Error"); dol_print_error($this->db, $docmodel->error); return 0; } - } - else - { + } else { $this->error = $langs->trans("ErrorFileDoesNotExists", $dir.$file); return -1; } @@ -720,9 +692,7 @@ class RemiseCheque extends CommonObject $this->errno = -1030; dol_syslog("RemiseCheque::updateAmount ERREUR UPDATE ($this->errno)"); } - } - else - { + } else { $this->errno = -1031; dol_syslog("RemiseCheque::updateAmount ERREUR SELECT ($this->errno)"); } @@ -730,9 +700,7 @@ class RemiseCheque extends CommonObject if ($this->errno === 0) { $this->db->commit(); - } - else - { + } else { $this->db->rollback(); dol_syslog("RemiseCheque::updateAmount ROLLBACK ($this->errno)"); } @@ -761,9 +729,7 @@ class RemiseCheque extends CommonObject if ($resql) { $this->updateAmount(); - } - else - { + } else { $this->errno = -1032; dol_syslog("RemiseCheque::removeCheck ERREUR UPDATE ($this->errno)"); } @@ -838,31 +804,23 @@ class RemiseCheque extends CommonObject { $this->db->commit(); return $rejectedPayment->id; - } - else - { + } else { $this->db->rollback(); return -1; } - } - else - { + } else { $this->error = $rejectedPayment->error; $this->errors = $rejectedPayment->errors; $this->db->rollback(); return -1; } - } - else - { + } else { $this->error = $rejectedPayment->error; $this->errors = $rejectedPayment->errors; $this->db->rollback(); return -1; } - } - else - { + } else { $this->error = $this->db->lasterror(); $this->db->rollback(); return -1; @@ -935,15 +893,11 @@ class RemiseCheque extends CommonObject { $this->date_bordereau = $date; return 1; - } - else - { + } else { $this->error = $this->db->error(); return -1; } - } - else - { + } else { return -2; } } @@ -970,15 +924,11 @@ class RemiseCheque extends CommonObject if ($resql) { return 1; - } - else - { + } else { $this->error = $this->db->error(); return -1; } - } - else - { + } else { return -2; } } @@ -1046,8 +996,7 @@ class RemiseCheque extends CommonObject } $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"'; $linkclose .= ' class="classfortooltip'.($morecss ? ' '.$morecss : '').'"'; - } - else $linkclose = ($morecss ? ' class="'.$morecss.'"' : ''); + } else $linkclose = ($morecss ? ' class="'.$morecss.'"' : ''); $linkstart = ''; diff --git a/htdocs/compta/paiement/cheque/index.php b/htdocs/compta/paiement/cheque/index.php index c85553d59a8..1ee79aeafd9 100644 --- a/htdocs/compta/paiement/cheque/index.php +++ b/htdocs/compta/paiement/cheque/index.php @@ -76,9 +76,7 @@ if ($resql) { print ''.$num.''; print ''; print "\n"; -} -else -{ +} else { dol_print_error($db); } @@ -140,9 +138,7 @@ if ($resql) print ""; $db->free($resql); -} -else -{ +} else { dol_print_error($db); } diff --git a/htdocs/compta/paiement/cheque/list.php b/htdocs/compta/paiement/cheque/list.php index fe1f7c31050..e76936c71fd 100644 --- a/htdocs/compta/paiement/cheque/list.php +++ b/htdocs/compta/paiement/cheque/list.php @@ -221,9 +221,7 @@ if ($resql) print "\n"; $i++; } - } - else - { + } else { print ''; print ''.$langs->trans("None").""; print ''; @@ -231,9 +229,7 @@ if ($resql) print ""; print ""; print "\n"; -} -else -{ +} else { dol_print_error($db); } diff --git a/htdocs/compta/paiement/class/paiement.class.php b/htdocs/compta/paiement/class/paiement.class.php index 9b0ee645fc7..f57e4408a6f 100644 --- a/htdocs/compta/paiement/class/paiement.class.php +++ b/htdocs/compta/paiement/class/paiement.class.php @@ -200,15 +200,11 @@ class Paiement extends CommonObject $this->db->free($resql); return 1; - } - else - { + } else { $this->db->free($resql); return 0; } - } - else - { + } else { dol_print_error($this->db); return -1; } @@ -242,9 +238,7 @@ class Paiement extends CommonObject { $amounts = &$this->amounts; $amounts_to_update = &$this->multicurrency_amounts; - } - else - { + } else { $amounts = &$this->multicurrency_amounts; $amounts_to_update = &$this->amounts; } @@ -282,9 +276,7 @@ class Paiement extends CommonObject { $total = $totalamount; $mtotal = $totalamount_converted; // Maybe use price2num with MT for the converted value - } - else - { + } else { $total = $totalamount_converted; // Maybe use price2num with MT for the converted value $mtotal = $totalamount; } @@ -340,8 +332,7 @@ class Paiement extends CommonObject if (!in_array($invoice->type, $affected_types)) dol_syslog("Invoice ".$facid." is not a standard, nor replacement invoice, nor credit note, nor deposit invoice, nor situation invoice. We do nothing more."); elseif ($remaintopay) dol_syslog("Remain to pay for invoice ".$facid." not null. We do nothing more."); //else if ($mustwait) dol_syslog("There is ".$mustwait." differed payment to process, we do nothing more."); - else - { + else { // If invoice is a down payment, we also convert down payment to discount if ($invoice->type == Facture::TYPE_DEPOSIT) { @@ -429,15 +420,11 @@ class Paiement extends CommonObject $error++; } } - } - else - { + } else { $this->error = $this->db->lasterror(); $error++; } - } - else - { + } else { dol_syslog(get_class($this).'::Create Amount line '.$key.' not a number. We discard it.'); } } @@ -449,9 +436,7 @@ class Paiement extends CommonObject if ($result < 0) { $error++; } // Fin appel triggers } - } - else - { + } else { $this->error = $this->db->lasterror(); $error++; } @@ -463,9 +448,7 @@ class Paiement extends CommonObject $this->multicurrency_amount = $mtotal; $this->db->commit(); return $this->id; - } - else - { + } else { $this->db->rollback(); return -1; } @@ -501,9 +484,7 @@ class Paiement extends CommonObject $this->db->rollback(); return -1; } - } - else - { + } else { $this->db->rollback(); return -2; } @@ -567,9 +548,7 @@ class Paiement extends CommonObject $this->db->commit(); return 1; - } - else - { + } else { $this->error = $this->db->error; $this->db->rollback(); return -5; @@ -730,9 +709,7 @@ class Paiement extends CommonObject if ($result < 0) { $error++; } // Fin appel triggers } - } - else - { + } else { $this->error = $acc->error; $error++; } @@ -740,9 +717,7 @@ class Paiement extends CommonObject if (!$error) { $this->db->commit(); - } - else - { + } else { $this->db->rollback(); } } @@ -750,9 +725,7 @@ class Paiement extends CommonObject if (!$error) { return $bank_line_id; - } - else - { + } else { return -1; } } @@ -776,9 +749,7 @@ class Paiement extends CommonObject if ($result) { return 1; - } - else - { + } else { $this->error = $this->db->lasterror(); dol_syslog(get_class($this).'::update_fk_bank '.$this->error); return -1; @@ -839,9 +810,7 @@ class Paiement extends CommonObject $this->db->commit(); return 0; - } - else - { + } else { $this->db->rollback(); return -2; } @@ -870,9 +839,7 @@ class Paiement extends CommonObject { $this->num_payment = $this->db->escape($num); return 0; - } - else - { + } else { $this->error = 'Error -1 '.$this->db->error(); return -2; } @@ -895,9 +862,7 @@ class Paiement extends CommonObject if ($result) { return 1; - } - else - { + } else { $this->error = $this->db->lasterror(); dol_syslog(get_class($this).'::valide '.$this->error); return -1; @@ -919,9 +884,7 @@ class Paiement extends CommonObject if ($result) { return 1; - } - else - { + } else { $this->error = $this->db->lasterror(); dol_syslog(get_class($this).'::reject '.$this->error); return -1; @@ -965,9 +928,7 @@ class Paiement extends CommonObject $this->date_modification = $this->db->jdate($obj->tms); } $this->db->free($result); - } - else - { + } else { dol_print_error($this->db); } } @@ -999,9 +960,7 @@ class Paiement extends CommonObject } return $billsarray; - } - else - { + } else { $this->error = $this->db->error(); dol_syslog(get_class($this).'::getBillsArray Error '.$this->error.' -', LOG_DEBUG); return -1; @@ -1033,9 +992,7 @@ class Paiement extends CommonObject } return $amounts; - } - else - { + } else { $this->error = $this->db->error(); dol_syslog(get_class($this).'::getAmountsArray Error '.$this->error.' -', LOG_DEBUG); return -1; @@ -1118,9 +1075,7 @@ class Paiement extends CommonObject } return $numref; - } - else - { + } else { $langs->load("errors"); print $langs->trans("Error")." ".$langs->trans("ErrorModuleSetupNotComplete", $langs->transnoentitiesnoconv("Invoice")); return ""; @@ -1221,8 +1176,7 @@ class Paiement extends CommonObject } $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"'; $linkclose .= ' class="classfortooltip'.($morecss ? ' '.$morecss : '').'"'; - } - else $linkclose = ($morecss ? ' class="'.$morecss.'"' : ''); + } else $linkclose = ($morecss ? ' class="'.$morecss.'"' : ''); $url = DOL_URL_ROOT.'/compta/paiement/card.php?id='.$this->id; diff --git a/htdocs/compta/paiement/list.php b/htdocs/compta/paiement/list.php index 20401d81a1a..eb2523960f3 100644 --- a/htdocs/compta/paiement/list.php +++ b/htdocs/compta/paiement/list.php @@ -129,9 +129,7 @@ if (GETPOST("orphelins", "alpha")) $parameters = array(); $reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook $sql .= $hookmanager->resPrint; -} -else -{ +} else { $sql = "SELECT DISTINCT p.rowid, p.ref, p.datep as dp, p.amount,"; // DISTINCT is to avoid duplicate when there is a link to sales representatives $sql .= " p.statut, p.num_paiement as num_payment,"; $sql .= " c.code as paiement_code,"; @@ -161,7 +159,7 @@ else if ($userid) { if ($userid == -1) $sql .= " AND f.fk_user_author IS NULL"; - else $sql .= " AND f.fk_user_author = ".$userid; + else $sql .= " AND f.fk_user_author = ".$userid; } // Search criteria $sql .= dolSqlDateFilter("p.datep", $day, $month, $year); @@ -378,9 +376,7 @@ if ($resql) print "\n"; print ""; print "\n"; -} -else -{ +} else { dol_print_error($db); } diff --git a/htdocs/compta/paiement/rapport.php b/htdocs/compta/paiement/rapport.php index 80013d3d865..9d3bae3140d 100644 --- a/htdocs/compta/paiement/rapport.php +++ b/htdocs/compta/paiement/rapport.php @@ -2,6 +2,7 @@ /* Copyright (C) 2003-2006 Rodolphe Quiedeville * Copyright (C) 2004-2014 Laurent Destailleur * Copyright (C) 2015 Jean-François Ferry + * Copyright (C) 2020 Maxime DEMAREST * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -26,6 +27,7 @@ require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/modules/rapport/pdf_paiement.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; // Security check @@ -68,9 +70,7 @@ if ($action == 'builddoc') if ($rap->write_file($dir, $_POST["remonth"], $_POST["reyear"], $outputlangs) > 0) { $outputlangs->charset_output = $sav_charset_output; - } - else - { + } else { $outputlangs->charset_output = $sav_charset_output; dol_print_error($db, $obj->error); } @@ -84,6 +84,7 @@ if ($action == 'builddoc') */ $formother = new FormOther($db); +$formfile = new FormFile($db); llxHeader(); @@ -155,7 +156,7 @@ if ($year) $tfile = $dir.'/'.$year.'/'.$file; $relativepath = $year.'/'.$file; print ''; - print ''.img_pdf().' '.$file.''; + print ''.img_pdf().' '.$file.''.$formfile->showPreview($file, 'facture_paiement', $relativepath, 0).''; print ''.dol_print_size(dol_filesize($tfile)).''; print ''.dol_print_date(dol_filemtime($tfile), "dayhour").''; print ''; diff --git a/htdocs/compta/paiement/tovalidate.php b/htdocs/compta/paiement/tovalidate.php index 91ef2c215e6..349c483a5db 100644 --- a/htdocs/compta/paiement/tovalidate.php +++ b/htdocs/compta/paiement/tovalidate.php @@ -126,9 +126,7 @@ if ($resql) if ($objp->statut == 0) { print ''.$langs->trans("PaymentStatusToValidShort").''; - } - else - { + } else { print "-"; } diff --git a/htdocs/compta/paiement_charge.php b/htdocs/compta/paiement_charge.php index 509e20f3613..9c5ceea22bf 100644 --- a/htdocs/compta/paiement_charge.php +++ b/htdocs/compta/paiement_charge.php @@ -141,9 +141,7 @@ if ($action == 'add_payment' || ($action == 'confirm_paiement' && $confirm == 'y $loc = DOL_URL_ROOT.'/compta/sociales/card.php?id='.$chid; header('Location: '.$loc); exit; - } - else - { + } else { $db->rollback(); } } @@ -283,9 +281,7 @@ if ($action == 'create') if ($objp->date_ech > 0) { print ''.dol_print_date($objp->date_ech, 'day').''."\n"; - } - else - { + } else { print "!!!\n"; } @@ -305,9 +301,7 @@ if ($action == 'create') $remaintopay = $objp->amount - $sumpaid; print ''; print ''; - } - else - { + } else { print '-'; } print ""; diff --git a/htdocs/compta/payment_sc/card.php b/htdocs/compta/payment_sc/card.php index bf790bb9a9d..fbe5d926d33 100644 --- a/htdocs/compta/payment_sc/card.php +++ b/htdocs/compta/payment_sc/card.php @@ -66,9 +66,7 @@ if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->tax->char $db->commit(); header("Location: ".DOL_URL_ROOT."/compta/sociales/payments.php?mode=sconly"); exit; - } - else - { + } else { setEventMessages($object->error, $object->errors, 'errors'); $db->rollback(); } @@ -128,7 +126,7 @@ $form = new Form($db); $h = 0; $head[$h][0] = DOL_URL_ROOT.'/compta/payment_sc/card.php?id='.$id; -$head[$h][1] = $langs->trans("Card"); +$head[$h][1] = $langs->trans("PaymentSocialContribution"); $hselected = $h; $h++; @@ -283,9 +281,7 @@ if ($resql) print "\n"; $db->free($resql); -} -else -{ +} else { dol_print_error($db); } @@ -316,9 +312,7 @@ if ($action == '') if (!$disable_delete) { print ''.$langs->trans('Delete').''; - } - else - { + } else { print ''.$langs->trans('Delete').''; } } diff --git a/htdocs/compta/paymentbybanktransfer/index.php b/htdocs/compta/paymentbybanktransfer/index.php new file mode 100644 index 00000000000..63769e2bd9e --- /dev/null +++ b/htdocs/compta/paymentbybanktransfer/index.php @@ -0,0 +1,228 @@ + + * Copyright (C) 2005-2020 Laurent Destailleur + * Copyright (C) 2005-2009 Regis Houssin + * Copyright (C) 2011 Juanjo Menent + * Copyright (C) 2013 Florian Henry + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** + * \file htdocs/compta/paymentbybanktransfer/index.php + * \ingroup paymentbybanktransfer + * \brief Payment by bank transfer index page + */ + + +require '../../main.inc.php'; +require_once DOL_DOCUMENT_ROOT.'/compta/prelevement/class/bonprelevement.class.php'; +require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; +require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/prelevement.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; + +// Load translation files required by the page +$langs->loadLangs(array('banks', 'categories', 'withdrawals')); + +// Security check +$socid = GETPOST('socid', 'int'); +if ($user->socid) $socid = $user->socid; +$result = restrictedArea($user, 'paymentbybanktransfer', '', ''); + + +/* + * Actions + */ + + + + +/* + * View + */ + +llxHeader('', $langs->trans("SuppliersStandingOrdersArea")); + +if (prelevement_check_config() < 0) +{ + $langs->load("errors"); + setEventMessages($langs->trans("ErrorModuleSetupNotComplete", $langs->transnoentitiesnoconv("Withdraw")), null, 'errors'); +} + +print load_fiche_titre($langs->trans("SuppliersStandingOrdersArea")); + + +print '
'; + + +$thirdpartystatic = new Societe($db); +$invoicestatic = new Facture($db); +$bprev = new BonPrelevement($db); + +print '
'; +print ''; +print ''; + +print ''; +print ''; + +print ''; +print '
'.$langs->trans("Statistics").'
'.$langs->trans("NbOfInvoiceToWithdraw").''; +print ''; +print $bprev->NbFactureAPrelever(); +print ''; +print '
'.$langs->trans("AmountToWithdraw").''; +print price($bprev->SommeAPrelever(), '', '', 1, -1, -1, 'auto'); +print '

'; + + + +/* + * Invoices waiting for withdraw + */ +$sql = "SELECT f.ref, f.rowid, f.total_ttc, f.fk_statut, f.paye, f.type,"; +$sql .= " pfd.date_demande, pfd.amount,"; +$sql .= " s.nom as name, s.rowid as socid"; +$sql .= " FROM ".MAIN_DB_PREFIX."facture as f,"; +$sql .= " ".MAIN_DB_PREFIX."societe as s"; +if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; +$sql .= " , ".MAIN_DB_PREFIX."prelevement_facture_demande as pfd"; +$sql .= " WHERE s.rowid = f.fk_soc"; +$sql .= " AND f.entity IN (".getEntity('invoice').")"; +$sql .= " AND f.total_ttc > 0"; +if (empty($conf->global->WITHDRAWAL_ALLOW_ANY_INVOICE_STATUS)) +{ + $sql .= " AND f.fk_statut = ".Facture::STATUS_VALIDATED; +} +$sql .= " AND pfd.traite = 0 AND pfd.fk_facture_fourn = f.rowid"; +if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; +if ($socid) $sql .= " AND f.fk_soc = ".$socid; + +$resql = $db->query($sql); +if ($resql) +{ + $num = $db->num_rows($resql); + $i = 0; + + print '
'; + print ''; + print ''; + print ''; + if ($num) + { + while ($i < $num && $i < 20) + { + $obj = $db->fetch_object($resql); + + $invoicestatic->id = $obj->rowid; + $invoicestatic->ref = $obj->ref; + $invoicestatic->statut = $obj->fk_statut; + $invoicestatic->paye = $obj->paye; + $invoicestatic->type = $obj->type; + $alreadypayed = $invoicestatic->getSommePaiement(); + + + print ''; + + print ''; + + print ''; + + print ''; + + print ''; + print ''; + $i++; + } + } else { + print ''; + } + print "
'.$langs->trans("SupplierInvoiceWaitingWithdraw").' ('.$num.')
'; + print $invoicestatic->getNomUrl(1, 'withdraw'); + print ''; + $thirdpartystatic->id = $obj->socid; + $thirdpartystatic->name = $obj->name; + print $thirdpartystatic->getNomUrl(1, 'customer'); + print ''; + print price($obj->amount); + print ''; + print dol_print_date($db->jdate($obj->date_demande), 'day'); + print ''; + print $invoicestatic->getLibStatut(3, $alreadypayed); + print '
'.$langs->trans("NoSupplierInvoiceToWithdraw", $langs->transnoentitiesnoconv("BankTransfer")).'

"; +} else { + dol_print_error($db); +} + + +print '
'; + + +/* + * Withdraw receipts + */ +$limit = 5; +$sql = "SELECT p.rowid, p.ref, p.amount, p.datec, p.statut"; +$sql .= " FROM ".MAIN_DB_PREFIX."prelevement_bons as p"; +$sql .= " ORDER BY datec DESC"; +$sql .= $db->plimit($limit); + +$result = $db->query($sql); +if ($result) +{ + $num = $db->num_rows($result); + $i = 0; + + print"\n\n"; + print '
'; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + + while ($i < min($num, $limit)) + { + $obj = $db->fetch_object($result); + + + print ''; + + print "\n"; + print '\n"; + print '\n"; + print '\n"; + + print "\n"; + $i++; + } + print "
'.$langs->trans("LatestBankTransferReceipts", $limit).''.$langs->trans("Date").''.$langs->trans("Amount").''.$langs->trans("Status").'
"; + $bprev->id = $obj->rowid; + $bprev->ref = $obj->ref; + $bprev->statut = $obj->statut; + print $bprev->getNomUrl(1); + print "'.dol_print_date($db->jdate($obj->datec), "dayhour")."'.price($obj->amount)."'.$bprev->getLibStatut(3)."

"; + $db->free($result); +} else { + dol_print_error($db); +} + + +print '
'; + +// End of page +llxFooter(); +$db->close(); diff --git a/htdocs/compta/prelevement/bons.php b/htdocs/compta/prelevement/bons.php index 8c9203c8a58..347b3ebb37f 100644 --- a/htdocs/compta/prelevement/bons.php +++ b/htdocs/compta/prelevement/bons.php @@ -54,7 +54,8 @@ $statut = GETPOST('statut', 'int'); $search_ref = GETPOST('search_ref', 'alpha'); $search_amount = GETPOST('search_amount', 'alpha'); -$bon = new BonPrelevement($db, ""); +$bon = new BonPrelevement($db); +$hookmanager->initHooks(array('withdrawalsreceiptslist')); /* @@ -189,9 +190,7 @@ if ($result) print ''; $db->free($result); -} -else -{ +} else { dol_print_error($db); } diff --git a/htdocs/compta/prelevement/card.php b/htdocs/compta/prelevement/card.php index 68f40999aa7..7d56cec823e 100644 --- a/htdocs/compta/prelevement/card.php +++ b/htdocs/compta/prelevement/card.php @@ -58,13 +58,14 @@ $pagenext = $page + 1; if (!$sortfield) $sortfield = 'pl.fk_soc'; if (!$sortorder) $sortorder = 'DESC'; -$object = new BonPrelevement($db, ""); +$object = new BonPrelevement($db); // Load object include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once // Must be include, not include_once. Include fetch and fetch_thirdparty but not fetch_optionals $hookmanager->initHooks(array('directdebitprevcard', 'globalcard', 'directdebitprevlist')); + /* * Actions */ @@ -271,10 +272,6 @@ if ($id > 0 || $ref) print ''.$langs->trans("TransMetod").''; print $form->selectarray("methode", $object->methodes_trans); print ''; - /*print ''.$langs->trans("File").''; - print ''; - print '
'; - print '';*/ print '
'; print '
'; print ''; @@ -321,7 +318,7 @@ if ($id > 0 || $ref) } - $ligne = new LignePrelevement($db, $user); + $ligne = new LignePrelevement($db); /* * Lines into withdraw request @@ -411,9 +408,7 @@ if ($id > 0 || $ref) if ($obj->statut == 3) { print ''.$langs->trans("StatusRefused").''; - } - else - { + } else { print " "; } @@ -445,9 +440,7 @@ if ($id > 0 || $ref) print ''; $db->free($result); - } - else - { + } else { dol_print_error($db); } } diff --git a/htdocs/compta/prelevement/class/bonprelevement.class.php b/htdocs/compta/prelevement/class/bonprelevement.class.php index 0a033e2df53..6192d97d92f 100644 --- a/htdocs/compta/prelevement/class/bonprelevement.class.php +++ b/htdocs/compta/prelevement/class/bonprelevement.class.php @@ -83,18 +83,16 @@ class BonPrelevement extends CommonObject * Constructor * * @param DoliDB $db Database handler - * @param string $filename Filename of withdraw receipt */ - public function __construct($db, $filename = '') + public function __construct($db) { global $conf, $langs; - $error = 0; $this->db = $db; - $this->filename = $filename; + $this->filename = ''; - $this->date_echeance = time(); + $this->date_echeance = dol_now(); $this->raison_sociale = ""; $this->reference_remise = ""; @@ -153,21 +151,15 @@ class BonPrelevement extends CommonObject if ($this->db->query($sql)) { $result = 0; - } - else - { + } else { $result = -1; dol_syslog(get_class($this)."::AddFacture Erreur $result"); } - } - else - { + } else { $result = -2; dol_syslog(get_class($this)."::AddFacture Erreur $result"); } - } - else - { + } else { $result = -3; dol_syslog(get_class($this)."::AddFacture Erreur $result"); } @@ -210,14 +202,10 @@ class BonPrelevement extends CommonObject if ($resql) { $num = $this->db->num_rows($resql); - } - else - { + } else { $result = -1; } - } - else - { + } else { /* * No aggregate */ @@ -245,9 +233,7 @@ class BonPrelevement extends CommonObject { $line_id = $this->db->last_insert_id(MAIN_DB_PREFIX."prelevement_lignes"); $result = 0; - } - else - { + } else { dol_syslog(get_class($this)."::addline Error -2"); $result = -2; } @@ -322,15 +308,11 @@ class BonPrelevement extends CommonObject $this->fetched = 1; return 1; - } - else - { + } else { dol_syslog(get_class($this)."::Fetch Erreur aucune ligne retournee"); return -1; } - } - else - { + } else { return -2; } } @@ -398,17 +380,13 @@ class BonPrelevement extends CommonObject { $this->db->commit(); return 0; - } - else - { + } else { $this->db->rollback(); dol_syslog(get_class($this)."::set_credite ROLLBACK "); return -1; } - } - else - { + } else { dol_syslog(get_class($this)."::set_credite Ouverture transaction SQL impossible "); return -2; } @@ -492,9 +470,7 @@ class BonPrelevement extends CommonObject { dol_syslog(get_class($this)."::set_infocredit AddPayment Error"); $error++; - } - else - { + } else { $result = $paiement->addPaymentToBank($user, 'payment', '(WithdrawalPayment)', $bankaccount, '', ''); if ($result < 0) { @@ -518,9 +494,7 @@ class BonPrelevement extends CommonObject dol_syslog(get_class($this)."::set_infocredit Update lines Error"); $error++; } - } - else - { + } else { dol_syslog(get_class($this)."::set_infocredit Update Bons Error"); $error++; } @@ -535,28 +509,20 @@ class BonPrelevement extends CommonObject $this->db->commit(); return 0; - } - else - { + } else { $this->db->rollback(); dol_syslog("bon-prelevment::set_infocredit ROLLBACK "); return -1; } - } - else - { + } else { dol_syslog(get_class($this)."::set_infocredit 1025 Open SQL transaction impossible "); return -1025; } - } - else - { + } else { dol_syslog("bon-prelevment::set_infocredit 1027 Date de credit < Date de trans "); return -1027; } - } - else - { + } else { return -1026; } } @@ -598,9 +564,7 @@ class BonPrelevement extends CommonObject $message .= $langs->trans("InfoTransData", price($this->amount), $this->methodes_trans[$this->method_trans], dol_print_date($date, 'day')); // TODO Call trigger to create a notification using notification module - } - else - { + } else { $error++; } @@ -611,17 +575,13 @@ class BonPrelevement extends CommonObject $this->db->commit(); return 0; - } - else - { + } else { $this->db->rollback(); dol_syslog(get_class($this)."::set_infotrans ROLLBACK", LOG_ERR); return -1; } - } - else - { + } else { dol_syslog(get_class($this)."::set_infotrans Ouverture transaction SQL impossible", LOG_CRIT); return -2; } @@ -666,8 +626,7 @@ class BonPrelevement extends CommonObject { $row = $this->db->fetch_row($resql); if (!$amounts) $arr[$i] = $row[0]; - else - { + else { $arr[$i] = array( $row[0], $row[1] @@ -677,9 +636,7 @@ class BonPrelevement extends CommonObject } } $this->db->free($resql); - } - else - { + } else { dol_syslog(get_class($this)."::getListInvoices Erreur"); } @@ -716,9 +673,7 @@ class BonPrelevement extends CommonObject $this->db->free($resql); return $obj->nb; - } - else - { + } else { $error = 1; dol_syslog(get_class($this)."::SommeAPrelever Erreur -1"); dol_syslog($this->db->error()); @@ -761,9 +716,7 @@ class BonPrelevement extends CommonObject $this->db->free($resql); return $obj->nb; - } - else - { + } else { $this->error = get_class($this)."::NbFactureAPrelever Erreur -1 sql=".$this->db->error(); return -1; } @@ -850,9 +803,7 @@ class BonPrelevement extends CommonObject } $this->db->free($resql); dol_syslog(__METHOD__."::Read invoices, ".$i." invoices to withdraw", LOG_DEBUG); - } - else - { + } else { $error++; dol_syslog(__METHOD__."::Read invoices error ".$this->db->error(), LOG_ERR); } @@ -892,31 +843,23 @@ class BonPrelevement extends CommonObject if ($bac->verif() >= 1) { $factures_prev[$i] = $fac; - /* second tableau necessaire pour BonPrelevement */ + /* second array necessary for BonPrelevement */ $factures_prev_id[$i] = $fac[0]; $i++; //dol_syslog(__METHOD__."::RIB is ok", LOG_DEBUG); - } - else - { + } else { dol_syslog(__METHOD__."::Check RIB Error on default bank number IBAN/BIC for thirdparty reported by verif() ".$fact->socid." ".$soc->name, LOG_WARNING); $this->invoice_in_error[$fac[0]] = "Error on default bank number IBAN/BIC for invoice ".$fact->getNomUrl(0)." for thirdparty ".$soc->getNomUrl(0); $this->thirdparty_in_error[$soc->id] = "Error on default bank number IBAN/BIC for invoice ".$fact->getNomUrl(0)." for thirdparty ".$soc->getNomUrl(0); } - } - else - { + } else { dol_syslog(__METHOD__."::Check RIB Failed to read company", LOG_WARNING); } - } - else - { + } else { dol_syslog(__METHOD__."::Check RIB Failed to read invoice", LOG_WARNING); } } - } - else - { + } else { dol_syslog(__METHOD__."::Check RIB No invoice to process", LOG_WARNING); } } @@ -942,9 +885,7 @@ class BonPrelevement extends CommonObject if ($mode == 'real') { $ok = 1; - } - else - { + } else { print $langs->trans("ModeWarning"); //"Option for real mode was not set, we stop after this simulation\n"; } } @@ -1001,15 +942,11 @@ class BonPrelevement extends CommonObject $prev_id = $this->db->last_insert_id(MAIN_DB_PREFIX."prelevement_bons"); $this->id = $prev_id; $this->ref = $ref; - } - else - { + } else { $error++; dol_syslog(__METHOD__."::Create withdraw receipt ".$this->db->lasterror(), LOG_ERR); } - } - else - { + } else { $error++; dol_syslog(__METHOD__."::Get last withdraw receipt ".$this->db->lasterror(), LOG_ERR); } @@ -1130,16 +1067,12 @@ class BonPrelevement extends CommonObject if (!$error) { $this->db->commit(); - } - else - { + } else { $this->db->rollback(); } return count($factures_prev); - } - else - { + } else { return 0; } } @@ -1199,9 +1132,7 @@ class BonPrelevement extends CommonObject { $this->db->commit(); return 1; - } - else - { + } else { $this->db->rollback(); return -1; } @@ -1260,8 +1191,7 @@ class BonPrelevement extends CommonObject $reshook=$hookmanager->executeHooks('getnomurltooltip',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks if ($reshook > 0) $linkclose = $hookmanager->resPrint; */ - } - else $linkclose = ($morecss ? ' class="'.$morecss.'"' : ''); + } else $linkclose = ($morecss ? ' class="'.$morecss.'"' : ''); $linkstart = ''; @@ -1302,9 +1232,7 @@ class BonPrelevement extends CommonObject if ($this->db->query($sql)) { return 0; - } - else - { + } else { return -1; } } @@ -1328,9 +1256,7 @@ class BonPrelevement extends CommonObject if ($this->db->query($sql)) { return 0; - } - else - { + } else { return -1; } } @@ -1360,9 +1286,7 @@ class BonPrelevement extends CommonObject if ($this->db->query($sql)) { $result = 0; - } - else - { + } else { $result = -1; dol_syslog(get_class($this)."::AddNotification Error $result"); } @@ -1465,9 +1389,7 @@ class BonPrelevement extends CommonObject $i++; } $nbtotalDrctDbtTxInf = $i; - } - else - { + } else { fputs($this->file, 'ERROR DEBITOR '.$sql.$CrLf); // DEBITOR = Customers $result = -2; } @@ -1476,9 +1398,7 @@ class BonPrelevement extends CommonObject if ($result != -2) { $fileEmetteurSection .= $this->EnregEmetteurSEPA($conf, $date_actu, $nbtotalDrctDbtTxInf, $this->total, $CrLf, $format); - } - else - { + } else { fputs($this->file, 'ERROR CREDITOR'.$CrLf); // CREDITOR = My company } @@ -1544,9 +1464,7 @@ class BonPrelevement extends CommonObject $this->total = $this->total + $obj->amount; $i++; } - } - else - { + } else { $result = -2; } @@ -1916,9 +1834,7 @@ class BonPrelevement extends CommonObject $XML_SEPA_INFO .= ' '.$CrLf; $XML_SEPA_INFO .= ' '.$CrLf; $XML_SEPA_INFO .= ' '.$CrLf; - } - else - { + } else { fputs($this->file, 'INCORRECT EMETTEUR '.$XML_SEPA_INFO.$CrLf); $result = -2; } diff --git a/htdocs/compta/prelevement/class/ligneprelevement.class.php b/htdocs/compta/prelevement/class/ligneprelevement.class.php index dd24ad9522c..1e731b24524 100644 --- a/htdocs/compta/prelevement/class/ligneprelevement.class.php +++ b/htdocs/compta/prelevement/class/ligneprelevement.class.php @@ -48,14 +48,12 @@ class LignePrelevement * Constructor * * @param DoliDb $db Database handler - * @param User $user Objet user */ - public function __construct($db, $user) + public function __construct($db) { global $conf, $langs; $this->db = $db; - $this->user = $user; // List of language codes for status @@ -98,17 +96,13 @@ class LignePrelevement $this->statut = $obj->statut; $this->bon_ref = $obj->ref; $this->bon_rowid = $obj->bon_rowid; - } - else - { + } else { $result++; dol_syslog("LignePrelevement::Fetch rowid=$rowid numrows=0"); } $this->db->free($resql); - } - else - { + } else { $result++; dol_syslog("LignePrelevement::Fetch rowid=$rowid"); dol_syslog($this->db->error()); @@ -144,20 +138,17 @@ class LignePrelevement if ($mode == 0) { return $langs->trans($this->statuts[$status]); - } - elseif ($mode == 1) + } elseif ($mode == 1) { if ($status == 0) return img_picto($langs->trans($this->statuts[$status]), 'statut1').' '.$langs->trans($this->statuts[$status]); // Waiting elseif ($status == 2) return img_picto($langs->trans($this->statuts[$status]), 'statut6').' '.$langs->trans($this->statuts[$status]); // Credited elseif ($status == 3) return img_picto($langs->trans($this->statuts[$status]), 'statut8').' '.$langs->trans($this->statuts[$status]); // Refused - } - elseif ($mode == 2) + } elseif ($mode == 2) { if ($status == 0) return img_picto($langs->trans($this->statuts[$status]), 'statut1'); elseif ($status == 2) return img_picto($langs->trans($this->statuts[$status]), 'statut6'); elseif ($status == 3) return img_picto($langs->trans($this->statuts[$status]), 'statut8'); - } - elseif ($mode == 3) + } elseif ($mode == 3) { if ($status == 0) return $langs->trans($this->statuts[$status]).' '.img_picto($langs->trans($this->statuts[$status]), 'statut1'); elseif ($status == 2) return $langs->trans($this->statuts[$status]).' '.img_picto($langs->trans($this->statuts[$status]), 'statut6'); diff --git a/htdocs/compta/prelevement/class/rejetprelevement.class.php b/htdocs/compta/prelevement/class/rejetprelevement.class.php index 74626baed13..8599987fb23 100644 --- a/htdocs/compta/prelevement/class/rejetprelevement.class.php +++ b/htdocs/compta/prelevement/class/rejetprelevement.class.php @@ -160,9 +160,7 @@ class RejetPrelevement { $error++; dol_syslog("RejetPrelevement::Create Error creation payment invoice ".$facs[$i][0]); - } - else - { + } else { $result = $pai->addPaymentToBank($user, 'payment', '(InvoiceRefused)', $bankaccount, '', ''); if ($result < 0) { @@ -191,9 +189,7 @@ class RejetPrelevement { dol_syslog("RejetPrelevement::Create Commit"); $this->db->commit(); - } - else - { + } else { dol_syslog("RejetPrelevement::Create Rollback"); $this->db->rollback(); } @@ -227,9 +223,7 @@ class RejetPrelevement $row = $this->db->fetch_row($resql); $userid = $row[0]; } - } - else - { + } else { dol_syslog("RejetPrelevement::_send_email Erreur lecture user"); } @@ -247,6 +241,7 @@ class RejetPrelevement $sendto = $emuser->getFullName($langs)." <".$emuser->email.">"; $from = $this->user->getFullName($langs)." <".$this->user->email.">"; $msgishtml = 1; + $trackid = 'use'.$emuser->id; $arr_file = array(); $arr_mime = array(); @@ -258,20 +253,16 @@ class RejetPrelevement $message = $langs->trans("InfoRejectMessage", $facref, $socname, $amount, $userinfo); - $mailfile = new CMailFile($subject, $sendto, $from, $message, $arr_file, $arr_mime, $arr_name, '', '', 0, $msgishtml, $this->user->email); + $mailfile = new CMailFile($subject, $sendto, $from, $message, $arr_file, $arr_mime, $arr_name, '', '', 0, $msgishtml, $this->user->email, '', $trackid); $result = $mailfile->sendfile(); if ($result) { dol_syslog("RejetPrelevement::_send_email email envoye"); - } - else - { + } else { dol_syslog("RejetPrelevement::_send_email Erreur envoi email"); } - } - else - { + } else { dol_syslog("RejetPrelevement::_send_email Userid invalide"); } } @@ -309,8 +300,7 @@ class RejetPrelevement { $row = $this->db->fetch_row($resql); if (!$amounts) $arr[$i] = $row[0]; - else - { + else { $arr[$i] = array( $row[0], $row[1] @@ -320,9 +310,7 @@ class RejetPrelevement } } $this->db->free($resql); - } - else - { + } else { dol_syslog("getListInvoices", LOG_ERR); } @@ -357,15 +345,11 @@ class RejetPrelevement $this->db->free($resql); return 0; - } - else - { + } else { dol_syslog("RejetPrelevement::Fetch Erreur rowid=$rowid numrows=0"); return -1; } - } - else - { + } else { dol_syslog("RejetPrelevement::Fetch Erreur rowid=$rowid"); return -2; } diff --git a/htdocs/compta/prelevement/create.php b/htdocs/compta/prelevement/create.php index 5306b6799b9..015380a669d 100644 --- a/htdocs/compta/prelevement/create.php +++ b/htdocs/compta/prelevement/create.php @@ -83,8 +83,7 @@ if (empty($reshook)) if ($result < 0) { setEventMessages($bprev->error, $bprev->errors, 'errors'); - } - elseif ($result == 0) + } elseif ($result == 0) { $mesg = $langs->trans("NoInvoiceCouldBeWithdrawed", $format); setEventMessages($mesg, null, 'errors'); @@ -93,9 +92,7 @@ if (empty($reshook)) { $mesg .= ''.$val."
\n"; } - } - else - { + } else { setEventMessages($langs->trans("DirectDebitOrderCreated", $bprev->getNomUrl(1)), null); } } @@ -174,22 +171,16 @@ if ($nb) { } else { print '
'.$langs->trans("CreateAll")."\n"; } - } - else - { + } else { if ($mysoc->isInEEC()) { print ''.$langs->trans("CreateForSepaFRST")."\n"; print ''.$langs->trans("CreateForSepaRCUR")."\n"; - } - else - { + } else { print ''.$langs->trans("CreateAll")."\n"; } } -} -else -{ +} else { print 'transnoentitiesnoconv("StandingOrders"))).'">'.$langs->trans("CreateAll")."\n"; } @@ -307,17 +298,13 @@ if ($resql) print ''; $i++; } - } - else - { + } else { print ''.$langs->trans("None").''; } print ""; print ""; print "
\n"; -} -else -{ +} else { dol_print_error($db); } diff --git a/htdocs/compta/prelevement/demandes.php b/htdocs/compta/prelevement/demandes.php index 181f71a678c..30618de8c24 100644 --- a/htdocs/compta/prelevement/demandes.php +++ b/htdocs/compta/prelevement/demandes.php @@ -88,9 +88,7 @@ if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x' if (!$status) { $title = $langs->trans("RequestStandingOrderToTreat"); -} -else -{ +} else { $title = $langs->trans("RequestStandingOrderTreated"); } @@ -142,9 +140,7 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) if (is_numeric($nbtotalofrecords) && $limit > $nbtotalofrecords) { $num = $nbtotalofrecords; -} -else -{ +} else { $sql .= $db->plimit($limit + 1, $offset); $resql = $db->query($sql); diff --git a/htdocs/compta/prelevement/factures.php b/htdocs/compta/prelevement/factures.php index ec004717946..c0fa4f55e68 100644 --- a/htdocs/compta/prelevement/factures.php +++ b/htdocs/compta/prelevement/factures.php @@ -53,7 +53,7 @@ $pagenext = $page + 1; if (!$sortfield) $sortfield = 'p.ref'; if (!$sortorder) $sortorder = 'DESC'; -$object = new BonPrelevement($db, ""); +$object = new BonPrelevement($db); @@ -134,9 +134,7 @@ if ($prev_id > 0 || $ref) print ''; dol_fiche_end(); - } - else - { + } else { dol_print_error($db); } } @@ -246,12 +244,10 @@ if ($result) if ($obj->statut == 0) { print '-'; - } - elseif ($obj->statut == 2) + } elseif ($obj->statut == 2) { print $langs->trans("StatusCredited"); - } - elseif ($obj->statut == 3) + } elseif ($obj->statut == 3) { print ''.$langs->trans("StatusRefused").''; } @@ -289,9 +285,7 @@ if ($result) print ''; $db->free($result); -} -else -{ +} else { dol_print_error($db); } diff --git a/htdocs/compta/prelevement/fiche-rejet.php b/htdocs/compta/prelevement/fiche-rejet.php index 44be3d1cd01..65116878bb9 100644 --- a/htdocs/compta/prelevement/fiche-rejet.php +++ b/htdocs/compta/prelevement/fiche-rejet.php @@ -51,7 +51,7 @@ $offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; -$object = new BonPrelevement($db, ""); +$object = new BonPrelevement($db); @@ -135,9 +135,7 @@ if ($prev_id > 0 || $ref) print ''; dol_fiche_end(); - } - else - { + } else { dol_print_error($db); } } @@ -220,9 +218,7 @@ if ($resql) $i++; } - } - else - { + } else { print ''.$langs->trans("None").''; } @@ -238,9 +234,7 @@ if ($resql) print ''; $db->free($resql); -} -else -{ +} else { dol_print_error($db); } diff --git a/htdocs/compta/prelevement/fiche-stat.php b/htdocs/compta/prelevement/fiche-stat.php index 6e8e8390ae8..0ada15853d9 100644 --- a/htdocs/compta/prelevement/fiche-stat.php +++ b/htdocs/compta/prelevement/fiche-stat.php @@ -50,7 +50,7 @@ $pageprev = $page - 1; $pagenext = $page + 1; -$object = new BonPrelevement($db, ""); +$object = new BonPrelevement($db); /* @@ -132,9 +132,7 @@ if ($prev_id > 0 || $ref) print ''; dol_fiche_end(); - } - else - { + } else { $langs->load("errors"); print $langs->trans("Error"); } @@ -142,7 +140,7 @@ if ($prev_id > 0 || $ref) /* * Stats */ - $ligne = new LignePrelevement($db, $user); + $ligne = new LignePrelevement($db); $sql = "SELECT sum(pl.amount), pl.statut"; $sql .= " FROM ".MAIN_DB_PREFIX."prelevement_lignes as pl"; @@ -185,9 +183,7 @@ if ($prev_id > 0 || $ref) print ""; $db->free($resql); - } - else - { + } else { print $db->error().' '.$sql; } } diff --git a/htdocs/compta/prelevement/index.php b/htdocs/compta/prelevement/index.php index eb2932fd4cb..d182176f0fa 100644 --- a/htdocs/compta/prelevement/index.php +++ b/htdocs/compta/prelevement/index.php @@ -158,15 +158,11 @@ if ($resql) print ''; $i++; } - } - else - { + } else { print ''.$langs->trans("NoInvoiceToWithdraw", $langs->transnoentitiesnoconv("StandingOrders")).''; } print "
"; -} -else -{ +} else { dol_print_error($db); } @@ -220,9 +216,7 @@ if ($result) } print "
"; $db->free($result); -} -else -{ +} else { dol_print_error($db); } diff --git a/htdocs/compta/prelevement/line.php b/htdocs/compta/prelevement/line.php index 6eef29d1e3e..fd77d6d90f6 100644 --- a/htdocs/compta/prelevement/line.php +++ b/htdocs/compta/prelevement/line.php @@ -73,9 +73,7 @@ if ($action == 'confirm_rejet') { $error++; setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Date")), null, 'errors'); - } - - elseif ($daterej > dol_now()) + } elseif ($daterej > dol_now()) { $error++; $langs->load("error"); @@ -90,7 +88,7 @@ if ($action == 'confirm_rejet') if (!$error) { - $lipre = new LignePrelevement($db, $user); + $lipre = new LignePrelevement($db); if ($lipre->fetch($id) == 0) @@ -102,14 +100,10 @@ if ($action == 'confirm_rejet') header("Location: line.php?id=".$id); exit; } - } - else - { + } else { $action = "rejet"; } - } - else - { + } else { header("Location: line.php?id=".$id); exit; } @@ -126,13 +120,13 @@ llxHeader('', $langs->trans("StandingOrder")); $h = 0; $head[$h][0] = DOL_URL_ROOT.'/compta/prelevement/line.php?id='.$id; -$head[$h][1] = $langs->trans("Card"); +$head[$h][1] = $langs->trans("StandingOrder"); $hselected = $h; $h++; if ($id) { - $lipre = new LignePrelevement($db, $user); + $lipre = new LignePrelevement($db); if ($lipre->fetch($id) == 0) { @@ -161,25 +155,19 @@ if ($id) { /* Historique pour certaines install */ print $langs->trans("Unknown"); - } - else - { + } else { print dol_print_date($rej->date_rejet, 'day'); } print ''; print ''.$langs->trans("RefusedInvoicing").''.$rej->invoicing.''; - } - else - { + } else { print ''.$resf.''; } } print ''; dol_fiche_end(); - } - else - { + } else { dol_print_error($db); } @@ -245,14 +233,10 @@ if ($id) if ($user->rights->prelevement->bons->credit) { print "id\">".$langs->trans("StandingOrderReject").""; - } - else - { + } else { print "trans("NotAllowed")."\">".$langs->trans("StandingOrderReject").""; } - } - else - { + } else { print "trans("NotPossibleForThisStatusOfWithdrawReceiptORLine")."\">".$langs->trans("StandingOrderReject").""; } } @@ -329,9 +313,7 @@ if ($id) print ""; $db->free($result); - } - else - { + } else { dol_print_error($db); } } diff --git a/htdocs/compta/prelevement/list.php b/htdocs/compta/prelevement/list.php index 5598168a436..3130aa475f6 100644 --- a/htdocs/compta/prelevement/list.php +++ b/htdocs/compta/prelevement/list.php @@ -64,10 +64,13 @@ $search_code = GETPOST('search_code', 'alpha'); $search_company = GETPOST('search_company', 'alpha'); $statut = GETPOST('statut', 'int'); -$bon = new BonPrelevement($db, ""); -$ligne = new LignePrelevement($db, $user); +$bon = new BonPrelevement($db); +$line = new LignePrelevement($db); $company = new Societe($db); +$hookmanager->initHooks(array('withdrawalsreceiptslineslist')); + + /* * Actions */ @@ -194,7 +197,7 @@ if ($result) print ''; print ''; - print $ligne->LibStatut($obj->statut_ligne, 2); + print $line->LibStatut($obj->statut_ligne, 2); print " "; print ''; print substr('000000'.$obj->rowid_ligne, -6); @@ -232,9 +235,7 @@ if ($result) print ''; $db->free($result); -} -else -{ +} else { dol_print_error($db); } diff --git a/htdocs/compta/prelevement/rejets.php b/htdocs/compta/prelevement/rejets.php index 602c57b5ad4..61417a2cd5f 100644 --- a/htdocs/compta/prelevement/rejets.php +++ b/htdocs/compta/prelevement/rejets.php @@ -43,6 +43,7 @@ $limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit; $sortorder = GETPOST('sortorder', 'alpha'); $sortfield = GETPOST('sortfield', '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 $offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; @@ -56,7 +57,10 @@ if ($sortorder == "") $sortorder = "DESC"; if ($sortfield == "") $sortfield = "p.datec"; $rej = new RejetPrelevement($db, $user); -$ligne = new LignePrelevement($db, $user); +$line = new LignePrelevement($db); + +$hookmanager->initHooks(array('withdrawalsreceiptsrejectedlist')); + /* * Liste des factures @@ -84,7 +88,7 @@ if ($result) print_barre_liste($langs->trans("WithdrawsRefused"), $page, $_SERVER["PHP_SELF"], $urladd, $sortfield, $sortorder, '', $num); print"\n\n"; - print ''; + print '
'; print ''; print_liste_field_titre("Line", $_SERVER["PHP_SELF"], "p.ref", '', $urladd); print_liste_field_titre("ThirdParty", $_SERVER["PHP_SELF"], "s.nom", '', $urladd); @@ -98,7 +102,7 @@ if ($result) $obj = $db->fetch_object($result); print '"; @@ -113,9 +117,7 @@ if ($result) print "
'; - print $ligne->LibStatut($obj->statut, 2).' '; + print $line->LibStatut($obj->statut, 2).' '; print ''; print substr('000000'.$obj->rowid, -6)."
"; $db->free($result); -} -else -{ +} else { dol_print_error($db); } diff --git a/htdocs/compta/prelevement/stats.php b/htdocs/compta/prelevement/stats.php index c19603df967..b12a6a2bb35 100644 --- a/htdocs/compta/prelevement/stats.php +++ b/htdocs/compta/prelevement/stats.php @@ -73,7 +73,7 @@ if ($resql) print '
'; print load_fiche_titre($langs->trans("WithdrawStatistics"), '', ''); -$ligne = new LignePrelevement($db, $user); +$ligne = new LignePrelevement($db); $sql = "SELECT sum(pl.amount), count(pl.amount), pl.statut"; $sql .= " FROM ".MAIN_DB_PREFIX."prelevement_lignes as pl"; @@ -125,9 +125,7 @@ if ($resql) print ' '; print ""; $db->free(); -} -else -{ +} else { dol_print_error($db); } @@ -219,9 +217,7 @@ if ($resql) print ' '; print ""; $db->free($resql); -} -else -{ +} else { dol_print_error($db); } diff --git a/htdocs/compta/recap-compta.php b/htdocs/compta/recap-compta.php index 3f2112537b1..8b75ec38fce 100644 --- a/htdocs/compta/recap-compta.php +++ b/htdocs/compta/recap-compta.php @@ -211,15 +211,11 @@ if ($id > 0) } $db->free($resqlp); - } - else - { + } else { dol_print_error($db); } } - } - else - { + } else { dol_print_error($db); } @@ -288,9 +284,7 @@ if ($id > 0) print ""; } -} -else -{ +} else { dol_print_error($db); } diff --git a/htdocs/compta/resultat/clientfourn.php b/htdocs/compta/resultat/clientfourn.php index 44be66a2218..671921506d5 100644 --- a/htdocs/compta/resultat/clientfourn.php +++ b/htdocs/compta/resultat/clientfourn.php @@ -8,6 +8,7 @@ * Copyright (C) 2014 Juanjo Menent * Copyright (C) 2014 Florian Henry * Copyright (C) 2018 Frédéric France + * Copyright (C) 2020 Maxime DEMAREST * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -38,7 +39,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountancycategory.class.php'; // Load translation files required by the page -$langs->loadLangs(array('compta', 'bills', 'donation', 'salaries', 'accountancy')); +$langs->loadLangs(array('compta', 'bills', 'donation', 'salaries', 'accountancy', 'loan')); $date_startmonth = GETPOST('date_startmonth', 'int'); $date_startday = GETPOST('date_startday', 'int'); @@ -98,8 +99,7 @@ if (empty($date_start) || empty($date_end)) // We define date_start and date_end $month_end = $month_start - 1; if ($month_end < 1) $month_end = 12; else $year_end++; - } - else $month_end = $month_start; + } else $month_end = $month_start; $date_start = dol_get_first_day($year_start, $month_start, false); $date_end = dol_get_last_day($year_end, $month_end, false); } if ($q == 1) { $date_start = dol_get_first_day($year_start, 1, false); $date_end = dol_get_last_day($year_start, 3, false); } @@ -150,11 +150,10 @@ if ($modecompta == "CREANCES-DETTES") $periodlink = ($year_start ? "
".img_previous()." ".img_next()."" : ""); $description = $langs->trans("RulesResultDue"); if (!empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) $description .= $langs->trans("DepositsAreNotIncluded"); - else $description .= $langs->trans("DepositsAreIncluded"); + else $description .= $langs->trans("DepositsAreIncluded"); $builddate = dol_now(); //$exportlink=$langs->trans("NotYetAvailable"); -} -elseif ($modecompta == "RECETTES-DEPENSES") +} elseif ($modecompta == "RECETTES-DEPENSES") { $name = $langs->trans("ReportInOut").', '.$langs->trans("ByPredefinedAccountGroups"); $calcmode = $langs->trans("CalcModeEngagement"); @@ -165,8 +164,7 @@ elseif ($modecompta == "RECETTES-DEPENSES") $description = $langs->trans("RulesResultInOut"); $builddate = dol_now(); //$exportlink=$langs->trans("NotYetAvailable"); -} -elseif ($modecompta == "BOOKKEEPING") +} elseif ($modecompta == "BOOKKEEPING") { $name = $langs->trans("ReportInOut").', '.$langs->trans("ByPredefinedAccountGroups"); $calcmode = $langs->trans("CalcModeBookkeeping"); @@ -211,9 +209,7 @@ print_liste_field_titre(''); if ($modecompta == 'BOOKKEEPING') { print_liste_field_titre("Amount", $_SERVER["PHP_SELF"], 'amount', '', $param, 'class="right"', $sortfield, $sortorder); -} -else -{ +} else { if ($modecompta == 'CREANCES-DETTES') { print_liste_field_titre("AmountHT", $_SERVER["PHP_SELF"], 'amount_ht', '', $param, 'class="right"', $sortfield, $sortorder); @@ -311,16 +307,11 @@ if ($modecompta == 'BOOKKEEPING') $i++; } - } - else - { + } else { print ''.$langs->trans("NoRecordFound").''; } - } - else dol_print_error($db); -} -else -{ + } else dol_print_error($db); +} else { /* * Factures clients */ @@ -335,12 +326,10 @@ else $sql .= " AND f.fk_statut IN (1,2)"; if (!empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) $sql .= " AND f.type IN (0,1,2,5)"; - else - $sql .= " AND f.type IN (0,1,2,3,5)"; + else $sql .= " AND f.type IN (0,1,2,3,5)"; if (!empty($date_start) && !empty($date_end)) $sql .= " AND f.datef >= '".$db->idate($date_start)."' AND f.datef <= '".$db->idate($date_end)."'"; - } - elseif ($modecompta == 'RECETTES-DEPENSES') + } elseif ($modecompta == 'RECETTES-DEPENSES') { /* * Liste des paiements (les anciens paiements ne sont pas vus par cette requete car, sur les @@ -462,12 +451,10 @@ else $sql .= " AND f.fk_statut IN (1,2)"; if (!empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) $sql .= " AND f.type IN (0,1,2)"; - else - $sql .= " AND f.type IN (0,1,2,3)"; + else $sql .= " AND f.type IN (0,1,2,3)"; if (!empty($date_start) && !empty($date_end)) $sql .= " AND f.datef >= '".$db->idate($date_start)."' AND f.datef <= '".$db->idate($date_end)."'"; - } - elseif ($modecompta == 'RECETTES-DEPENSES') + } elseif ($modecompta == 'RECETTES-DEPENSES') { $sql = "SELECT s.nom as name, s.rowid as socid, sum(pf.amount) as amount_ttc"; $sql .= " FROM ".MAIN_DB_PREFIX."paiementfourn as p"; @@ -516,9 +503,7 @@ else print "\n"; $i++; } - } - else - { + } else { print ' '; print ''.$langs->trans("None").''; print ''; @@ -551,8 +536,7 @@ else $sql .= " AND c.deductible = 0"; if (!empty($date_start) && !empty($date_end)) $sql .= " AND cs.date_ech >= '".$db->idate($date_start)."' AND cs.date_ech <= '".$db->idate($date_end)."'"; - } - elseif ($modecompta == 'RECETTES-DEPENSES') + } elseif ($modecompta == 'RECETTES-DEPENSES') { $sql = "SELECT c.id, c.libelle as label, sum(p.amount) as amount"; $sql .= " FROM ".MAIN_DB_PREFIX."c_chargesociales as c"; @@ -596,8 +580,7 @@ else print ''; $i++; } - } - else { + } else { print ' '; print ''.$langs->trans("None").''; print ''; @@ -628,8 +611,7 @@ else if (!empty($date_start) && !empty($date_end)) $sql .= " AND cs.date_ech >= '".$db->idate($date_start)."' AND cs.date_ech <= '".$db->idate($date_end)."'"; $sql .= " AND cs.entity = ".$conf->entity; - } - elseif ($modecompta == 'RECETTES-DEPENSES') + } elseif ($modecompta == 'RECETTES-DEPENSES') { $sql = "SELECT c.id, c.libelle as label, sum(p.amount) as amount"; $sql .= " FROM ".MAIN_DB_PREFIX."c_chargesociales as c"; @@ -673,8 +655,7 @@ else print ''; $i++; } - } - else { + } else { print ' '; print ''.$langs->trans("None").''; print ''; @@ -766,16 +747,12 @@ else print ''; $i++; } - } - else - { + } else { print ' '; print ''.$langs->trans("None").''; print ''; } - } - else - { + } else { dol_print_error($db); } print ''; @@ -852,16 +829,12 @@ else print ''.price(-$obj->amount_ttc).''; print ''; } - } - else - { + } else { print ' '; print ''.$langs->trans("None").''; print ''; } - } - else - { + } else { dol_print_error($db); } print ''; @@ -886,9 +859,7 @@ else $sql .= " FROM ".MAIN_DB_PREFIX."don as p"; $sql .= " WHERE p.entity IN (".getEntity('donation').")"; $sql .= " AND fk_statut in (1,2)"; - } - else - { + } else { $sql = "SELECT p.societe as nom, p.firstname, p.lastname, date_format(p.datedon,'%Y-%m') as dm, sum(p.amount) as amount"; $sql .= " FROM ".MAIN_DB_PREFIX."don as p"; $sql .= " INNER JOIN ".MAIN_DB_PREFIX."payment_donation as pe ON pe.fk_donation = p.rowid"; @@ -934,16 +905,12 @@ else print ''; $i++; } - } - else - { + } else { print ' '; print ''.$langs->trans("None").''; print ''; } - } - else - { + } else { dol_print_error($db); } print ''; @@ -953,6 +920,113 @@ else print ''; } + /* + * Various Payments + */ + + if (!empty($conf->global->ACCOUNTING_REPORTS_INCLUDE_VARPAY) && !empty($conf->banque->enabled) && ($modecompta == 'CREANCES-DETTES' || $modecompta == "RECETTES-DEPENSES")) + { + $subtotal_ht = 0; + $subtotal_ttc = 0; + + print ''.$langs->trans("VariousPayment").''; + + // Debit + $sql = "SELECT SUM(p.amount) AS amount FROM ".MAIN_DB_PREFIX."payment_various as p"; + $sql .= ' WHERE 1 = 1'; + if (!empty($date_start) && !empty($date_end)) + $sql .= " AND p.datep >= '".$db->idate($date_start)."' AND p.datep <= '".$db->idate($date_end)."'"; + $sql .= ' GROUP BY p.sens'; + $sql .= ' ORDER BY p.sens'; + + dol_syslog('get various payments', LOG_DEBUG); + $result = $db->query($sql); + if ($result) + { + // Debit + $obj = $db->fetch_object($result); + if (isset($obj->amount)) + { + $subtotal_ht += -$obj->amount; + $subtotal_ttc += -$obj->amount; + } + print ' '; + print "".$langs->trans("Debit")."\n"; + if ($modecompta == 'CREANCES-DETTES') print ''.price(-$obj->amount).''; + print ''.price(-$obj->amount)."\n"; + print "\n"; + + // Credit + $obj = $db->fetch_object($result); + if (isset($obj->amount)) + { + $subtotal_ht += $obj->amount; + $subtotal_ttc += $obj->amount; + } + print ' '; + print "".$langs->trans("Credit")."\n"; + if ($modecompta == 'CREANCES-DETTES') print ''.price($obj->amount).''; + print ''.price($obj->amount)."\n"; + print "\n"; + + // Total + $total_ht += $subtotal_ht; + $total_ttc += $subtotal_ttc; + print ''; + if ($modecompta == 'CREANCES-DETTES') + print ''.price($subtotal_ht).''; + print ''.price($subtotal_ttc).''; + print ''; + } else dol_print_error($db); + } + + /* + * Payement Loan + */ + + if (!empty($conf->global->ACCOUNTING_REPORTS_INCLUDE_LOAN) && !empty($conf->loan->enabled) && ($modecompta == 'CREANCES-DETTES' || $modecompta == "RECETTES-DEPENSES")) + { + $subtotal_ht = 0; + $subtotal_ttc = 0; + + print ''.$langs->trans("PaymentLoan").''; + + $sql = 'SELECT l.rowid as id, l.label AS label, SUM(p.amount_capital + p.amount_insurance + p.amount_interest) as amount FROM '.MAIN_DB_PREFIX.'payment_loan as p'; + $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'loan AS l ON l.rowid = p.fk_loan'; + $sql .= ' WHERE 1 = 1'; + if (!empty($date_start) && !empty($date_end)) + $sql .= " AND p.datep >= '".$db->idate($date_start)."' AND p.datep <= '".$db->idate($date_end)."'"; + $sql .= ' GROUP BY p.fk_loan'; + $sql .= ' ORDER BY p.fk_loan'; + + dol_syslog('get loan payments', LOG_DEBUG); + $result = $db->query($sql); + if ($result) + { + require_once DOL_DOCUMENT_ROOT.'/loan/class/loan.class.php'; + $loan_static = new Loan($db); + while ($obj = $db->fetch_object($result)) + { + $loan_static->id = $obj->id; + $loan_static->ref = $obj->id; + $loan_static->label = $obj->label; + print ' '; + print "".$loan_static->getNomUrl(1).' - '.$obj->label."\n"; + if ($modecompta == 'CREANCES-DETTES') print ''.price(-$obj->amount).''; + print ''.price(-$obj->amount)."\n"; + print "\n"; + $subtotal_ht -= $obj->amount; + $subtotal_ttc -= $obj->amount; + } + $total_ht += $subtotal_ht; + $total_ttc += $subtotal_ttc; + print ''; + if ($modecompta == 'CREANCES-DETTES') + print ''.price($subtotal_ht).''; + print ''.price($subtotal_ttc).''; + print ''; + } else dol_print_error($db); + } /* * VAT @@ -973,8 +1047,7 @@ else $sql .= " WHERE f.fk_statut IN (1,2)"; if (!empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) $sql .= " AND f.type IN (0,1,2,5)"; - else - $sql .= " AND f.type IN (0,1,2,3,5)"; + else $sql .= " AND f.type IN (0,1,2,3,5)"; if (!empty($date_start) && !empty($date_end)) $sql .= " AND f.datef >= '".$db->idate($date_start)."' AND f.datef <= '".$db->idate($date_end)."'"; $sql .= " AND f.entity IN (".getEntity('invoice').")"; @@ -1021,8 +1094,7 @@ else $sql .= " WHERE f.fk_statut IN (1,2)"; if (!empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) $sql .= " AND f.type IN (0,1,2)"; - else - $sql .= " AND f.type IN (0,1,2,3)"; + else $sql .= " AND f.type IN (0,1,2,3)"; if (!empty($date_start) && !empty($date_end)) $sql .= " AND f.datef >= '".$db->idate($date_start)."' AND f.datef <= '".$db->idate($date_end)."'"; $sql .= " AND f.entity = ".$conf->entity; @@ -1062,9 +1134,7 @@ else print ' '."\n"; print ''.price($amount)."\n"; print "\n"; - } - else - { + } else { // VAT really already paid $amount = 0; $sql = "SELECT date_format(t.datev,'%Y-%m') as dm, sum(t.amount) as amount"; @@ -1143,9 +1213,7 @@ else } } $db->free($result); - } - else - { + } else { dol_print_error($db); } print ' '; diff --git a/htdocs/compta/resultat/index.php b/htdocs/compta/resultat/index.php index d462007d273..7221e932ca6 100644 --- a/htdocs/compta/resultat/index.php +++ b/htdocs/compta/resultat/index.php @@ -6,6 +6,7 @@ * Copyright (C) 2014 Juanjo Menent * Copyright (C) 2014 Florian Henry * Copyright (C) 2018 Frédéric France + * Copyright (C) 2020 Maxime DEMAREST * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -77,8 +78,7 @@ if (empty($date_start) || empty($date_end)) // We define date_start and date_end $month_end = $month_start - 1; if ($month_end < 1) $month_end = 12; else $year_end++; - } - else $month_end = $month_start; + } else $month_end = $month_start; $date_start = dol_get_first_day($year_start, $month_start, false); $date_end = dol_get_last_day($year_end, $month_end, false); } if ($q == 1) { $date_start = dol_get_first_day($year_start, 1, false); $date_end = dol_get_last_day($year_start, 3, false); } @@ -130,11 +130,10 @@ if ($modecompta == 'CREANCES-DETTES') $description = $langs->trans("RulesAmountWithTaxIncluded"); $description .= '
'.$langs->trans("RulesResultDue"); if (!empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) $description .= "
".$langs->trans("DepositsAreNotIncluded"); - else $description .= "
".$langs->trans("DepositsAreIncluded"); + else $description .= "
".$langs->trans("DepositsAreIncluded"); $builddate = dol_now(); //$exportlink=$langs->trans("NotYetAvailable"); -} -elseif ($modecompta == "RECETTES-DEPENSES") { +} elseif ($modecompta == "RECETTES-DEPENSES") { $name = $langs->trans("ReportInOut").', '.$langs->trans("ByYear"); $calcmode = $langs->trans("CalcModeEngagement"); $calcmode .= '
('.$langs->trans("SeeReportInDueDebtMode", '', '').')'; @@ -145,8 +144,7 @@ elseif ($modecompta == "RECETTES-DEPENSES") { $description .= '
'.$langs->trans("RulesResultInOut"); $builddate = dol_now(); //$exportlink=$langs->trans("NotYetAvailable"); -} -elseif ($modecompta == "BOOKKEEPING") +} elseif ($modecompta == "BOOKKEEPING") { $name = $langs->trans("ReportInOut").', '.$langs->trans("ByYear"); $calcmode = $langs->trans("CalcModeBookkeeping"); @@ -190,8 +188,7 @@ if (!empty($conf->facture->enabled) && ($modecompta == 'CREANCES-DETTES' || $mod else $sql .= " AND f.type IN (0,1,2,3,5)"; if (!empty($date_start) && !empty($date_end)) $sql .= " AND f.datef >= '".$db->idate($date_start)."' AND f.datef <= '".$db->idate($date_end)."'"; - } - elseif ($modecompta == "RECETTES-DEPENSES") + } elseif ($modecompta == "RECETTES-DEPENSES") { /* * Liste des paiements (les anciens paiements ne sont pas vus par cette requete car, sur les @@ -227,12 +224,10 @@ if (!empty($conf->facture->enabled) && ($modecompta == 'CREANCES-DETTES' || $mod $i++; } $db->free($result); - } - else { + } else { dol_print_error($db); } -} -elseif ($modecompta == "BOOKKEEPING") +} elseif ($modecompta == "BOOKKEEPING") { // Nothing from this table } @@ -273,17 +268,14 @@ if (!empty($conf->facture->enabled) && ($modecompta == 'CREANCES-DETTES' || $mod $i++; } - } - else { + } else { dol_print_error($db); } - } - elseif ($modecompta == "RECETTES-DEPENSES") + } elseif ($modecompta == "RECETTES-DEPENSES") { // Nothing from this table } -} -elseif ($modecompta == "BOOKKEEPING") +} elseif ($modecompta == "BOOKKEEPING") { // Nothing from this table } @@ -306,8 +298,7 @@ if (!empty($conf->facture->enabled) && ($modecompta == 'CREANCES-DETTES' || $mod else $sql .= " AND f.type IN (0,1,2,3)"; if (!empty($date_start) && !empty($date_end)) $sql .= " AND f.datef >= '".$db->idate($date_start)."' AND f.datef <= '".$db->idate($date_end)."'"; - } - elseif ($modecompta == "RECETTES-DEPENSES") + } elseif ($modecompta == "RECETTES-DEPENSES") { $sql = "SELECT sum(pf.amount) as amount_ttc, date_format(p.datep,'%Y-%m') as dm"; $sql .= " FROM ".MAIN_DB_PREFIX."paiementfourn as p"; @@ -342,12 +333,10 @@ if (!empty($conf->facture->enabled) && ($modecompta == 'CREANCES-DETTES' || $mod $i++; } $db->free($result); - } - else { + } else { dol_print_error($db); } -} -elseif ($modecompta == "BOOKKEEPING") +} elseif ($modecompta == "BOOKKEEPING") { // Nothing from this table } @@ -428,8 +417,7 @@ if (!empty($conf->tax->enabled) && ($modecompta == 'CREANCES-DETTES' || $modecom } else { dol_print_error($db); } - } - elseif ($modecompta == "RECETTES-DEPENSES") + } elseif ($modecompta == "RECETTES-DEPENSES") { // TVA really already paid $sql = "SELECT sum(t.amount) as amount, date_format(t.datev,'%Y-%m') as dm"; @@ -492,8 +480,7 @@ if (!empty($conf->tax->enabled) && ($modecompta == 'CREANCES-DETTES' || $modecom dol_print_error($db); } } -} -elseif ($modecompta == "BOOKKEEPING") +} elseif ($modecompta == "BOOKKEEPING") { // Nothing from this table } @@ -515,8 +502,7 @@ if (!empty($conf->tax->enabled) && ($modecompta == 'CREANCES-DETTES' || $modecom $sql .= " AND c.deductible = 0"; if (!empty($date_start) && !empty($date_end)) $sql .= " AND cs.date_ech >= '".$db->idate($date_start)."' AND cs.date_ech <= '".$db->idate($date_end)."'"; - } - elseif ($modecompta == "RECETTES-DEPENSES") + } elseif ($modecompta == "RECETTES-DEPENSES") { $sql = "SELECT c.libelle as nom, date_format(p.datep,'%Y-%m') as dm, sum(p.amount) as amount"; $sql .= " FROM ".MAIN_DB_PREFIX."c_chargesociales as c"; @@ -553,8 +539,7 @@ if (!empty($conf->tax->enabled) && ($modecompta == 'CREANCES-DETTES' || $modecom } else { dol_print_error($db); } -} -elseif ($modecompta == "BOOKKEEPING") +} elseif ($modecompta == "BOOKKEEPING") { // Nothing from this table } @@ -577,8 +562,7 @@ if (!empty($conf->tax->enabled) && ($modecompta == 'CREANCES-DETTES' || $modecom $sql .= " AND c.deductible = 1"; if (!empty($date_start) && !empty($date_end)) $sql .= " AND cs.date_ech >= '".$db->idate($date_start)."' AND cs.date_ech <= '".$db->idate($date_end)."'"; - } - elseif ($modecompta == "RECETTES-DEPENSES") + } elseif ($modecompta == "RECETTES-DEPENSES") { $sql = "SELECT c.libelle as nom, date_format(p.datep,'%Y-%m') as dm, sum(p.amount) as amount"; $sql .= " FROM ".MAIN_DB_PREFIX."c_chargesociales as c"; @@ -615,8 +599,7 @@ if (!empty($conf->tax->enabled) && ($modecompta == 'CREANCES-DETTES' || $modecom } else { dol_print_error($db); } -} -elseif ($modecompta == "BOOKKEEPING") +} elseif ($modecompta == "BOOKKEEPING") { // Nothing from this table } @@ -663,8 +646,7 @@ if (!empty($conf->salaries->enabled) && ($modecompta == 'CREANCES-DETTES' || $mo } else { dol_print_error($db); } -} -elseif ($modecompta == "BOOKKEEPING") +} elseif ($modecompta == "BOOKKEEPING") { // Nothing from this table } @@ -722,13 +704,10 @@ if (!empty($conf->expensereport->enabled) && ($modecompta == 'CREANCES-DETTES' | $decaiss_ttc[$obj->dm] += $obj->amount_ttc; } } - } - else - { + } else { dol_print_error($db); } -} -elseif ($modecompta == 'BOOKKEEPING') { +} elseif ($modecompta == 'BOOKKEEPING') { // Nothing from this table } @@ -784,16 +763,114 @@ if (!empty($conf->don->enabled) && ($modecompta == 'CREANCES-DETTES' || $modecom $i++; } } - } - else - { + } else { dol_print_error($db); } -} -elseif ($modecompta == 'BOOKKEEPING') { +} elseif ($modecompta == 'BOOKKEEPING') { // Nothing from this table } +/* + * Various Payments + */ + +if (!empty($conf->global->ACCOUNTING_REPORTS_INCLUDE_VARPAY) && !empty($conf->banque->enabled) && ($modecompta == 'CREANCES-DETTES' || $modecompta == "RECETTES-DEPENSES")) +{ + // decaiss + + $sql = "SELECT date_format(p.datep, '%Y-%m') AS dm, SUM(p.amount) AS amount FROM ".MAIN_DB_PREFIX."payment_various as p"; + $sql .= ' WHERE p.sens = 0'; + if (!empty($date_start) && !empty($date_end)) + $sql .= " AND p.datep >= '".$db->idate($date_start)."' AND p.datep <= '".$db->idate($date_end)."'"; + $sql .= ' GROUP BY dm'; + + dol_syslog("get various payments"); + $result = $db->query($sql); + if ($result) + { + $num = $db->num_rows($result); + $i = 0; + if ($num) + { + while ($i < $num) + { + $obj = $db->fetch_object($result); + if (!isset($decaiss_ttc[$obj->dm])) $decaiss_ttc[$obj->dm] = 0; + if (isset($obj->amount)) $decaiss_ttc[$obj->dm] += $obj->amount; + $i++; + } + } + } else { + dol_print_error($db); + } + + // encaiss + + $sql = "SELECT date_format(p.datep, '%Y-%m') AS dm, SUM(p.amount) AS amount FROM ".MAIN_DB_PREFIX."payment_various AS p"; + $sql .= ' WHERE p.sens = 1'; + if (!empty($date_start) && !empty($date_end)) + $sql .= " AND p.datep >= '".$db->idate($date_start)."' AND p.datep <= '".$db->idate($date_end)."'"; + $sql .= ' GROUP BY dm'; + + dol_syslog("get various payments"); + $result = $db->query($sql); + if ($result) + { + $num = $db->num_rows($result); + $i = 0; + if ($num) + { + while ($i < $num) + { + $obj = $db->fetch_object($result); + if (!isset($encaiss_ttc[$obj->dm])) $encaiss_ttc[$obj->dm] = 0; + if (isset($obj->amount)) $encaiss_ttc[$obj->dm] += $obj->amount; + $i++; + } + } + } else { + dol_print_error($db); + } +} +// Useless with BOOKKEEPING +//elseif ($modecompta == 'BOOKKEEPING') { +//} + +/* + * Payement Loan + */ + +if (!empty($conf->global->ACCOUNTING_REPORTS_INCLUDE_LOAN) && !empty($conf->loan->enabled) && ($modecompta == 'CREANCES-DETTES' || $modecompta == "RECETTES-DEPENSES")) +{ + $sql = "SELECT date_format(p.datep, '%Y-%m') AS dm, SUM(p.amount_capital + p.amount_insurance + p.amount_interest) AS amount FROM ".MAIN_DB_PREFIX."payment_loan AS p"; + $sql .= ' WHERE 1 = 1'; + if (!empty($date_start) && !empty($date_end)) + $sql .= " AND p.datep >= '".$db->idate($date_start)."' AND p.datep <= '".$db->idate($date_end)."'"; + $sql .= ' GROUP BY dm'; + + dol_syslog("get loan payments"); + $result = $db->query($sql); + if ($result) + { + $num = $db->num_rows($result); + $i = 0; + if ($num) + { + while ($i < $num) + { + $obj = $db->fetch_object($result); + if (!isset($decaiss_ttc[$obj->dm])) $decaiss_ttc[$obj->dm] = 0; + if (isset($obj->amount)) $decaiss_ttc[$obj->dm] += $obj->amount; + $i++; + } + } + } else { + dol_print_error($db); + } +} +// Useless with BOOKKEEPING +//elseif ($modecompta == 'BOOKKEEPING') { +//} /* @@ -852,9 +929,7 @@ if (!empty($conf->accounting->enabled) && ($modecompta == 'BOOKKEEPING')) $i++; } } - } - else - { + } else { dol_print_error($db); } } @@ -933,9 +1008,7 @@ for ($mois = 1 + $nb_mois_decalage; $mois <= 12 + $nb_mois_decalage; $mois++) if (!isset($totsorties[$annee])) $totsorties[$annee] = 0; $totsorties[$annee] += $decaiss[$case]; } - } - else - { + } else { if (isset($decaiss_ttc[$case]) && $decaiss_ttc[$case] != 0) { print ''.price(price2num($decaiss_ttc[$case], 'MT')).''; @@ -954,9 +1027,7 @@ for ($mois = 1 + $nb_mois_decalage; $mois <= 12 + $nb_mois_decalage; $mois++) if (!isset($totentrees[$annee])) $totentrees[$annee] = 0; $totentrees[$annee] += $encaiss[$case]; } - } - else - { + } else { if (isset($encaiss_ttc[$case])) { print ''.price(price2num($encaiss_ttc[$case], 'MT')).''; diff --git a/htdocs/compta/resultat/result.php b/htdocs/compta/resultat/result.php index 66adea3371f..48cb8b1154e 100644 --- a/htdocs/compta/resultat/result.php +++ b/htdocs/compta/resultat/result.php @@ -90,8 +90,7 @@ if (empty($date_start) || empty($date_end)) // We define date_start and date_end $month_end = $month_start - 1; if ($month_end < 1) $month_end = 12; else $year_end++; - } - else $month_end = $month_start; + } else $month_end = $month_start; $date_start = dol_get_first_day($year_start, $month_start, false); $date_end = dol_get_last_day($year_end, $month_end, false); } if ($q == 1) { $date_start = dol_get_first_day($year_start, 1, false); $date_end = dol_get_last_day($year_start, 3, false); } @@ -178,11 +177,10 @@ if ($modecompta == "CREANCES-DETTES") //$periodlink=''.img_previous().' '.img_next().''; $description = $langs->trans("RulesResultDue"); if (!empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) $description .= $langs->trans("DepositsAreNotIncluded"); - else $description .= $langs->trans("DepositsAreIncluded"); + else $description .= $langs->trans("DepositsAreIncluded"); $builddate = dol_now(); //$exportlink=$langs->trans("NotYetAvailable"); -} -elseif ($modecompta == "RECETTES-DEPENSES") { +} elseif ($modecompta == "RECETTES-DEPENSES") { $name = $langs->trans("AnnualByAccountInputOutputMode"); $calcmode = $langs->trans("CalcModeEngagement"); $calcmode .= '
('.$langs->trans("SeeReportInDueDebtMode", '', '').')'; @@ -192,8 +190,7 @@ elseif ($modecompta == "RECETTES-DEPENSES") { $description = $langs->trans("RulesResultInOut"); $builddate = dol_now(); //$exportlink=$langs->trans("NotYetAvailable"); -} -elseif ($modecompta == "BOOKKEEPING") +} elseif ($modecompta == "BOOKKEEPING") { $name = $langs->trans("ReportInOut").', '.$langs->trans("ByPersonalizedAccountGroups"); $calcmode = $langs->trans("CalcModeBookkeeping"); @@ -248,13 +245,11 @@ if ($modecompta == 'CREANCES-DETTES') { //if (! empty($date_start) && ! empty($date_end)) // $sql.= " AND f.datef >= '".$db->idate($date_start)."' AND f.datef <= '".$db->idate($date_end)."'"; -} -elseif ($modecompta == "RECETTES-DEPENSES") +} elseif ($modecompta == "RECETTES-DEPENSES") { //if (! empty($date_start) && ! empty($date_end)) // $sql.= " AND p.datep >= '".$db->idate($date_start)."' AND p.datep <= '".$db->idate($date_end)."'"; -} -elseif ($modecompta == "BOOKKEEPING") +} elseif ($modecompta == "BOOKKEEPING") { // Get array of all report groups that are active $cats = $AccCat->getCats(); // WARNING: Computed groups must be after group they include @@ -375,7 +370,7 @@ elseif ($modecompta == "BOOKKEEPING") print "\n"; //var_dump($sommes); - } else // normal category + } else // normal category { $code = $cat['code']; // Category code we process diff --git a/htdocs/compta/sociales/card.php b/htdocs/compta/sociales/card.php index d7f20622a43..f9d5a90d543 100644 --- a/htdocs/compta/sociales/card.php +++ b/htdocs/compta/sociales/card.php @@ -128,9 +128,7 @@ if ($action == 'confirm_delete' && $confirm == 'yes') { header("Location: list.php"); exit; - } - else - { + } else { setEventMessages($object->error, $object->errors, 'errors'); } } @@ -145,29 +143,23 @@ if ($action == 'add' && $user->rights->tax->charges->creer) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Date")), null, 'errors'); $action = 'create'; - } - elseif (!$dateperiod) + } elseif (!$dateperiod) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Period")), null, 'errors'); $action = 'create'; - } - elseif (!$actioncode > 0) + } elseif (!$actioncode > 0) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Type")), null, 'errors'); $action = 'create'; - } - elseif (empty($amount)) + } elseif (empty($amount)) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Amount")), null, 'errors'); $action = 'create'; - } - elseif (!is_numeric($amount)) + } elseif (!is_numeric($amount)) { setEventMessages($langs->trans("ErrorFieldMustBeANumeric", $langs->transnoentities("Amount")), null, 'errors'); $action = 'create'; - } - else - { + } else { $object->type = $actioncode; $object->label = GETPOST('label', 'alpha'); $object->date_ech = $dateech; @@ -195,24 +187,19 @@ if ($action == 'update' && !$_POST["cancel"] && $user->rights->tax->charges->cre { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Date")), null, 'errors'); $action = 'edit'; - } - elseif (!$dateperiod) + } elseif (!$dateperiod) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Period")), null, 'errors'); $action = 'edit'; - } - elseif (empty($amount)) + } elseif (empty($amount)) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Amount")), null, 'errors'); $action = 'edit'; - } - elseif (!is_numeric($amount)) + } elseif (!is_numeric($amount)) { setEventMessages($langs->trans("ErrorFieldMustBeANumeric", $langs->transnoentities("Amount")), null, 'errors'); $action = 'create'; - } - else - { + } else { $result = $object->fetch($id); $object->date_ech = $dateech; @@ -245,16 +232,14 @@ if ($action == 'confirm_clone' && $confirm == 'yes' && ($user->rights->tax->char if (GETPOST('clone_label', 'alphanohtml')) { $object->label = GETPOST('clone_label', 'alphanohtml'); - } - else { + } else { $object->label = $langs->trans("CopyOf").' '.$object->label; } if (GETPOST('clone_for_next_month', 'int')) { $object->periode = dol_time_plus_duree($object->periode, 1, 'm'); $object->date_ech = dol_time_plus_duree($object->date_ech, 1, 'm'); - } - else { + } else { $newdateperiod = dol_mktime(0, 0, 0, GETPOST('clone_periodmonth', 'int'), GETPOST('clone_periodday', 'int'), GETPOST('clone_periodyear', 'int')); $newdateech = dol_mktime(0, 0, 0, GETPOST('clone_date_echmonth', 'int'), GETPOST('clone_date_echday', 'int'), GETPOST('clone_date_echyear', 'int')); if ($newdateperiod) $object->periode = $newdateperiod; @@ -271,18 +256,14 @@ if ($action == 'confirm_clone' && $confirm == 'yes' && ($user->rights->tax->char header("Location: ".$_SERVER["PHP_SELF"]."?id=".$id); exit; - } - else - { + } else { $id = $originalId; $db->rollback(); setEventMessages($object->error, $object->errors, 'errors'); } } - } - else - { + } else { $db->rollback(); dol_print_error($db, $object->error); } @@ -431,9 +412,7 @@ if ($id > 0) if (!empty($conf->global->TAX_ADD_CLON_FOR_NEXT_MONTH_CHECKBOX)) { $formquestion[] = array('type' => 'checkbox', 'name' => 'clone_for_next_month', 'label' => $langs->trans("CloneTaxForNextMonth"), 'value' => 1); - } - else - { + } else { $formquestion[] = array('type' => 'date', 'name' => 'clone_date_ech', 'label' => $langs->trans("Date"), 'value' => -1); $formquestion[] = array('type' => 'date', 'name' => 'clone_period', 'label' => $langs->trans("PeriodEndDate"), 'value' => -1); } @@ -535,9 +514,7 @@ if ($id > 0) if ($action == 'edit') { print $form->selectDate($object->periode, 'period', 0, 0, 0, 'charge', 1); - } - else - { + } else { print dol_print_date($object->periode, "day"); } print ""; @@ -548,8 +525,7 @@ if ($id > 0) print ''.$langs->trans("AmountTTC").""; print ''; print ""; - } - else { + } else { print ''.$langs->trans("AmountTTC").''.price($object->amount, 0, $outputlangs, 1, -1, -1, $conf->currency).''; } @@ -674,9 +650,7 @@ if ($id > 0) $totalpaye += $objp->amount; $i++; } - } - else - { + } else { print ''.$langs->trans("None").''; print ''; print ''; @@ -695,9 +669,7 @@ if ($id > 0) print ''; $db->free($resql); - } - else - { + } else { dol_print_error($db); } @@ -767,9 +739,7 @@ if ($id > 0) print ""; } - } - else - { + } else { /* Social contribution not found */ dol_print_error('', $object->error); } diff --git a/htdocs/compta/sociales/class/cchargesociales.class.php b/htdocs/compta/sociales/class/cchargesociales.class.php index b91d9ca31ee..cc66b56aabd 100644 --- a/htdocs/compta/sociales/class/cchargesociales.class.php +++ b/htdocs/compta/sociales/class/cchargesociales.class.php @@ -459,28 +459,23 @@ class Cchargesociales { if ($status == 1) return $langs->trans('Enabled'); elseif ($status == 0) return $langs->trans('Disabled'); - } - elseif ($mode == 1) + } elseif ($mode == 1) { if ($status == 1) return $langs->trans('Enabled'); elseif ($status == 0) return $langs->trans('Disabled'); - } - elseif ($mode == 2) + } elseif ($mode == 2) { if ($status == 1) return img_picto($langs->trans('Enabled'), 'statut4').' '.$langs->trans('Enabled'); elseif ($status == 0) return img_picto($langs->trans('Disabled'), 'statut5').' '.$langs->trans('Disabled'); - } - elseif ($mode == 3) + } elseif ($mode == 3) { if ($status == 1) return img_picto($langs->trans('Enabled'), 'statut4'); elseif ($status == 0) return img_picto($langs->trans('Disabled'), 'statut5'); - } - elseif ($mode == 4) + } elseif ($mode == 4) { if ($status == 1) return img_picto($langs->trans('Enabled'), 'statut4').' '.$langs->trans('Enabled'); elseif ($status == 0) return img_picto($langs->trans('Disabled'), 'statut5').' '.$langs->trans('Disabled'); - } - elseif ($mode == 5) + } elseif ($mode == 5) { if ($status == 1) return $langs->trans('Enabled').' '.img_picto($langs->trans('Enabled'), 'statut4'); elseif ($status == 0) return $langs->trans('Disabled').' '.img_picto($langs->trans('Disabled'), 'statut5'); diff --git a/htdocs/compta/sociales/class/chargesociales.class.php b/htdocs/compta/sociales/class/chargesociales.class.php index 6d3f4dffa4a..81ae1e28f20 100644 --- a/htdocs/compta/sociales/class/chargesociales.class.php +++ b/htdocs/compta/sociales/class/chargesociales.class.php @@ -171,14 +171,10 @@ class ChargeSociales extends CommonObject $this->db->free($resql); return 1; - } - else - { + } else { return 0; } - } - else - { + } else { $this->error = $this->db->lasterror(); return -1; } @@ -252,14 +248,11 @@ class ChargeSociales extends CommonObject if (empty($error)) { $this->db->commit(); return $this->id; - } - else { + } else { $this->db->rollback(); return -1 * $error; } - } - else - { + } else { $this->error = $this->db->error(); $this->db->rollback(); return -1; @@ -328,9 +321,7 @@ class ChargeSociales extends CommonObject { $this->db->commit(); return 1; - } - else - { + } else { $this->db->rollback(); return -1; } @@ -386,9 +377,7 @@ class ChargeSociales extends CommonObject } $this->db->rollback(); return -1 * $error; - } - else - { + } else { $this->db->commit(); return 1; } @@ -421,14 +410,10 @@ class ChargeSociales extends CommonObject $obj = $this->db->fetch_object($result); $this->db->free($result); return $obj->amount; - } - else - { + } else { return 0; } - } - else - { + } else { print $this->db->error(); return -1; } @@ -612,9 +597,7 @@ class ChargeSociales extends CommonObject $this->db->free($resql); return $amount; - } - else - { + } else { return -1; } } @@ -667,9 +650,7 @@ class ChargeSociales extends CommonObject } $this->db->free($result); - } - else - { + } else { dol_print_error($this->db); } } diff --git a/htdocs/compta/sociales/class/paymentsocialcontribution.class.php b/htdocs/compta/sociales/class/paymentsocialcontribution.class.php index bae8d28a756..4cb81422284 100644 --- a/htdocs/compta/sociales/class/paymentsocialcontribution.class.php +++ b/htdocs/compta/sociales/class/paymentsocialcontribution.class.php @@ -194,14 +194,11 @@ class PaymentSocialContribution extends CommonObject if ($remaintopay == 0) { $result = $contrib->set_paid($user); - } - else dol_syslog("Remain to pay for conrib ".$contribid." not null. We do nothing."); + } else dol_syslog("Remain to pay for conrib ".$contribid." not null. We do nothing."); } } } - } - else - { + } else { $error++; } } @@ -215,9 +212,7 @@ class PaymentSocialContribution extends CommonObject $this->total = $totalamount; // deprecated $this->db->commit(); return $this->id; - } - else - { + } else { $this->error = $this->db->error(); $this->db->rollback(); return -1; @@ -286,9 +281,7 @@ class PaymentSocialContribution extends CommonObject $this->db->free($resql); return 1; - } - else - { + } else { $this->error = "Error ".$this->db->lasterror(); return -1; } @@ -358,9 +351,7 @@ class PaymentSocialContribution extends CommonObject } $this->db->rollback(); return -1 * $error; - } - else - { + } else { $this->db->commit(); return 1; } @@ -414,9 +405,7 @@ class PaymentSocialContribution extends CommonObject } $this->db->rollback(); return -1 * $error; - } - else - { + } else { $this->db->commit(); return 1; } @@ -465,9 +454,7 @@ class PaymentSocialContribution extends CommonObject { $this->db->commit(); return $object->id; - } - else - { + } else { $this->db->rollback(); return -1; } @@ -577,9 +564,7 @@ class PaymentSocialContribution extends CommonObject if ($result <= 0) dol_print_error($this->db); } } - } - else - { + } else { $this->error = $acc->error; $error++; } @@ -588,9 +573,7 @@ class PaymentSocialContribution extends CommonObject if (!$error) { return 1; - } - else - { + } else { return -1; } } @@ -613,9 +596,7 @@ class PaymentSocialContribution extends CommonObject if ($result) { return 1; - } - else - { + } else { $this->error = $this->db->error(); return 0; } diff --git a/htdocs/compta/sociales/document.php b/htdocs/compta/sociales/document.php index 3c73c8e6614..e7d76b94a76 100644 --- a/htdocs/compta/sociales/document.php +++ b/htdocs/compta/sociales/document.php @@ -163,9 +163,7 @@ if ($object->id) $permtoedit = $user->rights->fournisseur->facture->creer; $param = '&id='.$object->id; include_once DOL_DOCUMENT_ROOT.'/core/tpl/document_actions_post_headers.tpl.php'; -} -else -{ +} else { print $langs->trans("ErrorUnknown"); } diff --git a/htdocs/compta/sociales/list.php b/htdocs/compta/sociales/list.php index 9d210c23d85..43823490ed9 100644 --- a/htdocs/compta/sociales/list.php +++ b/htdocs/compta/sociales/list.php @@ -80,9 +80,7 @@ if (!GETPOSTISSET('search_typeid')) $part = explode(':', $val); if ($part[0] == 'cs.fk_type') $search_typeid = $part[1]; } -} -else -{ +} else { $search_typeid = GETPOST('search_typeid', 'int'); } @@ -208,9 +206,7 @@ if ($resql) $countrynotdefined = $langs->trans("ErrorSetACountryFirst"); print $countrynotdefined; print ''; - } - else - { + } else { print '
'; print ''."\n"; @@ -313,9 +309,7 @@ if ($resql) if ($obj->periode) { print 'jdate($obj->periode)).'">'.dol_print_date($db->jdate($obj->periode), 'day').''; - } - else - { + } else { print ' '; } print "\n"; @@ -345,9 +339,7 @@ if ($resql) print ''; } print ''; -} -else -{ +} else { dol_print_error($db); } diff --git a/htdocs/compta/sociales/payments.php b/htdocs/compta/sociales/payments.php index 5cfa5df06ed..fc1f66d5e2c 100644 --- a/htdocs/compta/sociales/payments.php +++ b/htdocs/compta/sociales/payments.php @@ -92,9 +92,7 @@ if ($mode != 'sconly') { $center = ($year ? ''.img_previous($langs->trans("Previous"), 'class="valignbottom"')." ".$langs->trans("Year").' '.$year.' '.img_next($langs->trans("Next"), 'class="valignbottom"')."" : ""); print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $center, $num, $totalnboflines, 'title_accountancy', 0, '', '', $limit, 1); -} -else -{ +} else { print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $center, $num, $totalnboflines, 'title_accountancy', 0, '', '', $limit); } @@ -208,9 +206,7 @@ if (!empty($conf->tax->enabled) && $user->rights->tax->charges->lire) print ''; print '"; print ""; - } - else - { + } else { dol_print_error($db); } print '
 '.price($totalpaye)."
'; @@ -287,9 +283,7 @@ if (!empty($conf->tax->enabled) && $user->rights->tax->charges->lire) print ""; $db->free($result); - } - else - { + } else { dol_print_error($db); } } @@ -300,19 +294,15 @@ if ($mysoc->localtax1_assuj == "1" && $mysoc->localtax2_assuj == "1") { $j = 1; $numlt = 3; -} -elseif ($mysoc->localtax1_assuj == "1") +} elseif ($mysoc->localtax1_assuj == "1") { $j = 1; $numlt = 2; -} -elseif ($mysoc->localtax2_assuj == "1") +} elseif ($mysoc->localtax2_assuj == "1") { $j = 2; $numlt = 3; -} -else -{ +} else { $j = 0; $numlt = 0; } @@ -388,9 +378,7 @@ while ($j < $numlt) print ""; $db->free($result); - } - else - { + } else { dol_print_error($db); } } @@ -472,9 +460,7 @@ if (!empty($conf->salaries->enabled) && !empty($user->rights->salaries->read)) $db->free($result); print "
"; - } - else - { + } else { dol_print_error($db); } } diff --git a/htdocs/compta/stats/byratecountry.php b/htdocs/compta/stats/byratecountry.php index acd58f90217..dc5ebd1731d 100644 --- a/htdocs/compta/stats/byratecountry.php +++ b/htdocs/compta/stats/byratecountry.php @@ -77,9 +77,7 @@ if (empty($date_start) || empty($date_end)) // We define date_start and date_end else $year_end++; } $date_start = dol_get_first_day($year_start, $month_start, false); $date_end = dol_get_last_day($year_end, $month_end, false); - } - else - { + } else { if ($q == 1) { $date_start = dol_get_first_day($year_start, 1, false); $date_end = dol_get_last_day($year_start, 3, false); } if ($q == 2) { $date_start = dol_get_first_day($year_start, 4, false); $date_end = dol_get_last_day($year_start, 6, false); } if ($q == 3) { $date_start = dol_get_first_day($year_start, 7, false); $date_end = dol_get_last_day($year_start, 9, false); } @@ -209,8 +207,7 @@ if ($modecompta == "CREANCES-DETTES") { } $builddate = dol_now(); -} -elseif ($modecompta == "RECETTES-DEPENSES") +} elseif ($modecompta == "RECETTES-DEPENSES") { $name = $langs->trans("TurnoverCollected").', '.$langs->trans("ByVatRate"); $calcmode = $langs->trans("CalcModeEngagement"); @@ -220,11 +217,9 @@ elseif ($modecompta == "RECETTES-DEPENSES") $description .= $langs->trans("DepositsAreIncluded"); $builddate = dol_now(); -} -elseif ($modecompta == "BOOKKEEPING") +} elseif ($modecompta == "BOOKKEEPING") { -} -elseif ($modecompta == "BOOKKEEPINGCOLLECTED") +} elseif ($modecompta == "BOOKKEEPINGCOLLECTED") { } $period = $form->selectDate($date_start, 'date_start', 0, 0, 0, '', 1, 0).' - '.$form->selectDate($date_end, 'date_end', 0, 0, 0, '', 1, 0); diff --git a/htdocs/compta/stats/cabyprodserv.php b/htdocs/compta/stats/cabyprodserv.php index 5831467ce63..ab2c1dcadb1 100644 --- a/htdocs/compta/stats/cabyprodserv.php +++ b/htdocs/compta/stats/cabyprodserv.php @@ -103,9 +103,7 @@ if (empty($date_start) || empty($date_end)) // We define date_start and date_end else $year_end++; } $date_start = dol_get_first_day($year_start, $month_start, false); $date_end = dol_get_last_day($year_end, $month_end, false); - } - else - { + } else { if ($q == 1) { $date_start = dol_get_first_day($year_start, 1, false); $date_end = dol_get_last_day($year_start, 3, false); } if ($q == 2) { $date_start = dol_get_first_day($year_start, 4, false); $date_end = dol_get_last_day($year_start, 6, false); } if ($q == 3) { $date_start = dol_get_first_day($year_start, 7, false); $date_end = dol_get_last_day($year_start, 9, false); } @@ -181,8 +179,7 @@ if ($modecompta == "CREANCES-DETTES") { } $builddate = dol_now(); -} -elseif ($modecompta == "RECETTES-DEPENSES") +} elseif ($modecompta == "RECETTES-DEPENSES") { $name = $langs->trans("TurnoverCollected").', '.$langs->trans("ByProductsAndServices"); $calcmode = $langs->trans("CalcModeEngagement"); @@ -192,11 +189,9 @@ elseif ($modecompta == "RECETTES-DEPENSES") $description .= $langs->trans("DepositsAreIncluded"); $builddate = dol_now(); -} -elseif ($modecompta == "BOOKKEEPING") +} elseif ($modecompta == "BOOKKEEPING") { -} -elseif ($modecompta == "BOOKKEEPINGCOLLECTED") +} elseif ($modecompta == "BOOKKEEPINGCOLLECTED") { } @@ -232,8 +227,7 @@ if ($modecompta == 'CREANCES-DETTES') if ($selected_cat === -2) // Without any category { $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."categorie_product as cp ON p.rowid = cp.fk_product"; - } - elseif ($selected_cat) // Into a specific category + } elseif ($selected_cat) // Into a specific category { $sql .= ", ".MAIN_DB_PREFIX."categorie as c, ".MAIN_DB_PREFIX."categorie_product as cp"; } @@ -255,8 +249,7 @@ if ($modecompta == 'CREANCES-DETTES') if ($selected_cat === -2) // Without any category { $sql .= " AND cp.fk_product is null"; - } - elseif ($selected_cat) { // Into a specific category + } elseif ($selected_cat) { // Into a specific category $sql .= " AND (c.rowid = ".$selected_cat; if ($subcat) $sql .= " OR c.fk_parent = ".$selected_cat; $sql .= ")"; diff --git a/htdocs/compta/stats/cabyuser.php b/htdocs/compta/stats/cabyuser.php index 4d4f56a1354..8b6caa89a8f 100644 --- a/htdocs/compta/stats/cabyuser.php +++ b/htdocs/compta/stats/cabyuser.php @@ -96,9 +96,7 @@ if (empty($date_start) || empty($date_end)) // We define date_start and date_end if ($q == 2) { $date_start = dol_get_first_day($year_start, 4, false); $date_end = dol_get_last_day($year_start, 6, false); } if ($q == 3) { $date_start = dol_get_first_day($year_start, 7, false); $date_end = dol_get_last_day($year_start, 9, false); } if ($q == 4) { $date_start = dol_get_first_day($year_start, 10, false); $date_end = dol_get_last_day($year_start, 12, false); } -} -else -{ +} else { // TODO We define q } // $date_start and $date_end are defined. We force $year_start and $nbofyear @@ -154,11 +152,10 @@ if ($modecompta == "CREANCES-DETTES") { //$calcmode.='
('.$langs->trans("SeeReportInInputOutputMode",'','').')'; $description = $langs->trans("RulesCADue"); if (!empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) $description .= $langs->trans("DepositsAreNotIncluded"); - else $description .= $langs->trans("DepositsAreIncluded"); + else $description .= $langs->trans("DepositsAreIncluded"); $builddate = dol_now(); //$exportlink=$langs->trans("NotYetAvailable"); -} -elseif ($modecompta == "RECETTES-DEPENSES") +} elseif ($modecompta == "RECETTES-DEPENSES") { $name = $langs->trans("TurnoverCollected").', '.$langs->trans("ByUserAuthorOfInvoice"); $calcmode = $langs->trans("CalcModeEngagement"); @@ -167,12 +164,10 @@ elseif ($modecompta == "RECETTES-DEPENSES") $description .= $langs->trans("DepositsAreIncluded"); $builddate = dol_now(); //$exportlink=$langs->trans("NotYetAvailable"); -} -elseif ($modecompta == "BOOKKEEPING") +} elseif ($modecompta == "BOOKKEEPING") { // TODO -} -elseif ($modecompta == "BOOKKEEPINGCOLLECTED") +} elseif ($modecompta == "BOOKKEEPINGCOLLECTED") { // TODO } @@ -396,8 +391,7 @@ if (count($amount)) { } else { //print ''; } - } - elseif ($modecompta == 'CREANCES-DETTES') { + } elseif ($modecompta == 'CREANCES-DETTES') { if ($key > 0) { print ''; } else { @@ -416,8 +410,7 @@ if (count($amount)) { } else { //print ''; } - } - elseif ($modecompta == 'CREANCES-DETTES') { + } elseif ($modecompta == 'CREANCES-DETTES') { if ($key > 0) { print ''; } else { @@ -431,8 +424,7 @@ if (count($amount)) { } else { //print ''; } - } - elseif ($modecompta == 'CREANCES-DETTES') { + } elseif ($modecompta == 'CREANCES-DETTES') { if ($key > 0) { print ''; } diff --git a/htdocs/compta/stats/casoc.php b/htdocs/compta/stats/casoc.php index bec20998cfa..ab71b147b50 100644 --- a/htdocs/compta/stats/casoc.php +++ b/htdocs/compta/stats/casoc.php @@ -113,9 +113,7 @@ if (empty($date_start) || empty($date_end)) // We define date_start and date_end if ($q == 2) { $date_start = dol_get_first_day($year_start, 4, false); $date_end = dol_get_last_day($year_start, 6, false); } if ($q == 3) { $date_start = dol_get_first_day($year_start, 7, false); $date_end = dol_get_last_day($year_start, 9, false); } if ($q == 4) { $date_start = dol_get_first_day($year_start, 10, false); $date_end = dol_get_last_day($year_start, 12, false); } -} -else -{ +} else { // TODO We define q } @@ -180,11 +178,10 @@ if ($modecompta == "CREANCES-DETTES") //$calcmode.='
('.$langs->trans("SeeReportInInputOutputMode",'','').')'; $description = $langs->trans("RulesCADue"); if (!empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) $description .= $langs->trans("DepositsAreNotIncluded"); - else $description .= $langs->trans("DepositsAreIncluded"); + else $description .= $langs->trans("DepositsAreIncluded"); $builddate = dol_now(); //$exportlink=$langs->trans("NotYetAvailable"); -} -elseif ($modecompta == "RECETTES-DEPENSES") +} elseif ($modecompta == "RECETTES-DEPENSES") { $name = $langs->trans("TurnoverCollected").', '.$langs->trans("ByThirdParties"); $calcmode = $langs->trans("CalcModeEngagement"); @@ -193,11 +190,9 @@ elseif ($modecompta == "RECETTES-DEPENSES") $description .= $langs->trans("DepositsAreIncluded"); $builddate = dol_now(); //$exportlink=$langs->trans("NotYetAvailable"); -} -elseif ($modecompta == "BOOKKEEPING") +} elseif ($modecompta == "BOOKKEEPING") { -} -elseif ($modecompta == "BOOKKEEPINGCOLLECTED") +} elseif ($modecompta == "BOOKKEEPINGCOLLECTED") { } $period = $form->selectDate($date_start, 'date_start', 0, 0, 0, '', 1, 0).' - '.$form->selectDate($date_end, 'date_end', 0, 0, 0, '', 1, 0); @@ -223,8 +218,7 @@ if ($modecompta == 'CREANCES-DETTES') { if ($selected_cat === -2) // Without any category { $sql .= " LEFT OUTER JOIN ".MAIN_DB_PREFIX."categorie_societe as cs ON s.rowid = cs.fk_soc"; - } - elseif ($selected_cat) // Into a specific category + } elseif ($selected_cat) // Into a specific category { $sql .= ", ".MAIN_DB_PREFIX."categorie as c, ".MAIN_DB_PREFIX."categorie_societe as cs"; } @@ -241,8 +235,7 @@ if ($modecompta == 'CREANCES-DETTES') { if ($selected_cat === -2) // Without any category { $sql .= " AND cs.fk_soc is null"; - } - elseif ($selected_cat) { // Into a specific category + } elseif ($selected_cat) { // Into a specific category $sql .= " AND (c.rowid = ".$db->escape($selected_cat); if ($subcat) $sql .= " OR c.fk_parent = ".$db->escape($selected_cat); $sql .= ")"; @@ -261,8 +254,7 @@ if ($modecompta == 'CREANCES-DETTES') { if ($selected_cat === -2) // Without any category { $sql .= " LEFT OUTER JOIN ".MAIN_DB_PREFIX."categorie_societe as cs ON s.rowid = cs.fk_soc"; - } - elseif ($selected_cat) // Into a specific category + } elseif ($selected_cat) // Into a specific category { $sql .= ", ".MAIN_DB_PREFIX."categorie as c, ".MAIN_DB_PREFIX."categorie_societe as cs"; } @@ -275,8 +267,7 @@ if ($modecompta == 'CREANCES-DETTES') { if ($selected_cat === -2) // Without any category { $sql .= " AND cs.fk_soc is null"; - } - elseif ($selected_cat) { // Into a specific category + } elseif ($selected_cat) { // Into a specific category $sql .= " AND (c.rowid = ".$selected_cat; if ($subcat) $sql .= " OR c.fk_parent = ".$selected_cat; $sql .= ")"; diff --git a/htdocs/compta/stats/index.php b/htdocs/compta/stats/index.php index d1a64e218d2..796ce2cc6a6 100644 --- a/htdocs/compta/stats/index.php +++ b/htdocs/compta/stats/index.php @@ -73,8 +73,7 @@ if (empty($date_start) || empty($date_end)) // We define date_start and date_end } $month_end = $month_start - 1; if ($month_end < 1) $month_end = 12; - } - else $month_end = $month_start; + } else $month_end = $month_start; $date_start = dol_get_first_day($year_start, $month_start, false); $date_end = dol_get_last_day($year_end, $month_end, false); } if ($q == 1) { $date_start = dol_get_first_day($year_start, 1, false); $date_end = dol_get_last_day($year_start, 3, false); } @@ -124,11 +123,10 @@ if ($modecompta == "CREANCES-DETTES") $periodlink = ($year_start ? "".img_previous()." ".img_next()."" : ""); $description = $langs->trans("RulesCADue"); if (!empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) $description .= $langs->trans("DepositsAreNotIncluded"); - else $description .= $langs->trans("DepositsAreIncluded"); + else $description .= $langs->trans("DepositsAreIncluded"); $builddate = dol_now(); //$exportlink=$langs->trans("NotYetAvailable"); -} -elseif ($modecompta == "RECETTES-DEPENSES") +} elseif ($modecompta == "RECETTES-DEPENSES") { $name = $langs->trans("TurnoverCollected"); $calcmode = $langs->trans("CalcModeEngagement"); @@ -140,8 +138,7 @@ elseif ($modecompta == "RECETTES-DEPENSES") $description .= $langs->trans("DepositsAreIncluded"); $builddate = dol_now(); //$exportlink=$langs->trans("NotYetAvailable"); -} -elseif ($modecompta == "BOOKKEEPING") +} elseif ($modecompta == "BOOKKEEPING") { $name = $langs->trans("Turnover"); $calcmode = $langs->trans("CalcModeBookkeeping"); @@ -173,8 +170,7 @@ if ($modecompta == 'CREANCES-DETTES') else $sql .= " AND f.type IN (0,1,2,3,5)"; $sql .= " AND f.entity IN (".getEntity('invoice').")"; if ($socid) $sql .= " AND f.fk_soc = ".$socid; -} -elseif ($modecompta == "RECETTES-DEPENSES") +} elseif ($modecompta == "RECETTES-DEPENSES") { /* * Liste des paiements (les anciens paiements ne sont pas vus par cette requete car, sur les @@ -188,8 +184,7 @@ elseif ($modecompta == "RECETTES-DEPENSES") $sql .= " AND pf.fk_facture = f.rowid"; $sql .= " AND f.entity IN (".getEntity('invoice').")"; if ($socid) $sql .= " AND f.fk_soc = ".$socid; -} -elseif ($modecompta == "BOOKKEEPING") +} elseif ($modecompta == "BOOKKEEPING") { $sql = "SELECT date_format(b.doc_date,'%Y-%m') as dm, sum(b.credit) as amount_ttc"; $sql .= " FROM ".MAIN_DB_PREFIX."accounting_bookkeeping as b, ".MAIN_DB_PREFIX."accounting_journal as aj"; @@ -223,8 +218,7 @@ if ($result) $i++; } $db->free($result); -} -else { +} else { dol_print_error($db); } @@ -259,9 +253,7 @@ if ($modecompta == 'RECETTES-DEPENSES') } $i++; } - } - else - { + } else { dol_print_error($db); } } @@ -339,11 +331,8 @@ for ($mois = 1 + $nb_mois_decalage; $mois <= 12 + $nb_mois_decalage; $mois++) { $now_show_delta = 1; // On a trouve le premier mois de la premiere annee generant du chiffre. print ''.price($cum_ht[$case], 1).''; - } - else - { - if ($minyearmonth < $case && $case <= max($maxyearmonth, $nowyearmonth)) { print '0'; } - else { print ' '; } + } else { + if ($minyearmonth < $case && $case <= max($maxyearmonth, $nowyearmonth)) { print '0'; } else { print ' '; } } print ""; } @@ -356,11 +345,8 @@ for ($mois = 1 + $nb_mois_decalage; $mois <= 12 + $nb_mois_decalage; $mois++) if ($modecompta != 'BOOKKEEPING') print ''; print price($cum[$case], 1); if ($modecompta != 'BOOKKEEPING') print ''; - } - else - { - if ($minyearmonth < $case && $case <= max($maxyearmonth, $nowyearmonth)) { print '0'; } - else { print ' '; } + } else { + if ($minyearmonth < $case && $case <= max($maxyearmonth, $nowyearmonth)) { print '0'; } else { print ' '; } } print ""; @@ -390,12 +376,9 @@ for ($mois = 1 + $nb_mois_decalage; $mois <= 12 + $nb_mois_decalage; $mois++) { print '-'; } - } - else - { + } else { print ''; - if ($minyearmonth <= $case && $case <= $maxyearmonth) { print '-'; } - else { print ' '; } + if ($minyearmonth <= $case && $case <= $maxyearmonth) { print '-'; } else { print ' '; } print ''; } @@ -483,9 +466,7 @@ for ($annee = $year_start; $annee <= $year_end; $annee++) if ($total_ht[$annee] || ($annee >= $minyear && $annee <= max($nowyear, $maxyear))) { print ''.($total_ht[$annee] ?price($total_ht[$annee]) : "0").""; - } - else - { + } else { print ' '; } } @@ -494,9 +475,7 @@ for ($annee = $year_start; $annee <= $year_end; $annee++) if ($total[$annee] || ($annee >= $minyear && $annee <= max($nowyear, $maxyear))) { print ''.($total[$annee] ?price($total[$annee]) : "0").""; - } - else - { + } else { print ' '; } @@ -519,12 +498,9 @@ for ($annee = $year_start; $annee <= $year_end; $annee++) { print '+0%'; } - } - else - { + } else { print ''; - if ($total[$annee] || ($minyear <= $annee && $annee <= max($nowyear, $maxyear))) { print '-'; } - else { print ' '; } + if ($total[$annee] || ($minyear <= $annee && $annee <= max($nowyear, $maxyear))) { print '-'; } else { print ' '; } print ''; } diff --git a/htdocs/compta/stats/supplier_turnover.php b/htdocs/compta/stats/supplier_turnover.php index 3ff41f4d114..c257d5d1f73 100644 --- a/htdocs/compta/stats/supplier_turnover.php +++ b/htdocs/compta/stats/supplier_turnover.php @@ -69,8 +69,7 @@ if (empty($date_start) || empty($date_end)) // We define date_start and date_end } $month_end = $month_start - 1; if ($month_end < 1) $month_end = 12; - } - else $month_end = $month_start; + } else $month_end = $month_start; $date_start = dol_get_first_day($year_start, $month_start, false); $date_end = dol_get_last_day($year_end, $month_end, false); } if ($q == 1) { $date_start = dol_get_first_day($year_start, 1, false); $date_end = dol_get_last_day($year_start, 3, false); } @@ -121,8 +120,7 @@ if ($modecompta == "CREANCES-DETTES") $description = $langs->trans("RulesPurchaseTurnoverDue"); $builddate = dol_now(); //$exportlink=$langs->trans("NotYetAvailable"); -} -elseif ($modecompta == "RECETTES-DEPENSES") +} elseif ($modecompta == "RECETTES-DEPENSES") { $name = $langs->trans("PurchaseTurnoverCollected"); $calcmode = $langs->trans("CalcModeEngagement"); @@ -133,8 +131,7 @@ elseif ($modecompta == "RECETTES-DEPENSES") $description = $langs->trans("RulesPurchaseTurnoverIn"); $builddate = dol_now(); //$exportlink=$langs->trans("NotYetAvailable"); -} -elseif ($modecompta == "BOOKKEEPING") +} elseif ($modecompta == "BOOKKEEPING") { $name = $langs->trans("PurchaseTurnover"); $calcmode = $langs->trans("CalcModeBookkeeping"); @@ -165,8 +162,7 @@ if ($modecompta == 'CREANCES-DETTES') $sql .= " AND f.type IN (0,2)"; $sql .= " AND f.entity IN (".getEntity('supplier_invoice').")"; if ($socid) $sql .= " AND f.fk_soc = ".$socid; -} -elseif ($modecompta == "RECETTES-DEPENSES") +} elseif ($modecompta == "RECETTES-DEPENSES") { $sql = "SELECT date_format(p.datep,'%Y-%m') as dm, sum(pf.amount) as amount_ttc"; $sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn as f"; @@ -176,8 +172,7 @@ elseif ($modecompta == "RECETTES-DEPENSES") $sql .= " AND pf.fk_facturefourn = f.rowid"; $sql .= " AND f.entity IN (".getEntity('supplier_invoice').")"; if ($socid) $sql .= " AND f.fk_soc = ".$socid; -} -elseif ($modecompta == "BOOKKEEPING") +} elseif ($modecompta == "BOOKKEEPING") { $sql = "SELECT date_format(b.doc_date,'%Y-%m') as dm, sum(b.debit) as amount_ttc"; $sql .= " FROM ".MAIN_DB_PREFIX."accounting_bookkeeping as b, ".MAIN_DB_PREFIX."accounting_journal as aj"; @@ -211,8 +206,7 @@ if ($result) $i++; } $db->free($result); -} -else { +} else { dol_print_error($db); } @@ -289,11 +283,8 @@ for ($mois = 1 + $nb_mois_decalage; $mois <= 12 + $nb_mois_decalage; $mois++) { $now_show_delta = 1; // On a trouve le premier mois de la premiere annee generant du chiffre. print ''.price($cum_ht[$case], 1).''; - } - else - { - if ($minyearmonth < $case && $case <= max($maxyearmonth, $nowyearmonth)) { print '0'; } - else { print ' '; } + } else { + if ($minyearmonth < $case && $case <= max($maxyearmonth, $nowyearmonth)) { print '0'; } else { print ' '; } } print ""; } @@ -306,11 +297,8 @@ for ($mois = 1 + $nb_mois_decalage; $mois <= 12 + $nb_mois_decalage; $mois++) if ($modecompta != 'BOOKKEEPING') print ''; print price($cum[$case], 1); if ($modecompta != 'BOOKKEEPING') print ''; - } - else - { - if ($minyearmonth < $case && $case <= max($maxyearmonth, $nowyearmonth)) { print '0'; } - else { print ' '; } + } else { + if ($minyearmonth < $case && $case <= max($maxyearmonth, $nowyearmonth)) { print '0'; } else { print ' '; } } print ""; @@ -340,12 +328,9 @@ for ($mois = 1 + $nb_mois_decalage; $mois <= 12 + $nb_mois_decalage; $mois++) { print '-'; } - } - else - { + } else { print ''; - if ($minyearmonth <= $case && $case <= $maxyearmonth) { print '-'; } - else { print ' '; } + if ($minyearmonth <= $case && $case <= $maxyearmonth) { print '-'; } else { print ' '; } print ''; } @@ -368,9 +353,7 @@ for ($annee = $year_start; $annee <= $year_end; $annee++) if ($total_ht[$annee] || ($annee >= $minyear && $annee <= max($nowyear, $maxyear))) { print ''.($total_ht[$annee] ?price($total_ht[$annee]) : "0").""; - } - else - { + } else { print ' '; } } @@ -379,9 +362,7 @@ for ($annee = $year_start; $annee <= $year_end; $annee++) if ($total[$annee] || ($annee >= $minyear && $annee <= max($nowyear, $maxyear))) { print ''.($total[$annee] ?price($total[$annee]) : "0").""; - } - else - { + } else { print ' '; } @@ -404,12 +385,9 @@ for ($annee = $year_start; $annee <= $year_end; $annee++) { print '+0%'; } - } - else - { + } else { print ''; - if ($total[$annee] || ($minyear <= $annee && $annee <= max($nowyear, $maxyear))) { print '-'; } - else { print ' '; } + if ($total[$annee] || ($minyear <= $annee && $annee <= max($nowyear, $maxyear))) { print '-'; } else { print ' '; } print ''; } diff --git a/htdocs/compta/stats/supplier_turnover_by_prodserv.php b/htdocs/compta/stats/supplier_turnover_by_prodserv.php index fafb967ace1..5911daaba45 100644 --- a/htdocs/compta/stats/supplier_turnover_by_prodserv.php +++ b/htdocs/compta/stats/supplier_turnover_by_prodserv.php @@ -100,9 +100,7 @@ if (empty($date_start) || empty($date_end)) // We define date_start and date_end else $year_end++; } $date_start = dol_get_first_day($year_start, $month_start, false); $date_end = dol_get_last_day($year_end, $month_end, false); - } - else - { + } else { if ($q == 1) { $date_start = dol_get_first_day($year_start, 1, false); $date_end = dol_get_last_day($year_start, 3, false); } if ($q == 2) { $date_start = dol_get_first_day($year_start, 4, false); $date_end = dol_get_last_day($year_start, 6, false); } if ($q == 3) { $date_start = dol_get_first_day($year_start, 7, false); $date_end = dol_get_last_day($year_start, 9, false); } @@ -172,8 +170,7 @@ if ($modecompta == "CREANCES-DETTES") { $description = $langs->trans("RulesPurchaseTurnoverDue"); $builddate = dol_now(); -} -elseif ($modecompta == "RECETTES-DEPENSES") +} elseif ($modecompta == "RECETTES-DEPENSES") { $name = $langs->trans("PurchaseTurnoverCollected").', '.$langs->trans("ByProductsAndServices"); $calcmode = $langs->trans("CalcModeEngagement"); @@ -181,11 +178,9 @@ elseif ($modecompta == "RECETTES-DEPENSES") $description = $langs->trans("RulesPurchaseTurnoverIn"); $builddate = dol_now(); -} -elseif ($modecompta == "BOOKKEEPING") +} elseif ($modecompta == "BOOKKEEPING") { -} -elseif ($modecompta == "BOOKKEEPINGCOLLECTED") +} elseif ($modecompta == "BOOKKEEPINGCOLLECTED") { } @@ -221,8 +216,7 @@ if ($modecompta == 'CREANCES-DETTES') if ($selected_cat === -2) // Without any category { $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."categorie_product as cp ON p.rowid = cp.fk_product"; - } - elseif ($selected_cat) // Into a specific category + } elseif ($selected_cat) // Into a specific category { $sql .= ", ".MAIN_DB_PREFIX."categorie as c, ".MAIN_DB_PREFIX."categorie_product as cp"; } @@ -240,8 +234,7 @@ if ($modecompta == 'CREANCES-DETTES') if ($selected_cat === -2) // Without any category { $sql .= " AND cp.fk_product is null"; - } - elseif ($selected_cat) { // Into a specific category + } elseif ($selected_cat) { // Into a specific category $sql .= " AND (c.rowid = ".$selected_cat; if ($subcat) $sql .= " OR c.fk_parent = ".$selected_cat; $sql .= ")"; diff --git a/htdocs/compta/stats/supplier_turnover_by_thirdparty.php b/htdocs/compta/stats/supplier_turnover_by_thirdparty.php index fcae12f744b..60d65049800 100644 --- a/htdocs/compta/stats/supplier_turnover_by_thirdparty.php +++ b/htdocs/compta/stats/supplier_turnover_by_thirdparty.php @@ -107,9 +107,7 @@ if (empty($date_start) || empty($date_end)) // We define date_start and date_end if ($q == 2) { $date_start = dol_get_first_day($year_start, 4, false); $date_end = dol_get_last_day($year_start, 6, false); } if ($q == 3) { $date_start = dol_get_first_day($year_start, 7, false); $date_end = dol_get_last_day($year_start, 9, false); } if ($q == 4) { $date_start = dol_get_first_day($year_start, 10, false); $date_end = dol_get_last_day($year_start, 12, false); } -} -else -{ +} else { // TODO We define q } @@ -175,8 +173,7 @@ if ($modecompta == "CREANCES-DETTES") $description = $langs->trans("RulesPurchaseTurnoverDue"); $builddate = dol_now(); //$exportlink=$langs->trans("NotYetAvailable"); -} -elseif ($modecompta == "RECETTES-DEPENSES") +} elseif ($modecompta == "RECETTES-DEPENSES") { $name = $langs->trans("PurchaseTurnoverCollected").', '.$langs->trans("ByThirdParties"); $calcmode = $langs->trans("CalcModeEngagement"); @@ -184,11 +181,9 @@ elseif ($modecompta == "RECETTES-DEPENSES") $description = $langs->trans("RulesPurchaseTurnoverIn"); $builddate = dol_now(); //$exportlink=$langs->trans("NotYetAvailable"); -} -elseif ($modecompta == "BOOKKEEPING") +} elseif ($modecompta == "BOOKKEEPING") { -} -elseif ($modecompta == "BOOKKEEPINGCOLLECTED") +} elseif ($modecompta == "BOOKKEEPINGCOLLECTED") { } $period = $form->selectDate($date_start, 'date_start', 0, 0, 0, '', 1, 0).' - '.$form->selectDate($date_end, 'date_end', 0, 0, 0, '', 1, 0); @@ -215,8 +210,7 @@ if ($modecompta == 'CREANCES-DETTES') { if ($selected_cat === -2) // Without any category { $sql .= " LEFT OUTER JOIN ".MAIN_DB_PREFIX."categorie_societe as cs ON s.rowid = cs.fk_soc"; - } - elseif ($selected_cat) // Into a specific category + } elseif ($selected_cat) // Into a specific category { $sql .= ", ".MAIN_DB_PREFIX."categorie as c, ".MAIN_DB_PREFIX."categorie_societe as cs"; } @@ -229,8 +223,7 @@ if ($modecompta == 'CREANCES-DETTES') { if ($selected_cat === -2) // Without any category { $sql .= " AND cs.fk_soc is null"; - } - elseif ($selected_cat) { // Into a specific category + } elseif ($selected_cat) { // Into a specific category $sql .= " AND (c.rowid = ".$db->escape($selected_cat); if ($subcat) $sql .= " OR c.fk_parent = ".$db->escape($selected_cat); $sql .= ")"; @@ -245,8 +238,7 @@ if ($modecompta == 'CREANCES-DETTES') { if ($selected_cat === -2) // Without any category { $sql .= " LEFT OUTER JOIN ".MAIN_DB_PREFIX."categorie_societe as cs ON s.rowid = cs.fk_soc"; - } - elseif ($selected_cat) // Into a specific category + } elseif ($selected_cat) // Into a specific category { $sql .= ", ".MAIN_DB_PREFIX."categorie as c, ".MAIN_DB_PREFIX."categorie_societe as cs"; } @@ -259,8 +251,7 @@ if ($modecompta == 'CREANCES-DETTES') { if ($selected_cat === -2) // Without any category { $sql .= " AND cs.fk_soc is null"; - } - elseif ($selected_cat) { // Into a specific category + } elseif ($selected_cat) { // Into a specific category $sql .= " AND (c.rowid = ".$selected_cat; if ($subcat) $sql .= " OR c.fk_parent = ".$selected_cat; $sql .= ")"; diff --git a/htdocs/compta/tva/card.php b/htdocs/compta/tva/card.php index 658c9353a00..6fa22885dee 100644 --- a/htdocs/compta/tva/card.php +++ b/htdocs/compta/tva/card.php @@ -131,9 +131,7 @@ if ($action == 'add' && $_POST["cancel"] <> $langs->trans("Cancel")) $db->commit(); header("Location: list.php"); exit; - } - else - { + } else { $db->rollback(); setEventMessages($object->error, $object->errors, 'errors'); $action = "create"; @@ -166,22 +164,16 @@ if ($action == 'delete') $db->commit(); header("Location: ".DOL_URL_ROOT.'/compta/tva/list.php'); exit; - } - else - { + } else { $object->error = $accountline->error; $db->rollback(); setEventMessages($object->error, $object->errors, 'errors'); } - } - else - { + } else { $db->rollback(); setEventMessages($object->error, $object->errors, 'errors'); } - } - else - { + } else { $mesg = 'Error try do delete a line linked to a conciliated bank transaction'; setEventMessages($mesg, null, 'errors'); } @@ -388,14 +380,10 @@ if ($id) if (!empty($user->rights->tax->charges->supprimer)) { print ''; - } - else - { + } else { print ''; } - } - else - { + } else { print ''; } print "
"; diff --git a/htdocs/compta/tva/class/tva.class.php b/htdocs/compta/tva/class/tva.class.php index c01408f3c9a..3274a3eaebd 100644 --- a/htdocs/compta/tva/class/tva.class.php +++ b/htdocs/compta/tva/class/tva.class.php @@ -150,15 +150,11 @@ class Tva extends CommonObject { $this->db->commit(); return $this->id; - } - else - { + } else { $this->db->rollback(); return -1; } - } - else - { + } else { $this->error = "Error ".$this->db->lasterror(); $this->db->rollback(); return -1; @@ -224,9 +220,7 @@ class Tva extends CommonObject { $this->db->commit(); return 1; - } - else - { + } else { $this->db->rollback(); return -1; } @@ -293,9 +287,7 @@ class Tva extends CommonObject $this->db->free($resql); return 1; - } - else - { + } else { $this->error = "Error ".$this->db->lasterror(); return -1; } @@ -404,15 +396,11 @@ class Tva extends CommonObject $ret = $obj->amount; $this->db->free($result); return $ret; - } - else - { + } else { $this->db->free($result); return 0; } - } - else - { + } else { print $this->db->lasterror(); return -1; } @@ -445,15 +433,11 @@ class Tva extends CommonObject $ret = $obj->total_tva; $this->db->free($result); return $ret; - } - else - { + } else { $this->db->free($result); return 0; } - } - else - { + } else { print $this->db->lasterror(); return -1; } @@ -488,15 +472,11 @@ class Tva extends CommonObject $ret = $obj->amount; $this->db->free($result); return $ret; - } - else - { + } else { $this->db->free($result); return 0; } - } - else - { + } else { print $this->db->lasterror(); return -1; } @@ -612,9 +592,7 @@ class Tva extends CommonObject if ($bank_line_id > 0) { $this->update_fk_bank($bank_line_id); - } - else - { + } else { $this->error = $acc->error; $ok = 0; } @@ -632,21 +610,15 @@ class Tva extends CommonObject { $this->db->commit(); return $this->id; - } - else - { + } else { $this->db->rollback(); return -3; } - } - else - { + } else { $this->db->rollback(); return -2; } - } - else - { + } else { $this->error = $this->db->error(); $this->db->rollback(); return -1; @@ -669,9 +641,7 @@ class Tva extends CommonObject if ($result) { return 1; - } - else - { + } else { dol_print_error($this->db); return -1; } @@ -710,8 +680,7 @@ class Tva extends CommonObject } $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"'; $linkclose .= ' class="classfortooltip'.($morecss ? ' '.$morecss : '').'"'; - } - else $linkclose = ($morecss ? ' class="'.$morecss.'"' : ''); + } else $linkclose = ($morecss ? ' class="'.$morecss.'"' : ''); $linkstart = ''; @@ -752,9 +721,7 @@ class Tva extends CommonObject $this->db->free($resql); return $amount; - } - else - { + } else { return -1; } } @@ -799,9 +766,7 @@ class Tva extends CommonObject } $this->db->free($result); - } - else - { + } else { dol_print_error($this->db); } } diff --git a/htdocs/compta/tva/clients.php b/htdocs/compta/tva/clients.php index bcedba7a074..52466e33d84 100644 --- a/htdocs/compta/tva/clients.php +++ b/htdocs/compta/tva/clients.php @@ -66,14 +66,11 @@ if (empty($date_start) || empty($date_end)) // We define date_start and date_end $q = GETPOST("q", "int"); if (empty($q)) { - if (GETPOST("month", 'int')) { $date_start = dol_get_first_day($year_start, GETPOST("month", 'int'), false); $date_end = dol_get_last_day($year_start, GETPOST("month", 'int'), false); } - else - { + if (GETPOST("month", 'int')) { $date_start = dol_get_first_day($year_start, GETPOST("month", 'int'), false); $date_end = dol_get_last_day($year_start, GETPOST("month", 'int'), false); } else { if (empty($conf->global->MAIN_INFO_VAT_RETURN) || $conf->global->MAIN_INFO_VAT_RETURN == 2) { // quaterly vat, we take last past complete quarter $date_start = dol_time_plus_duree(dol_get_first_day($year_start, $current_date['mon'], false), -3 - (($current_date['mon'] - $conf->global->SOCIETE_FISCAL_MONTH_START) % 3), 'm'); $date_end = dol_time_plus_duree($date_start, 3, 'm') - 1; - } - elseif ($conf->global->MAIN_INFO_VAT_RETURN == 3) { // yearly vat + } elseif ($conf->global->MAIN_INFO_VAT_RETURN == 3) { // yearly vat if ($current_date['mon'] < $conf->global->SOCIETE_FISCAL_MONTH_START) { if (($conf->global->SOCIETE_FISCAL_MONTH_START - $current_date['mon']) > 6) { // If period started from less than 6 years, we show past year $year_start--; @@ -85,15 +82,12 @@ if (empty($date_start) || empty($date_end)) // We define date_start and date_end } $date_start = dol_get_first_day($year_start, $conf->global->SOCIETE_FISCAL_MONTH_START, false); $date_end = dol_time_plus_duree($date_start, 1, 'y') - 1; - } - elseif ($conf->global->MAIN_INFO_VAT_RETURN == 1) { // monthly vat, we take last past complete month + } elseif ($conf->global->MAIN_INFO_VAT_RETURN == 1) { // monthly vat, we take last past complete month $date_start = dol_time_plus_duree(dol_get_first_day($year_start, $current_date['mon'], false), -1, 'm'); $date_end = dol_time_plus_duree($date_start, 1, 'm') - 1; } } - } - else - { + } else { if ($q == 1) { $date_start = dol_get_first_day($year_start, 1, false); $date_end = dol_get_last_day($year_start, 3, false); } if ($q == 2) { $date_start = dol_get_first_day($year_start, 4, false); $date_end = dol_get_last_day($year_start, 6, false); } if ($q == 3) { $date_start = dol_get_first_day($year_start, 7, false); $date_end = dol_get_last_day($year_start, 9, false); } @@ -321,9 +315,7 @@ if (!is_array($x_coll) || !is_array($x_paye)) 'vat' =>$x_paye[$my_paye_thirdpartyid]['vat_list'][$id], 'link' =>$expensereport->getNomUrl(1) ); - } - else - { + } else { $invoice_supplier->id = $x_paye[$my_paye_thirdpartyid]['facid'][$id]; $invoice_supplier->ref = $x_paye[$my_paye_thirdpartyid]['facnum'][$id]; $invoice_supplier->type = $x_paye[$my_paye_thirdpartyid]['type'][$id]; @@ -693,9 +685,7 @@ if (!is_array($x_coll) || !is_array($x_paye)) || ($type == 1 && $conf->global->TAX_MODE_BUY_SERVICE == 'invoice')) { print $langs->trans("NA"); - } - else - { + } else { if (isset($fields['payment_amount']) && $fields['ftotal_ttc']) { $ratiopaymentinvoice = ($fields['payment_amount'] / $fields['ftotal_ttc']); } diff --git a/htdocs/compta/tva/document.php b/htdocs/compta/tva/document.php index fabaf1ee705..cb26304cde5 100644 --- a/htdocs/compta/tva/document.php +++ b/htdocs/compta/tva/document.php @@ -148,9 +148,7 @@ if ($object->id) $permtoedit = $user->rights->fournisseur->facture->creer; $param = '&id='.$object->id; include_once DOL_DOCUMENT_ROOT.'/core/tpl/document_actions_post_headers.tpl.php'; -} -else -{ +} else { print $langs->trans("ErrorUnknown"); } diff --git a/htdocs/compta/tva/index.php b/htdocs/compta/tva/index.php index 0a785aa78cd..43db8353c4c 100644 --- a/htdocs/compta/tva/index.php +++ b/htdocs/compta/tva/index.php @@ -57,14 +57,11 @@ if (empty($date_start) || empty($date_end)) // We define date_start and date_end $q = GETPOST("q", "int"); if (empty($q)) { - if (GETPOST("month", "int")) { $date_start = dol_get_first_day($year_start, GETPOST("month", "int"), false); $date_end = dol_get_last_day($year_start, GETPOST("month", "int"), false); } - else - { + if (GETPOST("month", "int")) { $date_start = dol_get_first_day($year_start, GETPOST("month", "int"), false); $date_end = dol_get_last_day($year_start, GETPOST("month", "int"), false); } else { if (empty($conf->global->MAIN_INFO_VAT_RETURN) || $conf->global->MAIN_INFO_VAT_RETURN == 2) { // quaterly vat, we take last past complete quarter $date_start = dol_time_plus_duree(dol_get_first_day($year_start, $current_date['mon'], false), -3 - (($current_date['mon'] - $conf->global->SOCIETE_FISCAL_MONTH_START) % 3), 'm'); $date_end = dol_time_plus_duree($date_start, 3, 'm') - 1; - } - elseif ($conf->global->MAIN_INFO_VAT_RETURN == 3) { // yearly vat + } elseif ($conf->global->MAIN_INFO_VAT_RETURN == 3) { // yearly vat if ($current_date['mon'] < $conf->global->SOCIETE_FISCAL_MONTH_START) { if (($conf->global->SOCIETE_FISCAL_MONTH_START - $current_date['mon']) > 6) { // If period started from less than 6 years, we show past year $year_start--; @@ -76,15 +73,12 @@ if (empty($date_start) || empty($date_end)) // We define date_start and date_end } $date_start = dol_get_first_day($year_start, $conf->global->SOCIETE_FISCAL_MONTH_START, false); $date_end = dol_time_plus_duree($date_start, 1, 'y') - 1; - } - elseif ($conf->global->MAIN_INFO_VAT_RETURN == 1) { // monthly vat, we take last past complete month + } elseif ($conf->global->MAIN_INFO_VAT_RETURN == 1) { // monthly vat, we take last past complete month $date_start = dol_time_plus_duree(dol_get_first_day($year_start, $current_date['mon'], false), -1, 'm'); $date_end = dol_time_plus_duree($date_start, 1, 'm') - 1; } } - } - else - { + } else { if ($q == 1) { $date_start = dol_get_first_day($year_start, 1, false); $date_end = dol_get_last_day($year_start, 3, false); } if ($q == 2) { $date_start = dol_get_first_day($year_start, 4, false); $date_end = dol_get_last_day($year_start, 6, false); } if ($q == 3) { $date_start = dol_get_first_day($year_start, 7, false); $date_end = dol_get_last_day($year_start, 9, false); } @@ -176,9 +170,7 @@ function pt($db, $sql, $date) $amountpaid = 0; $previousmode = ''; $previousmonth = ''; - } - else - { + } else { $previousmode = $obj->mode; $previousmonth = $obj->dm; } @@ -207,8 +199,7 @@ function pt($db, $sql, $date) print ""; $db->free($result); - } - else { + } else { dol_print_error($db); } } @@ -371,9 +362,7 @@ while ((($y < $yend) || ($y == $yend && $m <= $mend)) && $mcursor < 1000) // $mc 'vat' =>$x_paye[$my_paye_rate]['vat_list'][$id], //'link' =>$expensereport->getNomUrl(1) ); - } - else - { + } else { //$invoice_supplier->id=$x_paye[$my_paye_rate]['facid'][$id]; //$invoice_supplier->ref=$x_paye[$my_paye_rate]['facnum'][$id]; //$invoice_supplier->type=$x_paye[$my_paye_rate]['type'][$id]; diff --git a/htdocs/compta/tva/list.php b/htdocs/compta/tva/list.php index 003a7eabcad..5b09da5305c 100644 --- a/htdocs/compta/tva/list.php +++ b/htdocs/compta/tva/list.php @@ -72,9 +72,7 @@ if (empty($_REQUEST['typeid'])) $part = explode(':', $val); if ($part[0] == 't.fk_typepayment') $typeid = $part[1]; } -} -else -{ +} else { $typeid = $_REQUEST['typeid']; } @@ -228,9 +226,7 @@ if ($result) if ($obj->payment_code <> '') { $type = ''.$langs->trans("PaymentTypeShort".$obj->payment_code).' '.$obj->num_payment.''; - } - else - { + } else { $type = ' '; } @@ -266,8 +262,7 @@ if ($result) $bankstatic->label = $obj->blabel; print $bankstatic->getNomUrl(1); - } - else print ' '; + } else print ' '; print ''; } // Amount @@ -291,9 +286,7 @@ if ($result) print ''; $db->free($result); -} -else -{ +} else { dol_print_error($db); } diff --git a/htdocs/compta/tva/quadri_detail.php b/htdocs/compta/tva/quadri_detail.php index 79ee69a030c..abd5fb6841c 100644 --- a/htdocs/compta/tva/quadri_detail.php +++ b/htdocs/compta/tva/quadri_detail.php @@ -66,14 +66,11 @@ if (empty($date_start) || empty($date_end)) // We define date_start and date_end $q = GETPOST("q", "int"); if (empty($q)) { - if (GETPOST("month", "int")) { $date_start = dol_get_first_day($year_start, GETPOST("month", "int"), false); $date_end = dol_get_last_day($year_start, GETPOST("month", "int"), false); } - else - { + if (GETPOST("month", "int")) { $date_start = dol_get_first_day($year_start, GETPOST("month", "int"), false); $date_end = dol_get_last_day($year_start, GETPOST("month", "int"), false); } else { if (empty($conf->global->MAIN_INFO_VAT_RETURN) || $conf->global->MAIN_INFO_VAT_RETURN == 2) { // quaterly vat, we take last past complete quarter $date_start = dol_time_plus_duree(dol_get_first_day($year_start, $current_date['mon'], false), -3 - (($current_date['mon'] - $conf->global->SOCIETE_FISCAL_MONTH_START) % 3), 'm'); $date_end = dol_time_plus_duree($date_start, 3, 'm') - 1; - } - elseif ($conf->global->MAIN_INFO_VAT_RETURN == 3) { // yearly vat + } elseif ($conf->global->MAIN_INFO_VAT_RETURN == 3) { // yearly vat if ($current_date['mon'] < $conf->global->SOCIETE_FISCAL_MONTH_START) { if (($conf->global->SOCIETE_FISCAL_MONTH_START - $current_date['mon']) > 6) { // If period started from less than 6 years, we show past year $year_start--; @@ -85,15 +82,12 @@ if (empty($date_start) || empty($date_end)) // We define date_start and date_end } $date_start = dol_get_first_day($year_start, $conf->global->SOCIETE_FISCAL_MONTH_START, false); $date_end = dol_time_plus_duree($date_start, 1, 'y') - 1; - } - elseif ($conf->global->MAIN_INFO_VAT_RETURN == 1) { // monthly vat, we take last past complete month + } elseif ($conf->global->MAIN_INFO_VAT_RETURN == 1) { // monthly vat, we take last past complete month $date_start = dol_time_plus_duree(dol_get_first_day($year_start, $current_date['mon'], false), -1, 'm'); $date_end = dol_time_plus_duree($date_start, 1, 'm') - 1; } } - } - else - { + } else { if ($q == 1) { $date_start = dol_get_first_day($year_start, 1, false); $date_end = dol_get_last_day($year_start, 3, false); } if ($q == 2) { $date_start = dol_get_first_day($year_start, 4, false); $date_end = dol_get_last_day($year_start, 6, false); } if ($q == 3) { $date_start = dol_get_first_day($year_start, 7, false); $date_end = dol_get_last_day($year_start, 9, false); } @@ -315,9 +309,7 @@ if (!is_array($x_coll) || !is_array($x_paye)) 'vat' =>$x_paye[$my_paye_rate]['vat_list'][$id], 'link' =>$expensereport->getNomUrl(1) ); - } - else - { + } else { $invoice_supplier->id = $x_paye[$my_paye_rate]['facid'][$id]; $invoice_supplier->ref = $x_paye[$my_paye_rate]['facnum'][$id]; $invoice_supplier->type = $x_paye[$my_paye_rate]['type'][$id]; @@ -439,9 +431,7 @@ if (!is_array($x_coll) || !is_array($x_paye)) if (dol_string_nohtmltag($fields['descr'])) { print ' - '.dol_trunc(dol_string_nohtmltag($fields['descr']), 24); } - } - else - { + } else { if ($type) { $text = img_object($langs->trans('Service'), 'service'); } else { @@ -620,9 +610,7 @@ if (!is_array($x_coll) || !is_array($x_paye)) if (dol_string_nohtmltag($fields['descr'])) { print ' - '.dol_trunc(dol_string_nohtmltag($fields['descr']), 24); } - } - else - { + } else { if ($type) { $text = img_object($langs->trans('Service'), 'service'); } else { @@ -673,9 +661,7 @@ if (!is_array($x_coll) || !is_array($x_paye)) || ($type == 1 && $conf->global->TAX_MODE_BUY_SERVICE == 'invoice')) { print $langs->trans("NA"); - } - else - { + } else { if (isset($fields['payment_amount']) && $fields['ftotal_ttc']) { $ratiopaymentinvoice = ($fields['payment_amount'] / $fields['ftotal_ttc']); } diff --git a/htdocs/contact/agenda.php b/htdocs/contact/agenda.php index 625cf524169..0ea0018632b 100644 --- a/htdocs/contact/agenda.php +++ b/htdocs/contact/agenda.php @@ -76,9 +76,7 @@ if (GETPOST('actioncode', 'array')) { $actioncode = GETPOST('actioncode', 'array', 3); if (!count($actioncode)) $actioncode = '0'; -} -else -{ +} else { $actioncode = GETPOST("actioncode", "alpha", 3) ?GETPOST("actioncode", "alpha", 3) : (GETPOST("actioncode") == '0' ? '0' : (empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT) ? '' : $conf->global->AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT)); } $search_agenda_label = GETPOST('search_agenda_label'); @@ -159,9 +157,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) } $objcanvas->assign_values($action, $object->id, $object->ref); // Set value for templates $objcanvas->display_canvas($action); // Show template -} -else -{ +} else { // ----------------------------------------- // When used in standard mode // ----------------------------------------- diff --git a/htdocs/contact/canvas/actions_contactcard_common.class.php b/htdocs/contact/canvas/actions_contactcard_common.class.php index fbd31812fe8..415d9e47790 100644 --- a/htdocs/contact/canvas/actions_contactcard_common.class.php +++ b/htdocs/contact/canvas/actions_contactcard_common.class.php @@ -119,9 +119,7 @@ abstract class ActionsContactCardCommon { $this->tpl['company'] = $objsoc->getNomUrl(1); $this->tpl['company_id'] = $objsoc->id; - } - else - { + } else { $this->tpl['company'] = $form->select_company($this->object->socid, 'socid', '', 1); } @@ -208,8 +206,7 @@ abstract class ActionsContactCardCommon $dolibarr_user = new User($this->db); $result = $dolibarr_user->fetch($this->object->user_id); $this->tpl['dolibarr_user'] = $dolibarr_user->getLoginUrl(1); - } - else $this->tpl['dolibarr_user'] = $langs->trans("NoDolibarrAccess"); + } else $this->tpl['dolibarr_user'] = $langs->trans("NoDolibarrAccess"); } if ($action == 'view' || $action == 'delete') @@ -222,9 +219,7 @@ abstract class ActionsContactCardCommon $objsoc->fetch($this->object->socid); $this->tpl['company'] = $objsoc->getNomUrl(1); - } - else - { + } else { $this->tpl['company'] = $langs->trans("ContactNotLinkedToCompany"); } @@ -309,9 +304,7 @@ abstract class ActionsContactCardCommon if ($resql) { $obj = $this->db->fetch_object($resql); - } - else - { + } else { dol_print_error($this->db); } $this->object->country_id = $langs->trans("Country".$obj->code) ? $langs->trans("Country".$obj->code) : $obj->label; diff --git a/htdocs/contact/canvas/default/actions_contactcard_default.class.php b/htdocs/contact/canvas/default/actions_contactcard_default.class.php index 54b3f137967..099c973b0a4 100644 --- a/htdocs/contact/canvas/default/actions_contactcard_default.class.php +++ b/htdocs/contact/canvas/default/actions_contactcard_default.class.php @@ -104,9 +104,7 @@ class ActionsContactCardDefault extends ActionsContactCardCommon $this->tpl['actionstodo'] = show_actions_todo($conf, $langs, $db, $objsoc, $this->object, 1); $this->tpl['actionsdone'] = show_actions_done($conf, $langs, $db, $objsoc, $this->object, 1); - } - else - { + } else { // Confirm delete contact if ($action == 'delete' && $user->rights->societe->contact->supprimer) { diff --git a/htdocs/contact/card.php b/htdocs/contact/card.php index ce948211c46..6b73172decc 100644 --- a/htdocs/contact/card.php +++ b/htdocs/contact/card.php @@ -128,21 +128,15 @@ if (empty($reshook)) if ($result2) { $db->commit(); - } - else - { + } else { $error = $nuser->error; $errors = $nuser->errors; $db->rollback(); } - } - else - { + } else { $error = $nuser->error; $errors = $nuser->errors; $db->rollback(); } - } - else - { + } else { $error = $object->error; $errors = $object->errors; } } @@ -155,9 +149,7 @@ if (empty($reshook)) if ($object->setstatus(0) < 0) { setEventMessages($object->error, $object->errors, 'errors'); - } - else - { + } else { header("Location: ".$_SERVER['PHP_SELF'].'?id='.$id); exit; } @@ -170,9 +162,7 @@ if (empty($reshook)) if ($object->setstatus(1) < 0) { setEventMessages($object->error, $object->errors, 'errors'); - } - else - { + } else { header("Location: ".$_SERVER['PHP_SELF'].'?id='.$id); exit; } @@ -277,9 +267,7 @@ if (empty($reshook)) else $url = 'card.php?id='.$id; header("Location: ".$url); exit; - } - else - { + } else { $db->rollback(); } } @@ -299,15 +287,11 @@ if (empty($reshook)) { header("Location: ".$backtopage); exit; - } - else - { + } else { header("Location: ".DOL_URL_ROOT.'/contact/list.php'); exit; } - } - else - { + } else { setEventMessages($object->error, $object->errors, 'errors'); } } @@ -350,23 +334,17 @@ if (empty($reshook)) if (!$result > 0) { $errors[] = "ErrorFailedToSaveFile"; - } - else - { + } else { $object->photo = dol_sanitizeFileName($_FILES['photo']['name']); // Create thumbs $object->addThumbs($newfile); } } - } - else - { + } else { $errors[] = "ErrorBadImageFormat"; } - } - else - { + } else { switch ($_FILES['photo']['error']) { case 1: //uploaded file exceeds the upload_max_filesize directive in php.ini @@ -451,9 +429,7 @@ if (empty($reshook)) $resql = $db->query($sql); } } - } - else - { + } else { $sql = "DELETE FROM ".MAIN_DB_PREFIX."mailing_unsubscribe WHERE email = '".$db->escape($object->email)."' AND entity = ".$db->escape(getEntity('mailing', 0)); $resql = $db->query($sql); } @@ -464,9 +440,7 @@ if (empty($reshook)) $object->old_lastname = ''; $object->old_firstname = ''; $action = 'view'; - } - else - { + } else { setEventMessages($object->error, $object->errors, 'errors'); $action = 'edit'; } @@ -525,9 +499,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) } $objcanvas->assign_values($action, $object->id, $object->ref); // Set value for templates $objcanvas->display_canvas($action); // Show template -} -else -{ +} else { // ----------------------------------------- // When used in standard mode // ----------------------------------------- @@ -646,8 +618,7 @@ else print ''; print ''; print ''; - } - else { + } else { print ''; print $form->select_company($socid, 'socid', '', 'SelectThirdParty'); print ''; @@ -702,18 +673,14 @@ else if (!empty($conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT) && ($conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT == 1 || $conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT == 2)) { print ''; - } - else - { + } else { print ''; } if ($object->country_id) { print $formcompany->select_state(GETPOST("state_id", 'alpha') ? GETPOST("state_id", 'alpha') : $object->state_id, $object->country_code, 'state_id'); - } - else - { + } else { print $countrynotdefined; } print ''; @@ -870,9 +837,7 @@ else if ($object->birthday) { print $form->selectDate($object->birthday, 'birthday', 0, 0, 0, "perso", 1, 0); - } - else - { + } else { print $form->selectDate('', 'birthday', 0, 0, 1, "perso", 1, 0); } print ''; @@ -881,9 +846,7 @@ else if ($object->birthday_alert) { print ''; - } - else - { + } else { print ''; } print ''; @@ -899,17 +862,14 @@ else { print '     '; print ''; - } - else - { + } else { print '     '; print ''; } print ''; print ""; - } - elseif ($action == 'edit' && !empty($id)) + } elseif ($action == 'edit' && !empty($id)) { /* * Fiche en mode edition @@ -1030,9 +990,7 @@ else if (!empty($conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT) && ($conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT == 1 || $conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT == 2)) { print ''; - } - else - { + } else { print ''; } @@ -1069,9 +1027,7 @@ else $langs->load("mails"); print ''.$langs->trans("NbOfEMailingsSend").''; print ''.$object->getNbOfEMailings().''; - } - else - { + } else { print ''; } print ''; @@ -1095,9 +1051,7 @@ else print ''; print ''.$form->selectyesno('no_email', (GETPOSTISSET("no_email") ?GETPOST("no_email", 'alpha') : $noemail), 1).''; - } - else - { + } else { print ''; } print ''; @@ -1242,8 +1196,7 @@ else $dolibarr_user = new User($db); $result = $dolibarr_user->fetch($object->user_id); print $dolibarr_user->getLoginUrl(1); - } - else print $langs->trans("NoDolibarrAccess"); + } else print $langs->trans("NoDolibarrAccess"); print ''; // Photo @@ -1418,8 +1371,7 @@ else if (!empty($conf->commande->enabled) || !empty($conf->expedition->enabled)) { print ''; - if (!empty($conf->expedition->enabled)) { print $langs->trans("ContactForOrdersOrShipments"); } - else print $langs->trans("ContactForOrders"); + if (!empty($conf->expedition->enabled)) { print $langs->trans("ContactForOrdersOrShipments"); } else print $langs->trans("ContactForOrders"); print ''; $none = $langs->trans("NoContactForAnyOrder"); if (!empty($conf->expedition->enabled)) { $none = $langs->trans("NoContactForAnyOrderOrShipments"); } @@ -1447,14 +1399,13 @@ else $dolibarr_user = new User($db); $result = $dolibarr_user->fetch($object->user_id); print $dolibarr_user->getLoginUrl(1); - } - else print $langs->trans("NoDolibarrAccess"); + } else print $langs->trans("NoDolibarrAccess"); print ''; print ''; print $langs->trans("VCard").''; print ''; - print img_picto($langs->trans("Download"), 'vcard.png').' '; + print img_picto($langs->trans("Download"), 'vcard.png', 'class="paddingrightonly"'); print $langs->trans("Download"); print ''; print ''; @@ -1478,9 +1429,7 @@ else { $langs->load("mails"); print ''; - } - else - { + } else { $langs->load("mails"); print ''; } diff --git a/htdocs/contact/class/contact.class.php b/htdocs/contact/class/contact.class.php index a3cdb1747a0..cfe41eafca2 100644 --- a/htdocs/contact/class/contact.class.php +++ b/htdocs/contact/class/contact.class.php @@ -287,9 +287,7 @@ class Contact extends CommonObject } $this->db->free($resql); return 1; - } - else - { + } else { dol_print_error($this->db); $this->error = $this->db->lasterror(); return -1; @@ -388,16 +386,12 @@ class Contact extends CommonObject { $this->db->commit(); return $this->id; - } - else - { + } else { $this->db->rollback(); dol_syslog(get_class($this)."::create ".$this->error, LOG_ERR); return -2; } - } - else - { + } else { $this->error = $this->db->lasterror(); $this->db->rollback(); @@ -596,16 +590,12 @@ class Contact extends CommonObject { $this->db->commit(); return 1; - } - else - { + } else { dol_syslog(get_class($this)."::update Error ".$this->error, LOG_ERR); $this->db->rollback(); return -$error; } - } - else - { + } else { $this->error = $this->db->lasterror().' sql='.$sql; $this->db->rollback(); return -1; @@ -761,14 +751,10 @@ class Contact extends CommonObject $error++; $this->error = $this->db->lasterror(); } - } - else - { + } else { $result = true; } - } - else - { + } else { $sql = "DELETE FROM ".MAIN_DB_PREFIX."user_alert "; $sql .= "WHERE type=1 AND fk_contact=".$this->db->escape($id)." AND fk_user=".$user->id; $result = $this->db->query($sql); @@ -791,9 +777,7 @@ class Contact extends CommonObject { $this->db->commit(); return 1; - } - else - { + } else { dol_syslog(get_class($this)."::update Error ".$this->error, LOG_ERR); $this->db->rollback(); return -$error; @@ -846,8 +830,7 @@ class Contact extends CommonObject $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."user as u ON c.rowid = u.fk_socpeople"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON c.fk_soc = s.rowid"; if ($id) $sql .= " WHERE c.rowid = ".$id; - else - { + else { $sql .= " WHERE c.entity IN (".getEntity($this->element).")"; if ($ref_ext) { $sql .= " AND c.ref_ext = '".$this->db->escape($ref_ext)."'"; @@ -867,8 +850,7 @@ class Contact extends CommonObject dol_syslog($this->error, LOG_ERR); return 2; - } - elseif ($num) // $num = 1 + } elseif ($num) // $num = 1 { $obj = $this->db->fetch_object($resql); @@ -942,9 +924,7 @@ class Contact extends CommonObject $this->user_id = $uobj->rowid; } $this->db->free($resql); - } - else - { + } else { $this->error = $this->db->error(); return -1; } @@ -970,9 +950,7 @@ class Contact extends CommonObject $this->birthday_alert = 1; } $this->db->free($resql); - } - else - { + } else { $this->error = $this->db->error(); return -1; } @@ -987,15 +965,11 @@ class Contact extends CommonObject } return 1; - } - else - { + } else { $this->error = $langs->trans("RecordNotFound"); return 0; } - } - else - { + } else { $this->error = $this->db->error(); return -1; } @@ -1016,8 +990,7 @@ class Contact extends CommonObject if (in_array($this->civility_id, array('MR')) || in_array($this->civility_code, array('MR'))) { $this->gender = 'man'; - } - elseif (in_array($this->civility_id, array('MME', 'MLE')) || in_array($this->civility_code, array('MME', 'MLE'))) + } elseif (in_array($this->civility_id, array('MME', 'MLE')) || in_array($this->civility_code, array('MME', 'MLE'))) { $this->gender = 'woman'; } @@ -1061,9 +1034,7 @@ class Contact extends CommonObject } $this->db->free($resql); return 0; - } - else - { + } else { $this->error = $this->db->lasterror(); return -1; } @@ -1118,9 +1089,7 @@ class Contact extends CommonObject $i++; } - } - else - { + } else { $error++; $this->error = $this->db->error().' sql='.$sql; } @@ -1186,9 +1155,7 @@ class Contact extends CommonObject { $this->db->commit(); return 1; - } - else - { + } else { $this->db->rollback(); dol_syslog("Error ".$this->error, LOG_ERR); return -1; @@ -1235,9 +1202,7 @@ class Contact extends CommonObject } $this->db->free($resql); - } - else - { + } else { print $this->db->error(); } } @@ -1262,9 +1227,7 @@ class Contact extends CommonObject $this->db->free($resql); return $nb; - } - else - { + } else { $this->error = $this->db->error(); return -1; } @@ -1525,9 +1488,7 @@ class Contact extends CommonObject { $this->db->rollback(); return -$error; - } - else - { + } else { $this->db->commit(); return 1; } @@ -1590,7 +1551,7 @@ class Contact extends CommonObject public static function replaceThirdparty(DoliDB $db, $origin_id, $dest_id) { $tables = array( - 'socpeople' + 'socpeople', 'societe_contacts' ); return CommonObject::commonReplaceThirdparty($db, $origin_id, $dest_id, $tables); @@ -1680,9 +1641,7 @@ class Contact extends CommonObject } return $tab; - } - else - { + } else { $this->error = $this->db->error(); dol_print_error($this->db); return -1; diff --git a/htdocs/contact/consumption.php b/htdocs/contact/consumption.php index ad4b5ca08f5..7655e00ea3f 100644 --- a/htdocs/contact/consumption.php +++ b/htdocs/contact/consumption.php @@ -178,8 +178,7 @@ if ($type_element == 'fichinter') $where = ' WHERE f.entity IN ('.getEntity('ficheinter').')'; $dateprint = 'f.datec'; $doc_number = 'f.ref'; -} -elseif ($type_element == 'invoice') +} elseif ($type_element == 'invoice') { // Customer : show products from invoices require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; $documentstatic = new Facture($db); @@ -193,8 +192,7 @@ elseif ($type_element == 'invoice') $dateprint = 'f.datef'; $doc_number = 'f.ref'; $thirdTypeSelect = 'customer'; -} -elseif ($type_element == 'propal') +} elseif ($type_element == 'propal') { require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; $documentstatic = new Propal($db); @@ -208,8 +206,7 @@ elseif ($type_element == 'propal') $datePrint = 'c.datep'; $doc_number = 'c.ref'; $thirdTypeSelect = 'customer'; -} -elseif ($type_element == 'order') +} elseif ($type_element == 'order') { require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; $documentstatic = new Commande($db); @@ -223,8 +220,7 @@ elseif ($type_element == 'order') $dateprint = 'c.date_commande'; $doc_number = 'c.ref'; $thirdTypeSelect = 'customer'; -} -elseif ($type_element == 'supplier_invoice') +} elseif ($type_element == 'supplier_invoice') { // Supplier : Show products from invoices. require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php'; $documentstatic = new FactureFournisseur($db); @@ -266,8 +262,7 @@ elseif ($type_element == 'supplier_order') $dateprint = 'c.date_valid'; $doc_number = 'c.ref'; $thirdTypeSelect = 'supplier'; -} -elseif ($type_element == 'contract') +} elseif ($type_element == 'contract') { // Order require_once DOL_DOCUMENT_ROOT.'/contrat/class/contrat.class.php'; $documentstatic = new Contrat($db); @@ -423,9 +418,7 @@ if ($sql_select) if ($type_element == 'contract') { print $documentstaticline->getLibStatut(2); - } - else - { + } else { print $documentstatic->getLibStatut(2); } print ''; @@ -467,9 +460,7 @@ if ($sql_select) } $label = (!empty($prod->multilangs[$outputlangs->defaultlang]["label"])) ? $prod->multilangs[$outputlangs->defaultlang]["label"] : $objp->product_label; - } - else - { + } else { $label = $objp->product_label; } @@ -501,29 +492,23 @@ if ($sql_select) $discount = new DiscountAbsolute($db); $discount->fetch($objp->fk_remise_except); echo ($txt ? ' - ' : '').$langs->transnoentities("DiscountFromExcessReceived", $discount->getNomUrl(0)); - } - elseif ($objp->description == '(EXCESS PAID)' && $objp->fk_remise_except > 0) + } elseif ($objp->description == '(EXCESS PAID)' && $objp->fk_remise_except > 0) { $discount = new DiscountAbsolute($db); $discount->fetch($objp->fk_remise_except); echo ($txt ? ' - ' : '').$langs->transnoentities("DiscountFromExcessPaid", $discount->getNomUrl(0)); - } - elseif ($objp->description == '(DEPOSIT)' && $objp->fk_remise_except > 0) + } elseif ($objp->description == '(DEPOSIT)' && $objp->fk_remise_except > 0) { $discount = new DiscountAbsolute($db); $discount->fetch($objp->fk_remise_except); echo ($txt ? ' - ' : '').$langs->transnoentities("DiscountFromDeposit", $discount->getNomUrl(0)); // Add date of deposit if (!empty($conf->global->INVOICE_ADD_DEPOSIT_DATE)) echo ' ('.dol_print_date($discount->datec).')'; - } - else - { + } else { echo ($txt ? ' - ' : '').dol_htmlentitiesbr($objp->description); } } - } - else - { + } else { if ($objp->fk_product > 0) { echo $form->textwithtooltip($text, $description, 3, '', '', $i, 0, ''); diff --git a/htdocs/contact/ldap.php b/htdocs/contact/ldap.php index 842d03cb3a6..f601086ad05 100644 --- a/htdocs/contact/ldap.php +++ b/htdocs/contact/ldap.php @@ -67,9 +67,7 @@ if ($action == 'dolibarr2ldap') { setEventMessages($langs->trans("ContactSynchronized"), null, 'mesgs'); $db->commit(); - } - else - { + } else { setEventMessages($ldap->error, $ldap->errors, 'errors'); $db->rollback(); } @@ -106,9 +104,7 @@ if ($object->socid > 0) $thirdparty->fetch($object->socid); print ''.$langs->trans("ThirdParty").''.$thirdparty->getNomUrl(1).''; -} -else -{ +} else { print ''.$langs->trans("ThirdParty").''; print $langs->trans("ContactNotLinkedToCompany"); print ''; @@ -183,22 +179,16 @@ if ($result > 0) if (!is_array($records)) { print ''.$langs->trans("ErrorFailedToReadLDAP").''; - } - else - { + } else { $result = show_ldap_content($records, 0, $records['count'], true); } - } - else - { + } else { print ''.$langs->trans("LDAPRecordNotFound").' (dn='.$dn.' - search='.$search.')'; } $ldap->unbind(); $ldap->close(); -} -else -{ +} else { setEventMessages($ldap->error, $ldap->errors, 'errors'); } diff --git a/htdocs/contact/list.php b/htdocs/contact/list.php index 25242dc2185..3f7791019ec 100644 --- a/htdocs/contact/list.php +++ b/htdocs/contact/list.php @@ -123,14 +123,12 @@ if ($type == "c") if (empty($contextpage) || $contextpage == 'contactlist') $contextpage = 'contactcustomerlist'; $titre .= ' ('.$langs->trans("ThirdPartyCustomers").')'; $urlfiche = "card.php"; -} -elseif ($type == "f") +} elseif ($type == "f") { if (empty($contextpage) || $contextpage == 'contactlist') $contextpage = 'contactsupplierlist'; $titre .= ' ('.$langs->trans("ThirdPartySuppliers").')'; $urlfiche = "card.php"; -} -elseif ($type == "o") +} elseif ($type == "o") { if (empty($contextpage) || $contextpage == 'contactlist') $contextpage = 'contactotherlist'; $titre .= ' ('.$langs->trans("OthersNotLinkedToThirdParty").')'; @@ -326,9 +324,7 @@ if (!empty($userid)) // propre au commercial if ($search_priv != '0' && $search_priv != '1') { $sql .= " AND (p.priv='0' OR (p.priv='1' AND p.fk_user_creat=".$user->id."))"; -} -else -{ +} else { if ($search_priv == '0') $sql .= " AND p.priv='0'"; if ($search_priv == '1') $sql .= " AND (p.priv='1' AND p.fk_user_creat=".$user->id.")"; } @@ -358,7 +354,6 @@ if (strlen($search_fax)) $sql .= natural_search('p.fax', $search_fax) if (!empty($conf->socialnetworks->enabled)) { foreach ($socialnetworks as $key => $value) { if ($value['active'] && strlen($search_{$key})) { - //$sql.= natural_search("p.socialnetworks->'$.".$key."'", $search_{$key}); $sql .= ' AND p.socialnetworks LIKE \'%"'.$key.'":"'.$search_{$key}.'%\''; } } @@ -376,16 +371,13 @@ if ($search_import_key) $sql .= natural_search("p.import_key", $sear if ($type == "o") // filtre sur type { $sql .= " AND p.fk_soc IS NULL"; -} -elseif ($type == "f") // filtre sur type +} elseif ($type == "f") // filtre sur type { $sql .= " AND s.fournisseur = 1"; -} -elseif ($type == "c") // filtre sur type +} elseif ($type == "c") // filtre sur type { $sql .= " AND s.client IN (1, 3)"; -} -elseif ($type == "p") // filtre sur type +} elseif ($type == "p") // filtre sur type { $sql .= " AND s.client IN (2, 3)"; } @@ -403,9 +395,7 @@ $sql .= $hookmanager->resPrint; if ($view == "recent") { $sql .= $db->order("p.datec", "DESC"); -} -else -{ +} else { $sql .= $db->order($sortfield, $sortorder); } @@ -922,9 +912,7 @@ while ($i < min($num, $limit)) $objsoc = new Societe($db); $objsoc->fetch($obj->socid); print $objsoc->getNomUrl(1); - } - else - print ' '; + } else print ' '; print ''; if (!$i) $totalarray['nbfield']++; } @@ -939,7 +927,7 @@ while ($i < min($num, $limit)) // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; // Fields from hook - $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$obj); + $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray); $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; // Date creation diff --git a/htdocs/contact/perso.php b/htdocs/contact/perso.php index 5a6ea3eb032..a5a1714b6e5 100644 --- a/htdocs/contact/perso.php +++ b/htdocs/contact/perso.php @@ -85,21 +85,15 @@ if ($action == 'update' && !$_POST["cancel"] && $user->rights->societe->contact- if (!dol_move_uploaded_file($_FILES['photo']['tmp_name'], $newfile, 1, 0, $_FILES['photo']['error']) > 0) { setEventMessages($langs->trans("ErrorFailedToSaveFile"), null, 'errors'); - } - else - { + } else { // Create thumbs $object->addThumbs($newfile); } } - } - else - { + } else { setEventMessages("ErrorBadImageFormat", null, 'errors'); } - } - else - { + } else { switch ($_FILES['photo']['error']) { case 1: //uploaded file exceeds the upload_max_filesize directive in php.ini @@ -111,9 +105,7 @@ if ($action == 'update' && !$_POST["cancel"] && $user->rights->societe->contact- break; } } - } - else - { + } else { $error = $object->error; } } @@ -183,9 +175,7 @@ if ($action == 'edit') $objsoc->fetch($object->socid); print ''.$langs->trans("ThirdParty").''.$objsoc->getNomUrl(1).''; - } - else - { + } else { print ''.$langs->trans("ThirdParty").''; print $langs->trans("ContactNotLinkedToCompany"); print ''; @@ -207,9 +197,7 @@ if ($action == 'edit') if (!empty($object->birthday_alert)) { print ''; - } - else - { + } else { print ''; } print ''; @@ -225,9 +213,7 @@ if ($action == 'edit') print ''; print ""; -} -else -{ +} else { // View mode dol_fiche_head($head, 'perso', $title, -1, 'contact'); @@ -301,9 +287,7 @@ else if ($object->birthday_alert) print $langs->trans("BirthdayAlertOn"); else print $langs->trans("BirthdayAlertOff"); print ''; - } - else - { + } else { print ''.$langs->trans("DateToBirth").''; } print ""; diff --git a/htdocs/contact/vcard.php b/htdocs/contact/vcard.php index 75362491424..ee325317033 100644 --- a/htdocs/contact/vcard.php +++ b/htdocs/contact/vcard.php @@ -102,8 +102,7 @@ if ($company->id) $v->setEmail($company->email, 'INTERNET'); } // when e-mail of contact and company complete different use company e-mail at first (and contact e-mail at second) - else - { + else { $v->setEmail($company->email); // support by Microsoft Outlook (2019 and possible earlier) diff --git a/htdocs/contrat/agenda.php b/htdocs/contrat/agenda.php index 0055b0ba428..d016cb23d75 100644 --- a/htdocs/contrat/agenda.php +++ b/htdocs/contrat/agenda.php @@ -39,9 +39,7 @@ if (GETPOST('actioncode', 'array')) { $actioncode = GETPOST('actioncode', 'array', 3); if (!count($actioncode)) $actioncode = '0'; -} -else -{ +} else { $actioncode = GETPOST("actioncode", "alpha", 3) ?GETPOST("actioncode", "alpha", 3) : (GETPOST("actioncode") == '0' ? '0' : (empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT) ? '' : $conf->global->AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT)); } $search_agenda_label = GETPOST('search_agenda_label'); diff --git a/htdocs/contrat/card.php b/htdocs/contrat/card.php index 21d46fb2974..c4f923a7372 100644 --- a/htdocs/contrat/card.php +++ b/htdocs/contrat/card.php @@ -112,13 +112,10 @@ if (empty($reshook)) { header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); exit; - } - else { + } else { setEventMessages($object->error, $object->errors, 'errors'); } - } - - elseif ($action == 'confirm_closeline' && $confirm == 'yes' && $user->rights->contrat->activer) + } elseif ($action == 'confirm_closeline' && $confirm == 'yes' && $user->rights->contrat->activer) { if (!GETPOST('dateend')) { @@ -132,9 +129,7 @@ if (empty($reshook)) { header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); exit; - } - else - { + } else { setEventMessages($object->error, $object->errors, 'errors'); } } @@ -302,14 +297,11 @@ if (empty($reshook)) } $label = (!empty($prod->multilangs[$outputlangs->defaultlang]["libelle"])) ? $prod->multilangs[$outputlangs->defaultlang]["libelle"] : $lines[$i]->product_label; - } - else - { + } else { $label = $lines[$i]->product_label; } $desc = ($lines[$i]->desc && $lines[$i]->desc != $lines[$i]->libelle) ?dol_htmlentitiesbr($lines[$i]->desc) : ''; - } - else { + } else { $desc = dol_htmlentitiesbr($lines[$i]->desc); } @@ -354,9 +346,7 @@ if (empty($reshook)) } } } - } - else - { + } else { setEventMessages($srcobject->error, $srcobject->errors, 'errors'); $error++; } @@ -367,30 +357,23 @@ if (empty($reshook)) // modified by hook if ($reshook < 0) $error++; - } - else - { + } else { setEventMessages($object->error, $object->errors, 'errors'); $error++; } - } - else - { + } else { $result = $object->create($user); if ($result > 0) { header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); exit; - } - else { + } else { setEventMessages($object->error, $object->errors, 'errors'); } $action = 'create'; } } - } - - elseif ($action == 'classin' && $user->rights->contrat->creer) + } elseif ($action == 'classin' && $user->rights->contrat->creer) { $object->setProject(GETPOST('projectid')); } @@ -407,9 +390,7 @@ if (empty($reshook)) { $idprod = 0; $tva_tx = (GETPOST('tva_tx', 'alpha') ? GETPOST('tva_tx', 'alpha') : 0); - } - else - { + } else { $idprod = GETPOST('idprod', 'int'); $tva_tx = ''; } @@ -480,8 +461,7 @@ if (empty($reshook)) $pu_ttc = $prod->multiprices_ttc[$object->thirdparty->price_level]; $price_min = $prod->multiprices_min[$object->thirdparty->price_level]; $price_base_type = $prod->multiprices_base_type[$object->thirdparty->price_level]; - } - elseif (!empty($conf->global->PRODUIT_CUSTOMER_PRICES)) + } elseif (!empty($conf->global->PRODUIT_CUSTOMER_PRICES)) { require_once DOL_DOCUMENT_ROOT.'/product/class/productcustomerprice.class.php'; @@ -513,9 +493,7 @@ if (empty($reshook)) if ($price_base_type != 'HT') { $pu_ht = price2num($pu_ttc / (1 + ($tmpvat / 100)), 'MU'); - } - else - { + } else { $pu_ttc = price2num($pu_ht * (1 + ($tmpvat / 100)), 'MU'); } } @@ -525,9 +503,7 @@ if (empty($reshook)) else $desc = dol_concatdesc($desc, $product_desc, '', !empty($conf->global->MAIN_CHANGE_ORDER_CONCAT_DESCRIPTION)); $fk_unit = $prod->fk_unit; - } - else - { + } else { $pu_ht = GETPOST('price_ht'); $price_base_type = 'HT'; $tva_tx = GETPOST('tva_tx') ?str_replace('*', '', GETPOST('tva_tx')) : 0; // tva_tx field may be disabled, so we use vat rate 0 @@ -543,8 +519,7 @@ if (empty($reshook)) $fk_fournprice = $_POST['fournprice']; if (!empty($_POST['buying_price'])) $pa_ht = $_POST['buying_price']; - else - $pa_ht = null; + else $pa_ht = null; $info_bits = 0; if ($tva_npr) $info_bits |= 0x01; @@ -554,9 +529,7 @@ if (empty($reshook)) { $object->error = $langs->trans("CantBeLessThanMinPrice", price(price2num($price_min, 'MU'), 0, $langs, 0, 0, -1, $conf->currency)); $result = -1; - } - else - { + } else { // Insert line $result = $object->addline( $desc, @@ -629,15 +602,11 @@ if (empty($reshook)) unset($_POST['date_endday']); unset($_POST['date_endmonth']); unset($_POST['date_endyear']); - } - else - { + } else { setEventMessages($object->error, $object->errors, 'errors'); } } - } - - elseif ($action == 'updateline' && $user->rights->contrat->creer && !GETPOST('cancel', 'alpha')) { + } elseif ($action == 'updateline' && $user->rights->contrat->creer && !GETPOST('cancel', 'alpha')) { $error = 0; if (!empty($date_start_update) && !empty($date_end_update) && $date_start_update > $date_end_update) @@ -692,8 +661,7 @@ if (empty($reshook)) $fk_fournprice = $_POST['fournprice']; if (!empty($_POST['buying_price'])) $pa_ht = $_POST['buying_price']; - else - $pa_ht = null; + else $pa_ht = null; $fk_unit = GETPOST('unit', 'alpha'); @@ -744,14 +712,10 @@ if (empty($reshook)) if (!$error) { $db->commit(); - } - else - { + } else { $db->rollback(); } - } - - elseif ($action == 'confirm_deleteline' && $confirm == 'yes' && $user->rights->contrat->creer) + } elseif ($action == 'confirm_deleteline' && $confirm == 'yes' && $user->rights->contrat->creer) { $result = $object->deleteline(GETPOST('lineid'), $user); @@ -759,14 +723,10 @@ if (empty($reshook)) { header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); exit; - } - else - { + } else { setEventMessages($object->error, $object->errors, 'errors'); } - } - - elseif ($action == 'confirm_valid' && $confirm == 'yes' && $user->rights->contrat->creer) + } elseif ($action == 'confirm_valid' && $confirm == 'yes' && $user->rights->contrat->creer) { $result = $object->validate($user); @@ -788,14 +748,10 @@ if (empty($reshook)) $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref); } - } - else - { + } else { setEventMessages($object->error, $object->errors, 'errors'); } - } - - elseif ($action == 'reopen' && $user->rights->contrat->creer) + } elseif ($action == 'reopen' && $user->rights->contrat->creer) { $result = $object->reopen($user); if ($result < 0) @@ -822,23 +778,17 @@ if (empty($reshook)) { setEventMessages($object->error, $object->errors, 'errors'); } - } - - elseif ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->contrat->supprimer) + } elseif ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->contrat->supprimer) { $result = $object->delete($user); if ($result >= 0) { header("Location: list.php?restore_lastsearch_values=1"); return; - } - else - { + } else { setEventMessages($object->error, $object->errors, 'errors'); } - } - - elseif ($action == 'confirm_move' && $confirm == 'yes' && $user->rights->contrat->creer) + } elseif ($action == 'confirm_move' && $confirm == 'yes' && $user->rights->contrat->creer) { if (GETPOST('newcid') > 0) { @@ -850,18 +800,13 @@ if (empty($reshook)) { header("Location: ".$_SERVER['PHP_SELF']."?id=".$id); return; - } - else - { + } else { setEventMessages($object->error, $object->errors, 'errors'); } - } - else - { + } else { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("RefNewContract")), null, 'errors'); } - } - elseif ($action == 'update_extras') + } elseif ($action == 'update_extras') { $object->oldcopy = dol_clone($object); @@ -881,8 +826,7 @@ if (empty($reshook)) if ($error) { $action = 'edit_extras'; } - } - elseif ($action == 'setref_supplier') + } elseif ($action == 'setref_supplier') { $cancelbutton = GETPOST('cancel', 'alpha'); if (!$cancelbutton) { @@ -896,13 +840,11 @@ if (empty($reshook)) header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); exit; } - } - else { + } else { header("Location: ".$_SERVER['PHP_SELF']."?id=".$id); exit; } - } - elseif ($action == 'setref_customer') + } elseif ($action == 'setref_customer') { $cancelbutton = GETPOST('cancel', 'alpha'); @@ -918,13 +860,11 @@ if (empty($reshook)) header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); exit; } - } - else { + } else { header("Location: ".$_SERVER['PHP_SELF']."?id=".$id); exit; } - } - elseif ($action == 'setref') + } elseif ($action == 'setref') { $cancelbutton = GETPOST('cancel', 'alpha'); @@ -958,13 +898,11 @@ if (empty($reshook)) header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); exit; } - } - else { + } else { header("Location: ".$_SERVER['PHP_SELF']."?id=".$id); exit; } - } - elseif ($action == 'setdate_contrat') + } elseif ($action == 'setdate_contrat') { $cancelbutton = GETPOST('cancel', 'alpha'); @@ -982,8 +920,7 @@ if (empty($reshook)) header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); exit; } - } - else { + } else { header("Location: ".$_SERVER['PHP_SELF']."?id=".$id); exit; } @@ -1014,16 +951,12 @@ if (empty($reshook)) { header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); exit; - } - else - { + } else { if ($object->error == 'DB_ERROR_RECORD_ALREADY_EXISTS') { $langs->load("errors"); setEventMessages($langs->trans("ErrorThisContactIsAlreadyDefinedAsThisType"), null, 'errors'); - } - else - { + } else { setEventMessages($object->error, $object->errors, 'errors'); } } @@ -1044,8 +977,7 @@ if (empty($reshook)) { header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); exit; - } - else { + } else { setEventMessages($object->error, $object->errors, 'errors'); } } @@ -1057,9 +989,7 @@ if (empty($reshook)) if (!GETPOST('socid', 3)) { setEventMessages($langs->trans("NoCloneOptionsSpecified"), null, 'errors'); - } - else - { + } else { if ($object->id > 0) { $result = $object->createFromClone($user, $socid); if ($result > 0) { @@ -1119,9 +1049,7 @@ if ($action == 'create') if ($element == 'project') { $projectid = GETPOST('originid'); - } - else - { + } else { // For compatibility if ($element == 'order' || $element == 'commande') { $element = $subelement = 'commande'; } if ($element == 'propal') { $element = 'comm/propal'; $subelement = 'propal'; } @@ -1148,8 +1076,7 @@ if ($action == 'create') // Object source contacts list $srccontactslist = $objectsrc->liste_contact(-1, 'external', 1); } - } - else { + } else { $projectid = GETPOST('projectid', 'int'); $note_private = GETPOST("note_private"); $note_public = GETPOST("note_public"); @@ -1195,9 +1122,7 @@ if ($action == 'create') print $soc->getNomUrl(1); print ''; print ''; - } - else - { + } else { print ''; print $form->select_company('', 'socid', '', 'SelectThirdParty', 1, 0, null, 0, 'minwidth300'); print ' '.$langs->trans("AddThirdParty").''; @@ -1291,9 +1216,7 @@ if ($action == 'create') } print "\n"; -} -else -/* *************************************************************************** */ +} else /* *************************************************************************** */ /* */ /* Mode vue et edition */ /* */ @@ -1452,7 +1375,7 @@ else print ''; - // Ligne info remises tiers + // Line info of thirdparty discounts print ''; - } - else - { + } else { print '\n"; } // VAT @@ -1624,9 +1543,7 @@ else if ($objp->remise_percent > 0) { print '\n"; - } - else - { + } else { print ''; } @@ -1644,13 +1561,13 @@ else } if ($user->rights->contrat->creer && ($object->statut >= 0)) { - print ''; + print ''; print img_edit(); print ''; } if ($user->rights->contrat->creer && ($object->statut >= 0)) { - print ''; + print ''; print img_delete(); print ''; } @@ -1683,8 +1600,7 @@ else $textlate = $langs->trans("Late").' = '.$langs->trans("DateReference").' > '.$langs->trans("DateToday").' '.(ceil($warning_delay) >= 0 ? '+' : '').ceil($warning_delay).' '.$langs->trans("days"); print " ".img_warning($textlate); } - } - else print $langs->trans("Unknown"); + } else print $langs->trans("Unknown"); print '  -  '; print $langs->trans("DateEndPlanned").': '; if ($objp->date_fin) @@ -1695,8 +1611,7 @@ else $textlate = $langs->trans("Late").' = '.$langs->trans("DateReference").' > '.$langs->trans("DateToday").' '.(ceil($warning_delay) >= 0 ? '+' : '').ceil($warning_delay).' '.$langs->trans("days"); print " ".img_warning($textlate); } - } - else print $langs->trans("Unknown"); + } else print $langs->trans("Unknown"); print ''; print ''; @@ -1711,8 +1626,7 @@ else } } // Line in mode update - else - { + else { // Ligne carac print ''; print ''; } print ''; print ''; @@ -1803,9 +1715,7 @@ else } $db->free($result); - } - else - { + } else { dol_print_error($db); } @@ -1875,9 +1785,7 @@ else if (empty($dateactend)) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("DateEndReal")), null, 'errors'); - } - else - { + } else { print $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$object->id."&ligne=".GETPOST('ligne', 'int')."&date=".$dateactstart."&dateend=".$dateactend."&comment=".urlencode($comment), $langs->trans("CloseService"), $langs->trans("ConfirmCloseService", dol_print_date($dateactend, "%A %d %B %Y")), "confirm_closeline", '', 0, 1); } print '
'.$langs->trans('Discount').''; if ($object->thirdparty->remise_percent) print $langs->trans("CompanyHasRelativeDiscount", $object->thirdparty->remise_percent); else print $langs->trans("CompanyHasNoRelativeDiscount"); @@ -1502,8 +1425,6 @@ else } - $colorb = '666666'; - $arrayothercontracts = $object->getListOfContracts('others'); /* @@ -1601,9 +1522,7 @@ else echo $form->textwithtooltip($text, $description, 3, '', '', $cursorline, 0, (!empty($line->fk_parent_line) ?img_picto('', 'rightarrow') : '')); print ''.img_object($langs->trans("ShowProductOrService"), ($objp->product_type ? 'service' : 'product')).' '.dol_htmlentitiesbr($objp->description)."'.$objp->remise_percent."% 
'; @@ -1725,9 +1639,7 @@ else print $productstatic->getNomUrl(1, '', 32); print $objp->label ? ' - '.dol_trunc($objp->label, 32) : ''; print '
'; - } - else - { + } else { print $objp->label ? $objp->label.'
' : ''; } @@ -1775,8 +1687,8 @@ else print '
'; - print ''; - print '
'; + print ''; + print '
'; print '
'; @@ -2114,8 +2022,7 @@ else if ($object->statut == 1) { if ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) || $user->rights->commande->order_advance->send)) { print ''; - } else - print ''; + } else print ''; } } @@ -2154,9 +2061,7 @@ else if ($user->rights->contrat->activer) { print ''; - } - else - { + } else { print ''; } } @@ -2165,9 +2070,7 @@ else if ($user->rights->contrat->desactiver) { print ''; - } - else - { + } else { print ''; } @@ -2186,9 +2089,7 @@ else if (($user->rights->contrat->creer && $object->statut == 0) || $user->rights->contrat->supprimer) { print ''; - } - else - { + } else { print ''; } } @@ -2227,13 +2128,12 @@ else $MAXEVENT = 10; - $morehtmlright = dolGetButtonTitle($langs->trans('SeeAll'), '', 'fa fa-list-alt', DOL_URL_ROOT.'/contrat/agenda.php?id='.$object->id); + $morehtmlcenter = dolGetButtonTitle($langs->trans('SeeAll'), '', 'fa fa-list-alt imgforviewmode', DOL_URL_ROOT.'/contrat/agenda.php?id='.$object->id); // List of actions on element include_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php'; $formactions = new FormActions($db); - $somethingshown = $formactions->showactions($object, 'contract', $socid, 1, 'listactions', $MAXEVENT, '', $morehtmlright); - + $somethingshown = $formactions->showactions($object, 'contract', $socid, 1, 'listactions', $MAXEVENT, '', $morehtmlcenter); print ''; } diff --git a/htdocs/contrat/class/api_contracts.class.php b/htdocs/contrat/class/api_contracts.class.php index a35d3c871de..ffe66208afe 100644 --- a/htdocs/contrat/class/api_contracts.class.php +++ b/htdocs/contrat/class/api_contracts.class.php @@ -169,8 +169,7 @@ class Contracts extends DolibarrApi } $i++; } - } - else { + } else { throw new RestException(503, 'Error when retrieve contrat list : '.$db->lasterror()); } if (!count($obj_ret)) { @@ -464,9 +463,7 @@ class Contracts extends DolibarrApi $updateRes = $this->contract->deleteline($lineid, DolibarrApiAccess::$user); if ($updateRes > 0) { return $this->get($id); - } - else - { + } else { throw new RestException(405, $this->contract->error); } } @@ -501,9 +498,7 @@ class Contracts extends DolibarrApi if ($this->contract->update(DolibarrApiAccess::$user) > 0) { return $this->get($id); - } - else - { + } else { throw new RestException(500, $this->contract->error); } } diff --git a/htdocs/contrat/class/contrat.class.php b/htdocs/contrat/class/contrat.class.php index 1dec473edac..c2200a411c2 100644 --- a/htdocs/contrat/class/contrat.class.php +++ b/htdocs/contrat/class/contrat.class.php @@ -298,16 +298,12 @@ class Contrat extends CommonObject if ($numref != "") { return $numref; - } - else - { + } else { $this->error = $obj->error; dol_print_error($db, get_class($this)."::getNextValue ".$obj->error); return ""; } - } - else - { + } else { $langs->load("errors"); print $langs->trans("Error")." ".$langs->trans("ErrorModuleSetupNotComplete", $langs->transnoentitiesnoconv("Contract")); return ""; @@ -410,9 +406,7 @@ class Contrat extends CommonObject { $this->db->commit(); return 1; - } - else - { + } else { $this->db->rollback(); return -1; } @@ -467,9 +461,7 @@ class Contrat extends CommonObject { $this->db->commit(); return 1; - } - else - { + } else { $this->db->rollback(); return -1; } @@ -508,13 +500,10 @@ class Contrat extends CommonObject if ($force_number) { $num = $force_number; - } - elseif (!$error && (preg_match('/^[\(]?PROV/i', $this->ref) || empty($this->ref))) // empty should not happened, but when it occurs, the test save life + } elseif (!$error && (preg_match('/^[\(]?PROV/i', $this->ref) || empty($this->ref))) // empty should not happened, but when it occurs, the test save life { $num = $this->getNextNumRef($this->thirdparty); - } - else - { + } else { $num = $this->ref; } $this->newref = dol_sanitizeFileName($num); @@ -591,9 +580,7 @@ class Contrat extends CommonObject $this->brouillon = 0; $this->date_validation = $now; } - } - else - { + } else { $error++; } @@ -601,9 +588,7 @@ class Contrat extends CommonObject { $this->db->commit(); return 1; - } - else - { + } else { $this->db->rollback(); return -1; } @@ -666,9 +651,7 @@ class Contrat extends CommonObject { $this->db->commit(); return 1; - } - else - { + } else { $this->db->rollback(); return -1; } @@ -720,8 +703,7 @@ class Contrat extends CommonObject $this->error = 'Fetch found several records.'; dol_syslog($this->error, LOG_ERR); $result = -2; - } - elseif ($num) // $num = 1 + } elseif ($num) // $num = 1 { $obj = $this->db->fetch_object($resql); if ($obj) @@ -770,16 +752,12 @@ class Contrat extends CommonObject return $this->id; } - } - else - { + } else { dol_syslog(get_class($this)."::fetch Contract not found"); $this->error = "Contract not found"; return 0; } - } - else - { + } else { dol_syslog(get_class($this)."::fetch Error searching contract"); $this->error = $this->db->error(); return -1; @@ -939,9 +917,7 @@ class Contrat extends CommonObject $pos++; } $this->db->free($result); - } - else - { + } else { dol_syslog(get_class($this)."::Fetch Error when reading lines of contracts linked to products"); return -3; } @@ -1081,8 +1057,7 @@ class Contrat extends CommonObject $error++; } } - } - else // Old behaviour, if linked_object has only one link per type, so is something like array('contract'=>id1)) + } else // Old behaviour, if linked_object has only one link per type, so is something like array('contract'=>id1)) { $origin_id = $tmp_origin_id; $ret = $this->add_object_linked($origin, $origin_id); @@ -1129,8 +1104,7 @@ class Contrat extends CommonObject //print $objcontact->code.'-'.$objcontact->source.'-'.$objcontact->fk_socpeople."\n"; $this->add_contact($objcontact->fk_socpeople, $objcontact->code, $objcontact->source); // May failed because of duplicate key or because code of contact type does not exists for new object } - } - else dol_print_error($resqlcontact); + } else dol_print_error($resqlcontact); } } @@ -1145,24 +1119,18 @@ class Contrat extends CommonObject { $this->db->commit(); return $this->id; - } - else - { + } else { dol_syslog(get_class($this)."::create - 30 - ".$this->error, LOG_ERR); $this->db->rollback(); return -3; } - } - else - { + } else { $this->error = "Failed to add contract"; dol_syslog(get_class($this)."::create - 20 - ".$this->error, LOG_ERR); $this->db->rollback(); return -2; } - } - else - { + } else { $this->error = $langs->trans("UnknownError: ".$this->db->error()." -", LOG_DEBUG); $this->db->rollback(); @@ -1331,9 +1299,7 @@ class Contrat extends CommonObject { $this->db->commit(); return 1; - } - else - { + } else { $this->error = $this->db->lasterror(); $this->db->rollback(); return -1; @@ -1426,9 +1392,7 @@ class Contrat extends CommonObject } $this->db->rollback(); return -1 * $error; - } - else - { + } else { $this->db->commit(); return 1; } @@ -1505,9 +1469,7 @@ class Contrat extends CommonObject if ($price_base_type == 'HT') { $pu = $pu_ht; - } - else - { + } else { $pu = $pu_ttc; } @@ -1558,9 +1520,7 @@ class Contrat extends CommonObject if (($result = $this->defineBuyPrice($pu_ht, $remise_percent, $fk_product)) < 0) { return $result; - } - else - { + } else { $pa_ht = $result; } } @@ -1631,22 +1591,16 @@ class Contrat extends CommonObject { $this->db->rollback(); return -1; - } - else - { + } else { $this->db->commit(); return $contractlineid; } - } - else - { + } else { $this->db->rollback(); $this->error = $this->db->error()." sql=".$sql; return -1; } - } - else - { + } else { dol_syslog(get_class($this)."::addline ErrorTryToAddLineOnValidatedContract", LOG_ERR); return -2; } @@ -1698,9 +1652,7 @@ class Contrat extends CommonObject { $remise = round(($pu * $remise_percent / 100), 2); $price = $pu - $remise; - } - else - { + } else { $remise_percent = 0; } @@ -1750,9 +1702,7 @@ class Contrat extends CommonObject if (($result = $this->defineBuyPrice($pu, $remise_percent)) < 0) { return $result; - } - else - { + } else { $pa_ht = $result; } } @@ -1775,14 +1725,10 @@ class Contrat extends CommonObject $sql .= ", total_ttc='".price2num($total_ttc)."'"; $sql .= ", fk_product_fournisseur_price=".($fk_fournprice > 0 ? $fk_fournprice : "null"); $sql .= ", buy_price_ht='".price2num($pa_ht)."'"; - if ($date_start > 0) { $sql .= ",date_ouverture_prevue='".$this->db->idate($date_start)."'"; } - else { $sql .= ",date_ouverture_prevue=null"; } - if ($date_end > 0) { $sql .= ",date_fin_validite='".$this->db->idate($date_end)."'"; } - else { $sql .= ",date_fin_validite=null"; } - if ($date_debut_reel > 0) { $sql .= ",date_ouverture='".$this->db->idate($date_debut_reel)."'"; } - else { $sql .= ",date_ouverture=null"; } - if ($date_fin_reel > 0) { $sql .= ",date_cloture='".$this->db->idate($date_fin_reel)."'"; } - else { $sql .= ",date_cloture=null"; } + if ($date_start > 0) { $sql .= ",date_ouverture_prevue='".$this->db->idate($date_start)."'"; } else { $sql .= ",date_ouverture_prevue=null"; } + if ($date_end > 0) { $sql .= ",date_fin_validite='".$this->db->idate($date_end)."'"; } else { $sql .= ",date_fin_validite=null"; } + if ($date_debut_reel > 0) { $sql .= ",date_ouverture='".$this->db->idate($date_debut_reel)."'"; } else { $sql .= ",date_ouverture=null"; } + if ($date_fin_reel > 0) { $sql .= ",date_cloture='".$this->db->idate($date_fin_reel)."'"; } else { $sql .= ",date_cloture=null"; } $sql .= ", fk_unit=".($fk_unit ? "'".$this->db->escape($fk_unit)."'" : "null"); $sql .= " WHERE rowid = ".$rowid; @@ -1825,16 +1771,12 @@ class Contrat extends CommonObject $this->db->commit(); return 1; } - } - else - { + } else { $this->db->rollback(); dol_syslog(get_class($this)."::updateline Erreur -2"); return -2; } - } - else - { + } else { $this->db->rollback(); $this->error = $this->db->error(); dol_syslog(get_class($this)."::updateline Erreur -1"); @@ -1895,9 +1837,7 @@ class Contrat extends CommonObject $this->db->rollback(); return -1; } - } - else - { + } else { $this->error = 'ErrorDeleteLineNotAllowedByObjectStatus'; return -2; } @@ -1993,9 +1933,7 @@ class Contrat extends CommonObject $text .= ($mode != 7 || $this->nbofservicesclosed > 0) ? ($this->nbofservicesclosed.ContratLigne::LibStatut(5, 3, -1, 'class="marginleft2"')) : ''; $text .= ($mode == 7 ? '' : ''); return $text; - } - else - { + } else { return dolGetStatus($this->labelStatus[$status], $this->labelStatusShort[$status], '', $statusType, $mode); } } @@ -2113,9 +2051,7 @@ class Contrat extends CommonObject } $this->db->free($result); - } - else - { + } else { dol_print_error($this->db); } } @@ -2150,9 +2086,7 @@ class Contrat extends CommonObject $i++; } return $tab; - } - else - { + } else { $this->error = $this->db->error(); return -1; } @@ -2188,9 +2122,7 @@ class Contrat extends CommonObject $i++; } return $tab; - } - else - { + } else { $this->error = $this->db->error(); return -1; } @@ -2222,8 +2154,7 @@ class Contrat extends CommonObject $sql .= " WHERE c.statut = 1"; $sql .= " AND c.rowid = cd.fk_contrat"; $sql .= " AND cd.statut = 0"; - } - elseif ($mode == 'expired') + } elseif ($mode == 'expired') { $sql = "SELECT cd.rowid, cd.date_fin_validite as datefin"; $sql .= $this->from; @@ -2231,8 +2162,7 @@ class Contrat extends CommonObject $sql .= " AND c.rowid = cd.fk_contrat"; $sql .= " AND cd.statut = 4"; $sql .= " AND cd.date_fin_validite < '".$this->db->idate(dol_now())."'"; - } - elseif ($mode == 'active') + } elseif ($mode == 'active') { $sql = "SELECT cd.rowid, cd.date_fin_validite as datefin"; $sql .= $this->from; @@ -2258,8 +2188,7 @@ class Contrat extends CommonObject $label = $langs->trans("BoardNotActivatedServices"); $labelShort = $langs->trans("BoardNotActivatedServicesShort"); $url = DOL_URL_ROOT.'/contrat/services_list.php?mainmenu=commercial&leftmenu=contracts&mode=0&sortfield=cd.date_fin_validite&sortorder=asc'; - } - elseif ($mode == 'expired') { + } elseif ($mode == 'expired') { $warning_delay = $conf->contrat->services->expires->warning_delay; $url = DOL_URL_ROOT.'/contrat/services_list.php?mainmenu=commercial&leftmenu=contracts&mode=4&filter=expired&sortfield=cd.date_fin_validite&sortorder=asc'; $label = $langs->trans("BoardExpiredServices"); @@ -2290,9 +2219,7 @@ class Contrat extends CommonObject } return $response; - } - else - { + } else { dol_print_error($this->db); $this->error = $this->db->error(); return -1; @@ -2333,9 +2260,7 @@ class Contrat extends CommonObject } $this->db->free($resql); return 1; - } - else - { + } else { dol_print_error($this->db); $this->error = $this->db->error(); return -1; @@ -2791,11 +2716,22 @@ class ContratLigne extends CommonObjectLine global $langs; $langs->load("contracts"); - if ($status == self::STATUS_INITIAL) { $labelStatus = $langs->trans("ServiceStatusInitial"); $labelStatusShort = $langs->trans("ServiceStatusInitial"); } - elseif ($status == self::STATUS_OPEN && $expired == -1) { $labelStatus = $langs->trans("ServiceStatusRunning"); $labelStatusShort = $langs->trans("ServiceStatusRunning"); } - elseif ($status == self::STATUS_OPEN && $expired == 0) { $labelStatus = $langs->trans("ServiceStatusNotLate"); $labelStatusShort = $langs->trans("ServiceStatusNotLateShort"); } - elseif ($status == self::STATUS_OPEN && $expired == 1) { $labelStatus = $langs->trans("ServiceStatusLate"); $labelStatusShort = $langs->trans("ServiceStatusLateShort"); } - elseif ($status == self::STATUS_CLOSED) { $labelStatus = $langs->trans("ServiceStatusClosed"); $labelStatusShort = $langs->trans("ServiceStatusClosed"); } + if ($status == self::STATUS_INITIAL) { + $labelStatus = $langs->trans("ServiceStatusInitial"); + $labelStatusShort = $langs->trans("ServiceStatusInitial"); + } elseif ($status == self::STATUS_OPEN && $expired == -1) { + $labelStatus = $langs->trans("ServiceStatusRunning"); + $labelStatusShort = $langs->trans("ServiceStatusRunning"); + } elseif ($status == self::STATUS_OPEN && $expired == 0) { + $labelStatus = $langs->trans("ServiceStatusNotLate"); + $labelStatusShort = $langs->trans("ServiceStatusNotLateShort"); + } elseif ($status == self::STATUS_OPEN && $expired == 1) { + $labelStatus = $langs->trans("ServiceStatusLate"); + $labelStatusShort = $langs->trans("ServiceStatusLateShort"); + } elseif ($status == self::STATUS_CLOSED) { + $labelStatus = $langs->trans("ServiceStatusClosed"); + $labelStatusShort = $langs->trans("ServiceStatusClosed"); + } $statusType = 'status'.$status; if ($status == self::STATUS_OPEN && $expired == 1) $statusType = 'status1'; @@ -2959,9 +2895,7 @@ class ContratLigne extends CommonObjectLine $this->db->free($resql); return 1; - } - else - { + } else { $this->error = "Error ".$this->db->lasterror(); return -1; } @@ -3046,9 +2980,7 @@ class ContratLigne extends CommonObjectLine if (($result = $this->defineBuyPrice($this->subprice, $this->remise_percent, $this->fk_product)) < 0) { return $result; - } - else - { + } else { $this->pa_ht = $result; } } @@ -3195,9 +3127,7 @@ class ContratLigne extends CommonObjectLine { $this->db->commit(); return 1; - } - else - { + } else { $this->error = $this->db->error(); $this->db->rollback(); return -2; @@ -3278,9 +3208,7 @@ class ContratLigne extends CommonObjectLine $this->db->commit(); return 1; - } - else - { + } else { $this->db->rollback(); $this->error = $this->db->error()." sql=".$sql; return -1; @@ -3333,9 +3261,7 @@ class ContratLigne extends CommonObjectLine $this->db->commit(); return 1; - } - else - { + } else { $this->db->rollback(); return -1; } diff --git a/htdocs/contrat/contact.php b/htdocs/contrat/contact.php index 1da2416ce84..02d9c71776d 100644 --- a/htdocs/contrat/contact.php +++ b/htdocs/contrat/contact.php @@ -70,9 +70,7 @@ if ($action == 'addcontact' && $user->rights->contrat->creer) { header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); exit; - } - else - { + } else { if ($object->error == 'DB_ERROR_RECORD_ALREADY_EXISTS') { $langs->load("errors"); $msg = $langs->trans("ErrorThisContactIsAlreadyDefinedAsThisType"); @@ -90,9 +88,7 @@ if ($action == 'swapstatut' && $user->rights->contrat->creer) if ($object->fetch($id)) { $result = $object->swapContactStatus(GETPOST('ligne')); - } - else - { + } else { dol_print_error($db, $object->error); } } diff --git a/htdocs/contrat/document.php b/htdocs/contrat/document.php index 7d47b5102ac..d60d54258bb 100644 --- a/htdocs/contrat/document.php +++ b/htdocs/contrat/document.php @@ -179,7 +179,6 @@ if ($object->id) print '
'; print '
'; - print ''; print ''; print ''; @@ -194,9 +193,7 @@ if ($object->id) $permtoedit = $user->rights->contrat->creer; $param = '&id='.$object->id; include_once DOL_DOCUMENT_ROOT.'/core/tpl/document_actions_post_headers.tpl.php'; -} -else -{ +} else { print $langs->trans("ErrorUnknown"); } diff --git a/htdocs/contrat/index.php b/htdocs/contrat/index.php index 2a7c9c0d91a..40a9a4100da 100644 --- a/htdocs/contrat/index.php +++ b/htdocs/contrat/index.php @@ -140,9 +140,7 @@ if ($resql) $i++; } $db->free($resql); -} -else -{ +} else { dol_print_error($db); } // Search by status (only expired) @@ -179,9 +177,7 @@ if ($resql) $i++; } $db->free($resql); -} -else -{ +} else { dol_print_error($db); } @@ -298,16 +294,12 @@ if (!empty($conf->contrat->enabled) && $user->rights->contrat->lire) //$tot_ttc+=$obj->total_ttc; $i++; } - } - else - { + } else { print ''; } print "
'.$langs->trans("NbOfAttachedFiles").''.count($filearray).'
'.$langs->trans("TotalSizeOfAttachedFiles").''.dol_print_size($totalsize, 1, 1).'
'.$langs->trans("NoContracts").'

"; $db->free($resql); - } - else - { + } else { dol_print_error($db); } } @@ -383,9 +375,7 @@ if ($result) $db->free($result); print ""; -} -else -{ +} else { dol_print_error($db); } @@ -439,9 +429,7 @@ if ($resql) $productstatic->ref = $obj->pref; $productstatic->entity = $obj->pentity; print $productstatic->getNomUrl(1, '', 20); - } - else - { + } else { print ''.img_object($langs->trans("ShowService"), "service"); if ($obj->label) print ' '.dol_trunc($obj->label, 20).''; else print ' '.dol_trunc($obj->note, 20); @@ -462,9 +450,7 @@ if ($resql) $db->free(); print ""; -} -else -{ +} else { dol_print_error($db); } @@ -519,9 +505,7 @@ if ($resql) $productstatic->ref = $obj->pref; $productstatic->entity = $obj->pentity; print $productstatic->getNomUrl(1, '', 20); - } - else - { + } else { print ''.img_object($langs->trans("ShowService"), "service"); if ($obj->label) print ' '.dol_trunc($obj->label, 20).''; else print ' '.dol_trunc($obj->note, 20); @@ -541,9 +525,7 @@ if ($resql) $db->free(); print ""; -} -else -{ +} else { dol_print_error($db); } @@ -599,9 +581,7 @@ if ($resql) $productstatic->ref = $obj->pref; $productstatic->entity = $obj->pentity; print $productstatic->getNomUrl(1, '', 20); - } - else - { + } else { print ''.img_object($langs->trans("ShowService"), "service"); if ($obj->label) print ' '.dol_trunc($obj->label, 20).''; else print ' '.dol_trunc($obj->note, 20); @@ -621,9 +601,7 @@ if ($resql) $db->free(); print ""; -} -else -{ +} else { dol_print_error($db); } diff --git a/htdocs/contrat/list.php b/htdocs/contrat/list.php index 4b163480035..3627661c727 100644 --- a/htdocs/contrat/list.php +++ b/htdocs/contrat/list.php @@ -708,8 +708,7 @@ while ($i < min($num, $limit)) if ($nbofsalesrepresentative > 3) { // We print only number print $nbofsalesrepresentative; - } - elseif ($nbofsalesrepresentative > 0) + } elseif ($nbofsalesrepresentative > 0) { $userstatic = new User($db); $j = 0; @@ -731,9 +730,7 @@ while ($i < min($num, $limit)) } } //else print $langs->trans("NoSalesRepresentativeAffected"); - } - else - { + } else { print ' '; } print ''; @@ -746,7 +743,7 @@ while ($i < min($num, $limit)) // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; // Fields from hook - $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$obj); + $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray); $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; // Date creation diff --git a/htdocs/contrat/services_list.php b/htdocs/contrat/services_list.php index b8ab4cfe1ce..fd46b8eba98 100644 --- a/htdocs/contrat/services_list.php +++ b/htdocs/contrat/services_list.php @@ -98,14 +98,11 @@ if ($search_status != '') $tmp = explode('&', $search_status); $mode = $tmp[0]; if (empty($tmp[1])) $filter = ''; - else - { + else { if ($tmp[1] == 'filter=notexpired') $filter = 'notexpired'; if ($tmp[1] == 'filter=expired') $filter = 'expired'; } -} -else -{ +} else { $search_status = $mode; if ($filter == 'expired') $search_status .= '&filter=expired'; if ($filter == 'notexpired') $search_status .= '&filter=notexpired'; @@ -247,22 +244,31 @@ if ($search_name) $sql .= " AND s.nom LIKE '%".$db->escape($search_name)."%' if ($search_contract) $sql .= " AND c.ref LIKE '%".$db->escape($search_contract)."%' "; if ($search_service) $sql .= " AND (p.ref LIKE '%".$db->escape($search_service)."%' OR p.description LIKE '%".$db->escape($search_service)."%' OR cd.description LIKE '%".$db->escape($search_service)."%')"; if ($socid > 0) $sql .= " AND s.rowid = ".$socid; -$filter_dateouvertureprevue = dol_mktime(0, 0, 0, $opouvertureprevuemonth, $opouvertureprevueday, $opouvertureprevueyear); -if ($filter_dateouvertureprevue != '' && $filter_opouvertureprevue == -1) $filter_opouvertureprevue = '='; -$filter_date1 = dol_mktime(0, 0, 0, $op1month, $op1day, $op1year); -if ($filter_date1 != '' && $filter_op1 == -1) $filter_op1 = '='; +$filter_dateouvertureprevue_start=dol_mktime(0, 0, 0, $opouvertureprevuemonth, $opouvertureprevueday, $opouvertureprevueyear); +$filter_dateouvertureprevue_end=dol_mktime(23, 59, 59, $opouvertureprevuemonth, $opouvertureprevueday, $opouvertureprevueyear); +if ($filter_dateouvertureprevue_start != '' && $filter_opouvertureprevue == -1) $filter_opouvertureprevue = ' BETWEEN '; -$filter_date2 = dol_mktime(0, 0, 0, $op2month, $op2day, $op2year); -if ($filter_date2 != '' && $filter_op2 == -1) $filter_op2 = '='; +$filter_date1_start =dol_mktime(0, 0, 0, $op1month, $op1day, $op1year); +$filter_date1_end =dol_mktime(23, 59, 59, $op1month, $op1day, $op1year); +if ($filter_date1_start != '' && $filter_op1 == -1) $filter_op1 = ' BETWEEN '; -$filter_datecloture = dol_mktime(0, 0, 0, $opcloturemonth, $opclotureday, $opclotureyear); -if ($filter_datecloture != '' && $filter_opcloture == -1) $filter_opcloture = '='; +$filter_date2_start=dol_mktime(0, 0, 0, $op2month, $op2day, $op2year); +$filter_date2_end=dol_mktime(23, 59, 59, $op2month, $op2day, $op2year); +if ($filter_date2_start != '' && $filter_op2 == -1) $filter_op2 = ' BETWEEN '; -if (!empty($filter_opouvertureprevue) && $filter_opouvertureprevue != -1 && $filter_dateouvertureprevue != '') $sql .= " AND cd.date_ouverture_prevue ".$filter_opouvertureprevue." '".$db->idate($filter_dateouvertureprevue)."'"; -if (!empty($filter_op1) && $filter_op1 != -1 && $filter_date1 != '') $sql .= " AND cd.date_ouverture ".$filter_op1." '".$db->idate($filter_date1)."'"; -if (!empty($filter_op2) && $filter_op2 != -1 && $filter_date2 != '') $sql .= " AND cd.date_fin_validite ".$filter_op2." '".$db->idate($filter_date2)."'"; -if (!empty($filter_opcloture) && $filter_opcloture != -1 && $filter_datecloture != '') $sql .= " AND cd.date_cloture ".$filter_opcloture." '".$db->idate($filter_datecloture)."'"; +$filter_datecloture_start=dol_mktime(0, 0, 0, $opcloturemonth, $opclotureday, $opclotureyear); +$filter_datecloture_end=dol_mktime(23, 59, 59, $opcloturemonth, $opclotureday, $opclotureyear); +if ($filter_datecloture_start != '' && $filter_opcloture == -1) $filter_opcloture = ' BETWEEN '; + +if (! empty($filter_opouvertureprevue) && $filter_opouvertureprevue != -1 && $filter_opouvertureprevue != ' BETWEEN ' && $filter_dateouvertureprevue_start != '') $sql.= " AND cd.date_ouverture_prevue ".$filter_opouvertureprevue." '".$db->idate($filter_dateouvertureprevue_start)."'"; +if (! empty($filter_opouvertureprevue) && $filter_opouvertureprevue == ' BETWEEN ') $sql.= " AND '".$db->idate($filter_dateouvertureprevue_end)."'"; +if (! empty($filter_op1) && $filter_op1 != -1 && $filter_op1 != ' BETWEEN ' && $filter_date1_start != '') $sql.= " AND cd.date_ouverture ".$filter_op1." '".$db->idate($filter_date1_start)."'"; +if (! empty($filter_op1) && $filter_op1==' BETWEEN ') $sql.= " AND '".$db->idate($filter_date1_end)."'"; +if (! empty($filter_op2) && $filter_op2 != -1 && $filter_op2 != ' BETWEEN ' && $filter_date2_start != '') $sql.= " AND cd.date_fin_validite ".$filter_op2." '".$db->idate($filter_date2_start)."'"; +if (! empty($filter_op2) && $filter_op2==' BETWEEN ') $sql.= " AND '".$db->idate($filter_date2_end)."'"; +if (! empty($filter_opcloture) && $filter_opcloture != ' BETWEEN ' && $filter_opcloture != -1 && $filter_datecloture_start != '') $sql.= " AND cd.date_cloture ".$filter_opcloture." '".$db->idate($filter_datecloture_start)."'"; +if (! empty($filter_opcloture) && $filter_opcloture==' BETWEEN ') $sql.= " AND '".$db->idate($filter_datecloture_end)."'"; // Add where from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php'; $sql .= $db->order($sortfield, $sortorder); @@ -588,9 +594,7 @@ while ($i < min($num, $limit)) print $productstatic->getNomUrl(1, '', 24); print $obj->label ? ' - '.dol_trunc($obj->label, 16) : ''; if (!empty($obj->description) && !empty($conf->global->PRODUCT_DESC_IN_LIST)) print '
'.dol_nl2br($obj->description); - } - else - { + } else { if ($obj->type == 0) print img_object($obj->description, 'product').' '.dol_trunc($obj->description, 24); if ($obj->type == 1) print img_object($obj->description, 'service').' '.dol_trunc($obj->description, 24); } @@ -673,8 +677,7 @@ while ($i < min($num, $limit)) $warning_delay = $conf->contrat->services->expires->warning_delay / 3600 / 24; $textlate = $langs->trans("Late").' = '.$langs->trans("DateReference").' > '.$langs->trans("DateToday").' '.(ceil($warning_delay) >= 0 ? '+' : '').ceil($warning_delay).' '.$langs->trans("days"); print img_warning($textlate); - } - else print '    '; + } else print '    '; print ''; if (!$i) $totalarray['nbfield']++; } @@ -688,7 +691,7 @@ while ($i < min($num, $limit)) // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; // Fields from hook - $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$obj); + $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray); $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; // Date creation @@ -715,9 +718,7 @@ while ($i < min($num, $limit)) { // If contract is draft, we say line is also draft print $contractstatic->LibStatut(0, 5); - } - else - { + } else { print $staticcontratligne->LibStatut($obj->statut, 5, ($obj->date_fin_validite && $db->jdate($obj->date_fin_validite) < $now) ? 1 : 0); } print ''; diff --git a/htdocs/core/actions_addupdatedelete.inc.php b/htdocs/core/actions_addupdatedelete.inc.php index 66ed09413ef..f9f10f636ca 100644 --- a/htdocs/core/actions_addupdatedelete.inc.php +++ b/htdocs/core/actions_addupdatedelete.inc.php @@ -40,8 +40,7 @@ if ($cancel) { header("Location: ".$backtopageforcancel); exit; - } - elseif (!empty($backtopage)) + } elseif (!empty($backtopage)) { header("Location: ".$backtopage); exit; @@ -57,8 +56,7 @@ if ($action == 'add' && !empty($permissiontoadd)) { if ($object->fields[$key]['type'] == 'duration') { if (GETPOST($key.'hour') == '' && GETPOST($key.'min') == '') continue; // The field was not submited to be edited - } - else { + } else { if (!GETPOSTISSET($key)) continue; // The field was not submited to be edited } // Ignore special fields @@ -106,17 +104,13 @@ if ($action == 'add' && !empty($permissiontoadd)) $urltogo = preg_replace('/--IDFORBACKTOPAGE--/', $object->id, $urltogo); // New method to autoselect project after a New on another form object creation header("Location: ".$urltogo); exit; - } - else - { + } else { // Creation KO if (!empty($object->errors)) setEventMessages(null, $object->errors, 'errors'); - else setEventMessages($object->error, null, 'errors'); + else setEventMessages($object->error, null, 'errors'); $action = 'create'; } - } - else - { + } else { $action = 'create'; } } @@ -129,15 +123,12 @@ if ($action == 'update' && !empty($permissiontoadd)) // 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 - } - elseif ($object->fields[$key]['type'] == 'boolean') { + } 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 { + } else { if (!GETPOSTISSET($key)) continue; // The field was not submited to be edited } // Ignore special fields @@ -180,16 +171,12 @@ if ($action == 'update' && !empty($permissiontoadd)) if ($result > 0) { $action = 'view'; - } - else - { + } else { // Creation KO setEventMessages($object->error, $object->errors, 'errors'); $action = 'edit'; } - } - else - { + } else { $action = 'edit'; } } @@ -208,9 +195,7 @@ if ($action == "update_extras" && !empty($permissiontoadd)) { setEventMessages($langs->trans('RecordSaved'), null, 'mesgs'); $action = 'view'; - } - else - { + } else { setEventMessages($object->error, $object->errors, 'errors'); $action = 'edit_extras'; } @@ -232,9 +217,7 @@ if ($action == 'confirm_delete' && !empty($permissiontodelete)) setEventMessages("RecordDeleted", null, 'mesgs'); header("Location: ".$backurlforlist); exit; - } - else - { + } else { if (!empty($object->errors)) setEventMessages(null, $object->errors, 'errors'); else setEventMessages($object->error, null, 'errors'); } @@ -269,9 +252,7 @@ if ($action == 'confirm_deleteline' && $confirm == 'yes' && !empty($permissionto setEventMessages($langs->trans('RecordDeleted'), null, 'mesgs'); header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id); exit; - } - else - { + } else { setEventMessages($object->error, $object->errors, 'errors'); } } @@ -298,9 +279,7 @@ if ($action == 'confirm_validate' && $confirm == 'yes' && $permissiontoadd) $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref); } - } - else - { + } else { setEventMessages($object->error, $object->errors, 'errors'); } } @@ -327,9 +306,7 @@ if ($action == 'confirm_close' && $confirm == 'yes' && $permissiontoadd) $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref); } - } - else - { + } else { setEventMessages($object->error, $object->errors, 'errors'); } } @@ -341,9 +318,7 @@ if ($action == 'confirm_setdraft' && $confirm == 'yes' && $permissiontoadd) if ($result >= 0) { // Nothing else done - } - else - { + } else { setEventMessages($object->error, $object->errors, 'errors'); } } @@ -370,9 +345,7 @@ if ($action == 'confirm_reopen' && $confirm == 'yes' && $permissiontoadd) $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref); } - } - else - { + } else { setEventMessages($object->error, $object->errors, 'errors'); } } @@ -383,9 +356,7 @@ if ($action == 'confirm_clone' && $confirm == 'yes' && !empty($permissiontoadd)) if (1 == 0 && !GETPOST('clone_content') && !GETPOST('clone_receivers')) { setEventMessages($langs->trans("NoCloneOptionsSpecified"), null, 'errors'); - } - else - { + } 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')); // ... @@ -397,9 +368,7 @@ if ($action == 'confirm_clone' && $confirm == 'yes' && !empty($permissiontoadd)) else $newid = $result; header("Location: ".$_SERVER['PHP_SELF'].'?id='.$newid); // Open record of new object exit; - } - else - { + } else { setEventMessages($objectutil->error, $objectutil->errors, 'errors'); $action = ''; } diff --git a/htdocs/core/actions_builddoc.inc.php b/htdocs/core/actions_builddoc.inc.php index ce582040ac9..eb51796eccd 100644 --- a/htdocs/core/actions_builddoc.inc.php +++ b/htdocs/core/actions_builddoc.inc.php @@ -37,9 +37,7 @@ if ($action == 'builddoc' && $permissiontoadd) if (is_numeric(GETPOST('model', 'alpha'))) { $error = $langs->trans("ErrorFieldRequired", $langs->transnoentities("Model")); - } - else - { + } else { // Reload to get all modified line records and be ready for hooks $ret = $object->fetch($id); $ret = $object->fetch_thirdparty(); @@ -89,9 +87,7 @@ if ($action == 'builddoc' && $permissiontoadd) { setEventMessages($object->error, $object->errors, 'errors'); $action = ''; - } - else - { + } else { if (empty($donotredirect)) // This is set when include is done by bulk action "Bill Orders" { setEventMessages($langs->trans("FileGenerated"), null); @@ -134,8 +130,7 @@ if ($action == 'remove_file' && $permissiontoadd) header('Location: '.$urltoredirect); exit; - } - else { + } else { setEventMessages('BugFoundVarUploaddirnotDefined', null, 'errors'); } } diff --git a/htdocs/core/actions_comments.inc.php b/htdocs/core/actions_comments.inc.php index 07829999c10..c352f07f9f7 100644 --- a/htdocs/core/actions_comments.inc.php +++ b/htdocs/core/actions_comments.inc.php @@ -49,9 +49,7 @@ if ($action == 'addcomment') setEventMessages($langs->trans("CommentAdded"), null, 'mesgs'); header('Location: '.$varpage.'?id='.$id.($withproject ? '&withproject=1' : '')); exit; - } - else - { + } else { setEventMessages($comment->error, $comment->errors, 'errors'); $action = ''; } @@ -67,9 +65,7 @@ if ($action === 'updatecomment') setEventMessages($langs->trans("CommentAdded"), null, 'mesgs'); header('Location: '.$varpage.'?id='.$id.($withproject ? '&withproject=1#comment' : '')); exit; - } - else - { + } else { setEventMessages($comment->error, $comment->errors, 'errors'); $action = ''; } @@ -84,9 +80,7 @@ if ($action == 'deletecomment') setEventMessages($langs->trans("CommentDeleted"), null, 'mesgs'); header('Location: '.$varpage.'?id='.$id.($withproject ? '&withproject=1' : '')); exit; - } - else - { + } else { setEventMessages($comment->error, $comment->errors, 'errors'); $action = ''; } diff --git a/htdocs/core/actions_extrafields.inc.php b/htdocs/core/actions_extrafields.inc.php index bb5a7516fb2..46a6a31c202 100644 --- a/htdocs/core/actions_extrafields.inc.php +++ b/htdocs/core/actions_extrafields.inc.php @@ -122,9 +122,7 @@ if ($action == 'add') $mesg[] = $langs->trans("ErrorBadFormatValueList", $param_ligne); $action = 'create'; } - } - else - { + } else { $error++; $langs->load("errors"); $mesg[] = $langs->trans("ErrorBadFormatValueList", $param_ligne); @@ -149,9 +147,7 @@ if ($action == 'add') { $params['options'] = array($parameters=>null); } - } - else - { + } else { //Esle it's separated key/value and coma list foreach ($parameters_array as $param_ligne) { @@ -191,25 +187,19 @@ if ($action == 'add') setEventMessages($langs->trans('SetupSaved'), null, 'mesgs'); header("Location: ".$_SERVER["PHP_SELF"]); exit; - } - else - { + } else { $error++; $mesg = $extrafields->error; setEventMessages($mesg, null, 'errors'); } - } - else - { + } else { $error++; $langs->load("errors"); $mesg = $langs->trans("ErrorFieldCanNotContainSpecialNorUpperCharacters", $langs->transnoentities("AttributeCode")); setEventMessages($mesg, null, 'errors'); $action = 'create'; } - } - else - { + } else { setEventMessages($mesg, null, 'errors'); } } @@ -293,9 +283,7 @@ if ($action == 'update') $mesg[] = $langs->trans("ErrorBadFormatValueList", $param_ligne); $action = 'edit'; } - } - else - { + } else { $error++; $langs->load("errors"); $mesg[] = $langs->trans("ErrorBadFormatValueList", $param_ligne); @@ -319,9 +307,7 @@ if ($action == 'update') { $params['options'] = array($parameters=>null); } - } - else - { + } else { //Esle it's separated key/value and coma list foreach ($parameters_array as $param_ligne) { @@ -361,24 +347,18 @@ if ($action == 'update') setEventMessages($langs->trans('SetupSaved'), null, 'mesgs'); header("Location: ".$_SERVER["PHP_SELF"]); exit; - } - else - { + } else { $error++; $mesg = $extrafields->error; setEventMessages($mesg, null, 'errors'); } - } - else - { + } else { $error++; $langs->load("errors"); $mesg = $langs->trans("ErrorFieldCanNotContainSpecialCharacters", $langs->transnoentities("AttributeCode")); setEventMessages($mesg, null, 'errors'); } - } - else - { + } else { setEventMessages($mesg, null, 'errors'); } } @@ -394,11 +374,8 @@ if ($action == 'delete') { header("Location: ".$_SERVER["PHP_SELF"]); exit; - } - else $mesg = $extrafields->error; - } - else - { + } else $mesg = $extrafields->error; + } else { $error++; $langs->load("errors"); $mesg = $langs->trans("ErrorFieldCanNotContainSpecialCharacters", $langs->transnoentities("AttributeCode")); diff --git a/htdocs/core/actions_fetchobject.inc.php b/htdocs/core/actions_fetchobject.inc.php index 268d37d92d2..a77fc6e5ff6 100644 --- a/htdocs/core/actions_fetchobject.inc.php +++ b/htdocs/core/actions_fetchobject.inc.php @@ -37,17 +37,14 @@ if (($id > 0 || (!empty($ref) && !in_array($action, array('create', 'createtask' { $object->fetch_thirdparty(); $id = $object->id; - } - else - { + } else { 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 setEventMessages($object->error, $object->errors, 'errors'); + } else setEventMessages($object->error, $object->errors, 'errors'); $action = ''; } } diff --git a/htdocs/core/actions_linkedfiles.inc.php b/htdocs/core/actions_linkedfiles.inc.php index 2542cf23268..ea55052f880 100644 --- a/htdocs/core/actions_linkedfiles.inc.php +++ b/htdocs/core/actions_linkedfiles.inc.php @@ -41,8 +41,7 @@ if (GETPOST('sendit', 'alpha') && !empty($conf->global->MAIN_UPLOAD_DOC)) $error++; if ($_FILES['userfile']['error'][$key] == 1 || $_FILES['userfile']['error'][$key] == 2) { setEventMessages($langs->trans('ErrorFileSizeTooLarge'), null, 'errors'); - } - else { + } else { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("File")), null, 'errors'); } } @@ -58,15 +57,13 @@ if (GETPOST('sendit', 'alpha') && !empty($conf->global->MAIN_UPLOAD_DOC)) 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); - } - elseif (!empty($upload_dir)) + } elseif (!empty($upload_dir)) { $result = dol_add_file_process($upload_dir, $allowoverwrite, 1, 'userfile', GETPOST('savingdocmask', 'alpha'), null, '', $generatethumbs); } } } -} -elseif (GETPOST('linkit', 'none') && !empty($conf->global->MAIN_UPLOAD_DOC)) +} elseif (GETPOST('linkit', 'none') && !empty($conf->global->MAIN_UPLOAD_DOC)) { $link = GETPOST('link', 'alpha'); if ($link) @@ -86,8 +83,7 @@ if ($action == 'confirm_deletefile' && $confirm == 'yes') 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. + } 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; @@ -124,8 +120,7 @@ if ($action == 'confirm_deletefile' && $confirm == 'yes') } else { setEventMessages($langs->trans("ErrorFailToDeleteFile", $urlfile), null, 'errors'); } - } - elseif ($linkid) // delete of external link + } elseif ($linkid) // delete of external link { require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php'; $link = new Link($db); @@ -148,16 +143,13 @@ if ($action == 'confirm_deletefile' && $confirm == 'yes') if ($backtopage) { header('Location: '.$backtopage); exit; - } - else - { + } else { $tmpurl = $_SERVER["PHP_SELF"].'?id='.$object->id.(GETPOST('section_dir', 'alpha') ? '§ion_dir='.urlencode(GETPOST('section_dir', 'alpha')) : '').(!empty($withproject) ? '&withproject=1' : ''); header('Location: '.$tmpurl); 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'); @@ -176,13 +168,10 @@ elseif ($action == 'confirm_updateline' && GETPOST('save', 'alpha') && GETPOST(' { setEventMessages($langs->trans("ErrorFailedToUpdateLink", $link->label), null, 'mesgs'); } - } - else - { + } 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)) @@ -235,15 +224,11 @@ elseif ($action == 'renamefile' && GETPOST('renamefilesave', 'alpha')) } setEventMessages($langs->trans("FileRenamed"), null); - } - else - { + } else { $langs->load("errors"); // key must be loaded because we can't rely on loading during output, we need var substitution to be done now. setEventMessages($langs->trans("ErrorFailToRenameFile", $filenamefrom, $filenameto), null, 'errors'); } - } - else - { + } else { $langs->load("errors"); // key must be loaded because we can't rely on loading during output, we need var substitution to be done now. setEventMessages($langs->trans("ErrorDestinationAlreadyExists", $filenameto), null, 'errors'); } @@ -269,9 +254,7 @@ elseif ($action == 'renamefile' && GETPOST('renamefilesave', 'alpha')) require_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php'; $ecmfile->share = getRandomPassword(true); } - } - else - { + } else { $ecmfile->share = ''; } $result = $ecmfile->update($user); diff --git a/htdocs/core/actions_massactions.inc.php b/htdocs/core/actions_massactions.inc.php index ebae28e9582..23c76ae81fb 100644 --- a/htdocs/core/actions_massactions.inc.php +++ b/htdocs/core/actions_massactions.inc.php @@ -180,8 +180,7 @@ if (!$error && $massaction == 'confirm_presend') 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; @@ -210,8 +209,7 @@ if (!$error && $massaction == 'confirm_presend') 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 ? @@ -256,20 +254,17 @@ if (!$error && $massaction == 'confirm_presend') 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(); @@ -283,9 +278,7 @@ if (!$error && $massaction == 'confirm_presend') if (count($emails_to_sends) > 0) { $sendto = implode(',', $emails_to_sends); } - } - else - { + } else { $objectobj->fetch_thirdparty(); $sendto = $objectobj->thirdparty->email; } @@ -336,9 +329,7 @@ if (!$error && $massaction == 'confirm_presend') 'names'=>array($filename), 'mimes'=>array($mime) ); - } - else - { + } else { $nbignored++; $langs->load("errors"); $resaction .= '
'.$langs->trans('ErrorCantReadFile', $file).'

'; @@ -364,19 +355,15 @@ if (!$error && $massaction == 'confirm_presend') $fromtype = GETPOST('fromtype'); if ($fromtype === 'user') { $from = $user->getFullName($langs).' <'.$user->email.'>'; - } - elseif ($fromtype === 'company') { + } elseif ($fromtype === 'company') { $from = $conf->global->MAIN_INFO_SOCIETE_NOM.' <'.$conf->global->MAIN_INFO_SOCIETE_MAIL.'>'; - } - elseif (preg_match('/user_aliases_(\d+)/', $fromtype, $reg)) { + } elseif (preg_match('/user_aliases_(\d+)/', $fromtype, $reg)) { $tmp = explode(',', $user->email_aliases); $from = trim($tmp[($reg[1] - 1)]); - } - elseif (preg_match('/global_aliases_(\d+)/', $fromtype, $reg)) { + } elseif (preg_match('/global_aliases_(\d+)/', $fromtype, $reg)) { $tmp = explode(',', $conf->global->MAIN_INFO_SOCIETE_MAIL_ALIASES); $from = trim($tmp[($reg[1] - 1)]); - } - elseif (preg_match('/senderprofile_(\d+)_(\d+)/', $fromtype, $reg)) { + } elseif (preg_match('/senderprofile_(\d+)_(\d+)/', $fromtype, $reg)) { $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); @@ -384,8 +371,7 @@ if (!$error && $massaction == 'confirm_presend') { $from = $obj->label.' <'.$obj->email.'>'; } - } - else { + } else { $from = $_POST['fromname'].' <'.$_POST['frommail'].'>'; } @@ -412,9 +398,7 @@ if (!$error && $massaction == 'confirm_presend') { $looparray[$key]->thirdparty = $thirdparty; // Force thirdparty on object } - } - else - { + } else { $objectforloop = new $objectclass($db); $objectforloop->thirdparty = $thirdparty; // Force thirdparty on object (even if object was not loaded) $looparray[0] = $objectforloop; @@ -464,8 +448,7 @@ if (!$error && $massaction == 'confirm_presend') ); } } - } - elseif (!empty($attachedfilesThirdpartyObj[$thirdparty->id][$objectid])) { + } elseif (!empty($attachedfilesThirdpartyObj[$thirdparty->id][$objectid])) { // Create form object // if "one email per recipient" isn't check we must separate $attachedfiles by object $attachedfiles = $attachedfilesThirdpartyObj[$thirdparty->id][$objectid]; @@ -481,9 +464,7 @@ if (!$error && $massaction == 'confirm_presend') $trackid = 'thi'.$thirdparty->id; if ($objecttmp->element == 'expensereport') $trackid = 'use'.$thirdparty->id; if ($objecttmp->element == 'holiday') $trackid = 'use'.$thirdparty->id; - } - else - { + } else { $trackid = strtolower(get_class($objecttmp)); if (get_class($objecttmp) == 'Contrat') $trackid = 'con'; if (get_class($objecttmp) == 'Propal') $trackid = 'pro'; @@ -507,9 +488,7 @@ if (!$error && $massaction == 'confirm_presend') if ($mailfile->error) { $resaction .= '
'.$mailfile->error.'
'; - } - else - { + } else { $result = $mailfile->sendfile(); if ($result) { @@ -574,17 +553,13 @@ if (!$error && $massaction == 'confirm_presend') $nbsent++; // Nb of object sent } - } - else - { + } else { $langs->load("other"); if ($mailfile->error) { $resaction .= $langs->trans('ErrorFailedToSendMail', $from, $sendto); $resaction .= '
'.$mailfile->error.'
'; - } - else - { + } else { $resaction .= '
No mail sent. Feature is disabled by option MAIN_DISABLE_ALL_MAILS
'; } } @@ -605,9 +580,7 @@ if (!$error && $massaction == 'confirm_presend') //setEventMessages($langs->trans("EMailSentToNRecipients", $nbsent.'/'.count($toselect)), null, 'mesgs'); setEventMessages($langs->trans("EMailSentForNElements", $nbsent.'/'.count($toselect)), null, 'mesgs'); setEventMessages($resaction, null, 'mesgs'); - } - else - { + } else { //setEventMessages($langs->trans("EMailSentToNRecipients", 0), null, 'warnings'); // May be object has no generated PDF file setEventMessages($resaction, null, 'warnings'); } @@ -722,16 +695,12 @@ if ($massaction == 'confirm_createbills') // Create bills from orders { $result = $objecttmp->insert_discount($discountid); //$result=$discount->link_to_invoice($lineid,$id); - } - else - { + } else { setEventMessages($discount->error, $discount->errors, 'errors'); $error++; break; } - } - else - { + } else { // Positive line $product_type = ($lines[$i]->product_type ? $lines[$i]->product_type : 0); // Date start @@ -789,9 +758,7 @@ if ($massaction == 'confirm_createbills') // Create bills from orders if ($result > 0) { $lineid = $result; - } - else - { + } else { $lineid = 0; $error++; break; @@ -881,9 +848,7 @@ if ($massaction == 'confirm_createbills') // Create bills from orders header("Location: ".$_SERVER['PHP_SELF'].'?'.$param); exit; - } - else - { + } else { $db->rollback(); $action = 'create'; $_GET["origin"] = $_POST["origin"]; @@ -913,29 +878,22 @@ if (!$error && $massaction == 'cancelorders') setEventMessages($langs->trans("ErrorObjectMustHaveStatusValidToBeCanceled", $cmd->ref), null, 'errors'); $error++; break; - } - else - $result = $cmd->cancel(); + } else $result = $cmd->cancel(); if ($result < 0) { setEventMessages($cmd->error, $cmd->errors, 'errors'); $error++; break; - } - else - $nbok++; + } else $nbok++; } 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 - { + } else { $db->rollback(); } } @@ -1036,13 +994,10 @@ if (!$error && $massaction == "builddoc" && $permissiontoread && !GETPOST('butto $langs->load("exports"); setEventMessages($langs->trans('FileSuccessfullyBuilt', $filename.'_'.dol_print_date($now, 'dayhourlog')), null, 'mesgs'); - } - else - { + } else { setEventMessages($langs->trans('NoPDFAvailableForDocGenAmongChecked'), null, 'errors'); } - } - else { + } else { // Create empty PDF $formatarray = pdf_getFormat(); $page_largeur = $formatarray['width']; @@ -1099,9 +1054,7 @@ if (!$error && $massaction == "builddoc" && $permissiontoread && !GETPOST('butto $langs->load("exports"); setEventMessages($langs->trans('FileSuccessfullyBuilt', $filename.'_'.dol_print_date($now, 'dayhourlog')), null, 'mesgs'); - } - else - { + } else { setEventMessages($langs->trans('NoPDFAvailableForDocGenAmongChecked'), null, 'errors'); } } @@ -1157,17 +1110,13 @@ if (!$error && $massaction == 'validate' && $permissiontoadd) setEventMessages($langs->trans("ErrorObjectMustHaveStatusDraftToBeValidated", $objecttmp->ref), null, 'errors'); $error++; break; - } - elseif ($result < 0) + } elseif ($result < 0) { setEventMessages($objecttmp->error, $objecttmp->errors, 'errors'); $error++; break; - } - else $nbok++; - } - else - { + } else $nbok++; + } else { setEventMessages($objecttmp->error, $objecttmp->errors, 'errors'); $error++; break; @@ -1179,9 +1128,7 @@ if (!$error && $massaction == 'validate' && $permissiontoadd) if ($nbok > 1) setEventMessages($langs->trans("RecordsModified", $nbok), null, 'mesgs'); else setEventMessages($langs->trans("RecordsModified", $nbok), null, 'mesgs'); $db->commit(); - } - else - { + } else { $db->rollback(); } //var_dump($listofobjectthirdparties);exit; @@ -1202,10 +1149,8 @@ if (!$error && $massaction == 'closed' && $objectclass == "Propal" && $permissio setEventMessages($objecttmp->error, $objecttmp->errors, 'errors'); $error++; break; - } else - $nbok++; - } - else { + } else $nbok++; + } else { setEventMessages($objecttmp->error, $objecttmp->errors, 'errors'); $error++; break; @@ -1215,11 +1160,9 @@ if (!$error && $massaction == 'closed' && $objectclass == "Propal" && $permissio 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 { + } else { $db->rollback(); } } @@ -1266,11 +1209,8 @@ if (!$error && ($massaction == 'delete' || ($action == 'delete' && $confirm == ' setEventMessages($objecttmp->error, $objecttmp->errors, 'errors'); $error++; break; - } - else $nbok++; - } - else - { + } else $nbok++; + } else { setEventMessages($objecttmp->error, $objecttmp->errors, 'errors'); $error++; break; @@ -1282,9 +1222,7 @@ if (!$error && ($massaction == 'delete' || ($action == 'delete' && $confirm == ' if ($nbok > 1) setEventMessages($langs->trans("RecordsDeleted", $nbok), null, 'mesgs'); else setEventMessages($langs->trans("RecordDeleted", $nbok), null, 'mesgs'); $db->commit(); - } - else - { + } else { $db->rollback(); } //var_dump($listofobjectthirdparties);exit; @@ -1328,11 +1266,8 @@ if (!$error && $massaction == 'generate_doc' && $permissiontoread) setEventMessages($objecttmp->error, $objecttmp->errors, 'errors'); $error++; break; - } - else $nbok++; - } - else - { + } else $nbok++; + } else { setEventMessages($objecttmp->error, $objecttmp->errors, 'errors'); $error++; break; @@ -1344,9 +1279,7 @@ if (!$error && $massaction == 'generate_doc' && $permissiontoread) if ($nbok > 1) setEventMessages($langs->trans("RecordsGenerated", $nbok), null, 'mesgs'); else setEventMessages($langs->trans("RecordGenerated", $nbok), null, 'mesgs'); $db->commit(); - } - else - { + } else { $db->rollback(); } } diff --git a/htdocs/core/actions_printing.inc.php b/htdocs/core/actions_printing.inc.php index e2da8a4170c..e88fc937e38 100644 --- a/htdocs/core/actions_printing.inc.php +++ b/htdocs/core/actions_printing.inc.php @@ -75,8 +75,7 @@ if ($action == 'print_file' && $user->rights->printing->read) { 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'); diff --git a/htdocs/core/actions_sendmails.inc.php b/htdocs/core/actions_sendmails.inc.php index e23d2ce01a9..bc38d9839af 100644 --- a/htdocs/core/actions_sendmails.inc.php +++ b/htdocs/core/actions_sendmails.inc.php @@ -120,38 +120,32 @@ if (($action == 'send' || $action == 'relance') && !$_POST['addfile'] && !$_POST if ($object->element == 'user' && $result == 0) $result = 1; // Even if not found, we consider ok $thirdparty = $object->thirdparty; $sendtosocid = $thirdparty->id; - } - elseif ($object->element == 'member' || $object->element == 'user') + } elseif ($object->element == 'member' || $object->element == 'user') { $thirdparty = $object; if ($object->socid > 0) $sendtosocid = $object->socid; - } - elseif ($object->element == 'expensereport') + } elseif ($object->element == 'expensereport') { $tmpuser = new User($db); $tmpuser->fetch($object->fk_user_author); $thirdparty = $tmpuser; if ($object->socid > 0) $sendtosocid = $object->socid; - } - elseif ($object->element == 'societe') + } elseif ($object->element == 'societe') { $thirdparty = $object; if ($thirdparty->id > 0) $sendtosocid = $thirdparty->id; - } - elseif ($object->element == 'contact') + } elseif ($object->element == 'contact') { $contact = $object; if ($contact->id > 0) $sendtosocid = $contact->fetch_thirdparty()->id; - } - else dol_print_error('', "Use actions_sendmails.in.php for an element/object '".$object->element."' that is not supported"); + } else dol_print_error('', "Use actions_sendmails.in.php for an element/object '".$object->element."' that is not supported"); if (is_object($hookmanager)) { $parameters = array(); $reshook = $hookmanager->executeHooks('initSendToSocid', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks } - } - else $thirdparty = $mysoc; + } else $thirdparty = $mysoc; if ($result > 0) { @@ -189,8 +183,7 @@ if (($action == 'send' || $action == 'relance') && !$_POST['addfile'] && !$_POST elseif ($val == 'contact') // Key selected means current contact { $tmparray[] = dol_string_nospecial($contact->getFullName($langs), ' ', array(",")).' <'.$contact->email.'>'; - } - elseif ($val) // $val is the Id of a contact + } elseif ($val) // $val is the Id of a contact { $tmparray[] = $thirdparty->contact_get_property((int) $val, 'email'); $sendtoid[] = $val; @@ -239,8 +232,7 @@ if (($action == 'send' || $action == 'relance') && !$_POST['addfile'] && !$_POST elseif ($val == 'contact') // Key selected means current contact { $tmparray[] = dol_string_nospecial($contact->name, ' ', array(",")).' <'.$contact->email.'>'; - } - elseif ($val) // $val is the Id of a contact + } elseif ($val) // $val is the Id of a contact { $tmparray[] = $thirdparty->contact_get_property((int) $val, 'email'); //$sendtoid[] = $val; TODO Add also id of contact in CC ? @@ -277,22 +269,17 @@ if (($action == 'send' || $action == 'relance') && !$_POST['addfile'] && !$_POST $fromtype = GETPOST('fromtype', 'alpha'); if ($fromtype === 'robot') { $from = dol_string_nospecial($conf->global->MAIN_MAIL_EMAIL_FROM, ' ', array(",")).' <'.$conf->global->MAIN_MAIL_EMAIL_FROM.'>'; - } - elseif ($fromtype === 'user') { + } elseif ($fromtype === 'user') { $from = dol_string_nospecial($user->getFullName($langs), ' ', array(",")).' <'.$user->email.'>'; - } - elseif ($fromtype === 'company') { + } elseif ($fromtype === 'company') { $from = dol_string_nospecial($conf->global->MAIN_INFO_SOCIETE_NOM, ' ', array(",")).' <'.$conf->global->MAIN_INFO_SOCIETE_MAIL.'>'; - } - elseif (preg_match('/user_aliases_(\d+)/', $fromtype, $reg)) { + } elseif (preg_match('/user_aliases_(\d+)/', $fromtype, $reg)) { $tmp = explode(',', $user->email_aliases); $from = trim($tmp[($reg[1] - 1)]); - } - elseif (preg_match('/global_aliases_(\d+)/', $fromtype, $reg)) { + } elseif (preg_match('/global_aliases_(\d+)/', $fromtype, $reg)) { $tmp = explode(',', $conf->global->MAIN_INFO_SOCIETE_MAIL_ALIASES); $from = trim($tmp[($reg[1] - 1)]); - } - elseif (preg_match('/senderprofile_(\d+)_(\d+)/', $fromtype, $reg)) { + } elseif (preg_match('/senderprofile_(\d+)_(\d+)/', $fromtype, $reg)) { $sql = 'SELECT rowid, label, email FROM '.MAIN_DB_PREFIX.'c_email_senderprofile'; $sql .= ' WHERE rowid = '.(int) $reg[1]; $resql = $db->query($sql); @@ -301,8 +288,7 @@ if (($action == 'send' || $action == 'relance') && !$_POST['addfile'] && !$_POST { $from = dol_string_nospecial($obj->label, ' ', array(",")).' <'.$obj->email.'>'; } - } - else { + } else { $from = dol_string_nospecial($_POST['fromname'], ' ', array(",")).' <'.$_POST['frommail'].'>'; } @@ -419,9 +405,7 @@ if (($action == 'send' || $action == 'relance') && !$_POST['addfile'] && !$_POST { setEventMessages($mailfile->error, $mailfile->errors, 'errors'); $action = 'presend'; - } - else - { + } else { $result = $mailfile->sendfile(); if ($result) { @@ -479,18 +463,14 @@ if (($action == 'send' || $action == 'relance') && !$_POST['addfile'] && !$_POST if (isset($paramname2) || isset($paramval2)) $moreparam .= '&'.($paramname2 ? $paramname2 : 'mid').'='.$paramval2; header('Location: '.$_SERVER["PHP_SELF"].'?'.($paramname ? $paramname : 'id').'='.(is_object($object) ? $object->id : '').$moreparam); exit; - } - else - { + } else { $langs->load("other"); $mesg = '
'; if ($mailfile->error) { $mesg .= $langs->transnoentities('ErrorFailedToSendMail', dol_escape_htmltag($from), dol_escape_htmltag($sendto)); $mesg .= '
'.$mailfile->error; - } - else - { + } else { $mesg .= 'No mail sent. Feature is disabled by option MAIN_DISABLE_ALL_MAILS'; } $mesg .= '
'; @@ -499,17 +479,13 @@ if (($action == 'send' || $action == 'relance') && !$_POST['addfile'] && !$_POST $action = 'presend'; } } - } - else - { + } else { $langs->load("errors"); setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv("MailTo")), null, 'warnings'); dol_syslog('Try to send email with no recipient defined', LOG_WARNING); $action = 'presend'; } - } - else - { + } else { $langs->load("other"); setEventMessages($langs->trans('ErrorFailedToReadObject', $object->element), null, 'errors'); dol_syslog('Failed to read data of object id='.$object->id.' element='.$object->element); diff --git a/htdocs/core/actions_setmoduleoptions.inc.php b/htdocs/core/actions_setmoduleoptions.inc.php index 313375d1aa1..05be4a31d18 100644 --- a/htdocs/core/actions_setmoduleoptions.inc.php +++ b/htdocs/core/actions_setmoduleoptions.inc.php @@ -50,9 +50,7 @@ if ($action == 'update' && is_array($arrayofparameters)) { $db->commit(); if (empty($nomessageinupdate)) setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); - } - else - { + } else { $db->rollback(); if (empty($nomessageinupdate)) setEventMessages($langs->trans("SetupNotSaved"), null, 'errors'); } @@ -96,8 +94,7 @@ if ($action == 'setModuleOptions') unset($listofdir[$key]); continue; } if (!is_dir($tmpdir)) $texttitle .= img_warning($langs->trans("ErrorDirNotFound", $tmpdir), 0); - else - { + else { $upload_dir = $tmpdir; } } @@ -112,9 +109,7 @@ if ($action == 'setModuleOptions') { $db->commit(); if (empty($nomessageinsetmoduleoptions)) setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); - } - else - { + } else { $db->rollback(); if (empty($nomessageinsetmoduleoptions)) setEventMessages($langs->trans("SetupNotSaved"), null, 'errors'); } diff --git a/htdocs/core/ajax/ajaxdirpreview.php b/htdocs/core/ajax/ajaxdirpreview.php index bb6a8de30d4..3e96cefd5a3 100644 --- a/htdocs/core/ajax/ajaxdirpreview.php +++ b/htdocs/core/ajax/ajaxdirpreview.php @@ -68,8 +68,7 @@ if (!isset($mode) || $mode != 'noajax') // For ajax call //dol_print_error($db,$ecmdir->error); //exit; } -} -else // For no ajax call +} else // For no ajax call { $rootdirfordoc = $conf->ecm->dir_output; @@ -85,8 +84,7 @@ else // For no ajax call } $relativepath = $ecmdir->getRelativePath(); // Example 'mydir/' - } - elseif (GETPOST('section_dir')) + } elseif (GETPOST('section_dir')) { $relativepath = GETPOST('section_dir'); } @@ -234,8 +232,7 @@ if ($type == 'directory') $formfile->list_of_autoecmfiles($upload_dir, $filearray, $module, $param, 1, '', $perm, 1, $textifempty, $maxlengthname, $url, 1); } // Manual list - else - { + else { if ($module == 'medias') { /* @@ -259,9 +256,7 @@ if ($type == 'directory') 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 - { + } else { $relativepath = $ecmdir->getRelativePath(); $upload_dir = $conf->ecm->dir_output.'/'.$relativepath; } @@ -270,9 +265,7 @@ if ($type == 'directory') if (($section === '0' || empty($section)) && ($module != 'medias')) { $filearray = array(); - } - else - { + } else { $filearray = dol_dir_list($upload_dir, "files", 0, '', array('^\.', '(\.meta|_preview.*\.png)$', '^temp$', '^CVS$'), $sortfield, $sorting, 1); } @@ -282,13 +275,11 @@ if ($type == 'directory') if (isset($search_doc_ref) && $search_doc_ref != '') $param .= '&search_doc_ref='.$search_doc_ref; $textifempty = $langs->trans('NoFileFound'); - } - elseif ($section === '0') + } 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")); + } else $textifempty = ($showonrightsize == 'featurenotyetavailable' ? $langs->trans("FeatureNotYetAvailable") : $langs->trans("ECMSelectASection")); if ($module == 'medias') { @@ -296,8 +287,7 @@ if ($type == 'directory') $modulepart = 'medias'; $perm = ($user->rights->website->write || $user->rights->emailing->creer); $title = 'none'; - } - elseif ($module == 'ecm') // DMS/ECM -> manual structure + } elseif ($module == 'ecm') // DMS/ECM -> manual structure { if ($user->rights->ecm->read) { @@ -320,9 +310,7 @@ if ($type == 'directory') $perm = $user->rights->ecm->upload; $modulepart = 'ecm'; $title = ''; // Use default - } - else - { + } else { $useinecm = 5; $modulepart = 'ecm'; $perm = $user->rights->ecm->upload; @@ -355,7 +343,7 @@ if ($useajax || $action == 'delete') $section_id = $section; require_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php'; - $useglobalvars = 1; + $form = new Form($db); $formquestion['urlfile'] = array('type'=>'hidden', 'value'=>$urlfile, 'name'=>'urlfile'); // We must always put field, even if empty because it is filled by javascript later $formquestion['section'] = array('type'=>'hidden', 'value'=>$section, 'name'=>'section'); // We must always put field, even if empty because it is filled by javascript later diff --git a/htdocs/core/ajax/ajaxdirtree.php b/htdocs/core/ajax/ajaxdirtree.php index 04687b77829..620643da8f2 100644 --- a/htdocs/core/ajax/ajaxdirtree.php +++ b/htdocs/core/ajax/ajaxdirtree.php @@ -49,8 +49,7 @@ if (!isset($mode) || $mode != 'noajax') // For ajax call $preopened = GETPOST('preopened'); if ($selecteddir != '/') $selecteddir = preg_replace('/\/$/', '', $selecteddir); // We removed last '/' except if it is '/' -} -else // For no ajax call +} else // For no ajax call { //if (GETPOST('preopened')) { $_GET['dir'] = $_POST['dir'] = GETPOST('preopened'); } @@ -73,8 +72,7 @@ if ($modulepart == 'ecm') { $fullpathselecteddir = $conf->ecm->dir_output.'/'.($selecteddir != '/' ? $selecteddir : ''); $fullpathpreopened = $conf->ecm->dir_output.'/'.($preopened != '/' ? $preopened : ''); -} -elseif ($modulepart == 'medias') +} elseif ($modulepart == 'medias') { $fullpathselecteddir = $dolibarr_main_data_root.'/medias/'.($selecteddir != '/' ? $selecteddir : ''); $fullpathpreopened = $dolibarr_main_data_root.'/medias/'.($preopened != '/' ? $preopened : ''); @@ -95,8 +93,7 @@ if (preg_match('/\.\./', $fullpathselecteddir) || preg_match('/[<>|]/', $fullpat if ($modulepart == 'ecm') { if (!$user->rights->ecm->read) accessforbidden(); -} -elseif ($modulepart == 'medias') +} elseif ($modulepart == 'medias') { // Always allowed } @@ -428,11 +425,11 @@ function treeOutputForAbsoluteDir($sqltree, $selecteddir, $fullpathselecteddir, print (isset($val['cachenbofdoc']) && $val['cachenbofdoc'] >= 0) ? $val['cachenbofdoc'] : ' '; print ''; print ''; - if ($nbofsubdir > 0 && $nboffilesinsubdir > 0) print '+'.$nboffilesinsubdir.' '; + if ($nbofsubdir > 0 && $nboffilesinsubdir > 0) print '+'.$nboffilesinsubdir.' '; print ''; // Edit link - print ''.img_edit($langs->trans("Edit").' - '.$langs->trans("View"), 0, 'class="valignmiddle opacitymedium"').''; @@ -471,8 +468,7 @@ function treeOutputForAbsoluteDir($sqltree, $selecteddir, $fullpathselecteddir, if ($modulepart == 'ecm') { $newfullpathselecteddir = $conf->ecm->dir_output.'/'.($val['fullrelativename'] != '/' ? $val['fullrelativename'] : ''); - } - elseif ($modulepart == 'medias') + } elseif ($modulepart == 'medias') { $newfullpathselecteddir = $dolibarr_main_data_root.'/medias/'.($val['fullrelativename'] != '/' ? $val['fullrelativename'] : ''); } @@ -486,7 +482,6 @@ function treeOutputForAbsoluteDir($sqltree, $selecteddir, $fullpathselecteddir, echo "\n"; } - } - else print "PermissionDenied"; + } else print "PermissionDenied"; } } diff --git a/htdocs/core/ajax/check_notifications.php b/htdocs/core/ajax/check_notifications.php index d8f4985f6d8..98d7d00a8dc 100644 --- a/htdocs/core/ajax/check_notifications.php +++ b/htdocs/core/ajax/check_notifications.php @@ -60,9 +60,7 @@ if ($time >= $_SESSION['auto_check_events_not_before']) dol_syslog("We ask to check browser notification on a too large period. We fix this with current date."); $starttime = $time; } - } - else - { + } else { $starttime = $time; } @@ -109,9 +107,7 @@ if ($time >= $_SESSION['auto_check_events_not_before']) $eventfound[] = $event; } - } - else - { + } else { dol_syslog("Error sql = ".$db->lasterror(), LOG_ERR); } } diff --git a/htdocs/core/ajax/constantonoff.php b/htdocs/core/ajax/constantonoff.php index c7e5bbd8991..1ed8ca34076 100644 --- a/htdocs/core/ajax/constantonoff.php +++ b/htdocs/core/ajax/constantonoff.php @@ -57,8 +57,7 @@ if (!empty($action) && !empty($name)) if ($action == 'set') { dolibarr_set_const($db, $name, $value, 'chaine', 0, '', $entity); - } - elseif ($action == 'del') + } elseif ($action == 'del') { dolibarr_del_const($db, $name, $entity); } diff --git a/htdocs/core/ajax/extraparams.php b/htdocs/core/ajax/extraparams.php index a3db4505f70..16f39af9bde 100644 --- a/htdocs/core/ajax/extraparams.php +++ b/htdocs/core/ajax/extraparams.php @@ -51,20 +51,38 @@ if (!empty($id) && !empty($element) && !empty($htmlelement) && !empty($type)) $classpath = $subelement = $element; // For compatibility - if ($element == 'order' || $element == 'commande') { $classpath = $subelement = 'commande'; } - elseif ($element == 'propal') { $classpath = 'comm/propal'; $subelement = 'propal'; } - elseif ($element == 'facture') { $classpath = 'compta/facture'; $subelement = 'facture'; } - elseif ($element == 'contract') { $classpath = $subelement = 'contrat'; } - elseif ($element == 'shipping') { $classpath = $subelement = 'expedition'; } - elseif ($element == 'deplacement') { $classpath = 'compta/deplacement'; $subelement = 'deplacement'; } - elseif ($element == 'order_supplier') { $classpath = 'fourn'; $subelement = 'fournisseur.commande'; } - elseif ($element == 'invoice_supplier') { $classpath = 'fourn'; $subelement = 'fournisseur.facture'; } + if ($element == 'order' || $element == 'commande') { + $classpath = $subelement = 'commande'; + } elseif ($element == 'propal') { + $classpath = 'comm/propal'; + $subelement = 'propal'; + } elseif ($element == 'facture') { + $classpath = 'compta/facture'; + $subelement = 'facture'; + } elseif ($element == 'contract') { + $classpath = $subelement = 'contrat'; + } elseif ($element == 'shipping') { + $classpath = $subelement = 'expedition'; + } elseif ($element == 'deplacement') { + $classpath = 'compta/deplacement'; + $subelement = 'deplacement'; + } elseif ($element == 'order_supplier') { + $classpath = 'fourn'; + $subelement = 'fournisseur.commande'; + } elseif ($element == 'invoice_supplier') { + $classpath = 'fourn'; + $subelement = 'fournisseur.facture'; + } dol_include_once('/'.$classpath.'/class/'.$subelement.'.class.php'); - if ($element == 'order_supplier') { $classname = 'CommandeFournisseur'; } - elseif ($element == 'invoice_supplier') { $classname = 'FactureFournisseur'; } - else $classname = ucfirst($subelement); + if ($element == 'order_supplier') { + $classname = 'CommandeFournisseur'; + } elseif ($element == 'invoice_supplier') { + $classname = 'FactureFournisseur'; + } else { + $classname = ucfirst($subelement); + } $object = new $classname($db); $object->fetch($id); diff --git a/htdocs/core/ajax/loadinplace.php b/htdocs/core/ajax/loadinplace.php index 14258e1ebb1..b1a72868312 100644 --- a/htdocs/core/ajax/loadinplace.php +++ b/htdocs/core/ajax/loadinplace.php @@ -62,8 +62,7 @@ if (!empty($field) && !empty($element) && !empty($table_element) && !empty($fk_e elseif ($element == 'order_supplier') { $element = 'fournisseur'; $subelement = 'commande'; - } - elseif ($element == 'invoice_supplier') { + } elseif ($element == 'invoice_supplier') { $element = 'fournisseur'; $subelement = 'facture'; } @@ -83,8 +82,7 @@ if (!empty($field) && !empty($element) && !empty($table_element) && !empty($fk_e { $ret = $form->$methodname(); if ($ret > 0) echo json_encode($form->$cachename); - } - elseif (!empty($ext_element)) + } elseif (!empty($ext_element)) { $module = $subelement = $ext_element; if (preg_match('/^([^_]+)_([^_]+)/i', $ext_element, $regs)) @@ -99,16 +97,12 @@ if (!empty($field) && !empty($element) && !empty($table_element) && !empty($fk_e $ret = $object->$methodname($fk_element); if ($ret > 0) echo json_encode($object->$cachename); } - } - else - { + } else { $object = new GenericObject($db); $value = $object->$loadmethod($table_element, $fk_element, $field); echo $value; } - } - else - { + } else { echo $langs->transnoentities('NotEnoughPermissions'); } } diff --git a/htdocs/core/ajax/objectonoff.php b/htdocs/core/ajax/objectonoff.php index dd39bce6d4e..6c9f97bfbb0 100644 --- a/htdocs/core/ajax/objectonoff.php +++ b/htdocs/core/ajax/objectonoff.php @@ -43,9 +43,9 @@ if (!empty($user->socid)) { $socid = $user->socid; } -if (empty($conf->global->MAIN_DIRECT_STATUS_UPDATE)) { +/*if (empty($conf->global->MAIN_DIRECT_STATUS_UPDATE)) { accessforbidden('Calling this file is allowed only when MAIN_DIRECT_STATUS_UPDATE is set'); -} +}*/ /* @@ -58,11 +58,9 @@ print ''; $return .= ''; - } - else { + } else { $return .= ''; $return .= ''; } - } - else - { + } else { $return .= ''; $return .= ''; } - } - else - { + } else { if (empty($maxHeight) || $photo_vignette && $imgarray['height'] > $maxHeight) { $return .= ''; $return .= ''; - } - else { + } else { $return .= ''; $return .= ''; } @@ -7557,8 +7219,7 @@ abstract class CommonObject { $return .= ''; if (($nbphoto % $nbbyrow) == 0) $return .= ''; - } - elseif ($nbbyrow < 0) $return .= ''; + } elseif ($nbbyrow < 0) $return .= ''; } if (empty($size)) { // Format origine @@ -7647,8 +7308,7 @@ abstract class CommonObject { if (isset($info['type']) && ($info['type'] == 'duration')) return true; else return false; - } - else return false; + } else return false; } /** @@ -7663,8 +7323,7 @@ abstract class CommonObject { if (isset($info['type']) && ($info['type'] == 'int' || preg_match('/^integer/i', $info['type']))) return true; else return false; - } - else return false; + } else return false; } /** @@ -7768,13 +7427,10 @@ abstract class CommonObject if (empty($this->{$field})) { $queryarray[$field] = null; - } - else - { + } else { $queryarray[$field] = $this->db->idate($this->{$field}); } - } - elseif ($this->isArray($info)) + } elseif ($this->isArray($info)) { if (!empty($this->{$field})) { if (!is_array($this->{$field})) { @@ -7784,28 +7440,22 @@ abstract class CommonObject } else { $queryarray[$field] = null; } - } - elseif ($this->isDuration($info)) + } elseif ($this->isDuration($info)) { // $this->{$field} may be null, '', 0, '0', 123, '123' if ($this->{$field} != '' || !empty($info['notnull'])) $queryarray[$field] = (int) $this->{$field}; // If '0', it may be set to null later if $info['notnull'] == -1 else $queryarray[$field] = null; - } - elseif ($this->isInt($info) || $this->isFloat($info)) + } elseif ($this->isInt($info) || $this->isFloat($info)) { if ($field == 'entity' && is_null($this->{$field})) $queryarray[$field] = $conf->entity; - else - { + else { // $this->{$field} may be null, '', 0, '0', 123, '123' if ($this->{$field} != '' || !empty($info['notnull'])) { if ($this->isInt($info)) $queryarray[$field] = (int) $this->{$field}; // If '0', it may be set to null later if $info['notnull'] == -1 if ($this->isFloat($info)) $queryarray[$field] = (double) $this->{$field}; // If '0', it may be set to null later if $info['notnull'] == -1 - } - else $queryarray[$field] = null; + } else $queryarray[$field] = null; } - } - else - { + } else { $queryarray[$field] = $this->{$field}; } @@ -7830,8 +7480,7 @@ abstract class CommonObject { if (empty($obj->{$field}) || $obj->{$field} === '0000-00-00 00:00:00' || $obj->{$field} === '1000-01-01 00:00:00') $this->{$field} = 0; else $this->{$field} = strtotime($obj->{$field}); - } - elseif ($this->isArray($info)) + } elseif ($this->isArray($info)) { if (!empty($obj->{$field})) { $this->{$field} = @unserialize($obj->{$field}); @@ -7840,19 +7489,15 @@ abstract class CommonObject } else { $this->{$field} = array(); } - } - elseif ($this->isInt($info)) + } elseif ($this->isInt($info)) { if ($field == 'rowid') $this->id = (int) $obj->{$field}; - else - { + else { if ($this->isForcedToNullIfZero($info)) { if (empty($obj->{$field})) $this->{$field} = null; else $this->{$field} = (double) $obj->{$field}; - } - else - { + } else { if (!is_null($obj->{$field}) || (isset($info['notnull']) && $info['notnull'] == 1)) { $this->{$field} = (int) $obj->{$field}; } else { @@ -7860,25 +7505,20 @@ abstract class CommonObject } } } - } - elseif ($this->isFloat($info)) + } elseif ($this->isFloat($info)) { if ($this->isForcedToNullIfZero($info)) { if (empty($obj->{$field})) $this->{$field} = null; else $this->{$field} = (double) $obj->{$field}; - } - else - { + } else { if (!is_null($obj->{$field}) || (isset($info['notnull']) && $info['notnull'] == 1)) { $this->{$field} = (double) $obj->{$field}; } else { $this->{$field} = null; } } - } - else - { + } else { $this->{$field} = $obj->{$field}; } } @@ -8070,7 +7710,10 @@ abstract class CommonObject { if (empty($id) && empty($ref) && empty($morewhere)) return -1; - $sql = 'SELECT '.$this->getFieldList(); + $fieldlist = $this->getFieldList(); + if (empty($fieldlist)) return 0; + + $sql = 'SELECT '.$fieldlist; $sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element; if (!empty($id)) $sql .= ' WHERE rowid = '.$id; @@ -8088,14 +7731,10 @@ abstract class CommonObject { $this->setVarsFromFetchObj($obj); return $this->id; - } - else - { + } else { return 0; } - } - else - { + } else { $this->error = $this->db->lasterror(); $this->errors[] = $this->error; return -1; @@ -8143,9 +7782,7 @@ abstract class CommonObject } return 1; - } - else - { + } else { $this->error = $this->db->lasterror(); $this->errors[] = $this->error; return -1; @@ -8272,8 +7909,7 @@ abstract class CommonObject return -1; } } - } - elseif (!empty($this->fk_element) && !empty($this->childtables)) // If object has childs linked with a foreign key field, we check all child tables. + } elseif (!empty($this->fk_element) && !empty($this->childtables)) // If object has childs linked with a foreign key field, we check all child tables. { $objectisused = $this->isObjectUsed($this->id); if (!empty($objectisused)) @@ -8439,9 +8075,7 @@ abstract class CommonObject $this->db->rollback(); return -1; } - } - else - { + } else { $this->error = $this->db->error(); $this->db->rollback(); return -1; @@ -8519,8 +8153,68 @@ abstract class CommonObject } } + /* Part for categories/tags */ + /** - * copy related categories to another object + * Sets object to given categories. + * + * Deletes object from existing categories not supplied. + * Adds it to non existing supplied categories. + * Existing categories are left untouch. + * + * @param int[]|int $categories Category ID or array of Categories IDs + * @param string $type_categ Category type ('customer', 'supplier', 'website_page', ...) + * @return int <0 if KO, >0 if OK + */ + public function setCategoriesCommon($categories, $type_categ) + { + require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; + + // Handle single category + if (!is_array($categories)) { + $categories = array($categories); + } + + // Get current categories + $c = new Categorie($this->db); + $existing = $c->containing($this->id, $type_categ, 'id'); + + // Diff + if (is_array($existing)) { + $to_del = array_diff($existing, $categories); + $to_add = array_diff($categories, $existing); + } else { + $to_del = array(); // Nothing to delete + $to_add = $categories; + } + + $error = 0; + + // Process + foreach ($to_del as $del) { + if ($c->fetch($del) > 0) { + $c->del_type($this, $type_categ); + } + } + foreach ($to_add as $add) { + if ($c->fetch($add) > 0) + { + $result = $c->add_type($this, $type_categ); + if ($result < 0) + { + $error++; + $this->error = $c->error; + $this->errors = $c->errors; + break; + } + } + } + + return $error ? -1 : 1; + } + + /** + * Copy related categories to another object * * @param int $fromId Id object source * @param int $toId Id object cible diff --git a/htdocs/core/class/commonobjectline.class.php b/htdocs/core/class/commonobjectline.class.php index 5a09dbfed29..f92004120ff 100644 --- a/htdocs/core/class/commonobjectline.class.php +++ b/htdocs/core/class/commonobjectline.class.php @@ -54,8 +54,8 @@ abstract class CommonObjectLine extends CommonObject * Returns the translation key from units dictionary. * A langs->trans() must be called on result to get translated value. * - * @param string $type Label type (long or short) - * @return string|int <0 if ko, label if ok + * @param string $type Label type (long or short). This can be a translation key. + * @return string|int <0 if ko, label if ok */ public function getLabelOfUnit($type = 'long') { @@ -82,9 +82,7 @@ abstract class CommonObjectLine extends CommonObject $label = $res[$label_type]; $this->db->free($resql); return $label; - } - else - { + } else { $this->error = $this->db->error().' sql='.$sql; dol_syslog(get_class($this)."::getLabelOfUnit Error ".$this->error, LOG_ERR); return -1; diff --git a/htdocs/core/class/commonstickergenerator.class.php b/htdocs/core/class/commonstickergenerator.class.php index 50330f26b17..6c832c4788d 100644 --- a/htdocs/core/class/commonstickergenerator.class.php +++ b/htdocs/core/class/commonstickergenerator.class.php @@ -175,8 +175,7 @@ abstract class CommonStickerGenerator $hauteur = abs($y1 - $y2); if ($length > $hauteur) { $Pointilles = ($length / $nbPointilles) / 2; // taille des pointilles - } - else { + } else { $Pointilles = ($hauteur / $nbPointilles) / 2; } for ($i = $x1; $i <= $x2; $i += $Pointilles + $Pointilles) { diff --git a/htdocs/core/class/conf.class.php b/htdocs/core/class/conf.class.php index 0a52301e608..7973bc5ff16 100644 --- a/htdocs/core/class/conf.class.php +++ b/htdocs/core/class/conf.class.php @@ -1,7 +1,7 @@ * Copyright (C) 2003 Xavier Dutoit - * Copyright (C) 2004-2016 Laurent Destailleur + * Copyright (C) 2004-2020 Laurent Destailleur * Copyright (C) 2005-2017 Regis Houssin * Copyright (C) 2006 Jean Heimburger * @@ -37,7 +37,7 @@ class Conf public $file; /** - * @var DoliDB Database handler. + * @var Object Associative array with some properties ->type, ->db, ... */ public $db; @@ -249,8 +249,7 @@ class Conf { try { date_default_timezone_set($this->global->MAIN_SERVER_TZ); - } - catch (Exception $e) + } catch (Exception $e) { dol_syslog("Error: Bad value for parameter MAIN_SERVER_TZ=".$this->global->MAIN_SERVER_TZ, LOG_ERR); } @@ -332,9 +331,7 @@ class Conf // For backward compatibility $this->$module->$dirname = $rootfordata."/".$name; - } - else - { + } else { // For multicompany sharings $this->$module->$multidirname = array($this->entity => $rootfortemp."/".$name."/temp"); @@ -690,8 +687,6 @@ class Conf $this->global->AGENDA_DEFAULT_FILTER_TYPE = '0'; // 'AC_NON_AUTO' does not exists when AGENDA_DEFAULT_FILTER_TYPE is not on. } - if (!isset($this->global->MAIN_USE_OLD_TITLE_BUTTON)) $this->global->MAIN_USE_OLD_TITLE_BUTTON = 0; - if (!isset($this->global->MAIN_JS_GRAPH)) $this->global->MAIN_JS_GRAPH = 'chart'; // Use chart.js library if (empty($this->global->MAIN_MODULE_DOLISTORE_API_SRV)) $this->global->MAIN_MODULE_DOLISTORE_API_SRV = 'https://www.dolistore.com'; diff --git a/htdocs/core/class/coreobject.class.php b/htdocs/core/class/coreobject.class.php index 999b01341f0..caaeb706c32 100644 --- a/htdocs/core/class/coreobject.class.php +++ b/htdocs/core/class/coreobject.class.php @@ -74,9 +74,7 @@ class CoreObject extends CommonObject $this->is_clone = false; return true; - } - else - { + } else { return false; } } @@ -93,9 +91,7 @@ class CoreObject extends CommonObject if (isset($this->fields[$field]) && method_exists($this, 'is_'.$type)) { return $this->{'is_'.$type}($this->fields[$field]); - } - else - { + } else { return false; } } @@ -199,9 +195,7 @@ class CoreObject extends CommonObject $this->{$className}[] = $o; } - } - else - { + } else { $this->errors[] = $this->db->lasterror(); } } @@ -256,9 +250,7 @@ class CoreObject extends CommonObject $result = $this->call_trigger(strtoupper($this->element).'_UPDATE', $user); if ($result < 0) $error++; else $this->saveChild($user); - } - else - { + } else { $error++; $this->error = $this->db->lasterror(); $this->errors[] = $this->error; @@ -268,9 +260,7 @@ class CoreObject extends CommonObject { $this->db->commit(); return $this->id; - } - else - { + } else { $this->db->rollback(); return -1; } @@ -297,9 +287,7 @@ class CoreObject extends CommonObject $result = $this->call_trigger(strtoupper($this->element).'_CREATE', $user); if ($result < 0) $error++; else $this->saveChild($user); - } - else - { + } else { $error++; $this->error = $this->db->lasterror(); $this->errors[] = $this->error; @@ -309,9 +297,7 @@ class CoreObject extends CommonObject { $this->db->commit(); return $this->id; - } - else - { + } else { $this->db->rollback(); return -1; } @@ -356,9 +342,7 @@ class CoreObject extends CommonObject { $this->db->commit(); return 1; - } - else - { + } else { $this->error = $this->db->lasterror(); $this->errors[] = $this->error; $this->db->rollback(); @@ -377,8 +361,7 @@ class CoreObject extends CommonObject public function getDate($field, $format = '') { if (empty($this->{$field})) return ''; - else - { + else { return dol_print_date($this->{$field}, $format); } } @@ -395,9 +378,7 @@ class CoreObject extends CommonObject if (empty($date)) { $this->{$field} = 0; - } - else - { + } else { require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; $this->{$field} = dol_stringtotime($date); } @@ -419,16 +400,12 @@ class CoreObject extends CommonObject if ($this->checkFieldType($key, 'date')) { $this->setDate($key, $value); - } - elseif ($this->checkFieldType($key, 'float')) + } elseif ($this->checkFieldType($key, 'float')) { $this->{$key} = (double) price2num($value); - } - elseif ($this->checkFieldType($key, 'int')) { + } elseif ($this->checkFieldType($key, 'int')) { $this->{$key} = (int) price2num($value); - } - else - { + } else { $this->{$key} = dol_string_nohtmltag($value); } } diff --git a/htdocs/core/class/cstate.class.php b/htdocs/core/class/cstate.class.php index 406615aada6..34ef707b674 100644 --- a/htdocs/core/class/cstate.class.php +++ b/htdocs/core/class/cstate.class.php @@ -132,9 +132,7 @@ class Cstate // extends CommonObject } $this->db->rollback(); return -1 * $error; - } - else - { + } else { $this->db->commit(); return $this->id; } @@ -176,9 +174,7 @@ class Cstate // extends CommonObject $this->db->free($resql); return 1; - } - else - { + } else { $this->error = "Error ".$this->db->lasterror(); return -1; } @@ -264,9 +260,7 @@ class Cstate // extends CommonObject } $this->db->rollback(); return -1 * $error; - } - else - { + } else { $this->db->commit(); return 1; } diff --git a/htdocs/core/class/ctypent.class.php b/htdocs/core/class/ctypent.class.php index 2524445b294..07d3563088e 100644 --- a/htdocs/core/class/ctypent.class.php +++ b/htdocs/core/class/ctypent.class.php @@ -136,9 +136,7 @@ class Ctypent // extends CommonObject } $this->db->rollback(); return -1 * $error; - } - else - { + } else { $this->db->commit(); return $this->id; } @@ -185,9 +183,7 @@ class Ctypent // extends CommonObject $this->db->free($resql); return 1; - } - else - { + } else { $this->error = "Error ".$this->db->lasterror(); return -1; } @@ -240,9 +236,7 @@ class Ctypent // extends CommonObject } $this->db->rollback(); return -1 * $error; - } - else - { + } else { $this->db->commit(); return 1; } @@ -280,9 +274,7 @@ class Ctypent // extends CommonObject } $this->db->rollback(); return -1 * $error; - } - else - { + } else { $this->db->commit(); return 1; } diff --git a/htdocs/core/class/cunits.class.php b/htdocs/core/class/cunits.class.php index 096ae47a7b8..ac7b07ea5a9 100644 --- a/htdocs/core/class/cunits.class.php +++ b/htdocs/core/class/cunits.class.php @@ -135,9 +135,7 @@ class CUnits // extends CommonObject } $this->db->rollback(); return -1 * $error; - } - else - { + } else { $this->db->commit(); return $this->id; } @@ -195,9 +193,7 @@ class CUnits // extends CommonObject $this->db->free($resql); return 1; - } - else - { + } else { $this->error = "Error ".$this->db->lasterror(); return -1; } @@ -236,14 +232,11 @@ class CUnits // extends CommonObject foreach ($filter as $key => $value) { if ($key == 't.rowid' || $key == 't.active' || $key == 't.scale') { $sqlwhere[] = $key.'='.(int) $value; - } - elseif (strpos($key, 'date') !== false) { + } elseif (strpos($key, 'date') !== false) { $sqlwhere[] = $key.' = \''.$this->db->idate($value).'\''; - } - elseif ($key == 't.unit_type' || $key == 't.code' || $key == 't.short_label') { + } elseif ($key == 't.unit_type' || $key == 't.code' || $key == 't.short_label') { $sqlwhere[] = $key.' = \''.$this->db->escape($value).'\''; - } - else { + } else { $sqlwhere[] = $key.' LIKE \'%'.$this->db->escape($value).'%\''; } } @@ -339,9 +332,7 @@ class CUnits // extends CommonObject } $this->db->rollback(); return -1 * $error; - } - else - { + } else { $this->db->commit(); return 1; } @@ -379,9 +370,7 @@ class CUnits // extends CommonObject } $this->db->rollback(); return -1 * $error; - } - else - { + } else { $this->db->commit(); return 1; } @@ -397,10 +386,9 @@ class CUnits // extends CommonObject public function getUnitFromCode($code, $mode = 'code') { - if($mode == 'short_label'){ + if ($mode == 'short_label'){ return dol_getIdFromCode($this->db, $code, 'c_units', 'short_label', 'rowid'); - } - elseif($mode == 'code'){ + } elseif ($mode == 'code'){ return dol_getIdFromCode($this->db, $code, 'c_units', 'code', 'rowid'); } @@ -424,10 +412,10 @@ class CUnits // extends CommonObject // convert to standard unit $value = $value * $scaleUnitPow; - if($fk_new_unit !=0 ){ + if ($fk_new_unit !=0 ){ // Calcul en unité de base $scaleUnitPow = $this->scaleOfUnitPow($fk_new_unit); - if(!empty($scaleUnitPow)) + if (!empty($scaleUnitPow)) { // convert to new unit $value = $value / $scaleUnitPow; @@ -436,11 +424,9 @@ class CUnits // extends CommonObject return round($value, 2); } - - /** * get scale of unit factor - * @param $id int id of unit in dictionary + * @param int $id id of unit in dictionary * @return float|int */ public function scaleOfUnitPow($id) @@ -448,9 +434,9 @@ class CUnits // extends CommonObject $base = 10; // TODO : add base col into unit dictionary table $unit = $this->db->getRow('SELECT scale, unit_type from '.MAIN_DB_PREFIX.'c_units WHERE rowid = '.intval($id)); - if($unit){ + if ($unit) { // TODO : if base exist in unit dictionary table remove this convertion exception and update convertion infos in database exemple time hour currently scale 3600 will become scale 2 base 60 - if($unit->unit_type == 'time'){ + if ($unit->unit_type == 'time') { return doubleval($unit->scale); } diff --git a/htdocs/core/class/discount.class.php b/htdocs/core/class/discount.class.php index 724b2a778d8..4cddc65d636 100644 --- a/htdocs/core/class/discount.class.php +++ b/htdocs/core/class/discount.class.php @@ -187,15 +187,11 @@ class DiscountAbsolute $this->db->free($resql); return 1; - } - else - { + } else { $this->db->free($resql); return 0; } - } - else - { + } else { $this->error = $this->db->error(); return -1; } @@ -264,9 +260,7 @@ class DiscountAbsolute { $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."societe_remise_except"); return $this->id; - } - else - { + } else { $this->error = $this->db->lasterror().' - sql='.$sql; return -1; } @@ -303,9 +297,7 @@ class DiscountAbsolute $this->error = 'ErrorThisPartOrAnotherIsAlreadyUsedSoDiscountSerieCantBeRemoved'; return -2; } - } - else - { + } else { dol_print_error($this->db); return -1; } @@ -331,9 +323,7 @@ class DiscountAbsolute $this->error = 'ErrorThisPartOrAnotherIsAlreadyUsedSoDiscountSerieCantBeRemoved'; return -2; } - } - else - { + } else { dol_print_error($this->db); return -1; } @@ -368,15 +358,12 @@ class DiscountAbsolute { $this->db->commit(); return 1; - } - else - { + } else { $this->error = $this->db->lasterror(); $this->db->rollback(); return -1; } - } - elseif ($this->fk_invoice_supplier_source) { + } elseif ($this->fk_invoice_supplier_source) { $sql = "UPDATE ".MAIN_DB_PREFIX."facture_fourn"; $sql .= " set paye=0, fk_statut=1"; $sql .= " WHERE (type = 2 or type = 3) AND rowid=".$this->fk_invoice_supplier_source; @@ -387,22 +374,16 @@ class DiscountAbsolute { $this->db->commit(); return 1; - } - else - { + } else { $this->error = $this->db->lasterror(); $this->db->rollback(); return -1; } - } - else - { + } else { $this->db->commit(); return 1; } - } - else - { + } else { $this->error = $this->db->lasterror(); $this->db->rollback(); return -1; @@ -458,9 +439,7 @@ class DiscountAbsolute $this->fk_facture = $rowidinvoice; } return 1; - } - else - { + } else { $this->error = $this->db->error(); return -3; } @@ -490,9 +469,7 @@ class DiscountAbsolute if ($resql) { return 1; - } - else - { + } else { $this->error = $this->db->error(); return -3; } @@ -568,16 +545,13 @@ class DiscountAbsolute $sql .= ' FROM '.MAIN_DB_PREFIX.'societe_remise_except as rc, '.MAIN_DB_PREFIX.'facture as f'; $sql .= ' WHERE rc.fk_facture_source=f.rowid AND rc.fk_facture = '.$invoice->id; $sql .= ' AND f.type = 3'; - } - elseif ($invoice->element == 'invoice_supplier') + } elseif ($invoice->element == 'invoice_supplier') { $sql = 'SELECT sum(rc.amount_ttc) as amount, sum(rc.multicurrency_amount_ttc) as multicurrency_amount'; $sql .= ' FROM '.MAIN_DB_PREFIX.'societe_remise_except as rc, '.MAIN_DB_PREFIX.'facture_fourn as f'; $sql .= ' WHERE rc.fk_invoice_supplier_source=f.rowid AND rc.fk_invoice_supplier = '.$invoice->id; $sql .= ' AND f.type = 3'; - } - else - { + } else { $this->error = get_class($this)."::getSumDepositsUsed was called with a bad object as a first parameter"; dol_print_error($this->error); return -1; @@ -589,9 +563,7 @@ class DiscountAbsolute $obj = $this->db->fetch_object($resql); if ($multicurrency == 1) return $obj->multicurrency_amount; else return $obj->amount; - } - else - { + } else { $this->error = $this->db->lasterror(); return -1; } @@ -614,16 +586,13 @@ class DiscountAbsolute $sql .= ' FROM '.MAIN_DB_PREFIX.'societe_remise_except as rc, '.MAIN_DB_PREFIX.'facture as f'; $sql .= ' WHERE rc.fk_facture_source=f.rowid AND rc.fk_facture = '.$invoice->id; $sql .= ' AND f.type IN ('.$invoice::TYPE_STANDARD.', '.$invoice::TYPE_CREDIT_NOTE.', '.$invoice::TYPE_SITUATION.')'; // Find discount coming from credit note or excess received - } - elseif ($invoice->element == 'invoice_supplier') + } elseif ($invoice->element == 'invoice_supplier') { $sql = 'SELECT sum(rc.amount_ttc) as amount, sum(rc.multicurrency_amount_ttc) as multicurrency_amount'; $sql .= ' FROM '.MAIN_DB_PREFIX.'societe_remise_except as rc, '.MAIN_DB_PREFIX.'facture_fourn as f'; $sql .= ' WHERE rc.fk_invoice_supplier_source=f.rowid AND rc.fk_invoice_supplier = '.$invoice->id; $sql .= ' AND f.type IN ('.$invoice::TYPE_STANDARD.', '.$invoice::TYPE_CREDIT_NOTE.')'; // Find discount coming from credit note or excess paid - } - else - { + } else { $this->error = get_class($this)."::getSumCreditNotesUsed was called with a bad object as a first parameter"; dol_print_error($this->error); return -1; @@ -635,9 +604,7 @@ class DiscountAbsolute $obj = $this->db->fetch_object($resql); if ($multicurrency == 1) return $obj->multicurrency_amount; else return $obj->amount; - } - else - { + } else { $this->error = $this->db->lasterror(); return -1; } @@ -658,15 +625,12 @@ class DiscountAbsolute $sql = 'SELECT sum(rc.amount_ttc) as amount, sum(rc.multicurrency_amount_ttc) as multicurrency_amount'; $sql .= ' FROM '.MAIN_DB_PREFIX.'societe_remise_except as rc'; $sql .= ' WHERE rc.fk_facture IS NULL AND rc.fk_facture_source = '.$invoice->id; - } - elseif ($invoice->element == 'invoice_supplier') + } elseif ($invoice->element == 'invoice_supplier') { $sql = 'SELECT sum(rc.amount_ttc) as amount, sum(rc.multicurrency_amount_ttc) as multicurrency_amount'; $sql .= ' FROM '.MAIN_DB_PREFIX.'societe_remise_except as rc'; $sql .= ' WHERE rc.fk_invoice_supplier IS NULL AND rc.fk_invoice_supplier_source = '.$invoice->id; - } - else - { + } else { $this->error = get_class($this)."::getSumCreditNotesUsed was called with a bad object as a first parameter"; dol_print_error($this->error); return -1; @@ -678,9 +642,7 @@ class DiscountAbsolute $obj = $this->db->fetch_object($resql); if ($multicurrency) return $obj->multicurrency_amount; else return $obj->amount; - } - else - { + } else { $this->error = $this->db->lasterror(); return -1; } diff --git a/htdocs/core/class/dolgeoip.class.php b/htdocs/core/class/dolgeoip.class.php index 24e0a6de275..2b148a96e8a 100644 --- a/htdocs/core/class/dolgeoip.class.php +++ b/htdocs/core/class/dolgeoip.class.php @@ -55,16 +55,14 @@ class DolGeoIP { 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'))) { 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)) @@ -85,20 +83,16 @@ class DolGeoIP { 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); - } - else - { + } else { $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(); @@ -126,9 +120,7 @@ class DolGeoIP { // geoip_country_code_by_addr does not exists return strtolower(geoip_country_code_by_name($ip)); - } - else - { + } else { if (preg_match('/^[0-9]+.[0-9]+\.[0-9]+\.[0-9]+/', $ip)) { if ($geoipversion == '2') @@ -136,33 +128,25 @@ class DolGeoIP try { $record = $this->gi->country($ip); return strtolower($record->country->isoCode); - } - catch (Exception $e) { + } catch (Exception $e) { //return $e->getMessage(); return ''; } - } - else - { + } else { 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 - { + } else { if ($geoipversion == '2') { try { $record = $this->gi->country($ip); return strtolower($record->country->isoCode); - } - catch (Exception $e) { + } catch (Exception $e) { //return $e->getMessage(); return ''; } - } - else - { + } else { 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)); } @@ -193,14 +177,11 @@ class DolGeoIP try { $record = $this->gi->country($name); return $record->country->isoCode; - } - catch (Exception $e) { + } catch (Exception $e) { //return $e->getMessage(); return ''; } - } - else - { + } else { return geoip_country_code_by_name($this->gi, $name); } } diff --git a/htdocs/core/class/dolgraph.class.php b/htdocs/core/class/dolgraph.class.php index 8af46154223..4ca072897bb 100644 --- a/htdocs/core/class/dolgraph.class.php +++ b/htdocs/core/class/dolgraph.class.php @@ -472,14 +472,10 @@ class DolGraph { //print 'ee'.join(',',$theme_bgcoloronglet); $this->bgcolor = $theme_bgcoloronglet; - } - else - { + } else { $this->bgcolor = $theme_bgcolor; } - } - else - { + } else { $this->bgcolor = $bg_color; } } @@ -502,14 +498,10 @@ class DolGraph { //print 'ee'.join(',',$theme_bgcoloronglet); $this->bgcolorgrid = $theme_bgcoloronglet; - } - else - { + } else { $this->bgcolorgrid = $theme_bgcolor; } - } - else - { + } else { $this->bgcolorgrid = $bg_colorgrid; } } @@ -725,9 +717,7 @@ class DolGraph foreach ($values as $x => $y) { if (isset($y)) $serie[$i] .= 'd'.$i.'.push({"label":"'.dol_escape_js($legends[$x]).'", "data":'.$y.'});'."\n"; } - } - else - { + } else { foreach ($values as $x => $y) { if (isset($y)) $serie[$i] .= 'd'.$i.'.push(['.$x.', '.$y.']);'."\n"; } @@ -758,9 +748,7 @@ class DolGraph if ($nblot < 0) { $this->stringtoshow .= ''."\n"; - } - else - { + } else { while ($i < $nblot) { $this->stringtoshow .= ''."\n"; @@ -835,8 +823,7 @@ class DolGraph }'."\n"; } // Other cases, graph of type 'bars', 'lines' - else - { + else { // Add code to support tooltips // TODO: remove js css and use graph-tooltip-inner class instead by adding css in each themes $this->stringtoshow .= ' @@ -894,7 +881,14 @@ class DolGraph if ($i > $firstlot) $this->stringtoshow .= ', '."\n"; $color = sprintf("%02x%02x%02x", $this->datacolor[$i][0], $this->datacolor[$i][1], $this->datacolor[$i][2]); $this->stringtoshow .= '{ '; - if (!isset($this->type[$i]) || $this->type[$i] == 'bars') $this->stringtoshow .= 'bars: { lineWidth: 1, show: true, align: "'.($i == $firstlot ? 'center' : 'left').'", barWidth: 0.5 }, '; + if (! isset($this->type[$i]) || $this->type[$i] == 'bars') { + if ($nblot == 3) { + if ($i == $firstlot) $align = 'right'; + elseif ($i == $firstlot + 1) $align = 'center'; + else $align = 'left'; + $this->stringtoshow .= 'bars: { lineWidth: 1, show: true, align: "'.$align.'", barWidth: 0.45 }, '; + } else $this->stringtoshow.='bars: { lineWidth: 1, show: true, align: "'.($i==$firstlot?'center':'left').'", barWidth: 0.5 }, '; + } if (isset($this->type[$i]) && ($this->type[$i] == 'lines' || $this->type[$i] == 'linesnopoint')) $this->stringtoshow .= 'lines: { show: true, fill: false }, points: { show: '.($this->type[$i] == 'linesnopoint' ? 'false' : 'true').' }, '; $this->stringtoshow .= 'color: "#'.$color.'", label: "'.(isset($this->Legend[$i]) ? dol_escape_js($this->Legend[$i]) : '').'", data: d'.$i.' }'; $i++; @@ -1050,9 +1044,7 @@ class DolGraph if ($nblot < 0) { $this->stringtoshow .= ''; - } - else - { + } else { while ($i < $nblot) { //$this->stringtoshow .= ''."\n"; @@ -1095,8 +1087,7 @@ class DolGraph if (strpos($tmp, '-') !== false) { $foundnegativecolor++; $color = '#FFFFFF'; // If $val is '-123' - } - else $color = "#".$tmp; // If $val is '123' or '#123' + } else $color = "#".$tmp; // If $val is '123' or '#123' } $this->stringtoshow .= "'".$color."'"; $i++; @@ -1162,8 +1153,7 @@ class DolGraph $this->stringtoshow .= '});'."\n"; } // Other cases, graph of type 'bars', 'lines', 'linesnopoint' - else - { + else { $type = 'bar'; if (!isset($this->type[$firstlot]) || $this->type[$firstlot] == 'bars') $type = 'bar'; if (isset($this->type[$firstlot]) && ($this->type[$firstlot] == 'lines' || $this->type[$firstlot] == 'linesnopoint')) $type = 'line'; diff --git a/htdocs/core/class/emailsenderprofile.class.php b/htdocs/core/class/emailsenderprofile.class.php index 3bac7c8c2cc..25a0d2a25c5 100644 --- a/htdocs/core/class/emailsenderprofile.class.php +++ b/htdocs/core/class/emailsenderprofile.class.php @@ -350,28 +350,23 @@ class EmailSenderProfile extends CommonObject { if ($status == 1) return $langs->trans('Enabled'); elseif ($status == 0) return $langs->trans('Disabled'); - } - elseif ($mode == 2) + } elseif ($mode == 2) { if ($status == 1) return img_picto($langs->trans('Enabled'), 'statut4').' '.$langs->trans('Enabled'); elseif ($status == 0) return img_picto($langs->trans('Disabled'), 'statut5').' '.$langs->trans('Disabled'); - } - elseif ($mode == 3) + } elseif ($mode == 3) { if ($status == 1) return img_picto($langs->trans('Enabled'), 'statut4'); elseif ($status == 0) return img_picto($langs->trans('Disabled'), 'statut5'); - } - elseif ($mode == 4) + } elseif ($mode == 4) { if ($status == 1) return img_picto($langs->trans('Enabled'), 'statut4').' '.$langs->trans('Enabled'); elseif ($status == 0) return img_picto($langs->trans('Disabled'), 'statut5').' '.$langs->trans('Disabled'); - } - elseif ($mode == 5) + } elseif ($mode == 5) { if ($status == 1) return $langs->trans('Enabled').' '.img_picto($langs->trans('Enabled'), 'statut4'); elseif ($status == 0) return $langs->trans('Disabled').' '.img_picto($langs->trans('Disabled'), 'statut5'); - } - elseif ($mode == 6) + } elseif ($mode == 6) { if ($status == 1) return $langs->trans('Enabled').' '.img_picto($langs->trans('Enabled'), 'statut4'); elseif ($status == 0) return $langs->trans('Disabled').' '.img_picto($langs->trans('Disabled'), 'statut5'); @@ -424,9 +419,7 @@ class EmailSenderProfile extends CommonObject } $this->db->free($result); - } - else - { + } else { dol_print_error($this->db); } } diff --git a/htdocs/core/class/evalmath.class.php b/htdocs/core/class/evalmath.class.php index b0fcc963eba..4b261a0f3c6 100644 --- a/htdocs/core/class/evalmath.class.php +++ b/htdocs/core/class/evalmath.class.php @@ -272,8 +272,7 @@ class EvalMath while (($o2 = $stack->pop()) != '(') { // pop off the stack back to the last ( if (is_null($o2)) return $this->trigger(5, "unexpected ')'", ")"); - else - $output[] = $o2; + else $output[] = $o2; } if (preg_match("/^([a-z]\w*)\($/", $stack->last(2), $matches)) { // did we just close a function? $fnn = $matches[1]; // get the function name @@ -295,8 +294,7 @@ class EvalMath while (($o2 = $stack->pop()) != '(') { if (is_null($o2)) return $this->trigger(5, "unexpected ','", ","); // oops, never had a ( - else - $output[] = $o2; // pop the argument expression stuff and push onto the output + else $output[] = $o2; // pop the argument expression stuff and push onto the output } // make sure there was a function if (!preg_match("/^([a-z]\w*)\($/", $stack->last(2), $matches)) diff --git a/htdocs/core/class/events.class.php b/htdocs/core/class/events.class.php index 9c2e5b145dd..bffd23f05d2 100644 --- a/htdocs/core/class/events.class.php +++ b/htdocs/core/class/events.class.php @@ -173,9 +173,7 @@ class Events // extends CommonObject { $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."events"); return $this->id; - } - else - { + } else { $this->error = "Error ".$this->db->lasterror(); return -1; } @@ -260,9 +258,7 @@ class Events // extends CommonObject $this->db->free($resql); return 1; - } - else - { + } else { $this->error = "Error ".$this->db->lasterror(); return -1; } diff --git a/htdocs/core/class/extrafields.class.php b/htdocs/core/class/extrafields.class.php index 18dd686367b..c82e877fa80 100644 --- a/htdocs/core/class/extrafields.class.php +++ b/htdocs/core/class/extrafields.class.php @@ -43,7 +43,7 @@ class ExtraFields public $db; /** - * @var string type of element (for what object is the extrafield) + * @var array Array with type of element (for what object is the extrafield) * @deprecated */ public $attribute_elementtype; @@ -253,11 +253,8 @@ class ExtraFields $this->error = ''; $this->errno = 0; return 1; - } - else return -2; - } - else - { + } else return -2; + } else { return -1; } } @@ -338,16 +335,12 @@ class ExtraFields $resql = $this->db->query($sql, 1, 'dml'); } return 1; - } - else - { + } else { $this->error = $this->db->lasterror(); $this->errno = $this->db->lasterrno(); return -1; } - } - else - { + } else { return 0; } } @@ -401,13 +394,10 @@ class ExtraFields if (is_array($param) && count($param) > 0) { $params = serialize($param); - } - elseif (strlen($param) > 0) + } elseif (strlen($param) > 0) { $params = trim($param); - } - else - { + } else { $params = ''; } @@ -465,9 +455,7 @@ class ExtraFields if ($this->db->query($sql)) { return 1; - } - else - { + } else { $this->error = $this->db->lasterror(); $this->errno = $this->db->lasterrno(); return -1; @@ -527,9 +515,7 @@ class ExtraFields } return $result; - } - else - { + } else { return 0; } } @@ -562,15 +548,11 @@ class ExtraFields if ($resql) { return 1; - } - else - { + } else { dol_print_error($this->db); return -1; } - } - else - { + } else { return 0; } } @@ -659,29 +641,21 @@ class ExtraFields if ($unique) { $sql = "ALTER TABLE ".MAIN_DB_PREFIX.$table." ADD UNIQUE INDEX uk_".$table."_".$attrname." (".$attrname.")"; - } - else - { + } else { $sql = "ALTER TABLE ".MAIN_DB_PREFIX.$table." DROP INDEX uk_".$table."_".$attrname; } dol_syslog(get_class($this).'::update', LOG_DEBUG); $resql = $this->db->query($sql, 1, 'dml'); return 1; - } - else - { + } else { $this->error = $this->db->lasterror(); return -1; } - } - else - { + } else { $this->error = $this->db->lasterror(); return -1; } - } - else - { + } else { return 0; } } @@ -739,13 +713,10 @@ class ExtraFields if (is_array($param) && count($param) > 0) { $params = serialize($param); - } - elseif (strlen($param) > 0) + } elseif (strlen($param) > 0) { $params = trim($param); - } - else - { + } else { $params = ''; } @@ -756,9 +727,7 @@ class ExtraFields $sql_del .= " WHERE name = '".$attrname."'"; $sql_del .= " AND entity IN (0, ".($entity === '' ? $conf->entity : $entity).")"; $sql_del .= " AND elementtype = '".$elementtype."'"; - } - else - { + } else { // We want on all entities ($entities = '0'), we delete on all only (we keep setup specific to each entity) $sql_del = "DELETE FROM ".MAIN_DB_PREFIX."extrafields"; $sql_del .= " WHERE name = '".$attrname."'"; @@ -823,16 +792,12 @@ class ExtraFields { $this->db->commit(); return 1; - } - else - { + } else { $this->db->rollback(); dol_print_error($this->db); return -1; } - } - else - { + } else { return 0; } } @@ -932,9 +897,7 @@ class ExtraFields } } if ($elementtype) $this->attributes[$elementtype]['loaded'] = 1; // If nothing found, we also save tag 'loaded' - } - else - { + } else { $this->error = $this->db->lasterror(); dol_syslog(get_class($this)."::fetch_name_optionals_label ".$this->error, LOG_ERR); } @@ -991,8 +954,7 @@ class ExtraFields $totalizable = $this->attributes[$extrafieldsobjectkey]['totalizable'][$key]; $help = $this->attributes[$extrafieldsobjectkey]['help'][$key]; $hidden = (empty($list) ? 1 : 0); // If empty, we are sure it is hidden, otherwise we show. If it depends on mode (view/create/edit form or list, this must be filtered by caller) - } - else // Old usage + } else // Old usage { $label = $this->attribute_label[$key]; $type = $this->attribute_type[$key]; @@ -1020,39 +982,29 @@ class ExtraFields if ($type == 'date') { $morecss = 'minwidth100imp'; - } - elseif ($type == 'datetime' || $type == 'link') + } elseif ($type == 'datetime' || $type == 'link') { $morecss = 'minwidth200imp'; - } - elseif (in_array($type, array('int', 'integer', 'double', 'price'))) + } elseif (in_array($type, array('int', 'integer', 'double', 'price'))) { $morecss = 'maxwidth75'; - } - elseif ($type == 'password') + } elseif ($type == 'password') { $morecss = 'maxwidth100'; - } - elseif ($type == 'url') + } elseif ($type == 'url') { $morecss = 'minwidth400'; - } - elseif ($type == 'boolean') + } elseif ($type == 'boolean') { $morecss = ''; - } - else - { + } else { if (round($size) < 12) { $morecss = 'minwidth100'; - } - elseif (round($size) <= 48) + } elseif (round($size) <= 48) { $morecss = 'minwidth200'; - } - else - { + } else { $morecss = 'minwidth400'; } } @@ -1070,48 +1022,38 @@ class ExtraFields // TODO Must also support $moreparam $out = $form->selectDate($value, $keyprefix.$key.$keysuffix, $showtime, $showtime, $required, '', 1, (($keyprefix != 'search_' && $keyprefix != 'search_options_') ? 1 : 0), 0, 1); - } - elseif (in_array($type, array('int', 'integer'))) + } elseif (in_array($type, array('int', 'integer'))) { $tmp = explode(',', $size); $newsize = $tmp[0]; $out = ''; - } - elseif (preg_match('/varchar/', $type)) + } elseif (preg_match('/varchar/', $type)) { $out = ''; - } - elseif (in_array($type, array('mail', 'phone', 'url'))) + } elseif (in_array($type, array('mail', 'phone', 'url'))) { $out = ''; - } - elseif ($type == 'text') + } elseif ($type == 'text') { if (!preg_match('/search_/', $keyprefix)) // If keyprefix is search_ or search_options_, we must just use a simple text field { require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; $doleditor = new DolEditor($keyprefix.$key.$keysuffix, $value, '', 200, 'dolibarr_notes', 'In', false, false, false, ROWS_5, '90%'); $out = $doleditor->Create(1); - } - else - { + } else { $out = ''; } - } - elseif ($type == 'html') + } elseif ($type == 'html') { if (!preg_match('/search_/', $keyprefix)) // If keyprefix is search_ or search_options_, we must just use a simple text field { require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; $doleditor = new DolEditor($keyprefix.$key.$keysuffix, $value, '', 200, 'dolibarr_notes', 'In', false, false, !empty($conf->fckeditor->enabled) && $conf->global->FCKEDITOR_ENABLE_SOCIETE, ROWS_5, '90%'); $out = $doleditor->Create(1); - } - else - { + } else { $out = ''; } - } - elseif ($type == 'boolean') + } elseif ($type == 'boolean') { if (empty($mode)) { @@ -1122,27 +1064,22 @@ class ExtraFields $checked = ' value="1" '; } $out = ''; - } - else - { + } else { $out .= $form->selectyesno($keyprefix.$key.$keysuffix, $value, 1, false, 1); } - } - elseif ($type == 'price') + } elseif ($type == 'price') { if (!empty($value)) { // $value in memory is a php numeric, we format it into user number format. $value = price($value); } $out = ' '.$langs->getCurrencySymbol($conf->currency); - } - elseif ($type == 'double') + } elseif ($type == 'double') { if (!empty($value)) { // $value in memory is a php numeric, we format it into user number format. $value = price($value); } $out = ' '; - } - elseif ($type == 'select') + } elseif ($type == 'select') { $out = ''; if (!empty($conf->use_javascript_ajax) && !empty($conf->global->MAIN_EXTRAFIELDS_USE_SELECT2)) @@ -1166,8 +1103,7 @@ class ExtraFields $out .= ''; } $out .= ''; - } - elseif ($type == 'sellist') + } elseif ($type == 'sellist') { $out = ''; if (!empty($conf->use_javascript_ajax) && !empty($conf->global->MAIN_EXTRAFIELDS_USE_SELECT2)) @@ -1326,13 +1262,11 @@ class ExtraFields } } $out .= ''; - } - elseif ($type == 'checkbox') + } elseif ($type == 'checkbox') { $value_arr = explode(',', $value); $out = $form->multiselectarray($keyprefix.$key.$keysuffix, (empty($param['options']) ?null:$param['options']), $value_arr, '', 0, '', 0, '100%'); - } - elseif ($type == 'radio') + } elseif ($type == 'radio') { $out = ''; foreach ($param['options'] as $keyopt => $val) @@ -1343,13 +1277,11 @@ class ExtraFields $out .= ($value == $keyopt ? 'checked' : ''); $out .= '/>
'; } - } - elseif ($type == 'chkbxlst') + } elseif ($type == 'chkbxlst') { if (is_array($value)) { $value_arr = $value; - } - else { + } else { $value_arr = explode(',', $value); } @@ -1547,14 +1479,12 @@ class ExtraFields $out = $form->multiselectarray($keyprefix.$key.$keysuffix, $data, $value_arr, '', 0, '', 0, '100%'); } } - } - elseif ($type == 'link') + } elseif ($type == 'link') { $param_list = array_keys($param['options']); // $param_list='ObjectName:classPath' $showempty = (($required && $default != '') ? 0 : 1); $out = $form->selectForForms($param_list[0], $keyprefix.$key.$keysuffix, $value, $showempty, '', '', $morecss); - } - elseif ($type == 'password') + } elseif ($type == 'password') { // If prefix is 'search_', field is used as a filter, we use a common text field. $out = ''; // Hidden field to reduce impact of evil Google Chrome autopopulate bug. @@ -1602,8 +1532,7 @@ class ExtraFields $list = dol_eval($this->attributes[$extrafieldsobjectkey]['list'][$key], 1); $help = $this->attributes[$extrafieldsobjectkey]['help'][$key]; $hidden = (empty($list) ? 1 : 0); // If $list empty, we are sure it is hidden, otherwise we show. If it depends on mode (view/create/edit form or list, this must be filtered by caller) - } - else // Old usage + } else // Old usage { //dol_syslog("Warning: parameter 'extrafieldsobjectkey' is missing", LOG_WARNING); $label = $this->attribute_label[$key]; @@ -1630,17 +1559,14 @@ class ExtraFields { $showsize = 10; $value = dol_print_date($value, 'day'); - } - elseif ($type == 'datetime') + } elseif ($type == 'datetime') { $showsize = 19; $value = dol_print_date($value, 'dayhour'); - } - elseif ($type == 'int') + } elseif ($type == 'int') { $showsize = 10; - } - elseif ($type == 'double') + } elseif ($type == 'double') { if (!empty($value)) { //$value=price($value); @@ -1648,38 +1574,31 @@ class ExtraFields $number_decimals = $sizeparts[1]; $value = price($value, 0, $langs, 0, 0, $number_decimals, ''); } - } - elseif ($type == 'boolean') + } elseif ($type == 'boolean') { $checked = ''; if (!empty($value)) { $checked = ' checked '; } $value = ''; - } - elseif ($type == 'mail') + } elseif ($type == 'mail') { $value = dol_print_email($value, 0, 0, 0, 64, 1, 1); - } - elseif ($type == 'url') + } elseif ($type == 'url') { $value = dol_print_url($value, '_blank', 32, 1); - } - elseif ($type == 'phone') + } elseif ($type == 'phone') { $value = dol_print_phone($value, '', 0, 0, '', ' ', 'phone'); - } - elseif ($type == 'price') + } elseif ($type == 'price') { //$value = price($value, 0, $langs, 0, 0, -1, $conf->currency); if ($value || $value == '0') $value = price($value, 0, $langs, 0, 0, -1); - } - elseif ($type == 'select') + } elseif ($type == 'select') { if ($langfile && $param['options'][$value]) $value = $langs->trans($param['options'][$value]); else $value = $param['options'][$value]; - } - elseif ($type == 'sellist') + } elseif ($type == 'sellist') { $param_list = array_keys($param['options']); $InfoFieldList = explode(":", $param_list[0]); @@ -1740,9 +1659,7 @@ class ExtraFields $value .= $obj->$field_toshow.' '; } } - } - else - { + } else { $translabel = ''; if (!empty($obj->{$InfoFieldList[1]})) { $translabel = $langs->trans($obj->{$InfoFieldList[1]}); @@ -1753,14 +1670,11 @@ class ExtraFields $value = $obj->{$InfoFieldList[1]}; } } - } - else dol_syslog(get_class($this).'::showOutputField error '.$this->db->lasterror(), LOG_WARNING); - } - elseif ($type == 'radio') + } else dol_syslog(get_class($this).'::showOutputField error '.$this->db->lasterror(), LOG_WARNING); + } elseif ($type == 'radio') { $value = $param['options'][$value]; - } - elseif ($type == 'checkbox') + } elseif ($type == 'checkbox') { $value_arr = explode(',', $value); $value = ''; @@ -1772,8 +1686,7 @@ class ExtraFields } } $value = '
    '.implode(' ', $toprint).'
'; - } - elseif ($type == 'chkbxlst') + } elseif ($type == 'chkbxlst') { $value_arr = explode(',', $value); @@ -1840,8 +1753,7 @@ class ExtraFields } else { dol_syslog(get_class($this).'::showOutputField error '.$this->db->lasterror(), LOG_WARNING); } - } - elseif ($type == 'link') + } elseif ($type == 'link') { $out = ''; @@ -1862,28 +1774,21 @@ class ExtraFields $object->fetch($value); $value = $object->getNomUrl(3); } - } - else - { + } else { dol_syslog('Error bad setup of extrafield', LOG_WARNING); return 'Error bad setup of extrafield'; } } - } - elseif ($type == 'text') + } elseif ($type == 'text') { $value = dol_htmlentitiesbr($value); - } - elseif ($type == 'html') + } elseif ($type == 'html') { $value = dol_htmlentitiesbr($value); - } - elseif ($type == 'password') + } elseif ($type == 'password') { $value = dol_trunc(preg_replace('/./i', '*', $value), 8, 'right', 'UTF-8', 1); - } - else - { + } else { $showsize = round($size); if ($showsize > 48) $showsize = 48; } @@ -1913,36 +1818,28 @@ class ExtraFields if ($type == 'date') { $align = "center"; - } - elseif ($type == 'datetime') + } elseif ($type == 'datetime') { $align = "center"; - } - elseif ($type == 'int') + } elseif ($type == 'int') { $align = "right"; - } - elseif ($type == 'price') + } elseif ($type == 'price') { $align = "right"; - } - elseif ($type == 'double') + } elseif ($type == 'double') { $align = "right"; - } - elseif ($type == 'boolean') + } elseif ($type == 'boolean') { $align = "center"; - } - elseif ($type == 'radio') + } elseif ($type == 'radio') { $align = "center"; - } - elseif ($type == 'checkbox') + } elseif ($type == 'checkbox') { $align = "center"; - } - elseif ($type == 'price') + } elseif ($type == 'price') { $align = "right"; } @@ -2065,14 +1962,12 @@ class ExtraFields // Clean parameters // TODO GMT date in memory must be GMT so we should add gm=true in parameters $value_key = dol_mktime(0, 0, 0, $_POST["options_".$key."month"], $_POST["options_".$key."day"], $_POST["options_".$key."year"]); - } - elseif (in_array($key_type, array('datetime'))) + } elseif (in_array($key_type, array('datetime'))) { // Clean parameters // TODO GMT date in memory must be GMT so we should add gm=true in parameters $value_key = dol_mktime($_POST["options_".$key."hour"], $_POST["options_".$key."min"], 0, $_POST["options_".$key."month"], $_POST["options_".$key."day"], $_POST["options_".$key."year"]); - } - elseif (in_array($key_type, array('checkbox', 'chkbxlst'))) + } elseif (in_array($key_type, array('checkbox', 'chkbxlst'))) { $value_arr = GETPOST("options_".$key, 'array'); // check if an array if (!empty($value_arr)) { @@ -2080,14 +1975,11 @@ class ExtraFields } else { $value_key = ''; } - } - elseif (in_array($key_type, array('price', 'double'))) + } elseif (in_array($key_type, array('price', 'double'))) { $value_arr = GETPOST("options_".$key, 'alpha'); $value_key = price2num($value_arr); - } - else - { + } else { $value_key = GETPOST("options_".$key); if (in_array($key_type, array('link')) && $value_key == '-1') $value_key = ''; } @@ -2099,12 +1991,10 @@ class ExtraFields $langs->load('errors'); setEventMessages($langs->trans('ErrorFieldsRequired').' : '.implode(', ', $error_field_required), null, 'errors'); return -1; - } - else { + } else { return 1; } - } - else { + } else { return 0; } } @@ -2124,9 +2014,7 @@ class ExtraFields if (is_string($extrafieldsobjectkey) && is_array($this->attributes[$extrafieldsobjectkey]['label'])) { $extralabels = $this->attributes[$extrafieldsobjectkey]['label']; - } - else - { + } else { $extralabels = $extrafieldsobjectkey; } @@ -2148,23 +2036,19 @@ class ExtraFields if (!GETPOSTISSET($keysuffix."options_".$key.$keyprefix."year")) continue; // Value was not provided, we should not set it. // Clean parameters $value_key = dol_mktime(GETPOST($keysuffix."options_".$key.$keyprefix."hour", 'int'), GETPOST($keysuffix."options_".$key.$keyprefix."min", 'int'), 0, GETPOST($keysuffix."options_".$key.$keyprefix."month", 'int'), GETPOST($keysuffix."options_".$key.$keyprefix."day", 'int'), GETPOST($keysuffix."options_".$key.$keyprefix."year", 'int')); - } - elseif (in_array($key_type, array('checkbox', 'chkbxlst'))) + } elseif (in_array($key_type, array('checkbox', 'chkbxlst'))) { if (!GETPOSTISSET($keysuffix."options_".$key.$keyprefix)) continue; // Value was not provided, we should not set it. $value_arr = GETPOST($keysuffix."options_".$key.$keyprefix); // Make sure we get an array even if there's only one checkbox $value_arr = (array) $value_arr; $value_key = implode(',', $value_arr); - } - elseif (in_array($key_type, array('price', 'double', 'int'))) + } elseif (in_array($key_type, array('price', 'double', 'int'))) { if (!GETPOSTISSET($keysuffix."options_".$key.$keyprefix)) continue; // Value was not provided, we should not set it. $value_arr = GETPOST($keysuffix."options_".$key.$keyprefix); $value_key = price2num($value_arr); - } - else - { + } else { if (!GETPOSTISSET($keysuffix."options_".$key.$keyprefix)) continue; // Value was not provided, we should not set it. $value_key = GETPOST($keysuffix."options_".$key.$keyprefix); } diff --git a/htdocs/core/class/extralanguages.class.php b/htdocs/core/class/extralanguages.class.php index 71a6fa8c1aa..17851b09a6d 100644 --- a/htdocs/core/class/extralanguages.class.php +++ b/htdocs/core/class/extralanguages.class.php @@ -18,7 +18,7 @@ /** * \file htdocs/core/class/extralanguages.class.php * \ingroup core - * \brief File of class to manage extra fields + * \brief File of class to manage extra languages for some fields */ @@ -69,7 +69,8 @@ class ExtraLanguages // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** - * Load array this->attributes with list of fields per object that need an alternate translation. + * Load array this->attributes with list of fields per object that need an alternate translation. The object and field must be managed with + * the widgetForTranslation() method. * You can set variable MAIN_USE_ALTERNATE_TRANSLATION_FOR=elementA:fieldname,fieldname2;elementB:... * Example: MAIN_USE_ALTERNATE_TRANSLATION_FOR=societe:name,town;contact:firstname,lastname * @@ -119,16 +120,16 @@ class ExtraLanguages * * @param string $key Key of attribute * @param string $value Preselected value to show (for date type it must be in timestamp format, for amount or price it must be a php numeric value) + * @param string $extrafieldsobjectkey If defined (for example $object->table_element), use the new method to get extrafields data * @param string $moreparam To add more parametes on html input tag * @param string $keysuffix Prefix string to add after name and id of field (can be used to avoid duplicate names) * @param string $keyprefix Suffix string to add before name and id of field (can be used to avoid duplicate names) * @param string $morecss More css (to defined size of field. Old behaviour: may also be a numeric) * @param int $objectid Current object id - * @param string $extrafieldsobjectkey If defined (for example $object->table_element), use the new method to get extrafields data * @param string $mode 1=Used for search filters * @return string */ - public function showInputField($key, $value, $moreparam = '', $keysuffix = '', $keyprefix = '', $morecss = '', $objectid = 0, $extrafieldsobjectkey = '', $mode = 0) + public function showInputField($key, $value, $extrafieldsobjectkey, $moreparam = '', $keysuffix = '', $keyprefix = '', $morecss = '', $objectid = 0, $mode = 0) { global $conf, $langs, $form; @@ -145,601 +146,6 @@ class ExtraLanguages $keyprefix = $keyprefix.'options_'; } - if (!empty($extrafieldsobjectkey)) - { - $label = $this->attributes[$extrafieldsobjectkey]['label'][$key]; - $type = $this->attributes[$extrafieldsobjectkey]['type'][$key]; - $size = $this->attributes[$extrafieldsobjectkey]['size'][$key]; - $default = $this->attributes[$extrafieldsobjectkey]['default'][$key]; - $computed = $this->attributes[$extrafieldsobjectkey]['computed'][$key]; - $unique = $this->attributes[$extrafieldsobjectkey]['unique'][$key]; - $required = $this->attributes[$extrafieldsobjectkey]['required'][$key]; - $param = $this->attributes[$extrafieldsobjectkey]['param'][$key]; - $perms = dol_eval($this->attributes[$extrafieldsobjectkey]['perms'][$key], 1); - $langfile = $this->attributes[$extrafieldsobjectkey]['langfile'][$key]; - $list = dol_eval($this->attributes[$extrafieldsobjectkey]['list'][$key], 1); - $totalizable = $this->attributes[$extrafieldsobjectkey]['totalizable'][$key]; - $help = $this->attributes[$extrafieldsobjectkey]['help'][$key]; - $hidden = (empty($list) ? 1 : 0); // If empty, we are sure it is hidden, otherwise we show. If it depends on mode (view/create/edit form or list, this must be filtered by caller) - } - else // Old usage - { - $label = $this->attribute_label[$key]; - $type = $this->attribute_type[$key]; - $size = $this->attribute_size[$key]; - $elementtype = $this->attribute_elementtype[$key]; // Seems not used - $default = $this->attribute_default[$key]; - $computed = $this->attribute_computed[$key]; - $unique = $this->attribute_unique[$key]; - $required = $this->attribute_required[$key]; - $param = $this->attribute_param[$key]; - $langfile = $this->attribute_langfile[$key]; - $list = $this->attribute_list[$key]; - $totalizable = $this->attribute_totalizable[$key]; - $hidden = (empty($list) ? 1 : 0); // If empty, we are sure it is hidden, otherwise we show. If it depends on mode (view/create/edit form or list, this must be filtered by caller) - } - - if ($computed) - { - if (!preg_match('/^search_/', $keyprefix)) return ''.$langs->trans("AutomaticallyCalculated").''; - else return ''; - } - - if (empty($morecss)) - { - if ($type == 'date') - { - $morecss = 'minwidth100imp'; - } - elseif ($type == 'datetime' || $type == 'link') - { - $morecss = 'minwidth200imp'; - } - elseif (in_array($type, array('int', 'integer', 'double', 'price'))) - { - $morecss = 'maxwidth75'; - } - elseif ($type == 'password') - { - $morecss = 'maxwidth100'; - } - elseif ($type == 'url') - { - $morecss = 'minwidth400'; - } - elseif ($type == 'boolean') - { - $morecss = ''; - } - else - { - if (round($size) < 12) - { - $morecss = 'minwidth100'; - } - elseif (round($size) <= 48) - { - $morecss = 'minwidth200'; - } - else - { - $morecss = 'minwidth400'; - } - } - } - - if (in_array($type, array('date', 'datetime'))) - { - $tmp = explode(',', $size); - $newsize = $tmp[0]; - - $showtime = in_array($type, array('datetime')) ? 1 : 0; - - // Do not show current date when field not required (see selectDate() method) - if (!$required && $value == '') $value = '-1'; - - // TODO Must also support $moreparam - $out = $form->selectDate($value, $keyprefix.$key.$keysuffix, $showtime, $showtime, $required, '', 1, (($keyprefix != 'search_' && $keyprefix != 'search_options_') ? 1 : 0), 0, 1); - } - elseif (in_array($type, array('int', 'integer'))) - { - $tmp = explode(',', $size); - $newsize = $tmp[0]; - $out = ''; - } - elseif (preg_match('/varchar/', $type)) - { - $out = ''; - } - elseif (in_array($type, array('mail', 'phone', 'url'))) - { - $out = ''; - } - elseif ($type == 'text') - { - if (!preg_match('/search_/', $keyprefix)) // If keyprefix is search_ or search_options_, we must just use a simple text field - { - require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; - $doleditor = new DolEditor($keyprefix.$key.$keysuffix, $value, '', 200, 'dolibarr_notes', 'In', false, false, false, ROWS_5, '90%'); - $out = $doleditor->Create(1); - } - else - { - $out = ''; - } - } - elseif ($type == 'html') - { - if (!preg_match('/search_/', $keyprefix)) // If keyprefix is search_ or search_options_, we must just use a simple text field - { - require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; - $doleditor = new DolEditor($keyprefix.$key.$keysuffix, $value, '', 200, 'dolibarr_notes', 'In', false, false, !empty($conf->fckeditor->enabled) && $conf->global->FCKEDITOR_ENABLE_SOCIETE, ROWS_5, '90%'); - $out = $doleditor->Create(1); - } - else - { - $out = ''; - } - } - elseif ($type == 'boolean') - { - if (empty($mode)) - { - $checked = ''; - if (!empty($value)) { - $checked = ' checked value="1" '; - } else { - $checked = ' value="1" '; - } - $out = ''; - } - else - { - $out .= $form->selectyesno($keyprefix.$key.$keysuffix, $value, 1, false, 1); - } - } - elseif ($type == 'price') - { - if (!empty($value)) { // $value in memory is a php numeric, we format it into user number format. - $value = price($value); - } - $out = ' '.$langs->getCurrencySymbol($conf->currency); - } - elseif ($type == 'double') - { - if (!empty($value)) { // $value in memory is a php numeric, we format it into user number format. - $value = price($value); - } - $out = ' '; - } - elseif ($type == 'select') - { - $out = ''; - if (!empty($conf->use_javascript_ajax) && !empty($conf->global->MAIN_EXTRAFIELDS_USE_SELECT2)) - { - include_once DOL_DOCUMENT_ROOT.'/core/lib/ajax.lib.php'; - $out .= ajax_combobox($keyprefix.$key.$keysuffix, array(), 0); - } - - $out .= ''; - } - elseif ($type == 'sellist') - { - $out = ''; - if (!empty($conf->use_javascript_ajax) && !empty($conf->global->MAIN_EXTRAFIELDS_USE_SELECT2)) - { - include_once DOL_DOCUMENT_ROOT.'/core/lib/ajax.lib.php'; - $out .= ajax_combobox($keyprefix.$key.$keysuffix, array(), 0); - } - - $out .= ''; - } - elseif ($type == 'checkbox') - { - $value_arr = explode(',', $value); - $out = $form->multiselectarray($keyprefix.$key.$keysuffix, (empty($param['options']) ?null:$param['options']), $value_arr, '', 0, '', 0, '100%'); - } - elseif ($type == 'radio') - { - $out = ''; - foreach ($param['options'] as $keyopt => $val) - { - $out .= ''.$val.'
'; - } - } - elseif ($type == 'chkbxlst') - { - if (is_array($value)) { - $value_arr = $value; - } - else { - $value_arr = explode(',', $value); - } - - if (is_array($param['options'])) { - $param_list = array_keys($param['options']); - $InfoFieldList = explode(":", $param_list[0]); - $parentName = ''; - $parentField = ''; - // 0 : tableName - // 1 : label field name - // 2 : key fields name (if differ of rowid) - // 3 : key field parent (for dependent lists) - // 4 : where clause filter on column or table extrafield, syntax field='value' or extra.field=value - // 5 : id category type - // 6 : ids categories list separated by comma for category root - $keyList = (empty($InfoFieldList[2]) ? 'rowid' : $InfoFieldList[2].' as rowid'); - - if (count($InfoFieldList) > 3 && !empty($InfoFieldList[3])) { - list ($parentName, $parentField) = explode('|', $InfoFieldList[3]); - $keyList .= ', '.$parentField; - } - if (count($InfoFieldList) > 4 && !empty($InfoFieldList[4])) { - if (strpos($InfoFieldList[4], 'extra.') !== false) { - $keyList = 'main.'.$InfoFieldList[2].' as rowid'; - } else { - $keyList = $InfoFieldList[2].' as rowid'; - } - } - - $filter_categorie = false; - if (count($InfoFieldList) > 5) { - if ($InfoFieldList[0] == 'categorie') { - $filter_categorie = true; - } - } - - if ($filter_categorie === false) { - $fields_label = explode('|', $InfoFieldList[1]); - if (is_array($fields_label)) { - $keyList .= ', '; - $keyList .= implode(', ', $fields_label); - } - - $sqlwhere = ''; - $sql = 'SELECT '.$keyList; - $sql .= ' FROM '.MAIN_DB_PREFIX.$InfoFieldList[0]; - if (!empty($InfoFieldList[4])) { - // can use SELECT request - if (strpos($InfoFieldList[4], '$SEL$') !== false) { - $InfoFieldList[4] = str_replace('$SEL$', 'SELECT', $InfoFieldList[4]); - } - - // current object id can be use into filter - if (strpos($InfoFieldList[4], '$ID$') !== false && !empty($objectid)) { - $InfoFieldList[4] = str_replace('$ID$', $objectid, $InfoFieldList[4]); - } elseif (preg_match("#^.*list.php$#", $_SERVER["PHP_SELF"])) { - // Pattern for word=$ID$ - $word = '\b[a-zA-Z0-9-\.-_]+\b=\$ID\$'; - - // Removing space arount =, ( and ) - $InfoFieldList[4] = preg_replace('# *(=|\(|\)) *#', '$1', $InfoFieldList[4]); - - $nbPreg = 1; - // While we have parenthesis - while ($nbPreg != 0) { - // Init des compteurs - $nbPregRepl = $nbPregSel = 0; - // On retire toutes les parenthèses sans = avant - $InfoFieldList[4] = preg_replace('#([^=])(\([^)^(]*('.$word.')[^)^(]*\))#', '$1 $3 ', $InfoFieldList[4], -1, $nbPregRepl); - // On retire les espaces autour des = et parenthèses - $InfoFieldList[4] = preg_replace('# *(=|\(|\)) *#', '$1', $InfoFieldList[4]); - // On retire toutes les parenthèses avec = avant - $InfoFieldList[4] = preg_replace('#\b[a-zA-Z0-9-\.-_]+\b=\([^)^(]*('.$word.')[^)^(]*\)#', '$1 ', $InfoFieldList[4], -1, $nbPregSel); - // On retire les espaces autour des = et parenthèses - $InfoFieldList[4] = preg_replace('# *(=|\(|\)) *#', '$1', $InfoFieldList[4]); - - // Calcul du compteur général pour la boucle - $nbPreg = $nbPregRepl + $nbPregSel; - } - - // Si l'on a un AND ou un OR, avant ou après - preg_match('#(AND|OR|) *('.$word.') *(AND|OR|)#', $InfoFieldList[4], $matchCondition); - while (!empty($matchCondition[0])) { - // If the two sides differ but are not empty - if (!empty($matchCondition[1]) && !empty($matchCondition[3]) && $matchCondition[1] != $matchCondition[3]) { - // Nobody sain would do that without parentheses - $InfoFieldList[4] = str_replace('$ID$', '0', $InfoFieldList[4]); - } else { - if (!empty($matchCondition[1])) { - $boolCond = (($matchCondition[1] == "AND") ? ' AND TRUE ' : ' OR FALSE '); - $InfoFieldList[4] = str_replace($matchCondition[0], $boolCond.$matchCondition[3], $InfoFieldList[4]); - } elseif (!empty($matchCondition[3])) { - $boolCond = (($matchCondition[3] == "AND") ? ' TRUE AND ' : ' FALSE OR'); - $InfoFieldList[4] = str_replace($matchCondition[0], $boolCond, $InfoFieldList[4]); - } else { - $InfoFieldList[4] = " TRUE "; - } - } - - // Si l'on a un AND ou un OR, avant ou après - preg_match('#(AND|OR|) *('.$word.') *(AND|OR|)#', $InfoFieldList[4], $matchCondition); - } - } else { - $InfoFieldList[4] = str_replace('$ID$', '0', $InfoFieldList[4]); - } - - // We have to join on extrafield table - if (strpos($InfoFieldList[4], 'extra.') !== false) { - $sql .= ' as main, '.MAIN_DB_PREFIX.$InfoFieldList[0].'_extrafields as extra'; - $sqlwhere .= ' WHERE extra.fk_object=main.'.$InfoFieldList[2].' AND '.$InfoFieldList[4]; - } else { - $sqlwhere .= ' WHERE '.$InfoFieldList[4]; - } - } else { - $sqlwhere .= ' WHERE 1=1'; - } - // Some tables may have field, some other not. For the moment we disable it. - if (in_array($InfoFieldList[0], array('tablewithentity'))) { - $sqlwhere .= ' AND entity = '.$conf->entity; - } - // $sql.=preg_replace('/^ AND /','',$sqlwhere); - // print $sql; - - $sql .= $sqlwhere; - dol_syslog(get_class($this).'::showInputField type=chkbxlst', LOG_DEBUG); - $resql = $this->db->query($sql); - if ($resql) { - $num = $this->db->num_rows($resql); - $i = 0; - - $data = array(); - - while ($i < $num) { - $labeltoshow = ''; - $obj = $this->db->fetch_object($resql); - - $notrans = false; - // Several field into label (eq table:code|libelle:rowid) - $fields_label = explode('|', $InfoFieldList[1]); - if (is_array($fields_label)) { - $notrans = true; - foreach ($fields_label as $field_toshow) { - $labeltoshow .= $obj->$field_toshow.' '; - } - } else { - $labeltoshow = $obj->{$InfoFieldList[1]}; - } - $labeltoshow = dol_trunc($labeltoshow, 45); - - if (is_array($value_arr) && in_array($obj->rowid, $value_arr)) { - foreach ($fields_label as $field_toshow) { - $translabel = $langs->trans($obj->$field_toshow); - if ($translabel != $obj->$field_toshow) { - $labeltoshow = dol_trunc($translabel, 18).' '; - } else { - $labeltoshow = dol_trunc($obj->$field_toshow, 18).' '; - } - } - - $data[$obj->rowid] = $labeltoshow; - } else { - if (!$notrans) { - $translabel = $langs->trans($obj->{$InfoFieldList[1]}); - if ($translabel != $obj->{$InfoFieldList[1]}) { - $labeltoshow = dol_trunc($translabel, 18); - } else { - $labeltoshow = dol_trunc($obj->{$InfoFieldList[1]}, 18); - } - } - if (empty($labeltoshow)) - $labeltoshow = '(not defined)'; - - if (is_array($value_arr) && in_array($obj->rowid, $value_arr)) { - $data[$obj->rowid] = $labeltoshow; - } - - if (!empty($InfoFieldList[3]) && $parentField) { - $parent = $parentName.':'.$obj->{$parentField}; - } - - $data[$obj->rowid] = $labeltoshow; - } - - $i++; - } - $this->db->free($resql); - - $out = $form->multiselectarray($keyprefix.$key.$keysuffix, $data, $value_arr, '', 0, '', 0, '100%'); - } else { - print 'Error in request '.$sql.' '.$this->db->lasterror().'. Check setup of extra parameters.
'; - } - } else { - require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; - $data = $form->select_all_categories(Categorie::$MAP_ID_TO_CODE[$InfoFieldList[5]], '', 'parent', 64, $InfoFieldList[6], 1, 1); - $out = $form->multiselectarray($keyprefix.$key.$keysuffix, $data, $value_arr, '', 0, '', 0, '100%'); - } - } - } - elseif ($type == 'link') - { - $param_list = array_keys($param['options']); // $param_list='ObjectName:classPath' - $showempty = (($required && $default != '') ? 0 : 1); - $out = $form->selectForForms($param_list[0], $keyprefix.$key.$keysuffix, $value, $showempty, '', '', $morecss); - } - elseif ($type == 'password') - { - // If prefix is 'search_', field is used as a filter, we use a common text field. - $out = ''; // Hidden field to reduce impact of evil Google Chrome autopopulate bug. - $out .= ''; - } - if (!empty($hidden)) { - $out = ''; - } - /* Add comments - if ($type == 'date') $out.=' (YYYY-MM-DD)'; - elseif ($type == 'datetime') $out.=' (YYYY-MM-DD HH:MM:SS)'; - */ - /*if (! empty($help) && $keyprefix != 'search_options_') { - $out .= $form->textwithpicto('', $help, 1, 'help', '', 0, 3); - }*/ return $out; } @@ -749,601 +155,16 @@ class ExtraLanguages * * @param string $key Key of attribute * @param string $value Value to show - * @param string $moreparam To add more parameters on html input tag (only checkbox use html input for output rendering) * @param string $extrafieldsobjectkey If defined (for example $object->table_element), function uses the new method to get extrafields data + * @param string $moreparam To add more parameters on html input tag (only checkbox use html input for output rendering) * @return string Formated value */ - public function showOutputField($key, $value, $moreparam = '', $extrafieldsobjectkey = '') + public function showOutputField($key, $value, $extrafieldsobjectkey, $moreparam = '') { global $conf, $langs; - if (!empty($extrafieldsobjectkey)) - { - $label = $this->attributes[$extrafieldsobjectkey]['label'][$key]; - $type = $this->attributes[$extrafieldsobjectkey]['type'][$key]; - $size = $this->attributes[$extrafieldsobjectkey]['size'][$key]; - $default = $this->attributes[$extrafieldsobjectkey]['default'][$key]; - $computed = $this->attributes[$extrafieldsobjectkey]['computed'][$key]; - $unique = $this->attributes[$extrafieldsobjectkey]['unique'][$key]; - $required = $this->attributes[$extrafieldsobjectkey]['required'][$key]; - $param = $this->attributes[$extrafieldsobjectkey]['param'][$key]; - $perms = dol_eval($this->attributes[$extrafieldsobjectkey]['perms'][$key], 1); - $langfile = $this->attributes[$extrafieldsobjectkey]['langfile'][$key]; - $list = dol_eval($this->attributes[$extrafieldsobjectkey]['list'][$key], 1); - $help = $this->attributes[$extrafieldsobjectkey]['help'][$key]; - $hidden = (empty($list) ? 1 : 0); // If $list empty, we are sure it is hidden, otherwise we show. If it depends on mode (view/create/edit form or list, this must be filtered by caller) - } - else // Old usage - { - //dol_syslog("Warning: parameter 'extrafieldsobjectkey' is missing", LOG_WARNING); - $label = $this->attribute_label[$key]; - $type = $this->attribute_type[$key]; - $size = $this->attribute_size[$key]; - $default = $this->attribute_default[$key]; - $computed = $this->attribute_computed[$key]; - $unique = $this->attribute_unique[$key]; - $required = $this->attribute_required[$key]; - $param = $this->attribute_param[$key]; - $perms = dol_eval($this->attribute_perms[$key], 1); - $langfile = $this->attribute_langfile[$key]; - $list = dol_eval($this->attribute_list[$key], 1); - $help = ''; // Not supported with old syntax - $hidden = (empty($list) ? 1 : 0); // If $list empty, we are sure it is hidden, otherwise we show. If it depends on mode (view/create/edit form or list, this must be filtered by caller) - } - - if ($hidden) return ''; // This is a protection. If field is hidden, we should just not call this method. - - //if ($computed) $value = // $value is already calculated into $value before calling this method - - $showsize = 0; - if ($type == 'date') - { - $showsize = 10; - $value = dol_print_date($value, 'day'); - } - elseif ($type == 'datetime') - { - $showsize = 19; - $value = dol_print_date($value, 'dayhour'); - } - elseif ($type == 'int') - { - $showsize = 10; - } - elseif ($type == 'double') - { - if (!empty($value)) { - //$value=price($value); - $sizeparts = explode(",", $size); - $number_decimals = $sizeparts[1]; - $value = price($value, 0, $langs, 0, 0, $number_decimals, ''); - } - } - elseif ($type == 'boolean') - { - $checked = ''; - if (!empty($value)) { - $checked = ' checked '; - } - $value = ''; - } - elseif ($type == 'mail') - { - $value = dol_print_email($value, 0, 0, 0, 64, 1, 1); - } - elseif ($type == 'url') - { - $value = dol_print_url($value, '_blank', 32, 1); - } - elseif ($type == 'phone') - { - $value = dol_print_phone($value, '', 0, 0, '', ' ', 'phone'); - } - elseif ($type == 'price') - { - $value = price($value, 0, $langs, 0, 0, -1, $conf->currency); - } - elseif ($type == 'select') - { - if ($langfile && $param['options'][$value]) $value = $langs->trans($param['options'][$value]); - else $value = $param['options'][$value]; - } - elseif ($type == 'sellist') - { - $param_list = array_keys($param['options']); - $InfoFieldList = explode(":", $param_list[0]); - - $selectkey = "rowid"; - $keyList = 'rowid'; - - if (count($InfoFieldList) >= 3) - { - $selectkey = $InfoFieldList[2]; - $keyList = $InfoFieldList[2].' as rowid'; - } - - $fields_label = explode('|', $InfoFieldList[1]); - if (is_array($fields_label)) { - $keyList .= ', '; - $keyList .= implode(', ', $fields_label); - } - - $sql = 'SELECT '.$keyList; - $sql .= ' FROM '.MAIN_DB_PREFIX.$InfoFieldList[0]; - if (strpos($InfoFieldList[4], 'extra') !== false) - { - $sql .= ' as main'; - } - if ($selectkey == 'rowid' && empty($value)) { - $sql .= " WHERE ".$selectkey."=0"; - } elseif ($selectkey == 'rowid') { - $sql .= " WHERE ".$selectkey."=".$this->db->escape($value); - } else { - $sql .= " WHERE ".$selectkey."='".$this->db->escape($value)."'"; - } - - //$sql.= ' AND entity = '.$conf->entity; - - dol_syslog(get_class($this).':showOutputField:$type=sellist', LOG_DEBUG); - $resql = $this->db->query($sql); - if ($resql) - { - $value = ''; // value was used, so now we reste it to use it to build final output - - $obj = $this->db->fetch_object($resql); - - // Several field into label (eq table:code|libelle:rowid) - $fields_label = explode('|', $InfoFieldList[1]); - - if (is_array($fields_label) && count($fields_label) > 1) - { - foreach ($fields_label as $field_toshow) - { - $translabel = ''; - if (!empty($obj->$field_toshow)) { - $translabel = $langs->trans($obj->$field_toshow); - } - if ($translabel != $field_toshow) { - $value .= dol_trunc($translabel, 18).' '; - } else { - $value .= $obj->$field_toshow.' '; - } - } - } - else - { - $translabel = ''; - if (!empty($obj->{$InfoFieldList[1]})) { - $translabel = $langs->trans($obj->{$InfoFieldList[1]}); - } - if ($translabel != $obj->{$InfoFieldList[1]}) { - $value = dol_trunc($translabel, 18); - } else { - $value = $obj->{$InfoFieldList[1]}; - } - } - } - else dol_syslog(get_class($this).'::showOutputField error '.$this->db->lasterror(), LOG_WARNING); - } - elseif ($type == 'radio') - { - $value = $param['options'][$value]; - } - elseif ($type == 'checkbox') - { - $value_arr = explode(',', $value); - $value = ''; - $toprint = array(); - if (is_array($value_arr)) - { - foreach ($value_arr as $keyval=>$valueval) { - $toprint[] = '
  • '.$param['options'][$valueval].'
  • '; - } - } - $value = '
      '.implode(' ', $toprint).'
    '; - } - elseif ($type == 'chkbxlst') - { - $value_arr = explode(',', $value); - - $param_list = array_keys($param['options']); - $InfoFieldList = explode(":", $param_list[0]); - - $selectkey = "rowid"; - $keyList = 'rowid'; - - if (count($InfoFieldList) >= 3) { - $selectkey = $InfoFieldList[2]; - $keyList = $InfoFieldList[2].' as rowid'; - } - - $fields_label = explode('|', $InfoFieldList[1]); - if (is_array($fields_label)) { - $keyList .= ', '; - $keyList .= implode(', ', $fields_label); - } - - $sql = 'SELECT '.$keyList; - $sql .= ' FROM '.MAIN_DB_PREFIX.$InfoFieldList[0]; - if (strpos($InfoFieldList[4], 'extra') !== false) { - $sql .= ' as main'; - } - // $sql.= " WHERE ".$selectkey."='".$this->db->escape($value)."'"; - // $sql.= ' AND entity = '.$conf->entity; - - dol_syslog(get_class($this).':showOutputField:$type=chkbxlst', LOG_DEBUG); - $resql = $this->db->query($sql); - if ($resql) { - $value = ''; // value was used, so now we reste it to use it to build final output - $toprint = array(); - while ($obj = $this->db->fetch_object($resql)) { - // Several field into label (eq table:code|libelle:rowid) - $fields_label = explode('|', $InfoFieldList[1]); - if (is_array($value_arr) && in_array($obj->rowid, $value_arr)) { - if (is_array($fields_label) && count($fields_label) > 1) { - foreach ($fields_label as $field_toshow) { - $translabel = ''; - if (!empty($obj->$field_toshow)) { - $translabel = $langs->trans($obj->$field_toshow); - } - if ($translabel != $field_toshow) { - $toprint[] = '
  • '.dol_trunc($translabel, 18).'
  • '; - } else { - $toprint[] = '
  • '.$obj->$field_toshow.'
  • '; - } - } - } else { - $translabel = ''; - if (!empty($obj->{$InfoFieldList[1]})) { - $translabel = $langs->trans($obj->{$InfoFieldList[1]}); - } - if ($translabel != $obj->{$InfoFieldList[1]}) { - $toprint[] = '
  • '.dol_trunc($translabel, 18).'
  • '; - } else { - $toprint[] = '
  • '.$obj->{$InfoFieldList[1]}.'
  • '; - } - } - } - } - $value = '
      '.implode(' ', $toprint).'
    '; - } else { - dol_syslog(get_class($this).'::showOutputField error '.$this->db->lasterror(), LOG_WARNING); - } - } - elseif ($type == 'link') - { - $out = ''; - - // Only if something to display (perf) - if ($value) // If we have -1 here, pb is into insert, not into ouptut (fix insert instead of changing code here to compensate) - { - $param_list = array_keys($param['options']); // $param_list='ObjectName:classPath' - - $InfoFieldList = explode(":", $param_list[0]); - $classname = $InfoFieldList[0]; - $classpath = $InfoFieldList[1]; - if (!empty($classpath)) - { - dol_include_once($InfoFieldList[1]); - if ($classname && class_exists($classname)) - { - $object = new $classname($this->db); - $object->fetch($value); - $value = $object->getNomUrl(3); - } - } - else - { - dol_syslog('Error bad setup of extrafield', LOG_WARNING); - return 'Error bad setup of extrafield'; - } - } - } - elseif ($type == 'text') - { - $value = dol_htmlentitiesbr($value); - } - elseif ($type == 'html') - { - $value = dol_htmlentitiesbr($value); - } - elseif ($type == 'password') - { - $value = dol_trunc(preg_replace('/./i', '*', $value), 8, 'right', 'UTF-8', 1); - } - else - { - $showsize = round($size); - if ($showsize > 48) $showsize = 48; - } - - //print $type.'-'.$size; - $out = $value; + $out = $this->attributes[$extrafieldsobjectkey][$key]; return $out; } - - /** - * Return tag to describe alignement to use for this extrafield - * - * @param string $key Key of attribute - * @param string $extrafieldsobjectkey If defined, use the new method to get extrafields data - * @return string Formated value - */ - public function getAlignFlag($key, $extrafieldsobjectkey = '') - { - global $conf, $langs; - - if (!empty($extrafieldsobjectkey)) $type = $this->attributes[$extrafieldsobjectkey]['type'][$key]; - else $type = $this->attribute_type[$key]; - - $align = ''; - - if ($type == 'date') - { - $align = "center"; - } - elseif ($type == 'datetime') - { - $align = "center"; - } - elseif ($type == 'int') - { - $align = "right"; - } - elseif ($type == 'price') - { - $align = "right"; - } - elseif ($type == 'double') - { - $align = "right"; - } - elseif ($type == 'boolean') - { - $align = "center"; - } - elseif ($type == 'radio') - { - $align = "center"; - } - elseif ($type == 'checkbox') - { - $align = "center"; - } - elseif ($type == 'price') - { - $align = "right"; - } - - return $align; - } - - /** - * Return HTML string to print separator extrafield - * - * @param string $key Key of attribute - * @param string $object Object - * @param int $colspan Value of colspan to use (it must includes the first column with title) - * @return string HTML code with line for separator - */ - public function showSeparator($key, $object, $colspan = 2) - { - global $langs; - - $out = ''; - $out .= $langs->trans($this->attributes[$object->table_element]['label'][$key]); - $out .= ''; - - $extrafield_param = $this->attributes[$object->table_element]['param'][$key]; - if (!empty($extrafield_param) && is_array($extrafield_param)) { - $extrafield_param_list = array_keys($extrafield_param['options']); - - if (count($extrafield_param_list) > 0) { - $extrafield_collapse_display_value = intval($extrafield_param_list[0]); - if ($extrafield_collapse_display_value == 1 || $extrafield_collapse_display_value == 2) { - // Set the collapse_display status to cookie in priority or if ignorecollapsesetup is 1, if cookie and ignorecollapsesetup not defined, use the setup. - $collapse_display = ((isset($_COOKIE['DOLCOLLAPSE_'.$object->table_element.'_extrafields_'.$key]) || GETPOST('ignorecollapsesetup', 'int')) ? ($_COOKIE['DOLCOLLAPSE_'.$object->table_element.'_extrafields_'.$key] ? true : false) : ($extrafield_collapse_display_value == 2 ? false : true)); - $extrafields_collapse_num = $this->attributes[$object->table_element]['pos'][$key]; - - $out .= ''; - $out .= ''; - } - } - } - - return $out; - } - - /** - * Fill array_options property of object by extrafields value (using for data sent by forms) - * - * @param array $extralabels Deprecated (old $array of extrafields, now set this to null) - * @param object $object Object - * @param string $onlykey Only the following key is filled. When we make update of only one extrafield ($action = 'update_extras'), calling page must set this to avoid to have other extrafields being reset. - * @return int 1 if array_options set, 0 if no value, -1 if error (field required missing for example) - */ - public function setOptionalsFromPost($extralabels, &$object, $onlykey = '') - { - global $_POST, $langs; - - $nofillrequired = 0; // For error when required field left blank - $error_field_required = array(); - - if (is_array($this->attributes[$object->table_element]['label'])) $extralabels = $this->attributes[$object->table_element]['label']; - - if (is_array($extralabels)) - { - // Get extra fields - foreach ($extralabels as $key => $value) - { - if (!empty($onlykey) && $key != $onlykey) continue; - - $key_type = $this->attributes[$object->table_element]['type'][$key]; - if ($key_type == 'separate') continue; - - $enabled = 1; - if (isset($this->attributes[$object->table_element]['list'][$key])) - { - $enabled = dol_eval($this->attributes[$object->table_element]['list'][$key], 1); - } - $perms = 1; - if (isset($this->attributes[$object->table_element]['perms'][$key])) - { - $perms = dol_eval($this->attributes[$object->table_element]['perms'][$key], 1); - } - if (empty($enabled)) continue; - if (empty($perms)) continue; - - if ($this->attributes[$object->table_element]['required'][$key]) // Value is required - { - // Check if empty without using GETPOST, value can be alpha, int, array, etc... - if ((!is_array($_POST["options_".$key]) && empty($_POST["options_".$key]) && $this->attributes[$object->table_element]['type'][$key] != 'select' && $_POST["options_".$key] != '0') - || (!is_array($_POST["options_".$key]) && empty($_POST["options_".$key]) && $this->attributes[$object->table_element]['type'][$key] == 'select') - || (is_array($_POST["options_".$key]) && empty($_POST["options_".$key]))) - { - //print 'ccc'.$value.'-'.$this->attributes[$object->table_element]['required'][$key]; - $nofillrequired++; - $error_field_required[] = $langs->transnoentitiesnoconv($value); - } - } - - if (in_array($key_type, array('date'))) - { - // Clean parameters - // TODO GMT date in memory must be GMT so we should add gm=true in parameters - $value_key = dol_mktime(0, 0, 0, $_POST["options_".$key."month"], $_POST["options_".$key."day"], $_POST["options_".$key."year"]); - } - elseif (in_array($key_type, array('datetime'))) - { - // Clean parameters - // TODO GMT date in memory must be GMT so we should add gm=true in parameters - $value_key = dol_mktime($_POST["options_".$key."hour"], $_POST["options_".$key."min"], 0, $_POST["options_".$key."month"], $_POST["options_".$key."day"], $_POST["options_".$key."year"]); - } - elseif (in_array($key_type, array('checkbox', 'chkbxlst'))) - { - $value_arr = GETPOST("options_".$key, 'array'); // check if an array - if (!empty($value_arr)) { - $value_key = implode($value_arr, ','); - } else { - $value_key = ''; - } - } - elseif (in_array($key_type, array('price', 'double'))) - { - $value_arr = GETPOST("options_".$key, 'alpha'); - $value_key = price2num($value_arr); - } - else - { - $value_key = GETPOST("options_".$key); - if (in_array($key_type, array('link')) && $value_key == '-1') $value_key = ''; - } - - $object->array_options["options_".$key] = $value_key; - } - - if ($nofillrequired) { - $langs->load('errors'); - setEventMessages($langs->trans('ErrorFieldsRequired').' : '.implode(', ', $error_field_required), null, 'errors'); - return -1; - } - else { - return 1; - } - } - else { - return 0; - } - } - - /** - * return array_options array of data of extrafields value of object sent by a search form - * - * @param array|string $extrafieldsobjectkey array of extrafields (old usage) or value of object->table_element (new usage) - * @param string $keyprefix Prefix string to add into name and id of field (can be used to avoid duplicate names) - * @param string $keysuffix Suffix string to add into name and id of field (can be used to avoid duplicate names) - * @return array|int array_options set or 0 if no value - */ - public function getOptionalsFromPost($extrafieldsobjectkey, $keyprefix = '', $keysuffix = '') - { - global $_POST; - - if (is_string($extrafieldsobjectkey) && is_array($this->attributes[$extrafieldsobjectkey]['label'])) - { - $extralabels = $this->attributes[$extrafieldsobjectkey]['label']; - } - else - { - $extralabels = $extrafieldsobjectkey; - } - - if (is_array($extralabels)) - { - $array_options = array(); - - // Get extra fields - foreach ($extralabels as $key => $value) - { - $key_type = ''; - if (is_string($extrafieldsobjectkey)) - { - $key_type = $this->attributes[$extrafieldsobjectkey]['type'][$key]; - } - - if (in_array($key_type, array('date', 'datetime'))) - { - if (!GETPOSTISSET($keysuffix."options_".$key.$keyprefix."year")) continue; // Value was not provided, we should not set it. - // Clean parameters - $value_key = dol_mktime(GETPOST($keysuffix."options_".$key.$keyprefix."hour", 'int'), GETPOST($keysuffix."options_".$key.$keyprefix."min", 'int'), 0, GETPOST($keysuffix."options_".$key.$keyprefix."month", 'int'), GETPOST($keysuffix."options_".$key.$keyprefix."day", 'int'), GETPOST($keysuffix."options_".$key.$keyprefix."year", 'int')); - } - elseif (in_array($key_type, array('checkbox', 'chkbxlst'))) - { - if (!GETPOSTISSET($keysuffix."options_".$key.$keyprefix)) continue; // Value was not provided, we should not set it. - $value_arr = GETPOST($keysuffix."options_".$key.$keyprefix); - // Make sure we get an array even if there's only one checkbox - $value_arr = (array) $value_arr; - $value_key = implode(',', $value_arr); - } - elseif (in_array($key_type, array('price', 'double', 'int'))) - { - if (!GETPOSTISSET($keysuffix."options_".$key.$keyprefix)) continue; // Value was not provided, we should not set it. - $value_arr = GETPOST($keysuffix."options_".$key.$keyprefix); - $value_key = price2num($value_arr); - } - else - { - if (!GETPOSTISSET($keysuffix."options_".$key.$keyprefix)) continue; // Value was not provided, we should not set it. - $value_key = GETPOST($keysuffix."options_".$key.$keyprefix); - } - - $array_options[$keysuffix."options_".$key] = $value_key; // No keyprefix here. keyprefix is used only for read. - } - - return $array_options; - } - - return 0; - } } diff --git a/htdocs/core/class/fileupload.class.php b/htdocs/core/class/fileupload.class.php index c9bb7372bd2..c941a3a0745 100644 --- a/htdocs/core/class/fileupload.class.php +++ b/htdocs/core/class/fileupload.class.php @@ -64,46 +64,36 @@ class FileUpload if ($element == 'propal') { $pathname = 'comm/propal'; $dir_output = $conf->$element->dir_output; - } - elseif ($element == 'facture') { + } elseif ($element == 'facture') { $pathname = 'compta/facture'; $dir_output = $conf->$element->dir_output; - } - elseif ($element == 'project') { + } elseif ($element == 'project') { $element = $pathname = 'projet'; $dir_output = $conf->$element->dir_output; - } - elseif ($element == 'project_task') { + } elseif ($element == 'project_task') { $pathname = 'projet'; $filename = 'task'; $dir_output = $conf->projet->dir_output; $parentForeignKey = 'fk_project'; $parentClass = 'Project'; $parentElement = 'projet'; $parentObject = 'project'; - } - elseif ($element == 'fichinter') { + } elseif ($element == 'fichinter') { $element = 'ficheinter'; $dir_output = $conf->$element->dir_output; - } - elseif ($element == 'order_supplier') { + } elseif ($element == 'order_supplier') { $pathname = 'fourn'; $filename = 'fournisseur.commande'; $dir_output = $conf->fournisseur->commande->dir_output; - } - elseif ($element == 'invoice_supplier') { + } elseif ($element == 'invoice_supplier') { $pathname = 'fourn'; $filename = 'fournisseur.facture'; $dir_output = $conf->fournisseur->facture->dir_output; - } - elseif ($element == 'product') { + } elseif ($element == 'product') { $dir_output = $conf->product->multidir_output[$conf->entity]; - } - elseif ($element == 'productbatch') { + } elseif ($element == 'productbatch') { $dir_output = $conf->productbatch->multidir_output[$conf->entity]; - } - elseif ($element == 'action') { + } elseif ($element == 'action') { $pathname = 'comm/action'; $filename = 'actioncomm'; $dir_output = $conf->agenda->dir_output; - } - elseif ($element == 'chargesociales') { + } elseif ($element == 'chargesociales') { $pathname = 'compta/sociales'; $filename = 'chargesociales'; $dir_output = $conf->tax->dir_output; } else { @@ -298,9 +288,7 @@ class FileUpload if (preg_match('/error/i', $res)) return false; return true; - } - else - { + } else { return false; } } @@ -451,9 +439,7 @@ class FileUpload } else { dol_move_uploaded_file($uploaded_file, $file_path, 1, 0, 0, 0, 'userfile'); } - } - else - { + } else { // Non-multipart uploads (PUT method support) file_put_contents($file_path, fopen('php://input', 'r'), $append_file ? FILE_APPEND : 0); } @@ -469,8 +455,7 @@ class FileUpload $file->{$version.'_url'} = $options['upload_url'].rawurlencode($tmp[0].'_mini.'.$tmp[1]); } } - } - elseif ($this->options['discard_aborted_uploads']) + } elseif ($this->options['discard_aborted_uploads']) { unlink($file_path); $file->error = 'abort'; @@ -493,9 +478,7 @@ class FileUpload if ($file_name) { $info = $this->getFileObject($file_name); - } - else - { + } else { $info = $this->getFileObjects(); } header('Content-type: application/json'); diff --git a/htdocs/core/class/fiscalyear.class.php b/htdocs/core/class/fiscalyear.class.php index 514782593d9..0686b68115a 100644 --- a/htdocs/core/class/fiscalyear.class.php +++ b/htdocs/core/class/fiscalyear.class.php @@ -157,16 +157,12 @@ class Fiscalyear extends CommonObject { $this->db->commit(); return $this->id; - } - else - { + } else { $this->error = $this->db->lasterror(); $this->db->rollback(); return $result; } - } - else - { + } else { $this->error = $this->db->lasterror()." sql=".$sql; $this->db->rollback(); return -1; @@ -206,9 +202,7 @@ class Fiscalyear extends CommonObject { $this->db->commit(); return 1; - } - else - { + } else { $this->error = $this->db->lasterror(); dol_syslog($this->error, LOG_ERR); $this->db->rollback(); @@ -242,9 +236,7 @@ class Fiscalyear extends CommonObject $this->statut = $obj->statut; return 1; - } - else - { + } else { $this->error = $this->db->lasterror(); return -1; } @@ -268,9 +260,7 @@ class Fiscalyear extends CommonObject { $this->db->commit(); return 1; - } - else - { + } else { $this->error = $this->db->lasterror(); $this->db->rollback(); return -1; @@ -304,27 +294,22 @@ class Fiscalyear extends CommonObject if ($mode == 0) { return $langs->trans($this->statuts[$status]); - } - elseif ($mode == 1) + } elseif ($mode == 1) { return $langs->trans($this->statuts_short[$status]); - } - elseif ($mode == 2) + } elseif ($mode == 2) { if ($status == 0) return img_picto($langs->trans($this->statuts_short[$status]), 'statut4').' '.$langs->trans($this->statuts_short[$status]); elseif ($status == 1) return img_picto($langs->trans($this->statuts_short[$status]), 'statut8').' '.$langs->trans($this->statuts_short[$status]); - } - elseif ($mode == 3) + } elseif ($mode == 3) { if ($status == 0 && !empty($this->statuts_short[$status])) return img_picto($langs->trans($this->statuts_short[$status]), 'statut4'); elseif ($status == 1 && !empty($this->statuts_short[$status])) return img_picto($langs->trans($this->statuts_short[$status]), 'statut8'); - } - elseif ($mode == 4) + } elseif ($mode == 4) { if ($status == 0 && !empty($this->statuts_short[$status])) return img_picto($langs->trans($this->statuts_short[$status]), 'statut4').' '.$langs->trans($this->statuts[$status]); elseif ($status == 1 && !empty($this->statuts_short[$status])) return img_picto($langs->trans($this->statuts_short[$status]), 'statut8').' '.$langs->trans($this->statuts[$status]); - } - elseif ($mode == 5) + } elseif ($mode == 5) { if ($status == 0 && !empty($this->statuts_short[$status])) return $langs->trans($this->statuts_short[$status]).' '.img_picto($langs->trans($this->statuts_short[$status]), 'statut4'); elseif ($status == 1 && !empty($this->statuts_short[$status])) return $langs->trans($this->statuts_short[$status]).' '.img_picto($langs->trans($this->statuts_short[$status]), 'statut6'); @@ -369,9 +354,7 @@ class Fiscalyear extends CommonObject $this->date_modification = $this->db->jdate($obj->tms); } $this->db->free($result); - } - else - { + } else { dol_print_error($this->db); } } @@ -402,8 +385,7 @@ class Fiscalyear extends CommonObject { $obj = $this->db->fetch_object($resql); $nb = $obj->nb; - } - else dol_print_error($this->db); + } else dol_print_error($this->db); return $nb; } @@ -434,8 +416,7 @@ class Fiscalyear extends CommonObject { $obj = $this->db->fetch_object($resql); $nb = $obj->nb; - } - else dol_print_error($this->db); + } else dol_print_error($this->db); return $nb; } diff --git a/htdocs/core/class/hookmanager.class.php b/htdocs/core/class/hookmanager.class.php index e24bce5e247..97c45e2f926 100644 --- a/htdocs/core/class/hookmanager.class.php +++ b/htdocs/core/class/hookmanager.class.php @@ -266,8 +266,7 @@ class HookManager if (!empty($actionclassinstance->resprints)) $this->resPrint .= $actionclassinstance->resprints; } // Generic hooks that return a string or array (printLeftBlock, formAddObjectLine, formBuilddocOptions, ...) - else - { + else { // TODO. this test should be done into the method of hook by returning nothing if (is_array($parameters) && !empty($parameters['special_code']) && $parameters['special_code'] > 3 && $parameters['special_code'] != $actionclassinstance->module_number) continue; diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index f48ce989a7a..2a5bb0acbca 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -124,9 +124,7 @@ class Form } if ($fieldrequired) $ret .= ''; $ret .= ''."\n"; - } - else - { + } else { if ($fieldrequired) $ret .= ''; if ($help) { $ret .= $this->textwithpicto($langs->trans($text), $help); @@ -135,9 +133,7 @@ class Form } if ($fieldrequired) $ret .= ''; } - } - else - { + } else { if (empty($notabletag) && GETPOST('action', 'aZ09') != 'edit'.$htmlname && $perm) $ret .= '
    '; if ($fieldrequired) $ret .= ''; if ($help) { @@ -190,9 +186,7 @@ class Form if (!empty($conf->global->MAIN_USE_JQUERY_JEDITABLE) && !preg_match('/^select;|datehourpicker/', $typeofdata)) // TODO add jquery timepicker and support select { $ret .= $this->editInPlace($object, $value, $htmlname, $perm, $typeofdata, $editvalue, $extObject, $custommsg); - } - else - { + } else { if (GETPOST('action', 'aZ09') == 'edit'.$htmlname) { $ret .= "\n"; @@ -206,14 +200,12 @@ class Form { $tmp = explode(':', $typeofdata); $ret .= ''; - } - elseif (preg_match('/^(numeric|amount)/', $typeofdata)) + } elseif (preg_match('/^(numeric|amount)/', $typeofdata)) { $tmp = explode(':', $typeofdata); $valuetoshow = price2num($editvalue ? $editvalue : $value); $ret .= ''; - } - elseif (preg_match('/^text/', $typeofdata) || preg_match('/^note/', $typeofdata)) // if wysiwyg is enabled $typeofdata = 'ckeditor' + } elseif (preg_match('/^text/', $typeofdata) || preg_match('/^note/', $typeofdata)) // if wysiwyg is enabled $typeofdata = 'ckeditor' { $tmp = explode(':', $typeofdata); $cols = $tmp[2]; @@ -231,16 +223,13 @@ class Form $valuetoshow = str_replace('&', '&', $valuetoshow); $ret .= dol_string_neverthesehtmltags($valuetoshow, array('textarea')); $ret .= ''; - } - elseif ($typeofdata == 'day' || $typeofdata == 'datepicker') + } elseif ($typeofdata == 'day' || $typeofdata == 'datepicker') { $ret .= $this->selectDate($value, $htmlname, 0, 0, 1, 'form'.$htmlname, 1, 0); - } - elseif ($typeofdata == 'dayhour' || $typeofdata == 'datehourpicker') + } elseif ($typeofdata == 'dayhour' || $typeofdata == 'datehourpicker') { $ret .= $this->selectDate($value, $htmlname, 1, 1, 1, 'form'.$htmlname, 1, 0); - } - elseif (preg_match('/^select;/', $typeofdata)) + } elseif (preg_match('/^select;/', $typeofdata)) { $arraydata = explode(',', preg_replace('/^select;/', '', $typeofdata)); $arraylist = array(); @@ -251,8 +240,7 @@ class Form $arraylist[$tmpkey] = $tmp[1]; } $ret .= $this->selectarray($htmlname, $arraylist, $value); - } - elseif (preg_match('/^ckeditor/', $typeofdata)) + } elseif (preg_match('/^ckeditor/', $typeofdata)) { $tmp = explode(':', $typeofdata); // Example: ckeditor:dolibarr_zzz:width:height:savemethod:toolbarstartexpanded:rows:cols:uselocalbrowser require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; @@ -270,9 +258,7 @@ class Form if (empty($notabletag)) $ret .= '
    '."\n"; $ret .= ''."\n"; - } - else - { + } else { if (preg_match('/^(email)/', $typeofdata)) $ret .= dol_print_email($value, 0, 0, 0, 0, 1); elseif (preg_match('/^(amount|numeric)/', $typeofdata)) $ret .= ($value != '' ? price($value, '', $langs, 0, -1, -1, $conf->currency) : ''); elseif (preg_match('/^text/', $typeofdata) || preg_match('/^note/', $typeofdata)) $ret .= dol_htmlentitiesbr($value); @@ -289,8 +275,7 @@ class Form $arraylist[$tmp[0]] = $tmp[1]; } $ret .= $arraylist[$value]; - } - elseif (preg_match('/^ckeditor/', $typeofdata)) + } elseif (preg_match('/^ckeditor/', $typeofdata)) { $tmpcontent = dol_htmlentitiesbr($value); if (!empty($conf->global->MAIN_DISABLE_NOTES_TAB)) @@ -302,8 +287,7 @@ class Form // We dont use dol_escape_htmltag to get the html formating active, but this need we must also // clean data from some dangerous html $ret .= dol_string_onlythesehtmltags(dol_htmlentitiesbr($tmpcontent)); - } - else { + } else { $ret .= dol_escape_htmltag($value); } @@ -368,6 +352,8 @@ class Form $s = picto_from_langcode($langcode, 'class="pictoforlang paddingright"'); $resultforextrlang .= $s; + + // TODO Use the showInputField() method of ExtraLanguages object if ($typeofdata == 'textarea') { $resultforextrlang .= ''; print '
    '.$langs->trans("SmsInfoCharRemain").': '.(160 - dol_strlen($defaultmessage)).'
    '; } diff --git a/htdocs/core/class/html.formsocialcontrib.class.php b/htdocs/core/class/html.formsocialcontrib.class.php index 5ecef635d73..c6d28a7b70f 100644 --- a/htdocs/core/class/html.formsocialcontrib.class.php +++ b/htdocs/core/class/html.formsocialcontrib.class.php @@ -79,9 +79,7 @@ class FormSocialContrib $sql .= " WHERE c.active = 1"; $sql .= " AND c.fk_pays = ".$mysoc->country_id; $sql .= " ORDER BY c.libelle ASC"; - } - else - { + } else { $sql = "SELECT c.id, c.libelle as type"; $sql .= " FROM ".MAIN_DB_PREFIX."c_chargesociales as c, ".MAIN_DB_PREFIX."c_country as co"; $sql .= " WHERE c.active = 1 AND c.fk_pays = co.rowid"; @@ -111,14 +109,10 @@ class FormSocialContrib print ''; if ($user->admin && $help) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); if (!empty($conf->use_javascript_ajax)) print ajax_combobox($htmlname); - } - else - { + } else { print $langs->trans("ErrorNoSocialContributionForSellerCountry", $mysoc->country_code); } - } - else - { + } else { dol_print_error($db, $db->lasterror()); } } diff --git a/htdocs/core/class/html.formticket.class.php b/htdocs/core/class/html.formticket.class.php index da41a02491b..a8654f6bfc5 100644 --- a/htdocs/core/class/html.formticket.class.php +++ b/htdocs/core/class/html.formticket.class.php @@ -175,7 +175,7 @@ class FormTicket print ''; } - // Si origin du ticket + // If ticket created from another object if (isset($this->param['origin']) && $this->param['originid'] > 0) { // Parse element/subelement (ex: project_task) $element = $subelement = $this->param['origin']; @@ -225,7 +225,7 @@ class FormTicket if ($this->withthreadid > 0) { $subject = $langs->trans('SubjectAnswerToTicket').' '.$this->withthreadid.' : '.$this->topic_title.''; } - print ''; + print ''; print ''; } } diff --git a/htdocs/core/class/html.formwebsite.class.php b/htdocs/core/class/html.formwebsite.class.php index 7b067fa11d6..c656f5e39ee 100644 --- a/htdocs/core/class/html.formwebsite.class.php +++ b/htdocs/core/class/html.formwebsite.class.php @@ -79,9 +79,7 @@ class FormWebsite if ($selected == $obj->rowid) { $out .= '