This commit is contained in:
Anthony Berton 2022-07-27 15:35:35 +02:00
parent da7f267df3
commit 0e796a2a02

View File

@ -11,7 +11,7 @@
* Copyright (C) 2015 Jean-François Ferry <jfefe@aternatik.fr>
* Copyright (C) 2016-2021 Ferran Marcet <fmarcet@2byte.es>
* Copyright (C) 2018 Charlene Benke <charlie@patas-monkey.com>
* Copyright (C) 2021 Anthony Berton <anthony.berton@bb2a.fr>
* Copyright (C) 2021-2022 Anthony Berton <anthony.berton@bb2a.fr>
*
* 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
@ -71,15 +71,12 @@ $search_dateorder_end = dol_mktime(23, 59, 59, GETPOST('search_dateorder_end_mon
$search_datedelivery_start = dol_mktime(0, 0, 0, GETPOST('search_datedelivery_start_month', 'int'), GETPOST('search_datedelivery_start_day', 'int'), GETPOST('search_datedelivery_start_year', 'int'));
$search_datedelivery_end = dol_mktime(23, 59, 59, GETPOST('search_datedelivery_end_month', 'int'), GETPOST('search_datedelivery_end_day', 'int'), GETPOST('search_datedelivery_end_year', 'int'));
$search_product_category = GETPOST('search_product_category', 'int');
/*
// Détail commande
*/
$search_refProduct = GETPOST('search_refProduct', 'alpha');
$search_descProduct = GETPOST('search_descProduct', 'alpha');
$check_orderdetail = GETPOST('check_orderdetail', 'alpha');
/*
// Détail commande fin
*/
$search_ref = GETPOST('search_ref', 'alpha') != '' ?GETPOST('search_ref', 'alpha') : GETPOST('sref', 'alpha');
$search_ref_customer = GETPOST('search_ref_customer', 'alpha');
$search_company = GETPOST('search_company', 'alpha');
@ -213,17 +210,14 @@ $arrayfields = array(
'c.import_key' =>array('type'=>'varchar(14)', 'label'=>'ImportId', 'enabled'=>1, 'visible'=>-2, 'position'=>999),
'c.fk_statut'=>array('label'=>"Status", 'checked'=>1, 'position'=>1000)
);
/*
// Détail commande fin
*/
// Détail commande
if (!empty($check_orderdetail)) {
$arrayfields['cdet.qty'] = array('label'=>'QtyOrdered', 'checked'=>1, 'position'=>1);
$arrayfields['pr.desc'] = array('label'=>'ProductDescription', 'checked'=>1, 'position'=>1);
$arrayfields['pr.ref'] = array('label'=>'ProductRef', 'checked'=>1, 'position'=>1);
}
/*
// Détail commande fin
*/
// Extra fields
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php';
@ -812,16 +806,13 @@ $sql .= ' p.rowid as project_id, p.ref as project_ref, p.title as project_label,
$sql .= ' u.login, u.lastname, u.firstname, u.email as user_email, u.statut as user_statut, u.entity, u.photo, u.office_phone, u.office_fax, u.user_mobile, u.job, u.gender,';
$sql .= ' c.fk_cond_reglement,c.deposit_percent,c.fk_mode_reglement,c.fk_shipping_method,';
$sql .= ' c.fk_input_reason, c.import_key';
/*
// Détail commande
*/
if (!empty($check_orderdetail)) {
$sql .= ', cdet.description, cdet.qty, ';
$sql .= ' pr.rowid as product_rowid, pr.ref as product_ref, pr.label as product_label, pr.barcode as product_barcode, pr.tobatch as product_batch, pr.tosell as product_status, pr.tobuy as product_status_buy';
}
/*
// Détail commande fin
*/
if (($search_categ_cus > 0) || ($search_categ_cus == -2)) {
$sql .= ", cc.fk_categorie, cc.fk_soc";
}
@ -842,9 +833,8 @@ $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_departements as state on (state.rowid =
if (($search_categ_cus > 0) || ($search_categ_cus == -2)) {
$sql .= ' LEFT JOIN '.MAIN_DB_PREFIX."categorie_societe as cc ON s.rowid = cc.fk_soc"; // We'll need this table joined to the select in order to filter by categ
}
/*
// Détail commande
*/
if (!empty($check_orderdetail)) {
$sql .= ', '.MAIN_DB_PREFIX.'commandedet as cdet';
$sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'commande as c ON cdet.fk_commande=c.rowid';
@ -852,9 +842,7 @@ if (!empty($check_orderdetail)) {
} else {
$sql .= ', '.MAIN_DB_PREFIX.'commande as c';
}
/*
// Détail commande fin
*/
if (!empty($extrafields->attributes[$object->table_element]['label']) && is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) {
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."commande_extrafields as ef on (c.rowid = ef.fk_object)";
}
@ -1355,13 +1343,10 @@ if ($resql) {
print '</div>';
print '<br>';
}
/*
// Détail commande
*/
print '<div class="nowrap inline-block minheight30"><input type="checkbox" id="check_orderdetail" name="check_orderdetail" class="check_orderdetail"'.($check_orderdetail ? ' checked' : '').'><label for="check_orderdetail"> <span class="check_orderdetail_text">'.$langs->trans("OrderShowDetail").'</span></label> &nbsp; </div>';
/*
// Détail commande fin
*/
if ($sall) {
foreach ($fieldstosearchall as $key => $val) {
@ -1444,9 +1429,7 @@ if ($resql) {
print '<tr class="liste_titre_filter">';
/*
// Détail commande
*/
// Détail commande
if (!empty($arrayfields['pr.ref']['checked'])) {
print '<td class="liste_titre">';
print '<input class="flat" size="6" type="text" name="search_refProduct" value="'.dol_escape_htmltag($search_refProduct).'">';
@ -1462,9 +1445,6 @@ if ($resql) {
if (!empty($arrayfields['cdet.qty']['checked'])) {
print '<td class="liste_titre"></td>';
}
/*
// Détail commande fin
*/
// Action column
if (!empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) {
@ -1737,9 +1717,7 @@ if ($resql) {
// Fields title
print '<tr class="liste_titre">';
/*
// Détail commande
*/
if (!empty($arrayfields['pr.ref']['checked'])) {
print_liste_field_titre($arrayfields['pr.ref']['label'], $_SERVER["PHP_SELF"], 'pr.ref', '', $param, '', $sortfield, $sortorder);
}
@ -1749,9 +1727,6 @@ if ($resql) {
if (!empty($arrayfields['cdet.qty']['checked'])) {
print_liste_field_titre($arrayfields['cdet.qty']['label'], $_SERVER["PHP_SELF"], 'cdet.qty', '', $param, '', $sortfield, $sortorder);
}
/*
// Détail commande fin
*/
if (!empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) {
print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', $param, '', $sortfield, $sortorder, 'maxwidthsearch center ');
@ -1927,14 +1902,9 @@ if ($resql) {
}
$total_ht = 0;
$total_margin = 0;
/*
// Détail commande
*/
$totalqty = 0;
/*
// Détail commande fin
*/
$imaxinloop = ($limit ? min($num, $limit) : $num);
$last_num = min($num, $limit);
@ -1987,46 +1957,10 @@ if ($resql) {
$total_ht += $obj->total_ht;
$total_margin += $marginInfo['total_margin'];
}
/*
// Détail commande
*//*
if (isset($refpre) && $obj->product_ref != $refpre) {
print '<tr class="liste_total">';
$i = 0;
// var_dump($totalarray);
while ($i < $totalarray['nbfield']) {
$i++;
if (!empty($totalarray['pos'][$i]) && $totalarray['pos'][$i] == 'cdet.qty') {
print '<td class="nowrap tdoverflowmax200">'.$totalqty.'</td>';
} elseif ($i == 1) {
print '<td>';
if (is_object($form)) {
print $form->textwithpicto($langs->trans("Total"), $langs->transnoentitiesnoconv("Totalforthispage"));
} else {
print $langs->trans("Totalforthispage");
}
print '</td>';
} else {
print '<td></td>';
}
}
print '</tr>';
$totalqty = $obj->qty;
//include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php';
} else {
$totalqty = $totalqty + $obj->qty;
}
$refpre = isset($obj->product_ref) ? $obj->product_ref : '';
/*
// Détail commande fin
*/
print '<tr class="oddeven">';
/*
// Détail commande
*/
// Product Ref
if (!empty($arrayfields['pr.ref']['checked'])) {
if (!empty($obj->product_rowid)) {
@ -2070,9 +2004,6 @@ if ($resql) {
$totalarray['val']['cdet.qty'] = $obj->qty;
}
}
/*
// Détail commande fin
*/
// Action column
if (!empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) {