diff --git a/htdocs/accountancy/customer/lines.php b/htdocs/accountancy/customer/lines.php index 2bbb839459f..d00296ed2b9 100644 --- a/htdocs/accountancy/customer/lines.php +++ b/htdocs/accountancy/customer/lines.php @@ -1,7 +1,7 @@ * Copyright (C) 2013-2015 Alexandre Spangaro - * Copyright (C) 2014 Ari Elbaz (elarifr) + * Copyright (C) 2014-2015 Ari Elbaz (elarifr) * Copyright (C) 2014 Florian Henry * Copyright (C) 2014 Juanjo Menent * @@ -39,7 +39,7 @@ $langs->load("accountancy"); $account_parent = GETPOST('account_parent'); $changeaccount = GETPOST('changeaccount'); $search_ref = GETPOST('search_ref','alpha'); -$search_facture = GETPOST('search_facture','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'); @@ -49,13 +49,37 @@ $sortfield = GETPOST('sortfield','alpha'); $sortorder = GETPOST('sortorder','alpha'); $page = GETPOST('page','int'); -if ($page == -1) { $page = 0; } -$offset = $conf->liste_limit * $page; +//if ($page == -1) { $page = 0; } +if ($page < 0) $page = 0; + $pageprev = $page - 1; $pagenext = $page + 1; -$limit = $conf->liste_limit; -if (! $sortfield) $sortfield="f.facnumber"; -if (! $sortorder) $sortorder="DESC"; +//$limit = $conf->liste_limit; +if (! empty($conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION)) { + $limit = $conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION; +} else if ($conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION <= 0) { + $limit = $conf->liste_limit; +} else { + $limit = $conf->liste_limit; +} +//$offset = $conf->liste_limit * $page; +$offset = $limit * $page; + +// TODO : remove comment +//elarifr we can not use only +//$sql .= " ORDER BY l.rowid"; +// f.datef will order like FA08 FA09 FA10 FA05 FA06 FA07 FA04... +// f.facnumber will not order properly invoice / avoir / accompte you can have All AC then All AV and all FA +// l.rowid when an invoice is edited rowid are added at end of table & facturedet.rowid are not ordered +//if (! $sortfield) $sortfield="f.facnumber"; +if (! $sortfield) $sortfield="f.datef, f.facnumber, l.rowid"; + +//if (! $sortorder) $sortorder="DESC"; +if (! $sortorder) { + if ($conf->global->ACCOUNTING_LIST_SORT_VENTILATION_DONE > 0) { + $sortorder = " DESC "; + } +} // Security check if ($user->societe_id > 0) @@ -69,7 +93,7 @@ $formventilation = new FormVentilation($db); if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter")) // Both test are required to be compatible with all browsers { $search_ref=''; - $search_facture=''; + $search_invoice=''; $search_label=''; $search_desc=''; $search_amount=''; @@ -106,6 +130,31 @@ if (is_array($changeaccount) && count($changeaccount) > 0) { llxHeader('', $langs->trans("CustomersVentilation") . ' - ' . $langs->trans("Dispatched")); +print ''; + +/* + * Action + */ + + +/* + * Customer Invoice lines + */ $sql = "SELECT l.rowid , f.facnumber, f.rowid as facid, l.fk_product, l.description, l.total_ht, l.qty, l.tva_tx, l.fk_code_ventilation, 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"; $sql .= " FROM " . MAIN_DB_PREFIX . "facture as f"; @@ -114,8 +163,8 @@ $sql .= " , " . MAIN_DB_PREFIX . "facturedet as l"; $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "product as p ON p.rowid = l.fk_product"; $sql .= " WHERE f.rowid = l.fk_facture AND f.fk_statut >= 1 AND l.fk_code_ventilation <> 0 "; $sql .= " AND aa.rowid = l.fk_code_ventilation"; -if (strlen(trim(GETPOST("search_facture")))) { - $sql .= " AND f.facnumber like '%" . $search_facture . "%'"; +if (strlen(trim($search_invoice))) { + $sql .= " AND f.facnumber like '%" . $search_invoice . "%'"; } if (strlen(trim($search_ref))) { $sql .= " AND p.ref like '%" . $search_ref . "%'"; @@ -151,7 +200,7 @@ if ($result) { print '
'; print ''; - print '

