list.php 79 KB

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