list.php 89 KB

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