list.php 88 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205
  1. <?php
  2. /* Copyright (C) 2001-2007 Rodolphe Quiedeville <rodolphe@quiedeville.org>
  3. * Copyright (C) 2004-2016 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-2011 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) 2015 Jean-François Ferry <jfefe@aternatik.fr>
  13. * Copyright (C) 2016-2021 Ferran Marcet <fmarcet@2byte.es>
  14. * Copyright (C) 2017-2018 Charlene Benke <charlie@patas-monkey.com>
  15. * Copyright (C) 2018 Nicolas ZABOURI <info@inovea-conseil.com>
  16. * Copyright (C) 2019-2021 Alexandre Spangaro <aspangaro@open-dsi.fr>
  17. * Copyright (C) 2021 Anthony Berton <anthony.berton@bb2a.fr>
  18. * Copyright (C) 2021 Frédéric France <frederic.france@netlogic.fr>
  19. *
  20. * This program is free software; you can redistribute it and/or modify
  21. * it under the terms of the GNU General Public License as published by
  22. * the Free Software Foundation; either version 3 of the License, or
  23. * (at your option) any later version.
  24. *
  25. * This program is distributed in the hope that it will be useful,
  26. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  27. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  28. * GNU General Public License for more details.
  29. *
  30. * You should have received a copy of the GNU General Public License
  31. * along with this program. If not, see <https://www.gnu.org/licenses/>.
  32. */
  33. /**
  34. * \file htdocs/comm/propal/list.php
  35. * \ingroup propal
  36. * \brief Page of commercial proposals card and list
  37. */
  38. require '../../main.inc.php';
  39. require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
  40. require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
  41. require_once DOL_DOCUMENT_ROOT.'/core/class/html.formpropal.class.php';
  42. require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
  43. if (!empty($conf->margin->enabled)) {
  44. require_once DOL_DOCUMENT_ROOT.'/core/class/html.formmargin.class.php';
  45. }
  46. require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
  47. require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
  48. require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php';
  49. require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
  50. // Load translation files required by the page
  51. $langs->loadLangs(array('companies', 'propal', 'compta', 'bills', 'orders', 'products', 'deliveries', 'categories'));
  52. if (!empty($conf->expedition->enabled)) {
  53. $langs->loadLangs(array('sendings'));
  54. }
  55. $socid = GETPOST('socid', 'int');
  56. $action = GETPOST('action', 'aZ09');
  57. $massaction = GETPOST('massaction', 'alpha');
  58. $show_files = GETPOST('show_files', 'int');
  59. $confirm = GETPOST('confirm', 'alpha');
  60. $toselect = GETPOST('toselect', 'array');
  61. $contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'proposallist';
  62. $search_user = GETPOST('search_user', 'int');
  63. $search_sale = GETPOST('search_sale', 'int');
  64. $search_ref = GETPOST('sf_ref') ?GETPOST('sf_ref', 'alpha') : GETPOST('search_ref', 'alpha');
  65. $search_refcustomer = GETPOST('search_refcustomer', 'alpha');
  66. $search_refproject = GETPOST('search_refproject', 'alpha');
  67. $search_project = GETPOST('search_project', 'alpha');
  68. $search_societe = GETPOST('search_societe', 'alpha');
  69. $search_societe_alias = GETPOST('search_societe_alias', 'alpha');
  70. $search_montant_ht = GETPOST('search_montant_ht', 'alpha');
  71. $search_montant_vat = GETPOST('search_montant_vat', 'alpha');
  72. $search_montant_ttc = GETPOST('search_montant_ttc', 'alpha');
  73. $search_warehouse = GETPOST('search_warehouse', 'alpha');
  74. $search_multicurrency_code = GETPOST('search_multicurrency_code', 'alpha');
  75. $search_multicurrency_tx = GETPOST('search_multicurrency_tx', 'alpha');
  76. $search_multicurrency_montant_ht = GETPOST('search_multicurrency_montant_ht', 'alpha');
  77. $search_multicurrency_montant_vat = GETPOST('search_multicurrency_montant_vat', 'alpha');
  78. $search_multicurrency_montant_ttc = GETPOST('search_multicurrency_montant_ttc', 'alpha');
  79. $search_login = GETPOST('search_login', 'alpha');
  80. $search_product_category = GETPOST('search_product_category', 'int');
  81. $search_town = GETPOST('search_town', 'alpha');
  82. $search_zip = GETPOST('search_zip', 'alpha');
  83. $search_state = GETPOST("search_state");
  84. $search_country = GETPOST("search_country", 'int');
  85. $search_type_thirdparty = GETPOST("search_type_thirdparty", 'int');
  86. $search_date_startday = GETPOST('search_date_startday', 'int');
  87. $search_date_startmonth = GETPOST('search_date_startmonth', 'int');
  88. $search_date_startyear = GETPOST('search_date_startyear', 'int');
  89. $search_date_endday = GETPOST('search_date_endday', 'int');
  90. $search_date_endmonth = GETPOST('search_date_endmonth', 'int');
  91. $search_date_endyear = GETPOST('search_date_endyear', 'int');
  92. $search_date_start = dol_mktime(0, 0, 0, $search_date_startmonth, $search_date_startday, $search_date_startyear); // Use tzserver
  93. $search_date_end = dol_mktime(23, 59, 59, $search_date_endmonth, $search_date_endday, $search_date_endyear);
  94. $search_date_end_startday = GETPOST('search_date_end_startday', 'int');
  95. $search_date_end_startmonth = GETPOST('search_date_end_startmonth', 'int');
  96. $search_date_end_startyear = GETPOST('search_date_end_startyear', 'int');
  97. $search_date_end_endday = GETPOST('search_date_end_endday', 'int');
  98. $search_date_end_endmonth = GETPOST('search_date_end_endmonth', 'int');
  99. $search_date_end_endyear = GETPOST('search_date_end_endyear', 'int');
  100. $search_date_end_start = dol_mktime(0, 0, 0, $search_date_end_startmonth, $search_date_end_startday, $search_date_end_startyear); // Use tzserver
  101. $search_date_end_end = dol_mktime(23, 59, 59, $search_date_end_endmonth, $search_date_end_endday, $search_date_end_endyear);
  102. $search_date_delivery_startday = GETPOST('search_date_delivery_startday', 'int');
  103. $search_date_delivery_startmonth = GETPOST('search_date_delivery_startmonth', 'int');
  104. $search_date_delivery_startyear = GETPOST('search_date_delivery_startyear', 'int');
  105. $search_date_delivery_endday = GETPOST('search_date_delivery_endday', 'int');
  106. $search_date_delivery_endmonth = GETPOST('search_date_delivery_endmonth', 'int');
  107. $search_date_delivery_endyear = GETPOST('search_date_delivery_endyear', 'int');
  108. $search_date_delivery_start = dol_mktime(0, 0, 0, $search_date_delivery_startmonth, $search_date_delivery_startday, $search_date_delivery_startyear);
  109. $search_date_delivery_end = dol_mktime(23, 59, 59, $search_date_delivery_endmonth, $search_date_delivery_endday, $search_date_delivery_endyear);
  110. $search_availability = GETPOST('search_availability', 'int');
  111. $search_categ_cus = GETPOST("search_categ_cus", 'int');
  112. $search_fk_cond_reglement = GETPOST("search_fk_cond_reglement", 'int');
  113. $search_fk_shipping_method = GETPOST("search_fk_shipping_method", 'int');
  114. $search_fk_input_reason = GETPOST("search_fk_input_reason", 'int');
  115. $search_fk_mode_reglement = GETPOST("search_fk_mode_reglement", 'int');
  116. $search_btn = GETPOST('button_search', 'alpha');
  117. $search_remove_btn = GETPOST('button_removefilter', 'alpha');
  118. $search_date_signature_startday = GETPOST('search_date_signature_startday', 'int');
  119. $search_date_signature_startmonth = GETPOST('search_date_signature_startmonth', 'int');
  120. $search_date_signature_startyear = GETPOST('search_date_signature_startyear', 'int');
  121. $search_date_signature_endday = GETPOST('search_date_signature_endday', 'int');
  122. $search_date_signature_endmonth = GETPOST('search_date_signature_endmonth', 'int');
  123. $search_date_signature_endyear = GETPOST('search_date_signature_endyear', 'int');
  124. $search_date_signature_start = dol_mktime(0, 0, 0, $search_date_signature_startmonth, $search_date_signature_startday, $search_date_signature_startyear);
  125. $search_date_signature_end = dol_mktime(23, 59, 59, $search_date_signature_endmonth, $search_date_signature_endday, $search_date_signature_endyear);
  126. $search_status = GETPOST('search_status', 'alpha');
  127. $optioncss = GETPOST('optioncss', 'alpha');
  128. $object_statut = GETPOST('search_statut', 'alpha');
  129. $sall = trim((GETPOST('search_all', 'alphanohtml') != '') ?GETPOST('search_all', 'alphanohtml') : GETPOST('sall', 'alphanohtml'));
  130. $mesg = (GETPOST("msg") ? GETPOST("msg") : GETPOST("mesg"));
  131. $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
  132. $sortfield = GETPOST('sortfield', 'aZ09comma');
  133. $sortorder = GETPOST('sortorder', 'aZ09comma');
  134. $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
  135. if (empty($page) || $page == -1 || !empty($search_btn) || !empty($search_remove_btn) || (empty($toselect) && $massaction === '0')) {
  136. $page = 0;
  137. } // If $page is not defined, or '' or -1
  138. $offset = $limit * $page;
  139. $pageprev = $page - 1;
  140. $pagenext = $page + 1;
  141. if (!$sortfield) {
  142. $sortfield = 'p.ref';
  143. }
  144. if (!$sortorder) {
  145. $sortorder = 'DESC';
  146. }
  147. // Security check
  148. $module = 'propal';
  149. $dbtable = '';
  150. $objectid = '';
  151. if (!empty($user->socid)) {
  152. $socid = $user->socid;
  153. }
  154. if (!empty($socid)) {
  155. $objectid = $socid;
  156. $module = 'societe';
  157. $dbtable = '&societe';
  158. }
  159. $result = restrictedArea($user, $module, $objectid, $dbtable);
  160. $diroutputmassaction = $conf->propal->multidir_output[$conf->entity].'/temp/massgeneration/'.$user->id;
  161. // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
  162. $object = new Propal($db);
  163. $hookmanager->initHooks(array('propallist'));
  164. $extrafields = new ExtraFields($db);
  165. // fetch optionals attributes and labels
  166. $extrafields->fetch_name_optionals_label($object->table_element);
  167. $search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_');
  168. // List of fields to search into when doing a "search in all"
  169. $fieldstosearchall = array(
  170. 'p.ref'=>'Ref',
  171. 'p.ref_client'=>'RefCustomer',
  172. 'pd.description'=>'Description',
  173. 's.nom'=>"ThirdParty",
  174. 's.name_alias'=>"AliasNameShort",
  175. 's.zip'=>"Zip",
  176. 's.town'=>"Town",
  177. 'p.note_public'=>'NotePublic',
  178. );
  179. if (empty($user->socid)) {
  180. $fieldstosearchall["p.note_private"] = "NotePrivate";
  181. }
  182. $checkedtypetiers = 0;
  183. $arrayfields = array(
  184. 'p.ref'=>array('label'=>"Ref", 'checked'=>1),
  185. 'p.ref_client'=>array('label'=>"RefCustomer", 'checked'=>-1),
  186. 'pr.ref'=>array('label'=>"ProjectRef", 'checked'=>1, 'enabled'=>(empty($conf->project->enabled) ? 0 : 1)),
  187. 'pr.title'=>array('label'=>"ProjectLabel", 'checked'=>0, 'enabled'=>(empty($conf->project->enabled) ? 0 : 1)),
  188. 's.nom'=>array('label'=>"ThirdParty", 'checked'=>1),
  189. 's.name_alias'=>array('label'=>"AliasNameShort", 'checked'=>-1),
  190. 's.town'=>array('label'=>"Town", 'checked'=>-1),
  191. 's.zip'=>array('label'=>"Zip", 'checked'=>-1),
  192. 'state.nom'=>array('label'=>"StateShort", 'checked'=>0),
  193. 'country.code_iso'=>array('label'=>"Country", 'checked'=>0),
  194. 'typent.code'=>array('label'=>"ThirdPartyType", 'checked'=>$checkedtypetiers),
  195. 'p.date'=>array('label'=>"DatePropal", 'checked'=>1),
  196. 'p.fin_validite'=>array('label'=>"DateEnd", 'checked'=>1),
  197. 'p.date_livraison'=>array('label'=>"DeliveryDate", 'checked'=>0),
  198. 'p.date_signature'=>array('label'=>"DateSigning", 'checked'=>0),
  199. 'ava.rowid'=>array('label'=>"AvailabilityPeriod", 'checked'=>0),
  200. 'p.fk_shipping_method'=>array('label'=>"SendingMethod", 'checked'=>0, 'enabled'=>!empty($conf->expedition->enabled)),
  201. 'p.fk_input_reason'=>array('label'=>"Origin", 'checked'=>0, 'enabled'=>1),
  202. 'p.fk_cond_reglement'=>array('label'=>"PaymentConditionsShort", 'checked'=>0),
  203. 'p.fk_mode_reglement'=>array('label'=>"PaymentMode", 'checked'=>0),
  204. 'p.total_ht'=>array('label'=>"AmountHT", 'checked'=>1),
  205. 'p.total_tva'=>array('label'=>"AmountVAT", 'checked'=>0),
  206. 'p.total_ttc'=>array('label'=>"AmountTTC", 'checked'=>0),
  207. 'p.total_ht_invoiced'=>array('label'=>"AmountInvoicedHT", 'checked'=>0, 'enabled'=>!empty($conf->global->PROPOSAL_SHOW_INVOICED_AMOUNT)),
  208. 'p.total_invoiced'=>array('label'=>"AmountInvoicedTTC", 'checked'=>0, 'enabled'=>!empty($conf->global->PROPOSAL_SHOW_INVOICED_AMOUNT)),
  209. 'p.multicurrency_code'=>array('label'=>'Currency', 'checked'=>0, 'enabled'=>(empty($conf->multicurrency->enabled) ? 0 : 1)),
  210. 'p.multicurrency_tx'=>array('label'=>'CurrencyRate', 'checked'=>0, 'enabled'=>(empty($conf->multicurrency->enabled) ? 0 : 1)),
  211. 'p.multicurrency_total_ht'=>array('label'=>'MulticurrencyAmountHT', 'checked'=>0, 'enabled'=>(empty($conf->multicurrency->enabled) ? 0 : 1)),
  212. 'p.multicurrency_total_tva'=>array('label'=>'MulticurrencyAmountVAT', 'checked'=>0, 'enabled'=>(empty($conf->multicurrency->enabled) ? 0 : 1)),
  213. 'p.multicurrency_total_ttc'=>array('label'=>'MulticurrencyAmountTTC', 'checked'=>0, 'enabled'=>(empty($conf->multicurrency->enabled) ? 0 : 1)),
  214. 'p.multicurrency_total_ht_invoiced'=>array('label'=>'MulticurrencyAmountInvoicedHT', 'checked'=>0, 'enabled'=>!empty($conf->multicurrency->enabled) && !empty($conf->global->PROPOSAL_SHOW_INVOICED_AMOUNT)),
  215. 'p.multicurrency_total_invoiced'=>array('label'=>'MulticurrencyAmountInvoicedTTC', 'checked'=>0, 'enabled'=>!empty($conf->multicurrency->enabled) && !empty($conf->global->PROPOSAL_SHOW_INVOICED_AMOUNT)),
  216. 'u.login'=>array('label'=>"Author", 'checked'=>1, 'position'=>10),
  217. 'sale_representative'=>array('label'=>"SaleRepresentativesOfThirdParty", 'checked'=>-1),
  218. 'total_pa' => array('label' => (getDolGlobalString('MARGIN_TYPE') == '1' ? 'BuyingPrice' : 'CostPrice'), 'checked' => 0, 'position' => 300, 'enabled' => (empty($conf->margin->enabled) || !$user->rights->margins->liretous ? 0 : 1)),
  219. 'total_margin' => array('label' => 'Margin', 'checked' => 0, 'position' => 301, 'enabled' => (empty($conf->margin->enabled) || !$user->rights->margins->liretous ? 0 : 1)),
  220. 'total_margin_rate' => array('label' => 'MarginRate', 'checked' => 0, 'position' => 302, 'enabled' => (empty($conf->margin->enabled) || !$user->rights->margins->liretous || empty($conf->global->DISPLAY_MARGIN_RATES) ? 0 : 1)),
  221. 'total_mark_rate' => array('label' => 'MarkRate', 'checked' => 0, 'position' => 303, 'enabled' => (empty($conf->margin->enabled) || !$user->rights->margins->liretous || empty($conf->global->DISPLAY_MARK_RATES) ? 0 : 1)),
  222. 'p.datec'=>array('label'=>"DateCreation", 'checked'=>0, 'position'=>500),
  223. 'p.tms'=>array('label'=>"DateModificationShort", 'checked'=>0, 'position'=>500),
  224. 'p.date_cloture'=>array('label'=>"DateClosing", 'checked'=>0, 'position'=>500),
  225. 'p.note_public'=>array('label'=>'NotePublic', 'checked'=>0, 'position'=>510, 'enabled'=>(empty($conf->global->MAIN_LIST_ALLOW_PUBLIC_NOTES))),
  226. 'p.note_private'=>array('label'=>'NotePrivate', 'checked'=>0, 'position'=>511, 'enabled'=>(empty($conf->global->MAIN_LIST_ALLOW_PRIVATE_NOTES))),
  227. 'p.fk_statut'=>array('label'=>"Status", 'checked'=>1, 'position'=>1000),
  228. );
  229. // Extra fields
  230. include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php';
  231. $permissiontoread = $user->rights->propal->lire;
  232. $permissiontoadd = $user->rights->propal->creer;
  233. $permissiontodelete = $user->rights->propal->supprimer;
  234. if (!empty($conf->global->MAIN_USE_ADVANCED_PERMS)) {
  235. $permissiontovalidate = $user->rights->propal->propal_advance->validate;
  236. $permissiontoclose = $user->rights->propal->propal_advance->close;
  237. $permissiontosendbymail = $user->rights->propal->propal_advance->send;
  238. } else {
  239. $permissiontovalidate = $user->rights->propal->creer;
  240. $permissiontoclose = $user->rights->propal->creer;
  241. $permissiontosendbymail = $user->rights->propal->lire;
  242. }
  243. /*
  244. * Actions
  245. */
  246. if (GETPOST('cancel', 'alpha')) {
  247. $action = 'list';
  248. $massaction = '';
  249. }
  250. if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') {
  251. $massaction = '';
  252. }
  253. $parameters = array('socid'=>$socid, 'arrayfields'=>&$arrayfields);
  254. $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
  255. if ($reshook < 0) {
  256. setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
  257. }
  258. include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
  259. // Do we click on purge search criteria ?
  260. 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
  261. $search_categ = '';
  262. $search_user = '';
  263. $search_sale = '';
  264. $search_ref = '';
  265. $search_refcustomer = '';
  266. $search_refproject = '';
  267. $search_project = '';
  268. $search_societe = '';
  269. $search_societe_alias = '';
  270. $search_montant_ht = '';
  271. $search_montant_vat = '';
  272. $search_montant_ttc = '';
  273. $search_warehouse = '';
  274. $search_multicurrency_code = '';
  275. $search_multicurrency_tx = '';
  276. $search_multicurrency_montant_ht = '';
  277. $search_multicurrency_montant_vat = '';
  278. $search_multicurrency_montant_ttc = '';
  279. $search_login = '';
  280. $search_product_category = '';
  281. $search_town = '';
  282. $search_zip = "";
  283. $search_state = "";
  284. $search_type = '';
  285. $search_country = '';
  286. $search_type_thirdparty = '';
  287. $search_date_startday = '';
  288. $search_date_startmonth = '';
  289. $search_date_startyear = '';
  290. $search_date_endday = '';
  291. $search_date_endmonth = '';
  292. $search_date_endyear = '';
  293. $search_date_start = '';
  294. $search_date_end = '';
  295. $search_date_end_startday = '';
  296. $search_date_end_startmonth = '';
  297. $search_date_end_startyear = '';
  298. $search_date_end_endday = '';
  299. $search_date_end_endmonth = '';
  300. $search_date_end_endyear = '';
  301. $search_date_end_start = '';
  302. $search_date_end_end = '';
  303. $search_date_delivery_startday = '';
  304. $search_date_delivery_startmonth = '';
  305. $search_date_delivery_startyear = '';
  306. $search_date_delivery_endday = '';
  307. $search_date_delivery_endmonth = '';
  308. $search_date_delivery_endyear = '';
  309. $search_date_delivery_start = '';
  310. $search_date_delivery_end = '';
  311. $search_availability = '';
  312. $search_status = '';
  313. $object_statut = '';
  314. $toselect = array();
  315. $search_array_options = array();
  316. $search_categ_cus = 0;
  317. $search_fk_cond_reglement = '';
  318. $search_fk_shipping_method = '';
  319. $search_fk_input_reason = '';
  320. $search_fk_mode_reglement = '';
  321. $search_date_signature_startday = '';
  322. $search_date_signature_startmonth = '';
  323. $search_date_signature_startyear = '';
  324. $search_date_signature_endday = '';
  325. $search_date_signature_endmonth = '';
  326. $search_date_signature_endyear = '';
  327. $search_date_signature_start = '';
  328. $search_date_signature_end = '';
  329. }
  330. if ($object_statut != '') {
  331. $search_status = $object_statut;
  332. }
  333. if (empty($reshook)) {
  334. $objectclass = 'Propal';
  335. $objectlabel = 'Proposals';
  336. $uploaddir = $conf->propal->multidir_output[$conf->entity];
  337. include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';
  338. }
  339. if ($action == 'validate' && $permissiontovalidate) {
  340. if (GETPOST('confirm') == 'yes') {
  341. $tmpproposal = new Propal($db);
  342. $db->begin();
  343. $error = 0;
  344. foreach ($toselect as $checked) {
  345. if ($tmpproposal->fetch($checked) > 0) {
  346. if ($tmpproposal->statut == $tmpproposal::STATUS_DRAFT) {
  347. if ($tmpproposal->valid($user) > 0) {
  348. setEventMessages($langs->trans('hasBeenValidated', $tmpproposal->ref), null, 'mesgs');
  349. } else {
  350. setEventMessages($tmpproposal->error, $tmpproposal->errors, 'errors');
  351. $error++;
  352. }
  353. } else {
  354. $langs->load("errors");
  355. setEventMessages($langs->trans('ErrorIsNotADraft', $tmpproposal->ref), null, 'errors');
  356. $error++;
  357. }
  358. } else {
  359. setEventMessages($tmpproposal->error, $tmpproposal->errors, 'errors');
  360. $error++;
  361. }
  362. }
  363. if ($error) {
  364. $db->rollback();
  365. } else {
  366. $db->commit();
  367. }
  368. }
  369. }
  370. if ($action == "sign" && $permissiontoclose) {
  371. if (GETPOST('confirm') == 'yes') {
  372. $tmpproposal = new Propal($db);
  373. $db->begin();
  374. $error = 0;
  375. foreach ($toselect as $checked) {
  376. if ($tmpproposal->fetch($checked) > 0) {
  377. if ($tmpproposal->statut == $tmpproposal::STATUS_VALIDATED) {
  378. $tmpproposal->statut = $tmpproposal::STATUS_SIGNED;
  379. if ($tmpproposal->closeProposal($user, $tmpproposal::STATUS_SIGNED) >= 0) {
  380. setEventMessages($tmpproposal->ref." ".$langs->trans('Signed'), null, 'mesgs');
  381. } else {
  382. setEventMessages($tmpproposal->error, $tmpproposal->errors, 'errors');
  383. $error++;
  384. }
  385. } else {
  386. setEventMessage($langs->trans('MustBeValidatedToBeSigned', $tmpproposal->ref), 'errors');
  387. $error++;
  388. }
  389. } else {
  390. setEventMessages($tmpproposal->error, $tmpproposal->errors, 'errors');
  391. $error++;
  392. }
  393. }
  394. if ($error) {
  395. $db->rollback();
  396. } else {
  397. $db->commit();
  398. }
  399. }
  400. }
  401. if ($action == "nosign" && $permissiontoclose) {
  402. if (GETPOST('confirm') == 'yes') {
  403. $tmpproposal = new Propal($db);
  404. $db->begin();
  405. $error = 0;
  406. foreach ($toselect as $checked) {
  407. if ($tmpproposal->fetch($checked) > 0) {
  408. if ($tmpproposal->statut == $tmpproposal::STATUS_VALIDATED) {
  409. $tmpproposal->statut = $tmpproposal::STATUS_NOTSIGNED;
  410. if ($tmpproposal->closeProposal($user, $tmpproposal::STATUS_NOTSIGNED) > 0) {
  411. setEventMessage($tmpproposal->ref." ".$langs->trans('NoSigned'), 'mesgs');
  412. } else {
  413. setEventMessages($tmpproposal->error, $tmpproposal->errors, 'errors');
  414. $error++;
  415. }
  416. } else {
  417. setEventMessage($tmpproposal->ref." ".$langs->trans('CantBeNoSign'), 'errors');
  418. $error++;
  419. }
  420. } else {
  421. setEventMessages($tmpproposal->error, $tmpproposal->errors, 'errors');
  422. $error++;
  423. }
  424. }
  425. if ($error) {
  426. $db->rollback();
  427. } else {
  428. $db->commit();
  429. }
  430. }
  431. }
  432. // Closed records
  433. if (!$error && $massaction === 'setbilled' && $permissiontoclose) {
  434. $db->begin();
  435. $objecttmp = new $objectclass($db);
  436. $nbok = 0;
  437. foreach ($toselect as $toselectid) {
  438. $result = $objecttmp->fetch($toselectid);
  439. if ($result > 0) {
  440. $result = $objecttmp->classifyBilled($user, 0);
  441. if ($result <= 0) {
  442. setEventMessages($objecttmp->error, $objecttmp->errors, 'errors');
  443. $error++;
  444. break;
  445. } else {
  446. $nbok++;
  447. }
  448. } else {
  449. setEventMessages($objecttmp->error, $objecttmp->errors, 'errors');
  450. $error++;
  451. break;
  452. }
  453. }
  454. if (!$error) {
  455. if ($nbok > 1) {
  456. setEventMessages($langs->trans("RecordsModified", $nbok), null, 'mesgs');
  457. } else {
  458. setEventMessages($langs->trans("RecordsModified", $nbok), null, 'mesgs');
  459. }
  460. $db->commit();
  461. } else {
  462. $db->rollback();
  463. }
  464. }
  465. /*
  466. * View
  467. */
  468. $now = dol_now();
  469. $form = new Form($db);
  470. $formother = new FormOther($db);
  471. $formfile = new FormFile($db);
  472. $formpropal = new FormPropal($db);
  473. $formmargin = null;
  474. if (!empty($conf->margin->enabled)) {
  475. $formmargin = new FormMargin($db);
  476. }
  477. $companystatic = new Societe($db);
  478. $projectstatic = new Project($db);
  479. $formcompany = new FormCompany($db);
  480. $help_url = 'EN:Commercial_Proposals|FR:Proposition_commerciale|ES:Presupuestos';
  481. //llxHeader('',$langs->trans('Proposal'),$help_url);
  482. $sql = 'SELECT';
  483. if ($sall || $search_product_category > 0 || $search_user > 0) {
  484. $sql = 'SELECT DISTINCT';
  485. }
  486. $sql .= ' s.rowid as socid, s.nom as name, s.name_alias as alias, s.email, s.phone, s.fax , s.address, s.town, s.zip, s.fk_pays, s.client, s.code_client, ';
  487. $sql .= " typent.code as typent_code,";
  488. $sql .= " ava.rowid as availability,";
  489. $sql .= " country.code as country_code,";
  490. $sql .= " state.code_departement as state_code, state.nom as state_name,";
  491. $sql .= ' p.rowid, p.entity as propal_entity, p.note_private, p.total_ht, p.total_tva, p.total_ttc, p.localtax1, p.localtax2, p.ref, p.ref_client, p.fk_statut as status, p.fk_user_author, p.datep as dp, p.fin_validite as dfv,p.date_livraison as ddelivery,';
  492. $sql .= ' p.fk_multicurrency, p.multicurrency_code, p.multicurrency_tx, p.multicurrency_total_ht, p.multicurrency_total_tva, p.multicurrency_total_ttc,';
  493. $sql .= ' p.datec as date_creation, p.tms as date_update, p.date_cloture as date_cloture,';
  494. $sql .= ' p.date_signature as dsignature,';
  495. $sql .= ' p.note_public, p.note_private,';
  496. $sql .= ' p.fk_cond_reglement,p.deposit_percent,p.fk_mode_reglement,p.fk_shipping_method,p.fk_input_reason,';
  497. $sql .= " pr.rowid as project_id, pr.ref as project_ref, pr.title as project_label,";
  498. $sql .= ' u.login, u.lastname, u.firstname, u.email as user_email, u.statut as user_statut, u.entity as user_entity, u.photo, u.office_phone, u.office_fax, u.user_mobile, u.job, u.gender';
  499. if (empty($user->rights->societe->client->voir) && !$socid) {
  500. $sql .= ", sc.fk_soc, sc.fk_user";
  501. }
  502. if (!empty($search_categ_cus) && $search_categ_cus != '-1') {
  503. $sql .= ", cc.fk_categorie, cc.fk_soc";
  504. }
  505. // Add fields from extrafields
  506. if (!empty($extrafields->attributes[$object->table_element]['label'])) {
  507. foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) {
  508. $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key." as options_".$key : '');
  509. }
  510. }
  511. // Add fields from hooks
  512. $parameters = array();
  513. $reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters); // Note that $action and $object may have been modified by hook
  514. $sql .= $hookmanager->resPrint;
  515. $sql = preg_replace('/, $/', '', $sql);
  516. $sql .= ' FROM '.MAIN_DB_PREFIX.'societe as s';
  517. $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as country on (country.rowid = s.fk_pays)";
  518. $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_typent as typent on (typent.id = s.fk_typent)";
  519. $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_departements as state on (state.rowid = s.fk_departement)";
  520. if (!empty($search_categ_cus) && $search_categ_cus != '-1') {
  521. $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX."categorie_societe as cc ON s.rowid = cc.fk_soc"; // We'll need this table joined to the select in order to filter by categ
  522. }
  523. // Added by MMI Mathieu Moulin iProspective
  524. // Add fields from hooks
  525. $parameters = array();
  526. $reshook = $hookmanager->executeHooks('printFieldListJoinSoc', $parameters); // Note that $action and $object may have been modified by hook
  527. $sql .= $hookmanager->resPrint;
  528. $sql .= ', '.MAIN_DB_PREFIX.'propal as p';
  529. if (!empty($extrafields->attributes[$object->table_element]['label']) && is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) {
  530. $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (p.rowid = ef.fk_object)";
  531. }
  532. if ($sall || $search_product_category > 0) {
  533. $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'propaldet as pd ON p.rowid=pd.fk_propal';
  534. }
  535. if ($search_product_category > 0) {
  536. $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'categorie_product as cp ON cp.fk_product=pd.fk_product';
  537. }
  538. $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'user as u ON p.fk_user_author = u.rowid';
  539. $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."projet as pr ON pr.rowid = p.fk_projet";
  540. $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_availability as ava on (ava.rowid = p.fk_availability)";
  541. // Added by MMI Mathieu Moulin iProspective
  542. // Add fields from hooks
  543. $parameters = array();
  544. $reshook = $hookmanager->executeHooks('printFieldListJoinPropal', $parameters); // Note that $action and $object may have been modified by hook
  545. $sql .= $hookmanager->resPrint;
  546. //echo ($sql); die();
  547. // We'll need this table joined to the select in order to filter by sale
  548. if ($search_sale > 0 || (empty($user->rights->societe->client->voir) && !$socid)) {
  549. $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
  550. }
  551. if ($search_user > 0) {
  552. $sql .= ", ".MAIN_DB_PREFIX."element_contact as c";
  553. $sql .= ", ".MAIN_DB_PREFIX."c_type_contact as tc";
  554. }
  555. // Add table from hooks
  556. $parameters = array();
  557. $reshook = $hookmanager->executeHooks('printFieldListFrom', $parameters, $object); // Note that $action and $object may have been modified by hook
  558. $sql .= $hookmanager->resPrint;
  559. $sql .= ' WHERE p.fk_soc = s.rowid';
  560. $sql .= ' AND p.entity IN ('.getEntity('propal').')';
  561. if (empty($user->rights->societe->client->voir) && !$socid) { //restriction
  562. $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
  563. }
  564. if ($search_town) {
  565. $sql .= natural_search('s.town', $search_town);
  566. }
  567. if ($search_zip) {
  568. $sql .= natural_search("s.zip", $search_zip);
  569. }
  570. if ($search_state) {
  571. $sql .= natural_search("state.nom", $search_state);
  572. }
  573. if ($search_country) {
  574. $sql .= " AND s.fk_pays IN (".$db->sanitize($db->escape($search_country)).')';
  575. }
  576. if ($search_type_thirdparty != '' && $search_type_thirdparty > 0) {
  577. $sql .= " AND s.fk_typent IN (".$db->sanitize($db->escape($search_type_thirdparty)).')';
  578. }
  579. if ($search_ref) {
  580. $sql .= natural_search('p.ref', $search_ref);
  581. }
  582. if ($search_refcustomer) {
  583. $sql .= natural_search('p.ref_client', $search_refcustomer);
  584. }
  585. if ($search_refproject) {
  586. $sql .= natural_search('pr.ref', $search_refproject);
  587. }
  588. if ($search_project) {
  589. $sql .= natural_search('pr.title', $search_project);
  590. }
  591. if ($search_availability) {
  592. $sql .= " AND p.fk_availability IN (".$db->sanitize($db->escape($search_availability)).')';
  593. }
  594. if ($search_societe) {
  595. $sql .= natural_search('s.nom', $search_societe);
  596. }
  597. if ($search_societe_alias) {
  598. $sql .= natural_search('s.name_alias', $search_societe_alias);
  599. }
  600. if ($search_login) {
  601. $sql .= natural_search(array("u.login", "u.firstname", "u.lastname"), $search_login);
  602. }
  603. if ($search_montant_ht != '') {
  604. $sql .= natural_search("p.total_ht", $search_montant_ht, 1);
  605. }
  606. if ($search_montant_vat != '') {
  607. $sql .= natural_search("p.total_tva", $search_montant_vat, 1);
  608. }
  609. if ($search_montant_ttc != '') {
  610. $sql .= natural_search("p.total_ttc", $search_montant_ttc, 1);
  611. }
  612. if ($search_warehouse != '' && $search_warehouse > 0) {
  613. $sql .= natural_search("p.fk_warehouse", $search_warehouse, 1);
  614. }
  615. if ($search_multicurrency_code != '') {
  616. $sql .= " AND p.multicurrency_code = '".$db->escape($search_multicurrency_code)."'";
  617. }
  618. if ($search_multicurrency_tx != '') {
  619. $sql .= natural_search('p.multicurrency_tx', $search_multicurrency_tx, 1);
  620. }
  621. if ($search_multicurrency_montant_ht != '') {
  622. $sql .= natural_search('p.multicurrency_total_ht', $search_multicurrency_montant_ht, 1);
  623. }
  624. if ($search_multicurrency_montant_vat != '') {
  625. $sql .= natural_search('p.multicurrency_total_tva', $search_multicurrency_montant_vat, 1);
  626. }
  627. if ($search_multicurrency_montant_ttc != '') {
  628. $sql .= natural_search('p.multicurrency_total_ttc', $search_multicurrency_montant_ttc, 1);
  629. }
  630. if ($sall) {
  631. $sql .= natural_search(array_keys($fieldstosearchall), $sall);
  632. }
  633. if ($search_categ_cus > 0) {
  634. $sql .= " AND cc.fk_categorie = ".((int) $search_categ_cus);
  635. }
  636. if ($search_categ_cus == -2) {
  637. $sql .= " AND cc.fk_categorie IS NULL";
  638. }
  639. if ($search_fk_cond_reglement > 0) {
  640. $sql .= " AND p.fk_cond_reglement = ".((int) $search_fk_cond_reglement);
  641. }
  642. if ($search_fk_shipping_method > 0) {
  643. $sql .= " AND p.fk_shipping_method = ".((int) $search_fk_shipping_method);
  644. }
  645. if ($search_fk_input_reason > 0) {
  646. $sql .= " AND p.fk_input_reason = ".((int) $search_fk_input_reason);
  647. }
  648. if ($search_fk_mode_reglement > 0) {
  649. $sql .= " AND p.fk_mode_reglement = ".((int) $search_fk_mode_reglement);
  650. }
  651. if ($search_product_category > 0) {
  652. $sql .= " AND cp.fk_categorie = ".((int) $search_product_category);
  653. }
  654. if ($socid > 0) {
  655. $sql .= ' AND s.rowid = '.((int) $socid);
  656. }
  657. if ($search_status != '' && $search_status != '-1') {
  658. $sql .= ' AND p.fk_statut IN ('.$db->sanitize($search_status).')';
  659. }
  660. if ($search_date_start) {
  661. $sql .= " AND p.datep >= '".$db->idate($search_date_start)."'";
  662. }
  663. if ($search_date_end) {
  664. $sql .= " AND p.datep <= '".$db->idate($search_date_end)."'";
  665. }
  666. if ($search_date_end_start) {
  667. $sql .= " AND p.fin_validite >= '".$db->idate($search_date_end_start)."'";
  668. }
  669. if ($search_date_end_end) {
  670. $sql .= " AND p.fin_validite <= '".$db->idate($search_date_end_end)."'";
  671. }
  672. if ($search_date_delivery_start) {
  673. $sql .= " AND p.date_livraison >= '".$db->idate($search_date_delivery_start)."'";
  674. }
  675. if ($search_date_delivery_end) {
  676. $sql .= " AND p.date_livraison <= '".$db->idate($search_date_delivery_end)."'";
  677. }
  678. if ($search_sale > 0) {
  679. $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $search_sale);
  680. }
  681. if ($search_user > 0) {
  682. $sql .= " AND c.fk_c_type_contact = tc.rowid AND tc.element='propal' AND tc.source='internal' AND c.element_id = p.rowid AND c.fk_socpeople = ".((int) $search_user);
  683. }
  684. if ($search_date_signature_start) {
  685. $sql .= " AND p.date_signature >= '".$db->idate($search_date_signature_start)."'";
  686. }
  687. if ($search_date_signature_end) {
  688. $sql .= " AND p.date_signature <= '".$db->idate($search_date_signature_end)."'";
  689. }
  690. // Add where from extra fields
  691. include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php';
  692. // Add where from hooks
  693. $parameters = array();
  694. $reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook
  695. $sql .= $hookmanager->resPrint;
  696. // Add HAVING from hooks
  697. $parameters = array();
  698. $reshook = $hookmanager->executeHooks('printFieldListHaving', $parameters, $object); // Note that $action and $object may have been modified by hook
  699. $sql .= empty($hookmanager->resPrint) ? "" : " HAVING 1=1 ".$hookmanager->resPrint;
  700. $sql .= $db->order($sortfield, $sortorder);
  701. $sql .= ', p.ref DESC';
  702. // Count total nb of records
  703. $nbtotalofrecords = '';
  704. if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
  705. $result = $db->query($sql);
  706. $nbtotalofrecords = $db->num_rows($result);
  707. if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller then paging size (filtering), goto and load page 0
  708. $page = 0;
  709. $offset = 0;
  710. }
  711. }
  712. $sql .= $db->plimit($limit + 1, $offset);
  713. $resql = $db->query($sql);
  714. if ($resql) {
  715. $objectstatic = new Propal($db);
  716. $userstatic = new User($db);
  717. if ($socid > 0) {
  718. $soc = new Societe($db);
  719. $soc->fetch($socid);
  720. $title = $langs->trans('Proposals').' - '.$soc->name;
  721. if (empty($search_societe)) {
  722. $search_societe = $soc->name;
  723. }
  724. } else {
  725. $title = $langs->trans('Proposals');
  726. }
  727. $num = $db->num_rows($resql);
  728. $arrayofselected = is_array($toselect) ? $toselect : array();
  729. if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $sall) {
  730. $obj = $db->fetch_object($resql);
  731. $id = $obj->rowid;
  732. header("Location: ".DOL_URL_ROOT.'/comm/propal/card.php?id='.$id);
  733. exit;
  734. }
  735. llxHeader('', $langs->trans('Proposal'), $help_url);
  736. $param = '&search_status='.urlencode($search_status);
  737. if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
  738. $param .= '&contextpage='.urlencode($contextpage);
  739. }
  740. if ($limit > 0 && $limit != $conf->liste_limit) {
  741. $param .= '&limit='.urlencode($limit);
  742. }
  743. if ($sall) {
  744. $param .= '&sall='.urlencode($sall);
  745. }
  746. if ($search_date_startday) {
  747. $param .= '&search_date_startday='.urlencode($search_date_startday);
  748. }
  749. if ($search_date_startmonth) {
  750. $param .= '&search_date_startmonth='.urlencode($search_date_startmonth);
  751. }
  752. if ($search_date_startyear) {
  753. $param .= '&search_date_startyear='.urlencode($search_date_startyear);
  754. }
  755. if ($search_date_endday) {
  756. $param .= '&search_date_endday='.urlencode($search_date_endday);
  757. }
  758. if ($search_date_endmonth) {
  759. $param .= '&search_date_endmonth='.urlencode($search_date_endmonth);
  760. }
  761. if ($search_date_endyear) {
  762. $param .= '&search_date_endyear='.urlencode($search_date_endyear);
  763. }
  764. if ($search_date_end_startday) {
  765. $param .= '&search_date_end_startday='.urlencode($search_date_end_startday);
  766. }
  767. if ($search_date_end_startmonth) {
  768. $param .= '&search_date_end_startmonth='.urlencode($search_date_end_startmonth);
  769. }
  770. if ($search_date_end_startyear) {
  771. $param .= '&search_date_end_startyear='.urlencode($search_date_end_startyear);
  772. }
  773. if ($search_date_end_endday) {
  774. $param .= '&search_date_end_endday='.urlencode($search_date_end_endday);
  775. }
  776. if ($search_date_end_endmonth) {
  777. $param .= '&search_date_end_endmonth='.urlencode($search_date_end_endmonth);
  778. }
  779. if ($search_date_end_endyear) {
  780. $param .= '&search_date_end_endyear='.urlencode($search_date_end_endyear);
  781. }
  782. if ($search_date_delivery_startday) {
  783. $param .= '&search_date_delivery_startday='.urlencode($search_date_delivery_startday);
  784. }
  785. if ($search_date_delivery_startmonth) {
  786. $param .= '&search_date_delivery_startmonth='.urlencode($search_date_delivery_startmonth);
  787. }
  788. if ($search_date_delivery_startyear) {
  789. $param .= '&search_date_delivery_startyear='.urlencode($search_date_delivery_startyear);
  790. }
  791. if ($search_date_delivery_endday) {
  792. $param .= '&search_date_delivery_endday='.urlencode($search_date_delivery_endday);
  793. }
  794. if ($search_date_delivery_endmonth) {
  795. $param .= '&search_date_delivery_endmonth='.urlencode($search_date_delivery_endmonth);
  796. }
  797. if ($search_date_delivery_endyear) {
  798. $param .= '&search_date_delivery_endyear='.urlencode($search_date_delivery_endyear);
  799. }
  800. if ($search_ref) {
  801. $param .= '&search_ref='.urlencode($search_ref);
  802. }
  803. if ($search_refcustomer) {
  804. $param .= '&search_refcustomer='.urlencode($search_refcustomer);
  805. }
  806. if ($search_refproject) {
  807. $param .= '&search_refproject='.urlencode($search_refproject);
  808. }
  809. if ($search_societe) {
  810. $param .= '&search_societe='.urlencode($search_societe);
  811. }
  812. if ($search_societe_alias) {
  813. $param .= '&search_societe_alias='.urlencode($search_societe_alias);
  814. }
  815. if ($search_user > 0) {
  816. $param .= '&search_user='.urlencode($search_user);
  817. }
  818. if ($search_sale > 0) {
  819. $param .= '&search_sale='.urlencode($search_sale);
  820. }
  821. if ($search_montant_ht) {
  822. $param .= '&search_montant_ht='.urlencode($search_montant_ht);
  823. }
  824. if ($search_multicurrency_code != '') {
  825. $param .= '&search_multicurrency_code='.urlencode($search_multicurrency_code);
  826. }
  827. if ($search_multicurrency_tx != '') {
  828. $param .= '&search_multicurrency_tx='.urlencode($search_multicurrency_tx);
  829. }
  830. if ($search_multicurrency_montant_ht != '') {
  831. $param .= '&search_multicurrency_montant_ht='.urlencode($search_multicurrency_montant_ht);
  832. }
  833. if ($search_multicurrency_montant_vat != '') {
  834. $param .= '&search_multicurrency_montant_vat='.urlencode($search_multicurrency_montant_vat);
  835. }
  836. if ($search_multicurrency_montant_ttc != '') {
  837. $param .= '&search_multicurrency_montant_ttc='.urlencode($search_multicurrency_montant_ttc);
  838. }
  839. if ($search_login) {
  840. $param .= '&search_login='.urlencode($search_login);
  841. }
  842. if ($search_town) {
  843. $param .= '&search_town='.urlencode($search_town);
  844. }
  845. if ($search_zip) {
  846. $param .= '&search_zip='.urlencode($search_zip);
  847. }
  848. if ($socid > 0) {
  849. $param .= '&socid='.urlencode($socid);
  850. }
  851. if ($optioncss != '') {
  852. $param .= '&optioncss='.urlencode($optioncss);
  853. }
  854. if ($search_categ_cus > 0) {
  855. $param .= '&search_categ_cus='.urlencode($search_categ_cus);
  856. }
  857. if ($search_product_category != '') {
  858. $param .= '&search_product_category='.urlencode($search_product_category);
  859. }
  860. if ($search_fk_cond_reglement > 0) {
  861. $param .= '&search_fk_cond_reglement='.urlencode($search_fk_cond_reglement);
  862. }
  863. if ($search_fk_shipping_method > 0) {
  864. $param .= '&search_fk_shipping_method='.urlencode($search_fk_shipping_method);
  865. }
  866. if ($search_fk_input_reason > 0) {
  867. $param .= '&search_fk_input_reason='.urlencode($search_fk_input_reason);
  868. }
  869. if ($search_fk_mode_reglement > 0) {
  870. $param .= '&search_fk_mode_reglement='.urlencode($search_fk_mode_reglement);
  871. }
  872. if ($search_type_thirdparty > 0) {
  873. $param .= '&search_type_thirdparty='.urlencode($search_type_thirdparty);
  874. }
  875. if ($search_town) {
  876. $param .= '&search_town='.urlencode($search_town);
  877. }
  878. if ($search_zip) {
  879. $param .= '&search_zip='.urlencode($search_zip);
  880. }
  881. if ($search_state) {
  882. $param .= '&search_state='.urlencode($search_state);
  883. }
  884. if ($search_town) {
  885. $param .= '&search_town='.urlencode($search_town);
  886. }
  887. if ($search_country) {
  888. $param .= '&search_country='.urlencode($search_country);
  889. }
  890. if ($search_date_signature_startday) {
  891. $param .= '&search_date_signature_startday='.urlencode($search_date_signature_startday);
  892. }
  893. if ($search_date_signature_startmonth) {
  894. $param .= '&search_date_signature_startmonth='.urlencode($search_date_signature_startmonth);
  895. }
  896. if ($search_date_signature_startyear) {
  897. $param .= '&search_date_signature_startyear='.urlencode($search_date_signature_startyear);
  898. }
  899. if ($search_date_signature_endday) {
  900. $param .= '&search_date_signature_endday='.urlencode($search_date_signature_endday);
  901. }
  902. if ($search_date_signature_endmonth) {
  903. $param .= '&search_date_signature_endmonth='.urlencode($search_date_signature_endmonth);
  904. }
  905. if ($search_date_signature_endyear) {
  906. $param .= '&search_date_signature_endyear='.urlencode($search_date_signature_endyear);
  907. }
  908. // Add $param from extra fields
  909. include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
  910. // Add $param from hooks
  911. $parameters = array();
  912. $reshook = $hookmanager->executeHooks('printFieldListSearchParam', $parameters, $object); // Note that $action and $object may have been modified by hook
  913. $param .= $hookmanager->resPrint;
  914. // List of mass actions available
  915. $arrayofmassactions = array(
  916. 'generate_doc'=>img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("ReGeneratePDF"),
  917. 'builddoc'=>img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("PDFMerge"),
  918. );
  919. if ($permissiontosendbymail) {
  920. $arrayofmassactions['presend']=img_picto('', 'email', 'class="pictofixedwidth"').$langs->trans("SendByMail");
  921. }
  922. if ($permissiontovalidate) {
  923. $arrayofmassactions['prevalidate']=img_picto('', 'check', 'class="pictofixedwidth"').$langs->trans("Validate");
  924. }
  925. if ($permissiontoclose) {
  926. $arrayofmassactions['presign']=img_picto('', 'propal', 'class="pictofixedwidth"').$langs->trans("Sign");
  927. $arrayofmassactions['nopresign']=img_picto('', 'propal', 'class="pictofixedwidth"').$langs->trans("NoSign");
  928. $arrayofmassactions['setbilled'] =img_picto('', 'bill', 'class="pictofixedwidth"').$langs->trans("ClassifyBilled");
  929. }
  930. if ($permissiontodelete) {
  931. $arrayofmassactions['predelete'] = img_picto('', 'delete', 'class="pictofixedwidth"').$langs->trans("Delete");
  932. }
  933. if (in_array($massaction, array('presend', 'predelete', 'closed'))) {
  934. $arrayofmassactions = array();
  935. }
  936. $massactionbutton = $form->selectMassAction('', $arrayofmassactions);
  937. $url = DOL_URL_ROOT.'/comm/propal/card.php?action=create';
  938. if (!empty($socid)) {
  939. $url .= '&socid='.$socid;
  940. }
  941. $newcardbutton = dolGetButtonTitle($langs->trans('NewPropal'), '', 'fa fa-plus-circle', $url, '', $user->rights->propal->creer);
  942. // Fields title search
  943. print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">';
  944. if ($optioncss != '') {
  945. print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
  946. }
  947. print '<input type="hidden" name="token" value="'.newToken().'">';
  948. print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
  949. print '<input type="hidden" name="action" value="list">';
  950. print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
  951. print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
  952. print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
  953. print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'propal', 0, $newcardbutton, '', $limit, 0, 0, 1);
  954. $topicmail = "SendPropalRef";
  955. $modelmail = "propal_send";
  956. $objecttmp = new Propal($db);
  957. $trackid = 'pro'.$object->id;
  958. include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php';
  959. if ($massaction == 'prevalidate') {
  960. print $form->formconfirm($_SERVER["PHP_SELF"], $langs->trans("ConfirmMassValidation"), $langs->trans("ConfirmMassValidationQuestion"), "validate", null, '', 0, 200, 500, 1);
  961. }
  962. if ($massaction == 'presign') {
  963. print $form->formconfirm($_SERVER["PHP_SELF"], $langs->trans("ConfirmMassSignature"), $langs->trans("ConfirmMassSignatureQuestion"), "sign", null, '', 0, 200, 500, 1);
  964. }
  965. if ($massaction == 'nopresign') {
  966. print $form->formconfirm($_SERVER["PHP_SELF"], $langs->trans("ConfirmMassNoSignature"), $langs->trans("ConfirmMassNoSignatureQuestion"), "nosign", null, '', 0, 200, 500, 1);
  967. }
  968. if ($sall) {
  969. foreach ($fieldstosearchall as $key => $val) {
  970. $fieldstosearchall[$key] = $langs->trans($val);
  971. }
  972. print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $sall).join(', ', $fieldstosearchall).'</div>';
  973. }
  974. $i = 0;
  975. $moreforfilter = '';
  976. // If the user can view prospects other than his'
  977. if ($user->rights->user->user->lire) {
  978. $langs->load("commercial");
  979. $moreforfilter .= '<div class="divsearchfield">';
  980. $tmptitle = $langs->trans('ThirdPartiesOfSaleRepresentative');
  981. $moreforfilter .= img_picto($tmptitle, 'user', 'class="pictofixedwidth"').$formother->select_salesrepresentatives($search_sale, 'search_sale', $user, 0, $tmptitle, 'maxwidth250 widthcentpercentminusx');
  982. $moreforfilter .= '</div>';
  983. }
  984. // If the user can view prospects other than his'
  985. if ($user->rights->user->user->lire) {
  986. $moreforfilter .= '<div class="divsearchfield">';
  987. $tmptitle = $langs->trans('LinkedToSpecificUsers');
  988. $moreforfilter .= img_picto($tmptitle, 'user', 'class="pictofixedwidth"').$form->select_dolusers($search_user, 'search_user', $tmptitle, '', 0, '', '', 0, 0, 0, '', 0, '', 'maxwidth250 widthcentpercentminusx');
  989. $moreforfilter .= '</div>';
  990. }
  991. // If the user can view products
  992. if (!empty($conf->categorie->enabled) && $user->rights->categorie->lire && ($user->rights->produit->lire || $user->rights->service->lire)) {
  993. include_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
  994. $moreforfilter .= '<div class="divsearchfield">';
  995. $tmptitle = $langs->trans('IncludingProductWithTag');
  996. $cate_arbo = $form->select_all_categories(Categorie::TYPE_PRODUCT, null, 'parent', null, null, 1);
  997. $moreforfilter .= img_picto($tmptitle, 'category', 'class="pictofixedwidth"').$form->selectarray('search_product_category', $cate_arbo, $search_product_category, $tmptitle, 0, 0, '', 0, 0, 0, 0, (empty($conf->dol_optimize_smallscreen) ? 'maxwidth300 widthcentpercentminusx' : 'maxwidth250 widthcentpercentminusx'), 1);
  998. $moreforfilter .= '</div>';
  999. }
  1000. if (!empty($conf->categorie->enabled) && $user->rights->categorie->lire) {
  1001. require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
  1002. $moreforfilter .= '<div class="divsearchfield">';
  1003. $tmptitle = $langs->trans('CustomersProspectsCategoriesShort');
  1004. $moreforfilter .= img_picto($tmptitle, 'category', 'class="pictofixedwidth"').$formother->select_categories('customer', $search_categ_cus, 'search_categ_cus', 1, $tmptitle, (empty($conf->dol_optimize_smallscreen) ? 'maxwidth300 widthcentpercentminusx' : 'maxwidth250 widthcentpercentminusx'));
  1005. $moreforfilter .= '</div>';
  1006. }
  1007. if (!empty($conf->stock->enabled) && !empty($conf->global->WAREHOUSE_ASK_WAREHOUSE_DURING_PROPAL)) {
  1008. require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php';
  1009. $formproduct = new FormProduct($db);
  1010. $moreforfilter .= '<div class="divsearchfield">';
  1011. $tmptitle = $langs->trans('Warehouse');
  1012. $moreforfilter .= img_picto($tmptitle, 'stock', 'class="pictofixedwidth"').$formproduct->selectWarehouses($search_warehouse, 'search_warehouse', '', $tmptitle, 0, 0, $tmptitle);
  1013. $moreforfilter .= '</div>';
  1014. }
  1015. $parameters = array();
  1016. $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook
  1017. if (empty($reshook)) {
  1018. $moreforfilter .= $hookmanager->resPrint;
  1019. } else {
  1020. $moreforfilter = $hookmanager->resPrint;
  1021. }
  1022. if (!empty($moreforfilter)) {
  1023. print '<div class="liste_titre liste_titre_bydiv centpercent">';
  1024. print $moreforfilter;
  1025. print '</div>';
  1026. }
  1027. $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
  1028. $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields
  1029. $selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons('checkforselect', 1) : '');
  1030. print '<div class="div-table-responsive">';
  1031. print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n";
  1032. print '<tr class="liste_titre_filter">';
  1033. if (!empty($arrayfields['p.ref']['checked'])) {
  1034. print '<td class="liste_titre">';
  1035. print '<input class="flat maxwidth50" type="text" name="search_ref" value="'.dol_escape_htmltag($search_ref).'">';
  1036. print '</td>';
  1037. }
  1038. if (!empty($arrayfields['p.ref_client']['checked'])) {
  1039. print '<td class="liste_titre">';
  1040. print '<input class="flat maxwidth50" type="text" name="search_refcustomer" value="'.dol_escape_htmltag($search_refcustomer).'">';
  1041. print '</td>';
  1042. }
  1043. if (!empty($arrayfields['pr.ref']['checked'])) {
  1044. print '<td class="liste_titre">';
  1045. print '<input class="flat maxwidth50" type="text" name="search_refproject" value="'.dol_escape_htmltag($search_refproject).'">';
  1046. print '</td>';
  1047. }
  1048. if (!empty($arrayfields['pr.title']['checked'])) {
  1049. print '<td class="liste_titre">';
  1050. print '<input class="flat maxwidth50" type="text" name="search_project" value="'.dol_escape_htmltag($search_project).'">';
  1051. print '</td>';
  1052. }
  1053. if (!empty($arrayfields['s.nom']['checked'])) {
  1054. print '<td class="liste_titre" align="left">';
  1055. print '<input class="flat maxwidth100" type="text" name="search_societe" value="'.dol_escape_htmltag($search_societe).'">';
  1056. print '</td>';
  1057. }
  1058. if (!empty($arrayfields['s.name_alias']['checked'])) {
  1059. print '<td class="liste_titre" align="left">';
  1060. print '<input class="flat maxwidth100" type="text" name="search_societe_alias" value="'.dol_escape_htmltag($search_societe_alias).'">';
  1061. print '</td>';
  1062. }
  1063. if (!empty($arrayfields['s.town']['checked'])) {
  1064. print '<td class="liste_titre"><input class="flat maxwidth50" type="text" name="search_town" value="'.$search_town.'"></td>';
  1065. }
  1066. if (!empty($arrayfields['s.zip']['checked'])) {
  1067. print '<td class="liste_titre"><input class="flat maxwidth50" type="text" name="search_zip" value="'.$search_zip.'"></td>';
  1068. }
  1069. // State
  1070. if (!empty($arrayfields['state.nom']['checked'])) {
  1071. print '<td class="liste_titre">';
  1072. print '<input class="flat maxwidth50" type="text" name="search_state" value="'.dol_escape_htmltag($search_state).'">';
  1073. print '</td>';
  1074. }
  1075. // Country
  1076. if (!empty($arrayfields['country.code_iso']['checked'])) {
  1077. print '<td class="liste_titre" align="center">';
  1078. print $form->select_country($search_country, 'search_country', '', 0, 'minwidth100imp maxwidth100');
  1079. print '</td>';
  1080. }
  1081. // Company type
  1082. if (!empty($arrayfields['typent.code']['checked'])) {
  1083. print '<td class="liste_titre maxwidth100onsmartphone" align="center">';
  1084. 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);
  1085. print ajax_combobox('search_type_thirdparty');
  1086. print '</td>';
  1087. }
  1088. // Date
  1089. if (!empty($arrayfields['p.date']['checked'])) {
  1090. print '<td class="liste_titre center">';
  1091. print '<div class="nowrap">';
  1092. print $form->selectDate($search_date_start ? $search_date_start : -1, 'search_date_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From'));
  1093. print '</div>';
  1094. print '<div class="nowrap">';
  1095. print $form->selectDate($search_date_end ? $search_date_end : -1, 'search_date_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to'));
  1096. print '</div>';
  1097. print '</td>';
  1098. }
  1099. // Date end
  1100. if (!empty($arrayfields['p.fin_validite']['checked'])) {
  1101. print '<td class="liste_titre center">';
  1102. print '<div class="nowrap">';
  1103. print $form->selectDate($search_date_end_start ? $search_date_end_start : -1, 'search_date_end_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From'));
  1104. print '</div>';
  1105. print '<div class="nowrap">';
  1106. print $form->selectDate($search_date_end_end ? $search_date_end_end : -1, 'search_date_end_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to'));
  1107. print '</div>';
  1108. print '</td>';
  1109. }
  1110. // Date delivery
  1111. if (!empty($arrayfields['p.date_livraison']['checked'])) {
  1112. print '<td class="liste_titre center">';
  1113. print '<div class="nowrap">';
  1114. print $form->selectDate($search_date_delivery_start ? $search_date_delivery_start : -1, 'search_date_delivery_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From'));
  1115. print '</div>';
  1116. print '<div class="nowrap">';
  1117. print $form->selectDate($search_date_delivery_end ? $search_date_delivery_end : -1, 'search_date_delivery_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From'));
  1118. print '</div>';
  1119. print '</td>';
  1120. }
  1121. // Date Signature
  1122. if (!empty($arrayfields['p.date_signature']['checked'])) {
  1123. print '<td class="liste_titre center">';
  1124. print '<div class="nowrap">';
  1125. print $form->selectDate($search_date_signature_start ? $search_date_signature_start : -1, 'search_date_signature_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From'));
  1126. print '</div>';
  1127. print '<div class="nowrap">';
  1128. print $form->selectDate($search_date_signature_end ? $search_date_signature_end : -1, 'search_date_signature_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From'));
  1129. print '</div>';
  1130. print '</td>';
  1131. }
  1132. // Availability
  1133. if (!empty($arrayfields['ava.rowid']['checked'])) {
  1134. print '<td class="liste_titre maxwidth100onsmartphone center">';
  1135. $form->selectAvailabilityDelay($search_availability, 'search_availability', '', 1);
  1136. print ajax_combobox('search_availability');
  1137. print '</td>';
  1138. }
  1139. // Shipping Method
  1140. if (!empty($arrayfields['p.fk_shipping_method']['checked'])) {
  1141. print '<td class="liste_titre">';
  1142. $form->selectShippingMethod($search_fk_shipping_method, 'search_fk_shipping_method', '', 1, '', 1);
  1143. print '</td>';
  1144. }
  1145. // Source - Input reason
  1146. if (!empty($arrayfields['p.fk_input_reason']['checked'])) {
  1147. print '<td class="liste_titre">';
  1148. $form->selectInputReason($search_fk_input_reason, 'search_fk_input_reason', '', 1, 'maxwidth125', 1);
  1149. print '</td>';
  1150. }
  1151. // Payment term
  1152. if (!empty($arrayfields['p.fk_cond_reglement']['checked'])) {
  1153. print '<td class="liste_titre">';
  1154. $form->select_conditions_paiements($search_fk_cond_reglement, 'search_fk_cond_reglement', 1, 1, 1);
  1155. print '</td>';
  1156. }
  1157. // Payment mode
  1158. if (!empty($arrayfields['p.fk_mode_reglement']['checked'])) {
  1159. print '<td class="liste_titre">';
  1160. $form->select_types_paiements($search_fk_mode_reglement, 'search_fk_mode_reglement', '', 0, 1, 1, 0, -1);
  1161. print '</td>';
  1162. }
  1163. if (!empty($arrayfields['p.total_ht']['checked'])) {
  1164. // Amount
  1165. print '<td class="liste_titre right">';
  1166. print '<input class="flat" type="text" size="5" name="search_montant_ht" value="'.dol_escape_htmltag($search_montant_ht).'">';
  1167. print '</td>';
  1168. }
  1169. if (!empty($arrayfields['p.total_tva']['checked'])) {
  1170. // Amount
  1171. print '<td class="liste_titre right">';
  1172. print '<input class="flat" type="text" size="5" name="search_montant_vat" value="'.dol_escape_htmltag($search_montant_vat).'">';
  1173. print '</td>';
  1174. }
  1175. if (!empty($arrayfields['p.total_ttc']['checked'])) {
  1176. // Amount
  1177. print '<td class="liste_titre right">';
  1178. print '<input class="flat" type="text" size="5" name="search_montant_ttc" value="'.dol_escape_htmltag($search_montant_ttc).'">';
  1179. print '</td>';
  1180. }
  1181. if (!empty($arrayfields['p.total_ht_invoiced']['checked'])) {
  1182. // Amount invoiced
  1183. print '<td class="liste_titre right">';
  1184. print '</td>';
  1185. }
  1186. if (!empty($arrayfields['p.total_invoiced']['checked'])) {
  1187. // Amount invoiced
  1188. print '<td class="liste_titre right">';
  1189. print '</td>';
  1190. }
  1191. if (!empty($arrayfields['p.multicurrency_code']['checked'])) {
  1192. // Currency
  1193. print '<td class="liste_titre">';
  1194. print $form->selectMultiCurrency($search_multicurrency_code, 'search_multicurrency_code', 1);
  1195. print '</td>';
  1196. }
  1197. if (!empty($arrayfields['p.multicurrency_tx']['checked'])) {
  1198. // Currency rate
  1199. print '<td class="liste_titre">';
  1200. print '<input class="flat" type="text" size="4" name="search_multicurrency_tx" value="'.dol_escape_htmltag($search_multicurrency_tx).'">';
  1201. print '</td>';
  1202. }
  1203. if (!empty($arrayfields['p.multicurrency_total_ht']['checked'])) {
  1204. // Amount
  1205. print '<td class="liste_titre right">';
  1206. print '<input class="flat" type="text" size="4" name="search_multicurrency_montant_ht" value="'.dol_escape_htmltag($search_multicurrency_montant_ht).'">';
  1207. print '</td>';
  1208. }
  1209. if (!empty($arrayfields['p.multicurrency_total_tva']['checked'])) {
  1210. // Amount
  1211. print '<td class="liste_titre right">';
  1212. print '<input class="flat" type="text" size="4" name="search_multicurrency_montant_vat" value="'.dol_escape_htmltag($search_multicurrency_montant_vat).'">';
  1213. print '</td>';
  1214. }
  1215. if (!empty($arrayfields['p.multicurrency_total_ttc']['checked'])) {
  1216. // Amount
  1217. print '<td class="liste_titre right">';
  1218. print '<input class="flat" type="text" size="4" name="search_multicurrency_montant_ttc" value="'.dol_escape_htmltag($search_multicurrency_montant_ttc).'">';
  1219. print '</td>';
  1220. }
  1221. if (!empty($arrayfields['p.multicurrency_total_ht_invoiced']['checked'])) {
  1222. // Amount invoiced
  1223. print '<td class="liste_titre right">';
  1224. print '</td>';
  1225. }
  1226. if (!empty($arrayfields['p.multicurrency_total_invoiced']['checked'])) {
  1227. // Amount invoiced
  1228. print '<td class="liste_titre right">';
  1229. print '</td>';
  1230. }
  1231. if (!empty($arrayfields['u.login']['checked'])) {
  1232. // Author
  1233. print '<td class="liste_titre" align="center">';
  1234. print '<input class="flat" size="4" type="text" name="search_login" value="'.dol_escape_htmltag($search_login).'">';
  1235. print '</td>';
  1236. }
  1237. if (!empty($arrayfields['sale_representative']['checked'])) {
  1238. print '<td class="liste_titre"></td>';
  1239. }
  1240. if (!empty($arrayfields['total_pa']['checked'])) {
  1241. print '<td class="liste_titre right">';
  1242. print '</td>';
  1243. }
  1244. if (!empty($arrayfields['total_margin']['checked'])) {
  1245. print '<td class="liste_titre right">';
  1246. print '</td>';
  1247. }
  1248. if (!empty($arrayfields['total_margin_rate']['checked'])) {
  1249. print '<td class="liste_titre right">';
  1250. print '</td>';
  1251. }
  1252. if (!empty($arrayfields['total_mark_rate']['checked'])) {
  1253. print '<td class="liste_titre right">';
  1254. print '</td>';
  1255. }
  1256. // Extra fields
  1257. include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php';
  1258. // Fields from hook
  1259. $parameters = array('arrayfields'=>$arrayfields);
  1260. $reshook = $hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook
  1261. print $hookmanager->resPrint;
  1262. // Date creation
  1263. if (!empty($arrayfields['p.datec']['checked'])) {
  1264. print '<td class="liste_titre">';
  1265. print '</td>';
  1266. }
  1267. // Date modification
  1268. if (!empty($arrayfields['p.tms']['checked'])) {
  1269. print '<td class="liste_titre">';
  1270. print '</td>';
  1271. }
  1272. // Date cloture
  1273. if (!empty($arrayfields['p.date_cloture']['checked'])) {
  1274. print '<td class="liste_titre">';
  1275. print '</td>';
  1276. }
  1277. if (!empty($arrayfields['p.note_public']['checked'])) {
  1278. // Note public
  1279. print '<td class="liste_titre">';
  1280. print '</td>';
  1281. }
  1282. if (!empty($arrayfields['p.note_private']['checked'])) {
  1283. // Note private
  1284. print '<td class="liste_titre">';
  1285. print '</td>';
  1286. }
  1287. // Status
  1288. if (!empty($arrayfields['p.fk_statut']['checked'])) {
  1289. print '<td class="liste_titre maxwidthonsmartphone right">';
  1290. $formpropal->selectProposalStatus($search_status, 1, 0, 1, 'customer', 'search_statut');
  1291. print '</td>';
  1292. }
  1293. // Action column
  1294. print '<td class="liste_titre" align="middle">';
  1295. $searchpicto = $form->showFilterButtons();
  1296. print $searchpicto;
  1297. print '</td>';
  1298. print "</tr>\n";
  1299. $totalarray = array(
  1300. 'nbfield' => 0,
  1301. 'val' => array(
  1302. 'p.total_ht' => 0,
  1303. 'p.total_tva' => 0,
  1304. 'p.total_ttc' => 0,
  1305. ),
  1306. );
  1307. // Fields title
  1308. print '<tr class="liste_titre">';
  1309. if (!empty($arrayfields['p.ref']['checked'])) {
  1310. print_liste_field_titre($arrayfields['p.ref']['label'], $_SERVER["PHP_SELF"], 'p.ref', '', $param, '', $sortfield, $sortorder);
  1311. }
  1312. if (!empty($arrayfields['p.ref_client']['checked'])) {
  1313. print_liste_field_titre($arrayfields['p.ref_client']['label'], $_SERVER["PHP_SELF"], 'p.ref_client', '', $param, '', $sortfield, $sortorder);
  1314. }
  1315. if (!empty($arrayfields['pr.ref']['checked'])) {
  1316. print_liste_field_titre($arrayfields['pr.ref']['label'], $_SERVER["PHP_SELF"], 'pr.ref', '', $param, '', $sortfield, $sortorder);
  1317. }
  1318. if (!empty($arrayfields['pr.title']['checked'])) {
  1319. print_liste_field_titre($arrayfields['pr.title']['label'], $_SERVER["PHP_SELF"], 'pr.title', '', $param, '', $sortfield, $sortorder);
  1320. }
  1321. if (!empty($arrayfields['s.nom']['checked'])) {
  1322. print_liste_field_titre($arrayfields['s.nom']['label'], $_SERVER["PHP_SELF"], 's.nom', '', $param, '', $sortfield, $sortorder);
  1323. }
  1324. if (!empty($arrayfields['s.name_alias']['checked'])) {
  1325. print_liste_field_titre($arrayfields['s.name_alias']['label'], $_SERVER["PHP_SELF"], 's.name_alias', '', $param, '', $sortfield, $sortorder);
  1326. }
  1327. if (!empty($arrayfields['s.town']['checked'])) {
  1328. print_liste_field_titre($arrayfields['s.town']['label'], $_SERVER["PHP_SELF"], 's.town', '', $param, '', $sortfield, $sortorder);
  1329. }
  1330. if (!empty($arrayfields['s.zip']['checked'])) {
  1331. print_liste_field_titre($arrayfields['s.zip']['label'], $_SERVER["PHP_SELF"], 's.zip', '', $param, '', $sortfield, $sortorder);
  1332. }
  1333. if (!empty($arrayfields['state.nom']['checked'])) {
  1334. print_liste_field_titre($arrayfields['state.nom']['label'], $_SERVER["PHP_SELF"], "state.nom", "", $param, '', $sortfield, $sortorder);
  1335. }
  1336. if (!empty($arrayfields['country.code_iso']['checked'])) {
  1337. print_liste_field_titre($arrayfields['country.code_iso']['label'], $_SERVER["PHP_SELF"], "country.code_iso", "", $param, 'align="center"', $sortfield, $sortorder);
  1338. }
  1339. if (!empty($arrayfields['typent.code']['checked'])) {
  1340. print_liste_field_titre($arrayfields['typent.code']['label'], $_SERVER["PHP_SELF"], "typent.code", "", $param, 'align="center"', $sortfield, $sortorder);
  1341. }
  1342. if (!empty($arrayfields['p.date']['checked'])) {
  1343. print_liste_field_titre($arrayfields['p.date']['label'], $_SERVER["PHP_SELF"], 'p.datep', '', $param, 'align="center"', $sortfield, $sortorder);
  1344. }
  1345. if (!empty($arrayfields['p.fin_validite']['checked'])) {
  1346. print_liste_field_titre($arrayfields['p.fin_validite']['label'], $_SERVER["PHP_SELF"], 'dfv', '', $param, 'align="center"', $sortfield, $sortorder);
  1347. }
  1348. if (!empty($arrayfields['p.date_livraison']['checked'])) {
  1349. print_liste_field_titre($arrayfields['p.date_livraison']['label'], $_SERVER["PHP_SELF"], 'p.date_livraison', '', $param, 'align="center"', $sortfield, $sortorder);
  1350. }
  1351. if (!empty($arrayfields['p.date_signature']['checked'])) {
  1352. print_liste_field_titre($arrayfields['p.date_signature']['label'], $_SERVER["PHP_SELF"], 'p.date_signature', '', $param, 'align="center"', $sortfield, $sortorder);
  1353. }
  1354. if (!empty($arrayfields['ava.rowid']['checked'])) {
  1355. print_liste_field_titre($arrayfields['ava.rowid']['label'], $_SERVER["PHP_SELF"], 'availability', '', $param, '', $sortfield, $sortorder);
  1356. }
  1357. if (!empty($arrayfields['p.fk_shipping_method']['checked'])) {
  1358. print_liste_field_titre($arrayfields['p.fk_shipping_method']['label'], $_SERVER["PHP_SELF"], "p.fk_shipping_method", "", $param, '', $sortfield, $sortorder);
  1359. }
  1360. if (!empty($arrayfields['p.fk_input_reason']['checked'])) {
  1361. print_liste_field_titre($arrayfields['p.fk_input_reason']['label'], $_SERVER["PHP_SELF"], "p.fk_input_reason", "", $param, '', $sortfield, $sortorder);
  1362. }
  1363. if (!empty($arrayfields['p.fk_cond_reglement']['checked'])) {
  1364. print_liste_field_titre($arrayfields['p.fk_cond_reglement']['label'], $_SERVER["PHP_SELF"], "p.fk_cond_reglement", "", $param, '', $sortfield, $sortorder);
  1365. }
  1366. if (!empty($arrayfields['p.fk_mode_reglement']['checked'])) {
  1367. print_liste_field_titre($arrayfields['p.fk_mode_reglement']['label'], $_SERVER["PHP_SELF"], "p.fk_mode_reglement", "", $param, '', $sortfield, $sortorder);
  1368. }
  1369. if (!empty($arrayfields['p.total_ht']['checked'])) {
  1370. print_liste_field_titre($arrayfields['p.total_ht']['label'], $_SERVER["PHP_SELF"], 'p.total_ht', '', $param, 'class="right"', $sortfield, $sortorder);
  1371. }
  1372. if (!empty($arrayfields['p.total_tva']['checked'])) {
  1373. print_liste_field_titre($arrayfields['p.total_tva']['label'], $_SERVER["PHP_SELF"], 'p.total_tva', '', $param, 'class="right"', $sortfield, $sortorder);
  1374. }
  1375. if (!empty($arrayfields['p.total_ttc']['checked'])) {
  1376. print_liste_field_titre($arrayfields['p.total_ttc']['label'], $_SERVER["PHP_SELF"], 'p.total_ttc', '', $param, 'class="right"', $sortfield, $sortorder);
  1377. }
  1378. if (!empty($arrayfields['p.total_ht_invoiced']['checked'])) {
  1379. print_liste_field_titre($arrayfields['p.total_ht_invoiced']['label'], $_SERVER["PHP_SELF"], '', '', $param, 'class="right"', $sortfield, $sortorder);
  1380. }
  1381. if (!empty($arrayfields['p.total_invoiced']['checked'])) {
  1382. print_liste_field_titre($arrayfields['p.total_invoiced']['label'], $_SERVER["PHP_SELF"], '', '', $param, 'class="right"', $sortfield, $sortorder);
  1383. }
  1384. if (!empty($arrayfields['p.multicurrency_code']['checked'])) {
  1385. print_liste_field_titre($arrayfields['p.multicurrency_code']['label'], $_SERVER['PHP_SELF'], 'p.multicurrency_code', '', $param, '', $sortfield, $sortorder);
  1386. }
  1387. if (!empty($arrayfields['p.multicurrency_tx']['checked'])) {
  1388. print_liste_field_titre($arrayfields['p.multicurrency_tx']['label'], $_SERVER['PHP_SELF'], 'p.multicurrency_tx', '', $param, '', $sortfield, $sortorder);
  1389. }
  1390. if (!empty($arrayfields['p.multicurrency_total_ht']['checked'])) {
  1391. print_liste_field_titre($arrayfields['p.multicurrency_total_ht']['label'], $_SERVER['PHP_SELF'], 'p.multicurrency_total_ht', '', $param, 'class="right"', $sortfield, $sortorder);
  1392. }
  1393. if (!empty($arrayfields['p.multicurrency_total_tva']['checked'])) {
  1394. print_liste_field_titre($arrayfields['p.multicurrency_total_tva']['label'], $_SERVER['PHP_SELF'], 'p.multicurrency_total_tva', '', $param, 'class="right"', $sortfield, $sortorder);
  1395. }
  1396. if (!empty($arrayfields['p.multicurrency_total_ttc']['checked'])) {
  1397. print_liste_field_titre($arrayfields['p.multicurrency_total_ttc']['label'], $_SERVER['PHP_SELF'], 'p.multicurrency_total_ttc', '', $param, 'class="right"', $sortfield, $sortorder);
  1398. }
  1399. if (!empty($arrayfields['p.multicurrency_total_ht_invoiced']['checked'])) {
  1400. print_liste_field_titre($arrayfields['p.multicurrency_total_ht_invoiced']['label'], $_SERVER["PHP_SELF"], '', '', $param, 'class="right"', $sortfield, $sortorder);
  1401. }
  1402. if (!empty($arrayfields['p.multicurrency_total_invoiced']['checked'])) {
  1403. print_liste_field_titre($arrayfields['p.multicurrency_total_invoiced']['label'], $_SERVER["PHP_SELF"], '', '', $param, 'class="right"', $sortfield, $sortorder);
  1404. }
  1405. if (!empty($arrayfields['u.login']['checked'])) {
  1406. print_liste_field_titre($arrayfields['u.login']['label'], $_SERVER["PHP_SELF"], 'u.login', '', $param, 'align="center"', $sortfield, $sortorder);
  1407. }
  1408. if (!empty($arrayfields['sale_representative']['checked'])) {
  1409. print_liste_field_titre($arrayfields['sale_representative']['label'], $_SERVER["PHP_SELF"], "", "", "$param", '', $sortfield, $sortorder);
  1410. }
  1411. if (!empty($arrayfields['total_pa']['checked'])) {
  1412. print_liste_field_titre($arrayfields['total_pa']['label'], $_SERVER['PHP_SELF'], '', '', $param, 'class="right"', $sortfield, $sortorder);
  1413. }
  1414. if (!empty($arrayfields['total_margin']['checked'])) {
  1415. print_liste_field_titre($arrayfields['total_margin']['label'], $_SERVER['PHP_SELF'], '', '', $param, 'class="right"', $sortfield, $sortorder);
  1416. }
  1417. if (!empty($arrayfields['total_margin_rate']['checked'])) {
  1418. print_liste_field_titre($arrayfields['total_margin_rate']['label'], $_SERVER['PHP_SELF'], '', '', $param, 'class="right"', $sortfield, $sortorder);
  1419. }
  1420. if (!empty($arrayfields['total_mark_rate']['checked'])) {
  1421. print_liste_field_titre($arrayfields['total_mark_rate']['label'], $_SERVER['PHP_SELF'], '', '', $param, 'class="right"', $sortfield, $sortorder);
  1422. }
  1423. // Extra fields
  1424. include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php';
  1425. // Hook fields
  1426. $parameters = array(
  1427. 'arrayfields' => $arrayfields,
  1428. 'param' => $param,
  1429. 'sortfield' => $sortfield,
  1430. 'sortorder' => $sortorder,
  1431. 'totalarray' => &$totalarray,
  1432. );
  1433. $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters); // Note that $action and $object may have been modified by hook
  1434. print $hookmanager->resPrint;
  1435. if (!empty($arrayfields['p.datec']['checked'])) {
  1436. print_liste_field_titre($arrayfields['p.datec']['label'], $_SERVER["PHP_SELF"], "p.datec", "", $param, 'align="center" class="nowrap"', $sortfield, $sortorder);
  1437. }
  1438. if (!empty($arrayfields['p.tms']['checked'])) {
  1439. print_liste_field_titre($arrayfields['p.tms']['label'], $_SERVER["PHP_SELF"], "p.tms", "", $param, 'align="center" class="nowrap"', $sortfield, $sortorder);
  1440. }
  1441. if (!empty($arrayfields['p.date_cloture']['checked'])) {
  1442. print_liste_field_titre($arrayfields['p.date_cloture']['label'], $_SERVER["PHP_SELF"], "p.date_cloture", "", $param, 'align="center" class="nowrap"', $sortfield, $sortorder);
  1443. }
  1444. if (!empty($arrayfields['p.note_public']['checked'])) {
  1445. print_liste_field_titre($arrayfields['p.note_public']['label'], $_SERVER["PHP_SELF"], "p.note_public", "", $param, '', $sortfield, $sortorder, 'center nowrap ');
  1446. }
  1447. if (!empty($arrayfields['p.note_private']['checked'])) {
  1448. print_liste_field_titre($arrayfields['p.note_private']['label'], $_SERVER["PHP_SELF"], "p.note_private", "", $param, '', $sortfield, $sortorder, 'center nowrap ');
  1449. }
  1450. if (!empty($arrayfields['p.fk_statut']['checked'])) {
  1451. print_liste_field_titre($arrayfields['p.fk_statut']['label'], $_SERVER["PHP_SELF"], "p.fk_statut", "", $param, 'class="right"', $sortfield, $sortorder);
  1452. }
  1453. print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', 'align="center"', $sortfield, $sortorder, 'maxwidthsearch ');
  1454. print '</tr>'."\n";
  1455. $now = dol_now();
  1456. $i = 0;
  1457. $typenArray = null;
  1458. $with_margin_info = false;
  1459. if (!empty($conf->margin->enabled) && (
  1460. !empty($arrayfields['total_pa']['checked'])
  1461. || !empty($arrayfields['total_margin']['checked'])
  1462. || !empty($arrayfields['total_margin_rate']['checked'])
  1463. || !empty($arrayfields['total_mark_rate']['checked'])
  1464. )
  1465. ) {
  1466. $with_margin_info = true;
  1467. }
  1468. $total_ht = 0;
  1469. $total_margin = 0;
  1470. $savnbfield = $totalarray['nbfield'];
  1471. $totalarray = array();
  1472. $totalarray['nbfield'] = 0;
  1473. $last_num = min($num, $limit);
  1474. while ($i < $last_num) {
  1475. $obj = $db->fetch_object($resql);
  1476. $objectstatic->id = $obj->rowid;
  1477. $objectstatic->ref = $obj->ref;
  1478. $objectstatic->ref_client = $obj->ref_client;
  1479. $objectstatic->note_public = $obj->note_public;
  1480. $objectstatic->note_private = $obj->note_private;
  1481. $objectstatic->statut = $obj->status;
  1482. $objectstatic->status = $obj->status;
  1483. $companystatic->id = $obj->socid;
  1484. $companystatic->name = $obj->name;
  1485. $companystatic->name_alias = $obj->alias;
  1486. $companystatic->client = $obj->client;
  1487. $companystatic->code_client = $obj->code_client;
  1488. $companystatic->email = $obj->email;
  1489. $companystatic->phone = $obj->phone;
  1490. $companystatic->address = $obj->address;
  1491. $companystatic->zip = $obj->zip;
  1492. $companystatic->town = $obj->town;
  1493. $companystatic->country_code = $obj->country_code;
  1494. $projectstatic->id = $obj->project_id;
  1495. $projectstatic->ref = $obj->project_ref;
  1496. $projectstatic->title = $obj->project_label;
  1497. $totalInvoicedHT = 0;
  1498. $totalInvoicedTTC = 0;
  1499. $multicurrency_totalInvoicedHT = 0;
  1500. $multicurrency_totalInvoicedTTC = 0;
  1501. $TInvoiceData = $objectstatic->InvoiceArrayList($obj->rowid);
  1502. if (!empty($TInvoiceData)) {
  1503. foreach ($TInvoiceData as $invoiceData) {
  1504. $invoice = new Facture($db);
  1505. $invoice->fetch($invoiceData->facid);
  1506. if (!empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS) && $invoice->type == Facture::TYPE_DEPOSIT) {
  1507. continue;
  1508. }
  1509. $totalInvoicedHT += $invoice->total_ht;
  1510. $totalInvoicedTTC += $invoice->total_ttc;
  1511. $multicurrency_totalInvoicedHT += $invoice->multicurrency_total_ht;
  1512. $multicurrency_totalInvoicedTTC += $invoice->multicurrency_total_ttc;
  1513. }
  1514. }
  1515. $marginInfo = array();
  1516. if ($with_margin_info === true) {
  1517. $objectstatic->fetch_lines();
  1518. $marginInfo = $formmargin->getMarginInfosArray($objectstatic);
  1519. $total_ht += $obj->total_ht;
  1520. $total_margin += $marginInfo['total_margin'];
  1521. }
  1522. print '<tr class="oddeven">';
  1523. if (!empty($arrayfields['p.ref']['checked'])) {
  1524. print '<td class="nowraponall">';
  1525. print '<table class="nobordernopadding"><tr class="nocellnopadd">';
  1526. // Picto + Ref
  1527. print '<td class="nobordernopadding nowraponall">';
  1528. print $objectstatic->getNomUrl(1, '', '', 0, 1, (isset($conf->global->PROPAL_LIST_SHOW_NOTES) ? $conf->global->PROPAL_LIST_SHOW_NOTES : 1));
  1529. print '</td>';
  1530. // Warning
  1531. $warnornote = '';
  1532. if ($obj->status == Propal::STATUS_VALIDATED && $db->jdate($obj->dfv) < ($now - $conf->propal->cloture->warning_delay)) {
  1533. $warnornote .= img_warning($langs->trans("Late"));
  1534. }
  1535. if ($warnornote) {
  1536. print '<td style="min-width: 20px" class="nobordernopadding nowrap">';
  1537. print $warnornote;
  1538. print '</td>';
  1539. }
  1540. // Other picto tool
  1541. print '<td width="16" class="nobordernopadding right">';
  1542. $filename = dol_sanitizeFileName($obj->ref);
  1543. $filedir = $conf->propal->multidir_output[$obj->propal_entity].'/'.dol_sanitizeFileName($obj->ref);
  1544. $urlsource = $_SERVER['PHP_SELF'].'?id='.$obj->rowid;
  1545. print $formfile->getDocumentsLink($objectstatic->element, $filename, $filedir);
  1546. print '</td></tr></table>';
  1547. print "</td>\n";
  1548. if (!$i) {
  1549. $totalarray['nbfield']++;
  1550. }
  1551. }
  1552. if (!empty($arrayfields['p.ref_client']['checked'])) {
  1553. // Customer ref
  1554. print '<td class="nowrap tdoverflowmax200">';
  1555. print $obj->ref_client;
  1556. print '</td>';
  1557. if (!$i) {
  1558. $totalarray['nbfield']++;
  1559. }
  1560. }
  1561. if (!empty($arrayfields['pr.ref']['checked'])) {
  1562. // Project ref
  1563. print '<td class="nowraponall">';
  1564. if ($obj->project_id > 0) {
  1565. print $projectstatic->getNomUrl(1);
  1566. }
  1567. print '</td>';
  1568. if (!$i) {
  1569. $totalarray['nbfield']++;
  1570. }
  1571. }
  1572. if (!empty($arrayfields['pr.title']['checked'])) {
  1573. // Project label
  1574. print '<td class="nowrap">';
  1575. if ($obj->project_id > 0) {
  1576. print $projectstatic->title;
  1577. }
  1578. print '</td>';
  1579. if (!$i) {
  1580. $totalarray['nbfield']++;
  1581. }
  1582. }
  1583. // Thirdparty
  1584. if (!empty($arrayfields['s.nom']['checked'])) {
  1585. print '<td class="tdoverflowmax150">';
  1586. print $companystatic->getNomUrl(1, 'customer');
  1587. print '</td>';
  1588. if (!$i) {
  1589. $totalarray['nbfield']++;
  1590. }
  1591. }
  1592. // Alias
  1593. if (!empty($arrayfields['s.name_alias']['checked'])) {
  1594. print '<td class="tdoverflowmax200">';
  1595. print $obj->alias;
  1596. print '</td>';
  1597. if (!$i) {
  1598. $totalarray['nbfield']++;
  1599. }
  1600. }
  1601. // Town
  1602. if (!empty($arrayfields['s.town']['checked'])) {
  1603. print '<td class="nocellnopadd">';
  1604. print $obj->town;
  1605. print '</td>';
  1606. if (!$i) {
  1607. $totalarray['nbfield']++;
  1608. }
  1609. }
  1610. // Zip
  1611. if (!empty($arrayfields['s.zip']['checked'])) {
  1612. print '<td class="nocellnopadd">';
  1613. print $obj->zip;
  1614. print '</td>';
  1615. if (!$i) {
  1616. $totalarray['nbfield']++;
  1617. }
  1618. }
  1619. // State
  1620. if (!empty($arrayfields['state.nom']['checked'])) {
  1621. print "<td>".$obj->state_name."</td>\n";
  1622. if (!$i) {
  1623. $totalarray['nbfield']++;
  1624. }
  1625. }
  1626. // Country
  1627. if (!empty($arrayfields['country.code_iso']['checked'])) {
  1628. print '<td class="center">';
  1629. $tmparray = getCountry($obj->fk_pays, 'all');
  1630. print $tmparray['label'];
  1631. print '</td>';
  1632. if (!$i) {
  1633. $totalarray['nbfield']++;
  1634. }
  1635. }
  1636. // Type ent
  1637. if (!empty($arrayfields['typent.code']['checked'])) {
  1638. if (!is_array($typenArray) || empty($typenArray)) {
  1639. $typenArray = $formcompany->typent_array(1);
  1640. }
  1641. print '<td class="center">';
  1642. print $typenArray[$obj->typent_code];
  1643. print '</td>';
  1644. if (!$i) {
  1645. $totalarray['nbfield']++;
  1646. }
  1647. }
  1648. // Date proposal
  1649. if (!empty($arrayfields['p.date']['checked'])) {
  1650. print '<td class="center">';
  1651. print dol_print_date($db->jdate($obj->dp), 'day');
  1652. print "</td>\n";
  1653. if (!$i) {
  1654. $totalarray['nbfield']++;
  1655. }
  1656. }
  1657. // Date end validity
  1658. if (!empty($arrayfields['p.fin_validite']['checked'])) {
  1659. if ($obj->dfv) {
  1660. print '<td class="center">'.dol_print_date($db->jdate($obj->dfv), 'day');
  1661. print '</td>';
  1662. } else {
  1663. print '<td>&nbsp;</td>';
  1664. }
  1665. if (!$i) {
  1666. $totalarray['nbfield']++;
  1667. }
  1668. }
  1669. // Date delivery
  1670. if (!empty($arrayfields['p.date_livraison']['checked'])) {
  1671. if ($obj->ddelivery) {
  1672. print '<td class="center">'.dol_print_date($db->jdate($obj->ddelivery), 'day');
  1673. print '</td>';
  1674. } else {
  1675. print '<td>&nbsp;</td>';
  1676. }
  1677. if (!$i) {
  1678. $totalarray['nbfield']++;
  1679. }
  1680. }
  1681. // Date Signature
  1682. if (!empty($arrayfields['p.date_signature']['checked'])) {
  1683. if ($obj->dsignature) {
  1684. print '<td class="center">'.dol_print_date($db->jdate($obj->dsignature), 'day');
  1685. print '</td>';
  1686. } else {
  1687. print '<td>&nbsp;</td>';
  1688. }
  1689. if (!$i) {
  1690. $totalarray['nbfield']++;
  1691. }
  1692. }
  1693. // Availability
  1694. if (!empty($arrayfields['ava.rowid']['checked'])) {
  1695. print '<td class="center">';
  1696. $form->form_availability('', $obj->availability, 'none', 1);
  1697. print '</td>';
  1698. if (!$i) {
  1699. $totalarray['nbfield']++;
  1700. }
  1701. }
  1702. // Shipping Method
  1703. if (!empty($arrayfields['p.fk_shipping_method']['checked'])) {
  1704. print '<td>';
  1705. $form->formSelectShippingMethod('', $obj->fk_shipping_method, 'none', 1);
  1706. print '</td>';
  1707. if (!$i) {
  1708. $totalarray['nbfield']++;
  1709. }
  1710. }
  1711. // Source - input reason
  1712. if (!empty($arrayfields['p.fk_input_reason']['checked'])) {
  1713. print '<td class="tdoverflowmax125" title="'.dol_escape_htmltag($form->cache_demand_reason[$obj->fk_input_reason]['label']).'">';
  1714. if ($obj->fk_input_reason > 0) {
  1715. print $form->cache_demand_reason[$obj->fk_input_reason]['label'];
  1716. }
  1717. print '</td>';
  1718. if (!$i) {
  1719. $totalarray['nbfield']++;
  1720. }
  1721. }
  1722. // Payment terms
  1723. if (!empty($arrayfields['p.fk_cond_reglement']['checked'])) {
  1724. print '<td>';
  1725. $form->form_conditions_reglement($_SERVER['PHP_SELF'], $obj->fk_cond_reglement, 'none', 0, '', 1, $obj->deposit_percent);
  1726. print '</td>';
  1727. if (!$i) {
  1728. $totalarray['nbfield']++;
  1729. }
  1730. }
  1731. // Payment mode
  1732. if (!empty($arrayfields['p.fk_mode_reglement']['checked'])) {
  1733. print '<td>';
  1734. $form->form_modes_reglement($_SERVER['PHP_SELF'], $obj->fk_mode_reglement, 'none', '', -1);
  1735. print '</td>';
  1736. if (!$i) {
  1737. $totalarray['nbfield']++;
  1738. }
  1739. }
  1740. // Amount HT
  1741. if (!empty($arrayfields['p.total_ht']['checked'])) {
  1742. print '<td class="nowrap right"><span class="amount">'.price($obj->total_ht)."</span></td>\n";
  1743. if (!$i) {
  1744. $totalarray['nbfield']++;
  1745. }
  1746. if (!$i) {
  1747. $totalarray['pos'][$totalarray['nbfield']] = 'p.total_ht';
  1748. }
  1749. $totalarray['val']['p.total_ht'] += $obj->total_ht;
  1750. }
  1751. // Amount VAT
  1752. if (!empty($arrayfields['p.total_tva']['checked'])) {
  1753. print '<td class="nowrap right"><span class="amount">'.price($obj->total_tva)."</span></td>\n";
  1754. if (!$i) {
  1755. $totalarray['nbfield']++;
  1756. }
  1757. if (!$i) {
  1758. $totalarray['pos'][$totalarray['nbfield']] = 'p.total_tva';
  1759. }
  1760. $totalarray['val']['p.total_tva'] += $obj->total_tva;
  1761. }
  1762. // Amount TTC
  1763. if (!empty($arrayfields['p.total_ttc']['checked'])) {
  1764. print '<td class="nowrap right"><span class="amount">'.price($obj->total_ttc)."</span></td>\n";
  1765. if (!$i) {
  1766. $totalarray['nbfield']++;
  1767. }
  1768. if (!$i) {
  1769. $totalarray['pos'][$totalarray['nbfield']] = 'p.total_ttc';
  1770. }
  1771. $totalarray['val']['p.total_ttc'] += $obj->total_ttc;
  1772. }
  1773. // Amount invoiced HT
  1774. if (!empty($arrayfields['p.total_ht_invoiced']['checked'])) {
  1775. print '<td class="nowrap right"><span class="amount">'.price($totalInvoicedHT)."</span></td>\n";
  1776. if (!$i) {
  1777. $totalarray['nbfield']++;
  1778. }
  1779. if (!$i) {
  1780. $totalarray['pos'][$totalarray['nbfield']] = 'p.total_ht_invoiced';
  1781. }
  1782. $totalarray['val']['p.total_ht_invoiced'] += $totalInvoicedHT;
  1783. }
  1784. // Amount invoiced TTC
  1785. if (!empty($arrayfields['p.total_invoiced']['checked'])) {
  1786. print '<td class="nowrap right"><span class="amount">'.price($totalInvoicedTTC)."</span></td>\n";
  1787. if (!$i) {
  1788. $totalarray['nbfield']++;
  1789. }
  1790. if (!$i) {
  1791. $totalarray['pos'][$totalarray['nbfield']] = 'p.total_invoiced';
  1792. }
  1793. $totalarray['val']['p.total_invoiced'] += $totalInvoicedTTC;
  1794. }
  1795. // Currency
  1796. if (!empty($arrayfields['p.multicurrency_code']['checked'])) {
  1797. print '<td class="nowrap">'.$obj->multicurrency_code.' - '.$langs->trans('Currency'.$obj->multicurrency_code)."</td>\n";
  1798. if (!$i) {
  1799. $totalarray['nbfield']++;
  1800. }
  1801. }
  1802. // Currency rate
  1803. if (!empty($arrayfields['p.multicurrency_tx']['checked'])) {
  1804. print '<td class="nowrap">';
  1805. $form->form_multicurrency_rate($_SERVER['PHP_SELF'].'?id='.$obj->rowid, $obj->multicurrency_tx, 'none', $obj->multicurrency_code);
  1806. print "</td>\n";
  1807. if (!$i) {
  1808. $totalarray['nbfield']++;
  1809. }
  1810. }
  1811. // Amount HT
  1812. if (!empty($arrayfields['p.multicurrency_total_ht']['checked'])) {
  1813. print '<td class="right nowrap"><span class="amount">'.price($obj->multicurrency_total_ht)."</span></td>\n";
  1814. if (!$i) {
  1815. $totalarray['nbfield']++;
  1816. }
  1817. }
  1818. // Amount VAT
  1819. if (!empty($arrayfields['p.multicurrency_total_tva']['checked'])) {
  1820. print '<td class="right nowrap"><span class="amount">'.price($obj->multicurrency_total_tva)."</span></td>\n";
  1821. if (!$i) {
  1822. $totalarray['nbfield']++;
  1823. }
  1824. }
  1825. // Amount TTC
  1826. if (!empty($arrayfields['p.multicurrency_total_ttc']['checked'])) {
  1827. print '<td class="right nowrap"><span class="amount">'.price($obj->multicurrency_total_ttc)."</span></td>\n";
  1828. if (!$i) {
  1829. $totalarray['nbfield']++;
  1830. }
  1831. }
  1832. // Amount invoiced
  1833. if (!empty($arrayfields['p.multicurrency_total_ht_invoiced']['checked'])) {
  1834. print '<td class="nowrap right"><span class="amount">'.price($multicurrency_totalInvoicedHT)."</span></td>\n";
  1835. if (!$i) {
  1836. $totalarray['nbfield']++;
  1837. }
  1838. }
  1839. // Amount invoiced
  1840. if (!empty($arrayfields['p.multicurrency_total_invoiced']['checked'])) {
  1841. print '<td class="nowrap right"><span class="amount">'.price($multicurrency_totalInvoicedTTC)."</span></td>\n";
  1842. if (!$i) {
  1843. $totalarray['nbfield']++;
  1844. }
  1845. }
  1846. $userstatic->id = $obj->fk_user_author;
  1847. $userstatic->login = $obj->login;
  1848. $userstatic->lastname = $obj->lastname;
  1849. $userstatic->firstname = $obj->firstname;
  1850. $userstatic->email = $obj->user_email;
  1851. $userstatic->statut = $obj->user_statut;
  1852. $userstatic->entity = $obj->user_entity;
  1853. $userstatic->photo = $obj->photo;
  1854. $userstatic->office_phone = $obj->office_phone;
  1855. $userstatic->office_fax = $obj->office_fax;
  1856. $userstatic->user_mobile = $obj->user_mobile;
  1857. $userstatic->job = $obj->job;
  1858. $userstatic->gender = $obj->gender;
  1859. // Author
  1860. if (!empty($arrayfields['u.login']['checked'])) {
  1861. print '<td class="tdoverflowmax150">';
  1862. if ($userstatic->id) {
  1863. print $userstatic->getNomUrl(-1);
  1864. }
  1865. print "</td>\n";
  1866. if (!$i) {
  1867. $totalarray['nbfield']++;
  1868. }
  1869. }
  1870. if (!empty($arrayfields['sale_representative']['checked'])) {
  1871. // Sales representatives
  1872. print '<td class="tdoverflowmax150">';
  1873. if ($obj->socid > 0) {
  1874. $listsalesrepresentatives = $companystatic->getSalesRepresentatives($user);
  1875. if ($listsalesrepresentatives < 0) {
  1876. dol_print_error($db);
  1877. }
  1878. $nbofsalesrepresentative = count($listsalesrepresentatives);
  1879. if ($nbofsalesrepresentative > 6) {
  1880. // We print only number
  1881. print $nbofsalesrepresentative;
  1882. } elseif ($nbofsalesrepresentative > 0) {
  1883. $userstatic = new User($db);
  1884. $j = 0;
  1885. foreach ($listsalesrepresentatives as $val) {
  1886. $userstatic->id = $val['id'];
  1887. $userstatic->lastname = $val['lastname'];
  1888. $userstatic->firstname = $val['firstname'];
  1889. $userstatic->email = $val['email'];
  1890. $userstatic->statut = $val['statut'];
  1891. $userstatic->entity = $val['entity'];
  1892. $userstatic->photo = $val['photo'];
  1893. $userstatic->login = $val['login'];
  1894. $userstatic->office_phone = $val['office_phone'];
  1895. $userstatic->office_fax = $val['office_fax'];
  1896. $userstatic->user_mobile = $val['user_mobile'];
  1897. $userstatic->job = $val['job'];
  1898. $userstatic->gender = $val['gender'];
  1899. //print '<div class="float">':
  1900. print ($nbofsalesrepresentative < 2) ? $userstatic->getNomUrl(-1, '', 0, 0, 12) : $userstatic->getNomUrl(-2);
  1901. $j++;
  1902. if ($j < $nbofsalesrepresentative) {
  1903. print ' ';
  1904. }
  1905. //print '</div>';
  1906. }
  1907. }
  1908. //else print $langs->trans("NoSalesRepresentativeAffected");
  1909. } else {
  1910. print '&nbsp;';
  1911. }
  1912. print '</td>';
  1913. if (!$i) {
  1914. $totalarray['nbfield']++;
  1915. }
  1916. }
  1917. // Total buying or cost price
  1918. if (!empty($arrayfields['total_pa']['checked'])) {
  1919. print '<td class="right nowrap">'.price($marginInfo['pa_total']).'</td>';
  1920. if (!$i) {
  1921. $totalarray['nbfield']++;
  1922. }
  1923. }
  1924. // Total margin
  1925. if (!empty($arrayfields['total_margin']['checked'])) {
  1926. print '<td class="right nowrap">'.price($marginInfo['total_margin']).'</td>';
  1927. if (!$i) {
  1928. $totalarray['nbfield']++;
  1929. }
  1930. if (!$i) {
  1931. $totalarray['pos'][$totalarray['nbfield']] = 'total_margin';
  1932. }
  1933. $totalarray['val']['total_margin'] = $total_margin;
  1934. }
  1935. // Total margin rate
  1936. if (!empty($arrayfields['total_margin_rate']['checked'])) {
  1937. print '<td class="right nowrap">'.(($marginInfo['total_margin_rate'] == '') ? '' : price($marginInfo['total_margin_rate'], null, null, null, null, 2).'%').'</td>';
  1938. if (!$i) {
  1939. $totalarray['nbfield']++;
  1940. }
  1941. }
  1942. // Total mark rate
  1943. if (!empty($arrayfields['total_mark_rate']['checked'])) {
  1944. print '<td class="right nowrap">'.(($marginInfo['total_mark_rate'] == '') ? '' : price($marginInfo['total_mark_rate'], null, null, null, null, 2).'%').'</td>';
  1945. if (!$i) {
  1946. $totalarray['nbfield']++;
  1947. }
  1948. if (!$i) {
  1949. $totalarray['pos'][$totalarray['nbfield']] = 'total_mark_rate';
  1950. }
  1951. if ($i >= $last_num - 1) {
  1952. if (!empty($total_ht)) {
  1953. $totalarray['val']['total_mark_rate'] = price2num($total_margin * 100 / $total_ht, 'MT');
  1954. } else {
  1955. $totalarray['val']['total_mark_rate'] = '';
  1956. }
  1957. }
  1958. }
  1959. // Extra fields
  1960. include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php';
  1961. // Fields from hook
  1962. $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray);
  1963. $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook
  1964. print $hookmanager->resPrint;
  1965. // Date creation
  1966. if (!empty($arrayfields['p.datec']['checked'])) {
  1967. print '<td align="center" class="nowrap">';
  1968. print dol_print_date($db->jdate($obj->date_creation), 'dayhour', 'tzuser');
  1969. print '</td>';
  1970. if (!$i) {
  1971. $totalarray['nbfield']++;
  1972. }
  1973. }
  1974. // Date modification
  1975. if (!empty($arrayfields['p.tms']['checked'])) {
  1976. print '<td align="center" class="nowrap">';
  1977. print dol_print_date($db->jdate($obj->date_update), 'dayhour', 'tzuser');
  1978. print '</td>';
  1979. if (!$i) {
  1980. $totalarray['nbfield']++;
  1981. }
  1982. }
  1983. // Date cloture
  1984. if (!empty($arrayfields['p.date_cloture']['checked'])) {
  1985. print '<td align="center" class="nowrap">';
  1986. print dol_print_date($db->jdate($obj->date_cloture), 'dayhour', 'tzuser');
  1987. print '</td>';
  1988. if (!$i) {
  1989. $totalarray['nbfield']++;
  1990. }
  1991. }
  1992. // Note public
  1993. if (!empty($arrayfields['p.note_public']['checked'])) {
  1994. print '<td class="center">';
  1995. print dol_string_nohtmltag($obj->note_public);
  1996. print '</td>';
  1997. if (!$i) {
  1998. $totalarray['nbfield']++;
  1999. }
  2000. }
  2001. // Note private
  2002. if (!empty($arrayfields['p.note_private']['checked'])) {
  2003. print '<td class="center">';
  2004. print dol_string_nohtmltag($obj->note_private);
  2005. print '</td>';
  2006. if (!$i) {
  2007. $totalarray['nbfield']++;
  2008. }
  2009. }
  2010. // Status
  2011. if (!empty($arrayfields['p.fk_statut']['checked'])) {
  2012. print '<td class="nowrap right">'.$objectstatic->getLibStatut(5).'</td>';
  2013. if (!$i) {
  2014. $totalarray['nbfield']++;
  2015. }
  2016. }
  2017. // Action column
  2018. print '<td class="nowrap" align="center">';
  2019. if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
  2020. $selected = 0;
  2021. if (in_array($obj->rowid, $arrayofselected)) {
  2022. $selected = 1;
  2023. }
  2024. print '<input id="cb'.$obj->rowid.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.'"'.($selected ? ' checked="checked"' : '').'>';
  2025. }
  2026. print '</td>';
  2027. if (!$i) {
  2028. $totalarray['nbfield']++;
  2029. }
  2030. print '</tr>'."\n";
  2031. $i++;
  2032. }
  2033. // Show total line
  2034. include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php';
  2035. // If no record found
  2036. if ($num == 0) {
  2037. $colspan = 1;
  2038. foreach ($arrayfields as $key => $val) {
  2039. if (!empty($val['checked'])) {
  2040. $colspan++;
  2041. }
  2042. }
  2043. print '<tr><td colspan="'.$colspan.'"><span class="opacitymedium">'.$langs->trans("NoRecordFound").'</span></td></tr>';
  2044. }
  2045. $db->free($resql);
  2046. $parameters = array('arrayfields'=>$arrayfields, 'sql'=>$sql);
  2047. $reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters); // Note that $action and $object may have been modified by hook
  2048. print $hookmanager->resPrint;
  2049. print '</table>'."\n";
  2050. print '</div>'."\n";
  2051. print '</form>'."\n";
  2052. $hidegeneratedfilelistifempty = 1;
  2053. if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) {
  2054. $hidegeneratedfilelistifempty = 0;
  2055. }
  2056. // Show list of available documents
  2057. $urlsource = $_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder;
  2058. $urlsource .= str_replace('&amp;', '&', $param);
  2059. $filedir = $diroutputmassaction;
  2060. $genallowed = $user->rights->propal->lire;
  2061. $delallowed = $user->rights->propal->creer;
  2062. print $formfile->showdocuments('massfilesarea_proposals', '', $filedir, $urlsource, 0, $delallowed, '', 1, 1, 0, 48, 1, $param, $title, '', '', '', null, $hidegeneratedfilelistifempty);
  2063. } else {
  2064. dol_print_error($db);
  2065. }
  2066. // End of page
  2067. llxFooter();
  2068. $db->close();