diff --git a/.travis.yml b/.travis.yml index db0f3196cf8..509578e57ef 100644 --- a/.travis.yml +++ b/.travis.yml @@ -11,7 +11,7 @@ php: - '5.3' - '5.4' - '5.5' -- '5.6.29' +- '5.6' - '7.0' - '7.1' - nightly diff --git a/ChangeLog b/ChangeLog index 9cd6f11d1b8..2417a7db682 100644 --- a/ChangeLog +++ b/ChangeLog @@ -4,10 +4,127 @@ English Dolibarr ChangeLog ***** ChangeLog for 6.0.0 compared to 5.0.* ***** +NEW: Add experimental BlockeLog module (to log business events in a non reversible log file). +NEW: Add a payment module for Stripe. +NEW: Add module "Product variant" (like red, blue for the product shoes) +NEW: Accountancy - Activate multi-journal & Add journal_label to database (FEC) +NEW: Add a tracking id into mass emailing. +NEW: Tax system more compatible with the new tax roollout in India (IGST / CGST / SGST). +NEW: Add calculation function for Loan schedule +NEW: Add "depends on" and "required by" into module informations +NEW: Add hidden option THIRDPARTY_INCLUDE_PARENT_IN_LINKTO +NEW: Add key __USERID__ and __ENTITYID__ as key for dynamic filters. +NEW: Add last activation author and ip of modules +NEW: Add mass actions (pdf merge and delete) for interventions +NEW: Add module resources import/export +NEW: Add option PROJECT_THIRDPARTY_REQUIRED +NEW: Add page statistics for project tasks +NEW: add property to show warnings when activating modules +NEW: add rapport file for supplier paiement +NEW: Add statistics on supplier tab. +NEW: Add tooltip help on shipment weight and volume calculation +NEW: An external module can hook and add mass actions +NEW: Better reponsive design +NEW: Bookmarks are into a combo list. +NEW: Bulk actions available on supplier orders +NEW: Can add a background image on login page +NEW: Can change customer from POS +NEW: Can clone expense report on another user +NEW: Can control constants values into file integrity checker +NEW: Can define default values for create forms. +NEW: Can define default filters for list pages. +NEW: Can define default sort order for list pages. +NEW: Can deploy an external module from the module setup area. +NEW: Can disable all overwrote translations in one click. +NEW: Can edit background color for odd and even lines in tables +NEW: Can filter on code in dictionnaries +NEW: Can filter on year and product tags on the product statistic page +NEW: Can import users +NEW: Can read time spent of others (hierarchy only or all if granted) +NEW: Can send an email to a user from its card. +NEW: Can send email to multiple destinaries from the mailform combo list. +NEW: Can set margins of PDFs +NEW: Can set number of dump to keep with job "local database backup" +NEW: Can sort customer balance summary on date. +NEW: Can sort thumbs visible on product card. +NEW: Can use a credit note into a "down payment/deposit". +NEW: Can use dol_fiche_end without showing bottom border. +NEW: Can use translations into all substitutions (watermark, freetext...) +NEW: Change to allow a specific numbering rule for invoice with POS module. +NEW: convert exceiss received to reduc +NEW: custom dir is enabled dy default on first install. +NEW: Description of feature of a module visible into a dedicated popup. +NEW: Direct open of card after a search if one record only found. +NEW: download button +NEW: Enable bulk actions delete on supplier invoices. +NEW: Extrafields support formulas to be computed using PHP expressions. +NEW: Feature to crop/resize images available on user and expense reports. +NEW: Filechecker can include custom dir and report added files. +NEW: fix listview class and add a demo for product list +NEW: [FP17] Accountancy - Add select field in list of accounts +NEW: get amount base on hourly rate for ficheinter +NEW: hidden Easter egg to display commitstrip strip on login page +NEW: Include an hourglass icon when we click on online payment button +NEW: Index upload files into database. +NEW: Introduce mass action on product list ('delete' for the moment) +NEW: Introduce mass actions on contacts +NEW: Introduce option MAIN_HTTP_CONTENT_SECURITY_POLICY +NEW: It's easier to switch between sandbox and live for paypal +NEW: Mass action delete available on project and tasks +NEW: Move login information on home page into a widget +NEW: new demo entry page +NEW: No external check of version without explicit click in about page. +NEW: ODT docs for USER USERGROUP CONTRACT and PRODUCT class +NEW: odt usergroup +NEW: On invoices generated by template, we save if invoice come from a source template. +NEW: option to copy into attachement files of events, files send by mail (with auto event creation) +NEW: PDF with numbertoword +NEW: Permit multiple file upload in linked documents +NEW: PHP 7.1 compatibility +NEW: Reduce memory usage by removing deprecated constant loading. +NEW: Report page and menu for suppliers paiements +NEW: Show by default README.md file found into root dir of ext module. +NEW: Show company into combo list of projects +NEW: show files in the bank statement + download +NEW: Show local taxes in facture list +NEW: Show local taxes in supplier facture list +NEW: Small PDF template for products +NEW: Option SUPPLIER_ORDER_EDIT_BUYINGPRICE_DURING_RECEIPT +NEW: The substitution keys available for emailing edition are now visible into a popup. +NEW: Uniformize behaviour: Action to make order is an action button. +NEW: Use autocompletion on the "Add widget list". +NEW: Use html5 type "number" on select field for year and duration. +NEW: Can use pdktk to concat mass pdf because tcpdf generate avoid to split large file into multiple smaller file (all have same size) encounter issue with mailer provider virtual delivery service +NEW: Default theme of v6 is cleaner. +NEW: When down payment is entered, discount to reuse into final invoice is automatically created. This save one click into invoice workflow. +NEW: Add UI to configure MEMBER_NEWFORM_FORCETYPE +NEW: #2763 Go to document block after clicking in Generate document button +NEW: #6280: Generate PDF after creating an invoice from a customer order +NEW: #6915 Simplest change. +NEW: Uniformize the look and feel with v6 new look. + For developers: NEW: Add a lot of API REST: dictionaryevents, memberstypes, ... NEW: Big refactorization of multicompany transverse mode. NEW: getEntity function use true $shared value by default. +NEW: Add font-awesome css. +NEW: Add function ajax_autoselect +NEW: Add function dolMd2Html +NEW: Add hook doUpgrade2 +NEW: Add hook "formatNotificationMessage" +NEW: Add index and constraints keys on supplier proposal detail table +NEW: Add phpunit to check the engine is defined into sql create files. +NEW: Add project and Hook to Loan +NEW: Add REST API to push a file. +NEW: Allow extrafields list select to be dependands on other standard list and not only other extrafields list +NEW: Architecture to manage search criteria persistance (using save_lastsearch_values=1 on exit links and restore_lastsearch_values=1 in entry links) +NEW: data files are now also parsed by phpunit for sql syntax +NEW: Hook to allow inserting custom product head #6001 +NEW: Introduce fields that can be computed during export in export profiles. +NEW: Introduce function dol_compress_dir +NEW: Removed commande_pdf_create, contract_pdf_create,expedition_pdf_create, facture_pdf_create, delivery_order_pdf_create, task_pdf_create, project_pdf_create, propale_pdf_create, supplier_invoice_pdf_create, supplier_order_pdf_create, supplier_proposal_pdf_create deprecated functions +NEW: tooltip can be on hover or on click with textwithpicto function. +NEW: Upgrade jquery to 3.3.1 and jquery-ui to 1.12 WARNING: diff --git a/build/exe/doliwamp/doliwamp.iss b/build/exe/doliwamp/doliwamp.iss index 34757a5123a..2ef8ab32f22 100644 --- a/build/exe/doliwamp/doliwamp.iss +++ b/build/exe/doliwamp/doliwamp.iss @@ -353,10 +353,12 @@ begin begin // TODO Copy file or ask to install package ? //CustomMessage('YouWillInstallDoliWamp')+#13#13 - MsgBox('The package vcredist_x86.exe must have been installed first. It seems it is not. Please install it first from http://www.microsoft.com/en-us/download/details.aspx?id=30679 then restart DoliWamp installation/upgrade.',mbInformation,MB_OK); + MsgBox('The package vcredist_x86.exe must have been installed first. It seems it is not. Please install it first from http://www.microsoft.com/en-us/download/details.aspx?id=30679 then restart DoliWamp installation/upgrade.',mbInformation,MB_OK); end; - - + // Pb seems similar with msvcp110.dll + //vcredist_x64.exe + + // If we have a new database version, we should only copy old my.ini file into new directory // and change only all basedir= strings to use new version. Like this, data dir is still correct. // Install of service and stop/start scripts are already rebuild by installer. diff --git a/build/makepack-dolibarr.pl b/build/makepack-dolibarr.pl index c2d983653cb..1843f3c8cfd 100755 --- a/build/makepack-dolibarr.pl +++ b/build/makepack-dolibarr.pl @@ -592,6 +592,8 @@ if ($nboftargetok) { print "Remove subdir of custom dir\n"; print "find $BUILDROOT/$PROJECT/htdocs/custom/* -type d -exec rm -fr {} \\;\n"; $ret=`find $BUILDROOT/$PROJECT/htdocs/custom/* -type d -exec rm -fr {} \\; >/dev/null 2>&1`; # For custom we want to remove all subdirs but not files + print "find $BUILDROOT/$PROJECT/htdocs/custom/* -type l -exec rm -fr {} \\;\n"; + $ret=`find $BUILDROOT/$PROJECT/htdocs/custom/* -type l -exec rm -fr {} \\; >/dev/null 2>&1`; # For custom we want to remove all subdirs, even symbolic links, but not files } # Build package for each target @@ -972,9 +974,11 @@ if ($nboftargetok) { $ret=`$cmd`; $ret=`chmod 755 $BUILDROOT/$PROJECT.tmp/debian/rules`; $ret=`chmod -R 644 $BUILDROOT/$PROJECT.tmp/dev/translation/autotranslator.class.php`; + $ret=`chmod -R 644 $BUILDROOT/$PROJECT.tmp/htdocs/modulebuilder/template/class/actions_mymodule.class.php`; + $ret=`chmod -R 644 $BUILDROOT/$PROJECT.tmp/htdocs/modulebuilder/template/class/api_myobject.class.php`; $ret=`chmod -R 644 $BUILDROOT/$PROJECT.tmp/htdocs/modulebuilder/template/class/myobject.class.php`; - $ret=`chmod -R 644 $BUILDROOT/$PROJECT.tmp/htdocs/modulebuilder/template/class/myobject_api_class.class.php`; $ret=`chmod -R 644 $BUILDROOT/$PROJECT.tmp/htdocs/modulebuilder/template/core/modules/modMyModule.class.php`; + $ret=`chmod -R 644 $BUILDROOT/$PROJECT.tmp/htdocs/modulebuilder/template/mymoduleindex.php`; $ret=`chmod -R 644 $BUILDROOT/$PROJECT.tmp/htdocs/modulebuilder/template/myobject_card.php`; $ret=`chmod -R 644 $BUILDROOT/$PROJECT.tmp/htdocs/modulebuilder/template/myobject_list.php`; $ret=`chmod -R 755 $BUILDROOT/$PROJECT.tmp/htdocs/modulebuilder/template/scripts/myobject.php`; diff --git a/build/rpm/dolibarr_fedora.spec b/build/rpm/dolibarr_fedora.spec index 33dc951309d..55898481691 100755 --- a/build/rpm/dolibarr_fedora.spec +++ b/build/rpm/dolibarr_fedora.spec @@ -162,6 +162,7 @@ done >>%{name}.lang %_datadir/dolibarr/htdocs/api %_datadir/dolibarr/htdocs/asterisk %_datadir/dolibarr/htdocs/barcode +%_datadir/dolibarr/htdocs/blockedlog %_datadir/dolibarr/htdocs/bookmarks %_datadir/dolibarr/htdocs/cashdesk %_datadir/dolibarr/htdocs/categories diff --git a/build/rpm/dolibarr_generic.spec b/build/rpm/dolibarr_generic.spec index 42a89675abf..e5b346278ab 100755 --- a/build/rpm/dolibarr_generic.spec +++ b/build/rpm/dolibarr_generic.spec @@ -242,6 +242,7 @@ done >>%{name}.lang %_datadir/dolibarr/htdocs/api %_datadir/dolibarr/htdocs/asterisk %_datadir/dolibarr/htdocs/barcode +%_datadir/dolibarr/htdocs/blockedlog %_datadir/dolibarr/htdocs/bookmarks %_datadir/dolibarr/htdocs/cashdesk %_datadir/dolibarr/htdocs/categories diff --git a/build/rpm/dolibarr_mandriva.spec b/build/rpm/dolibarr_mandriva.spec index 9dd2100b02c..04a3138d9f9 100755 --- a/build/rpm/dolibarr_mandriva.spec +++ b/build/rpm/dolibarr_mandriva.spec @@ -159,6 +159,7 @@ done >>%{name}.lang %_datadir/dolibarr/htdocs/api %_datadir/dolibarr/htdocs/asterisk %_datadir/dolibarr/htdocs/barcode +%_datadir/dolibarr/htdocs/blockedlog %_datadir/dolibarr/htdocs/bookmarks %_datadir/dolibarr/htdocs/cashdesk %_datadir/dolibarr/htdocs/categories diff --git a/build/rpm/dolibarr_opensuse.spec b/build/rpm/dolibarr_opensuse.spec index d780c47da99..c77661fe420 100755 --- a/build/rpm/dolibarr_opensuse.spec +++ b/build/rpm/dolibarr_opensuse.spec @@ -170,6 +170,7 @@ done >>%{name}.lang %_datadir/dolibarr/htdocs/api %_datadir/dolibarr/htdocs/asterisk %_datadir/dolibarr/htdocs/barcode +%_datadir/dolibarr/htdocs/blockedlog %_datadir/dolibarr/htdocs/bookmarks %_datadir/dolibarr/htdocs/cashdesk %_datadir/dolibarr/htdocs/categories diff --git a/dev/dolibarr_changes.txt b/dev/dolibarr_changes.txt index 9b82bd05b2a..3b9ef4cc447 100644 --- a/dev/dolibarr_changes.txt +++ b/dev/dolibarr_changes.txt @@ -5,7 +5,7 @@ in Dolibarr root. ALL: ---- -Check "DOL_CHANGE" +Check "@CHANGE" CKEDITOR (4.6.2): diff --git a/dev/resources/iso-normes/world_tax_rates.txt b/dev/resources/iso-normes/world_tax_rates.txt index e5bb64a86f2..740062288dc 100644 --- a/dev/resources/iso-normes/world_tax_rates.txt +++ b/dev/resources/iso-normes/world_tax_rates.txt @@ -1 +1,4 @@ -http://www.taxrates.cc/index.html \ No newline at end of file +http://www.taxrates.cc/index.html + +For India: VAT=IGST/CGST=Localtax1/SGST=Localtax2: https://cleartax.in/s/what-is-sgst-cgst-igst + diff --git a/dev/translation/sanity_check_en_langfiles.php b/dev/translation/sanity_check_en_langfiles.php index 9136c192739..f65cefd7f94 100755 --- a/dev/translation/sanity_check_en_langfiles.php +++ b/dev/translation/sanity_check_en_langfiles.php @@ -25,7 +25,7 @@ $path=dirname(__FILE__).'/'; $web=0; // Test if batch mode -if (substr($sapi_type, 0, 3) == 'cgi') +if (substr($sapi_type, 0, 3) == 'cgi') { $web=1; } @@ -35,9 +35,9 @@ if ($web) { echo ""; echo ""; - + echo ""; - + echo ""; } @@ -142,9 +142,9 @@ foreach ($files AS $file) { } } -foreach ($langstrings_3d AS $filename => $file) +foreach ($langstrings_3d AS $filename => $file) { - foreach ($file AS $linenum => $value) + foreach ($file AS $linenum => $value) { $keys = array_keys($langstrings_full, $value); if (count($keys)>1) @@ -173,11 +173,11 @@ $sininstallandadmin=''; $sother=''; $count = 0; -foreach ($dups as $string => $pages) +foreach ($dups as $string => $pages) { $count++; $s=''; - + // Keyword $string if ($web) $s.=""; if ($web) $s.=""; @@ -188,32 +188,32 @@ foreach ($dups as $string => $pages) if ($web) $s.=""; if ($web) $s.=""; if (! $web) $s.= ' : '; - + // Loop on each files keyword was found $duplicateinsamefile=0; $inmain=0; $inadmin=0; - foreach ($pages AS $file => $lines) + foreach ($pages AS $file => $lines) { if ($file == 'main.lang') { $inmain=1; $inadmin=0; } if ($file == 'admin.lang' && ! $inmain) { $inadmin=1; } - + $s.=$file." "; - + // Loop on each line keword was found into file. $listoffilesforthisentry=array(); - foreach ($lines as $line => $translatedvalue) + foreach ($lines as $line => $translatedvalue) { if (! empty($listoffilesforthisentry[$file])) $duplicateinsamefile=1; $listoffilesforthisentry[$file]=1; - + $s.= "(".$line." - ".htmlentities($translatedvalue).") "; } if ($web) $s.="
"; } if ($web) $s.=""; $s.="\n"; - + if ($duplicateinsamefile) $sduplicateinsamefile .= $s; else if ($inmain) $sinmainandother .= $s; else if ($inadmin) $sininstallandadmin .= $s; @@ -252,7 +252,7 @@ if ($web) if ((! empty($_REQUEST['unused']) && $_REQUEST['unused'] == 'true') || (isset($argv[1]) && $argv[1]=='unused=true')) { print "***** Strings in en_US that are never used:\n"; - + $unused=array(); foreach ($langstrings_dist AS $value => $line) { @@ -288,7 +288,7 @@ if ((! empty($_REQUEST['unused']) && $_REQUEST['unused'] == 'true') || (isset($a if (preg_match('/^JuridicalStatus/', $value)) $qualifiedforclean=0; if (preg_match('/^CalcMode/', $value)) $qualifiedforclean=0; if (preg_match('/^newLT/', $value)) $qualifiedforclean=0; - if (preg_match('/^LT\d/', $value)) $qualifiedforclean=0; + if (preg_match('/^LT[0-9]/', $value)) $qualifiedforclean=0; if (preg_match('/^TypeContact_contrat_/', $value)) $qualifiedforclean=0; if (preg_match('/^ErrorPriceExpression/', $value)) $qualifiedforclean=0; if (preg_match('/^Language_/', $value)) $qualifiedforclean=0; @@ -315,7 +315,7 @@ if ((! empty($_REQUEST['unused']) && $_REQUEST['unused'] == 'true') || (isset($a // orders if (preg_match('/^OrderSource/', $value)) $qualifiedforclean=0; if (preg_match('/^TypeContact_/', $value)) $qualifiedforclean=0; - // other.lang + // other.lang if (preg_match('/^Notify_/', $value)) $qualifiedforclean=0; if (preg_match('/^PredefinedMail/', $value)) $qualifiedforclean=0; if (preg_match('/^DemoCompany/', $value)) $qualifiedforclean=0; @@ -336,17 +336,17 @@ if ((! empty($_REQUEST['unused']) && $_REQUEST['unused'] == 'true') || (isset($a if (preg_match('/OppStatus/', $value)) $qualifiedforclean=0; if (preg_match('/AvailabilityType/', $value)) $qualifiedforclean=0; if (preg_match('/CardProduct/', $value)) $qualifiedforclean=0; - + if (preg_match('/sms/i', $value)) $qualifiedforclean=0; if (preg_match('/TF_/i', $value)) $qualifiedforclean=0; if (preg_match('/WithBankUsing/i', $value)) $qualifiedforclean=0; if (preg_match('/descWORKFLOW_/i', $value)) $qualifiedforclean=0; - + if (! $qualifiedforclean) { - continue; + continue; } - + //$search = '\'trans("'.$value.'")\''; $search = '-e "\''.$value.'\'" -e \'"'.$value.'"\' -e "('.$value.')" -e "('.$value.',"'; $string = 'grep -R -m 1 -F --exclude=includes/* --include=*.php '.$search.' '.$htdocs.'* '.$scripts.'*'; @@ -356,7 +356,7 @@ 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'; @@ -364,7 +364,7 @@ if ((! empty($_REQUEST['unused']) && $_REQUEST['unused'] == 'true') || (isset($a } 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"; diff --git a/htdocs/accountancy/admin/account.php b/htdocs/accountancy/admin/account.php index e369081f7e1..905fd8b97ef 100644 --- a/htdocs/accountancy/admin/account.php +++ b/htdocs/accountancy/admin/account.php @@ -97,7 +97,7 @@ if (empty($reshook)) include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; - if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") ||GETPOST("button_removefilter")) // All test are required to be compatible with all browsers + if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x','alpha') ||GETPOST('button_removefilter','alpha')) // All test are required to be compatible with all browsers { $search_account = ""; $search_label = ""; diff --git a/htdocs/accountancy/admin/productaccount.php b/htdocs/accountancy/admin/productaccount.php index 311aab692ff..c72ce8cc134 100644 --- a/htdocs/accountancy/admin/productaccount.php +++ b/htdocs/accountancy/admin/productaccount.php @@ -98,7 +98,7 @@ $reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); // Purge search criteria -if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETPOST("button_removefilter")) // All test are required to be compatible with all browsers +if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x','alpha') || GETPOST('button_removefilter','alpha')) // All test are required to be compatible with all browsers { $search_ref = ''; $search_label = ''; diff --git a/htdocs/accountancy/bookkeeping/balance.php b/htdocs/accountancy/bookkeeping/balance.php index e742f4651cf..fb503c17ca0 100644 --- a/htdocs/accountancy/bookkeeping/balance.php +++ b/htdocs/accountancy/bookkeeping/balance.php @@ -98,7 +98,7 @@ if (! empty($search_accountancy_code_end)) { * Action */ -if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETPOST("button_removefilter")) // All tests are required to be compatible with all browsers +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 = ''; diff --git a/htdocs/accountancy/bookkeeping/card.php b/htdocs/accountancy/bookkeeping/card.php index c6d84ec9b57..d05dc11ed26 100644 --- a/htdocs/accountancy/bookkeeping/card.php +++ b/htdocs/accountancy/bookkeeping/card.php @@ -72,15 +72,24 @@ if ($action == "confirm_update") { $error = 0; if ((floatval($debit) != 0.0) && (floatval($credit) != 0.0)) { - setEventMessages($langs->trans('ErrorDebitCredit'), null, 'errors'); - $error ++; + $error++; + setEventMessages($langs->trans('ErrorDebitCredit'), null, 'errors'); + $action='update'; } + if (empty($account_number) || $account_number == '-1') + { + $error++; + setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv("AccountAccountingShort")), null, 'errors'); + $action='update'; + } - if (empty($error)) { + if (! $error) + { $book = new BookKeeping($db); $result = $book->fetch($id, null, $mode); if ($result < 0) { + $error++; setEventMessages($book->error, $book->errors, 'errors'); } else { $book->numero_compte = $account_number; @@ -120,12 +129,20 @@ if ($action == "confirm_update") { else if ($action == "add") { $error = 0; - if (empty($debit) && empty($credit)) { - setEventMessages($langs->trans('ErrorDebitCredit'), null, 'errors'); - $error ++; + if ((floatval($debit) != 0.0) && (floatval($credit) != 0.0)) + { + $error++; + setEventMessages($langs->trans('ErrorDebitCredit'), null, 'errors'); + $action=''; + } + if (empty($account_number) || $account_number == '-1') + { + $error++; + setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv("AccountAccountingShort")), null, 'errors'); + $action=''; } - if (empty($error)) { + if (! $error) { $book = new BookKeeping($db); $book->numero_compte = $account_number; @@ -567,7 +584,7 @@ if ($action == 'create') { if ($action == 'update' && $line->id == $id) { print ''; - print $formaccounting->select_account($line->numero_compte, 'account_number', 0, array (), 1, 1, ''); + print $formaccounting->select_account($line->numero_compte, 'account_number', 1, array (), 1, 1, ''); print ''; print ''; // TODO For the moment we keep a fre input text instead of a combo. The select_auxaccount has problem because it does not @@ -583,8 +600,8 @@ if ($action == 'create') { print ''; print ''; print ''; - print ''; - print ''; + print ''; + print ''; print ''; print '' . "\n"; print ''; @@ -622,7 +639,7 @@ if ($action == 'create') { if ($action == "" || $action == 'add') { print ''; print ''; - print $formaccounting->select_account($account_number, 'account_number', 0, array (), 1, 1, ''); + print $formaccounting->select_account($account_number, 'account_number', 1, array (), 1, 1, ''); print ''; print ''; // TODO For the moment we keep a fre input text instead of a combo. The select_auxaccount has problem because it does not @@ -638,24 +655,30 @@ if ($action == 'create') { print ''; print ''; print ''; - print ''; - print ''; + print ''; + print ''; print ''; print ''; } print ''; + if ($mode=='_tmp' && $action=='') { - print '
'; + print '
'; + print '
'; if ($total_debit == $total_credit) { - print ''.$langs->trans("ValidTransaction").''; + print ''.$langs->trans("ValidTransaction").''; } else { - print ''.$langs->trans("ValidTransaction").''; + print ''; } + + print '   '; + print ''.$langs->trans("Cancel").''; + print "
"; } print ''; diff --git a/htdocs/accountancy/bookkeeping/list.php b/htdocs/accountancy/bookkeeping/list.php index 114b765e658..93968644a8f 100644 --- a/htdocs/accountancy/bookkeeping/list.php +++ b/htdocs/accountancy/bookkeeping/list.php @@ -1,8 +1,8 @@ - * Copyright (C) 2013-2016 Florian Henry - * Copyright (C) 2013-2017 Alexandre Spangaro - * Copyright (C) 2016 Laurent Destailleur +/* Copyright (C) 2013-2016 Olivier Geffroy + * Copyright (C) 2013-2016 Florian Henry + * Copyright (C) 2013-2017 Alexandre Spangaro + * Copyright (C) 2016-2017 Laurent Destailleur * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -16,7 +16,6 @@ * * You should have received a copy of the GNU General Public License * along with this program. If not, see . - * */ /** @@ -112,7 +111,7 @@ if ($action != 'export_file' && ! isset($_POST['begin']) && ! isset($_GET['begin if (GETPOST('cancel')) { $action='list'; $massaction=''; } if (! GETPOST('confirmmassaction') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction=''; } -if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETPOST("button_removefilter")) // All tests are required to be compatible with all browsers +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_mvt_num = ''; $search_doc_type = ''; @@ -377,28 +376,28 @@ print ''; print ''; print ''; print '
'; -print $langs->trans('From') . ': '; +print $langs->trans('From') . ' '; print $form->select_date($search_date_start, 'date_start', 0, 0, 1); print '
'; print '
'; -print $langs->trans('to') . ': '; +print $langs->trans('to') . ' '; print $form->select_date($search_date_end, 'date_end', 0, 0, 1); print '
'; print ''; print ''; print ''; print '
'; -print $langs->trans('From'); +print $langs->trans('From').' '; print $formaccounting->select_account($search_accountancy_code_start, 'search_accountancy_code_start', 1, array (), 1, 1, 'maxwidth200'); print '
'; print '
'; -print $langs->trans('to'); +print $langs->trans('to').' '; print $formaccounting->select_account($search_accountancy_code_end, 'search_accountancy_code_end', 1, array (), 1, 1, 'maxwidth200'); print '
'; print ''; print ''; print '
'; -print $langs->trans('From'); +print $langs->trans('From').' '; // TODO For the moment we keep a fre input text instead of a combo. The select_auxaccount has problem because it does not // use setup of keypress to select thirdparty and this hang browser on large database. if (! empty($conf->global->ACCOUNTANCY_COMBO_FOR_AUX)) @@ -411,7 +410,7 @@ else } print '
'; print '
'; -print $langs->trans('to'); +print $langs->trans('to').' '; // TODO For the moment we keep a fre input text instead of a combo. The select_auxaccount has problem because it does not // use setup of keypress to select thirdparty and this hang browser on large database. if (! empty($conf->global->ACCOUNTANCY_COMBO_FOR_AUX)) @@ -455,7 +454,10 @@ print "\n"; $total_debit = 0; $total_credit = 0; -foreach ($object->lines as $line ) { +$i=0; +while ($i < min($num, $limit)) +{ + $line = $object->lines[$i]; $total_debit += $line->debit; $total_credit += $line->credit; @@ -481,6 +483,8 @@ foreach ($object->lines as $line ) { print '' . img_delete() . ''; print ''; print "\n"; + + $i++; } print ''; diff --git a/htdocs/accountancy/bookkeeping/listbyaccount.php b/htdocs/accountancy/bookkeeping/listbyaccount.php index a1398df6fb2..1f43964bd0a 100644 --- a/htdocs/accountancy/bookkeeping/listbyaccount.php +++ b/htdocs/accountancy/bookkeeping/listbyaccount.php @@ -92,7 +92,7 @@ if (! empty($search_doc_date)) { } -if (!GETPOST("button_removefilter_x") && !GETPOST("button_removefilter")) // Both test are required to be compatible with all browsers +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 (! empty($search_accountancy_code_start)) { $filter['t.numero_compte'] = $search_accountancy_code_start; @@ -121,7 +121,7 @@ if (!GETPOST("button_removefilter_x") && !GETPOST("button_removefilter")) // Bot * Action */ -if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETPOST("button_removefilter")) // All tests are required to be compatible with all browsers +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 = ''; @@ -160,7 +160,6 @@ $title_page = $langs->trans("Bookkeeping") . ' ' . strtolower($langs->trans("By" llxHeader('', $title_page); // List - $nbtotalofrecords = ''; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $nbtotalofrecords = $object->fetchAllByAccount($sortorder, $sortfield, 0, 0, $filter); @@ -173,7 +172,9 @@ $result = $object->fetchAllByAccount($sortorder, $sortfield, $limit, $offset, $f if ($result < 0) { setEventMessages($object->error, $object->errors, 'errors'); } -$nbtotalofrecords = $result; + +$num=count($object->lines); + if ($action == 'delmouv') { $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?mvt_num=' . GETPOST('mvt_num'), $langs->trans('DeleteMvt'), $langs->trans('ConfirmDeleteMvt'), 'delmouvconfirm', '', 0, 1); @@ -204,7 +205,7 @@ if ($action == 'delbookkeepingyear') { -print '
'; +print ''; $viewflat = ' ' . $langs->trans("ViewFlatList") . ''; @@ -236,7 +237,7 @@ print ''; print ' '; print ' '; -print ''; +print ''; print ''; $searchpicto=$form->showFilterAndCheckAddButtons(0); print $searchpicto; @@ -250,7 +251,7 @@ print_liste_field_titre($langs->trans("Docref"), $_SERVER['PHP_SELF'], "t.doc_re print_liste_field_titre($langs->trans("Label")); print_liste_field_titre($langs->trans("Debit"), $_SERVER['PHP_SELF'], "t.debit", "", $options, 'align="right"', $sortfield, $sortorder); print_liste_field_titre($langs->trans("Credit"), $_SERVER['PHP_SELF'], "t.credit", "", $options, 'align="right"', $sortfield, $sortorder); -print_liste_field_titre($langs->trans("Codejournal"), $_SERVER['PHP_SELF'], "t.code_journal", "", $options, 'align="right"', $sortfield, $sortorder); +print_liste_field_titre($langs->trans("Codejournal"), $_SERVER['PHP_SELF'], "t.code_journal", "", $options, 'align="center"', $sortfield, $sortorder); print_liste_field_titre('', $_SERVER["PHP_SELF"], "", $options, "", 'width="60" align="center"', $sortfield, $sortorder); print "\n"; @@ -263,7 +264,10 @@ $sous_total_debit = 0; $sous_total_credit = 0; $displayed_account_number = null; // Start with undefined to be able to distinguish with empty -foreach ( $object->lines as $line ) { +$i=0; +while ($i < min($num, $limit)) +{ + $line = $object->lines[$i]; $total_debit += $line->debit; $total_credit += $line->credit; @@ -323,10 +327,11 @@ foreach ( $object->lines as $line ) { print ''; print "\n"; - // Comptabilise le sous-total - $sous_total_debit += $line->debit; - $sous_total_credit += $line->credit; + // Comptabilise le sous-total + $sous_total_debit += $line->debit; + $sous_total_credit += $line->credit; + $i++; } // Affiche un Sous-Total du dernier compte comptable affiché diff --git a/htdocs/accountancy/bookkeeping/listbyyear.php b/htdocs/accountancy/bookkeeping/listbyyear.php index becb700761a..d10f621d9e3 100644 --- a/htdocs/accountancy/bookkeeping/listbyyear.php +++ b/htdocs/accountancy/bookkeeping/listbyyear.php @@ -86,7 +86,7 @@ $offset = $limit * $page; * Actions */ -if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETPOST("button_removefilter")) // All tests are required to be compatible with all browsers +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_type = ""; $search_doc_date = ""; diff --git a/htdocs/accountancy/class/accountancysystem.class.php b/htdocs/accountancy/class/accountancysystem.class.php index 87d1ccd663c..68beff8d043 100644 --- a/htdocs/accountancy/class/accountancysystem.class.php +++ b/htdocs/accountancy/class/accountancysystem.class.php @@ -37,7 +37,7 @@ class AccountancySystem var $label; var $account_number; var $account_parent; - + /** * Constructor * @@ -46,8 +46,8 @@ class AccountancySystem function __construct($db) { $this->db = $db; } - - + + /** * Load record in memory * @@ -55,11 +55,11 @@ class AccountancySystem * @param string $ref ref * @return int <0 if KO, Id of record if OK and found */ - function fetch($rowid = 0, $ref = '') + function fetch($rowid = 0, $ref = '') { global $conf; - - if ($rowid > 0 || $ref) + + if ($rowid > 0 || $ref) { $sql = "SELECT a.pcg_version, a.label, a.active"; $sql .= " FROM " . MAIN_DB_PREFIX . "accounting_system as a"; @@ -69,12 +69,12 @@ class AccountancySystem } elseif ($ref) { $sql .= " a.pcg_version = '" . $ref . "'"; } - + dol_syslog(get_class($this) . "::fetch sql=" . $sql, LOG_DEBUG); $result = $this->db->query($sql); if ($result) { $obj = $this->db->fetch_object($result); - + if ($obj) { $this->id = $obj->rowid; $this->rowid = $obj->rowid; @@ -82,7 +82,7 @@ class AccountancySystem $this->ref = $obj->pcg_version; $this->label = $obj->label; $this->active = $obj->active; - + return $this->id; } else { return 0; @@ -94,8 +94,8 @@ class AccountancySystem } return - 1; } - - + + /** * Insert accountancy system name into database * @@ -104,16 +104,16 @@ class AccountancySystem */ function create($user) { $now = dol_now(); - + $sql = "INSERT INTO " . MAIN_DB_PREFIX . "accounting_system"; $sql .= " (date_creation, fk_user_author, numero, label)"; - $sql .= " VALUES (" . $this->db->idate($now) . "," . $user->id . ",'" . $this->numero . "','" . $this->label . "')"; - + $sql .= " VALUES ('" . $this->db->idate($now) . "'," . $user->id . ",'" . $this->numero . "','" . $this->label . "')"; + dol_syslog(get_class($this) . "::create sql=" . $sql, LOG_DEBUG); $resql = $this->db->query($sql); if ($resql) { $id = $this->db->last_insert_id(MAIN_DB_PREFIX . "accounting_system"); - + if ($id > 0) { $this->rowid = $id; $result = $this->rowid; @@ -127,7 +127,7 @@ class AccountancySystem $this->error = "AccountancySystem::Create Erreur $result"; dol_syslog($this->error, LOG_ERR); } - + return $result; } } \ No newline at end of file diff --git a/htdocs/accountancy/class/bookkeeping.class.php b/htdocs/accountancy/class/bookkeeping.class.php index 5c5fb022de9..ad28dd1af97 100644 --- a/htdocs/accountancy/class/bookkeeping.class.php +++ b/htdocs/accountancy/class/bookkeeping.class.php @@ -176,7 +176,7 @@ class BookKeeping extends CommonObject if (empty($this->credit)) $this->credit = 0; // Check parameters - if (empty($this->numero_compte) || $this->numero_compte == '-1') + if (empty($this->numero_compte) || $this->numero_compte == '-1' || $this->numero_compte == 'NotDefined') { $langs->load("errors"); if (in_array($this->doc_type, array('bank', 'expense_report'))) @@ -803,7 +803,7 @@ class BookKeeping extends CommonObject if (! empty($limit)) { $sql .= ' ' . $this->db->plimit($limit + 1, $offset); } - $this->lines = array (); + $this->lines = array(); $resql = $this->db->query($sql); if ($resql) { @@ -1260,7 +1260,7 @@ class BookKeeping extends CommonObject global $user; $error = 0; - $object = new Accountingbookkeeping($this->db); + $object = new BookKeeping($this->db); $this->db->begin(); diff --git a/htdocs/accountancy/customer/lines.php b/htdocs/accountancy/customer/lines.php index d6d006c6556..d48f81259df 100644 --- a/htdocs/accountancy/customer/lines.php +++ b/htdocs/accountancy/customer/lines.php @@ -85,7 +85,7 @@ $formaccounting = new FormAccounting($db); */ // Purge search criteria -if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETPOST("button_removefilter")) // All tests are required to be compatible with all browsers +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_lineid = ''; $search_ref = ''; @@ -153,7 +153,7 @@ print ''; - $return .= ''; - - if ($showempty) - $return .= ''; - - // Find if keys is in selected array value - if (is_array($selected_array) && count($selected_array)>0) { - $intersect_array = array_intersect_key($options_array, array_flip($selected_array)); - } else { - $intersect_array=array(); - } - - if (count($options_array) > 0) { - foreach ($options_array as $keyoption => $valoption) { - // If key is in intersect table then it have to e selected - $selected = ''; - if (count ( $intersect_array ) > 0) { - if (array_key_exists ( $keyoption, $intersect_array )) { - $selected = ' selected="selected"'; - } - } - $return .= '' . $valoption . ''; - } - } - - $return .= ''; - + $form=new Form($this->db); + $return = $form->multiselectarray($htmlname, $options_array, $selected_array,0,0,'',0,295); return $return; } @@ -448,7 +407,7 @@ class FormAdvTargetEmailing extends Form dol_print_error($this->db); } - return $this->advMultiselectarray ( $htmlname, $options_array, $selected_array ); + return $this->advMultiselectarray( $htmlname, $options_array, $selected_array ); } /** diff --git a/htdocs/comm/propal/card.php b/htdocs/comm/propal/card.php index 4668c6a56a4..b603d1e6a17 100644 --- a/htdocs/comm/propal/card.php +++ b/htdocs/comm/propal/card.php @@ -1250,6 +1250,8 @@ $now = dol_now(); // Add new proposal if ($action == 'create') { + $currency_code = $conf->currency; + print load_fiche_titre($langs->trans("NewProp")); $soc = new Societe($db); @@ -1748,6 +1750,7 @@ if ($action == 'create') $morehtmlref.=$form->editfieldval("RefCustomer", 'ref_client', $object->ref_client, $object, $user->rights->propal->creer, 'string', '', null, null, '', 1); // Thirdparty $morehtmlref.='
'.$langs->trans('ThirdParty') . ' : ' . $object->thirdparty->getNomUrl(1); + if (empty($conf->global->MAIN_DISABLE_OTHER_LINK) && $object->thirdparty->id > 0) $morehtmlref.=' ('.$langs->trans("OtherProposals").')'; // Project if (! empty($conf->projet->enabled)) { diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index ec8f7d62b0f..f007cbdbf81 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -2362,7 +2362,7 @@ class Propal extends CommonObject $this->db->begin(); $sql = 'UPDATE '.MAIN_DB_PREFIX.'propal SET fk_statut = '.self::STATUS_BILLED; - $sql .= ' WHERE rowid = '.$this->id.' AND fk_statut > '.self::STATUS_DRAFT.' ;'; + $sql .= ' WHERE rowid = '.$this->id.' AND fk_statut > '.self::STATUS_DRAFT; dol_syslog(__METHOD__, LOG_DEBUG); $resql=$this->db->query($sql); @@ -3502,7 +3502,7 @@ class Propal extends CommonObject /** * Class to manage commercial proposal lines */ -class PropaleLigne extends CommonObjectLine +class PropaleLigne extends CommonObjectLine { public $element='propaldet'; public $table_element='propaldet'; diff --git a/htdocs/comm/propal/list.php b/htdocs/comm/propal/list.php index e9626a638b8..6062f6033dc 100644 --- a/htdocs/comm/propal/list.php +++ b/htdocs/comm/propal/list.php @@ -178,7 +178,7 @@ if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'e include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; // Do we click on purge search criteria ? -if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETPOST("button_removefilter")) // All tests are required to be compatible with all browsers +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_categ=''; $search_user=''; @@ -355,6 +355,7 @@ if ($resql) $soc = new Societe($db); $soc->fetch($socid); $title = $langs->trans('ListOfProposals') . ' - '.$soc->name; + if (empty($search_societe)) $search_societe = $soc->name; } else { diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php index 13fe07f78df..ddb44153e49 100644 --- a/htdocs/commande/card.php +++ b/htdocs/commande/card.php @@ -1924,6 +1924,7 @@ if ($action == 'create' && $user->rights->commande->creer) $morehtmlref.=$form->editfieldval("RefCustomer", 'ref_client', $object->ref_client, $object, $user->rights->commande->creer, 'string', '', null, null, '', 1); // Thirdparty $morehtmlref.='
'.$langs->trans('ThirdParty') . ' : ' . $soc->getNomUrl(1); + if (empty($conf->global->MAIN_DISABLE_OTHER_LINK) && $object->thirdparty->id > 0) $morehtmlref.=' ('.$langs->trans("OtherOrders").')'; // Project if (! empty($conf->projet->enabled)) { @@ -2039,7 +2040,7 @@ if ($action == 'create' && $user->rights->commande->creer) print ''; } else { print $object->date ? dol_print_date($object->date, 'day') : ' '; - if ($object->hasDelay() && empty($object->date_livraison)) { + if ($object->hasDelay() && ! empty($object->date_livraison)) { print ' '.img_picto($langs->trans("Late").' : '.$object->showDelay(), "warning"); } } diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index b93e399871c..f9ebf8a4cde 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -65,9 +65,8 @@ class Commande extends CommonOrder public $contactid; /** - * Status of the order. Check the following constants: + * Status of the order * @var int - * @see Commande::STATUS_CANCELED, Commande::STATUS_DRAFT, Commande::STATUS_ACCEPTED, Commande::STATUS_CLOSED */ public $statut; /** diff --git a/htdocs/commande/list.php b/htdocs/commande/list.php index 8ce3ba7cd04..565f39e62a2 100644 --- a/htdocs/commande/list.php +++ b/htdocs/commande/list.php @@ -162,7 +162,7 @@ if (empty($reshook)) include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; // Purge search criteria - if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETPOST("button_removefilter")) // All tests are required to be compatible with all browsers + 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_categ=''; $search_user=''; @@ -191,6 +191,11 @@ if (empty($reshook)) $toselect=''; $search_array_options=array(); } + if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x','alpha') || GETPOST('button_removefilter','alpha') + || GETPOST('button_search_x','alpha') || GETPOST('button_search.x','alpha') || GETPOST('button_search','alpha')) + { + $massaction=''; // Protection to avoid mass action if we force a new search during a mass action confirmation + } // Mass actions $objectclass='Commande'; @@ -371,7 +376,7 @@ if (empty($reshook)) } - $cmd->classifyBilled($user); + //$cmd->classifyBilled($user); // Disabled. This behavior must be set or not using the workflow module. if(!empty($createbills_onebythird) && empty($TFactThird[$cmd->socid])) $TFactThird[$cmd->socid] = $object; else $TFact[$object->id] = $object; @@ -573,6 +578,7 @@ if ($resql) $soc = new Societe($db); $soc->fetch($socid); $title = $langs->trans('ListOfOrders') . ' - '.$soc->name; + if (empty($search_company)) $search_company = $soc->name; } else { @@ -754,7 +760,7 @@ if ($resql) //var_dump($_REQUEST); print ''; - print ''; + print '
'; print ''; print ''; print ''; print ''; print '
'; print $langs->trans('DateInvoice'); @@ -776,7 +782,15 @@ if ($resql) print $langs->trans('ValidateInvoices'); print ''; - print $form->selectyesno('valdate_invoices', 1, 1); + if (! empty($conf->stock->enabled) && ! empty($conf->global->STOCK_CALCULATE_ON_BILL)) + { + print $form->selectyesno('valdate_invoices', 0, 1, 1); + print ' ('.$langs->trans("AutoValidationNotPossibleWhenStockIsDecreasedOnInvoiceValidation").')'; + } + else + { + print $form->selectyesno('valdate_invoices', 0, 1); + } print '
'; @@ -838,7 +852,7 @@ if ($resql) $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); + $selectedfields.=$form->showCheckAddButtons('checkforselect', 1); print '
'; print ''."\n"; @@ -976,6 +990,7 @@ if ($resql) Commande::STATUS_VALIDATED=>$langs->trans("StatusOrderValidated"), Commande::STATUS_ACCEPTED=>$langs->trans("StatusOrderSentShort"), Commande::STATUS_CLOSED=>$langs->trans("StatusOrderDelivered"), + -3=>$langs->trans("StatusOrderValidatedShort").'+'.$langs->trans("StatusOrderSentShort").'+'.$langs->trans("StatusOrderDelivered"), Commande::STATUS_CANCELED=>$langs->trans("StatusOrderCanceledShort") ); print $form->selectarray('viewstatut', $liststatus, $viewstatut, -4); @@ -1033,7 +1048,7 @@ if ($resql) if (! empty($arrayfields['c.tms']['checked'])) print_liste_field_titre($arrayfields['c.tms']['label'],$_SERVER["PHP_SELF"],"c.tms","",$param,'align="center" class="nowrap"',$sortfield,$sortorder); if (! empty($arrayfields['c.fk_statut']['checked'])) print_liste_field_titre($arrayfields['c.fk_statut']['label'],$_SERVER["PHP_SELF"],"c.fk_statut","",$param,'align="right"',$sortfield,$sortorder); if (! empty($arrayfields['c.facture']['checked'])) print_liste_field_titre($arrayfields['c.facture']['label'],$_SERVER["PHP_SELF"],'c.facture','',$param,'align="center"',$sortfield,$sortorder,''); - print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"],"",'','','align="center"',$sortfield,$sortorder,'maxwidthsearch '); + print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"],"",'',$param,'align="center"',$sortfield,$sortorder,'maxwidthsearch '); print ''."\n"; $total=0; diff --git a/htdocs/compta/bank/bankentries.php b/htdocs/compta/bank/bankentries.php index 2bc2242abc4..a19ccbb6b7c 100644 --- a/htdocs/compta/bank/bankentries.php +++ b/htdocs/compta/bank/bankentries.php @@ -35,6 +35,7 @@ require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/bankcateg.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php'; require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/sociales/class/chargesociales.class.php'; @@ -46,17 +47,7 @@ require_once DOL_DOCUMENT_ROOT.'/expensereport/class/paymentexpensereport.class. require_once DOL_DOCUMENT_ROOT.'/loan/class/loan.class.php'; require_once DOL_DOCUMENT_ROOT.'/fourn/class/paiementfourn.class.php'; -$langs->load("banks"); -$langs->load("bills"); -$langs->load("categories"); -$langs->load("companies"); -$langs->load("margins"); -$langs->load("salaries"); -$langs->load("loan"); -$langs->load("donations"); -$langs->load("trips"); -$langs->load("members"); -$langs->load("compta"); +$langs->loadLangs(array("banks","bills","categories","companies","margins","salaries","loan","donations","trips","members","compta","accountancy")); $id = GETPOST('id','int'); $ref = GETPOST('ref','alpha'); @@ -84,6 +75,7 @@ $debit=GETPOST("debit",'alpha'); $credit=GETPOST("credit",'alpha'); $type=GETPOST("type",'alpha'); $account=GETPOST("account",'int'); +$accountancy_code=GETPOST('accountancy_code', 'alpha'); $bid=GETPOST("bid","int"); $search_dt_start = dol_mktime(0, 0, 0, GETPOST('search_start_dtmonth', 'int'), GETPOST('search_start_dtday', 'int'), GETPOST('search_start_dtyear', 'int')); $search_dt_end = dol_mktime(0, 0, 0, GETPOST('search_end_dtmonth', 'int'), GETPOST('search_end_dtday', 'int'), GETPOST('search_end_dtyear', 'int')); @@ -178,7 +170,7 @@ if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'e include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; -if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETPOST("button_removefilter")) // All tests are required to be compatible with all browsers +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_dt_start=''; $search_dt_end=''; @@ -276,11 +268,11 @@ if (GETPOST('save') && $id && ! $cancel && $user->rights->banque->modifier) $amount = - price2num($_POST["adddebit"]); } - $dateop = dol_mktime(12,0,0,$_POST["opmonth"],$_POST["opday"],$_POST["opyear"]); - $operation=$_POST["operation"]; - $num_chq=$_POST["num_chq"]; - $label=$_POST["label"]; - $cat1=$_POST["cat1"]; + $dateop = dol_mktime(12,0,0,$_POST["opmonth"],$_POST["opday"],$_POST["opyear"]); + $operation = GETPOST("operation",'alpha'); + $num_chq = GETPOST("num_chq",'alpha'); + $label = GETPOST("label",'alpha'); + $cat1 = GETPOST("cat1",'alpha'); if (! $dateop) { $error++; @@ -290,15 +282,24 @@ if (GETPOST('save') && $id && ! $cancel && $user->rights->banque->modifier) $error++; setEventMessages($langs->trans("ErrorFieldRequired", $langs->trans("Type")), null, 'errors'); } + if (! $label) { + $error++; + setEventMessages($langs->trans("ErrorFieldRequired", $langs->trans("Label")), null, 'errors'); + } if (! $amount) { $error++; setEventMessages($langs->trans("ErrorFieldRequired", $langs->trans("Amount")), null, 'errors'); } + /*if (! empty($conf->accounting->enabled) && (empty($accountancy_code) || $accountancy_code == '-1')) + { + setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("AccountAccounting")), null, 'errors'); + $error++; + }*/ if (! $error) { $object->fetch($id); - $insertid = $object->addline($dateop, $operation, $label, $amount, $num_chq, ($cat1 > 0 ? $cat1 : 0), $user); + $insertid = $object->addline($dateop, $operation, $label, $amount, $num_chq, ($cat1 > 0 ? $cat1 : 0), $user, '', '', $accountancy_code); if ($insertid > 0) { setEventMessages($langs->trans("RecordSaved"), null, 'mesgs'); @@ -331,6 +332,7 @@ if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->banque->m $form = new Form($db); $formother = new FormOther($db); +$formaccounting = new FormAccounting($db); $companystatic=new Societe($db); $bankaccountstatic=new Account($db); @@ -365,6 +367,7 @@ if (!empty($debit)) $param.='&debit='.$debit; if (!empty($credit)) $param.='&credit='.$credit; if (!empty($account)) $param.='&account='.$account; if (!empty($search_num_releve)) $param.='&search_num_releve='.urlencode($search_num_releve); +if ($search_conciliated != '') $param.='&search_conciliated='.urlencode($search_conciliated); if (!empty($bid)) $param.='&bid='.$bid; if (dol_strlen($search_dt_start) > 0) $param .= '&search_start_dtmonth=' . GETPOST('search_start_dtmonth', 'int') . '&search_start_dtday=' . GETPOST('search_start_dtday', 'int') . '&search_start_dtyear=' . GETPOST('search_start_dtyear', 'int'); if (dol_strlen($search_dt_end) > 0) $param .= '&search_end_dtmonth=' . GETPOST('search_end_dtmonth', 'int') . '&search_end_dtday=' . GETPOST('search_end_dtday', 'int') . '&search_end_dtyear=' . GETPOST('search_end_dtyear', 'int'); @@ -408,19 +411,32 @@ if ($id > 0 || ! empty($ref)) dol_fiche_end(); + /* * Buttons actions */ + if ($action != 'reconcile') { print '
'; if (empty($conf->global->BANK_DISABLE_DIRECT_INPUT)) { - if ($user->rights->banque->modifier) { - print ''.$langs->trans("AddBankRecord").''; - } else { - print ''.$langs->trans("AddBankRecord").''; + if (! empty($conf->global->BANK_USE_VARIOUS_PAYMENT)) // If direct entries is done using miscellaneous payments + { + if ($user->rights->banque->modifier) { + print ''.$langs->trans("AddBankRecord").''; + } else { + print ''.$langs->trans("AddBankRecord").''; + } + } + else // If direct entries is not done using miscellaneous payments + { + if ($user->rights->banque->modifier) { + print ''.$langs->trans("AddBankRecord").''; + } else { + print ''.$langs->trans("AddBankRecord").''; + } } } else @@ -431,7 +447,7 @@ if ($id > 0 || ! empty($ref)) if ($object->canBeConciliated() > 0) { // If not cash account and can be reconciliate if ($user->rights->banque->consolidate) { - print ''.$langs->trans("Conciliate").''; + print ''.$langs->trans("Conciliate").''; } else { print ''.$langs->trans("Conciliate").''; } @@ -637,6 +653,60 @@ if ($resql) // print '
'; } + // Form to add a transaction with no invoice + if ($user->rights->banque->modifier && $action == 'addline') + { + print load_fiche_titre($langs->trans("AddBankRecordLong"),'',''); + + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + /*if (! empty($conf->accounting->enabled)) + { + print ''; + }*/ + print ''; + print ''; + + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + /*if (! empty($conf->accounting->enabled)) + { + print ''; + }*/ + print ''; + + print '
'.$langs->trans("Date").' '.$langs->trans("Type").''.$langs->trans("Numero").''.$langs->trans("Description").''.$langs->trans("Debit").''.$langs->trans("Credit").''; + print $langs->trans("AccountAccounting"); + print ' 
'; + $form->select_date(empty($dateop)?-1:$dateop,'op',0,0,0,'transaction'); + print ''; + $form->select_types_paiements((GETPOST('operation')?GETPOST('operation'):($object->courant == Account::TYPE_CASH ? 'LIQ' : '')),'operation','1,2',2,1); + print ''; + print ''; + print ''; + if ($options) { + print '
'.$langs->trans("Rubrique").': '; + print Form::selectarray('cat1', $options, GETPOST('cat1'), 1); + } + print '
'; + print $formaccounting->select_account($accountancy_code, 'accountancy_code', 1, null, 1, 1, ''); + print ''; + print '
'; + print ''; + print '
'; + print '
'; + } /// ajax to adjust value date with plus and less picto print ' diff --git a/htdocs/compta/bank/class/account.class.php b/htdocs/compta/bank/class/account.class.php index 43b6dace19c..08631abec79 100644 --- a/htdocs/compta/bank/class/account.class.php +++ b/htdocs/compta/bank/class/account.class.php @@ -39,7 +39,7 @@ class Account extends CommonObject public $element = 'bank_account'; public $table_element = 'bank_account'; public $picto = 'account'; - + /** * @var int Use id instead of rowid * @deprecated @@ -394,9 +394,10 @@ class Account extends CommonObject * @param User $user User that create * @param string $emetteur Name of cheque writer * @param string $banque Bank of cheque writer + * @param string $accountancycode When we record a free bank entry, we must provide accounting account if accountancy module is on. * @return int Rowid of added entry, <0 if KO */ - function addline($date, $oper, $label, $amount, $num_chq, $categorie, User $user, $emetteur='',$banque='') + function addline($date, $oper, $label, $amount, $num_chq, $categorie, User $user, $emetteur='',$banque='', $accountancycode='') { // Deprecatîon warning if (is_numeric($oper)) { @@ -456,6 +457,7 @@ class Account extends CommonObject $accline->fk_user_author = $user->id; $accline->fk_account = $this->rowid; $accline->fk_type = $oper; + $accline->numero_compte = $accountancycode; if ($num_chq) { $accline->num_chq = $num_chq; @@ -538,7 +540,7 @@ class Account extends CommonObject $now=dol_now(); $this->db->begin(); - + $sql = "INSERT INTO ".MAIN_DB_PREFIX."bank_account ("; $sql.= "datec"; $sql.= ", ref"; @@ -619,14 +621,14 @@ class Account extends CommonObject $result=$this->insertExtraFields(); if ($result < 0) $error++; } - + if (! $error && ! $notrigger) { // Call trigger $result=$this->call_trigger('BANKACCOUNT_CREATE',$user); if ($result < 0) $error++; // End call triggers - } + } } else { @@ -670,9 +672,9 @@ class Account extends CommonObject global $langs,$conf, $hookmanager; $error=0; - + $this->db->begin(); - + // Clean parameters $this->state_id = ($this->state_id?$this->state_id:$this->state_id); $this->country_id = ($this->country_id?$this->country_id:$this->country_id); @@ -739,7 +741,7 @@ class Account extends CommonObject if ($result < 0) $error++; } } - + if (! $error && ! $notrigger) { // Call trigger @@ -754,7 +756,7 @@ class Account extends CommonObject $this->error=$this->db->lasterror(); dol_print_error($this->db); } - + if (! $error) { $this->db->commit(); @@ -906,7 +908,7 @@ class Account extends CommonObject $this->date_creation = $this->db->jdate($obj->date_creation); $this->date_update = $this->db->jdate($obj->date_update); - + // Retreive all extrafield for thirdparty // fetch optionals attributes and labels require_once(DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'); @@ -983,15 +985,15 @@ class Account extends CommonObject global $conf; $error=0; - + $this->db->begin(); - + // Delete link between tag and bank account if (! $error) { $sql = "DELETE FROM ".MAIN_DB_PREFIX."categorie_account"; $sql.= " WHERE fk_account = ".$this->id; - + $resql = $this->db->query($sql); if (!$resql) { @@ -999,15 +1001,15 @@ class Account extends CommonObject $this->error = "Error ".$this->db->lasterror(); } } - + if (! $error) { $sql = "DELETE FROM ".MAIN_DB_PREFIX."bank_account"; $sql.= " WHERE rowid = ".$this->rowid; - + dol_syslog(get_class($this)."::delete", LOG_DEBUG); $result = $this->db->query($sql); - if ($result) + if ($result) { // Remove extrafields if ((empty($conf->global->MAIN_EXTRAFIELDS_DISABLED))) // For avoid conflicts if trigger used @@ -1020,13 +1022,13 @@ class Account extends CommonObject } } } - else + else { $error++; $this->error = "Error ".$this->db->lasterror(); - } + } } - + if (! $error) { $this->db->commit(); @@ -1433,7 +1435,7 @@ class Account extends CommonObject * - DeskCode * * Some countries show less or more bank account properties to the user - * + * * @param int $includeibanbic 1=Return also key for IBAN and BIC * @return array * @see useDetailedBBAN @@ -1554,7 +1556,7 @@ class AccountLine extends CommonObject var $element='bank'; var $table_element='bank'; var $picto = 'generic'; - + var $id; var $ref; var $datec; @@ -1683,8 +1685,9 @@ class AccountLine extends CommonObject $sql .= ", num_chq"; $sql .= ", fk_account"; $sql .= ", fk_type"; - $sql .= ",emetteur,banque"; + $sql .= ", emetteur,banque"; $sql .= ", rappro"; + $sql .= ", numero_compte"; $sql .= ") VALUES ("; $sql .= "'".$this->db->idate($this->datec)."'"; $sql .= ", '".$this->db->idate($this->dateo)."'"; @@ -1698,6 +1701,7 @@ class AccountLine extends CommonObject $sql .= ", ".($this->emetteur ? "'".$this->db->escape($this->emetteur)."'" : "null"); $sql .= ", ".($this->bank_chq ? "'".$this->db->escape($this->bank_chq)."'" : "null"); $sql .= ", ".(int) $this->rappro; + $sql .= ", ".($this->numero_compte ? "'".$this->db->escape($this->numero_compte)."'" : "''"); $sql .= ")"; dol_syslog(get_class($this)."::insert", LOG_DEBUG); @@ -1842,7 +1846,7 @@ class AccountLine extends CommonObject function update_conciliation(User $user, $cat) { global $conf; - + $this->db->begin(); // Check statement field @@ -1854,7 +1858,7 @@ class AccountLine extends CommonObject return -1; } } - + $sql = "UPDATE ".MAIN_DB_PREFIX."bank SET"; $sql.= " rappro = 1"; $sql.= ", num_releve = '".$this->db->escape($this->num_releve)."'"; @@ -2042,7 +2046,7 @@ class AccountLine extends CommonObject return $result; } - + /** * Return label of status (activity, closed) * @@ -2053,7 +2057,7 @@ class AccountLine extends CommonObject { return $this->LibStatut($this->status,$mode); } - + /** * Renvoi le libelle d'un statut donne * @@ -2097,6 +2101,6 @@ class AccountLine extends CommonObject if ($statut==1) return $langs->trans("InActivity").' '.img_picto($langs->trans("InActivity"),'statut4', 'class="pictostatus"'); }*/ } - + } diff --git a/htdocs/compta/bank/class/api_bankaccounts.class.php b/htdocs/compta/bank/class/api_bankaccounts.class.php index 869b86238ff..c6fd3f72def 100644 --- a/htdocs/compta/bank/class/api_bankaccounts.class.php +++ b/htdocs/compta/bank/class/api_bankaccounts.class.php @@ -72,7 +72,7 @@ class BankAccounts extends DolibarrApi $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."bank_account as t"; $sql.= ' WHERE t.entity IN ('.getEntity('bank_account').')'; // Add sql filters - if ($sqlfilters) + if ($sqlfilters) { if (! DolibarrApi::_checkFilters($sqlfilters)) { @@ -81,7 +81,7 @@ class BankAccounts extends DolibarrApi $regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; $sql.=" AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")"; } - + $sql.= $this->db->order($sortfield, $sortorder); if ($limit) { if ($page < 0) @@ -89,10 +89,10 @@ class BankAccounts extends DolibarrApi $page = 0; } $offset = $limit * $page; - + $sql.= $this->db->plimit($limit + 1, $offset); } - + dol_syslog("API Rest request"); $result = $this->db->query($sql); @@ -236,7 +236,7 @@ class BankAccounts extends DolibarrApi function _validate($data) { $account = array(); - foreach (Accounts::$FIELDS as $field) { + foreach (BankAccounts::$FIELDS as $field) { if (! isset($data[$field])) throw new RestException(400, "$field field missing"); $account[$field] = $data[$field]; diff --git a/htdocs/compta/bank/class/paymentvarious.class.php b/htdocs/compta/bank/class/paymentvarious.class.php index 939872ce7fd..1d0568c8064 100644 --- a/htdocs/compta/bank/class/paymentvarious.class.php +++ b/htdocs/compta/bank/class/paymentvarious.class.php @@ -86,9 +86,9 @@ class PaymentVarious extends CommonObject // Update request $sql = "UPDATE ".MAIN_DB_PREFIX."payment_various SET"; - $sql.= " tms=".$this->db->idate($this->tms).","; - $sql.= " datep=".$this->db->idate($this->datep).","; - $sql.= " datev=".$this->db->idate($this->datev).","; + $sql.= " tms='".$this->db->idate($this->tms)."',"; + $sql.= " datep='".$this->db->idate($this->datep)."',"; + $sql.= " datev='".$this->db->idate($this->datev)."',"; $sql.= " sens=".$this->sens.","; $sql.= " amount=".price2num($this->amount).","; $sql.= " fk_typepayment=".$this->fk_typepayment."',"; @@ -325,14 +325,14 @@ class PaymentVarious extends CommonObject $sql.= " VALUES ("; $sql.= "'".$this->db->idate($this->datep)."'"; $sql.= ", '".$this->db->idate($this->datev)."'"; - $sql.= ", '".$this->sens."'"; + $sql.= ", '".$this->db->escape($this->sens)."'"; $sql.= ", ".$this->amount; - $sql.= ", '".$this->type_payment."'"; - $sql.= ", '".$this->num_payment."'"; + $sql.= ", '".$this->db->escape($this->type_payment)."'"; + $sql.= ", '".$this->db->escape($this->num_payment)."'"; if ($this->note) $sql.= ", '".$this->db->escape($this->note)."'"; $sql.= ", '".$this->db->escape($this->label)."'"; - $sql.= ", '".$this->accountancy_code."'"; - $sql.= ", '".$user->id."'"; + $sql.= ", '".$this->db->escape($this->accountancy_code)."'"; + $sql.= ", ".$user->id; $sql.= ", '".$this->db->idate($now)."'"; $sql.= ", NULL"; $sql.= ", ".$conf->entity; @@ -342,7 +342,6 @@ class PaymentVarious extends CommonObject $result = $this->db->query($sql); if ($result) { - $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."payment_various"); if ($this->id > 0) diff --git a/htdocs/compta/bank/index.php b/htdocs/compta/bank/index.php index 9d8cf29ee39..9bc8608692d 100644 --- a/htdocs/compta/bank/index.php +++ b/htdocs/compta/bank/index.php @@ -121,7 +121,7 @@ if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'e include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; // Purge search criteria -if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETPOST("button_removefilter")) // All test are required to be compatible with all browsers +if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x','alpha') || GETPOST('button_removefilter','alpha')) // All test are required to be compatible with all browsers { $statut = 'all'; $search_ref=''; diff --git a/htdocs/compta/bank/releve.php b/htdocs/compta/bank/releve.php index 61a88aa9c2f..ec61c39ee84 100644 --- a/htdocs/compta/bank/releve.php +++ b/htdocs/compta/bank/releve.php @@ -122,7 +122,7 @@ if ($action=="dl" && $numref > 0) { // TODO Replace this with a standard builddoc action that use a document generation module to build the ZIP $log = ''; - + $outdir = $conf->bank->dir_temp.'/'.$numref.'-'.$object->label; $outdirinvoices = $outdir.'/'.$langs->trans("BillsCustomers"); $outdirsupplierinvoices = $outdir.'/'.$langs->trans("BillsSuppliers"); @@ -130,7 +130,7 @@ if ($action=="dl" && $numref > 0) dol_mkdir($outdir); dol_mkdir($outdirinvoices); dol_mkdir($outdirsupplierinvoices); - + //$zipname = $object->label.'-'.$numref . '.zip'; //$zip = new ZipArchive(); //$zip->open($zipname, ZipArchive::OVERWRITE); @@ -138,7 +138,7 @@ if ($action=="dl" && $numref > 0) $sql = $sqlrequestforbankline; $facturestatic=new Facture($db); - + $resd = $db->query($sql); if ($resd) { $numd = $db->num_rows($resd); @@ -146,7 +146,7 @@ if ($action=="dl" && $numref > 0) if ($numd > 0) { $objd = $db->fetch_object($resd); - + $log.='Transaction '.$objd->rowid; $links = $object->get_url($objd->rowid); @@ -165,7 +165,7 @@ if ($action=="dl" && $numref > 0) { $facturestatic->fetch($billid); $subdir = get_exdir($facturestatic->id, 2, 0, 0, $facturestatic, 'invoice'); - + $arrayofinclusion=array(); // TODO Find a way to get doc ODT or other // TODO Use get_exdir $arrayofinclusion[]=preg_quote($facturestatic->ref.'.pdf','/'); @@ -202,7 +202,7 @@ if ($action=="dl" && $numref > 0) { $facturestatic->fetch($billid); $subdir = get_exdir($facturestatic->id, 2, 0, 0, $facturestatic, 'invoice_supplier'); - + $arrayofinclusion=array(); // TODO Find a way to get doc ODT or other // TODO Use get_exdir $arrayofinclusion[]=preg_quote($facturestatic->ref.'.pdf','/'); @@ -227,7 +227,7 @@ if ($action=="dl" && $numref > 0) dol_copy($srcfile, $destfile); } } - } + } break; case "payment_expensereport": /*$subdir = dol_sanitizeFileName($objd->refe); @@ -246,7 +246,7 @@ if ($action=="dl" && $numref > 0) } } $log.="\n"; - + /*if (! empty($upload_dir)) { $files = dol_dir_list($upload_dir, "files", 0, '', '(\.meta|_preview.*\.png)$', '', SORT_ASC, 1); @@ -259,24 +259,24 @@ if ($action=="dl" && $numref > 0) } else { $log .= $key . ',' . $langs->trans("Nofile") . "\n"; } - + }*/ } } - + $db->free($resd); - - + + //$zip->addFromString('log '.$numref.'.csv', $log); //$zip->close(); - + // /Then download the zipped file. /*header('Content-Type: application/zip'); header('Content-disposition: attachment; filename=' . $zipname); header('Content-Length: ' . filesize($zipname)); - + readfile($zipname); - + exit;*/ } @@ -329,18 +329,18 @@ if (empty($numref)) dol_fiche_head($head,'statement',$langs->trans("FinancialAccount"),0,'account'); $linkback = ''.$langs->trans("BackToList").''; - + dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref, '', 0, '', '', 1); - + dol_fiche_end(); - + print '
'; if ($object->canBeConciliated() > 0) { // If not cash account and can be reconciliate if ($user->rights->banque->consolidate) { - print ''.$langs->trans("Conciliate").''; + print ''.$langs->trans("Conciliate").''; } else { print ''.$langs->trans("Conciliate").''; } @@ -348,7 +348,7 @@ if (empty($numref)) print '
'; print '

'; - + print_barre_liste('', $page, $_SERVER["PHP_SELF"], "&account=".$object->id, $sortfield, $sortorder,'',$numrows); @@ -481,8 +481,8 @@ else //$mesprevnext.='   '; $mesprevnext.=''; $mesprevnext.='
'; - - $title=$langs->trans("AccountStatement").' '.$numref.', '.$langs->trans("BankAccount").' : '.$object->getNomUrl(0, 'receipts'); + + $title=$langs->trans("AccountStatement").' '.$numref.' - '.$langs->trans("BankAccount").' '.$object->getNomUrl(1, 'receipts'); print load_fiche_titre($title, $mesprevnext, 'title_bank.png'); //print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, 0, $nbtotalofrecords, 'title_bank.png', 0, '', '', 0, 1); print '
'; @@ -520,7 +520,7 @@ else // Recherche les ecritures pour le releve $sql = $sqlrequestforbankline; - + $result = $db->query($sql); if ($result) { @@ -553,7 +553,7 @@ else print img_edit_add() .""; print "\n"; print ''; - + // Type and num if ($objp->fk_type == 'SOLD') { $type_label=' '; @@ -753,9 +753,9 @@ else print "\n"; print ""; print "
"; - + print "\n"; - + // Add a download button if ($conf->global->MAIN_FEATURES_LEVEL >= 2) // Started a rewrite to make this feature more Dolibarr compliant. Still need dev to be completed. { diff --git a/htdocs/compta/bank/various_payment/card.php b/htdocs/compta/bank/various_payment/card.php index e19deca91c9..f75c111094d 100644 --- a/htdocs/compta/bank/various_payment/card.php +++ b/htdocs/compta/bank/various_payment/card.php @@ -29,15 +29,14 @@ require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; if (! empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php'; if (! empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingaccount.class.php'; -$langs->load("compta"); -$langs->load("banks"); -$langs->load("bills"); -$langs->load("users"); -$langs->load("accountancy"); +$langs->loadLangs(array("compta", "banks", "bills", "users", "accountancy")); + +// Get parameters +$id = GETPOST('id', 'int'); +$action = GETPOST('action', 'alpha'); +$cancel = GETPOST('cancel', 'aZ09'); +$backtopage = GETPOST('backtopage', 'alpha'); -$id=GETPOST("id",'int'); -$action=GETPOST('action','alpha'); -$cancel=GETPOST('cancel','alpha'); $accountid=GETPOST("accountid") > 0 ? GETPOST("accountid","int") : 0; $label=GETPOST("label","alpha"); $sens=GETPOST("sens","int"); @@ -61,115 +60,139 @@ $hookmanager->initHooks(array('variouscard','globalcard')); * Actions */ -if (! empty($cancel)) +$parameters=array(); +$reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks +if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + +if (empty($reshook)) { - header("Location: index.php"); - exit; -} - -if ($action == 'add' && empty($cancel)) -{ - $error=0; - - $datep=dol_mktime(12,0,0, GETPOST("datepmonth"), GETPOST("datepday"), GETPOST("datepyear")); - $datev=dol_mktime(12,0,0, GETPOST("datevmonth"), GETPOST("datevday"), GETPOST("datevyear")); - if (empty($datev)) $datev=$datep; - - $object->accountid=GETPOST("accountid") > 0 ? GETPOST("accountid","int") : 0; - $object->datev=$datev; - $object->datep=$datep; - $object->amount=price2num(GETPOST("amount")); - $object->label=GETPOST("label"); - $object->note=GETPOST("note"); - $object->type_payment=GETPOST("paymenttype") > 0 ? GETPOST("paymenttype", "int") : 0; - $object->num_payment=GETPOST("num_payment"); - $object->fk_user_author=$user->id; - $object->accountancy_code=GETPOST("accountancy_code") > 0 ? GETPOST("accountancy_code","int") : ""; - - if (empty($datep) || empty($datev)) + if ($cancel) { - setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Date")), null, 'errors'); - $error++; - } - if (empty($object->type_payment) || $object->type_payment < 0) - { - setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("PaymentMode")), null, 'errors'); - $error++; - } - if (empty($object->amount)) - { - setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Amount")), null, 'errors'); - $error++; - } - if (! empty($conf->banque->enabled) && ! $object->accountid > 0) - { - setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("BankAccount")), null, 'errors'); - $error++; - } - - if (! $error) - { - $db->begin(); - - $ret=$object->create($user); - if ($ret > 0) + if ($action != 'addlink') { - $db->commit(); - header("Location: index.php"); + $urltogo=$backtopage?$backtopage:dol_buildpath('/mymodule/myobject_list.php',1); + header("Location: ".$urltogo); exit; } - else - { - $db->rollback(); - setEventMessages($object->error, $object->errors, 'errors'); - $action="create"; - } + if ($id > 0 || ! empty($ref)) $ret = $object->fetch($id,$ref); + $action=''; } - $action='create'; -} - -if ($action == 'delete') -{ - $result=$object->fetch($id); - - if ($object->rappro == 0) + if ($action == 'add') { - $db->begin(); + $error=0; - $ret=$object->delete($user); - if ($ret > 0) + $datep=dol_mktime(12,0,0, GETPOST("datepmonth"), GETPOST("datepday"), GETPOST("datepyear")); + $datev=dol_mktime(12,0,0, GETPOST("datevmonth"), GETPOST("datevday"), GETPOST("datevyear")); + if (empty($datev)) $datev=$datep; + + $object->accountid=GETPOST("accountid") > 0 ? GETPOST("accountid","int") : 0; + $object->datev=$datev; + $object->datep=$datep; + $object->amount=price2num(GETPOST("amount")); + $object->label=GETPOST("label"); + $object->note=GETPOST("note"); + $object->type_payment=GETPOST("paymenttype") > 0 ? GETPOST("paymenttype", "int") : 0; + $object->num_payment=GETPOST("num_payment"); + $object->fk_user_author=$user->id; + $object->accountancy_code=GETPOST("accountancy_code") > 0 ? GETPOST("accountancy_code","int") : ""; + $object->sens=GETPOST('sens'); + + if (empty($datep) || empty($datev)) { - if ($object->fk_bank) - { - $accountline=new AccountLine($db); - $result=$accountline->fetch($object->fk_bank); - if ($result > 0) $result=$accountline->delete($user); // $result may be 0 if not found (when bank entry was deleted manually and fk_bank point to nothing) - } + $langs->load('errors'); + setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Date")), null, 'errors'); + $error++; + } + if (empty($object->type_payment) || $object->type_payment < 0) + { + $langs->load('errors'); + setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("PaymentMode")), null, 'errors'); + $error++; + } + if (empty($object->amount)) + { + $langs->load('errors'); + setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Amount")), null, 'errors'); + $error++; + } + if (! empty($conf->banque->enabled) && ! $object->accountid > 0) + { + $langs->load('errors'); + setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("BankAccount")), null, 'errors'); + $error++; + } + if (! empty($conf->accounting->enabled) && ! $object->accountancy_code) + { + $langs->load('errors'); + setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("AccountAccounting")), null, 'errors'); + $error++; + } - if ($result >= 0) + if (! $error) + { + $db->begin(); + + $ret=$object->create($user); + if ($ret > 0) { $db->commit(); - header("Location: ".DOL_URL_ROOT.'/compta/salaries/index.php'); + header("Location: index.php"); exit; } else { - $object->error=$accountline->error; + $db->rollback(); + setEventMessages($object->error, $object->errors, 'errors'); + $action="create"; + } + } + + $action='create'; + } + + if ($action == 'delete') + { + $result=$object->fetch($id); + + if ($object->rappro == 0) + { + $db->begin(); + + $ret=$object->delete($user); + if ($ret > 0) + { + if ($object->fk_bank) + { + $accountline=new AccountLine($db); + $result=$accountline->fetch($object->fk_bank); + if ($result > 0) $result=$accountline->delete($user); // $result may be 0 if not found (when bank entry was deleted manually and fk_bank point to nothing) + } + + if ($result >= 0) + { + $db->commit(); + header("Location: ".DOL_URL_ROOT.'/compta/salaries/index.php'); + exit; + } + else + { + $object->error=$accountline->error; + $db->rollback(); + setEventMessages($object->error, $object->errors, 'errors'); + } + } + else + { $db->rollback(); setEventMessages($object->error, $object->errors, 'errors'); } } else { - $db->rollback(); - setEventMessages($object->error, $object->errors, 'errors'); + setEventMessages('Error try do delete a line linked to a conciliated bank transaction', null, 'errors'); } } - else - { - setEventMessages('Error try do delete a line linked to a conciliated bank transaction', null, 'errors'); - } } @@ -200,8 +223,9 @@ if ($id) /* ************************************************************************** */ if ($action == 'create') { - print '
'; + print ''; print ''; + print ''; print ''; print load_fiche_titre($langs->trans("NewVariousPayment"),'', 'title_accountancy.png'); @@ -269,7 +293,7 @@ if ($action == 'create') // Accountancy account if (! empty($conf->accounting->enabled)) { - print ''.$langs->trans("AccountAccounting").''; + print ''.$langs->trans("AccountAccounting").''; print ''; print $formaccounting->select_account($accountancy_code, 'accountancy_code', 1, null, 1, 1, ''); print ''; @@ -292,7 +316,7 @@ if ($action == 'create') print '
'; print ''; - print '     '; + print '   '; print ''; print '
'; diff --git a/htdocs/compta/bank/various_payment/index.php b/htdocs/compta/bank/various_payment/index.php index 6594bacea7f..5b2488cc5e8 100644 --- a/htdocs/compta/bank/various_payment/index.php +++ b/htdocs/compta/bank/various_payment/index.php @@ -1,5 +1,6 @@ + * Copyright (C) 2017 Laurent Destailleur * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -16,9 +17,9 @@ */ /** - * \file htdocs/compta/bank/various_payment/index.php - * \ingroup bank - * \brief List of various payments + * \file htdocs/compta/bank/various_payment/index.php + * \ingroup bank + * \brief List of various payments */ require '../../../main.inc.php'; @@ -34,6 +35,8 @@ $socid = GETPOST("socid","int"); if ($user->societe_id) $socid=$user->societe_id; $result = restrictedArea($user, 'banque', '', '', ''); +$optioncss = GETPOST('optioncss','alpha'); + $limit = GETPOST('limit')?GETPOST('limit','int'):$conf->liste_limit; $search_ref = GETPOST('search_ref','int'); $search_user = GETPOST('search_user','alpha'); @@ -50,11 +53,10 @@ $pageprev = $page - 1; $pagenext = $page + 1; if (! $sortfield) $sortfield="v.datep"; if (! $sortorder) $sortorder="DESC"; -$optioncss = GETPOST('optioncss','alpha'); -$filtre=$_GET["filtre"]; +$filtre=GETPOST("filtre",'alpha'); -if (empty($_REQUEST['typeid'])) +if (! GETPOST('typeid')) { $newfiltre=str_replace('filtre=','',$filtre); $filterarray=explode('-',$newfiltre); @@ -66,10 +68,10 @@ if (empty($_REQUEST['typeid'])) } else { - $typeid=$_REQUEST['typeid']; + $typeid=GETPOST('typeid'); } -if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETPOST("button_removefilter")) // All test are required to be compatible with all browsers +if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x','alpha') || GETPOST('button_removefilter','alpha')) // All test are required to be compatible with all browsers { $search_ref=""; $search_label=""; @@ -240,9 +242,12 @@ if ($result) $colspan=4; if (! empty($conf->banque->enabled)) $colspan++; - print ''.$langs->trans("Total").''; + print ''; + print ''.$langs->trans("Total").''; print ''.price($total).""; - print ""; + print ''; + print ''; + print ''; print ""; print '
'; diff --git a/htdocs/compta/deplacement/list.php b/htdocs/compta/deplacement/list.php index de5e00045e7..e42e9f2325a 100644 --- a/htdocs/compta/deplacement/list.php +++ b/htdocs/compta/deplacement/list.php @@ -57,7 +57,7 @@ if (! $sortfield) $sortfield="d.dated"; $year=GETPOST("year"); $month=GETPOST("month"); -if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter")) // Both test are required to be compatible with all browsers +if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter','alpha')) // Both test are required to be compatible with all browsers { $search_ref=""; $search_name=""; diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index dd89ae944ef..c8fb3804e60 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -1440,7 +1440,7 @@ if (empty($reshook)) { if (GETPOST('type') < 0 && ! GETPOST('search_idprod')) { - setEventMessages($langs->trans('ErrorChooseBetweenFreeAntryOrPredefinedProduct'), null, 'errors'); + setEventMessages($langs->trans('ErrorChooseBetweenFreeEntryOrPredefinedProduct'), null, 'errors'); $error ++; } } @@ -3075,6 +3075,7 @@ else if ($id > 0 || ! empty($ref)) $morehtmlref.=$form->editfieldval("RefCustomer", 'ref_client', $object->ref_client, $object, $user->rights->facture->creer, 'string', '', null, null, '', 1); // Thirdparty $morehtmlref.='
'.$langs->trans('ThirdParty') . ' : ' . $object->thirdparty->getNomUrl(1); + if (empty($conf->global->MAIN_DISABLE_OTHER_LINK) && $object->thirdparty->id > 0) $morehtmlref.=' (
'.$langs->trans("OtherBills").')'; // Project if (! empty($conf->projet->enabled)) { @@ -4185,7 +4186,7 @@ else if ($id > 0 || ! empty($ref)) { if (! $objectidnext && count($object->lines) > 0) { - print '
' . $langs->trans("ChangeIntoRepeatableInvoice") . '
'; + print '
' . $langs->trans("ChangeIntoRepeatableInvoice") . '
'; } } diff --git a/htdocs/compta/facture/fiche-rec.php b/htdocs/compta/facture/fiche-rec.php index 22306e498f2..3a072f946be 100644 --- a/htdocs/compta/facture/fiche-rec.php +++ b/htdocs/compta/facture/fiche-rec.php @@ -46,13 +46,18 @@ $langs->load('compta'); $langs->load('admin'); $langs->load('other'); +$action = GETPOST('action','alpha'); +$massaction = GETPOST('massaction','alpha'); +$show_files = GETPOST('show_files','int'); +$confirm = GETPOST('confirm','alpha'); +$cancel = GETPOST('cancel', 'alpha'); +$toselect = GETPOST('toselect', 'array'); +$contextpage= GETPOST('contextpage','aZ')?GETPOST('contextpage','aZ'):'invoicetemplatelist'; // To manage different context of search + // Security check $id=(GETPOST('facid','int')?GETPOST('facid','int'):GETPOST('id','int')); -$confirm = GETPOST('confirm', 'alpha'); -$cancel = GETPOST('cancel', 'alpha'); $lineid=GETPOST('lineid','int'); $ref=GETPOST('ref','alpha'); -$action=GETPOST('action', 'alpha'); if ($user->societe_id) $socid=$user->societe_id; $objecttype = 'facture_rec'; if ($action == "create" || $action == "add") $objecttype = ''; @@ -112,7 +117,7 @@ $arrayfields=array( 'f.tva'=>array('label'=>$langs->trans("AmountVAT"), 'checked'=>1), 'f.total_ttc'=>array('label'=>$langs->trans("AmountTTC"), 'checked'=>1), 'f.frequency'=>array('label'=>$langs->trans("RecurringInvoiceTemplate"), 'checked'=>1), - 'f.nb_gen_done'=>array('label'=>$langs->trans("NbGeneration"), 'checked'=>1), + 'f.nb_gen_done'=>array('label'=>$langs->trans("NbOfGenerationDone"), 'checked'=>1), 'f.date_last_gen'=>array('label'=>$langs->trans("DateLastGeneration"), 'checked'=>1), 'f.date_when'=>array('label'=>$langs->trans("NextDateToExecution"), 'checked'=>1), 'f.datec'=>array('label'=>$langs->trans("DateCreation"), 'checked'=>0, 'position'=>500), @@ -132,6 +137,9 @@ if (is_array($extrafields->attribute_label) && count($extrafields->attribute_lab * Actions */ +if (GETPOST('cancel')) { $action='list'; $massaction=''; } +if (! GETPOST('confirmmassaction') && $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'); @@ -140,6 +148,9 @@ if (empty($reshook)) { if (GETPOST('cancel')) $action=''; + // Selection of new fields + include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; + // Set note include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include, not include_once @@ -148,7 +159,7 @@ if (empty($reshook)) include DOL_DOCUMENT_ROOT.'/core/actions_lineupdown.inc.php'; // Must be include, not include_once // Do we click on purge search criteria ? - if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETPOST("button_removefilter")) // All test are required to be compatible with all browsers + if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x','alpha') || GETPOST('button_removefilter','alpha')) // All test are required to be compatible with all browsers { $search_ref=''; $search_societe=''; @@ -165,6 +176,14 @@ if (empty($reshook)) $search_array_options=array(); } + // Mass actions + /*$objectclass='MyObject'; + $objectlabel='MyObject'; + $permtoread = $user->rights->mymodule->read; + $permtodelete = $user->rights->mymodule->delete; + $uploaddir = $conf->mymodule->dir_output; + include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';*/ + // Create predefined invoice if ($action == 'add') { @@ -517,7 +536,7 @@ if (empty($reshook)) $tmpvat = price2num(preg_replace('/\s*\(.*\)/', '', $tva_tx)); $tmpprodvat = price2num(preg_replace('/\s*\(.*\)/', '', $prod->tva_tx)); - + // if price ht was forced (ie: from gui when calculated by margin rate and cost price). TODO Why this ? if (! empty($price_ht)) { @@ -905,7 +924,7 @@ if ($action == 'create') print ''; print ''; - dol_fiche_head(); + dol_fiche_head(null, '', '', 0); $rowspan=4; if (! empty($conf->projet->enabled)) $rowspan++; @@ -942,7 +961,7 @@ if ($action == 'create') '__INVOICE_NEXT_YEAR__' => $langs->trans("NextYearOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date(dol_time_plus_duree($object->date, 1, 'y'),'%Y').')' ); $substitutionarray['__(TransKey)__']=$langs->trans("TransKey"); - + $htmltext = ''.$langs->trans("FollowingConstantsWillBeSubstituted").':
'; foreach($substitutionarray as $key => $val) { @@ -952,10 +971,10 @@ if ($action == 'create') // Public note print ''; - print ''; + print ''; print $form->textwithpicto($langs->trans('NotePublic'), $htmltext, 1, 'help', '', 0, 2, 'notepublic'); print ''; - print ''; + print ''; $doleditor = new DolEditor('note_public', $note_public, '', 80, 'dolibarr_notes', 'In', 0, false, true, ROWS_3, '90%'); print $doleditor->Create(1); @@ -963,7 +982,7 @@ if ($action == 'create') if (empty($user->societe_id)) { print ''; - print ''; + print ''; print $form->textwithpicto($langs->trans('NotePrivate'), $htmltext, 1, 'help', '', 0, 2, 'noteprivate'); print ''; print ''; @@ -1007,12 +1026,14 @@ if ($action == 'create') print ""; - print '

'; + dol_fiche_end(); // Autogeneration $title = $langs->trans("Recurrence"); - print load_fiche_titre($title, '', 'calendar'); + print load_fiche_titre(' '.$title, '', ''); + + dol_fiche_head(null, '', '', 0); print ''; @@ -1040,7 +1061,8 @@ if ($action == 'create') print "
"; - print '

'; + dol_fiche_end(); + $title = $langs->trans("ProductsAndServices"); if (empty($conf->service->enabled)) @@ -1078,8 +1100,6 @@ if ($action == 'create') } print "\n"; - dol_fiche_end(); - print '
'; print '     '; print ''; @@ -1260,7 +1280,7 @@ else '__INVOICE_NEXT_YEAR__' => $langs->trans("NextYearOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date(dol_time_plus_duree($dateexample, 1, 'y'),'%Y').')' ); $substitutionarray['__(TransKey)__']=$langs->trans("TransKey"); - + $htmltext = ''.$langs->trans("FollowingConstantsWillBeSubstituted").':
'; foreach($substitutionarray as $key => $val) { @@ -1291,7 +1311,7 @@ else print ''; print '
'; print $langs->trans('RIB'); print ''; - if (($action != 'editbankaccount') && $user->rights->commande->creer && ! empty($object->brouillon)) + if (($action != 'editbankaccount') && $user->rights->facture->creer && ! empty($object->brouillon)) print 'id.'">'.img_edit($langs->trans('SetBankAccount'),1).'
'; print ''; @@ -1323,7 +1343,7 @@ else print ''; print ''; - + // if "frequency" is empty or = 0, the reccurence is disabled print ''; $total_ttc += $obj->total_ttc; - $total += $obj->total; + $total += $obj->total_ht; $totalam += $obj->am; $i++; diff --git a/htdocs/compta/localtax/class/localtax.class.php b/htdocs/compta/localtax/class/localtax.class.php index e59b2c6ce2b..870c123b468 100644 --- a/htdocs/compta/localtax/class/localtax.class.php +++ b/htdocs/compta/localtax/class/localtax.class.php @@ -151,9 +151,9 @@ class Localtax extends CommonObject // Update request $sql = "UPDATE ".MAIN_DB_PREFIX."localtax SET"; $sql.= " localtaxtype=".$this->ltt.","; - $sql.= " tms=".$this->db->idate($this->tms).","; - $sql.= " datep=".$this->db->idate($this->datep).","; - $sql.= " datev=".$this->db->idate($this->datev).","; + $sql.= " tms='".$this->db->idate($this->tms)."',"; + $sql.= " datep='".$this->db->idate($this->datep)."',"; + $sql.= " datev='".$this->db->idate($this->datev)."',"; $sql.= " amount=".price2num($this->amount).","; $sql.= " label='".$this->db->escape($this->label)."',"; $sql.= " note='".$this->db->escape($this->note)."',"; diff --git a/htdocs/compta/localtax/quadri_detail.php b/htdocs/compta/localtax/quadri_detail.php index 13c753db464..a70066bdb5d 100644 --- a/htdocs/compta/localtax/quadri_detail.php +++ b/htdocs/compta/localtax/quadri_detail.php @@ -54,8 +54,9 @@ if (empty($year)) $year_current = $year; $year_start = $year; } -$date_start=dol_mktime(0,0,0,$_REQUEST["date_startmonth"],$_REQUEST["date_startday"],$_REQUEST["date_startyear"]); -$date_end=dol_mktime(23,59,59,$_REQUEST["date_endmonth"],$_REQUEST["date_endday"],$_REQUEST["date_endyear"]); + +$date_start = dol_mktime( 0, 0, 0, GETPOST( "date_startmonth" ), GETPOST( "date_startday" ), GETPOST( "date_startyear" ) ); +$date_end = dol_mktime( 23, 59, 59, GETPOST( "date_endmonth" ), GETPOST( "date_endday" ), GETPOST( "date_endyear" ) ); // Quarter if (empty($date_start) || empty($date_end)) // We define date_start and date_end { @@ -92,12 +93,9 @@ $socid = GETPOST('socid','int'); if ($user->societe_id) $socid=$user->societe_id; $result = restrictedArea($user, 'tax', '', '', 'charges'); - - -/* +/** * View */ - $morequerystring=''; $listofparams=array('date_startmonth','date_startyear','date_startday','date_endmonth','date_endyear','date_endday'); foreach($listofparams as $param) @@ -118,6 +116,7 @@ $paymentfourn_static=new PaiementFourn($db); $fsearch.=' '; $fsearch.=' '; +$fsearch.=' '; $calc=$conf->global->MAIN_INFO_LOCALTAX_CALC.$local; @@ -196,9 +195,8 @@ $total = 0; $i=0; // Load arrays of datas -$x_coll = vat_by_date($db, 0, 0, $date_start, $date_end, $modetax, 'sell'); -$x_paye = vat_by_date($db, 0, 0, $date_start, $date_end, $modetax, 'buy'); - +$x_coll = tax_by_date('localtax' . $local, $db, 0, 0, $date_start, $date_end, $modetax, 'sell'); +$x_paye = tax_by_date('localtax' . $local, $db, 0, 0, $date_start, $date_end, $modetax, 'buy'); echo '
'.$title.'
'; print ''; print "\n"; + print ''; - print_liste_field_titre($langs->trans("Ref"),$_SERVER['PHP_SELF'],"f.titre","",$param,"",$sortfield,$sortorder); - print_liste_field_titre($langs->trans("ThirdParty"),$_SERVER['PHP_SELF'],"s.nom","",$param,"",$sortfield,$sortorder); - print_liste_field_titre($langs->trans("AmountHT"),$_SERVER['PHP_SELF'],"f.total","",$param,'align="right"',$sortfield,$sortorder); - print_liste_field_titre($langs->trans("AmountVAT"),$_SERVER['PHP_SELF'],"f.tva","",$param,'align="right"',$sortfield,$sortorder); - print_liste_field_titre($langs->trans("AmountTTC"),$_SERVER['PHP_SELF'],"f.total_ttc","",$param,'align="right"',$sortfield,$sortorder); - print_liste_field_titre($langs->trans("RecurringInvoiceTemplate"),$_SERVER['PHP_SELF'],"f.frequency","",$param,'align="center"',$sortfield,$sortorder); - if (! empty($arrayfields['f.nb_gen_done']['checked'])) - { - print_liste_field_titre($langs->trans("NbOfGenerationDone"),$_SERVER['PHP_SELF'],"f.nb_gen_done","",$param,'align="center"',$sortfield,$sortorder); - } - print_liste_field_titre($langs->trans("DateLastGeneration"),$_SERVER['PHP_SELF'],"f.date_last_gen","",$param,'align="center"',$sortfield,$sortorder); - print_liste_field_titre($langs->trans("NextDateToExecution"),$_SERVER['PHP_SELF'],"f.date_when","",$param,'align="center"',$sortfield,$sortorder); - print_liste_field_titre(''); // Field may contains ling text + if (! empty($arrayfields['f.titre']['checked'])) print_liste_field_titre($arrayfields['f.titre']['label'],$_SERVER['PHP_SELF'],"f.titre","",$param,"",$sortfield,$sortorder); + if (! empty($arrayfields['s.nom']['checked'])) print_liste_field_titre($arrayfields['s.nom']['label'],$_SERVER['PHP_SELF'],"s.nom","",$param,"",$sortfield,$sortorder); + if (! empty($arrayfields['f.total']['checked'])) print_liste_field_titre($arrayfields['f.total']['label'],$_SERVER['PHP_SELF'],"f.total","",$param,'align="right"',$sortfield,$sortorder); + if (! empty($arrayfields['f.tva']['checked'])) print_liste_field_titre($arrayfields['f.tva']['label'],$_SERVER['PHP_SELF'],"f.tva","",$param,'align="right"',$sortfield,$sortorder); + if (! empty($arrayfields['f.total_ttc']['checked'])) print_liste_field_titre($arrayfields['f.total_ttc']['label'],$_SERVER['PHP_SELF'],"f.total_ttc","",$param,'align="right"',$sortfield,$sortorder); + if (! empty($arrayfields['f.frequency']['checked'])) print_liste_field_titre($arrayfields['f.frequency']['label'],$_SERVER['PHP_SELF'],"f.frequency","",$param,'align="center"',$sortfield,$sortorder); + if (! empty($arrayfields['f.nb_gen_done']['checked'])) print_liste_field_titre($arrayfields['f.nb_gen_done']['label'],$_SERVER['PHP_SELF'],"f.nb_gen_done","",$param,'align="center"',$sortfield,$sortorder); + if (! empty($arrayfields['f.date_last_gen']['checked'])) print_liste_field_titre($arrayfields['f.date_last_gen']['label'],$_SERVER['PHP_SELF'],"f.date_last_gen","",$param,'align="center"',$sortfield,$sortorder); + if (! empty($arrayfields['f.date_when']['checked'])) print_liste_field_titre($arrayfields['f.date_when']['label'],$_SERVER['PHP_SELF'],"f.date_when","",$param,'align="center"',$sortfield,$sortorder); + if (! empty($arrayfields['f.datec']['checked'])) print_liste_field_titre($arrayfields['f.datec']['label'],$_SERVER['PHP_SELF'],"f.date_when","",$param,'align="center"',$sortfield,$sortorder); + if (! empty($arrayfields['f.tms']['checked'])) print_liste_field_titre($arrayfields['f.tms']['label'],$_SERVER['PHP_SELF'],"f.date_when","",$param,'align="center"',$sortfield,$sortorder); + print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"],"",'','','align="center"',$sortfield,$sortorder,'maxwidthsearch ')."\n"; print "\n"; - - + + if ($num > 0) { $var=true; @@ -1800,26 +1828,67 @@ else { $objp = $db->fetch_object($resql); - print ''; - - print '\n"; - $companystatic->id=$objp->socid; $companystatic->name=$objp->name; - print ''; - print ''."\n"; - print ''."\n"; - print ''."\n"; - print ''; + print ''; + + if (! empty($arrayfields['f.titre']['checked'])) + { + print '\n"; + } + if (! empty($arrayfields['s.nom']['checked'])) + { + print ''; + } + if (! empty($arrayfields['f.total']['checked'])) + { + print ''."\n"; + } + if (! empty($arrayfields['f.tva']['checked'])) + { + print ''."\n"; + } + if (! empty($arrayfields['f.total_ttc']['checked'])) + { + print ''."\n"; + } + if (! empty($arrayfields['f.frequency']['checked'])) + { + print ''; + } if (! empty($arrayfields['f.nb_gen_done']['checked'])) { - print ''; + print ''; } - print ''; - print ''; - + if (! empty($arrayfields['f.date_last_gen']['checked'])) + { + print ''; + } + if (! empty($arrayfields['f.date_when']['checked'])) + { + print ''; + } + if (! empty($arrayfields['f.datec']['checked'])) + { + print ''; + } + if (! empty($arrayfields['f.tms']['checked'])) + { + print ''; + } + // Action column print ''; + else + { + $colspan=1; + foreach($arrayfields as $key => $val) { if (! empty($val['checked'])) $colspan++; } + print ''; + } print "
'; @@ -1558,7 +1578,8 @@ else * List mode */ $sql = "SELECT s.nom as name, s.rowid as socid, f.rowid as facid, f.titre, f.total, f.tva as total_vat, f.total_ttc, f.frequency,"; - $sql.= " f.nb_gen_done, f.nb_gen_max, f.date_last_gen, f.date_when"; + $sql.= " f.nb_gen_done, f.nb_gen_max, f.date_last_gen, f.date_when,"; + $sql.= " f.datec, f.tms"; $sql.= " FROM ".MAIN_DB_PREFIX."societe as s,".MAIN_DB_PREFIX."facture_rec as f"; if (! $user->rights->societe->client->voir && ! $socid) { $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; @@ -1570,10 +1591,10 @@ else } if ($search_ref) $sql .= natural_search('f.titre', $search_ref); if ($search_societe) $sql .= natural_search('s.nom', $search_societe); - if ($search_frequency) $sql .= natural_search('f.frequency', $search_frequency); if ($search_montant_ht != '') $sql.= natural_search('f.total', $search_montant_ht, 1); if ($search_montant_vat != '') $sql.= natural_search('f.tva', $search_montant_vat, 1); if ($search_montant_ttc != '') $sql.= natural_search('f.total_ttc', $search_montant_ttc, 1); + if ($search_frequency > 0) $sql.= natural_search('f.frequency', $search_frequency); if ($search_frequency == '1') $sql.= ' AND f.frequency > 0'; if ($search_frequency == '0') $sql.= ' AND (f.frequency IS NULL or f.frequency = 0)'; @@ -1605,23 +1626,24 @@ else } $nbtotalofrecords = ''; - if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) - { - $result = $db->query($sql); - $nbtotalofrecords = $db->num_rows($result); - } + if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) + { + $result = $db->query($sql); + $nbtotalofrecords = $db->num_rows($result); + } - $sql.= $db->order($sortfield, $sortorder); - $sql.= $db->plimit($limit+1,$offset); + $sql.= $db->order($sortfield, $sortorder); + $sql.= $db->plimit($limit+1,$offset); $resql = $db->query($sql); if ($resql) { $num = $db->num_rows($resql); - $param='&socid='.$socid; - if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage; + $param=''; + if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage; if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit; + if ($socid) $param.='&socid='.$socid; if ($day) $param.='&day='.$day; if ($month) $param.='&month='.$month; if ($year) $param.='&year=' .$year; @@ -1631,9 +1653,9 @@ else if ($search_ref) $param.='&search_ref=' .$search_ref; if ($search_societe) $param.='&search_societe=' .$search_societe; if ($search_montant_ht != '') $param.='&search_montant_ht='.$search_montant_ht; - if ($search_montant_vat != '') $param.='&search_montant_vat='.$search_montant_vat; + if ($search_montant_vat != '') $param.='&search_montant_vat='.$search_montant_vat; if ($search_montant_ttc != '') $param.='&search_montant_ttc='.$search_montant_ttc; - if ($search_frequency) $param.='&search_frequency=' .$search_frequency; + if ($search_frequency > 0) $param.='&search_frequency=' .$search_frequency; if ($option) $param.="&option=".$option; if ($optioncss != '') $param.='&optioncss='.$optioncss; // Add $param from extra fields @@ -1646,14 +1668,20 @@ else $massactionbutton=$form->selectMassAction('', $massaction == 'presend' ? array() : array('presend'=>$langs->trans("SendByMail"), 'builddoc'=>$langs->trans("PDFMerge"))); - print ''."\n"; + $varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage; + $selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields + //$selectedfields.=$form->showCheckAddButtons('checkforselect', 1); + + print ''."\n"; if ($optioncss != '') print ''; print ''; + print ''; print ''; print ''; print ''; print ''; - print ''; + print ''; + print ''; print_barre_liste($langs->trans("RepeatableInvoices"),$page,$_SERVER['PHP_SELF'],$param,$sortfield,$sortorder,'',$num,$nbtotalofrecords,'title_accountancy.png',0,'','',$limit); @@ -1776,23 +1804,23 @@ else print '
'.img_object($langs->trans("ShowBill"),"bill").' '.$objp->titre; - print "'.$companystatic->getNomUrl(1,'customer').''.price($objp->total).''.price($objp->total_vat).''.price($objp->total_ttc).''.yn($objp->frequency?1:0).'
'.img_object($langs->trans("ShowBill"),"bill").' '.$objp->titre; + print "'.$companystatic->getNomUrl(1,'customer').''.price($objp->total).''.price($objp->total_vat).''.price($objp->total_ttc).''.yn($objp->frequency?1:0).''.($objp->frequency ? $objp->nb_gen_done.($objp->nb_gen_max>0?' / '. $objp->nb_gen_max:'') : '').''; + print ($objp->frequency ? $objp->nb_gen_done.($objp->nb_gen_max>0?' / '. $objp->nb_gen_max:'') : ''.$langs->trans('NA').''); + print ''.($objp->frequency ? dol_print_date($objp->date_last_gen,'day') : '').''.($objp->frequency ? dol_print_date($objp->date_when,'day') : '').''; + print ($objp->frequency ? dol_print_date($db->jdate($objp->date_last_gen),'day') : ''.$langs->trans('NA').''); + print ''; + print ($objp->frequency ? dol_print_date($db->jdate($objp->date_when),'day') : ''.$langs->trans('NA').''); + print ''; + print dol_print_date($db->jdate($objp->datec),'dayhour'); + print ''; + print dol_print_date($db->jdate($objp->tms),'dayhour'); + print ''; if ($user->rights->facture->creer) { @@ -1842,7 +1911,12 @@ else $i++; } } - else print '
'.$langs->trans("NoneF").'
'.$langs->trans("NoRecordFound").'
"; print ""; diff --git a/htdocs/compta/facture/list.php b/htdocs/compta/facture/list.php index 5ab62bf5337..13e9a22d717 100644 --- a/htdocs/compta/facture/list.php +++ b/htdocs/compta/facture/list.php @@ -191,7 +191,7 @@ if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'e include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; // Do we click on purge search criteria ? -if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter") || GETPOST("button_removefilter.x")) // All tests are required to be compatible with all browsers +if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter','alpha') || GETPOST('button_removefilter.x','alpha')) // All tests are required to be compatible with all browsers { $search_user=''; $search_sale=''; @@ -531,6 +531,7 @@ if ($resql) { $soc = new Societe($db); $soc->fetch($socid); + if (empty($search_societe)) $search_societe = $soc->name; } $param='&socid='.$socid; diff --git a/htdocs/compta/index.php b/htdocs/compta/index.php index 321c2456ddd..103ec747e37 100644 --- a/htdocs/compta/index.php +++ b/htdocs/compta/index.php @@ -378,7 +378,7 @@ if (! empty($conf->facture->enabled) && $user->rights->facture->lire) print '
'; diff --git a/htdocs/compta/paiement.php b/htdocs/compta/paiement.php index cdc5eb2e545..394e2f23841 100644 --- a/htdocs/compta/paiement.php +++ b/htdocs/compta/paiement.php @@ -99,7 +99,7 @@ if (empty($reshook)) $atleastonepaymentnotnull = 0; // Generate payment array and check if there is payment higher than invoice and payment date before invoice date - $tmpinvoice=new Facture($db); + $tmpinvoice=new Facture($db); foreach ($_POST as $key => $value) { if (substr($key,0,7) == 'amount_') @@ -188,7 +188,7 @@ if (empty($reshook)) setEventMessages($langs->transnoentities('ErrorFieldRequired',$langs->transnoentities('Date')), null, 'errors'); $error++; } - + // Check if payments in both currency if ($totalpayment > 0 && $multicurrency_totalpayment > 0) { @@ -228,7 +228,7 @@ if (empty($reshook)) $newvalue = price2num($value,'MT'); $amounts[$key] = -$newvalue; } - + foreach ($multicurrency_amounts as $key => $value) // How payment is dispatch { $newvalue = price2num($value,'MT'); @@ -319,7 +319,7 @@ llxHeader('', $langs->trans("Payment")); if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paiement') { $facture = new Facture($db); - $result=$facture->fetch($facid); + $result = $facture->fetch($facid); if ($result >= 0) { @@ -389,7 +389,7 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie { subJson[n["name"]] = n["value"]; }); - + return subJson; } function callForResult(imgId) @@ -516,31 +516,31 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie print ''; print ''; - + print '
'.$langs->trans('Comments').''; print '
'; dol_fiche_end(); - + /* * List of unpaid invoices */ - + $sql = 'SELECT f.rowid as facid, f.facnumber, f.total_ttc, f.multicurrency_code, f.multicurrency_total_ttc, f.type, '; $sql.= ' f.datef as df, f.fk_soc as socid'; $sql.= ' FROM '.MAIN_DB_PREFIX.'facture as f'; - + if(!empty($conf->global->FACTURE_PAYMENTS_ON_DIFFERENT_THIRDPARTIES_BILLS)) { $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe as s ON (f.fk_soc = s.rowid)'; } - + $sql.= ' WHERE f.entity = '.$conf->entity; $sql.= ' AND (f.fk_soc = '.$facture->socid; - + if(!empty($conf->global->FACTURE_PAYMENTS_ON_DIFFERENT_THIRDPARTIES_BILLS) && !empty($facture->thirdparty->parent)) { $sql.= ' OR f.fk_soc IN (SELECT rowid FROM '.MAIN_DB_PREFIX.'societe WHERE parent = '.$facture->thirdparty->parent.')'; } - + $sql.= ') AND f.paye = 0'; $sql.= ' AND f.fk_statut = 1'; // Statut=0 => not validated, Statut=2 => canceled if ($facture->type != 2) @@ -577,7 +577,7 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie //print ''; print '
'; print ''; - + print ''; print ''; print ''; @@ -602,7 +602,7 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie while ($i < $num) { $objp = $db->fetch_object($resql); - + $soc = new Societe($db); $soc->fetch($objp->socid); @@ -614,9 +614,9 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie $deposits=$invoice->getSumDepositsUsed(); $alreadypayed=price2num($paiement + $creditnotes + $deposits,'MT'); $remaintopay=price2num($invoice->total_ttc - $paiement - $creditnotes - $deposits,'MT'); - + // Multicurrency Price - if (!empty($conf->multicurrency->enabled)) + if (!empty($conf->multicurrency->enabled)) { $multicurrency_payment = $invoice->getSommePaiement(1); $multicurrency_creditnotes=$invoice->getSumCreditNotesUsed(1); @@ -624,7 +624,7 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie $multicurrency_alreadypayed=price2num($multicurrency_payment + $multicurrency_creditnotes + $multicurrency_deposits,'MT'); $multicurrency_remaintopay=price2num($invoice->multicurrency_total_ttc - $multicurrency_payment - $multicurrency_creditnotes - $multicurrency_deposits,'MT'); } - + print ''; print '\n"; - + // Currency if (!empty($conf->multicurrency->enabled)) print '\n"; - + // Multicurrency Price - if (!empty($conf->multicurrency->enabled)) + if (!empty($conf->multicurrency->enabled)) { print ''; - + // Multicurrency Price print ''; - + // Multicurrency Price print ''; } - + // Price print ''; - + // Received or paid back print '"; // Multicurrency Price - if (! empty($conf->multicurrency->enabled)) + if (! empty($conf->multicurrency->enabled)) { print ''; print ''; - print ''; + print ''; // Autofilled if (!empty($conf->multicurrency->enabled)) print ''; print ''; print "\n"; @@ -802,9 +802,9 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie print '
'; if (!empty($totalpayment)) $text=$langs->trans('ConfirmCustomerPayment',$totalpayment,$langs->trans("Currency".$conf->currency)); - if (!empty($multicurrency_totalpayment)) + if (!empty($multicurrency_totalpayment)) { - $text.='
'.$langs->trans('ConfirmCustomerPayment',$multicurrency_totalpayment,$langs->trans("paymentInInvoiceCurrency")); + $text.='
'.$langs->trans('ConfirmCustomerPayment',$multicurrency_totalpayment,$langs->trans("paymentInInvoiceCurrency")); } if (GETPOST('closepaidinvoices')) { @@ -864,7 +864,7 @@ if (! GETPOST('action','aZ09')) while ($i < min($num,$limit)) { $objp = $db->fetch_object($resql); - + print ''; print '\n"; print '\n"; diff --git a/htdocs/compta/paiement/cheque/list.php b/htdocs/compta/paiement/cheque/list.php index aeed72d93d1..3e2b43b7f34 100644 --- a/htdocs/compta/paiement/cheque/list.php +++ b/htdocs/compta/paiement/cheque/list.php @@ -68,7 +68,7 @@ $accountstatic=new Account($db); */ // If click on purge search criteria ? -if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETPOST("button_removefilter")) // All tests are required to be compatible with all browsers +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_ref=''; $search_amount=''; diff --git a/htdocs/compta/paiement/list.php b/htdocs/compta/paiement/list.php index ec2bbc78fc6..4a7a2e3c81a 100644 --- a/htdocs/compta/paiement/list.php +++ b/htdocs/compta/paiement/list.php @@ -77,7 +77,7 @@ $extrafields = new ExtraFields($db); * Actions */ -if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter")) // Both test are required to be compatible with all browsers +if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter','alpha')) // Both test are required to be compatible with all browsers { $search_ref=""; $search_account=""; diff --git a/htdocs/compta/prelevement/bons.php b/htdocs/compta/prelevement/bons.php index 9a5585c2513..6fcbb62b5d9 100644 --- a/htdocs/compta/prelevement/bons.php +++ b/htdocs/compta/prelevement/bons.php @@ -57,7 +57,7 @@ $search_ref = GETPOST('search_ref','alpha'); * Actions */ -if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETPOST("button_removefilter")) // All tests are required to be compatible with all browsers +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_ref=""; } diff --git a/htdocs/compta/prelevement/list.php b/htdocs/compta/prelevement/list.php index 208be88aeae..6251a6f6521 100644 --- a/htdocs/compta/prelevement/list.php +++ b/htdocs/compta/prelevement/list.php @@ -65,7 +65,7 @@ $ligne=new LignePrelevement($db,$user); * Actions */ -if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETPOST("button_removefilter")) // All tests are required to be compatible with all browsers +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_line=""; $search_bon=""; diff --git a/htdocs/compta/salaries/card.php b/htdocs/compta/salaries/card.php index 45bde4bcd32..2b8b6a6fe5b 100644 --- a/htdocs/compta/salaries/card.php +++ b/htdocs/compta/salaries/card.php @@ -44,7 +44,7 @@ $action=GETPOST('action','aZ09'); // Security check $socid = GETPOST("socid","int"); if ($user->societe_id) $socid=$user->societe_id; -$result = restrictedArea($user, 'salaries', '', '', ''); +$result = restrictedArea($user, 'salaries', '', '', 'payment'); $object = new PaymentSalary($db); diff --git a/htdocs/compta/salaries/class/paymentsalary.class.php b/htdocs/compta/salaries/class/paymentsalary.class.php index d3f76a84bdf..ee2832cb08e 100644 --- a/htdocs/compta/salaries/class/paymentsalary.class.php +++ b/htdocs/compta/salaries/class/paymentsalary.class.php @@ -34,7 +34,7 @@ class PaymentSalary extends CommonObject //public $element='payment_salary'; //!< Id that identify managed objects //public $table_element='payment_salary'; //!< Name of table without prefix where object is stored public $picto='payment'; - + public $tms; public $fk_user; public $datep; @@ -97,16 +97,16 @@ class PaymentSalary extends CommonObject // Update request $sql = "UPDATE ".MAIN_DB_PREFIX."payment_salary SET"; - $sql.= " tms=".$this->db->idate($this->tms).","; + $sql.= " tms='".$this->db->idate($this->tms)."',"; $sql.= " fk_user=".$this->fk_user.","; - $sql.= " datep=".$this->db->idate($this->datep).","; - $sql.= " datev=".$this->db->idate($this->datev).","; + $sql.= " datep='".$this->db->idate($this->datep)."',"; + $sql.= " datev='".$this->db->idate($this->datev)."',"; $sql.= " amount=".price2num($this->amount).","; $sql.= " fk_typepayment=".$this->fk_typepayment."',"; $sql.= " num_payment='".$this->db->escape($this->num_payment)."',"; $sql.= " label='".$this->db->escape($this->label)."',"; - $sql.= " datesp=".$this->db->idate($this->datesp).","; - $sql.= " dateep=".$this->db->idate($this->dateep).","; + $sql.= " datesp='".$this->db->idate($this->datesp)."',"; + $sql.= " dateep='".$this->db->idate($this->dateep)."',"; $sql.= " note='".$this->db->escape($this->note)."',"; $sql.= " fk_bank=".($this->fk_bank > 0 ? "'".$this->fk_bank."'":"null").","; $sql.= " fk_user_author=".$this->fk_user_author.","; @@ -548,7 +548,7 @@ class PaymentSalary extends CommonObject } } - + /** * Retourne le libelle du statut d'une facture (brouillon, validee, abandonnee, payee) * @@ -559,7 +559,7 @@ class PaymentSalary extends CommonObject { return $this->LibStatut($this->statut,$mode); } - + /** * Renvoi le libelle d'un statut donne * @@ -570,7 +570,7 @@ class PaymentSalary extends CommonObject function LibStatut($status,$mode=0) { global $langs; // TODO Renvoyer le libelle anglais et faire traduction a affichage - + $langs->load('compta'); /*if ($mode == 0) { @@ -609,5 +609,5 @@ class PaymentSalary extends CommonObject }*/ return ''; } - + } diff --git a/htdocs/compta/salaries/index.php b/htdocs/compta/salaries/index.php index baf99182993..b25df5a71ac 100644 --- a/htdocs/compta/salaries/index.php +++ b/htdocs/compta/salaries/index.php @@ -79,7 +79,7 @@ else * Actions */ -if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETPOST("button_removefilter")) // All test are required to be compatible with all browsers +if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x','alpha') || GETPOST('button_removefilter','alpha')) // All test are required to be compatible with all browsers { $search_ref=""; $search_label=""; diff --git a/htdocs/compta/sociales/index.php b/htdocs/compta/sociales/index.php index 2ab2cb1c172..50dd4d430ed 100644 --- a/htdocs/compta/sociales/index.php +++ b/htdocs/compta/sociales/index.php @@ -71,7 +71,7 @@ else $typeid=$_REQUEST['typeid']; } -if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETPOST("button_removefilter")) // All test are required to be compatible with all browsers +if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x','alpha') || GETPOST('button_removefilter','alpha')) // All test are required to be compatible with all browsers { $search_ref=""; $search_label=""; diff --git a/htdocs/compta/tva/class/tva.class.php b/htdocs/compta/tva/class/tva.class.php index ff26347576e..df1bc8c03cf 100644 --- a/htdocs/compta/tva/class/tva.class.php +++ b/htdocs/compta/tva/class/tva.class.php @@ -173,9 +173,9 @@ class Tva extends CommonObject // Update request $sql = "UPDATE ".MAIN_DB_PREFIX."tva SET"; - $sql.= " tms=".$this->db->idate($this->tms).","; - $sql.= " datep=".$this->db->idate($this->datep).","; - $sql.= " datev=".$this->db->idate($this->datev).","; + $sql.= " tms='".$this->db->idate($this->tms)."',"; + $sql.= " datep='".$this->db->idate($this->datep)."',"; + $sql.= " datev='".$this->db->idate($this->datev)."',"; $sql.= " amount=".price2num($this->amount).","; $sql.= " label='".$this->db->escape($this->label)."',"; $sql.= " note='".$this->db->escape($this->note)."',"; diff --git a/htdocs/compta/tva/index.php b/htdocs/compta/tva/index.php index 618ba11a37e..89accf57492 100644 --- a/htdocs/compta/tva/index.php +++ b/htdocs/compta/tva/index.php @@ -117,7 +117,7 @@ $textprevyear="".img_previo $textnextyear=" ".img_next($langs->trans("Next"), 'class="valignbottom"').""; print $conf->dol_optimize_smallscreen; -print load_fiche_titre($langs->trans("VAT"), $textprevyear." ".$langs->trans("Year")." ".$year_start." ".$textnextyear, 'title_accountancy.png'); +print load_fiche_titre($langs->transcountry("VAT", $mysoc->country_code), $textprevyear." ".$langs->trans("Year")." ".$year_start." ".$textnextyear, 'title_accountancy.png'); print $langs->trans("VATReportBuildWithOptionDefinedInModule").'
'; print '('.$langs->trans("TaxModuleSetupToModifyRules",DOL_URL_ROOT.'/admin/taxes.php').')
'; @@ -263,18 +263,18 @@ if (! empty($conf->global->MAIN_FEATURES_LEVEL)) print ""; print ''; // need to add translation - print ''; + print ''; print "\n"; print ""; print ''; - print '\n"; + print '\n"; print "\n"; $restopay = $total - $obj->mm; print ""; print ''; // need to add translation - print ''; + print ''; print "\n"; print '
'.$arraytitle.''.$langs->trans('Date').'
'; @@ -634,36 +634,36 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie // Date print ''.dol_print_date($db->jdate($objp->df),'day')."'.$objp->multicurrency_code."'; if ($objp->multicurrency_code && $objp->multicurrency_code != $conf->currency) print price($sign * $objp->multicurrency_total_ttc); print ''; - if ($objp->multicurrency_code && $objp->multicurrency_code != $conf->currency) + if ($objp->multicurrency_code && $objp->multicurrency_code != $conf->currency) { print price($sign * $multicurrency_payment); if ($multicurrency_creditnotes) print '+'.price($multicurrency_creditnotes); if ($multicurrency_deposits) print '+'.price($multicurrency_deposits); } print ''; if ($objp->multicurrency_code && $objp->multicurrency_code != $conf->currency) print price($sign * $multicurrency_remaintopay); print ''.price($sign * $objp->total_ttc).''.price($sign * $paiement); if ($creditnotes) print '+'.price($creditnotes); @@ -685,7 +685,7 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie { if (!empty($conf->use_javascript_ajax)) print img_picto("Auto fill",'rightarrow', "class='AutoFillAmout' data-rowname='".$namef."' data-value='".($sign * $remaintopay)."'"); - print ''; + print ''; print ''; } else @@ -696,14 +696,14 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie print "'; - + // Add remind multicurrency amount $namef = 'multicurrency_amount_'.$objp->facid; $nameRemain = 'multicurrency_remain_'.$objp->facid; - + if ($objp->multicurrency_code && $objp->multicurrency_code != $conf->currency) { if ($action != 'add_paiement') @@ -723,7 +723,7 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie } // Warning - print ''; + print ''; //print "xx".$amounts[$invoice->id]."-".$amountsresttopay[$invoice->id]."
"; if ($amounts[$invoice->id] && (abs($amounts[$invoice->id]) > abs($amountsresttopay[$invoice->id])) || $multicurrency_amounts[$invoice->id] && (abs($multicurrency_amounts[$invoice->id]) > abs($multicurrency_amountsresttopay[$invoice->id]))) @@ -744,7 +744,7 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie $totalrecudeposits+=$deposits; $i++; } - + if ($i > 1) { // Print total @@ -760,7 +760,7 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie if ($totalrecudeposits) print '+'.price($totalrecudeposits); print '
'.price($sign * price2num($total_ttc - $totalrecu - $totalrecucreditnote - $totalrecudeposits,'MT')).' 
'.$objp->facnumber."'.dol_print_date($db->jdate($objp->dp))."
' . $langs->trans("VATDue") . '' . price(price2num($total, 1)) . '' . price(price2num($total, 'MT')) . '
' . $langs->trans("VATPaid") . '' . price(price2num($obj->mm, 1)) . "' . price(price2num($obj->mm, 'MT')) . "
' . $langs->trans("VATRestopay") . '' . price(price2num($restopay, 1)) . '' . price(price2num($restopay, 'MT')) . '
'; diff --git a/htdocs/compta/tva/reglement.php b/htdocs/compta/tva/reglement.php index 44c45a65dc7..c75730d2f8e 100644 --- a/htdocs/compta/tva/reglement.php +++ b/htdocs/compta/tva/reglement.php @@ -74,7 +74,7 @@ else $typeid=$_REQUEST['typeid']; } -if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETPOST("button_removefilter")) // Both test are required to be compatible with all browsers +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_ref=""; $search_label=""; diff --git a/htdocs/contact/agenda.php b/htdocs/contact/agenda.php index 74ec89bf5d1..7f35c71cd11 100644 --- a/htdocs/contact/agenda.php +++ b/htdocs/contact/agenda.php @@ -122,7 +122,7 @@ if (empty($reshook)) } // Purge search criteria - if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETPOST("button_removefilter")) // All test are required to be compatible with all browsers + if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x','alpha') || GETPOST('button_removefilter','alpha')) // All test are required to be compatible with all browsers { $actioncode=''; $search_agenda_label=''; diff --git a/htdocs/contact/card.php b/htdocs/contact/card.php index fbd27b0d841..d5854297f43 100644 --- a/htdocs/contact/card.php +++ b/htdocs/contact/card.php @@ -625,7 +625,7 @@ else // EMail if (($objsoc->typent_code == 'TE_PRIVATE' || ! empty($conf->global->CONTACT_USE_COMPANY_ADDRESS)) && dol_strlen(trim($object->email)) == 0) $object->email = $objsoc->email; // Predefined with third party print ''; - print 'email).'">'; + print 'email).'">'; if (! empty($conf->mailing->enabled)) { print ''; @@ -860,7 +860,7 @@ else // EMail print ''; - print 'email).'">'; + print 'email).'">'; if (! empty($conf->mailing->enabled)) { $langs->load("mails"); diff --git a/htdocs/contact/class/contact.class.php b/htdocs/contact/class/contact.class.php index b80a300431a..3b7ce848731 100644 --- a/htdocs/contact/class/contact.class.php +++ b/htdocs/contact/class/contact.class.php @@ -108,7 +108,7 @@ class Contact extends CommonObject $this->db = $db; $this->statut = 1; // By default, status is enabled } - + /** * Load indicators into this->nb for board * @@ -117,10 +117,10 @@ class Contact extends CommonObject function load_state_board() { global $user; - + $this->nb=array(); $clause = "WHERE"; - + $sql = "SELECT count(sp.rowid) as nb"; $sql.= " FROM ".MAIN_DB_PREFIX."socpeople as sp"; if (!$user->rights->societe->client->voir && !$user->societe_id) @@ -133,7 +133,7 @@ class Contact extends CommonObject $sql.= ' '.$clause.' sp.entity IN ('.getEntity($this->element, 1).')'; $sql.= " AND (sp.priv='0' OR (sp.priv='1' AND sp.fk_user_creat=".$user->id."))"; if ($user->societe_id > 0) $sql.=" AND sp.fk_soc = ".$user->societe_id; - + $resql=$this->db->query($sql); if ($resql) { @@ -410,7 +410,9 @@ class Contact extends CommonObject { global $conf,$langs; - // Object classes + $info = array(); + + // Object classes $info["objectclass"]=explode(',',$conf->global->LDAP_CONTACT_OBJECT_CLASS); $this->fullname=$this->getFullName($langs); @@ -486,7 +488,7 @@ class Contact extends CommonObject $result=false; $this->db->begin(); - + // Mis a jour contact $sql = "UPDATE ".MAIN_DB_PREFIX."socpeople SET"; $sql.= " birthday=".($this->birthday ? "'".$this->db->idate($this->birthday)."'" : "null"); @@ -544,7 +546,7 @@ class Contact extends CommonObject if ($result < 0) { $error++; } // End call triggers } - + if (! $error) { $this->db->commit(); @@ -659,7 +661,7 @@ class Contact extends CommonObject $this->canvas = $obj->canvas; $this->import_key = $obj->import_key; - + // Define gender according to civility $this->setGenderFromCivility(); @@ -735,7 +737,7 @@ class Contact extends CommonObject /** * Set property ->gender from property ->civility_id - * + * * @return void */ function setGenderFromCivility() @@ -746,8 +748,8 @@ class Contact extends CommonObject } else if(in_array($this->civility_id, array('MME','MLE'))) { $this->gender = 'woman'; } - } - + } + /** * Load number of elements the contact is used as a link for * ref_facturation @@ -1007,13 +1009,13 @@ class Contact extends CommonObject if ($this->phone_perso) $phonelist[]=$this->phone_perso; $label.= '
' . $langs->trans("Phone") . ': '.join(', ',$phonelist); $label.= '
' . $langs->trans("Address") . ': '.dol_format_address($this, 1, ' ', $langs); - + $link = 'global->MAIN_OPTIMIZEFORTEXTBROWSER)) + if (! empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { $label=$langs->trans("ShowContact"); - $linkclose.=' alt="'.dol_escape_htmltag($label, 1).'"'; + $linkclose.=' alt="'.dol_escape_htmltag($label, 1).'"'; } $linkclose.= ' title="'.dol_escape_htmltag($label, 1).'"'; $linkclose.= ' class="classfortooltip">'; @@ -1029,15 +1031,15 @@ class Contact extends CommonObject if ($reshook > 0) $linkclose = $hookmanager->resPrint; $link.=$linkclose; - + $linkend=''; - + if ($option == 'xxx') { $link = ''; $linkend=''; } - + if ($withpicto) $result.=($link.img_object($label, 'contact', 'class="classfortooltip"').$linkend.' '); $result.=$link.($maxlen?dol_trunc($this->getFullName($langs),$maxlen):$this->getFullName($langs)).$linkend; return $result; diff --git a/htdocs/contact/list.php b/htdocs/contact/list.php index 1293a258fab..a0f7ae9a87d 100644 --- a/htdocs/contact/list.php +++ b/htdocs/contact/list.php @@ -48,12 +48,14 @@ if ($user->societe_id) $socid=$user->societe_id; $result = restrictedArea($user, 'contact', $contactid,''); $sall=GETPOST('sall', 'alphanohtml'); +$search_cti=preg_replace('/^0+/', '', preg_replace('/[^0-9]/', '', GETPOST('search_cti', 'alphanohtml'))); // Phone number without any special chars +$search_phone=GETPOST("search_phone"); + $search_firstlast_only=GETPOST("search_firstlast_only"); $search_lastname=GETPOST("search_lastname"); $search_firstname=GETPOST("search_firstname"); $search_societe=GETPOST("search_societe"); $search_poste=GETPOST("search_poste"); -$search_phone=GETPOST("search_phone"); $search_phone_perso=GETPOST("search_phone_perso"); $search_phone_pro=GETPOST("search_phone_pro"); $search_phone_mobile=GETPOST("search_phone_mobile"); @@ -272,53 +274,25 @@ if ($search_categ > 0) $sql.= " AND cc.fk_categorie = ".$db->escape($search_ca if ($search_categ == -2) $sql.= " AND cc.fk_categorie IS NULL"; if ($search_categ_thirdparty > 0) $sql.= " AND cs.fk_categorie = ".$db->escape($search_categ_thirdparty); if ($search_categ_thirdparty == -2) $sql.= " AND cs.fk_categorie IS NULL"; -if ($search_categ_supplier > 0) $sql.= " AND cs2.fk_categorie = ".$db->escape($search_categ_supplier); -if ($search_categ_supplier == -2) $sql.= " AND cs2.fk_categorie IS NULL"; +if ($search_categ_supplier > 0) $sql.= " AND cs2.fk_categorie = ".$db->escape($search_categ_supplier); +if ($search_categ_supplier == -2) $sql.= " AND cs2.fk_categorie IS NULL"; -if ($search_firstlast_only) { - $sql .= natural_search(array('p.lastname','p.firstname'), $search_firstlast_only); -} -if ($search_lastname) { // filter on lastname - $sql .= natural_search('p.lastname', $search_lastname); -} -if ($search_firstname) { // filter on firstname - $sql .= natural_search('p.firstname', $search_firstname); -} -if ($search_societe) { // filtre sur la societe - $sql .= natural_search('s.nom', $search_societe); -} -if (strlen($search_poste)) { // filtre sur la societe - $sql .= natural_search('p.poste', $search_poste); -} -if (strlen($search_phone)) -{ - $sql .= " AND (p.phone LIKE '%".$db->escape($search_phone)."%' OR p.phone_perso LIKE '%".$db->escape($search_phone)."%' OR p.phone_mobile LIKE '%".$db->escape($search_phone)."%')"; -} -if (strlen($search_phone_perso)) -{ - $sql .= " AND p.phone_perso LIKE '%".$db->escape($search_phone_perso)."%'"; -} -if (strlen($search_phone_pro)) -{ - $sql .= " AND p.phone LIKE '%".$db->escape($search_phone_pro)."%'"; -} -if (strlen($search_phone_mobile)) -{ - $sql .= " AND p.phone_mobile LIKE '%".$db->escape($search_phone_mobile)."%'"; -} -if (strlen($search_fax)) -{ - $sql .= " AND p.fax LIKE '%".$db->escape($search_fax)."%'"; -} -if (strlen($search_email)) // filtre sur l'email -{ - $sql .= " AND p.email LIKE '%".$db->escape($search_email)."%'"; -} -if (strlen($search_skype)) // filtre sur skype -{ - $sql .= " AND p.skype LIKE '%".$db->escape($search_skype)."%'"; -} -if ($search_status != '' && $search_status >= 0) $sql .= " AND p.statut = ".$db->escape($search_status); +if ($sall) $sql.= natural_search(array_keys($fieldstosearchall), $sall); +if (strlen($search_phone)) $sql.= natural_search(array('p.phone', 'p.phone_perso', 'p.phone_mobile'), $search_phone); +if (strlen($search_cti)) $sql.= natural_search(array('p.phone', 'p.phone_perso', 'p.phone_mobile'), $search_cti); +if (strlen($search_firstlast_only)) $sql.= natural_search(array('p.lastname', 'p.firstname'), $search_firstlast_only); + +if ($search_lastname) $sql.= natural_search('p.lastname', $search_lastname); +if ($search_firstname) $sql.= natural_search('p.firstname', $search_firstname); +if ($search_societe) $sql.= natural_search('s.nom', $search_societe); +if (strlen($search_poste)) $sql.= natural_search('p.poste', $search_poste); +if (strlen($search_phone_perso)) $sql.= natural_search('p.phone_perso', $search_phone_perso); +if (strlen($search_phone_pro)) $sql.= natural_search('p.phone', $search_phone); +if (strlen($search_phone_mobile)) $sql.= natural_search('p.phone_mobile', $search_phone_mobile); +if (strlen($search_fax)) $sql.= natural_search('p.phone_fax', $search_fax); +if (strlen($search_skype)) $sql.= natural_search('p.skype', $search_skype); +if (strlen($search_email)) $sql.= natural_search('p.email', $search_email); +if ($search_status != '' && $search_status >= 0) $sql.= " AND p.statut = ".$db->escape($search_status); if ($type == "o") // filtre sur type { $sql .= " AND p.fk_soc IS NULL"; @@ -335,10 +309,6 @@ else if ($type == "p") // filtre sur type { $sql .= " AND s.client IN (2, 3)"; } -if ($sall) -{ - $sql .= natural_search(array_keys($fieldstosearchall), $sall); -} if (! empty($socid)) { $sql .= " AND s.rowid = ".$socid; @@ -391,7 +361,7 @@ $num = $db->num_rows($result); $arrayofselected=is_array($toselect)?$toselect:array(); -if ($num == 1 && ! empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $sall) +if ($num == 1 && ! empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && ($sall != '' || $seearch_cti != '')) { $obj = $db->fetch_object($resql); $id = $obj->rowid; diff --git a/htdocs/contrat/class/contrat.class.php b/htdocs/contrat/class/contrat.class.php index e08e10a0966..0c3ee14666a 100644 --- a/htdocs/contrat/class/contrat.class.php +++ b/htdocs/contrat/class/contrat.class.php @@ -1278,6 +1278,15 @@ class Contrat extends CommonObject //// End call triggers } } + + if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED) && is_array($this->array_options) && count($this->array_options)>0) // For avoid conflicts if trigger used + { + $result=$this->insertExtraFields(); + if ($result < 0) + { + $error++; + } + } // Commit or rollback if ($error) @@ -1633,8 +1642,8 @@ class Contrat extends CommonObject if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED) && is_array($array_options) && count($array_options)>0) // For avoid conflicts if trigger used { $contractline = new ContratLigne($this->db); - $contractline->array_options=$array_option; - $contractline->id= $this->db->last_insert_id(MAIN_DB_PREFIX.$contractline->table_element); + $contractline->array_options=$array_options; + $contractline->id= $rowid; $result=$contractline->insertExtraFields(); if ($result < 0) { diff --git a/htdocs/contrat/list.php b/htdocs/contrat/list.php index a526a9bd78c..d53bc0a3ee1 100644 --- a/htdocs/contrat/list.php +++ b/htdocs/contrat/list.php @@ -146,7 +146,7 @@ if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'e include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; // Purge search criteria -if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETPOST("button_removefilter")) // All test are required to be compatible with all browsers +if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x','alpha') || GETPOST('button_removefilter','alpha')) // All test are required to be compatible with all browsers { $day=''; $month=''; @@ -306,6 +306,13 @@ if ($resql) $arrayofselected=is_array($toselect)?$toselect:array(); + if ($socid > 0) + { + $soc = new Societe($db); + $soc->fetch($socid); + if (empty($search_name)) $search_name = $soc->name; + } + $param=''; if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage; if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit; diff --git a/htdocs/contrat/services.php b/htdocs/contrat/services.php index aea03a73df5..6534ef1e362 100644 --- a/htdocs/contrat/services.php +++ b/htdocs/contrat/services.php @@ -152,7 +152,7 @@ if (empty($reshook)) // Selection of new fields include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; - if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETPOST("button_removefilter")) // All test are required to be compatible with all browsers + if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x','alpha') || GETPOST('button_removefilter','alpha')) // All test are required to be compatible with all browsers { $search_name=""; $search_contract=""; @@ -332,7 +332,7 @@ if ($conf->categorie->enabled && ($user->rights->produit->lire || $user->rights- $moreforfilter.='
'; $moreforfilter.=$langs->trans('IncludingProductWithTag'). ': '; $cate_arbo = $form->select_all_categories(Categorie::TYPE_PRODUCT, null, 'parent', null, null, 1); - $moreforfilter.=$form->selectarray('search_product_category', $cate_arbo, $search_product_category, 1, 0, 0, '', 0, 0, 0, 0, '', 1); + $moreforfilter.=$form->selectarray('search_product_category', $cate_arbo, $search_product_category, 1, 0, 0, '', 0, 0, 0, 0, 'maxwidth300', 1); $moreforfilter.='
'; } @@ -523,7 +523,6 @@ while ($i < min($num,$limit)) $contractstatic->ref=$obj->ref?$obj->ref:$obj->cid; - print ''; // Ref diff --git a/htdocs/core/actions_setmoduleoptions.inc.php b/htdocs/core/actions_setmoduleoptions.inc.php index 03b33b19eb1..b8ae96cb920 100644 --- a/htdocs/core/actions_setmoduleoptions.inc.php +++ b/htdocs/core/actions_setmoduleoptions.inc.php @@ -32,16 +32,19 @@ if ($action == 'setModuleOptions') $db->begin(); // Process common param fields - foreach($_POST as $key => $val) + if (is_array($_POST)) { - if (preg_match('/^param(\d*)$/', $key, $reg)) // Works for POST['param'], POST['param1'], POST['param2'], ... + foreach($_POST as $key => $val) { - $param=GETPOST("param".$reg[1],'alpha'); - $value=GETPOST("value".$reg[1],'alpha'); - if ($param) + if (preg_match('/^param(\d*)$/', $key, $reg)) // Works for POST['param'], POST['param1'], POST['param2'], ... { - $res = dolibarr_set_const($db,$param,$value,'chaine',0,'',$conf->entity); - if (! $res > 0) $error++; + $param=GETPOST("param".$reg[1],'alpha'); + $value=GETPOST("value".$reg[1],'alpha'); + if ($param) + { + $res = dolibarr_set_const($db,$param,$value,'chaine',0,'',$conf->entity); + if (! $res > 0) $error++; + } } } } diff --git a/htdocs/core/ajax/selectsearchbox.php b/htdocs/core/ajax/selectsearchbox.php index 2e837fcbaae..2d92bc8f938 100644 --- a/htdocs/core/ajax/selectsearchbox.php +++ b/htdocs/core/ajax/selectsearchbox.php @@ -31,8 +31,17 @@ if (! isset($usedbyinclude) || empty($usedbyinclude)) if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1'); if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1'); if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1'); + if (! defined('NOREDIRECTBYMAINTOLOGIN')) define('NOREDIRECTBYMAINTOLOGIN','1'); $res=@include '../../main.inc.php'; + if ($res == 'ERROR_NOT_LOGGED') + { + $langs->load("other"); + $arrayresult['jumptologin']=array('img'=>'object_generic', 'label'=>$langs->trans("JumpToLogin"), 'text'=>' '.$langs->trans("JumpToLogin"), 'url'=>DOL_URL_ROOT.'/index.php'); + print json_encode($arrayresult); + if (is_object($db)) $db->close(); + exit; + } } include_once DOL_DOCUMENT_ROOT.'/core/lib/json.lib.php'; diff --git a/htdocs/core/boxes/modules_boxes.php b/htdocs/core/boxes/modules_boxes.php index d83f0e80cba..9c496964942 100644 --- a/htdocs/core/boxes/modules_boxes.php +++ b/htdocs/core/boxes/modules_boxes.php @@ -375,6 +375,133 @@ class ModeleBoxes // Can't be abtract as it is instantiated to build "empty" return ''; } + + /** + * Return list of widget. Function used by admin page htdoc/admin/widget. + * List is sorted by widget filename so by priority to run. + * + * @param array $forcedirwidget null=All default directories. This parameter is used by modulebuilder module only. + * @return array Array list of widget + */ + static function getWidgetsList($forcedirwidget=null) + { + global $conf, $langs, $db; + + $files = array(); + $fullpath = array(); + $relpath = array(); + $iscoreorexternal = array(); + $modules = array(); + $orders = array(); + $i = 0; + + $dirwidget=array_merge(array('/core/boxes/')); + if (is_array($forcedirwidget)) + { + $dirwidget=$forcedirwidget; + } + + foreach($dirwidget as $reldir) + { + $dir=dol_buildpath($reldir,0); + $newdir=dol_osencode($dir); + + // Check if directory exists (we do not use dol_is_dir to avoid loading files.lib.php at each call) + if (! is_dir($newdir)) continue; + + $handle=opendir($newdir); + if (is_resource($handle)) + { + while (($file = readdir($handle))!==false) + { + if (is_readable($newdir.'/'.$file) && preg_match('/^(.+)\.php/',$file,$reg)) + { + if (preg_match('/\.back$/',$file)) continue; + + $part1=$reg[1]; + + $modName = ucfirst($reg[1]); + //print "file=$file"; print "modName=$modName"; exit; + if (in_array($modName,$modules)) + { + $langs->load("errors"); + print '
'.$langs->trans("Error").' : '.$langs->trans("ErrorDuplicateWidget",$modName,"").'
'; + } + else + { + try { + include_once $newdir.'/'.$file; + } + catch(Exception $e) + { + print $e->getMessage(); + } + } + + $files[$i] = $file; + $fullpath[$i] = $dir.'/'.$file; + $relpath[$i] = preg_replace('/^\//','',$reldir).'/'.$file; + $iscoreorexternal[$i] = ($reldir == '/core/boxes/'?'internal':'external'); + $modules[$i] = $modName; + $orders[$i] = $part1; // Set sort criteria value + + $i++; + } + } + closedir($handle); + } + } + + asort($orders); + + $widget = array(); + $j = 0; + + // Loop on each widget + foreach ($orders as $key => $value) + { + $modName = $modules[$key]; + if (empty($modName)) continue; + + if (! class_exists($modName)) + { + print 'Error: A widget file was found but its class "'.$modName.'" was not found.'."
\n"; + continue; + } + + $objMod = new $modName($db); + if (is_object($objMod)) + { + // Define disabledbyname and disabledbymodule + $disabledbyname=0; + $module=''; + + // Check if widget file is disabled by name + if (preg_match('/NORUN$/i',$files[$key])) $disabledbyname=1; + + // We set info of modules + $widget[$j]['picto'] = $objMod->picto?img_object('',$objMod->picto):img_object('','generic'); + $widget[$j]['file'] = $files[$key]; + $widget[$j]['fullpath'] = $fullpath[$key]; + $widget[$j]['relpath'] = $relpath[$key]; + $widget[$j]['iscoreorexternal'] = $iscoreorexternal[$key]; + //$widget[$j]['version'] = $objMod->getVersion(); + $widget[$j]['status'] = img_picto($langs->trans("Active"),'tick'); + if ($disabledbyname > 0 || $disabledbymodule > 1) $widget[$j]['status'] = ''; + + $text =''.$langs->trans("Description").':
'; + $text.=$objMod->boxlabel.'
'; + $text.='
'.$langs->trans("Status").':
'; + if ($disabledbymodule == 2) $text.=$langs->trans("HooksDisabledAsModuleDisabled",$module).'
'; + + $widget[$j]['info'] = $text; + } + $j++; + } + return $widget; + } + + } diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 96de26be956..8f618e2fbf0 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -334,23 +334,23 @@ abstract class CommonObject // No constructor as it is an abstract class - /** - * Check an object id/ref exists - * If you don't need/want to instantiate object and just need to know if object exists, use this method instead of fetch - * + /** + * Check an object id/ref exists + * If you don't need/want to instantiate object and just need to know if object exists, use this method instead of fetch + * * @param string $element String of element ('product', 'facture', ...) * @param int $id Id of object * @param string $ref Ref of object to check * @param string $ref_ext Ref ext of object to check * @return int <0 if KO, 0 if OK but not found, >0 if OK and exists - */ - static function isExistingObject($element, $id, $ref='', $ref_ext='') - { - global $db,$conf; + */ + static function isExistingObject($element, $id, $ref='', $ref_ext='') + { + global $db,$conf; $sql = "SELECT rowid, ref, ref_ext"; $sql.= " FROM ".MAIN_DB_PREFIX.$element; - $sql.= " WHERE entity IN (".getEntity($element, true).")" ; + $sql.= " WHERE entity IN (".getEntity($element).")" ; if ($id > 0) $sql.= " AND rowid = ".$db->escape($id); else if ($ref) $sql.= " AND ref = '".$db->escape($ref)."'"; @@ -371,17 +371,17 @@ abstract class CommonObject else return 0; } return -1; - } + } - /** - * Method to output saved errors - * - * @return string String with errors - */ - function errorsToString() - { - return $this->error.(is_array($this->errors)?(($this->error!=''?', ':'').join(', ',$this->errors)):''); - } + /** + * Method to output saved errors + * + * @return string String with errors + */ + function errorsToString() + { + return $this->error.(is_array($this->errors)?(($this->error!=''?', ':'').join(', ',$this->errors)):''); + } /** * Return full name (civility+' '+name+' '+lastname) @@ -599,7 +599,7 @@ abstract class CommonObject } $datecreate = dol_now(); - + // Socpeople must have already been added by some a trigger, then we have to check it to avoid DB_ERROR_RECORD_ALREADY_EXISTS error $TListeContacts=$this->liste_contact(-1, $source); $already_added=false; @@ -611,11 +611,11 @@ abstract class CommonObject } } } - + if(!$already_added) { - + $this->db->begin(); - + // Insertion dans la base $sql = "INSERT INTO ".MAIN_DB_PREFIX."element_contact"; $sql.= " (element_id, fk_socpeople, datecreate, statut, fk_c_type_contact) "; @@ -623,7 +623,7 @@ abstract class CommonObject $sql.= "'".$this->db->idate($datecreate)."'"; $sql.= ", 4, ". $id_type_contact; $sql.= ")"; - + $resql=$this->db->query($sql); if ($resql) { @@ -636,7 +636,7 @@ abstract class CommonObject return -1; } } - + $this->db->commit(); return 1; } @@ -3947,7 +3947,7 @@ abstract class CommonObject // Now we add first model found in directories scanned $listofdir=explode(',',$dirtoscan); - foreach($listofdir as $key=>$tmpdir) + foreach($listofdir as $key => $tmpdir) { $tmpdir=trim($tmpdir); $tmpdir=preg_replace('/DOL_DATA_ROOT/',DOL_DATA_ROOT,$tmpdir); @@ -4169,6 +4169,9 @@ abstract class CommonObject $optionsArray = $extrafields->attributes[$this->table_element]['label']; } + $table_element = $this->table_element; + if ($table_element == 'categorie') $table_element = 'categories'; // For compatibility + // Request to get complementary values if (count($optionsArray) > 0) { @@ -4180,7 +4183,7 @@ abstract class CommonObject $sql.= ", ".$name; } } - $sql.= " FROM ".MAIN_DB_PREFIX.$this->table_element."_extrafields"; + $sql.= " FROM ".MAIN_DB_PREFIX.$table_element."_extrafields"; $sql.= " WHERE fk_object = ".$rowid; dol_syslog(get_class($this)."::fetch_optionals get extrafields data for ".$this->table_element, LOG_DEBUG); @@ -4226,7 +4229,10 @@ abstract class CommonObject { $this->db->begin(); - $sql_del = "DELETE FROM ".MAIN_DB_PREFIX.$this->table_element."_extrafields WHERE fk_object = ".$this->id; + $table_element = $this->table_element; + if ($table_element == 'categorie') $table_element = 'categories'; // For compatibility + + $sql_del = "DELETE FROM ".MAIN_DB_PREFIX.$table_element."_extrafields WHERE fk_object = ".$this->id; dol_syslog(get_class($this)."::deleteExtraFields delete", LOG_DEBUG); $resql=$this->db->query($sql_del); if (! $resql) @@ -4332,11 +4338,14 @@ abstract class CommonObject } $this->db->begin(); - $sql_del = "DELETE FROM ".MAIN_DB_PREFIX.$this->table_element."_extrafields WHERE fk_object = ".$this->id; + $table_element = $this->table_element; + if ($table_element == 'categorie') $table_element = 'categories'; // For compatibility + + $sql_del = "DELETE FROM ".MAIN_DB_PREFIX.$table_element."_extrafields WHERE fk_object = ".$this->id; dol_syslog(get_class($this)."::insertExtraFields delete", LOG_DEBUG); $this->db->query($sql_del); - $sql = "INSERT INTO ".MAIN_DB_PREFIX.$this->table_element."_extrafields (fk_object"; + $sql = "INSERT INTO ".MAIN_DB_PREFIX.$table_element."_extrafields (fk_object"; foreach($new_array_options as $key => $value) { $attributeKey = substr($key,8); // Remove 'options_' prefix @@ -4646,18 +4655,17 @@ abstract class CommonObject /** * Get buy price to use for margin calculation. This function is called when buy price is unknown. - * set buy price = sell price if ForceBuyingPriceIfNull configured, + * Set buy price = sell price if ForceBuyingPriceIfNull configured, * else if calculation MARGIN_TYPE = 'costprice' and costprice is defined, use costprice as buyprice * else if calculation MARGIN_TYPE = 'pmp' and pmp is calculated, use pmp as buyprice * else set min buy price as buy price * - * @param float $unitPrice product unit price - * @param float $discountPercent line discount percent - * @param int $fk_product product id - * - * @return float <0 if ko, buyprice if ok + * @param float $unitPrice Product unit price + * @param float $discountPercent Line discount percent + * @param int $fk_product Product id + * @return float <0 if KO, buyprice if OK */ - public function defineBuyPrice($unitPrice = 0, $discountPercent = 0, $fk_product = 0) + public function defineBuyPrice($unitPrice = 0.0, $discountPercent = 0.0, $fk_product = 0) { global $conf; @@ -4726,6 +4734,9 @@ abstract class CommonObject return $buyPrice; } + + + /** * Function test if type is date * @@ -4734,7 +4745,7 @@ abstract class CommonObject */ protected function isDate($info) { - if(isset($info['type']) && $info['type']=='date') return true; + if(isset($info['type']) && ($info['type']=='date' || $info['type']=='datetime' || $info['type']=='timestamp')) return true; else return false; } @@ -4796,7 +4807,7 @@ abstract class CommonObject { if(is_array($info)) { - if(isset($info['type']) && $info['type']=='float') return true; + if (isset($info['type']) && (preg_match('/^(double|real)/i', $info['type']))) return true; else return false; } else return false; @@ -4835,83 +4846,58 @@ abstract class CommonObject } /** - * Function to prepare the values to insert + * Function to prepare the values to insert. + * Note $this->${field} are set by the page that make the createCommon or the updateCommon. * * @return array */ private function set_save_query() { - $query=array(); - foreach ($this->fields as $field=>$info) + global $conf; + + $queryarray=array(); + foreach ($this->fields as $field=>$info) // Loop on definition of fields { + // Depending on field type ('datetime', ...) if($this->isDate($info)) { if(empty($this->{$field})) { - $query[$field] = NULL; + $queryarray[$field] = NULL; } else { - $query[$field] = $this->db->idate($this->{$field}); + $queryarray[$field] = $this->db->idate($this->{$field}); } } else if($this->isArray($info)) { - $query[$field] = serialize($this->{$field}); + $queryarray[$field] = serialize($this->{$field}); } else if($this->isInt($info)) { - $query[$field] = (int) price2num($this->{$field}); + if ($field == 'entity' && is_null($this->{$field})) $queryarray[$field]=$conf->entity; + else + { + $queryarray[$field] = (int) price2num($this->{$field}); + if (empty($queryarray[$field])) $queryarray[$field]=0; // May be rest to null later if property 'nullifempty' is on for this field. + } } else if($this->isFloat($info)) { - $query[$field] = (double) price2num($this->{$field}); - } - elseif($this->isNull($info)) - { - $query[$field] = (is_null($this->{$field}) || (empty($this->{$field}) && $this->{$field}!==0 && $this->{$field}!=='0') ? null : $this->{$field}); + $queryarray[$field] = (double) price2num($this->{$field}); + if (empty($queryarray[$field])) $queryarray[$field]=0; } else { - $query[$field] = $this->{$field}; + $queryarray[$field] = $this->{$field}; } + + if ($info['type'] == 'timestamp' && empty($queryarray[$field])) unset($queryarray[$field]); + if (! empty($info['nullifempty']) && empty($queryarray[$field])) $queryarray[$field] = null; } - return $query; - } - - /** - * Create object into database - * - * @param User $user User that creates - * @param bool $notrigger false=launch triggers after, true=disable triggers - * - * @return int <0 if KO, Id of created object if OK - */ - public function createCommon(User $user, $notrigger = false) - { - - $fields = array_merge(array('datec'=>$this->db->idate(dol_now())), $this->set_save_query()); - - foreach ($fields as $k => $v) { - - $keys[] = $k; - $values[] = $this->quote($v); - - } - $sql = 'INSERT INTO '.MAIN_DB_PREFIX.$this->table_element.' - ( '.implode( ",", $keys ).' ) - VALUES ( '.implode( ",", $values ).' ) '; - $res = $this->db->query( $sql ); - if($res===false) { - - return false; - } - - // TODO Add triggers - - return true; - + return $queryarray; } /** @@ -4921,39 +4907,39 @@ abstract class CommonObject */ private function set_vars_by_db(&$obj) { - foreach ($this->fields as $field => $info) - { - if($this->isDate($info)) - { - 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)) - { - $this->{$field} = @unserialize($obj->{$field}); - // Hack for data not in UTF8 - if($this->{$field } === FALSE) @unserialize(utf8_decode($obj->{$field})); - } - elseif($this->isInt($info)) - { - $this->{$field} = (int) $obj->{$field}; - } - elseif($this->isFloat($info)) - { - $this->{$field} = (double) $obj->{$field}; - } - elseif($this->isNull($info)) - { - $val = $obj->{$field}; - // zero is not null - $this->{$field} = (is_null($val) || (empty($val) && $val!==0 && $val!=='0') ? null : $val); - } - else - { - $this->{$field} = $obj->{$field}; - } + foreach ($this->fields as $field => $info) + { + if($this->isDate($info)) + { + 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)) + { + $this->{$field} = @unserialize($obj->{$field}); + // Hack for data not in UTF8 + if($this->{$field } === FALSE) @unserialize(utf8_decode($obj->{$field})); + } + elseif($this->isInt($info)) + { + $this->{$field} = (int) $obj->{$field}; + } + elseif($this->isFloat($info)) + { + $this->{$field} = (double) $obj->{$field}; + } + elseif($this->isNull($info)) + { + $val = $obj->{$field}; + // zero is not null + $this->{$field} = (is_null($val) || (empty($val) && $val!==0 && $val!=='0') ? null : $val); + } + else + { + $this->{$field} = $obj->{$field}; + } - } + } } /** @@ -4963,41 +4949,170 @@ abstract class CommonObject */ private function get_field_list() { - $keys = array_keys($this->fields); - return implode(',', $keys); + $keys = array_keys($this->fields); + return implode(',', $keys); + } + + /** + * Add quote to field value if necessary + * + * @param string|int $value Value to protect + * @param array $fieldsentry Properties of field + * @return string + */ + protected function quote($value, $fieldsentry) { + if (is_null($value)) return 'NULL'; + else if (preg_match('/^(int|double|real)/i', $fieldsentry['type'])) return $this->db->escape("$value"); + else return "'".$this->db->escape($value)."'"; + } + + + /** + * Create object into database + * + * @param User $user User that creates + * @param bool $notrigger false=launch triggers after, true=disable triggers + * @return int <0 if KO, Id of created object if OK + */ + public function createCommon(User $user, $notrigger = false) + { + $error = 0; + + $now=dol_now(); + + $fieldvalues = $this->set_save_query(); + if (array_key_exists('date_creation', $fieldvalues) && empty($fieldvalues['date_creation'])) $fieldvalues['date_creation']=$this->db->idate($now); + unset($fieldvalues['rowid']); // We suppose the field rowid is reserved field for autoincrement field. + + $keys=array(); + $values = array(); + foreach ($fieldvalues as $k => $v) { + $keys[] = $k; + $values[] = $this->quote($v, $this->fields[$k]); + } + + $this->db->begin(); + + if (! $error) + { + $sql = 'INSERT INTO '.MAIN_DB_PREFIX.$this->table_element; + $sql.= ' ('.implode( ", ", $keys ).')'; + $sql.= ' VALUES ('.implode( ", ", $values ).')'; + + $res = $this->db->query( $sql ); + if ($res===false) { + $error++; + $this->errors[] = $this->db->lasterror(); + } + } + + if (! $error && ! $notrigger) { + $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX . $this->table_element); + + if (!$notrigger) { + // Call triggers + $result=$this->call_trigger(strtoupper(get_class(self)).'_CREATE',$user); + if ($result < 0) { $error++; } + // End call triggers + } + } + + // Commit or rollback + if ($error) { + $this->db->rollback(); + return -1; + } else { + $this->db->commit(); + return $this->id; + } + } + + /** + * Load an object from its id and create a new one in database + * + * @param User $user User that creates + * @param int $fromid Id of object to clone + * @return int New id of clone + */ + public function createFromCloneCommon(User $user, $fromid) + { + global $user, $langs; + + $error = 0; + + dol_syslog(__METHOD__, LOG_DEBUG); + + $object = new self($this->db); + + $this->db->begin(); + + // Load source object + $object->fetchCommon($fromid); + // Reset object + $object->id = 0; + + // Clear fields + $object->ref = "copy_of_".$object->ref; + $object->title = $langs->trans("CopyOf")." ".$object->title; + // ... + + // Create clone + $result = $object->createCommon($user); + + // Other options + if ($result < 0) { + $error++; + $this->error = $object->error; + $this->errors = $object->errors; + dol_syslog(__METHOD__ . ' ' . implode(',', $this->errors), LOG_ERR); + } + + // End + if (!$error) { + $this->db->commit(); + return $object->id; + } else { + $this->db->rollback(); + return -1; + } } /** * Load object in memory from the database * - * @param int $id Id object - * @param string $ref Ref - * - * @return int <0 if KO, 0 if not found, >0 if OK + * @param int $id Id object + * @param string $ref Ref + * @return int <0 if KO, 0 if not found, >0 if OK */ public function fetchCommon($id, $ref = null) { - if (empty($id) && empty($ref)) return false; - $sql = 'SELECT '.$this->get_field_list().', datec, tms'; + $sql = 'SELECT '.$this->get_field_list().', date_creation, tms'; $sql.= ' FROM '.MAIN_DB_PREFIX.$this->table_element; if(!empty($id)) $sql.= ' WHERE rowid = '.$id; - else $sql.= ' WHERE ref = \''.$this->quote($ref).'\''; + else $sql.= " WHERE ref = ".$this->quote($ref, $this->fields['ref']); $res = $this->db->query($sql); if ($res) { if ($obj = $this->db->fetch_object($res)) { - $this->id = $id; - $this->set_vars_by_db($obj); + if ($obj) + { + $this->id = $id; + $this->set_vars_by_db($obj); - $this->datec = $this->db->idate($obj->datec); - $this->tms = $this->db->idate($obj->tms); + $this->date_creation = $this->db->idate($obj->date_creation); + $this->tms = $this->db->idate($obj->tms); - return $this->id; + return $this->id; + } + else + { + return 0; + } } else { @@ -5019,78 +5134,114 @@ abstract class CommonObject * * @param User $user User that modifies * @param bool $notrigger false=launch triggers after, true=disable triggers - * - * @return int <0 if KO, >0 if OK + * @return int <0 if KO, >0 if OK */ public function updateCommon(User $user, $notrigger = false) { - $fields = $this->set_save_query(); + $error = 0; - foreach ($fields as $k => $v) { + $fieldvalues = $this->set_save_query(); + unset($fieldvalues['rowid']); // We don't update this field, it is the key to define which record to update. + foreach ($fieldvalues as $k => $v) { if (is_array($key)){ $i=array_search($k, $key); if ( $i !== false) { - $where[] = $key[$i].'=' . $this->quote( $v ) ; + $where[] = $key[$i].'=' . $this->quote($v, $this->fields[$k]); continue; } } else { if ( $k == $key) { - $where[] = $k.'=' .$this->quote( $v ) ; + $where[] = $k.'=' .$this->quote($v, $this->fields[$k]); continue; } } - - $tmp[] = $k.'='.$this->quote($v); + $tmp[] = $k.'='.$this->quote($v, $this->fields[$k]); } $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element.' SET '.implode( ',', $tmp ).' WHERE rowid='.$this->id ; - $res = $this->db->query( $sql ); - if($res===false) { - //error - return false; + $this->db->begin(); + if (! $error) + { + $res = $this->db->query($sql); + if ($res===false) + { + $error++; + $this->errors[] = $this->db->lasterror(); + } } - // TODO Add triggers + if (! $error && ! $notrigger) { + // Call triggers + $result=$this->call_trigger(strtoupper(get_class(self)).'_MODIFY',$user); + if ($result < 0) { $error++; } //Do also here what you must do to rollback action if trigger fail + // End call triggers + } - return true; + // Commit or rollback + if ($error) { + $this->db->rollback(); + return -1; + } else { + $this->db->commit(); + return $this->id; + } } /** * Delete object in database * - * @param User $user User that deletes - * @param bool $notrigger false=launch triggers after, true=disable triggers - * - * @return int <0 if KO, >0 if OK + * @param User $user User that deletes + * @param bool $notrigger false=launch triggers after, true=disable triggers + * @return int <0 if KO, >0 if OK */ public function deleteCommon(User $user, $notrigger = false) { - $sql = 'DELETE FROM '.MAIN_DB_PREFIX.$this->table_element.' WHERE rowid='.$this->id; + $error=0; - $res = $this->db->query( $sql ); - if($res===false) { - return false; + $this->db->begin(); + + if (! $error) { + if (! $notrigger) { + // Call triggers + $result=$this->call_trigger(strtoupper(get_class(self)).'_DELETE', $user); + if ($result < 0) { $error++; } // Do also here what you must do to rollback action if trigger fail + // End call triggers + } + } + + if (! $error) + { + $sql = 'DELETE FROM '.MAIN_DB_PREFIX.$this->table_element.' WHERE rowid='.$this->id; + + $res = $this->db->query($sql); + if($res===false) { + $error++; + $this->errors[] = $this->db->lasterror(); + } + } + + // Commit or rollback + if ($error) { + $this->db->rollback(); + return -1; + } else { + $this->db->commit(); + return 1; } - - // TODO Add triggers - - return true; } /** - * Add quote to field value if necessary + * Initialise object with example values + * Id must be 0 if object instance is a specimen * - * @param string|int $value value to protect - * @return string|int + * @return void */ - protected function quote($value) { - - if(is_null($value)) return 'NULL'; - else if(is_numeric($value)) return $value; - else return "'".$this->db->escape( $value )."'"; + public function initAsSpecimenCommon() + { + $this->id = 0; + // TODO... } } - diff --git a/htdocs/core/class/doleditor.class.php b/htdocs/core/class/doleditor.class.php index 9258e2b145d..549037a6fe2 100644 --- a/htdocs/core/class/doleditor.class.php +++ b/htdocs/core/class/doleditor.class.php @@ -81,7 +81,7 @@ class DolEditor // Check if extended editor is ok. If not we force textarea if (empty($conf->fckeditor->enabled) || ! $okforextendededitor) $this->tool = 'textarea'; - if ($conf->dol_use_jmobile) $this->tool = 'textarea'; // TODO ckeditor ko with jmobile + //if ($conf->dol_use_jmobile) $this->tool = 'textarea'; // ckeditor and ace seems ok with mobile // Define content and some properties if ($this->tool == 'ckeditor') diff --git a/htdocs/core/class/events.class.php b/htdocs/core/class/events.class.php index 2cfedfb7d1a..68f033870c2 100644 --- a/htdocs/core/class/events.class.php +++ b/htdocs/core/class/events.class.php @@ -172,7 +172,7 @@ class Events // extends CommonObject // Update request $sql = "UPDATE ".MAIN_DB_PREFIX."events SET"; $sql.= " type='".$this->db->escape($this->type)."',"; - $sql.= " dateevent=".$this->db->idate($this->dateevent).","; + $sql.= " dateevent='".$this->db->idate($this->dateevent)."',"; $sql.= " description='".$this->db->escape($this->description)."'"; $sql.= " WHERE rowid=".$this->id; diff --git a/htdocs/core/class/extrafields.class.php b/htdocs/core/class/extrafields.class.php index 4b5f151ec72..e44fa8a5aec 100644 --- a/htdocs/core/class/extrafields.class.php +++ b/htdocs/core/class/extrafields.class.php @@ -197,6 +197,7 @@ class ExtraFields if ($elementtype == 'contact') $elementtype='socpeople'; $table=$elementtype.'_extrafields'; + if ($elementtype == 'categorie') $table='categories_extrafields'; if (! empty($attrname) && preg_match("/^\w[a-zA-Z0-9_]*$/",$attrname) && ! is_numeric($attrname)) { @@ -350,6 +351,7 @@ class ExtraFields if ($elementtype == 'contact') $elementtype='socpeople'; $table=$elementtype.'_extrafields'; + if ($elementtype == 'categorie') $table='categories_extrafields'; $error=0; @@ -460,6 +462,7 @@ class ExtraFields if ($elementtype == 'contact') $elementtype='socpeople'; $table=$elementtype.'_extrafields'; + if ($elementtype == 'categorie') $table='categories_extrafields'; if (isset($attrname) && $attrname != '' && preg_match("/^\w[a-zA-Z0-9-_]*$/",$attrname)) { diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index ab64fad57dc..27115d12eb7 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -4,7 +4,7 @@ * Copyright (C) 2004 Benoit Mortier * Copyright (C) 2004 Sebastien Di Cintio * Copyright (C) 2004 Eric Seigne - * Copyright (C) 2005-2014 Regis Houssin + * Copyright (C) 2005-2017 Regis Houssin * Copyright (C) 2006 Andre Cianfarani * Copyright (C) 2006 Marc Barilley/Ocebo * Copyright (C) 2007 Franky Van Liedekerke @@ -4417,7 +4417,7 @@ class Form dol_syslog(__METHOD__, LOG_DEBUG); - $sql = "SELECT DISTINCT t.rowid, t.code, t.taux, t.recuperableonly"; + $sql = "SELECT DISTINCT t.rowid, t.code, t.taux, t.localtax1, t.localtax1_type, t.localtax2, t.localtax2_type, t.recuperableonly"; $sql.= " FROM ".MAIN_DB_PREFIX."c_tva as t, ".MAIN_DB_PREFIX."c_country as c"; $sql.= " WHERE t.fk_pays = c.rowid"; $sql.= " AND t.active > 0"; @@ -4436,8 +4436,20 @@ class Form $this->cache_vatrates[$i]['rowid'] = $obj->rowid; $this->cache_vatrates[$i]['code'] = $obj->code; $this->cache_vatrates[$i]['txtva'] = $obj->taux; - $this->cache_vatrates[$i]['libtva'] = $obj->taux.'%'.($obj->code?' ('.$obj->code.')':''); // Label must contains only 0-9 , . % or * $this->cache_vatrates[$i]['nprtva'] = $obj->recuperableonly; + $this->cache_vatrates[$i]['localtax1'] = $obj->localtax1; + $this->cache_vatrates[$i]['localtax1_type'] = $obj->localtax1_type; + $this->cache_vatrates[$i]['localtax2'] = $obj->localtax2; + $this->cache_vatrates[$i]['localtax2_type'] = $obj->localtax1_type; + + $this->cache_vatrates[$i]['label'] = $obj->taux.'%'.($obj->code?' ('.$obj->code.')':''); // Label must contains only 0-9 , . % or * + $this->cache_vatrates[$i]['labelallrates'] = $obj->taux.'/'.($obj->localtax1?$obj->localtax1:'0').'/'.($obj->localtax2?$obj->localtax2:'0').($obj->code?' ('.$obj->code.')':''); // Must never be used as key, only label + $positiverates=''; + if ($obj->taux) $positiverates.=($positiverates?'/':'').$obj->taux; + if ($obj->localtax1) $positiverates.=($positiverates?'/':'').$obj->localtax1; + if ($obj->localtax2) $positiverates.=($positiverates?'/':'').$obj->localtax2; + if (empty($positiverates)) $positiverates='0'; + $this->cache_vatrates[$i]['labelpositiverates'] = $positiverates.($obj->code?' ('.$obj->code.')':''); // Must never be used as key, only label } return $num; @@ -4611,7 +4623,16 @@ class Form $selectedfound=true; } } - $return.= '>'.vatrate($rate['libtva']); + $return.= '>'; + //if (! empty($conf->global->MAIN_VAT_SHOW_POSITIVE_RATES)) + if ($mysoc->country_code == 'IN' || ! empty($conf->global->MAIN_VAT_LABEL_IS_POSITIVE_RATES)) + { + $return.= $rate['labelpositiverates']; + } + else + { + $return.= vatrate($rate['label']); + } //$return.=($rate['code']?' '.$rate['code']:''); $return.= (empty($rate['code']) && $rate['nprtva']) ? ' *': ''; // We show the * (old behaviour only if new vat code is not used) @@ -5604,6 +5625,14 @@ class Form { $listofidcompanytoscan=$object->thirdparty->id; if (($object->thirdparty->parent > 0) && ! empty($conf->global->THIRDPARTY_INCLUDE_PARENT_IN_LINKTO)) $listofidcompanytoscan.=','.$object->thirdparty->parent; + if (($object->fk_project > 0) && ! empty($conf->global->THIRDPARTY_INCLUDE_PROJECT_THIRDPARY_IN_LINKTO)) + { + include_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; + $tmpproject=new Project($this->db); + $tmpproject->fetch($object->fk_project); + if ($tmpproject->socid > 0 && ($tmpproject->socid != $object->thirdparty->id)) $listofidcompanytoscan.=','.$tmpproject->socid; + unset($tmpproject); + } $possiblelinks=array( 'propal'=>array('enabled'=>$conf->propal->enabled, 'perms'=>1, 'label'=>'LinkToProposal', 'sql'=>"SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.ref, t.ref_client, t.total_ht FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."propal as t WHERE t.fk_soc = s.rowid AND t.fk_soc IN (".$listofidcompanytoscan.') AND t.entity IN ('.getEntity('propal').')'), @@ -5845,11 +5874,11 @@ class Form * @param string $morehtmlright More html code to show after ref. * @return string Portion HTML with ref + navigation buttons */ - function showrefnav($object,$paramid,$morehtml='',$shownav=1,$fieldid='rowid',$fieldref='ref',$morehtmlref='',$moreparam='',$nodbprefix=0,$morehtmlleft='',$morehtmlstatus='',$morehtmlright='') - { - global $langs,$conf,$hookmanager; + function showrefnav($object,$paramid,$morehtml='',$shownav=1,$fieldid='rowid',$fieldref='ref',$morehtmlref='',$moreparam='',$nodbprefix=0,$morehtmlleft='',$morehtmlstatus='',$morehtmlright='') + { + global $langs,$conf,$hookmanager; - $ret=''; + $ret=''; if (empty($fieldid)) $fieldid='rowid'; if (empty($fieldref)) $fieldref='ref'; @@ -5880,10 +5909,10 @@ class Form // Right part of banner if ($morehtmlright) $ret.='
'.$morehtmlright.'
'; - if ($previous_ref || $next_ref || $morehtml) - { - $ret.=''; } diff --git a/htdocs/projet/tasks/time.php b/htdocs/projet/tasks/time.php index 37331b000ab..f643b9b5ca3 100644 --- a/htdocs/projet/tasks/time.php +++ b/htdocs/projet/tasks/time.php @@ -96,7 +96,7 @@ if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'e include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; // Purge search criteria -if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") ||GETPOST("button_removefilter")) // All tests are required to be compatible with all browsers +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_date=''; $search_datehour=''; diff --git a/htdocs/public/websites/index.php b/htdocs/public/websites/index.php index 0bc85dce463..991ca11b683 100644 --- a/htdocs/public/websites/index.php +++ b/htdocs/public/websites/index.php @@ -47,7 +47,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; $error=0; -$website=GETPOST('website', 'alpha'); +$websitekey=GETPOST('website', 'alpha'); $pageid=GETPOST('page', 'alpha')?GETPOST('page', 'alpha'):GETPOST('pageid', 'alpha'); $accessallowed = 1; @@ -69,7 +69,7 @@ if (empty($pageid)) require_once DOL_DOCUMENT_ROOT.'/websites/class/websitepage.class.php'; $object=new Website($db); - $object->fetch(0, $website); + $object->fetch(0, $websitekey); if (empty($object->id)) { if (empty($pageid)) @@ -125,11 +125,11 @@ if ($pageid == 'css') // No more used ? //if (empty($dolibarr_nocache)) header('Cache-Control: max-age=3600, public, must-revalidate'); //else header('Cache-Control: no-cache'); - $original_file=$dolibarr_main_data_root.'/websites/'.$website.'/styles.css.php'; + $original_file=$dolibarr_main_data_root.'/websites/'.$websitekey.'/styles.css.php'; } else { - $original_file=$dolibarr_main_data_root.'/websites/'.$website.'/page'.$pageid.'.tpl.php'; + $original_file=$dolibarr_main_data_root.'/websites/'.$websitekey.'/page'.$pageid.'.tpl.php'; } // Find the subdirectory name as the reference @@ -177,7 +177,7 @@ if (! file_exists($original_file_osencoded)) // Output page content define('USEDOLIBARRSERVER', 1); -print "\n".''."\n"; +print ''."\n"; include_once $original_file_osencoded; diff --git a/htdocs/resource/list.php b/htdocs/resource/list.php index 53658c588c6..0564392071a 100644 --- a/htdocs/resource/list.php +++ b/htdocs/resource/list.php @@ -130,7 +130,7 @@ if (is_array($extrafields->attribute_label) && count($extrafields->attribute_lab include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; // Do we click on purge search criteria ? -if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETPOST("button_removefilter")) // Both test are required to be compatible with all browsers +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_ref=""; $search_label=""; diff --git a/htdocs/societe/agenda.php b/htdocs/societe/agenda.php index c67fb1c4dc4..497b9593142 100644 --- a/htdocs/societe/agenda.php +++ b/htdocs/societe/agenda.php @@ -83,7 +83,7 @@ if (empty($reshook)) } // Purge search criteria - if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETPOST("button_removefilter")) // All tests are required to be compatible with all browsers + 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 { $actioncode=''; $search_agenda_label=''; diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index 1605e7281b8..2bd764c92ed 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -4,7 +4,7 @@ * Copyright (C) 2004 Eric Seigne * Copyright (C) 2003 Brian Fraval * Copyright (C) 2006 Andre Cianfarani - * Copyright (C) 2005-2016 Regis Houssin + * Copyright (C) 2005-2017 Regis Houssin * Copyright (C) 2008 Patrick Raguin * Copyright (C) 2010-2014 Juanjo Menent * Copyright (C) 2013 Florian Henry @@ -3346,31 +3346,36 @@ class Societe extends CommonObject */ function getOutstandingProposals($mode='customer') { - $table='propal'; - if ($mode == 'supplier') $table = 'supplier_proposal'; + $table='propal'; + if ($mode == 'supplier') $table = 'supplier_proposal'; - $sql = "SELECT rowid, total_ht, total as total_ttc, fk_statut FROM ".MAIN_DB_PREFIX.$table." as f"; - $sql .= " WHERE fk_soc = ". $this->id; + $sql = "SELECT rowid, total_ht, total as total_ttc, fk_statut FROM ".MAIN_DB_PREFIX.$table." as f"; + $sql .= " WHERE fk_soc = ". $this->id; + if ($mode == 'supplier') { + $sql .= " AND entity IN (".getEntity('supplier_proposal').")"; + } else { + $sql .= " AND entity IN (".getEntity('propal').")"; + } - dol_syslog("getOutstandingProposals", LOG_DEBUG); - $resql=$this->db->query($sql); - if ($resql) - { - $outstandingOpened = 0; - $outstandingTotal = 0; - $outstandingTotalIncTax = 0; - while($obj=$this->db->fetch_object($resql)) { - $outstandingTotal+= $obj->total_ht; - $outstandingTotalIncTax+= $obj->total_ttc; - if ($obj->fk_statut != 0) // Not a draft - { - $outstandingOpened+=$obj->total_ttc; - } - } - return array('opened'=>$outstandingOpened, 'total_ht'=>$outstandingTotal, 'total_ttc'=>$outstandingTotalIncTax); - } - else - return array(); + dol_syslog("getOutstandingProposals", LOG_DEBUG); + $resql=$this->db->query($sql); + if ($resql) + { + $outstandingOpened = 0; + $outstandingTotal = 0; + $outstandingTotalIncTax = 0; + while($obj=$this->db->fetch_object($resql)) { + $outstandingTotal+= $obj->total_ht; + $outstandingTotalIncTax+= $obj->total_ttc; + if ($obj->fk_statut != 0) // Not a draft + { + $outstandingOpened+=$obj->total_ttc; + } + } + return array('opened'=>$outstandingOpened, 'total_ht'=>$outstandingTotal, 'total_ttc'=>$outstandingTotalIncTax); + } + else + return array(); } /** @@ -3381,31 +3386,36 @@ class Societe extends CommonObject */ function getOutstandingOrders($mode='customer') { - $table='commande'; - if ($mode == 'supplier') $table = 'commande_fournisseur'; + $table='commande'; + if ($mode == 'supplier') $table = 'commande_fournisseur'; - $sql = "SELECT rowid, total_ht, total_ttc, fk_statut FROM ".MAIN_DB_PREFIX.$table." as f"; - $sql .= " WHERE fk_soc = ". $this->id; + $sql = "SELECT rowid, total_ht, total_ttc, fk_statut FROM ".MAIN_DB_PREFIX.$table." as f"; + $sql .= " WHERE fk_soc = ". $this->id; + if ($mode == 'supplier') { + $sql .= " AND entity IN (".getEntity('supplier_order').")"; + } else { + $sql .= " AND entity IN (".getEntity('commande').")"; + } - dol_syslog("getOutstandingOrders", LOG_DEBUG); - $resql=$this->db->query($sql); - if ($resql) - { - $outstandingOpened = 0; - $outstandingTotal = 0; - $outstandingTotalIncTax = 0; - while($obj=$this->db->fetch_object($resql)) { - $outstandingTotal+= $obj->total_ht; - $outstandingTotalIncTax+= $obj->total_ttc; - if ($obj->fk_statut != 0) // Not a draft - { - $outstandingOpened+=$obj->total_ttc; - } - } - return array('opened'=>$outstandingOpened, 'total_ht'=>$outstandingTotal, 'total_ttc'=>$outstandingTotalIncTax); - } - else - return array(); + dol_syslog("getOutstandingOrders", LOG_DEBUG); + $resql=$this->db->query($sql); + if ($resql) + { + $outstandingOpened = 0; + $outstandingTotal = 0; + $outstandingTotalIncTax = 0; + while($obj=$this->db->fetch_object($resql)) { + $outstandingTotal+= $obj->total_ht; + $outstandingTotalIncTax+= $obj->total_ttc; + if ($obj->fk_statut != 0) // Not a draft + { + $outstandingOpened+=$obj->total_ttc; + } + } + return array('opened'=>$outstandingOpened, 'total_ht'=>$outstandingTotal, 'total_ttc'=>$outstandingTotalIncTax); + } + else + return array(); } /** @@ -3416,64 +3426,69 @@ class Societe extends CommonObject */ function getOutstandingBills($mode='customer') { - $table='facture'; - if ($mode == 'supplier') $table = 'facture_fourn'; + $table='facture'; + if ($mode == 'supplier') $table = 'facture_fourn'; - /* Accurate value of remain to pay is to sum remaintopay for each invoice - $paiement = $invoice->getSommePaiement(); - $creditnotes=$invoice->getSumCreditNotesUsed(); - $deposits=$invoice->getSumDepositsUsed(); - $alreadypayed=price2num($paiement + $creditnotes + $deposits,'MT'); - $remaintopay=price2num($invoice->total_ttc - $paiement - $creditnotes - $deposits,'MT'); - */ - if ($mode == 'supplier') $sql = "SELECT rowid, total_ht as total_ht, total_ttc, paye, fk_statut, close_code FROM ".MAIN_DB_PREFIX.$table." as f"; - else $sql = "SELECT rowid, total as total_ht, total_ttc, paye, fk_statut, close_code FROM ".MAIN_DB_PREFIX.$table." as f"; - $sql .= " WHERE fk_soc = ". $this->id; + /* Accurate value of remain to pay is to sum remaintopay for each invoice + $paiement = $invoice->getSommePaiement(); + $creditnotes=$invoice->getSumCreditNotesUsed(); + $deposits=$invoice->getSumDepositsUsed(); + $alreadypayed=price2num($paiement + $creditnotes + $deposits,'MT'); + $remaintopay=price2num($invoice->total_ttc - $paiement - $creditnotes - $deposits,'MT'); + */ + if ($mode == 'supplier') $sql = "SELECT rowid, total_ht as total_ht, total_ttc, paye, fk_statut, close_code FROM ".MAIN_DB_PREFIX.$table." as f"; + else $sql = "SELECT rowid, total as total_ht, total_ttc, paye, fk_statut, close_code FROM ".MAIN_DB_PREFIX.$table." as f"; + $sql .= " WHERE fk_soc = ". $this->id; + if ($mode == 'supplier') { + $sql .= " AND entity IN (".getEntity('facture_fourn').")"; + } else { + $sql .= " AND entity IN (".getEntity('facture').")"; + } - dol_syslog("getOutstandingBills", LOG_DEBUG); - $resql=$this->db->query($sql); - if ($resql) - { - $outstandingOpened = 0; - $outstandingTotal = 0; - $outstandingTotalIncTax = 0; - if ($mode == 'supplier') - { - require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php'; - $tmpobject=new FactureFournisseur($this->db); - } - else - { - require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; - $tmpobject=new Facture($this->db); - } - while($obj=$this->db->fetch_object($resql)) { - $tmpobject->id=$obj->rowid; - if ($obj->fk_statut != 0 // Not a draft - && ! ($obj->fk_statut == 3 && $obj->close_code == 'replaced') // Not a replaced invoice - ) - { - $outstandingTotal+= $obj->total_ht; - $outstandingTotalIncTax+= $obj->total_ttc; - } - if ($obj->paye == 0 - && $obj->fk_statut != 0 // Not a draft - && $obj->fk_statut != 3 // Not abandonned - && $obj->fk_statut != 2) // Not classified as paid - //$sql .= " AND (fk_statut <> 3 OR close_code <> 'abandon')"; // Not abandonned for undefined reason - { - $paiement = $tmpobject->getSommePaiement(); - $creditnotes = $tmpobject->getSumCreditNotesUsed(); - $deposits = $tmpobject->getSumDepositsUsed(); - $outstandingOpened+=$obj->total_ttc - $paiement - $creditnotes - $deposits; - } - } - return array('opened'=>$outstandingOpened, 'total_ht'=>$outstandingTotal, 'total_ttc'=>$outstandingTotalIncTax); - } - else - { - return array(); - } + dol_syslog("getOutstandingBills", LOG_DEBUG); + $resql=$this->db->query($sql); + if ($resql) + { + $outstandingOpened = 0; + $outstandingTotal = 0; + $outstandingTotalIncTax = 0; + if ($mode == 'supplier') + { + require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php'; + $tmpobject=new FactureFournisseur($this->db); + } + else + { + require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; + $tmpobject=new Facture($this->db); + } + while($obj=$this->db->fetch_object($resql)) { + $tmpobject->id=$obj->rowid; + if ($obj->fk_statut != 0 // Not a draft + && ! ($obj->fk_statut == 3 && $obj->close_code == 'replaced') // Not a replaced invoice + ) + { + $outstandingTotal+= $obj->total_ht; + $outstandingTotalIncTax+= $obj->total_ttc; + } + if ($obj->paye == 0 + && $obj->fk_statut != 0 // Not a draft + && $obj->fk_statut != 3 // Not abandonned + && $obj->fk_statut != 2) // Not classified as paid + //$sql .= " AND (fk_statut <> 3 OR close_code <> 'abandon')"; // Not abandonned for undefined reason + { + $paiement = $tmpobject->getSommePaiement(); + $creditnotes = $tmpobject->getSumCreditNotesUsed(); + $deposits = $tmpobject->getSumDepositsUsed(); + $outstandingOpened+=$obj->total_ttc - $paiement - $creditnotes - $deposits; + } + } + return array('opened'=>$outstandingOpened, 'total_ht'=>$outstandingTotal, 'total_ttc'=>$outstandingTotalIncTax); + } + else + { + return array(); + } } /** diff --git a/htdocs/societe/consumption.php b/htdocs/societe/consumption.php index d9cae2a4170..5c134aee36d 100644 --- a/htdocs/societe/consumption.php +++ b/htdocs/societe/consumption.php @@ -57,7 +57,7 @@ $month = GETPOST('month','int'); $year = GETPOST('year','int'); // Clean up on purge search criteria ? -if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETPOST("button_removefilter")) // Both test are required to be compatible with all browsers +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 { $sref=''; $sprod_fulldescr=''; diff --git a/htdocs/societe/list.php b/htdocs/societe/list.php index 252bfc9383c..6896685f4fc 100644 --- a/htdocs/societe/list.php +++ b/htdocs/societe/list.php @@ -49,6 +49,8 @@ if ($user->societe_id) $socid=$user->societe_id; $result = restrictedArea($user,'societe',$socid,''); $search_all=trim(GETPOST('sall', 'alphanohtml')); +$search_cti=preg_replace('/^0+/', '', preg_replace('/[^0-9]/', '', GETPOST('search_cti', 'alphanohtml'))); // Phone number without any special chars + $search_nom=trim(GETPOST("search_nom")); $search_alias=trim(GETPOST("search_alias")); $search_nom_only=trim(GETPOST("search_nom_only")); @@ -209,7 +211,7 @@ if (empty($reshook)) include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; // Did we click on purge search criteria ? - if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETPOST("button_removefilter")) // All tests are required to be compatible with all browsers + 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_nom=''; $search_alias=''; @@ -401,39 +403,42 @@ if ($search_sale || (!$user->rights->societe->client->voir && !$socid)) $sql.= " $sql.= " WHERE s.fk_stcomm = st.id"; $sql.= " AND s.entity IN (".getEntity('societe').")"; if (! $user->rights->societe->client->voir && ! $socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; -if ($socid) $sql.= " AND s.rowid = ".$socid; -if ($search_sale) $sql.= " AND s.rowid = sc.fk_soc"; // Join for the needed table to filter by sale +if ($socid) $sql.= " AND s.rowid = ".$socid; +if ($search_sale) $sql.= " AND s.rowid = sc.fk_soc"; // Join for the needed table to filter by sale if (! $user->rights->fournisseur->lire) $sql.=" AND (s.fournisseur <> 1 OR s.client <> 0)"; // client=0, fournisseur=0 must be visible -if ($search_sale) $sql.= " AND sc.fk_user = ".$db->escape($search_sale); -if ($search_categ > 0) $sql.= " AND cs.fk_categorie = ".$db->escape($search_categ); -if ($search_categ == -2) $sql.= " AND cs.fk_categorie IS NULL"; -if ($search_all) $sql.= natural_search(array_keys($fieldstosearchall), $search_all); -if ($search_nom) $sql.= natural_search("s.nom",$search_nom); -if ($search_alias) $sql.= natural_search("s.name_alias",$search_alias); -if ($search_nom_only) $sql.= natural_search("s.nom",$search_nom_only); +if ($search_sale) $sql.= " AND sc.fk_user = ".$db->escape($search_sale); +if ($search_categ > 0) $sql.= " AND cs.fk_categorie = ".$db->escape($search_categ); +if ($search_categ == -2) $sql.= " AND cs.fk_categorie IS NULL"; + +if ($search_all) $sql.= natural_search(array_keys($fieldstosearchall), $search_all); +if (strlen($search_cti)) $sql.= natural_search('s.phone', $search_cti); + +if ($search_nom) $sql.= natural_search("s.nom",$search_nom); +if ($search_alias) $sql.= natural_search("s.name_alias",$search_alias); +if ($search_nom_only) $sql.= natural_search("s.nom",$search_nom_only); if ($search_customer_code) $sql.= natural_search("s.code_client",$search_customer_code); if ($search_supplier_code) $sql.= natural_search("s.code_fournisseur",$search_supplier_code); if ($search_account_customer_code) $sql.= natural_search("s.code_compta",$search_account_customer_code); if ($search_account_supplier_code) $sql.= natural_search("s.code_compta_fournisseur",$search_account_supplier_code); -if ($search_town) $sql.= natural_search("s.town",$search_town); -if ($search_zip) $sql.= natural_search("s.zip",$search_zip); -if ($search_state) $sql.= natural_search("state.nom",$search_state); -if ($search_country) $sql .= " AND s.fk_pays IN (".$search_country.')'; -if ($search_email) $sql.= natural_search("s.email",$search_email); -if ($search_phone) $sql.= natural_search("s.phone",$search_phone); -if ($search_url) $sql.= natural_search("s.url",$search_url); -if ($search_idprof1) $sql.= natural_search("s.siren",$search_idprof1); -if ($search_idprof2) $sql.= natural_search("s.siret",$search_idprof2); -if ($search_idprof3) $sql.= natural_search("s.ape",$search_idprof3); -if ($search_idprof4) $sql.= natural_search("s.idprof4",$search_idprof4); -if ($search_idprof5) $sql.= natural_search("s.idprof5",$search_idprof5); -if ($search_idprof6) $sql.= natural_search("s.idprof6",$search_idprof6); +if ($search_town) $sql.= natural_search("s.town",$search_town); +if (strlen($search_zip)) $sql.= natural_search("s.zip",$search_zip); +if ($search_state) $sql.= natural_search("state.nom",$search_state); +if ($search_country) $sql .= " AND s.fk_pays IN (".$search_country.')'; +if ($search_email) $sql.= natural_search("s.email",$search_email); +if (strlen($search_phone)) $sql.= natural_search("s.phone", $search_phone); +if ($search_url) $sql.= natural_search("s.url",$search_url); +if (strlen($search_idprof1)) $sql.= natural_search("s.siren",$search_idprof1); +if (strlen($search_idprof2)) $sql.= natural_search("s.siret",$search_idprof2); +if (strlen($search_idprof3)) $sql.= natural_search("s.ape",$search_idprof3); +if (strlen($search_idprof4)) $sql.= natural_search("s.idprof4",$search_idprof4); +if (strlen($search_idprof5)) $sql.= natural_search("s.idprof5",$search_idprof5); +if (strlen($search_idprof6)) $sql.= natural_search("s.idprof6",$search_idprof6); // Filter on type of thirdparty if ($search_type > 0 && in_array($search_type,array('1,3','2,3'))) $sql .= " AND s.client IN (".$db->escape($search_type).")"; if ($search_type > 0 && in_array($search_type,array('4'))) $sql .= " AND s.fournisseur = 1"; if ($search_type == '0') $sql .= " AND s.client = 0 AND s.fournisseur = 0"; if ($search_status!='' && $search_status >= 0) $sql .= " AND s.status = ".$db->escape($search_status); -if (!empty($conf->barcode->enabled) && $search_barcode) $sql.= " AND s.barcode LIKE '%".$db->escape($search_barcode)."%'"; +if (!empty($conf->barcode->enabled) && $search_barcode) $sql.= natural_search("s.barcode", $search_barcode); if ($search_type_thirdparty) $sql .= " AND s.fk_typent IN (".$search_type_thirdparty.')'; if ($search_levels) $sql .= " AND s.fk_prospectlevel IN (".$search_levels.')'; if ($search_stcomm != '' && $search_stcomm != -2) $sql.= natural_search("s.fk_stcomm",$search_stcomm,2); @@ -478,7 +483,7 @@ $num = $db->num_rows($resql); $arrayofselected=is_array($toselect)?$toselect:array(); -if ($num == 1 && ! empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $search_all && $action != 'list') +if ($num == 1 && ! empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && ($search_all != '' || $search_cti != '') && $action != 'list') { $obj = $db->fetch_object($resql); $id = $obj->rowid; diff --git a/htdocs/societe/price.php b/htdocs/societe/price.php index 5146e3ad6a5..515aef60a6a 100644 --- a/htdocs/societe/price.php +++ b/htdocs/societe/price.php @@ -69,7 +69,7 @@ if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'e if (empty($reshook)) { - if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETPOST("button_removefilter")) // Both test are required to be compatible with all browsers + 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_prod = ''; } @@ -187,7 +187,7 @@ if (! empty($conf->notification->enabled)) $langs->load("mails"); $head = societe_prepare_head($object); -dol_fiche_head($head, 'price', $langs->trans("ThirdParty"), 0, 'company'); +dol_fiche_head($head, 'price', $langs->trans("ThirdParty"), -1, 'company'); $linkback = ''.$langs->trans("BackToList").''; @@ -200,11 +200,11 @@ print ''; if (! empty($conf->global->SOCIETE_USEPREFIX)) // Old not used prefix field { - print ''; + print ''; } if ($object->client) { - print '
' . $langs->trans('Prefix') . '' . $object->prefix_comm . '
' . $langs->trans('Prefix') . '' . $object->prefix_comm . '
'; + print '
'; print $langs->trans('CustomerCode') . ''; print $object->code_client; if ($object->check_codeclient() != 0) @@ -213,7 +213,7 @@ if ($object->client) { } if ($object->fournisseur) { - print '
'; + print '
'; print $langs->trans('SupplierCode') . ''; print $object->code_fournisseur; if ($object->check_codefournisseur() != 0) diff --git a/htdocs/supplier_proposal/card.php b/htdocs/supplier_proposal/card.php index e5040b3150d..5c39f910b66 100644 --- a/htdocs/supplier_proposal/card.php +++ b/htdocs/supplier_proposal/card.php @@ -511,7 +511,8 @@ if (empty($reshook)) $error = 0; // Set if we used free entry or predefined product - $predef=''; + $predef=''; + $ref_fourn = GETPOST('fourn_ref'); $product_desc=(GETPOST('dp_desc')?GETPOST('dp_desc'):''); $date_start=dol_mktime(GETPOST('date_start'.$predef.'hour'), GETPOST('date_start'.$predef.'min'), GETPOST('date_start' . $predef . 'sec'), GETPOST('date_start'.$predef.'month'), GETPOST('date_start'.$predef.'day'), GETPOST('date_start'.$predef.'year')); $date_end=dol_mktime(GETPOST('date_end'.$predef.'hour'), GETPOST('date_end'.$predef.'min'), GETPOST('date_end' . $predef . 'sec'), GETPOST('date_end'.$predef.'month'), GETPOST('date_end'.$predef.'day'), GETPOST('date_end'.$predef.'year')); @@ -599,7 +600,7 @@ if (empty($reshook)) $price_base_type = $productsupplier->fourn_price_base_type; $type = $productsupplier->type; $label = $productsupplier->label; - $desc = $productsupplier->description; + $desc = $productsupplier->description; if (trim($product_desc) != trim($desc)) $desc = dol_concatdesc($desc, $product_desc); $tva_tx = get_default_tva($object->thirdparty, $mysoc, $productsupplier->id, GETPOST('idprodfournprice')); @@ -983,7 +984,9 @@ $now = dol_now(); // Add new askprice if ($action == 'create') { - print load_fiche_titre($langs->trans("NewAskPrice")); + $currency_code = $conf->currency; + + print load_fiche_titre($langs->trans("NewAskPrice")); $soc = new Societe($db); if ($socid > 0) diff --git a/htdocs/supplier_proposal/class/supplier_proposal.class.php b/htdocs/supplier_proposal/class/supplier_proposal.class.php index 0c8410213af..c37555efdb7 100644 --- a/htdocs/supplier_proposal/class/supplier_proposal.class.php +++ b/htdocs/supplier_proposal/class/supplier_proposal.class.php @@ -2563,10 +2563,9 @@ class SupplierProposal extends CommonObject /** - * \class SupplierProposalLine - * \brief Class to manage supplier_proposal lines + * Class to manage supplier_proposal lines */ -class SupplierProposalLine extends CommonObjectLine +class SupplierProposalLine extends CommonObjectLine { var $db; var $error; @@ -2798,6 +2797,7 @@ class SupplierProposalLine extends CommonObjectLine if (empty($this->fk_parent_line)) $this->fk_parent_line=0; if (empty($this->fk_fournprice)) $this->fk_fournprice=0; if (empty($this->fk_unit)) $this->fk_unit=0; + if (empty($this->subprice)) $this->subprice=0; if (empty($this->pa_ht)) $this->pa_ht=0; @@ -2841,7 +2841,7 @@ class SupplierProposalLine extends CommonObjectLine $sql.= " ".price2num($this->localtax2_tx).","; $sql.= " '".$this->localtax1_type."',"; $sql.= " '".$this->localtax2_type."',"; - $sql.= " ".price2num($this->subprice).","; + $sql.= " ".(!empty($this->subprice)?price2num($this->subprice):"null").","; $sql.= " ".price2num($this->remise_percent).","; $sql.= " ".(isset($this->info_bits)?"'".$this->info_bits."'":"null").","; $sql.= " ".price2num($this->total_ht).","; @@ -2982,6 +2982,7 @@ class SupplierProposalLine extends CommonObjectLine if (empty($this->fk_parent_line)) $this->fk_parent_line=0; if (empty($this->fk_fournprice)) $this->fk_fournprice=0; if (empty($this->fk_unit)) $this->fk_unit=0; + if (empty($this->subprice)) $this->subprice=0; if (empty($this->pa_ht)) $this->pa_ht=0; diff --git a/htdocs/supplier_proposal/list.php b/htdocs/supplier_proposal/list.php index f6d9c9510a0..23a0fae1876 100644 --- a/htdocs/supplier_proposal/list.php +++ b/htdocs/supplier_proposal/list.php @@ -177,7 +177,7 @@ if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'e include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; // Do we click on purge search criteria ? -if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") ||GETPOST("button_removefilter")) // All tests are required to be compatible with all browsers +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_categ=''; $search_user=''; diff --git a/htdocs/theme/eldy/ckeditor/config.js b/htdocs/theme/eldy/ckeditor/config.js index eabd0c58bd3..cddbef17dd1 100644 --- a/htdocs/theme/eldy/ckeditor/config.js +++ b/htdocs/theme/eldy/ckeditor/config.js @@ -15,6 +15,7 @@ CKEDITOR.editorConfig = function( config ) //config.height = '300px'; //config.resize_dir = 'vertical'; // horizontal, vertical, both config.removePlugins = 'elementspath,save'; // config.removePlugins = 'elementspath,save,font'; + //config.extraPlugins = 'docprops,scayt,showprotected'; config.removeDialogTabs = 'flash:advanced'; // config.removeDialogTabs = 'flash:advanced;image:Link'; config.protectedSource.push( /<\?[\s\S]*?\?>/g ); // Prevent PHP Code to be formatted //config.menu_groups = 'clipboard,table,anchor,link,image'; // for context menu 'clipboard,form,tablecell,tablecellproperties,tablerow,tablecolumn,table,anchor,link,image,flash,checkbox,radio,textfield,hiddenfield,imagebutton,button,select,textarea' @@ -25,7 +26,10 @@ CKEDITOR.editorConfig = function( config ) config.dialog_backgroundCoverColor = 'rgb(255, 254, 253)'; //config.contentsCss = '/css/mysitestyles.css'; config.image_previewText=' '; // Must no be empty - + //config.autoParagraph = false; + //config.removeFormatTags = 'b,big,code,del,dfn,em,font,i,ins,kbd'; // See also rules on this.dataProcessor.writer.setRules + //config.forcePasteAsPlainText = true; + config.toolbar_Full = [ ['Templates','NewPage'], diff --git a/htdocs/theme/eldy/style.css.php b/htdocs/theme/eldy/style.css.php index 1136e1c1fc4..7bd3d913782 100644 --- a/htdocs/theme/eldy/style.css.php +++ b/htdocs/theme/eldy/style.css.php @@ -2607,7 +2607,7 @@ form.tagtr:last-of-type div.tagtd, tr.pair:last-of-type td, tr.impair:last-of-ty tr.pair td .nobordernopadding tr td, tr.impair td .nobordernopadding tr td { border-bottom: 0px !important; } -td.nobottom, td.nobottom { +tr.nobottom td, tr.nobottom , td.nobottom { border-bottom: 0px !important; } div.liste_titre .tagtd { @@ -3347,6 +3347,11 @@ a.websitebuttonsitepreview img { width: 26px; display: inline-block; } +.websitehelp { + vertical-align: middle; + float: right; + padding-top: 8px; +} /* ============================================================================== */ diff --git a/htdocs/theme/md/ckeditor/config.js b/htdocs/theme/md/ckeditor/config.js index 6f1bbe7fb30..e0374f6b271 100644 --- a/htdocs/theme/md/ckeditor/config.js +++ b/htdocs/theme/md/ckeditor/config.js @@ -15,6 +15,7 @@ CKEDITOR.editorConfig = function( config ) //config.height = '300px'; //config.resize_dir = 'vertical'; // horizontal, vertical, both config.removePlugins = 'elementspath,save'; // config.removePlugins = 'elementspath,save,font'; + //config.extraPlugins = 'docprops,scayt,showprotected'; config.removeDialogTabs = 'flash:advanced'; // config.removeDialogTabs = 'flash:advanced;image:Link'; config.protectedSource.push( /<\?[\s\S]*?\?>/g ); // Prevent PHP Code to be formatted //config.menu_groups = 'clipboard,table,anchor,link,image'; // for context menu 'clipboard,form,tablecell,tablecellproperties,tablerow,tablecolumn,table,anchor,link,image,flash,checkbox,radio,textfield,hiddenfield,imagebutton,button,select,textarea' @@ -25,7 +26,10 @@ CKEDITOR.editorConfig = function( config ) config.dialog_backgroundCoverColor = 'rgb(255, 254, 253)'; //config.contentsCss = '/css/mysitestyles.css'; config.image_previewText=' '; // Must no be empty - + //config.autoParagraph = false; + //config.removeFormatTags = 'b,big,code,del,dfn,em,font,i,ins,kbd'; // See also rules on this.dataProcessor.writer.setRules + //config.forcePasteAsPlainText = true; + config.toolbar_Full = [ ['Templates','NewPage'], diff --git a/htdocs/theme/md/style.css.php b/htdocs/theme/md/style.css.php index 978b093fc9d..b190a3fad67 100644 --- a/htdocs/theme/md/style.css.php +++ b/htdocs/theme/md/style.css.php @@ -2684,7 +2684,7 @@ tr.pair:last-of-type td, tr.impair:last-of-type td { tr.pair td .nobordernopadding tr td, tr.impair td .nobordernopadding tr td { border-bottom: 0px !important; } -td.nobottom, td.nobottom { +tr.nobottom td, tr.nobottom , td.nobottom { border-bottom: 0px !important; } div.liste_titre .tagtd { @@ -3428,7 +3428,11 @@ a.websitebuttonsitepreview img { .websiteiframenoborder { border: 0px; } - +.websitehelp { + vertical-align: middle; + float: right; + padding-top: 8px; +} /* ============================================================================== */ /* Module agenda */ diff --git a/htdocs/user/bank.php b/htdocs/user/bank.php index 939f7c35aa7..b71a5ccdf18 100644 --- a/htdocs/user/bank.php +++ b/htdocs/user/bank.php @@ -46,8 +46,17 @@ $cancel = GETPOST('cancel','alpha'); $socid=0; if ($user->societe_id > 0) $socid = $user->societe_id; $feature2 = (($socid && $user->rights->user->self->creer)?'':'user'); -if ($user->id == $id) $feature2=''; // A user can always read its own card -$result = restrictedArea($user, 'salaries|hrm', $id, 'user&user', $feature2); +// Ok if user->rights->salaries->read or user->rights->salaries->payment->write or user->rights->hrm->read +//$result = restrictedArea($user, 'salaries|hrm', $id, 'user&user', $feature2); +$ok=false; +if ($user->id == $id) $ok=true; // A user can always read its own card +if ($user->rights->salaries->read) $ok=true; +if ($user->rights->salaries->payment->write) $ok=true; +if ($user->rights->hrm->read) $ok=true; +if (! $ok) +{ + accessforbidden(); +} $object = new User($db); if ($id > 0 || ! empty($ref)) @@ -61,6 +70,42 @@ if ($id > 0 || ! empty($ref)) * Actions */ +if ($action == 'add' && ! $cancel) +{ + // Modification + $account = new UserBankAccount($db); + + $account->userid = $object->id; + + $account->bank = $_POST["bank"]; + $account->label = $_POST["label"]; + $account->courant = $_POST["courant"]; + $account->clos = $_POST["clos"]; + $account->code_banque = $_POST["code_banque"]; + $account->code_guichet = $_POST["code_guichet"]; + $account->number = $_POST["number"]; + $account->cle_rib = $_POST["cle_rib"]; + $account->bic = $_POST["bic"]; + $account->iban = $_POST["iban"]; + $account->domiciliation = $_POST["domiciliation"]; + $account->proprio = $_POST["proprio"]; + $account->owner_address = $_POST["owner_address"]; + + $result = $account->create($user); + + if (! $result) + { + setEventMessages($account->error, $account->errors, 'errors'); + $action='edit'; // Force chargement page edition + } + else + { + $url=DOL_URL_ROOT.'/user/bank.php?id='.$object->id.'&bankid='.$bankid; + header('Location: '.$url); + exit; + } +} + if ($action == 'update' && ! $cancel) { // Modification @@ -122,7 +167,7 @@ else if (empty($account->userid)) $account->userid=$object->id; -if ($bankid && $action == 'edit' && $user->rights->user->user->creer) +if ($id && $bankid && $action == 'edit' && $user->rights->user->user->creer) { print ''; print ''; @@ -130,7 +175,7 @@ if ($bankid && $action == 'edit' && $user->rights->user->user->creer) print ''; print ''; } -if ($bankid && $action == 'create' && $user->rights->user->user->creer) +if ($id && $action == 'create' && $user->rights->user->user->creer) { print ''; print ''; @@ -140,7 +185,7 @@ if ($bankid && $action == 'create' && $user->rights->user->user->creer) // View -if ($account->id && $action != 'edit') +if ($action != 'edit' && $action != 'create') // If not bank account yet, $account may be empty { $title = $langs->trans("User"); dol_fiche_head($head, 'bank', $title, -1, 'user'); @@ -150,24 +195,25 @@ if ($account->id && $action != 'edit') if ($user->rights->user->user->lire || $user->admin) { $linkback = ''.$langs->trans("BackToList").''; } - + dol_banner_tab($object,'id',$linkback,$user->rights->user->user->lire || $user->admin); - + print '
'; print '
'; - + print ''; - - print ''; - print ''; - + + print ''; + print ''; + print ''; + print '
'.$langs->trans("xxx").'
'.$langs->trans("Login").''.$object->login.'
'; - + print '
'; - + print load_fiche_titre($langs->trans("BAN")); - + print '
'; print ''; @@ -237,7 +283,7 @@ if ($account->id && $action != 'edit') } print ""; - + dol_fiche_end(); /* @@ -247,24 +293,27 @@ if ($account->id && $action != 'edit') if ($user->rights->user->user->creer) { + if ($account->id > 0) print ''.$langs->trans("Edit").''; + else + print ''.$langs->trans("Create").''; } print ''; } // Edit -if ($id && $action == 'edit' && $user->rights->user->user->creer) +if ($id && ($action == 'edit' || $action == 'create' ) && $user->rights->user->user->creer) { $title = $langs->trans("User"); dol_fiche_head($head, 'bank', $title, 0, 'user'); $linkback = ''.$langs->trans("BackToList").''; - - dol_banner_tab($object, 'id', $linkback,$user->rights->user->user->lire || $user->admin); - + + dol_banner_tab($object, 'id', $linkback, $user->rights->user->user->lire || $user->admin); + //print '
'; - + print '
'; print '
'; @@ -323,7 +372,7 @@ if ($id && $action == 'edit' && $user->rights->user->user->creer) print '
'; //print '
'; - + dol_fiche_end(); print '
'; @@ -334,7 +383,9 @@ if ($id && $action == 'edit' && $user->rights->user->user->creer) } if ($id && $action == 'edit' && $user->rights->user->user->creer) print ''; - + +if ($id && $action == 'create' && $user->rights->user->user->creer) print ''; + llxFooter(); $db->close(); diff --git a/htdocs/user/class/userbankaccount.class.php b/htdocs/user/class/userbankaccount.class.php index 00d350c3b0f..77872bf8654 100644 --- a/htdocs/user/class/userbankaccount.class.php +++ b/htdocs/user/class/userbankaccount.class.php @@ -73,7 +73,8 @@ class UserBankAccount extends Account if ($this->db->affected_rows($resql)) { $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."user_rib"); - return 1; + + return $this->update($user); } } else diff --git a/htdocs/user/class/usergroup.class.php b/htdocs/user/class/usergroup.class.php index be9bb0e1f4c..5240605c25c 100644 --- a/htdocs/user/class/usergroup.class.php +++ b/htdocs/user/class/usergroup.class.php @@ -806,6 +806,7 @@ class UserGroup extends CommonObject function _load_ldap_info() { global $conf,$langs; + $info=array(); // Object classes diff --git a/htdocs/user/group/card.php b/htdocs/user/group/card.php index e53080cea73..a32db37d3fb 100644 --- a/htdocs/user/group/card.php +++ b/htdocs/user/group/card.php @@ -1,9 +1,9 @@ - * Copyright (C) 2005-2015 Laurent Destailleur - * Copyright (C) 2005-2017 Regis Houssin - * Copyright (C) 2011 Herve Prot - * Copyright (C) 2012 Florian Henry +/* Copyright (C) 2005 Rodolphe Quiedeville + * Copyright (C) 2005-2015 Laurent Destailleur + * Copyright (C) 2005-2017 Regis Houssin + * Copyright (C) 2011 Herve Prot + * Copyright (C) 2012 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 @@ -82,7 +82,7 @@ if ($action == 'confirm_delete' && $confirm == "yes") } else { - $langs->load("errors"); + $langs->load("errors"); setEventMessages($langs->trans('ErrorForbidden'), null, 'errors'); } } @@ -132,7 +132,7 @@ if ($action == 'add') } else { - $langs->load("errors"); + $langs->load("errors"); setEventMessages($langs->trans('ErrorForbidden'), null, 'errors'); } } @@ -165,7 +165,7 @@ if ($action == 'adduser' || $action =='removeuser') } else { - $langs->load("errors"); + $langs->load("errors"); setEventMessages($langs->trans('ErrorForbidden'), null, 'errors'); } } @@ -207,7 +207,7 @@ if ($action == 'update') } else { - $langs->load("errors"); + $langs->load("errors"); setEventMessages($langs->trans('ErrorForbidden'), null, 'mesgs'); } } @@ -275,7 +275,7 @@ if ($action == 'create') print $hookmanager->resPrint; if (empty($reshook) && ! empty($extrafields->attribute_label)) { - print $object->showOptionals($extrafields,'edit'); + print $object->showOptionals($extrafields,'edit'); } print "
\n"; @@ -316,23 +316,26 @@ else if ($action != 'edit') { - dol_fiche_head($head, 'group', $title, -1, 'group'); + dol_fiche_head($head, 'group', $title, -1, 'group'); dol_banner_tab($object,'id','',$user->rights->user->user->lire || $user->admin); print '
'; print '
'; - print ''; + print '
'; - // Name - print ''; - print '\n"; + // Name (already in dol_banner, we keep it to have the GlobalGroup picto, but we should move it in dol_banner) + if (! empty($conf->mutlicompany->enabled)) + { + print ''; + print '\n"; + } // Multicompany if (! empty($conf->multicompany->enabled) && is_object($mc) && empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE) && $conf->entity == 1 && $user->admin && ! $user->entity) @@ -350,7 +353,7 @@ else // Other attributes $parameters=array('colspan' => ' colspan="2"'); - include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php'; + include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php'; print "
'.$langs->trans("Name").''.$object->name; - if (empty($object->entity)) - { - print img_picto($langs->trans("GlobalGroup"),'redstar'); - } - print "
'.$langs->trans("Name").''.$object->name; + if (empty($object->entity)) + { + print img_picto($langs->trans("GlobalGroup"),'redstar'); + } + print "
\n"; print '
'; @@ -435,59 +438,57 @@ else print ''.$langs->trans("Lastname").''; print ''.$langs->trans("Firstname").''; if (! empty($conf->multicompany->enabled) && $conf->entity == 1) - { - print ''.$langs->trans("Entity").''; + { + print ''.$langs->trans("Entity").''; } print ''.$langs->trans("Status").''; print ' '; print "\n"; - if (! empty($object->members)) - { - foreach($object->members as $useringroup) - { - - - print ''; - print ''; - print $useringroup->getNomUrl(-1, '', 0, 0, 24, 0, 'login'); - if ($useringroup->admin && ! $useringroup->entity) print img_picto($langs->trans("SuperAdministrator"),'redstar'); - else if ($useringroup->admin) print img_picto($langs->trans("Administrator"),'star'); - print ''; - print ''.$useringroup->lastname.''; - print ''.$useringroup->firstname.''; - if (! empty($conf->multicompany->enabled) && is_object($mc) && ! empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE) && $conf->entity == 1 && $user->admin && ! $user->entity) - { - print ''; - if (! empty($useringroup->usergroup_entity)) - { - $nb=0; - foreach($useringroup->usergroup_entity as $group_entity) - { - $mc->getInfo($group_entity); - print ($nb > 0 ? ', ' : '').$mc->label; - print ''; - print img_delete($langs->trans("RemoveFromGroup")); - print ''; - $nb++; - } - } - print ''; - } - print ''.$useringroup->getLibStatut(3).''; - print ''; - if (! empty($user->admin) && empty($conf->multicompany->enabled)) - { - print ''; - print img_delete($langs->trans("RemoveFromGroup")); - print ''; - } - else - { - print "-"; - } - print "\n"; - } + if (! empty($object->members)) + { + foreach($object->members as $useringroup) + { + print ''; + print ''; + print $useringroup->getNomUrl(-1, '', 0, 0, 24, 0, 'login'); + if ($useringroup->admin && ! $useringroup->entity) print img_picto($langs->trans("SuperAdministrator"),'redstar'); + else if ($useringroup->admin) print img_picto($langs->trans("Administrator"),'star'); + print ''; + print ''.$useringroup->lastname.''; + print ''.$useringroup->firstname.''; + if (! empty($conf->multicompany->enabled) && is_object($mc) && ! empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE) && $conf->entity == 1 && $user->admin && ! $user->entity) + { + print ''; + if (! empty($useringroup->usergroup_entity)) + { + $nb=0; + foreach($useringroup->usergroup_entity as $group_entity) + { + $mc->getInfo($group_entity); + print ($nb > 0 ? ', ' : '').$mc->label; + print ''; + print img_delete($langs->trans("RemoveFromGroup")); + print ''; + $nb++; + } + } + print ''; + } + print ''.$useringroup->getLibStatut(3).''; + print ''; + if (! empty($user->admin) && empty($conf->multicompany->enabled)) + { + print ''; + print img_delete($langs->trans("RemoveFromGroup")); + print ''; + } + else + { + print "-"; + } + print "\n"; + } } else { @@ -547,10 +548,10 @@ else print "".$mc->select_entities($object->entity); print "\n"; } - else - { - print ''; - } + else + { + print ''; + } } print ''.$langs->trans("Description").''; @@ -560,13 +561,13 @@ else $doleditor->Create(); print ''; print "\n"; - // Other attributes + // Other attributes $parameters=array(); $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; if (empty($reshook) && ! empty($extrafields->attribute_label)) { - print $object->showOptionals($extrafields,'edit'); + print $object->showOptionals($extrafields,'edit'); } print "\n"; diff --git a/htdocs/user/group/index.php b/htdocs/user/group/index.php index e8d37801998..41eb7d0fa77 100644 --- a/htdocs/user/group/index.php +++ b/htdocs/user/group/index.php @@ -81,7 +81,7 @@ if (empty($reshook)) include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; // Purge search criteria - if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") ||GETPOST("button_removefilter")) // All test are required to be compatible with all browsers + if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x','alpha') ||GETPOST('button_removefilter','alpha')) // All test are required to be compatible with all browsers { $search_label=""; $search_date_creation=""; diff --git a/htdocs/user/group/ldap.php b/htdocs/user/group/ldap.php index 6d987be85cb..c195136863e 100644 --- a/htdocs/user/group/ldap.php +++ b/htdocs/user/group/ldap.php @@ -32,6 +32,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/ldap.lib.php'; $langs->load("companies"); $langs->load("ldap"); $langs->load("users"); +$langs->load("admin"); // Users/Groups management only in master entity if transverse mode if (! empty($conf->multicompany->enabled) && $conf->entity > 1 && $conf->global->MULTICOMPANY_TRANSVERSE_MODE) @@ -110,22 +111,23 @@ print '
'; print ''; -// Name -print ''; -print ''; + print '\n"; } -print "\n"; // Note -print ''; -print ''; +print ''; +print ''; print "\n"; -$langs->load("admin"); - // LDAP DN print '\n"; diff --git a/htdocs/user/group/perms.php b/htdocs/user/group/perms.php index 94a9c9c1883..46477879b14 100644 --- a/htdocs/user/group/perms.php +++ b/htdocs/user/group/perms.php @@ -205,14 +205,17 @@ if ($object->id) print '
'.$langs->trans("Name").''.$object->name; -if (!$object->entity) +// Name (already in dol_banner, we keep it to have the GlobalGroup picto, but we should move it in dol_banner) +if (! empty($conf->mutlicompany->enabled)) { - print img_picto($langs->trans("GlobalGroup"),'redstar'); + print '
'.$langs->trans("Name").''.$object->name; + if (!$object->entity) + { + print img_picto($langs->trans("GlobalGroup"),'redstar'); + } + print "
'.$langs->trans("Note").''.nl2br($object->note).' 
'.$langs->trans("Description").''.dol_htmlentitiesbr($object->note).'
LDAP '.$langs->trans("LDAPGroupDn").''.$conf->global->LDAP_GROUP_DN."
'; - // Nom - print ''; - print ''; + print '\n"; } - print "\n"; // Note print ''; diff --git a/htdocs/user/hierarchy.php b/htdocs/user/hierarchy.php index 3e82e2b6357..59798d65e1a 100644 --- a/htdocs/user/hierarchy.php +++ b/htdocs/user/hierarchy.php @@ -47,7 +47,7 @@ $search_statut=GETPOST('search_statut','int'); if ($search_statut == '') $search_statut='1'; -if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter")) // Both test are required to be compatible with all browsers +if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter','alpha')) // Both test are required to be compatible with all browsers { $search_statut=""; } diff --git a/htdocs/user/index.php b/htdocs/user/index.php index 54fffcd3fb7..631a75d47c4 100644 --- a/htdocs/user/index.php +++ b/htdocs/user/index.php @@ -148,7 +148,7 @@ if (empty($reshook)) include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; // Purge search criteria - if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") ||GETPOST("button_removefilter")) // All tests are required to be compatible with all browsers + 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_user=""; $search_login=""; diff --git a/htdocs/websites/class/website.class.php b/htdocs/websites/class/website.class.php index a77079c94a6..1d67eb4ebb0 100644 --- a/htdocs/websites/class/website.class.php +++ b/htdocs/websites/class/website.class.php @@ -48,11 +48,6 @@ class Website extends CommonObject */ public $table_element = 'website'; - /** - * @var WebsitePage[] Lines of all pages - */ - public $lines = array(); - /** * @var int */ @@ -85,13 +80,7 @@ class Website extends CommonObject * @var string */ public $virtualhost; - - - public $records; - - /** - */ - + /** * Constructor @@ -144,7 +133,7 @@ class Website extends CommonObject $sql.= 'status,'; $sql.= 'fk_default_home,'; $sql.= 'virtualhost,'; - $sql.= 'fk_user_create'; + $sql.= 'fk_user_create,'; $sql.= 'date_creation'; $sql .= ') VALUES ('; $sql .= ' '.(! isset($this->entity)?'NULL':$this->entity).','; @@ -218,7 +207,7 @@ class Website extends CommonObject $sql .= " t.tms"; $sql .= ' FROM ' . MAIN_DB_PREFIX . $this->table_element . ' as t'; if (null !== $ref) { - $sql .= ' WHERE t.ref = ' . '\'' . $ref . '\''; + $sql .= " WHERE t.ref = '" . $this->db->escape($ref) . "'"; } else { $sql .= ' WHERE t.rowid = ' . $id; } @@ -230,7 +219,7 @@ class Website extends CommonObject $obj = $this->db->fetch_object($resql); $this->id = $obj->rowid; - + $this->entity = $obj->entity; $this->ref = $obj->ref; $this->description = $obj->description; @@ -297,7 +286,7 @@ class Website extends CommonObject if (count($sqlwhere) > 0) { $sql .= ' WHERE ' . implode(' '.$filtermode.' ', $sqlwhere); } - + if (!empty($sortfield)) { $sql .= $this->db->order($sortfield,$sortorder); } @@ -314,7 +303,7 @@ class Website extends CommonObject $line = new self($this->db); $line->id = $obj->rowid; - + $line->entity = $obj->entity; $line->ref = $obj->ref; $line->description = $obj->description; @@ -354,7 +343,7 @@ class Website extends CommonObject dol_syslog(__METHOD__, LOG_DEBUG); // Clean parameters - + if (isset($this->entity)) { $this->entity = trim($this->entity); } @@ -552,7 +541,7 @@ class Website extends CommonObject $result.= $link . $this->ref . $linkend; return $result; } - + /** * Retourne le libelle du status d'un user (actif, inactif) * @@ -607,8 +596,8 @@ class Website extends CommonObject if ($status == 0) return $langs->trans('Disabled').' '.img_picto($langs->trans('Disabled'),'statut5'); } } - - + + /** * Initialise object with example values * Id must be 0 if object instance is a specimen @@ -618,9 +607,9 @@ class Website extends CommonObject public function initAsSpecimen() { global $user; - + $this->id = 0; - + $this->entity = 1; $this->ref = 'myspecimenwebsite'; $this->description = 'A specimen website'; @@ -632,7 +621,7 @@ class Website extends CommonObject $this->date_creation = dol_now(); $this->tms = dol_now(); - + } } diff --git a/htdocs/websites/class/websitepage.class.php b/htdocs/websites/class/websitepage.class.php index 99fd4d64603..4f9dc58c615 100644 --- a/htdocs/websites/class/websitepage.class.php +++ b/htdocs/websites/class/websitepage.class.php @@ -129,7 +129,7 @@ class WebsitePage extends CommonObject $sql.= 'content,'; $sql.= 'status,'; $sql.= 'date_creation,'; - $sql.= 'date_modification'; + $sql.= 'tms'; $sql .= ') VALUES ('; $sql .= ' '.(! isset($this->fk_website)?'NULL':$this->fk_website).','; $sql .= ' '.(! isset($this->pageurl)?'NULL':"'".$this->db->escape($this->pageurl)."'").','; diff --git a/htdocs/websites/index.php b/htdocs/websites/index.php index a5c2ae4e046..9fbd6e6a4e0 100644 --- a/htdocs/websites/index.php +++ b/htdocs/websites/index.php @@ -98,6 +98,7 @@ if (GETPOST('editcss')) { $action='editcss'; } if (GETPOST('editmenu')) { $action='editmenu'; } if (GETPOST('setashome')) { $action='setashome'; } if (GETPOST('editmeta')) { $action='editmeta'; } +if (GETPOST('editsource')) { $action='editsource'; } if (GETPOST('editcontent')) { $action='editcontent'; } if (empty($action)) $action='preview'; @@ -129,6 +130,7 @@ if ($pageid > 0 && $action != 'add') global $dolibarr_main_data_root; $pathofwebsite=$dolibarr_main_data_root.'/websites/'.$website; +$filehtmlheader=$pathofwebsite.'/header.html'; $filecss=$pathofwebsite.'/styles.css.php'; $filetpl=$pathofwebsite.'/page'.$pageid.'.tpl.php'; $fileindex=$pathofwebsite.'/index.php'; @@ -240,25 +242,30 @@ if ($action == 'delete') // Update css if ($action == 'updatecss') { - //$db->begin(); - $res = $object->fetch(0, $website); - /* - $res = $object->update($user); - if ($res > 0) - { - $db->commit(); - $action=''; - } - else + // Html header file + $htmlheadercontent = ''."\n"; + $htmlheadercontent.= ''."\n"; + $htmlheadercontent.= ''."\n"; + $htmlheadercontent.= GETPOST('WEBSITE_HTML_HEADER'); + + dol_syslog("Save file css into ".$filehtmlheader); + + dol_mkdir($pathofwebsite); + $result = file_put_contents($filehtmlheader, $htmlheadercontent); + if (! empty($conf->global->MAIN_UMASK)) + @chmod($filehtmlheader, octdec($conf->global->MAIN_UMASK)); + + if (! $result) { $error++; - $db->rollback(); - }*/ + setEventMessages('Failed to write file '.$filehtmlheader, null, 'errors'); + } + // Css file $csscontent = ''."\n"; - $csscontent.= ''."\n"; + $csscontent.= ''."\n"; $csscontent.= '"."\n"; @@ -278,6 +285,7 @@ if ($action == 'updatecss') setEventMessages('Failed to write file '.$filecss, null, 'errors'); } + if (! $error) { setEventMessages($langs->trans("Saved"), null, 'mesgs'); @@ -310,7 +318,7 @@ if ($action == 'setashome') dol_delete_file($fileindex); $indexcontent = ''."\n"; $result = file_put_contents($fileindex, $indexcontent); @@ -365,12 +373,13 @@ if ($action == 'updatemeta') // Now generate the master.inc.php page - dol_syslog("We regenerate the master file"); + dol_syslog("We regenerate the master file (because we update meta)"); dol_delete_file($filemaster); $mastercontent = ''."\n"; $result = file_put_contents($filemaster, $mastercontent); if (! empty($conf->global->MAIN_UMASK)) @@ -406,6 +415,7 @@ if ($action == 'updatemeta') $tplcontent.= ''."\n"; $tplcontent.= ''."\n"; $tplcontent.= '
'."\n"; + $tplcontent.= ''.dol_escape_htmltag($objectpage->title).''."\n"; $tplcontent.= ''."\n"; $tplcontent.= ''."\n"; $tplcontent.= ''."\n"; @@ -414,8 +424,10 @@ if ($action == 'updatemeta') $tplcontent.= ''."\n"; $tplcontent.= ''."\n"; $tplcontent.= ''."\n"; + $tplcontent.= ''."\n"; $tplcontent.= ''."\n"; - $tplcontent.= ''.dol_escape_htmltag($objectpage->title).''."\n"; + $tplcontent.= ''."\n"; + $tplcontent.= 'ref.'/header.html"); ?>'."\n"; $tplcontent.= '
'."\n"; $tplcontent.= ''."\n"; @@ -458,7 +470,8 @@ if ($action == 'updatecontent' || GETPOST('refreshsite') || GETPOST('refreshpage if (! is_link(dol_osencode($pathtomediasinwebsite))) { dol_syslog("Create symlink for ".$pathtomedias." into name ".$pathtomediasinwebsite); - symlink($pathtomedias, $pathtomediasinwebsite); + dol_mkdir(dirname($pathtomediasinwebsite)); // To be sure dir for website exists + $result = symlink($pathtomedias, $pathtomediasinwebsite); } /*if (GETPOST('savevirtualhost') && $object->virtualhost != GETPOST('previewsite')) @@ -554,12 +567,15 @@ if ($action == 'updatecontent' || GETPOST('refreshsite') || GETPOST('refreshpage $tplcontent =''; $tplcontent.= "\n"; $tplcontent.= ''."\n"; $tplcontent.= '
'."\n"; + $tplcontent.= ''.dol_escape_htmltag($objectpage->title).''."\n"; $tplcontent.= ''."\n"; $tplcontent.= ''."\n"; $tplcontent.= ''."\n"; @@ -567,8 +583,10 @@ if ($action == 'updatecontent' || GETPOST('refreshsite') || GETPOST('refreshpage $tplcontent.= ''."\n"; $tplcontent.= ''."\n"; $tplcontent.= ''."\n"; - $tplcontent.= ''."\n"; - $tplcontent.= ''.dol_escape_htmltag($objectpage->title).''."\n"; + $tplcontent.= ''."\n"; + $tplcontent.= ''."\n"; + $tplcontent.= ''."\n"; + $tplcontent.= 'ref.'/header.html"); ?>'."\n"; $tplcontent.= '
'."\n"; $tplcontent.= ''."\n"; @@ -648,6 +666,10 @@ if ($action == 'editmeta') { print ''; } +if ($action == 'editsource') +{ + print ''; +} if ($action == 'editcontent') { print ''; @@ -660,7 +682,7 @@ if ($action == 'edit') // Add a margin under toolbar ? $style=''; -if ($action != 'preview' && $action != 'editcontent') $style=' margin-bottom: 5px;'; +if ($action != 'preview' && $action != 'editcontent' && $action != 'editsource') $style=' margin-bottom: 5px;'; //var_dump($objectpage);exit; print '
'; @@ -732,12 +754,9 @@ if (count($object->records) > 0) $urlext=$virtualurl; $urlint=$urlwithroot.'/public/websites/index.php?website='.$website; - //if (! empty($object->virtualhost)) - //{ - print 'transnoentitiesnoconv("Site"), $langs->transnoentitiesnoconv("Site"), $dataroot, $urlext)).'">'; - print $form->textwithpicto('', $langs->trans("PreviewSiteServedByWebServer", $langs->transnoentitiesnoconv("Site"), $langs->transnoentitiesnoconv("Site"), $dataroot, $urlext?$urlext:$langs->trans("VirtualHostUrlNotDefined")), 1, 'preview_ext'); - print ''; - //} + print 'transnoentitiesnoconv("Site"), $langs->transnoentitiesnoconv("Site"), $dataroot, $urlext)).'">'; + print $form->textwithpicto('', $langs->trans("PreviewSiteServedByWebServer", $langs->transnoentitiesnoconv("Site"), $langs->transnoentitiesnoconv("Site"), $dataroot, $urlext?$urlext:$langs->trans("VirtualHostUrlNotDefined")), 1, 'preview_ext'); + print ''; print 'transnoentitiesnoconv("Site"), $langs->transnoentitiesnoconv("Site"), $urlint)).'">'; print $form->textwithpicto('', $langs->trans("PreviewSiteServedByDolibarr", $langs->transnoentitiesnoconv("Site"), $langs->transnoentitiesnoconv("Site"), $urlint, $dataroot), 1, 'preview'); @@ -808,7 +827,6 @@ if (count($object->records) > 0) } print ''; - //print $form->selectarray('page', $array); if ($action == 'preview') { @@ -822,6 +840,7 @@ if (count($object->records) > 0) if ($object->fk_default_home > 0 && $pageid == $object->fk_default_home) print ''; else print ''; print ''; + print ''; print ''; //print ''.dol_escape_htmltag($langs->trans("EditPageMeta")).''; //print ''.dol_escape_htmltag($langs->trans("EditPageContent")).''; @@ -829,8 +848,6 @@ if (count($object->records) > 0) } } - print '
'; - print '
'; print '
'; print '
'; @@ -845,7 +862,6 @@ if (count($object->records) > 0) print '
'; print ''; - //print ''; $htmltext=$langs->trans("PageNameAliasHelp", $langs->transnoentitiesnoconv("EditPageMeta")); print $form->textwithpicto('', $htmltext, 1, 'help', '', 0, 2, 'helppagealias'); print '
'; @@ -853,7 +869,7 @@ if (count($object->records) > 0) if (! empty($object->virtualhost)) { $urlext=$virtualurl.'/'.$pagealias.'.php'; - print 'transnoentitiesnoconv("Page"), $langs->transnoentitiesnoconv("Page"), $dataroot, $urlext)).'">'; + print 'transnoentitiesnoconv("Page"), $langs->transnoentitiesnoconv("Page"), $dataroot, $urlext)).'">'; print $form->textwithpicto('', $langs->trans("PreviewSiteServedByWebServer", $langs->transnoentitiesnoconv("Page"), $langs->transnoentitiesnoconv("Page"), $dataroot, $urlext?$urlext:$langs->trans("VirtualHostUrlNotDefined")), 1, 'preview_ext'); print ''; } @@ -880,6 +896,16 @@ if (count($object->records) > 0) print '
'; + print '
'; + if (GETPOST('editsource', 'alpha') || GETPOST('editcontent', 'alpha')) + { + $htmltext=$langs->transnoentitiesnoconv("YouCanEditHtmlSource"); + print $form->textwithpicto($langs->trans("SyntaxHelp"), $htmltext, 1, 'help', 'inline-block', 0, 2, 'tooltipsubstitution'); + } + print '
'; + + + if ($action == 'preview') { // Adding jquery code to change on the fly url of preview ext @@ -939,6 +965,11 @@ if ($action == 'editcss') print '
'; + $htmlheader = @file_get_contents($filehtmlheader); + // Clean the php css file to remove php code and get only html part + $htmlheader = preg_replace('//s', '', $htmlheader); + + $csscontent = @file_get_contents($filecss); // Clean the php css file to remove php code and get only css part $csscontent = preg_replace('//s', '', $csscontent); @@ -957,11 +988,19 @@ if ($action == 'editcss') print ''; + print ''; + /*print '
'.$langs->trans("Name").''.$object->name.''; - if (! $object->entity) + // Name (already in dol_banner, we keep it to have the GlobalGroup picto, but we should move it in dol_banner) + if (! empty($conf->mutlicompany->enabled)) { - print img_picto($langs->trans("GlobalGroup"),'redstar'); + print '
'.$langs->trans("Name").''.$object->name.''; + if (! $object->entity) + { + print img_picto($langs->trans("GlobalGroup"),'redstar'); + } + print "
'.$langs->trans("Description").'
'; print $langs->trans('WEBSITE_CSS_INLINE'); print ''; - print ''; print '
'; + print $langs->trans('WEBSITE_HTML_HEADER'); + print ''; + print ''; + print '
'; print $langs->trans('WEBSITE_CSS_URL'); print ''; @@ -1050,6 +1089,25 @@ if ($action == 'editmenu') print '
'.$langs->trans("FeatureNotYetAvailable").''; } +if ($action == 'editsource') +{ + /* + * Editing global variables not related to a specific theme + */ + + $csscontent = @file_get_contents($filecss); + + $contentforedit = ''; + /*$contentforedit.=''."\n";*/ + $contentforedit .= $objectpage->content; + + require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; + $doleditor=new DolEditor('PAGE_CONTENT',$contentforedit,'',500,'Full','',true,true,true,ROWS_5,'90%'); + $doleditor->Create(0, '', false); +} + if ($action == 'editcontent') { /* @@ -1079,7 +1137,7 @@ if ($action == 'preview') { $objectpage->fetch($pageid); - $out = "\n".''."\n"; + $out = ''."\n"; $out.='
'."\n"; @@ -1089,7 +1147,10 @@ if ($action == 'preview') $out.=$csscontent; $out.=''."\n"; - $out.=$objectpage->content."\n"; + // Replace php code + $content = preg_replace('/<\?php.*\?>/ims', '...php...', $objectpage->content); + + $out.=$content."\n"; $out.='
'; diff --git a/scripts/modulebuilder/builddoc.php b/scripts/modulebuilder/builddoc.php new file mode 100755 index 00000000000..2ac8d97ac32 --- /dev/null +++ b/scripts/modulebuilder/builddoc.php @@ -0,0 +1,67 @@ +#!/usr/bin/env php + + * + * 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 scripts/modulebuilder/builddoc.php + * \ingroup modulebuilder + * \brief Script to build a documentation from input files (.asciidoc or .md files). Use asciidoctor tool. + * + * If file is a MD file, convert image links into asciidoc format. + * ![Screenshot patient card](img/dolimed_screenshot_patientcard.png?raw=true "Patient card") + * image:img/dolimed_screenshot_patientcard.png[Screenshot patient card] + */ + + +$sapi_type = php_sapi_name(); +$script_file = basename(__FILE__); +$path=dirname(__FILE__).'/'; + +// Test if batch mode +if (substr($sapi_type, 0, 3) == 'cgi') { + echo "Error: You are using PHP for CGI. To execute ".$script_file." from command line, you must use PHP for CLI mode.\n"; + exit(-1); +} + +if (! isset($argv[1]) || ! $argv[1]) { + print "Usage: ".$script_file." inputfile1\n"; + exit(-1); +} +$inputfile1=$argv[1]; + +require_once ($path."../../htdocs/master.inc.php"); + + +// Global variables +$version=DOL_VERSION; +$error=0; + + + +/* + * Main + */ + +@set_time_limit(0); +print "***** ".$script_file." (".$version.") pid=".dol_getmypid()." *****\n"; +print $inputfile1."
"; + + + + diff --git a/scripts/product/migrate_picture_path.php b/scripts/product/migrate_picture_path.php index f8624ebc040..98a5c4d51bc 100755 --- a/scripts/product/migrate_picture_path.php +++ b/scripts/product/migrate_picture_path.php @@ -104,7 +104,7 @@ function migrate_product_photospath($product) global $conf; $dir = $conf->product->multidir_output[$product->entity]; - $origin = $dir .'/'. get_exdir($product->id,2) . $product->id ."/photos"; + $origin = $dir .'/'. get_exdir($product->id,2,0,0,$product,'product') . $product->id ."/photos"; $destin = $dir.'/'.dol_sanitizeFileName($product->ref); $error = 0; diff --git a/test/phpunit/CodingPhpTest.php b/test/phpunit/CodingPhpTest.php index 5df31da812c..3460bb7f711 100644 --- a/test/phpunit/CodingPhpTest.php +++ b/test/phpunit/CodingPhpTest.php @@ -155,6 +155,25 @@ class CodingPhpTest extends PHPUnit_Framework_TestCase print 'Check php file '.$file['fullname']."\n"; $filecontent=file_get_contents($file['fullname']); + + $ok=true; + $matches=array(); + // Check string ='".$this->xxx with xxx that is not 'escape'. It means we forget a db->escape when forging sql request. + preg_match_all('/(..)\s*\.\s*\$this->db->idate\(/', $filecontent, $matches, PREG_SET_ORDER); + foreach($matches as $key => $val) + { + if ($val[1] != '\'"' && $val[1] != '\'\'') + { + $ok=false; + break; + } + //if ($reg[0] != 'db') $ok=false; + } + //print __METHOD__." Result for checking we don't have non escaped string in sql requests for file ".$file."\n"; + $this->assertTrue($ok, 'Found a $this->db->idate to forge a sql request without quotes around this date field '.$file['fullname'].' :: '.$val[0]); + //exit; + + $ok=true; $matches=array(); // Check string ='".$this->xxx with xxx that is not 'escape'. It means we forget a db->escape when forging sql request. @@ -172,6 +191,7 @@ class CodingPhpTest extends PHPUnit_Framework_TestCase $this->assertTrue($ok, 'Found non escaped string in building of a sql request '.$file['fullname'].' ('.$val[0].'). Bad.'); //exit; + // Test that output of $_SERVER\[\'QUERY_STRING\'\] is escaped. $ok=true; $matches=array(); diff --git a/test/phpunit/FilesLibTest.php b/test/phpunit/FilesLibTest.php index c0a4ce845a9..feac8b212ed 100644 --- a/test/phpunit/FilesLibTest.php +++ b/test/phpunit/FilesLibTest.php @@ -286,11 +286,27 @@ class FilesLibTest extends PHPUnit_Framework_TestCase $db=$this->savdb; $dirout=$conf->admin->dir_temp.'/test'; + $dirout2=$conf->admin->dir_temp.'/test2'; $count=0; - $result=dol_delete_dir_recursive($dirout,$count,1); // If it has no permission to delete, it will fails as if dir does not exists, so we can't test it + $result=dol_delete_dir_recursive($dirout,$count); // If it has no permission to delete, it will fails as if dir does not exists, so we can't test it print __METHOD__." result=".$result."\n"; $this->assertGreaterThanOrEqual(0,$result); + + $count=0; + $countdeleted=0; + $result=dol_delete_dir_recursive($dirout,$count,1,0,$countdeleted); // If it has no permission to delete, it will fails as if dir does not exists, so we can't test it + print __METHOD__." result=".$result."\n"; + $this->assertGreaterThanOrEqual(0,$result); + $this->assertGreaterThanOrEqual(0,$countdeleted); + + dol_mkdir($dirout2); + $count=0; + $countdeleted=0; + $result=dol_delete_dir_recursive($dirout2,$count,1,0,$countdeleted); // If it has no permission to delete, it will fails as if dir does not exists, so we can't test it + print __METHOD__." result=".$result."\n"; + $this->assertGreaterThanOrEqual(1,$result); + $this->assertGreaterThanOrEqual(1,$countdeleted); } @@ -399,7 +415,7 @@ class FilesLibTest extends PHPUnit_Framework_TestCase print __METHOD__." result=".join(',',$result)."\n"; $this->assertEquals(0,count($result)); } - + /** * testDolDirList * @@ -411,7 +427,7 @@ class FilesLibTest extends PHPUnit_Framework_TestCase public function testDolDirList() { global $conf,$user,$langs,$db; - + // Scan dir to guaruante we on't have library jquery twice (we accept exception of duplicte into ckeditor because all dir is removed for debian package, so there is no duplicate). $founddirs=dol_dir_list(DOL_DOCUMENT_ROOT.'/includes/', 'files', 1, '^jquery\.js', array('ckeditor')); print __METHOD__." count(founddirs)=".count($founddirs)."\n"; @@ -431,60 +447,60 @@ class FilesLibTest extends PHPUnit_Framework_TestCase $user=$this->savuser; $langs=$this->savlangs; $db=$this->savdb; - - + + //$dummyuser=new User($db); //$result=restrictedArea($dummyuser,'societe'); // We save user properties $savpermlire = $user->rights->facture->lire; $savpermcreer = $user->rights->facture->creer; - - + + // Check access to SPECIMEN $user->rights->facture->lire = 0; $user->rights->facture->creer = 0; $filename='SPECIMEN.pdf'; // Filename relative to module part $result=dol_check_secure_access_document('facture', $filename, 0, '', '', 'read'); $this->assertEquals(1,$result['accessallowed']); - - + + // Check read permission $user->rights->facture->lire = 1; $user->rights->facture->creer = 1; $filename='FA010101/FA010101.pdf'; // Filename relative to module part $result=dol_check_secure_access_document('facture', $filename, 0, '', '', 'read'); $this->assertEquals(1,$result['accessallowed']); - + $user->rights->facture->lire = 0; $user->rights->facture->creer = 0; $filename='FA010101/FA010101.pdf'; // Filename relative to module part $result=dol_check_secure_access_document('facture', $filename, 0, '', '', 'read'); $this->assertEquals(0,$result['accessallowed']); - + // Check write permission $user->rights->facture->lire = 0; $user->rights->facture->creer = 0; $filename='FA010101/FA010101.pdf'; // Filename relative to module part $result=dol_check_secure_access_document('facture', $filename, 0, '', '', 'write'); $this->assertEquals(0,$result['accessallowed']); - + $user->rights->facture->lire = 1; $user->rights->facture->creer = 1; $filename='FA010101/FA010101.pdf'; // Filename relative to module part $result=dol_check_secure_access_document('facture', $filename, 0, '', '', 'write'); $this->assertEquals(1,$result['accessallowed']); - + $user->rights->facture->lire = 1; $user->rights->facture->creer = 0; $filename='FA010101/FA010101.pdf'; // Filename relative to module part $result=dol_check_secure_access_document('facture', $filename, 0, '', '', 'write'); $this->assertEquals(0,$result['accessallowed']); - - + + // We restore user properties $user->rights->facture->lire = $savpermlire; $user->rights->facture->creer = $savpermcreer; - } + } } diff --git a/test/phpunit/FunctionsLibTest.php b/test/phpunit/FunctionsLibTest.php index 873a17758c8..0821e6c7a6c 100644 --- a/test/phpunit/FunctionsLibTest.php +++ b/test/phpunit/FunctionsLibTest.php @@ -122,10 +122,75 @@ class FunctionsLibTest extends PHPUnit_Framework_TestCase + /** + * testDolGetFirstLineOfText + * + * @return void + */ + public function testDolGetFirstLineOfText() + { + // Nb of line is same than entry text + + $input="aaaa"; + $result=dolGetFirstLineOfText($input); + print __METHOD__." result=".$result."\n"; + $this->assertEquals("aaaa", $result); + + $input="aaaa\nbbbbbbbbbbbb\n"; + $result=dolGetFirstLineOfText($input, 2); + print __METHOD__." result=".$result."\n"; + $this->assertEquals("aaaa\nbbbbbbbbbbbb", $result); + + $input="aaaa
bbbbbbbbbbbb
"; + $result=dolGetFirstLineOfText($input, 2); + print __METHOD__." result=".$result."\n"; + $this->assertEquals("aaaa
\nbbbbbbbbbbbb", $result); + + // Nb of line is lower + + $input="aaaa\nbbbbbbbbbbbb\ncccccc\n"; + $result=dolGetFirstLineOfText($input); + print __METHOD__." result=".$result."\n"; + $this->assertEquals("aaaa...", $result); + + $input="aaaa
bbbbbbbbbbbb
cccccc
"; + $result=dolGetFirstLineOfText($input); + print __METHOD__." result=".$result."\n"; + $this->assertEquals("aaaa...", $result); + + $input="aaaa\nbbbbbbbbbbbb\ncccccc\n"; + $result=dolGetFirstLineOfText($input, 2); + print __METHOD__." result=".$result."\n"; + $this->assertEquals("aaaa\nbbbbbbbbbbbb...", $result); + + $input="aaaa
bbbbbbbbbbbb
cccccc
"; + $result=dolGetFirstLineOfText($input, 2); + print __METHOD__." result=".$result."\n"; + $this->assertEquals("aaaa
\nbbbbbbbbbbbb...", $result); + + // Nb of line is higher + + $input="aaaa
bbbbbbbbbbbb
cccccc"; + $result=dolGetFirstLineOfText($input, 100); + print __METHOD__." result=".$result."\n"; + $this->assertEquals("aaaa
\nbbbbbbbbbbbb
\ncccccc", $result, 'dolGetFirstLineOfText with nb 100 a'); + + $input="aaaa
bbbbbbbbbbbb
cccccc
"; + $result=dolGetFirstLineOfText($input, 100); + print __METHOD__." result=".$result."\n"; + $this->assertEquals("aaaa
\nbbbbbbbbbbbb
\ncccccc", $result, 'dolGetFirstLineOfText with nb 100 b'); + + $input="aaaa
bbbbbbbbbbbb
cccccc
\n"; + $result=dolGetFirstLineOfText($input, 100); + print __METHOD__." result=".$result."\n"; + $this->assertEquals("aaaa
\nbbbbbbbbbbbb
\ncccccc", $result, 'dolGetFirstLineOfText with nb 100 c'); + } + + /** * testDolBuildPath * - * @return boolean + * @return void */ public function testDolBuildPath() { diff --git a/test/phpunit/RestAPIDocumentTest.php b/test/phpunit/RestAPIDocumentTest.php index b60a7e9e833..7eb485ffbab 100644 --- a/test/phpunit/RestAPIDocumentTest.php +++ b/test/phpunit/RestAPIDocumentTest.php @@ -144,11 +144,11 @@ class RestAPIDocumentTest extends PHPUnit_Framework_TestCase echo __METHOD__.' Request POST url='.$url."\n"; - + // Send to non existant directory - + dol_delete_dir_recursive(DOL_DATA_ROOT.'/medias/tmpphpunit'); - + //$data = '{ "filename": "mynewfile.txt", "modulepart": "medias", "ref": "", "subdir": "mysubdir1/mysubdir2", "filecontent": "content text", "fileencoding": "" }'; $data = array( 'filename'=>"mynewfile.txt", @@ -158,7 +158,7 @@ class RestAPIDocumentTest extends PHPUnit_Framework_TestCase 'filecontent'=>"content text", 'fileencoding'=>"" ); - + $result = getURLContent($url, 'POST', $data, 1); echo __METHOD__.' Result for sending document: '.var_export($result, true)."\n"; echo __METHOD__.' curl_error_no: '.$result['curl_error_no']."\n"; @@ -166,11 +166,11 @@ class RestAPIDocumentTest extends PHPUnit_Framework_TestCase $this->assertNotNull($object, 'Parsing of json result must no be null'); $this->assertEquals('401', $object['error']['code']); - + // Send to existant directory - + dol_mkdir(DOL_DATA_ROOT.'/medias/tmpphpunit/tmpphpunit2'); - + $data = array( 'filename'=>"mynewfile.txt", 'modulepart'=>"medias", @@ -187,5 +187,7 @@ class RestAPIDocumentTest extends PHPUnit_Framework_TestCase $this->assertNotNull($object2, 'Parsing of json result must no be null'); $this->assertEquals($result2['curl_error_no'], ''); $this->assertEquals($result2['content'], 'true'); + + dol_delete_dir_recursive(DOL_DATA_ROOT.'/medias/tmpphpunit'); } }