|
@@ -43,7 +43,6 @@ $langs->load("accountancy");
|
|
|
$action = GETPOST('action');
|
|
|
|
|
|
// Select Box
|
|
|
-$codeventil = GETPOST('codeventil', 'array');
|
|
|
$mesCasesCochees = GETPOST('mesCasesCochees', 'array');
|
|
|
|
|
|
// Search Getpost
|
|
@@ -56,28 +55,20 @@ $search_account = GETPOST('search_account', 'alpha');
|
|
|
$search_vat = GETPOST('search_vat', 'alpha');
|
|
|
$btn_ventil = GETPOST('ventil', 'alpha');
|
|
|
|
|
|
-// Getpost Order and column and limit page
|
|
|
+// Load variable for pagination
|
|
|
+$limit = GETPOST('limit') ? GETPOST('limit', 'int') : (empty($conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION)?$conf->liste_limit:$conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION);
|
|
|
$sortfield = GETPOST('sortfield', 'alpha');
|
|
|
$sortorder = GETPOST('sortorder', 'alpha');
|
|
|
-
|
|
|
-$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 = GETPOST('limit') ? GETPOST('limit', 'int') : $conf->liste_limit;
|
|
|
-} else {
|
|
|
- $limit = GETPOST('limit') ? GETPOST('limit', 'int') : $conf->liste_limit;
|
|
|
-}
|
|
|
+$page = GETPOST('page','int');
|
|
|
+if ($page < 0) { $page = 0; }
|
|
|
$offset = $limit * $page;
|
|
|
-
|
|
|
+$pageprev = $page - 1;
|
|
|
+$pagenext = $page + 1;
|
|
|
if (! $sortfield)
|
|
|
$sortfield = "f.datef, f.ref, l.rowid";
|
|
|
if (! $sortorder) {
|
|
|
if ($conf->global->ACCOUNTING_LIST_SORT_VENTILATION_TODO > 0) {
|
|
|
- $sortorder = " DESC ";
|
|
|
+ $sortorder = "DESC";
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -104,7 +95,7 @@ $aarowid_p = $accounting->fetch('', $conf->global->ACCOUNTING_PRODUCT_BUY_ACCOUN
|
|
|
*/
|
|
|
|
|
|
// Purge search criteria
|
|
|
-if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter")) // Both test are required to be compatible with all browsers
|
|
|
+if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETPOST("button_removefilter")) // All test are required to be compatible with all browsers
|
|
|
{
|
|
|
$search_ref = '';
|
|
|
$search_label = '';
|
|
@@ -117,38 +108,51 @@ if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter")) // Both
|
|
|
if ($action == 'ventil' && ! empty($btn_ventil)) {
|
|
|
$msg='';
|
|
|
//print '<div><font color="red">' . $langs->trans("Processing") . '...</font></div>';
|
|
|
- if ($_POST['codeventil'] && $_POST["mesCasesCochees"]) {
|
|
|
- $msg = '<div><font color="red">' . count($_POST["mesCasesCochees"]) . ' ' . $langs->trans("SelectedLines") . '</font></div>';
|
|
|
+ if (! empty($mesCasesCochees)) {
|
|
|
+ $msg = '<div>' . $langs->trans("SelectedLines") . ': '.count($_POST["mesCasesCochees"]).'</div>';
|
|
|
+ $msg.='<div class="detail">';
|
|
|
$mesCodesVentilChoisis = $codeventil;
|
|
|
$cpt = 0;
|
|
|
+ $ok=0;
|
|
|
+ $ko=0;
|
|
|
|
|
|
foreach ( $mesCasesCochees as $maLigneCochee ) {
|
|
|
// print '<div><font color="red">id selectionnee : '.$monChoix."</font></div>";
|
|
|
$maLigneCourante = explode("_", $maLigneCochee);
|
|
|
$monId = $maLigneCourante[0];
|
|
|
- $monNumLigne = $maLigneCourante[1];
|
|
|
- $monCompte = $mesCodesVentilChoisis[$monNumLigne];
|
|
|
+ $monCompte = GETPOST('codeventil'.$monId);
|
|
|
|
|
|
- $sql = " UPDATE " . MAIN_DB_PREFIX . "facture_fourn_det";
|
|
|
- $sql .= " SET fk_code_ventilation = " . $monCompte;
|
|
|
- $sql .= " WHERE rowid = " . $monId;
|
|
|
-
|
|
|
- $accountventilated = new AccountingAccount($db);
|
|
|
- $accountventilated->fetch($monCompte, '');
|
|
|
-
|
|
|
- dol_syslog('accountancy/supplier/list.php:: sql=' . $sql, LOG_DEBUG);
|
|
|
- if ($db->query($sql)) {
|
|
|
- $msg.= '<div><font color="green">' . $langs->trans("Lineofinvoice") . ' ' . $monId . ' - ' . $langs->trans("VentilatedinAccount") . ' : ' . length_accountg($accountventilated->account_number) . '</font></div>';
|
|
|
- } else {
|
|
|
- $msg.= '<div><font color="red">' . $langs->trans("ErrorDB") . ' : ' . $langs->trans("Lineofinvoice") . ' ' . $monId . ' - ' . $langs->trans("NotVentilatedinAccount") . ' : ' . length_accountg($accountventilated->account_number) . '<br/> <pre>' . $sql . '</pre></font></div>';
|
|
|
+ if ($monCompte <= 0)
|
|
|
+ {
|
|
|
+ $msg.= '<div><font color="red">' . $langs->trans("Lineofinvoice") . ' ' . $monId . ' - ' . $langs->trans("NoAccountSelected") . '</font></div>';
|
|
|
+ $ko++;
|
|
|
}
|
|
|
-
|
|
|
- $cpt ++;
|
|
|
+ else
|
|
|
+ {
|
|
|
+ $sql = " UPDATE " . MAIN_DB_PREFIX . "facture_fourn_det";
|
|
|
+ $sql .= " SET fk_code_ventilation = " . $monCompte;
|
|
|
+ $sql .= " WHERE rowid = " . $monId;
|
|
|
+
|
|
|
+ $accountventilated = new AccountingAccount($db);
|
|
|
+ $accountventilated->fetch($monCompte, '');
|
|
|
+
|
|
|
+ dol_syslog('accountancy/supplier/list.php:: sql=' . $sql, LOG_DEBUG);
|
|
|
+ if ($db->query($sql)) {
|
|
|
+ $ok++;
|
|
|
+ $msg.= '<div><font color="green">' . $langs->trans("Lineofinvoice") . ' ' . $monId . ' - ' . $langs->trans("VentilatedinAccount") . ' : ' . length_accountg($accountventilated->account_number) . '</font></div>';
|
|
|
+ } else {
|
|
|
+ $ko++;
|
|
|
+ $msg.= '<div><font color="red">' . $langs->trans("ErrorDB") . ' : ' . $langs->trans("Lineofinvoice") . ' ' . $monId . ' - ' . $langs->trans("NotVentilatedinAccount") . ' : ' . length_accountg($accountventilated->account_number) . '<br/> <pre>' . $sql . '</pre></font></div>';
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ $cpt++;
|
|
|
}
|
|
|
+ $msg.='</div>';
|
|
|
} else {
|
|
|
- $msg.= '<div><font color="red">' . $langs->trans("AnyLineVentilate") . '</font></div>';
|
|
|
+ setEventMessages($langs->trans("NoRecordSelected"), null, 'warnings');
|
|
|
}
|
|
|
- $msg.= '<div><font color="red">' . $langs->trans("EndProcessing") . '</font></div>';
|
|
|
+ $msg.= '<div>' . $langs->trans("EndProcessing") . '</div>';
|
|
|
}
|
|
|
|
|
|
|
|
@@ -158,37 +162,7 @@ if ($action == 'ventil' && ! empty($btn_ventil)) {
|
|
|
*/
|
|
|
llxHeader('', $langs->trans("SuppliersVentilation"));
|
|
|
|
|
|
-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>';
|
|
|
-
|
|
|
-
|
|
|
-/*
|
|
|
- * Supplier Invoice Lines
|
|
|
- */
|
|
|
-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 = GETPOST('limit') ? GETPOST('limit', 'int') : $conf->liste_limit;
|
|
|
-} else {
|
|
|
- $limit = GETPOST('limit') ? GETPOST('limit', 'int') : $conf->liste_limit;
|
|
|
-}
|
|
|
-
|
|
|
-$offset = $limit * $page;
|
|
|
-
|
|
|
+// Supplier Invoice Lines
|
|
|
$sql = "SELECT f.ref, f.rowid as facid, f.ref_supplier, f.datef, l.fk_product, l.description, l.total_ht as price, l.rowid, l.fk_code_ventilation, l.product_type as type_l, l.tva_tx as tva_tx_line, ";
|
|
|
$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";
|
|
@@ -197,7 +171,7 @@ $sql .= " INNER JOIN " . MAIN_DB_PREFIX . "facture_fourn_det as l ON f.rowid = l
|
|
|
$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";
|
|
|
$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 .= " WHERE f.fk_statut > 0 AND l.fk_code_ventilation <= 0";
|
|
|
$sql .= " AND product_type <= 2";
|
|
|
$sql .= " AND (accsys.rowid='" . $conf->global->CHARTOFACCOUNTS . "' OR p.accountancy_code_sell IS NULL OR p.accountancy_code_buy ='')";
|
|
|
// Add search filter like
|
|
@@ -225,50 +199,71 @@ if (strlen(trim($search_vat))) {
|
|
|
if (! empty($conf->multicompany->enabled)) {
|
|
|
$sql .= " AND f.entity IN (" . getEntity("facture_fourn", 1) . ")";
|
|
|
}
|
|
|
-
|
|
|
$sql .= $db->order($sortfield, $sortorder);
|
|
|
|
|
|
+// Count total nb of records
|
|
|
+$nbtotalofrecords = 0;
|
|
|
+if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
|
|
|
+{
|
|
|
+ $result = $db->query($sql);
|
|
|
+ $nbtotalofrecords = $db->num_rows($result);
|
|
|
+}
|
|
|
+
|
|
|
$sql .= $db->plimit($limit + 1, $offset);
|
|
|
|
|
|
-dol_syslog('accountancy/supplier/list.php:: $sql=' . $sql);
|
|
|
+dol_syslog('accountancy/supplier/list.php');
|
|
|
$result = $db->query($sql);
|
|
|
if ($result) {
|
|
|
$num_lines = $db->num_rows($result);
|
|
|
$i = 0;
|
|
|
|
|
|
- // 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, 0, 'title_accountancy');
|
|
|
+ $arrayofselected=is_array($toselect)?$toselect:array();
|
|
|
+
|
|
|
+ $param='';
|
|
|
+ if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage;
|
|
|
+ if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit;
|
|
|
+
|
|
|
+ print '<form action="' . $_SERVER["PHP_SELF"] . '" method="post">' . "\n";
|
|
|
+ print '<input type="hidden" name="action" value="ventil">';
|
|
|
+ if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
|
|
|
+ print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
|
|
+ print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
|
|
|
+ print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
|
|
|
+ print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
|
|
|
+
|
|
|
+ $center='<div align="center"><input type="submit" class="butAction" value="' . $langs->trans("Ventilate") . '" name="ventil"></div>';
|
|
|
+
|
|
|
+ print_barre_liste($langs->trans("InvoiceLines"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $center, $num_lines, 0, 'title_accountancy', 0, '', '', $limit);
|
|
|
|
|
|
if ($msg) print $msg.'<br>';
|
|
|
|
|
|
print $langs->trans("DescVentilTodoCustomer") . '</br><br>';
|
|
|
|
|
|
- print '<form action="' . $_SERVER["PHP_SELF"] . '" method="post">' . "\n";
|
|
|
- print '<input type="hidden" name="action" value="ventil">';
|
|
|
-
|
|
|
- print '<table class="noborder" width="100%">';
|
|
|
+ $moreforfilter = '';
|
|
|
+
|
|
|
+ print '<table class="tagtable liste'.($moreforfilter?" listwithfilterbefore":"").'">'."\n";
|
|
|
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"), $_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("Amount"), $_SERVER["PHP_SELF"], "l.total_ht", "", $param, 'align="right"', $sortfield, $sortorder);
|
|
|
+ print_liste_field_titre($langs->trans("VATRate"), $_SERVER["PHP_SELF"], "l.tva_tx", "", $param, 'align="right"', $sortfield, $sortorder);
|
|
|
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("LineId"), $_SERVER["PHP_SELF"], "l.rowid", "", $param, 'align="right"', $sortfield, $sortorder);
|
|
|
print_liste_field_titre('', '', '', '', '', 'align="center"');
|
|
|
print "</tr>\n";
|
|
|
|
|
|
print '<tr class="liste_titre">';
|
|
|
print '<td class="liste_titre"><input type="text" class="flat" size="10" name="search_invoice" 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="20" name="search_label" value="' . $search_label . '"></td>';
|
|
|
- print '<td class="liste_titre"><input type="text" class="flat" size="20" name="search_desc" value="' . $search_desc . '"></td>';
|
|
|
- print '<td class="liste_titre" align="right"><input type="text" class="flat" size="10" 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"> </td>';
|
|
|
- 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="10" name="search_label" value="' . $search_label . '"></td>';
|
|
|
+ print '<td class="liste_titre"><input type="text" class="flat" size="10" name="search_desc" value="' . $search_desc . '"></td>';
|
|
|
+ print '<td class="liste_titre" align="right"><input type="text" class="flat" size="6" name="search_amount" value="' . $search_amount . '"></td>';
|
|
|
+ print '<td class="liste_titre" align="right"><input type="text" class="flat" size="5" name="search_vat" value="' . $search_vat . '"></td>';
|
|
|
+ print '<td class="liste_titre"></td>';
|
|
|
+ print '<td class="liste_titre"></td>';
|
|
|
print '<td class="liste_titre"></td>';
|
|
|
print '<td align="right" class="liste_titre">';
|
|
|
$searchpitco=$form->showFilterAndCheckAddButtons(1);
|
|
@@ -322,7 +317,7 @@ if ($result) {
|
|
|
if ($objp->code_buy_l != $objp->code_buy_p)
|
|
|
$code_buy_p_l_differ = 'color:red';
|
|
|
|
|
|
- print '<tr'. $bc[$var].'>';
|
|
|
+ print '<tr '. $bc[$var].'>';
|
|
|
|
|
|
// Ref Invoice
|
|
|
$facturefourn_static->ref = $objp->ref;
|
|
@@ -350,26 +345,31 @@ if ($result) {
|
|
|
print price($objp->price);
|
|
|
print '</td>';
|
|
|
|
|
|
+ // Vat rate
|
|
|
if ($objp->vat_tx_l != $objp->vat_tx_p)
|
|
|
$code_vat_differ = 'font-weight:bold; text-decoration:blink; color:red';
|
|
|
- print '<td style="' . $code_vat_differ . '" align="center">';
|
|
|
+ print '<td style="' . $code_vat_differ . '" align="right">';
|
|
|
print price($objp->tva_tx_line);
|
|
|
print '</td>';
|
|
|
|
|
|
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 not same kind of product_type stored in product & facturedet we display both account and let user choose
|
|
|
if ($objp->code_buy_l == $objp->code_buy_p) {
|
|
|
- print $objp->code_buy_l;
|
|
|
- } else {
|
|
|
+ if ($objp->code_buy_l > 0) print $objp->code_buy_l;
|
|
|
+ else print $langs->trans("Unknown");
|
|
|
+ } else { // This can happen if user has change type of product after creation of invoice
|
|
|
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_suggest, 'codeventil[]', 1);
|
|
|
+ print $formventilation->select_account($objp->aarowid_suggest, 'codeventil'.$objp->rowid, 1);
|
|
|
print '</td>';
|
|
|
+
|
|
|
+ // Line id
|
|
|
print '<td align="center">' . $objp->rowid . '</td>';
|
|
|
+
|
|
|
// Colonne choix ligne a ventiler
|
|
|
print '<td align="right">';
|
|
|
print '<input type="checkbox" class="checkforaction" name="mesCasesCochees[]" value="' . $objp->rowid . "_" . $i . '"' . ($objp->aarowid ? "checked" : "") . '/>';
|
|
@@ -380,7 +380,6 @@ if ($result) {
|
|
|
}
|
|
|
|
|
|
print '</table>';
|
|
|
- print '<br><div align="center"><input type="submit" class="butAction" value="' . $langs->trans("Ventilate") . '" name="ventil" ></div>';
|
|
|
print '</form>';
|
|
|
} else {
|
|
|
print $db->error();
|