diff --git a/htdocs/accountancy/class/accountingaccount.class.php b/htdocs/accountancy/class/accountingaccount.class.php index f3ad3e23a477156c134b3af72d2fea0ae86e093e..5fc546a8ce99f22125d05e1918fa111f3ecce062 100644 --- a/htdocs/accountancy/class/accountingaccount.class.php +++ b/htdocs/accountancy/class/accountingaccount.class.php @@ -3,6 +3,7 @@ * Copyright (C) 2013-2015 Alexandre Spangaro <alexandre.spangaro@gmail.com> * Copyright (C) 2013-2014 Florian Henry <florian.henry@open-concept.pro> * Copyright (C) 2014 Juanjo Menent <jmenent@2byte.es> + * Copyright (C) 2015 Ari Elbaz (elarifr) <github@accedinfo.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 @@ -119,8 +120,6 @@ class AccountingAccount extends CommonObject $error = 0; $now = dol_now(); - $now=dol_now(); - // Clean parameters if (isset($this->fk_pcg_version)) $this->fk_pcg_version = trim($this->fk_pcg_version); diff --git a/htdocs/accountancy/class/html.formventilation.class.php b/htdocs/accountancy/class/html.formventilation.class.php index abd66a7885dc230ce2985840e0ef09378f099c5b..a596d481d9c378c58b5fc339a7b70c829828e823 100644 --- a/htdocs/accountancy/class/html.formventilation.class.php +++ b/htdocs/accountancy/class/html.formventilation.class.php @@ -2,6 +2,7 @@ /* Copyright (C) 2013-2014 Florian Henry <florian.henry@open-concept.pro> * Copyright (C) 2013-2014 Olivier Geffroy <jeff@jeffinfo.com> * Copyright (C) 2013-2014 Alexandre Spangaro <alexandre.spangaro@gmail.com> + * Copyright (C) 2015 Ari Elbaz (elarifr) <github@accedinfo.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 @@ -91,10 +92,13 @@ class FormVentilation extends Form * @param string $htmlname Name of field in html form * @param int $showempty Add an empty field * @param array $event Event options + * @param int $select_in $selectid value is a aa.rowid (0 default) or aa.account_number (1) + * @param int $select_out set value returned by select 0=rowid (default), 1=account_number + * @param int $aabase set accountingaccount base class to display empty=all or from 1 to 8 will display only account beginning by * * @return string String with HTML select */ - function select_account($selectid, $htmlname = 'account', $showempty = 0, $event = array()) + function select_account($selectid, $htmlname = 'account', $showempty = 0, $event = array(), $select_in = 0, $select_out = 0, $aabase = '') { global $conf; @@ -116,21 +120,26 @@ class FormVentilation extends Form if ($showempty) $out .= '<option value="-1"></option>'; $num = $this->db->num_rows($resql); + $trunclength = defined('ACCOUNTING_LENGTH_DESCRIPTION_ACCOUNT') ? $conf->global->ACCOUNTING_LENGTH_DESCRIPTION_ACCOUNT : '50'; $i = 0; if ($num) { while ( $i < $num ) { $obj = $this->db->fetch_object($resql); $label = $obj->account_number . ' - ' . $obj->label; - + $label = dol_trunc($label, $trunclength); + if ($select_in == 0 ) $select_value_in = $obj->rowid; + if ($select_in == 1 ) $select_value_in = $obj->account_number; + if ($select_out == 0 ) $select_value_out = $obj->rowid; + if ($select_out == 1 ) $select_value_out = $obj->account_number; // Remember guy's we store in database llx_facturedet the rowid of accountingaccount and not the account_number // Because same account_number can be share between different accounting_system and do have the same meaning - if (($selectid != '') && $selectid == $obj->rowid) { + if (($selectid != '') && $selectid == $select_value_in) { // $out .= '<option value="' . $obj->account_number . '" selected>' . $label . '</option>'; - $out .= '<option value="' . $obj->rowid . '" selected>' . $label . '</option>'; + $out .= '<option value="' . $select_value_out . '" selected>' . $label . '</option>'; } else { // $out .= '<option value="' . $obj->account_number . '">' . $label . '</option>'; - $out .= '<option value="' . $obj->rowid . '">' . $label . '</option>'; + $out .= '<option value="' . $select_value_out . '">' . $label . '</option>'; } $i ++; } diff --git a/htdocs/accountancy/customer/lines.php b/htdocs/accountancy/customer/lines.php index 2bbb839459f5cd48b5f6b2c1416190b93a083d09..d00296ed2b928a8b2b1c0663d48dd95a7ce3abb3 100644 --- a/htdocs/accountancy/customer/lines.php +++ b/htdocs/accountancy/customer/lines.php @@ -1,7 +1,7 @@ <?php /* Copyright (C) 2013-2014 Olivier Geffroy <jeff@jeffinfo.com> * Copyright (C) 2013-2015 Alexandre Spangaro <alexandre.spangaro@gmail.com> - * Copyright (C) 2014 Ari Elbaz (elarifr) <github@accedinfo.com> + * Copyright (C) 2014-2015 Ari Elbaz (elarifr) <github@accedinfo.com> * Copyright (C) 2014 Florian Henry <florian.henry@open-concept.pro> * Copyright (C) 2014 Juanjo Menent <jmenent@2byte.es> * @@ -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 '<script type="text/javascript"> + $(function () { + $(\'#select-all\').click(function(event) { + // Iterate each checkbox + $(\':checkbox\').each(function() { + this.checked = true; + }); + }); + $(\'#unselect-all\').click(function(event) { + // Iterate each checkbox + $(\':checkbox\').each(function() { + this.checked = false; + }); + }); + }); + </script>'; + +/* + * 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 '<form method="POST" action="' . $_SERVER["PHP_SELF"] . '">'; print '<table class="noborder" width="100%">'; - print '<br><br><div class="inline-block divButAction">' . $langs->trans("ChangeAccount") . '<br>'; + print '<br><div class="inline-block divButAction">' . $langs->trans("ChangeAccount") . '<br>'; print $formventilation->select_account($account_parent, 'account_parent', 1); print '<input type="submit" class="butAction" value="' . $langs->trans("Validate") . '"/></div>'; @@ -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").'<br><label id="select-all">'.$langs->trans('All').'</label>/<label id="unselect-all">'.$langs->trans('None').'</label>','','','','','align="center"'); print "</tr>\n"; - - print '<tr class="liste_titre"><td><input type="text" class="flat" name="search_facture" size="8" value="' . $search_facture . '"></td>'; + + print '<tr class="liste_titre">'; + print '<td class="liste_titre"><input type="text" class="flat" name="search_invoice" size="10" value="' . $search_invoice . '"></td>'; print '<td class="liste_titre"><input type="text" class="flat" size="15" name="search_ref" value="' . $search_ref . '"></td>'; print '<td class="liste_titre"><input type="text" class="flat" size="15" name="search_label" value="' . $search_label . '"></td>'; print '<td class="liste_titre"><input type="text" class="flat" size="15" name="search_desc" value="' . $search_desc . '"></td>'; @@ -188,12 +238,12 @@ if ($result) { print "<tr $bc[$var]>"; - // Ref facture + // Ref Invoice $facture_static->ref = $objp->facnumber; $facture_static->id = $objp->facid; print '<td>' . $facture_static->getNomUrl(1) . '</td>'; - // 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 '<td>' . nl2br(dol_trunc($objp->description, 32)) . '</td>'; print '<td align="right">' . price($objp->total_ht) . '</td>'; print '<td align="center">' . $codecompta . '</td>'; - print '<td>' . $objp->rowid . '</td>'; - print '<td><a href="./card.php?id=' . $objp->rowid . '">'; + print '<td align="right">' . $objp->rowid . '</td>'; + print '<td align="left"><a href="./card.php?id=' . $objp->rowid . '">'; print img_edit(); print '</a></td>'; diff --git a/htdocs/accountancy/customer/list.php b/htdocs/accountancy/customer/list.php index ac1c342965832f86b6079c9d0f7fb6f79c428e31..eb6446ae13d5b54f7bc53457d78741482a29b368 100644 --- a/htdocs/accountancy/customer/list.php +++ b/htdocs/accountancy/customer/list.php @@ -1,7 +1,7 @@ <?php /* Copyright (C) 2013-2014 Olivier Geffroy <jeff@jeffinfo.com> - * Copyright (C) 2013-2014 Alexandre Spangaro <alexandre.spangaro@gmail.com> - * Copyright (C) 2014 Ari Elbaz (elarifr) <github@accedinfo.com> + * Copyright (C) 2013-2015 Alexandre Spangaro <alexandre.spangaro@gmail.com> + * Copyright (C) 2014-2015 Ari Elbaz (elarifr) <github@accedinfo.com> * Copyright (C) 2013-2014 Florian Henry <florian.henry@open-concept.pro> * Copyright (C) 2014 Juanjo Menent <jmenent@2byte.es> * @@ -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 '<script type="text/javascript"> $(function () { $(\'#select-all\').click(function(event) { @@ -68,6 +127,7 @@ print '<script type="text/javascript"> }); }); </script>'; + /* * 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 '<input type="hidden" name="action" value="ventil">'; print '<table class="noborder" width="100%">'; - print '<tr class="liste_titre"><td>' . $langs->trans("Invoice") . '</td>'; - print '<td>' . $langs->trans("Ref") . '</td>'; - print '<td>' . $langs->trans("Label") . '</td>'; - print '<td>' . $langs->trans("Description") . '</td>'; - print '<td align="right">' . $langs->trans("Amount") . '</td>'; - print '<td align="right">' . $langs->trans("AccountAccounting") . '</td>'; - print '<td align="center">' . $langs->trans("IntoAccount") . '</td>'; - print '<td align="center">' . $langs->trans("Ventilate") . '<br><label id="select-all">'.$langs->trans('All').'</label>/<label id="unselect-all">'.$langs->trans('None').'</label>'.'</td>'; + print '<tr class="liste_titre">'; + 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") . '<br><label id="select-all">'.$langs->trans('All').'</label>/<label id="unselect-all">'.$langs->trans('None').'</label>','','','','','align="center"'); print '</tr>'; +// We add search filter +/* But Hit Enter will validate ventilation.... + print '<tr class="liste_titre">'; + print '<td class="liste_titre" > </td>'; + print '<td class="liste_titre"><input type="text" class="flat" size="10" name="search_ref" value="' . $search_ref . '"></td>'; + print '<td class="liste_titre"><input type="text" class="flat" size="20" name="search_label" value="' . $search_label . '"></td>'; + print '<td class="liste_titre"><input type="text" class="flat" size="30" name="search_desc" value="' . $search_desc . '"></td>'; + + print '<td class="liste_titre" colspan="3"> </td>'; + print '<td align="right" colspan="2" class="liste_titre">'; + print '<input type="image" class="liste_titre" src="'.img_picto($langs->trans("Search"),'search.png','','',1).'" name="button_search" value="'.dol_escape_htmltag($langs->trans("Search")).'" title="'.dol_escape_htmltag($langs->trans("Search")).'">'; + print ' '; + print '<input type="image" class="liste_titre" src="'.img_picto($langs->trans("Search"),'searchclear.png','','',1).'" name="button_removefilter" value="'.dol_escape_htmltag($langs->trans("RemoveFilter")).'" title="'.dol_escape_htmltag($langs->trans("RemoveFilter")).'">'; + print '</td>'; + print '</tr>'; +*/ $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 = ''; - - 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")); - } + // 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 = ''; + + //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 "<tr $bc[$var]>"; - // Ref facture + // Ref Invoice $facture_static->ref = $objp->facnumber; $facture_static->id = $objp->facid; print '<td>' . $facture_static->getNomUrl(1) . '</td>'; - - // 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 '</td>'; - print '<td>' . dol_trunc($objp->product_label, 24) . '</td>'; - print '<td>' . nl2br(dol_trunc($objp->description, 32)) . '</td>'; + print '<td style="' . $code_sell_p_l_differ . '">' . dol_trunc($objp->product_label, 24) . '</td>'; + //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 '<td style="' . $code_sell_p_l_differ . '">' . nl2br(dol_trunc($objp->description, $trunclength)) . '</td>'; print '<td align="right">'; print price($objp->total_ht); print '</td>'; - print '<td align="center" style="' . $code_sell_notset . '">'; - print $objp->code_sell; + print '<td align="center" style="' . $code_sell_p_notset . '">'; + // 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 . '<br />product=' . $objp->code_sell_p; + } print '</td>'; // Colonne choix du compte print '<td align="center">'; - 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 '</td>'; + print '<td align="center">' . $objp->rowid . '</td>'; // Colonne choix ligne a ventiler print '<td align="center">'; - print '<input type="checkbox" name="mesCasesCochees[]" value="' . $objp->rowid . "_" . $i . '"' . ($objp->aarowid ? "checked" : "") . '/>'; + //TODO checked only if account exist in product, if only suggested do not check, user must validate + print '<input type="checkbox" name="mesCasesCochees[]" value="' . $objp->rowid . "_" . $i . '"' . ($objp->aarowid_suggest ? "checked" : "") . '/>'; print '</td>'; - +//debug +//print '</tr><tr><td colspan=6>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.'</td>'; print '</tr>'; $i ++; } @@ -250,5 +379,5 @@ if ($result) { print $db->error(); } -$db->close(); llxFooter(); +$db->close(); diff --git a/htdocs/accountancy/supplier/lines.php b/htdocs/accountancy/supplier/lines.php index 917ee15f1d4dae993ea6cb20714a8f52c5cc3bff..80f7bc5e6eed450a13980c4a7056888ff0eefe70 100644 --- a/htdocs/accountancy/supplier/lines.php +++ b/htdocs/accountancy/supplier/lines.php @@ -1,7 +1,7 @@ <?php /* Copyright (C) 2013-2014 Olivier Geffroy <jeff@jeffinfo.com> * Copyright (C) 2013-2015 Alexandre Spangaro <alexandre.spangaro@gmail.com> - * Copyright (C) 2014 Ari Elbaz (elarifr) <github@accedinfo.com> + * Copyright (C) 2014-2015 Ari Elbaz (elarifr) <github@accedinfo.com> * Copyright (C) 2013-2014 Florian Henry <florian.henry@open-concept.pro> * Copyright (C) 2014 Juanjo Menent <jmenent@2byte.es> * @@ -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 '<script type="text/javascript"> + $(function () { + $(\'#select-all\').click(function(event) { + // Iterate each checkbox + $(\':checkbox\').each(function() { + this.checked = true; + }); + }); + $(\'#unselect-all\').click(function(event) { + // Iterate each checkbox + $(\':checkbox\').each(function() { + this.checked = false; + }); + }); + }); + </script>'; + +/* + * 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 '<td align="left"><b>' . $langs->trans("DescVentilDoneSupplier") . '</b></td>'; - print '<form method="GET" action="' . $_SERVER["PHP_SELF"] . '">'; + print '<form method="POST" action="' . $_SERVER["PHP_SELF"] . '">'; print '<table class="noborder" width="100%">'; - print '<br><br><div class="inline-block divButAction">'. $langs->trans("ChangeAccount") . '<br>'; + print '<br><div class="inline-block divButAction">'. $langs->trans("ChangeAccount") . '<br>'; print $formventilation->select_account(GETPOST('account_parent'), 'account_parent', 1); print '<input type="submit" class="butAction" value="' . $langs->trans("Validate") . '" /></div>'; @@ -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").'<br><label id="select-all">'.$langs->trans('All').'</label>/<label id="unselect-all">'.$langs->trans('None').'</label>','','','','','align="center"'); print "</tr>\n"; - print '<tr class="liste_titre"><td><input type="text" class="flat" name="search_facture" size="8" value="' . $search_facture . '"></td>'; + print '<tr class="liste_titre"><td><input type="text" class="flat" name="search_invoice" size="10" value="' . $search_invoice . '"></td>'; print '<td class="liste_titre"><input type="text" class="flat" size="15" name="search_ref" value="' . $search_ref . '"></td>'; print '<td class="liste_titre"><input type="text" class="flat" size="15" name="search_label" value="' . $search_label . '"></td>'; print '<td class="liste_titre"><input type="text" class="flat" size="15" name="search_desc" value="' . $search_desc . '"></td>'; @@ -211,8 +235,8 @@ if ($result) { print '<td>' . nl2br(dol_trunc($objp->description, 32)) . '</td>'; print '<td align="right">' . price($objp->total_ht) . '</td>'; print '<td align="center">' . $codeCompta . '</td>'; - print '<td>' . $objp->rowid . '</td>'; - print '<td><a href="./card.php?id=' . $objp->rowid . '">'; + print '<td align="right">' . $objp->rowid . '</td>'; + print '<td align="left"><a href="./card.php?id=' . $objp->rowid . '">'; print img_edit(); print '</a></td>'; diff --git a/htdocs/accountancy/supplier/list.php b/htdocs/accountancy/supplier/list.php index bf14ebc185e6a9a02d5632dfb05751f612a0b1c0..02057b3125564f11ea3dc09f95f8adde784beea6 100644 --- a/htdocs/accountancy/supplier/list.php +++ b/htdocs/accountancy/supplier/list.php @@ -1,7 +1,7 @@ <?php /* Copyright (C) 2013-2014 Olivier Geffroy <jeff@jeffinfo.com> - * Copyright (C) 2013-2014 Alexandre Spangaro <alexandre.spangaro@gmail.com> - * Copyright (C) 2014 Ari Elbaz (elarifr) <github@accedinfo.com> + * Copyright (C) 2013-2015 Alexandre Spangaro <alexandre.spangaro@gmail.com> + * Copyright (C) 2014-2015 Ari Elbaz (elarifr) <github@accedinfo.com> * Copyright (C) 2013-2014 Florian Henry <florian.henry@open-concept.pro> * Copyright (C) 2014 Juanjo Menent <jmenent@2byte.es>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 '<script type="text/javascript"> $(function () { $(\'#select-all\').click(function(event) { @@ -91,7 +151,7 @@ if ($action == 'ventil') { $sql .= " SET fk_code_ventilation = " . $monCompte; $sql .= " WHERE rowid = " . $monId; - dol_syslog('accountancy/supplier/list.php:: sql=' . $sql); + dol_syslog('accountancy/supplier/list.php:: sql=' . $sql, LOG_DEBUG); if ($db->query($sql)) { print '<div><font color="green">' . $langs->trans("Lineofinvoice") . ' ' . $monId . ' ' . $langs->trans("VentilatedinAccount") . ' : ' . $monCompte . '</font></div>'; } else { @@ -126,6 +186,9 @@ $offset = $limit * $page; $sql = "SELECT f.ref, f.rowid as facid, f.ref_supplier, l.fk_product, l.description, l.total_ht as price, 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_buy as code_buy"; +$sql .= " , aa.rowid as aarowid"; +$sql .= " , f.datef"; +$sql .= " , l.product_type as type_l"; $sql .= " FROM " . MAIN_DB_PREFIX . "facture_fourn as f"; $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"; @@ -134,14 +197,22 @@ $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_system as accsys ON accsys. $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_buy ='')"; +// 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_fourn", 1) . ")"; } -$sql .= " ORDER BY l.rowid"; -if ($conf->global->ACCOUNTING_LIST_SORT_VENTILATION_TODO > 0) { - $sql .= " DESC "; -} +$sql.= $db->order($sortfield,$sortorder); + $sql .= $db->plimit($limit + 1, $offset); dol_syslog('accountancy/supplier/list.php:: $sql=' . $sql); @@ -153,20 +224,22 @@ if ($result) { // TODO : print_barre_liste always use $conf->liste_limit and do not care about custom limit in list... print_barre_liste($langs->trans("InvoiceLines"), $page, $_SERVER["PHP_SELF"], "", $sortfield, $sortorder, '', $num_lines); - print '<td align="left"><br><b>' . $langs->trans("DescVentilTodoSupplier") . '</b></br></td>'; + print '<br><b>' . $langs->trans("DescVentilTodoCustomer") . '</b></br>'; print '<form action="' . $_SERVER["PHP_SELF"] . '" method="post">' . "\n"; print '<input type="hidden" name="action" value="ventil">'; print '<table class="noborder" width="100%">'; - print '<tr class="liste_titre"><td>Facture</td>'; - print '<td align="left">' . $langs->trans("Ref") . '</td>'; - print '<td align="left">' . $langs->trans("Label") . '</td>'; - print '<td>' . $langs->trans("Description") . '</td>'; - print '<td align="right">' . $langs->trans("Amount") . '</td>'; - print '<td align="right">' . $langs->trans("Compte") . '</td>'; - print '<td align="center">' . $langs->trans("IntoAccount") . '</td>'; - print '<td align="center">' . $langs->trans("Ventilate") . '<br><label id="select-all">'.$langs->trans('All').'</label>/<label id="unselect-all">'.$langs->trans('None').'</label>'.'</td>'; + print '<tr class="liste_titre">'; + print_liste_field_titre($langs->trans("Invoice"), $_SERVER["PHP_SELF"],"f.ref","",$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") . '<br><label id="select-all">'.$langs->trans('All').'</label>/<label id="unselect-all">'.$langs->trans('None').'</label>','','','','','align="center"'); print "</tr>\n"; $facturefourn_static = new FactureFournisseur($db); @@ -181,27 +254,48 @@ if ($result) { // 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_buy_notset = ''; - - if (empty($objp->code_buy)) { - $code_buy_notset = 'color:red'; + $objp->code_buy_l = ''; + $objp->code_buy_p = ''; + $objp->aarowid_suggest = ''; + $code_buy_p_l_differ = ''; + + $code_buy_p_notset = ''; + + $objp->aarowid_suggest = $objp->aarowid; + if ( ! empty($objp->code_buy)) { + $objp->code_buy_p = $objp->code_buy; + } else { + $code_buy_p_notset = 'color:red'; if ($objp->type == 1) { - $objp->code_buy = (! empty($conf->global->ACCOUNTING_SERVICE_BUY_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_BUY_ACCOUNT : $langs->trans("CodeNotDef")); - } else { - $objp->code_buy = (! empty($conf->global->ACCOUNTING_PRODUCT_BUY_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_BUY_ACCOUNT : $langs->trans("CodeNotDef")); + $objp->code_buy_p = (! empty($conf->global->ACCOUNTING_SERVICE_BUY_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_BUY_ACCOUNT : $langs->trans("CodeNotDef")); + + + } + + elseif ($objp->type == 0) { + $objp->code_buy_p = (! empty($conf->global->ACCOUNTING_PRODUCT_BUY_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_BUY_ACCOUNT : $langs->trans("CodeNotDef")); } - }else { - $code_buy_notset = 'color:blue'; } + if ($objp->type_l == 1) { + $objp->code_buy_l = (! empty($conf->global->ACCOUNTING_SERVICE_BUY_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_BUY_ACCOUNT : $langs->trans("CodeNotDef")); + if ($objp->aarowid == '') $objp->aarowid_suggest = $aarowid_s; + } + elseif ($objp->type_l == 0) { + $objp->code_buy_l = (! empty($conf->global->ACCOUNTING_PRODUCT_BUY_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_BUY_ACCOUNT : $langs->trans("CodeNotDef")); + if ($objp->aarowid == '') $objp->aarowid_suggest = $aarowid_p; + } + + if ($objp->code_buy_l <> $objp->code_buy_p) $code_buy_p_l_differ = 'color:red'; + print "<tr $bc[$var]>"; - // Ref facture + // Ref Invoice $facturefourn_static->ref = $objp->ref; $facturefourn_static->id = $objp->facid; print '<td>' . $facturefourn_static->getNomUrl(1) . '</td>'; - // Ref facture supplier + // Ref Supplier Invoice $productfourn_static->ref = $objp->product_ref; $productfourn_static->id = $objp->product_id; $productfourn_static->type = $objp->type; @@ -212,29 +306,33 @@ if ($result) { print ' '; print '</td>'; - // print '<td><a href="'.DOL_URL_ROOT.'/fourn/facture/card.php?facid='.$objp->facid.'">'.$objp->ref.'</a></td>'; - - // print '<td><a href="'.DOL_URL_ROOT.'/fourn/facture/card.php?facid='.$objp->facid.'">'.$objp->ref_supplier.'</a></td>'; + print '<td style="' . $code_buy_p_l_differ . '">' . dol_trunc($objp->product_label, 24) . '</td>'; - print '<td>' . dol_trunc($objp->product_label, 24) . '</td>'; - - print '<td>' . stripslashes(nl2br($objp->description)) . '</td>'; + // 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 '<td style="' . $code_buy_p_l_differ . '">' . nl2br(dol_trunc($objp->description, $trunclength)) . '</td>'; print '<td align="right">'; print price($objp->price); print '</td>'; - print '<td align="center" style="' . $code_buy_notset . '">'; - print $objp->code_buy; + print '<td align="center" style="' . $code_buy_p_notset . '">'; + //if not same kind of product_type stored in product & facturedt we display both account and let user choose + if ($objp->code_buy_l == $objp->code_buy_p) { + print $objp->code_buy_l; + } else { + print 'lines='.$objp->code_buy_l . '<br />product=' . $objp->code_buy_p; + } print '</td>'; // Colonne choix du compte print '<td align="center">'; - print $formventilation->select_account($objp->aarowid, 'codeventil[]', 1); + print $formventilation->select_account($objp->aarowid_suggest, 'codeventil[]', 1); print '</td>'; + print '<td align="center">' . $objp->rowid . '</td>'; // Colonne choix ligne a ventiler print '<td align="center">'; - print '<input type="checkbox" name="mesCasesCochees[]" value="' . $objp->rowid . "_" . $i . '"' . ($objp->aarowid ? "checked" : "") . '/>'; + print '<input type="checkbox" name="mesCasesCochees[]" value="' . $objp->rowid . "_" . $i . '"' . ($objp->aarowid_suggest ? "checked" : "") . '/>'; print '</td>'; print "</tr>"; diff --git a/htdocs/langs/en_US/accountancy.lang b/htdocs/langs/en_US/accountancy.lang index f98e2cf929b177def84cf3094c276205b2f13ff0..c63ce9f1ddfe911a0cbfdf5135568c397cb3dbd6 100644 --- a/htdocs/langs/en_US/accountancy.lang +++ b/htdocs/langs/en_US/accountancy.lang @@ -84,6 +84,8 @@ ACCOUNTING_LIST_SORT_VENTILATION_DONE=Begin the sorting of the breakdown pages " AccountLength=Length of the accounting accounts shown in Dolibarr AccountLengthDesc=Function allowing to feign a length of accounting account by replacing spaces by the zero figure. This function touches only the display, it does not modify the accounting accounts registered in Dolibarr. For the export, this function is necessary to be compatible with certain software. +ACCOUNTING_LENGTH_DESCRIPTION=Length for displaying product & services description in listings (Best = 50) +ACCOUNTING_LENGTH_DESCRIPTION_ACCOUNT=Length for displaying product & services account description form in listings (Best = 50) ACCOUNTING_LENGTH_GACCOUNT=Length of the general accounts ACCOUNTING_LENGTH_AACCOUNT=Length of the third party accounts