list.php 56 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371
  1. <?php
  2. /* Copyright (C) 2001-2007 Rodolphe Quiedeville <rodolphe@quiedeville.org>
  3. * Copyright (C) 2004-2017 Laurent Destailleur <eldy@users.sourceforge.net>
  4. * Copyright (C) 2004 Eric Seigne <eric.seigne@ryxeo.com>
  5. * Copyright (C) 2005 Marc Barilley / Ocebo <marc@ocebo.com>
  6. * Copyright (C) 2005-2013 Regis Houssin <regis.houssin@inodbox.com>
  7. * Copyright (C) 2006 Andre Cianfarani <acianfa@free.fr>
  8. * Copyright (C) 2010-2011 Juanjo Menent <jmenent@2byte.es>
  9. * Copyright (C) 2010-2019 Philippe Grand <philippe.grand@atoo-net.com>
  10. * Copyright (C) 2012 Christophe Battarel <christophe.battarel@altairis.fr>
  11. * Copyright (C) 2013 Cédric Salvador <csalvador@gpcsolutions.fr>
  12. * Copyright (C) 2016 Ferran Marcet <fmarcet@2byte.es>
  13. * Copyright (C) 2018-2023 Charlene Benke <charlene@patas-monkey.com>
  14. * Copyright (C) 2021 Alexandre Spangaro <aspangaro@open-dsi.fr>
  15. *
  16. * This program is free software; you can redistribute it and/or modify
  17. * it under the terms of the GNU General Public License as published by
  18. * the Free Software Foundation; either version 3 of the License, or
  19. * (at your option) any later version.
  20. *
  21. * This program is distributed in the hope that it will be useful,
  22. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  23. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  24. * GNU General Public License for more details.
  25. *
  26. * You should have received a copy of the GNU General Public License
  27. * along with this program. If not, see <https://www.gnu.org/licenses/>.
  28. */
  29. /**
  30. * \file htdocs/supplier_proposal/list.php
  31. * \ingroup supplier_proposal
  32. * \brief Page of supplier proposals card and list
  33. */
  34. // Load Dolibarr environment
  35. require '../main.inc.php';
  36. require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
  37. require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
  38. require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
  39. require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
  40. require_once DOL_DOCUMENT_ROOT.'/core/class/html.formpropal.class.php';
  41. require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
  42. require_once DOL_DOCUMENT_ROOT.'/supplier_proposal/class/supplier_proposal.class.php';
  43. if (isModEnabled('project')) {
  44. require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
  45. }
  46. // Load translation files required by the page
  47. $langs->loadLangs(array('companies', 'propal', 'supplier_proposal', 'compta', 'bills', 'orders', 'products'));
  48. $socid = GETPOST('socid', 'int');
  49. $action = GETPOST('action', 'aZ09');
  50. $massaction = GETPOST('massaction', 'alpha');
  51. $show_files = GETPOST('show_files', 'int');
  52. $confirm = GETPOST('confirm', 'alpha');
  53. $toselect = GETPOST('toselect', 'array');
  54. $contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'supplierproposallist';
  55. $mode = GETPOST('mode', 'alpha');
  56. $search_user = GETPOST('search_user', 'int');
  57. $search_sale = GETPOST('search_sale', 'int');
  58. $search_ref = GETPOST('sf_ref') ? GETPOST('sf_ref', 'alpha') : GETPOST('search_ref', 'alpha');
  59. $search_societe = GETPOST('search_societe', 'alpha');
  60. $search_societe_alias = GETPOST('search_societe_alias', 'alpha');
  61. $search_login = GETPOST('search_login', 'alpha');
  62. $search_town = GETPOST('search_town', 'alpha');
  63. $search_zip = GETPOST('search_zip', 'alpha');
  64. $search_state = GETPOST("search_state");
  65. $search_country = GETPOST("search_country", 'int');
  66. $search_date_startday = GETPOST('search_date_startday', 'int');
  67. $search_date_startmonth = GETPOST('search_date_startmonth', 'int');
  68. $search_date_startyear = GETPOST('search_date_startyear', 'int');
  69. $search_date_endday = GETPOST('search_date_endday', 'int');
  70. $search_date_endmonth = GETPOST('search_date_endmonth', 'int');
  71. $search_date_endyear = GETPOST('search_date_endyear', 'int');
  72. $search_date_start = dol_mktime(0, 0, 0, $search_date_startmonth, $search_date_startday, $search_date_startyear); // Use tzserver
  73. $search_date_end = dol_mktime(23, 59, 59, $search_date_endmonth, $search_date_endday, $search_date_endyear);
  74. $search_date_valid_startday = GETPOST('search_date_valid_startday', 'int');
  75. $search_date_valid_startmonth = GETPOST('search_date_valid_startmonth', 'int');
  76. $search_date_valid_startyear = GETPOST('search_date_valid_startyear', 'int');
  77. $search_date_valid_endday = GETPOST('search_date_valid_endday', 'int');
  78. $search_date_valid_endmonth = GETPOST('search_date_valid_endmonth', 'int');
  79. $search_date_valid_endyear = GETPOST('search_date_valid_endyear', 'int');
  80. $search_date_valid_start = dol_mktime(0, 0, 0, $search_date_valid_startmonth, $search_date_valid_startday, $search_date_valid_startyear); // Use tzserver
  81. $search_date_valid_end = dol_mktime(23, 59, 59, $search_date_valid_endmonth, $search_date_valid_endday, $search_date_valid_endyear);
  82. $search_type_thirdparty = GETPOST("search_type_thirdparty", 'int');
  83. $search_montant_ht = GETPOST('search_montant_ht', 'alpha');
  84. $search_montant_vat = GETPOST('search_montant_vat', 'alpha');
  85. $search_montant_ttc = GETPOST('search_montant_ttc', 'alpha');
  86. $search_multicurrency_code = GETPOST('search_multicurrency_code', 'alpha');
  87. $search_multicurrency_tx = GETPOST('search_multicurrency_tx', 'alpha');
  88. $search_multicurrency_montant_ht = GETPOST('search_multicurrency_montant_ht', 'alpha');
  89. $search_multicurrency_montant_vat = GETPOST('search_multicurrency_montant_vat', 'alpha');
  90. $search_multicurrency_montant_ttc = GETPOST('search_multicurrency_montant_ttc', 'alpha');
  91. $search_status = GETPOST('search_status', 'int');
  92. $search_product_category = GETPOST('search_product_category', 'int');
  93. $object_statut = $db->escape(GETPOST('supplier_proposal_statut'));
  94. $search_btn = GETPOST('button_search', 'alpha');
  95. $search_remove_btn = GETPOST('button_removefilter', 'alpha');
  96. $sall = trim((GETPOST('search_all', 'alphanohtml') != '') ? GETPOST('search_all', 'alphanohtml') : GETPOST('sall', 'alphanohtml'));
  97. $mesg = (GETPOST("msg") ? GETPOST("msg") : GETPOST("mesg"));
  98. $optioncss = GETPOST('optioncss', 'alpha');
  99. $limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit;
  100. $sortfield = GETPOST('sortfield', 'aZ09comma');
  101. $sortorder = GETPOST('sortorder', 'aZ09comma');
  102. $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
  103. if (empty($page) || $page == -1 || !empty($search_btn) || !empty($search_remove_btn) || (empty($toselect) && $massaction === '0')) {
  104. $page = 0;
  105. } // If $page is not defined, or '' or -1
  106. $offset = $limit * $page;
  107. $pageprev = $page - 1;
  108. $pagenext = $page + 1;
  109. if (!$sortfield) {
  110. $sortfield = 'sp.date_livraison';
  111. }
  112. if (!$sortorder) {
  113. $sortorder = 'DESC';
  114. }
  115. if ($object_statut != '') {
  116. $search_status = $object_statut;
  117. }
  118. // Nombre de ligne pour choix de produit/service predefinis
  119. $NBLINES = 4;
  120. // Security check
  121. $module = 'supplier_proposal';
  122. $dbtable = '';
  123. $objectid = '';
  124. if (!empty($user->socid)) {
  125. $socid = $user->socid;
  126. }
  127. if (!empty($socid)) {
  128. $objectid = $socid;
  129. $module = 'societe';
  130. $dbtable = '&societe';
  131. }
  132. $diroutputmassaction = $conf->supplier_proposal->dir_output.'/temp/massgeneration/'.$user->id;
  133. // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
  134. $object = new SupplierProposal($db);
  135. $hookmanager->initHooks(array('supplier_proposallist'));
  136. $extrafields = new ExtraFields($db);
  137. // fetch optionals attributes and labels
  138. $extrafields->fetch_name_optionals_label($object->table_element);
  139. $search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_');
  140. // List of fields to search into when doing a "search in all"
  141. $fieldstosearchall = array(
  142. 'sp.ref'=>'Ref',
  143. 's.nom'=>'Supplier',
  144. 'pd.description'=>'Description',
  145. 'sp.note_public'=>'NotePublic',
  146. );
  147. if (empty($user->socid)) {
  148. $fieldstosearchall["p.note_private"] = "NotePrivate";
  149. }
  150. $checkedtypetiers = 0;
  151. $arrayfields = array(
  152. 'sp.ref'=>array('label'=>$langs->trans("Ref"), 'checked'=>1),
  153. 's.nom'=>array('label'=>$langs->trans("Supplier"), 'checked'=>1),
  154. 's.name_alias'=>array('label'=>"AliasNameShort", 'checked'=>0),
  155. 's.town'=>array('label'=>$langs->trans("Town"), 'checked'=>1),
  156. 's.zip'=>array('label'=>$langs->trans("Zip"), 'checked'=>1),
  157. 'state.nom'=>array('label'=>$langs->trans("StateShort"), 'checked'=>0),
  158. 'country.code_iso'=>array('label'=>$langs->trans("Country"), 'checked'=>0),
  159. 'typent.code'=>array('label'=>$langs->trans("ThirdPartyType"), 'checked'=>$checkedtypetiers),
  160. 'sp.date_valid'=>array('label'=>$langs->trans("DateValidation"), 'checked'=>1),
  161. 'sp.date_livraison'=>array('label'=>$langs->trans("DateEnd"), 'checked'=>1),
  162. 'sp.total_ht'=>array('label'=>$langs->trans("AmountHT"), 'checked'=>1),
  163. 'sp.total_tva'=>array('label'=>$langs->trans("AmountVAT"), 'checked'=>0),
  164. 'sp.total_ttc'=>array('label'=>$langs->trans("AmountTTC"), 'checked'=>0),
  165. 'sp.multicurrency_code'=>array('label'=>'Currency', 'checked'=>0, 'enabled'=>(!isModEnabled("multicurrency") ? 0 : 1)),
  166. 'sp.multicurrency_tx'=>array('label'=>'CurrencyRate', 'checked'=>0, 'enabled'=>(!isModEnabled("multicurrency") ? 0 : 1)),
  167. 'sp.multicurrency_total_ht'=>array('label'=>'MulticurrencyAmountHT', 'checked'=>0, 'enabled'=>(!isModEnabled("multicurrency") ? 0 : 1)),
  168. 'sp.multicurrency_total_vat'=>array('label'=>'MulticurrencyAmountVAT', 'checked'=>0, 'enabled'=>(!isModEnabled("multicurrency") ? 0 : 1)),
  169. 'sp.multicurrency_total_ttc'=>array('label'=>'MulticurrencyAmountTTC', 'checked'=>0, 'enabled'=>(!isModEnabled("multicurrency") ? 0 : 1)),
  170. 'u.login'=>array('label'=>$langs->trans("Author"), 'checked'=>1, 'position'=>10),
  171. 'sp.datec'=>array('label'=>$langs->trans("DateCreation"), 'checked'=>0, 'position'=>500),
  172. 'sp.tms'=>array('label'=>$langs->trans("DateModificationShort"), 'checked'=>0, 'position'=>500),
  173. 'sp.fk_statut'=>array('label'=>$langs->trans("Status"), 'checked'=>1, 'position'=>1000),
  174. );
  175. // Extra fields
  176. include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php';
  177. $object->fields = dol_sort_array($object->fields, 'position');
  178. $arrayfields = dol_sort_array($arrayfields, 'position');
  179. if (!$user->hasRight('societe', 'client', 'voir')) {
  180. $search_sale = $user->id;
  181. }
  182. $result = restrictedArea($user, $module, $objectid, $dbtable);
  183. $permissiontoread = $user->rights->supplier_proposal->lire;
  184. $permissiontodelete = $user->rights->supplier_proposal->supprimer;
  185. /*
  186. * Actions
  187. */
  188. if (GETPOST('cancel', 'alpha')) {
  189. $action = 'list';
  190. $massaction = '';
  191. }
  192. if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') {
  193. $massaction = '';
  194. }
  195. $parameters = array('socid'=>$socid);
  196. $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
  197. if ($reshook < 0) {
  198. setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
  199. }
  200. if (empty($reshook)) {
  201. // Selection of new fields
  202. include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
  203. // Purge search criteria
  204. if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // All tests are required to be compatible with all browsers
  205. $search_categ = '';
  206. $search_user = '';
  207. $search_sale = '';
  208. $search_ref = '';
  209. $search_societe = '';
  210. $search_societe_alias = '';
  211. $search_montant_ht = '';
  212. $search_montant_vat = '';
  213. $search_montant_ttc = '';
  214. $search_multicurrency_code = '';
  215. $search_multicurrency_tx = '';
  216. $search_multicurrency_montant_ht = '';
  217. $search_multicurrency_montant_vat = '';
  218. $search_multicurrency_montant_ttc = '';
  219. $search_login = '';
  220. $search_product_category = '';
  221. $search_town = '';
  222. $search_zip = "";
  223. $search_state = "";
  224. $search_type = '';
  225. $search_country = '';
  226. $search_type_thirdparty = '';
  227. $search_date_startday = '';
  228. $search_date_startmonth = '';
  229. $search_date_startyear = '';
  230. $search_date_endday = '';
  231. $search_date_endmonth = '';
  232. $search_date_endyear = '';
  233. $search_date_start = '';
  234. $search_date_end = '';
  235. $search_date_valid_startday = '';
  236. $search_date_valid_startmonth = '';
  237. $search_date_valid_startyear = '';
  238. $search_date_valid_endday = '';
  239. $search_date_valid_endmonth = '';
  240. $search_date_valid_endyear = '';
  241. $search_date_valid_start = '';
  242. $search_date_valid_end = '';
  243. $search_status = '';
  244. $object_statut = '';
  245. }
  246. $objectclass = 'SupplierProposal';
  247. $objectlabel = 'SupplierProposals';
  248. $uploaddir = $conf->supplier_proposal->dir_output;
  249. include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';
  250. }
  251. /*
  252. * View
  253. */
  254. $form = new Form($db);
  255. $formother = new FormOther($db);
  256. $formfile = new FormFile($db);
  257. $formpropal = new FormPropal($db);
  258. $companystatic = new Societe($db);
  259. $formcompany = new FormCompany($db);
  260. $now = dol_now();
  261. $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
  262. $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields
  263. $title = $langs->trans('ListOfSupplierProposals');
  264. $help_url = 'EN:Ask_Price_Supplier|FR:Demande_de_prix_fournisseur';
  265. // Build and execute select
  266. // --------------------------------------------------------------------
  267. $sql = 'SELECT';
  268. if ($sall || $search_user > 0) {
  269. $sql = 'SELECT DISTINCT';
  270. }
  271. $sql .= ' s.rowid as socid, s.nom as name, s.name_alias as alias, s.town, s.zip, s.fk_pays, s.client, s.code_client,';
  272. $sql .= " typent.code as typent_code,";
  273. $sql .= " state.code_departement as state_code, state.nom as state_name,";
  274. $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,';
  275. $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,';
  276. $sql .= ' sp.datec as date_creation, sp.tms as date_update,';
  277. $sql .= " p.rowid as project_id, p.ref as project_ref,";
  278. $sql .= " u.firstname, u.lastname, u.photo, u.login, u.statut as ustatus, u.admin, u.employee, u.email as uemail";
  279. // Add fields from extrafields
  280. if (!empty($extrafields->attributes[$object->table_element]['label'])) {
  281. foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) {
  282. $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key." as options_".$key : '');
  283. }
  284. }
  285. // Add fields from hooks
  286. $parameters = array();
  287. $reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters); // Note that $action and $object may have been modified by hook
  288. $sql .= $hookmanager->resPrint;
  289. $sql .= ' FROM '.MAIN_DB_PREFIX.'societe as s';
  290. $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as country on (country.rowid = s.fk_pays)";
  291. $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_typent as typent on (typent.id = s.fk_typent)";
  292. $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_departements as state on (state.rowid = s.fk_departement)";
  293. $sql .= ', '.MAIN_DB_PREFIX.'supplier_proposal as sp';
  294. if (isset($extrafields->attributes[$object->table_element]['label']) && is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) {
  295. $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (sp.rowid = ef.fk_object)";
  296. }
  297. if ($sall) {
  298. $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'supplier_proposaldet as pd ON sp.rowid=pd.fk_supplier_proposal';
  299. }
  300. $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'user as u ON sp.fk_user_author = u.rowid';
  301. $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."projet as p ON p.rowid = sp.fk_projet";
  302. if ($search_user > 0) {
  303. $sql .= ", ".MAIN_DB_PREFIX."element_contact as c";
  304. $sql .= ", ".MAIN_DB_PREFIX."c_type_contact as tc";
  305. }
  306. $sql .= ' WHERE sp.fk_soc = s.rowid';
  307. $sql .= ' AND sp.entity IN ('.getEntity('supplier_proposal').')';
  308. if ($search_town) {
  309. $sql .= natural_search('s.town', $search_town);
  310. }
  311. if ($search_zip) {
  312. $sql .= natural_search("s.zip", $search_zip);
  313. }
  314. if ($search_state) {
  315. $sql .= natural_search("state.nom", $search_state);
  316. }
  317. if ($search_country) {
  318. $sql .= " AND s.fk_pays IN (".$db->sanitize($search_country).')';
  319. }
  320. if ($search_type_thirdparty != '' && $search_type_thirdparty > 0) {
  321. $sql .= " AND s.fk_typent IN (".$db->sanitize($search_type_thirdparty).')';
  322. }
  323. if ($search_ref) {
  324. $sql .= natural_search('sp.ref', $search_ref);
  325. }
  326. if (empty($arrayfields['s.name_alias']['checked']) && $search_societe) {
  327. $sql .= natural_search(array("s.nom", "s.name_alias"), $search_societe);
  328. } else {
  329. if ($search_societe) {
  330. $sql .= natural_search('s.nom', $search_societe);
  331. }
  332. if ($search_societe_alias) {
  333. $sql .= natural_search('s.name_alias', $search_societe_alias);
  334. }
  335. }
  336. if ($search_login) {
  337. $sql .= natural_search(array('u.lastname', 'u.firstname', 'u.login'), $search_login);
  338. }
  339. if ($search_montant_ht) {
  340. $sql .= natural_search('sp.total_ht', $search_montant_ht, 1);
  341. }
  342. if ($search_montant_vat != '') {
  343. $sql .= natural_search("sp.total_tva", $search_montant_vat, 1);
  344. }
  345. if ($search_montant_ttc != '') {
  346. $sql .= natural_search("sp.total_ttc", $search_montant_ttc, 1);
  347. }
  348. if ($search_multicurrency_code != '') {
  349. $sql .= " AND sp.multicurrency_code = '".$db->escape($search_multicurrency_code)."'";
  350. }
  351. if ($search_multicurrency_tx != '') {
  352. $sql .= natural_search('sp.multicurrency_tx', $search_multicurrency_tx, 1);
  353. }
  354. if ($search_multicurrency_montant_ht != '') {
  355. $sql .= natural_search('sp.multicurrency_total_ht', $search_multicurrency_montant_ht, 1);
  356. }
  357. if ($search_multicurrency_montant_vat != '') {
  358. $sql .= natural_search('sp.multicurrency_total_tva', $search_multicurrency_montant_vat, 1);
  359. }
  360. if ($search_multicurrency_montant_ttc != '') {
  361. $sql .= natural_search('sp.multicurrency_total_ttc', $search_multicurrency_montant_ttc, 1);
  362. }
  363. if ($sall) {
  364. $sql .= natural_search(array_keys($fieldstosearchall), $sall);
  365. }
  366. if ($socid > 0) {
  367. $sql .= ' AND s.rowid = '.((int) $socid);
  368. }
  369. if ($search_status >= 0 && $search_status != '') {
  370. $sql .= ' AND sp.fk_statut IN ('.$db->sanitize($db->escape($search_status)).')';
  371. }
  372. if ($search_date_start) {
  373. $sql .= " AND sp.date_livraison >= '".$db->idate($search_date_start)."'";
  374. }
  375. if ($search_date_end) {
  376. $sql .= " AND sp.date_livraison <= '".$db->idate($search_date_end)."'";
  377. }
  378. if ($search_date_valid_start) {
  379. $sql .= " AND sp.date_valid >= '".$db->idate($search_date_valid_start)."'";
  380. }
  381. if ($search_date_valid_end) {
  382. $sql .= " AND sp.date_valid <= '".$db->idate($search_date_valid_end)."'";
  383. }
  384. /*
  385. if ($search_sale > 0) {
  386. $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $search_sale);
  387. }*/
  388. if ($search_user > 0) {
  389. $sql .= " AND c.fk_c_type_contact = tc.rowid AND tc.element='supplier_proposal' AND tc.source='internal' AND c.element_id = sp.rowid AND c.fk_socpeople = ".((int) $search_user);
  390. }
  391. // Search on sale representative
  392. if ($search_sale && $search_sale != '-1') {
  393. if ($search_sale == -2) {
  394. $sql .= " AND NOT EXISTS (SELECT sc.fk_soc FROM ".MAIN_DB_PREFIX."societe_commerciaux as sc WHERE sc.fk_soc = sp.fk_soc)";
  395. } elseif ($search_sale > 0) {
  396. $sql .= " AND EXISTS (SELECT sc.fk_soc FROM ".MAIN_DB_PREFIX."societe_commerciaux as sc WHERE sc.fk_soc = sp.fk_soc AND sc.fk_user = ".((int) $search_sale).")";
  397. }
  398. }
  399. // Search for tag/category ($searchCategoryProductList is an array of ID)
  400. $searchCategoryProductOperator = -1;
  401. $searchCategoryProductList = array($search_product_category);
  402. if (!empty($searchCategoryProductList)) {
  403. $searchCategoryProductSqlList = array();
  404. $listofcategoryid = '';
  405. foreach ($searchCategoryProductList as $searchCategoryProduct) {
  406. if (intval($searchCategoryProduct) == -2) {
  407. $searchCategoryProductSqlList[] = "NOT EXISTS (SELECT ck.fk_product FROM ".MAIN_DB_PREFIX."categorie_product as ck, ".MAIN_DB_PREFIX."supplier_proposaldet as sd WHERE sd.fk_supplier_proposal = sp.rowid AND sd.fk_product = ck.fk_product)";
  408. } elseif (intval($searchCategoryProduct) > 0) {
  409. if ($searchCategoryProductOperator == 0) {
  410. $searchCategoryProductSqlList[] = " EXISTS (SELECT ck.fk_product FROM ".MAIN_DB_PREFIX."categorie_product as ck, ".MAIN_DB_PREFIX."supplier_proposaldet as sd WHERE sd.fk_supplier_proposal = sp.rowid AND sd.fk_product = ck.fk_product AND ck.fk_categorie = ".((int) $searchCategoryProduct).")";
  411. } else {
  412. $listofcategoryid .= ($listofcategoryid ? ', ' : '') .((int) $searchCategoryProduct);
  413. }
  414. }
  415. }
  416. if ($listofcategoryid) {
  417. $searchCategoryProductSqlList[] = " EXISTS (SELECT ck.fk_product FROM ".MAIN_DB_PREFIX."categorie_product as ck, ".MAIN_DB_PREFIX."supplier_proposaldet as sd WHERE sd.fk_supplier_proposal = sp.rowid AND sd.fk_product = ck.fk_product AND ck.fk_categorie IN (".$db->sanitize($listofcategoryid)."))";
  418. }
  419. if ($searchCategoryProductOperator == 1) {
  420. if (!empty($searchCategoryProductSqlList)) {
  421. $sql .= " AND (".implode(' OR ', $searchCategoryProductSqlList).")";
  422. }
  423. } else {
  424. if (!empty($searchCategoryProductSqlList)) {
  425. $sql .= " AND (".implode(' AND ', $searchCategoryProductSqlList).")";
  426. }
  427. }
  428. }
  429. // Add where from extra fields
  430. include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php';
  431. // Add where from hooks
  432. $parameters = array();
  433. $reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
  434. $sql .= $hookmanager->resPrint;
  435. $sql .= $db->order($sortfield, $sortorder);
  436. $sql .= ', sp.ref DESC';
  437. // Count total nb of records
  438. $nbtotalofrecords = '';
  439. if (!getDolGlobalInt('MAIN_DISABLE_FULL_SCANLIST')) {
  440. $resql = $db->query($sql);
  441. $nbtotalofrecords = $db->num_rows($resql);
  442. if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller then paging size (filtering), goto and load page 0
  443. $page = 0;
  444. $offset = 0;
  445. }
  446. }
  447. $sql .= $db->plimit($limit + 1, $offset);
  448. $resql = $db->query($sql);
  449. if ($resql) {
  450. $objectstatic = new SupplierProposal($db);
  451. $userstatic = new User($db);
  452. if ($socid > 0) {
  453. $soc = new Societe($db);
  454. $soc->fetch($socid);
  455. $title = $langs->trans('SupplierProposals').' - '.$soc->name;
  456. } else {
  457. $title = $langs->trans('SupplierProposals');
  458. }
  459. $num = $db->num_rows($resql);
  460. $arrayofselected = is_array($toselect) ? $toselect : array();
  461. if ($num == 1 && getDolGlobalString('MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE') && $sall) {
  462. $obj = $db->fetch_object($resql);
  463. $id = $obj->rowid;
  464. header("Location: ".DOL_URL_ROOT.'/supplier_proposal/card.php?id='.$id);
  465. exit;
  466. }
  467. // Output page
  468. // --------------------------------------------------------------------
  469. llxHeader('', $title, $help_url);
  470. $param = '';
  471. if (!empty($mode)) {
  472. $param .= '&mode='.urlencode($mode);
  473. }
  474. if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
  475. $param .= '&contextpage='.urlencode($contextpage);
  476. }
  477. if ($limit > 0 && $limit != $conf->liste_limit) {
  478. $param .= '&limit='.((int) $limit);
  479. }
  480. if ($sall) {
  481. $param .= '&sall='.urlencode($sall);
  482. }
  483. if ($search_date_startday) {
  484. $param .= '&search_date_startday='.urlencode($search_date_startday);
  485. }
  486. if ($search_date_startmonth) {
  487. $param .= '&search_date_startmonth='.urlencode($search_date_startmonth);
  488. }
  489. if ($search_date_startyear) {
  490. $param .= '&search_date_startyear='.urlencode($search_date_startyear);
  491. }
  492. if ($search_date_endday) {
  493. $param .= '&search_date_endday='.urlencode($search_date_endday);
  494. }
  495. if ($search_date_endmonth) {
  496. $param .= '&search_date_endmonth='.urlencode($search_date_endmonth);
  497. }
  498. if ($search_date_endyear) {
  499. $param .= '&search_date_endyear='.urlencode($search_date_endyear);
  500. }
  501. if ($search_date_valid_startday) {
  502. $param .= '&search_date_valid_startday='.urlencode($search_date_valid_startday);
  503. }
  504. if ($search_date_valid_startmonth) {
  505. $param .= '&search_date_valid_startmonth='.urlencode($search_date_valid_startmonth);
  506. }
  507. if ($search_date_valid_startyear) {
  508. $param .= '&search_date_valid_startyear='.urlencode($search_date_valid_startyear);
  509. }
  510. if ($search_date_valid_endday) {
  511. $param .= '&search_date_valid_endday='.urlencode($search_date_valid_endday);
  512. }
  513. if ($search_date_valid_endmonth) {
  514. $param .= '&search_date_valid_endmonth='.urlencode($search_date_valid_endmonth);
  515. }
  516. if ($search_date_valid_endyear) {
  517. $param .= '&search_date_valid_endyear='.urlencode($search_date_valid_endyear);
  518. }
  519. if ($search_ref) {
  520. $param .= '&search_ref='.urlencode($search_ref);
  521. }
  522. if ($search_societe) {
  523. $param .= '&search_societe='.urlencode($search_societe);
  524. }
  525. if ($search_societe_alias) {
  526. $param .= '&search_societe_alias='.urlencode($search_societe_alias);
  527. }
  528. if ($search_user > 0) {
  529. $param .= '&search_user='.urlencode($search_user);
  530. }
  531. if ($search_sale > 0) {
  532. $param .= '&search_sale='.urlencode($search_sale);
  533. }
  534. if ($search_montant_ht) {
  535. $param .= '&search_montant_ht='.urlencode($search_montant_ht);
  536. }
  537. if ($search_multicurrency_code != '') {
  538. $param .= '&search_multicurrency_code='.urlencode($search_multicurrency_code);
  539. }
  540. if ($search_multicurrency_tx != '') {
  541. $param .= '&search_multicurrency_tx='.urlencode($search_multicurrency_tx);
  542. }
  543. if ($search_multicurrency_montant_ht != '') {
  544. $param .= '&search_multicurrency_montant_ht='.urlencode($search_multicurrency_montant_ht);
  545. }
  546. if ($search_multicurrency_montant_vat != '') {
  547. $param .= '&search_multicurrency_montant_vat='.urlencode($search_multicurrency_montant_vat);
  548. }
  549. if ($search_multicurrency_montant_ttc != '') {
  550. $param .= '&search_multicurrency_montant_ttc='.urlencode($search_multicurrency_montant_ttc);
  551. }
  552. if ($search_login) {
  553. $param .= '&search_login='.urlencode($search_login);
  554. }
  555. if ($search_town) {
  556. $param .= '&search_town='.urlencode($search_town);
  557. }
  558. if ($search_zip) {
  559. $param .= '&search_zip='.urlencode($search_zip);
  560. }
  561. if ($socid > 0) {
  562. $param .= '&socid='.urlencode($socid);
  563. }
  564. if ($search_status != '') {
  565. $param .= '&search_status='.urlencode($search_status);
  566. }
  567. if ($optioncss != '') {
  568. $param .= '&optioncss='.urlencode($optioncss);
  569. }
  570. if ($search_type_thirdparty != '' && $search_type_thirdparty > 0) {
  571. $param .= '&search_type_thirdparty='.urlencode($search_type_thirdparty);
  572. }
  573. // Add $param from extra fields
  574. include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
  575. // List of mass actions available
  576. $arrayofmassactions = array(
  577. 'generate_doc'=>img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("ReGeneratePDF"),
  578. 'builddoc'=>img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("PDFMerge"),
  579. //'presend'=>img_picto('', 'email', 'class="pictofixedwidth"').$langs->trans("SendByMail"),
  580. );
  581. if ($user->hasRight('supplier_proposal', 'supprimer')) {
  582. $arrayofmassactions['predelete'] = img_picto('', 'delete', 'class="pictofixedwidth"').$langs->trans("Delete");
  583. }
  584. if (in_array($massaction, array('presend', 'predelete'))) {
  585. $arrayofmassactions = array();
  586. }
  587. $massactionbutton = $form->selectMassAction('', $arrayofmassactions);
  588. $url = DOL_URL_ROOT.'/supplier_proposal/card.php?action=create';
  589. if (!empty($socid)) {
  590. $url .= '&socid='.$socid;
  591. }
  592. $newcardbutton = '';
  593. $newcardbutton .= dolGetButtonTitle($langs->trans('ViewList'), '', 'fa fa-bars imgforviewmode', $_SERVER["PHP_SELF"].'?mode=common'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ((empty($mode) || $mode == 'common') ? 2 : 1), array('morecss'=>'reposition'));
  594. $newcardbutton .= dolGetButtonTitle($langs->trans('ViewKanban'), '', 'fa fa-th-list imgforviewmode', $_SERVER["PHP_SELF"].'?mode=kanban'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ($mode == 'kanban' ? 2 : 1), array('morecss'=>'reposition'));
  595. $newcardbutton .= dolGetButtonTitleSeparator();
  596. $newcardbutton .= dolGetButtonTitle($langs->trans('NewAskPrice'), '', 'fa fa-plus-circle', $url, '', $user->hasRight('supplier_proposal', 'creer'));
  597. // Fields title search
  598. print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">';
  599. if ($optioncss != '') {
  600. print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
  601. }
  602. print '<input type="hidden" name="token" value="'.newToken().'">';
  603. print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
  604. print '<input type="hidden" name="action" value="list">';
  605. print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
  606. print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
  607. print '<input type="hidden" name="mode" value="'.$mode.'">';
  608. print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'supplier_proposal', 0, $newcardbutton, '', $limit, 0, 0, 1);
  609. $topicmail = "SendSupplierProposalRef";
  610. $modelmail = "supplier_proposal_send";
  611. $objecttmp = new SupplierProposal($db);
  612. $trackid = 'spro'.$object->id;
  613. include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php';
  614. if ($sall) {
  615. foreach ($fieldstosearchall as $key => $val) {
  616. $fieldstosearchall[$key] = $langs->trans($val);
  617. }
  618. print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $sall).join(', ', $fieldstosearchall).'</div>';
  619. }
  620. $i = 0;
  621. $moreforfilter = '';
  622. // If the user can view prospects other than his'
  623. if ($user->hasRight('user', 'user', 'lire')) {
  624. $langs->load("commercial");
  625. $moreforfilter .= '<div class="divsearchfield">';
  626. $tmptitle = $langs->trans('ThirdPartiesOfSaleRepresentative');
  627. $moreforfilter .= img_picto($tmptitle, 'user', 'class="pictofixedwidth"').$formother->select_salesrepresentatives($search_sale, 'search_sale', $user, 0, $tmptitle, 'maxwidth250 widthcentpercentminusx');
  628. $moreforfilter .= '</div>';
  629. }
  630. // If the user can view prospects other than his'
  631. if ($user->hasRight('user', 'user', 'lire')) {
  632. $moreforfilter .= '<div class="divsearchfield">';
  633. $tmptitle = $langs->trans('LinkedToSpecificUsers');
  634. $moreforfilter .= img_picto($tmptitle, 'user', 'class="pictofixedwidth"').$form->select_dolusers($search_user, 'search_user', $tmptitle, '', 0, '', '', 0, 0, 0, '', 0, '', 'maxwidth250 widthcentpercentminusx');
  635. $moreforfilter .= '</div>';
  636. }
  637. // If the user can view products
  638. if (isModEnabled('categorie') && $user->hasRight('categorie', 'lire') && ($user->hasRight('produit', 'lire') || $user->hasRight('service', 'lire'))) {
  639. include_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
  640. $moreforfilter .= '<div class="divsearchfield">';
  641. $tmptitle = $langs->trans('IncludingProductWithTag');
  642. $cate_arbo = $form->select_all_categories(Categorie::TYPE_PRODUCT, null, 'parent', null, null, 1);
  643. $moreforfilter .= img_picto($tmptitle, 'category', 'class="pictofixedwidth"').$form->selectarray('search_product_category', $cate_arbo, $search_product_category, $tmptitle, 0, 0, '', 0, 0, 0, 0, 'maxwidth300 widthcentpercentminusx', 1);
  644. $moreforfilter .= '</div>';
  645. }
  646. $parameters = array();
  647. $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook
  648. if (empty($reshook)) {
  649. $moreforfilter .= $hookmanager->resPrint;
  650. } else {
  651. $moreforfilter = $hookmanager->resPrint;
  652. }
  653. if (!empty($moreforfilter)) {
  654. print '<div class="liste_titre liste_titre_bydiv centpercent">';
  655. print $moreforfilter;
  656. print '</div>';
  657. }
  658. $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
  659. $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage, getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN', '')); // This also change content of $arrayfields
  660. $selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons('checkforselect', 1) : '');
  661. print '<div class="div-table-responsive">';
  662. print '<table class="tagtable nobottomiftotal liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n";
  663. // Fields title search
  664. // --------------------------------------------------------------------
  665. print '<tr class="liste_titre_filter">';
  666. // Action column
  667. if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
  668. print '<td class="liste_titre maxwidthsearch">';
  669. $searchpicto = $form->showFilterButtons('left');
  670. print $searchpicto;
  671. print '</td>';
  672. }
  673. if (!empty($arrayfields['sp.ref']['checked'])) {
  674. print '<td class="liste_titre">';
  675. print '<input class="flat" size="6" type="text" name="search_ref" value="'.dol_escape_htmltag($search_ref).'">';
  676. print '</td>';
  677. }
  678. if (!empty($arrayfields['s.nom']['checked'])) {
  679. print '<td class="liste_titre left">';
  680. print '<input class="flat" type="text" size="12" name="search_societe" value="'.dol_escape_htmltag($search_societe).'">';
  681. print '</td>';
  682. }
  683. if (!empty($arrayfields['s.name_alias']['checked'])) {
  684. print '<td class="liste_titre left">';
  685. print '<input class="flat" type="text" size="12" name="search_societe_alias" value="'.dol_escape_htmltag($search_societe_alias).'">';
  686. print '</td>';
  687. }
  688. if (!empty($arrayfields['s.town']['checked'])) {
  689. print '<td class="liste_titre"><input class="flat" type="text" size="6" name="search_town" value="'.$search_town.'"></td>';
  690. }
  691. if (!empty($arrayfields['s.zip']['checked'])) {
  692. print '<td class="liste_titre"><input class="flat" type="text" size="4" name="search_zip" value="'.$search_zip.'"></td>';
  693. }
  694. // State
  695. if (!empty($arrayfields['state.nom']['checked'])) {
  696. print '<td class="liste_titre">';
  697. print '<input class="flat" size="4" type="text" name="search_state" value="'.dol_escape_htmltag($search_state).'">';
  698. print '</td>';
  699. }
  700. // Country
  701. if (!empty($arrayfields['country.code_iso']['checked'])) {
  702. print '<td class="liste_titre center">';
  703. print $form->select_country($search_country, 'search_country', '', 0, 'minwidth100imp maxwidth100');
  704. print '</td>';
  705. }
  706. // Company type
  707. if (!empty($arrayfields['typent.code']['checked'])) {
  708. print '<td class="liste_titre maxwidthonsmartphone center">';
  709. print $form->selectarray("search_type_thirdparty", $formcompany->typent_array(0), $search_type_thirdparty, 1, 0, 0, '', 0, 0, 0, (!getDolGlobalString('SOCIETE_SORT_ON_TYPEENT') ? 'ASC' : $conf->global->SOCIETE_SORT_ON_TYPEENT), '', 1);
  710. print '</td>';
  711. }
  712. // Date
  713. if (!empty($arrayfields['sp.date_valid']['checked'])) {
  714. print '<td class="liste_titre center">';
  715. print '<div class="nowrapfordate">';
  716. print $form->selectDate($search_date_valid_start ? $search_date_valid_start : -1, 'search_date_valid_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From'));
  717. print '</div>';
  718. print '<div class="nowrapfordate">';
  719. print $form->selectDate($search_date_valid_end ? $search_date_valid_end : -1, 'search_date_valid_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to'));
  720. print '</div>';
  721. print '</td>';
  722. }
  723. // Date
  724. if (!empty($arrayfields['sp.date_livraison']['checked'])) {
  725. print '<td class="liste_titre center">';
  726. print '<div class="nowrapfordate">';
  727. print $form->selectDate($search_date_start ? $search_date_start : -1, 'search_date_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From'));
  728. print '</div>';
  729. print '<div class="nowrapfordate">';
  730. print $form->selectDate($search_date_end ? $search_date_end : -1, 'search_date_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to'));
  731. print '</div>';
  732. print '</td>';
  733. }
  734. if (!empty($arrayfields['sp.total_ht']['checked'])) {
  735. // Amount
  736. print '<td class="liste_titre right">';
  737. print '<input class="flat" type="text" size="5" name="search_montant_ht" value="'.dol_escape_htmltag($search_montant_ht).'">';
  738. print '</td>';
  739. }
  740. if (!empty($arrayfields['sp.total_tva']['checked'])) {
  741. // Amount
  742. print '<td class="liste_titre right">';
  743. print '<input class="flat" type="text" size="5" name="search_montant_vat" value="'.dol_escape_htmltag($search_montant_vat).'">';
  744. print '</td>';
  745. }
  746. if (!empty($arrayfields['sp.total_ttc']['checked'])) {
  747. // Amount
  748. print '<td class="liste_titre right">';
  749. print '<input class="flat" type="text" size="5" name="search_montant_ttc" value="'.dol_escape_htmltag($search_montant_ttc).'">';
  750. print '</td>';
  751. }
  752. if (!empty($arrayfields['sp.multicurrency_code']['checked'])) {
  753. // Currency
  754. print '<td class="liste_titre">';
  755. print $form->selectMultiCurrency($search_multicurrency_code, 'search_multicurrency_code', 1);
  756. print '</td>';
  757. }
  758. if (!empty($arrayfields['sp.multicurrency_tx']['checked'])) {
  759. // Currency rate
  760. print '<td class="liste_titre">';
  761. print '<input class="flat" type="text" size="4" name="search_multicurrency_tx" value="'.dol_escape_htmltag($search_multicurrency_tx).'">';
  762. print '</td>';
  763. }
  764. if (!empty($arrayfields['sp.multicurrency_total_ht']['checked'])) {
  765. // Amount
  766. print '<td class="liste_titre right">';
  767. print '<input class="flat" type="text" size="4" name="search_multicurrency_montant_ht" value="'.dol_escape_htmltag($search_multicurrency_montant_ht).'">';
  768. print '</td>';
  769. }
  770. if (!empty($arrayfields['sp.multicurrency_total_vat']['checked'])) {
  771. // Amount
  772. print '<td class="liste_titre right">';
  773. print '<input class="flat" type="text" size="4" name="search_multicurrency_montant_vat" value="'.dol_escape_htmltag($search_multicurrency_montant_vat).'">';
  774. print '</td>';
  775. }
  776. if (!empty($arrayfields['sp.multicurrency_total_ttc']['checked'])) {
  777. // Amount
  778. print '<td class="liste_titre right">';
  779. print '<input class="flat" type="text" size="4" name="search_multicurrency_montant_ttc" value="'.dol_escape_htmltag($search_multicurrency_montant_ttc).'">';
  780. print '</td>';
  781. }
  782. if (!empty($arrayfields['u.login']['checked'])) {
  783. // Author
  784. print '<td class="liste_titre center">';
  785. print '<input class="flat" size="4" type="text" name="search_login" value="'.dol_escape_htmltag($search_login).'">';
  786. print '</td>';
  787. }
  788. // Extra fields
  789. include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php';
  790. // Fields from hook
  791. $parameters = array('arrayfields'=>$arrayfields);
  792. $reshook = $hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook
  793. print $hookmanager->resPrint;
  794. // Date creation
  795. if (!empty($arrayfields['sp.datec']['checked'])) {
  796. print '<td class="liste_titre">';
  797. print '</td>';
  798. }
  799. // Date modification
  800. if (!empty($arrayfields['sp.tms']['checked'])) {
  801. print '<td class="liste_titre">';
  802. print '</td>';
  803. }
  804. // Status
  805. if (!empty($arrayfields['sp.fk_statut']['checked'])) {
  806. print '<td class="liste_titre center parentonrightofpage">';
  807. $formpropal->selectProposalStatus($search_status, 1, 0, 1, 'supplier', 'search_status', 'search_status width100 onrightofpage');
  808. print '</td>';
  809. }
  810. // Action column
  811. if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
  812. print '<td class="liste_titre maxwidthsearch">';
  813. $searchpicto = $form->showFilterButtons();
  814. print $searchpicto;
  815. print '</td>';
  816. }
  817. print "</tr>\n";
  818. $totalarray = array();
  819. $totalarray['nbfield'] = 0;
  820. // Fields title
  821. print '<tr class="liste_titre">';
  822. if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
  823. print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ');
  824. $totalarray['nbfield']++;
  825. }
  826. if (!empty($arrayfields['sp.ref']['checked'])) {
  827. print_liste_field_titre($arrayfields['sp.ref']['label'], $_SERVER["PHP_SELF"], 'sp.ref', '', $param, '', $sortfield, $sortorder);
  828. $totalarray['nbfield']++;
  829. }
  830. if (!empty($arrayfields['s.nom']['checked'])) {
  831. print_liste_field_titre($arrayfields['s.nom']['label'], $_SERVER["PHP_SELF"], 's.nom', '', $param, '', $sortfield, $sortorder);
  832. $totalarray['nbfield']++;
  833. }
  834. if (!empty($arrayfields['s.name_alias']['checked'])) {
  835. print_liste_field_titre($arrayfields['s.name_alias']['label'], $_SERVER["PHP_SELF"], 's.name_alias', '', $param, '', $sortfield, $sortorder);
  836. $totalarray['nbfield']++;
  837. }
  838. if (!empty($arrayfields['s.town']['checked'])) {
  839. print_liste_field_titre($arrayfields['s.town']['label'], $_SERVER["PHP_SELF"], 's.town', '', $param, '', $sortfield, $sortorder);
  840. $totalarray['nbfield']++;
  841. }
  842. if (!empty($arrayfields['s.zip']['checked'])) {
  843. print_liste_field_titre($arrayfields['s.zip']['label'], $_SERVER["PHP_SELF"], 's.zip', '', $param, '', $sortfield, $sortorder);
  844. $totalarray['nbfield']++;
  845. }
  846. if (!empty($arrayfields['state.nom']['checked'])) {
  847. print_liste_field_titre($arrayfields['state.nom']['label'], $_SERVER["PHP_SELF"], "state.nom", "", $param, '', $sortfield, $sortorder);
  848. $totalarray['nbfield']++;
  849. }
  850. if (!empty($arrayfields['country.code_iso']['checked'])) {
  851. print_liste_field_titre($arrayfields['country.code_iso']['label'], $_SERVER["PHP_SELF"], "country.code_iso", "", $param, '', $sortfield, $sortorder, 'center ');
  852. $totalarray['nbfield']++;
  853. }
  854. if (!empty($arrayfields['typent.code']['checked'])) {
  855. print_liste_field_titre($arrayfields['typent.code']['label'], $_SERVER["PHP_SELF"], "typent.code", "", $param, '', $sortfield, $sortorder, 'center ');
  856. $totalarray['nbfield']++;
  857. }
  858. if (!empty($arrayfields['sp.date_valid']['checked'])) {
  859. print_liste_field_titre($arrayfields['sp.date_valid']['label'], $_SERVER["PHP_SELF"], 'sp.date_valid', '', $param, '', $sortfield, $sortorder, 'center ');
  860. $totalarray['nbfield']++;
  861. }
  862. if (!empty($arrayfields['sp.date_livraison']['checked'])) {
  863. print_liste_field_titre($arrayfields['sp.date_livraison']['label'], $_SERVER["PHP_SELF"], 'sp.date_livraison', '', $param, '', $sortfield, $sortorder, 'center ');
  864. $totalarray['nbfield']++;
  865. }
  866. if (!empty($arrayfields['sp.total_ht']['checked'])) {
  867. print_liste_field_titre($arrayfields['sp.total_ht']['label'], $_SERVER["PHP_SELF"], 'sp.total_ht', '', $param, '', $sortfield, $sortorder, 'right ');
  868. $totalarray['nbfield']++;
  869. }
  870. if (!empty($arrayfields['sp.total_tva']['checked'])) {
  871. print_liste_field_titre($arrayfields['sp.total_tva']['label'], $_SERVER["PHP_SELF"], 'sp.total_tva', '', $param, '', $sortfield, $sortorder, 'right ');
  872. $totalarray['nbfield']++;
  873. }
  874. if (!empty($arrayfields['sp.total_ttc']['checked'])) {
  875. print_liste_field_titre($arrayfields['sp.total_ttc']['label'], $_SERVER["PHP_SELF"], 'sp.total_ttc', '', $param, '', $sortfield, $sortorder, 'right ');
  876. $totalarray['nbfield']++;
  877. }
  878. if (!empty($arrayfields['sp.multicurrency_code']['checked'])) {
  879. print_liste_field_titre($arrayfields['sp.multicurrency_code']['label'], $_SERVER['PHP_SELF'], 'sp.multicurrency_code', '', $param, '', $sortfield, $sortorder);
  880. $totalarray['nbfield']++;
  881. }
  882. if (!empty($arrayfields['sp.multicurrency_tx']['checked'])) {
  883. print_liste_field_titre($arrayfields['sp.multicurrency_tx']['label'], $_SERVER['PHP_SELF'], 'sp.multicurrency_tx', '', $param, '', $sortfield, $sortorder);
  884. $totalarray['nbfield']++;
  885. }
  886. if (!empty($arrayfields['sp.multicurrency_total_ht']['checked'])) {
  887. print_liste_field_titre($arrayfields['sp.multicurrency_total_ht']['label'], $_SERVER['PHP_SELF'], 'sp.multicurrency_total_ht', '', $param, 'class="right"', $sortfield, $sortorder);
  888. $totalarray['nbfield']++;
  889. }
  890. if (!empty($arrayfields['sp.multicurrency_total_vat']['checked'])) {
  891. print_liste_field_titre($arrayfields['sp.multicurrency_total_vat']['label'], $_SERVER['PHP_SELF'], 'sp.multicurrency_total_tva', '', $param, 'class="right"', $sortfield, $sortorder);
  892. $totalarray['nbfield']++;
  893. }
  894. if (!empty($arrayfields['sp.multicurrency_total_ttc']['checked'])) {
  895. print_liste_field_titre($arrayfields['sp.multicurrency_total_ttc']['label'], $_SERVER['PHP_SELF'], 'sp.multicurrency_total_ttc', '', $param, 'class="right"', $sortfield, $sortorder);
  896. $totalarray['nbfield']++;
  897. }
  898. if (!empty($arrayfields['u.login']['checked'])) {
  899. print_liste_field_titre($arrayfields['u.login']['label'], $_SERVER["PHP_SELF"], 'u.login', '', $param, '', $sortfield, $sortorder, 'center ');
  900. $totalarray['nbfield']++;
  901. }
  902. // Extra fields
  903. include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php';
  904. // Hook fields
  905. $parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder);
  906. $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters); // Note that $action and $object may have been modified by hook
  907. print $hookmanager->resPrint;
  908. if (!empty($arrayfields['sp.datec']['checked'])) {
  909. print_liste_field_titre($arrayfields['sp.datec']['label'], $_SERVER["PHP_SELF"], "sp.datec", "", $param, '', $sortfield, $sortorder, 'center nowrap ');
  910. $totalarray['nbfield']++;
  911. }
  912. if (!empty($arrayfields['sp.tms']['checked'])) {
  913. print_liste_field_titre($arrayfields['sp.tms']['label'], $_SERVER["PHP_SELF"], "sp.tms", "", $param, '', $sortfield, $sortorder, 'center nowrap');
  914. $totalarray['nbfield']++;
  915. }
  916. if (!empty($arrayfields['sp.fk_statut']['checked'])) {
  917. print_liste_field_titre($arrayfields['sp.fk_statut']['label'], $_SERVER["PHP_SELF"], "sp.fk_statut", "", $param, '', $sortfield, $sortorder, 'center ');
  918. $totalarray['nbfield']++;
  919. }
  920. // Action
  921. if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
  922. print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ');
  923. $totalarray['nbfield']++;
  924. }
  925. print '</tr>'."\n";
  926. $now = dol_now();
  927. $i = 0;
  928. $total = 0;
  929. $subtotal = 0;
  930. $savnbfield = $totalarray['nbfield'];
  931. $totalarray = array();
  932. $totalarray['nbfield'] = 0;
  933. $totalarray['val'] = array();
  934. $totalarray['val']['sp.total_ht'] = 0;
  935. $totalarray['val']['sp.total_tva'] = 0;
  936. $totalarray['val']['sp.total_ttc'] = 0;
  937. $imaxinloop = ($limit ? min($num, $limit) : $num);
  938. while ($i < $imaxinloop) {
  939. $obj = $db->fetch_object($resql);
  940. $objectstatic->id = $obj->rowid;
  941. $objectstatic->ref = $obj->ref;
  942. $objectstatic->note_public = $obj->note_public;
  943. $objectstatic->note_private = $obj->note_private;
  944. $objectstatic->status = $obj->status;
  945. // Company
  946. $companystatic->id = $obj->socid;
  947. $companystatic->name = $obj->name;
  948. $companystatic->name_alias = $obj->alias;
  949. $companystatic->client = $obj->client;
  950. $companystatic->code_client = $obj->code_client;
  951. if ($mode == 'kanban') {
  952. if ($i == 0) {
  953. print '<tr class="trkanban"><td colspan="'.$savnbfield.'">';
  954. print '<div class="box-flex-container kanban">';
  955. }
  956. // Output Kanban
  957. // TODO Use a cahe on user
  958. $userstatic->fetch($obj->fk_user_author);
  959. $objectstatic->delivery_date = $obj->dp;
  960. print $objectstatic->getKanbanView('', array('thirdparty'=>$companystatic, 'userauthor'=>$userstatic, 'selected' => in_array($obj->id, $arrayofselected)));
  961. if ($i == ($imaxinloop - 1)) {
  962. print '</div>';
  963. print '</td></tr>';
  964. }
  965. } else {
  966. print '<tr class="oddeven">';
  967. // Action column
  968. if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
  969. print '<td class="nowrap center">';
  970. if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
  971. $selected = 0;
  972. if (in_array($obj->rowid, $arrayofselected)) {
  973. $selected = 1;
  974. }
  975. print '<input id="cb'.$obj->rowid.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.'"'.($selected ? ' checked="checked"' : '').'>';
  976. }
  977. print '</td>';
  978. }
  979. if (!empty($arrayfields['sp.ref']['checked'])) {
  980. print '<td class="nowraponall">';
  981. print '<table class="nobordernopadding"><tr class="nocellnopadd">';
  982. // Picto + Ref
  983. print '<td class="nobordernopadding nowraponall">';
  984. print $objectstatic->getNomUrl(1, '', '', 0, -1, 1);
  985. print '</td>';
  986. // Warning
  987. $warnornote = '';
  988. //if ($obj->fk_statut == 1 && $db->jdate($obj->date_valid) < ($now - $conf->supplier_proposal->warning_delay)) $warnornote .= img_warning($langs->trans("Late"));
  989. if ($warnornote) {
  990. print '<td style="min-width: 20px" class="nobordernopadding nowrap">';
  991. print $warnornote;
  992. print '</td>';
  993. }
  994. // Other picto tool
  995. print '<td width="16" class="right nobordernopadding hideonsmartphone">';
  996. $filename = dol_sanitizeFileName($obj->ref);
  997. $filedir = $conf->supplier_proposal->dir_output.'/'.dol_sanitizeFileName($obj->ref);
  998. $urlsource = $_SERVER['PHP_SELF'].'?id='.$obj->rowid;
  999. print $formfile->getDocumentsLink($objectstatic->element, $filename, $filedir);
  1000. print '</td></tr></table>';
  1001. print "</td>\n";
  1002. if (!$i) {
  1003. $totalarray['nbfield']++;
  1004. }
  1005. }
  1006. // Thirdparty
  1007. if (!empty($arrayfields['s.nom']['checked'])) {
  1008. print '<td class="tdoverflowmax200">';
  1009. print $companystatic->getNomUrl(1, 'supplier', 0, 0, -1, empty($arrayfields['s.name_alias']['checked']) ? 0 : 1);
  1010. print '</td>';
  1011. if (!$i) {
  1012. $totalarray['nbfield']++;
  1013. }
  1014. }
  1015. // Alias
  1016. if (!empty($arrayfields['s.name_alias']['checked'])) {
  1017. print '<td class="tdoverflowmax200">';
  1018. print $companystatic->name_alias;
  1019. print '</td>';
  1020. if (!$i) {
  1021. $totalarray['nbfield']++;
  1022. }
  1023. }
  1024. // Town
  1025. if (!empty($arrayfields['s.town']['checked'])) {
  1026. print '<td class="nocellnopadd">';
  1027. print $obj->town;
  1028. print '</td>';
  1029. if (!$i) {
  1030. $totalarray['nbfield']++;
  1031. }
  1032. }
  1033. // Zip
  1034. if (!empty($arrayfields['s.zip']['checked'])) {
  1035. print '<td class="nocellnopadd">';
  1036. print $obj->zip;
  1037. print '</td>';
  1038. if (!$i) {
  1039. $totalarray['nbfield']++;
  1040. }
  1041. }
  1042. // State
  1043. if (!empty($arrayfields['state.nom']['checked'])) {
  1044. print "<td>".$obj->state_name."</td>\n";
  1045. if (!$i) {
  1046. $totalarray['nbfield']++;
  1047. }
  1048. }
  1049. // Country
  1050. if (!empty($arrayfields['country.code_iso']['checked'])) {
  1051. print '<td class="center">';
  1052. $tmparray = getCountry($obj->fk_pays, 'all');
  1053. print $tmparray['label'];
  1054. print '</td>';
  1055. if (!$i) {
  1056. $totalarray['nbfield']++;
  1057. }
  1058. }
  1059. // Type ent
  1060. if (!empty($arrayfields['typent.code']['checked'])) {
  1061. print '<td class="center">';
  1062. if (empty($typenArray) || !is_array($typenArray) || count($typenArray) == 0) {
  1063. $typenArray = $formcompany->typent_array(1);
  1064. }
  1065. print $typenArray[$obj->typent_code];
  1066. print '</td>';
  1067. if (!$i) {
  1068. $totalarray['nbfield']++;
  1069. }
  1070. }
  1071. // Date proposal
  1072. if (!empty($arrayfields['sp.date_valid']['checked'])) {
  1073. print '<td class="center">';
  1074. print dol_print_date($db->jdate($obj->date_valid), 'day');
  1075. print "</td>\n";
  1076. if (!$i) {
  1077. $totalarray['nbfield']++;
  1078. }
  1079. }
  1080. // Date delivery
  1081. if (!empty($arrayfields['sp.date_livraison']['checked'])) {
  1082. print '<td class="center">';
  1083. print dol_print_date($db->jdate($obj->dp), 'day');
  1084. print "</td>\n";
  1085. if (!$i) {
  1086. $totalarray['nbfield']++;
  1087. }
  1088. }
  1089. // Amount HT
  1090. if (!empty($arrayfields['sp.total_ht']['checked'])) {
  1091. print '<td class="right"><span class="amount">'.price($obj->total_ht)."</span></td>\n";
  1092. if (!$i) {
  1093. $totalarray['nbfield']++;
  1094. }
  1095. if (!$i) {
  1096. $totalarray['pos'][$totalarray['nbfield']] = 'sp.total_ht';
  1097. }
  1098. $totalarray['val']['sp.total_ht'] += $obj->total_ht;
  1099. }
  1100. // Amount VAT
  1101. if (!empty($arrayfields['sp.total_tva']['checked'])) {
  1102. print '<td class="right"><span class="amount">'.price($obj->total_tva)."</span></td>\n";
  1103. if (!$i) {
  1104. $totalarray['nbfield']++;
  1105. }
  1106. if (!$i) {
  1107. $totalarray['pos'][$totalarray['nbfield']] = 'sp.total_tva';
  1108. }
  1109. $totalarray['val']['sp.total_tva'] += $obj->total_tva;
  1110. }
  1111. // Amount TTC
  1112. if (!empty($arrayfields['sp.total_ttc']['checked'])) {
  1113. print '<td class="right"><span class="amount">'.price($obj->total_ttc)."</span></td>\n";
  1114. if (!$i) {
  1115. $totalarray['nbfield']++;
  1116. }
  1117. if (!$i) {
  1118. $totalarray['pos'][$totalarray['nbfield']] = 'sp.total_ttc';
  1119. }
  1120. $totalarray['val']['sp.total_ttc'] += $obj->total_ttc;
  1121. }
  1122. // Currency
  1123. if (!empty($arrayfields['sp.multicurrency_code']['checked'])) {
  1124. print '<td class="nowrap">'.$obj->multicurrency_code.' - '.$langs->trans('Currency'.$obj->multicurrency_code)."</td>\n";
  1125. if (!$i) {
  1126. $totalarray['nbfield']++;
  1127. }
  1128. }
  1129. // Currency rate
  1130. if (!empty($arrayfields['sp.multicurrency_tx']['checked'])) {
  1131. print '<td class="nowrap">';
  1132. $form->form_multicurrency_rate($_SERVER['PHP_SELF'].'?id='.$obj->rowid, $obj->multicurrency_tx, 'none', $obj->multicurrency_code);
  1133. print "</td>\n";
  1134. if (!$i) {
  1135. $totalarray['nbfield']++;
  1136. }
  1137. }
  1138. // Amount HT
  1139. if (!empty($arrayfields['sp.multicurrency_total_ht']['checked'])) {
  1140. print '<td class="right nowrap"><span class="amount">'.price($obj->multicurrency_total_ht)."</span></td>\n";
  1141. if (!$i) {
  1142. $totalarray['nbfield']++;
  1143. }
  1144. }
  1145. // Amount VAT
  1146. if (!empty($arrayfields['sp.multicurrency_total_vat']['checked'])) {
  1147. print '<td class="right nowrap"><span class="amount">'.price($obj->multicurrency_total_vat)."</span></td>\n";
  1148. if (!$i) {
  1149. $totalarray['nbfield']++;
  1150. }
  1151. }
  1152. // Amount TTC
  1153. if (!empty($arrayfields['sp.multicurrency_total_ttc']['checked'])) {
  1154. print '<td class="right nowrap"><span class="amount">'.price($obj->multicurrency_total_ttc)."</span></td>\n";
  1155. if (!$i) {
  1156. $totalarray['nbfield']++;
  1157. }
  1158. }
  1159. $userstatic->id = $obj->fk_user_author;
  1160. $userstatic->login = $obj->login;
  1161. $userstatic->status = $obj->ustatus;
  1162. $userstatic->lastname = $obj->name;
  1163. $userstatic->firstname = $obj->firstname;
  1164. $userstatic->photo = $obj->photo;
  1165. $userstatic->admin = $obj->admin;
  1166. $userstatic->ref = $obj->fk_user_author;
  1167. $userstatic->employee = $obj->employee;
  1168. $userstatic->email = $obj->uemail;
  1169. // Author
  1170. if (!empty($arrayfields['u.login']['checked'])) {
  1171. print '<td class="center">';
  1172. if ($userstatic->id > 0) {
  1173. print $userstatic->getNomUrl(-1, '', 0, 0, 24, 1, 'login', '', 1);
  1174. } else {
  1175. print '&nbsp;';
  1176. }
  1177. print "</td>\n";
  1178. if (!$i) {
  1179. $totalarray['nbfield']++;
  1180. }
  1181. }
  1182. // Extra fields
  1183. include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php';
  1184. // Fields from hook
  1185. $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray);
  1186. $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook
  1187. print $hookmanager->resPrint;
  1188. // Date creation
  1189. if (!empty($arrayfields['sp.datec']['checked'])) {
  1190. print '<td class="center nowraponall">';
  1191. print dol_print_date($db->jdate($obj->date_creation), 'dayhour', 'tzuser');
  1192. print '</td>';
  1193. if (!$i) {
  1194. $totalarray['nbfield']++;
  1195. }
  1196. }
  1197. // Date modification
  1198. if (!empty($arrayfields['sp.tms']['checked'])) {
  1199. print '<td class="center nowraponall">';
  1200. print dol_print_date($db->jdate($obj->date_update), 'dayhour', 'tzuser');
  1201. print '</td>';
  1202. if (!$i) {
  1203. $totalarray['nbfield']++;
  1204. }
  1205. }
  1206. // Status
  1207. if (!empty($arrayfields['sp.fk_statut']['checked'])) {
  1208. print '<td class="center">'.$objectstatic->getLibStatut(5)."</td>\n";
  1209. if (!$i) {
  1210. $totalarray['nbfield']++;
  1211. }
  1212. }
  1213. // Action column
  1214. if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
  1215. print '<td class="nowrap center">';
  1216. if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
  1217. $selected = 0;
  1218. if (in_array($obj->rowid, $arrayofselected)) {
  1219. $selected = 1;
  1220. }
  1221. print '<input id="cb'.$obj->rowid.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.'"'.($selected ? ' checked="checked"' : '').'>';
  1222. }
  1223. print '</td>';
  1224. }
  1225. if (!$i) {
  1226. $totalarray['nbfield']++;
  1227. }
  1228. print "</tr>\n";
  1229. $total += $obj->total_ht;
  1230. $subtotal += $obj->total_ht;
  1231. }
  1232. $i++;
  1233. }
  1234. // Show total line
  1235. include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php';
  1236. // If no record found
  1237. if ($num == 0) {
  1238. $colspan = 1;
  1239. foreach ($arrayfields as $key => $val) {
  1240. if (!empty($val['checked'])) {
  1241. $colspan++;
  1242. }
  1243. }
  1244. print '<tr><td colspan="'.$colspan.'"><span class="opacitymedium">'.$langs->trans("NoRecordFound").'</span></td></tr>';
  1245. }
  1246. $db->free($resql);
  1247. $parameters = array('arrayfields'=>$arrayfields, 'sql'=>$sql);
  1248. $reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters); // Note that $action and $object may have been modified by hook
  1249. print $hookmanager->resPrint;
  1250. print '</table>'."\n";
  1251. print '</div>'."\n";
  1252. print '</form>'."\n";
  1253. $hidegeneratedfilelistifempty = 1;
  1254. if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) {
  1255. $hidegeneratedfilelistifempty = 0;
  1256. }
  1257. // Show list of available documents
  1258. $urlsource = $_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder;
  1259. $urlsource .= str_replace('&amp;', '&', $param);
  1260. $filedir = $diroutputmassaction;
  1261. $genallowed = $user->rights->supplier_proposal->lire;
  1262. $delallowed = $user->rights->supplier_proposal->creer;
  1263. print $formfile->showdocuments('massfilesarea_supplier_proposal', '', $filedir, $urlsource, 0, $delallowed, '', 1, 1, 0, 48, 1, $param, $title, '', '', '', null, $hidegeneratedfilelistifempty);
  1264. } else {
  1265. dol_print_error($db);
  1266. }
  1267. // End of page
  1268. llxFooter();
  1269. $db->close();