list.php 55 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338
  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. $result = restrictedArea($user, $module, $objectid, $dbtable);
  180. $permissiontoread = $user->rights->supplier_proposal->lire;
  181. $permissiontodelete = $user->rights->supplier_proposal->supprimer;
  182. /*
  183. * Actions
  184. */
  185. if (GETPOST('cancel', 'alpha')) {
  186. $action = 'list';
  187. $massaction = '';
  188. }
  189. if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') {
  190. $massaction = '';
  191. }
  192. $parameters = array('socid'=>$socid);
  193. $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
  194. if ($reshook < 0) {
  195. setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
  196. }
  197. if (empty($reshook)) {
  198. // Selection of new fields
  199. include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
  200. // Purge search criteria
  201. 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
  202. $search_categ = '';
  203. $search_user = '';
  204. $search_sale = '';
  205. $search_ref = '';
  206. $search_societe = '';
  207. $search_societe_alias = '';
  208. $search_montant_ht = '';
  209. $search_montant_vat = '';
  210. $search_montant_ttc = '';
  211. $search_multicurrency_code = '';
  212. $search_multicurrency_tx = '';
  213. $search_multicurrency_montant_ht = '';
  214. $search_multicurrency_montant_vat = '';
  215. $search_multicurrency_montant_ttc = '';
  216. $search_login = '';
  217. $search_product_category = '';
  218. $search_town = '';
  219. $search_zip = "";
  220. $search_state = "";
  221. $search_type = '';
  222. $search_country = '';
  223. $search_type_thirdparty = '';
  224. $search_date_startday = '';
  225. $search_date_startmonth = '';
  226. $search_date_startyear = '';
  227. $search_date_endday = '';
  228. $search_date_endmonth = '';
  229. $search_date_endyear = '';
  230. $search_date_start = '';
  231. $search_date_end = '';
  232. $search_date_valid_startday = '';
  233. $search_date_valid_startmonth = '';
  234. $search_date_valid_startyear = '';
  235. $search_date_valid_endday = '';
  236. $search_date_valid_endmonth = '';
  237. $search_date_valid_endyear = '';
  238. $search_date_valid_start = '';
  239. $search_date_valid_end = '';
  240. $search_status = '';
  241. $object_statut = '';
  242. }
  243. $objectclass = 'SupplierProposal';
  244. $objectlabel = 'SupplierProposals';
  245. $uploaddir = $conf->supplier_proposal->dir_output;
  246. include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';
  247. }
  248. /*
  249. * View
  250. */
  251. $form = new Form($db);
  252. $formother = new FormOther($db);
  253. $formfile = new FormFile($db);
  254. $formpropal = new FormPropal($db);
  255. $companystatic = new Societe($db);
  256. $formcompany = new FormCompany($db);
  257. $now = dol_now();
  258. $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
  259. $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields
  260. $title = $langs->trans('ListOfSupplierProposals');
  261. $help_url = 'EN:Ask_Price_Supplier|FR:Demande_de_prix_fournisseur';
  262. // Build and execute select
  263. // --------------------------------------------------------------------
  264. $sql = 'SELECT';
  265. if ($sall || $search_user > 0) {
  266. $sql = 'SELECT DISTINCT';
  267. }
  268. $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,';
  269. $sql .= " typent.code as typent_code,";
  270. $sql .= " state.code_departement as state_code, state.nom as state_name,";
  271. $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,';
  272. $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,';
  273. $sql .= ' sp.datec as date_creation, sp.tms as date_update,';
  274. $sql .= " p.rowid as project_id, p.ref as project_ref,";
  275. if (empty($user->rights->societe->client->voir) && !$socid) {
  276. $sql .= " sc.fk_soc, sc.fk_user,";
  277. }
  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. // We'll need this table joined to the select in order to filter by sale
  303. if ($search_sale > 0 || (empty($user->rights->societe->client->voir) && !$socid)) {
  304. $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
  305. }
  306. if ($search_user > 0) {
  307. $sql .= ", ".MAIN_DB_PREFIX."element_contact as c";
  308. $sql .= ", ".MAIN_DB_PREFIX."c_type_contact as tc";
  309. }
  310. $sql .= ' WHERE sp.fk_soc = s.rowid';
  311. $sql .= ' AND sp.entity IN ('.getEntity('supplier_proposal').')';
  312. if (empty($user->rights->societe->client->voir) && !$socid) { //restriction
  313. $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
  314. }
  315. if ($search_town) {
  316. $sql .= natural_search('s.town', $search_town);
  317. }
  318. if ($search_zip) {
  319. $sql .= natural_search("s.zip", $search_zip);
  320. }
  321. if ($search_state) {
  322. $sql .= natural_search("state.nom", $search_state);
  323. }
  324. if ($search_country) {
  325. $sql .= " AND s.fk_pays IN (".$db->sanitize($search_country).')';
  326. }
  327. if ($search_type_thirdparty != '' && $search_type_thirdparty > 0) {
  328. $sql .= " AND s.fk_typent IN (".$db->sanitize($search_type_thirdparty).')';
  329. }
  330. if ($search_ref) {
  331. $sql .= natural_search('sp.ref', $search_ref);
  332. }
  333. if (empty($arrayfields['s.name_alias']['checked']) && $search_societe) {
  334. $sql .= natural_search(array("s.nom", "s.name_alias"), $search_societe);
  335. } else {
  336. if ($search_societe) {
  337. $sql .= natural_search('s.nom', $search_societe);
  338. }
  339. if ($search_societe_alias) {
  340. $sql .= natural_search('s.name_alias', $search_societe_alias);
  341. }
  342. }
  343. if ($search_login) {
  344. $sql .= natural_search(array('u.lastname', 'u.firstname', 'u.login'), $search_login);
  345. }
  346. if ($search_montant_ht) {
  347. $sql .= natural_search('sp.total_ht', $search_montant_ht, 1);
  348. }
  349. if ($search_montant_vat != '') {
  350. $sql .= natural_search("sp.total_tva", $search_montant_vat, 1);
  351. }
  352. if ($search_montant_ttc != '') {
  353. $sql .= natural_search("sp.total_ttc", $search_montant_ttc, 1);
  354. }
  355. if ($search_multicurrency_code != '') {
  356. $sql .= " AND sp.multicurrency_code = '".$db->escape($search_multicurrency_code)."'";
  357. }
  358. if ($search_multicurrency_tx != '') {
  359. $sql .= natural_search('sp.multicurrency_tx', $search_multicurrency_tx, 1);
  360. }
  361. if ($search_multicurrency_montant_ht != '') {
  362. $sql .= natural_search('sp.multicurrency_total_ht', $search_multicurrency_montant_ht, 1);
  363. }
  364. if ($search_multicurrency_montant_vat != '') {
  365. $sql .= natural_search('sp.multicurrency_total_tva', $search_multicurrency_montant_vat, 1);
  366. }
  367. if ($search_multicurrency_montant_ttc != '') {
  368. $sql .= natural_search('sp.multicurrency_total_ttc', $search_multicurrency_montant_ttc, 1);
  369. }
  370. if ($sall) {
  371. $sql .= natural_search(array_keys($fieldstosearchall), $sall);
  372. }
  373. if ($socid) {
  374. $sql .= ' AND s.rowid = '.((int) $socid);
  375. }
  376. if ($search_status >= 0 && $search_status != '') {
  377. $sql .= ' AND sp.fk_statut IN ('.$db->sanitize($db->escape($search_status)).')';
  378. }
  379. if ($search_date_start) {
  380. $sql .= " AND sp.date_livraison >= '".$db->idate($search_date_start)."'";
  381. }
  382. if ($search_date_end) {
  383. $sql .= " AND sp.date_livraison <= '".$db->idate($search_date_end)."'";
  384. }
  385. if ($search_date_valid_start) {
  386. $sql .= " AND sp.date_valid >= '".$db->idate($search_date_valid_start)."'";
  387. }
  388. if ($search_date_valid_end) {
  389. $sql .= " AND sp.date_valid <= '".$db->idate($search_date_valid_end)."'";
  390. }
  391. if ($search_sale > 0) {
  392. $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $search_sale);
  393. }
  394. if ($search_user > 0) {
  395. $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);
  396. }
  397. // Search for tag/category ($searchCategoryProductList is an array of ID)
  398. $searchCategoryProductOperator = -1;
  399. $searchCategoryProductList = array($search_product_category);
  400. if (!empty($searchCategoryProductList)) {
  401. $searchCategoryProductSqlList = array();
  402. $listofcategoryid = '';
  403. foreach ($searchCategoryProductList as $searchCategoryProduct) {
  404. if (intval($searchCategoryProduct) == -2) {
  405. $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)";
  406. } elseif (intval($searchCategoryProduct) > 0) {
  407. if ($searchCategoryProductOperator == 0) {
  408. $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).")";
  409. } else {
  410. $listofcategoryid .= ($listofcategoryid ? ', ' : '') .((int) $searchCategoryProduct);
  411. }
  412. }
  413. }
  414. if ($listofcategoryid) {
  415. $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)."))";
  416. }
  417. if ($searchCategoryProductOperator == 1) {
  418. if (!empty($searchCategoryProductSqlList)) {
  419. $sql .= " AND (".implode(' OR ', $searchCategoryProductSqlList).")";
  420. }
  421. } else {
  422. if (!empty($searchCategoryProductSqlList)) {
  423. $sql .= " AND (".implode(' AND ', $searchCategoryProductSqlList).")";
  424. }
  425. }
  426. }
  427. // Add where from extra fields
  428. include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php';
  429. // Add where from hooks
  430. $parameters = array();
  431. $reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
  432. $sql .= $hookmanager->resPrint;
  433. $sql .= $db->order($sortfield, $sortorder);
  434. $sql .= ', sp.ref DESC';
  435. // Count total nb of records
  436. $nbtotalofrecords = '';
  437. if (!getDolGlobalInt('MAIN_DISABLE_FULL_SCANLIST')) {
  438. $resql = $db->query($sql);
  439. $nbtotalofrecords = $db->num_rows($resql);
  440. if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller then paging size (filtering), goto and load page 0
  441. $page = 0;
  442. $offset = 0;
  443. }
  444. }
  445. $sql .= $db->plimit($limit + 1, $offset);
  446. $resql = $db->query($sql);
  447. if ($resql) {
  448. $objectstatic = new SupplierProposal($db);
  449. $userstatic = new User($db);
  450. if ($socid > 0) {
  451. $soc = new Societe($db);
  452. $soc->fetch($socid);
  453. $title = $langs->trans('SupplierProposals').' - '.$soc->name;
  454. } else {
  455. $title = $langs->trans('SupplierProposals');
  456. }
  457. $num = $db->num_rows($resql);
  458. $arrayofselected = is_array($toselect) ? $toselect : array();
  459. if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $sall) {
  460. $obj = $db->fetch_object($resql);
  461. $id = $obj->rowid;
  462. header("Location: ".DOL_URL_ROOT.'/supplier_proposal/card.php?id='.$id);
  463. exit;
  464. }
  465. // Output page
  466. // --------------------------------------------------------------------
  467. llxHeader('', $title, $help_url);
  468. $param = '';
  469. if (!empty($mode)) {
  470. $param .= '&mode='.urlencode($mode);
  471. }
  472. if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
  473. $param .= '&contextpage='.urlencode($contextpage);
  474. }
  475. if ($limit > 0 && $limit != $conf->liste_limit) {
  476. $param .= '&limit='.((int) $limit);
  477. }
  478. if ($sall) {
  479. $param .= '&sall='.urlencode($sall);
  480. }
  481. if ($search_date_startday) {
  482. $param .= '&search_date_startday='.urlencode($search_date_startday);
  483. }
  484. if ($search_date_startmonth) {
  485. $param .= '&search_date_startmonth='.urlencode($search_date_startmonth);
  486. }
  487. if ($search_date_startyear) {
  488. $param .= '&search_date_startyear='.urlencode($search_date_startyear);
  489. }
  490. if ($search_date_endday) {
  491. $param .= '&search_date_endday='.urlencode($search_date_endday);
  492. }
  493. if ($search_date_endmonth) {
  494. $param .= '&search_date_endmonth='.urlencode($search_date_endmonth);
  495. }
  496. if ($search_date_endyear) {
  497. $param .= '&search_date_endyear='.urlencode($search_date_endyear);
  498. }
  499. if ($search_date_valid_startday) {
  500. $param .= '&search_date_valid_startday='.urlencode($search_date_valid_startday);
  501. }
  502. if ($search_date_valid_startmonth) {
  503. $param .= '&search_date_valid_startmonth='.urlencode($search_date_valid_startmonth);
  504. }
  505. if ($search_date_valid_startyear) {
  506. $param .= '&search_date_valid_startyear='.urlencode($search_date_valid_startyear);
  507. }
  508. if ($search_date_valid_endday) {
  509. $param .= '&search_date_valid_endday='.urlencode($search_date_valid_endday);
  510. }
  511. if ($search_date_valid_endmonth) {
  512. $param .= '&search_date_valid_endmonth='.urlencode($search_date_valid_endmonth);
  513. }
  514. if ($search_date_valid_endyear) {
  515. $param .= '&search_date_valid_endyear='.urlencode($search_date_valid_endyear);
  516. }
  517. if ($search_ref) {
  518. $param .= '&search_ref='.urlencode($search_ref);
  519. }
  520. if ($search_societe) {
  521. $param .= '&search_societe='.urlencode($search_societe);
  522. }
  523. if ($search_societe_alias) {
  524. $param .= '&search_societe_alias='.urlencode($search_societe_alias);
  525. }
  526. if ($search_user > 0) {
  527. $param .= '&search_user='.urlencode($search_user);
  528. }
  529. if ($search_sale > 0) {
  530. $param .= '&search_sale='.urlencode($search_sale);
  531. }
  532. if ($search_montant_ht) {
  533. $param .= '&search_montant_ht='.urlencode($search_montant_ht);
  534. }
  535. if ($search_multicurrency_code != '') {
  536. $param .= '&search_multicurrency_code='.urlencode($search_multicurrency_code);
  537. }
  538. if ($search_multicurrency_tx != '') {
  539. $param .= '&search_multicurrency_tx='.urlencode($search_multicurrency_tx);
  540. }
  541. if ($search_multicurrency_montant_ht != '') {
  542. $param .= '&search_multicurrency_montant_ht='.urlencode($search_multicurrency_montant_ht);
  543. }
  544. if ($search_multicurrency_montant_vat != '') {
  545. $param .= '&search_multicurrency_montant_vat='.urlencode($search_multicurrency_montant_vat);
  546. }
  547. if ($search_multicurrency_montant_ttc != '') {
  548. $param .= '&search_multicurrency_montant_ttc='.urlencode($search_multicurrency_montant_ttc);
  549. }
  550. if ($search_login) {
  551. $param .= '&search_login='.urlencode($search_login);
  552. }
  553. if ($search_town) {
  554. $param .= '&search_town='.urlencode($search_town);
  555. }
  556. if ($search_zip) {
  557. $param .= '&search_zip='.urlencode($search_zip);
  558. }
  559. if ($socid > 0) {
  560. $param .= '&socid='.urlencode($socid);
  561. }
  562. if ($search_status != '') {
  563. $param .= '&search_status='.urlencode($search_status);
  564. }
  565. if ($optioncss != '') {
  566. $param .= '&optioncss='.urlencode($optioncss);
  567. }
  568. if ($search_type_thirdparty != '' && $search_type_thirdparty > 0) {
  569. $param .= '&search_type_thirdparty='.urlencode($search_type_thirdparty);
  570. }
  571. // Add $param from extra fields
  572. include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
  573. // List of mass actions available
  574. $arrayofmassactions = array(
  575. 'generate_doc'=>img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("ReGeneratePDF"),
  576. 'builddoc'=>img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("PDFMerge"),
  577. //'presend'=>img_picto('', 'email', 'class="pictofixedwidth"').$langs->trans("SendByMail"),
  578. );
  579. if ($user->rights->supplier_proposal->supprimer) {
  580. $arrayofmassactions['predelete'] = img_picto('', 'delete', 'class="pictofixedwidth"').$langs->trans("Delete");
  581. }
  582. if (in_array($massaction, array('presend', 'predelete'))) {
  583. $arrayofmassactions = array();
  584. }
  585. $massactionbutton = $form->selectMassAction('', $arrayofmassactions);
  586. $url = DOL_URL_ROOT.'/supplier_proposal/card.php?action=create';
  587. if (!empty($socid)) {
  588. $url .= '&socid='.$socid;
  589. }
  590. $newcardbutton = '';
  591. $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'));
  592. $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'));
  593. $newcardbutton .= dolGetButtonTitle($langs->trans('NewAskPrice'), '', 'fa fa-plus-circle', $url, '', $user->rights->supplier_proposal->creer);
  594. // Fields title search
  595. print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">';
  596. if ($optioncss != '') {
  597. print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
  598. }
  599. print '<input type="hidden" name="token" value="'.newToken().'">';
  600. print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
  601. print '<input type="hidden" name="action" value="list">';
  602. print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
  603. print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
  604. print '<input type="hidden" name="mode" value="'.$mode.'">';
  605. print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'supplier_proposal', 0, $newcardbutton, '', $limit, 0, 0, 1);
  606. $topicmail = "SendSupplierProposalRef";
  607. $modelmail = "supplier_proposal_send";
  608. $objecttmp = new SupplierProposal($db);
  609. $trackid = 'spro'.$object->id;
  610. include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php';
  611. if ($sall) {
  612. foreach ($fieldstosearchall as $key => $val) {
  613. $fieldstosearchall[$key] = $langs->trans($val);
  614. }
  615. print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $sall).join(', ', $fieldstosearchall).'</div>';
  616. }
  617. $i = 0;
  618. $moreforfilter = '';
  619. // If the user can view prospects other than his'
  620. if ($user->rights->user->user->lire) {
  621. $langs->load("commercial");
  622. $moreforfilter .= '<div class="divsearchfield">';
  623. $tmptitle = $langs->trans('ThirdPartiesOfSaleRepresentative');
  624. $moreforfilter .= img_picto($tmptitle, 'user', 'class="pictofixedwidth"').$formother->select_salesrepresentatives($search_sale, 'search_sale', $user, 0, $tmptitle, 'maxwidth250 widthcentpercentminusx');
  625. $moreforfilter .= '</div>';
  626. }
  627. // If the user can view prospects other than his'
  628. if ($user->rights->user->user->lire) {
  629. $moreforfilter .= '<div class="divsearchfield">';
  630. $tmptitle = $langs->trans('LinkedToSpecificUsers');
  631. $moreforfilter .= img_picto($tmptitle, 'user', 'class="pictofixedwidth"').$form->select_dolusers($search_user, 'search_user', $tmptitle, '', 0, '', '', 0, 0, 0, '', 0, '', 'maxwidth250 widthcentpercentminusx');
  632. $moreforfilter .= '</div>';
  633. }
  634. // If the user can view products
  635. if (isModEnabled('categorie') && $user->hasRight('categorie', 'lire') && ($user->hasRight('produit', 'lire') || $user->hasRight('service', 'lire'))) {
  636. include_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
  637. $moreforfilter .= '<div class="divsearchfield">';
  638. $tmptitle = $langs->trans('IncludingProductWithTag');
  639. $cate_arbo = $form->select_all_categories(Categorie::TYPE_PRODUCT, null, 'parent', null, null, 1);
  640. $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);
  641. $moreforfilter .= '</div>';
  642. }
  643. $parameters = array();
  644. $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook
  645. if (empty($reshook)) {
  646. $moreforfilter .= $hookmanager->resPrint;
  647. } else {
  648. $moreforfilter = $hookmanager->resPrint;
  649. }
  650. if (!empty($moreforfilter)) {
  651. print '<div class="liste_titre liste_titre_bydiv centpercent">';
  652. print $moreforfilter;
  653. print '</div>';
  654. }
  655. $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
  656. $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage, getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN', '')); // This also change content of $arrayfields
  657. $selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons('checkforselect', 1) : '');
  658. print '<div class="div-table-responsive">';
  659. print '<table class="tagtable nobottomiftotal liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n";
  660. // Fields title search
  661. // --------------------------------------------------------------------
  662. print '<tr class="liste_titre_filter">';
  663. // Action column
  664. if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
  665. print '<td class="liste_titre maxwidthsearch">';
  666. $searchpicto = $form->showFilterButtons('left');
  667. print $searchpicto;
  668. print '</td>';
  669. }
  670. if (!empty($arrayfields['sp.ref']['checked'])) {
  671. print '<td class="liste_titre">';
  672. print '<input class="flat" size="6" type="text" name="search_ref" value="'.dol_escape_htmltag($search_ref).'">';
  673. print '</td>';
  674. }
  675. if (!empty($arrayfields['s.nom']['checked'])) {
  676. print '<td class="liste_titre left">';
  677. print '<input class="flat" type="text" size="12" name="search_societe" value="'.dol_escape_htmltag($search_societe).'">';
  678. print '</td>';
  679. }
  680. if (!empty($arrayfields['s.name_alias']['checked'])) {
  681. print '<td class="liste_titre left">';
  682. print '<input class="flat" type="text" size="12" name="search_societe_alias" value="'.dol_escape_htmltag($search_societe_alias).'">';
  683. print '</td>';
  684. }
  685. if (!empty($arrayfields['s.town']['checked'])) {
  686. print '<td class="liste_titre"><input class="flat" type="text" size="6" name="search_town" value="'.$search_town.'"></td>';
  687. }
  688. if (!empty($arrayfields['s.zip']['checked'])) {
  689. print '<td class="liste_titre"><input class="flat" type="text" size="4" name="search_zip" value="'.$search_zip.'"></td>';
  690. }
  691. // State
  692. if (!empty($arrayfields['state.nom']['checked'])) {
  693. print '<td class="liste_titre">';
  694. print '<input class="flat" size="4" type="text" name="search_state" value="'.dol_escape_htmltag($search_state).'">';
  695. print '</td>';
  696. }
  697. // Country
  698. if (!empty($arrayfields['country.code_iso']['checked'])) {
  699. print '<td class="liste_titre center">';
  700. print $form->select_country($search_country, 'search_country', '', 0, 'minwidth100imp maxwidth100');
  701. print '</td>';
  702. }
  703. // Company type
  704. if (!empty($arrayfields['typent.code']['checked'])) {
  705. print '<td class="liste_titre maxwidthonsmartphone center">';
  706. print $form->selectarray("search_type_thirdparty", $formcompany->typent_array(0), $search_type_thirdparty, 1, 0, 0, '', 0, 0, 0, (empty($conf->global->SOCIETE_SORT_ON_TYPEENT) ? 'ASC' : $conf->global->SOCIETE_SORT_ON_TYPEENT), '', 1);
  707. print '</td>';
  708. }
  709. // Date
  710. if (!empty($arrayfields['sp.date_valid']['checked'])) {
  711. print '<td class="liste_titre center">';
  712. print '<div class="nowrap">';
  713. 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'));
  714. print '</div>';
  715. print '<div class="nowrap">';
  716. 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'));
  717. print '</div>';
  718. print '</td>';
  719. }
  720. // Date
  721. if (!empty($arrayfields['sp.date_livraison']['checked'])) {
  722. print '<td class="liste_titre center">';
  723. print '<div class="nowrap">';
  724. print $form->selectDate($search_date_start ? $search_date_start : -1, 'search_date_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From'));
  725. print '</div>';
  726. print '<div class="nowrap">';
  727. print $form->selectDate($search_date_end ? $search_date_end : -1, 'search_date_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to'));
  728. print '</div>';
  729. print '</td>';
  730. }
  731. if (!empty($arrayfields['sp.total_ht']['checked'])) {
  732. // Amount
  733. print '<td class="liste_titre right">';
  734. print '<input class="flat" type="text" size="5" name="search_montant_ht" value="'.dol_escape_htmltag($search_montant_ht).'">';
  735. print '</td>';
  736. }
  737. if (!empty($arrayfields['sp.total_tva']['checked'])) {
  738. // Amount
  739. print '<td class="liste_titre right">';
  740. print '<input class="flat" type="text" size="5" name="search_montant_vat" value="'.dol_escape_htmltag($search_montant_vat).'">';
  741. print '</td>';
  742. }
  743. if (!empty($arrayfields['sp.total_ttc']['checked'])) {
  744. // Amount
  745. print '<td class="liste_titre right">';
  746. print '<input class="flat" type="text" size="5" name="search_montant_ttc" value="'.dol_escape_htmltag($search_montant_ttc).'">';
  747. print '</td>';
  748. }
  749. if (!empty($arrayfields['sp.multicurrency_code']['checked'])) {
  750. // Currency
  751. print '<td class="liste_titre">';
  752. print $form->selectMultiCurrency($search_multicurrency_code, 'search_multicurrency_code', 1);
  753. print '</td>';
  754. }
  755. if (!empty($arrayfields['sp.multicurrency_tx']['checked'])) {
  756. // Currency rate
  757. print '<td class="liste_titre">';
  758. print '<input class="flat" type="text" size="4" name="search_multicurrency_tx" value="'.dol_escape_htmltag($search_multicurrency_tx).'">';
  759. print '</td>';
  760. }
  761. if (!empty($arrayfields['sp.multicurrency_total_ht']['checked'])) {
  762. // Amount
  763. print '<td class="liste_titre right">';
  764. print '<input class="flat" type="text" size="4" name="search_multicurrency_montant_ht" value="'.dol_escape_htmltag($search_multicurrency_montant_ht).'">';
  765. print '</td>';
  766. }
  767. if (!empty($arrayfields['sp.multicurrency_total_vat']['checked'])) {
  768. // Amount
  769. print '<td class="liste_titre right">';
  770. print '<input class="flat" type="text" size="4" name="search_multicurrency_montant_vat" value="'.dol_escape_htmltag($search_multicurrency_montant_vat).'">';
  771. print '</td>';
  772. }
  773. if (!empty($arrayfields['sp.multicurrency_total_ttc']['checked'])) {
  774. // Amount
  775. print '<td class="liste_titre right">';
  776. print '<input class="flat" type="text" size="4" name="search_multicurrency_montant_ttc" value="'.dol_escape_htmltag($search_multicurrency_montant_ttc).'">';
  777. print '</td>';
  778. }
  779. if (!empty($arrayfields['u.login']['checked'])) {
  780. // Author
  781. print '<td class="liste_titre center">';
  782. print '<input class="flat" size="4" type="text" name="search_login" value="'.dol_escape_htmltag($search_login).'">';
  783. print '</td>';
  784. }
  785. // Extra fields
  786. include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php';
  787. // Fields from hook
  788. $parameters = array('arrayfields'=>$arrayfields);
  789. $reshook = $hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook
  790. print $hookmanager->resPrint;
  791. // Date creation
  792. if (!empty($arrayfields['sp.datec']['checked'])) {
  793. print '<td class="liste_titre">';
  794. print '</td>';
  795. }
  796. // Date modification
  797. if (!empty($arrayfields['sp.tms']['checked'])) {
  798. print '<td class="liste_titre">';
  799. print '</td>';
  800. }
  801. // Status
  802. if (!empty($arrayfields['sp.fk_statut']['checked'])) {
  803. print '<td class="liste_titre right parentonrightofpage">';
  804. $formpropal->selectProposalStatus($search_status, 1, 0, 1, 'supplier', 'search_status', 'search_status width100 onrightofpage');
  805. print '</td>';
  806. }
  807. // Action column
  808. if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
  809. print '<td class="liste_titre maxwidthsearch">';
  810. $searchpicto = $form->showFilterButtons();
  811. print $searchpicto;
  812. print '</td>';
  813. }
  814. print "</tr>\n";
  815. // Fields title
  816. print '<tr class="liste_titre">';
  817. if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
  818. print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ');
  819. }
  820. if (!empty($arrayfields['sp.ref']['checked'])) {
  821. print_liste_field_titre($arrayfields['sp.ref']['label'], $_SERVER["PHP_SELF"], 'sp.ref', '', $param, '', $sortfield, $sortorder);
  822. }
  823. if (!empty($arrayfields['s.nom']['checked'])) {
  824. print_liste_field_titre($arrayfields['s.nom']['label'], $_SERVER["PHP_SELF"], 's.nom', '', $param, '', $sortfield, $sortorder);
  825. }
  826. if (!empty($arrayfields['s.name_alias']['checked'])) {
  827. print_liste_field_titre($arrayfields['s.name_alias']['label'], $_SERVER["PHP_SELF"], 's.name_alias', '', $param, '', $sortfield, $sortorder);
  828. }
  829. if (!empty($arrayfields['s.town']['checked'])) {
  830. print_liste_field_titre($arrayfields['s.town']['label'], $_SERVER["PHP_SELF"], 's.town', '', $param, '', $sortfield, $sortorder);
  831. }
  832. if (!empty($arrayfields['s.zip']['checked'])) {
  833. print_liste_field_titre($arrayfields['s.zip']['label'], $_SERVER["PHP_SELF"], 's.zip', '', $param, '', $sortfield, $sortorder);
  834. }
  835. if (!empty($arrayfields['state.nom']['checked'])) {
  836. print_liste_field_titre($arrayfields['state.nom']['label'], $_SERVER["PHP_SELF"], "state.nom", "", $param, '', $sortfield, $sortorder);
  837. }
  838. if (!empty($arrayfields['country.code_iso']['checked'])) {
  839. print_liste_field_titre($arrayfields['country.code_iso']['label'], $_SERVER["PHP_SELF"], "country.code_iso", "", $param, '', $sortfield, $sortorder, 'center ');
  840. }
  841. if (!empty($arrayfields['typent.code']['checked'])) {
  842. print_liste_field_titre($arrayfields['typent.code']['label'], $_SERVER["PHP_SELF"], "typent.code", "", $param, '', $sortfield, $sortorder, 'center ');
  843. }
  844. if (!empty($arrayfields['sp.date_valid']['checked'])) {
  845. print_liste_field_titre($arrayfields['sp.date_valid']['label'], $_SERVER["PHP_SELF"], 'sp.date_valid', '', $param, '', $sortfield, $sortorder, 'center ');
  846. }
  847. if (!empty($arrayfields['sp.date_livraison']['checked'])) {
  848. print_liste_field_titre($arrayfields['sp.date_livraison']['label'], $_SERVER["PHP_SELF"], 'sp.date_livraison', '', $param, '', $sortfield, $sortorder, 'center ');
  849. }
  850. if (!empty($arrayfields['sp.total_ht']['checked'])) {
  851. print_liste_field_titre($arrayfields['sp.total_ht']['label'], $_SERVER["PHP_SELF"], 'sp.total_ht', '', $param, '', $sortfield, $sortorder, 'right ');
  852. }
  853. if (!empty($arrayfields['sp.total_tva']['checked'])) {
  854. print_liste_field_titre($arrayfields['sp.total_tva']['label'], $_SERVER["PHP_SELF"], 'sp.total_tva', '', $param, '', $sortfield, $sortorder, 'right ');
  855. }
  856. if (!empty($arrayfields['sp.total_ttc']['checked'])) {
  857. print_liste_field_titre($arrayfields['sp.total_ttc']['label'], $_SERVER["PHP_SELF"], 'sp.total_ttc', '', $param, '', $sortfield, $sortorder, 'right ');
  858. }
  859. if (!empty($arrayfields['sp.multicurrency_code']['checked'])) {
  860. print_liste_field_titre($arrayfields['sp.multicurrency_code']['label'], $_SERVER['PHP_SELF'], 'sp.multicurrency_code', '', $param, '', $sortfield, $sortorder);
  861. }
  862. if (!empty($arrayfields['sp.multicurrency_tx']['checked'])) {
  863. print_liste_field_titre($arrayfields['sp.multicurrency_tx']['label'], $_SERVER['PHP_SELF'], 'sp.multicurrency_tx', '', $param, '', $sortfield, $sortorder);
  864. }
  865. if (!empty($arrayfields['sp.multicurrency_total_ht']['checked'])) {
  866. print_liste_field_titre($arrayfields['sp.multicurrency_total_ht']['label'], $_SERVER['PHP_SELF'], 'sp.multicurrency_total_ht', '', $param, 'class="right"', $sortfield, $sortorder);
  867. }
  868. if (!empty($arrayfields['sp.multicurrency_total_vat']['checked'])) {
  869. print_liste_field_titre($arrayfields['sp.multicurrency_total_vat']['label'], $_SERVER['PHP_SELF'], 'sp.multicurrency_total_tva', '', $param, 'class="right"', $sortfield, $sortorder);
  870. }
  871. if (!empty($arrayfields['sp.multicurrency_total_ttc']['checked'])) {
  872. print_liste_field_titre($arrayfields['sp.multicurrency_total_ttc']['label'], $_SERVER['PHP_SELF'], 'sp.multicurrency_total_ttc', '', $param, 'class="right"', $sortfield, $sortorder);
  873. }
  874. if (!empty($arrayfields['u.login']['checked'])) {
  875. print_liste_field_titre($arrayfields['u.login']['label'], $_SERVER["PHP_SELF"], 'u.login', '', $param, '', $sortfield, $sortorder, 'center ');
  876. }
  877. // Extra fields
  878. include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php';
  879. // Hook fields
  880. $parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder);
  881. $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters); // Note that $action and $object may have been modified by hook
  882. print $hookmanager->resPrint;
  883. if (!empty($arrayfields['sp.datec']['checked'])) {
  884. print_liste_field_titre($arrayfields['sp.datec']['label'], $_SERVER["PHP_SELF"], "sp.datec", "", $param, '', $sortfield, $sortorder, 'center nowrap ');
  885. }
  886. if (!empty($arrayfields['sp.tms']['checked'])) {
  887. print_liste_field_titre($arrayfields['sp.tms']['label'], $_SERVER["PHP_SELF"], "sp.tms", "", $param, '', $sortfield, $sortorder, 'center nowrap');
  888. }
  889. if (!empty($arrayfields['sp.fk_statut']['checked'])) {
  890. print_liste_field_titre($arrayfields['sp.fk_statut']['label'], $_SERVER["PHP_SELF"], "sp.fk_statut", "", $param, '', $sortfield, $sortorder, 'right ');
  891. }
  892. if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
  893. print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ');
  894. }
  895. print '</tr>'."\n";
  896. $now = dol_now();
  897. $i = 0;
  898. $total = 0;
  899. $subtotal = 0;
  900. $totalarray = array();
  901. $totalarray['nbfield'] = 0;
  902. $totalarray['val'] = array();
  903. $totalarray['val']['sp.total_ht'] = 0;
  904. $totalarray['val']['sp.total_tva'] = 0;
  905. $totalarray['val']['sp.total_ttc'] = 0;
  906. $imaxinloop = ($limit ? min($num, $limit) : $num);
  907. while ($i < $imaxinloop) {
  908. $obj = $db->fetch_object($resql);
  909. $objectstatic->id = $obj->rowid;
  910. $objectstatic->ref = $obj->ref;
  911. $objectstatic->note_public = $obj->note_public;
  912. $objectstatic->note_private = $obj->note_private;
  913. $objectstatic->status = $obj->status;
  914. // Company
  915. $companystatic->id = $obj->socid;
  916. $companystatic->name = $obj->name;
  917. $companystatic->name_alias = $obj->alias;
  918. $companystatic->client = $obj->client;
  919. $companystatic->code_client = $obj->code_client;
  920. if ($mode == 'kanban') {
  921. if ($i == 0) {
  922. print '<tr><td colspan="12">';
  923. print '<div class="box-flex-container kanban">';
  924. }
  925. // Output Kanban
  926. // TODO Use a cahe on user
  927. $userstatic->fetch($obj->fk_user_author);
  928. $objectstatic->delivery_date = $obj->dp;
  929. print $objectstatic->getKanbanView('', array('thirdparty'=>$companystatic, 'userauthor'=>$userstatic, 'selected' => in_array($obj->id, $arrayofselected)));
  930. if ($i == ($imaxinloop - 1)) {
  931. print '</div>';
  932. print '</td></tr>';
  933. }
  934. } else {
  935. print '<tr class="oddeven">';
  936. // Action column
  937. if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
  938. print '<td class="nowrap center">';
  939. if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
  940. $selected = 0;
  941. if (in_array($obj->rowid, $arrayofselected)) {
  942. $selected = 1;
  943. }
  944. print '<input id="cb'.$obj->rowid.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.'"'.($selected ? ' checked="checked"' : '').'>';
  945. }
  946. print '</td>';
  947. }
  948. if (!empty($arrayfields['sp.ref']['checked'])) {
  949. print '<td class="nowraponall">';
  950. print '<table class="nobordernopadding"><tr class="nocellnopadd">';
  951. // Picto + Ref
  952. print '<td class="nobordernopadding nowraponall">';
  953. print $objectstatic->getNomUrl(1, '', '', 0, -1, 1);
  954. print '</td>';
  955. // Warning
  956. $warnornote = '';
  957. //if ($obj->fk_statut == 1 && $db->jdate($obj->date_valid) < ($now - $conf->supplier_proposal->warning_delay)) $warnornote .= img_warning($langs->trans("Late"));
  958. if ($warnornote) {
  959. print '<td style="min-width: 20px" class="nobordernopadding nowrap">';
  960. print $warnornote;
  961. print '</td>';
  962. }
  963. // Other picto tool
  964. print '<td width="16" class="right nobordernopadding hideonsmartphone">';
  965. $filename = dol_sanitizeFileName($obj->ref);
  966. $filedir = $conf->supplier_proposal->dir_output.'/'.dol_sanitizeFileName($obj->ref);
  967. $urlsource = $_SERVER['PHP_SELF'].'?id='.$obj->rowid;
  968. print $formfile->getDocumentsLink($objectstatic->element, $filename, $filedir);
  969. print '</td></tr></table>';
  970. print "</td>\n";
  971. if (!$i) {
  972. $totalarray['nbfield']++;
  973. }
  974. }
  975. // Thirdparty
  976. if (!empty($arrayfields['s.nom']['checked'])) {
  977. print '<td class="tdoverflowmax200">';
  978. print $companystatic->getNomUrl(1, 'supplier', 0, 0, -1, empty($arrayfields['s.name_alias']['checked']) ? 0 : 1);
  979. print '</td>';
  980. if (!$i) {
  981. $totalarray['nbfield']++;
  982. }
  983. }
  984. // Alias
  985. if (!empty($arrayfields['s.name_alias']['checked'])) {
  986. print '<td class="tdoverflowmax200">';
  987. print $companystatic->name_alias;
  988. print '</td>';
  989. if (!$i) {
  990. $totalarray['nbfield']++;
  991. }
  992. }
  993. // Town
  994. if (!empty($arrayfields['s.town']['checked'])) {
  995. print '<td class="nocellnopadd">';
  996. print $obj->town;
  997. print '</td>';
  998. if (!$i) {
  999. $totalarray['nbfield']++;
  1000. }
  1001. }
  1002. // Zip
  1003. if (!empty($arrayfields['s.zip']['checked'])) {
  1004. print '<td class="nocellnopadd">';
  1005. print $obj->zip;
  1006. print '</td>';
  1007. if (!$i) {
  1008. $totalarray['nbfield']++;
  1009. }
  1010. }
  1011. // State
  1012. if (!empty($arrayfields['state.nom']['checked'])) {
  1013. print "<td>".$obj->state_name."</td>\n";
  1014. if (!$i) {
  1015. $totalarray['nbfield']++;
  1016. }
  1017. }
  1018. // Country
  1019. if (!empty($arrayfields['country.code_iso']['checked'])) {
  1020. print '<td class="center">';
  1021. $tmparray = getCountry($obj->fk_pays, 'all');
  1022. print $tmparray['label'];
  1023. print '</td>';
  1024. if (!$i) {
  1025. $totalarray['nbfield']++;
  1026. }
  1027. }
  1028. // Type ent
  1029. if (!empty($arrayfields['typent.code']['checked'])) {
  1030. print '<td class="center">';
  1031. if (empty($typenArray) || !is_array($typenArray) || count($typenArray) == 0) {
  1032. $typenArray = $formcompany->typent_array(1);
  1033. }
  1034. print $typenArray[$obj->typent_code];
  1035. print '</td>';
  1036. if (!$i) {
  1037. $totalarray['nbfield']++;
  1038. }
  1039. }
  1040. // Date proposal
  1041. if (!empty($arrayfields['sp.date_valid']['checked'])) {
  1042. print '<td class="center">';
  1043. print dol_print_date($db->jdate($obj->date_valid), 'day');
  1044. print "</td>\n";
  1045. if (!$i) {
  1046. $totalarray['nbfield']++;
  1047. }
  1048. }
  1049. // Date delivery
  1050. if (!empty($arrayfields['sp.date_livraison']['checked'])) {
  1051. print '<td class="center">';
  1052. print dol_print_date($db->jdate($obj->dp), 'day');
  1053. print "</td>\n";
  1054. if (!$i) {
  1055. $totalarray['nbfield']++;
  1056. }
  1057. }
  1058. // Amount HT
  1059. if (!empty($arrayfields['sp.total_ht']['checked'])) {
  1060. print '<td class="right"><span class="amount">'.price($obj->total_ht)."</span></td>\n";
  1061. if (!$i) {
  1062. $totalarray['nbfield']++;
  1063. }
  1064. if (!$i) {
  1065. $totalarray['pos'][$totalarray['nbfield']] = 'sp.total_ht';
  1066. }
  1067. $totalarray['val']['sp.total_ht'] += $obj->total_ht;
  1068. }
  1069. // Amount VAT
  1070. if (!empty($arrayfields['sp.total_tva']['checked'])) {
  1071. print '<td class="right"><span class="amount">'.price($obj->total_tva)."</span></td>\n";
  1072. if (!$i) {
  1073. $totalarray['nbfield']++;
  1074. }
  1075. if (!$i) {
  1076. $totalarray['pos'][$totalarray['nbfield']] = 'sp.total_tva';
  1077. }
  1078. $totalarray['val']['sp.total_tva'] += $obj->total_tva;
  1079. }
  1080. // Amount TTC
  1081. if (!empty($arrayfields['sp.total_ttc']['checked'])) {
  1082. print '<td class="right"><span class="amount">'.price($obj->total_ttc)."</span></td>\n";
  1083. if (!$i) {
  1084. $totalarray['nbfield']++;
  1085. }
  1086. if (!$i) {
  1087. $totalarray['pos'][$totalarray['nbfield']] = 'sp.total_ttc';
  1088. }
  1089. $totalarray['val']['sp.total_ttc'] += $obj->total_ttc;
  1090. }
  1091. // Currency
  1092. if (!empty($arrayfields['sp.multicurrency_code']['checked'])) {
  1093. print '<td class="nowrap">'.$obj->multicurrency_code.' - '.$langs->trans('Currency'.$obj->multicurrency_code)."</td>\n";
  1094. if (!$i) {
  1095. $totalarray['nbfield']++;
  1096. }
  1097. }
  1098. // Currency rate
  1099. if (!empty($arrayfields['sp.multicurrency_tx']['checked'])) {
  1100. print '<td class="nowrap">';
  1101. $form->form_multicurrency_rate($_SERVER['PHP_SELF'].'?id='.$obj->rowid, $obj->multicurrency_tx, 'none', $obj->multicurrency_code);
  1102. print "</td>\n";
  1103. if (!$i) {
  1104. $totalarray['nbfield']++;
  1105. }
  1106. }
  1107. // Amount HT
  1108. if (!empty($arrayfields['sp.multicurrency_total_ht']['checked'])) {
  1109. print '<td class="right nowrap"><span class="amount">'.price($obj->multicurrency_total_ht)."</span></td>\n";
  1110. if (!$i) {
  1111. $totalarray['nbfield']++;
  1112. }
  1113. }
  1114. // Amount VAT
  1115. if (!empty($arrayfields['sp.multicurrency_total_vat']['checked'])) {
  1116. print '<td class="right nowrap"><span class="amount">'.price($obj->multicurrency_total_vat)."</span></td>\n";
  1117. if (!$i) {
  1118. $totalarray['nbfield']++;
  1119. }
  1120. }
  1121. // Amount TTC
  1122. if (!empty($arrayfields['sp.multicurrency_total_ttc']['checked'])) {
  1123. print '<td class="right nowrap"><span class="amount">'.price($obj->multicurrency_total_ttc)."</span></td>\n";
  1124. if (!$i) {
  1125. $totalarray['nbfield']++;
  1126. }
  1127. }
  1128. $userstatic->id = $obj->fk_user_author;
  1129. $userstatic->login = $obj->login;
  1130. $userstatic->status = $obj->ustatus;
  1131. $userstatic->lastname = $obj->name;
  1132. $userstatic->firstname = $obj->firstname;
  1133. $userstatic->photo = $obj->photo;
  1134. $userstatic->admin = $obj->admin;
  1135. $userstatic->ref = $obj->fk_user_author;
  1136. $userstatic->employee = $obj->employee;
  1137. $userstatic->email = $obj->uemail;
  1138. // Author
  1139. if (!empty($arrayfields['u.login']['checked'])) {
  1140. print '<td class="center">';
  1141. if ($userstatic->id > 0) {
  1142. print $userstatic->getNomUrl(-1, '', 0, 0, 24, 1, 'login', '', 1);
  1143. } else {
  1144. print '&nbsp;';
  1145. }
  1146. print "</td>\n";
  1147. if (!$i) {
  1148. $totalarray['nbfield']++;
  1149. }
  1150. }
  1151. // Extra fields
  1152. include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php';
  1153. // Fields from hook
  1154. $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray);
  1155. $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook
  1156. print $hookmanager->resPrint;
  1157. // Date creation
  1158. if (!empty($arrayfields['sp.datec']['checked'])) {
  1159. print '<td class="center nowrap">';
  1160. print dol_print_date($db->jdate($obj->date_creation), 'dayhour', 'tzuser');
  1161. print '</td>';
  1162. if (!$i) {
  1163. $totalarray['nbfield']++;
  1164. }
  1165. }
  1166. // Date modification
  1167. if (!empty($arrayfields['sp.tms']['checked'])) {
  1168. print '<td class="center nowrap">';
  1169. print dol_print_date($db->jdate($obj->date_update), 'dayhour', 'tzuser');
  1170. print '</td>';
  1171. if (!$i) {
  1172. $totalarray['nbfield']++;
  1173. }
  1174. }
  1175. // Status
  1176. if (!empty($arrayfields['sp.fk_statut']['checked'])) {
  1177. print '<td class="right">'.$objectstatic->getLibStatut(5)."</td>\n";
  1178. if (!$i) {
  1179. $totalarray['nbfield']++;
  1180. }
  1181. }
  1182. // Action column
  1183. if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
  1184. print '<td class="nowrap center">';
  1185. if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
  1186. $selected = 0;
  1187. if (in_array($obj->rowid, $arrayofselected)) {
  1188. $selected = 1;
  1189. }
  1190. print '<input id="cb'.$obj->rowid.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.'"'.($selected ? ' checked="checked"' : '').'>';
  1191. }
  1192. print '</td>';
  1193. }
  1194. if (!$i) {
  1195. $totalarray['nbfield']++;
  1196. }
  1197. print "</tr>\n";
  1198. $total += $obj->total_ht;
  1199. $subtotal += $obj->total_ht;
  1200. }
  1201. $i++;
  1202. }
  1203. // Show total line
  1204. include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php';
  1205. // If no record found
  1206. if ($num == 0) {
  1207. $colspan = 1;
  1208. foreach ($arrayfields as $key => $val) {
  1209. if (!empty($val['checked'])) {
  1210. $colspan++;
  1211. }
  1212. }
  1213. print '<tr><td colspan="'.$colspan.'"><span class="opacitymedium">'.$langs->trans("NoRecordFound").'</span></td></tr>';
  1214. }
  1215. $db->free($resql);
  1216. $parameters = array('arrayfields'=>$arrayfields, 'sql'=>$sql);
  1217. $reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters); // Note that $action and $object may have been modified by hook
  1218. print $hookmanager->resPrint;
  1219. print '</table>'."\n";
  1220. print '</div>'."\n";
  1221. print '</form>'."\n";
  1222. $hidegeneratedfilelistifempty = 1;
  1223. if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) {
  1224. $hidegeneratedfilelistifempty = 0;
  1225. }
  1226. // Show list of available documents
  1227. $urlsource = $_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder;
  1228. $urlsource .= str_replace('&amp;', '&', $param);
  1229. $filedir = $diroutputmassaction;
  1230. $genallowed = $user->rights->supplier_proposal->lire;
  1231. $delallowed = $user->rights->supplier_proposal->creer;
  1232. print $formfile->showdocuments('massfilesarea_supplier_proposal', '', $filedir, $urlsource, 0, $delallowed, '', 1, 1, 0, 48, 1, $param, $title, '', '', '', null, $hidegeneratedfilelistifempty);
  1233. } else {
  1234. dol_print_error($db);
  1235. }
  1236. // End of page
  1237. llxFooter();
  1238. $db->close();