瀏覽代碼

Merge branch 'develop' into new_branch_19_04_2018

Laurent Destailleur 7 年之前
父節點
當前提交
721ff3e1a4
共有 50 個文件被更改,包括 371 次插入327 次删除
  1. 1 6
      htdocs/accountancy/admin/account.php
  2. 10 10
      htdocs/accountancy/admin/accountmodel.php
  3. 1 3
      htdocs/accountancy/admin/card.php
  4. 1 2
      htdocs/accountancy/admin/categories.php
  5. 2 2
      htdocs/accountancy/admin/categories_list.php
  6. 1 6
      htdocs/accountancy/admin/defaultaccounts.php
  7. 1 5
      htdocs/accountancy/admin/export.php
  8. 1 2
      htdocs/accountancy/admin/fiscalyear.php
  9. 1 2
      htdocs/accountancy/admin/fiscalyear_card.php
  10. 1 2
      htdocs/accountancy/admin/fiscalyear_info.php
  11. 1 2
      htdocs/accountancy/admin/importaccounts.php
  12. 1 4
      htdocs/accountancy/admin/index.php
  13. 2 4
      htdocs/accountancy/admin/journals_list.php
  14. 1 2
      htdocs/accountancy/admin/productaccount.php
  15. 1 1
      htdocs/accountancy/bookkeeping/balance.php
  16. 1 2
      htdocs/accountancy/bookkeeping/balancebymonth.php
  17. 1 2
      htdocs/accountancy/bookkeeping/list.php
  18. 1 2
      htdocs/accountancy/bookkeeping/listbyaccount.php
  19. 2 1
      htdocs/accountancy/bookkeeping/thirdparty_lettrage.php
  20. 2 1
      htdocs/accountancy/bookkeeping/thirdparty_lettrage_supplier.php
  21. 1 1
      htdocs/accountancy/class/accountingaccount.class.php
  22. 1 1
      htdocs/accountancy/class/accountingjournal.class.php
  23. 1 1
      htdocs/accountancy/class/bookkeeping.class.php
  24. 1 4
      htdocs/accountancy/customer/card.php
  25. 39 38
      htdocs/accountancy/customer/lines.php
  26. 38 17
      htdocs/accountancy/customer/list.php
  27. 1 5
      htdocs/accountancy/expensereport/card.php
  28. 1 9
      htdocs/accountancy/expensereport/lines.php
  29. 1 2
      htdocs/accountancy/expensereport/list.php
  30. 1 15
      htdocs/accountancy/index.php
  31. 1 4
      htdocs/accountancy/supplier/card.php
  32. 34 27
      htdocs/accountancy/supplier/lines.php
  33. 39 18
      htdocs/accountancy/supplier/list.php
  34. 5 5
      htdocs/admin/defaultvalues.php
  35. 22 8
      htdocs/admin/mails_templates.php
  36. 3 3
      htdocs/admin/tools/dolibarr_export.php
  37. 1 4
      htdocs/contact/list.php
  38. 15 12
      htdocs/core/class/commonobject.class.php
  39. 2 2
      htdocs/core/class/extrafields.class.php
  40. 8 8
      htdocs/core/class/html.formticketsup.class.php
  41. 5 5
      htdocs/core/js/lib_foot.js.php
  42. 33 8
      htdocs/core/modules/societe/mod_codecompta_aquarium.php
  43. 1 1
      htdocs/core/tpl/extrafields_view.tpl.php
  44. 15 14
      htdocs/langs/en_US/admin.lang
  45. 3 6
      htdocs/public/ticketsup/create_ticket.php
  46. 32 24
      htdocs/public/ticketsup/list.php
  47. 17 12
      htdocs/public/ticketsup/view.php
  48. 7 4
      htdocs/ticketsup/card.php
  49. 2 2
      htdocs/ticketsup/class/ticketsup.class.php
  50. 8 6
      htdocs/ticketsup/list.php

+ 1 - 6
htdocs/accountancy/admin/account.php

@@ -28,12 +28,7 @@ require_once DOL_DOCUMENT_ROOT . '/core/lib/admin.lib.php';
 require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php';
 require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingaccount.class.php';
 
-// Langs
-$langs->load("compta");
-$langs->load("bills");
-$langs->load("admin");
-$langs->load("accountancy");
-$langs->load("salaries");
+$langs->loadLangs(array("compta","bills","admin","accountancy","salaries"));
 
 $mesg = '';
 $action = GETPOST('action','aZ09');

+ 10 - 10
htdocs/accountancy/admin/accountmodel.php

@@ -880,7 +880,7 @@ if ($id)
 								$valuetoshow=price($valuetoshow);
 							}
 							else if ($fieldlist[$field]=='libelle_facture') {
-								$langs->load("bills");
+								$langs->loadLangs(array("bills"));
 								$key=$langs->trans("PaymentCondition".strtoupper($obj->code));
 								$valuetoshow=($obj->code && $key != "PaymentCondition".strtoupper($obj->code)?$key:$obj->{$fieldlist[$field]});
 								$valuetoshow=nl2br($valuetoshow);
@@ -890,7 +890,7 @@ if ($id)
 								$valuetoshow=($obj->code && $key != "Country".strtoupper($obj->code)?$key:$obj->{$fieldlist[$field]});
 							}
 							else if ($fieldlist[$field]=='label' && $tabname[$id]==MAIN_DB_PREFIX.'c_availability') {
-								$langs->load("propal");
+								$langs->loadLangs(array("propal"));
 								$key=$langs->trans("AvailabilityType".strtoupper($obj->code));
 								$valuetoshow=($obj->code && $key != "AvailabilityType".strtoupper($obj->code)?$key:$obj->{$fieldlist[$field]});
 							}
@@ -915,17 +915,17 @@ if ($id)
 								$valuetoshow=($obj->code && $key != "Civility".strtoupper($obj->code)?$key:$obj->{$fieldlist[$field]});
 							}
 							else if ($fieldlist[$field]=='libelle' && $tabname[$id]==MAIN_DB_PREFIX.'c_type_contact') {
-								$langs->load('agenda');
+								$langs->loadLangs(array("agenda"));
 								$key=$langs->trans("TypeContact_".$obj->element."_".$obj->source."_".strtoupper($obj->code));
 								$valuetoshow=($obj->code && $key != "TypeContact_".$obj->element."_".$obj->source."_".strtoupper($obj->code)?$key:$obj->{$fieldlist[$field]});
 							}
 							else if ($fieldlist[$field]=='libelle' && $tabname[$id]==MAIN_DB_PREFIX.'c_payment_term') {
-								$langs->load("bills");
+								$langs->loadLangs(array("bills"));
 								$key=$langs->trans("PaymentConditionShort".strtoupper($obj->code));
 								$valuetoshow=($obj->code && $key != "PaymentConditionShort".strtoupper($obj->code)?$key:$obj->{$fieldlist[$field]});
 							}
 							else if ($fieldlist[$field]=='libelle' && $tabname[$id]==MAIN_DB_PREFIX.'c_paiement') {
-								$langs->load("bills");
+								$langs->loadLangs(array("bills"));
 								$key=$langs->trans("PaymentType".strtoupper($obj->code));
 								$valuetoshow=($obj->code && $key != "PaymentType".strtoupper($obj->code)?$key:$obj->{$fieldlist[$field]});
 							}
@@ -934,12 +934,12 @@ if ($id)
 								$valuetoshow=($obj->code && $key != "DemandReasonType".strtoupper($obj->code)?$key:$obj->{$fieldlist[$field]});
 							}
 							else if ($fieldlist[$field]=='libelle' && $tabname[$id]==MAIN_DB_PREFIX.'c_input_method') {
-								$langs->load("orders");
+								$langs->loadLangs(array("orders"));
 								$key=$langs->trans($obj->code);
 								$valuetoshow=($obj->code && $key != $obj->code)?$key:$obj->{$fieldlist[$field]};
 							}
 							else if ($fieldlist[$field]=='libelle' && $tabname[$id]==MAIN_DB_PREFIX.'c_shipment_mode') {
-								$langs->load("sendings");
+								$langs->loadLangs(array("sendings"));
 								$key=$langs->trans("SendingMethod".strtoupper($obj->code));
 								$valuetoshow=($obj->code && $key != "SendingMethod".strtoupper($obj->code)?$key:$obj->{$fieldlist[$field]});
 							}
@@ -950,7 +950,7 @@ if ($id)
 							}
 							else if ($fieldlist[$field] == 'label' && $tabname[$id] == MAIN_DB_PREFIX.'c_type_fees')
 							{
-								$langs->load('trips');
+								$langs->loadLangs(array("trips"));
 								$key = $langs->trans(strtoupper($obj->code));
 								$valuetoshow = ($obj->code && $key != strtoupper($obj->code) ? $key : $obj->{$fieldlist[$field]});
 							}
@@ -961,11 +961,11 @@ if ($id)
 								$valuetoshow = $langs->getCurrencySymbol($obj->code,1);
 							}
 							else if ($fieldlist[$field]=='label' && $tabname[$_GET["id"]]==MAIN_DB_PREFIX.'c_units') {
-								$langs->load("products");
+								$langs->loadLangs(array("products"));
 								$valuetoshow=$langs->trans($obj->{$fieldlist[$field]});
 							}
 							else if ($fieldlist[$field]=='short_label' && $tabname[$_GET["id"]]==MAIN_DB_PREFIX.'c_units') {
-								$langs->load("products");
+								$langs->loadLangs(array("products"));
 								$valuetoshow = $langs->trans($obj->{$fieldlist[$field]});
 							}
 							else if (($fieldlist[$field] == 'unit') && ($tabname[$id] == MAIN_DB_PREFIX.'c_paper_format'))

+ 1 - 3
htdocs/accountancy/admin/card.php

@@ -31,9 +31,7 @@ require_once DOL_DOCUMENT_ROOT . '/core/class/html.formaccounting.class.php';
 
 $error = 0;
 
-// Langs
-$langs->load("bills");
-$langs->load("accountancy");
+$langs->loadLangs(array("bills","accountancy"));
 
 $mesg = '';
 $action = GETPOST('action','aZ09');

+ 1 - 2
htdocs/accountancy/admin/categories.php

@@ -29,8 +29,7 @@ require_once DOL_DOCUMENT_ROOT . '/core/class/html.formaccounting.class.php';
 
 $error = 0;
 
-$langs->load("bills");
-$langs->load("accountancy");
+$langs->loadLangs(array("bills","accountancy"));
 
 $mesg = '';
 $id = GETPOST('id', 'int');

+ 2 - 2
htdocs/accountancy/admin/categories_list.php

@@ -178,7 +178,7 @@ if (GETPOST('actionadd') || GETPOST('actionmodify'))
     }
     if (! is_numeric(GETPOST('position','alpha')))
     {
-    	$langs->load("errors");
+    	$langs->loadLangs(array("errors"));
    		$ok=0;
    		setEventMessages($langs->transnoentities('ErrorFieldMustBeANumeric', $langs->transnoentities("Position")), null, 'errors');
     }
@@ -735,7 +735,7 @@ if ($id)
                                 $valuetoshow=($obj->code && $key != "Country".strtoupper($obj->code)?$key:$obj->{$fieldlist[$field]});
                             }
                             else if ($fieldlist[$field]=='label' && $tabname[$id]==MAIN_DB_PREFIX.'c_availability') {
-                                $langs->load("propal");
+                                $langs->loadLangs(array("propal"));
                                 $key=$langs->trans("AvailabilityType".strtoupper($obj->code));
                                 $valuetoshow=($obj->code && $key != "AvailabilityType".strtoupper($obj->code)?$key:$obj->{$fieldlist[$field]});
                             }

+ 1 - 6
htdocs/accountancy/admin/defaultaccounts.php

@@ -34,12 +34,7 @@ require_once DOL_DOCUMENT_ROOT . '/core/lib/admin.lib.php';
 require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php';
 require_once DOL_DOCUMENT_ROOT . '/core/class/html.formaccounting.class.php';
 
-$langs->load("compta");
-$langs->load("bills");
-$langs->load("admin");
-$langs->load("accountancy");
-$langs->load("salaries");
-$langs->load("loan");
+$langs->loadLangs(array("compta","bills","admin","accountancy","salaries","loan"));
 
 // Security check
 if (empty($user->rights->accounting->chartofaccount))

+ 1 - 5
htdocs/accountancy/admin/export.php

@@ -28,15 +28,11 @@
  */
 require '../../main.inc.php';
 
-// Class
 require_once DOL_DOCUMENT_ROOT . '/core/lib/admin.lib.php';
 require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php';
 require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountancyexport.class.php';
 
-$langs->load("compta");
-$langs->load("bills");
-$langs->load("admin");
-$langs->load("accountancy");
+$langs->loadLangs(array("compta","bills","admin","accountancy"));
 
 // Security access
 if (empty($user->rights->accounting->chartofaccount))

+ 1 - 2
htdocs/accountancy/admin/fiscalyear.php

@@ -39,8 +39,7 @@ $pagenext = $page + 1;
 if (! $sortfield) $sortfield="f.rowid"; // Set here default search field
 if (! $sortorder) $sortorder="ASC";
 
-$langs->load("admin");
-$langs->load("compta");
+$langs->loadLangs(array("admin","compta"));
 
 // Security check
 if ($user->societe_id > 0)

+ 1 - 2
htdocs/accountancy/admin/fiscalyear_card.php

@@ -26,8 +26,7 @@ require '../../main.inc.php';
 require_once DOL_DOCUMENT_ROOT . '/core/lib/fiscalyear.lib.php';
 require_once DOL_DOCUMENT_ROOT . '/core/class/fiscalyear.class.php';
 
