diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index cbf6dc69a65..877f6607f88 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -292,6 +292,7 @@ class Commande extends CommonOrder * 'type' if the field format ('integer', 'integer:ObjectClass:PathToClass[:AddCreateButtonOrNot[:Filter]]', 'varchar(x)', 'double(24,8)', 'real', 'price', 'text', 'html', 'date', 'datetime', 'timestamp', 'duration', 'mail', 'phone', 'url', 'password') * Note: Filter can be a string like "(t.ref:like:'SO-%') or (t.date_creation:<:'20160101') or (t.nature:is:NULL)" * 'label' the translation key. + * 'langfile' the key of the language file for translation. * 'enabled' is a condition when the field must be managed. * 'position' is the sort order of field. * 'notnull' is set to 1 if not null in database. Set to -1 if we must set data to null if empty ('' or 0). diff --git a/htdocs/commande/list.php b/htdocs/commande/list.php index e9cb4a09ac2..34f3c89256e 100644 --- a/htdocs/commande/list.php +++ b/htdocs/commande/list.php @@ -74,7 +74,7 @@ $confirm = GETPOST('confirm', 'alpha'); $toselect = GETPOST('toselect', 'array'); $contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'orderlist'; $optioncss = GETPOST('optioncss', 'alpha'); -$mode = GETPOST('mode', 'alpha'); +$mode = GETPOST('mode', 'aZ'); // The output mode ('list', 'kanban', 'hierarchy', 'calendar', ...) if (getDolGlobalInt('MAIN_SEE_SUBORDINATES')) { $userschilds = $user->getAllChildIds(); @@ -200,14 +200,14 @@ if (empty($user->socid)) { $fieldstosearchall["c.note_private"] = "NotePrivate"; } -$checkedtypetiers = 0; +$checkedtypetiers = '0'; $arrayfields = array( 'c.rowid' => array('label' => "ID", 'checked' => '1', 'enabled' => (string) getDolGlobalInt('MAIN_SHOW_TECHNICAL_ID'), 'position' => 1), 'c.ref' => array('label' => "Ref", 'checked' => '1', 'position' => 5, 'searchall' => 1), 'c.ref_ext' => array('label' => "RefExt", 'checked' => '1', 'position' => 5, 'visible' => 0, 'searchall' => 1), 'c.ref_client' => array('label' => "RefCustomerOrder", 'checked' => '-1', 'position' => 10, 'searchall' => 1), - 'p.ref' => array('label' => "ProjectRef", 'checked' => '-1', 'enabled' => (!isModEnabled('project') ? '0' : '1'), 'position' => 20), - 'p.title' => array('label' => "ProjectLabel", 'checked' => '0', 'enabled' => (!isModEnabled('project') ? '0' : '1'), 'position' => 25), + 'p.ref' => array('label' => "ProjectRef", 'langfile' => 'projects', 'checked' => '-1', 'enabled' => (!isModEnabled('project') ? '0' : '1'), 'position' => 20), + 'p.title' => array('label' => "ProjectLabel", 'langfile' => 'projects', 'checked' => '0', 'enabled' => (!isModEnabled('project') ? '0' : '1'), 'position' => 25), 's.nom' => array('label' => "ThirdParty", 'checked' => '1', 'position' => 30, 'searchall' => 1), 's.name_alias' => array('label' => "AliasNameShort", 'checked' => '-1', 'position' => 31, 'searchall' => 1), 's2.nom' => array('label' => 'ParentCompany', 'position' => 32, 'checked' => '0'), @@ -222,10 +222,12 @@ $arrayfields = array( 'c.fk_cond_reglement' => array('label' => "PaymentConditionsShort", 'checked' => '-1', 'position' => 67), 'c.fk_mode_reglement' => array('label' => "PaymentMode", 'checked' => '-1', 'position' => 68), 'c.fk_input_reason' => array('label' => "Origin", 'checked' => '-1', 'position' => 69), + 'c.module_source' => array('label' => "POSModule", 'langfile' => 'cashdesk', 'checked' => ($contextpage == 'poslist' ? '1' : '0'), 'enabled' => "(isModEnabled('cashdesk') || isModEnabled('takepos') || getDolGlobalInt('ORDER_SHOW_POS'))", 'position' => 90), + 'c.pos_source' => array('label' => "POSTerminal", 'langfile' => 'cashdesk', 'checked' => ($contextpage == 'poslist' ? '1' : '0'), 'enabled' => "(isModEnabled('cashdesk') || isModEnabled('takepos') || getDolGlobalInt('ORDER_SHOW_POS'))", 'position' => 91), 'c.total_ht' => array('label' => "AmountHT", 'checked' => '1', 'position' => 75), 'c.total_vat' => array('label' => "AmountVAT", 'checked' => '0', 'position' => 80), 'c.total_ttc' => array('label' => "AmountTTC", 'checked' => '0', 'position' => 85), - 'c.multicurrency_code' => array('label' => 'Currency', 'checked' => '0', 'enabled' => (!isModEnabled("multicurrency") ? '0' : '1'), 'position' => 90), + 'c.multicurrency_code' => array('label' => 'Currency', 'checked' => '0', 'enabled' => (!isModEnabled("multicurrency") ? '0' : '1'), 'position' => 92), 'c.multicurrency_tx' => array('label' => 'CurrencyRate', 'checked' => '0', 'enabled' => (!isModEnabled("multicurrency") ? '0' : '1'), 'position' => 95), 'c.multicurrency_total_ht' => array('label' => 'MulticurrencyAmountHT', 'checked' => '0', 'enabled' => (!isModEnabled("multicurrency") ? '0' : '1'), 'position' => 100), 'c.multicurrency_total_vat' => array('label' => 'MulticurrencyAmountVAT', 'checked' => '0', 'enabled' => (!isModEnabled("multicurrency") ? '0' : '1'), 'position' => 105), @@ -317,6 +319,8 @@ if (empty($reshook)) { $search_company = ''; $search_company_alias = ''; $search_parent_name = ''; + $search_module_source = ''; + $search_pos_source = ''; $search_town = ''; $search_zip = ""; $search_state = ""; @@ -915,10 +919,11 @@ $sql .= ' c.rowid, c.ref, c.ref_ext, c.total_ht, c.total_tva, c.total_ttc, c.ref $sql .= ' c.fk_multicurrency, c.multicurrency_code, c.multicurrency_tx, c.multicurrency_total_ht, c.multicurrency_total_tva as multicurrency_total_vat, c.multicurrency_total_ttc,'; $sql .= ' c.date_valid, c.date_commande, c.note_public, c.note_private, c.date_livraison as delivery_date, c.fk_statut, c.facture as billed,'; $sql .= ' c.date_creation as date_creation, c.tms as date_modification, c.date_cloture as date_cloture,'; -$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'; +$sql .= ' c.fk_input_reason, c.import_key,'; +$sql .= " c.module_source, c.pos_source,"; +$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'; // Add fields from extrafields if (!empty($extrafields->attributes[$object->table_element]['label'])) { @@ -980,9 +985,6 @@ if ($search_ref_ext) { if ($search_ref_customer) { $sql .= natural_search('c.ref_client', $search_ref_customer); } -if ($search_all) { - $sql .= natural_search(array_keys($fieldstosearchall), $search_all); -} if ($search_billed != '' && $search_billed >= 0) { $sql .= ' AND c.facture = '.((int) $search_billed); } @@ -1107,6 +1109,12 @@ if ($search_fk_mode_reglement > 0) { if ($search_fk_input_reason > 0) { $sql .= " AND c.fk_input_reason = ".((int) $search_fk_input_reason); } +if ($search_module_source) { + $sql .= natural_search("c.module_source", $search_module_source); +} +if ($search_pos_source) { + $sql .= natural_search("c.pos_source", $search_pos_source); +} if ($search_import_key) { $sql .= natural_search("s.import_key", $search_import_key); } @@ -1116,7 +1124,7 @@ if ($search_user > 0) { $sql .= " SELECT ec.fk_c_type_contact, ec.element_id, ec.fk_socpeople"; $sql .= " FROM ".MAIN_DB_PREFIX."element_contact as ec"; $sql .= " INNER JOIN ".MAIN_DB_PREFIX."c_type_contact as tc"; - $sql .= " ON ec.fk_c_type_contact = tc.rowid AND tc.element='commande' AND tc.source='internal'"; + $sql .= " ON ec.fk_c_type_contact = tc.rowid AND tc.element = 'commande' AND tc.source = 'internal'"; $sql .= " WHERE ec.element_id = c.rowid AND ec.fk_socpeople = ".((int) $search_user).")"; } // Search on sale representative @@ -1194,6 +1202,10 @@ $parameters = array(); $reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters, $object, $action); // Note that $action and $object may have been modified by hook $sql .= $hookmanager->resPrint; +if ($search_all) { + $sql .= natural_search(array_keys($fieldstosearchall), $search_all); +} + // Add HAVING from hooks $parameters = array(); $reshook = $hookmanager->executeHooks('printFieldListHaving', $parameters, $object, $action); // Note that $action and $object may have been modified by hook @@ -1214,13 +1226,14 @@ if (!getDolGlobalInt('MAIN_DISABLE_FULL_SCANLIST')) { dol_print_error($db); } - if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller than paging size (filtering), goto and load page 0 + if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller than the paging size (filtering), goto and load page 0 $page = 0; $offset = 0; } $db->free($resql); } +// Complete request and execute it with limit $sql .= $db->order($sortfield, $sortorder); if ($limit) { $sql .= $db->plimit($limit + 1, $offset); @@ -1428,6 +1441,12 @@ if ($search_fk_mode_reglement > 0) { if ($search_fk_input_reason > 0) { $param .= '&search_fk_input_reason='.urlencode((string) ($search_fk_input_reason)); } +if ($search_module_source) { + $param .= '&search_module_source='.urlencode($search_module_source); +} +if ($search_pos_source) { + $param .= '&search_pos_source='.urlencode($search_pos_source); +} if ($search_import_key != '') { $param .= '&search_import_key='.urlencode($search_import_key); } @@ -1482,7 +1501,7 @@ $newcardbutton .= dolGetButtonTitleSeparator(); $newcardbutton .= dolGetButtonTitle($langs->trans('NewOrder'), '', 'fa fa-plus-circle', $url, '', (int) (($contextpage == 'orderlist' || $contextpage == 'billableorders') && $permissiontoadd)); // Lines of title fields -print '