list.php 38 KB

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