list.php 84 KB

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