PageRenderTime 53ms CodeModel.GetById 20ms RepoModel.GetById 1ms app.codeStats 0ms

/htdocs/admin/company.php

https://bitbucket.org/speedealing/speedealing
PHP | 886 lines | 589 code | 140 blank | 157 comment | 88 complexity | 35b13ec903076064ec1fd9e70ee6fc9c MD5 | raw file
Possible License(s): LGPL-3.0, LGPL-2.1, GPL-3.0, MIT
  1. <?php
  2. /* Copyright (C) 2001-2007 Rodolphe Quiedeville <rodolphe@quiedeville.org>
  3. * Copyright (C) 2004-2012 Laurent Destailleur <eldy@users.sourceforge.net>
  4. * Copyright (C) 2005-2013 Regis Houssin <regis.houssin@capnetworks.com>
  5. * Copyright (C) 2010 Juanjo Menent <jmenent@2byte.es>
  6. * Copyright (C) 2011 Philippe Grand <philippe.grand@atoo-net.com>
  7. * Copyright (C) 2012 Herve Prot <herve.prot@symeos.com>
  8. *
  9. * This program is free software; you can redistribute it and/or modify
  10. * it under the terms of the GNU General Public License as published by
  11. * the Free Software Foundation; either version 3 of the License, or
  12. * (at your option) any later version.
  13. *
  14. * This program is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. * GNU General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU General Public License
  20. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  21. */
  22. require '../main.inc.php';
  23. require_once DOL_DOCUMENT_ROOT . '/core/lib/admin.lib.php';
  24. require_once DOL_DOCUMENT_ROOT . '/societe/lib/societe.lib.php';
  25. require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php';
  26. require_once DOL_DOCUMENT_ROOT . '/core/lib/images.lib.php';
  27. require_once DOL_DOCUMENT_ROOT . '/core/lib/functions2.lib.php';
  28. require_once DOL_DOCUMENT_ROOT . '/core/class/html.formother.class.php';
  29. require_once DOL_DOCUMENT_ROOT . '/core/class/html.formcompany.class.php';
  30. $action = GETPOST('action');
  31. $langs->load("admin");
  32. $langs->load("companies");
  33. if (!$user->admin)
  34. accessforbidden();
  35. $message = '';
  36. try {
  37. $mysoc->load("societe:mysoc"); // Refresh load
  38. } catch (Exception $e) {
  39. error_log("CreateMySocCompany");
  40. }
  41. /*
  42. * Actions
  43. */
  44. if (($action == 'update' && empty($_POST["cancel"]))
  45. || ($action == 'updateedit')) {
  46. require_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php';
  47. $object = $mysoc;
  48. $object->_id = "societe:mysoc";
  49. $object->_rev = $mysoc->_rev;
  50. $object->country_id = GETPOST('country_id');
  51. $object->name = $_POST["nom"];
  52. $object->address = $_POST["address"];
  53. $object->town = $_POST["ville"];
  54. $object->zip = $_POST["cp"];
  55. $object->state_id = $_POST["departement_id"];
  56. $object->currency = $_POST["currency"];
  57. $object->phone = $_POST["tel"];
  58. $object->fax = $_POST["fax"];
  59. $object->email = $_POST["mail"];
  60. $object->url = $_POST["web"];
  61. $object->notes = $_POST["note"];
  62. $object->barcode = $_POST["barcode"];
  63. $object->capital = $_POST["capital"];
  64. $object->forme_juridique_code = $_POST["forme_juridique_code"];
  65. $object->idprof1 = $_POST["siren"];
  66. $object->idprof2 = $_POST["siret"];
  67. $object->idprof3 = $_POST["ape"];
  68. $object->idprof4 = $_POST["rcs"];
  69. $object->idprof5 = $_POST["MAIN_INFO_PROFID5"];
  70. $object->idprof6 = $_POST["MAIN_INFO_PROFID6"];
  71. $object->tva_intra = $_POST["tva"];
  72. $object->fiscal_month_start = $_POST["fiscalmonthstart"];
  73. $object->tva_assuj = $_POST["optiontva"];
  74. // Local taxes
  75. $object->localtax1 = $_POST["optionlocaltax1"];
  76. $object->localtax2 = $_POST["optionlocaltax2"];
  77. /*
  78. } elseif (!empty($_FILES['photo']['name']))
  79. $edituser->Photo = dol_sanitizeFileName($_FILES['photo']['name']);
  80. $id = $edituser->update($user, 0, $action);
  81. print $id;
  82. if ($id == $edituser->id) {
  83. $file_OK = is_uploaded_file($_FILES['photo']['tmp_name']);
  84. if ($file_OK) {
  85. if (image_format_supported($_FILES['photo']['name']) > 0) {
  86. $edituser->storeFile('photo');
  87. } else {
  88. $errmsgs[] = "ErrorBadImageFormat";
  89. }
  90. } */
  91. if ($_FILES["logo"]["tmp_name"]) {
  92. if (preg_match('/([^\\/:]+)$/i', $_FILES["logo"]["name"], $reg)) {
  93. $original_file = $reg[1];
  94. $isimage = image_format_supported($original_file);
  95. if ($isimage >= 0) {
  96. dol_syslog("Move file " . $_FILES["logo"]["tmp_name"] . " to " . $conf->mycompany->dir_output . '/logos/' . $original_file);
  97. $result = is_uploaded_file($_FILES['logo']['tmp_name']);
  98. //$result = dol_move_uploaded_file($_FILES["logo"]["tmp_name"], $conf->mycompany->dir_output . '/logos/' . $original_file, 1, 0, $_FILES['logo']['error']);
  99. if ($result > 0) {
  100. $object->logo = $original_file;
  101. $object->record(true);
  102. $object->storeFile('logo', true);
  103. // Create thumbs of logo (Note that PDF use original file and not thumbs)
  104. /* if ($isimage > 0) {
  105. // Create small thumbs for company (Ratio is near 16/9)
  106. // Used on logon for example
  107. $imgThumbSmall = vignette($conf->mycompany->dir_output . '/logos/' . $original_file, $maxwidthsmall, $maxheightsmall, '_small', $quality);
  108. if (preg_match('/([^\\/:]+)$/i', $imgThumbSmall, $reg)) {
  109. $imgThumbSmall = $reg[1];
  110. $object->logo_small = $imgThumbSmall;
  111. }
  112. else
  113. dol_syslog($imgThumbSmall); */
  114. }
  115. else
  116. dol_syslog($langs->trans("ErrorImageFormatNotSupported"), LOG_WARNING);
  117. }
  118. else if (preg_match('/^ErrorFileIsInfectedWithAVirus/', $result)) {
  119. $langs->load("errors");
  120. $tmparray = explode(':', $result);
  121. $message .= '<div class="error">' . $langs->trans('ErrorFileIsInfectedWithAVirus', $tmparray[1]) . '</div>';
  122. } else {
  123. $message .= '<div class="error">' . $langs->trans("ErrorFailedToSaveFile") . '</div>';
  124. }
  125. } else {
  126. $message .= '<div class="error">' . $langs->trans("ErrorOnlyPngJpgSupported") . '</div>';
  127. }
  128. } else
  129. $object->record(true);
  130. if ($action != 'updateedit' && !$message) {
  131. header("Location: " . $_SERVER["PHP_SELF"]);
  132. exit;
  133. }
  134. }
  135. /*
  136. if ($action == 'addthumb') {
  137. $isimage = image_format_supported($_GET["file"]);
  138. // Create thumbs of logo
  139. if ($isimage > 0) {
  140. // Create small thumbs for company (Ratio is near 16/9)
  141. // Used on logon for example
  142. $imgThumbSmall = vignette($conf->mycompany->dir_output . '/logos/' . $_GET["file"], $maxwidthsmall, $maxheightsmall, '_small', $quality);
  143. if (image_format_supported($imgThumbSmall) >= 0 && preg_match('/([^\\/:]+)$/i', $imgThumbSmall, $reg)) {
  144. $imgThumbSmall = $reg[1];
  145. dolibarr_set_const($db, "MAIN_INFO_SOCIETE_LOGO_SMALL", $imgThumbSmall, 'chaine', 0, '', $conf->entity);
  146. }
  147. else
  148. dol_syslog($imgThumbSmall);
  149. // Create mini thumbs for company (Ratio is near 16/9)
  150. // Used on menu or for setup page for example
  151. $imgThumbMini = vignette($conf->mycompany->dir_output . '/logos/' . $_GET["file"], $maxwidthmini, $maxheightmini, '_mini', $quality);
  152. if (image_format_supported($imgThumbSmall) >= 0 && preg_match('/([^\\/:]+)$/i', $imgThumbMini, $reg)) {
  153. $imgThumbMini = $reg[1];
  154. dolibarr_set_const($db, "MAIN_INFO_SOCIETE_LOGO_MINI", $imgThumbMini, 'chaine', 0, '', $conf->entity);
  155. }
  156. else
  157. dol_syslog($imgThumbMini);
  158. header("Location: " . $_SERVER["PHP_SELF"]);
  159. exit;
  160. }
  161. else {
  162. $message .= '<div class="error">' . $langs->trans("ErrorImageFormatNotSupported") . '</div>';
  163. dol_syslog($langs->transnoentities("ErrorImageFormatNotSupported"), LOG_WARNING);
  164. }
  165. } */
  166. if ($action == 'removelogo') {
  167. $del_photo = $mysoc->logo;
  168. unset($mysoc->logo);
  169. $mysoc->record(true);
  170. if (!empty($del_photo))
  171. $mysoc->deleteFile($del_photo, true);
  172. /*
  173. $del_photo = $mysoc->logo_small;
  174. if (!empty($del_photo))
  175. $mysoc->deleteFile($del_photo);
  176. unset($mysoc->logo_small); */
  177. }
  178. /*
  179. * View
  180. */
  181. llxHeader('', $langs->trans("Setup"));
  182. $form = new Form($db);
  183. $formother = new FormOther($db);
  184. $formcompany = new FormCompany($db);
  185. $countrynotdefined = '<font class="error">' . $langs->trans("ErrorSetACountryFirst") . ' (' . $langs->trans("SeeAbove") . ')</font>';
  186. $title = $langs->trans("CompanyFoundation");
  187. print_fiche_titre($title);
  188. print '<div class="with-padding">';
  189. print '<div class="columns">';
  190. print start_box($title, "twelve", $mysoc->fk_extrafields->ico, false);
  191. print $langs->trans("CompanyFundationDesc") . "<br>\n";
  192. print "<br>\n";
  193. if ($action == 'edit' || $action == 'updateedit') {
  194. /**
  195. * Edition des parametres
  196. */
  197. print "\n" . '<script type="text/javascript" language="javascript">';
  198. print '$(document).ready(function () {
  199. $("#selectcountry_id").change(function() {
  200. document.form_index.action.value="updateedit";
  201. document.form_index.submit();
  202. });
  203. });';
  204. print '</script>' . "\n";
  205. print '<form enctype="multipart/form-data" method="post" action="' . $_SERVER["PHP_SELF"] . '" name="form_index">';
  206. print '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">';
  207. print '<input type="hidden" name="action" value="update">';
  208. $var = true;
  209. print '<table class="noborder" width="100%">';
  210. print '<tr class="liste_titre"><td width="35%">' . $langs->trans("CompanyInfo") . '</td><td>' . $langs->trans("Value") . '</td></tr>' . "\n";
  211. $var = !$var;
  212. print '<tr ' . $bc[$var] . '><td class="fieldrequired">' . $langs->trans("CompanyName") . '</td><td>';
  213. print '<input name="nom" size="30" value="' . ($mysoc->name ? $mysoc->name : $_POST["nom"]) . '"></td></tr>' . "\n";
  214. $var = !$var;
  215. print '<tr ' . $bc[$var] . '><td>' . $langs->trans("CompanyAddress") . '</td><td>';
  216. print '<textarea name="address" cols="80" rows="' . ROWS_3 . '">' . ($mysoc->address ? $mysoc->address : $_POST["address"]) . '</textarea></td></tr>' . "\n";
  217. $var = !$var;
  218. print '<tr ' . $bc[$var] . '><td>' . $langs->trans("CompanyZip") . '</td><td>';
  219. print '<input name="cp" value="' . ($mysoc->zip ? $mysoc->zip : $_POST["cp"]) . '" size="10"></td></tr>' . "\n";
  220. $var = !$var;
  221. print '<tr ' . $bc[$var] . '><td>' . $langs->trans("CompanyTown") . '</td><td>';
  222. print '<input name="ville" size="30" value="' . ($mysoc->town ? $mysoc->town : $_POST["ville"]) . '"></td></tr>' . "\n";
  223. // Country
  224. $var = !$var;
  225. print '<tr ' . $bc[$var] . '><td class="fieldrequired">' . $langs->trans("Country") . '</td><td>';
  226. //if (empty($pays_selected)) $pays_selected=substr($langs->defaultlang,-2); // Par defaut, pays de la localisation
  227. print $mysoc->select_fk_extrafields('country_id', 'country_id');
  228. if ($user->admin)
  229. print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionnarySetup"), 1);
  230. print '</td></tr>' . "\n";
  231. $var = !$var;
  232. print '<tr ' . $bc[$var] . '><td>' . $langs->trans("State") . '</td><td>';
  233. print $mysoc->select_fk_extrafields('state_id', 'departement_id');
  234. print '</td></tr>' . "\n";
  235. $var = !$var;
  236. print '<tr ' . $bc[$var] . '><td>' . $langs->trans("CompanyCurrency") . '</td><td>';
  237. if (empty($mysoc->currency))
  238. $mysoc->currency = $conf->currency;
  239. print $mysoc->select_fk_extrafields("currency", 'currency');
  240. print '</td></tr>' . "\n";
  241. $var = !$var;
  242. print '<tr ' . $bc[$var] . '><td>' . $langs->trans("Phone") . '</td><td>';
  243. print '<input name="tel" value="' . $mysoc->phone . '"></td></tr>';
  244. print '</td></tr>' . "\n";
  245. $var = !$var;
  246. print '<tr ' . $bc[$var] . '><td>' . $langs->trans("Fax") . '</td><td>';
  247. print '<input name="fax" value="' . $mysoc->fax . '"></td></tr>';
  248. print '</td></tr>' . "\n";
  249. $var = !$var;
  250. print '<tr ' . $bc[$var] . '><td>' . $langs->trans("EMail") . '</td><td>';
  251. print '<input name="mail" size="60" value="' . $mysoc->email . '"></td></tr>';
  252. print '</td></tr>' . "\n";
  253. // Web
  254. $var = !$var;
  255. print '<tr ' . $bc[$var] . '><td>' . $langs->trans("Web") . '</td><td>';
  256. print '<input name="web" size="60" value="' . $mysoc->url . '"></td></tr>';
  257. print '</td></tr>' . "\n";
  258. // Barcode
  259. if (!empty($conf->barcode->enabled)) {
  260. $var = !$var;
  261. print '<tr ' . $bc[$var] . '><td>' . $langs->trans("Gencod") . '</td><td>';
  262. print '<input name="barcode" size="40" value="' . $mysoc->barcode . '"></td></tr>';
  263. print '</td></tr>';
  264. }
  265. // Logo
  266. $var = !$var;
  267. print '<tr ' . $bc[$var] . '><td>' . $langs->trans("Logo") . ' (png,jpg)</td><td>';
  268. print '<table width="100%" class="nocellnopadd"><tr class="nocellnopadd"><td valign="middle" class="nocellnopadd">';
  269. print '<input type="file" class="flat" name="logo" size="50">';
  270. print '</td><td valign="middle" align="right">';
  271. if (!empty($mysoc->logo))
  272. print '<a href="' . $_SERVER["PHP_SELF"] . '?action=removelogo">' . img_delete($langs->trans("Delete")) . '</a>';
  273. print $mysoc->print_fk_extrafields('logo');
  274. print '</td></tr></table>';
  275. print '</td></tr>';
  276. // Note
  277. $var = !$var;
  278. print '<tr ' . $bc[$var] . '><td valign="top">' . $langs->trans("Note") . '</td><td>';
  279. print '<textarea class="flat" name="note" cols="80" rows="' . ROWS_5 . '">' . $mysoc->notes . '</textarea></td></tr>';
  280. print '</td></tr>';
  281. print '</table>';
  282. print '<br>';
  283. // Identifiants de la societe (propre au pays)
  284. print '<table class="noborder" width="100%">';
  285. print '<tr class="liste_titre"><td>' . $langs->trans("CompanyIds") . '</td><td>' . $langs->trans("Value") . '</td></tr>';
  286. $var = true;
  287. $langs->load("companies");
  288. // Capital
  289. $var = !$var;
  290. print '<tr ' . $bc[$var] . '><td width="35%">' . $langs->trans("Capital") . '</td><td>';
  291. print '<input name="capital" size="20" value="' . $mysoc->capital . '"></td></tr>';
  292. // Forme juridique
  293. $var = !$var;
  294. print '<tr ' . $bc[$var] . '><td>' . $langs->trans("JuridicalStatus") . '</td><td>';
  295. if ($mysoc->country_id) {
  296. print $mysoc->select_fk_extrafields("forme_juridique_code", "forme_juridique_code");
  297. } else {
  298. print $countrynotdefined;
  299. }
  300. print '</td></tr>';
  301. // ProfID1
  302. if ($langs->transcountry("ProfId1", $mysoc->country_id) != '-') {
  303. $var = !$var;
  304. print '<tr ' . $bc[$var] . '><td width="35%">' . $langs->transcountry("ProfId1", $mysoc->country_id) . '</td><td>';
  305. if (!empty($mysoc->country_id)) {
  306. print '<input name="siren" size="20" value="' . $mysoc->idprof1 . '">';
  307. } else {
  308. print $countrynotdefined;
  309. }
  310. print '</td></tr>';
  311. }
  312. // ProfId2
  313. if ($langs->transcountry("ProfId2", $mysoc->country_id) != '-') {
  314. $var = !$var;
  315. print '<tr ' . $bc[$var] . '><td width="35%">' . $langs->transcountry("ProfId2", $mysoc->country_id) . '</td><td>';
  316. if (!empty($mysoc->country_id)) {
  317. print '<input name="siret" size="20" value="' . $mysoc->idprof2 . '">';
  318. } else {
  319. print $countrynotdefined;
  320. }
  321. print '</td></tr>';
  322. }
  323. // ProfId3
  324. if ($langs->transcountry("ProfId3", $mysoc->country_id) != '-') {
  325. $var = !$var;
  326. print '<tr ' . $bc[$var] . '><td width="35%">' . $langs->transcountry("ProfId3", $mysoc->country_id) . '</td><td>';
  327. if (!empty($mysoc->country_id)) {
  328. print '<input name="ape" size="20" value="' . $mysoc->idprof3 . '">';
  329. } else {
  330. print $countrynotdefined;
  331. }
  332. print '</td></tr>';
  333. }
  334. // ProfId4
  335. if ($langs->transcountry("ProfId4", $mysoc->country_id) != '-') {
  336. $var = !$var;
  337. print '<tr ' . $bc[$var] . '><td width="35%">' . $langs->transcountry("ProfId4", $mysoc->country_id) . '</td><td>';
  338. if (!empty($mysoc->country_id)) {
  339. print '<input name="rcs" size="20" value="' . $mysoc->idprof4 . '">';
  340. } else {
  341. print $countrynotdefined;
  342. }
  343. print '</td></tr>';
  344. }
  345. // ProfId5
  346. if ($langs->transcountry("ProfId5", $mysoc->country_id) != '-') {
  347. $var = !$var;
  348. print '<tr ' . $bc[$var] . '><td width="35%">' . $langs->transcountry("ProfId5", $mysoc->country_id) . '</td><td>';
  349. if (!empty($mysoc->country_id)) {
  350. print '<input name="MAIN_INFO_PROFID5" size="20" value="' . $mysoc->idprof5 . '">';
  351. } else {
  352. print $countrynotdefined;
  353. }
  354. print '</td></tr>';
  355. }
  356. // ProfId6
  357. if ($langs->transcountry("ProfId6", $mysoc->country_id) != '-') {
  358. $var = !$var;
  359. print '<tr ' . $bc[$var] . '><td width="35%">' . $langs->transcountry("ProfId6", $mysoc->country_id) . '</td><td>';
  360. if (!empty($mysoc->country_id)) {
  361. print '<input name="MAIN_INFO_PROFID6" size="20" value="' . $mysoc->idprof6 . '">';
  362. } else {
  363. print $countrynotdefined;
  364. }
  365. print '</td></tr>';
  366. }
  367. // TVA Intra
  368. $var = !$var;
  369. print '<tr ' . $bc[$var] . '><td width="35%">' . $langs->trans("VATIntra") . '</td><td>';
  370. print '<input name="tva" size="20" value="' . $mysoc->tva_intra . '">';
  371. print '</td></tr>';
  372. print '</table>';
  373. /*
  374. * Debut d'annee fiscale
  375. */
  376. print '<br>';
  377. print '<table class="noborder" width="100%">';
  378. print '<tr class="liste_titre">';
  379. print '<td>' . $langs->trans("FiscalYearInformation") . '</td><td>' . $langs->trans("Value") . '</td>';
  380. print "</tr>\n";
  381. $var = true;
  382. $var = !$var;
  383. print '<tr ' . $bc[$var] . '><td width="35%">' . $langs->trans("FiscalMonthStart") . '</td><td>';
  384. print $formother->select_month($mysoc->fiscal_month_start, 'fiscalmonthstart', 0) . '</td></tr>';
  385. print "</table>";
  386. /*
  387. * Options fiscale
  388. */
  389. print '<br>';
  390. print '<table class="noborder" width="100%">';
  391. print '<tr class="liste_titre">';
  392. print '<td>' . $langs->trans("VATManagement") . '</td><td>' . $langs->trans("Description") . '</td>';
  393. print '<td align="right">&nbsp;</td>';
  394. print "</tr>\n";
  395. $var = true;
  396. $var = !$var;
  397. print "<tr " . $bc[$var] . "><td width=\"140\"><label><input type=\"radio\" name=\"optiontva\" value=\"1\"" . ($mysoc->tva_assuj ? " checked" : "") . "> " . $langs->trans("VATIsUsed") . "</label></td>";
  398. print '<td colspan="2">';
  399. print "<table>";
  400. print "<tr><td>" . $langs->trans("VATIsUsedDesc") . "</td></tr>";
  401. print "<tr><td><i>" . $langs->trans("Example") . ': ' . $langs->trans("VATIsUsedExampleFR") . "</i></td></tr>\n";
  402. print "</table>";
  403. print "</td></tr>\n";
  404. $var = !$var;
  405. print "<tr " . $bc[$var] . "><td width=\"140\"><label><input type=\"radio\" name=\"optiontva\" value=\"0\"" . (!$mysoc->tva_assuj ? " checked" : "") . "> " . $langs->trans("VATIsNotUsed") . "</label></td>";
  406. print '<td colspan="2">';
  407. print "<table>";
  408. print "<tr><td>" . $langs->trans("VATIsNotUsedDesc") . "</td></tr>";
  409. print "<tr><td><i>" . $langs->trans("Example") . ': ' . $langs->trans("VATIsNotUsedExampleFR") . "</i></td></tr>\n";
  410. print "</table>";
  411. print "</td></tr>\n";
  412. print "</table>";
  413. /*
  414. * Local Taxes
  415. */
  416. if ($mysoc->country_id == 'ES') {
  417. // Local Tax 1
  418. print '<br>';
  419. print '<table class="noborder" width="100%">';
  420. print '<tr class="liste_titre">';
  421. print '<td>' . $langs->transcountry("LocalTax1Management", $mysoc->country_id) . '</td><td>' . $langs->trans("Description") . '</td>';
  422. print '<td align="right">&nbsp;</td>';
  423. print "</tr>\n";
  424. $var = true;
  425. $var = !$var;
  426. print "<tr " . $bc[$var] . "><td width=\"140\"><label><input type=\"radio\" name=\"optionlocaltax1\" value=\"localtax1on\"" . ($conf->global->FACTURE_LOCAL_TAX1_OPTION != "localtax1off" ? " checked" : "") . "> " . $langs->transcountry("LocalTax1IsUsed", $mysoc->country_code) . "</label></td>";
  427. print '<td colspan="2">';
  428. print "<table>";
  429. print "<tr><td>" . $langs->transcountry("LocalTax1IsUsedDesc", $mysoc->country_id) . "</td></tr>";
  430. print "<tr><td><i>" . $langs->trans("Example") . ': ' . $langs->transcountry("LocalTax1IsUsedExample", $mysoc->country_id) . "</i></td></tr>\n";
  431. print "</table>";
  432. print "</td></tr>\n";
  433. $var = !$var;
  434. print "<tr " . $bc[$var] . "><td width=\"140\"><label><input type=\"radio\" name=\"optionlocaltax1\" value=\"localtax1off\"" . ($conf->global->FACTURE_LOCAL_TAX1_OPTION == "localtax1off" ? " checked" : "") . "> " . $langs->transcountry("LocalTax1IsNotUsed", $mysoc->country_code) . "</label></td>";
  435. print '<td colspan="2">';
  436. print "<table>";
  437. print "<tr><td>" . $langs->transcountry("LocalTax1IsNotUsedDesc", $mysoc->country_id) . "</td></tr>";
  438. print "<tr><td><i>" . $langs->trans("Example") . ': ' . $langs->transcountry("LocalTax1IsNotUsedExample", $mysoc->country_id) . "</i></td></tr>\n";
  439. print "</table>";
  440. print "</td></tr>\n";
  441. print "</table>";
  442. // Local Tax 2
  443. print '<br>';
  444. print '<table class="noborder" width="100%">';
  445. print '<tr class="liste_titre">';
  446. print '<td>' . $langs->transcountry("LocalTax2Management", $mysoc->country_id) . '</td><td>' . $langs->trans("Description") . '</td>';
  447. print '<td align="right">&nbsp;</td>';
  448. print "</tr>\n";
  449. $var = true;
  450. $var = !$var;
  451. print "<tr " . $bc[$var] . "><td width=\"140\"><label><input type=\"radio\" name=\"optionlocaltax2\" value=\"localtax2on\"" . ($conf->global->FACTURE_LOCAL_TAX2_OPTION != "localtax2off" ? " checked" : "") . "> " . $langs->transcountry("LocalTax2IsUsed", $mysoc->country_code) . "</label></td>";
  452. print '<td colspan="2">';
  453. print "<table>";
  454. print "<tr><td>" . $langs->transcountry("LocalTax2IsUsedDesc", $mysoc->country_id) . "</td></tr>";
  455. print "<tr><td><i>" . $langs->trans("Example") . ': ' . $langs->transcountry("LocalTax2IsUsedExample", $mysoc->country_id) . "</i></td></tr>\n";
  456. print "</table>";
  457. print "</td></tr>\n";
  458. $var = !$var;
  459. print "<tr " . $bc[$var] . "><td width=\"140\"><label><input type=\"radio\" name=\"optionlocaltax2\" value=\"localtax2off\"" . ($conf->global->FACTURE_LOCAL_TAX2_OPTION == "localtax2off" ? " checked" : "") . "> " . $langs->transcountry("LocalTax2IsNotUsed", $mysoc->country_code) . "</label></td>";
  460. print '<td colspan="2">';
  461. print "<table>";
  462. print "<tr><td>" . $langs->transcountry("LocalTax2IsNotUsedDesc", $mysoc->country_id) . "</td></tr>";
  463. print "<tr><td><i>" . $langs->trans("Example") . ': ' . $langs->transcountry("LocalTax2IsNotUsedExample", $mysoc->country_code) . "</i></td></tr>\n";
  464. print "</table>";
  465. print "</td></tr>\n";
  466. print "</table>";
  467. }
  468. print '<br><center>';
  469. print '<input type="submit" class="button" name="save" value="' . $langs->trans("Save") . '">';
  470. print ' &nbsp; &nbsp; ';
  471. print '<input type="submit" class="button" name="cancel" value="' . $langs->trans("Cancel") . '">';
  472. print '</center>';
  473. print '<br>';
  474. print '</form>';
  475. } else {
  476. /*
  477. * Show parameters
  478. */
  479. dol_htmloutput_mesg($message);
  480. // Actions buttons
  481. //print '<div class="tabsAction">';
  482. //print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=edit">'.$langs->trans("Modify").'</a>';
  483. //print '</div><br>';
  484. print '<table class="noborder" width="100%">';
  485. print '<tr class="liste_titre"><td>' . $langs->trans("CompanyInfo") . '</td><td>' . $langs->trans("Value") . '</td></tr>';
  486. $var = true;
  487. $var = !$var;
  488. print '<tr ' . $bc[$var] . '><td width="35%">' . $langs->trans("CompanyName") . '</td><td>';
  489. if (!empty($mysoc->name))
  490. print $mysoc->name;
  491. else
  492. print img_warning() . ' <font class="error">' . $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("CompanyName")) . '</font>';
  493. print '</td></tr>';
  494. $var = !$var;
  495. print '<tr ' . $bc[$var] . '><td width="35%">' . $langs->trans("CompanyAddress") . '</td><td>' . nl2br($mysoc->address) . '</td></tr>';
  496. $var = !$var;
  497. print '<tr ' . $bc[$var] . '><td width="35%">' . $langs->trans("CompanyZip") . '</td><td>' . $mysoc->zip . '</td></tr>';
  498. $var = !$var;
  499. print '<tr ' . $bc[$var] . '><td width="35%">' . $langs->trans("CompanyTown") . '</td><td>' . $mysoc->town . '</td></tr>';
  500. $var = !$var;
  501. print '<tr ' . $bc[$var] . '><td>' . $langs->trans("CompanyCountry") . '</td><td>';
  502. if ($mysoc->country_id) {
  503. $img = picto_from_langcode($mysoc->country_id);
  504. if ($mysoc->isInEEC())
  505. print $form->textwithpicto(($img ? $img . ' ' : '') . $mysoc->country_id, $langs->trans("CountryIsInEEC"), 1, 0);
  506. else
  507. print ($img ? $img . ' ' : '') . $mysoc->country_id;
  508. }
  509. else
  510. print img_warning() . ' <font class="error">' . $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("CompanyCountry")) . '</font>';
  511. print '</td></tr>';
  512. $var = !$var;
  513. print '<tr ' . $bc[$var] . '><td>' . $langs->trans("State") . '</td><td>';
  514. print $mysoc->print_fk_extrafields("state_id");
  515. print '</td></tr>';
  516. $var = !$var;
  517. print '<tr ' . $bc[$var] . '><td width="35%">' . $langs->trans("CompanyCurrency") . '</td><td>';
  518. print $mysoc->print_fk_extrafields("currency");
  519. print '</td></tr>';
  520. $var = !$var;
  521. print '<tr ' . $bc[$var] . '><td width="35%">' . $langs->trans("Tel") . '</td><td>' . dol_print_phone($mysoc->phone, $mysoc->country_id) . '</td></tr>';
  522. $var = !$var;
  523. print '<tr ' . $bc[$var] . '><td width="35%">' . $langs->trans("Fax") . '</td><td>' . dol_print_phone($mysoc->fax, $mysoc->country_id) . '</td></tr>';
  524. $var = !$var;
  525. print '<tr ' . $bc[$var] . '><td width="35%">' . $langs->trans("Mail") . '</td><td>' . dol_print_email($mysoc->email, 0, 0, 0, 80) . '</td></tr>';
  526. // Web
  527. $var = !$var;
  528. print '<tr ' . $bc[$var] . '><td width="35%">' . $langs->trans("Web") . '</td><td>' . dol_print_url($mysoc->url, '_blank', 80) . '</td></tr>';
  529. // Barcode
  530. if (!empty($conf->barcode->enabled)) {
  531. $var = !$var;
  532. print '<tr ' . $bc[$var] . '><td width="35%">' . $langs->trans("Gencod") . '</td><td>' . $mysoc->barcode . '</td></tr>';
  533. }
  534. // Logo
  535. $var = !$var;
  536. print '<tr ' . $bc[$var] . '><td width="35%">' . $langs->trans("Logo") . '</td><td>';
  537. print '<table width="100%" class="nocellnopadd"><tr class="nocellnopadd"><td valign="middle" class="nocellnopadd">';
  538. print $mysoc->logo;
  539. print '</td><td valign="center" align="right">';
  540. print $mysoc->print_fk_extrafields('logo');
  541. print '</td></tr></table>';
  542. print '</td></tr>';
  543. $var = !$var;
  544. print '<tr ' . $bc[$var] . '><td width="35%" valign="top">' . $langs->trans("Note") . '</td><td>' . (!empty($conf->global->MAIN_INFO_SOCIETE_NOTE) ? nl2br($conf->global->MAIN_INFO_SOCIETE_NOTE) : '') . '</td></tr>';
  545. print '</table>';
  546. print '<br>';
  547. // Identifiants de la societe (propre au pays)
  548. print '<form name="formsoc" method="post">';
  549. print '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">';
  550. print '<table class="noborder" width="100%">';
  551. print '<tr class="liste_titre"><td>' . $langs->trans("CompanyIds") . '</td><td>' . $langs->trans("Value") . '</td></tr>';
  552. $var = true;
  553. // Capital
  554. $var = !$var;
  555. print '<tr ' . $bc[$var] . '><td width="35%">' . $langs->trans("Capital") . '</td><td>';
  556. print $mysoc->capital . '</td></tr>';
  557. // Forme juridique
  558. $var = !$var;
  559. print '<tr ' . $bc[$var] . '><td width="35%">' . $langs->trans("JuridicalStatus") . '</td><td>';
  560. print $mysoc->print_fk_extrafields('forme_juridique_code');
  561. print '</td></tr>';
  562. // ProfId1
  563. if ($langs->transcountry("ProfId1", $mysoc->country_id) != '-') {
  564. $var = !$var;
  565. print '<tr ' . $bc[$var] . '><td width="35%">' . $langs->transcountry("ProfId1", $mysoc->country_id) . '</td><td>';
  566. print $mysoc->idprof1;
  567. print '</td></tr>';
  568. }
  569. // ProfId2
  570. if ($langs->transcountry("ProfId2", $mysoc->country_id) != '-') {
  571. $var = !$var;
  572. print '<tr ' . $bc[$var] . '><td width="35%">' . $langs->transcountry("ProfId2", $mysoc->country_id) . '</td><td>';
  573. print $mysoc->idprof2;
  574. print '</td></tr>';
  575. }
  576. // ProfId3
  577. if ($langs->transcountry("ProfId3", $mysoc->country_id) != '-') {
  578. $var = !$var;
  579. print '<tr ' . $bc[$var] . '><td width="35%">' . $langs->transcountry("ProfId3", $mysoc->country_id) . '</td><td>';
  580. print $mysoc->idprof3;
  581. print '</td></tr>';
  582. }
  583. // ProfId4
  584. if ($langs->transcountry("ProfId4", $mysoc->country_id) != '-') {
  585. $var = !$var;
  586. print '<tr ' . $bc[$var] . '><td width="35%">' . $langs->transcountry("ProfId4", $mysoc->country_id) . '</td><td>';
  587. print $mysoc->idprof4;
  588. print '</td></tr>';
  589. }
  590. // ProfId5
  591. if ($langs->transcountry("ProfId5", $mysoc->country_id) != '-') {
  592. $var = !$var;
  593. print '<tr ' . $bc[$var] . '><td width="35%">' . $langs->transcountry("ProfId5", $mysoc->country_id) . '</td><td>';
  594. print $mysoc->idprof5;
  595. print '</td></tr>';
  596. }
  597. // ProfId6
  598. if ($langs->transcountry("ProfId6", $mysoc->country_id) != '-') {
  599. $var = !$var;
  600. print '<tr ' . $bc[$var] . '><td width="35%">' . $langs->transcountry("ProfId6", $mysoc->country_id) . '</td><td>';
  601. print $mysoc->idprof6;
  602. print '</td></tr>';
  603. }
  604. // TVA
  605. $var = !$var;
  606. print '<tr ' . $bc[$var] . '><td>' . $langs->trans("VATIntra") . '</td>';
  607. print '<td>';
  608. if (!empty($mysoc->tva_intra)) {
  609. $s = '';
  610. $s.=$mysoc->tva_intra;
  611. $s.='<input type="hidden" name="tva_intra" size="12" maxlength="20" value="' . $mysoc->tva_intra . '">';
  612. if (empty($conf->global->MAIN_DISABLEVATCHECK)) {
  613. $s.=' &nbsp; ';
  614. if (!empty($conf->use_javascript_ajax)) {
  615. print "\n";
  616. print '<script language="JavaScript" type="text/javascript">';
  617. print "function CheckVAT(a) {\n";
  618. print "newpopup('" . DOL_URL_ROOT . "/societe/checkvat/checkVatPopup.php?vatNumber='+a,'" . dol_escape_js($langs->trans("VATIntraCheckableOnEUSite")) . "',500,285);\n";
  619. print "}\n";
  620. print '</script>';
  621. print "\n";
  622. $s.='<a href="#" onClick="javascript: CheckVAT(document.formsoc.tva_intra.value);">' . $langs->trans("VATIntraCheck") . '</a>';
  623. $s = $form->textwithpicto($s, $langs->trans("VATIntraCheckDesc", $langs->trans("VATIntraCheck")), 1);
  624. } else {
  625. $s.='<a href="' . $langs->transcountry("VATIntraCheckURL", $mysoc->country_id) . '" target="_blank">' . img_picto($langs->trans("VATIntraCheckableOnEUSite"), 'help') . '</a>';
  626. }
  627. }
  628. print $s;
  629. } else {
  630. print '&nbsp;';
  631. }
  632. print '</td>';
  633. print '</tr>';
  634. print '</table>';
  635. print '</form>';
  636. /*
  637. * Debut d'annee fiscale
  638. */
  639. print '<br>';
  640. print '<table class="noborder" width="100%">';
  641. print '<tr class="liste_titre">';
  642. print '<td>' . $langs->trans("FiscalYearInformation") . '</td><td>' . $langs->trans("Value") . '</td>';
  643. print "</tr>\n";
  644. $var = true;
  645. $var = !$var;
  646. print '<tr ' . $bc[$var] . '><td width="35%">' . $langs->trans("FiscalMonthStart") . '</td><td>';
  647. $monthstart = $mysoc->fiscal_month_start;
  648. print dol_print_date(dol_mktime(12, 0, 0, $monthstart, 1, 2000, 1), '%B', 'gm') . '</td></tr>';
  649. print "</table>";
  650. /*
  651. * Options fiscale
  652. */
  653. print '<br>';
  654. print '<table class="noborder" width="100%">';
  655. print '<tr class="liste_titre">';
  656. print '<td>' . $langs->trans("VATManagement") . '</td><td>' . $langs->trans("Description") . '</td>';
  657. print '<td align="right">&nbsp;</td>';
  658. print "</tr>\n";
  659. $var = true;
  660. $var = !$var;
  661. print "<tr " . $bc[$var] . "><td width=\"140\"><label><input " . $bc[$var] . " type=\"radio\" name=\"optiontva\" disabled value=\"1\"" . ($mysoc->tva_assuj ? " checked" : "") . "> " . $langs->trans("VATIsUsed") . "</label></td>";
  662. print '<td colspan="2">';
  663. print "<table>";
  664. print "<tr><td>" . $langs->trans("VATIsUsedDesc") . "</td></tr>";
  665. print "<tr><td><i>" . $langs->trans("Example") . ': ' . $langs->trans("VATIsUsedExampleFR") . "</i></td></tr>\n";
  666. print "</table>";
  667. print "</td></tr>\n";
  668. $var = !$var;
  669. print "<tr " . $bc[$var] . "><td width=\"140\"><label><input " . $bc[$var] . " type=\"radio\" name=\"optiontva\" disabled value=\"0\"" . (!$mysoc->tva_assuj ? " checked" : "") . "> " . $langs->trans("VATIsNotUsed") . "</label></td>";
  670. print '<td colspan="2">';
  671. print "<table>";
  672. print "<tr><td>" . $langs->trans("VATIsNotUsedDesc") . "</td></tr>";
  673. print "<tr><td><i>" . $langs->trans("Example") . ': ' . $langs->trans("VATIsNotUsedExampleFR") . "</i></td></tr>\n";
  674. print "</table>";
  675. print "</td></tr>\n";
  676. print "</table>";
  677. /*
  678. * Local Taxes
  679. */
  680. if ($mysoc->country_id == 'ES') {
  681. // Local Tax 1
  682. print '<br>';
  683. print '<table class="noborder" width="100%">';
  684. print '<tr class="liste_titre">';
  685. print '<td>' . $langs->transcountry("LocalTax1Management", $mysoc->country_id) . '</td><td>' . $langs->trans("Description") . '</td>';
  686. print '<td align="right">&nbsp;</td>';
  687. print "</tr>\n";
  688. $var = true;
  689. $var = !$var;
  690. print "<tr " . $bc[$var] . "><td width=\"140\"><label><input " . $bc[$var] . " type=\"radio\" name=\"optionlocaltax1\" disabled value=\"localtax1on\"" . ($conf->global->FACTURE_LOCAL_TAX1_OPTION != "localtax1off" ? " checked" : "") . "> " . $langs->transcountry("LocalTax1IsUsed", $mysoc->country_code) . "</label></td>";
  691. print '<td colspan="2">';
  692. print "<table>";
  693. print "<tr><td>" . $langs->transcountry("LocalTax1IsUsedDesc", $mysoc->country_id) . "</td></tr>";
  694. print "<tr><td><i>" . $langs->trans("Example", $mysoc->country_id) . ': ' . $langs->transcountry("LocalTax1IsUsedExample", $mysoc->country_id) . "</i></td></tr>\n";
  695. print "</table>";
  696. print "</td></tr>\n";
  697. $var = !$var;
  698. print "<tr " . $bc[$var] . "><td width=\"140\"><label><input " . $bc[$var] . " type=\"radio\" name=\"optionlocaltax1\" disabled value=\"localtax1off\"" . ($conf->global->FACTURE_LOCAL_TAX1_OPTION == "localtax1off" ? " checked" : "") . "> " . $langs->transcountry("LocalTax1IsNotUsed", $mysoc->country_code) . "</label></td>";
  699. print '<td colspan="2">';
  700. print "<table>";
  701. print "<tr><td>" . $langs->transcountry("LocalTax1IsNotUsedDesc", $mysoc->country_id) . "</td></tr>";
  702. print "<tr><td><i>" . $langs->trans("Example", $mysoc->country_id) . ': ' . $langs->transcountry("LocalTax1IsNotUsedExample", $mysoc->country_id) . "</i></td></tr>\n";
  703. print "</table>";
  704. print "</td></tr>\n";
  705. print "</table>";
  706. // Local Tax 2
  707. print '<br>';
  708. print '<table class="noborder" width="100%">';
  709. print '<tr class="liste_titre">';
  710. print '<td>' . $langs->transcountry("LocalTax2Management", $mysoc->country_id) . '</td><td>' . $langs->trans("Description") . '</td>';
  711. print '<td align="right">&nbsp;</td>';
  712. print "</tr>\n";
  713. $var = true;
  714. $var = !$var;
  715. print "<tr " . $bc[$var] . "><td width=\"140\"><label><input " . $bc[$var] . " type=\"radio\" name=\"optionlocaltax2\" disabled value=\"localtax2on\"" . ($conf->global->FACTURE_LOCAL_TAX2_OPTION != "localtax2off" ? " checked" : "") . "> " . $langs->transcountry("LocalTax2IsUsed", $mysoc->country_code) . "</label></td>";
  716. print '<td colspan="2">';
  717. print "<table>";
  718. print "<tr><td>" . $langs->transcountry("LocalTax2IsUsedDesc", $mysoc->country_id) . "</td></tr>";
  719. print "<tr><td><i>" . $langs->trans("Example") . ': ' . $langs->transcountry("LocalTax2IsUsedExample", $mysoc->country_id) . "</i></td></tr>\n";
  720. print "</table>";
  721. print "</td></tr>\n";
  722. $var = !$var;
  723. print "<tr " . $bc[$var] . "><td width=\"140\"><label><input " . $bc[$var] . " type=\"radio\" name=\"optionlocaltax2\" disabled value=\"localtax2off\"" . ($conf->global->FACTURE_LOCAL_TAX2_OPTION == "localtax2off" ? " checked" : "") . "> " . $langs->transcountry("LocalTax2IsNotUsed", $mysoc->country_code) . "</label></td>";
  724. print '<td colspan="2">';
  725. print "<table>";
  726. print "<tr><td>" . $langs->transcountry("LocalTax2IsNotUsedDesc", $mysoc->country_id) . "</td></tr>";
  727. print "<tr><td><i>" . $langs->trans("Example") . ': ' . $langs->transcountry("LocalTax2IsNotUsedExample", $mysoc->country_id) . "</i></td></tr>\n";
  728. print "</table>";
  729. print "</td></tr>\n";
  730. print "</table>";
  731. }
  732. // Actions buttons
  733. print '<div class="tabsAction">';
  734. print '<a class="butAction" href="' . $_SERVER["PHP_SELF"] . '?action=edit">' . $langs->trans("Modify") . '</a>';
  735. print '</div>';
  736. }
  737. print end_box();
  738. print '</div></div>';
  739. llxFooter();
  740. ?>