-$langs->load("admin");
-$langs->load("compta");
+$langs->loadLangs(array("admin","compta"));
 
 // Security check
 if ($user->societe_id > 0)

+ 1 - 2
htdocs/accountancy/admin/fiscalyear_info.php

@@ -26,8 +26,7 @@ require_once DOL_DOCUMENT_ROOT . '/core/lib/fiscalyear.lib.php';
 require_once DOL_DOCUMENT_ROOT . '/core/lib/functions2.lib.php';
 require_once DOL_DOCUMENT_ROOT . '/core/class/fiscalyear.class.php';
 
-$langs->load("admin");
-$langs->load("compta");
+$langs->loadLangs(array("admin","compta"));
 
 // Security check
 if ($user->societe_id > 0)

+ 1 - 2
htdocs/accountancy/admin/importaccounts.php

@@ -24,13 +24,12 @@
  */
 require '../../main.inc.php';
 
-// Class
 require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php';
 require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingaccount.class.php';
 require_once DOL_DOCUMENT_ROOT . '/core/class/html.formaccounting.class.php';
 
 // Load traductions files requiredby by page
-$langs->loadLangs(array("compta","bills","main","accountancy"));
+$langs->loadLangs(array("compta","bills","accountancy"));
 
 // Security check
 if (! $user->admin)

+ 1 - 4
htdocs/accountancy/admin/index.php

@@ -32,10 +32,7 @@ require '../../main.inc.php';
 require_once DOL_DOCUMENT_ROOT . '/core/lib/admin.lib.php';
 require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php';
 
-$langs->load("compta");
-$langs->load("bills");
-$langs->load("admin");
-$langs->load("accountancy");
+$langs->loadLangs(array("compta","bills","admin","accountancy"));
 
 // Security access
 if (empty($user->rights->accounting->chartofaccount))

+ 2 - 4
htdocs/accountancy/admin/journals_list.php

@@ -30,9 +30,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
 require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php';
 require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingjournal.class.php';
 
-$langs->load("admin");
-$langs->load("compta");
-$langs->load("accountancy");
+$langs->loadLangs(array("admin","compta","accountancy"));
 
 $action=GETPOST('action','alpha')?GETPOST('action','alpha'):'view';
 $confirm=GETPOST('confirm','alpha');
@@ -629,7 +627,7 @@ if ($id)
 								$valuetoshow=$langs->trans('All');
 							}
 							else if ($fieldlist[$field]=='nature' && $tabname[$id]==MAIN_DB_PREFIX.'accounting_journal') {
-								$langs->load("accountancy");
+								$langs->loadLangs(array("accountancy"));
 								$key=$langs->trans("AccountingJournalType".strtoupper($obj->nature));
 								$valuetoshow=($obj->nature && $key != "AccountingJournalType".strtoupper($obj->nature)?$key:$obj->{$fieldlist[$field]});
 							}

+ 1 - 2
htdocs/accountancy/admin/productaccount.php

@@ -26,7 +26,6 @@
  */
 require '../../main.inc.php';
 
-// Class
 require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php';
 require_once DOL_DOCUMENT_ROOT . '/core/lib/report.lib.php';
 require_once DOL_DOCUMENT_ROOT . '/core/lib/admin.lib.php';
@@ -36,7 +35,7 @@ require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingaccount.class.php
 require_once DOL_DOCUMENT_ROOT . '/product/class/product.class.php';
 
 // Load traductions files requiredby by page
