From d286c1814842f472c4b27ad21e1acfe776ef0fc4 Mon Sep 17 00:00:00 2001 From: aspangaro Date: Thu, 9 Jul 2015 07:11:08 +0200 Subject: [PATCH 1/5] Update lines.php with elarifr modification --- htdocs/accountancy/customer/lines.php | 86 +++++++++++++++++++++------ htdocs/accountancy/supplier/lines.php | 46 ++++++++++---- 2 files changed, 103 insertions(+), 29 deletions(-) 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 ''; From 0b19f2e06861e8048f278861a5425909803dc543 Mon Sep 17 00:00:00 2001 From: aspangaro Date: Thu, 9 Jul 2015 07:46:58 +0200 Subject: [PATCH 2/5] Update list.php with elarifr modification --- htdocs/accountancy/customer/list.php | 221 +++++++++++++++++++++------ htdocs/accountancy/supplier/list.php | 172 ++++++++++++++++----- 2 files changed, 310 insertions(+), 83 deletions(-) diff --git a/htdocs/accountancy/customer/list.php b/htdocs/accountancy/customer/list.php index ac1c3429658..eb6446ae13d 100644 --- a/htdocs/accountancy/customer/list.php +++ b/htdocs/accountancy/customer/list.php @@ -1,7 +1,7 @@ - * Copyright (C) 2013-2014 Alexandre Spangaro - * Copyright (C) 2014 Ari Elbaz (elarifr) + * Copyright (C) 2013-2015 Alexandre Spangaro + * Copyright (C) 2014-2015 Ari Elbaz (elarifr) * Copyright (C) 2013-2014 Florian Henry * Copyright (C) 2014 Juanjo Menent * @@ -31,16 +31,52 @@ require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; require_once DOL_DOCUMENT_ROOT.'/accountancy/class/html.formventilation.class.php'; +require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingaccount.class.php'; // Langs $langs->load("compta"); $langs->load("bills"); +$langs->load("other"); $langs->load("main"); $langs->load("accountancy"); $action = GETPOST('action'); $codeventil = GETPOST('codeventil', 'array'); $mesCasesCochees = GETPOST('mesCasesCochees', 'array'); +$search_ref = GETPOST('search_ref','alpha'); +$search_label = GETPOST('search_label','alpha'); +$search_desc = GETPOST('search_desc','alpha'); + +$sortfield = GETPOST('sortfield','alpha'); +$sortorder = GETPOST('sortorder','alpha'); +//Should move to top with all GETPOST +$page = GETPOST('page'); +if ($page < 0) $page = 0; + +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 = $limit * $page; +//End Should move to top with all GETPOST + +// 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="l.rowid"; +if (! $sortfield) $sortfield="f.datef, f.facnumber, l.rowid"; +//if (! $sortorder) $sortorder="DESC"; +if (! $sortorder) { + if ($conf->global->ACCOUNTING_LIST_SORT_VENTILATION_TODO > 0) { + $sortorder = " DESC "; + } +} // Security check if ($user->societe_id > 0) @@ -50,8 +86,31 @@ if (! $user->rights->accounting->ventilation->dispatch) $formventilation = new FormVentilation($db); +//Defaut AccountingAccount RowId Product / Service +//at this time ACCOUNTING_SERVICE_SOLD_ACCOUNT & ACCOUNTING_PRODUCT_SOLD_ACCOUNT are account number not accountingacount rowid +//so we need to get those default value rowid first +$accounting = new AccountingAccount($db); +//TODO: we should need to check if result is a really exist accountaccount rowid..... +$aarowid_s = $accounting->fetch('', ACCOUNTING_SERVICE_SOLD_ACCOUNT); +$aarowid_p = $accounting->fetch('', ACCOUNTING_PRODUCT_SOLD_ACCOUNT); + +// Purge search criteria +if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter")) // Both test are required to be compatible with all browsers +{ + $search_ref=''; + $search_label=''; + $search_desc=''; +} +/* + * View + */ + llxHeader('', $langs->trans("Ventilation")); +//debug +//print_r($aarowid_s); +//print_r($aarowid_p); + print ''; + /* * Action */ @@ -123,7 +183,13 @@ $offset = $limit * $page; $sql = "SELECT f.facnumber, f.rowid as facid, l.fk_product, l.description, l.total_ht, l.rowid, l.fk_code_ventilation,"; $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"; +// A REVOIR elarifr si vraiment necessaire de rajouter , p.fk_product_type as type. le type produit / service est de facto defini pour chaque ligne de facturedet.product_type +// il est donc plus logique de se servir de l.product_type au lieu de p.fk_product_type $sql .= " , aa.rowid as aarowid"; +// we need f.datef to reorder lines +$sql .= " , f.datef"; +// we need to use llx_facturedet l.product_type as used at the time on invoice. if llx_product fk_product_type is changed later it could not change the sell already made ! +$sql .= " , l.product_type as type_l"; $sql .= " FROM " . MAIN_DB_PREFIX . "facture as f"; $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"; @@ -131,14 +197,27 @@ $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accountingaccount as aa ON p.accountan $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_system as accsys ON accsys.pcg_version = aa.fk_pcg_version"; $sql .= " WHERE f.fk_statut > 0 AND fk_code_ventilation <= 0"; $sql .= " AND (accsys.rowid='" . $conf->global->CHARTOFACCOUNTS . "' OR p.accountancy_code_sell IS NULL OR p.accountancy_code_sell ='')"; +// Add search filter like +if (strlen(trim($search_ref))) { + $sql .= " AND (p.ref like '%" . $search_ref . "%')"; +} +if (strlen(trim($search_label))) { + $sql .= " AND (p.label like '%" . $search_label . "%')"; +} +if (strlen(trim($search_desc))) { + $sql .= " AND (l.description like '%" . $search_desc . "%')"; +} if (! empty($conf->multicompany->enabled)) { $sql .= " AND f.entity IN (" . getEntity("facture", 1) . ")"; } +//TODO: Remove comment +//replaced by default value $sortfield,$sortorder +//$sql .= " ORDER BY l.rowid"; +//if ($conf->global->ACCOUNTING_LIST_SORT_VENTILATION_TODO > 0) { +// $sql .= " DESC "; +//} +$sql.= $db->order($sortfield,$sortorder); -$sql .= " ORDER BY l.rowid"; -if ($conf->global->ACCOUNTING_LIST_SORT_VENTILATION_TODO > 0) { - $sql .= " DESC "; -} $sql .= $db->plimit($limit + 1, $offset); dol_syslog("/accountancy/customer/list.php sql=" . $sql, LOG_DEBUG); @@ -156,58 +235,96 @@ if ($result) { print ''; print '
' . nl2br(dol_trunc($objp->description, 32)) . '' . price($objp->total_ht) . '' . $codeCompta . '' . $objp->rowid . ''; + print '' . $objp->rowid . ''; print img_edit(); print '
'; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; + print ''; + print_liste_field_titre($langs->trans("Invoice"), $_SERVER["PHP_SELF"],"f.facnumber","",$param,'',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("Ref"), $_SERVER["PHP_SELF"],"p.ref","",$param,'',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("Label"), $_SERVER["PHP_SELF"],"p.label","",$param,'',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("Description"), $_SERVER["PHP_SELF"],"l.description","",$param,'',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("Amount"),'','','','','align="right"'); + print_liste_field_titre($langs->trans("AccountAccounting"),'','','','','align="center"'); + print_liste_field_titre($langs->trans("IntoAccount"),'','','','','align="center"'); + print_liste_field_titre(''); + print_liste_field_titre($langs->trans("Ventilate") . '
/','','','','','align="center"'); print ''; +// We add search filter +/* But Hit Enter will validate ventilation.... + print ''; + print ''; + print ''; + print ''; + print ''; + + print ''; + print ''; + print ''; +*/ $facture_static = new Facture($db); $product_static = new Product($db); $form = new Form($db); - $var = True; + $var = true; while ( $i < min($num_lines, $limit) ) { $objp = $db->fetch_object($result); $var = ! $var; // product_type: 0 = service ? 1 = product - // if product does not exist we use the value of product_type provided in facturedet to define if this is a product or service - // issue : if we change product_type value in product DB it should differ from the value stored in facturedet DB ! - $code_sell_notset = ''; + // C'est le contraire dans les base !!!!!! IT IS INVERTED IN LLX_PRODUCT & LLX_FACTUREDET + // elarifr define account numbercode comptable si pas defini dans la fiche produit a partir des lignes de facturation + // product_type: 1 = service ? 0 = product + // because some modules like subtotal module l.product_type can be other than 0 or 1 ! and we don't put in account lines with product_type=9 + // first we check product.fk_product_type as type and l.product_type as type_l + // if product does not exist we use the value of l.product_type provided in facturedet to define if this is a product or service + // issue : if we change product_type value in product DB it should differ from the value stored in facturedet DB ! so we report both and user make choice of accounting account. + $objp->code_sell_l = ''; + $objp->code_sell_p = ''; + $objp->aarowid_suggest = ''; + $code_sell_p_l_differ = ''; - if (empty($objp->code_sell)) { - $code_sell_notset = 'color:red'; - - if (! empty($objp->type)) { - if ($objp->type == 1) { - $objp->code_sell = (! empty($conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT : $langs->trans("CodeNotDef")); - } else { - $objp->code_sell = (! empty($conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT : $langs->trans("CodeNotDef")); - } - } else { - $code_sell_notset = 'color:blue'; - - if ($objp->type == 1) { - $objp->code_sell = (! empty($conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT : $langs->trans("CodeNotDef")); - } else { - $objp->code_sell = (! empty($conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT : $langs->trans("CodeNotDef")); - } + //check if code_sell defined in product or set default value according p.fk_product_type do not care lines when product_type value not 0 || 1 + //and we set suggested accounting account rowid as $objp->aarowid_s + $code_sell_p_notset = ''; + $objp->aarowid_suggest = $objp->aarowid; + if ( ! empty($objp->code_sell)) { + $objp->code_sell_p = $objp->code_sell; + } else { + $code_sell_p_notset = 'color:red'; + if ($objp->type == 1) { + $objp->code_sell_p = (! empty($conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT : $langs->trans("CodeNotDef")); + } + elseif ($objp->type == 0) { + $objp->code_sell_p = (! empty($conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT : $langs->trans("CodeNotDef")); } } + // check facturedet.product_type & set default value according l.type_l, do not care lines when product_type value not 0 || 1 +// if ( ! empty($objp->type_l)) { +// $objp->code_sell_l = $objp->type_l; +// } else { + if ($objp->type_l == 1) { + $objp->code_sell_l = (! empty($conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT : $langs->trans("CodeNotDef")); + if ($objp->aarowid == '') $objp->aarowid_suggest = $aarowid_s; + } + elseif ($objp->type_l == 0) { + $objp->code_sell_l = (! empty($conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT : $langs->trans("CodeNotDef")); + if ($objp->aarowid == '') $objp->aarowid_suggest = $aarowid_p; + } +// } + + + //if not same code for product fk_prouct_type and facturedet.product_type, product has been change after sale and must report + if ($objp->code_sell_l <> $objp->code_sell_p) $code_sell_p_l_differ = 'color:red'; print ""; - // Ref facture + // Ref Invoice $facture_static->ref = $objp->facnumber; $facture_static->id = $objp->facid; print ''; - - // Ref produit + // Ref Customer Invoice $product_static->ref = $objp->product_ref; $product_static->id = $objp->product_id; $product_static->type = $objp->type; @@ -218,27 +335,39 @@ if ($result) { print ' '; print ''; - print ''; - print ''; + print ''; + //TODO: we should set a user defined value to adjust user square / wide screen size + $trunclength = defined('ACCOUNTING_LENGTH_DESCRIPTION') ? ACCOUNTING_LENGTH_DESCRIPTION : 32; + print ''; print ''; - print ''; // Colonne choix du compte print ''; + print ''; // Colonne choix ligne a ventiler print ''; - +//debug +//print ''; print ''; $i ++; } @@ -250,5 +379,5 @@ if ($result) { print $db->error(); } -$db->close(); llxFooter(); +$db->close(); diff --git a/htdocs/accountancy/supplier/list.php b/htdocs/accountancy/supplier/list.php index bf14ebc185e..02057b31255 100644 --- a/htdocs/accountancy/supplier/list.php +++ b/htdocs/accountancy/supplier/list.php @@ -1,7 +1,7 @@ - * Copyright (C) 2013-2014 Alexandre Spangaro - * Copyright (C) 2014 Ari Elbaz (elarifr) + * Copyright (C) 2013-2015 Alexandre Spangaro + * Copyright (C) 2014-2015 Ari Elbaz (elarifr) * Copyright (C) 2013-2014 Florian Henry * Copyright (C) 2014 Juanjo Menent s * @@ -31,6 +31,7 @@ require '../../main.inc.php'; 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.'/accountancy/class/html.formventilation.class.php'; +require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingaccount.class.php'; // Langs $langs->load("compta"); @@ -42,6 +43,42 @@ $langs->load("accountancy"); $action = GETPOST('action'); $codeventil = GETPOST('codeventil', 'array'); $mesCasesCochees = GETPOST('mesCasesCochees', 'array'); +$search_ref = GETPOST('search_ref','alpha'); +$search_label = GETPOST('search_label','alpha'); +$search_desc = GETPOST('search_desc','alpha'); + +$sortfield = GETPOST('sortfield','alpha'); +$sortorder = GETPOST('sortorder','alpha'); +//Should move to top with all GETPOST +$page = GETPOST('page'); +if ($page < 0) $page = 0; + + +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 = $limit * $page; +//End Should move to top with all GETPOST + + +// 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.ref 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="l.rowid"; +if (! $sortfield) $sortfield="f.datef, f.ref, l.rowid"; +//if (! $sortorder) $sortorder="DESC"; +if (! $sortorder) { + if ($conf->global->ACCOUNTING_LIST_SORT_VENTILATION_TODO > 0) { + $sortorder = " DESC "; + } +} // Security check if ($user->societe_id > 0) @@ -51,8 +88,31 @@ if (! $user->rights->accounting->ventilation->dispatch) $formventilation = new FormVentilation($db); +//Defaut AccountingAccount RowId Product / Service +//at this time ACCOUNTING_SERVICE_SOLD_ACCOUNT & ACCOUNTING_PRODUCT_SOLD_ACCOUNT are account number not accountingacount rowid +//so we need to get those default value rowid first +$accounting = new AccountingAccount($db); + +//TODO: we should need to check if result is a really exist accountaccount rowid..... +$aarowid_s = $accounting->fetch('', ACCOUNTING_SERVICE_BUY_ACCOUNT); +$aarowid_p = $accounting->fetch('', ACCOUNTING_PRODUCT_BUY_ACCOUNT); + +// Purge search criteria +if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter")) // Both test are required to be compatible with all browsers +{ + $search_ref=''; + $search_label=''; + $search_desc=''; +} + +/* + * View + */ llxHeader('', $langs->trans("Ventilation")); +//debug +//print_r($aarowid_s); +//print_r($aarowid_p); print '
' . $langs->trans("Invoice") . '' . $langs->trans("Ref") . '' . $langs->trans("Label") . '' . $langs->trans("Description") . '' . $langs->trans("Amount") . '' . $langs->trans("AccountAccounting") . '' . $langs->trans("IntoAccount") . '' . $langs->trans("Ventilate") . '
/'.'
  '; + print ''; + print ' '; + print ''; + print '
