list.php 44 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048
  1. <?php
  2. /* Copyright (C) 2001-2007 Rodolphe Quiedeville <rodolphe@quiedeville.org>
  3. * Copyright (C) 2004-2016 Laurent Destailleur <eldy@users.sourceforge.net>
  4. * Copyright (C) 2004 Eric Seigne <eric.seigne@ryxeo.com>
  5. * Copyright (C) 2005 Marc Barilley / Ocebo <marc@ocebo.com>
  6. * Copyright (C) 2005-2013 Regis Houssin <regis.houssin@capnetworks.com>
  7. * Copyright (C) 2006 Andre Cianfarani <acianfa@free.fr>
  8. * Copyright (C) 2010-2011 Juanjo Menent <jmenent@2byte.es>
  9. * Copyright (C) 2010-2011 Philippe Grand <philippe.grand@atoo-net.com>
  10. * Copyright (C) 2012 Christophe Battarel <christophe.battarel@altairis.fr>
  11. * Copyright (C) 2013 Cédric Salvador <csalvador@gpcsolutions.fr>
  12. * Copyright (C) 2015 Jean-François Ferry <jfefe@aternatik.fr>
  13. * Copyright (C) 2016 Ferran Marcet <fmarcet@2byte.es>
  14. *
  15. * This program is free software; you can redistribute it and/or modify
  16. * it under the terms of the GNU General Public License as published by
  17. * the Free Software Foundation; either version 3 of the License, or
  18. * (at your option) any later version.
  19. *
  20. * This program is distributed in the hope that it will be useful,
  21. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  22. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  23. * GNU General Public License for more details.
  24. *
  25. * You should have received a copy of the GNU General Public License
  26. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  27. */
  28. /**
  29. * \file htdocs/comm/propal/list.php
  30. * \ingroup propal
  31. * \brief Page of commercial proposals card and list
  32. */
  33. require '../../main.inc.php';
  34. require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
  35. require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
  36. require_once DOL_DOCUMENT_ROOT.'/core/class/html.formpropal.class.php';
  37. require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
  38. require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
  39. require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
  40. require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php';
  41. if (! empty($conf->projet->enabled))
  42. require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
  43. $langs->load('companies');
  44. $langs->load('propal');
  45. $langs->load('compta');
  46. $langs->load('bills');
  47. $langs->load('orders');
  48. $langs->load('products');
  49. $socid=GETPOST('socid','int');
  50. $action=GETPOST('action','alpha');
  51. $massaction=GETPOST('massaction','alpha');
  52. $show_files=GETPOST('show_files','int');
  53. $confirm=GETPOST('confirm','alpha');
  54. $toselect = GETPOST('toselect', 'array');
  55. $search_user=GETPOST('search_user','int');
  56. $search_sale=GETPOST('search_sale','int');
  57. $search_ref=GETPOST('sf_ref')?GETPOST('sf_ref','alpha'):GETPOST('search_ref','alpha');
  58. $search_refcustomer=GETPOST('search_refcustomer','alpha');
  59. $search_societe=GETPOST('search_societe','alpha');
  60. $search_montant_ht=GETPOST('search_montant_ht','alpha');
  61. $search_montant_vat=GETPOST('search_montant_vat','alpha');
  62. $search_montant_ttc=GETPOST('search_montant_ttc','alpha');
  63. $search_login=GETPOST('search_login','alpha');
  64. $search_product_category=GETPOST('search_product_category','int');
  65. $search_town=GETPOST('search_town','alpha');
  66. $search_zip=GETPOST('search_zip','alpha');
  67. $search_state=trim(GETPOST("search_state"));
  68. $search_country=GETPOST("search_country",'int');
  69. $search_type_thirdparty=GETPOST("search_type_thirdparty",'int');
  70. $viewstatut=GETPOST('viewstatut');
  71. $optioncss = GETPOST('optioncss','alpha');
  72. $object_statut=GETPOST('propal_statut');
  73. $sall=GETPOST('sall', 'alphanohtml');
  74. $mesg=(GETPOST("msg") ? GETPOST("msg") : GETPOST("mesg"));
  75. $day=GETPOST("day","int");
  76. $month=GETPOST("month","int");
  77. $year=GETPOST("year","int");
  78. $limit = GETPOST('limit')?GETPOST('limit','int'):$conf->liste_limit;
  79. $sortfield = GETPOST("sortfield",'alpha');
  80. $sortorder = GETPOST("sortorder",'alpha');
  81. $page = GETPOST("page",'int');
  82. if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
  83. $offset = $limit * $page;
  84. $pageprev = $page - 1;
  85. $pagenext = $page + 1;
  86. if (! $sortfield) $sortfield='p.ref';
  87. if (! $sortorder) $sortorder='DESC';
  88. // Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array
  89. $contextpage='proposallist';
  90. // Security check
  91. $module='propal';
  92. $dbtable='';
  93. $objectid='';
  94. if (! empty($user->societe_id)) $socid=$user->societe_id;
  95. if (! empty($socid))
  96. {
  97. $objectid=$socid;
  98. $module='societe';
  99. $dbtable='&societe';
  100. }
  101. $result = restrictedArea($user, $module, $objectid, $dbtable);
  102. $diroutputmassaction=$conf->propal->dir_output . '/temp/massgeneration/'.$user->id;
  103. // Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array
  104. $hookmanager->initHooks(array('propallist'));
  105. $extrafields = new ExtraFields($db);
  106. // fetch optionals attributes and labels
  107. $extralabels = $extrafields->fetch_name_optionals_label('propal');
  108. $search_array_options=$extrafields->getOptionalsFromPost($extralabels,'','search_');
  109. // List of fields to search into when doing a "search in all"
  110. $fieldstosearchall = array(
  111. 'p.ref'=>'Ref',
  112. 'p.ref_client'=>'CustomerRef',
  113. 'pd.description'=>'Description',
  114. 's.nom'=>"ThirdParty",
  115. 'p.note_public'=>'NotePublic',
  116. );
  117. if (empty($user->socid)) $fieldstosearchall["p.note_private"]="NotePrivate";
  118. $checkedtypetiers=0;
  119. $arrayfields=array(
  120. 'p.ref'=>array('label'=>$langs->trans("Ref"), 'checked'=>1),
  121. 'p.ref_client'=>array('label'=>$langs->trans("RefCustomer"), 'checked'=>1),
  122. 's.nom'=>array('label'=>$langs->trans("ThirdParty"), 'checked'=>1),
  123. 's.town'=>array('label'=>$langs->trans("Town"), 'checked'=>1),
  124. 's.zip'=>array('label'=>$langs->trans("Zip"), 'checked'=>1),
  125. 'state.nom'=>array('label'=>$langs->trans("StateShort"), 'checked'=>0),
  126. 'country.code_iso'=>array('label'=>$langs->trans("Country"), 'checked'=>0),
  127. 'typent.code'=>array('label'=>$langs->trans("ThirdPartyType"), 'checked'=>$checkedtypetiers),
  128. 'p.date'=>array('label'=>$langs->trans("Date"), 'checked'=>1),
  129. 'p.fin_validite'=>array('label'=>$langs->trans("DateEnd"), 'checked'=>1),
  130. 'p.total_ht'=>array('label'=>$langs->trans("AmountHT"), 'checked'=>1),
  131. 'p.total_vat'=>array('label'=>$langs->trans("AmountVAT"), 'checked'=>0),
  132. 'p.total_ttc'=>array('label'=>$langs->trans("AmountTTC"), 'checked'=>0),
  133. 'u.login'=>array('label'=>$langs->trans("Author"), 'checked'=>1, 'position'=>10),
  134. 'p.datec'=>array('label'=>$langs->trans("DateCreation"), 'checked'=>0, 'position'=>500),
  135. 'p.tms'=>array('label'=>$langs->trans("DateModificationShort"), 'checked'=>0, 'position'=>500),
  136. 'p.fk_statut'=>array('label'=>$langs->trans("Status"), 'checked'=>1, 'position'=>1000),
  137. );
  138. // Extra fields
  139. if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label))
  140. {
  141. foreach($extrafields->attribute_label as $key => $val)
  142. {
  143. $arrayfields["ef.".$key]=array('label'=>$extrafields->attribute_label[$key], 'checked'=>$extrafields->attribute_list[$key], 'position'=>$extrafields->attribute_pos[$key], 'enabled'=>$extrafields->attribute_perms[$key]);
  144. }
  145. }
  146. $object = new Propal($db); // To be passed as parameter of executeHooks that need
  147. /*
  148. * Actions
  149. */
  150. if (GETPOST('cancel')) { $action='list'; $massaction=''; }
  151. if (! GETPOST('confirmmassaction') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction=''; }
  152. $parameters=array('socid'=>$socid);
  153. $reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks
  154. if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
  155. include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
  156. // Do we click on purge search criteria ?
  157. if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETPOST("button_removefilter")) // All tests are required to be compatible with all browsers
  158. {
  159. $search_categ='';
  160. $search_user='';
  161. $search_sale='';
  162. $search_ref='';
  163. $search_refcustomer='';
  164. $search_societe='';
  165. $search_montant_ht='';
  166. $search_montant_vat='';
  167. $search_montant_ttc='';
  168. $search_login='';
  169. $search_product_category='';
  170. $search_town='';
  171. $search_zip="";
  172. $search_state="";
  173. $search_type='';
  174. $search_country='';
  175. $search_type_thirdparty='';
  176. $year='';
  177. $month='';
  178. $day='';
  179. $viewstatut='';
  180. $object_statut='';
  181. $toselect='';
  182. $search_array_options=array();
  183. }
  184. if ($object_statut != '') $viewstatut=$object_statut;
  185. if (empty($reshook))
  186. {
  187. $objectclass='Propal';
  188. $objectlabel='Proposals';
  189. $permtoread = $user->rights->propal->lire;
  190. $permtodelete = $user->rights->propal->supprimer;
  191. $uploaddir = $conf->propal->dir_output;
  192. include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';
  193. }
  194. /*
  195. * View
  196. */
  197. $now=dol_now();
  198. $form = new Form($db);
  199. $formother = new FormOther($db);
  200. $formfile = new FormFile($db);
  201. $formpropal = new FormPropal($db);
  202. $companystatic=new Societe($db);
  203. $formcompany=new FormCompany($db);
  204. $help_url='EN:Commercial_Proposals|FR:Proposition_commerciale|ES:Presupuestos';
  205. llxHeader('',$langs->trans('Proposal'),$help_url);
  206. $sql = 'SELECT';
  207. if ($sall || $search_product_category > 0) $sql = 'SELECT DISTINCT';
  208. $sql.= ' s.rowid as socid, s.nom as name, s.town, s.zip, s.fk_pays, s.client, s.code_client, ';
  209. $sql.= " typent.code as typent_code,";
  210. $sql.= " state.code_departement as state_code, state.nom as state_name,";
  211. $sql.= ' p.rowid, p.note_private, p.total_ht, p.tva as total_vat, p.total as total_ttc, p.localtax1, p.localtax2, p.ref, p.ref_client, p.fk_statut, p.fk_user_author, p.datep as dp, p.fin_validite as dfv,';
  212. $sql.= ' p.datec as date_creation, p.tms as date_update,';
  213. $sql.= " pr.rowid as project_id, pr.ref as project_ref,";
  214. if (! $user->rights->societe->client->voir && ! $socid) $sql .= " sc.fk_soc, sc.fk_user,";
  215. $sql.= ' u.login';
  216. // Add fields from extrafields
  217. foreach ($extrafields->attribute_label as $key => $val) $sql.=($extrafields->attribute_type[$key] != 'separate' ? ",ef.".$key.' as options_'.$key : '');
  218. // Add fields from hooks
  219. $parameters=array();
  220. $reshook=$hookmanager->executeHooks('printFieldListSelect',$parameters); // Note that $action and $object may have been modified by hook
  221. $sql.=$hookmanager->resPrint;
  222. $sql.= ' FROM '.MAIN_DB_PREFIX.'societe as s';
  223. $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as country on (country.rowid = s.fk_pays)";
  224. $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_typent as typent on (typent.id = s.fk_typent)";
  225. $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_departements as state on (state.rowid = s.fk_departement)";
  226. $sql.= ', '.MAIN_DB_PREFIX.'propal as p';
  227. if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."propal_extrafields as ef on (p.rowid = ef.fk_object)";
  228. if ($sall || $search_product_category > 0) $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'propaldet as pd ON p.rowid=pd.fk_propal';
  229. if ($search_product_category > 0) $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'categorie_product as cp ON cp.fk_product=pd.fk_product';
  230. $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'user as u ON p.fk_user_author = u.rowid';
  231. $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."projet as pr ON pr.rowid = p.fk_projet";
  232. // We'll need this table joined to the select in order to filter by sale
  233. if ($search_sale > 0 || (! $user->rights->societe->client->voir && ! $socid)) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
  234. if ($search_user > 0)
  235. {
  236. $sql.=", ".MAIN_DB_PREFIX."element_contact as c";
  237. $sql.=", ".MAIN_DB_PREFIX."c_type_contact as tc";
  238. }
  239. $sql.= ' WHERE p.fk_soc = s.rowid';
  240. $sql.= ' AND p.entity IN ('.getEntity('propal').')';
  241. if (! $user->rights->societe->client->voir && ! $socid) //restriction
  242. {
  243. $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
  244. }
  245. if ($search_town) $sql.= natural_search('s.town', $search_town);
  246. if ($search_zip) $sql.= natural_search("s.zip",$search_zip);
  247. if ($search_state) $sql.= natural_search("state.nom",$search_state);
  248. if ($search_country) $sql .= " AND s.fk_pays IN (".$search_country.')';
  249. if ($search_type_thirdparty) $sql .= " AND s.fk_typent IN (".$search_type_thirdparty.')';
  250. if ($search_ref) $sql .= natural_search('p.ref', $search_ref);
  251. if ($search_refcustomer) $sql .= natural_search('p.ref_client', $search_refcustomer);
  252. if ($search_societe) $sql .= natural_search('s.nom', $search_societe);
  253. if ($search_login) $sql.= " AND u.login LIKE '%".$db->escape(trim($search_login))."%'";
  254. if ($search_montant_ht != '') $sql.= natural_search("p.total_ht", $search_montant_ht, 1);
  255. if ($search_montant_vat != '') $sql.= natural_search("p.tva", $search_montant_vat, 1);
  256. if ($search_montant_ttc != '') $sql.= natural_search("p.total", $search_montant_ttc, 1);
  257. if ($sall) {
  258. $sql .= natural_search(array_keys($fieldstosearchall), $sall);
  259. }
  260. if ($search_product_category > 0) $sql.=" AND cp.fk_categorie = ".$search_product_category;
  261. if ($socid > 0) $sql.= ' AND s.rowid = '.$socid;
  262. if ($viewstatut != '' && $viewstatut != '-1')
  263. {
  264. $sql.= ' AND p.fk_statut IN ('.$viewstatut.')';
  265. }
  266. if ($month > 0)
  267. {
  268. if ($year > 0 && empty($day))
  269. $sql.= " AND p.datep BETWEEN '".$db->idate(dol_get_first_day($year,$month,false))."' AND '".$db->idate(dol_get_last_day($year,$month,false))."'";
  270. else if ($year > 0 && ! empty($day))
  271. $sql.= " AND p.datep BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $month, $day, $year))."' AND '".$db->idate(dol_mktime(23, 59, 59, $month, $day, $year))."'";
  272. else
  273. $sql.= " AND date_format(p.datep, '%m') = '".$month."'";
  274. }
  275. else if ($year > 0)
  276. {
  277. $sql.= " AND p.datep BETWEEN '".$db->idate(dol_get_first_day($year,1,false))."' AND '".$db->idate(dol_get_last_day($year,12,false))."'";
  278. }
  279. if ($search_sale > 0) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$search_sale;
  280. if ($search_user > 0)
  281. {
  282. $sql.= " AND c.fk_c_type_contact = tc.rowid AND tc.element='propal' AND tc.source='internal' AND c.element_id = p.rowid AND c.fk_socpeople = ".$search_user;
  283. }
  284. // Add where from extra fields
  285. foreach ($search_array_options as $key => $val)
  286. {
  287. $crit=$val;
  288. $tmpkey=preg_replace('/search_options_/','',$key);
  289. $typ=$extrafields->attribute_type[$tmpkey];
  290. $mode=0;
  291. if (in_array($typ, array('int','double'))) $mode=1; // Search on a numeric
  292. if ($val && ( ($crit != '' && ! in_array($typ, array('select'))) || ! empty($crit)))
  293. {
  294. $sql .= natural_search('ef.'.$tmpkey, $crit, $mode);
  295. }
  296. }
  297. // Add where from hooks
  298. $parameters=array();
  299. $reshook=$hookmanager->executeHooks('printFieldListWhere',$parameters); // Note that $action and $object may have been modified by hook
  300. $sql.=$hookmanager->resPrint;
  301. $sql.= $db->order($sortfield,$sortorder);
  302. $sql.=', p.ref DESC';
  303. // Count total nb of records
  304. $nbtotalofrecords = '';
  305. if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
  306. {
  307. $result = $db->query($sql);
  308. $nbtotalofrecords = $db->num_rows($result);
  309. }
  310. $sql.= $db->plimit($limit+1, $offset);
  311. $resql=$db->query($sql);
  312. if ($resql)
  313. {
  314. $objectstatic=new Propal($db);
  315. $userstatic=new User($db);
  316. if ($socid > 0)
  317. {
  318. $soc = new Societe($db);
  319. $soc->fetch($socid);
  320. $title = $langs->trans('ListOfProposals') . ' - '.$soc->name;
  321. }
  322. else
  323. {
  324. $title = $langs->trans('ListOfProposals');
  325. }
  326. $num = $db->num_rows($resql);
  327. $arrayofselected=is_array($toselect)?$toselect:array();
  328. $param='&viewstatut='.$viewstatut;
  329. if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage;
  330. if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit;
  331. if ($sall) $param.='&sall='.$sall;
  332. if ($month) $param.='&month='.$month;
  333. if ($year) $param.='&year='.$year;
  334. if ($search_ref) $param.='&search_ref=' .$search_ref;
  335. if ($search_refcustomer) $param.='&search_refcustomer=' .$search_refcustomer;
  336. if ($search_societe) $param.='&search_societe=' .$search_societe;
  337. if ($search_user > 0) $param.='&search_user='.$search_user;
  338. if ($search_sale > 0) $param.='&search_sale='.$search_sale;
  339. if ($search_montant_ht) $param.='&search_montant_ht='.$search_montant_ht;
  340. if ($search_login) $param.='&search_login='.$search_login;
  341. if ($search_town) $param.='&search_town='.$search_town;
  342. if ($search_zip) $param.='&search_zip='.$search_zip;
  343. if ($socid > 0) $param.='&socid='.$socid;
  344. if ($optioncss != '') $param.='&optioncss='.$optioncss;
  345. // Add $param from extra fields
  346. foreach ($search_array_options as $key => $val)
  347. {
  348. $crit=$val;
  349. $tmpkey=preg_replace('/search_options_/','',$key);
  350. if ($val != '') $param.='&search_options_'.$tmpkey.'='.urlencode($val);
  351. }
  352. // List of mass actions available
  353. $arrayofmassactions = array(
  354. 'presend'=>$langs->trans("SendByMail"),
  355. 'builddoc'=>$langs->trans("PDFMerge"),
  356. );
  357. if ($user->rights->propal->supprimer) $arrayofmassactions['delete']=$langs->trans("Delete");
  358. if ($massaction == 'presend') $arrayofmassactions=array();
  359. $massactionbutton=$form->selectMassAction('', $arrayofmassactions);
  360. // Lignes des champs de filtre
  361. print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">';
  362. if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
  363. print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
  364. print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
  365. print '<input type="hidden" name="action" value="list">';
  366. print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
  367. print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
  368. print '<input type="hidden" name="page" value="'.$page.'">';
  369. print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'title_commercial.png', 0, '', '', $limit);
  370. if ($massaction == 'presend')
  371. {
  372. $langs->load("mails");
  373. if (! GETPOST('cancel'))
  374. {
  375. $objecttmp=new Propal($db);
  376. $listofselectedid=array();
  377. $listofselectedthirdparties=array();
  378. $listofselectedref=array();
  379. foreach($arrayofselected as $toselectid)
  380. {
  381. $result=$objecttmp->fetch($toselectid);
  382. if ($result > 0)
  383. {
  384. $listofselectedid[$toselectid]=$toselectid;
  385. $thirdpartyid=$objecttmp->fk_soc?$objecttmp->fk_soc:$objecttmp->socid;
  386. $listofselectedthirdparties[$thirdpartyid]=$thirdpartyid;
  387. $listofselectedref[$thirdpartyid][$toselectid]=$objecttmp->ref;
  388. }
  389. }
  390. }
  391. print '<input type="hidden" name="massaction" value="confirm_presend">';
  392. include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php';
  393. $formmail = new FormMail($db);
  394. dol_fiche_head(null, '', '');
  395. $topicmail="SendSupplierProposalRef";
  396. $modelmail="supplier_proposal_send";
  397. // Cree l'objet formulaire mail
  398. include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php';
  399. $formmail = new FormMail($db);
  400. $formmail->withform=-1;
  401. $formmail->fromtype = (GETPOST('fromtype')?GETPOST('fromtype'):(!empty($conf->global->MAIN_MAIL_DEFAULT_FROMTYPE)?$conf->global->MAIN_MAIL_DEFAULT_FROMTYPE:'user'));
  402. if($formmail->fromtype === 'user'){
  403. $formmail->fromid = $user->id;
  404. }
  405. if (! empty($conf->global->MAIN_EMAIL_ADD_TRACK_ID) && ($conf->global->MAIN_EMAIL_ADD_TRACK_ID & 1)) // If bit 1 is set
  406. {
  407. $formmail->trackid='ord'.$object->id;
  408. }
  409. if (! empty($conf->global->MAIN_EMAIL_ADD_TRACK_ID) && ($conf->global->MAIN_EMAIL_ADD_TRACK_ID & 2)) // If bit 2 is set
  410. {
  411. include DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
  412. $formmail->frommail=dolAddEmailTrackId($formmail->frommail, 'ord'.$object->id);
  413. }
  414. $formmail->withfrom=1;
  415. $liste=$langs->trans("AllRecipientSelected");
  416. if (count($listofselectedthirdparties) == 1)
  417. {
  418. $liste=array();
  419. $thirdpartyid=array_shift($listofselectedthirdparties);
  420. $soc=new Societe($db);
  421. $soc->fetch($thirdpartyid);
  422. foreach ($soc->thirdparty_and_contact_email_array(1) as $key=>$value)
  423. {
  424. $liste[$key]=$value;
  425. }
  426. $formmail->withtoreadonly=0;
  427. }
  428. else
  429. {
  430. $formmail->withtoreadonly=1;
  431. }
  432. $formmail->withto=$liste;
  433. $formmail->withtofree=0;
  434. $formmail->withtocc=1;
  435. $formmail->withtoccc=$conf->global->MAIN_EMAIL_USECCC;
  436. $formmail->withtopic=$langs->transnoentities($topicmail, '__REF__', '__REFCLIENT__');
  437. $formmail->withfile=$langs->trans("OnlyPDFattachmentSupported");
  438. $formmail->withbody=1;
  439. $formmail->withdeliveryreceipt=1;
  440. $formmail->withcancel=1;
  441. // Tableau des substitutions
  442. $formmail->substit['__REF__']='__REF__'; // We want to keep the tag
  443. $formmail->substit['__SIGNATURE__']=$user->signature;
  444. $formmail->substit['__REFCLIENT__']='__REFCLIENT__'; // We want to keep the tag
  445. $formmail->substit['__PERSONALIZED__']='';
  446. $formmail->substit['__CONTACTCIVNAME__']='';
  447. // Tableau des parametres complementaires du post
  448. $formmail->param['action']=$action;
  449. $formmail->param['models']=$modelmail;
  450. $formmail->param['models_id']=GETPOST('modelmailselected','int');
  451. $formmail->param['id']=join(',',$arrayofselected);
  452. //$formmail->param['returnurl']=$_SERVER["PHP_SELF"].'?id='.$object->id;
  453. print $formmail->get_form();
  454. dol_fiche_end();
  455. }
  456. if ($sall)
  457. {
  458. foreach($fieldstosearchall as $key => $val) $fieldstosearchall[$key]=$langs->trans($val);
  459. print $langs->trans("FilterOnInto", $sall) . join(', ',$fieldstosearchall);
  460. }
  461. $i = 0;
  462. $moreforfilter='';
  463. // If the user can view prospects other than his'
  464. if ($user->rights->societe->client->voir || $socid)
  465. {
  466. $langs->load("commercial");
  467. $moreforfilter.='<div class="divsearchfield">';
  468. $moreforfilter.=$langs->trans('ThirdPartiesOfSaleRepresentative'). ': ';
  469. $moreforfilter.=$formother->select_salesrepresentatives($search_sale, 'search_sale', $user, 0, 1, 'maxwidth300');
  470. $moreforfilter.='</div>';
  471. }
  472. // If the user can view prospects other than his'
  473. if ($user->rights->societe->client->voir || $socid)
  474. {
  475. $moreforfilter.='<div class="divsearchfield">';
  476. $moreforfilter.=$langs->trans('LinkedToSpecificUsers'). ': ';
  477. $moreforfilter.=$form->select_dolusers($search_user, 'search_user', 1, '', 0, '', '', 0, 0, 0, '', 0, '', 'maxwidth300');
  478. $moreforfilter.='</div>';
  479. }
  480. // If the user can view products
  481. if ($conf->categorie->enabled && ($user->rights->produit->lire || $user->rights->service->lire))
  482. {
  483. include_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
  484. $moreforfilter.='<div class="divsearchfield">';
  485. $moreforfilter.=$langs->trans('IncludingProductWithTag'). ': ';
  486. $cate_arbo = $form->select_all_categories(Categorie::TYPE_PRODUCT, null, 'parent', null, null, 1);
  487. $moreforfilter.=$form->selectarray('search_product_category', $cate_arbo, $search_product_category, 1, 0, 0, '', 0, 0, 0, 0, 'maxwidth300', 1);
  488. $moreforfilter.='</div>';
  489. }
  490. $parameters=array();
  491. $reshook=$hookmanager->executeHooks('printFieldPreListTitle',$parameters); // Note that $action and $object may have been modified by hook
  492. if (empty($reshook)) $moreforfilter .= $hookmanager->resPrint;
  493. else $moreforfilter = $hookmanager->resPrint;
  494. if (! empty($moreforfilter))
  495. {
  496. print '<div class="liste_titre liste_titre_bydiv centpercent">';
  497. print $moreforfilter;
  498. print '</div>';
  499. }
  500. $varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage;
  501. $selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields
  502. if ($massactionbutton) $selectedfields.=$form->showCheckAddButtons('checkforselect', 1);
  503. print '<div class="div-table-responsive">';
  504. print '<table class="tagtable liste'.($moreforfilter?" listwithfilterbefore":"").'">'."\n";
  505. print '<tr class="liste_titre_filter">';
  506. if (! empty($arrayfields['p.ref']['checked']))
  507. {
  508. print '<td class="liste_titre">';
  509. print '<input class="flat" size="6" type="text" name="search_ref" value="'.$search_ref.'">';
  510. print '</td>';
  511. }
  512. if (! empty($arrayfields['p.ref_client']['checked']))
  513. {
  514. print '<td class="liste_titre">';
  515. print '<input class="flat" size="6" type="text" name="search_refcustomer" value="'.$search_refcustomer.'">';
  516. print '</td>';
  517. }
  518. if (! empty($arrayfields['s.nom']['checked']))
  519. {
  520. print '<td class="liste_titre" align="left">';
  521. print '<input class="flat" type="text" size="10" name="search_societe" value="'.$search_societe.'">';
  522. print '</td>';
  523. }
  524. if (! empty($arrayfields['s.town']['checked'])) print '<td class="liste_titre"><input class="flat" type="text" size="6" name="search_town" value="'.$search_town.'"></td>';
  525. if (! empty($arrayfields['s.zip']['checked'])) print '<td class="liste_titre"><input class="flat" type="text" size="4" name="search_zip" value="'.$search_zip.'"></td>';
  526. // State
  527. if (! empty($arrayfields['state.nom']['checked']))
  528. {
  529. print '<td class="liste_titre">';
  530. print '<input class="flat" size="4" type="text" name="search_state" value="'.dol_escape_htmltag($search_state).'">';
  531. print '</td>';
  532. }
  533. // Country
  534. if (! empty($arrayfields['country.code_iso']['checked']))
  535. {
  536. print '<td class="liste_titre" align="center">';
  537. print $form->select_country($search_country,'search_country','',0,'maxwidth100');
  538. print '</td>';
  539. }
  540. // Company type
  541. if (! empty($arrayfields['typent.code']['checked']))
  542. {
  543. print '<td class="liste_titre maxwidthonsmartphone" align="center">';
  544. print $form->selectarray("search_type_thirdparty", $formcompany->typent_array(0), $search_type_thirdparty, 0, 0, 0, '', 0, 0, 0, (empty($conf->global->SOCIETE_SORT_ON_TYPEENT)?'ASC':$conf->global->SOCIETE_SORT_ON_TYPEENT));
  545. print '</td>';
  546. }
  547. // Date
  548. if (! empty($arrayfields['p.date']['checked']))
  549. {
  550. print '<td class="liste_titre" colspan="1" align="center">';
  551. //print $langs->trans('Month').': ';
  552. if (! empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print '<input class="flat" type="text" size="1" maxlength="2" name="day" value="'.$day.'">';
  553. print '<input class="flat" type="text" size="1" maxlength="2" name="month" value="'.$month.'">';
  554. //print '&nbsp;'.$langs->trans('Year').': ';
  555. $syear = $year;
  556. $formother->select_year($syear,'year',1, 20, 5);
  557. print '</td>';
  558. }
  559. // Date end
  560. if (! empty($arrayfields['p.fin_validite']['checked']))
  561. {
  562. print '<td class="liste_titre" colspan="1">&nbsp;</td>';
  563. }
  564. if (! empty($arrayfields['p.total_ht']['checked']))
  565. {
  566. // Amount
  567. print '<td class="liste_titre" align="right">';
  568. print '<input class="flat" type="text" size="5" name="search_montant_ht" value="'.$search_montant_ht.'">';
  569. print '</td>';
  570. }
  571. if (! empty($arrayfields['p.total_vat']['checked']))
  572. {
  573. // Amount
  574. print '<td class="liste_titre" align="right">';
  575. print '<input class="flat" type="text" size="5" name="search_montant_vat" value="'.$search_montant_vat.'">';
  576. print '</td>';
  577. }
  578. if (! empty($arrayfields['p.total_ttc']['checked']))
  579. {
  580. // Amount
  581. print '<td class="liste_titre" align="right">';
  582. print '<input class="flat" type="text" size="5" name="search_montant_ttc" value="'.$search_montant_ttc.'">';
  583. print '</td>';
  584. }
  585. if (! empty($arrayfields['u.login']['checked']))
  586. {
  587. // Author
  588. print '<td class="liste_titre" align="center">';
  589. print '<input class="flat" size="4" type="text" name="search_login" value="'.$search_login.'">';
  590. print '</td>';
  591. }
  592. // Extra fields
  593. if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label))
  594. {
  595. foreach($extrafields->attribute_label as $key => $val)
  596. {
  597. if (! empty($arrayfields["ef.".$key]['checked']))
  598. {
  599. $align=$extrafields->getAlignFlag($key);
  600. $typeofextrafield=$extrafields->attribute_type[$key];
  601. print '<td class="liste_titre'.($align?' '.$align:'').'">';
  602. if (in_array($typeofextrafield, array('varchar', 'int', 'double', 'select')))
  603. {
  604. $crit=$val;
  605. $tmpkey=preg_replace('/search_options_/','',$key);
  606. $searchclass='';
  607. if (in_array($typeofextrafield, array('varchar', 'select'))) $searchclass='searchstring';
  608. if (in_array($typeofextrafield, array('int', 'double'))) $searchclass='searchnum';
  609. print '<input class="flat'.($searchclass?' '.$searchclass:'').'" size="4" type="text" name="search_options_'.$tmpkey.'" value="'.dol_escape_htmltag($search_array_options['search_options_'.$tmpkey]).'">';
  610. }
  611. print '</td>';
  612. }
  613. }
  614. }
  615. // Fields from hook
  616. $parameters=array('arrayfields'=>$arrayfields);
  617. $reshook=$hookmanager->executeHooks('printFieldListOption',$parameters); // Note that $action and $object may have been modified by hook
  618. print $hookmanager->resPrint;
  619. // Date creation
  620. if (! empty($arrayfields['p.datec']['checked']))
  621. {
  622. print '<td class="liste_titre">';
  623. print '</td>';
  624. }
  625. // Date modification
  626. if (! empty($arrayfields['p.tms']['checked']))
  627. {
  628. print '<td class="liste_titre">';
  629. print '</td>';
  630. }
  631. // Status
  632. if (! empty($arrayfields['p.fk_statut']['checked']))
  633. {
  634. print '<td class="liste_titre maxwidthonsmartphone" align="right">';
  635. $formpropal->selectProposalStatus($viewstatut,1);
  636. print '</td>';
  637. }
  638. // Action column
  639. print '<td class="liste_titre" align="middle">';
  640. $searchpicto=$form->showFilterButtons();
  641. print $searchpicto;
  642. print '</td>';
  643. print "</tr>\n";
  644. // Fields title
  645. print '<tr class="liste_titre">';
  646. if (! empty($arrayfields['p.ref']['checked'])) print_liste_field_titre($arrayfields['p.ref']['label'],$_SERVER["PHP_SELF"],'p.ref','',$param,'',$sortfield,$sortorder);
  647. if (! empty($arrayfields['p.ref_client']['checked'])) print_liste_field_titre($arrayfields['p.ref_client']['label'],$_SERVER["PHP_SELF"],'p.ref_client','',$param,'',$sortfield,$sortorder);
  648. if (! empty($arrayfields['s.nom']['checked'])) print_liste_field_titre($arrayfields['s.nom']['label'],$_SERVER["PHP_SELF"],'s.nom','',$param,'',$sortfield,$sortorder);
  649. if (! empty($arrayfields['s.town']['checked'])) print_liste_field_titre($arrayfields['s.town']['label'],$_SERVER["PHP_SELF"],'s.town','',$param,'',$sortfield,$sortorder);
  650. if (! empty($arrayfields['s.zip']['checked'])) print_liste_field_titre($arrayfields['s.zip']['label'],$_SERVER["PHP_SELF"],'s.zip','',$param,'',$sortfield,$sortorder);
  651. if (! empty($arrayfields['state.nom']['checked'])) print_liste_field_titre($arrayfields['state.nom']['label'],$_SERVER["PHP_SELF"],"state.nom","",$param,'',$sortfield,$sortorder);
  652. if (! empty($arrayfields['country.code_iso']['checked'])) print_liste_field_titre($arrayfields['country.code_iso']['label'],$_SERVER["PHP_SELF"],"country.code_iso","",$param,'align="center"',$sortfield,$sortorder);
  653. if (! empty($arrayfields['typent.code']['checked'])) print_liste_field_titre($arrayfields['typent.code']['label'],$_SERVER["PHP_SELF"],"typent.code","",$param,'align="center"',$sortfield,$sortorder);
  654. if (! empty($arrayfields['p.date']['checked'])) print_liste_field_titre($arrayfields['p.date']['label'],$_SERVER["PHP_SELF"],'p.datep','',$param, 'align="center"',$sortfield,$sortorder);
  655. if (! empty($arrayfields['p.fin_validite']['checked'])) print_liste_field_titre($arrayfields['p.fin_validite']['label'],$_SERVER["PHP_SELF"],'dfv','',$param, 'align="center"',$sortfield,$sortorder);
  656. if (! empty($arrayfields['p.total_ht']['checked'])) print_liste_field_titre($arrayfields['p.total_ht']['label'],$_SERVER["PHP_SELF"],'p.total_ht','',$param, 'align="right"',$sortfield,$sortorder);
  657. if (! empty($arrayfields['p.total_vat']['checked'])) print_liste_field_titre($arrayfields['p.total_vat']['label'],$_SERVER["PHP_SELF"],'p.tva','',$param, 'align="right"',$sortfield,$sortorder);
  658. if (! empty($arrayfields['p.total_ttc']['checked'])) print_liste_field_titre($arrayfields['p.total_ttc']['label'],$_SERVER["PHP_SELF"],'p.total','',$param, 'align="right"',$sortfield,$sortorder);
  659. if (! empty($arrayfields['u.login']['checked'])) print_liste_field_titre($arrayfields['u.login']['label'],$_SERVER["PHP_SELF"],'u.login','',$param,'align="center"',$sortfield,$sortorder);
  660. // Extra fields
  661. if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label))
  662. {
  663. foreach($extrafields->attribute_label as $key => $val)
  664. {
  665. if (! empty($arrayfields["ef.".$key]['checked']))
  666. {
  667. $align=$extrafields->getAlignFlag($key);
  668. print_liste_field_titre($langs->trans($extralabels[$key]),$_SERVER["PHP_SELF"],"ef.".$key,"",$param,($align?'align="'.$align.'"':''),$sortfield,$sortorder);
  669. }
  670. }
  671. }
  672. // Hook fields
  673. $parameters=array('arrayfields'=>$arrayfields);
  674. $reshook=$hookmanager->executeHooks('printFieldListTitle',$parameters); // Note that $action and $object may have been modified by hook
  675. print $hookmanager->resPrint;
  676. if (! empty($arrayfields['p.datec']['checked'])) print_liste_field_titre($arrayfields['p.datec']['label'],$_SERVER["PHP_SELF"],"p.datec","",$param,'align="center" class="nowrap"',$sortfield,$sortorder);
  677. if (! empty($arrayfields['p.tms']['checked'])) print_liste_field_titre($arrayfields['p.tms']['label'],$_SERVER["PHP_SELF"],"p.tms","",$param,'align="center" class="nowrap"',$sortfield,$sortorder);
  678. if (! empty($arrayfields['p.fk_statut']['checked'])) print_liste_field_titre($arrayfields['p.fk_statut']['label'],$_SERVER["PHP_SELF"],"p.fk_statut","",$param,'align="right"',$sortfield,$sortorder);
  679. print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"],"",'','','align="center"',$sortfield,$sortorder,'maxwidthsearch ');
  680. print '</tr>'."\n";
  681. $now = dol_now();
  682. $i=0;
  683. $totalarray=array();
  684. while ($i < min($num,$limit))
  685. {
  686. $obj = $db->fetch_object($resql);
  687. $objectstatic->id=$obj->rowid;
  688. $objectstatic->ref=$obj->ref;
  689. print '<tr class="oddeven">';
  690. if (! empty($arrayfields['p.ref']['checked']))
  691. {
  692. print '<td class="nowrap">';
  693. print '<table class="nobordernopadding"><tr class="nocellnopadd">';
  694. // Picto + Ref
  695. print '<td class="nobordernopadding nowrap">';
  696. print $objectstatic->getNomUrl(1);
  697. print '</td>';
  698. // Warning
  699. $warnornote='';
  700. if ($obj->fk_statut == 1 && $db->jdate($obj->dfv) < ($now - $conf->propal->cloture->warning_delay)) $warnornote.=img_warning($langs->trans("Late"));
  701. if (! empty($obj->note_private))
  702. {
  703. $warnornote.=($warnornote?' ':'');
  704. $warnornote.= '<span class="note">';
  705. $warnornote.= '<a href="note.php?id='.$obj->rowid.'">'.img_picto($langs->trans("ViewPrivateNote"),'object_generic').'</a>';
  706. $warnornote.= '</span>';
  707. }
  708. if ($warnornote)
  709. {
  710. print '<td style="min-width: 20px" class="nobordernopadding nowrap">';
  711. print $warnornote;
  712. print '</td>';
  713. }
  714. // Other picto tool
  715. print '<td width="16" align="right" class="nobordernopadding">';
  716. $filename=dol_sanitizeFileName($obj->ref);
  717. $filedir=$conf->propal->dir_output . '/' . dol_sanitizeFileName($obj->ref);
  718. $urlsource=$_SERVER['PHP_SELF'].'?id='.$obj->rowid;
  719. print $formfile->getDocumentsLink($objectstatic->element, $filename, $filedir);
  720. print '</td></tr></table>';
  721. print "</td>\n";
  722. if (! $i) $totalarray['nbfield']++;
  723. }
  724. if (! empty($arrayfields['p.ref_client']['checked']))
  725. {
  726. // Customer ref
  727. print '<td class="nocellnopadd nowrap">';
  728. print $obj->ref_client;
  729. print '</td>';
  730. if (! $i) $totalarray['nbfield']++;
  731. }
  732. $companystatic->id=$obj->socid;
  733. $companystatic->name=$obj->name;
  734. $companystatic->client=$obj->client;
  735. $companystatic->code_client=$obj->code_client;
  736. // Thirdparty
  737. if (! empty($arrayfields['s.nom']['checked']))
  738. {
  739. print '<td class="tdoverflowmax200">';
  740. print $companystatic->getNomUrl(1,'customer');
  741. print '</td>';
  742. if (! $i) $totalarray['nbfield']++;
  743. }
  744. // Town
  745. if (! empty($arrayfields['s.town']['checked']))
  746. {
  747. print '<td class="nocellnopadd">';
  748. print $obj->town;
  749. print '</td>';
  750. if (! $i) $totalarray['nbfield']++;
  751. }
  752. // Zip
  753. if (! empty($arrayfields['s.zip']['checked']))
  754. {
  755. print '<td class="nocellnopadd">';
  756. print $obj->zip;
  757. print '</td>';
  758. if (! $i) $totalarray['nbfield']++;
  759. }
  760. // State
  761. if (! empty($arrayfields['state.nom']['checked']))
  762. {
  763. print "<td>".$obj->state_name."</td>\n";
  764. if (! $i) $totalarray['nbfield']++;
  765. }
  766. // Country
  767. if (! empty($arrayfields['country.code_iso']['checked']))
  768. {
  769. print '<td align="center">';
  770. $tmparray=getCountry($obj->fk_pays,'all');
  771. print $tmparray['label'];
  772. print '</td>';
  773. if (! $i) $totalarray['nbfield']++;
  774. }
  775. // Type ent
  776. if (! empty($arrayfields['typent.code']['checked']))
  777. {
  778. print '<td align="center">';
  779. if (count($typenArray)==0) $typenArray = $formcompany->typent_array(1);
  780. print $typenArray[$obj->typent_code];
  781. print '</td>';
  782. if (! $i) $totalarray['nbfield']++;
  783. }
  784. // Date proposal
  785. if (! empty($arrayfields['p.date']['checked']))
  786. {
  787. print '<td align="center">';
  788. print dol_print_date($db->jdate($obj->dp), 'day');
  789. print "</td>\n";
  790. if (! $i) $totalarray['nbfield']++;
  791. }
  792. // Date end validity
  793. if (! empty($arrayfields['p.fin_validite']['checked']))
  794. {
  795. if ($obj->dfv)
  796. {
  797. print '<td align="center">'.dol_print_date($db->jdate($obj->dfv),'day');
  798. print '</td>';
  799. }
  800. else
  801. {
  802. print '<td>&nbsp;</td>';
  803. }
  804. if (! $i) $totalarray['nbfield']++;
  805. }
  806. // Amount HT
  807. if (! empty($arrayfields['p.total_ht']['checked']))
  808. {
  809. print '<td align="right">'.price($obj->total_ht)."</td>\n";
  810. if (! $i) $totalarray['nbfield']++;
  811. if (! $i) $totalarray['totalhtfield']=$totalarray['nbfield'];
  812. $totalarray['totalht'] += $obj->total_ht;
  813. }
  814. // Amount VAT
  815. if (! empty($arrayfields['p.total_vat']['checked']))
  816. {
  817. print '<td align="right">'.price($obj->total_vat)."</td>\n";
  818. if (! $i) $totalarray['nbfield']++;
  819. if (! $i) $totalarray['totalvatfield']=$totalarray['nbfield'];
  820. $totalarray['totalvat'] += $obj->total_vat;
  821. }
  822. // Amount TTC
  823. if (! empty($arrayfields['p.total_ttc']['checked']))
  824. {
  825. print '<td align="right">'.price($obj->total_ttc)."</td>\n";
  826. if (! $i) $totalarray['nbfield']++;
  827. if (! $i) $totalarray['totalttcfield']=$totalarray['nbfield'];
  828. $totalarray['totalttc'] += $obj->total_ttc;
  829. }
  830. $userstatic->id=$obj->fk_user_author;
  831. $userstatic->login=$obj->login;
  832. // Author
  833. if (! empty($arrayfields['u.login']['checked']))
  834. {
  835. print '<td align="center">';
  836. if ($userstatic->id) print $userstatic->getLoginUrl(1);
  837. else print '&nbsp;';
  838. print "</td>\n";
  839. if (! $i) $totalarray['nbfield']++;
  840. }
  841. // Extra fields
  842. if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label))
  843. {
  844. foreach($extrafields->attribute_label as $key => $val)
  845. {
  846. if (! empty($arrayfields["ef.".$key]['checked']))
  847. {
  848. print '<td';
  849. $align=$extrafields->getAlignFlag($key);
  850. if ($align) print ' align="'.$align.'"';
  851. print '>';
  852. $tmpkey='options_'.$key;
  853. print $extrafields->showOutputField($key, $obj->$tmpkey, '', 1);
  854. print '</td>';
  855. if (! $i) $totalarray['nbfield']++;
  856. }
  857. }
  858. }
  859. // Fields from hook
  860. $parameters=array('arrayfields'=>$arrayfields, 'obj'=>$obj);
  861. $reshook=$hookmanager->executeHooks('printFieldListValue',$parameters); // Note that $action and $object may have been modified by hook
  862. print $hookmanager->resPrint;
  863. // Date creation
  864. if (! empty($arrayfields['p.datec']['checked']))
  865. {
  866. print '<td align="center" class="nowrap">';
  867. print dol_print_date($db->jdate($obj->date_creation), 'dayhour');
  868. print '</td>';
  869. if (! $i) $totalarray['nbfield']++;
  870. }
  871. // Date modification
  872. if (! empty($arrayfields['p.tms']['checked']))
  873. {
  874. print '<td align="center" class="nowrap">';
  875. print dol_print_date($db->jdate($obj->date_update), 'dayhour');
  876. print '</td>';
  877. if (! $i) $totalarray['nbfield']++;
  878. }
  879. // Status
  880. if (! empty($arrayfields['p.fk_statut']['checked']))
  881. {
  882. print '<td align="right" class="nowrap">'.$objectstatic->LibStatut($obj->fk_statut,5).'</td>';
  883. if (! $i) $totalarray['nbfield']++;
  884. }
  885. // Action column
  886. print '<td class="nowrap" align="center">';
  887. if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
  888. {
  889. $selected=0;
  890. if (in_array($obj->rowid, $arrayofselected)) $selected=1;
  891. print '<input id="cb'.$obj->rowid.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.'"'.($selected?' checked="checked"':'').'>';
  892. }
  893. print '</td>';
  894. if (! $i) $totalarray['nbfield']++;
  895. print "</tr>\n";
  896. $i++;
  897. }
  898. // Show total line
  899. if (isset($totalarray['totalhtfield'])
  900. || isset($totalarray['totalvatfield'])
  901. || isset($totalarray['totalttcfield'])
  902. || isset($totalarray['totalamfield'])
  903. || isset($totalarray['totalrtpfield'])
  904. )
  905. {
  906. print '<tr class="liste_total">';
  907. $i=0;
  908. while ($i < $totalarray['nbfield'])
  909. {
  910. $i++;
  911. if ($i == 1)
  912. {
  913. if ($num < $limit && empty($offset)) print '<td align="left">'.$langs->trans("Total").'</td>';
  914. else print '<td align="left">'.$langs->trans("Totalforthispage").'</td>';
  915. }
  916. elseif ($totalarray['totalhtfield'] == $i) print '<td align="right">'.price($totalarray['totalht']).'</td>';
  917. elseif ($totalarray['totalvatfield'] == $i) print '<td align="right">'.price($totalarray['totalvat']).'</td>';
  918. elseif ($totalarray['totalttcfield'] == $i) print '<td align="right">'.price($totalarray['totalttc']).'</td>';
  919. else print '<td></td>';
  920. }
  921. print '</tr>';
  922. }
  923. $db->free($resql);
  924. $parameters=array('arrayfields'=>$arrayfields, 'sql'=>$sql);
  925. $reshook=$hookmanager->executeHooks('printFieldListFooter',$parameters); // Note that $action and $object may have been modified by hook
  926. print $hookmanager->resPrint;
  927. print '</table>'."\n";
  928. print '</div>'."\n";
  929. print '</form>'."\n";
  930. if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files)
  931. {
  932. /*
  933. * Show list of available documents
  934. */
  935. $urlsource=$_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder;
  936. $urlsource.=str_replace('&amp;','&',$param);
  937. $filedir=$diroutputmassaction;
  938. $genallowed=$user->rights->propal->lire;
  939. $delallowed=$user->rights->propal->lire;
  940. print $formfile->showdocuments('massfilesarea_proposals','',$filedir,$urlsource,0,$delallowed,'',1,1,0,48,1,$param,'','');
  941. }
  942. else
  943. {
  944. print '<br><a name="show_files"></a><a href="'.$_SERVER["PHP_SELF"].'?show_files=1'.$param.'#show_files">'.$langs->trans("ShowTempMassFilesArea").'</a>';
  945. }
  946. }
  947. else
  948. {
  949. dol_print_error($db);
  950. }
  951. // End of page
  952. llxFooter();
  953. $db->close();