list.php 92 KB

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