|
@@ -65,6 +65,8 @@ $search_vat = GETPOST('search_vat', 'alpha');
|
|
|
$search_day=GETPOST("search_day","int");
|
|
|
$search_month=GETPOST("search_month","int");
|
|
|
$search_year=GETPOST("search_year","int");
|
|
|
+$search_country = GETPOST('search_country', 'alpha');
|
|
|
+$search_tvaintra = GETPOST('search_tvaintra', 'alpha');
|
|
|
|
|
|
$btn_ventil = GETPOST('ventil', 'alpha');
|
|
|
|
|
@@ -104,7 +106,7 @@ $chartaccountcode = dol_getIdFromCode($db, $conf->global->CHARTOFACCOUNTS, 'acco
|
|
|
|
|
|
|
|
|
/*
|
|
|
- * Action
|
|
|
+ * Actions
|
|
|
*/
|
|
|
|
|
|
if (GETPOST('cancel','alpha')) { $action='list'; $massaction=''; }
|
|
@@ -130,6 +132,8 @@ if (empty($reshook))
|
|
|
$search_day = '';
|
|
|
$search_month = '';
|
|
|
$search_year = '';
|
|
|
+ $search_country = '';
|
|
|
+ $search_tvaintra = '';
|
|
|
}
|
|
|
|
|
|
// Mass actions
|
|
@@ -213,11 +217,14 @@ if (empty($chartaccountcode))
|
|
|
$sql = "SELECT f.rowid as facid, f.ref, f.ref_supplier, f.libelle as invoice_label, f.datef, f.type as ftype,";
|
|
|
$sql.= " l.rowid, l.fk_product, l.description, l.total_ht, l.fk_code_ventilation, l.product_type as type_l, l.tva_tx as tva_tx_line, l.vat_src_code,";
|
|
|
$sql.= " p.rowid as product_id, p.ref as product_ref, p.label as product_label, p.fk_product_type as type, p.accountancy_code_buy as code_buy, p.tva_tx as tva_tx_prod,";
|
|
|
-$sql.= " aa.rowid as aarowid";
|
|
|
+$sql.= " aa.rowid as aarowid,";
|
|
|
+$sql.= " co.label as country, s.tva_intra";
|
|
|
$parameters=array();
|
|
|
$reshook=$hookmanager->executeHooks('printFieldListSelect',$parameters); // Note that $action and $object may have been modified by hook
|
|
|
$sql.=$hookmanager->resPrint;
|
|
|
$sql.= " FROM " . MAIN_DB_PREFIX . "facture_fourn as f";
|
|
|
+$sql .= " INNER JOIN " . MAIN_DB_PREFIX . "societe as s ON s.rowid = f.fk_soc";
|
|
|
+$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "c_country as co ON co.rowid = s.fk_pays ";
|
|
|
$sql.= " INNER JOIN " . MAIN_DB_PREFIX . "facture_fourn_det as l ON f.rowid = l.fk_facture_fourn";
|
|
|
$sql.= " LEFT JOIN " . MAIN_DB_PREFIX . "product as p ON p.rowid = l.fk_product";
|
|
|
$sql.= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa ON p.accountancy_code_buy = aa.account_number AND aa.fk_pcg_version = '" . $chartaccountcode."'";
|
|
@@ -228,25 +235,28 @@ if ($search_lineid) {
|
|
|
$sql .= natural_search("l.rowid", $search_lineid, 1);
|
|
|
}
|
|
|
if (strlen(trim($search_invoice))) {
|
|
|
- $sql .= natural_search("f.ref",$search_invoice);
|
|
|
+ $sql .= natural_search("f.ref", $search_invoice);
|
|
|
}
|
|
|
if (strlen(trim($search_ref))) {
|
|
|
- $sql .= natural_search("p.ref",$search_ref);
|
|
|
+ $sql .= natural_search("p.ref", $search_ref);
|
|
|
}
|
|
|
if (strlen(trim($search_label))) {
|
|
|
- $sql .= natural_search("p.label",$search_label);
|
|
|
+ $sql .= natural_search("p.label", $search_label);
|
|
|
}
|
|
|
if (strlen(trim($search_desc))) {
|
|
|
- $sql .= natural_search("l.description",$search_desc);
|
|
|
+ $sql .= natural_search("l.description", $search_desc);
|
|
|
}
|
|
|
if (strlen(trim($search_amount))) {
|
|
|
- $sql .= natural_search("l.total_ht",$search_amount,1);
|
|
|
+ $sql .= natural_search("l.total_ht", $search_amount, 1);
|
|
|
}
|
|
|
if (strlen(trim($search_account))) {
|
|
|
- $sql .= natural_search("aa.account_number",$search_account);
|
|
|
+ $sql .= natural_search("aa.account_number", $search_account);
|
|
|
}
|
|
|
if (strlen(trim($search_vat))) {
|
|
|
- $sql .= natural_search("l.tva_tx",$search_vat,1);
|
|
|
+ $sql .= natural_search("l.tva_tx", price2num($search_vat), 1);
|
|
|
+}
|
|
|
+if (strlen(trim($search_tvaintra))) {
|
|
|
+ $sql .= natural_search("s.tva_intra", $search_tvaintra);
|
|
|
}
|
|
|
if ($search_month > 0)
|
|
|
{
|
|
@@ -261,6 +271,9 @@ else if ($search_year > 0)
|
|
|
{
|
|
|
$sql.= " AND f.datef BETWEEN '".$db->idate(dol_get_first_day($search_year,1,false))."' AND '".$db->idate(dol_get_last_day($search_year,12,false))."'";
|
|
|
}
|
|
|
+if (strlen(trim($search_country))) {
|
|
|
+ $sql .= natural_search("co.label", $search_country);
|
|
|
+}
|
|
|
if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) {
|
|
|
$sql .= " AND f.type IN (" . FactureFournisseur::TYPE_STANDARD . "," . FactureFournisseur::TYPE_REPLACEMENT . "," . FactureFournisseur::TYPE_CREDIT_NOTE . "," . FactureFournisseur::TYPE_SITUATION . ")";
|
|
|
} else {
|
|
@@ -287,6 +300,7 @@ $sql .= $db->plimit($limit + 1, $offset);
|
|
|
|
|
|
dol_syslog('accountancy/supplier/list.php');
|
|
|
$result = $db->query($sql);
|
|
|
+
|
|
|
if ($result) {
|
|
|
$num_lines = $db->num_rows($result);
|
|
|
$i = 0;
|
|
@@ -305,6 +319,8 @@ if ($result) {
|
|
|
if ($search_desc) $param.='&search_desc='.urlencode($search_desc);
|
|
|
if ($search_amount) $param.='&search_amount='.urlencode($search_amount);
|
|
|
if ($search_vat) $param.='&search_vat='.urlencode($search_vat);
|
|
|
+ if ($search_country) $param .= "&search_country=" . urlencode($search_country);
|
|
|
+ if ($search_tvaintra) $param .= "&search_tvaintra=" . urlencode($search_tvaintra);
|
|
|
|
|
|
$arrayofmassactions = array(
|
|
|
'ventil'=>$langs->trans("Ventilate")
|
|
@@ -343,7 +359,7 @@ if ($result) {
|
|
|
|
|
|
// We add search filter
|
|
|
print '<tr class="liste_titre_filter">';
|
|
|
- print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_lineid" value="' . dol_escape_htmltag($search_lineid) . '""></td>';
|
|
|
+ print '<td class="liste_titre"><input type="text" class="flat maxwidth25" name="search_lineid" value="' . dol_escape_htmltag($search_lineid) . '""></td>';
|
|
|
print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_invoice" value="' . dol_escape_htmltag($search_invoice) . '"></td>';
|
|
|
print '<td class="liste_titre"></td>';
|
|
|
print '<td class="liste_titre center">';
|
|
@@ -353,16 +369,18 @@ if ($result) {
|
|
|
print '</td>';
|
|
|
print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_ref" value="' . dol_escape_htmltag($search_ref) . '"></td>';
|
|
|
//print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_label" value="' . dol_escape_htmltag($search_label) . '"></td>';
|
|
|
- print '<td class="liste_titre"><input type="text" class="flat maxwidthonsmartphone" name="search_desc" value="' . dol_escape_htmltag($search_desc) . '"></td>';
|
|
|
+ print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_desc" value="' . dol_escape_htmltag($search_desc) . '"></td>';
|
|
|
print '<td class="liste_titre" align="right"><input type="text" class="right flat maxwidth50" name="search_amount" value="' . dol_escape_htmltag($search_amount) . '"></td>';
|
|
|
print '<td class="liste_titre" align="right"><input type="text" class="right flat maxwidth50" name="search_vat" placeholder="%" size="1" value="' . dol_escape_htmltag($search_vat) . '"></td>';
|
|
|
+ print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_country" value="' . dol_escape_htmltag($search_country) . '"></td>';
|
|
|
+ print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_tvaintra" value="' . dol_escape_htmltag($search_tvaintra) . '"></td>';
|
|
|
print '<td class="liste_titre"></td>';
|
|
|
print '<td class="liste_titre"></td>';
|
|
|
print '<td align="center" class="liste_titre">';
|
|
|
$searchpicto=$form->showFilterButtons();
|
|
|
print $searchpicto;
|
|
|
print '</td>';
|
|
|
- print '</tr>';
|
|
|
+ print "</tr>\n";
|
|
|
|
|
|
print '<tr class="liste_titre">';
|
|
|
print_liste_field_titre("LineId", $_SERVER["PHP_SELF"], "l.rowid", "", $param, '', $sortfield, $sortorder);
|
|
@@ -374,6 +392,8 @@ if ($result) {
|
|
|
print_liste_field_titre("Description", $_SERVER["PHP_SELF"], "l.description", "", $param, '', $sortfield, $sortorder);
|
|
|
print_liste_field_titre("Amount", $_SERVER["PHP_SELF"], "l.total_ht", "", $param, 'align="right"', $sortfield, $sortorder);
|
|
|
print_liste_field_titre("VATRate", $_SERVER["PHP_SELF"], "l.tva_tx", "", $param, 'align="right"', $sortfield, $sortorder);
|
|
|
+ print_liste_field_titre("Country", $_SERVER["PHP_SELF"], "co.label", "", $param, '', $sortfield, $sortorder);
|
|
|
+ print_liste_field_titre("VATIntra", $_SERVER["PHP_SELF"], "s.tva_intra", "", $param, '', $sortfield, $sortorder);
|
|
|
print_liste_field_titre("AccountAccountingSuggest", '', '', '', '', 'align="center"');
|
|
|
print_liste_field_titre("IntoAccount", '', '', '', '', 'align="center"');
|
|
|
$checkpicto='';
|
|
@@ -383,10 +403,8 @@ if ($result) {
|
|
|
|
|
|
$facturefourn_static = new FactureFournisseur($db);
|
|
|
$productfourn_static = new ProductFournisseur($db);
|
|
|
- $form = new Form($db);
|
|
|
|
|
|
- $var = true;
|
|
|
- while ( $i < min($num_lines, $limit) ) {
|
|
|
+ while ($i < min($num_lines, $limit)) {
|
|
|
$objp = $db->fetch_object($result);
|
|
|
|
|
|
// product_type: 0 = service ? 1 = product
|
|
@@ -448,9 +466,9 @@ if ($result) {
|
|
|
if ($productfourn_static->id)
|
|
|
print $productfourn_static->getNomUrl(1);
|
|
|
if ($objp->product_label) print '<br>'.$objp->product_label;
|
|
|
- print '</td>';
|
|
|
+ print '</td>';
|
|
|
|
|
|
- // Description
|
|
|
+ // Description
|
|
|
print '<td>';
|
|
|
$text = dolGetFirstLineOfText(dol_string_nohtmltag($objp->description));
|
|
|
$trunclength = empty($conf->global->ACCOUNTING_LENGTH_DESCRIPTION) ? 32 : $conf->global->ACCOUNTING_LENGTH_DESCRIPTION;
|
|
@@ -468,6 +486,9 @@ if ($result) {
|
|
|
print vatrate($objp->tva_tx_line.($objp->vat_src_code?' ('.$objp->vat_src_code.')':''));
|
|
|
print '</td>';
|
|
|
|
|
|
+ print '<td>' . $objp->country .'</td>';
|
|
|
+ print '<td>' . $objp->tva_intra . '</td>';
|
|
|
+
|
|
|
// Current account
|
|
|
print '<td align="center" style="' . $code_buy_p_notset . '">';
|
|
|
print (($objp->type_l == 1)?$langs->trans("DefaultForService"):$langs->trans("DefaultForProduct")) . ' = ' . ($objp->code_buy_l > 0 ? length_accountg($objp->code_buy_l) : $langs->trans("Unknown"));
|