list.php 89 KB

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