type.php 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643
  1. <?php
  2. /* Copyright (C) 2018 Alexandre Spangaro <aspangaro@open-dsi.fr>
  3. *
  4. * This program is free software; you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License as published by
  6. * the Free Software Foundation; either version 3 of the License, or
  7. * (at your option) any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  16. */
  17. /**
  18. * \file htdocs/asset/type.php
  19. * \ingroup asset
  20. * \brief Asset's type setup
  21. */
  22. require '../main.inc.php';
  23. require_once DOL_DOCUMENT_ROOT.'/core/lib/asset.lib.php';
  24. require_once DOL_DOCUMENT_ROOT.'/asset/class/asset.class.php';
  25. require_once DOL_DOCUMENT_ROOT.'/asset/class/asset_type.class.php';
  26. require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
  27. if (! empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php';
  28. if (! empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php';
  29. if (! empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingaccount.class.php';
  30. // Load translation files required by the page
  31. $langs->load("assets");
  32. $rowid = GETPOST('rowid','int');
  33. $action = GETPOST('action','alpha');
  34. $cancel = GETPOST('cancel','alpha');
  35. $backtopage = GETPOST('backtopage','alpha');
  36. $type = GETPOST('type','alpha');
  37. $limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit;
  38. $sortfield = GETPOST("sortfield",'alpha');
  39. $sortorder = GETPOST("sortorder",'alpha');
  40. $page = GETPOST("page",'int');
  41. if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
  42. $offset = $limit * $page ;
  43. $pageprev = $page - 1;
  44. $pagenext = $page + 1;
  45. if (! $sortorder) { $sortorder="DESC"; }
  46. if (! $sortfield) { $sortfield="a.label"; }
  47. $label=GETPOST("label","alpha");
  48. $accountancy_code_asset=GETPOST('accountancy_code_asset','string');
  49. $accountancy_code_depreciation_asset=GETPOST('accountancy_code_depreciation_asset','string');
  50. $accountancy_code_depreciation_expense=GETPOST('accountancy_code_depreciation_expense','string');
  51. $comment=GETPOST('comment','string');
  52. // Security check
  53. $result=restrictedArea($user,'asset',$rowid,'asset_type');
  54. $object = new AssetType($db);
  55. $extrafields = new ExtraFields($db);
  56. // fetch optionals attributes and labels
  57. $extralabels=$extrafields->fetch_name_optionals_label('asset_type');
  58. 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
  59. {
  60. $type="";
  61. $sall="";
  62. }
  63. // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
  64. $hookmanager->initHooks(array('assettypecard','globalcard'));
  65. /*
  66. * Actions
  67. */
  68. if ($cancel) {
  69. $action='';
  70. if (! empty($backtopage))
  71. {
  72. header("Location: ".$backtopage);
  73. exit;
  74. }
  75. }
  76. if ($action == 'add' && $user->rights->asset->write)
  77. {
  78. $object->label = trim($label);
  79. $object->accountancy_code_asset = trim($accountancy_code_asset);
  80. $object->accountancy_code_depreciation_asset = trim($accountancy_code_depreciation_asset);
  81. $object->accountancy_code_depreciation_expense = trim($accountancy_code_depreciation_expense);
  82. $object->note = trim($comment);
  83. // Fill array 'array_options' with data from add form
  84. $ret = $extrafields->setOptionalsFromPost($extralabels,$object);
  85. if ($ret < 0) $error++;
  86. if (empty($object->label)) {
  87. $error++;
  88. setEventMessages($langs->trans("ErrorFieldRequired",$langs->transnoentities("Label")), null, 'errors');
  89. }
  90. else {
  91. $sql = "SELECT label FROM ".MAIN_DB_PREFIX."asset_type WHERE label='".$db->escape($object->label)."'";
  92. $result = $db->query($sql);
  93. if ($result) {
  94. $num = $db->num_rows($result);
  95. }
  96. if ($num) {
  97. $error++;
  98. $langs->load("errors");
  99. setEventMessages($langs->trans("ErrorLabelAlreadyExists",$login), null, 'errors');
  100. }
  101. }
  102. if (! $error)
  103. {
  104. $id=$object->create($user);
  105. if ($id > 0)
  106. {
  107. header("Location: ".$_SERVER["PHP_SELF"]);
  108. exit;
  109. }
  110. else
  111. {
  112. setEventMessages($object->error, $object->errors, 'errors');
  113. $action = 'create';
  114. }
  115. }
  116. else
  117. {
  118. $action = 'create';
  119. }
  120. }
  121. if ($action == 'update' && $user->rights->asset->write)
  122. {
  123. $object->fetch($rowid);
  124. $object->oldcopy = clone $object;
  125. $object->label = trim($label);
  126. $object->accountancy_code_asset = trim($accountancy_code_asset);
  127. $object->accountancy_code_depreciation_asset = trim($accountancy_code_depreciation_asset);
  128. $object->accountancy_code_depreciation_expense = trim($accountancy_code_depreciation_expense);
  129. $object->note = trim($comment);
  130. // Fill array 'array_options' with data from add form
  131. $ret = $extrafields->setOptionalsFromPost($extralabels,$object);
  132. if ($ret < 0) $error++;
  133. $ret=$object->update($user);
  134. if ($ret >= 0 && ! count($object->errors))
  135. {
  136. setEventMessages($langs->trans("AssetsTypeModified"), null, 'mesgs');
  137. }
  138. else
  139. {
  140. setEventMessages($object->error, $object->errors, 'errors');
  141. }
  142. header("Location: ".$_SERVER["PHP_SELF"]."?rowid=".$object->id);
  143. exit;
  144. }
  145. if ($action == 'confirm_delete' && $user->rights->asset->write)
  146. {
  147. $object->fetch($rowid);
  148. $res=$object->delete();
  149. if ($res > 0)
  150. {
  151. setEventMessages($langs->trans("AssetsTypeDeleted"), null, 'mesgs');
  152. header("Location: ".$_SERVER["PHP_SELF"]);
  153. exit;
  154. }
  155. else
  156. {
  157. setEventMessages($langs->trans("AssetsTypeCanNotBeDeleted"), null, 'errors');
  158. $action='';
  159. }
  160. }
  161. /*
  162. * View
  163. */
  164. $form=new Form($db);
  165. $helpurl='';
  166. llxHeader('',$langs->trans("AssetsTypeSetup"),$helpurl);
  167. // List of asset type
  168. if (! $rowid && $action != 'create' && $action != 'edit')
  169. {
  170. //dol_fiche_head('');
  171. $sql = "SELECT d.rowid, d.label as label, d.accountancy_code_asset, d.accountancy_code_depreciation_asset, d.accountancy_code_depreciation_expense, d.note";
  172. $sql.= " FROM ".MAIN_DB_PREFIX."asset_type as d";
  173. $sql.= " WHERE d.entity IN (".getEntity('asset_type').")";
  174. $result = $db->query($sql);
  175. if ($result)
  176. {
  177. $num = $db->num_rows($result);
  178. $nbtotalofrecords = $num;
  179. $i = 0;
  180. $param = '';
  181. print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
  182. if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
  183. print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
  184. print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
  185. print '<input type="hidden" name="action" value="list">';
  186. print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
  187. print '<input type="hidden" name="page" value="'.$page.'">';
  188. print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
  189. print_barre_liste($langs->trans("AssetsTypes"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'title_generic.png', 0, '', '', $limit);
  190. $moreforfilter = '';
  191. print '<div class="div-table-responsive">';
  192. print '<table class="tagtable liste'.($moreforfilter?" listwithfilterbefore":"").'">'."\n";
  193. print '<tr class="liste_titre">';
  194. print '<th>'.$langs->trans("Ref").'</th>';
  195. print '<th>'.$langs->trans("Label").'</th>';
  196. print '<th align="center">'.$langs->trans("AccountancyCodeAsset").'</th>';
  197. print '<th align="center">'.$langs->trans("AccountancyCodeDepreciationAsset").'</th>';
  198. print '<th align="center">'.$langs->trans("AccountancyCodeDepreciationExpense").'</th>';
  199. print '<th>&nbsp;</th>';
  200. print "</tr>\n";
  201. $assettype = new AssetType($db);
  202. while ($i < $num)
  203. {
  204. $objp = $db->fetch_object($result);
  205. $assettype->id = $objp->rowid;
  206. $assettype->ref = $objp->rowid;
  207. $assettype->label = $objp->rowid;
  208. print '<tr class="oddeven">';
  209. print '<td>';
  210. print $assettype->getNomUrl(1);
  211. //<a href="'.$_SERVER["PHP_SELF"].'?rowid='.$objp->rowid.'">'.img_object($langs->trans("ShowType"),'group').' '.$objp->rowid.'</a>
  212. print '</td>';
  213. print '<td>'.dol_escape_htmltag($objp->label).'</td>';
  214. print '<td class="center">';
  215. if (! empty($conf->accounting->enabled))
  216. {
  217. $accountingaccount = new AccountingAccount($db);
  218. $accountingaccount->fetch('',$objp->accountancy_code_asset,1);
  219. print $accountingaccount->getNomUrl(0,0,0,'',0);
  220. } else {
  221. print $objp->accountancy_code_asset;
  222. }
  223. print '</td>';
  224. print '<td class="center">';
  225. if (! empty($conf->accounting->enabled))
  226. {
  227. $accountingaccount2 = new AccountingAccount($db);
  228. $accountingaccount2->fetch('',$objp->accountancy_code_depreciation_asset,1);
  229. print $accountingaccount2->getNomUrl(0,0,0,'',0);
  230. } else {
  231. print $objp->accountancy_code_depreciation_asset;
  232. }
  233. print '</td>';
  234. print '<td class="center">';
  235. if (! empty($conf->accounting->enabled))
  236. {
  237. $accountingaccount3 = new AccountingAccount($db);
  238. $accountingaccount3->fetch('',$objp->accountancy_code_depreciation_expense,1);
  239. print $accountingaccount3->getNomUrl(0,0,0,'',0);
  240. } else {
  241. print $objp->accountancy_code_depreciation_expense;
  242. }
  243. print '</td>';
  244. if ($user->rights->asset->write)
  245. print '<td class="right"><a href="'.$_SERVER["PHP_SELF"].'?action=edit&rowid='.$objp->rowid.'">'.img_edit().'</a></td>';
  246. else
  247. print '<td class="right">&nbsp;</td>';
  248. print "</tr>";
  249. $i++;
  250. }
  251. print "</table>";
  252. print '</div>';
  253. print '</form>';
  254. }
  255. else
  256. {
  257. dol_print_error($db);
  258. }
  259. }
  260. /* ************************************************************************** */
  261. /* */
  262. /* Creation mode */
  263. /* */
  264. /* ************************************************************************** */
  265. if ($action == 'create')
  266. {
  267. $object = new AssetType($db);
  268. if (! empty($conf->accounting->enabled)) $formaccounting = new FormAccounting($db);
  269. print load_fiche_titre($langs->trans("NewAssetType"));
  270. print '<form action="'.$_SERVER['PHP_SELF'].'" method="POST">';
  271. print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
  272. print '<input type="hidden" name="action" value="add">';
  273. dol_fiche_head('');
  274. print '<table class="border" width="100%">';
  275. print '<tbody>';
  276. print '<tr><td class="titlefieldcreate fieldrequired">'.$langs->trans("Label").'</td><td><input type="text" name="label" size="40"></td></tr>';
  277. if (! empty($conf->accounting->enabled))
  278. {
  279. // Accountancy_code_asset
  280. print '<tr><td class="titlefield">'.$langs->trans("AccountancyCodeAsset").'</td>';
  281. print '<td>';
  282. print $formaccounting->select_account($object->accountancy_code_asset, 'accountancy_code_asset', 1, '', 1, 1);
  283. print '</td></tr>';
  284. // Accountancy_code_depreciation_expense
  285. print '<tr><td class="titlefield">'.$langs->trans("AccountancyCodeDepreciationAsset").'</td>';
  286. print '<td>';
  287. print $formaccounting->select_account($object->accountancy_code_depreciation_asset, 'accountancy_code_depreciation_asset', 1, '', 1, 1);
  288. print '</td></tr>';
  289. // Accountancy_code_depreciation_expense
  290. print '<tr><td class="titlefield">'.$langs->trans("AccountancyCodeDepreciationExpense").'</td>';
  291. print '<td>';
  292. print $formaccounting->select_account($object->accountancy_code_depreciation_expense, 'accountancy_code_depreciation_expense', 1, '', 1, 1);
  293. print '</td></tr>';
  294. }
  295. else // For external software
  296. {
  297. // Accountancy_code_asset
  298. print '<tr><td class="titlefield">'.$langs->trans("AccountancyCodeAsset").'</td>';
  299. print '<td><input name="accountancy_code_asset" class="maxwidth200" value="'.$object->accountancy_code_asset.'">';
  300. print '</td></tr>';
  301. // Accountancy_code_depreciation_asset
  302. print '<tr><td class="titlefield">'.$langs->trans("AccountancyCodeDepreciationAsset").'</td>';
  303. print '<td><input name="accountancy_code_depreciation_asset" class="maxwidth200" value="'.$object->accountancy_code_depreciation_asset.'">';
  304. print '</td></tr>';
  305. // Accountancy_code_depreciation_expense
  306. print '<tr><td class="titlefield">'.$langs->trans("AccountancyCodeDepreciationExpense").'</td>';
  307. print '<td><input name="accountancy_code_depreciation_expense" class="maxwidth200" value="'.$object->accountancy_code_depreciation_expense.'">';
  308. print '</td></tr>';
  309. }
  310. print '<tr><td class="tdtop">'.$langs->trans("Description").'</td><td>';
  311. print '<textarea name="comment" wrap="soft" class="centpercent" rows="3"></textarea></td></tr>';
  312. // Other attributes
  313. $parameters=array();
  314. $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$act,$action); // Note that $action and $object may have been modified by hook
  315. print $hookmanager->resPrint;
  316. if (empty($reshook))
  317. {
  318. print $object->showOptionals($extrafields,'edit');
  319. }
  320. print '<tbody>';
  321. print "</table>\n";
  322. dol_fiche_end();
  323. print '<div class="center">';
  324. print '<input type="submit" name="button" class="button" value="'.$langs->trans("Add").'">';
  325. print '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
  326. print '<input type="submit" name="cancel" class="button" value="'.$langs->trans("Cancel").'" onclick="history.go(-1)" />';
  327. print '</div>';
  328. print "</form>\n";
  329. }
  330. /* ************************************************************************** */
  331. /* */
  332. /* View mode */
  333. /* */
  334. /* ************************************************************************** */
  335. if ($rowid > 0)
  336. {
  337. if ($action != 'edit')
  338. {
  339. $object = new AssetType($db);
  340. $object->fetch($rowid);
  341. $object->fetch_optionals();
  342. /*
  343. * Confirmation suppression
  344. */
  345. if ($action == 'delete')
  346. {
  347. print $form->formconfirm($_SERVER['PHP_SELF']."?rowid=".$object->id,$langs->trans("DeleteAnAssetType"),$langs->trans("ConfirmDeleteAssetType",$object->label),"confirm_delete", '',0,1);
  348. }
  349. $head = asset_type_prepare_head($object);
  350. dol_fiche_head($head, 'card', $langs->trans("AssetType"), -1, 'setup');
  351. $linkback = '<a href="'.DOL_URL_ROOT.'/asset/type.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
  352. $morehtmlref='<div class="refidno">';
  353. // Ref asset type
  354. $morehtmlref.=$form->editfieldkey("Label", 'label', $object->label, $object, $user->rights->asset->write, 'string', '', 0, 1);
  355. $morehtmlref.=$form->editfieldval("Label", 'label', $object->label, $object, $user->rights->asset->write, 'string', '', null, null, '', 1);
  356. $morehtmlref.='</div>';
  357. dol_banner_tab($object, 'rowid', $linkback, 1, 'rowid', 'ref', $morehtmlref, '', 0, '', $morehtmlright);
  358. print '<div class="fichecenter">';
  359. print '<div class="underbanner clearboth"></div>';
  360. print '<table class="border" width="100%">';
  361. print '<tr>';
  362. print '<td class="nowrap">';
  363. print $langs->trans("AccountancyCodeAsset");
  364. print '</td><td>';
  365. if (! empty($conf->accounting->enabled))
  366. {
  367. $accountingaccount = new AccountingAccount($db);
  368. $accountingaccount->fetch('',$object->accountancy_code_asset,1);
  369. print $accountingaccount->getNomUrl(0,1,1,'',1);
  370. } else {
  371. print $object->accountancy_code_asset;
  372. }
  373. print '</td>';
  374. print '</tr>';
  375. print '<tr>';
  376. print '<td class="nowrap">';
  377. print $langs->trans("AccountancyCodeDepreciationAsset");
  378. print '</td><td>';
  379. if (! empty($conf->accounting->enabled))
  380. {
  381. $accountingaccount2 = new AccountingAccount($db);
  382. $accountingaccount2->fetch('',$object->accountancy_code_depreciation_asset,1);
  383. print $accountingaccount2->getNomUrl(0,1,1,'',1);
  384. } else {
  385. print $object->accountancy_code_depreciation_asset;
  386. }
  387. print '</td>';
  388. print '</tr>';
  389. print '<tr>';
  390. print '<td class="nowrap">';
  391. print $langs->trans("AccountancyCodeDepreciationExpense");
  392. print '</td><td>';
  393. if (! empty($conf->accounting->enabled))
  394. {
  395. $accountingaccount3 = new AccountingAccount($db);
  396. $accountingaccount3->fetch('',$object->accountancy_code_depreciation_expense,1);
  397. print $accountingaccount3->getNomUrl(0,1,1,'',1);
  398. } else {
  399. print $object->accountancy_code_depreciation_expense;
  400. }
  401. print '</td>';
  402. print '</tr>';
  403. print '<tr><td class="tdtop">'.$langs->trans("Description").'</td><td>';
  404. print nl2br($object->note)."</td></tr>";
  405. // Other attributes
  406. include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php';
  407. print '</table>';
  408. print '</div>';
  409. dol_fiche_end();
  410. /*
  411. * Buttons
  412. */
  413. print '<div class="tabsAction">';
  414. // Edit
  415. if ($user->rights->asset->write)
  416. {
  417. print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER['PHP_SELF'].'?action=edit&amp;rowid='.$object->id.'">'.$langs->trans("Modify").'</a></div>';
  418. }
  419. // Delete
  420. if ($user->rights->asset->write)
  421. {
  422. print '<div class="inline-block divButAction"><a class="butActionDelete" href="'.$_SERVER['PHP_SELF'].'?action=delete&rowid='.$object->id.'">'.$langs->trans("DeleteType").'</a></div>';
  423. }
  424. print "</div>";
  425. }
  426. /* ************************************************************************** */
  427. /* */
  428. /* Edition mode */
  429. /* */
  430. /* ************************************************************************** */
  431. if ($action == 'edit')
  432. {
  433. $object = new AssetType($db);
  434. $object->fetch($rowid);
  435. $object->fetch_optionals();
  436. if (! empty($conf->accounting->enabled)) $formaccounting = new FormAccounting($db);
  437. $head = asset_type_prepare_head($object);
  438. print '<form method="post" action="'.$_SERVER["PHP_SELF"].'?rowid='.$object->id.'">';
  439. print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
  440. print '<input type="hidden" name="rowid" value="'.$object->id.'">';
  441. print '<input type="hidden" name="action" value="update">';
  442. dol_fiche_head($head, 'card', $langs->trans("AssetsType"), -1, 'setup');
  443. print '<table class="border" width="100%">';
  444. print '<tr><td class="titlefield">'.$langs->trans("Ref").'</td><td>'.$object->id.'</td></tr>';
  445. print '<tr><td class="fieldrequired">'.$langs->trans("Label").'</td><td><input type="text" name="label" size="40" value="'.dol_escape_htmltag($object->label).'"></td></tr>';
  446. if (! empty($conf->accounting->enabled))
  447. {
  448. // Accountancy_code_asset
  449. print '<tr><td class="titlefield">'.$langs->trans("AccountancyCodeAsset").'</td>';
  450. print '<td>';
  451. print $formaccounting->select_account($object->accountancy_code_asset, 'accountancy_code_asset', 1, '', 1, 1);
  452. print '</td></tr>';
  453. // Accountancy_code_depreciation_expense
  454. print '<tr><td class="titlefield">'.$langs->trans("AccountancyCodeDepreciationAsset").'</td>';
  455. print '<td>';
  456. print $formaccounting->select_account($object->accountancy_code_depreciation_asset, 'accountancy_code_depreciation_asset', 1, '', 1, 1);
  457. print '</td></tr>';
  458. // Accountancy_code_depreciation_expense
  459. print '<tr><td class="titlefield">'.$langs->trans("AccountancyCodeDepreciationExpense").'</td>';
  460. print '<td>';
  461. print $formaccounting->select_account($object->accountancy_code_depreciation_expense, 'accountancy_code_depreciation_expense', 1, '', 1, 1);
  462. print '</td></tr>';
  463. }
  464. else // For external software
  465. {
  466. // Accountancy_code_asset
  467. print '<tr><td class="titlefield">'.$langs->trans("AccountancyCodeAsset").'</td>';
  468. print '<td><input name="accountancy_code_asset" class="maxwidth200" value="'.$object->accountancy_code_asset.'">';
  469. print '</td></tr>';
  470. // Accountancy_code_depreciation_asset
  471. print '<tr><td class="titlefield">'.$langs->trans("AccountancyCodeDepreciationAsset").'</td>';
  472. print '<td><input name="accountancy_code_depreciation_asset" class="maxwidth200" value="'.$object->accountancy_code_depreciation_asset.'">';
  473. print '</td></tr>';
  474. // Accountancy_code_depreciation_expense
  475. print '<tr><td class="titlefield">'.$langs->trans("AccountancyCodeDepreciationExpense").'</td>';
  476. print '<td><input name="accountancy_code_depreciation_expense" class="maxwidth200" value="'.$object->accountancy_code_depreciation_expense.'">';
  477. print '</td></tr>';
  478. }
  479. print '<tr><td class="tdtop">'.$langs->trans("Description").'</td><td>';
  480. print '<textarea name="comment" wrap="soft" class="centpercent" rows="3">'.$object->note.'</textarea></td></tr>';
  481. // Other attributes
  482. $parameters=array();
  483. $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$act,$action); // Note that $action and $object may have been modified by hook
  484. print $hookmanager->resPrint;
  485. if (empty($reshook))
  486. {
  487. print $object->showOptionals($extrafields,'edit');
  488. }
  489. print '</table>';
  490. // Extra field
  491. if (empty($reshook))
  492. {
  493. print '<br><br><table class="border" width="100%">';
  494. foreach($extrafields->attribute_label as $key=>$label)
  495. {
  496. if (isset($_POST["options_" . $key])) {
  497. if (is_array($_POST["options_" . $key])) {
  498. // $_POST["options"] is an array but following code expects a comma separated string
  499. $value = implode(",", $_POST["options_" . $key]);
  500. } else {
  501. $value = $_POST["options_" . $key];
  502. }
  503. } else {
  504. $value = $adht->array_options["options_" . $key];
  505. }
  506. print '<tr><td width="30%">'.$label.'</td><td>';
  507. print $extrafields->showInputField($key,$value);
  508. print "</td></tr>\n";
  509. }
  510. print '</table><br><br>';
  511. }
  512. dol_fiche_end();
  513. print '<div class="center">';
  514. print '<input type="submit" class="button" value="'.$langs->trans("Save").'">';
  515. print '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
  516. print '<input type="submit" name="cancel" class="button" value="'.$langs->trans("Cancel").'">';
  517. print '</div>';
  518. print "</form>";
  519. }
  520. }
  521. // End of page
  522. llxFooter();
  523. $db->close();