|
@@ -48,6 +48,8 @@ $search_desc = GETPOST('search_desc', 'alpha');
|
|
|
$search_amount = GETPOST('search_amount', 'alpha');
|
|
|
$search_account = GETPOST('search_account', 'alpha');
|
|
|
$search_vat = GETPOST('search_vat', 'alpha');
|
|
|
+$search_country = GETPOST('search_country', 'alpha');
|
|
|
+$search_tvaintra = GETPOST('search_tvaintra', 'alpha');
|
|
|
|
|
|
// Getpost Order and column and limit page
|
|
|
$sortfield = GETPOST('sortfield', 'alpha');
|
|
@@ -68,7 +70,7 @@ if (! empty($conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION)) {
|
|
|
$offset = $limit * $page;
|
|
|
|
|
|
if (! $sortfield)
|
|
|
- $sortfield = "f.datef, f.facnumber, l.rowid";
|
|
|
+ $sortfield = "f.datef, f.facnumber, fd.rowid";
|
|
|
|
|
|
if (! $sortorder) {
|
|
|
if ($conf->global->ACCOUNTING_LIST_SORT_VENTILATION_DONE > 0) {
|
|
@@ -94,6 +96,8 @@ if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter")) // Both
|
|
|
$search_amount = '';
|
|
|
$search_account = '';
|
|
|
$search_vat = '';
|
|
|
+ $search_country = '';
|
|
|
+ $search_tvaintra = '';
|
|
|
}
|
|
|
|
|
|
if (is_array($changeaccount) && count($changeaccount) > 0) {
|
|
@@ -150,14 +154,27 @@ print '<script type="text/javascript">
|
|
|
/*
|
|
|
* 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";
|
|
|
-$sql .= " , " . MAIN_DB_PREFIX . "accounting_account as aa";
|
|
|
-$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";
|
|
|
+$sql = "SELECT f.rowid, f.facnumber, f.type, f.datef as df, f.ref_client,";
|
|
|
+$sql .= " fd.rowid as fdid, fd.description, fd.product_type, fd.total_ht, fd.total_tva, fd.tva_tx, 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 ";
|
|
|
+if (! empty($conf->multicompany->enabled)) {
|
|
|
+ $sql .= " AND f.entity IN (" . getEntity("facture", 1) . ")";
|
|
|
+}
|
|
|
+$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 {
|
|
|
+ $sql .= " AND f.type IN (" . Facture::TYPE_STANDARD . "," . Facture::TYPE_STANDARD . "," . Facture::TYPE_CREDIT_NOTE . "," . Facture::TYPE_DEPOSIT . "," . Facture::TYPE_SITUATION . ")";
|
|
|
+}
|
|
|
if (strlen(trim($search_invoice))) {
|
|
|
$sql .= " AND f.facnumber like '%" . $search_invoice . "%'";
|
|
|
}
|
|
@@ -168,16 +185,22 @@ if (strlen(trim($search_label))) {
|
|
|
$sql .= " AND p.label like '%" . $search_label . "%'";
|
|
|
}
|
|
|
if (strlen(trim($search_desc))) {
|
|
|
- $sql .= " AND l.description like '%" . $search_desc . "%'";
|
|
|
+ $sql .= " AND fd.description like '%" . $search_desc . "%'";
|
|
|
}
|
|
|
if (strlen(trim($search_amount))) {
|
|
|
- $sql .= " AND l.total_ht like '%" . $search_amount . "%'";
|
|
|
+ $sql .= " AND fd.total_ht like '%" . $search_amount . "%'";
|
|
|
}
|
|
|
if (strlen(trim($search_account))) {
|
|
|
$sql .= " AND aa.account_number like '%" . $search_account . "%'";
|
|
|
}
|
|
|
if (strlen(trim($search_vat))) {
|
|
|
- $sql .= " AND (l.tva_tx like '" . $search_vat . "%')";
|
|
|
+ $sql .= " AND (fd.tva_tx like '" . $search_vat . "%')";
|
|
|
+}
|
|
|
+if (strlen(trim($search_country))) {
|
|
|
+ $sql .= " AND (co.label like'" . $search_country . "%')";
|
|
|
+}
|
|
|
+if (strlen(trim($search_tvaintra))) {
|
|
|
+ $sql .= " AND (s.tva_intra like'" . $search_tvaintra . "%')";
|
|
|
}
|
|
|
if (! empty($conf->multicompany->enabled)) {
|
|
|
$sql .= " AND f.entity IN (" . getEntity("facture", 1) . ")";
|
|
@@ -201,8 +224,8 @@ if ($result) {
|
|
|
$i = 0;
|
|
|
|
|
|
$param = "";
|
|
|
- if ($search_facture)
|
|
|
- $param .= "&search_facture=" . $search_facture;
|
|
|
+ if ($search_invoice)
|
|
|
+ $param .= "&search_invoice=" . $search_invoice;
|
|
|
if ($search_ref)
|
|
|
$param .= "&search_ref=" . $search_ref;
|
|
|
if ($search_label)
|
|
@@ -211,8 +234,13 @@ if ($result) {
|
|
|
$param .= "&search_desc=" . $search_desc;
|
|
|
if ($search_account)
|
|
|
$param .= "&search_account=" . $search_account;
|
|
|
- if ($filter)
|
|
|
- $param .= "&filter=" . $filter;
|
|
|
+ if ($search_vat)
|
|
|
+ $param .= "&search_vat=" . $search_vat;
|
|
|
+ if ($search_country)
|
|
|
+ $param .= "&search_country=" . $search_country;
|
|
|
+ if ($search_tvaintra)
|
|
|
+ $param .= "&search_tvaintra=" . $search_tvaintra;
|
|
|
+
|
|
|
|
|
|
print_barre_liste($langs->trans("InvoiceLinesDone"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num_lines, $nbtotalofrecords);
|
|
|
print '<td align="left"><b>' . $langs->trans("DescVentilDoneCustomer") . '</b></td>';
|
|
@@ -228,12 +256,12 @@ if ($result) {
|
|
|
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"), $_SERVER["PHP_SELF"], "l.total_ht", "", $param, 'align="center"', $sortfield, $sortorder);
|
|
|
- print_liste_field_titre($langs->trans("VATRate"), $_SERVER["PHP_SELF"], "l.tva_tx", "", $param, 'align="center"', $sortfield, $sortorder);
|
|
|
+ print_liste_field_titre($langs->trans("Description"), $_SERVER["PHP_SELF"], "fd.description", "", $param, '', $sortfield, $sortorder);
|
|
|
+ print_liste_field_titre($langs->trans("Amount"), $_SERVER["PHP_SELF"], "fd.total_ht", "", $param, 'align="center"', $sortfield, $sortorder);
|
|
|
+ print_liste_field_titre($langs->trans("VATRate"), $_SERVER["PHP_SELF"], "fd.tva_tx", "", $param, 'align="center"', $sortfield, $sortorder);
|
|
|
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($langs->trans("Country"), $_SERVER["PHP_SELF"], "co.label", "", $param, 'align="center"', $sortfield, $sortorder);
|
|
|
+ print_liste_field_titre($langs->trans("IntracommunityVATNumber"), $_SERVER["PHP_SELF"], "s.tva_intra", "", $param, 'align="center"', $sortfield, $sortorder);
|
|
|
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";
|
|
|
|
|
@@ -243,14 +271,13 @@ if ($result) {
|
|
|
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>';
|
|
|
print '<td class="liste_titre" align="center"><input type="text" class="flat" size="8" name="search_amount" value="' . $search_amount . '"></td>';
|
|
|
- print '<td class="liste_titre" align="center"><input type="text" class="flat" size="5" name="search_vat" value="' . $search_vat . '">%</td>';
|
|
|
+ print '<td class="liste_titre" align="center">%<input type="text" class="flat" size="5" name="search_vat" value="' . $search_vat . '"></td>';
|
|
|
print '<td class="liste_titre" align="center"><input type="text" class="flat" size="15" name="search_account" value="' . $search_account . '"></td>';
|
|
|
- print '<td class="liste_titre" colspan="2"> </td>';
|
|
|
- print '<td class="liste_titre" align="right">';
|
|
|
- $searchpitco=$form->showFilterAndCheckAddButtons(0);
|
|
|
- print $searchpitco;
|
|
|
- print '</td>';
|
|
|
- print "</tr>\n";
|
|
|
+ print '<td class="liste_titre" align="center"><input type="text" class="flat" size="15" name="search_country" value="' . $search_country . '"></td>';
|
|
|
+ print '<td class="liste_titre" align="center"><input type="text" class="flat" size="15" name="search_tavintra" value="' . $search_tavintra . '"></td>';
|
|
|
+ print '<td class="liste_titre" align="center"><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></tr>\n";
|
|
|
|
|
|
$facture_static = new Facture($db);
|
|
|
$product_static = new Product($db);
|
|
@@ -258,7 +285,7 @@ if ($result) {
|
|
|
$var = True;
|
|
|
while ( $objp = $db->fetch_object($result) ) {
|
|
|
$var = ! $var;
|
|
|
- $codecompta = $objp->account_number . ' ' . $objp->label;
|
|
|
+ $codecompta = $objp->account_number . ' - ' . $objp->label_compte;
|
|
|
|
|
|
print "<tr $bc[$var]>";
|
|
|
|
|
@@ -282,13 +309,12 @@ if ($result) {
|
|
|
print '<td>' . nl2br(dol_trunc($objp->description, 32)) . '</td>';
|
|
|
print '<td align="right">' . price($objp->total_ht) . '</td>';
|
|
|
print '<td align="center">' . price($objp->tva_tx) . '</td>';
|
|
|
- print '<td align="center">' . $codecompta . '</td>';
|
|
|
- print '<td align="right">' . $objp->rowid . '</td>';
|
|
|
- print '<td align="left"><a href="./card.php?id=' . $objp->rowid . '">';
|
|
|
+ print '<td align="center">' . $codecompta . '<a href="./card.php?id=' . $objp->fdid . '">';
|
|
|
print img_edit();
|
|
|
print '</a></td>';
|
|
|
-
|
|
|
- print '<td align="center"><input type="checkbox" name="changeaccount[]" value="' . $objp->rowid . '"/></td>';
|
|
|
+ print '<td align="right">' . $objp->country .'</td>';
|
|
|
+ print '<td align="center">' . $objp->tva_intra . '</td>';
|
|
|
+ print '<td align="center"><input type="checkbox" name="changeaccount[]" value="' . $objp->fdid . '"/></td>';
|
|
|
|
|
|
print "</tr>";
|
|
|
$i ++;
|