diff --git a/htdocs/supplier_proposal/list.php b/htdocs/supplier_proposal/list.php index 3e8b03d3d22..2fed4e1020d 100644 --- a/htdocs/supplier_proposal/list.php +++ b/htdocs/supplier_proposal/list.php @@ -48,8 +48,18 @@ if (isModEnabled('project')) { require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; } + +/** + * @var Conf $conf + * @var DoliDB $db + * @var HookManager $hookmanager + * @var Translate $langs + * @var User $user + */ + + // Load translation files required by the page -$langs->loadLangs(array('companies', 'propal', 'supplier_proposal', 'compta', 'bills', 'orders', 'products')); +$langs->loadLangs(array('companies', 'propal', 'supplier_proposal', 'compta', 'bills', 'orders', 'products', 'projects')); $socid = GETPOSTINT('socid'); @@ -97,6 +107,7 @@ $search_multicurrency_tx = GETPOST('search_multicurrency_tx', 'alpha'); $search_multicurrency_montant_ht = GETPOST('search_multicurrency_montant_ht', 'alpha'); $search_multicurrency_montant_vat = GETPOST('search_multicurrency_montant_vat', 'alpha'); $search_multicurrency_montant_ttc = GETPOST('search_multicurrency_montant_ttc', 'alpha'); +$search_project_ref = GETPOST('search_project_ref', 'alpha'); $search_status = GETPOST('search_status', 'intcomma'); $search_product_category = GETPOST('search_product_category', 'int'); $search_all = trim((GETPOST('search_all', 'alphanohtml') != '') ? GETPOST('search_all', 'alphanohtml') : GETPOST('sall', 'alphanohtml')); @@ -109,9 +120,10 @@ $limit = GETPOSTINT('limit') ? GETPOSTINT('limit') : $conf->liste_limit; $sortfield = GETPOST('sortfield', 'aZ09comma'); $sortorder = GETPOST('sortorder', 'aZ09comma'); $page = GETPOSTISSET('pageplusone') ? (GETPOSTINT('pageplusone') - 1) : GETPOSTINT("page"); -if (empty($page) || $page == -1 || !empty($search_btn) || !empty($search_remove_btn) || (empty($toselect) && $massaction === '0')) { +if (empty($page) || $page < 0 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha')) { + // If $page is not defined, or '' or -1 or if we click on clear filters $page = 0; -} // If $page is not defined, or '' or -1 +} $offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; @@ -156,12 +168,17 @@ $search_array_options = $extrafields->getOptionalsFromPost($object->table_elemen // List of fields to search into when doing a "search in all" -$fieldstosearchall = array( - 'sp.ref' => 'Ref', - 's.nom' => 'Supplier', - 'pd.description' => 'Description', - 'sp.note_public' => 'NotePublic', -); +$fieldstosearchall = array(); +foreach ($object->fields as $key => $val) { + if (!empty($val['searchall'])) { + $fieldstosearchall['sp.'.$key] = $val['label']; + } +} +$fieldstosearchall['pd.description'] = 'Description'; +$fieldstosearchall['s.nom'] = "ThirdParty"; +$fieldstosearchall['s.name_alias'] = "AliasNameShort"; +$fieldstosearchall['s.zip'] = "Zip"; +$fieldstosearchall['s.town'] = "Town"; if (empty($user->socid)) { $fieldstosearchall["p.note_private"] = "NotePrivate"; } @@ -186,6 +203,7 @@ $arrayfields = array( 'sp.multicurrency_total_ht' => array('label' => 'MulticurrencyAmountHT', 'checked' => 0, 'enabled' => (!isModEnabled("multicurrency") ? 0 : 1)), 'sp.multicurrency_total_vat' => array('label' => 'MulticurrencyAmountVAT', 'checked' => 0, 'enabled' => (!isModEnabled("multicurrency") ? 0 : 1)), 'sp.multicurrency_total_ttc' => array('label' => 'MulticurrencyAmountTTC', 'checked' => 0, 'enabled' => (!isModEnabled("multicurrency") ? 0 : 1)), + 'sp.fk_projet' => array('label' => $langs->trans("RefProject"), 'checked' => 1,'enabled' => (!isModEnabled("project") ? 0 : 1)), 'u.login' => array('label' => $langs->trans("Author"), 'checked' => 1, 'position' => 10), 'sp.datec' => array('label' => $langs->trans("DateCreation"), 'checked' => 0, 'position' => 500), 'sp.tms' => array('label' => $langs->trans("DateModificationShort"), 'checked' => 0, 'position' => 500), @@ -247,6 +265,7 @@ if (empty($reshook)) { $search_multicurrency_montant_ht = ''; $search_multicurrency_montant_vat = ''; $search_multicurrency_montant_ttc = ''; + $search_project_ref = ''; $search_login = ''; $search_product_category = ''; $search_town = ''; @@ -322,7 +341,7 @@ $sql .= " state.code_departement as state_code, state.nom as state_name,"; $sql .= ' sp.rowid, sp.note_public, sp.note_private, sp.total_ht, sp.total_tva, sp.total_ttc, sp.localtax1, sp.localtax2, sp.ref, sp.fk_statut as status, sp.fk_user_author, sp.date_valid, sp.date_livraison as dp,'; $sql .= ' sp.fk_multicurrency, sp.multicurrency_code, sp.multicurrency_tx, sp.multicurrency_total_ht, sp.multicurrency_total_tva as multicurrency_total_vat, sp.multicurrency_total_ttc,'; $sql .= ' sp.datec as date_creation, sp.tms as date_modification,'; -$sql .= " p.rowid as project_id, p.ref as project_ref,"; +$sql .= " p.rowid as project_id, p.ref as project_ref, p.title as project_title,"; $sql .= " u.firstname, u.lastname, u.photo, u.login, u.statut as ustatus, u.admin, u.employee, u.email as uemail"; // Add fields from extrafields if (!empty($extrafields->attributes[$object->table_element]['label'])) { @@ -408,6 +427,9 @@ if ($search_multicurrency_montant_vat != '') { if ($search_multicurrency_montant_ttc != '') { $sql .= natural_search('sp.multicurrency_total_ttc', $search_multicurrency_montant_ttc, 1); } +if ($search_project_ref != '') { + $sql .= natural_search("p.ref", $search_project_ref); +} if ($search_all) { $sql .= natural_search(array_keys($fieldstosearchall), $search_all); } @@ -625,6 +647,9 @@ if ($resql) { if ($search_status != '') { $param .= '&search_status='.urlencode($search_status); } + if ($search_project_ref >= 0) { + $param .= "&search_project_ref=".urlencode($search_project_ref); + } if ($optioncss != '') { $param .= '&optioncss='.urlencode($optioncss); } @@ -749,6 +774,12 @@ if ($resql) { print ''; print ''; } + // Project ref + if (!empty($arrayfields['sp.fk_projet']['checked'])) { + print ''; + print ''; + print ''; + } if (!empty($arrayfields['s.nom']['checked'])) { print ''; print ''; @@ -905,6 +936,12 @@ if ($resql) { print_liste_field_titre($arrayfields['sp.ref']['label'], $_SERVER["PHP_SELF"], 'sp.ref', '', $param, '', $sortfield, $sortorder); $totalarray['nbfield']++; } + + if (!empty($arrayfields['sp.fk_projet']['checked'])) { + print_liste_field_titre($arrayfields['sp.fk_projet']['label'], $_SERVER["PHP_SELF"], "p.ref", "", $param, '', $sortfield, $sortorder); + $totalarray['nbfield']++; + } + if (!empty($arrayfields['s.nom']['checked'])) { print_liste_field_titre($arrayfields['s.nom']['label'], $_SERVER["PHP_SELF"], 's.nom', '', $param, '', $sortfield, $sortorder); $totalarray['nbfield']++; @@ -1006,10 +1043,13 @@ if ($resql) { $i = 0; $total = 0; $subtotal = 0; + + $userstatic = new User($db); + $objectstatic = new SupplierProposal($db); + $projectstatic = new Project($db); + $savnbfield = $totalarray['nbfield']; - $totalarray = array(); - $totalarray['nbfield'] = 0; - $totalarray['val'] = array(); + $totalarray = array('nbfield' => 0, 'val' => array(), 'pos' => array()); $totalarray['val']['sp.total_ht'] = 0; $totalarray['val']['sp.total_tva'] = 0; $totalarray['val']['sp.total_ttc'] = 0; @@ -1089,6 +1129,21 @@ if ($resql) { } } + // Project + if (!empty($arrayfields['sp.fk_projet']['checked'])) { + $projectstatic->id = $obj->project_id; + $projectstatic->ref = $obj->project_ref; + $projectstatic->title = $obj->project_title; + print ''; + if ($obj->project_id > 0) { + print $projectstatic->getNomUrl(1); + } + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Thirdparty if (!empty($arrayfields['s.nom']['checked'])) { print '';