list.php 77 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932
  1. <?php
  2. /* Copyright (C) 2001-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
  3. * Copyright (C) 2004-2019 Laurent Destailleur <eldy@users.sourceforge.net>
  4. * Copyright (C) 2005 Marc Bariley / Ocebo <marc@ocebo.com>
  5. * Copyright (C) 2005-2010 Regis Houssin <regis.houssin@inodbox.com>
  6. * Copyright (C) 2013 Cédric Salvador <csalvador@gpcsolutions.fr>
  7. * Copyright (C) 2015 Claudio Aschieri <c.aschieri@19.coop>
  8. * Copyright (C) 2018 Ferran Marcet <fmarcet@2byte.es>
  9. * Copyright (C) 2019 Juanjo Menent <jmenent@2byte.es>
  10. * Copyright (C) 2020 Tobias Sean <tobias.sekan@startmail.com>
  11. *
  12. * This program is free software; you can redistribute it and/or modify
  13. * it under the terms of the GNU General Public License as published by
  14. * the Free Software Foundation; either version 3 of the License, or
  15. * (at your option) any later version.
  16. *
  17. * This program is distributed in the hope that it will be useful,
  18. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  19. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  20. * GNU General Public License for more details.
  21. *
  22. * You should have received a copy of the GNU General Public License
  23. * along with this program. If not, see <https://www.gnu.org/licenses/>.
  24. */
  25. /**
  26. * \file htdocs/projet/list.php
  27. * \ingroup project
  28. * \brief Page to list projects
  29. */
  30. // Load Dolibarr environment
  31. require '../main.inc.php';
  32. require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
  33. require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
  34. require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
  35. require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php';
  36. require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
  37. require_once DOL_DOCUMENT_ROOT.'/projet/class/task.class.php';
  38. if (isModEnabled('categorie')) {
  39. require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcategory.class.php';
  40. require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
  41. }
  42. // Load translation files required by the page
  43. $langs->loadLangs(array('projects', 'companies', 'commercial'));
  44. if (isModEnabled('eventorganization') && $conf->eventorganization->enabled) {
  45. $langs->loadLangs(array('eventorganization'));
  46. }
  47. $action = GETPOST('action', 'aZ09');
  48. $massaction = GETPOST('massaction', 'alpha');
  49. $show_files = GETPOST('show_files', 'int');
  50. $confirm = GETPOST('confirm', 'alpha');
  51. $toselect = GETPOST('toselect', 'array');
  52. $optioncss = GETPOST('optioncss', 'alpha');
  53. $contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'projectlist';
  54. $mode = GETPOST('mode', 'alpha');
  55. $title = $langs->trans("Projects");
  56. // Security check
  57. $socid = GETPOST('socid', 'int');
  58. //if ($user->socid > 0) $socid = $user->socid; // For external user, no check is done on company because readability is managed by public status of project and assignement.
  59. if ($socid > 0) {
  60. $soc = new Societe($db);
  61. $soc->fetch($socid);
  62. $title .= ' (<a href="list.php">'.$soc->name.'</a>)';
  63. }
  64. if (!$user->rights->projet->lire) {
  65. accessforbidden();
  66. }
  67. $diroutputmassaction = $conf->project->dir_output.'/temp/massgeneration/'.$user->id;
  68. $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
  69. $sortfield = GETPOST('sortfield', 'aZ09comma');
  70. $sortorder = GETPOST('sortorder', 'aZ09comma');
  71. $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
  72. if (empty($page) || $page < 0 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha')) {
  73. // If $page is not defined, or '' or -1 or if we click on clear filters
  74. $page = 0;
  75. }
  76. if (!$sortfield) {
  77. $sortfield = "p.ref";
  78. }
  79. if (!$sortorder) {
  80. $sortorder = "ASC";
  81. }
  82. $offset = $limit * $page;
  83. $pageprev = $page - 1;
  84. $pagenext = $page + 1;
  85. $search_all = GETPOST('search_all', 'alphanohtml') ? GETPOST('search_all', 'alphanohtml') : GETPOST('sall', 'alphanohtml');
  86. $search_ref = GETPOST("search_ref", 'alpha');
  87. $search_label = GETPOST("search_label", 'alpha');
  88. $search_societe = GETPOST("search_societe", 'alpha');
  89. $search_societe_alias = GETPOST("search_societe_alias", 'alpha');
  90. $search_status = GETPOST("search_status", 'int');
  91. $search_opp_status = GETPOST("search_opp_status", 'alpha');
  92. $search_opp_percent = GETPOST("search_opp_percent", 'alpha');
  93. $search_opp_amount = GETPOST("search_opp_amount", 'alpha');
  94. $search_budget_amount = GETPOST("search_budget_amount", 'alpha');
  95. $search_public = GETPOST("search_public", 'int');
  96. $search_project_user = GETPOST('search_project_user', 'int');
  97. $search_project_contact = GETPOST('search_project_contact', 'int');
  98. $search_sale = GETPOST('search_sale', 'int');
  99. $search_usage_opportunity = GETPOST('search_usage_opportunity', 'int');
  100. $search_usage_task = GETPOST('search_usage_task', 'int');
  101. $search_usage_bill_time = GETPOST('search_usage_bill_time', 'int');
  102. $search_usage_event_organization = GETPOST('search_usage_event_organization', 'int');
  103. $search_accept_conference_suggestions = GETPOST('search_accept_conference_suggestions', 'int');
  104. $search_accept_booth_suggestions = GETPOST('search_accept_booth_suggestions', 'int');
  105. $search_price_registration = GETPOST("search_price_registration", 'alpha');
  106. $search_price_booth = GETPOST("search_price_booth", 'alpha');
  107. $search_login = GETPOST('search_login', 'alpha');
  108. $search_import_key = GETPOST('search_import_key', 'alpha');
  109. $searchCategoryCustomerOperator = 0;
  110. if (GETPOSTISSET('formfilteraction')) {
  111. $searchCategoryCustomerOperator = GETPOST('search_category_customer_operator', 'int');
  112. } elseif (!empty($conf->global->MAIN_SEARCH_CAT_OR_BY_DEFAULT)) {
  113. $searchCategoryCustomerOperator = $conf->global->MAIN_SEARCH_CAT_OR_BY_DEFAULT;
  114. }
  115. $searchCategoryCustomerList = GETPOST('search_category_customer_list', 'array');
  116. $mine = ((GETPOST('mode') == 'mine') ? 1 : 0);
  117. if ($mine) {
  118. $search_project_user = $user->id; $mine = 0;
  119. }
  120. $search_sday = GETPOST('search_sday', 'int');
  121. $search_smonth = GETPOST('search_smonth', 'int');
  122. $search_syear = GETPOST('search_syear', 'int');
  123. $search_eday = GETPOST('search_eday', 'int');
  124. $search_emonth = GETPOST('search_emonth', 'int');
  125. $search_eyear = GETPOST('search_eyear', 'int');
  126. $search_date_start_startmonth = GETPOST('search_date_start_startmonth', 'int');
  127. $search_date_start_startyear = GETPOST('search_date_start_startyear', 'int');
  128. $search_date_start_startday = GETPOST('search_date_start_startday', 'int');
  129. $search_date_start_start = dol_mktime(0, 0, 0, $search_date_start_startmonth, $search_date_start_startday, $search_date_start_startyear); // Use tzserver
  130. $search_date_start_endmonth = GETPOST('search_date_start_endmonth', 'int');
  131. $search_date_start_endyear = GETPOST('search_date_start_endyear', 'int');
  132. $search_date_start_endday = GETPOST('search_date_start_endday', 'int');
  133. $search_date_start_end = dol_mktime(23, 59, 59, $search_date_start_endmonth, $search_date_start_endday, $search_date_start_endyear); // Use tzserver
  134. $search_date_end_startmonth = GETPOST('search_date_end_startmonth', 'int');
  135. $search_date_end_startyear = GETPOST('search_date_end_startyear', 'int');
  136. $search_date_end_startday = GETPOST('search_date_end_startday', 'int');
  137. $search_date_end_start = dol_mktime(0, 0, 0, $search_date_end_startmonth, $search_date_end_startday, $search_date_end_startyear); // Use tzserver
  138. $search_date_end_endmonth = GETPOST('search_date_end_endmonth', 'int');
  139. $search_date_end_endyear = GETPOST('search_date_end_endyear', 'int');
  140. $search_date_end_endday = GETPOST('search_date_end_endday', 'int');
  141. $search_date_end_end = dol_mktime(23, 59, 59, $search_date_end_endmonth, $search_date_end_endday, $search_date_end_endyear); // Use tzserver
  142. if (isModEnabled('categorie')) {
  143. $search_category_array = GETPOST("search_category_".Categorie::TYPE_PROJECT."_list", "array");
  144. }
  145. if ($search_status == '') {
  146. $search_status = -1; // -1 or 1
  147. }
  148. // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
  149. $object = new Project($db);
  150. $hookmanager->initHooks(array('projectlist'));
  151. $extrafields = new ExtraFields($db);
  152. // fetch optionals attributes and labels
  153. $extrafields->fetch_name_optionals_label($object->table_element);
  154. $search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_');
  155. // List of fields to search into when doing a "search in all"
  156. $fieldstosearchall = array();
  157. foreach ($object->fields as $key => $val) {
  158. if (empty($val['searchall'])) {
  159. continue;
  160. }
  161. // Don't allow search in private notes for external users when doing "search in all"
  162. if (!empty($user->socid) && $key == "note_private") {
  163. continue;
  164. }
  165. $fieldstosearchall['p.'.$key] = $val['label'];
  166. }
  167. // Add name object fields to "search in all"
  168. $fieldstosearchall['s.nom'] = "ThirdPartyName";
  169. $fieldstosearchall['s.name_alias'] = "AliasNameShort";
  170. $fieldstosearchall['s.code_client'] = "CustomerCode";
  171. // Definition of array of fields for columns
  172. $arrayfields = array();
  173. foreach ($object->fields as $key => $val) {
  174. // If $val['visible']==0, then we never show the field
  175. if (!empty($val['visible'])) {
  176. $visible = dol_eval($val['visible'], 1, 1, '1');
  177. $arrayfields['p.'.$key] = array(
  178. 'label'=>$val['label'],
  179. 'checked'=>(($visible < 0) ? 0 : 1),
  180. 'enabled'=>($visible != 3 && dol_eval($val['enabled'], 1, 1, '1')),
  181. 'position'=>$val['position'],
  182. 'help'=> isset($val['help']) ? $val['help'] : ''
  183. );
  184. }
  185. }
  186. // Extra fields
  187. include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php';
  188. // Add non object fields to fields for list
  189. $arrayfields['s.nom'] = array('label'=>$langs->trans("ThirdParty"), 'checked'=>1, 'position'=>21, 'enabled'=>(!isModEnabled('societe') ? 0 : 1));
  190. $arrayfields['s.name_alias'] = array('label'=>"AliasNameShort", 'checked'=>0, 'position'=>22);
  191. $arrayfields['commercial'] = array('label'=>$langs->trans("SaleRepresentativesOfThirdParty"), 'checked'=>0, 'position'=>23);
  192. $arrayfields['c.assigned'] = array('label'=>$langs->trans("AssignedTo"), 'checked'=>1, 'position'=>120);
  193. $arrayfields['opp_weighted_amount'] = array('label'=>$langs->trans('OpportunityWeightedAmountShort'), 'checked'=>0, 'enabled'=>(empty($conf->global->PROJECT_USE_OPPORTUNITIES) ? 0 : 1), 'position'=>106);
  194. $arrayfields['u.login'] = array('label'=>"Author", 'checked'=>-1, 'position'=>165);
  195. // Force some fields according to search_usage filter...
  196. if (GETPOST('search_usage_opportunity')) {
  197. //$arrayfields['p.usage_opportunity']['visible'] = 1; // Not require, filter on search_opp_status is enough
  198. //$arrayfields['p.usage_opportunity']['checked'] = 1; // Not require, filter on search_opp_status is enough
  199. }
  200. if (GETPOST('search_usage_event_organization')) {
  201. $arrayfields['p.fk_opp_status']['enabled'] = 0;
  202. $arrayfields['p.opp_amount']['enabled'] = 0;
  203. $arrayfields['p.opp_percent']['enabled'] = 0;
  204. $arrayfields['opp_weighted_amount']['enabled'] = 0;
  205. $arrayfields['p.usage_organize_event']['visible'] = 1;
  206. $arrayfields['p.usage_organize_event']['checked'] = 1;
  207. }
  208. $object->fields = dol_sort_array($object->fields, 'position');
  209. $arrayfields = dol_sort_array($arrayfields, 'position');
  210. /*
  211. * Actions
  212. */
  213. if (GETPOST('cancel', 'alpha')) {
  214. $action = 'list';
  215. $massaction = '';
  216. }
  217. if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') {
  218. $massaction = '';
  219. }
  220. $parameters = array('socid'=>$socid);
  221. $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
  222. if ($reshook < 0) {
  223. setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
  224. }
  225. if (empty($reshook)) {
  226. // Selection of new fields
  227. include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
  228. // Purge search criteria
  229. 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
  230. $search_all = '';
  231. $search_ref = "";
  232. $search_label = "";
  233. $search_societe = "";
  234. $search_societe_alias = '';
  235. $search_status = -1;
  236. $search_opp_status = -1;
  237. $search_opp_amount = '';
  238. $search_opp_percent = '';
  239. $search_budget_amount = '';
  240. $search_public = "";
  241. $search_sale = "";
  242. $search_project_user = '';
  243. $search_project_contact = '';
  244. $search_sday = "";
  245. $search_smonth = "";
  246. $search_syear = "";
  247. $search_eday = "";
  248. $search_emonth = "";
  249. $search_eyear = "";
  250. $search_date_start_startmonth = "";
  251. $search_date_start_startyear = "";
  252. $search_date_start_startday = "";
  253. $search_date_start_start = "";
  254. $search_date_start_endmonth = "";
  255. $search_date_start_endyear = "";
  256. $search_date_start_endday = "";
  257. $search_date_start_end = "";
  258. $search_date_end_startmonth = "";
  259. $search_date_end_startyear = "";
  260. $search_date_end_startday = "";
  261. $search_date_end_start = "";
  262. $search_date_end_endmonth = "";
  263. $search_date_end_endyear = "";
  264. $search_date_end_endday = "";
  265. $search_date_end_end = "";
  266. $search_usage_opportunity = '';
  267. $search_usage_task = '';
  268. $search_usage_bill_time = '';
  269. $search_usage_event_organization = '';
  270. $search_accept_conference_suggestions = '';
  271. $search_accept_booth_suggestions = '';
  272. $search_price_registration = '';
  273. $search_price_booth = '';
  274. $search_login = '';
  275. $search_import_key = '';
  276. $toselect = array();
  277. $search_array_options = array();
  278. $search_category_array = array();
  279. }
  280. // Mass actions
  281. $objectclass = 'Project';
  282. $objectlabel = 'Project';
  283. $permissiontoread = $user->rights->projet->lire;
  284. $permissiontodelete = $user->rights->projet->supprimer;
  285. $permissiontoadd = $user->rights->projet->creer;
  286. $uploaddir = $conf->project->dir_output;
  287. include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';
  288. // Close records
  289. if (!$error && $massaction == 'close' && $user->rights->projet->creer) {
  290. $db->begin();
  291. $objecttmp = new $objectclass($db);
  292. $nbok = 0;
  293. foreach ($toselect as $toselectid) {
  294. $result = $objecttmp->fetch($toselectid);
  295. if ($result > 0) {
  296. $userWrite = $object->restrictedProjectArea($user, 'write');
  297. if ($userWrite > 0 && $objecttmp->statut == 1) {
  298. $result = $objecttmp->setClose($user);
  299. if ($result <= 0) {
  300. setEventMessages($objecttmp->error, $objecttmp->errors, 'errors');
  301. $error++;
  302. break;
  303. } else {
  304. $nbok++;
  305. }
  306. } elseif ($userWrite <= 0) {
  307. setEventMessages($langs->trans("DontHavePermissionForCloseProject", $objecttmp->ref), null, 'warnings');
  308. } else {
  309. setEventMessages($langs->trans("DontHaveTheValidateStatus", $objecttmp->ref), null, 'warnings');
  310. }
  311. } else {
  312. setEventMessages($objecttmp->error, $objecttmp->errors, 'errors');
  313. $error++;
  314. break;
  315. }
  316. }
  317. if (!$error) {
  318. if ($nbok > 1) {
  319. setEventMessages($langs->trans("RecordsClosed", $nbok), null, 'mesgs');
  320. } else {
  321. setEventMessages($langs->trans("RecordsClosed", $nbok), null, 'mesgs');
  322. }
  323. $db->commit();
  324. } else {
  325. $db->rollback();
  326. }
  327. }
  328. }
  329. /*
  330. * View
  331. */
  332. $form = new Form($db);
  333. $formcompany = new FormCompany($db);
  334. $now = dol_now();
  335. $companystatic = new Societe($db);
  336. $taskstatic = new Task($db);
  337. $formother = new FormOther($db);
  338. $formproject = new FormProjets($db);
  339. $userstatic = new User($db);
  340. $help_url = "EN:Module_Projects|FR:Module_Projets|ES:M&oacute;dulo_Proyectos";
  341. $title = $langs->trans("LeadsOrProjects");
  342. if (empty($conf->global->PROJECT_USE_OPPORTUNITIES)) {
  343. $title = $langs->trans("Projects");
  344. }
  345. if (isset($conf->global->PROJECT_USE_OPPORTUNITIES) && $conf->global->PROJECT_USE_OPPORTUNITIES == 2) { // 2 = leads only
  346. $title = $langs->trans("Leads");
  347. }
  348. $morejs = array();
  349. $morecss = array();
  350. // Get list of project id allowed to user (in a string list separated by comma)
  351. $projectsListId = '';
  352. if (empty($user->rights->projet->all->lire)) {
  353. $projectsListId = $object->getProjectsAuthorizedForUser($user, 0, 1, $socid);
  354. }
  355. // Get id of types of contacts for projects (This list never contains a lot of elements)
  356. $listofprojectcontacttype = array();
  357. $listofprojectcontacttypeexternal = array();
  358. $sql = "SELECT ctc.rowid, ctc.code, ctc.source FROM ".MAIN_DB_PREFIX."c_type_contact as ctc";
  359. $sql .= " WHERE ctc.element = '".$db->escape($object->element)."'";
  360. $resql = $db->query($sql);
  361. if ($resql) {
  362. while ($obj = $db->fetch_object($resql)) {
  363. if ($obj->source == 'internal') $listofprojectcontacttype[$obj->rowid] = $obj->code;
  364. else $listofprojectcontacttypeexternal[$obj->rowid] = $obj->code;
  365. }
  366. } else {
  367. dol_print_error($db);
  368. }
  369. if (count($listofprojectcontacttype) == 0) {
  370. $listofprojectcontacttype[0] = '0'; // To avoid sql syntax error if not found
  371. }
  372. if (count($listofprojectcontacttypeexternal) == 0) {
  373. $listofprojectcontacttypeexternal[0] = '0'; // To avoid sql syntax error if not found
  374. }
  375. $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
  376. $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields
  377. $distinct = 'DISTINCT'; // We add distinct until filter on contact of project or task is implemented with AND EXISTS
  378. $sql = "SELECT ".$distinct." p.rowid as id, p.ref, p.title, p.fk_statut as status, p.fk_opp_status, p.public, p.fk_user_creat,";
  379. $sql .= " p.datec as date_creation, p.dateo as date_start, p.datee as date_end, p.opp_amount, p.opp_percent, (p.opp_amount*p.opp_percent/100) as opp_weighted_amount, p.tms as date_update, p.budget_amount,";
  380. $sql .= " p.usage_opportunity, p.usage_task, p.usage_bill_time, p.usage_organize_event,";
  381. $sql .= " p.email_msgid, p.import_key,";
  382. $sql .= " p.accept_conference_suggestions, p.accept_booth_suggestions, p.price_registration, p.price_booth,";
  383. $sql .= " s.rowid as socid, s.nom as name, s.name_alias as alias, s.email, s.email, s.phone, s.fax, s.address, s.town, s.zip, s.fk_pays, s.client, s.code_client,";
  384. $sql .= " country.code as country_code,";
  385. $sql .= " cls.code as opp_status_code,";
  386. $sql .= ' u.login, u.lastname, u.firstname, u.email as user_email, u.statut as user_statut, u.entity, u.photo, u.office_phone, u.office_fax, u.user_mobile, u.job, u.gender';
  387. // Add fields from extrafields
  388. if (!empty($extrafields->attributes[$object->table_element]['label'])) {
  389. foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) {
  390. $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key." as options_".$key : '');
  391. }
  392. }
  393. // Add fields from hooks
  394. $parameters = array();
  395. $reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $object); // Note that $action and $object may have been modified by hook
  396. $sql .= $hookmanager->resPrint;
  397. $sql = preg_replace('/,\s*$/', '', $sql);
  398. $sqlfields = $sql; // $sql fields to remove for count total
  399. $sql .= " FROM ".MAIN_DB_PREFIX.$object->table_element." as p";
  400. if (!empty($extrafields->attributes[$object->table_element]['label']) &&is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) {
  401. $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (p.rowid = ef.fk_object)";
  402. }
  403. $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s on p.fk_soc = s.rowid";
  404. $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as country on (country.rowid = s.fk_pays)";
  405. $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_lead_status as cls on p.fk_opp_status = cls.rowid";
  406. $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'user AS u ON p.fk_user_creat = u.rowid';
  407. // We'll need this table joined to the select in order to filter by sale
  408. // No check is done on company permission because readability is managed by public status of project and assignement.
  409. //if ($search_sale > 0 || (! $user->rights->societe->client->voir && ! $socid)) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON sc.fk_soc = s.rowid";
  410. if ($search_sale > 0) {
  411. $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON sc.fk_soc = s.rowid";
  412. }
  413. if ($search_project_user > 0) {
  414. $sql .= ", ".MAIN_DB_PREFIX."element_contact as ecp";
  415. }
  416. if ($search_project_contact > 0) {
  417. $sql .= ", ".MAIN_DB_PREFIX."element_contact as ecp_contact";
  418. }
  419. $reshook = $hookmanager->executeHooks('printFieldListFrom', $parameters, $object); // Note that $action and $object may have been modified by hook
  420. $sql .= $hookmanager->resPrint;
  421. $sql .= " WHERE p.entity IN (".getEntity('project', (GETPOST('search_current_entity', 'int') ? 0 : 1)).')';
  422. if (empty($user->rights->projet->all->lire)) {
  423. $sql .= " AND p.rowid IN (".$db->sanitize($projectsListId).")"; // public and assigned to, or restricted to company for external users
  424. }
  425. // No need to check if company is external user, as filtering of projects must be done by getProjectsAuthorizedForUser
  426. if ($socid > 0) {
  427. $sql .= " AND (p.fk_soc = ".((int) $socid).")"; // This filter if when we use a hard coded filter on company on url (not related to filter for external users)
  428. }
  429. if ($search_ref) {
  430. $sql .= natural_search('p.ref', $search_ref);
  431. }
  432. if ($search_label) {
  433. $sql .= natural_search('p.title', $search_label);
  434. }
  435. if (empty($arrayfields['s.name_alias']['checked']) && $search_societe) {
  436. $sql .= natural_search(array("s.nom", "s.name_alias"), $search_societe);
  437. } else {
  438. if ($search_societe) {
  439. $sql .= natural_search('s.nom', $search_societe);
  440. }
  441. if ($search_societe_alias) {
  442. $sql .= natural_search('s.name_alias', $search_societe_alias);
  443. }
  444. }
  445. if ($search_opp_amount) {
  446. $sql .= natural_search('p.opp_amount', $search_opp_amount, 1);
  447. }
  448. if ($search_opp_percent) {
  449. $sql .= natural_search('p.opp_percent', $search_opp_percent, 1);
  450. }
  451. $sql .= dolSqlDateFilter('p.dateo', $search_sday, $search_smonth, $search_syear);
  452. $sql .= dolSqlDateFilter('p.datee', $search_eday, $search_emonth, $search_eyear);
  453. if ($search_date_start_start) {
  454. $sql .= " AND p.dateo >= '".$db->idate($search_date_start_start)."'";
  455. }
  456. if ($search_date_start_end) {
  457. $sql .= " AND p.dateo <= '".$db->idate($search_date_start_end)."'";
  458. }
  459. if ($search_date_end_start) {
  460. $sql .= " AND p.datee >= '".$db->idate($search_date_end_start)."'";
  461. }
  462. if ($search_date_end_end) {
  463. $sql .= " AND p.datee <= '".$db->idate($search_date_end_end)."'";
  464. }
  465. if ($search_all) {
  466. $sql .= natural_search(array_keys($fieldstosearchall), $search_all);
  467. }
  468. if ($search_status >= 0) {
  469. if ($search_status == 99) {
  470. $sql .= " AND p.fk_statut <> 2";
  471. } else {
  472. $sql .= " AND p.fk_statut = ".((int) $search_status);
  473. }
  474. }
  475. if ($search_opp_status) {
  476. if (is_numeric($search_opp_status) && $search_opp_status > 0) {
  477. $sql .= " AND p.fk_opp_status = ".((int) $search_opp_status);
  478. }
  479. if ($search_opp_status == 'all') {
  480. $sql .= " AND (p.fk_opp_status IS NOT NULL AND p.fk_opp_status <> -1)";
  481. }
  482. if ($search_opp_status == 'openedopp') {
  483. $sql .= " AND p.fk_opp_status IS NOT NULL AND p.fk_opp_status <> -1 AND p.fk_opp_status NOT IN (SELECT rowid FROM ".MAIN_DB_PREFIX."c_lead_status WHERE code IN ('WON','LOST'))";
  484. }
  485. if ($search_opp_status == 'notopenedopp') {
  486. $sql .= " AND (p.fk_opp_status IS NULL OR p.fk_opp_status = -1 OR p.fk_opp_status IN (SELECT rowid FROM ".MAIN_DB_PREFIX."c_lead_status WHERE code = 'WON'))";
  487. }
  488. if ($search_opp_status == 'none') {
  489. $sql .= " AND (p.fk_opp_status IS NULL OR p.fk_opp_status = -1)";
  490. }
  491. }
  492. if ($search_public != '') {
  493. $sql .= " AND p.public = ".((int) $search_public);
  494. }
  495. // For external user, no check is done on company permission because readability is managed by public status of project and assignement.
  496. //if ($socid > 0) $sql.= " AND s.rowid = ".((int) $socid);
  497. if ($search_sale > 0) {
  498. $sql .= " AND sc.fk_user = ".((int) $search_sale);
  499. }
  500. // No check is done on company permission because readability is managed by public status of project and assignement.
  501. //if (! $user->rights->societe->client->voir && ! $socid) $sql.= " AND ((s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id).") OR (s.rowid IS NULL))";
  502. if ($search_project_user > 0) {
  503. // TODO Replace this with a EXISTS and remove the link to table + DISTINCT
  504. $sql .= " AND ecp.fk_c_type_contact IN (".$db->sanitize(join(',', array_keys($listofprojectcontacttype))).") AND ecp.element_id = p.rowid AND ecp.fk_socpeople = ".((int) $search_project_user);
  505. }
  506. if ($search_project_contact > 0) {
  507. // TODO Replace this with a EXISTS and remove the link to table + DISTINCT
  508. $sql .= " AND ecp_contact.fk_c_type_contact IN (".$db->sanitize(join(',', array_keys($listofprojectcontacttypeexternal))).") AND ecp_contact.element_id = p.rowid AND ecp_contact.fk_socpeople = ".((int) $search_project_contact);
  509. }
  510. if ($search_opp_amount != '') {
  511. $sql .= natural_search('p.opp_amount', $search_opp_amount, 1);
  512. }
  513. if ($search_budget_amount != '') {
  514. $sql .= natural_search('p.budget_amount', $search_budget_amount, 1);
  515. }
  516. if ($search_usage_opportunity != '' && $search_usage_opportunity >= 0) {
  517. $sql .= natural_search('p.usage_opportunity', $search_usage_opportunity, 2);
  518. }
  519. if ($search_usage_task != '' && $search_usage_task >= 0) {
  520. $sql .= natural_search('p.usage_task', $search_usage_task, 2);
  521. }
  522. if ($search_usage_bill_time != '' && $search_usage_bill_time >= 0) {
  523. $sql .= natural_search('p.usage_bill_time', $search_usage_bill_time, 2);
  524. }
  525. if ($search_usage_event_organization != '' && $search_usage_event_organization >= 0) {
  526. $sql .= natural_search('p.usage_organize_event', $search_usage_event_organization, 2);
  527. }
  528. if ($search_accept_conference_suggestions != '' && $search_accept_conference_suggestions >= 0) {
  529. $sql .= natural_search('p.accept_conference_suggestions', $search_accept_conference_suggestions, 2);
  530. }
  531. if ($search_accept_booth_suggestions != '' && $search_accept_booth_suggestions >= 0) {
  532. $sql .= natural_search('p.accept_booth_suggestions', $search_accept_booth_suggestions, 2);
  533. }
  534. if ($search_price_registration != '') {
  535. $sql .= natural_search('p.price_registration', $search_price_registration, 1);
  536. }
  537. if ($search_price_booth != '') {
  538. $sql .= natural_search('p.price_booth', $search_price_booth, 1);
  539. }
  540. if ($search_login) {
  541. $sql .= natural_search(array('u.login', 'u.firstname', 'u.lastname'), $search_login);
  542. }
  543. if ($search_import_key) {
  544. $sql .= natural_search(array('p.import_key'), $search_import_key);
  545. }
  546. // Search for tag/category ($searchCategoryProjectList is an array of ID)
  547. $searchCategoryProjectList = $search_category_array;
  548. $searchCategoryProjectOperator = 0;
  549. if (!empty($searchCategoryProjectList)) {
  550. $searchCategoryProjectSqlList = array();
  551. $listofcategoryid = '';
  552. foreach ($searchCategoryProjectList as $searchCategoryProject) {
  553. if (intval($searchCategoryProject) == -2) {
  554. $searchCategoryProjectSqlList[] = "NOT EXISTS (SELECT ck.fk_project FROM ".MAIN_DB_PREFIX."categorie_project as ck WHERE p.rowid = ck.fk_project)";
  555. } elseif (intval($searchCategoryProject) > 0) {
  556. if ($searchCategoryProjectOperator == 0) {
  557. $searchCategoryProjectSqlList[] = " EXISTS (SELECT ck.fk_project FROM ".MAIN_DB_PREFIX."categorie_project as ck WHERE p.rowid = ck.fk_project AND ck.fk_categorie = ".((int) $searchCategoryProject).")";
  558. } else {
  559. $listofcategoryid .= ($listofcategoryid ? ', ' : '') .((int) $searchCategoryProject);
  560. }
  561. }
  562. }
  563. if ($listofcategoryid) {
  564. $searchCategoryProjectSqlList[] = " EXISTS (SELECT ck.fk_project FROM ".MAIN_DB_PREFIX."categorie_project as ck WHERE p.rowid = ck.fk_project AND ck.fk_categorie IN (".$db->sanitize($listofcategoryid)."))";
  565. }
  566. if ($searchCategoryProjectOperator == 1) {
  567. if (!empty($searchCategoryProjectSqlList)) {
  568. $sql .= " AND (".implode(' OR ', $searchCategoryProjectSqlList).")";
  569. }
  570. } else {
  571. if (!empty($searchCategoryProjectSqlList)) {
  572. $sql .= " AND (".implode(' AND ', $searchCategoryProjectSqlList).")";
  573. }
  574. }
  575. }
  576. $searchCategoryCustomerSqlList = array();
  577. if ($searchCategoryCustomerOperator == 1) {
  578. $existsCategoryCustomerList = array();
  579. foreach ($searchCategoryCustomerList as $searchCategoryCustomer) {
  580. if (intval($searchCategoryCustomer) == -2) {
  581. $sqlCategoryCustomerNotExists = " NOT EXISTS (";
  582. $sqlCategoryCustomerNotExists .= " SELECT cat_cus.fk_soc";
  583. $sqlCategoryCustomerNotExists .= " FROM ".$db->prefix()."categorie_societe AS cat_cus";
  584. $sqlCategoryCustomerNotExists .= " WHERE cat_cus.fk_soc = p.fk_soc";
  585. $sqlCategoryCustomerNotExists .= " )";
  586. $searchCategoryCustomerSqlList[] = $sqlCategoryCustomerNotExists;
  587. } elseif (intval($searchCategoryCustomer) > 0) {
  588. $existsCategoryCustomerList[] = $db->escape($searchCategoryCustomer);
  589. }
  590. }
  591. if (!empty($existsCategoryCustomerList)) {
  592. $sqlCategoryCustomerExists = " EXISTS (";
  593. $sqlCategoryCustomerExists .= " SELECT cat_cus.fk_soc";
  594. $sqlCategoryCustomerExists .= " FROM ".$db->prefix()."categorie_societe AS cat_cus";
  595. $sqlCategoryCustomerExists .= " WHERE cat_cus.fk_soc = p.fk_soc";
  596. $sqlCategoryCustomerExists .= " AND cat_cus.fk_categorie IN (".$db->sanitize(implode(',', $existsCategoryCustomerList)).")";
  597. $sqlCategoryCustomerExists .= " )";
  598. $searchCategoryCustomerSqlList[] = $sqlCategoryCustomerExists;
  599. }
  600. if (!empty($searchCategoryCustomerSqlList)) {
  601. $sql .= " AND (".implode(' OR ', $searchCategoryCustomerSqlList).")";
  602. }
  603. } else {
  604. foreach ($searchCategoryCustomerList as $searchCategoryCustomer) {
  605. if (intval($searchCategoryCustomer) == -2) {
  606. $sqlCategoryCustomerNotExists = " NOT EXISTS (";
  607. $sqlCategoryCustomerNotExists .= " SELECT cat_cus.fk_soc";
  608. $sqlCategoryCustomerNotExists .= " FROM ".$db->prefix()."categorie_societe AS cat_cus";
  609. $sqlCategoryCustomerNotExists .= " WHERE cat_cus.fk_soc = p.fk_soc";
  610. $sqlCategoryCustomerNotExists .= " )";
  611. $searchCategoryCustomerSqlList[] = $sqlCategoryCustomerNotExists;
  612. } elseif (intval($searchCategoryCustomer) > 0) {
  613. $searchCategoryCustomerSqlList[] = "p.fk_soc IN (SELECT fk_soc FROM ".$db->prefix()."categorie_societe WHERE fk_categorie = ".((int) $searchCategoryCustomer).")";
  614. }
  615. }
  616. if (!empty($searchCategoryCustomerSqlList)) {
  617. $sql .= " AND (".implode(' AND ', $searchCategoryCustomerSqlList).")";
  618. }
  619. }
  620. // Add where from extra fields
  621. include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php';
  622. // Add where from hooks
  623. $parameters = array();
  624. $reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters, $object); // Note that $action and $object may have been modified by hook
  625. $sql .= $hookmanager->resPrint;
  626. //print $sql;
  627. // Count total nb of records
  628. $nbtotalofrecords = '';
  629. if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
  630. /* The fast and low memory method to get and count full list converts the sql into a sql count */
  631. $sqlforcount = preg_replace('/^'.preg_quote($sqlfields, '/').'/', 'SELECT COUNT(*) as nbtotalofrecords', $sql);
  632. $sqlforcount = preg_replace('/GROUP BY .*$/', '', $sqlforcount);
  633. $resql = $db->query($sqlforcount);
  634. if ($resql) {
  635. $objforcount = $db->fetch_object($resql);
  636. $nbtotalofrecords = $objforcount->nbtotalofrecords;
  637. } else {
  638. dol_print_error($db);
  639. }
  640. if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller then paging size (filtering), goto and load page 0
  641. $page = 0;
  642. $offset = 0;
  643. }
  644. $db->free($resql);
  645. }
  646. // Complete request and execute it with limit
  647. $sql .= $db->order($sortfield, $sortorder);
  648. if ($limit) {
  649. $sql .= $db->plimit($limit + 1, $offset);
  650. }
  651. $resql = $db->query($sql);
  652. if (!$resql) {
  653. dol_print_error($db);
  654. exit;
  655. }
  656. $num = $db->num_rows($resql);
  657. // Direct jump if only one record found
  658. if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $search_all && !$page) {
  659. $obj = $db->fetch_object($resql);
  660. header("Location: ".DOL_URL_ROOT.'/projet/card.php?id='.$obj->id);
  661. exit;
  662. }
  663. // Output page
  664. // --------------------------------------------------------------------
  665. llxHeader('', $title, $help_url);
  666. $arrayofselected = is_array($toselect) ? $toselect : array();
  667. $param = '';
  668. if (!empty($mode)) {
  669. $param .= '&mode='.urlencode($mode);
  670. }
  671. if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
  672. $param .= '&contextpage='.urlencode($contextpage);
  673. }
  674. if ($limit > 0 && $limit != $conf->liste_limit) {
  675. $param .= '&limit='.((int) $limit);
  676. }
  677. if ($search_all != '') {
  678. $param .= '&search_all='.urlencode($search_all);
  679. }
  680. if ($search_sday) {
  681. $param .= '&search_sday='.urlencode($search_sday);
  682. }
  683. if ($search_smonth) {
  684. $param .= '&search_smonth='.urlencode($search_smonth);
  685. }
  686. if ($search_syear) {
  687. $param .= '&search_syear='.urlencode($search_syear);
  688. }
  689. if ($search_eday) {
  690. $param .= '&search_eday='.urlencode($search_eday);
  691. }
  692. if ($search_emonth) {
  693. $param .= '&search_emonth='.urlencode($search_emonth);
  694. }
  695. if ($search_eyear) {
  696. $param .= '&search_eyear='.urlencode($search_eyear);
  697. }
  698. if ($search_date_start_startmonth) {
  699. $param .= '&search_date_start_startmonth='.urlencode($search_date_start_startmonth);
  700. }
  701. if ($search_date_start_startyear) {
  702. $param .= '&search_date_start_startyear='.urlencode($search_date_start_startyear);
  703. }
  704. if ($search_date_start_startday) {
  705. $param .= '&search_date_start_startday='.urlencode($search_date_start_startday);
  706. }
  707. if ($search_date_start_start) {
  708. $param .= '&search_date_start_start='.urlencode($search_date_start_start);
  709. }
  710. if ($search_date_start_endmonth) {
  711. $param .= '&search_date_start_endmonth='.urlencode($search_date_start_endmonth);
  712. }
  713. if ($search_date_start_endyear) {
  714. $param .= '&search_date_start_endyear='.urlencode($search_date_start_endyear);
  715. }
  716. if ($search_date_start_endday) {
  717. $param .= '&search_date_start_endday='.urlencode($search_date_start_endday);
  718. }
  719. if ($search_date_start_end) {
  720. $param .= '&search_date_start_end='.urlencode($search_date_start_end);
  721. }
  722. if ($search_date_end_startmonth) {
  723. $param .= '&search_date_end_startmonth='.urlencode($search_date_end_startmonth);
  724. }
  725. if ($search_date_end_startyear) {
  726. $param .= '&search_date_end_startyear='.urlencode($search_date_end_startyear);
  727. }
  728. if ($search_date_end_startday) {
  729. $param .= '&search_date_end_startday='.urlencode($search_date_end_startday);
  730. }
  731. if ($search_date_end_start) {
  732. $param .= '&search_date_end_start='.urlencode($search_date_end_start);
  733. }
  734. if ($search_date_end_endmonth) {
  735. $param .= '&search_date_end_endmonth='.urlencode($search_date_end_endmonth);
  736. }
  737. if ($search_date_end_endyear) {
  738. $param .= '&search_date_end_endyear='.urlencode($search_date_end_endyear);
  739. }
  740. if ($search_date_end_endday) {
  741. $param .= '&search_date_end_endday='.urlencode($search_date_end_endday);
  742. }
  743. if ($search_date_end_end) {
  744. $param .= '&search_date_end_end=' . urlencode($search_date_end_end);
  745. }
  746. if ($socid) {
  747. $param .= '&socid='.urlencode($socid);
  748. }
  749. if (!empty($search_category_array)) {
  750. foreach ($search_category_array as $tmpval) {
  751. $param .= '&search_categegory_project_list[]='.urlencode($tmpval);
  752. }
  753. }
  754. if ($search_ref != '') {
  755. $param .= '&search_ref='.urlencode($search_ref);
  756. }
  757. if ($search_label != '') {
  758. $param .= '&search_label='.urlencode($search_label);
  759. }
  760. if ($search_societe != '') {
  761. $param .= '&search_societe='.urlencode($search_societe);
  762. }
  763. if ($search_societe_alias != '') {
  764. $param .= '&search_societe_alias='.urlencode($search_societe_alias);
  765. }
  766. if ($search_status >= 0) {
  767. $param .= '&search_status='.urlencode($search_status);
  768. }
  769. if ((is_numeric($search_opp_status) && $search_opp_status >= 0) || in_array($search_opp_status, array('all', 'openedopp', 'notopenedopp', 'none'))) {
  770. $param .= '&search_opp_status='.urlencode($search_opp_status);
  771. }
  772. if ($search_opp_percent != '') {
  773. $param .= '&search_opp_percent='.urlencode($search_opp_percent);
  774. }
  775. if ($search_public != '') {
  776. $param .= '&search_public='.urlencode($search_public);
  777. }
  778. if ($search_project_user > 0) {
  779. $param .= '&search_project_user='.urlencode($search_project_user);
  780. }
  781. if ($search_project_contact > 0) {
  782. $param .= '&search_project_contact='.urlencode($search_project_contact);
  783. }
  784. if ($search_sale > 0) {
  785. $param .= '&search_sale='.urlencode($search_sale);
  786. }
  787. if ($search_opp_amount != '') {
  788. $param .= '&search_opp_amount='.urlencode($search_opp_amount);
  789. }
  790. if ($search_budget_amount != '') {
  791. $param .= '&search_budget_amount='.urlencode($search_budget_amount);
  792. }
  793. if ($search_usage_task != '') {
  794. $param .= '&search_usage_task='.urlencode($search_usage_task);
  795. }
  796. if ($search_usage_bill_time != '') {
  797. $param .= '&search_usage_opportunity='.urlencode($search_usage_bill_time);
  798. }
  799. if ($search_usage_event_organization != '') {
  800. $param .= '&search_usage_event_organization='.urlencode($search_usage_event_organization);
  801. }
  802. if ($search_accept_conference_suggestions != '') {
  803. $param .= '&search_accept_conference_suggestions='.urlencode($search_accept_conference_suggestions);
  804. }
  805. if ($search_accept_booth_suggestions != '') {
  806. $param .= '&search_accept_booth_suggestions='.urlencode($search_accept_booth_suggestions);
  807. }
  808. if ($search_price_registration != '') {
  809. $param .= '&search_price_registration='.urlencode($search_price_registration);
  810. }
  811. if ($search_price_booth != '') {
  812. $param .= '&search_price_booth='.urlencode($search_price_booth);
  813. }
  814. if ($search_login) {
  815. $param .= '&search_login='.urlencode($search_login);
  816. }
  817. if ($search_import_key) {
  818. $param .= '&search_import_key='.urlencode($search_import_key);
  819. }
  820. if ($optioncss != '') {
  821. $param .= '&optioncss='.urlencode($optioncss);
  822. }
  823. foreach ($searchCategoryCustomerList as $searchCategoryCustomer) {
  824. $param .= "&search_category_customer_list[]=".urlencode($searchCategoryCustomer);
  825. }
  826. // Add $param from extra fields
  827. include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
  828. // List of mass actions available
  829. $arrayofmassactions = array(
  830. 'validate'=>img_picto('', 'check', 'class="pictofixedwidth"').$langs->trans("Validate"),
  831. 'generate_doc'=>img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("ReGeneratePDF"),
  832. //'builddoc'=>img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("PDFMerge"),
  833. //'presend'=>img_picto('', 'email', 'class="pictofixedwidth"').$langs->trans("SendByMail"),
  834. );
  835. //if($user->rights->societe->creer) $arrayofmassactions['createbills']=$langs->trans("CreateInvoiceForThisCustomer");
  836. if ($user->rights->projet->creer) {
  837. $arrayofmassactions['close'] = img_picto('', 'close_title', 'class="pictofixedwidth"').$langs->trans("Close");
  838. $arrayofmassactions['preaffectuser'] = img_picto('', 'user', 'class="pictofixedwidth"').$langs->trans("AffectUser");
  839. }
  840. if ($user->rights->projet->supprimer) {
  841. $arrayofmassactions['predelete'] = img_picto('', 'delete', 'class="pictofixedwidth"').$langs->trans("Delete");
  842. }
  843. if (isModEnabled('category') && $user->rights->projet->creer) {
  844. $arrayofmassactions['preaffecttag'] = img_picto('', 'category', 'class="pictofixedwidth"').$langs->trans("AffectTag");
  845. }
  846. if (in_array($massaction, array('presend', 'predelete', 'preaffecttag', 'preaffectuser'))) {
  847. $arrayofmassactions = array();
  848. }
  849. $massactionbutton = $form->selectMassAction('', $arrayofmassactions);
  850. $url = DOL_URL_ROOT.'/projet/card.php?action=create';
  851. if (!empty($socid)) {
  852. $url .= '&socid='.$socid;
  853. }
  854. if ($search_usage_event_organization == 1) {
  855. $url .= '&usage_organize_event=1';
  856. }
  857. $newcardbutton = '';
  858. $newcardbutton .= dolGetButtonTitle($langs->trans('ViewList'), '', 'fa fa-bars imgforviewmode', $_SERVER["PHP_SELF"].'?mode=common'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ((empty($mode) || $mode == 'common') ? 2 : 1), array('morecss'=>'reposition'));
  859. $newcardbutton .= dolGetButtonTitle($langs->trans('ViewKanban'), '', 'fa fa-th-list imgforviewmode', $_SERVER["PHP_SELF"].'?mode=kanban'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ($mode == 'kanban' ? 2 : 1), array('morecss'=>'reposition'));
  860. $newcardbutton .= dolGetButtonTitle($langs->trans('NewProject'), '', 'fa fa-plus-circle', $url, '', $user->rights->projet->creer);
  861. print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">';
  862. if ($optioncss != '') {
  863. print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
  864. }
  865. print '<input type="hidden" name="token" value="'.newToken().'">';
  866. print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
  867. print '<input type="hidden" name="action" value="list">';
  868. print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
  869. print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
  870. print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
  871. print '<input type="hidden" name="mode" value="'.$mode.'">';
  872. // Show description of content
  873. $texthelp = '';
  874. if ($search_project_user == $user->id) {
  875. $texthelp .= $langs->trans("MyProjectsDesc");
  876. } else {
  877. if ($user->rights->projet->all->lire && !$socid) {
  878. $texthelp .= $langs->trans("ProjectsDesc");
  879. } else {
  880. $texthelp .= $langs->trans("ProjectsPublicDesc");
  881. }
  882. }
  883. print_barre_liste($form->textwithpicto($title, $texthelp), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'project', 0, $newcardbutton, '', $limit, 0, 0, 1);
  884. $topicmail = "Information";
  885. $modelmail = "project";
  886. $objecttmp = new Project($db);
  887. $trackid = 'proj'.$object->id;
  888. include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php';
  889. if ($search_all) {
  890. foreach ($fieldstosearchall as $key => $val) {
  891. $fieldstosearchall[$key] = $langs->trans($val);
  892. }
  893. print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $search_all).join(', ', $fieldstosearchall).'</div>';
  894. }
  895. $moreforfilter = '';
  896. // If the user can view user other than himself
  897. $moreforfilter .= '<div class="divsearchfield">';
  898. $tmptitle = $langs->trans('ProjectsWithThisUserAsContact');
  899. //$includeonly = 'hierarchyme';
  900. $includeonly = '';
  901. if (empty($user->rights->user->user->lire)) {
  902. $includeonly = array($user->id);
  903. }
  904. $moreforfilter .= img_picto($tmptitle, 'user', 'class="pictofixedwidth"').$form->select_dolusers($search_project_user ? $search_project_user : '', 'search_project_user', $tmptitle, '', 0, $includeonly, '', 0, 0, 0, '', 0, '', 'maxwidth250 widthcentpercentminusx');
  905. $moreforfilter .= '</div>';
  906. $moreforfilter .= '<div class="divsearchfield">';
  907. $tmptitle = $langs->trans('ProjectsWithThisContact');
  908. $moreforfilter .= img_picto($tmptitle, 'contact', 'class="pictofixedwidth"').$form->selectcontacts(0, $search_project_contact ? $search_project_contact : '', 'search_project_contact', $tmptitle, '', '', 0, 'maxwidth250 widthcentpercentminusx');
  909. $moreforfilter .= '</div>';
  910. // If the user can view thirdparties other than his'
  911. if ($user->rights->user->user->lire) {
  912. $langs->load("commercial");
  913. $moreforfilter .= '<div class="divsearchfield">';
  914. $tmptitle = $langs->trans('ThirdPartiesOfSaleRepresentative');
  915. $moreforfilter .= img_picto($tmptitle, 'user', 'class="pictofixedwidth"').$formother->select_salesrepresentatives($search_sale, 'search_sale', $user, 0, $tmptitle, 'maxwidth250 widthcentpercentminusx');
  916. $moreforfilter .= '</div>';
  917. }
  918. // Filter on categories
  919. if (isModEnabled('categorie') && $user->rights->categorie->lire) {
  920. $formcategory = new FormCategory($db);
  921. $moreforfilter .= $formcategory->getFilterBox(Categorie::TYPE_PROJECT, $search_category_array, 'minwidth300imp widthcentpercentminusx');
  922. }
  923. // Filter on customer categories
  924. if (!empty($conf->global->MAIN_SEARCH_CATEGORY_CUSTOMER_ON_PROJECT_LIST) && isModEnabled("categorie") && $user->rights->categorie->lire) {
  925. $moreforfilter .= '<div class="divsearchfield">';
  926. $tmptitle = $langs->transnoentities('CustomersProspectsCategoriesShort');
  927. $moreforfilter .= img_picto($tmptitle, 'category', 'class="pictofixedwidth"');
  928. $categoriesArr = $form->select_all_categories(Categorie::TYPE_CUSTOMER, '', '', 64, 0, 1);
  929. $categoriesArr[-2] = '- '.$langs->trans('NotCategorized').' -';
  930. $moreforfilter .= Form::multiselectarray('search_category_customer_list', $categoriesArr, $searchCategoryCustomerList, 0, 0, 'minwidth300', 0, 0, '', 'category', $tmptitle);
  931. $moreforfilter .= ' <input type="checkbox" class="valignmiddle" id="search_category_customer_operator" name="search_category_customer_operator" value="1"'.($searchCategoryCustomerOperator == 1 ? ' checked="checked"' : '').'/>';
  932. $moreforfilter .= $form->textwithpicto('', $langs->trans('UseOrOperatorForCategories') . ' : ' . $tmptitle, 1, 'help', '', 0, 2, 'tooltip_cat_cus'); // Tooltip on click
  933. $moreforfilter .= '</div>';
  934. }
  935. if (!empty($moreforfilter)) {
  936. print '<div class="liste_titre liste_titre_bydiv centpercent">';
  937. print $moreforfilter;
  938. $parameters = array();
  939. $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook
  940. print $hookmanager->resPrint;
  941. print '</div>';
  942. }
  943. $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
  944. $selectedfields = ($mode != 'kanban' ? $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage, getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN', '')) : ''); // This also change content of $arrayfields
  945. $selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons('checkforselect', 1) : '');
  946. print '<div class="div-table-responsive">';
  947. print '<table class="tagtable nobottomiftotal liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n";
  948. // Fields title search
  949. // --------------------------------------------------------------------
  950. print '<tr class="liste_titre_filter">';
  951. // Action column
  952. if (!empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) {
  953. print '<td class="liste_titre maxwidthsearch">';
  954. $searchpicto = $form->showFilterButtons('left');
  955. print $searchpicto;
  956. print '</td>';
  957. }
  958. // Project ref
  959. if (!empty($arrayfields['p.ref']['checked'])) {
  960. print '<td class="liste_titre">';
  961. print '<input type="text" class="flat" name="search_ref" value="'.dol_escape_htmltag($search_ref).'" size="6">';
  962. print '</td>';
  963. }
  964. // Project label
  965. if (!empty($arrayfields['p.title']['checked'])) {
  966. print '<td class="liste_titre">';
  967. print '<input type="text" class="flat" name="search_label" size="8" value="'.dol_escape_htmltag($search_label).'">';
  968. print '</td>';
  969. }
  970. // Third party
  971. if (!empty($arrayfields['s.nom']['checked'])) {
  972. print '<td class="liste_titre">';
  973. if ($socid > 0) {
  974. $tmpthirdparty = new Societe($db);
  975. $tmpthirdparty->fetch($socid);
  976. $search_societe = $tmpthirdparty->name;
  977. }
  978. print '<input type="text" class="flat" name="search_societe" size="8" value="'.dol_escape_htmltag($search_societe).'">';
  979. print '</td>';
  980. }
  981. // Alias
  982. if (!empty($arrayfields['s.name_alias']['checked'])) {
  983. print '<td class="liste_titre">';
  984. if ($socid > 0) {
  985. $tmpthirdparty = new Societe($db);
  986. $tmpthirdparty->fetch($socid);
  987. $search_societe_alias = $tmpthirdparty->name_alias;
  988. }
  989. print '<input type="text" class="flat" name="search_societe_alias" size="8" value="'.dol_escape_htmltag($search_societe_alias).'">';
  990. print '</td>';
  991. }
  992. // Sale representative
  993. if (!empty($arrayfields['commercial']['checked'])) {
  994. print '<td class="liste_titre">&nbsp;</td>';
  995. }
  996. // Start date
  997. if (!empty($arrayfields['p.dateo']['checked'])) {
  998. print '<td class="liste_titre center nowraponall">';
  999. /*if (!empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) {
  1000. print '<input class="flat valignmiddle" type="text" size="1" maxlength="2" name="search_sday" value="'.dol_escape_htmltag($search_sday).'">';
  1001. }
  1002. print '<input class="flat valignmiddle" type="text" size="1" maxlength="2" name="search_smonth" value="'.dol_escape_htmltag($search_smonth).'">';
  1003. print $formother->selectyear($search_syear ? $search_syear : -1, 'search_syear', 1, 20, 5, 0, 0, '', 'widthauto valignmiddle');*/
  1004. print '<div class="nowrap">';
  1005. print $form->selectDate($search_date_start_start ? $search_date_start_start : -1, 'search_date_start_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From'));
  1006. print '</div>';
  1007. print '<div class="nowrap">';
  1008. print $form->selectDate($search_date_start_end ? $search_date_start_end : -1, 'search_date_start_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to'));
  1009. print '</div>';
  1010. print '</td>';
  1011. }
  1012. // End date
  1013. if (!empty($arrayfields['p.datee']['checked'])) {
  1014. print '<td class="liste_titre center nowraponall">';
  1015. /*if (!empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) {
  1016. print '<input class="flat valignmiddle" type="text" size="1" maxlength="2" name="search_eday" value="'.dol_escape_htmltag($search_eday).'">';
  1017. }
  1018. print '<input class="flat valignmiddle" type="text" size="1" maxlength="2" name="search_emonth" value="'.dol_escape_htmltag($search_emonth).'">';
  1019. print $formother->selectyear($search_eyear ? $search_eyear : -1, 'search_eyear', 1, 20, 5, 0, 0, '', 'widthauto valignmiddle');*/
  1020. print '<div class="nowrap">';
  1021. 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'));
  1022. print '</div>';
  1023. print '<div class="nowrap">';
  1024. 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'));
  1025. print '</div>';
  1026. print '</td>';
  1027. }
  1028. // Visibility
  1029. if (!empty($arrayfields['p.public']['checked'])) {
  1030. print '<td class="liste_titre center">';
  1031. $array = array(''=>'', 0 => $langs->trans("PrivateProject"), 1 => $langs->trans("SharedProject"));
  1032. print $form->selectarray('search_public', $array, $search_public, 0, 0, 0, '', 0, 0, 0, '', 'maxwidth75');
  1033. print '</td>';
  1034. }
  1035. if (!empty($arrayfields['c.assigned']['checked'])) {
  1036. print '<td class="liste_titre center">';
  1037. print '</td>';
  1038. }
  1039. // Opp status
  1040. if (!empty($arrayfields['p.fk_opp_status']['checked'])) {
  1041. print '<td class="liste_titre nowrap center">';
  1042. print $formproject->selectOpportunityStatus('search_opp_status', $search_opp_status, 1, 1, 1, 0, 'maxwidth125 nowrapoption', 1, 1);
  1043. print '</td>';
  1044. }
  1045. if (!empty($arrayfields['p.opp_amount']['checked'])) {
  1046. print '<td class="liste_titre nowrap right">';
  1047. print '<input type="text" class="flat" name="search_opp_amount" size="3" value="'.$search_opp_amount.'">';
  1048. print '</td>';
  1049. }
  1050. if (!empty($arrayfields['p.opp_percent']['checked'])) {
  1051. print '<td class="liste_titre nowrap right">';
  1052. print '<input type="text" class="flat" name="search_opp_percent" size="2" value="'.$search_opp_percent.'">';
  1053. print '</td>';
  1054. }
  1055. if (!empty($arrayfields['opp_weighted_amount']['checked'])) {
  1056. print '<td class="liste_titre nowrap right">';
  1057. print '</td>';
  1058. }
  1059. if (!empty($arrayfields['p.budget_amount']['checked'])) {
  1060. print '<td class="liste_titre nowrap right">';
  1061. print '<input type="text" class="flat" name="search_budget_amount" size="4" value="'.$search_budget_amount.'">';
  1062. print '</td>';
  1063. }
  1064. if (!empty($arrayfields['p.usage_opportunity']['checked'])) {
  1065. print '<td class="liste_titre nowrap right">';
  1066. print $form->selectyesno('search_usage_opportunity', $search_usage_opportunity, 1, false, 1);
  1067. print '';
  1068. print '</td>';
  1069. }
  1070. if (!empty($arrayfields['p.usage_task']['checked'])) {
  1071. print '<td class="liste_titre nowrap right">';
  1072. print $form->selectyesno('search_usage_task', $search_usage_task, 1, false, 1);
  1073. print '</td>';
  1074. }
  1075. if (!empty($arrayfields['p.usage_bill_time']['checked'])) {
  1076. print '<td class="liste_titre nowrap right">';
  1077. print $form->selectyesno('search_usage_bill_time', $search_usage_bill_time, 1, false, 1);
  1078. print '</td>';
  1079. }
  1080. if (!empty($arrayfields['p.usage_organize_event']['checked'])) {
  1081. print '<td class="liste_titre nowrap right">';
  1082. print $form->selectyesno('search_usage_event_organization', $search_usage_event_organization, 1, false, 1);
  1083. print '</td>';
  1084. }
  1085. if (!empty($arrayfields['p.accept_conference_suggestions']['checked'])) {
  1086. print '<td class="liste_titre nowrap right">';
  1087. print $form->selectyesno('search_accept_conference_suggestions', $search_accept_conference_suggestions, 1, false, 1);
  1088. print '</td>';
  1089. }
  1090. if (!empty($arrayfields['p.accept_booth_suggestions']['checked'])) {
  1091. print '<td class="liste_titre nowrap right">';
  1092. print $form->selectyesno('search_accept_booth_suggestions', $search_accept_booth_suggestions, 1, false, 1);
  1093. print '</td>';
  1094. }
  1095. if (!empty($arrayfields['p.price_registration']['checked'])) {
  1096. print '<td class="liste_titre nowrap right">';
  1097. print '<input type="text" class="flat" name="search_price_registration" size="4" value="'.$search_price_registration.'">';
  1098. print '</td>';
  1099. }
  1100. if (!empty($arrayfields['p.price_booth']['checked'])) {
  1101. print '<td class="liste_titre nowrap right">';
  1102. print '<input type="text" class="flat" name="search_price_booth" size="4" value="'.$search_price_booth.'">';
  1103. print '</td>';
  1104. }
  1105. if (!empty($arrayfields['u.login']['checked'])) {
  1106. // Author
  1107. print '<td class="liste_titre" align="center">';
  1108. print '<input class="flat" size="4" type="text" name="search_login" value="'.dol_escape_htmltag($search_login).'">';
  1109. print '</td>';
  1110. }
  1111. // Extra fields
  1112. include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php';
  1113. // Fields from hook
  1114. $parameters = array('arrayfields'=>$arrayfields);
  1115. $reshook = $hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook
  1116. print $hookmanager->resPrint;
  1117. if (!empty($arrayfields['p.datec']['checked'])) {
  1118. // Date creation
  1119. print '<td class="liste_titre">';
  1120. print '</td>';
  1121. }
  1122. if (!empty($arrayfields['p.tms']['checked'])) {
  1123. // Date modification
  1124. print '<td class="liste_titre">';
  1125. print '</td>';
  1126. }
  1127. if (!empty($arrayfields['p.email_msgid']['checked'])) {
  1128. // Email msg id
  1129. print '<td class="liste_titre">';
  1130. print '</td>';
  1131. }
  1132. if (!empty($arrayfields['p.import_key']['checked'])) {
  1133. // Import key
  1134. print '<td class="liste_titre">';
  1135. print '<input class="flat width75" type="text" name="search_import_key" value="'.dol_escape_htmltag($search_import_key).'">';
  1136. print '</td>';
  1137. }
  1138. if (!empty($arrayfields['p.fk_statut']['checked'])) {
  1139. print '<td class="liste_titre center parentonrightofpage">';
  1140. $arrayofstatus = array();
  1141. foreach ($object->statuts_short as $key => $val) {
  1142. $arrayofstatus[$key] = $langs->trans($val);
  1143. }
  1144. $arrayofstatus['99'] = $langs->trans("NotClosed").' ('.$langs->trans('Draft').' + '.$langs->trans('Opened').')';
  1145. print $form->selectarray('search_status', $arrayofstatus, $search_status, 1, 0, 0, '', 0, 0, 0, '', 'search_status width100 onrightofpage', 1);
  1146. print '</td>';
  1147. }
  1148. // Action column
  1149. if (empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) {
  1150. print '<td class="liste_titre maxwidthsearch">';
  1151. $searchpicto = $form->showFilterButtons();
  1152. print $searchpicto;
  1153. print '</td>';
  1154. }
  1155. print '</tr>'."\n";
  1156. $totalarray = array();
  1157. $totalarray['nbfield'] = 0;
  1158. // Fields title label
  1159. // --------------------------------------------------------------------
  1160. print '<tr class="liste_titre">';
  1161. if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
  1162. print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n";
  1163. $totalarray['nbfield']++;
  1164. }
  1165. if (!empty($arrayfields['p.ref']['checked'])) {
  1166. print_liste_field_titre($arrayfields['p.ref']['label'], $_SERVER["PHP_SELF"], "p.ref", "", $param, "", $sortfield, $sortorder);
  1167. $totalarray['nbfield']++;
  1168. }
  1169. if (!empty($arrayfields['p.title']['checked'])) {
  1170. print_liste_field_titre($arrayfields['p.title']['label'], $_SERVER["PHP_SELF"], "p.title", "", $param, "", $sortfield, $sortorder);
  1171. $totalarray['nbfield']++;
  1172. }
  1173. if (!empty($arrayfields['s.nom']['checked'])) {
  1174. print_liste_field_titre($arrayfields['s.nom']['label'], $_SERVER["PHP_SELF"], "s.nom", "", $param, "", $sortfield, $sortorder);
  1175. $totalarray['nbfield']++;
  1176. }
  1177. if (!empty($arrayfields['s.name_alias']['checked'])) {
  1178. print_liste_field_titre($arrayfields['s.name_alias']['label'], $_SERVER["PHP_SELF"], "s.name_alias", "", $param, "", $sortfield, $sortorder);
  1179. $totalarray['nbfield']++;
  1180. }
  1181. if (!empty($arrayfields['commercial']['checked'])) {
  1182. print_liste_field_titre($arrayfields['commercial']['label'], $_SERVER["PHP_SELF"], "", "", $param, "", $sortfield, $sortorder, 'tdoverflowmax100imp ');
  1183. $totalarray['nbfield']++;
  1184. }
  1185. if (!empty($arrayfields['p.dateo']['checked'])) {
  1186. print_liste_field_titre($arrayfields['p.dateo']['label'], $_SERVER["PHP_SELF"], "p.dateo", "", $param, '', $sortfield, $sortorder, 'center ');
  1187. $totalarray['nbfield']++;
  1188. }
  1189. if (!empty($arrayfields['p.datee']['checked'])) {
  1190. print_liste_field_titre($arrayfields['p.datee']['label'], $_SERVER["PHP_SELF"], "p.datee", "", $param, '', $sortfield, $sortorder, 'center ');
  1191. $totalarray['nbfield']++;
  1192. }
  1193. if (!empty($arrayfields['p.public']['checked'])) {
  1194. print_liste_field_titre($arrayfields['p.public']['label'], $_SERVER["PHP_SELF"], "p.public", "", $param, "", $sortfield, $sortorder, 'center ');
  1195. $totalarray['nbfield']++;
  1196. }
  1197. if (!empty($arrayfields['c.assigned']['checked'])) {
  1198. print_liste_field_titre($arrayfields['c.assigned']['label'], $_SERVER["PHP_SELF"], "", '', $param, '', $sortfield, $sortorder, 'center ', '');
  1199. $totalarray['nbfield']++;
  1200. }
  1201. if (!empty($arrayfields['p.fk_opp_status']['checked'])) {
  1202. print_liste_field_titre($arrayfields['p.fk_opp_status']['label'], $_SERVER["PHP_SELF"], 'p.fk_opp_status', "", $param, '', $sortfield, $sortorder, 'center ');
  1203. $totalarray['nbfield']++;
  1204. }
  1205. if (!empty($arrayfields['p.opp_amount']['checked'])) {
  1206. print_liste_field_titre($arrayfields['p.opp_amount']['label'], $_SERVER["PHP_SELF"], 'p.opp_amount', "", $param, '', $sortfield, $sortorder, 'right ');
  1207. $totalarray['nbfield']++;
  1208. }
  1209. if (!empty($arrayfields['p.opp_percent']['checked'])) {
  1210. print_liste_field_titre($arrayfields['p.opp_percent']['label'], $_SERVER['PHP_SELF'], 'p.opp_percent', "", $param, '', $sortfield, $sortorder, 'right ');
  1211. $totalarray['nbfield']++;
  1212. }
  1213. if (!empty($arrayfields['opp_weighted_amount']['checked'])) {
  1214. print_liste_field_titre($arrayfields['opp_weighted_amount']['label'], $_SERVER['PHP_SELF'], 'opp_weighted_amount', '', $param, '', $sortfield, $sortorder, 'right ');
  1215. $totalarray['nbfield']++;
  1216. }
  1217. if (!empty($arrayfields['p.budget_amount']['checked'])) {
  1218. print_liste_field_titre($arrayfields['p.budget_amount']['label'], $_SERVER["PHP_SELF"], 'p.budget_amount', "", $param, '', $sortfield, $sortorder, 'right ');
  1219. $totalarray['nbfield']++;
  1220. }
  1221. if (!empty($arrayfields['p.usage_opportunity']['checked'])) {
  1222. print_liste_field_titre($arrayfields['p.usage_opportunity']['label'], $_SERVER["PHP_SELF"], 'p.usage_opportunity', "", $param, '', $sortfield, $sortorder, 'right ');
  1223. $totalarray['nbfield']++;
  1224. }
  1225. if (!empty($arrayfields['p.usage_task']['checked'])) {
  1226. print_liste_field_titre($arrayfields['p.usage_task']['label'], $_SERVER["PHP_SELF"], 'p.usage_task', "", $param, '', $sortfield, $sortorder, 'right ');
  1227. $totalarray['nbfield']++;
  1228. }
  1229. if (!empty($arrayfields['p.usage_bill_time']['checked'])) {
  1230. print_liste_field_titre($arrayfields['p.usage_bill_time']['label'], $_SERVER["PHP_SELF"], 'p.usage_bill_time', "", $param, '', $sortfield, $sortorder, 'right ');
  1231. $totalarray['nbfield']++;
  1232. }
  1233. if (!empty($arrayfields['p.usage_organize_event']['checked'])) {
  1234. print_liste_field_titre($arrayfields['p.usage_organize_event']['label'], $_SERVER["PHP_SELF"], 'p.usage_organize_event', "", $param, '', $sortfield, $sortorder, 'right ');
  1235. $totalarray['nbfield']++;
  1236. }
  1237. if (!empty($arrayfields['p.accept_conference_suggestions']['checked'])) {
  1238. print_liste_field_titre($arrayfields['p.accept_conference_suggestions']['label'], $_SERVER["PHP_SELF"], 'p.accept_conference_suggestions', "", $param, '', $sortfield, $sortorder, 'right ');
  1239. $totalarray['nbfield']++;
  1240. }
  1241. if (!empty($arrayfields['p.accept_booth_suggestions']['checked'])) {
  1242. print_liste_field_titre($arrayfields['p.accept_booth_suggestions']['label'], $_SERVER["PHP_SELF"], 'p.accept_booth_suggestions', "", $param, '', $sortfield, $sortorder, 'right ');
  1243. $totalarray['nbfield']++;
  1244. }
  1245. if (!empty($arrayfields['p.price_registration']['checked'])) {
  1246. print_liste_field_titre($arrayfields['p.price_registration']['label'], $_SERVER["PHP_SELF"], 'p.price_registration', "", $param, '', $sortfield, $sortorder, 'right ');
  1247. $totalarray['nbfield']++;
  1248. }
  1249. if (!empty($arrayfields['p.price_booth']['checked'])) {
  1250. print_liste_field_titre($arrayfields['p.price_booth']['label'], $_SERVER["PHP_SELF"], 'p.price_booth', "", $param, '', $sortfield, $sortorder, 'right ');
  1251. $totalarray['nbfield']++;
  1252. }
  1253. if (!empty($arrayfields['u.login']['checked'])) {
  1254. print_liste_field_titre($arrayfields['u.login']['label'], $_SERVER["PHP_SELF"], 'u.login', '', $param, 'align="center"', $sortfield, $sortorder);
  1255. $totalarray['nbfield']++;
  1256. }
  1257. // Extra fields
  1258. include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php';
  1259. // Hook fields
  1260. $parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder, 'totalarray'=>&$totalarray);
  1261. $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
  1262. print $hookmanager->resPrint;
  1263. if (!empty($arrayfields['p.datec']['checked'])) {
  1264. print_liste_field_titre($arrayfields['p.datec']['label'], $_SERVER["PHP_SELF"], "p.datec", "", $param, '', $sortfield, $sortorder, 'center nowrap ');
  1265. $totalarray['nbfield']++;
  1266. }
  1267. if (!empty($arrayfields['p.tms']['checked'])) {
  1268. print_liste_field_titre($arrayfields['p.tms']['label'], $_SERVER["PHP_SELF"], "p.tms", "", $param, '', $sortfield, $sortorder, 'center nowrap ');
  1269. $totalarray['nbfield']++;
  1270. }
  1271. if (!empty($arrayfields['p.email_msgid']['checked'])) {
  1272. print_liste_field_titre($arrayfields['p.email_msgid']['label'], $_SERVER["PHP_SELF"], "p.email_msgid", "", $param, '', $sortfield, $sortorder, 'center ');
  1273. $totalarray['nbfield']++;
  1274. }
  1275. if (!empty($arrayfields['p.import_key']['checked'])) {
  1276. print_liste_field_titre($arrayfields['p.import_key']['label'], $_SERVER["PHP_SELF"], "p.import_key", "", $param, '', $sortfield, $sortorder, '');
  1277. $totalarray['nbfield']++;
  1278. }
  1279. if (!empty($arrayfields['p.fk_statut']['checked'])) {
  1280. print_liste_field_titre($arrayfields['p.fk_statut']['label'], $_SERVER["PHP_SELF"], "p.fk_statut", "", $param, '', $sortfield, $sortorder, 'center ');
  1281. $totalarray['nbfield']++;
  1282. }
  1283. // Action column
  1284. if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
  1285. print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n";
  1286. $totalarray['nbfield']++;
  1287. }
  1288. print '</tr>'."\n";
  1289. $i = 0;
  1290. $savnbfield = $totalarray['nbfield'];
  1291. $totalarray = array(
  1292. 'nbfield' => 0,
  1293. 'val' => array()
  1294. );
  1295. $imaxinloop = ($limit ? min($num, $limit) : $num);
  1296. while ($i < $imaxinloop) {
  1297. $obj = $db->fetch_object($resql);
  1298. if (empty($obj)) {
  1299. break; // Should not happen
  1300. }
  1301. $object->id = $obj->id;
  1302. $object->ref = $obj->ref;
  1303. $object->title = $obj->title;
  1304. $object->fk_opp_status = $obj->fk_opp_status;
  1305. $object->user_author_id = $obj->fk_user_creat;
  1306. $object->date_creation = $db->jdate($obj->date_creation);
  1307. $object->date_start = $db->jdate($obj->date_start);
  1308. $object->date_end = $db->jdate($obj->date_end);
  1309. $object->statut = $obj->status; // deprecated
  1310. $object->status = $obj->status;
  1311. $object->public = $obj->public;
  1312. $object->opp_percent = $obj->opp_percent;
  1313. $object->opp_status = $obj->fk_opp_status;
  1314. $object->opp_status_code = $obj->opp_status_code;
  1315. $object->opp_amount = !empty($obj->opp_amount) ? $obj->opp_amount : "";
  1316. $object->opp_weighted_amount = $obj->opp_weighted_amount;
  1317. $object->budget_amount = $obj->budget_amount;
  1318. $object->usage_opportunity = $obj->usage_opportunity;
  1319. $object->usage_task = $obj->usage_task;
  1320. $object->usage_bill_time = $obj->usage_bill_time;
  1321. $object->usage_organize_event = $obj->usage_organize_event;
  1322. $object->email_msgid = $obj->email_msgid;
  1323. $object->import_key = $obj->import_key;
  1324. //$userAccess = $object->restrictedProjectArea($user); // disabled, permission on project must be done by the select
  1325. //if ($userAccess >= 0) {
  1326. // Thirdparty
  1327. $companystatic->id = $obj->socid;
  1328. $companystatic->name = $obj->name;
  1329. $companystatic->name_alias = $obj->alias;
  1330. $companystatic->client = $obj->client;
  1331. $companystatic->code_client = $obj->code_client;
  1332. $companystatic->email = $obj->email;
  1333. $companystatic->phone = $obj->phone;
  1334. $companystatic->address = $obj->address;
  1335. $companystatic->zip = $obj->zip;
  1336. $companystatic->town = $obj->town;
  1337. $companystatic->country_code = $obj->country_code;
  1338. if ($mode == 'kanban') {
  1339. if ($i == 0) {
  1340. print '<tr><td colspan="'.$savnbfield.'">';
  1341. print '<div class="box-flex-container kanban">';
  1342. }
  1343. print $object->getKanbanView('');
  1344. if ($i == ($imaxinloop - 1)) {
  1345. print '</div>';
  1346. print '</td></tr>';
  1347. }
  1348. } else {
  1349. // Show here line of result
  1350. $j = 0;
  1351. print '<tr data-rowid="'.$object->id.'" class="oddeven">';
  1352. // Action column
  1353. if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
  1354. print '<td class="nowrap center">';
  1355. if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
  1356. $selected = 0;
  1357. if (in_array($object->id, $arrayofselected)) {
  1358. $selected = 1;
  1359. }
  1360. print '<input id="cb'.$object->id.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$object->id.'"'.($selected ? ' checked="checked"' : '').'>';
  1361. }
  1362. print '</td>';
  1363. if (!$i) {
  1364. $totalarray['nbfield']++;
  1365. }
  1366. }
  1367. // Project url
  1368. if (!empty($arrayfields['p.ref']['checked'])) {
  1369. print '<td class="nowraponall tdoverflowmax200" title="'.dol_escape_htmltag($object->ref).'">';
  1370. print $object->getNomUrl(1, (!empty(GETPOST('search_usage_event_organization', 'int'))?'eventorganization':''));
  1371. if ($object->hasDelay()) {
  1372. print img_warning($langs->trans('Late'));
  1373. }
  1374. print '</td>';
  1375. if (!$i) {
  1376. $totalarray['nbfield']++;
  1377. }
  1378. }
  1379. // Title
  1380. if (!empty($arrayfields['p.title']['checked'])) {
  1381. print '<td class="tdoverflowmax200" title="'.dol_escape_htmltag($obj->title).'">';
  1382. print dol_escape_htmltag($obj->title);
  1383. print '</td>';
  1384. if (!$i) {
  1385. $totalarray['nbfield']++;
  1386. }
  1387. }
  1388. // Company
  1389. if (!empty($arrayfields['s.nom']['checked'])) {
  1390. print '<td class="tdoverflowmax125">';
  1391. if ($obj->socid) {
  1392. print $companystatic->getNomUrl(1, '', 0, 0, -1, empty($arrayfields['s.name_alias']['checked']) ? 0 : 1);
  1393. } else {
  1394. print '&nbsp;';
  1395. }
  1396. print '</td>';
  1397. if (!$i) {
  1398. $totalarray['nbfield']++;
  1399. }
  1400. }
  1401. // Alias
  1402. if (!empty($arrayfields['s.name_alias']['checked'])) {
  1403. print '<td class="tdoverflowmax100">';
  1404. if ($obj->socid) {
  1405. print $companystatic->name_alias;
  1406. } else {
  1407. print '&nbsp;';
  1408. }
  1409. print '</td>';
  1410. if (!$i) {
  1411. $totalarray['nbfield']++;
  1412. }
  1413. }
  1414. // Sales Representatives
  1415. if (!empty($arrayfields['commercial']['checked'])) {
  1416. print '<td class="tdoverflowmax150">';
  1417. if ($obj->socid) {
  1418. $companystatic->id = $obj->socid;
  1419. $companystatic->name = $obj->name;
  1420. $listsalesrepresentatives = $companystatic->getSalesRepresentatives($user);
  1421. $nbofsalesrepresentative = count($listsalesrepresentatives);
  1422. if ($nbofsalesrepresentative > 6) {
  1423. // We print only number
  1424. print $nbofsalesrepresentative;
  1425. } elseif ($nbofsalesrepresentative > 0) {
  1426. $userstatic = new User($db);
  1427. $j = 0;
  1428. foreach ($listsalesrepresentatives as $val) {
  1429. $userstatic->id = $val['id'];
  1430. $userstatic->lastname = $val['lastname'];
  1431. $userstatic->firstname = $val['firstname'];
  1432. $userstatic->email = $val['email'];
  1433. $userstatic->statut = $val['statut'];
  1434. $userstatic->entity = $val['entity'];
  1435. $userstatic->photo = $val['photo'];
  1436. $userstatic->login = $val['login'];
  1437. $userstatic->office_phone = $val['office_phone'];
  1438. $userstatic->office_fax = $val['office_fax'];
  1439. $userstatic->user_mobile = $val['user_mobile'];
  1440. $userstatic->job = $val['job'];
  1441. $userstatic->gender = $val['gender'];
  1442. print ($nbofsalesrepresentative < 2) ? $userstatic->getNomUrl(-1, '', 0, 0, 12) : $userstatic->getNomUrl(-2);
  1443. $j++;
  1444. if ($j < $nbofsalesrepresentative) {
  1445. print ' ';
  1446. }
  1447. }
  1448. }
  1449. //else print $langs->trans("NoSalesRepresentativeAffected");
  1450. } else {
  1451. print '&nbsp;';
  1452. }
  1453. print '</td>';
  1454. if (!$i) {
  1455. $totalarray['nbfield']++;
  1456. }
  1457. }
  1458. // Date start project
  1459. if (!empty($arrayfields['p.dateo']['checked'])) {
  1460. print '<td class="center">';
  1461. print dol_print_date($db->jdate($obj->date_start), 'day');
  1462. print '</td>';
  1463. if (!$i) {
  1464. $totalarray['nbfield']++;
  1465. }
  1466. }
  1467. // Date end project
  1468. if (!empty($arrayfields['p.datee']['checked'])) {
  1469. print '<td class="center">';
  1470. print dol_print_date($db->jdate($obj->date_end), 'day');
  1471. print '</td>';
  1472. if (!$i) {
  1473. $totalarray['nbfield']++;
  1474. }
  1475. }
  1476. // Visibility
  1477. if (!empty($arrayfields['p.public']['checked'])) {
  1478. print '<td class="center">';
  1479. if ($obj->public) {
  1480. print img_picto($langs->trans('SharedProject'), 'world', 'class="paddingrightonly"');
  1481. //print $langs->trans('SharedProject');
  1482. } else {
  1483. print img_picto($langs->trans('PrivateProject'), 'private', 'class="paddingrightonly"');
  1484. //print $langs->trans('PrivateProject');
  1485. }
  1486. print '</td>';
  1487. if (!$i) {
  1488. $totalarray['nbfield']++;
  1489. }
  1490. }
  1491. // Contacts of project
  1492. if (!empty($arrayfields['c.assigned']['checked'])) {
  1493. print '<td class="center nowraponall tdoverflowmax200">';
  1494. $ifisrt = 1;
  1495. foreach (array('internal', 'external') as $source) {
  1496. $tab = $object->liste_contact(-1, $source, 0, '', 1);
  1497. $numcontact = count($tab);
  1498. if (!empty($numcontact)) {
  1499. foreach ($tab as $contactproject) {
  1500. //var_dump($contacttask);
  1501. if ($source == 'internal') {
  1502. $c = new User($db);
  1503. } else {
  1504. $c = new Contact($db);
  1505. }
  1506. $c->fetch($contactproject['id']);
  1507. if (!empty($c->photo)) {
  1508. if (get_class($c) == 'User') {
  1509. print $c->getNomUrl(-2, '', 0, 0, 24, 1, '', ($ifisrt ? '' : 'notfirst'));
  1510. } else {
  1511. print $c->getNomUrl(-2, '', 0, '', -1, 0, ($ifisrt ? '' : 'notfirst'));
  1512. }
  1513. } else {
  1514. if (get_class($c) == 'User') {
  1515. print $c->getNomUrl(2, '', 0, 0, 24, 1, '', ($ifisrt ? '' : 'notfirst'));
  1516. } else {
  1517. print $c->getNomUrl(2, '', 0, '', -1, 0, ($ifisrt ? '' : 'notfirst'));
  1518. }
  1519. }
  1520. $ifisrt = 0;
  1521. }
  1522. }
  1523. }
  1524. print '</td>';
  1525. if (!$i) {
  1526. $totalarray['nbfield']++;
  1527. }
  1528. }
  1529. // Opp Status
  1530. if (!empty($arrayfields['p.fk_opp_status']['checked'])) {
  1531. print '<td class="center">';
  1532. if ($obj->opp_status_code) {
  1533. print $langs->trans("OppStatus".$obj->opp_status_code);
  1534. }
  1535. print '</td>';
  1536. if (!$i) {
  1537. $totalarray['nbfield']++;
  1538. }
  1539. }
  1540. // Opp Amount
  1541. if (!empty($arrayfields['p.opp_amount']['checked'])) {
  1542. print '<td class="right">';
  1543. //if ($obj->opp_status_code)
  1544. if (strcmp($obj->opp_amount, '')) {
  1545. print '<span class="amount">'.price($obj->opp_amount, 1, $langs, 1, -1, -1, '').'</span>';
  1546. if (!isset($totalarray['val']['p.opp_amount'])) {
  1547. $totalarray['val']['p.opp_amount'] = $obj->opp_amount;
  1548. } else {
  1549. $totalarray['val']['p.opp_amount'] += $obj->opp_amount;
  1550. }
  1551. }
  1552. print '</td>';
  1553. if (!$i) {
  1554. $totalarray['nbfield']++;
  1555. }
  1556. if (!$i) {
  1557. $totalarray['pos'][$totalarray['nbfield']] = 'p.opp_amount';
  1558. }
  1559. }
  1560. // Opp percent
  1561. if (!empty($arrayfields['p.opp_percent']['checked'])) {
  1562. print '<td class="right">';
  1563. if ($obj->opp_percent) {
  1564. print price($obj->opp_percent, 1, $langs, 1, 0).'%';
  1565. }
  1566. print '</td>';
  1567. if (!$i) {
  1568. $totalarray['nbfield']++;
  1569. }
  1570. }
  1571. // Opp weighted amount
  1572. if (!empty($arrayfields['opp_weighted_amount']['checked'])) {
  1573. if (!isset($totalarray['val']['opp_weighted_amount'])) {
  1574. $totalarray['val']['opp_weighted_amount'] = 0;
  1575. }
  1576. print '<td align="right">';
  1577. if ($obj->opp_weighted_amount) {
  1578. print '<span class="amount">'.price($obj->opp_weighted_amount, 1, $langs, 1, -1, -1, '').'</span>';
  1579. $totalarray['val']['opp_weighted_amount'] += $obj->opp_weighted_amount;
  1580. }
  1581. print '</td>';
  1582. if (!$i) {
  1583. $totalarray['nbfield']++;
  1584. }
  1585. if (!$i) {
  1586. $totalarray['pos'][$totalarray['nbfield']] = 'opp_weighted_amount';
  1587. }
  1588. }
  1589. // Budget
  1590. if (!empty($arrayfields['p.budget_amount']['checked'])) {
  1591. print '<td class="right">';
  1592. if ($obj->budget_amount != '') {
  1593. print '<span class="amount">'.price($obj->budget_amount, 1, $langs, 1, -1, -1).'</span>';
  1594. if (!isset($totalarray['val']['p.budget_amount'])) {
  1595. $totalarray['val']['p.budget_amount'] = $obj->budget_amount;
  1596. } else {
  1597. $totalarray['val']['p.budget_amount'] += $obj->budget_amount;
  1598. }
  1599. }
  1600. print '</td>';
  1601. if (!$i) {
  1602. $totalarray['nbfield']++;
  1603. }
  1604. if (!$i) {
  1605. $totalarray['pos'][$totalarray['nbfield']] = 'p.budget_amount';
  1606. }
  1607. }
  1608. // Usage opportunity
  1609. if (!empty($arrayfields['p.usage_opportunity']['checked'])) {
  1610. print '<td class="right">';
  1611. if ($obj->usage_opportunity) {
  1612. print yn($obj->usage_opportunity);
  1613. }
  1614. print '</td>';
  1615. if (!$i) {
  1616. $totalarray['nbfield']++;
  1617. }
  1618. }
  1619. // Usage task
  1620. if (!empty($arrayfields['p.usage_task']['checked'])) {
  1621. print '<td class="right">';
  1622. if ($obj->usage_task) {
  1623. print yn($obj->usage_task);
  1624. }
  1625. print '</td>';
  1626. if (!$i) {
  1627. $totalarray['nbfield']++;
  1628. }
  1629. }
  1630. // Bill time
  1631. if (!empty($arrayfields['p.usage_bill_time']['checked'])) {
  1632. print '<td class="right">';
  1633. if ($obj->usage_bill_time) {
  1634. print yn($obj->usage_bill_time);
  1635. }
  1636. print '</td>';
  1637. if (!$i) {
  1638. $totalarray['nbfield']++;
  1639. }
  1640. }
  1641. // Event Organization
  1642. if (!empty($arrayfields['p.usage_organize_event']['checked'])) {
  1643. print '<td class="right">';
  1644. if ($obj->usage_organize_event) {
  1645. print yn($obj->usage_organize_event);
  1646. }
  1647. print '</td>';
  1648. if (!$i) {
  1649. $totalarray['nbfield']++;
  1650. }
  1651. }
  1652. // Allow unknown people to suggest conferences
  1653. if (!empty($arrayfields['p.accept_conference_suggestions']['checked'])) {
  1654. print '<td class="right">';
  1655. if ($obj->accept_conference_suggestions) {
  1656. print yn($obj->accept_conference_suggestions);
  1657. }
  1658. print '</td>';
  1659. if (!$i) {
  1660. $totalarray['nbfield']++;
  1661. }
  1662. }
  1663. // Allow unknown people to suggest booth
  1664. if (!empty($arrayfields['p.accept_booth_suggestions']['checked'])) {
  1665. print '<td class="right">';
  1666. if ($obj->accept_booth_suggestions) {
  1667. print yn($obj->accept_booth_suggestions);
  1668. }
  1669. print '</td>';
  1670. if (!$i) {
  1671. $totalarray['nbfield']++;
  1672. }
  1673. }
  1674. // Price of registration
  1675. if (!empty($arrayfields['p.price_registration']['checked'])) {
  1676. print '<td class="right">';
  1677. if ($obj->price_registration != '') {
  1678. print '<span class="amount">'.price($obj->price_registration, 1, $langs, 1, -1, -1).'</span>';
  1679. $totalarray['val']['p.price_registration'] += $obj->price_registration;
  1680. }
  1681. print '</td>';
  1682. if (!$i) {
  1683. $totalarray['nbfield']++;
  1684. }
  1685. if (!$i) {
  1686. $totalarray['pos'][$totalarray['nbfield']] = 'p.price_registration';
  1687. }
  1688. }
  1689. // Price of booth
  1690. if (!empty($arrayfields['p.price_booth']['checked'])) {
  1691. print '<td class="right">';
  1692. if ($obj->price_booth != '') {
  1693. print '<span class="amount">'.price($obj->price_booth, 1, $langs, 1, -1, -1).'</span>';
  1694. $totalarray['val']['p.price_booth'] += $obj->price_booth;
  1695. }
  1696. print '</td>';
  1697. if (!$i) {
  1698. $totalarray['nbfield']++;
  1699. }
  1700. if (!$i) {
  1701. $totalarray['pos'][$totalarray['nbfield']] = 'p.price_booth';
  1702. }
  1703. }
  1704. // Author
  1705. $userstatic->id = $obj->fk_user_creat;
  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->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. if (!empty($arrayfields['u.login']['checked'])) {
  1719. print '<td class="center tdoverflowmax150">';
  1720. if ($userstatic->id) {
  1721. print $userstatic->getNomUrl(-1);
  1722. } else {
  1723. print '&nbsp;';
  1724. }
  1725. print "</td>\n";
  1726. if (!$i) {
  1727. $totalarray['nbfield']++;
  1728. }
  1729. }
  1730. // Extra fields
  1731. include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php';
  1732. // Fields from hook
  1733. $parameters = array('arrayfields'=>$arrayfields, 'object'=>$object, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray);
  1734. $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
  1735. print $hookmanager->resPrint;
  1736. // Date creation
  1737. if (!empty($arrayfields['p.datec']['checked'])) {
  1738. print '<td class="center nowraponall">';
  1739. print dol_print_date($db->jdate($obj->date_creation), 'dayhour', 'tzuser');
  1740. print '</td>';
  1741. if (!$i) {
  1742. $totalarray['nbfield']++;
  1743. }
  1744. }
  1745. // Date modification
  1746. if (!empty($arrayfields['p.tms']['checked'])) {
  1747. print '<td class="center nowraponall">';
  1748. print dol_print_date($db->jdate($obj->date_update), 'dayhour', 'tzuser');
  1749. print '</td>';
  1750. if (!$i) {
  1751. $totalarray['nbfield']++;
  1752. }
  1753. }
  1754. // Email MsgID
  1755. if (!empty($arrayfields['p.email_msgid']['checked'])) {
  1756. print '<td class="tdoverflowmax125" title="'.dol_escape_htmltag($obj->email_msgid).'">';
  1757. print dol_escape_htmltag($obj->email_msgid);
  1758. print '</td>';
  1759. if (!$i) {
  1760. $totalarray['nbfield']++;
  1761. }
  1762. }
  1763. // Import key
  1764. if (!empty($arrayfields['p.import_key']['checked'])) {
  1765. print '<td class="right">'.dol_escape_htmltag($obj->import_key).'</td>';
  1766. if (!$i) {
  1767. $totalarray['nbfield']++;
  1768. }
  1769. }
  1770. // Status
  1771. if (!empty($arrayfields['p.fk_statut']['checked'])) {
  1772. print '<td class="right">'.$object->getLibStatut(5).'</td>';
  1773. if (!$i) {
  1774. $totalarray['nbfield']++;
  1775. }
  1776. }
  1777. // Action column
  1778. if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
  1779. print '<td class="nowrap center">';
  1780. if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
  1781. $selected = 0;
  1782. if (in_array($object->id, $arrayofselected)) {
  1783. $selected = 1;
  1784. }
  1785. print '<input id="cb'.$object->id.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$object->id.'"'.($selected ? ' checked="checked"' : '').'>';
  1786. }
  1787. print '</td>';
  1788. if (!$i) {
  1789. $totalarray['nbfield']++;
  1790. }
  1791. }
  1792. print '</tr>'."\n";
  1793. }
  1794. //}
  1795. $i++;
  1796. }
  1797. // Show total line
  1798. include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php';
  1799. // If no record found
  1800. if ($num == 0) {
  1801. $colspan = 1;
  1802. foreach ($arrayfields as $key => $val) {
  1803. if (!empty($val['checked'])) {
  1804. $colspan++;
  1805. }
  1806. }
  1807. print '<tr><td colspan="'.$colspan.'"><span class="opacitymedium">'.$langs->trans("NoRecordFound").'</span></td></tr>';
  1808. }
  1809. $db->free($resql);
  1810. $parameters = array('arrayfields'=>$arrayfields, 'sql' => $sql);
  1811. $reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
  1812. print $hookmanager->resPrint;
  1813. print '</table>'."\n";
  1814. print '</div>'."\n";
  1815. print '</form>'."\n";
  1816. // End of page
  1817. llxFooter();
  1818. $db->close();