list.php 54 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436
  1. <?php
  2. /* Copyright (C) 2001-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
  3. * Copyright (C) 2004-2015 Laurent Destailleur <eldy@users.sourceforge.net>
  4. * Copyright (C) 2005-2010 Regis Houssin <regis.houssin@capnetworks.com>
  5. * Copyright (C) 2016 Ferran Marcet <fmarcet@2byte.es>
  6. * Copyright (C) 2023 Alexandre Spangaro <aspangaro@open-dsi.fr>
  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/reception/list.php
  23. * \ingroup reception
  24. * \brief Page to list all receptions
  25. */
  26. // Load Dolibarr environment
  27. require '../main.inc.php';
  28. require_once DOL_DOCUMENT_ROOT.'/reception/class/reception.class.php';
  29. require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php';
  30. require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php';
  31. require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.product.class.php';
  32. require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
  33. require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
  34. require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
  35. require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
  36. $langs->loadLangs(array("sendings", "receptions", "deliveries", 'companies', 'bills', 'orders'));
  37. $contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'shipmentlist'; // To manage different context of search
  38. $socid = GETPOST('socid', 'int');
  39. $massaction = GETPOST('massaction', 'alpha');
  40. $toselect = GETPOST('toselect', 'array');
  41. $optioncss = GETPOST('optioncss', 'alpha');
  42. $mode = GETPOST('mode', 'alpha');
  43. $diroutputmassaction = $conf->reception->dir_output.'/temp/massgeneration/'.$user->id;
  44. $search_ref_rcp = GETPOST("search_ref_rcp");
  45. $search_ref_liv = GETPOST('search_ref_liv');
  46. $search_ref_supplier = GETPOST('search_ref_supplier');
  47. $search_company = GETPOST("search_company");
  48. $search_town = GETPOST('search_town', 'alpha');
  49. $search_zip = GETPOST('search_zip', 'alpha');
  50. $search_state = GETPOST("search_state");
  51. $search_country = GETPOST("search_country", 'int');
  52. $search_type_thirdparty = GETPOST("search_type_thirdparty", 'int');
  53. $search_date_delivery_startday = GETPOST('search_date_delivery_startday', 'int');
  54. $search_date_delivery_startmonth = GETPOST('search_date_delivery_startmonth', 'int');
  55. $search_date_delivery_startyear = GETPOST('search_date_delivery_startyear', 'int');
  56. $search_date_delivery_endday = GETPOST('search_date_delivery_endday', 'int');
  57. $search_date_delivery_endmonth = GETPOST('search_date_delivery_endmonth', 'int');
  58. $search_date_delivery_endyear = GETPOST('search_date_delivery_endyear', 'int');
  59. $search_date_delivery_start = dol_mktime(0, 0, 0, $search_date_delivery_startmonth, $search_date_delivery_startday, $search_date_delivery_startyear); // Use tzserver
  60. $search_date_delivery_end = dol_mktime(23, 59, 59, $search_date_delivery_endmonth, $search_date_delivery_endday, $search_date_delivery_endyear);
  61. $search_date_create_startday = GETPOST('search_date_create_startday', 'int');
  62. $search_date_create_startmonth = GETPOST('search_date_create_startmonth', 'int');
  63. $search_date_create_startyear = GETPOST('search_date_create_startyear', 'int');
  64. $search_date_create_endday = GETPOST('search_date_create_endday', 'int');
  65. $search_date_create_endmonth = GETPOST('search_date_create_endmonth', 'int');
  66. $search_date_create_endyear = GETPOST('search_date_create_endyear', 'int');
  67. $search_date_create_start = dol_mktime(0, 0, 0, $search_date_create_startmonth, $search_date_create_startday, $search_date_create_startyear); // Use tzserver
  68. $search_date_create_end = dol_mktime(23, 59, 59, $search_date_create_endmonth, $search_date_create_endday, $search_date_create_endyear);
  69. $search_billed = GETPOST("search_billed", 'int');
  70. $search_status = GETPOST('search_status', 'intcomma');
  71. $search_all = GETPOST('search_all', 'alphanohtml') ? GETPOST('search_all', 'alphanohtml') : GETPOST('sall', 'alphanohtml');
  72. $limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit;
  73. $sortfield = GETPOST('sortfield', 'aZ09comma');
  74. $sortorder = GETPOST('sortorder', 'aZ09comma');
  75. $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
  76. if (!$sortfield) {
  77. $sortfield = "e.ref";
  78. }
  79. if (!$sortorder) {
  80. $sortorder = "DESC";
  81. }
  82. if (empty($page) || $page < 0 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha')) {
  83. // If $page is not defined, or '' or -1 or if we click on clear filters
  84. $page = 0;
  85. }
  86. $offset = $limit * $page;
  87. $pageprev = $page - 1;
  88. $pagenext = $page + 1;
  89. $object = new Reception($db);
  90. // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
  91. $hookmanager->initHooks(array('receptionlist'));
  92. $extrafields = new ExtraFields($db);
  93. // Fetch optionals attributes and labels
  94. $extrafields->fetch_name_optionals_label($object->table_element);
  95. $search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_');
  96. // List of fields to search into when doing a "search in all"
  97. $fieldstosearchall = array(
  98. 'e.ref'=>"Ref",
  99. 's.nom'=>"ThirdParty",
  100. 'e.note_public'=>'NotePublic',
  101. );
  102. if (empty($user->socid)) {
  103. $fieldstosearchall["e.note_private"] = "NotePrivate";
  104. }
  105. $checkedtypetiers = 0;
  106. $arrayfields = array(
  107. 'e.ref'=>array('label'=>$langs->trans("Ref"), 'checked'=>1),
  108. 'e.ref_supplier'=>array('label'=>$langs->trans("RefSupplier"), 'checked'=>1),
  109. 's.nom'=>array('label'=>$langs->trans("ThirdParty"), 'checked'=>1),
  110. 's.town'=>array('label'=>$langs->trans("Town"), 'checked'=>1),
  111. 's.zip'=>array('label'=>$langs->trans("Zip"), 'checked'=>1),
  112. 'state.nom'=>array('label'=>$langs->trans("StateShort"), 'checked'=>0),
  113. 'country.code_iso'=>array('label'=>$langs->trans("Country"), 'checked'=>0),
  114. 'typent.code'=>array('label'=>$langs->trans("ThirdPartyType"), 'checked'=>$checkedtypetiers),
  115. 'e.date_delivery'=>array('label'=>$langs->trans("DateDeliveryPlanned"), 'checked'=>1),
  116. 'e.datec'=>array('label'=>$langs->trans("DateCreation"), 'checked'=>0, 'position'=>500),
  117. 'e.tms'=>array('label'=>$langs->trans("DateModificationShort"), 'checked'=>0, 'position'=>500),
  118. 'e.fk_statut'=>array('label'=>$langs->trans("Status"), 'checked'=>1, 'position'=>1000),
  119. 'e.billed'=>array('label'=>$langs->trans("Billed"), 'checked'=>1, 'position'=>1000, 'enabled'=>'getDolGlobalString("WORKFLOW_BILL_ON_RECEPTION") !== "0"')
  120. );
  121. // Extra fields
  122. include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php';
  123. $object->fields = dol_sort_array($object->fields, 'position');
  124. $arrayfields = dol_sort_array($arrayfields, 'position');
  125. $error = 0;
  126. // Security check
  127. $receptionid = GETPOST('id', 'int');
  128. if ($user->socid) {
  129. $socid = $user->socid;
  130. }
  131. $result = restrictedArea($user, 'reception', $receptionid, '');
  132. /*
  133. * Actions
  134. */
  135. if (GETPOST('cancel', 'alpha')) {
  136. $action = 'list';
  137. $massaction = '';
  138. }
  139. if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_createbills') {
  140. $massaction = '';
  141. }
  142. $parameters = array('socid'=>$socid);
  143. $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
  144. if ($reshook < 0) {
  145. setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
  146. }
  147. include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
  148. // Purge search criteria
  149. 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
  150. $search_ref_supplier = '';
  151. $search_ref_rcp = '';
  152. $search_ref_liv = '';
  153. $search_company = '';
  154. $search_town = '';
  155. $search_zip = "";
  156. $search_state = "";
  157. $search_country = '';
  158. $search_type_thirdparty = '';
  159. $search_date_delivery_startday = '';
  160. $search_date_delivery_startmonth = '';
  161. $search_date_delivery_startyear = '';
  162. $search_date_delivery_endday = '';
  163. $search_date_delivery_endmonth = '';
  164. $search_date_delivery_endyear = '';
  165. $search_date_delivery_start = '';
  166. $search_date_delivery_end = '';
  167. $search_date_create_startday = '';
  168. $search_date_create_startmonth = '';
  169. $search_date_create_startyear = '';
  170. $search_date_create_endday = '';
  171. $search_date_create_endmonth = '';
  172. $search_date_create_endyear = '';
  173. $search_date_create_start = '';
  174. $search_date_create_end = '';
  175. $search_billed = '';
  176. $search_status = '';
  177. $toselect = array();
  178. $search_array_options = array();
  179. }
  180. if (empty($reshook)) {
  181. // Mass actions
  182. $objectclass = 'Reception';
  183. $objectlabel = 'Receptions';
  184. $permissiontoread = $user->rights->reception->lire;
  185. $permissiontoadd = $user->rights->reception->creer;
  186. $permissiontodelete = $user->rights->reception->supprimer;
  187. $uploaddir = $conf->reception->multidir_output[$conf->entity];
  188. include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';
  189. if ($massaction == 'confirm_createbills') {
  190. $receptions = GETPOST('toselect', 'array');
  191. $createbills_onebythird = GETPOST('createbills_onebythird', 'int');
  192. $validate_invoices = GETPOST('validate_invoices', 'int');
  193. $errors = array();
  194. $TFact = array();
  195. $TFactThird = array();
  196. $TFactThirdNbLines = array();
  197. $nb_bills_created = 0;
  198. $lastid= 0;
  199. $lastref = '';
  200. $db->begin();
  201. //sort ids to keep order if one bill per third
  202. sort($receptions);
  203. foreach ($receptions as $id_reception) {
  204. $rcp = new Reception($db);
  205. // We not allow invoice reception that are in draft status
  206. if ($rcp->fetch($id_reception) <= 0 || $rcp->statut == $rcp::STATUS_DRAFT) {
  207. $errors[] = $langs->trans('StatusOfRefMustBe', $rcp->ref, $langs->transnoentities("StatusReceptionValidatedShort"));
  208. $error++;
  209. continue;
  210. }
  211. $objecttmp = new FactureFournisseur($db);
  212. if (!empty($createbills_onebythird) && !empty($TFactThird[$rcp->socid])) {
  213. // If option "one bill per third" is set, and an invoice for this thirdparty was already created, we re-use it.
  214. $objecttmp = $TFactThird[$rcp->socid];
  215. // Add all links of this new reception to the existing invoice
  216. $objecttmp->fetchObjectLinked();
  217. $rcp->fetchObjectLinked();
  218. if (count($rcp->linkedObjectsIds['order_supplier']) > 0) {
  219. foreach ($rcp->linkedObjectsIds['order_supplier'] as $key => $value) {
  220. if (empty($objecttmp->linkedObjectsIds['order_supplier']) || !in_array($value, $objecttmp->linkedObjectsIds['order_supplier'])) { //Dont try to link if already linked
  221. $objecttmp->add_object_linked('order_supplier', $value); // add supplier order linked object
  222. }
  223. }
  224. }
  225. } else {
  226. $cond_reglement_id = 0;
  227. $mode_reglement_id = 0;
  228. $fk_account = 0;
  229. $transport_mode_id = 0;
  230. if (!empty($rcp->cond_reglement_id)) {
  231. $cond_reglement_id = $rcp->cond_reglement_id;
  232. }
  233. if (!empty($rcp->mode_reglement_id)) {
  234. $mode_reglement_id = $rcp->mode_reglement_id;
  235. }
  236. if (!empty($rcp->fk_account)) {
  237. $fk_account = $rcp->fk_account;
  238. }
  239. if (!empty($rcp->transport_mode_id)) {
  240. $transport_mode_id = $rcp->transport_mode_id;
  241. }
  242. if (empty($cond_reglement_id)
  243. || empty($mode_reglement_id)
  244. || empty($fk_account)
  245. || empty($transport_mode_id)
  246. ) {
  247. if (!isset($rcp->supplier_order)) {
  248. $rcp->fetch_origin();
  249. }
  250. // try to get from source of reception (supplier order)
  251. if (!empty($rcp->commandeFournisseur)) {
  252. $supplierOrder = $rcp->commandeFournisseur;
  253. if (empty($cond_reglement_id) && !empty($supplierOrder->cond_reglement_id)) {
  254. $cond_reglement_id = $supplierOrder->cond_reglement_id;
  255. }
  256. if (empty($mode_reglement_id) && !empty($supplierOrder->mode_reglement_id)) {
  257. $mode_reglement_id = $supplierOrder->mode_reglement_id;
  258. }
  259. if (empty($fk_account) && !empty($supplierOrder->fk_account)) {
  260. $fk_account = $supplierOrder->fk_account;
  261. }
  262. if (empty($transport_mode_id) && !empty($supplierOrder->transport_mode_id)) {
  263. $transport_mode_id = $supplierOrder->transport_mode_id;
  264. }
  265. }
  266. // try get from third-party of reception
  267. if (!empty($rcp->thirdparty)) {
  268. $soc = $rcp->thirdparty;
  269. if (empty($cond_reglement_id) && !empty($soc->cond_reglement_supplier_id)) {
  270. $cond_reglement_id = $soc->cond_reglement_supplier_id;
  271. }
  272. if (empty($mode_reglement_id) && !empty($soc->mode_reglement_supplier_id)) {
  273. $mode_reglement_id = $soc->mode_reglement_supplier_id;
  274. }
  275. if (empty($fk_account) && !empty($soc->fk_account)) {
  276. $fk_account = $soc->fk_account;
  277. }
  278. if (empty($transport_mode_id) && !empty($soc->transport_mode_id)) {
  279. $transport_mode_id = $soc->transport_mode_id;
  280. }
  281. }
  282. }
  283. // If we want one invoice per reception or if there is no first invoice yet for this thirdparty.
  284. $objecttmp->socid = $rcp->socid;
  285. $objecttmp->type = $objecttmp::TYPE_STANDARD;
  286. $objecttmp->cond_reglement_id = $cond_reglement_id;
  287. $objecttmp->mode_reglement_id = $mode_reglement_id;
  288. $objecttmp->fk_account = $fk_account;
  289. $objecttmp->transport_mode_id = $transport_mode_id;
  290. // if the VAT reverse-charge is activated by default in supplier card to resume the information
  291. $objecttmp->vat_reverse_charge = $soc->vat_reverse_charge;
  292. $objecttmp->fk_project = $rcp->fk_project;
  293. //$objecttmp->multicurrency_code = $rcp->multicurrency_code;
  294. if (empty($createbills_onebythird)) {
  295. $objecttmp->ref_supplier = $rcp->ref;
  296. } else {
  297. // Set a unique value for the invoice for the n reception
  298. $objecttmp->ref_supplier = $langs->trans("Reception").' '.dol_print_date(dol_now(), 'dayhourlog').'-'.$rcp->socid;
  299. }
  300. $datefacture = dol_mktime(12, 0, 0, GETPOST('remonth', 'int'), GETPOST('reday', 'int'), GETPOST('reyear', 'int'));
  301. if (empty($datefacture)) {
  302. $datefacture = dol_now();
  303. }
  304. $objecttmp->date = $datefacture;
  305. $objecttmp->origin = 'reception';
  306. $objecttmp->origin_id = $id_reception;
  307. // Auto calculation of date due if not filled by user
  308. if (empty($objecttmp->date_echeance)) {
  309. $objecttmp->date_echeance = $objecttmp->calculate_date_lim_reglement();
  310. }
  311. $objecttmp->array_options = $rcp->array_options; // Copy extrafields
  312. // Set $objecttmp->linked_objects with all links order_supplier existing on reception, so same links will be added to the generated supplier invoice
  313. $rcp->fetchObjectLinked();
  314. if (count($rcp->linkedObjectsIds['order_supplier']) > 0) {
  315. foreach ($rcp->linkedObjectsIds['order_supplier'] as $key => $value) {
  316. $objecttmp->linked_objects['order_supplier'] = $value;
  317. }
  318. }
  319. $res = $objecttmp->create($user); // This should create the supplier invoice + links into $objecttmp->linked_objects + add a link to ->origin_id
  320. //var_dump($objecttmp->error);exit;
  321. if ($res > 0) {
  322. $nb_bills_created++;
  323. $lastref = $objecttmp->ref;
  324. $lastid = $objecttmp->id;
  325. $TFactThird[$rcp->socid] = $objecttmp;
  326. $TFactThirdNbLines[$rcp->socid] = 0; //init nblines to have lines ordered by expedition and rang
  327. } else {
  328. $langs->load("errors");
  329. $errors[] = $rcp->ref.' : '.$langs->trans($objecttmp->error);
  330. $error++;
  331. }
  332. }
  333. if ($objecttmp->id > 0) {
  334. $res = $objecttmp->add_object_linked($objecttmp->origin, $id_reception);
  335. if ($res == 0) {
  336. $errors[] = $objecttmp->error;
  337. $error++;
  338. }
  339. if (!$error) {
  340. $lines = $rcp->lines;
  341. if (empty($lines) && method_exists($rcp, 'fetch_lines')) {
  342. $rcp->fetch_lines();
  343. $lines = $rcp->lines;
  344. }
  345. $fk_parent_line = 0;
  346. $num = count($lines);
  347. for ($i = 0; $i < $num; $i++) {
  348. $desc = ($lines[$i]->desc ? $lines[$i]->desc : $lines[$i]->libelle);
  349. // If we build one invoice for several reception, we must put the ref of reception on the invoice line
  350. if (!empty($createbills_onebythird)) {
  351. $desc = dol_concatdesc($desc, $langs->trans("Reception").' '.$rcp->ref.' - '.dol_print_date($rcp->date, 'day'));
  352. }
  353. if ($lines[$i]->subprice < 0) {
  354. // Negative line, we create a discount line
  355. $discount = new DiscountAbsolute($db);
  356. $discount->fk_soc = $objecttmp->socid;
  357. $discount->amount_ht = abs($lines[$i]->total_ht);
  358. $discount->amount_tva = abs($lines[$i]->total_tva);
  359. $discount->amount_ttc = abs($lines[$i]->total_ttc);
  360. $discount->tva_tx = $lines[$i]->tva_tx;
  361. $discount->fk_user = $user->id;
  362. $discount->description = $desc;
  363. $discountid = $discount->create($user);
  364. if ($discountid > 0) {
  365. $result = $objecttmp->insert_discount($discountid);
  366. //$result=$discount->link_to_invoice($lineid,$id);
  367. } else {
  368. setEventMessages($discount->error, $discount->errors, 'errors');
  369. $error++;
  370. break;
  371. }
  372. } else {
  373. // Positive line
  374. $product_type = ($lines[$i]->product_type ? $lines[$i]->product_type : 0);
  375. // Date start
  376. $date_start = false;
  377. if ($lines[$i]->date_debut_prevue) {
  378. $date_start = $lines[$i]->date_debut_prevue;
  379. }
  380. if ($lines[$i]->date_debut_reel) {
  381. $date_start = $lines[$i]->date_debut_reel;
  382. }
  383. if ($lines[$i]->date_start) {
  384. $date_start = $lines[$i]->date_start;
  385. }
  386. //Date end
  387. $date_end = false;
  388. if ($lines[$i]->date_fin_prevue) {
  389. $date_end = $lines[$i]->date_fin_prevue;
  390. }
  391. if ($lines[$i]->date_fin_reel) {
  392. $date_end = $lines[$i]->date_fin_reel;
  393. }
  394. if ($lines[$i]->date_end) {
  395. $date_end = $lines[$i]->date_end;
  396. }
  397. // Reset fk_parent_line for no child products and special product
  398. if (($lines[$i]->product_type != 9 && empty($lines[$i]->fk_parent_line)) || $lines[$i]->product_type == 9) {
  399. $fk_parent_line = 0;
  400. }
  401. // Extrafields
  402. if (method_exists($lines[$i], 'fetch_optionals')) {
  403. $lines[$i]->fetch_optionals();
  404. $array_options = $lines[$i]->array_options;
  405. }
  406. $objecttmp->context['createfromclone'];
  407. $rang = $i;
  408. //there may already be rows from previous receptions
  409. if (!empty($createbills_onebythird)) {
  410. $rang = $TFactThirdNbLines[$rcp->socid];
  411. }
  412. $result = $objecttmp->addline(
  413. $desc,
  414. $lines[$i]->subprice,
  415. $lines[$i]->tva_tx,
  416. $lines[$i]->localtax1_tx,
  417. $lines[$i]->localtax2_tx,
  418. $lines[$i]->qty,
  419. $lines[$i]->fk_product,
  420. $lines[$i]->remise_percent,
  421. $date_start,
  422. $date_end,
  423. 0,
  424. $lines[$i]->info_bits,
  425. 'HT',
  426. $product_type,
  427. $rang,
  428. false,
  429. 0,
  430. null,
  431. $lines[$i]->rowid,
  432. 0,
  433. $lines[$i]->ref_supplier
  434. );
  435. $rcp->add_object_linked('facture_fourn_det', $result);
  436. if ($result > 0) {
  437. $lineid = $result;
  438. if (!empty($createbills_onebythird)) { //increment rang to keep order
  439. $TFactThirdNbLines[$rcp->socid]++;
  440. }
  441. } else {
  442. $lineid = 0;
  443. $error++;
  444. break;
  445. }
  446. // Defined the new fk_parent_line
  447. if ($result > 0 && $lines[$i]->product_type == 9) {
  448. $fk_parent_line = $result;
  449. }
  450. }
  451. }
  452. }
  453. }
  454. //$rcp->classifyBilled($user); // Disabled. This behavior must be set or not using the workflow module.
  455. if (!empty($createbills_onebythird) && empty($TFactThird[$rcp->socid])) {
  456. $TFactThird[$rcp->socid] = $objecttmp;
  457. } else {
  458. $TFact[$objecttmp->id] = $objecttmp;
  459. }
  460. }
  461. // Build doc with all invoices
  462. $TAllFact = empty($createbills_onebythird) ? $TFact : $TFactThird;
  463. $toselect = array();
  464. if (!$error && $validate_invoices) {
  465. $massaction = $action = 'builddoc';
  466. foreach ($TAllFact as &$objecttmp) {
  467. $result = $objecttmp->validate($user);
  468. if ($result <= 0) {
  469. $error++;
  470. setEventMessages($objecttmp->error, $objecttmp->errors, 'errors');
  471. break;
  472. }
  473. $id = $objecttmp->id; // For builddoc action
  474. $lastref = $objecttmp->ref; // generated ref
  475. $object =$objecttmp;
  476. // Fac builddoc
  477. $donotredirect = 1;
  478. $upload_dir = $conf->fournisseur->facture->dir_output;
  479. $permissiontoadd = ($user->rights->fournisseur->facture->creer || $user->rights->supplier_invoice->creer);
  480. // Call action to build doc
  481. $savobject = $object;
  482. $object = $objecttmp;
  483. include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php';
  484. $object = $savobject;
  485. }
  486. $massaction = $action = 'confirm_createbills';
  487. }
  488. if (!$error) {
  489. $db->commit();
  490. if ($nb_bills_created == 1) {
  491. $texttoshow = $langs->trans('BillXCreated', '{s1}');
  492. $texttoshow = str_replace('{s1}', '<a href="'.DOL_URL_ROOT.'/fourn/facture/card.php?id='.urlencode($lastid).'">'.$lastref.'</a>', $texttoshow);
  493. setEventMessages($texttoshow, null, 'mesgs');
  494. } else {
  495. setEventMessages($langs->trans('BillCreated', $nb_bills_created), null, 'mesgs');
  496. }
  497. } else {
  498. $db->rollback();
  499. $action = 'create';
  500. $_GET["origin"] = $_POST["origin"];
  501. $_GET["originid"] = $_POST["originid"];
  502. setEventMessages($object->error, $errors, 'errors');
  503. $error++;
  504. }
  505. }
  506. }
  507. /*
  508. * View
  509. */
  510. $now = dol_now();
  511. $form = new Form($db);
  512. $companystatic = new Societe($db);
  513. $reception = new Reception($db);
  514. $formcompany = new FormCompany($db);
  515. $formfile = new FormFile($db);
  516. $helpurl = 'EN:Module_Receptions|FR:Module_Receptions|ES:M&oacute;dulo_Receptiones';
  517. llxHeader('', $langs->trans('ListOfReceptions'), $helpurl);
  518. $sql = "SELECT e.rowid, e.ref, e.ref_supplier, e.date_reception as date_reception, e.date_delivery as delivery_date, l.date_delivery as date_reception2, e.fk_statut as status, e.billed,";
  519. $sql .= " s.rowid as socid, s.nom as name, s.town, s.zip, s.fk_pays, s.client, s.code_client,";
  520. $sql .= " typent.code as typent_code,";
  521. $sql .= " state.code_departement as state_code, state.nom as state_name,";
  522. $sql .= " e.date_creation as date_creation, e.tms as date_update";
  523. // Add fields from extrafields
  524. if (!empty($extrafields->attributes[$object->table_element]['label'])) {
  525. foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) {
  526. $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key." as options_".$key : '');
  527. }
  528. }
  529. // Add fields from hooks
  530. $parameters = array();
  531. $reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters); // Note that $action and $object may have been modified by hook
  532. $sql .= $hookmanager->resPrint;
  533. $sqlfields = $sql; // $sql fields to remove for count total
  534. $sql .= " FROM ".MAIN_DB_PREFIX."reception as e";
  535. if (!empty($extrafields->attributes[$object->table_element]['label']) && is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) {
  536. $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (e.rowid = ef.fk_object)";
  537. }
  538. $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = e.fk_soc";
  539. $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as country on (country.rowid = s.fk_pays)";
  540. $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_typent as typent on (typent.id = s.fk_typent)";
  541. $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_departements as state on (state.rowid = s.fk_departement)";
  542. $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."element_element as ee ON e.rowid = ee.fk_source AND ee.sourcetype = 'reception' AND ee.targettype = 'delivery'";
  543. $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."delivery as l ON l.rowid = ee.fk_target";
  544. // Add table from hooks
  545. $parameters = array();
  546. $reshook = $hookmanager->executeHooks('printFieldListFrom', $parameters, $object); // Note that $action and $object may have been modified by hook
  547. $sql .= $hookmanager->resPrint;
  548. $sql .= " WHERE e.entity IN (".getEntity('reception').")";
  549. if ($socid) {
  550. $sql .= " AND e.fk_soc = ".((int) $socid);
  551. }
  552. if ($search_status != '' && $search_status >= 0) {
  553. $sql .= " AND e.fk_statut = ".((int) $search_status);
  554. }
  555. if ($search_billed != '' && $search_billed >= 0) {
  556. $sql .= ' AND e.billed = '.((int) $search_billed);
  557. }
  558. if ($search_town) {
  559. $sql .= natural_search('s.town', $search_town);
  560. }
  561. if ($search_zip) {
  562. $sql .= natural_search("s.zip", $search_zip);
  563. }
  564. if ($search_state) {
  565. $sql .= natural_search("state.nom", $search_state);
  566. }
  567. if ($search_country) {
  568. $sql .= " AND s.fk_pays IN (".$db->sanitize($search_country).')';
  569. }
  570. if ($search_type_thirdparty != '' && $search_type_thirdparty > 0) {
  571. $sql .= " AND s.fk_typent IN (".$db->sanitize($search_type_thirdparty).')';
  572. }
  573. if ($search_date_delivery_start) {
  574. $sql .= " AND e.date_delivery >= '".$db->idate($search_date_delivery_start)."'";
  575. }
  576. if ($search_date_delivery_end) {
  577. $sql .= " AND e.date_delivery <= '".$db->idate($search_date_delivery_end)."'";
  578. }
  579. if ($search_date_create_start) {
  580. $sql .= " AND e.date_creation >= '".$db->idate($search_date_create_start)."'";
  581. }
  582. if ($search_date_create_end) {
  583. $sql .= " AND e.date_creation <= '".$db->idate($search_date_create_end)."'";
  584. }
  585. if ($search_ref_rcp) {
  586. $sql .= natural_search('e.ref', $search_ref_rcp);
  587. }
  588. if ($search_ref_liv) {
  589. $sql .= natural_search('l.ref', $search_ref_liv);
  590. }
  591. if ($search_company) {
  592. $sql .= natural_search('s.nom', $search_company);
  593. }
  594. if ($search_ref_supplier) {
  595. $sql .= natural_search('e.ref_supplier', $search_ref_supplier);
  596. }
  597. if ($search_all) {
  598. $sql .= natural_search(array_keys($fieldstosearchall), $search_all);
  599. }
  600. // Search on sale representative
  601. /*
  602. if ($search_sale && $search_sale != '-1') {
  603. if ($search_sale == -2) {
  604. $sql .= " AND NOT EXISTS (SELECT sc.fk_soc FROM ".MAIN_DB_PREFIX."societe_commerciaux as sc WHERE sc.fk_soc = c.fk_soc)";
  605. } elseif ($search_sale > 0) {
  606. $sql .= " AND EXISTS (SELECT sc.fk_soc FROM ".MAIN_DB_PREFIX."societe_commerciaux as sc WHERE sc.fk_soc = c.fk_soc AND sc.fk_user = ".((int) $search_sale).")";
  607. }
  608. }
  609. */
  610. // Add where from extra fields
  611. include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php';
  612. // Add where from hooks
  613. $parameters = array();
  614. $reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook
  615. $sql .= $hookmanager->resPrint;
  616. // Add HAVING from hooks
  617. $parameters = array();
  618. $reshook = $hookmanager->executeHooks('printFieldListHaving', $parameters, $object); // Note that $action and $object may have been modified by hook
  619. $sql .= empty($hookmanager->resPrint) ? "" : " HAVING 1=1 ".$hookmanager->resPrint;
  620. $nbtotalofrecords = '';
  621. if (!getDolGlobalInt('MAIN_DISABLE_FULL_SCANLIST')) {
  622. /* The fast and low memory method to get and count full list converts the sql into a sql count */
  623. $sqlforcount = preg_replace('/^'.preg_quote($sqlfields, '/').'/', 'SELECT COUNT(*) as nbtotalofrecords', $sql);
  624. $sqlforcount = preg_replace('/GROUP BY .*$/', '', $sqlforcount);
  625. $resql = $db->query($sqlforcount);
  626. if ($resql) {
  627. $objforcount = $db->fetch_object($resql);
  628. $nbtotalofrecords = $objforcount->nbtotalofrecords;
  629. } else {
  630. dol_print_error($db);
  631. }
  632. if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller then paging size (filtering), goto and load page 0
  633. $page = 0;
  634. $offset = 0;
  635. }
  636. $db->free($resql);
  637. }
  638. // Complete request and execute it with limit
  639. $sql .= $db->order($sortfield, $sortorder);
  640. if ($limit) {
  641. $sql .= $db->plimit($limit + 1, $offset);
  642. }
  643. //print $sql;
  644. $resql = $db->query($sql);
  645. if (!$resql) {
  646. dol_print_error($db);
  647. exit;
  648. }
  649. $num = $db->num_rows($resql);
  650. $reception = new Reception($db);
  651. $arrayofselected = is_array($toselect) ? $toselect : array();
  652. $param = '';
  653. if (!empty($mode)) {
  654. $param .= '&mode='.urlencode($mode);
  655. }
  656. if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
  657. $param .= '&contextpage='.urlencode($contextpage);
  658. }
  659. if ($limit > 0 && $limit != $conf->liste_limit) {
  660. $param .= '&limit='.((int) $limit);
  661. }
  662. if ($search_all) {
  663. $param .= "&search_all=".urlencode($search_all);
  664. }
  665. if ($search_ref_rcp) {
  666. $param .= "&search_ref_rcp=".urlencode($search_ref_rcp);
  667. }
  668. if ($search_ref_liv) {
  669. $param .= "&search_ref_liv=".urlencode($search_ref_liv);
  670. }
  671. if ($search_company) {
  672. $param .= "&search_company=".urlencode($search_company);
  673. }
  674. if ($optioncss != '') {
  675. $param .= '&optioncss='.urlencode($optioncss);
  676. }
  677. if ($search_billed != '' && $search_billed >= 0) {
  678. $param .= "&search_billed=".urlencode($search_billed);
  679. }
  680. if ($search_town) {
  681. $param .= "&search_town=".urlencode($search_town);
  682. }
  683. if ($search_zip) {
  684. $param .= "&search_zip=".urlencode($search_zip);
  685. }
  686. if ($search_state) {
  687. $param .= "&search_state=".urlencode($search_state);
  688. }
  689. if ($search_status != '') {
  690. $param .= "&search_status=".urlencode($search_status);
  691. }
  692. if ($search_country) {
  693. $param .= "&search_country=".urlencode($search_country);
  694. }
  695. if ($search_type_thirdparty) {
  696. $param .= "&search_type_thirdparty=".urlencode($search_type_thirdparty);
  697. }
  698. if ($search_date_delivery_startday) {
  699. $param .= '&search_date_delivery_startday='.urlencode($search_date_delivery_startday);
  700. }
  701. if ($search_date_delivery_startmonth) {
  702. $param .= '&search_date_delivery_startmonth='.urlencode($search_date_delivery_startmonth);
  703. }
  704. if ($search_date_delivery_startyear) {
  705. $param .= '&search_date_delivery_startyear='.urlencode($search_date_delivery_startyear);
  706. }
  707. if ($search_date_delivery_endday) {
  708. $param .= '&search_date_delivery_endday='.urlencode($search_date_delivery_endday);
  709. }
  710. if ($search_date_delivery_endmonth) {
  711. $param .= '&search_date_delivery_endmonth='.urlencode($search_date_delivery_endmonth);
  712. }
  713. if ($search_date_delivery_endyear) {
  714. $param .= '&search_date_delivery_endyear='.urlencode($search_date_delivery_endyear);
  715. }
  716. if ($search_date_create_startday) {
  717. $param .= '&search_date_create_startday='.urlencode($search_date_create_startday);
  718. }
  719. if ($search_date_create_startmonth) {
  720. $param .= '&search_date_create_startmonth='.urlencode($search_date_create_startmonth);
  721. }
  722. if ($search_date_create_startyear) {
  723. $param .= '&search_date_create_startyear='.urlencode($search_date_create_startyear);
  724. }
  725. if ($search_date_create_endday) {
  726. $param .= '&search_date_create_endday='.urlencode($search_date_create_endday);
  727. }
  728. if ($search_date_create_endmonth) {
  729. $param .= '&search_date_create_endmonth='.urlencode($search_date_create_endmonth);
  730. }
  731. if ($search_date_create_endyear) {
  732. $param .= '&search_date_create_endyear='.urlencode($search_date_create_endyear);
  733. }
  734. if ($search_ref_supplier) {
  735. $param .= "&search_ref_supplier=".urlencode($search_ref_supplier);
  736. }
  737. // Add $param from extra fields
  738. if ($search_array_options) {
  739. foreach ($search_array_options as $key => $val) {
  740. $crit = $val;
  741. $tmpkey = preg_replace('/search_options_/', '', $key);
  742. if (is_array($val) && array_key_exists('start', $val) && array_key_exists('end', $val)) {
  743. // date range from list filters is stored as array('start' => <timestamp>, 'end' => <timestamp>)
  744. // start date
  745. $param .= '&search_options_'.$tmpkey.'_startyear='.dol_print_date($val['start'], '%Y');
  746. $param .= '&search_options_'.$tmpkey.'_startmonth='.dol_print_date($val['start'], '%m');
  747. $param .= '&search_options_'.$tmpkey.'_startday='.dol_print_date($val['start'], '%d');
  748. $param .= '&search_options_'.$tmpkey.'_starthour='.dol_print_date($val['start'], '%H');
  749. $param .= '&search_options_'.$tmpkey.'_startmin='.dol_print_date($val['start'], '%M');
  750. // end date
  751. $param .= '&search_options_'.$tmpkey.'_endyear='.dol_print_date($val['end'], '%Y');
  752. $param .= '&search_options_'.$tmpkey.'_endmonth='.dol_print_date($val['end'], '%m');
  753. $param .= '&search_options_'.$tmpkey.'_endday='.dol_print_date($val['end'], '%d');
  754. $param .= '&search_options_'.$tmpkey.'_endhour='.dol_print_date($val['end'], '%H');
  755. $param .= '&search_options_'.$tmpkey.'_endmin='.dol_print_date($val['end'], '%M');
  756. $val = '';
  757. }
  758. if ($val != '') {
  759. $param .= '&search_options_'.$tmpkey.'='.urlencode($val);
  760. }
  761. }
  762. }
  763. $arrayofmassactions = array(
  764. // 'presend'=>img_picto('', 'email', 'class="pictofixedwidth"').$langs->trans("SendByMail"),
  765. );
  766. if ($user->hasRight('fournisseur', 'facture', 'creer') || $user->hasRight('supplier_invoice', 'creer')) {
  767. $arrayofmassactions['createbills'] = $langs->trans("CreateInvoiceForThisReceptions");
  768. }
  769. if (in_array($massaction, array('presend', 'createbills'))) {
  770. $arrayofmassactions = array();
  771. }
  772. $massactionbutton = $form->selectMassAction('', $arrayofmassactions);
  773. // Currently: a sending can't create from sending list
  774. // $url = DOL_URL_ROOT.'/expedition/card.php?action=create';
  775. // if (!empty($socid)) $url .= '&socid='.$socid;
  776. // $newcardbutton = dolGetButtonTitle($langs->trans('NewSending'), '', 'fa fa-plus-circle', $url, '', $user->rights->expedition->creer);
  777. $newcardbutton = '';
  778. $newcardbutton .= dolGetButtonTitle($langs->trans('ViewList'), '', 'fa fa-bars imgforviewmode', $_SERVER["PHP_SELF"].'?mode=common'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ((empty($mode) || $mode == 'common') ? 2 : 1), array('morecss'=>'reposition'));
  779. $newcardbutton .= dolGetButtonTitle($langs->trans('ViewKanban'), '', 'fa fa-th-list imgforviewmode', $_SERVER["PHP_SELF"].'?mode=kanban'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ($mode == 'kanban' ? 2 : 1), array('morecss'=>'reposition'));
  780. $newcardbutton .= dolGetButtonTitleSeparator();
  781. $newcardbutton .= dolGetButtonTitle($langs->trans('NewReception'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/reception/card.php?action=create2', '', $user->hasRight('reception', 'creer'));
  782. $i = 0;
  783. print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">'."\n";
  784. if ($optioncss != '') {
  785. print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
  786. }
  787. print '<input type="hidden" name="token" value="'.newToken().'">';
  788. print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
  789. print '<input type="hidden" name="action" value="list">';
  790. print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
  791. print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
  792. print '<input type="hidden" name="mode" value="'.$mode.'">';
  793. print_barre_liste($langs->trans('ListOfReceptions'), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'dollyrevert', 0, $newcardbutton, '', $limit, 0, 0, 1);
  794. if ($massaction == 'createbills') {
  795. //var_dump($_REQUEST);
  796. print '<input type="hidden" name="massaction" value="confirm_createbills">';
  797. print '<table class="noborder" width="100%" >';
  798. print '<tr>';
  799. print '<td class="titlefieldmiddle">';
  800. print $langs->trans('DateInvoice');
  801. print '</td>';
  802. print '<td>';
  803. print $form->selectDate('', '', '', '', '', '', 1, 1);
  804. print '</td>';
  805. print '</tr>';
  806. print '<tr>';
  807. print '<td>';
  808. print $langs->trans('CreateOneBillByThird');
  809. print '</td>';
  810. print '<td>';
  811. print $form->selectyesno('createbills_onebythird', '', 1);
  812. print '</td>';
  813. print '</tr>';
  814. print '<tr>';
  815. print '<td>';
  816. print $langs->trans('ValidateInvoices');
  817. print '</td>';
  818. print '<td>';
  819. if (isModEnabled('stock') && getDolGlobalString('STOCK_CALCULATE_ON_BILL')) {
  820. print $form->selectyesno('validate_invoices', 0, 1, 1);
  821. print ' ('.$langs->trans("AutoValidationNotPossibleWhenStockIsDecreasedOnInvoiceValidation").')';
  822. } else {
  823. print $form->selectyesno('validate_invoices', 0, 1);
  824. }
  825. print '</td>';
  826. print '</tr>';
  827. print '</table>';
  828. print '<br>';
  829. print '<div class="center">';
  830. print '<input type="submit" class="button" id="createbills" name="createbills" value="'.$langs->trans('CreateInvoiceForThisReceptions').'"> ';
  831. print '<input type="submit" class="button button-cancel" id="cancel" name="cancel" value="'.$langs->trans("Cancel").'">';
  832. print '</div>';
  833. print '<br>';
  834. }
  835. if ($search_all) {
  836. foreach ($fieldstosearchall as $key => $val) {
  837. $fieldstosearchall[$key] = $langs->trans($val);
  838. }
  839. print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $search_all).join(', ', $fieldstosearchall).'</div>';
  840. }
  841. $moreforfilter = '';
  842. if (!empty($moreforfilter)) {
  843. print '<div class="liste_titre liste_titre_bydiv centpercent">';
  844. print $moreforfilter;
  845. $parameters = array('type'=>$type);
  846. $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook
  847. print $hookmanager->resPrint;
  848. print '</div>';
  849. }
  850. $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
  851. $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage, getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN', ''));
  852. if ($massactionbutton) {
  853. $selectedfields .= $form->showCheckAddButtons('checkforselect', 1); // This also change content of $arrayfields
  854. }
  855. print '<div class="div-table-responsive">';
  856. print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n";
  857. // Fields title search
  858. // --------------------------------------------------------------------
  859. print '<tr class="liste_titre_filter">';
  860. // Action column
  861. if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
  862. print '<td class="liste_titre center maxwidthsearch">';
  863. $searchpicto = $form->showFilterButtons('left');
  864. print $searchpicto;
  865. print '</td>';
  866. }
  867. // Ref
  868. if (!empty($arrayfields['e.ref']['checked'])) {
  869. print '<td class="liste_titre">';
  870. print '<input class="flat" size="6" type="text" name="search_ref_rcp" value="'.$search_ref_rcp.'">';
  871. print '</td>';
  872. }
  873. // Ref customer
  874. if (!empty($arrayfields['e.ref_supplier']['checked'])) {
  875. print '<td class="liste_titre">';
  876. print '<input class="flat" size="6" type="text" name="search_ref_supplier" value="'.$search_ref_supplier.'">';
  877. print '</td>';
  878. }
  879. // Thirdparty
  880. if (!empty($arrayfields['s.nom']['checked'])) {
  881. print '<td class="liste_titre left">';
  882. print '<input class="flat" type="text" size="8" name="search_company" value="'.dol_escape_htmltag($search_company).'">';
  883. print '</td>';
  884. }
  885. // Town
  886. if (!empty($arrayfields['s.town']['checked'])) {
  887. print '<td class="liste_titre"><input class="flat" type="text" size="6" name="search_town" value="'.$search_town.'"></td>';
  888. }
  889. // Zip
  890. if (!empty($arrayfields['s.zip']['checked'])) {
  891. print '<td class="liste_titre"><input class="flat" type="text" size="6" name="search_zip" value="'.$search_zip.'"></td>';
  892. }
  893. // State
  894. if (!empty($arrayfields['state.nom']['checked'])) {
  895. print '<td class="liste_titre">';
  896. print '<input class="flat" size="4" type="text" name="search_state" value="'.dol_escape_htmltag($search_state).'">';
  897. print '</td>';
  898. }
  899. // Country
  900. if (!empty($arrayfields['country.code_iso']['checked'])) {
  901. print '<td class="liste_titre center">';
  902. print $form->select_country($search_country, 'search_country', '', 0, 'minwidth100imp maxwidth100');
  903. print '</td>';
  904. }
  905. // Company type
  906. if (!empty($arrayfields['typent.code']['checked'])) {
  907. print '<td class="liste_titre maxwidthonsmartphone center">';
  908. print $form->selectarray("search_type_thirdparty", $formcompany->typent_array(0), $search_type_thirdparty, 1, 0, 0, '', 0, 0, 0, (!getDolGlobalString('SOCIETE_SORT_ON_TYPEENT') ? 'ASC' : $conf->global->SOCIETE_SORT_ON_TYPEENT), '', 1);
  909. print '</td>';
  910. }
  911. // Date delivery planned
  912. if (!empty($arrayfields['e.date_delivery']['checked'])) {
  913. print '<td class="liste_titre center">';
  914. print '<div class="nowrapfordate">';
  915. print $form->selectDate($search_date_delivery_start ? $search_date_delivery_start : -1, 'search_date_delivery_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From'));
  916. print '</div>';
  917. print '<div class="nowrapfordate">';
  918. print $form->selectDate($search_date_delivery_end ? $search_date_delivery_end : -1, 'search_date_delivery_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to'));
  919. print '</div>';
  920. print '</td>';
  921. }
  922. if (!empty($arrayfields['l.ref']['checked'])) {
  923. // Delivery ref
  924. print '<td class="liste_titre">';
  925. print '<input class="flat" type="text" name="search_ref_liv" value="'.dol_escape_htmltag($search_ref_liv).'"';
  926. print '</td>';
  927. }
  928. if (!empty($arrayfields['l.date_delivery']['checked'])) {
  929. // Date received
  930. print '<td class="liste_titre center">&nbsp;</td>';
  931. }
  932. // Extra fields
  933. include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php';
  934. // Fields from hook
  935. $parameters = array('arrayfields'=>$arrayfields);
  936. $reshook = $hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook
  937. print $hookmanager->resPrint;
  938. // Date creation
  939. if (!empty($arrayfields['e.datec']['checked'])) {
  940. print '<td class="liste_titre center">';
  941. print '<div class="nowrapfordate">';
  942. print $form->selectDate($search_date_create_start ? $search_date_create_start : -1, 'search_date_create_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From'));
  943. print '</div>';
  944. print '<div class="nowrapfordate">';
  945. print $form->selectDate($search_date_create_end ? $search_date_create_end : -1, 'search_date_create_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to'));
  946. print '</div>';
  947. print '</td>';
  948. }
  949. // Date modification
  950. if (!empty($arrayfields['e.tms']['checked'])) {
  951. print '<td class="liste_titre">';
  952. print '</td>';
  953. }
  954. // Status
  955. if (!empty($arrayfields['e.fk_statut']['checked'])) {
  956. print '<td class="liste_titre right parentonrightofpage">';
  957. print $form->selectarray('search_status', array('0'=>$langs->trans('StatusReceptionDraftShort'), '1'=>$langs->trans('StatusReceptionValidatedShort'), '2'=>$langs->trans('StatusReceptionProcessedShort')), $search_status, 1, 0, 0, '', 0, 0, 0, '', 'search_status width100 onrightofpage');
  958. print '</td>';
  959. }
  960. // Status billed
  961. if (!empty($arrayfields['e.billed']['checked'])) {
  962. print '<td class="liste_titre maxwidthonsmartphone center">';
  963. print $form->selectyesno('search_billed', $search_billed, 1, 0, 1);
  964. print '</td>';
  965. }
  966. // Action column
  967. if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
  968. print '<td class="liste_titre middle">';
  969. $searchpicto = $form->showFilterButtons();
  970. print $searchpicto;
  971. print '</td>';
  972. }
  973. print '</tr>'."\n";
  974. $totalarray = array();
  975. $totalarray['nbfield'] = 0;
  976. // Fields title label
  977. // --------------------------------------------------------------------
  978. print '<tr class="liste_titre">';
  979. // Action column
  980. if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
  981. print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ');
  982. $totalarray['nbfield']++;
  983. }
  984. if (!empty($arrayfields['e.ref']['checked'])) {
  985. print_liste_field_titre($arrayfields['e.ref']['label'], $_SERVER["PHP_SELF"], "e.ref", "", $param, '', $sortfield, $sortorder);
  986. $totalarray['nbfield']++;
  987. }
  988. if (!empty($arrayfields['e.ref_supplier']['checked'])) {
  989. print_liste_field_titre($arrayfields['e.ref_supplier']['label'], $_SERVER["PHP_SELF"], "e.ref_supplier", "", $param, '', $sortfield, $sortorder);
  990. $totalarray['nbfield']++;
  991. }
  992. if (!empty($arrayfields['s.nom']['checked'])) {
  993. print_liste_field_titre($arrayfields['s.nom']['label'], $_SERVER["PHP_SELF"], "s.nom", "", $param, '', $sortfield, $sortorder, 'left ');
  994. $totalarray['nbfield']++;
  995. }
  996. if (!empty($arrayfields['s.town']['checked'])) {
  997. print_liste_field_titre($arrayfields['s.town']['label'], $_SERVER["PHP_SELF"], 's.town', '', $param, '', $sortfield, $sortorder);
  998. $totalarray['nbfield']++;
  999. }
  1000. if (!empty($arrayfields['s.zip']['checked'])) {
  1001. print_liste_field_titre($arrayfields['s.zip']['label'], $_SERVER["PHP_SELF"], 's.zip', '', $param, '', $sortfield, $sortorder);
  1002. $totalarray['nbfield']++;
  1003. }
  1004. if (!empty($arrayfields['state.nom']['checked'])) {
  1005. print_liste_field_titre($arrayfields['state.nom']['label'], $_SERVER["PHP_SELF"], "state.nom", "", $param, '', $sortfield, $sortorder);
  1006. $totalarray['nbfield']++;
  1007. }
  1008. if (!empty($arrayfields['country.code_iso']['checked'])) {
  1009. print_liste_field_titre($arrayfields['country.code_iso']['label'], $_SERVER["PHP_SELF"], "country.code_iso", "", $param, '', $sortfield, $sortorder, 'center ');
  1010. $totalarray['nbfield']++;
  1011. }
  1012. if (!empty($arrayfields['typent.code']['checked'])) {
  1013. print_liste_field_titre($arrayfields['typent.code']['label'], $_SERVER["PHP_SELF"], "typent.code", "", $param, '', $sortfield, $sortorder, 'center ');
  1014. $totalarray['nbfield']++;
  1015. }
  1016. if (!empty($arrayfields['e.date_delivery']['checked'])) {
  1017. print_liste_field_titre($arrayfields['e.date_delivery']['label'], $_SERVER["PHP_SELF"], "e.date_delivery", "", $param, '', $sortfield, $sortorder, 'center ');
  1018. $totalarray['nbfield']++;
  1019. }
  1020. if (!empty($arrayfields['l.ref']['checked'])) {
  1021. print_liste_field_titre($arrayfields['l.ref']['label'], $_SERVER["PHP_SELF"], "l.ref", "", $param, '', $sortfield, $sortorder);
  1022. $totalarray['nbfield']++;
  1023. }
  1024. if (!empty($arrayfields['l.date_delivery']['checked'])) {
  1025. print_liste_field_titre($arrayfields['l.date_delivery']['label'], $_SERVER["PHP_SELF"], "l.date_delivery", "", $param, '', $sortfield, $sortorder, 'center ');
  1026. $totalarray['nbfield']++;
  1027. }
  1028. // Extra fields
  1029. include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php';
  1030. // Hook fields
  1031. $parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder, '$totalarray'=>&$totalarray);
  1032. $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook
  1033. print $hookmanager->resPrint;
  1034. if (!empty($arrayfields['e.datec']['checked'])) {
  1035. print_liste_field_titre($arrayfields['e.datec']['label'], $_SERVER["PHP_SELF"], "e.date_creation", "", $param, '', $sortfield, $sortorder, 'center nowrap ');
  1036. $totalarray['nbfield']++;
  1037. }
  1038. if (!empty($arrayfields['e.tms']['checked'])) {
  1039. print_liste_field_titre($arrayfields['e.tms']['label'], $_SERVER["PHP_SELF"], "e.tms", "", $param, '', $sortfield, $sortorder, 'center nowrap ');
  1040. $totalarray['nbfield']++;
  1041. }
  1042. if (!empty($arrayfields['e.fk_statut']['checked'])) {
  1043. print_liste_field_titre($arrayfields['e.fk_statut']['label'], $_SERVER["PHP_SELF"], "e.fk_statut", "", $param, '', $sortfield, $sortorder, 'right ');
  1044. $totalarray['nbfield']++;
  1045. }
  1046. if (!empty($arrayfields['e.billed']['checked'])) {
  1047. print_liste_field_titre($arrayfields['e.billed']['label'], $_SERVER["PHP_SELF"], "e.billed", "", $param, '', $sortfield, $sortorder, 'center ');
  1048. $totalarray['nbfield']++;
  1049. }
  1050. // Action column
  1051. if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
  1052. print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ');
  1053. $totalarray['nbfield']++;
  1054. }
  1055. print "</tr>\n";
  1056. // Loop on record
  1057. // --------------------------------------------------------------------
  1058. $i = 0;
  1059. $savnbfield = $totalarray['nbfield'];
  1060. $totalarray = array();
  1061. $totalarray['nbfield'] = 0;
  1062. $imaxinloop = ($limit ? min($num, $limit) : $num);
  1063. while ($i < $imaxinloop) {
  1064. $obj = $db->fetch_object($resql);
  1065. if (empty($obj)) {
  1066. break; // Should not happen
  1067. }
  1068. $reception->id = $obj->rowid;
  1069. $reception->ref = $obj->ref;
  1070. //$reception->ref_supplier = $obj->ref_supplier;
  1071. $reception->statut = $obj->status;
  1072. $reception->status = $obj->status;
  1073. $reception->socid = $obj->socid;
  1074. $reception->billed = $obj->billed;
  1075. $reception->fetch_thirdparty();
  1076. $object = $reception;
  1077. $companystatic->id = $obj->socid;
  1078. $companystatic->ref = $obj->name;
  1079. $companystatic->name = $obj->name;
  1080. if ($mode == 'kanban') {
  1081. if ($i == 0) {
  1082. print '<tr class="trkanban"><td colspan="'.$savnbfield.'">';
  1083. print '<div class="box-flex-container kanban">';
  1084. }
  1085. $object->date_delivery = $obj->delivery_date;
  1086. $object->town = $obj->town;
  1087. // Output Kanban
  1088. $selected = -1;
  1089. if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
  1090. $selected = 0;
  1091. if (in_array($object->id, $arrayofselected)) {
  1092. $selected = 1;
  1093. }
  1094. }
  1095. print $object->getKanbanView('', array('thirdparty' => $companystatic->getNomUrl(1), 'selected' => $selected));
  1096. if ($i == min($num, $limit) - 1) {
  1097. print '</div>';
  1098. print '</td></tr>';
  1099. }
  1100. } else {
  1101. print '<tr class="oddeven">';
  1102. // Action column
  1103. if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
  1104. print '<td class="nowrap center">';
  1105. if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
  1106. $selected = 0;
  1107. if (in_array($obj->rowid, $arrayofselected)) {
  1108. $selected = 1;
  1109. }
  1110. print '<input id="cb'.$obj->rowid.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.'"'.($selected ? ' checked="checked"' : '').'>';
  1111. }
  1112. print '</td>';
  1113. }
  1114. // Ref
  1115. if (!empty($arrayfields['e.ref']['checked'])) {
  1116. print '<td class="nowraponall">';
  1117. print $reception->getNomUrl(1);
  1118. $filename = dol_sanitizeFileName($reception->ref);
  1119. $filedir = $conf->reception->dir_output.'/'.dol_sanitizeFileName($reception->ref);
  1120. $urlsource = $_SERVER['PHP_SELF'].'?id='.$reception->id;
  1121. print $formfile->getDocumentsLink($reception->element, $filename, $filedir);
  1122. print "</td>\n";
  1123. if (!$i) {
  1124. $totalarray['nbfield']++;
  1125. }
  1126. }
  1127. // Ref supplier
  1128. if (!empty($arrayfields['e.ref_supplier']['checked'])) {
  1129. print '<td class="tdoverflowmax200" title="'.dol_escape_htmltag($obj->ref_supplier).'">';
  1130. print dol_escape_htmltag($obj->ref_supplier);
  1131. print "</td>\n";
  1132. if (!$i) {
  1133. $totalarray['nbfield']++;
  1134. }
  1135. }
  1136. // Third party
  1137. if (!empty($arrayfields['s.nom']['checked'])) {
  1138. print '<td class="tdoverflowmax150">';
  1139. print $companystatic->getNomUrl(1);
  1140. print '</td>';
  1141. if (!$i) {
  1142. $totalarray['nbfield']++;
  1143. }
  1144. }
  1145. // Town
  1146. if (!empty($arrayfields['s.town']['checked'])) {
  1147. print '<td class="nocellnopadd tdoverflowmax200" title="'.dol_escape_htmltag($obj->town).'">';
  1148. print dol_escape_htmltag($obj->town);
  1149. print '</td>';
  1150. if (!$i) {
  1151. $totalarray['nbfield']++;
  1152. }
  1153. }
  1154. // Zip
  1155. if (!empty($arrayfields['s.zip']['checked'])) {
  1156. print '<td class="nocellnopadd center"">';
  1157. print dol_escape_htmltag($obj->zip);
  1158. print '</td>';
  1159. if (!$i) {
  1160. $totalarray['nbfield']++;
  1161. }
  1162. }
  1163. // State
  1164. if (!empty($arrayfields['state.nom']['checked'])) {
  1165. print "<td>".dol_escape_htmltag($obj->state_name)."</td>\n";
  1166. if (!$i) {
  1167. $totalarray['nbfield']++;
  1168. }
  1169. }
  1170. // Country
  1171. if (!empty($arrayfields['country.code_iso']['checked'])) {
  1172. print '<td class="center">';
  1173. $tmparray = getCountry($obj->fk_pays, 'all');
  1174. print dol_escape_htmltag($tmparray['label']);
  1175. print '</td>';
  1176. if (!$i) {
  1177. $totalarray['nbfield']++;
  1178. }
  1179. }
  1180. // Type ent
  1181. if (!empty($arrayfields['typent.code']['checked'])) {
  1182. print '<td class="center">';
  1183. if (!isset($typenArray) || empty($typenArray)) {
  1184. $typenArray = $formcompany->typent_array(1);
  1185. }
  1186. if (isset($typenArray[$obj->typent_code])) {
  1187. print $typenArray[$obj->typent_code];
  1188. }
  1189. print '</td>';
  1190. if (!$i) {
  1191. $totalarray['nbfield']++;
  1192. }
  1193. }
  1194. // Date delivery planed
  1195. if (!empty($arrayfields['e.date_delivery']['checked'])) {
  1196. print '<td class="center">';
  1197. print dol_print_date($db->jdate($obj->delivery_date), "day");
  1198. /*$now = time();
  1199. if ( ($now - $db->jdate($obj->date_reception)) > $conf->warnings->lim && $obj->statutid == 1 )
  1200. {
  1201. }*/
  1202. print "</td>\n";
  1203. if (!$i) {
  1204. $totalarray['nbfield']++;
  1205. }
  1206. }
  1207. if (!empty($arrayfields['l.ref']['checked']) || !empty($arrayfields['l.date_delivery']['checked'])) {
  1208. $reception->fetchObjectLinked($reception->id, $reception->element);
  1209. $receiving = '';
  1210. if (count($reception->linkedObjects['delivery']) > 0) {
  1211. $receiving = reset($reception->linkedObjects['delivery']);
  1212. }
  1213. if (!empty($arrayfields['l.ref']['checked'])) {
  1214. // Ref
  1215. print '<td>';
  1216. print !empty($receiving) ? $receiving->getNomUrl($db) : '';
  1217. print '</td>';
  1218. }
  1219. if (!empty($arrayfields['l.date_delivery']['checked'])) {
  1220. // Date received
  1221. print '<td class="center">';
  1222. print dol_print_date($db->jdate($obj->date_reception), "day");
  1223. print '</td>'."\n";
  1224. }
  1225. }
  1226. // Extra fields
  1227. include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php';
  1228. // Fields from hook
  1229. $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray);
  1230. $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook
  1231. print $hookmanager->resPrint;
  1232. // Date creation
  1233. if (!empty($arrayfields['e.datec']['checked'])) {
  1234. print '<td class="center nowraponall">';
  1235. print dol_print_date($db->jdate($obj->date_creation), 'dayhour', 'tzuserrel');
  1236. print '</td>';
  1237. if (!$i) {
  1238. $totalarray['nbfield']++;
  1239. }
  1240. }
  1241. // Date modification
  1242. if (!empty($arrayfields['e.tms']['checked'])) {
  1243. print '<td class="center nowraponall">';
  1244. print dol_print_date($db->jdate($obj->date_update), 'dayhour', 'tzuserrel');
  1245. print '</td>';
  1246. if (!$i) {
  1247. $totalarray['nbfield']++;
  1248. }
  1249. }
  1250. // Status
  1251. if (!empty($arrayfields['e.fk_statut']['checked'])) {
  1252. print '<td class="right nowrap">'.$reception->LibStatut($obj->status, 5).'</td>';
  1253. if (!$i) {
  1254. $totalarray['nbfield']++;
  1255. }
  1256. }
  1257. // Billed
  1258. if (!empty($arrayfields['e.billed']['checked'])) {
  1259. print '<td class="center">'.yn($obj->billed).'</td>';
  1260. if (!$i) {
  1261. $totalarray['nbfield']++;
  1262. }
  1263. }
  1264. // Action column
  1265. if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
  1266. print '<td class="nowrap center">';
  1267. if ($massactionbutton || $massaction) {
  1268. // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
  1269. $selected = 0;
  1270. if (in_array($obj->rowid, $arrayofselected)) {
  1271. $selected = 1;
  1272. }
  1273. print '<input id="cb'.$obj->rowid.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.'"'.($selected ? ' checked="checked"' : '').'>';
  1274. }
  1275. print '</td>';
  1276. }
  1277. if (!$i) {
  1278. $totalarray['nbfield']++;
  1279. }
  1280. print "</tr>\n";
  1281. }
  1282. $i++;
  1283. }
  1284. // If no record found
  1285. if ($num == 0) {
  1286. $colspan = 1;
  1287. foreach ($arrayfields as $key => $val) {
  1288. if (!empty($val['checked'])) {
  1289. $colspan++;
  1290. }
  1291. }
  1292. print '<tr><td colspan="'.$colspan.'" class="opacitymedium">'.$langs->trans("NoRecordFound").'</td></tr>';
  1293. }
  1294. // Show total line
  1295. include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php';
  1296. $parameters = array('arrayfields'=>$arrayfields, 'totalarray' => $totalarray, 'sql'=>$sql);
  1297. $reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters); // Note that $action and $object may have been modified by hook
  1298. print $hookmanager->resPrint;
  1299. print "</table>";
  1300. print "</div>";
  1301. print '</form>';
  1302. $db->free($resql);
  1303. llxFooter();
  1304. $db->close();