lines.php 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550
  1. <?php
  2. /* Copyright (C) 2013-2016 Olivier Geffroy <jeff@jeffinfo.com>
  3. * Copyright (C) 2013-2021 Alexandre Spangaro <aspangaro@open-dsi.fr>
  4. * Copyright (C) 2014-2015 Ari Elbaz (elarifr) <github@accedinfo.com>
  5. * Copyright (C) 2013-2016 Florian Henry <florian.henry@open-concept.pro>
  6. * Copyright (C) 2014 Juanjo Menent <jmenent@2byte.es>
  7. *
  8. * This program is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation; either version 3 of the License, or
  11. * (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program. If not, see <https://www.gnu.org/licenses/>.
  20. */
  21. /**
  22. * \file htdocs/accountancy/supplier/lines.php
  23. * \ingroup Accountancy (Double entries)
  24. * \brief Page of detail of the lines of ventilation of invoices suppliers
  25. */
  26. require '../../main.inc.php';
  27. require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php';
  28. require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
  29. require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
  30. require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php';
  31. require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.product.class.php';
  32. require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingaccount.class.php';
  33. require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
  34. require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php';
  35. require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
  36. require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
  37. // Load translation files required by the page
  38. $langs->loadLangs(array("compta", "bills", "other", "accountancy", "productbatch", "products"));
  39. $optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print')
  40. $account_parent = GETPOST('account_parent');
  41. $changeaccount = GETPOST('changeaccount');
  42. // Search Getpost
  43. $search_societe = GETPOST('search_societe', 'alpha');
  44. $search_lineid = GETPOST('search_lineid', 'int');
  45. $search_ref = GETPOST('search_ref', 'alpha');
  46. $search_invoice = GETPOST('search_invoice', 'alpha');
  47. $search_label = GETPOST('search_label', 'alpha');
  48. $search_desc = GETPOST('search_desc', 'alpha');
  49. $search_amount = GETPOST('search_amount', 'alpha');
  50. $search_account = GETPOST('search_account', 'alpha');
  51. $search_vat = GETPOST('search_vat', 'alpha');
  52. $search_date_startday = GETPOST('search_date_startday', 'int');
  53. $search_date_startmonth = GETPOST('search_date_startmonth', 'int');
  54. $search_date_startyear = GETPOST('search_date_startyear', 'int');
  55. $search_date_endday = GETPOST('search_date_endday', 'int');
  56. $search_date_endmonth = GETPOST('search_date_endmonth', 'int');
  57. $search_date_endyear = GETPOST('search_date_endyear', 'int');
  58. $search_date_start = dol_mktime(0, 0, 0, $search_date_startmonth, $search_date_startday, $search_date_startyear); // Use tzserver
  59. $search_date_end = dol_mktime(23, 59, 59, $search_date_endmonth, $search_date_endday, $search_date_endyear);
  60. $search_country = GETPOST('search_country', 'alpha');
  61. $search_tvaintra = GETPOST('search_tvaintra', 'alpha');
  62. // Load variable for pagination
  63. $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : (empty($conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION) ? $conf->liste_limit : $conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION);
  64. $sortfield = GETPOST('sortfield', 'aZ09comma');
  65. $sortorder = GETPOST('sortorder', 'aZ09comma');
  66. $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
  67. if (empty($page) || $page < 0) {
  68. $page = 0;
  69. }
  70. $offset = $limit * $page;
  71. $pageprev = $page - 1;
  72. $pagenext = $page + 1;
  73. if (!$sortfield) {
  74. $sortfield = "f.datef, f.ref, l.rowid";
  75. }
  76. if (!$sortorder) {
  77. if ($conf->global->ACCOUNTING_LIST_SORT_VENTILATION_DONE > 0) {
  78. $sortorder = "DESC";
  79. }
  80. }
  81. $formaccounting = new FormAccounting($db);
  82. // Security check
  83. if (empty($conf->accounting->enabled)) {
  84. accessforbidden();
  85. }
  86. if ($user->socid > 0) {
  87. accessforbidden();
  88. }
  89. if (empty($user->rights->accounting->mouvements->lire)) {
  90. accessforbidden();
  91. }
  92. $formaccounting = new FormAccounting($db);
  93. /*
  94. * Actions
  95. */
  96. // Purge search criteria
  97. 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
  98. $search_societe = '';
  99. $search_lineid = '';
  100. $search_ref = '';
  101. $search_invoice = '';
  102. $search_label = '';
  103. $search_desc = '';
  104. $search_amount = '';
  105. $search_account = '';
  106. $search_vat = '';
  107. $search_date_startday = '';
  108. $search_date_startmonth = '';
  109. $search_date_startyear = '';
  110. $search_date_endday = '';
  111. $search_date_endmonth = '';
  112. $search_date_endyear = '';
  113. $search_date_start = '';
  114. $search_date_end = '';
  115. $search_country = '';
  116. $search_tvaintra = '';
  117. }
  118. if (is_array($changeaccount) && count($changeaccount) > 0 && $user->rights->accounting->bind->write) {
  119. $error = 0;
  120. if (!(GETPOST('account_parent', 'int') >= 0)) {
  121. $error++;
  122. setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Account")), null, 'errors');
  123. }
  124. if (!$error) {
  125. $db->begin();
  126. $sql1 = "UPDATE ".MAIN_DB_PREFIX."facture_fourn_det as l";
  127. $sql1 .= " SET l.fk_code_ventilation=".(GETPOST('account_parent', 'int') > 0 ? GETPOST('account_parent', 'int') : '0');
  128. $sql1 .= ' WHERE l.rowid IN ('.$db->sanitize(implode(',', $changeaccount)).')';
  129. dol_syslog('accountancy/supplier/lines.php::changeaccount sql= '.$sql1);
  130. $resql1 = $db->query($sql1);
  131. if (!$resql1) {
  132. $error++;
  133. setEventMessages($db->lasterror(), null, 'errors');
  134. }
  135. if (!$error) {
  136. $db->commit();
  137. setEventMessages($langs->trans("Save"), null, 'mesgs');
  138. } else {
  139. $db->rollback();
  140. setEventMessages($db->lasterror(), null, 'errors');
  141. }
  142. $account_parent = ''; // Protection to avoid to mass apply it a second time
  143. }
  144. }
  145. /*
  146. * View
  147. */
  148. $form = new Form($db);
  149. $formother = new FormOther($db);
  150. llxHeader('', $langs->trans("SuppliersVentilation").' - '.$langs->trans("Dispatched"));
  151. print '<script type="text/javascript">
  152. $(function () {
  153. $(\'#select-all\').click(function(event) {
  154. // Iterate each checkbox
  155. $(\':checkbox\').each(function() {
  156. this.checked = true;
  157. });
  158. });
  159. $(\'#unselect-all\').click(function(event) {
  160. // Iterate each checkbox
  161. $(\':checkbox\').each(function() {
  162. this.checked = false;
  163. });
  164. });
  165. });
  166. </script>';
  167. /*
  168. * Supplier Invoice lines
  169. */
  170. $sql = "SELECT f.rowid as facid, f.ref as ref, f.ref_supplier, f.libelle as invoice_label, f.datef, f.fk_soc,";
  171. $sql .= " l.rowid, l.fk_product, l.product_type as line_type, l.description, l.total_ht , l.qty, l.tva_tx, l.vat_src_code,";
  172. $sql .= " aa.label as label_account, aa.labelshort as labelshort_account, aa.account_number,";
  173. $sql .= " p.rowid as product_id, p.fk_product_type as product_type, p.ref as product_ref, p.label as product_label, p.fk_product_type as type, p.tobuy, p.tosell,";
  174. if (!empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED)) {
  175. $sql .= " ppe.accountancy_code_buy, ppe.accountancy_code_buy_intra, ppe.accountancy_code_buy_export,";
  176. } else {
  177. $sql .= " p.accountancy_code_buy, p.accountancy_code_buy_intra, p.accountancy_code_buy_export,";
  178. }
  179. $sql .= " co.code as country_code, co.label as country,";
  180. $sql .= " s.rowid as socid, s.nom as name, s.tva_intra, s.email, s.town, s.zip, s.fk_pays, s.client, s.fournisseur, s.code_client, s.code_fournisseur";
  181. if (!empty($conf->global->MAIN_COMPANY_PERENTITY_SHARED)) {
  182. $sql .= ", spe.accountancy_code_customer as code_compta_client";
  183. $sql .= ", spe.accountancy_code_supplier as code_compta_fournisseur";
  184. } else {
  185. $sql .= ", s.code_compta as code_compta_client";
  186. $sql .= ", s.code_compta_fournisseur";
  187. }
  188. $parameters = array();
  189. $reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters); // Note that $action and $object may have been modified by hook
  190. $sql .= $hookmanager->resPrint;
  191. $sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn_det as l";
  192. $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON p.rowid = l.fk_product";
  193. if (!empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED)) {
  194. $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "product_perentity as ppe ON ppe.fk_product = p.rowid AND ppe.entity = " . ((int) $conf->entity);
  195. }
  196. $sql .= " INNER JOIN ".MAIN_DB_PREFIX."accounting_account as aa ON aa.rowid = l.fk_code_ventilation";
  197. $sql .= " INNER JOIN ".MAIN_DB_PREFIX."facture_fourn as f ON f.rowid = l.fk_facture_fourn";
  198. $sql .= " INNER JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = f.fk_soc";
  199. if (!empty($conf->global->MAIN_COMPANY_PERENTITY_SHARED)) {
  200. $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "societe_perentity as spe ON spe.fk_soc = s.rowid AND spe.entity = " . ((int) $conf->entity);
  201. }
  202. $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as co ON co.rowid = s.fk_pays ";
  203. $sql .= " WHERE f.rowid = l.fk_facture_fourn and f.fk_statut >= 1 AND l.fk_code_ventilation <> 0 ";
  204. // Add search filter like
  205. if ($search_societe) {
  206. $sql .= natural_search('s.nom', $search_societe);
  207. }
  208. if ($search_lineid) {
  209. $sql .= natural_search("l.rowid", $search_lineid, 1);
  210. }
  211. if (strlen(trim($search_invoice))) {
  212. $sql .= natural_search("f.ref", $search_invoice);
  213. }
  214. if (strlen(trim($search_label))) {
  215. $sql .= natural_search("f.libelle", $search_label);
  216. }
  217. if (strlen(trim($search_ref))) {
  218. $sql .= natural_search("p.ref", $search_ref);
  219. }
  220. if (strlen(trim($search_desc))) {
  221. $sql .= natural_search("l.description", $search_desc);
  222. }
  223. if (strlen(trim($search_amount))) {
  224. $sql .= natural_search("l.total_ht", $search_amount, 1);
  225. }
  226. if (strlen(trim($search_account))) {
  227. $sql .= natural_search("aa.account_number", $search_account);
  228. }
  229. if (strlen(trim($search_vat))) {
  230. $sql .= natural_search("l.tva_tx", price2num($search_vat), 1);
  231. }
  232. if ($search_date_start) {
  233. $sql .= " AND f.datef >= '".$db->idate($search_date_start)."'";
  234. }
  235. if ($search_date_end) {
  236. $sql .= " AND f.datef <= '".$db->idate($search_date_end)."'";
  237. }
  238. if (strlen(trim($search_country))) {
  239. $arrayofcode = getCountriesInEEC();
  240. $country_code_in_EEC = $country_code_in_EEC_without_me = '';
  241. foreach ($arrayofcode as $key => $value) {
  242. $country_code_in_EEC .= ($country_code_in_EEC ? "," : "")."'".$value."'";
  243. if ($value != $mysoc->country_code) {
  244. $country_code_in_EEC_without_me .= ($country_code_in_EEC_without_me ? "," : "")."'".$value."'";
  245. }
  246. }
  247. if ($search_country == 'special_allnotme') {
  248. $sql .= " AND co.code <> '".$db->escape($mysoc->country_code)."'";
  249. } elseif ($search_country == 'special_eec') {
  250. $sql .= " AND co.code IN (".$db->sanitize($country_code_in_EEC, 1).")";
  251. } elseif ($search_country == 'special_eecnotme') {
  252. $sql .= " AND co.code IN (".$db->sanitize($country_code_in_EEC_without_me, 1).")";
  253. } elseif ($search_country == 'special_noteec') {
  254. $sql .= " AND co.code NOT IN (".$db->sanitize($country_code_in_EEC, 1).")";
  255. } else {
  256. $sql .= natural_search("co.code", $search_country);
  257. }
  258. }
  259. if (strlen(trim($search_tvaintra))) {
  260. $sql .= natural_search("s.tva_intra", $search_tvaintra);
  261. }
  262. $sql .= " AND f.entity IN (".getEntity('facture_fourn', 0).")"; // We don't share object for accountancy
  263. // Add where from hooks
  264. $parameters = array();
  265. $reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook
  266. $sql .= $hookmanager->resPrint;
  267. $sql .= $db->order($sortfield, $sortorder);
  268. // Count total nb of records
  269. $nbtotalofrecords = '';
  270. if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
  271. $result = $db->query($sql);
  272. $nbtotalofrecords = $db->num_rows($result);
  273. if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller then paging size (filtering), goto and load page 0
  274. $page = 0;
  275. $offset = 0;
  276. }
  277. }
  278. $sql .= $db->plimit($limit + 1, $offset);
  279. dol_syslog("accountancy/supplier/lines.php", LOG_DEBUG);
  280. $result = $db->query($sql);
  281. if ($result) {
  282. $num_lines = $db->num_rows($result);
  283. $i = 0;
  284. $param = '';
  285. if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
  286. $param .= '&contextpage='.urlencode($contextpage);
  287. }
  288. if ($limit > 0 && $limit != $conf->liste_limit) {
  289. $param .= '&limit='.urlencode($limit);
  290. }
  291. if ($search_societe) {
  292. $param .= "&search_societe=".urlencode($search_societe);
  293. }
  294. if ($search_invoice) {
  295. $param .= "&search_invoice=".urlencode($search_invoice);
  296. }
  297. if ($search_ref) {
  298. $param .= "&search_ref=".urlencode($search_ref);
  299. }
  300. if ($search_label) {
  301. $param .= "&search_label=".urlencode($search_label);
  302. }
  303. if ($search_desc) {
  304. $param .= "&search_desc=".urlencode($search_desc);
  305. }
  306. if ($search_account) {
  307. $param .= "&search_account=".urlencode($search_account);
  308. }
  309. if ($search_vat) {
  310. $param .= "&search_vat=".urlencode($search_vat);
  311. }
  312. if ($search_date_startday) {
  313. $param .= '&search_date_startday='.urlencode($search_date_startday);
  314. }
  315. if ($search_date_startmonth) {
  316. $param .= '&search_date_startmonth='.urlencode($search_date_startmonth);
  317. }
  318. if ($search_date_startyear) {
  319. $param .= '&search_date_startyear='.urlencode($search_date_startyear);
  320. }
  321. if ($search_date_endday) {
  322. $param .= '&search_date_endday='.urlencode($search_date_endday);
  323. }
  324. if ($search_date_endmonth) {
  325. $param .= '&search_date_endmonth='.urlencode($search_date_endmonth);
  326. }
  327. if ($search_date_endyear) {
  328. $param .= '&search_date_endyear='.urlencode($search_date_endyear);
  329. }
  330. if ($search_country) {
  331. $param .= "&search_country=".urlencode($search_country);
  332. }
  333. if ($search_tvaintra) {
  334. $param .= "&search_tvaintra=".urlencode($search_tvaintra);
  335. }
  336. print '<form action="'.$_SERVER["PHP_SELF"].'" method="post">'."\n";
  337. print '<input type="hidden" name="action" value="ventil">';
  338. if ($optioncss != '') {
  339. print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
  340. }
  341. print '<input type="hidden" name="token" value="'.newToken().'">';
  342. print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
  343. print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
  344. print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
  345. print '<input type="hidden" name="page" value="'.$page.'">';
  346. print_barre_liste($langs->trans("InvoiceLinesDone"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num_lines, $nbtotalofrecords, 'title_accountancy', 0, '', '', $limit);
  347. print '<span class="opacitymedium">'.$langs->trans("DescVentilDoneSupplier").'</span><br>';
  348. print '<br><div class="inline-block divButAction paddingbottom">'.$langs->trans("ChangeAccount").' ';
  349. print $formaccounting->select_account($account_parent, 'account_parent', 2, array(), 0, 0, 'maxwidth300 maxwidthonsmartphone valignmiddle');
  350. print '<input type="submit" class="button small valignmiddle" value="'.$langs->trans("ChangeBinding").'"/></div>';
  351. $moreforfilter = '';
  352. print '<div class="div-table-responsive">';
  353. print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n";
  354. // We add search filter
  355. print '<tr class="liste_titre_filter">';
  356. print '<td class="liste_titre"><input type="text" class="flat maxwidth25" name="search_lineid" value="'.dol_escape_htmltag($search_lineid).'"></td>';
  357. print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_invoice" value="'.dol_escape_htmltag($search_invoice).'"></td>';
  358. print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_label" value="'.dol_escape_htmltag($search_label).'"></td>';
  359. print '<td class="liste_titre center">';
  360. print '<div class="nowrap">';
  361. print $form->selectDate($search_date_start ? $search_date_start : -1, 'search_date_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From'));
  362. print '</div>';
  363. print '<div class="nowrap">';
  364. print $form->selectDate($search_date_end ? $search_date_end : -1, 'search_date_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to'));
  365. print '</div>';
  366. print '</td>';
  367. print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_ref" value="'.dol_escape_htmltag($search_ref).'"></td>';
  368. print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_desc" value="'.dol_escape_htmltag($search_desc).'"></td>';
  369. print '<td class="liste_titre right"><input type="text" class="right flat maxwidth50" name="search_amount" value="'.dol_escape_htmltag($search_amount).'"></td>';
  370. print '<td class="liste_titre right"><input type="text" class="right flat maxwidth50" name="search_vat" placeholder="%" size="1" value="'.dol_escape_htmltag($search_vat).'"></td>';
  371. print '<td class="liste_titre"><input type="text" class="flat maxwidth75imp" name="search_societe" value="'.dol_escape_htmltag($search_societe).'"></td>';
  372. print '<td class="liste_titre">';
  373. print $form->select_country($search_country, 'search_country', '', 0, 'maxwidth150', 'code2', 1, 0, 1);
  374. // print '<input type="text" class="flat maxwidth50" name="search_country" value="' . dol_escape_htmltag($search_country) . '">';
  375. print '</td>';
  376. print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_tvaintra" value="'.dol_escape_htmltag($search_tvaintra).'"></td>';
  377. print '<td class="liste_titre center"><input type="text" class="flat maxwidth50" name="search_account" value="'.dol_escape_htmltag($search_account).'"></td>';
  378. print '<td class="liste_titre center">';
  379. $searchpicto = $form->showFilterButtons();
  380. print $searchpicto;
  381. print "</td></tr>\n";
  382. print '<tr class="liste_titre">';
  383. print_liste_field_titre("LineId", $_SERVER["PHP_SELF"], "l.rowid", "", $param, '', $sortfield, $sortorder);
  384. print_liste_field_titre("Invoice", $_SERVER["PHP_SELF"], "f.ref", "", $param, '', $sortfield, $sortorder);
  385. print_liste_field_titre("InvoiceLabel", $_SERVER["PHP_SELF"], "f.libelle", "", $param, '', $sortfield, $sortorder);
  386. print_liste_field_titre("Date", $_SERVER["PHP_SELF"], "f.datef, f.ref, l.rowid", "", $param, '', $sortfield, $sortorder, 'center ');
  387. print_liste_field_titre("ProductRef", $_SERVER["PHP_SELF"], "p.ref", "", $param, '', $sortfield, $sortorder);
  388. //print_liste_field_titre("ProductLabel", $_SERVER["PHP_SELF"], "p.label", "", $param, '', $sortfield, $sortorder);
  389. print_liste_field_titre("ProductDescription", $_SERVER["PHP_SELF"], "l.description", "", $param, '', $sortfield, $sortorder);
  390. print_liste_field_titre("Amount", $_SERVER["PHP_SELF"], "l.total_ht", "", $param, '', $sortfield, $sortorder, 'right ');
  391. print_liste_field_titre("VATRate", $_SERVER["PHP_SELF"], "l.tva_tx", "", $param, '', $sortfield, $sortorder, 'right ');
  392. print_liste_field_titre("ThirdParty", $_SERVER["PHP_SELF"], "s.nom", "", $param, '', $sortfield, $sortorder);
  393. print_liste_field_titre("Country", $_SERVER["PHP_SELF"], "co.label", "", $param, '', $sortfield, $sortorder);
  394. print_liste_field_titre("VATIntraShort", $_SERVER["PHP_SELF"], "s.tva_intra", "", $param, '', $sortfield, $sortorder);
  395. print_liste_field_titre("AccountAccounting", $_SERVER["PHP_SELF"], "aa.account_number", "", $param, '', $sortfield, $sortorder);
  396. $checkpicto = $form->showCheckAddButtons();
  397. print_liste_field_titre($checkpicto, '', '', '', '', '', '', '', 'center ');
  398. print "</tr>\n";
  399. $thirdpartystatic = new Societe($db);
  400. $facturefournisseur_static = new FactureFournisseur($db);
  401. $productstatic = new ProductFournisseur($db);
  402. $accountingaccountstatic = new AccountingAccount($db);
  403. $i = 0;
  404. while ($i < min($num_lines, $limit)) {
  405. $objp = $db->fetch_object($result);
  406. $facturefournisseur_static->ref = $objp->ref;
  407. $facturefournisseur_static->id = $objp->facid;
  408. $thirdpartystatic->id = $objp->socid;
  409. $thirdpartystatic->name = $objp->name;
  410. $thirdpartystatic->client = $objp->client;
  411. $thirdpartystatic->fournisseur = $objp->fournisseur;
  412. $thirdpartystatic->code_client = $objp->code_client;
  413. $thirdpartystatic->code_compta_client = $objp->code_compta_client;
  414. $thirdpartystatic->code_fournisseur = $objp->code_fournisseur;
  415. $thirdpartystatic->code_compta_fournisseur = $objp->code_compta_fournisseur;
  416. $thirdpartystatic->email = $objp->email;
  417. $thirdpartystatic->country_code = $objp->country_code;
  418. $productstatic->ref = $objp->product_ref;
  419. $productstatic->id = $objp->product_id;
  420. $productstatic->label = $objp->product_label;
  421. $productstatic->type = $objp->line_type;
  422. $productstatic->status = $objp->tosell;
  423. $productstatic->status_buy = $objp->tobuy;
  424. $productstatic->accountancy_code_buy = $objp->accountancy_code_buy;
  425. $productstatic->accountancy_code_buy_intra = $objp->accountancy_code_sell_buy;
  426. $productstatic->accountancy_code_buy_export = $objp->accountancy_code_sell_buy;
  427. $accountingaccountstatic->rowid = $objp->fk_compte;
  428. $accountingaccountstatic->label = $objp->label_account;
  429. $accountingaccountstatic->labelshort = $objp->labelshort_account;
  430. $accountingaccountstatic->account_number = $objp->account_number;
  431. print '<tr class="oddeven">';
  432. // Line id
  433. print '<td>'.$objp->rowid.'</td>';
  434. // Ref Invoice
  435. print '<td class="nowraponall">'.$facturefournisseur_static->getNomUrl(1).'</td>';
  436. print '<td class="tdoverflowonsmartphone">';
  437. print $objp->invoice_label;
  438. print '</td>';
  439. // Date invoice
  440. print '<td class="center">'.dol_print_date($db->jdate($objp->datef), 'day').'</td>';
  441. // Ref Product
  442. print '<td class="tdoverflowmax100">';
  443. if ($productstatic->id > 0) {
  444. print $productstatic->getNomUrl(1);
  445. }
  446. if ($productstatic->id > 0 && $objp->product_label) {
  447. print '<br>';
  448. }
  449. if ($objp->product_label) {
  450. print '<span class="opacitymedium">'.$objp->product_label.'</span>';
  451. }
  452. print '</td>';
  453. print '<td class="tdoverflowonsmartphone">';
  454. $text = dolGetFirstLineOfText(dol_string_nohtmltag($objp->description));
  455. $trunclength = empty($conf->global->ACCOUNTING_LENGTH_DESCRIPTION) ? 32 : $conf->global->ACCOUNTING_LENGTH_DESCRIPTION;
  456. print $form->textwithtooltip(dol_trunc($text, $trunclength), $objp->description);
  457. print '</td>';
  458. print '<td class="right nowraponall amount">'.price($objp->total_ht).'</td>';
  459. print '<td class="right">'.vatrate($objp->tva_tx.($objp->vat_src_code ? ' ('.$objp->vat_src_code.')' : '')).'</td>';
  460. // Thirdparty
  461. print '<td class="tdoverflowmax100">'.$thirdpartystatic->getNomUrl(1, 'supplier').'</td>';
  462. // Country
  463. print '<td>';
  464. if ($objp->country_code) {
  465. print $langs->trans("Country".$objp->country_code).' ('.$objp->country_code.')';
  466. }
  467. print '</td>';
  468. print '<td>'.$objp->tva_intra.'</td>';
  469. print '<td>';
  470. print $accountingaccountstatic->getNomUrl(0, 1, 1, '', 1);
  471. print ' <a class="editfielda" href="./card.php?id='.$objp->rowid.'&backtopage='.urlencode($_SERVER["PHP_SELF"].($param ? '?'.$param : '')).'">';
  472. print img_edit();
  473. print '</a></td>';
  474. print '<td class="center"><input type="checkbox" class="checkforaction" name="changeaccount[]" value="'.$objp->rowid.'"/></td>';
  475. print '</tr>';
  476. $i++;
  477. }
  478. print '</table>';
  479. print "</div>";
  480. if ($nbtotalofrecords > $limit) {
  481. print_barre_liste('', $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num_lines, $nbtotalofrecords, '', 0, '', '', $limit, 1);
  482. }
  483. print '</form>';
  484. } else {
  485. print $db->lasterror();
  486. }
  487. // End of page
  488. llxFooter();
  489. $db->close();