';
- print '| ';
+ print ' | ';
if ($row[0] == 'tobind') {
//print ''.$langs->trans("Unknown").'';
} else {
print length_accountg($row[0]).' - ';
}
- //print ' | ';
- //print '';
if ($row[0] == 'tobind') {
print $langs->trans("UseMenuToSetBindindManualy", DOL_URL_ROOT.'/accountancy/expensereport/list.php?search_year='.((int) $y), $langs->transnoentitiesnoconv("ToBind"));
} else {
diff --git a/htdocs/accountancy/supplier/card.php b/htdocs/accountancy/supplier/card.php
index 153c86b7c6c..03332e9a862 100644
--- a/htdocs/accountancy/supplier/card.php
+++ b/htdocs/accountancy/supplier/card.php
@@ -141,20 +141,23 @@ if (!empty($id)) {
print '';
- // ref invoice
+ // Ref invoice
print '| '.$langs->trans("BillsSuppliers").' | ';
$facturefournisseur_static->ref = $objp->ref;
$facturefournisseur_static->id = $objp->facid;
print ''.$facturefournisseur_static->getNomUrl(1).' | ';
print ' ';
- print '| '.$langs->trans("Line").' | ';
- print ''.stripslashes(nl2br($objp->description)).' | ';
- print '| '.$langs->trans("ProductLabel").' | ';
- print ''.dol_trunc($objp->product_label, 24).' | ';
- print ' | '.$langs->trans("Account").' | ';
+ print ' | | '.$langs->trans("Description").' | ';
+ print ''.dolPrintHTML($objp->description).' | ';
+
+ print '| '.$langs->trans("ProductLabel").' | ';
+ print ''.dol_trunc($objp->product_label, 24).' | ';
+
+ print '| '.$langs->trans("Account").' | ';
print $formaccounting->select_account($objp->fk_code_ventilation, 'codeventil', 1);
print ' | ';
+
print ' ';
print dol_get_fiche_end();
diff --git a/htdocs/accountancy/supplier/index.php b/htdocs/accountancy/supplier/index.php
index bb9572bc879..19064b24d6d 100644
--- a/htdocs/accountancy/supplier/index.php
+++ b/htdocs/accountancy/supplier/index.php
@@ -81,7 +81,7 @@ if (!$user->hasRight('accounting', 'bind', 'write')) {
*/
if (($action == 'clean' || $action == 'validatehistory') && $user->hasRight('accounting', 'bind', 'write')) {
- // Clean database
+ // Clean database by removing binding done on non existing or no more existing accounts
$db->begin();
$sql1 = "UPDATE ".$db->prefix()."facture_fourn_det as fd";
$sql1 .= " SET fk_code_ventilation = 0";
@@ -178,31 +178,31 @@ if ($action == 'validatehistory' && $user->hasRight('accounting', 'bind', 'write
while ($i < min($num_lines, 10000)) { // No more than 10000 at once
$objp = $db->fetch_object($result);
- $thirdpartystatic->id = $objp->socid;
- $thirdpartystatic->name = $objp->name;
- $thirdpartystatic->client = $objp->client;
- $thirdpartystatic->fournisseur = $objp->fournisseur;
- $thirdpartystatic->code_client = $objp->code_client;
- $thirdpartystatic->code_compta_client = $objp->code_compta_client;
- $thirdpartystatic->code_fournisseur = $objp->code_fournisseur;
- $thirdpartystatic->code_compta_fournisseur = $objp->code_compta_fournisseur;
- $thirdpartystatic->email = $objp->email;
- $thirdpartystatic->country_code = $objp->country_code;
- $thirdpartystatic->tva_intra = $objp->tva_intra;
+ $thirdpartystatic->id = !empty($objp->socid) ? $objp->socid : 0;
+ $thirdpartystatic->name = !empty($objp->name) ? $objp->name : "";
+ $thirdpartystatic->client = !empty($objp->client) ? $objp->client : "";
+ $thirdpartystatic->fournisseur = !empty($objp->fournisseur) ? $objp->fournisseur : "";
+ $thirdpartystatic->code_client = !empty($objp->code_client) ? $objp->code_client : "";
+ $thirdpartystatic->code_compta_client = !empty($objp->code_compta_client) ? $objp->code_compta_client : "";
+ $thirdpartystatic->code_fournisseur = !empty($objp->code_fournisseur) ? $objp->code_fournisseur : "";
+ $thirdpartystatic->code_compta_fournisseur = !empty($objp->code_compta_fournisseur) ? $objp->code_compta_fournisseur : "";
+ $thirdpartystatic->email = !empty($objp->email) ? $objp->email : "";
+ $thirdpartystatic->country_code = !empty($objp->country_code) ? $objp->country_code : "";
+ $thirdpartystatic->tva_intra = !empty($objp->tva_intra) ? $objp->tva_intra : "";
$thirdpartystatic->code_compta_product = $objp->company_code_buy; // The accounting account for product stored on thirdparty object (for level3 suggestion)
$product_static->ref = $objp->product_ref;
$product_static->id = $objp->product_id;
$product_static->type = $objp->type;
$product_static->label = $objp->product_label;
- $product_static->status = $objp->status;
- $product_static->status_buy = $objp->status_buy;
+ $product_static->status = !empty($objp->status) ? $objp->status : 0;
+ $product_static->status_buy = !empty($objp->status_buy) ? $objp->status_buy : 0;
$product_static->accountancy_code_sell = $objp->code_sell;
$product_static->accountancy_code_sell_intra = $objp->code_sell_intra;
$product_static->accountancy_code_sell_export = $objp->code_sell_export;
- $product_static->accountancy_code_buy = $objp->code_buy;
- $product_static->accountancy_code_buy_intra = $objp->code_buy_intra;
- $product_static->accountancy_code_buy_export = $objp->code_buy_export;
+ $product_static->accountancy_code_buy = !empty($objp->code_buy) ? $objp->code_buy : "";
+ $product_static->accountancy_code_buy_intra = !empty($objp->code_buy_intra) ? $objp->code_buy_intra : "";
+ $product_static->accountancy_code_buy_export = !empty($objp->code_buy_export) ? $objp->code_buy_export : "";
$product_static->tva_tx = $objp->tva_tx_prod;
$facture_static->ref = $objp->ref;
@@ -301,7 +301,7 @@ print ' ';
$y = $year_current;
-$buttonbind = ''.img_picto('', 'link', 'class="paddingright fa-color-unset smallpaddingimp"').$langs->trans("ValidateHistory").'';
+$buttonbind = ''.img_picto($langs->trans("ValidateHistory"), 'link', 'class="pictofixedwidth fa-color-unset"').$langs->trans("ValidateHistory").'';
print_barre_liste(img_picto('', 'unlink', 'class="paddingright fa-color-unset"').$langs->trans("OverviewOfAmountOfLinesNotBound"), '', '', '', '', '', '', -1, '', '', 0, '', '', 0, 1, 1, 0, $buttonbind);
@@ -344,8 +344,9 @@ for ($i = 1; $i <= 12; $i++) {
$j -= 12;
}
$sql .= " SUM(".$db->ifsql("MONTH(ff.datef) = ".((int) $j), "ffd.total_ht", "0").") AS month".str_pad((string) $j, 2, "0", STR_PAD_LEFT).",";
+ $sql .= " SUM(".$db->ifsql("MONTH(ff.datef) = ".((string) $j), "1", "0").") AS nbmonth".str_pad((string) $j, 2, "0", STR_PAD_LEFT).",";
}
-$sql .= " SUM(ffd.total_ht) as total";
+$sql .= " SUM(ffd.total_ht) as total, COUNT(ffd.rowid) as nb";
$sql .= " FROM ".$db->prefix()."facture_fourn_det as ffd";
$sql .= " LEFT JOIN ".$db->prefix()."facture_fourn as ff ON ff.rowid = ffd.fk_facture_fourn";
$sql .= " LEFT JOIN ".$db->prefix()."accounting_account as aa ON aa.rowid = ffd.fk_code_ventilation";
@@ -405,17 +406,17 @@ if ($resql) {
$cursoryear = ($cursormonth < getDolGlobalInt('SOCIETE_FISCAL_MONTH_START', 1)) ? $y + 1 : $y;
$tmp = dol_getdate(dol_get_last_day($cursoryear, $cursormonth, 'gmt'), false, 'gmt');
- print ' | ';
- print price($row[$i]);
+ print ' | ';
+ print price($row[2*$i - 2]);
// Add link to make binding
- if (!empty(price2num($row[$i]))) {
+ if (!empty(price2num($row[2*$i - 2])) || !empty($row[2*$i - 1])) {
print '';
print img_picto($langs->trans("ValidateHistory").' ('.$langs->trans('Month'.str_pad((string) $cursormonth, 2, '0', STR_PAD_LEFT)).' '.$cursoryear.')', 'link', 'class="marginleft2"');
print '';
}
print ' | ';
}
- print ''.price($row[14]).' | ';
+ print ''.price($row[26]).' | ';
print '
';
}
$db->free($resql);