list.php 87 KB

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