-$langs->loadLangs(array("companies","compta","main","accountancy","products"));
+$langs->loadLangs(array("companies","compta","accountancy","products"));
 
 // Security check
 if (empty($conf->accounting->enabled)) {

+ 1 - 1
htdocs/accountancy/bookkeeping/balance.php

@@ -35,7 +35,7 @@ require_once DOL_DOCUMENT_ROOT . '/core/class/html.formaccounting.class.php';
 require_once DOL_DOCUMENT_ROOT . '/core/class/html.formother.class.php';
 
 // Langs
-$langs->load("accountancy");
+$langs->loadLangs(array("accountancy"));
 
 $page = GETPOST("page");
 $sortorder = GETPOST("sortorder");

+ 1 - 2
htdocs/accountancy/bookkeeping/balancebymonth.php

@@ -26,12 +26,11 @@
  */
 require '../../main.inc.php';
 
-// Class
 require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php';
 require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php';
 
 // Load traductions files requiredby by page
-$langs->loadLangs(array("bills","compta","main","accountancy","other"));
+$langs->loadLangs(array("bills","compta","accountancy","other"));
 
 // Filter
 $year = GETPOST("year",'int');

+ 1 - 2
htdocs/accountancy/bookkeeping/list.php

@@ -32,8 +32,7 @@ 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 . '/core/lib/date.lib.php';
 
-// Langs
-$langs->load("accountancy");
+$langs->loadLangs(array("accountancy"));
 
 $action = GETPOST('action', 'alpha');
 $search_mvt_num = GETPOST('search_mvt_num', 'int');

+ 1 - 2
htdocs/accountancy/bookkeeping/listbyaccount.php

@@ -33,8 +33,7 @@ require_once DOL_DOCUMENT_ROOT . '/core/class/html.formaccounting.class.php';
 require_once DOL_DOCUMENT_ROOT . '/core/class/html.formother.class.php';
 require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php';
 
-// Langs
-$langs->load("accountancy");
+$langs->loadLangs(array("accountancy"));
 
 $page = GETPOST("page");
 $sortorder = GETPOST("sortorder");

+ 2 - 1
htdocs/accountancy/bookkeeping/thirdparty_lettrage.php

@@ -33,6 +33,8 @@ require_once DOL_DOCUMENT_ROOT . '/accountancy/class/lettering.class.php';
 require_once DOL_DOCUMENT_ROOT . '/societe/class/societe.class.php';
 require_once DOL_DOCUMENT_ROOT . '/core/lib/company.lib.php';
 
+$langs->loadLangs(array("compta"));
+
 $action = GETPOST('action', 'aZ09');
 $massaction = GETPOST('massaction', 'alpha');
 $show_files = GETPOST('show_files', 'int');
@@ -141,7 +143,6 @@ if ($object->check_codeclient() != 0)
 print '</td>';
 print '</tr>';
 
-$langs->load('compta');
 print '<tr>';
 print '<td>';
 print $form->editfieldkey("CustomerAccountancyCode", 'customeraccountancycode', $object->code_compta, $object, $user->rights->societe->creer);

+ 2 - 1
htdocs/accountancy/bookkeeping/thirdparty_lettrage_supplier.php

@@ -35,6 +35,8 @@ require_once DOL_DOCUMENT_ROOT . '/accountancy/class/lettering.class.php';
 require_once DOL_DOCUMENT_ROOT . '/societe/class/societe.class.php';
 require_once DOL_DOCUMENT_ROOT . '/core/lib/company.lib.php';
 
+$langs->loadLangs(array("compta"));
+
 $action = GETPOST('action', 'aZ09');
 $massaction = GETPOST('massaction', 'alpha');
 $show_files = GETPOST('show_files', 'int');
@@ -157,7 +159,6 @@ if ($object->check_codefournisseur() != 0)
 print '</td>';
 print '</tr>';
 
-$langs->load('compta');
 print '<tr>';
 print '<td>';
 print $form->editfieldkey("SupplierAccountancyCode", 'supplieraccountancycode', $object->code_compta_fournisseur, $object, $user->rights->societe->creer);

+ 1 - 1
htdocs/accountancy/class/accountingaccount.class.php

@@ -566,7 +566,7 @@ class AccountingAccount extends CommonObject
 	function LibStatut($statut,$mode=0)
 	{
 		global $langs;
-		$langs->load('users');
+		$langs->loadLangs(array("users"));
 
 		if ($mode == 0)
 		{

+ 1 - 1
htdocs/accountancy/class/accountingjournal.class.php

@@ -256,7 +256,7 @@ class AccountingJournal extends CommonObject
 	{
 		global $langs;
 
-		$langs->load("accountancy");
+		$langs->loadLangs(array("accountancy"));
 
 		if ($mode == 0)
 		{

+ 1 - 1
htdocs/accountancy/class/bookkeeping.class.php

@@ -170,7 +170,7 @@ class BookKeeping extends CommonObject
 		// Check parameters
 		if (empty($this->numero_compte) || $this->numero_compte == '-1' || $this->numero_compte == 'NotDefined')
 		{
-			$langs->load("errors");
+			$langs->loadLangs(array("errors"));
 			if (in_array($this->doc_type, array('bank', 'expense_report')))
 			{
 				$this->errors[]=$langs->trans('ErrorFieldAccountNotDefinedForBankLine', $this->fk_docdet,  $this->doc_type);

+ 1 - 4
htdocs/accountancy/customer/card.php

@@ -24,13 +24,10 @@
  */
 require '../../main.inc.php';
 
-// Class
 require_once DOL_DOCUMENT_ROOT . '/compta/facture/class/facture.class.php';
 require_once DOL_DOCUMENT_ROOT . '/core/class/html.formaccounting.class.php';
 
-// Langs
-$langs->load("bills");
-$langs->load("accountancy");
+$langs->loadLangs(array("bills","accountancy"));
 
 $action = GETPOST('action', 'alpha');
 $cancel = GETPOST('cancel', 'alpha');

+ 39 - 38
htdocs/accountancy/customer/lines.php

@@ -27,7 +27,6 @@
  */
 require '../../main.inc.php';
 
-// Class
 require_once DOL_DOCUMENT_ROOT . '/core/class/html.formaccounting.class.php';
 require_once DOL_DOCUMENT_ROOT . '/compta/facture/class/facture.class.php';
 require_once DOL_DOCUMENT_ROOT . '/product/class/product.class.php';
@@ -35,12 +34,7 @@ require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php';
 require_once DOL_DOCUMENT_ROOT . '/core/class/html.formother.class.php';
 require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php';
 
-// Langs
-$langs->load("bills");
-$langs->load("compta");
-$langs->load("main");
-$langs->load("accountancy");
-$langs->load("productbatch");
+$langs->loadLangs(array("bills","compta","accountancy","productbatch"));
 
 $account_parent = GETPOST('account_parent');
 $changeaccount = GETPOST('changeaccount');
@@ -116,10 +110,10 @@ if (is_array($changeaccount) && count($changeaccount) > 0) {
 		setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Account")), null, 'errors');
 	}
 
-	$db->begin();
-
 	if (! $error)
 	{
+		$db->begin();
+
 		$sql1 = "UPDATE " . MAIN_DB_PREFIX . "facturedet as l";
 		$sql1 .= " SET l.fk_code_ventilation=" . (GETPOST('account_parent','int') > 0 ? GETPOST('account_parent','int') : '0');
 		$sql1 .= ' WHERE l.rowid IN (' . implode(',', $changeaccount) . ')';
@@ -173,20 +167,24 @@ print '<script type="text/javascript">
 /*
  * Customer Invoice lines
  */
-$sql = "SELECT f.rowid as facid, f.facnumber, f.type, f.datef, f.ref_client,";
-$sql .= " fd.rowid, fd.description, fd.product_type, fd.total_ht, fd.total_tva, fd.tva_tx, fd.vat_src_code, fd.total_ttc,";
-$sql .= " s.rowid as socid, s.nom as name, s.code_compta, s.code_client,";
-$sql .= " p.rowid as product_id, p.ref as product_ref, p.label as product_label, p.accountancy_code_sell, aa.rowid as fk_compte, aa.account_number, aa.label as label_compte,";
-$sql .= " fd.situation_percent, co.label as country, s.tva_intra";
-$sql .= " FROM " . MAIN_DB_PREFIX . "facturedet as fd";
-$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "product as p ON p.rowid = fd.fk_product";
-$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa ON aa.rowid = fd.fk_code_ventilation";
-$sql .= " INNER JOIN " . MAIN_DB_PREFIX . "facture as f ON f.rowid = fd.fk_facture";
-$sql .= " INNER JOIN " . MAIN_DB_PREFIX . "societe as s ON s.rowid = f.fk_soc";
-$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "c_country as co ON co.rowid = s.fk_pays ";
-$sql .= " WHERE fd.fk_code_ventilation > 0 ";
-$sql .= " AND f.entity IN (" . getEntity('facture', 0) . ")";   // We don't share object for accountancy
-$sql .= " AND f.fk_statut > 0";
+$sql = "SELECT f.rowid as facid, f.facnumber as ref, f.type, f.datef, f.ref_client,";
+$sql.= " fd.rowid, fd.description, fd.product_type, fd.total_ht, fd.total_tva, fd.tva_tx, fd.vat_src_code, fd.total_ttc,";
+$sql.= " s.rowid as socid, s.nom as name, s.code_compta, s.code_client,";
+$sql.= " p.rowid as product_id, p.ref as product_ref, p.label as product_label, p.accountancy_code_sell, aa.rowid as fk_compte, aa.account_number, aa.label as label_compte,";
+$sql.= " fd.situation_percent,";
+$sql.= " co.label as country, s.tva_intra";
+$parameters=array();
+$reshook=$hookmanager->executeHooks('printFieldListSelect',$parameters);    // Note that $action and $object may have been modified by hook
+$sql.=$hookmanager->resPrint;
+$sql.= " FROM " . MAIN_DB_PREFIX . "facturedet as fd";
+$sql.= " LEFT JOIN " . MAIN_DB_PREFIX . "product as p ON p.rowid = fd.fk_product";
+$sql.= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa ON aa.rowid = fd.fk_code_ventilation";
+$sql.= " INNER JOIN " . MAIN_DB_PREFIX . "facture as f ON f.rowid = fd.fk_facture";
+$sql.= " INNER JOIN " . MAIN_DB_PREFIX . "societe as s ON s.rowid = f.fk_soc";
+$sql.= " LEFT JOIN " . MAIN_DB_PREFIX . "c_country as co ON co.rowid = s.fk_pays ";
+$sql.= " WHERE fd.fk_code_ventilation > 0";
+$sql.= " AND f.entity IN (" . getEntity('facture', 0) . ")";   // We don't share object for accountancy
+$sql.= " AND f.fk_statut > 0";
 if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) {
 	$sql .= " AND f.type IN (" . Facture::TYPE_STANDARD . "," . Facture::TYPE_REPLACEMENT . "," . Facture::TYPE_CREDIT_NOTE . "," . Facture::TYPE_SITUATION . ")";
 } else {
@@ -291,11 +289,11 @@ if ($result) {
 	print '<table class="tagtable liste'.($moreforfilter?" listwithfilterbefore":"").'">'."\n";
 
 	print '<tr class="liste_titre_filter">';
-	print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_lineid" value="' . dol_escape_htmltag($search_lineid) . '""></td>';
+	print '<td class="liste_titre"><input type="text" class="flat maxwidth25" name="search_lineid" value="' . dol_escape_htmltag($search_lineid) . '""></td>';
 	print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_invoice" value="' . dol_escape_htmltag($search_invoice) . '"></td>';
 	print '<td class="liste_titre center">';
-   	if (! empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print '<input class="flat" type="text" size="1" maxlength="2" name="search_day" value="'.$search_day.'">';
-   	print '<input class="flat" type="text" size="1" maxlength="2" name="search_month" value="'.$search_month.'">';
+	if (! empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print '<input class="flat" type="text" size="1" maxlength="2" name="search_day" value="'.dol_escape_htmltag($search_day).'">';
+   	print '<input class="flat" type="text" size="1" maxlength="2" name="search_month" value="'.dol_escape_htmltag($search_month).'">';
    	$formother->select_year($search_year,'search_year',1, 20, 5);
 	print '</td>';
 	print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_ref" value="' . dol_escape_htmltag($search_ref) . '"></td>';
@@ -303,9 +301,9 @@ if ($result) {
 	print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_desc" value="' . dol_escape_htmltag($search_desc) . '"></td>';
 	print '<td class="liste_titre" align="right"><input type="text" class="right flat maxwidth50" name="search_amount" value="' . dol_escape_htmltag($search_amount) . '"></td>';
 	print '<td class="liste_titre" align="right"><input type="text" class="right flat maxwidth50" placeholder="%" name="search_vat" size="1" value="' . dol_escape_htmltag($search_vat) . '"></td>';
+	print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_country" value="' . dol_escape_htmltag($search_country) . '"></td>';
+	print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_tvaintra" value="' . dol_escape_htmltag($search_tvaintra) . '"></td>';
 	print '<td class="liste_titre" align="center"><input type="text" class="flat maxwidth50" name="search_account" value="' . dol_escape_htmltag($search_account) . '"></td>';
-	print '<td class="liste_titre" align="center"><input type="text" class="flat maxwidth50" name="search_country" value="' . dol_escape_htmltag($search_country) . '"></td>';
-	print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_tavintra" value="' . dol_escape_htmltag($search_tavintra) . '"></td>';
 	print '<td class="liste_titre" align="center">';
 	$searchpicto=$form->showFilterButtons();
 	print $searchpicto;
@@ -320,9 +318,9 @@ if ($result) {
 	print_liste_field_titre("Description", $_SERVER["PHP_SELF"], "fd.description", "", $param, '', $sortfield, $sortorder);
 	print_liste_field_titre("Amount", $_SERVER["PHP_SELF"], "fd.total_ht", "", $param, 'align="right"', $sortfield, $sortorder);
 	print_liste_field_titre("VATRate", $_SERVER["PHP_SELF"], "fd.tva_tx", "", $param, 'align="right"', $sortfield, $sortorder);
-	print_liste_field_titre("Account", $_SERVER["PHP_SELF"], "aa.account_number", "", $param, 'align="center"', $sortfield, $sortorder);
-	print_liste_field_titre("Country", $_SERVER["PHP_SELF"], "co.label", "", $param, 'align="center"', $sortfield, $sortorder);
+	print_liste_field_titre("Country", $_SERVER["PHP_SELF"], "co.label", "", $param, '', $sortfield, $sortorder);
 	print_liste_field_titre("VATIntra", $_SERVER["PHP_SELF"], "s.tva_intra", "", $param, '', $sortfield, $sortorder);
+	print_liste_field_titre("Account", $_SERVER["PHP_SELF"], "aa.account_number", "", $param, 'align="center"', $sortfield, $sortorder);
 	$clickpicto=$form->showCheckAddButtons();
 	print_liste_field_titre($clickpicto, '', '', '', '', 'align="center"');
 	print "</tr>\n";
@@ -333,16 +331,18 @@ if ($result) {
 	while ( $objp = $db->fetch_object($result) ) {
 		$codecompta = length_accountg($objp->account_number) . ' - ' . $objp->label_compte;
 
-		$facture_static->ref = $objp->facnumber;
+		$facture_static->ref = $objp->ref;
 		$facture_static->id = $objp->facid;
-
+		$facture_static->type = $objp->ftype;
+		
 		$product_static->ref = $objp->product_ref;
 		$product_static->id = $objp->product_id;
-		$product_static->type = $objp->product_type;
+		$product_static->type = $objp->type;
 		$product_static->label = $objp->product_label;
 
 		print '<tr class="oddeven">';
 
+		// Line id
 		print '<td>' . $objp->rowid . '</td>';
 
 		// Ref Invoice
@@ -357,7 +357,7 @@ if ($result) {
 		if ($objp->product_label) print '<br>'.$objp->product_label;
 		print '</td>';
 
-		print '<td>';
+		print '<td class="tdoverflowonsmartphone">';
 		$text = dolGetFirstLineOfText(dol_string_nohtmltag($objp->description));
 		$trunclength = empty($conf->global->ACCOUNTING_LENGTH_DESCRIPTION) ? 32 : $conf->global->ACCOUNTING_LENGTH_DESCRIPTION;
 		print $form->textwithtooltip(dol_trunc($text,$trunclength), $objp->description);
@@ -365,16 +365,17 @@ if ($result) {
 
 		print '<td align="right">' . price($objp->total_ht) . '</td>';
 		print '<td align="right">' . vatrate($objp->tva_tx.($objp->vat_src_code?' ('.$objp->vat_src_code.')':'')) . '</td>';
+
+		print '<td>' . $objp->country .'</td>';
+
+		print '<td>' . $objp->tva_intra . '</td>';
+
 		print '<td align="center">';
 		print $codecompta . ' <a href="./card.php?id=' . $objp->rowid . '&backtopage='.urlencode($_SERVER["PHP_SELF"].($param?'?'.$param:'')).'">';
 		print img_edit();
 		print '</a>';
 		print '</td>';
 
-		print '<td>' . $objp->country .'</td>';
-
-		print '<td>' . $objp->tva_intra . '</td>';
-
 		print '<td class="center"><input type="checkbox" class="checkforaction" name="changeaccount[]" value="' . $objp->rowid . '"/></td>';
 
 		print "</tr>";

+ 38 - 17
htdocs/accountancy/customer/list.php

@@ -27,7 +27,6 @@
  */
 require '../../main.inc.php';
 
-// Class
 require_once DOL_DOCUMENT_ROOT . '/compta/facture/class/facture.class.php';
 require_once DOL_DOCUMENT_ROOT . '/product/class/product.class.php';
 require_once DOL_DOCUMENT_ROOT . '/core/class/html.formaccounting.class.php';
@@ -37,7 +36,7 @@ require_once DOL_DOCUMENT_ROOT . '/core/class/html.formother.class.php';
 require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php';
 
 // Load traductions files requiredby by page
-$langs->loadLangs(array("bills","compta","main","accountancy","other","productbatch"));
+$langs->loadLangs(array("bills","compta","accountancy","other","productbatch"));
 
 $action=GETPOST('action','alpha');
 $massaction=GETPOST('massaction','alpha');
@@ -50,8 +49,8 @@ $mesCasesCochees = GETPOST('toselect', 'array');
 
 // Search Getpost
 $search_lineid = GETPOST('search_lineid', 'int');
-$search_invoice = GETPOST('search_invoice', 'alpha');
 $search_ref = GETPOST('search_ref', 'alpha');
+$search_invoice = GETPOST('search_invoice', 'alpha');
 $search_label = GETPOST('search_label', 'alpha');
 $search_desc = GETPOST('search_desc', 'alpha');
 $search_amount = GETPOST('search_amount', 'alpha');
@@ -60,6 +59,8 @@ $search_vat = GETPOST('search_vat', 'alpha');
 $search_day=GETPOST("search_day","int");
 $search_month=GETPOST("search_month","int");
 $search_year=GETPOST("search_year","int");
+$search_country = GETPOST('search_country', 'alpha');
+$search_tvaintra = GETPOST('search_tvaintra', 'alpha');
 
 $btn_ventil = GETPOST('ventil', 'alpha');
 
@@ -98,7 +99,7 @@ $chartaccountcode = dol_getIdFromCode($db, $conf->global->CHARTOFACCOUNTS, 'acco
 
 
 /*
- * Action
+ * Actions
  */
 
 if (GETPOST('cancel','alpha')) { $action='list'; $massaction=''; }
@@ -124,6 +125,8 @@ if (empty($reshook))
 		$search_day = '';
 		$search_month = '';
 		$search_year = '';
+		$search_country = '';
+		$search_tvaintra = '';
 	}
 
 	// Mass actions
@@ -204,14 +207,17 @@ if (empty($chartaccountcode))
 }
 
 // Customer Invoice lines
-$sql = "SELECT f.rowid as facid, f.facnumber, f.datef, f.type as ftype,";
+$sql = "SELECT f.rowid as facid, f.facnumber as ref, f.datef, f.type as ftype,";
 $sql.= " l.rowid, l.fk_product, l.description, l.total_ht, l.fk_code_ventilation, l.product_type as type_l, l.tva_tx as tva_tx_line, l.vat_src_code,";
 $sql.= " p.rowid as product_id, p.ref as product_ref, p.label as product_label, p.fk_product_type as type, p.accountancy_code_sell as code_sell, p.tva_tx as tva_tx_prod,";
-$sql.= " aa.rowid as aarowid";
+$sql.= " aa.rowid as aarowid,";
+$sql.= " co.label as country, s.tva_intra";
 $parameters=array();
 $reshook=$hookmanager->executeHooks('printFieldListSelect',$parameters);    // Note that $action and $object may have been modified by hook
 $sql.=$hookmanager->resPrint;
 $sql.= " FROM " . MAIN_DB_PREFIX . "facture as f";
+$sql.= " INNER JOIN " . MAIN_DB_PREFIX . "societe as s ON s.rowid = f.fk_soc";
+$sql.= " LEFT JOIN " . MAIN_DB_PREFIX . "c_country as co ON co.rowid = s.fk_pays ";
 $sql.= " INNER JOIN " . MAIN_DB_PREFIX . "facturedet as l ON f.rowid = l.fk_facture";
 $sql.= " LEFT JOIN " . MAIN_DB_PREFIX . "product as p ON p.rowid = l.fk_product";
 $sql.= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa ON p.accountancy_code_sell = aa.account_number AND aa.fk_pcg_version = '" . $chartaccountcode."'";
@@ -224,25 +230,25 @@ if ($search_lineid) {
     $sql .= natural_search("l.rowid", $search_lineid, 1);
 }
 if (strlen(trim($search_invoice))) {
-    $sql .= natural_search("f.facnumber",$search_invoice);
+    $sql .= natural_search("f.facnumber", $search_invoice);
 }
 if (strlen(trim($search_ref))) {
-    $sql .= natural_search("p.ref",$search_ref);
+    $sql .= natural_search("p.ref", $search_ref);
 }
 if (strlen(trim($search_label))) {
-    $sql .= natural_search("p.label",$search_label);
+    $sql .= natural_search("p.label", $search_label);
 }
 if (strlen(trim($search_desc))) {
-    $sql .= natural_search("l.description",$search_desc);
+    $sql .= natural_search("l.description", $search_desc);
 }
 if (strlen(trim($search_amount))) {
-    $sql .= natural_search("l.total_ht",$search_amount,1);
+    $sql .= natural_search("l.total_ht", $search_amount, 1);
 }
 if (strlen(trim($search_account))) {
-    $sql .= natural_search("aa.account_number",$search_account);
+    $sql .= natural_search("aa.account_number", $search_account);
 }
 if (strlen(trim($search_vat))) {
-    $sql .= natural_search("l.tva_tx",$search_vat,1);
+    $sql .= natural_search("l.tva_tx", $search_vat, 1);
 }
 if ($search_month > 0)
 {
@@ -257,6 +263,12 @@ else if ($search_year > 0)
 {
 	$sql.= " AND f.datef BETWEEN '".$db->idate(dol_get_first_day($search_year,1,false))."' AND '".$db->idate(dol_get_last_day($search_year,12,false))."'";
 }
+if (strlen(trim($search_country))) {
+	$sql .= natural_search("co.label", $search_country);
+}
+if (strlen(trim($search_tvaintra))) {
+	$sql .= natural_search("s.tva_intra", $search_tvaintra);
+}
 if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) {
 	$sql .= " AND f.type IN (" . Facture::TYPE_STANDARD . "," . Facture::TYPE_REPLACEMENT . "," . Facture::TYPE_CREDIT_NOTE . "," . Facture::TYPE_SITUATION . ")";
 } else {
@@ -301,7 +313,9 @@ if ($result) {
 	if ($search_desc)        $param.='&search_desc='.urlencode($search_desc);
 	if ($search_amount)      $param.='&search_amount='.urlencode($search_amount);
 	if ($search_vat)         $param.='&search_vat='.urlencode($search_vat);
-
+	if ($search_country)  	$param .= "&search_country=" . urlencode($search_country);
+	if ($search_tvaintra)	$param .= "&search_tvaintra=" . urlencode($search_tvaintra);
+	
 	$arrayofmassactions =  array(
 	    'ventil'=>$langs->trans("Ventilate")
 	    //'presend'=>$langs->trans("SendByMail"),
@@ -339,7 +353,7 @@ if ($result) {
 
 	// We add search filter
 	print '<tr class="liste_titre_filter">';
-	print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_lineid" value="' . dol_escape_htmltag($search_lineid) . '""></td>';
+	print '<td class="liste_titre"><input type="text" class="flat maxwidth25" name="search_lineid" value="' . dol_escape_htmltag($search_lineid) . '""></td>';
 	print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_invoice" value="' . dol_escape_htmltag($search_invoice) . '"></td>';
 	print '<td class="liste_titre center">';
    	if (! empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print '<input class="flat" type="text" size="1" maxlength="2" name="search_day" value="'.$search_day.'">';
@@ -351,6 +365,8 @@ if ($result) {
 	print '<td class="liste_titre"><input type="text" class="flat maxwidthonsmartphone" name="search_desc" value="' . dol_escape_htmltag($search_desc) . '"></td>';
 	print '<td class="liste_titre" align="right"><input type="text" class="flat maxwidth50 right" name="search_amount" value="' . dol_escape_htmltag($search_amount) . '"></td>';
 	print '<td class="liste_titre" align="right"><input type="text" class="flat maxwidth50 right" name="search_vat" placeholder="%" size="1" value="' . dol_escape_htmltag($search_vat) . '"></td>';
+	print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_country" value="' . dol_escape_htmltag($search_country) . '"></td>';
+	print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_tvaintra" value="' . dol_escape_htmltag($search_tvaintra) . '"></td>';
 	print '<td class="liste_titre"></td>';
 	print '<td class="liste_titre"></td>';
 	print '<td align="center" class="liste_titre">';
@@ -368,6 +384,8 @@ if ($result) {
 	print_liste_field_titre("Description", $_SERVER["PHP_SELF"], "l.description", "", $param, '', $sortfield, $sortorder);
 	print_liste_field_titre("Amount", $_SERVER["PHP_SELF"], "l.total_ht", "", $param, 'align="right"', $sortfield, $sortorder);
 	print_liste_field_titre("VATRate", $_SERVER["PHP_SELF"], "l.tva_tx", "", $param, 'align="right"', $sortfield, $sortorder);
+	print_liste_field_titre("Country", $_SERVER["PHP_SELF"], "co.label", "", $param, '', $sortfield, $sortorder);
+	print_liste_field_titre("VATIntra", $_SERVER["PHP_SELF"], "s.tva_intra", "", $param, '', $sortfield, $sortorder);
 	print_liste_field_titre("AccountAccountingSuggest", '', '', '', '', 'align="center"');
 	print_liste_field_titre("IntoAccount", '', '', '', '', 'align="center"');
 	$checkpicto='';
@@ -377,7 +395,6 @@ if ($result) {
 
 	$facture_static = new Facture($db);
 	$product_static = new Product($db);
-	$form = new Form($db);
 
 	while ( $i < min($num_lines, $limit) ) {
 		$objp = $db->fetch_object($result);
@@ -391,7 +408,7 @@ if ($result) {
 		$product_static->type = $objp->type;
 		$product_static->label = $objp->product_label;
 
-		$facture_static->ref = $objp->facnumber;
+		$facture_static->ref = $objp->ref;
 		$facture_static->id = $objp->facid;
 		$facture_static->type = $objp->ftype;
 
@@ -455,6 +472,10 @@ if ($result) {
 		print vatrate($objp->tva_tx_line.($objp->vat_src_code?' ('.$objp->vat_src_code.')':''));
 		print '</td>';
 
+		print '<td>' . $objp->country .'</td>';
+		
+		print '<td>' . $objp->tva_intra . '</td>';
+		
 		// Current account
 		print '<td align="center" style="' . $code_sell_p_notset . '">';
 	    print (($objp->type_l == 1)?$langs->trans("DefaultForService"):$langs->trans("DefaultForProduct")) . ' = ' . ($objp->code_sell_l > 0 ? length_accountg($objp->code_sell_l) : $langs->trans("Unknown"));

+ 1 - 5
htdocs/accountancy/expensereport/card.php

@@ -28,14 +28,10 @@
  */
 require '../../main.inc.php';
 
-// Class
 require_once DOL_DOCUMENT_ROOT . '/expensereport/class/expensereport.class.php';
 require_once DOL_DOCUMENT_ROOT . '/core/class/html.formaccounting.class.php';
 
-// Langs
-$langs->load("bills");
-$langs->load("accountancy");
-$langs->load("trips");
+$langs->loadLangs(array("bills","accountancy","trips"));
 
 $action = GETPOST('action', 'alpha');
 $cancel = GETPOST('cancel', 'alpha');

+ 1 - 9
htdocs/accountancy/expensereport/lines.php

@@ -26,7 +26,6 @@
  */
 require '../../main.inc.php';
 
-// Class
 require_once DOL_DOCUMENT_ROOT . '/core/class/html.formaccounting.class.php';
 require_once DOL_DOCUMENT_ROOT . '/expensereport/class/expensereport.class.php';
 require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php';
@@ -34,14 +33,7 @@ require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php';
 require_once DOL_DOCUMENT_ROOT . '/core/class/html.formother.class.php';
 require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php';
 
-// Langs
-$langs->load("compta");
-$langs->load("bills");
-$langs->load("other");
-$langs->load("main");
-$langs->load("accountancy");
-$langs->load("trips");
-$langs->load("productbatch");
+$langs->loadLangs(array("compta","bills","other","accountancy","trips","productbatch"));
 
 $account_parent = GETPOST('account_parent','int');
 $changeaccount = GETPOST('changeaccount');

+ 1 - 2
htdocs/accountancy/expensereport/list.php

@@ -27,7 +27,6 @@
  */
 require '../../main.inc.php';
 
-// Class
 require_once DOL_DOCUMENT_ROOT . '/expensereport/class/expensereport.class.php';
 require_once DOL_DOCUMENT_ROOT . '/core/class/html.formaccounting.class.php';
 require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingaccount.class.php';
@@ -36,7 +35,7 @@ require_once DOL_DOCUMENT_ROOT . '/core/class/html.formother.class.php';
 require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php';
 
 // Load traductions files requiredby by page
-$langs->loadLangs(array("bills","compta","main","accountancy","other","trips","productbatch"));
+$langs->loadLangs(array("bills","compta","accountancy","other","trips","productbatch"));
 
 $action=GETPOST('action','alpha');
 $massaction=GETPOST('massaction','alpha');

+ 1 - 15
htdocs/accountancy/index.php

@@ -26,26 +26,12 @@ require '../main.inc.php';
 require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php';
 require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php';
 
-// Langs
-$langs->load("compta");
-$langs->load("bills");
-$langs->load("other");
-$langs->load("main");
-$langs->load("accountancy");
+$langs->loadLangs(array("compta","bills","other","accountancy","loans","banks","admin","dict"));
 
 // Security check
 if ($user->societe_id > 0)
 	accessforbidden();
 
-$langs->load("admin");
-$langs->load("dict");
-$langs->load("bills");
-$langs->load("accountancy");
-$langs->load("compta");
-$langs->load("banks");
-$langs->load("loans");
-
-
 /*
  * Actions
  */

+ 1 - 4
htdocs/accountancy/supplier/card.php

@@ -28,13 +28,10 @@
  */
 require '../../main.inc.php';
 
-// Class
 require_once DOL_DOCUMENT_ROOT . '/fourn/class/fournisseur.facture.class.php';
 require_once DOL_DOCUMENT_ROOT . '/core/class/html.formaccounting.class.php';
 
-// Langs
-$langs->load("bills");
-$langs->load("accountancy");
+$langs->loadLangs(array("bills","accountancy"));
 
 $action = GETPOST('action', 'alpha');
 $cancel = GETPOST('cancel', 'alpha');

+ 34 - 27
htdocs/accountancy/supplier/lines.php

@@ -26,7 +26,6 @@
  */
 require '../../main.inc.php';
 
-// Class
 require_once DOL_DOCUMENT_ROOT . '/core/class/html.formaccounting.class.php';
 require_once DOL_DOCUMENT_ROOT . '/fourn/class/fournisseur.facture.class.php';
 require_once DOL_DOCUMENT_ROOT . '/product/class/product.class.php';
@@ -35,13 +34,7 @@ require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php';
 require_once DOL_DOCUMENT_ROOT . '/core/class/html.formother.class.php';
 require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php';
 
-// Langs
-$langs->load("compta");
-$langs->load("bills");
-$langs->load("other");
-$langs->load("main");
-$langs->load("accountancy");
-$langs->load("productbatch");
+$langs->loadLangs(array("compta","bills","other","accountancy","productbatch"));
 
 $account_parent = GETPOST('account_parent');
 $changeaccount = GETPOST('changeaccount');
@@ -117,10 +110,11 @@ if (is_array($changeaccount) && count($changeaccount) > 0) {
 		setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Account")), null, 'errors');
 	}
 
-	$db->begin();
 
 	if (! $error)
 	{
+		$db->begin();
+
 		$sql1 = "UPDATE " . MAIN_DB_PREFIX . "facture_fourn_det as l";
 		$sql1 .= " SET l.fk_code_ventilation=" . (GETPOST('account_parent','int') > 0 ? GETPOST('account_parent','int') : '0');
 		$sql1 .= ' WHERE l.rowid IN (' . implode(',', $changeaccount) . ')';
@@ -173,10 +167,13 @@ print '<script type="text/javascript">
 /*
  * Supplier Invoice lines
  */
-$sql = "SELECT f.rowid as facid, f.ref as facnumber, f.ref_supplier, f.libelle as invoice_label, f.datef, f.fk_soc,";
+$sql = "SELECT f.rowid as facid, f.ref as ref, f.ref_supplier, f.libelle as invoice_label, f.datef, f.fk_soc,";
 $sql.= " l.rowid, l.fk_product, l.description, l.total_ht , l.qty, l.tva_tx, l.vat_src_code,";
 $sql.= " aa.label, aa.account_number, ";
 $sql.= " p.rowid as product_id, p.ref as product_ref, p.label as product_label, p.fk_product_type as type, co.label as country, s.tva_intra";
+$parameters=array();
+$reshook=$hookmanager->executeHooks('printFieldListSelect',$parameters);    // Note that $action and $object may have been modified by hook
+$sql.=$hookmanager->resPrint;
 $sql .= " FROM " . MAIN_DB_PREFIX . "facture_fourn_det as l";
 $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "product as p ON p.rowid = l.fk_product";
 $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa ON aa.rowid = l.fk_code_ventilation";
@@ -230,6 +227,11 @@ if (strlen(trim($search_tvaintra))) {
 }
 $sql .= " AND f.entity IN (" . getEntity('facture_fourn', 0) . ")";  // We don't share object for accountancy
 
+// Add where from hooks
+$parameters=array();
+$reshook=$hookmanager->executeHooks('printFieldListWhere',$parameters);    // Note that $action and $object may have been modified by hook
+$sql.=$hookmanager->resPrint;
+
 $sql .= $db->order($sortfield, $sortorder);
 
 // Count total nb of records
@@ -242,7 +244,7 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
 
 $sql .= $db->plimit($limit + 1, $offset);
 
-dol_syslog('accountancy/supplier/lines.php::list');
+dol_syslog('accountancy/supplier/lines.php');
 $result = $db->query($sql);
 
 if ($result) {
@@ -273,7 +275,7 @@ if ($result) {
 	print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
 	print '<input type="hidden" name="page" value="'.$page.'">';
 
-	print_barre_liste($langs->trans("InvoiceLinesDone"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num_lines, $nbtotalofrecords, 'title_accountancy', 0, '', '', $limit);
+	print_barre_liste($langs->trans("InvoiceLinesDone"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num_lines, $nbtotalofrecords, 'title_accountancy', 0, '', '', $limit);
 
 	print $langs->trans("DescVentilDoneSupplier") . '<br>';
 
@@ -283,11 +285,12 @@ if ($result) {
 
 	$moreforfilter = '';
 
-    print '<div class="div-table-responsive">';
+	print '<div class="div-table-responsive">';
 	print '<table class="tagtable liste'.($moreforfilter?" listwithfilterbefore":"").'">'."\n";
 
+	// We add search filter
 	print '<tr class="liste_titre_filter">';
-	print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_lineid" value="' . dol_escape_htmltag($search_lineid) . '""></td>';
+	print '<td class="liste_titre"><input type="text" class="flat maxwidth25" name="search_lineid" value="' . dol_escape_htmltag($search_lineid) . '""></td>';
 	print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_invoice" value="' . dol_escape_htmltag($search_invoice) . '"></td>';
 	print '<td class="liste_titre"></td>';
 	print '<td class="liste_titre center">';
@@ -300,10 +303,10 @@ if ($result) {
 	print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_desc" value="' . dol_escape_htmltag($search_desc) . '"></td>';
 	print '<td class="liste_titre" align="right"><input type="text" class="right flat maxwidth50" name="search_amount" value="' . dol_escape_htmltag($search_amount) . '"></td>';
 	print '<td class="liste_titre" align="right"><input type="text" class="right flat maxwidth50" name="search_vat" placeholder="%" size="1" value="' . dol_escape_htmltag($search_vat) . '"></td>';
-	print '<td class="liste_titre" align="center"><input type="text" class="flat maxwidth50" name="search_account" value="' . dol_escape_htmltag($search_account) . '"></td>';
 	print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_country" value="' . dol_escape_htmltag($search_country) . '"></td>';
-	print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_tavintra" value="' . dol_escape_htmltag($search_tavintra) . '"></td>';
-    print '<td class="liste_titre" align="center">';
+	print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_tvaintra" value="' . dol_escape_htmltag($search_tvaintra) . '"></td>';
+	print '<td class="liste_titre" align="center"><input type="text" class="flat maxwidth50" name="search_account" value="' . dol_escape_htmltag($search_account) . '"></td>';
+	print '<td class="liste_titre" align="center">';
     $searchpicto=$form->showFilterButtons();
     print $searchpicto;
     print '</td>';
@@ -319,22 +322,22 @@ if ($result) {
 	print_liste_field_titre("Description", $_SERVER["PHP_SELF"], "l.description", "", $param, '', $sortfield, $sortorder);
 	print_liste_field_titre("Amount", $_SERVER["PHP_SELF"], "l.total_ht", "", $param, 'align="right"', $sortfield, $sortorder);
 	print_liste_field_titre("VATRate", $_SERVER["PHP_SELF"], "l.tva_tx", "", $param, 'align="right"', $sortfield, $sortorder);
-	print_liste_field_titre("Account", $_SERVER["PHP_SELF"], "aa.account_number", "", $param, 'align="center"', $sortfield, $sortorder);
 	print_liste_field_titre("Country", $_SERVER["PHP_SELF"], "co.label", "", $param, '', $sortfield, $sortorder);
 	print_liste_field_titre("VATIntra", $_SERVER["PHP_SELF"], "s.tva_intra", "", $param, '', $sortfield, $sortorder);
-    $checkpicto=$form->showCheckAddButtons();
+	print_liste_field_titre("Account", $_SERVER["PHP_SELF"], "aa.account_number", "", $param, 'align="center"', $sortfield, $sortorder);
+	$checkpicto=$form->showCheckAddButtons();
 	print_liste_field_titre($checkpicto, '', '', '', '', 'align="center"');
 	print "</tr>\n";
 
 	$facturefournisseur_static = new FactureFournisseur($db);
-	$product_static = new Product($db);
+	$product_static = new ProductFournisseur($db);
 
 	while ($i < min($num_lines, $limit)) {
 		$objp = $db->fetch_object($result);
 
 		$codecompta = length_accountg($objp->account_number) . ' - ' . $objp->label;
 
-		$facturefournisseur_static->ref = $objp->facnumber;
+		$facturefournisseur_static->ref = $objp->ref;
 		$facturefournisseur_static->id = $objp->facid;
 
 		$product_static->ref = $objp->product_ref;
@@ -344,24 +347,26 @@ if ($result) {
 
 		print '<tr class="oddeven">';
 
+		// Line id
 		print '<td>' . $objp->rowid . '</td>';
 
 		// Ref Invoice
 		print '<td>' . $facturefournisseur_static->getNomUrl(1) . '</td>';
 
-		print '<td>';
+		print '<td class="tdoverflowonsmartphone">';
 		print $objp->invoice_label;
 		print '</td>';
 
 		print '<td align="center">' . dol_print_date($db->jdate($objp->datef), 'day') . '</td>';
 
-		// Ref Product
+		// Ref product
 		print '<td>';
 		if ($product_static->id)
 			print $product_static->getNomUrl(1);
 	    if ($objp->product_label) print '<br>'.$objp->product_label;
 		print '</td>';
 
+		// Description
 		print '<td>';
 		$text = dolGetFirstLineOfText(dol_string_nohtmltag($objp->description));
 		$trunclength = empty($conf->global->ACCOUNTING_LENGTH_DESCRIPTION) ? 32 : $conf->global->ACCOUNTING_LENGTH_DESCRIPTION;
@@ -370,18 +375,20 @@ if ($result) {
 
 		print '<td align="right">' . price($objp->total_ht) . '</td>';
 		print '<td align="right">' . vatrate($objp->tva_tx.($objp->vat_src_code?' ('.$objp->vat_src_code.')':'')) . '</td>';
+
+		print '<td>' . $objp->country .'</td>';
+		print '<td>' . $objp->tva_intra . '</td>';
+
 		print '<td align="center">';
 		print $codecompta . ' <a href="./card.php?id=' . $objp->rowid  . '&backtopage='.urlencode($_SERVER["PHP_SELF"].($param?'?'.$param:'')) . '">';
 		print img_edit();
 		print '</a></td>';
-		print '<td>' . $objp->country .'</td>';
-		print '<td>' . $objp->tva_intra . '</td>';
 		print '<td class="center"><input type="checkbox" class="checkforaction" name="changeaccount[]" value="' . $objp->rowid . '"/></td>';
 
-		print "</tr>";
+		print '</tr>';
 		$i ++;
 	}
-    print "</table>";
+    print '</table>';
     print "</div>";
 
     if ($nbtotalofrecords > $limit) {

+ 39 - 18
htdocs/accountancy/supplier/list.php

@@ -27,7 +27,6 @@
  */
 require '../../main.inc.php';
 
-// Class
 require_once DOL_DOCUMENT_ROOT . '/fourn/class/fournisseur.facture.class.php';
 require_once DOL_DOCUMENT_ROOT . '/fourn/class/fournisseur.product.class.php';
 require_once DOL_DOCUMENT_ROOT . '/core/class/html.formaccounting.class.php';
@@ -37,7 +36,7 @@ require_once DOL_DOCUMENT_ROOT . '/core/class/html.formother.class.php';
 require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php';
 
 // Load traductions files requiredby by page
-$langs->loadLangs(array("bills","compta","main","accountancy","other","productbatch"));
+$langs->loadLangs(array("bills","compta","accountancy","other","productbatch"));
 
 $action=GETPOST('action','alpha');
 $massaction=GETPOST('massaction','alpha');
@@ -60,6 +59,8 @@ $search_vat = GETPOST('search_vat', 'alpha');
 $search_day=GETPOST("search_day","int");
 $search_month=GETPOST("search_month","int");
 $search_year=GETPOST("search_year","int");
+$search_country = GETPOST('search_country', 'alpha');
+$search_tvaintra = GETPOST('search_tvaintra', 'alpha');
 
 $btn_ventil = GETPOST('ventil', 'alpha');
 
@@ -99,7 +100,7 @@ $chartaccountcode = dol_getIdFromCode($db, $conf->global->CHARTOFACCOUNTS, 'acco
 
 
 /*
- * Action
+ * Actions
  */
 
 if (GETPOST('cancel','alpha')) { $action='list'; $massaction=''; }
@@ -125,6 +126,8 @@ if (empty($reshook))
 		$search_day = '';
 		$search_month = '';
 		$search_year = '';
+		$search_country = '';
+		$search_tvaintra = '';
 	}
 
 	// Mass actions
@@ -208,11 +211,14 @@ if (empty($chartaccountcode))
 $sql = "SELECT f.rowid as facid, f.ref, f.ref_supplier, f.libelle as invoice_label, f.datef, f.type as ftype,";
 $sql.= " l.rowid, l.fk_product, l.description, l.total_ht, l.fk_code_ventilation, l.product_type as type_l, l.tva_tx as tva_tx_line, l.vat_src_code,";
 $sql.= " p.rowid as product_id, p.ref as product_ref, p.label as product_label, p.fk_product_type as type, p.accountancy_code_buy as code_buy, p.tva_tx as tva_tx_prod,";
-$sql.= " aa.rowid as aarowid";
+$sql.= " aa.rowid as aarowid,";
+$sql.= " co.label as country, s.tva_intra";
 $parameters=array();
 $reshook=$hookmanager->executeHooks('printFieldListSelect',$parameters);    // Note that $action and $object may have been modified by hook
 $sql.=$hookmanager->resPrint;
 $sql.= " FROM " . MAIN_DB_PREFIX . "facture_fourn as f";
+$sql .= " INNER JOIN " . MAIN_DB_PREFIX . "societe as s ON s.rowid = f.fk_soc";
+$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "c_country as co ON co.rowid = s.fk_pays ";
 $sql.= " INNER JOIN " . MAIN_DB_PREFIX . "facture_fourn_det as l ON f.rowid = l.fk_facture_fourn";
 $sql.= " LEFT JOIN " . MAIN_DB_PREFIX . "product as p ON p.rowid = l.fk_product";
 $sql.= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa ON p.accountancy_code_buy = aa.account_number AND aa.fk_pcg_version = '" . $chartaccountcode."'";
@@ -223,25 +229,28 @@ if ($search_lineid) {
     $sql .= natural_search("l.rowid", $search_lineid, 1);
 }
 if (strlen(trim($search_invoice))) {
-    $sql .= natural_search("f.ref",$search_invoice);
+    $sql .= natural_search("f.ref", $search_invoice);
 }
 if (strlen(trim($search_ref))) {
-    $sql .= natural_search("p.ref",$search_ref);
+    $sql .= natural_search("p.ref", $search_ref);
 }
 if (strlen(trim($search_label))) {
-    $sql .= natural_search("p.label",$search_label);
+    $sql .= natural_search("p.label", $search_label);
 }
 if (strlen(trim($search_desc))) {
-    $sql .= natural_search("l.description",$search_desc);
+    $sql .= natural_search("l.description", $search_desc);
 }
 if (strlen(trim($search_amount))) {
-    $sql .= natural_search("l.total_ht",$search_amount,1);
+    $sql .= natural_search("l.total_ht", $search_amount, 1);
 }
 if (strlen(trim($search_account))) {
-    $sql .= natural_search("aa.account_number",$search_account);
+    $sql .= natural_search("aa.account_number", $search_account);
 }
 if (strlen(trim($search_vat))) {
-    $sql .= natural_search("l.tva_tx",$search_vat,1);
+    $sql .= natural_search("l.tva_tx", price2num($search_vat), 1);
+}
+if (strlen(trim($search_tvaintra))) {
+	$sql .= natural_search("s.tva_intra", $search_tvaintra);
 }
 if ($search_month > 0)
 {
@@ -256,6 +265,9 @@ else if ($search_year > 0)
 {
 	$sql.= " AND f.datef BETWEEN '".$db->idate(dol_get_first_day($search_year,1,false))."' AND '".$db->idate(dol_get_last_day($search_year,12,false))."'";
 }
+if (strlen(trim($search_country))) {
+	$sql .= natural_search("co.label", $search_country);
+}
 if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) {
 	$sql .= " AND f.type IN (" . FactureFournisseur::TYPE_STANDARD . "," . FactureFournisseur::TYPE_REPLACEMENT . "," . FactureFournisseur::TYPE_CREDIT_NOTE . "," . FactureFournisseur::TYPE_SITUATION . ")";
 } else {
@@ -282,6 +294,7 @@ $sql .= $db->plimit($limit + 1, $offset);
 
 dol_syslog('accountancy/supplier/list.php');
 $result = $db->query($sql);
+
 if ($result) {
 	$num_lines = $db->num_rows($result);
 	$i = 0;
@@ -300,6 +313,8 @@ if ($result) {
 	if ($search_desc)        $param.='&search_desc='.urlencode($search_desc);
 	if ($search_amount)      $param.='&search_amount='.urlencode($search_amount);
 	if ($search_vat)         $param.='&search_vat='.urlencode($search_vat);
+	if ($search_country) 	$param .= "&search_country=" . urlencode($search_country);
+	if ($search_tvaintra)	$param .= "&search_tvaintra=" . urlencode($search_tvaintra);
 
 	$arrayofmassactions =  array(
 	    'ventil'=>$langs->trans("Ventilate")
@@ -338,7 +353,7 @@ if ($result) {
 
 	// We add search filter
 	print '<tr class="liste_titre_filter">';
-	print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_lineid" value="' . dol_escape_htmltag($search_lineid) . '""></td>';
+	print '<td class="liste_titre"><input type="text" class="flat maxwidth25" name="search_lineid" value="' . dol_escape_htmltag($search_lineid) . '""></td>';
 	print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_invoice" value="' . dol_escape_htmltag($search_invoice) . '"></td>';
 	print '<td class="liste_titre"></td>';
 	print '<td class="liste_titre center">';
@@ -348,16 +363,18 @@ if ($result) {
 	print '</td>';
 	print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_ref" value="' . dol_escape_htmltag($search_ref) . '"></td>';
 	//print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_label" value="' . dol_escape_htmltag($search_label) . '"></td>';
-	print '<td class="liste_titre"><input type="text" class="flat maxwidthonsmartphone" name="search_desc" value="' . dol_escape_htmltag($search_desc) . '"></td>';
+	print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_desc" value="' . dol_escape_htmltag($search_desc) . '"></td>';
 	print '<td class="liste_titre" align="right"><input type="text" class="right flat maxwidth50" name="search_amount" value="' . dol_escape_htmltag($search_amount) . '"></td>';
 	print '<td class="liste_titre" align="right"><input type="text" class="right flat maxwidth50" name="search_vat" placeholder="%" size="1" value="' . dol_escape_htmltag($search_vat) . '"></td>';
+	print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_country" value="' . dol_escape_htmltag($search_country) . '"></td>';
+	print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_tvaintra" value="' . dol_escape_htmltag($search_tvaintra) . '"></td>';
 	print '<td class="liste_titre"></td>';
 	print '<td class="liste_titre"></td>';
 	print '<td align="center" class="liste_titre">';
 	$searchpicto=$form->showFilterButtons();
 	print $searchpicto;
 	print '</td>';
-	print '</tr>';
+	print "</tr>\n";
 
 	print '<tr class="liste_titre">';
 	print_liste_field_titre("LineId", $_SERVER["PHP_SELF"], "l.rowid", "", $param, '', $sortfield, $sortorder);
@@ -369,6 +386,8 @@ if ($result) {
 	print_liste_field_titre("Description", $_SERVER["PHP_SELF"], "l.description", "", $param, '', $sortfield, $sortorder);
 	print_liste_field_titre("Amount", $_SERVER["PHP_SELF"], "l.total_ht", "", $param, 'align="right"', $sortfield, $sortorder);
 	print_liste_field_titre("VATRate", $_SERVER["PHP_SELF"], "l.tva_tx", "", $param, 'align="right"', $sortfield, $sortorder);
+	print_liste_field_titre("Country", $_SERVER["PHP_SELF"], "co.label", "", $param, '', $sortfield, $sortorder);
+	print_liste_field_titre("VATIntra", $_SERVER["PHP_SELF"], "s.tva_intra", "", $param, '', $sortfield, $sortorder);
 	print_liste_field_titre("AccountAccountingSuggest", '', '', '', '', 'align="center"');
 	print_liste_field_titre("IntoAccount", '', '', '', '', 'align="center"');
 	$checkpicto='';
@@ -378,9 +397,8 @@ if ($result) {
 
 	$facturefourn_static = new FactureFournisseur($db);
 	$productfourn_static = new ProductFournisseur($db);
-	$form = new Form($db);
 
-	while ( $i < min($num_lines, $limit) ) {
+	while ($i < min($num_lines, $limit)) {
 		$objp = $db->fetch_object($result);
 
 		// product_type: 0 = service ? 1 = product
@@ -442,9 +460,9 @@ if ($result) {
 		if ($productfourn_static->id)
 			print $productfourn_static->getNomUrl(1);
 		if ($objp->product_label) print '<br>'.$objp->product_label;
-        print '</td>';
+		print '</td>';
 
-        // Description
+		// Description
 		print '<td>';
 		$text = dolGetFirstLineOfText(dol_string_nohtmltag($objp->description));
 		$trunclength = empty($conf->global->ACCOUNTING_LENGTH_DESCRIPTION) ? 32 : $conf->global->ACCOUNTING_LENGTH_DESCRIPTION;
@@ -462,6 +480,9 @@ if ($result) {
 		print vatrate($objp->tva_tx_line.($objp->vat_src_code?' ('.$objp->vat_src_code.')':''));
 		print '</td>';
 
+		print '<td>' . $objp->country .'</td>';
+		print '<td>' . $objp->tva_intra . '</td>';
+
 		// Current account
 		print '<td align="center" style="' . $code_buy_p_notset . '">';
 		print (($objp->type_l == 1)?$langs->trans("DefaultForService"):$langs->trans("DefaultForProduct")) . ' = ' . ($objp->code_buy_l > 0 ? length_accountg($objp->code_buy_l) : $langs->trans("Unknown"));

+ 5 - 5
htdocs/admin/defaultvalues.php

@@ -1,6 +1,6 @@
 <?php
-/* Copyright (C) 2017	Laurent Destailleur	<eldy@users.sourceforge.net>
- * Copyright (C) 2017	Regis Houssin		<regis.houssin@capnetworks.com>
+/* Copyright (C) 2017		Laurent Destailleur	<eldy@users.sourceforge.net>
+ * Copyright (C) 2017-2018	Regis Houssin		<regis.houssin@capnetworks.com>
  *
  * 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
@@ -212,9 +212,9 @@ print "<br>\n";
 if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage;
 if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit;
 if ($optioncss != '')  $param.='&optioncss='.$optioncss;
-if (defaulturl)        $param.='&defaulturl='.urlencode(defaulturl);
-if (defaultkey)        $param.='&defaultkey='.urlencode(defaultkey);
-if (defaultvalue)      $param.='&defaultvalue='.urlencode(defaultvalue);
+if ($defaulturl)        $param.='&defaulturl='.urlencode($defaulturl);
+if ($defaultkey)        $param.='&defaultkey='.urlencode($defaultkey);
+if ($defaultvalue)      $param.='&defaultvalue='.urlencode($defaultvalue);
 
 
 print '<form action="'.$_SERVER["PHP_SELF"].((empty($user->entity) && $debug)?'?debug=1':'').'" method="POST">';

+ 22 - 8
htdocs/admin/mails_templates.php

@@ -169,9 +169,10 @@ if ($conf->adherent->enabled)          $elementList['member']=$langs->trans('Mai
 if ($conf->contrat->enabled)           $elementList['contract']=$langs->trans('MailToSendContract');
 if ($conf->projet->enabled)            $elementList['project']=$langs->trans('MailToProject');
 $elementList['user']=$langs->trans('MailToUser');
-$elementList['all'] =$langs->trans('VisibleEverywhere');
-$elementList['none']=$langs->trans('VisibleNowhere');
-
+sort($elementList);
+// Add all and none after the sort
+$elementList['all'] ='-- '.$langs->trans("All").' -- ('.$langs->trans('VisibleEverywhere').')';
+$elementList['none']='-- '.$langs->trans("None").' -- ('.$langs->trans('VisibleNowhere').')';
 
 $parameters=array('elementList'=>$elementList);
 $reshook=$hookmanager->executeHooks('emailElementlist',$parameters);    // Note that $action and $object may have been modified by some hooks
@@ -726,10 +727,10 @@ if ($resql)
         {
             $obj = $db->fetch_object($resql);
 
-            print '<tr class="oddeven" id="rowid-'.$obj->rowid.'">';
-
             if ($action == 'edit' && ($rowid == (! empty($obj->rowid)?$obj->rowid:$obj->code)))
             {
+            	print '<tr class="oddeven" id="rowid-'.$obj->rowid.'">';
+
             	$tmpaction='edit';
                 $parameters=array('fieldlist'=>$fieldlist, 'tabname'=>$tabname[$id]);
                 $reshook=$hookmanager->executeHooks('editEmailTemplateFieldlist',$parameters,$obj, $tmpaction);    // Note that $action and $object may have been modified by some hooks
@@ -787,10 +788,23 @@ if ($resql)
                         print '<td></td>';
                     }
                 }
+
+                print "</tr>\n";
             }
             else
             {
-              	$tmpaction = 'view';
+            	$keyforobj='type_template';
+            	if (! in_array($obj->$keyforobj, array_keys($elementList)))
+            	{
+            		$i++;
+            		continue;		// It means this is a type of template not into elementList (may be because enabled condition of this type is false because module is not enabled)
+            	}
+				// TODO Test on 'enabled'
+
+
+            	print '<tr class="oddeven" id="rowid-'.$obj->rowid.'">';
+
+            	$tmpaction = 'view';
                 $parameters=array('var'=>$var, 'fieldlist'=>$fieldlist, 'tabname'=>$tabname[$id]);
                 $reshook=$hookmanager->executeHooks('viewEmailTemplateFieldlist',$parameters,$obj, $tmpaction);    // Note that $action and $object may have been modified by some hooks
 
@@ -876,7 +890,6 @@ if ($resql)
                 }
                 print '</td>';
 
-
                 /*
                 $fieldsforcontent = array('content');
                 if (! empty($conf->global->MAIN_EMAIL_TEMPLATES_FOR_OBJECT_LINES))
@@ -904,8 +917,9 @@ if ($resql)
 
                     }
                 }*/
+
+                print "</tr>\n";
             }
-            print "</tr>\n";
 
 
             $i++;

+ 3 - 3
htdocs/admin/tools/dolibarr_export.php

@@ -1,6 +1,6 @@
 <?php
-/* Copyright (C) 2006-2015	Laurent Destailleur	<eldy@users.sourceforge.net>
- * Copyright (C) 2006-2012	Regis Houssin		<regis.houssin@capnetworks.com>
+/* Copyright (C) 2006-2018	Laurent Destailleur	<eldy@users.sourceforge.net>
+ * Copyright (C) 2006-2018	Regis Houssin		<regis.houssin@capnetworks.com>
  *
  * 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
@@ -36,7 +36,7 @@ $sortorder = GETPOST('sortorder','alpha');
 $page = GETPOST('page','int');
 if (! $sortorder) $sortorder="DESC";
 if (! $sortfield) $sortfield="date";
-if ($page < 0) { $page = 0; }
+if (empty($page) || $page == -1) { $page = 0; }
 $limit = GETPOST('limit')?GETPOST('limit','int'):$conf->liste_limit;
 $offset = $limit * $page;
 

+ 1 - 4
htdocs/contact/list.php

@@ -7,11 +7,8 @@
  * Copyright (C) 2013       Cédric Salvador         <csalvador@gpcsolutions.fr>
  * Copyright (C) 2013       Alexandre Spangaro      <aspangaro.dolibarr@gmail.com>
  * Copyright (C) 2015       Jean-François Ferry     <jfefe@aternatik.fr>
-<<<<<<< HEAD
- * Copyright (C) 2018       Nicolas ZABOURI          <info@inovea-conseil.com>
-=======
+ * Copyright (C) 2018       Nicolas ZABOURI         <info@inovea-conseil.com>
  * Copyright (C) 2018       Juanjo Menent			<jmenent@2byte.es>
->>>>>>> branch '7.0' of git@github.com:Dolibarr/dolibarr.git
  *
  * 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

+ 15 - 12
htdocs/core/class/commonobject.class.php

@@ -3923,23 +3923,26 @@ abstract class CommonObject
 		$var = true;
 		$i	 = 0;
 
-		foreach ($this->lines as $line)
+		if (! empty($this->lines))
 		{
-			if (is_object($hookmanager) && (($line->product_type == 9 && ! empty($line->special_code)) || ! empty($line->fk_parent_line)))
+			foreach ($this->lines as $line)
 			{
-				if (empty($line->fk_parent_line))
+				if (is_object($hookmanager) && (($line->product_type == 9 && ! empty($line->special_code)) || ! empty($line->fk_parent_line)))
 				{
-					$parameters=array('line'=>$line,'var'=>$var,'i'=>$i);
-					$action='';
-					$hookmanager->executeHooks('printOriginObjectLine',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
+					if (empty($line->fk_parent_line))
+					{
+						$parameters=array('line'=>$line,'var'=>$var,'i'=>$i);
+						$action='';
+						$hookmanager->executeHooks('printOriginObjectLine',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
+					}
+				}
+				else
+				{
+					$this->printOriginLine($line, $var, $restrictlist);
 				}
-			}
-			else
-			{
-				$this->printOriginLine($line, $var, $restrictlist);
-			}
 
-			$i++;
+				$i++;
+			}
 		}
 	}
 

+ 2 - 2
htdocs/core/class/extrafields.class.php

@@ -1028,7 +1028,7 @@ class ExtraFields
 				$out.= (((string) $value == (string) $key)?' selected':'');
 				$out.= (!empty($parent)?' parent="'.$parent.'"':'');
 				$out.='>';
-				if ($langfile) $out.=$langs->trans($val);
+				if ($langfile && $val) $out.=$langs->trans($val);
 				else $out.=$val;
 				$out.='</option>';
 			}
@@ -1492,7 +1492,7 @@ class ExtraFields
 		}
 		elseif ($type == 'select')
 		{
-			if ($langfile) $value=$langs->trans($param['options'][$value]);
+			if ($langfile && $param['options'][$value]) $value=$langs->trans($param['options'][$value]);
 			else $value=$param['options'][$value];
 		}
 		elseif ($type == 'sellist')

+ 8 - 8
htdocs/core/class/html.formticketsup.class.php

@@ -150,7 +150,7 @@ class FormTicketsup
         }
         print '<input type="hidden" name="fk_user_create" value="' . $this->fk_user_create . '">';
 
-        print '<div class="">';
+        dol_fiche_head('');
         print '<table class="tableticket centpercent">';
 
 
@@ -183,7 +183,7 @@ class FormTicketsup
                 print '<tr><td class="titlefield">' . $langs->trans("ThirdParty") . '</td><td>';
                 $events = array();
                 $events[] = array('method' => 'getContacts', 'url' => dol_buildpath('/core/ajax/contacts.php', 1), 'htmlname' => 'contactid', 'params' => array('add-customer-contact' => 'disabled'));
-                print $form->select_company($this->withfromsocid, 'socid', '', 1, 1, '', $events);
+                print $form->select_company($this->withfromsocid, 'socid', '', 1, 1, '', $events, 0, 'minwidth200');
                 print '</td></tr>';
                 if (! empty($conf->use_javascript_ajax) && ! empty($conf->global->COMPANY_USE_SEARCH_TO_SELECT)) {
                     $htmlname = 'socid';
@@ -443,7 +443,7 @@ class FormTicketsup
 
         $ticketstat->loadCacheTypesTickets();
 
-        print '<select id="select' . $htmlname . '" class="flat select_tickettype'.($morecss?' '.$morecss:'').'" name="' . $htmlname . '">';
+        print '<select id="select' . $htmlname . '" class="flat minwidth200'.($morecss?' '.$morecss:'').'" name="' . $htmlname . '">';
         if ($empty) {
             print '<option value="">&nbsp;</option>';
         }
@@ -543,7 +543,7 @@ class FormTicketsup
 
         $ticketstat->loadCacheCategoriesTickets();
 
-        print '<select id="select' . $htmlname . '" class="flat select_ticketcategory'.($morecss?' '.$morecss:'').'" name="' . $htmlname . '">';
+        print '<select id="select' . $htmlname . '" class="flat minwidth150'.($morecss?' '.$morecss:'').'" name="' . $htmlname . '">';
         if ($empty) {
             print '<option value="">&nbsp;</option>';
         }
@@ -612,7 +612,7 @@ class FormTicketsup
             print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1);
         }
 
-        print ajax_combobox('select'.$htmlname);
+        print ajax_combobox('select'.$htmlname,'',0,0,'off');
     }
 
     /**
@@ -644,7 +644,7 @@ class FormTicketsup
 
         $ticketstat->loadCacheSeveritiesTickets();
 
-        print '<select id="select' . $htmlname . '" class="flat select_ticketseverity'.($morecss?' '.$morecss:'').'" name="' . $htmlname . '">';
+        print '<select id="select' . $htmlname . '" class="flat minwidth150'.($morecss?' '.$morecss:'').'" name="' . $htmlname . '">';
         if ($empty) {
             print '<option value="">&nbsp;</option>';
         }
@@ -864,7 +864,7 @@ class FormTicketsup
             // Destinataires
             print '<tr class="email_line"><td>' . $langs->trans('MailRecipients') . '</td><td colspan="2">';
             $ticketstat = new Ticketsup($this->db);
-            $res = $ticketstat->fetch('', $this->track_id);
+            $res = $ticketstat->fetch('', '', $this->track_id);
             if ($res) {
                 // Retrieve email of all contacts (internal and external)
                 $contacts = $ticketstat->getInfosTicketInternalContact();
@@ -887,7 +887,7 @@ class FormTicketsup
                     $ticketstat->socid = $ticketstat->fk_soc;
                     $ticketstat->fetch_thirdparty();
 
-                    if (!in_array($ticketstat->thirdparty->email, $sendto)) {
+                    if (is_array($ticketstat->thirdparty->email) && !in_array($ticketstat->thirdparty->email, $sendto)) {
                         $sendto[] = $ticketstat->thirdparty->email . '(' . $langs->trans('Customer') . ')';
                     }
                 }

+ 5 - 5
htdocs/core/js/lib_foot.js.php

@@ -143,17 +143,17 @@ print '
 
 				/* Set handler to add page_y param on output (click on href links or submit button) */
 				jQuery(".reposition").click(function() {
-  	           		var page_y = $(document).scrollTop();
-					if (this.ref)
+					var page_y = $(document).scrollTop();
+					if (this.href)
 					{
-  	           			this.href=this.href+\'&page_y=\'+page_y;
-  	           			console.log("We click on tag with .reposition class. this.ref is now "+this.href);
+						this.href=this.href+\'&page_y=\'+page_y;
+						console.log("We click on tag with .reposition class. this.ref is now "+this.href);
 					}
 					else
 					{
 						console.log("We click on tag with .reposition class but element is not an <a> html tag, so we try to update form field page_y with value "+page_y);
 						jQuery("input[type=hidden][name=page_y]").val(page_y);
 					}
-		 		});
+				});
 			});'."\n";
 

+ 33 - 8
htdocs/core/modules/societe/mod_codecompta_aquarium.php

@@ -74,7 +74,9 @@ class mod_codecompta_aquarium extends ModeleAccountancyCode
 		$texte.= '<table class="nobordernopadding" width="100%">';
 		$s1= $form->textwithpicto('<input type="text" class="flat" size="4" name="value1" value="'.$conf->global->COMPANY_AQUARIUM_MASK_SUPPLIER.'">',$tooltip,1,1);
 		$s2= $form->textwithpicto('<input type="text" class="flat" size="4" name="value2" value="'.$conf->global->COMPANY_AQUARIUM_MASK_CUSTOMER.'">',$tooltip,1,1);
-		$texte.= '<tr><td>'.$langs->trans("ModuleCompanyCode".$this->name,$s1,$s2)."<br>\n";
+		$texte.= '<tr><td>';
+		$texte.=$langs->trans("ModuleCompanyCodeCustomer".$this->name,$s2)."<br>\n";
+		$texte.=$langs->trans("ModuleCompanyCodeSupplier".$this->name,$s1)."<br>\n";
 		$texte.= '</td>';
 		$texte.= '<td align="left">&nbsp; <input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button"></td>';
         $texte.= '</tr></table>';
@@ -93,7 +95,11 @@ class mod_codecompta_aquarium extends ModeleAccountancyCode
 	 */
 	function getExample($langs,$objsoc=0,$type=-1)
 	{
-	    return $this->prefixsupplieraccountancycode.'SUPPCODE'."<br>\n".$this->prefixcustomeraccountancycode.'CUSTCODE';
+		$s='';
+		$s.=$this->prefixcustomeraccountancycode.'CUSTCODE';
+	    $s.="<br>\n";
+	    $s.=$this->prefixsupplieraccountancycode.'SUPPCODE';
+	    return $s;
 	}
 
 
@@ -107,24 +113,43 @@ class mod_codecompta_aquarium extends ModeleAccountancyCode
 	 */
 	function get_code($db, $societe, $type='')
 	{
+		global $conf;
+
 		$i = 0;
 		$this->db = $db;
 
 		dol_syslog("mod_codecompta_aquarium::get_code search code for type=".$type." company=".(! empty($societe->name)?$societe->name:''));
 
 		// Regle gestion compte compta
-		$codetouse='';
 		if ($type == 'customer')
 		{
-			$codetouse = $this->prefixcustomeraccountancycode;
-			$codetouse.= (! empty($societe->code_client)?$societe->code_client:'CUSTCODE');
+			$codetouse=(! empty($societe->code_client)?$societe->code_client:'CUSTCODE');
+			$prefix = $this->prefixcustomeraccountancycode;
 		}
 		else if ($type == 'supplier')
 		{
-			$codetouse = $this->prefixsupplieraccountancycode;
-			$codetouse.= (! empty($societe->code_fournisseur)?$societe->code_fournisseur:'SUPPCODE');
+			$codetouse=(! empty($societe->code_fournisseur)?$societe->code_fournisseur:'SUPPCODE');
+			$prefix = $this->prefixsupplieraccountancycode;
 		}
-		$codetouse=strtoupper(preg_replace('/([^a-z0-9])/i','',$codetouse));
+		else
+		{
+			$this->error = 'Bad value for parameter type';
+			return -1;
+		}
+
+		//$conf->global->COMPANY_AQUARIUM_CLEAN_REGEX='^..(..)..';
+
+		// Remove special char if COMPANY_AQUARIUM_REMOVE_SPECIAL is set to 1 or not set (default)
+		if (! isset($conf->global->COMPANY_AQUARIUM_REMOVE_SPECIAL) || ! empty($conf->global->COMPANY_AQUARIUM_REMOVE_SPECIAL)) $codetouse=preg_replace('/([^a-z0-9])/i','',$codetouse);
+		// Remove special alpha if COMPANY_AQUARIUM_REMOVE_ALPHA is set to 1
+		if (! empty($conf->global->COMPANY_AQUARIUM_REMOVE_ALPHA))   $codetouse=preg_replace('/([a-z])/i','',$codetouse);
+		// Apply a regex replacement pattern if COMPANY_AQUARIUM_REMOVE_ALPHA is set to 1
+		if (! empty($conf->global->COMPANY_AQUARIUM_CLEAN_REGEX))	// Example: $conf->global->COMPANY_AQUARIUM_CLEAN_REGEX='^..(..)..';
+		{
+			$codetouse=preg_replace('/'.$conf->global->COMPANY_AQUARIUM_CLEAN_REGEX.'/','\1\2\3',$codetouse);
+		}
+
+		$codetouse=$prefix.strtoupper($codetouse);
 
 		$is_dispo = $this->verif($db, $codetouse, $societe, $type);
 		if (! $is_dispo)

+ 1 - 1
htdocs/core/tpl/extrafields_view.tpl.php

@@ -113,7 +113,7 @@ if (empty($reshook) && is_array($extrafields->attributes[$object->table_element]
 			{
 			    $fieldid='id';
 			    if ($object->table_element == 'societe') $fieldid='socid';
-				print '<td align="right"><a href="' . $_SERVER['PHP_SELF'] . '?'.$fieldid.'=' . $object->id . '&action=edit_extras&attribute=' . $key . '">' . img_edit().'</a></td>';
+				print '<td align="right"><a class="reposition" href="' . $_SERVER['PHP_SELF'] . '?'.$fieldid.'=' . $object->id . '&action=edit_extras&attribute=' . $key . '">' . img_edit().'</a></td>';
 			}
 			print '</tr></table>';
 			$html_id = !empty($object->id) ? $object->element.'_extras_'.$key.'_'.$object->id : '';

+ 15 - 14
htdocs/langs/en_US/admin.lang

@@ -446,7 +446,8 @@ DisplayCompanyInfo=Display company address
 DisplayCompanyManagers=Display manager names
 DisplayCompanyInfoAndManagers=Display company address and manager names
 EnableAndSetupModuleCron=If you want to have this recurring invoice beeing generated automatically, module *%s* must be enabled and correctly setup. Otherwise, generation of invoices must be done manually from this template with button *Create*. Note that even if you enabled automatic generation, you can still safely launch manual generation. Duplicates generation for same period are not possible. 
-ModuleCompanyCodeAquarium=Return an accounting code built by:<br>%s followed by third party supplier code for a supplier accounting code,<br>%s followed by third party customer code for a customer accounting code.
+ModuleCompanyCodeCustomerAquarium=%s followed by third party customer code for a customer accounting code
+ModuleCompanyCodeSupplierAquarium=%s followed by third party supplier code for a supplier accounting code
 ModuleCompanyCodePanicum=Return an empty accounting code.
 ModuleCompanyCodeDigitaria=Accounting code depends on third party code. The code is composed of the character "C" in the first position followed by the first 5 characters of the third party code.  
 Use3StepsApproval=By default, Purchase Orders need to be created and approved by 2 different users (one step/user to create and one step/user to approve. Note that if user has both permission to create and approve, one step/user will be enough). You can ask with this option to introduce a third step/user approval, if amount is higher than a dedicated value (so 3 steps will be necessary: 1=validation, 2=first approval and 3=second approval if amount is enough).<br>Set this to empty if one approval (2 steps) is enough, set it to a very low value (0.1) if a second approval (3 steps) is always required.  
@@ -1721,19 +1722,19 @@ FillFixTZOnlyIfRequired=Example: +2 (fill only if problem experienced)
 ExpectedChecksum=Expected Checksum
 CurrentChecksum=Current Checksum
 ForcedConstants=Required constant values
-MailToSendProposal=To send customer proposal
-MailToSendOrder=To send customer order
-MailToSendInvoice=To send customer invoice
-MailToSendShipment=To send shipment
-MailToSendIntervention=To send intervention
-MailToSendSupplierRequestForQuotation=To send quotation request to supplier
-MailToSendSupplierOrder=To send supplier order
-MailToSendSupplierInvoice=To send supplier invoice
-MailToSendContract=To send a contract
-MailToThirdparty=To send email from third party page
-MailToMember=To send email from member page
-MailToUser=To send email from user page
-MailToProject= To send email from project page
+MailToSendProposal=Customer proposals
+MailToSendOrder=Customer orders
+MailToSendInvoice=Customer invoices
+MailToSendShipment=Shipments
+MailToSendIntervention=Interventions
+MailToSendSupplierRequestForQuotation=Supplier quotations
+MailToSendSupplierOrder=Supplier orders
+MailToSendSupplierInvoice=Supplier invoices
+MailToSendContract=Contracts
+MailToThirdparty=Third parties
+MailToMember=Members
+MailToUser=Users
+MailToProject=Projects page
 ByDefaultInList=Show by default on list view
 YouUseLastStableVersion=You use the latest stable version
 TitleExampleForMajorRelease=Example of message you can use to announce this major release (feel free to use it on your web sites)

+ 3 - 6
htdocs/public/ticketsup/create_ticket.php

@@ -75,7 +75,7 @@ $extralabels = $extrafields->fetch_name_optionals_label($object->table_element);
 
 // Add file in email form
 if (GETPOST('addfile') && !GETPOST('add_ticket')) {
-    ////$res = $object->fetch('',GETPOST('track_id'));
+    ////$res = $object->fetch('','',GETPOST('track_id'));
     ////if($res > 0)
     ////{
     include_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php';
@@ -93,9 +93,7 @@ if (GETPOST('addfile') && !GETPOST('add_ticket')) {
 
 // Remove file
 if (GETPOST('removedfile') && !GETPOST('add_ticket')) {
-    ////$res = $object->fetch('',GETPOST('track_id'));
-    ////if($res > 0)
-    ////{
+
     include_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php';
 
     // Set tmp directory
@@ -103,9 +101,8 @@ if (GETPOST('removedfile') && !GETPOST('add_ticket')) {
     $upload_dir_tmp = $vardir . '/temp';
 
     // TODO Delete only files that was uploaded from email form
-    dol_remove_file_process($_POST['removedfile'], 0);
+    dol_remove_file_process($_POST['removedfile'], 0, 0);
     $action = 'create_ticket';
-    ////}
 }
 if ($action == 'create_ticket' && GETPOST('add_ticket')) {
     $error = 0;

+ 32 - 24
htdocs/public/ticketsup/list.php

@@ -60,6 +60,13 @@ if (isset($_SESSION['email_customer'])) {
 
 $object = new ActionsTicketsup($db);
 
+
+
+
+/*
+ * Actions
+ */
+
 if ($action == "view_ticketlist") {
     $error = 0;
     $display_ticket_list = false;
@@ -82,7 +89,8 @@ if ($action == "view_ticketlist") {
     }
 
     if (!$error) {
-        $ret = $object->fetch('', $track_id);
+    	$ret = $object->fetch('', '', $track_id);
+
         if ($ret && $object->dao->id > 0) {
             // vérifie si l'adresse email est bien dans les contacts du ticket
             $contacts = $object->dao->liste_contact(-1, 'external');
@@ -118,6 +126,7 @@ if ($action == "view_ticketlist") {
         $action = '';
     }
 }
+
 $object->doActions($action);
 
 
@@ -143,11 +152,13 @@ if (!$conf->global->TICKETS_ENABLE_PUBLIC_INTERFACE) {
 
 print '<div style="margin: 0 auto; width:60%">';
 
-if ($action == "view_ticketlist") {
+if ($action == "view_ticketlist")
+{
+
     if ($display_ticket_list) {
         // Filters
         $search_fk_status = GETPOST("search_fk_status", 'alpha');
-        $search_subject = GETPOST("search_subject");
+        $search_subject = GETPOST("search_subject", 'alpha');
         $search_type = GETPOST("search_type", 'alpha');
         $search_category = GETPOST("search_category", 'alpha');
         $search_severity = GETPOST("search_severity", 'alpha');
@@ -263,15 +274,13 @@ if ($action == "view_ticketlist") {
         $limit = $conf->liste_limit;
 
         $page = GETPOST("page", 'int');
-        if ($page == -1) {
-            $page = 0;
-        }
+        if (empty($page) || $page == -1) { $page = 0; }     // If $page is not defined, or '' or -1
         $offset = $limit * $page;
         $pageprev = $page - 1;
         $pagenext = $page + 1;
 
         // Request SQL
-        $sql = "SELECT";
+        $sql = "SELECT DISTINCT";
         $sql .= " t.rowid,";
         $sql .= " t.ref,";
         $sql .= " t.track_id,";
@@ -313,12 +322,12 @@ if ($action == "view_ticketlist") {
             $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "ticketsup_extrafields as ef on (t.rowid = ef.fk_object)";
         }
         $sql .= " WHERE t.entity IN (" . getEntity('ticketsup') . ")";
-        $sql .= " AND tc.source = 'external'";
-        $sql .= " AND tc.element='" . $object->dao->element . "'";
-        $sql .= " AND tc.active=1";
-        $sql .= " AND (sp.email='" . $db->escape($_SESSION['email_customer']) . "'";
+        $sql .= " AND ((tc.source = 'external'";
+        $sql .= " AND tc.element='" . $db->escape($object->dao->element) . "'";
+        $sql .= " AND tc.active=1)";
+        $sql .= " OR (sp.email='" . $db->escape($_SESSION['email_customer']) . "'";
         $sql .= " OR s.email='" . $db->escape($_SESSION['email_customer']) . "'";
-        $sql .= " OR t.origin_email='" . $db->escape($_SESSION['email_customer']) . "')";
+        $sql .= " OR t.origin_email='" . $db->escape($_SESSION['email_customer']) . "'))";
         // Manage filter
         if (!empty($filter)) {
             foreach ($filter as $key => $value) {
@@ -337,7 +346,7 @@ if ($action == "view_ticketlist") {
                 }
             }
         }
-        $sql .= " GROUP BY t.track_id";
+        //$sql .= " GROUP BY t.track_id";
         $sql .= " ORDER BY " . $sortfield . ' ' . $sortorder;
 
         $resql = $db->query($sql);
@@ -442,9 +451,9 @@ if ($action == "view_ticketlist") {
 
                 // Status
                 if (!empty($arrayfields['t.fk_statut']['checked'])) {
-                    print '<td>';
+                    print '<td class="liste_titre">';
                     $selected = ($search_fk_status != "non_closed" ? $search_fk_status : '');
-                    $object->printSelectStatus($selected);
+                    //$object->printSelectStatus($selected);
                     print '</td>';
                 }
 
@@ -497,16 +506,15 @@ if ($action == "view_ticketlist") {
                     }
                 }
 
-                print '<td class="liste_titre" align="right">';
+                print '<td class="liste_titre nowraponall" align="right">';
                 print '<input type="image" class="liste_titre" name="button_search" src="' . img_picto($langs->trans("Search"), 'search.png', '', '', 1) . '" value="' . dol_escape_htmltag($langs->trans("Search")) . '" title="' . dol_escape_htmltag($langs->trans("Search")) . '">';
                 print '<input type="image" class="liste_titre" name="button_removefilter" src="' . img_picto($langs->trans("Search"), 'searchclear.png', '', '', 1) . '" value="' . dol_escape_htmltag($langs->trans("RemoveFilter")) . '" title="' . dol_escape_htmltag($langs->trans("RemoveFilter")) . '">';
                 print '</td>';
                 print '</tr>';
 
-                $var = true;
-                while ($obj = $db->fetch_object($resql)) {
-                    $var = !$var;
-                    print "<tr " . $bc[$var] . ">";
+                while ($obj = $db->fetch_object($resql))
+                {
+                    print '<tr class="oddeven">';
 
                     // Date ticket
                     if (!empty($arrayfields['t.datec']['checked'])) {
@@ -582,11 +590,11 @@ if ($action == "view_ticketlist") {
                     // Message author
                     if (!empty($arrayfields['t.fk_user_create']['checked'])) {
                         print '<td>';
-                        if ($obj->fk_user_create) {
+                        if ($obj->fk_user_create > 0) {
                             $user_create->firstname = (!empty($obj->user_create_firstname) ? $obj->user_create_firstname : '');
                             $user_create->name = (!empty($obj->user_create_lastname) ? $obj->user_create_lastname : '');
                             $user_create->id = (!empty($obj->fk_user_create) ? $obj->fk_user_create : '');
-                            print $user_create->getFullName();
+                            print $user_create->getFullName($langs);
                         } else {
                             print $langs->trans('Email');
                         }
@@ -596,11 +604,11 @@ if ($action == "view_ticketlist") {
                     // Assigned author
                     if (!empty($arrayfields['t.fk_user_assign']['checked'])) {
                         print '<td>';
-                        if ($obj->fk_user_assign) {
+                        if ($obj->fk_user_assig > 0) {
                             $user_assign->firstname = (!empty($obj->user_assign_firstname) ? $obj->user_assign_firstname : '');
                             $user_assign->lastname = (!empty($obj->user_assign_lastname) ? $obj->user_assign_lastname : '');
                             $user_assign->id = (!empty($obj->fk_user_assign) ? $obj->fk_user_assign : '');
-                            print $user_assign->getFullName();
+                            print $user_assign->getFullName($langs);
                         } else {
                             print $langs->trans('None');
                         }

+ 17 - 12
htdocs/public/ticketsup/view.php

@@ -40,9 +40,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formticketsup.class.php';
 require_once DOL_DOCUMENT_ROOT.'/core/lib/ticketsup.lib.php';
 
 // Load traductions files requiredby by page
-$langs->load("companies");
-$langs->load("other");
-$langs->load("ticketsup");
+$langs->loadLangs(array("companies","other","ticketsup"));
 
 // Get parameters
 $track_id = GETPOST('track_id', 'alpha');
@@ -58,6 +56,11 @@ if (isset($_SESSION['email_customer'])) {
 
 $object = new ActionsTicketsup($db);
 
+
+/*
+ * Actions
+ */
+
 if ($action == "view_ticket" || $action == "add_message" || $action == "close" || $action == "confirm_public_close" || $action == "new_public_message") {
     $error = 0;
     $display_ticket = false;
@@ -80,7 +83,7 @@ if ($action == "view_ticket" || $action == "add_message" || $action == "close" |
     }
 
     if (!$error) {
-        $ret = $object->fetch('', $track_id);
+        $ret = $object->fetch('', '', $track_id);
         if ($ret && $object->dao->id > 0) {
             // vérifie si l'adresse email est bien dans les contacts du ticket
             $contacts = $object->dao->liste_contact(-1, 'external');
@@ -116,16 +119,18 @@ if ($action == "view_ticket" || $action == "add_message" || $action == "close" |
 }
 $object->doActions($action);
 
-/***************************************************
- * VIEW
- *
- ****************************************************/
+
+
+/*
+ * View
+ */
 
 $form = new Form($db);
 $formticket = new FormTicketsup($db);
 
 $arrayofjs = array();
 $arrayofcss = array('/ticketsup/css/styles.css.php');
+
 llxHeaderTicket($langs->trans("Tickets"), "", 0, 0, $arrayofjs, $arrayofcss);
 
 if (!$conf->global->TICKETS_ENABLE_PUBLIC_INTERFACE) {
@@ -151,17 +156,17 @@ if ($action == "view_ticket" || $action == "add_message" || $action == "close" |
         print '<table class="border" style="width:100%">';
 
         // Ref
-        print '<tr><td style="width:40%">' . $langs->trans("Ref") . '</td><td>';
+        print '<tr><td class="titlefield">' . $langs->trans("Ref") . '</td><td>';
         print $object->dao->ref;
         print '</td></tr>';
 
         // Tracking ID
-        print '<tr><td style="width:40%">' . $langs->trans("TicketTrackId") . '</td><td>';
+        print '<tr><td>' . $langs->trans("TicketTrackId") . '</td><td>';
         print $object->dao->track_id;
         print '</td></tr>';
 
         // Subject
-        print '<tr><td><strong>' . $langs->trans("Subject") . '</strong></td><td>';
+        print '<tr><td>' . $langs->trans("Subject") . '</td><td>';
         print $object->dao->subject;
         print '</td></tr>';
 
@@ -218,7 +223,7 @@ if ($action == "view_ticket" || $action == "add_message" || $action == "close" |
         }
 
         // User assigned
-        print '<tr><td>' . $langs->trans("UserAssignedTo") . '</td><td>';
+        print '<tr><td>' . $langs->trans("AssignedTo") . '</td><td>';
         if ($object->dao->fk_user_assign > 0) {
             $fuser = new User($db);
             $fuser->fetch($object->dao->fk_user_assign);

+ 7 - 4
htdocs/ticketsup/card.php

@@ -134,7 +134,10 @@ include DOL_DOCUMENT_ROOT.'/core/actions_dellink.inc.php';        // Must be inc
 $userstat = new User($db);
 $form = new Form($db);
 $formticket = new FormTicketsup($db);
-$formproject = new FormProjets($db);
+
+if (! empty($conf->projet->enabled)) {
+	$formproject = new FormProjets($db);
+}
 
 if ($action == 'view' || $action == 'add_message' || $action == 'close' || $action == 'delete' || $action == 'editcustomer' || $action == 'progression' || $action == 'reopen'
 	|| $action == 'editsubject' || $action == 'edit_extras' || $action == 'update_extras' || $action == 'edit_extrafields' || $action == 'set_extrafields' || $action == 'classify' || $action == 'sel_contract' || $action == 'edit_message_init' || $action == 'set_status' || $action == 'dellink')
@@ -631,15 +634,15 @@ if ($action == 'view' || $action == 'add_message' || $action == 'close' || $acti
 
 	                print '<div class="tagtd">';
 
-	                print dol_print_phone($tab[$i]['phone'], '', '', '', AC_TEL).'<br>';
+	                print dol_print_phone($tab[$i]['phone'], '', '', '', 'AC_TEL').'<br>';
 
 	                if (! empty($tab[$i]['phone_perso'])) {
 	                    //print img_picto($langs->trans('PhonePerso'),'object_phoning.png','',0,0,0).' ';
-	                    print '<br>'.dol_print_phone($tab[$i]['phone_perso'], '', '', '', AC_TEL).'<br>';
+	                    print '<br>'.dol_print_phone($tab[$i]['phone_perso'], '', '', '', 'AC_TEL').'<br>';
 	                }
 	                if (! empty($tab[$i]['phone_mobile'])) {
 	                    //print img_picto($langs->trans('PhoneMobile'),'object_phoning.png','',0,0,0).' ';
-	                    print dol_print_phone($tab[$i]['phone_mobile'], '', '', '', AC_TEL).'<br>';
+	                    print dol_print_phone($tab[$i]['phone_mobile'], '', '', '', 'AC_TEL').'<br>';
 	                }
 	                print '</div>';
 

+ 2 - 2
htdocs/ticketsup/class/ticketsup.class.php

@@ -1639,7 +1639,7 @@ class Ticketsup extends CommonObject
     {
         global $langs;
 
-        if (count($this->cache_logs_ticket)) {
+        if (is_array($this->cache_logs_ticket) && count($this->cache_logs_ticket)) {
             return 0;
         }
         // Cache deja charge
@@ -1751,7 +1751,7 @@ class Ticketsup extends CommonObject
     {
         global $langs;
 
-        if (count($this->cache_msgs_ticket)) {
+        if (is_array($this->cache_msgs_ticket) && count($this->cache_msgs_ticket)) {
             return 0;
         }
         // Cache deja charge

+ 8 - 6
htdocs/ticketsup/list.php

@@ -1,6 +1,7 @@
 <?php
-/* Copyright (C) 2013-2018    Jean-François FERRY <hello@librethic.io>
- * Copyright (C) 2016         Christophe Battarel <christophe@altairis.fr>
+/* Copyright (C) 2013-2018	Jean-François FERRY	<hello@librethic.io>
+ * Copyright (C) 2016		Christophe Battarel	<christophe@altairis.fr>
+ * Copyright (C) 2018		Regis Houssin		<regis.houssin@capnetworks.com>
  *
  * 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
@@ -580,12 +581,13 @@ print '</tr>'."\n";
 
 // Detect if we need a fetch on each output line
 $needToFetchEachLine=0;
-foreach ($extrafields->attributes[$object->table_element]['computed'] as $key => $val)
-{
-	if (preg_match('/\$object/',$val)) $needToFetchEachLine++;  // There is at least one compute field that use $object
+if (! empty($extrafields->attributes[$object->table_element]['computed'])) {
+	foreach ($extrafields->attributes[$object->table_element]['computed'] as $key => $val)
+	{
+		if (preg_match('/\$object/',$val)) $needToFetchEachLine++;  // There is at least one compute field that use $object
+	}
 }
 
-
 // Loop on record
 // --------------------------------------------------------------------
 $i=0;