' . $facture_static->getNomUrl(1) . '' . dol_trunc($objp->product_label, 24) . '' . nl2br(dol_trunc($objp->description, 32)) . '' . dol_trunc($objp->product_label, 24) . '' . nl2br(dol_trunc($objp->description, $trunclength)) . ''; print price($objp->total_ht); print ''; - print $objp->code_sell; + print ''; + // if not same kind of product_type stored in product & facturedet we display both account and let user choose + if ($objp->code_sell_l == $objp->code_sell_p) { + print $objp->code_sell_l; + } else { + print 'lines='.$objp->code_sell_l . '
product=' . $objp->code_sell_p; + } print '
'; - print $formventilation->select_account($objp->aarowid, 'codeventil[]', 1); + // TODO: we should set a user defined value to adjust user square / wide screen size + // $trunclengthform = defined('ACCOUNTING_LENGTH_DESCRIPTION_ACCOUNT') ? ACCOUNTING_LENGTH_DESCRIPTION_ACCOUNT : 50; + print $formventilation->select_account($objp->aarowid_suggest, 'codeventil[]', 1); print '' . $objp->rowid . ''; - print 'aarowid ? "checked" : "") . '/>'; + //TODO checked only if account exist in product, if only suggested do not check, user must validate + print 'aarowid_suggest ? "checked" : "") . '/>'; print '
Product: p.type='. $objp->type .' - p.code_sell='. $objp->code_sell .' --- Check code_sell_product=' . $objp->code_sell_p .' ---Check facturedet l.type_l='. $objp->type_l .' - code_sell_lines=' . $objp->code_sell_l . ' -- aarowid_suggest=' . $objp->aarowid_suggest.'