' . $langs->trans("ChangeAccount") . '
'; + print '
' . $langs->trans("ChangeAccount") . '
'; print $formventilation->select_account($account_parent, 'account_parent', 1); print '
'; @@ -164,10 +213,11 @@ if ($result) { print_liste_field_titre($langs->trans("Account"), $_SERVER["PHP_SELF"],"aa.account_number","",$param,'align="center"',$sortfield,$sortorder); print_liste_field_titre(''); print_liste_field_titre(''); - print_liste_field_titre(''); + print_liste_field_titre($langs->trans("Ventilate").'
/','','','','','align="center"'); print "\n"; - - print '
'; + + print ''; + print ''; print ''; print ''; print ''; @@ -188,12 +238,12 @@ if ($result) { print ""; - // Ref facture + // Ref Invoice $facture_static->ref = $objp->facnumber; $facture_static->id = $objp->facid; print ''; - // Ref produit + // Ref Product $product_static->ref = $objp->product_ref; $product_static->id = $objp->product_id; $product_static->type = $objp->type; @@ -208,8 +258,8 @@ if ($result) { print ''; print ''; print ''; - print ''; - print ''; + print ''; diff --git a/htdocs/accountancy/supplier/lines.php b/htdocs/accountancy/supplier/lines.php index 917ee15f1d4..80f7bc5e6ee 100644 --- a/htdocs/accountancy/supplier/lines.php +++ b/htdocs/accountancy/supplier/lines.php @@ -1,7 +1,7 @@ * Copyright (C) 2013-2015 Alexandre Spangaro - * Copyright (C) 2014 Ari Elbaz (elarifr) + * Copyright (C) 2014-2015 Ari Elbaz (elarifr) * Copyright (C) 2013-2014 Florian Henry * Copyright (C) 2014 Juanjo Menent * @@ -40,7 +40,7 @@ $langs->load("accountancy"); $account_parent = GETPOST('account_parent'); $changeaccount = GETPOST('changeaccount'); $search_ref = GETPOST('search_ref','alpha'); -$search_facture = GETPOST('search_facture','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'); @@ -70,7 +70,7 @@ $formventilation = new FormVentilation($db); if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter")) // Both test are required to be compatible with all browsers { $search_ref=''; - $search_facture=''; + $search_invoice=''; $search_label=''; $search_desc=''; $search_amount=''; @@ -107,6 +107,30 @@ if (is_array($changeaccount) && count($changeaccount) > 0) { llxHeader('', $langs->trans("SuppliersVentilation") . ' - ' . $langs->trans("Dispatched")); +print ''; + +/* + * Action + */ + +/* + * Supplier Invoice lines + */ $sql = "SELECT f.ref as facnumber, f.rowid as facid, l.fk_product, l.description, l.total_ht , l.qty, l.rowid, l.tva_tx, 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"; $sql .= " FROM " . MAIN_DB_PREFIX . "facture_fourn as f"; @@ -115,8 +139,8 @@ $sql .= " , " . MAIN_DB_PREFIX . "facture_fourn_det as l"; $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "product as p ON p.rowid = l.fk_product"; $sql .= " WHERE f.rowid = l.fk_facture_fourn and f.fk_statut >= 1 AND l.fk_code_ventilation <> 0 "; $sql .= " AND aa.rowid = l.fk_code_ventilation"; -if (strlen(trim($search_facture))) { - $sql .= " AND f.ref like '%" . $search_facture . "%'"; +if (strlen(trim($search_invoice))) { + $sql .= " AND f.ref like '%" . $search_invoice . "%'"; } if (strlen(trim($search_ref))) { $sql .= " AND p.ref like '%" . $search_ref . "%'"; @@ -150,10 +174,10 @@ if ($result) { print ''; - print ''; + print ''; print '
' . $facture_static->getNomUrl(1) . '' . nl2br(dol_trunc($objp->description, 32)) . '' . price($objp->total_ht) . '' . $codecompta . '' . $objp->rowid . ''; + print '' . $objp->rowid . ''; print img_edit(); print '' . $langs->trans("DescVentilDoneSupplier") . '
'; - print '

'. $langs->trans("ChangeAccount") . '
'; + print '
'. $langs->trans("ChangeAccount") . '
'; print $formventilation->select_account(GETPOST('account_parent'), 'account_parent', 1); print '
'; @@ -166,10 +190,10 @@ if ($result) { print_liste_field_titre($langs->trans("Account"), $_SERVER["PHP_SELF"],"aa.account_number","",$param,'align="center"',$sortfield,$sortorder); print_liste_field_titre(''); print_liste_field_titre(''); - print_liste_field_titre(''); + print_liste_field_titre($langs->trans("Ventilate").'
/','','','','','align="center"'); print "\n"; - print '
'; + print ''; print ''; print ''; print ''; @@ -211,8 +235,8 @@ if ($result) { print ''; print ''; print ''; - print ''; - print ''; + print '';
' . nl2br(dol_trunc($objp->description, 32)) . '' . price($objp->total_ht) . '' . $codeCompta . '' . $objp->rowid . ''; + print '' . $objp->rowid . ''; print img_edit(); print '