list.php 73 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745
  1. <?php
  2. /* Copyright (C) 2002-2006 Rodolphe Quiedeville <rodolphe@quiedeville.org>
  3. * Copyright (C) 2004-2019 Laurent Destailleur <eldy@users.sourceforge.net>
  4. * Copyright (C) 2005-2013 Regis Houssin <regis.houssin@inodbox.com>
  5. * Copyright (C) 2013-2019 Philippe Grand <philippe.grand@atoo-net.com>
  6. * Copyright (C) 2013 Florian Henry <florian.henry@open-concept.pro>
  7. * Copyright (C) 2013 Cédric Salvador <csalvador@gpcsolutions.fr>
  8. * Copyright (C) 2015 Marcos García <marcosgdf@gmail.com>
  9. * Copyright (C) 2015-2007 Juanjo Menent <jmenent@2byte.es>
  10. * Copyright (C) 2015 Abbes Bahfir <bafbes@gmail.com>
  11. * Copyright (C) 2015-2016 Ferran Marcet <fmarcet@2byte.es>
  12. * Copyright (C) 2017 Josep Lluís Amador <joseplluis@lliuretic.cat>
  13. * Copyright (C) 2018 Charlene Benke <charlie@patas-monkey.com>
  14. * Copyright (C) 2018-2020 Frédéric France <frederic.france@netlogic.fr>
  15. * Copyright (C) 2019-2021 Alexandre Spangaro <aspangaro@open-dsi.fr>
  16. *
  17. * This program is free software; you can redistribute it and/or modify
  18. * it under the terms of the GNU General Public License as published by
  19. * the Free Software Foundation; either version 3 of the License, or
  20. * (at your option) any later version.
  21. *
  22. * This program is distributed in the hope that it will be useful,
  23. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  24. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  25. * GNU General Public License for more details.
  26. *
  27. * You should have received a copy of the GNU General Public License
  28. * along with this program. If not, see <https://www.gnu.org/licenses/>.
  29. */
  30. /**
  31. * \file htdocs/fourn/facture/list.php
  32. * \ingroup fournisseur,facture
  33. * \brief List of suppliers invoices
  34. */
  35. require '../../main.inc.php';
  36. require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
  37. require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
  38. require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
  39. require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
  40. require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php';
  41. require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.class.php';
  42. require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
  43. require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
  44. require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
  45. // Load translation files required by the page
  46. $langs->loadLangs(array('products', 'bills', 'companies', 'projects'));
  47. $action = GETPOST('action', 'aZ09');
  48. $massaction = GETPOST('massaction', 'alpha');
  49. $show_files = GETPOST('show_files', 'int');
  50. $confirm = GETPOST('confirm', 'alpha');
  51. $toselect = GETPOST('toselect', 'array');
  52. $optioncss = GETPOST('optioncss', 'alpha');
  53. $contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'supplierinvoicelist';
  54. $socid = GETPOST('socid', 'int');
  55. // Security check
  56. if ($user->socid > 0) {
  57. $action = '';
  58. $_GET["action"] = '';
  59. $socid = $user->socid;
  60. }
  61. $mode = GETPOST("mode", 'aZ09');
  62. $search_all = trim((GETPOST('search_all', 'alphanohtml') != '') ?GETPOST('search_all', 'alphanohtml') : GETPOST('sall', 'alphanohtml'));
  63. $search_label = GETPOST("search_label", "alpha");
  64. $search_amount_no_tax = GETPOST("search_amount_no_tax", "alpha");
  65. $search_amount_all_tax = GETPOST("search_amount_all_tax", "alpha");
  66. $search_product_category = GETPOST('search_product_category', 'int');
  67. $search_ref = GETPOST('sf_ref') ?GETPOST('sf_ref', 'alpha') : GETPOST('search_ref', 'alpha');
  68. $search_refsupplier = GETPOST('search_refsupplier', 'alpha');
  69. $search_type = GETPOST('search_type', 'int');
  70. $search_project = GETPOST('search_project', 'alpha');
  71. $search_company = GETPOST('search_company', 'alpha');
  72. $search_montant_ht = GETPOST('search_montant_ht', 'alpha');
  73. $search_montant_vat = GETPOST('search_montant_vat', 'alpha');
  74. $search_montant_localtax1 = GETPOST('search_montant_localtax1', 'alpha');
  75. $search_montant_localtax2 = GETPOST('search_montant_localtax2', 'alpha');
  76. $search_montant_ttc = GETPOST('search_montant_ttc', 'alpha');
  77. $search_login = GETPOST('search_login', 'alpha');
  78. $search_multicurrency_code = GETPOST('search_multicurrency_code', 'alpha');
  79. $search_multicurrency_tx = GETPOST('search_multicurrency_tx', 'alpha');
  80. $search_multicurrency_montant_ht = GETPOST('search_multicurrency_montant_ht', 'alpha');
  81. $search_multicurrency_montant_vat = GETPOST('search_multicurrency_montant_vat', 'alpha');
  82. $search_multicurrency_montant_ttc = GETPOST('search_multicurrency_montant_ttc', 'alpha');
  83. $search_status = GETPOST('search_status', 'int');
  84. $search_paymentmode = GETPOST('search_paymentmode', 'int');
  85. $search_paymentcond = GETPOST('search_paymentcond', 'int');
  86. $search_town = GETPOST('search_town', 'alpha');
  87. $search_zip = GETPOST('search_zip', 'alpha');
  88. $search_state = GETPOST("search_state");
  89. $search_country = GETPOST("search_country", 'int');
  90. $search_type_thirdparty = GETPOST("search_type_thirdparty", 'int');
  91. $search_user = GETPOST('search_user', 'int');
  92. $search_sale = GETPOST('search_sale', 'int');
  93. $search_date_startday = GETPOST('search_date_startday', 'int');
  94. $search_date_startmonth = GETPOST('search_date_startmonth', 'int');
  95. $search_date_startyear = GETPOST('search_date_startyear', 'int');
  96. $search_date_endday = GETPOST('search_date_endday', 'int');
  97. $search_date_endmonth = GETPOST('search_date_endmonth', 'int');
  98. $search_date_endyear = GETPOST('search_date_endyear', 'int');
  99. $search_date_start = dol_mktime(0, 0, 0, $search_date_startmonth, $search_date_startday, $search_date_startyear); // Use tzserver
  100. $search_date_end = dol_mktime(23, 59, 59, $search_date_endmonth, $search_date_endday, $search_date_endyear);
  101. $search_datelimit_startday = GETPOST('search_datelimit_startday', 'int');
  102. $search_datelimit_startmonth = GETPOST('search_datelimit_startmonth', 'int');
  103. $search_datelimit_startyear = GETPOST('search_datelimit_startyear', 'int');
  104. $search_datelimit_endday = GETPOST('search_datelimit_endday', 'int');
  105. $search_datelimit_endmonth = GETPOST('search_datelimit_endmonth', 'int');
  106. $search_datelimit_endyear = GETPOST('search_datelimit_endyear', 'int');
  107. $search_datelimit_start = dol_mktime(0, 0, 0, $search_datelimit_startmonth, $search_datelimit_startday, $search_datelimit_startyear);
  108. $search_datelimit_end = dol_mktime(23, 59, 59, $search_datelimit_endmonth, $search_datelimit_endday, $search_datelimit_endyear);
  109. $toselect = GETPOST('toselect', 'array');
  110. $search_btn = GETPOST('button_search', 'alpha');
  111. $search_remove_btn = GETPOST('button_removefilter', 'alpha');
  112. $search_categ_sup = trim(GETPOST("search_categ_sup", 'int'));
  113. $option = GETPOST('search_option');
  114. if ($option == 'late') {
  115. $search_status = '1';
  116. }
  117. $filter = GETPOST('filtre', 'alpha');
  118. $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
  119. $sortfield = GETPOST('sortfield', 'aZ09comma');
  120. $sortorder = GETPOST('sortorder', 'aZ09comma');
  121. $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
  122. if ($page == -1 || $page == null || !empty($search_btn) || !empty($search_remove_btn) || (empty($toselect) && $massaction === '0')) {
  123. $page = 0;
  124. }
  125. $offset = $limit * $page;
  126. $pageprev = $page - 1;
  127. $pagenext = $page + 1;
  128. if (!$sortorder) {
  129. $sortorder = "DESC";
  130. }
  131. if (!$sortfield) {
  132. $sortfield = "f.datef,f.rowid";
  133. }
  134. $diroutputmassaction = $conf->fournisseur->facture->dir_output.'/temp/massgeneration/'.$user->id;
  135. $now = dol_now();
  136. // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
  137. $object = new FactureFournisseur($db);
  138. $hookmanager->initHooks(array('supplierinvoicelist'));
  139. $extrafields = new ExtraFields($db);
  140. // fetch optionals attributes and labels
  141. $extrafields->fetch_name_optionals_label($object->table_element);
  142. $search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_');
  143. // List of fields to search into when doing a "search in all"
  144. $fieldstosearchall = array(
  145. 'f.ref'=>'Ref',
  146. 'f.ref_supplier'=>'RefSupplier',
  147. 'pd.description'=>'Description',
  148. 's.nom'=>"ThirdParty",
  149. 'f.note_public'=>'NotePublic',
  150. );
  151. if (empty($user->socid)) {
  152. $fieldstosearchall["f.note_private"] = "NotePrivate";
  153. }
  154. $checkedtypetiers = 0;
  155. $arrayfields = array(
  156. 'f.ref'=>array('label'=>"Ref", 'checked'=>1),
  157. 'f.ref_supplier'=>array('label'=>"RefSupplier", 'checked'=>1),
  158. 'f.type'=>array('label'=>"Type", 'checked'=>0),
  159. 'f.label'=>array('label'=>"Label", 'checked'=>0),
  160. 'f.datef'=>array('label'=>"DateInvoice", 'checked'=>1),
  161. 'f.date_lim_reglement'=>array('label'=>"DateDue", 'checked'=>1),
  162. 'p.ref'=>array('label'=>"ProjectRef", 'checked'=>0),
  163. 's.nom'=>array('label'=>"ThirdParty", 'checked'=>1),
  164. 's.town'=>array('label'=>"Town", 'checked'=>-1),
  165. 's.zip'=>array('label'=>"Zip", 'checked'=>1),
  166. 'state.nom'=>array('label'=>"StateShort", 'checked'=>0),
  167. 'country.code_iso'=>array('label'=>"Country", 'checked'=>0),
  168. 'typent.code'=>array('label'=>"ThirdPartyType", 'checked'=>$checkedtypetiers),
  169. 'f.fk_cond_reglement'=>array('label'=>"PaymentTerm", 'checked'=>1, 'position'=>50),
  170. 'f.fk_mode_reglement'=>array('label'=>"PaymentMode", 'checked'=>1, 'position'=>52),
  171. 'f.total_ht'=>array('label'=>"AmountHT", 'checked'=>1, 'position'=>105),
  172. 'f.total_vat'=>array('label'=>"AmountVAT", 'checked'=>0, 'position'=>110),
  173. 'f.total_localtax1'=>array('label'=>$langs->transcountry("AmountLT1", $mysoc->country_code), 'checked'=>0, 'enabled'=>$mysoc->localtax1_assuj == "1", 'position'=>95),
  174. 'f.total_localtax2'=>array('label'=>$langs->transcountry("AmountLT2", $mysoc->country_code), 'checked'=>0, 'enabled'=>$mysoc->localtax2_assuj == "1", 'position'=>100),
  175. 'f.total_ttc'=>array('label'=>"AmountTTC", 'checked'=>0, 'position'=>115),
  176. 'u.login'=>array('label'=>"Author", 'checked'=>1),
  177. 'dynamount_payed'=>array('label'=>"Paid", 'checked'=>0),
  178. 'rtp'=>array('label'=>"Rest", 'checked'=>0),
  179. 'f.multicurrency_code'=>array('label'=>'Currency', 'checked'=>0, 'enabled'=>(empty($conf->multicurrency->enabled) ? 0 : 1)),
  180. 'f.multicurrency_tx'=>array('label'=>'CurrencyRate', 'checked'=>0, 'enabled'=>(empty($conf->multicurrency->enabled) ? 0 : 1)),
  181. 'f.multicurrency_total_ht'=>array('label'=>'MulticurrencyAmountHT', 'checked'=>0, 'enabled'=>(empty($conf->multicurrency->enabled) ? 0 : 1)),
  182. 'f.multicurrency_total_vat'=>array('label'=>'MulticurrencyAmountVAT', 'checked'=>0, 'enabled'=>(empty($conf->multicurrency->enabled) ? 0 : 1)),
  183. 'f.multicurrency_total_ttc'=>array('label'=>'MulticurrencyAmountTTC', 'checked'=>0, 'enabled'=>(empty($conf->multicurrency->enabled) ? 0 : 1)),
  184. 'multicurrency_dynamount_payed'=>array('label'=>'MulticurrencyAlreadyPaid', 'checked'=>0, 'enabled'=>(empty($conf->multicurrency->enabled) ? 0 : 1)),
  185. 'multicurrency_rtp'=>array('label'=>'MulticurrencyRemainderToPay', 'checked'=>0, 'enabled'=>(empty($conf->multicurrency->enabled) ? 0 : 1)), // Not enabled by default because slow
  186. 'f.datec'=>array('label'=>"DateCreation", 'checked'=>0, 'position'=>500),
  187. 'f.tms'=>array('label'=>"DateModificationShort", 'checked'=>0, 'position'=>500),
  188. 'f.fk_statut'=>array('label'=>"Status", 'checked'=>1, 'position'=>1000),
  189. );
  190. // Extra fields
  191. include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php';
  192. $object->fields = dol_sort_array($object->fields, 'position');
  193. $arrayfields = dol_sort_array($arrayfields, 'position');
  194. if ((empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD))
  195. || (empty($conf->supplier_invoice->enabled) && !empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD))) {
  196. accessforbidden();
  197. }
  198. if ((empty($user->rights->fournisseur->facture->lire) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD))
  199. || (empty($user->rights->supplier_invoice->lire) && !empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD))) {
  200. accessforbidden();
  201. }
  202. /*
  203. * Actions
  204. */
  205. if (GETPOST('cancel', 'alpha')) {
  206. $action = 'list'; $massaction = '';
  207. }
  208. if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') {
  209. $massaction = '';
  210. }
  211. $parameters = array('socid'=>$socid);
  212. $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
  213. if ($reshook < 0) {
  214. setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
  215. }
  216. if (empty($reshook)) {
  217. include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
  218. if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter', 'alpha') || GETPOST('button_removefilter.x', 'alpha')) { // All tests must be present to be compatible with all browsers
  219. $search_all = "";
  220. $search_user = '';
  221. $search_sale = '';
  222. $search_product_category = '';
  223. $search_ref = "";
  224. $search_refsupplier = "";
  225. $search_type = "";
  226. $search_label = "";
  227. $search_project = '';
  228. $search_company = "";
  229. $search_amount_no_tax = "";
  230. $search_amount_all_tax = "";
  231. $search_montant_ht = '';
  232. $search_montant_vat = '';
  233. $search_montant_localtax1 = '';
  234. $search_montant_localtax2 = '';
  235. $search_montant_ttc = '';
  236. $search_login = '';
  237. $search_multicurrency_code = '';
  238. $search_multicurrency_tx = '';
  239. $search_multicurrency_montant_ht = '';
  240. $search_multicurrency_montant_vat = '';
  241. $search_multicurrency_montant_ttc = '';
  242. $search_status = '';
  243. $search_paymentmode = '';
  244. $search_paymentcond = '';
  245. $search_town = '';
  246. $search_zip = "";
  247. $search_state = "";
  248. $search_type = '';
  249. $search_country = '';
  250. $search_type_thirdparty = '';
  251. $search_date_startday = '';
  252. $search_date_startmonth = '';
  253. $search_date_startyear = '';
  254. $search_date_endday = '';
  255. $search_date_endmonth = '';
  256. $search_date_endyear = '';
  257. $search_date_start = '';
  258. $search_date_end = '';
  259. $search_datelimit_startday = '';
  260. $search_datelimit_startmonth = '';
  261. $search_datelimit_startyear = '';
  262. $search_datelimit_endday = '';
  263. $search_datelimit_endmonth = '';
  264. $search_datelimit_endyear = '';
  265. $search_datelimit_start = '';
  266. $search_datelimit_end = '';
  267. $toselect = array();
  268. $search_array_options = array();
  269. $filter = '';
  270. $option = '';
  271. $socid = "";
  272. $search_categ_sup = 0;
  273. }
  274. // Mass actions
  275. $objectclass = 'FactureFournisseur';
  276. $objectlabel = 'SupplierInvoices';
  277. $permissiontoread = ($user->rights->fournisseur->facture->lire || $user->rights->supplier_invoice->lire);
  278. $permissiontoadd = ($user->rights->fournisseur->facture->creer || $user->rights->supplier_invoice->creer);
  279. $permissiontodelete = ($user->rights->fournisseur->facture->supprimer || $user->rights->supplier_invoice->supprimer);
  280. $uploaddir = $conf->fournisseur->facture->dir_output;
  281. include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';
  282. if ($massaction == 'banktransfertrequest') {
  283. $langs->load("withdrawals");
  284. if (!$user->rights->paymentbybanktransfer->create) {
  285. $error++;
  286. setEventMessages($langs->trans("NotEnoughPermissions"), null, 'errors');
  287. } else {
  288. //Checking error
  289. $error = 0;
  290. $arrayofselected = is_array($toselect) ? $toselect : array();
  291. $listofbills = array();
  292. foreach ($arrayofselected as $toselectid) {
  293. $objecttmp = new FactureFournisseur($db);
  294. $result = $objecttmp->fetch($toselectid);
  295. if ($result > 0) {
  296. $totalpaye = $objecttmp->getSommePaiement();
  297. $totalcreditnotes = $objecttmp->getSumCreditNotesUsed();
  298. $totaldeposits = $objecttmp->getSumDepositsUsed();
  299. $objecttmp->resteapayer = price2num($objecttmp->total_ttc - $totalpaye - $totalcreditnotes - $totaldeposits, 'MT');
  300. if ($objecttmp->statut == FactureFournisseur::STATUS_DRAFT) {
  301. $error++;
  302. setEventMessages($objecttmp->ref.' '.$langs->trans("Draft"), $objecttmp->errors, 'errors');
  303. } elseif ($objecttmp->paye || $objecttmp->resteapayer == 0) {
  304. $error++;
  305. setEventMessages($objecttmp->ref.' '.$langs->trans("AlreadyPaid"), $objecttmp->errors, 'errors');
  306. } elseif ($objecttmp->resteapayer < 0) {
  307. $error++;
  308. setEventMessages($objecttmp->ref.' '.$langs->trans("AmountMustBePositive"), $objecttmp->errors, 'errors');
  309. }
  310. $rsql = "SELECT pfd.rowid, pfd.traite, pfd.date_demande as date_demande";
  311. $rsql .= " , pfd.date_traite as date_traite";
  312. $rsql .= " , pfd.amount";
  313. $rsql .= " , u.rowid as user_id, u.lastname, u.firstname, u.login";
  314. $rsql .= " FROM ".MAIN_DB_PREFIX."prelevement_facture_demande as pfd";
  315. $rsql .= " , ".MAIN_DB_PREFIX."user as u";
  316. $rsql .= " WHERE fk_facture_fourn = ".((int) $objecttmp->id);
  317. $rsql .= " AND pfd.fk_user_demande = u.rowid";
  318. $rsql .= " AND pfd.traite = 0";
  319. $rsql .= " ORDER BY pfd.date_demande DESC";
  320. $result_sql = $db->query($rsql);
  321. if ($result_sql) {
  322. $numprlv = $db->num_rows($result_sql);
  323. }
  324. if ($numprlv > 0) {
  325. $error++;
  326. setEventMessages($objecttmp->ref.' '.$langs->trans("RequestAlreadyDone"), $objecttmp->errors, 'warnings');
  327. } elseif (!empty($objecttmp->mode_reglement_code) && $objecttmp->mode_reglement_code != 'VIR') {
  328. $error++;
  329. setEventMessages($objecttmp->ref.' '.$langs->trans("BadPaymentMethod"), $objecttmp->errors, 'errors');
  330. } else {
  331. $listofbills[] = $objecttmp; // $listofbills will only contains invoices with good payment method and no request already done
  332. }
  333. }
  334. }
  335. // Massive withdraw request for request with no errors
  336. if (!empty($listofbills)) {
  337. $nbwithdrawrequestok = 0;
  338. foreach ($listofbills as $aBill) {
  339. $db->begin();
  340. $result = $aBill->demande_prelevement($user, $aBill->resteapayer, 'bank-transfer', 'supplier_invoice');
  341. if ($result > 0) {
  342. $db->commit();
  343. $nbwithdrawrequestok++;
  344. } else {
  345. $db->rollback();
  346. setEventMessages($aBill->error, $aBill->errors, 'errors');
  347. }
  348. }
  349. if ($nbwithdrawrequestok > 0) {
  350. setEventMessages($langs->trans("WithdrawRequestsDone", $nbwithdrawrequestok), null, 'mesgs');
  351. }
  352. }
  353. }
  354. }
  355. }
  356. /*
  357. * View
  358. */
  359. $form = new Form($db);
  360. $formother = new FormOther($db);
  361. $formfile = new FormFile($db);
  362. $bankaccountstatic = new Account($db);
  363. $facturestatic = new FactureFournisseur($db);
  364. $formcompany = new FormCompany($db);
  365. $thirdparty = new Societe($db);
  366. // llxHeader('',$langs->trans("SuppliersInvoices"),'EN:Suppliers_Invoices|FR:FactureFournisseur|ES:Facturas_de_proveedores');
  367. $sql = "SELECT";
  368. if ($search_all || $search_product_category > 0) {
  369. $sql = 'SELECT DISTINCT';
  370. }
  371. $sql .= " f.rowid as facid, f.ref, f.ref_supplier, f.type, f.datef, f.date_lim_reglement as datelimite, f.fk_mode_reglement, f.fk_cond_reglement,";
  372. $sql .= " f.total_ht, f.total_ttc, f.total_tva as total_vat, f.paye as paye, f.fk_statut as fk_statut, f.libelle as label, f.datec as date_creation, f.tms as date_update,";
  373. $sql .= " f.localtax1 as total_localtax1, f.localtax2 as total_localtax2,";
  374. $sql .= ' f.fk_multicurrency, f.multicurrency_code, f.multicurrency_tx, f.multicurrency_total_ht, f.multicurrency_total_tva as multicurrency_total_vat, f.multicurrency_total_ttc,';
  375. $sql .= " f.note_public, f.note_private,";
  376. $sql .= " f.fk_user_author,";
  377. $sql .= " s.rowid as socid, s.nom as name, s.email, s.town, s.zip, s.fk_pays, s.client, s.fournisseur, s.code_client, s.code_fournisseur, s.code_compta as code_compta_client, s.code_compta_fournisseur,";
  378. $sql .= " typent.code as typent_code,";
  379. $sql .= " state.code_departement as state_code, state.nom as state_name,";
  380. $sql .= " country.code as country_code,";
  381. $sql .= " p.rowid as project_id, p.ref as project_ref, p.title as project_label,";
  382. $sql .= ' u.login, u.lastname, u.firstname, u.email as user_email, u.statut as user_statut, u.entity, u.photo, u.office_phone, u.office_fax, u.user_mobile, u.job, u.gender';
  383. if ($search_categ_sup && $search_categ_sup != '-1') {
  384. $sql .= ", cs.fk_categorie, cs.fk_soc";
  385. }
  386. // We need dynamount_payed to be able to sort on status (value is surely wrong because we can count several lines several times due to other left join or link with contacts. But what we need is just 0 or > 0)
  387. // TODO Better solution to be able to sort on already payed or remain to pay is to store amount_payed in a denormalized field.
  388. if (!$search_all) {
  389. $sql .= ', SUM(pf.amount) as dynamount_payed';
  390. }
  391. // Add fields from extrafields
  392. if (!empty($extrafields->attributes[$object->table_element]['label'])) {
  393. foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) {
  394. $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key." as options_".$key : '');
  395. }
  396. }
  397. // Add fields from hooks
  398. $parameters = array();
  399. $reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters); // Note that $action and $object may have been modified by hook
  400. $sql .= $hookmanager->resPrint;
  401. $sql .= ' FROM '.MAIN_DB_PREFIX.'societe as s';
  402. $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as country on (country.rowid = s.fk_pays)";
  403. $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_typent as typent on (typent.id = s.fk_typent)";
  404. $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_departements as state on (state.rowid = s.fk_departement)";
  405. if (!empty($search_categ_sup) && $search_categ_supplier != '-1') {
  406. $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX."categorie_fournisseur as cs ON s.rowid = cs.fk_soc";
  407. }
  408. $sql .= ', '.MAIN_DB_PREFIX.'facture_fourn as f';
  409. if (isset($extrafields->attributes[$object->table_element]['label']) && is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) {
  410. $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (f.rowid = ef.fk_object)";
  411. }
  412. if (!$search_all) {
  413. $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'paiementfourn_facturefourn as pf ON pf.fk_facturefourn = f.rowid';
  414. }
  415. if ($search_all || $search_product_category > 0) {
  416. $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'facture_fourn_det as pd ON f.rowid=pd.fk_facture_fourn';
  417. }
  418. if ($search_product_category > 0) {
  419. $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'categorie_product as cp ON cp.fk_product=pd.fk_product';
  420. }
  421. $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'user AS u ON f.fk_user_author = u.rowid';
  422. $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."projet as p ON p.rowid = f.fk_projet";
  423. // We'll need this table joined to the select in order to filter by sale
  424. if ($search_sale > 0 || (empty($user->rights->societe->client->voir) && !$socid)) {
  425. $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
  426. }
  427. if ($search_user > 0) {
  428. $sql .= ", ".MAIN_DB_PREFIX."element_contact as ec";
  429. $sql .= ", ".MAIN_DB_PREFIX."c_type_contact as tc";
  430. }
  431. // Add table from hooks
  432. $parameters = array();
  433. $reshook = $hookmanager->executeHooks('printFieldListFrom', $parameters, $object); // Note that $action and $object may have been modified by hook
  434. $sql .= $hookmanager->resPrint;
  435. $sql .= ' WHERE f.fk_soc = s.rowid';
  436. $sql .= ' AND f.entity IN ('.getEntity('facture_fourn').')';
  437. if (empty($user->rights->societe->client->voir) && !$socid) {
  438. $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
  439. }
  440. if ($search_product_category > 0) {
  441. $sql .= " AND cp.fk_categorie = ".((int) $search_product_category);
  442. }
  443. if ($socid > 0) {
  444. $sql .= ' AND s.rowid = '.((int) $socid);
  445. }
  446. if ($search_ref) {
  447. if (is_numeric($search_ref)) {
  448. $sql .= natural_search(array('f.ref'), $search_ref);
  449. } else {
  450. $sql .= natural_search('f.ref', $search_ref);
  451. }
  452. }
  453. if ($search_ref) {
  454. $sql .= natural_search('f.ref', $search_ref);
  455. }
  456. if ($search_refsupplier) {
  457. $sql .= natural_search('f.ref_supplier', $search_refsupplier);
  458. }
  459. if ($search_type != '' && $search_type >= 0) {
  460. if ($search_type == '0') {
  461. $sql .= " AND f.type = 0"; // standard
  462. }
  463. if ($search_type == '1') {
  464. $sql .= " AND f.type = 1"; // replacement
  465. }
  466. if ($search_type == '2') {
  467. $sql .= " AND f.type = 2"; // credit note
  468. }
  469. if ($search_type == '3') {
  470. $sql .= " AND f.type = 3"; // deposit
  471. }
  472. //if ($search_type == '4') $sql.=" AND f.type = 4"; // proforma
  473. //if ($search_type == '5') $sql.=" AND f.type = 5"; // situation
  474. }
  475. if ($search_project) {
  476. $sql .= natural_search('p.ref', $search_project);
  477. }
  478. if ($search_company) {
  479. $sql .= natural_search('s.nom', $search_company);
  480. }
  481. if ($search_town) {
  482. $sql .= natural_search('s.town', $search_town);
  483. }
  484. if ($search_zip) {
  485. $sql .= natural_search("s.zip", $search_zip);
  486. }
  487. if ($search_state) {
  488. $sql .= natural_search("state.nom", $search_state);
  489. }
  490. if ($search_country) {
  491. $sql .= " AND s.fk_pays IN (".$db->sanitize($search_country).')';
  492. }
  493. if ($search_type_thirdparty != '' && $search_type_thirdparty >= 0) {
  494. $sql .= " AND s.fk_typent IN (".$db->sanitize($search_type_thirdparty).')';
  495. }
  496. if ($search_montant_ht != '') {
  497. $sql .= natural_search('f.total_ht', $search_montant_ht, 1);
  498. }
  499. if ($search_montant_vat != '') {
  500. $sql .= natural_search('f.total_tva', $search_montant_vat, 1);
  501. }
  502. if ($search_montant_localtax1 != '') {
  503. $sql .= natural_search('f.localtax1', $search_montant_localtax1, 1);
  504. }
  505. if ($search_montant_localtax2 != '') {
  506. $sql .= natural_search('f.localtax2', $search_montant_localtax2, 1);
  507. }
  508. if ($search_montant_ttc != '') {
  509. $sql .= natural_search('f.total_ttc', $search_montant_ttc, 1);
  510. }
  511. if ($search_multicurrency_code != '') {
  512. $sql .= " AND f.multicurrency_code = '".$db->escape($search_multicurrency_code)."'";
  513. }
  514. if ($search_multicurrency_tx != '') {
  515. $sql .= natural_search('f.multicurrency_tx', $search_multicurrency_tx, 1);
  516. }
  517. if ($search_multicurrency_montant_ht != '') {
  518. $sql .= natural_search('f.multicurrency_total_ht', $search_multicurrency_montant_ht, 1);
  519. }
  520. if ($search_multicurrency_montant_vat != '') {
  521. $sql .= natural_search('f.multicurrency_total_tva', $search_multicurrency_montant_vat, 1);
  522. }
  523. if ($search_multicurrency_montant_ttc != '') {
  524. $sql .= natural_search('f.multicurrency_total_ttc', $search_multicurrency_montant_ttc, 1);
  525. }
  526. if ($search_login) {
  527. $sql .= natural_search(array('u.lastname', 'u.firstname', 'u.login'), $search_login);
  528. }
  529. if ($search_status != '' && $search_status >= 0) {
  530. $sql .= " AND f.fk_statut = ".((int) $search_status);
  531. }
  532. if ($search_paymentmode > 0) {
  533. $sql .= " AND f.fk_mode_reglement = ".((int) $search_paymentmode);
  534. }
  535. if ($search_paymentcond > 0) {
  536. $sql .= " AND f.fk_cond_reglement = ".((int) $search_paymentcond);
  537. }
  538. if ($search_date_start) {
  539. $sql .= " AND f.datef >= '" . $db->idate($search_date_start) . "'";
  540. }
  541. if ($search_date_end) {
  542. $sql .= " AND f.datef <= '" . $db->idate($search_date_end) . "'";
  543. }
  544. if ($search_datelimit_start) {
  545. $sql .= " AND f.date_lim_reglement >= '" . $db->idate($search_datelimit_start) . "'";
  546. }
  547. if ($search_datelimit_end) {
  548. $sql .= " AND f.date_lim_reglement <= '" . $db->idate($search_datelimit_end) . "'";
  549. }
  550. if ($option == 'late') {
  551. $sql .= " AND f.date_lim_reglement < '".$db->idate(dol_now() - $conf->facture->fournisseur->warning_delay)."'";
  552. }
  553. if ($search_label) {
  554. $sql .= natural_search('f.libelle', $search_label);
  555. }
  556. if ($search_categ_sup > 0) {
  557. $sql .= " AND cs.fk_categorie = ".((int) $search_categ_sup);
  558. }
  559. if ($search_categ_sup == -2) {
  560. $sql .= " AND cs.fk_categorie IS NULL";
  561. }
  562. if ($search_status != '' && $search_status >= 0) {
  563. $sql .= " AND f.fk_statut = ".((int) $search_status);
  564. }
  565. if ($filter && $filter != -1) {
  566. $aFilter = explode(',', $filter);
  567. foreach ($aFilter as $fil) {
  568. $filt = explode(':', $fil);
  569. $sql .= " AND ".$db->escape(trim($filt[0]))." = '".$db->escape(trim($filt[1]))."'";
  570. }
  571. }
  572. if ($search_sale > 0) {
  573. $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $search_sale);
  574. }
  575. if ($search_user > 0) {
  576. $sql .= " AND ec.fk_c_type_contact = tc.rowid AND tc.element='invoice_supplier' AND tc.source='internal' AND ec.element_id = f.rowid AND ec.fk_socpeople = ".((int) $search_user);
  577. }
  578. // Add where from extra fields
  579. include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php';
  580. // Add where from hooks
  581. $parameters = array();
  582. $reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook
  583. $sql .= $hookmanager->resPrint;
  584. if (!$search_all) {
  585. $sql .= " GROUP BY f.rowid, f.ref, f.ref_supplier, f.type, f.datef, f.date_lim_reglement, f.fk_mode_reglement, f.fk_cond_reglement,";
  586. $sql .= " f.total_ht, f.total_ttc, f.total_tva, f.paye, f.fk_statut, f.libelle, f.datec, f.tms,";
  587. $sql .= " f.localtax1, f.localtax2,";
  588. $sql .= ' f.fk_multicurrency, f.multicurrency_code, f.multicurrency_tx, f.multicurrency_total_ht, f.multicurrency_total_tva, f.multicurrency_total_ttc,';
  589. $sql .= " f.note_public, f.note_private,";
  590. $sql .= " f.fk_user_author,";
  591. $sql .= ' s.rowid, s.nom, s.email, s.town, s.zip, s.fk_pays, s.client, s.fournisseur, s.code_client, s.code_fournisseur, s.code_compta, s.code_compta_fournisseur,';
  592. $sql .= " typent.code,";
  593. $sql .= " state.code_departement, state.nom,";
  594. $sql .= ' country.code,';
  595. $sql .= " p.rowid, p.ref, p.title,";
  596. $sql .= " u.login, u.lastname, u.firstname, u.email, u.statut, u.entity, u.photo, u.office_phone, u.office_fax, u.user_mobile, u.job, u.gender";
  597. if ($search_categ_sup && $search_categ_sup != '-1') {
  598. $sql .= ", cs.fk_categorie, cs.fk_soc";
  599. }
  600. if (!empty($extrafields->attributes[$object->table_element]['label'])) {
  601. foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) {
  602. //prevent error with sql_mode=only_full_group_by
  603. $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ",ef.".$key : '');
  604. }
  605. }
  606. // Add GroupBy from hooks
  607. $parameters = array('all' => $all, 'fieldstosearchall' => $fieldstosearchall);
  608. $reshook = $hookmanager->executeHooks('printFieldListGroupBy', $parameters, $object); // Note that $action and $object may have been modified by hook
  609. $sql .= $hookmanager->resPrint;
  610. } else {
  611. $sql .= natural_search(array_keys($fieldstosearchall), $search_all);
  612. }
  613. // Add HAVING from hooks
  614. $parameters = array();
  615. $reshook = $hookmanager->executeHooks('printFieldListHaving', $parameters, $object); // Note that $action and $object may have been modified by hook
  616. $sql .= empty($hookmanager->resPrint) ? "" : " HAVING 1=1 ".$hookmanager->resPrint;
  617. $sql .= $db->order($sortfield, $sortorder);
  618. $nbtotalofrecords = '';
  619. if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
  620. $result = $db->query($sql);
  621. $nbtotalofrecords = $db->num_rows($result);
  622. if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller then paging size (filtering), goto and load page 0
  623. $page = 0;
  624. $offset = 0;
  625. }
  626. }
  627. $sql .= $db->plimit($limit + 1, $offset);
  628. //print $sql;
  629. $resql = $db->query($sql);
  630. if ($resql) {
  631. $num = $db->num_rows($resql);
  632. $arrayofselected = is_array($toselect) ? $toselect : array();
  633. if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $sall) {
  634. $obj = $db->fetch_object($resql);
  635. $id = $obj->facid;
  636. header("Location: ".DOL_URL_ROOT.'/fourn/facture/card.php?facid='.$id);
  637. exit;
  638. }
  639. llxHeader('', $langs->trans("SuppliersInvoices"), 'EN:Suppliers_Invoices|FR:FactureFournisseur|ES:Facturas_de_proveedores');
  640. if ($socid) {
  641. $soc = new Societe($db);
  642. $soc->fetch($socid);
  643. if (empty($search_company)) {
  644. $search_company = $soc->name;
  645. }
  646. }
  647. $param = '&socid='.$socid;
  648. if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
  649. $param .= '&contextpage='.urlencode($contextpage);
  650. }
  651. if ($limit > 0 && $limit != $conf->liste_limit) {
  652. $param .= '&limit='.urlencode($limit);
  653. }
  654. if ($search_all) {
  655. $param .= '&search_all='.urlencode($search_all);
  656. }
  657. if ($search_date_startday) {
  658. $param .= '&search_date_startday='.urlencode($search_date_startday);
  659. }
  660. if ($search_date_startmonth) {
  661. $param .= '&search_date_startmonth='.urlencode($search_date_startmonth);
  662. }
  663. if ($search_date_startyear) {
  664. $param .= '&search_date_startyear='.urlencode($search_date_startyear);
  665. }
  666. if ($search_date_endday) {
  667. $param .= '&search_date_endday='.urlencode($search_date_endday);
  668. }
  669. if ($search_date_endmonth) {
  670. $param .= '&search_date_endmonth='.urlencode($search_date_endmonth);
  671. }
  672. if ($search_date_endyear) {
  673. $param .= '&search_date_endyear='.urlencode($search_date_endyear);
  674. }
  675. if ($search_datelimit_startday) {
  676. $param .= '&search_datelimit_startday='.urlencode($search_datelimit_startday);
  677. }
  678. if ($search_datelimit_startmonth) {
  679. $param .= '&search_datelimit_startmonth='.urlencode($search_datelimit_startmonth);
  680. }
  681. if ($search_datelimit_startyear) {
  682. $param .= '&search_datelimit_startyear='.urlencode($search_datelimit_startyear);
  683. }
  684. if ($search_datelimit_endday) {
  685. $param .= '&search_datelimit_endday='.urlencode($search_datelimit_endday);
  686. }
  687. if ($search_datelimit_endmonth) {
  688. $param .= '&search_datelimit_endmonth='.urlencode($search_datelimit_endmonth);
  689. }
  690. if ($search_datelimit_endyear) {
  691. $param .= '&search_datelimit_endyear='.urlencode($search_datelimit_endyear);
  692. }
  693. if ($search_ref) {
  694. $param .= '&search_ref='.urlencode($search_ref);
  695. }
  696. if ($search_refsupplier) {
  697. $param .= '&search_refsupplier='.urlencode($search_refsupplier);
  698. }
  699. if ($search_type != '') {
  700. $param .= '&search_type='.urlencode($search_type);
  701. }
  702. if ($search_label) {
  703. $param .= '&search_label='.urlencode($search_label);
  704. }
  705. if ($search_company) {
  706. $param .= '&search_company='.urlencode($search_company);
  707. }
  708. if ($search_login) {
  709. $param .= '&search_login='.urlencode($search_login);
  710. }
  711. if ($search_montant_ht != '') {
  712. $param .= '&search_montant_ht='.urlencode($search_montant_ht);
  713. }
  714. if ($search_montant_vat != '') {
  715. $param .= '&search_montant_vat='.urlencode($search_montant_vat);
  716. }
  717. if ($search_montant_localtax1 != '') {
  718. $param .= '&search_montant_localtax1='.urlencode($search_montant_localtax1);
  719. }
  720. if ($search_montant_localtax2 != '') {
  721. $param .= '&search_montant_localtax2='.urlencode($search_montant_localtax2);
  722. }
  723. if ($search_montant_ttc != '') {
  724. $param .= '&search_montant_ttc='.urlencode($search_montant_ttc);
  725. }
  726. if ($search_multicurrency_code != '') {
  727. $param .= '&search_multicurrency_code='.urlencode($search_multicurrency_code);
  728. }
  729. if ($search_multicurrency_tx != '') {
  730. $param .= '&search_multicurrency_tx='.urlencode($search_multicurrency_tx);
  731. }
  732. if ($search_multicurrency_montant_ht != '') {
  733. $param .= '&search_multicurrency_montant_ht='.urlencode($search_multicurrency_montant_ht);
  734. }
  735. if ($search_multicurrency_montant_vat != '') {
  736. $param .= '&search_multicurrency_montant_vat='.urlencode($search_multicurrency_montant_vat);
  737. }
  738. if ($search_multicurrency_montant_ttc != '') {
  739. $param .= '&search_multicurrency_montant_ttc='.urlencode($search_multicurrency_montant_ttc);
  740. }
  741. if ($search_amount_no_tax) {
  742. $param .= '&search_amount_no_tax='.urlencode($search_amount_no_tax);
  743. }
  744. if ($search_amount_all_tax) {
  745. $param .= '&search_amount_all_tax='.urlencode($search_amount_all_tax);
  746. }
  747. if ($search_status >= 0) {
  748. $param .= "&search_status=".urlencode($search_status);
  749. }
  750. if ($show_files) {
  751. $param .= '&show_files='.urlencode($show_files);
  752. }
  753. if ($option) {
  754. $param .= "&search_option=".urlencode($option);
  755. }
  756. if ($optioncss != '') {
  757. $param .= '&optioncss='.urlencode($optioncss);
  758. }
  759. if ($search_categ_sup > 0) {
  760. $param .= '&search_categ_sup='.urlencode($search_categ_sup);
  761. }
  762. if ($search_type_thirdparty != '' && $search_type_thirdparty > 0) {
  763. $param .= '&search_type_thirdparty='.urlencode($search_type_thirdparty);
  764. }
  765. // Add $param from extra fields
  766. include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
  767. // Add $param from hooks
  768. $parameters = array();
  769. $reshook = $hookmanager->executeHooks('printFieldListSearchParam', $parameters, $object); // Note that $action and $object may have been modified by hook
  770. $param .= $hookmanager->resPrint;
  771. // List of mass actions available
  772. $arrayofmassactions = array(
  773. 'validate'=>img_picto('', 'check', 'class="pictofixedwidth"').$langs->trans("Validate"),
  774. 'generate_doc'=>img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("ReGeneratePDF"),
  775. //'builddoc'=>img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("PDFMerge"),
  776. //'presend'=>img_picto('', 'email', 'class="pictofixedwidth"').$langs->trans("SendByMail"),
  777. );
  778. if (!empty($conf->paymentbybanktransfer->enabled) && !empty($user->rights->paymentbybanktransfer->create)) {
  779. $langs->load('withdrawals');
  780. $arrayofmassactions['banktransfertrequest'] = img_picto('', 'payment', 'class="pictofixedwidth"').$langs->trans("MakeBankTransferOrder");
  781. }
  782. if ($user->rights->fournisseur->facture->supprimer) {
  783. $arrayofmassactions['predelete'] = img_picto('', 'delete', 'class="pictofixedwidth"').$langs->trans("Delete");
  784. }
  785. if (in_array($massaction, array('presend', 'predelete'))) {
  786. $arrayofmassactions = array();
  787. }
  788. $massactionbutton = $form->selectMassAction('', $arrayofmassactions);
  789. $url = DOL_URL_ROOT.'/fourn/facture/card.php?action=create';
  790. if (!empty($socid)) {
  791. $url .= '&socid='.urlencode($socid);
  792. }
  793. $newcardbutton = dolGetButtonTitle($langs->trans('NewBill'), '', 'fa fa-plus-circle', $url, '', ($user->rights->fournisseur->facture->creer || $user->rights->supplier_invoice->creer));
  794. $i = 0;
  795. print '<form method="POST" name="searchFormList" action="'.$_SERVER["PHP_SELF"].'">'."\n";
  796. if ($optioncss != '') {
  797. print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
  798. }
  799. print '<input type="hidden" name="token" value="'.newToken().'">';
  800. print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
  801. print '<input type="hidden" name="action" value="list">';
  802. print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
  803. print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
  804. print '<input type="hidden" name="socid" value="'.$socid.'">';
  805. print_barre_liste($langs->trans("BillsSuppliers").($socid ? ' '.$soc->name : ''), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'supplier_invoice', 0, $newcardbutton, '', $limit, 0, 0, 1);
  806. $topicmail = "SendBillRef";
  807. $modelmail = "invoice_supplier_send";
  808. $objecttmp = new FactureFournisseur($db);
  809. $trackid = 'sinv'.$object->id;
  810. include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php';
  811. if ($search_all) {
  812. foreach ($fieldstosearchall as $key => $val) {
  813. $fieldstosearchall[$key] = $langs->trans($val);
  814. }
  815. print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $search_all).join(', ', $fieldstosearchall).'</div>';
  816. }
  817. // If the user can view prospects other than his'
  818. $moreforfilter = '';
  819. if ($user->rights->user->user->lire) {
  820. $langs->load("commercial");
  821. $moreforfilter .= '<div class="divsearchfield">';
  822. $tmptitle = $langs->trans('ThirdPartiesOfSaleRepresentative');
  823. $moreforfilter .= img_picto($tmptitle, 'user', 'class="pictofixedwidth"').$formother->select_salesrepresentatives($search_sale, 'search_sale', $user, 0, $tmptitle, 'maxwidth200');
  824. $moreforfilter .= '</div>';
  825. }
  826. // If the user can view prospects other than his'
  827. if ($user->rights->user->user->lire) {
  828. $moreforfilter .= '<div class="divsearchfield">';
  829. $tmptitle = $langs->trans('LinkedToSpecificUsers');
  830. $moreforfilter .= img_picto($tmptitle, 'user', 'class="pictofixedwidth"').$form->select_dolusers($search_user, 'search_user', $tmptitle, '', 0, '', '', 0, 0, 0, '', 0, '', 'maxwidth200');
  831. $moreforfilter .= '</div>';
  832. }
  833. // If the user can view prospects other than his'
  834. if (!empty($conf->categorie->enabled) && $user->rights->categorie->lire && ($user->rights->produit->lire || $user->rights->service->lire)) {
  835. include_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
  836. $moreforfilter .= '<div class="divsearchfield">';
  837. $tmptitle = $langs->trans('IncludingProductWithTag');
  838. $cate_arbo = $form->select_all_categories(Categorie::TYPE_PRODUCT, null, 'parent', null, null, 1);
  839. $moreforfilter .= img_picto($tmptitle, 'category', 'class="pictofixedwidth"').$form->selectarray('search_product_category', $cate_arbo, $search_product_category, $tmptitle, 0, 0, '', 0, 0, 0, 0, 'maxwidth300 widthcentpercentminusx', 1);
  840. $moreforfilter .= '</div>';
  841. }
  842. if (!empty($conf->categorie->enabled)) {
  843. require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
  844. $moreforfilter .= '<div class="divsearchfield">';
  845. $tmptitle = $langs->trans('SuppliersCategoriesShort');
  846. $moreforfilter .= img_picto($tmptitle, 'category', 'class="pictofixedwidth"').$formother->select_categories('supplier', $search_categ_sup, 'search_categ_sup', 1, $tmptitle);
  847. $moreforfilter .= '</div>';
  848. }
  849. $parameters = array();
  850. $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook
  851. if (empty($reshook)) {
  852. $moreforfilter .= $hookmanager->resPrint;
  853. } else {
  854. $moreforfilter = $hookmanager->resPrint;
  855. }
  856. if ($moreforfilter) {
  857. print '<div class="liste_titre liste_titre_bydiv centpercent">';
  858. print $moreforfilter;
  859. print '</div>';
  860. }
  861. $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
  862. $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields
  863. if ($massactionbutton) {
  864. $selectedfields .= $form->showCheckAddButtons('checkforselect', 1);
  865. }
  866. print '<div class="div-table-responsive">';
  867. print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n";
  868. // Line for filters
  869. print '<tr class="liste_titre_filter">';
  870. // Ref
  871. if (!empty($arrayfields['f.ref']['checked'])) {
  872. print '<td class="liste_titre left">';
  873. print '<input class="flat maxwidth50" type="text" name="search_ref" value="'.dol_escape_htmltag($search_ref).'">';
  874. print '</td>';
  875. }
  876. // Ref supplier
  877. if (!empty($arrayfields['f.ref_supplier']['checked'])) {
  878. print '<td class="liste_titre">';
  879. print '<input class="flat maxwidth75" type="text" name="search_refsupplier" value="'.dol_escape_htmltag($search_refsupplier).'">';
  880. print '</td>';
  881. }
  882. // Type
  883. if (!empty($arrayfields['f.type']['checked'])) {
  884. print '<td class="liste_titre maxwidthonsmartphone">';
  885. $listtype = array(
  886. FactureFournisseur::TYPE_STANDARD=>$langs->trans("InvoiceStandard"),
  887. FactureFournisseur::TYPE_REPLACEMENT=>$langs->trans("InvoiceReplacement"),
  888. FactureFournisseur::TYPE_CREDIT_NOTE=>$langs->trans("InvoiceAvoir"),
  889. FactureFournisseur::TYPE_DEPOSIT=>$langs->trans("InvoiceDeposit"),
  890. );
  891. /*
  892. if (! empty($conf->global->INVOICE_USE_SITUATION))
  893. {
  894. $listtype[Facture::TYPE_SITUATION] = $langs->trans("InvoiceSituation");
  895. }
  896. */
  897. //$listtype[Facture::TYPE_PROFORMA]=$langs->trans("InvoiceProForma"); // A proformat invoice is not an invoice but must be an order.
  898. print $form->selectarray('search_type', $listtype, $search_type, 1, 0, 0, '', 0, 0, 0, 'ASC', 'maxwidth100');
  899. print '</td>';
  900. }
  901. // Label
  902. if (!empty($arrayfields['f.label']['checked'])) {
  903. print '<td class="liste_titre">';
  904. print '<input class="flat maxwidth75" type="text" name="search_label" value="'.dol_escape_htmltag($search_label).'">';
  905. print '</td>';
  906. }
  907. // Date invoice
  908. if (!empty($arrayfields['f.datef']['checked'])) {
  909. print '<td class="liste_titre center">';
  910. print '<div class="nowrap">';
  911. print $form->selectDate($search_date_start ? $search_date_start : -1, 'search_date_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From'));
  912. print '</div>';
  913. print '<div class="nowrap">';
  914. print $form->selectDate($search_date_end ? $search_date_end : -1, 'search_date_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to'));
  915. print '</div>';
  916. print '</td>';
  917. }
  918. // Date due
  919. if (!empty($arrayfields['f.date_lim_reglement']['checked'])) {
  920. print '<td class="liste_titre center">';
  921. print '<div class="nowrap">';
  922. /*
  923. print $langs->trans('From').' ';
  924. print $form->selectDate($search_datelimit_start ? $search_datelimit_start : -1, 'search_datelimit_start', 0, 0, 1);
  925. print '</div>';
  926. print '<div class="nowrap">';
  927. print $langs->trans('to').' ';*/
  928. print $form->selectDate($search_datelimit_end ? $search_datelimit_end : -1, 'search_datelimit_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("Before"));
  929. print '<br><input type="checkbox" name="search_option" value="late"'.($option == 'late' ? ' checked' : '').'> '.$langs->trans("Alert");
  930. print '</div>';
  931. print '</td>';
  932. }
  933. // Project
  934. if (!empty($arrayfields['p.ref']['checked'])) {
  935. print '<td class="liste_titre"><input class="flat maxwidth50" type="text" name="search_project" value="'.dol_escape_htmltag($search_project).'"></td>';
  936. }
  937. // Thirpdarty
  938. if (!empty($arrayfields['s.nom']['checked'])) {
  939. print '<td class="liste_titre"><input class="flat maxwidth50" type="text" name="search_company" value="'.dol_escape_htmltag($search_company).'"></td>';
  940. }
  941. // Town
  942. if (!empty($arrayfields['s.town']['checked'])) {
  943. print '<td class="liste_titre"><input class="flat maxwidth50" type="text" name="search_town" value="'.dol_escape_htmltag($search_town).'"></td>';
  944. }
  945. // Zip
  946. if (!empty($arrayfields['s.zip']['checked'])) {
  947. print '<td class="liste_titre center"><input class="flat maxwidth50" type="text" name="search_zip" value="'.dol_escape_htmltag($search_zip).'"></td>';
  948. }
  949. // State
  950. if (!empty($arrayfields['state.nom']['checked'])) {
  951. print '<td class="liste_titre">';
  952. print '<input class="flat" size="4" type="text" name="search_state" value="'.dol_escape_htmltag($search_state).'">';
  953. print '</td>';
  954. }
  955. // Country
  956. if (!empty($arrayfields['country.code_iso']['checked'])) {
  957. print '<td class="liste_titre center">';
  958. print $form->select_country($search_country, 'search_country', '', 0, 'minwidth100imp maxwidth100');
  959. print '</td>';
  960. }
  961. // Company type
  962. if (!empty($arrayfields['typent.code']['checked'])) {
  963. print '<td class="liste_titre maxwidthonsmartphone center">';
  964. print $form->selectarray("search_type_thirdparty", $formcompany->typent_array(0), $search_type_thirdparty, 1, 0, 0, '', 0, 0, 0, (empty($conf->global->SOCIETE_SORT_ON_TYPEENT) ? 'ASC' : $conf->global->SOCIETE_SORT_ON_TYPEENT), '', 1);
  965. print '</td>';
  966. }
  967. // Condition of payment
  968. if (!empty($arrayfields['f.fk_cond_reglement']['checked'])) {
  969. print '<td class="liste_titre left">';
  970. $form->select_conditions_paiements($search_paymentcond, 'search_paymentcond', -1, 1, 1, 'maxwidth100');
  971. print '</td>';
  972. }
  973. // Payment mode
  974. if (!empty($arrayfields['f.fk_mode_reglement']['checked'])) {
  975. print '<td class="liste_titre left">';
  976. $form->select_types_paiements($search_paymentmode, 'search_paymentmode', '', 0, 1, 1, 20, 1, 'maxwidth100');
  977. print '</td>';
  978. }
  979. if (!empty($arrayfields['f.total_ht']['checked'])) {
  980. // Amount without tax
  981. print '<td class="liste_titre right">';
  982. print '<input class="flat" type="text" size="5" name="search_montant_ht" value="'.dol_escape_htmltag($search_montant_ht).'">';
  983. print '</td>';
  984. }
  985. if (!empty($arrayfields['f.total_vat']['checked'])) {
  986. // Amount vat
  987. print '<td class="liste_titre right">';
  988. print '<input class="flat" type="text" size="5" name="search_montant_vat" value="'.dol_escape_htmltag($search_montant_vat).'">';
  989. print '</td>';
  990. }
  991. if (!empty($arrayfields['f.total_localtax1']['checked'])) {
  992. // Amount tax 1
  993. print '<td class="liste_titre right">';
  994. print '<input class="flat" type="text" size="5" name="search_montant_localtax1" value="'.dol_escape_htmltag($search_montant_localtax1).'">';
  995. print '</td>';
  996. }
  997. if (!empty($arrayfields['f.total_localtax2']['checked'])) {
  998. // Amount tax 2
  999. print '<td class="liste_titre right">';
  1000. print '<input class="flat" type="text" size="5" name="search_montant_localtax2" value="'.dol_escape_htmltag($search_montant_localtax2).'">';
  1001. print '</td>';
  1002. }
  1003. if (!empty($arrayfields['f.total_ttc']['checked'])) {
  1004. // Amount inc tac
  1005. print '<td class="liste_titre right">';
  1006. print '<input class="flat" type="text" size="5" name="search_montant_ttc" value="'.dol_escape_htmltag($search_montant_ttc).'">';
  1007. print '</td>';
  1008. }
  1009. if (!empty($arrayfields['u.login']['checked'])) {
  1010. // Author
  1011. print '<td class="liste_titre" align="center">';
  1012. print '<input class="flat" size="4" type="text" name="search_login" value="'.dol_escape_htmltag($search_login).'">';
  1013. print '</td>';
  1014. }
  1015. if (!empty($arrayfields['dynamount_payed']['checked'])) {
  1016. print '<td class="liste_titre right">';
  1017. print '</td>';
  1018. }
  1019. if (!empty($arrayfields['rtp']['checked'])) {
  1020. print '<td class="liste_titre">';
  1021. print '</td>';
  1022. }
  1023. if (!empty($arrayfields['f.multicurrency_code']['checked'])) {
  1024. // Currency
  1025. print '<td class="liste_titre">';
  1026. print $form->selectMultiCurrency($search_multicurrency_code, 'search_multicurrency_code', 1);
  1027. print '</td>';
  1028. }
  1029. if (!empty($arrayfields['f.multicurrency_tx']['checked'])) {
  1030. // Currency rate
  1031. print '<td class="liste_titre">';
  1032. print '<input class="flat" type="text" size="4" name="search_multicurrency_tx" value="'.dol_escape_htmltag($search_multicurrency_tx).'">';
  1033. print '</td>';
  1034. }
  1035. if (!empty($arrayfields['f.multicurrency_total_ht']['checked'])) {
  1036. // Amount
  1037. print '<td class="liste_titre right">';
  1038. print '<input class="flat" type="text" size="4" name="search_multicurrency_montant_ht" value="'.dol_escape_htmltag($search_multicurrency_montant_ht).'">';
  1039. print '</td>';
  1040. }
  1041. if (!empty($arrayfields['f.multicurrency_total_vat']['checked'])) {
  1042. // Amount
  1043. print '<td class="liste_titre right">';
  1044. print '<input class="flat" type="text" size="4" name="search_multicurrency_montant_vat" value="'.dol_escape_htmltag($search_multicurrency_montant_vat).'">';
  1045. print '</td>';
  1046. }
  1047. if (!empty($arrayfields['f.multicurrency_total_ttc']['checked'])) {
  1048. // Amount
  1049. print '<td class="liste_titre right">';
  1050. print '<input class="flat" type="text" size="4" name="search_multicurrency_montant_ttc" value="'.dol_escape_htmltag($search_multicurrency_montant_ttc).'">';
  1051. print '</td>';
  1052. }
  1053. if (!empty($arrayfields['multicurrency_dynamount_payed']['checked'])) {
  1054. print '<td class="liste_titre">';
  1055. print '</td>';
  1056. }
  1057. if (!empty($arrayfields['multicurrency_rtp']['checked'])) {
  1058. print '<td class="liste_titre right">';
  1059. print '</td>';
  1060. }
  1061. // Extra fields
  1062. include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php';
  1063. // Fields from hook
  1064. $parameters = array('arrayfields'=>$arrayfields);
  1065. $reshook = $hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook
  1066. print $hookmanager->resPrint;
  1067. // Date creation
  1068. if (!empty($arrayfields['f.datec']['checked'])) {
  1069. print '<td class="liste_titre">';
  1070. print '</td>';
  1071. }
  1072. // Date modification
  1073. if (!empty($arrayfields['f.tms']['checked'])) {
  1074. print '<td class="liste_titre">';
  1075. print '</td>';
  1076. }
  1077. // Status
  1078. if (!empty($arrayfields['f.fk_statut']['checked'])) {
  1079. print '<td class="liste_titre maxwidthonsmartphone right">';
  1080. $liststatus = array('0'=>$langs->trans("Draft"), '1'=>$langs->trans("Unpaid"), '2'=>$langs->trans("Paid"));
  1081. print $form->selectarray('search_status', $liststatus, $search_status, 1, 0, 0, '', 0, 0, 0, '', '', 1);
  1082. print '</td>';
  1083. }
  1084. // Action column
  1085. print '<td class="liste_titre middle">';
  1086. $searchpicto = $form->showFilterButtons();
  1087. print $searchpicto;
  1088. print '</td>';
  1089. print "</tr>\n";
  1090. print '<tr class="liste_titre">';
  1091. if (!empty($arrayfields['f.ref']['checked'])) {
  1092. print_liste_field_titre($arrayfields['f.ref']['label'], $_SERVER['PHP_SELF'], 'f.ref,f.rowid', '', $param, '', $sortfield, $sortorder);
  1093. }
  1094. if (!empty($arrayfields['f.ref_supplier']['checked'])) {
  1095. print_liste_field_titre($arrayfields['f.ref_supplier']['label'], $_SERVER["PHP_SELF"], 'f.ref_supplier', '', $param, '', $sortfield, $sortorder);
  1096. }
  1097. if (!empty($arrayfields['f.type']['checked'])) {
  1098. print_liste_field_titre($arrayfields['f.type']['label'], $_SERVER["PHP_SELF"], 'f.type', '', $param, '', $sortfield, $sortorder);
  1099. }
  1100. if (!empty($arrayfields['f.label']['checked'])) {
  1101. print_liste_field_titre($arrayfields['f.label']['label'], $_SERVER['PHP_SELF'], "f.libelle,f.rowid", '', $param, '', $sortfield, $sortorder);
  1102. }
  1103. if (!empty($arrayfields['f.datef']['checked'])) {
  1104. print_liste_field_titre($arrayfields['f.datef']['label'], $_SERVER['PHP_SELF'], 'f.datef,f.rowid', '', $param, '', $sortfield, $sortorder, 'center ');
  1105. }
  1106. if (!empty($arrayfields['f.date_lim_reglement']['checked'])) {
  1107. print_liste_field_titre($arrayfields['f.date_lim_reglement']['label'], $_SERVER['PHP_SELF'], "f.date_lim_reglement", '', $param, '', $sortfield, $sortorder, 'center ');
  1108. }
  1109. if (!empty($arrayfields['p.ref']['checked'])) {
  1110. print_liste_field_titre($arrayfields['p.ref']['label'], $_SERVER['PHP_SELF'], "p.ref", '', $param, '', $sortfield, $sortorder);
  1111. }
  1112. if (!empty($arrayfields['s.nom']['checked'])) {
  1113. print_liste_field_titre($arrayfields['s.nom']['label'], $_SERVER['PHP_SELF'], 's.nom', '', $param, '', $sortfield, $sortorder);
  1114. }
  1115. if (!empty($arrayfields['s.town']['checked'])) {
  1116. print_liste_field_titre($arrayfields['s.town']['label'], $_SERVER["PHP_SELF"], 's.town', '', $param, '', $sortfield, $sortorder);
  1117. }
  1118. if (!empty($arrayfields['s.zip']['checked'])) {
  1119. print_liste_field_titre($arrayfields['s.zip']['label'], $_SERVER["PHP_SELF"], 's.zip', '', $param, '', $sortfield, $sortorder, 'center ');
  1120. }
  1121. if (!empty($arrayfields['state.nom']['checked'])) {
  1122. print_liste_field_titre($arrayfields['state.nom']['label'], $_SERVER["PHP_SELF"], "state.nom", "", $param, '', $sortfield, $sortorder);
  1123. }
  1124. if (!empty($arrayfields['country.code_iso']['checked'])) {
  1125. print_liste_field_titre($arrayfields['country.code_iso']['label'], $_SERVER["PHP_SELF"], "country.code_iso", "", $param, '', $sortfield, $sortorder, 'center ');
  1126. }
  1127. if (!empty($arrayfields['typent.code']['checked'])) {
  1128. print_liste_field_titre($arrayfields['typent.code']['label'], $_SERVER["PHP_SELF"], "typent.code", "", $param, '', $sortfield, $sortorder, 'center ');
  1129. }
  1130. if (!empty($arrayfields['f.fk_cond_reglement']['checked'])) {
  1131. print_liste_field_titre($arrayfields['f.fk_cond_reglement']['label'], $_SERVER["PHP_SELF"], "f.fk_cond_reglement", "", $param, "", $sortfield, $sortorder);
  1132. }
  1133. if (!empty($arrayfields['f.fk_mode_reglement']['checked'])) {
  1134. print_liste_field_titre($arrayfields['f.fk_mode_reglement']['label'], $_SERVER["PHP_SELF"], "f.fk_mode_reglement", "", $param, "", $sortfield, $sortorder);
  1135. }
  1136. if (!empty($arrayfields['f.total_ht']['checked'])) {
  1137. print_liste_field_titre($arrayfields['f.total_ht']['label'], $_SERVER['PHP_SELF'], 'f.total_ht', '', $param, '', $sortfield, $sortorder, 'right ');
  1138. }
  1139. if (!empty($arrayfields['f.total_vat']['checked'])) {
  1140. print_liste_field_titre($arrayfields['f.total_vat']['label'], $_SERVER['PHP_SELF'], 'f.total_tva', '', $param, '', $sortfield, $sortorder, 'right ');
  1141. }
  1142. if (!empty($arrayfields['f.total_localtax1']['checked'])) {
  1143. print_liste_field_titre($arrayfields['f.total_localtax1']['label'], $_SERVER['PHP_SELF'], 'f.localtax1', '', $param, '', $sortfield, $sortorder, 'right ');
  1144. }
  1145. if (!empty($arrayfields['f.total_localtax2']['checked'])) {
  1146. print_liste_field_titre($arrayfields['f.total_localtax2']['label'], $_SERVER['PHP_SELF'], 'f.localtax2', '', $param, '', $sortfield, $sortorder, 'right ');
  1147. }
  1148. if (!empty($arrayfields['f.total_ttc']['checked'])) {
  1149. print_liste_field_titre($arrayfields['f.total_ttc']['label'], $_SERVER['PHP_SELF'], 'f.total_ttc', '', $param, '', $sortfield, $sortorder, 'right ');
  1150. }
  1151. if (!empty($arrayfields['u.login']['checked'])) {
  1152. print_liste_field_titre($arrayfields['u.login']['label'], $_SERVER["PHP_SELF"], 'u.login', '', $param, 'align="center"', $sortfield, $sortorder);
  1153. }
  1154. if (!empty($arrayfields['dynamount_payed']['checked'])) {
  1155. print_liste_field_titre($arrayfields['dynamount_payed']['label'], $_SERVER['PHP_SELF'], '', '', $param, '', $sortfield, $sortorder, 'right ');
  1156. }
  1157. if (!empty($arrayfields['rtp']['checked'])) {
  1158. print_liste_field_titre($arrayfields['rtp']['label'], $_SERVER['PHP_SELF'], '', '', $param, '', $sortfield, $sortorder, 'right ');
  1159. }
  1160. if (!empty($arrayfields['f.multicurrency_code']['checked'])) {
  1161. print_liste_field_titre($arrayfields['f.multicurrency_code']['label'], $_SERVER['PHP_SELF'], 'f.multicurrency_code', '', $param, '', $sortfield, $sortorder);
  1162. }
  1163. if (!empty($arrayfields['f.multicurrency_tx']['checked'])) {
  1164. print_liste_field_titre($arrayfields['f.multicurrency_tx']['label'], $_SERVER['PHP_SELF'], 'f.multicurrency_tx', '', $param, '', $sortfield, $sortorder);
  1165. }
  1166. if (!empty($arrayfields['f.multicurrency_total_ht']['checked'])) {
  1167. print_liste_field_titre($arrayfields['f.multicurrency_total_ht']['label'], $_SERVER['PHP_SELF'], 'f.multicurrency_total_ht', '', $param, 'class="right"', $sortfield, $sortorder);
  1168. }
  1169. if (!empty($arrayfields['f.multicurrency_total_vat']['checked'])) {
  1170. print_liste_field_titre($arrayfields['f.multicurrency_total_vat']['label'], $_SERVER['PHP_SELF'], 'f.multicurrency_total_tva', '', $param, 'class="right"', $sortfield, $sortorder);
  1171. }
  1172. if (!empty($arrayfields['f.multicurrency_total_ttc']['checked'])) {
  1173. print_liste_field_titre($arrayfields['f.multicurrency_total_ttc']['label'], $_SERVER['PHP_SELF'], 'f.multicurrency_total_ttc', '', $param, 'class="right"', $sortfield, $sortorder);
  1174. }
  1175. if (!empty($arrayfields['multicurrency_dynamount_payed']['checked'])) {
  1176. print_liste_field_titre($arrayfields['multicurrency_dynamount_payed']['label'], $_SERVER['PHP_SELF'], '', '', $param, 'class="right"', $sortfield, $sortorder);
  1177. }
  1178. if (!empty($arrayfields['multicurrency_rtp']['checked'])) {
  1179. print_liste_field_titre($arrayfields['multicurrency_rtp']['label'], $_SERVER['PHP_SELF'], '', '', $param, 'class="right"', $sortfield, $sortorder);
  1180. }
  1181. // Extra fields
  1182. include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php';
  1183. // Hook fields
  1184. $parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder);
  1185. $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters); // Note that $action and $object may have been modified by hook
  1186. print $hookmanager->resPrint;
  1187. if (!empty($arrayfields['f.datec']['checked'])) {
  1188. print_liste_field_titre($arrayfields['f.datec']['label'], $_SERVER["PHP_SELF"], "f.datec", "", $param, '', $sortfield, $sortorder, 'center nowrap ');
  1189. }
  1190. if (!empty($arrayfields['f.tms']['checked'])) {
  1191. print_liste_field_titre($arrayfields['f.tms']['label'], $_SERVER["PHP_SELF"], "f.tms", "", $param, '', $sortfield, $sortorder, 'center nowrap ');
  1192. }
  1193. if (!empty($arrayfields['f.fk_statut']['checked'])) {
  1194. print_liste_field_titre($arrayfields['f.fk_statut']['label'], $_SERVER["PHP_SELF"], "fk_statut,paye,type", "", $param, '', $sortfield, $sortorder, 'right ');
  1195. }
  1196. print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ');
  1197. print "</tr>\n";
  1198. $facturestatic = new FactureFournisseur($db);
  1199. $supplierstatic = new Fournisseur($db);
  1200. $projectstatic = new Project($db);
  1201. $userstatic = new User($db);
  1202. if ($num > 0) {
  1203. $i = 0;
  1204. $totalarray = array();
  1205. while ($i < min($num, $limit)) {
  1206. $obj = $db->fetch_object($resql);
  1207. $datelimit = $db->jdate($obj->datelimite);
  1208. $facturestatic->id = $obj->facid;
  1209. $facturestatic->ref = $obj->ref;
  1210. $facturestatic->type = $obj->type;
  1211. $facturestatic->ref_supplier = $obj->ref_supplier;
  1212. $facturestatic->date_echeance = $db->jdate($obj->datelimite);
  1213. $facturestatic->statut = $obj->fk_statut;
  1214. $facturestatic->note_public = $obj->note_public;
  1215. $facturestatic->note_private = $obj->note_private;
  1216. $facturestatic->multicurrency_code = $obj->multicurrency_code;
  1217. $facturestatic->multicurrency_tx = $obj->multicurrency_tx;
  1218. $facturestatic->multicurrency_total_ht = $obj->multicurrency_total_ht;
  1219. $facturestatic->multicurrency_total_tva = $obj->multicurrency_total_vat;
  1220. $facturestatic->multicurrency_total_ttc = $obj->multicurrency_total_ttc;
  1221. $thirdparty->id = $obj->socid;
  1222. $thirdparty->name = $obj->name;
  1223. $thirdparty->client = $obj->client;
  1224. $thirdparty->fournisseur = $obj->fournisseur;
  1225. $thirdparty->code_client = $obj->code_client;
  1226. $thirdparty->code_compta_client = $obj->code_compta_client;
  1227. $thirdparty->code_fournisseur = $obj->code_fournisseur;
  1228. $thirdparty->code_compta_fournisseur = $obj->code_compta_fournisseur;
  1229. $thirdparty->email = $obj->email;
  1230. $thirdparty->country_code = $obj->country_code;
  1231. $paiement = $facturestatic->getSommePaiement();
  1232. $totalcreditnotes = $facturestatic->getSumCreditNotesUsed();
  1233. $totaldeposits = $facturestatic->getSumDepositsUsed();
  1234. $totalpay = $paiement + $totalcreditnotes + $totaldeposits;
  1235. $remaintopay = $obj->total_ttc - $totalpay;
  1236. $multicurrency_paiement = $facturestatic->getSommePaiement(1);
  1237. $multicurrency_totalcreditnotes = $facturestatic->getSumCreditNotesUsed(1);
  1238. $multicurrency_totaldeposits = $facturestatic->getSumDepositsUsed(1);
  1239. $multicurrency_totalpay = $multicurrency_paiement + $multicurrency_totalcreditnotes + $multicurrency_totaldeposits;
  1240. $multicurrency_remaintopay = price2num($facturestatic->multicurrency_total_ttc - $multicurrency_totalpay);
  1241. $facturestatic->alreadypaid = ($paiement ? $paiement : 0);
  1242. $facturestatic->paye = $obj->paye;
  1243. $facturestatic->statut = $obj->fk_statut;
  1244. $facturestatic->type = $obj->type;
  1245. //If invoice has been converted and the conversion has been used, we dont have remain to pay on invoice
  1246. if ($facturestatic->type == FactureFournisseur::TYPE_CREDIT_NOTE) {
  1247. if ($facturestatic->isCreditNoteUsed()) {
  1248. $remaintopay = -$facturestatic->getSumFromThisCreditNotesNotUsed();
  1249. }
  1250. }
  1251. print '<tr class="oddeven">';
  1252. if (!empty($arrayfields['f.ref']['checked'])) {
  1253. print '<td class="nowraponall">';
  1254. print '<table class="nobordernopadding"><tr class="nocellnopadd">';
  1255. // Picto + Ref
  1256. print '<td class="nobordernopadding nowraponall">';
  1257. print $facturestatic->getNomUrl(1, '', 0, 0, '', 0, -1, 1);
  1258. $filename = dol_sanitizeFileName($obj->ref);
  1259. $filedir = $conf->fournisseur->facture->dir_output.'/'.get_exdir($obj->facid, 2, 0, 0, $facturestatic, 'invoice_supplier').dol_sanitizeFileName($obj->ref);
  1260. $subdir = get_exdir($obj->facid, 2, 0, 0, $facturestatic, 'invoice_supplier').dol_sanitizeFileName($obj->ref);
  1261. print $formfile->getDocumentsLink('facture_fournisseur', $subdir, $filedir);
  1262. print '</td></tr></table>';
  1263. print "</td>\n";
  1264. if (!$i) {
  1265. $totalarray['nbfield']++;
  1266. }
  1267. }
  1268. // Supplier ref
  1269. if (!empty($arrayfields['f.ref_supplier']['checked'])) {
  1270. print '<td class="nowrap tdoverflowmax150" title="'.dol_escape_htmltag($obj->ref_supplier).'">';
  1271. print $obj->ref_supplier;
  1272. print '</td>';
  1273. if (!$i) {
  1274. $totalarray['nbfield']++;
  1275. }
  1276. }
  1277. // Type
  1278. if (!empty($arrayfields['f.type']['checked'])) {
  1279. print '<td class="nowrap">';
  1280. print $facturestatic->getLibType();
  1281. print "</td>";
  1282. if (!$i) {
  1283. $totalarray['nbfield']++;
  1284. }
  1285. }
  1286. // Label
  1287. if (!empty($arrayfields['f.label']['checked'])) {
  1288. print '<td class="nowrap">';
  1289. print $obj->label;
  1290. print '</td>';
  1291. if (!$i) {
  1292. $totalarray['nbfield']++;
  1293. }
  1294. }
  1295. // Date
  1296. if (!empty($arrayfields['f.datef']['checked'])) {
  1297. print '<td class="center nowrap">';
  1298. print dol_print_date($db->jdate($obj->datef), 'day');
  1299. print '</td>';
  1300. if (!$i) {
  1301. $totalarray['nbfield']++;
  1302. }
  1303. }
  1304. // Date limit
  1305. if (!empty($arrayfields['f.date_lim_reglement']['checked'])) {
  1306. print '<td class="center nowraponall">'.dol_print_date($datelimit, 'day');
  1307. if ($facturestatic->hasDelay()) {
  1308. print img_warning($langs->trans('Alert').' - '.$langs->trans('Late'));
  1309. }
  1310. print '</td>';
  1311. if (!$i) {
  1312. $totalarray['nbfield']++;
  1313. }
  1314. }
  1315. // Project
  1316. if (!empty($arrayfields['p.ref']['checked'])) {
  1317. print '<td class="nowrap">';
  1318. if ($obj->project_id > 0) {
  1319. $projectstatic->id = $obj->project_id;
  1320. $projectstatic->ref = $obj->project_ref;
  1321. $projectstatic->title = $obj->project_label;
  1322. print $projectstatic->getNomUrl(1);
  1323. }
  1324. print '</td>';
  1325. if (!$i) {
  1326. $totalarray['nbfield']++;
  1327. }
  1328. }
  1329. // Third party
  1330. if (!empty($arrayfields['s.nom']['checked'])) {
  1331. print '<td class="tdoverflowmax200">';
  1332. print $thirdparty->getNomUrl(1, 'supplier');
  1333. print '</td>';
  1334. if (!$i) {
  1335. $totalarray['nbfield']++;
  1336. }
  1337. }
  1338. // Town
  1339. if (!empty($arrayfields['s.town']['checked'])) {
  1340. print '<td class="nocellnopadd">';
  1341. print $obj->town;
  1342. print '</td>';
  1343. if (!$i) {
  1344. $totalarray['nbfield']++;
  1345. }
  1346. }
  1347. // Zip
  1348. if (!empty($arrayfields['s.zip']['checked'])) {
  1349. print '<td class="nocellnopadd center">';
  1350. print $obj->zip;
  1351. print '</td>';
  1352. if (!$i) {
  1353. $totalarray['nbfield']++;
  1354. }
  1355. }
  1356. // State
  1357. if (!empty($arrayfields['state.nom']['checked'])) {
  1358. print "<td>".$obj->state_name."</td>\n";
  1359. if (!$i) {
  1360. $totalarray['nbfield']++;
  1361. }
  1362. }
  1363. // Country
  1364. if (!empty($arrayfields['country.code_iso']['checked'])) {
  1365. print '<td class="center">';
  1366. $tmparray = getCountry($obj->fk_pays, 'all');
  1367. print $tmparray['label'];
  1368. print '</td>';
  1369. if (!$i) {
  1370. $totalarray['nbfield']++;
  1371. }
  1372. }
  1373. // Type ent
  1374. if (!empty($arrayfields['typent.code']['checked'])) {
  1375. print '<td class="center">';
  1376. if (empty($typenArray)) {
  1377. $typenArray = $formcompany->typent_array(1);
  1378. }
  1379. print $typenArray[$obj->typent_code];
  1380. print '</td>';
  1381. if (!$i) {
  1382. $totalarray['nbfield']++;
  1383. }
  1384. }
  1385. // Payment condition
  1386. if (!empty($arrayfields['f.fk_cond_reglement']['checked'])) {
  1387. print '<td class="tdoverflowmax125">';
  1388. $form->form_conditions_reglement($_SERVER['PHP_SELF'], $obj->fk_cond_reglement, 'none', '', -1);
  1389. print '</td>';
  1390. if (!$i) {
  1391. $totalarray['nbfield']++;
  1392. }
  1393. }
  1394. // Payment mode
  1395. if (!empty($arrayfields['f.fk_mode_reglement']['checked'])) {
  1396. print '<td class="tdoverflowmax125">';
  1397. $form->form_modes_reglement($_SERVER['PHP_SELF'], $obj->fk_mode_reglement, 'none', '', -1);
  1398. print '</td>';
  1399. if (!$i) {
  1400. $totalarray['nbfield']++;
  1401. }
  1402. }
  1403. // Amount HT
  1404. if (!empty($arrayfields['f.total_ht']['checked'])) {
  1405. print '<td class="right nowrap"><span class="amount">'.price($obj->total_ht)."</span></td>\n";
  1406. if (!$i) {
  1407. $totalarray['nbfield']++;
  1408. }
  1409. if (!$i) {
  1410. $totalarray['pos'][$totalarray['nbfield']] = 'f.total_ht';
  1411. }
  1412. $totalarray['val']['f.total_ht'] += $obj->total_ht;
  1413. }
  1414. // Amount VAT
  1415. if (!empty($arrayfields['f.total_vat']['checked'])) {
  1416. print '<td class="right nowrap"><span class="amount">'.price($obj->total_vat)."</span></td>\n";
  1417. if (!$i) {
  1418. $totalarray['nbfield']++;
  1419. }
  1420. if (!$i) {
  1421. $totalarray['pos'][$totalarray['nbfield']] = 'f.total_vat';
  1422. }
  1423. $totalarray['val']['f.total_vat'] += $obj->total_vat;
  1424. }
  1425. // Amount LocalTax1
  1426. if (!empty($arrayfields['f.total_localtax1']['checked'])) {
  1427. print '<td class="right nowrap"><span class="amount">'.price($obj->total_localtax1)."</span></td>\n";
  1428. if (!$i) {
  1429. $totalarray['nbfield']++;
  1430. }
  1431. if (!$i) {
  1432. $totalarray['pos'][$totalarray['nbfield']] = 'f.total_localtax1';
  1433. }
  1434. $totalarray['val']['f.total_localtax1'] += $obj->total_localtax1;
  1435. }
  1436. // Amount LocalTax2
  1437. if (!empty($arrayfields['f.total_localtax2']['checked'])) {
  1438. print '<td class="right nowrap"><span class="amount">'.price($obj->total_localtax2)."</span></td>\n";
  1439. if (!$i) {
  1440. $totalarray['nbfield']++;
  1441. }
  1442. if (!$i) {
  1443. $totalarray['pos'][$totalarray['nbfield']] = 'f.total_localtax2';
  1444. }
  1445. $totalarray['val']['f.total_localtax2'] += $obj->total_localtax2;
  1446. }
  1447. // Amount TTC
  1448. if (!empty($arrayfields['f.total_ttc']['checked'])) {
  1449. print '<td class="right nowrap"><span class="amount">'.price($obj->total_ttc)."</span></td>\n";
  1450. if (!$i) {
  1451. $totalarray['nbfield']++;
  1452. }
  1453. if (!$i) {
  1454. $totalarray['pos'][$totalarray['nbfield']] = 'f.total_ttc';
  1455. }
  1456. $totalarray['val']['f.total_ttc'] += $obj->total_ttc;
  1457. }
  1458. $userstatic->id = $obj->fk_user_author;
  1459. $userstatic->login = $obj->login;
  1460. $userstatic->lastname = $obj->lastname;
  1461. $userstatic->firstname = $obj->firstname;
  1462. $userstatic->email = $obj->user_email;
  1463. $userstatic->statut = $obj->user_statut;
  1464. $userstatic->entity = $obj->entity;
  1465. $userstatic->photo = $obj->photo;
  1466. $userstatic->office_phone = $obj->office_phone;
  1467. $userstatic->office_fax = $obj->office_fax;
  1468. $userstatic->user_mobile = $obj->user_mobile;
  1469. $userstatic->job = $obj->job;
  1470. $userstatic->gender = $obj->gender;
  1471. // Author
  1472. if (!empty($arrayfields['u.login']['checked'])) {
  1473. print '<td class="tdoverflowmax200">';
  1474. if ($userstatic->id) {
  1475. print $userstatic->getLoginUrl(-1);
  1476. } else {
  1477. print '&nbsp;';
  1478. }
  1479. print "</td>\n";
  1480. if (!$i) {
  1481. $totalarray['nbfield']++;
  1482. }
  1483. }
  1484. if (!empty($arrayfields['dynamount_payed']['checked'])) {
  1485. print '<td class="right nowrap"><span class="amount">'.(!empty($totalpay) ?price($totalpay, 0, $langs) : '').'</span></td>'; // TODO Use a denormalized field
  1486. if (!$i) {
  1487. $totalarray['nbfield']++;
  1488. }
  1489. if (!$i) {
  1490. $totalarray['pos'][$totalarray['nbfield']] = 'totalam';
  1491. }
  1492. $totalarray['val']['totalam'] += $totalpay;
  1493. }
  1494. if (!empty($arrayfields['rtp']['checked'])) {
  1495. print '<td class="right nowrap">'.(!empty($remaintopay) ?price($remaintopay, 0, $langs) : '&nbsp;').'</td>'; // TODO Use a denormalized field
  1496. if (!$i) {
  1497. $totalarray['nbfield']++;
  1498. }
  1499. if (!$i) {
  1500. $totalarray['pos'][$totalarray['nbfield']] = 'rtp';
  1501. }
  1502. $totalarray['val']['rtp'] += $remaintopay;
  1503. }
  1504. // Currency
  1505. if (!empty($arrayfields['f.multicurrency_code']['checked'])) {
  1506. print '<td class="nowrap">'.$obj->multicurrency_code.' - '.$langs->trans('Currency'.$obj->multicurrency_code)."</td>\n";
  1507. if (!$i) {
  1508. $totalarray['nbfield']++;
  1509. }
  1510. }
  1511. // Currency rate
  1512. if (!empty($arrayfields['f.multicurrency_tx']['checked'])) {
  1513. print '<td class="nowrap">';
  1514. $form->form_multicurrency_rate($_SERVER['PHP_SELF'].'?id='.$obj->rowid, $obj->multicurrency_tx, 'none', $obj->multicurrency_code);
  1515. print "</td>\n";
  1516. if (!$i) {
  1517. $totalarray['nbfield']++;
  1518. }
  1519. }
  1520. // Amount HT
  1521. if (!empty($arrayfields['f.multicurrency_total_ht']['checked'])) {
  1522. print '<td class="right nowrap"><span class="amount">'.price($obj->multicurrency_total_ht)."</span></td>\n";
  1523. if (!$i) {
  1524. $totalarray['nbfield']++;
  1525. }
  1526. }
  1527. // Amount VAT
  1528. if (!empty($arrayfields['f.multicurrency_total_vat']['checked'])) {
  1529. print '<td class="right nowrap"><span class="amount">'.price($obj->multicurrency_total_vat)."</span></td>\n";
  1530. if (!$i) {
  1531. $totalarray['nbfield']++;
  1532. }
  1533. }
  1534. // Amount TTC
  1535. if (!empty($arrayfields['f.multicurrency_total_ttc']['checked'])) {
  1536. print '<td class="right nowrap"><span class="amount">'.price($obj->multicurrency_total_ttc)."</span></td>\n";
  1537. if (!$i) {
  1538. $totalarray['nbfield']++;
  1539. }
  1540. }
  1541. if (!empty($arrayfields['multicurrency_dynamount_payed']['checked'])) {
  1542. print '<td class="right nowrap"><span class="amount">'.(!empty($multicurrency_totalpay) ?price($multicurrency_totalpay, 0, $langs) : '').'</span></td>'; // TODO Use a denormalized field
  1543. if (!$i) {
  1544. $totalarray['nbfield']++;
  1545. }
  1546. }
  1547. // Pending amount
  1548. if (!empty($arrayfields['multicurrency_rtp']['checked'])) {
  1549. print '<td class="right nowrap"><span class="amount">';
  1550. print (!empty($multicurrency_remaintopay) ? price($multicurrency_remaintopay, 0, $langs) : '');
  1551. print '</span></td>'; // TODO Use a denormalized field
  1552. if (!$i) {
  1553. $totalarray['nbfield']++;
  1554. }
  1555. }
  1556. // Extra fields
  1557. include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php';
  1558. // Fields from hook
  1559. $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray);
  1560. $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook
  1561. print $hookmanager->resPrint;
  1562. // Date creation
  1563. if (!empty($arrayfields['f.datec']['checked'])) {
  1564. print '<td class="center nowrap">';
  1565. print dol_print_date($db->jdate($obj->date_creation), 'dayhour', 'tzuser');
  1566. print '</td>';
  1567. if (!$i) {
  1568. $totalarray['nbfield']++;
  1569. }
  1570. }
  1571. // Date modification
  1572. if (!empty($arrayfields['f.tms']['checked'])) {
  1573. print '<td class="center nowrap">';
  1574. print dol_print_date($db->jdate($obj->date_update), 'dayhour', 'tzuser');
  1575. print '</td>';
  1576. if (!$i) {
  1577. $totalarray['nbfield']++;
  1578. }
  1579. }
  1580. // Status
  1581. if (!empty($arrayfields['f.fk_statut']['checked'])) {
  1582. print '<td class="right nowrap">';
  1583. print $facturestatic->LibStatut($obj->paye, $obj->fk_statut, 5, $paiement, $obj->type);
  1584. print "</td>";
  1585. if (!$i) {
  1586. $totalarray['nbfield']++;
  1587. }
  1588. }
  1589. // Action column
  1590. print '<td class="nowrap center">';
  1591. if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
  1592. $selected = 0;
  1593. if (in_array($obj->facid, $arrayofselected)) {
  1594. $selected = 1;
  1595. }
  1596. print '<input id="cb'.$obj->facid.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->facid.'"'.($selected ? ' checked="checked"' : '').'>';
  1597. }
  1598. print '</td>';
  1599. if (!$i) {
  1600. $totalarray['nbfield']++;
  1601. }
  1602. print "</tr>\n";
  1603. $i++;
  1604. }
  1605. // Show total line
  1606. include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php';
  1607. }
  1608. $db->free($resql);
  1609. $parameters = array('arrayfields'=>$arrayfields, 'sql'=>$sql);
  1610. $reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters); // Note that $action and $object may have been modified by hook
  1611. print $hookmanager->resPrint;
  1612. print "</table>\n";
  1613. print '</div>';
  1614. print "</form>\n";
  1615. $hidegeneratedfilelistifempty = 1;
  1616. if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) {
  1617. $hidegeneratedfilelistifempty = 0;
  1618. }
  1619. // Show list of available documents
  1620. $urlsource = $_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder;
  1621. $urlsource .= str_replace('&amp;', '&', $param);
  1622. $filedir = $diroutputmassaction;
  1623. $genallowed = $user->rights->facture->lire;
  1624. $delallowed = $user->rights->facture->creer;
  1625. $title = '';
  1626. print $formfile->showdocuments('massfilesarea_supplier_invoice', '', $filedir, $urlsource, 0, $delallowed, '', 1, 1, 0, 48, 1, $param, $title, '', '', '', null, $hidegeneratedfilelistifempty);
  1627. } else {
  1628. dol_print_error($db);
  1629. }
  1630. // End of page
  1631. llxFooter();
  1632. $db->close();